|
@@ -0,0 +1,319 @@
|
|
|
|
+<template>
|
|
|
|
+ <div>
|
|
|
|
+ <el-dialog :visible.sync="show" :close-on-click-modal="false" :modal-append-to-body="false" @close="cancelHandle"
|
|
|
|
+ custom-class="knowledge-import-dialog" top="10vh" v-dialogDrag title="事件信息" width="1200px">
|
|
|
|
+ <div class="more-set-btn">
|
|
|
|
+ <el-button type="primary" @click="setMore">批量设置</el-button>
|
|
|
|
+ </div>
|
|
|
|
+ <el-form class="more-set-form" ref="formRef" hide-required-asterisk :model="eventForm" :rules="formRules"
|
|
|
|
+ label-width="0">
|
|
|
|
+ <el-table :data="eventForm.tableData" ref="table" element-loading-text="加载中..." v-loading="tableLoading" border
|
|
|
|
+ style="width: 100%;" max-height="400">
|
|
|
|
+ <el-table-column label="标题" align="center">
|
|
|
|
+ <template slot-scope="scope">
|
|
|
|
+ <el-form-item :prop="'tableData.' + scope.$index + '.title'" :rules="formRules.title">
|
|
|
|
+ <el-input v-model="scope.row.title" placeholder="请输入标题" style="width:100%" />
|
|
|
|
+ </el-form-item>
|
|
|
|
+ </template>
|
|
|
|
+ </el-table-column>
|
|
|
|
+ <el-table-column label="分类" align="center">
|
|
|
|
+ <template slot-scope="scope">
|
|
|
|
+ <el-form-item :prop="'tableData.' + scope.$index + '.classifyId'" :rules="formRules.classifyId">
|
|
|
|
+ <el-cascader :options="classifyOptions" v-model="scope.row.classifyId" :props="{
|
|
|
|
+ value: 'ClassifyId',
|
|
|
|
+ label: 'ClassifyName',
|
|
|
|
+ children: 'Child',
|
|
|
|
+ emitPath: false
|
|
|
|
+ }" clearable placeholder="请选择分类" style="width:100%"></el-cascader>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ </template>
|
|
|
|
+ </el-table-column>
|
|
|
|
+ <el-table-column label="来源" align="center">
|
|
|
|
+ <template slot-scope="scope">
|
|
|
|
+ <el-form-item :prop="'tableData.' + scope.$index + '.source'" :rules="formRules.source">
|
|
|
|
+ <el-input v-model="scope.row.source" placeholder="请输入来源" style="width:100%" clearable />
|
|
|
|
+ </el-form-item>
|
|
|
|
+ </template>
|
|
|
|
+ </el-table-column>
|
|
|
|
+ <el-table-column label="标签" align="center">
|
|
|
|
+ <template slot-scope="scope">
|
|
|
|
+ <el-form-item :prop="'tableData.' + scope.$index + '.tagId'" :rules="formRules.tagId">
|
|
|
|
+ <el-select v-model="scope.row.tagId" placeholder="请选择标签" size="medium" clearable style="width:100%">
|
|
|
|
+ <el-option v-for="item in tagsOptions" :key="item.TagId" :label="item.TagName" :value="item.TagId" />
|
|
|
|
+ </el-select>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ </template>
|
|
|
|
+ </el-table-column>
|
|
|
|
+ <el-table-column label="开始时间" align="center">
|
|
|
|
+ <template slot-scope="scope">
|
|
|
|
+ <el-form-item :prop="'tableData.' + scope.$index + '.startTime'" :rules="formRules.startTime">
|
|
|
|
+ <el-date-picker v-model="scope.row.startTime" :value-format="formatTime" :format="formatTime"
|
|
|
|
+ :type="[2, 3].includes(ResourceType) ? 'date' : 'datetime'" placeholder="请选择开始时间"
|
|
|
|
+ style="width:100%" />
|
|
|
|
+ </el-form-item>
|
|
|
|
+ </template>
|
|
|
|
+ </el-table-column>
|
|
|
|
+ <el-table-column v-if="![2, 3].includes(ResourceType)" label="结束时间" align="center">
|
|
|
|
+ <template slot-scope="scope">
|
|
|
|
+ <el-form-item :prop="'tableData.' + scope.$index + '.endTime'" :rules="formRules.endTime">
|
|
|
|
+ <el-date-picker v-model="scope.row.endTime" :value-format="formatTime" :format="formatTime"
|
|
|
|
+ :type="[2, 3].includes(ResourceType) ? 'date' : 'datetime'" placeholder="请选择结束时间"
|
|
|
|
+ style="width:100%" />
|
|
|
|
+ </el-form-item>
|
|
|
|
+ </template>
|
|
|
|
+ </el-table-column>
|
|
|
|
+ <el-table-column label="操作" width="80" align="center">
|
|
|
|
+ <template slot-scope="scope">
|
|
|
|
+ <el-button type="text" style="color: #F56C6C;" size="small"
|
|
|
|
+ @click="deleteRow(scope.$index)">删除</el-button>
|
|
|
|
+ </template>
|
|
|
|
+ </el-table-column>
|
|
|
|
+ <div slot="empty" style="padding: 20px 0">
|
|
|
|
+ <tableNoData :text="$t('Table.prompt_slogan')" size="mini" />
|
|
|
|
+ </div>
|
|
|
|
+ </el-table>
|
|
|
|
+ </el-form>
|
|
|
|
+ <div class="btn-bottom">
|
|
|
|
+ <el-button type="primary" plain @click="cancelHandle">取消</el-button>
|
|
|
|
+ <el-button type="primary" @click="handleConfirmEvent">批量导入</el-button>
|
|
|
|
+ </div>
|
|
|
|
+ </el-dialog>
|
|
|
|
+ <el-dialog :visible.sync="showSet" :close-on-click-modal="false" :modal-append-to-body="false" @close="cancelSet"
|
|
|
|
+ custom-class="knowledge-import-dialog" top="10vh" v-dialogDrag title="批量设置" width="556px">
|
|
|
|
+ <el-form ref="setRef" hide-required-asterisk :model="setForm" :rules="formRules" label-width="100px">
|
|
|
|
+ <el-form-item prop="classifyId" label="分类">
|
|
|
|
+ <el-cascader :options="classifyOptions" v-model="setForm.classifyId" :props="{
|
|
|
|
+ value: 'ClassifyId',
|
|
|
|
+ label: 'ClassifyName',
|
|
|
|
+ children: 'Child',
|
|
|
|
+ emitPath: false
|
|
|
|
+ }" clearable placeholder="请选择分类" style="width:80%"></el-cascader>
|
|
|
|
+ </el-form-item>
|
|
|
|
+
|
|
|
|
+ <el-form-item prop="source" label="来源">
|
|
|
|
+ <el-input v-model="setForm.source" placeholder="请输入来源" style="width:80%" clearable />
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <el-form-item prop="tagId" label="标签">
|
|
|
|
+ <el-select v-model="setForm.tagId" placeholder="请选择标签" size="medium" clearable style="width:80%">
|
|
|
|
+ <el-option v-for="item in tagsOptions" :key="item.TagId" :label="item.TagName" :value="item.TagId" />
|
|
|
|
+ </el-select>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <el-form-item prop="startTime" label="开始时间">
|
|
|
|
+ <el-date-picker v-model="setForm.startTime" :value-format="formatTime" :format="formatTime"
|
|
|
|
+ :type="[2, 3].includes(ResourceType) ? 'date' : 'datetime'" placeholder="请选择开始时间" style="width:80%" />
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <el-form-item prop="endTime" v-if="![2, 3].includes(ResourceType)" label="结束时间">
|
|
|
|
+ <el-date-picker v-model="setForm.endTime" :value-format="formatTime" :format="formatTime"
|
|
|
|
+ :type="[2, 3].includes(ResourceType) ? 'date' : 'datetime'" placeholder="请选择结束时间" style="width:80%" />
|
|
|
|
+ </el-form-item>
|
|
|
|
+ </el-form>
|
|
|
|
+ <div class="btn-bottom">
|
|
|
|
+ <el-button type="primary" plain @click="cancelSet">取消</el-button>
|
|
|
|
+ <el-button type="primary" @click="handleConfirmSet">确定</el-button>
|
|
|
|
+ </div>
|
|
|
|
+ </el-dialog>
|
|
|
|
+ </div>
|
|
|
|
+</template>
|
|
|
|
+<script>
|
|
|
|
+import { eventInterface } from '@/api/modules/knowledge';
|
|
|
|
+export default {
|
|
|
|
+ props: {
|
|
|
|
+ show: {
|
|
|
|
+ type: Boolean
|
|
|
|
+ },
|
|
|
|
+ ResourceType: {
|
|
|
|
+ type: Number
|
|
|
|
+ },
|
|
|
|
+ fileList: {
|
|
|
|
+ type: Array,
|
|
|
|
+ default: () => []
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ computed: {
|
|
|
|
+ formatTime() {
|
|
|
|
+ return [2, 3].includes(this.ResourceType) ? 'yyyy-MM-dd' : 'yyyy-MM-dd HH:mm:ss'
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ watch: {
|
|
|
|
+ show(nval) {
|
|
|
|
+ if (!nval) return
|
|
|
|
+ this.eventForm.tableData = this.fileList
|
|
|
|
+ this.getClassifyList();
|
|
|
|
+ this.getTagsList();
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ data() {
|
|
|
|
+ return {
|
|
|
|
+ showSet: false,
|
|
|
|
+ setForm: {
|
|
|
|
+ classifyId: '',
|
|
|
|
+ source: '',
|
|
|
|
+ tagId: '',
|
|
|
|
+ startTime: '',
|
|
|
|
+ endTime: ''
|
|
|
|
+ },
|
|
|
|
+ eventForm: {
|
|
|
|
+ tableData: []
|
|
|
|
+ },
|
|
|
|
+ formRules: {
|
|
|
|
+ title: [
|
|
|
|
+ { required: true, message: '标题不能为空', trigger: 'blur' },
|
|
|
|
+ ],
|
|
|
|
+ classifyId: [
|
|
|
|
+ { required: true, message: '分类不能为空', trigger: 'blur' },
|
|
|
|
+ ],
|
|
|
|
+ source: [
|
|
|
|
+ { required: true, message: '来源不能为空', trigger: 'blur' },
|
|
|
|
+ ],
|
|
|
|
+ startTime: [
|
|
|
|
+ { required: true, message: '开始时间不能为空', trigger: 'blur' },
|
|
|
|
+ ],
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ classifyOptions: [],
|
|
|
|
+ sourcesOptions: [],
|
|
|
|
+ tagsOptions: [],
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ mounted() {
|
|
|
|
+
|
|
|
|
+ },
|
|
|
|
+ methods: {
|
|
|
|
+ // 删除
|
|
|
|
+ deleteRow(index) {
|
|
|
|
+ if (this.eventForm.tableData.length < 2) {
|
|
|
|
+ this.$message.warning('当前仅剩一条文件信息时不可删除!')
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ this.eventForm.tableData.splice(index, 1)
|
|
|
|
+ },
|
|
|
|
+ // 批量设置
|
|
|
|
+ setMore() {
|
|
|
|
+ this.showSet = true
|
|
|
|
+ },
|
|
|
|
+ async getClassifyList() {
|
|
|
|
+ const res = await eventInterface.getClassify({
|
|
|
|
+ ResourceType: this.ResourceType
|
|
|
|
+ })
|
|
|
|
+ if (res.Ret !== 200) return
|
|
|
|
+
|
|
|
|
+ this.classifyOptions = res.Data.List || []
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ async getSourceList() {
|
|
|
|
+ const res = await eventInterface.getSourcesList({
|
|
|
|
+ ResourceType: this.ResourceType
|
|
|
|
+ })
|
|
|
|
+ if (res.Ret !== 200) return
|
|
|
|
+
|
|
|
|
+ this.sourcesOptions = res.Data.List || []
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ async getTagsList() {
|
|
|
|
+ const res = await eventInterface.getTagList({ ResourceType: this.ResourceType })
|
|
|
|
+ if (res.Ret !== 200) return
|
|
|
|
+
|
|
|
|
+ this.tagsOptions = res.Data.List || []
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ async handleConfirmSet() {
|
|
|
|
+ await this.$refs.setRef.validate()
|
|
|
|
+ this.eventForm.tableData.forEach((el, index) => {
|
|
|
|
+ const arr = ['classifyId', 'source', 'tagId', 'startTime', 'endTime']
|
|
|
|
+ arr.forEach(item => {
|
|
|
|
+ this.$set(this.eventForm.tableData[index], item, this.setForm[item])
|
|
|
|
+ })
|
|
|
|
+ })
|
|
|
|
+ this.cancelSet()
|
|
|
|
+ },
|
|
|
|
+ async handleConfirmEvent() {
|
|
|
|
+ this.$refs.formRef.validate((valid) => {
|
|
|
|
+ if (valid) {
|
|
|
|
+ let downloadHint = this.$message({
|
|
|
|
+ type: "info",
|
|
|
|
+ message: '上传中,请稍后······',
|
|
|
|
+ duration: 0,
|
|
|
|
+ iconClass: 'el-icon-loading'
|
|
|
|
+ })
|
|
|
|
+ let tableData = this.eventForm.tableData
|
|
|
|
+ let objPromises = tableData.map(async el => {
|
|
|
|
+ let formData = new FormData()
|
|
|
|
+ formData.append('File', el.file)
|
|
|
|
+ formData.append('ResourceType', this.ResourceType)
|
|
|
|
+ return eventInterface.fileImportUpload(formData).then(res => Promise.resolve(res)).catch(err => Promise.reject(err))
|
|
|
|
+ })
|
|
|
|
+ Promise.all(objPromises).then(async res => {
|
|
|
|
+ console.log(res)
|
|
|
|
+ let postArr = []
|
|
|
|
+ tableData.forEach((el, index) => {
|
|
|
|
+ postArr.push({
|
|
|
|
+ ResourceType: this.ResourceType,
|
|
|
|
+ ClassifyId: el.classifyId,
|
|
|
|
+ Title: el.title,
|
|
|
|
+ Content: '',
|
|
|
|
+ SourceFrom: el.source,
|
|
|
|
+ TagId: el.tagId || 0,
|
|
|
|
+ StartTime: el.startTime,
|
|
|
|
+ EndTime: el.endTime || '',
|
|
|
|
+ FileUrl: res[index].Data.FileUrl
|
|
|
|
+ })
|
|
|
|
+ })
|
|
|
|
+ downloadHint.close()
|
|
|
|
+ const resAdd = await eventInterface.addEvent(postArr)
|
|
|
|
+
|
|
|
|
+ if (resAdd.Ret !== 200) return
|
|
|
|
+
|
|
|
|
+ this.$message.success('添加成功')
|
|
|
|
+
|
|
|
|
+ this.$emit('confirm')
|
|
|
|
+ this.cancelHandle()
|
|
|
|
+ }).catch(err => Promise.reject(err))
|
|
|
|
+ } else {
|
|
|
|
+ this.$message.warning(' 还未填写文件信息!')
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ },
|
|
|
|
+ cancelSet() {
|
|
|
|
+ this.$refs.setRef.resetFields()
|
|
|
|
+ this.showSet = false
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ cancelHandle() {
|
|
|
|
+ this.$refs.formRef.resetFields()
|
|
|
|
+ this.$emit('update:show', false)
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+}
|
|
|
|
+</script>
|
|
|
|
+<style scoped lang='scss'>
|
|
|
|
+.el-form {
|
|
|
|
+ padding: 0 40px;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+.btn-bottom {
|
|
|
|
+ display: flex;
|
|
|
|
+ justify-content: center;
|
|
|
|
+ margin: 30px 0;
|
|
|
|
+
|
|
|
|
+ .el-button {
|
|
|
|
+ width: 130px;
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+.more-set-form {
|
|
|
|
+ .el-form-item {
|
|
|
|
+ margin-bottom: 0;
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+.more-set-btn {
|
|
|
|
+ display: flex;
|
|
|
|
+ justify-content: flex-end;
|
|
|
|
+ padding: 0 40px;
|
|
|
|
+ margin-bottom: 24px;
|
|
|
|
+}
|
|
|
|
+</style>
|