|  |  | @ -4,14 +4,15 @@ | 
			
		
	
		
			
				
					|  |  |  |     <div class="setting-dialog"> | 
			
		
	
		
			
				
					|  |  |  |       <div class="bulk-import-item"> | 
			
		
	
		
			
				
					|  |  |  |         <h4 class="bulk-import-title1">下载模板</h4> | 
			
		
	
		
			
				
					|  |  |  |         <a class="template-name" href="/path/to/file.pdf" download><i class="iconfont icon-xiazai" />文书档案(案卷)</a> | 
			
		
	
		
			
				
					|  |  |  |         <!-- <a href="" download></a> --> | 
			
		
	
		
			
				
					|  |  |  |         <span class="template-name" @click="downloadTemplate"><i class="iconfont icon-xiazai" />{{ selectedCategory.cnName }}</span> | 
			
		
	
		
			
				
					|  |  |  |       </div> | 
			
		
	
		
			
				
					|  |  |  |       <div class="bulk-import-item"> | 
			
		
	
		
			
				
					|  |  |  |         <h4 class="bulk-import-title2">上传导入</h4> | 
			
		
	
		
			
				
					|  |  |  |         <el-form ref="form" :model="form" :rules="rules" label-width="110px"> | 
			
		
	
		
			
				
					|  |  |  |           <el-form-item label="上传Excel" prop="file"> | 
			
		
	
		
			
				
					|  |  |  |             <div class="input-import"> | 
			
		
	
		
			
				
					|  |  |  |               <input ref="excelInput" type="file" @change="handleFileExcel"> | 
			
		
	
		
			
				
					|  |  |  |               <input ref="excelInput" type="file" accept=".xlsx" @change="handleFileExcel"> | 
			
		
	
		
			
				
					|  |  |  |               <div class="upload-excel"><i class="iconfont icon-shangchuan2" />选择文件</div> | 
			
		
	
		
			
				
					|  |  |  |             </div> | 
			
		
	
		
			
				
					|  |  |  |             <div v-for="item in excelList" :key="item.name" class="file-list"> | 
			
		
	
	
		
			
				
					|  |  | @ -29,13 +30,13 @@ | 
			
		
	
		
			
				
					|  |  |  |               /> | 
			
		
	
		
			
				
					|  |  |  |             </el-select> | 
			
		
	
		
			
				
					|  |  |  |           </el-form-item> | 
			
		
	
		
			
				
					|  |  |  |           <el-form-item label="重复验证字段" prop="fields"> | 
			
		
	
		
			
				
					|  |  |  |             <el-select v-model="form.fields" multiple placeholder="请选择" style="width: 560px;"> | 
			
		
	
		
			
				
					|  |  |  |           <el-form-item label="重复验证字段" prop="replicated"> | 
			
		
	
		
			
				
					|  |  |  |             <el-select v-model="form.replicated" value-key="id" multiple placeholder="请选择" style="width: 560px;"> | 
			
		
	
		
			
				
					|  |  |  |               <el-option | 
			
		
	
		
			
				
					|  |  |  |                 v-for="item in fieldsOptions" | 
			
		
	
		
			
				
					|  |  |  |                 :key="item.value" | 
			
		
	
		
			
				
					|  |  |  |                 :label="item.label" | 
			
		
	
		
			
				
					|  |  |  |                 :value="item.value" | 
			
		
	
		
			
				
					|  |  |  |                 :key="item.id" | 
			
		
	
		
			
				
					|  |  |  |                 :label="item.fieldCnName" | 
			
		
	
		
			
				
					|  |  |  |                 :value="item.fieldName" | 
			
		
	
		
			
				
					|  |  |  |               /> | 
			
		
	
		
			
				
					|  |  |  |             </el-select> | 
			
		
	
		
			
				
					|  |  |  |           </el-form-item> | 
			
		
	
	
		
			
				
					|  |  | @ -54,10 +55,33 @@ | 
			
		
	
		
			
				
					|  |  |  | </template> | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | <script> | 
			
		
	
		
			
				
					|  |  |  | import qs from 'qs' | 
			
		
	
		
			
				
					|  |  |  | import { exportFile } from '@/utils/index' | 
			
		
	
		
			
				
					|  |  |  | import { mapGetters } from 'vuex' | 
			
		
	
		
			
				
					|  |  |  | import { FetchInitCategoryInputFieldByPid } from '@/api/system/category/category' | 
			
		
	
		
			
				
					|  |  |  | import { BatchImport } from '@/utils/upload' | 
			
		
	
		
			
				
					|  |  |  | export default { | 
			
		
	
		
			
				
					|  |  |  |   name: 'BulkImport', | 
			
		
	
		
			
				
					|  |  |  |   components: { }, | 
			
		
	
		
			
				
					|  |  |  |   mixins: [], | 
			
		
	
		
			
				
					|  |  |  |   props: { | 
			
		
	
		
			
				
					|  |  |  |     selectedCategory: { | 
			
		
	
		
			
				
					|  |  |  |       type: Object, | 
			
		
	
		
			
				
					|  |  |  |       default: function() { | 
			
		
	
		
			
				
					|  |  |  |         return {} | 
			
		
	
		
			
				
					|  |  |  |       } | 
			
		
	
		
			
				
					|  |  |  |     }, | 
			
		
	
		
			
				
					|  |  |  |     collectLevel: { | 
			
		
	
		
			
				
					|  |  |  |       type: Number, | 
			
		
	
		
			
				
					|  |  |  |       default: function() { | 
			
		
	
		
			
				
					|  |  |  |         return null | 
			
		
	
		
			
				
					|  |  |  |       } | 
			
		
	
		
			
				
					|  |  |  |     }, | 
			
		
	
		
			
				
					|  |  |  |     selections: { | 
			
		
	
		
			
				
					|  |  |  |       type: Array, | 
			
		
	
		
			
				
					|  |  |  |       default: () => [] | 
			
		
	
		
			
				
					|  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  |   }, | 
			
		
	
		
			
				
					|  |  |  |   data() { | 
			
		
	
		
			
				
					|  |  |  |     return { | 
			
		
	
		
			
				
					|  |  |  |       // 批量导入 | 
			
		
	
	
		
			
				
					|  |  | @ -69,9 +93,9 @@ export default { | 
			
		
	
		
			
				
					|  |  |  |         ] | 
			
		
	
		
			
				
					|  |  |  |       }, | 
			
		
	
		
			
				
					|  |  |  |       form: { | 
			
		
	
		
			
				
					|  |  |  |         file: '', | 
			
		
	
		
			
				
					|  |  |  |         type: '', | 
			
		
	
		
			
				
					|  |  |  |         fields: [] | 
			
		
	
		
			
				
					|  |  |  |         file: null, | 
			
		
	
		
			
				
					|  |  |  |         type: '追加', | 
			
		
	
		
			
				
					|  |  |  |         replicated: [] | 
			
		
	
		
			
				
					|  |  |  |       }, | 
			
		
	
		
			
				
					|  |  |  |       excelList: [], | 
			
		
	
		
			
				
					|  |  |  |       typeOptions: [ | 
			
		
	
	
		
			
				
					|  |  | @ -80,37 +104,77 @@ export default { | 
			
		
	
		
			
				
					|  |  |  |           label: '追加' | 
			
		
	
		
			
				
					|  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |       ], | 
			
		
	
		
			
				
					|  |  |  |       fieldsOptions: [ | 
			
		
	
		
			
				
					|  |  |  |         { | 
			
		
	
		
			
				
					|  |  |  |           value: '字段1', | 
			
		
	
		
			
				
					|  |  |  |           label: '字段1' | 
			
		
	
		
			
				
					|  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |       ] | 
			
		
	
		
			
				
					|  |  |  |       fieldsOptions: [], | 
			
		
	
		
			
				
					|  |  |  |       fileNames: '', // 附件 - name | 
			
		
	
		
			
				
					|  |  |  |       formatType: '', // 附件 - type | 
			
		
	
		
			
				
					|  |  |  |       postfix: '', // 附件 - 文件后缀 | 
			
		
	
		
			
				
					|  |  |  |       fileSize: '', // 附件 - 大小 | 
			
		
	
		
			
				
					|  |  |  |       filePath: '', // 附件 - path | 
			
		
	
		
			
				
					|  |  |  |       nowDate: '' // 当前时间 | 
			
		
	
		
			
				
					|  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  |   }, | 
			
		
	
		
			
				
					|  |  |  |   computed: { | 
			
		
	
		
			
				
					|  |  |  |     ...mapGetters([ | 
			
		
	
		
			
				
					|  |  |  |       'baseApi' | 
			
		
	
		
			
				
					|  |  |  |     ]) | 
			
		
	
		
			
				
					|  |  |  |   }, | 
			
		
	
		
			
				
					|  |  |  |   created() { | 
			
		
	
		
			
				
					|  |  |  |   }, | 
			
		
	
		
			
				
					|  |  |  |   mounted() { | 
			
		
	
		
			
				
					|  |  |  |     this.$nextTick(() => { | 
			
		
	
		
			
				
					|  |  |  |       this.getInitCategoryInputFieldByPid() | 
			
		
	
		
			
				
					|  |  |  |     }) | 
			
		
	
		
			
				
					|  |  |  |   }, | 
			
		
	
		
			
				
					|  |  |  |   methods: { | 
			
		
	
		
			
				
					|  |  |  |     getInitCategoryInputFieldByPid() { | 
			
		
	
		
			
				
					|  |  |  |       const params = { | 
			
		
	
		
			
				
					|  |  |  |         'categoryId': this.selectedCategory.id, | 
			
		
	
		
			
				
					|  |  |  |         'categoryLevel': this.collectLevel | 
			
		
	
		
			
				
					|  |  |  |       } | 
			
		
	
		
			
				
					|  |  |  |       FetchInitCategoryInputFieldByPid(params).then(data => { | 
			
		
	
		
			
				
					|  |  |  |         this.fieldsOptions = data | 
			
		
	
		
			
				
					|  |  |  |       }) | 
			
		
	
		
			
				
					|  |  |  |     }, | 
			
		
	
		
			
				
					|  |  |  |     downloadTemplate() { | 
			
		
	
		
			
				
					|  |  |  |       const params = { | 
			
		
	
		
			
				
					|  |  |  |         'categoryId': this.selectedCategory.id, | 
			
		
	
		
			
				
					|  |  |  |         'categoryLevel': this.collectLevel, | 
			
		
	
		
			
				
					|  |  |  |         'categoryName': this.selectedCategory.cnName | 
			
		
	
		
			
				
					|  |  |  |       } | 
			
		
	
		
			
				
					|  |  |  |       console.log(params) | 
			
		
	
		
			
				
					|  |  |  |       exportFile(this.baseApi + '/api/collect/exportTemplate?' + qs.stringify(params, { indices: false })) | 
			
		
	
		
			
				
					|  |  |  |     }, | 
			
		
	
		
			
				
					|  |  |  |     handleFileExcel(event) { | 
			
		
	
		
			
				
					|  |  |  |       const files = event.target.files | 
			
		
	
		
			
				
					|  |  |  |       const file = files[0] // 获取上传的文件 | 
			
		
	
		
			
				
					|  |  |  |       const allowedExtensions = /(\.xlsx)$/i // 定义允许上传的文件格式,这里只限制为xlsx格式 | 
			
		
	
		
			
				
					|  |  |  |       if (!allowedExtensions.exec(file.name)) { | 
			
		
	
		
			
				
					|  |  |  |         this.$message.warning('只能上传Excel文件!') // 弹出提示信息 | 
			
		
	
		
			
				
					|  |  |  |         event.target.value = '' // 清空文件输入框内容 | 
			
		
	
		
			
				
					|  |  |  |         return false | 
			
		
	
		
			
				
					|  |  |  |       } | 
			
		
	
		
			
				
					|  |  |  |       this.form.file = event.target.files[0] | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |       for (let i = 0; i < files.length; i++) { | 
			
		
	
		
			
				
					|  |  |  |         this.excelList = [] | 
			
		
	
		
			
				
					|  |  |  |         this.excelList.push(files[i]) | 
			
		
	
		
			
				
					|  |  |  |       } | 
			
		
	
		
			
				
					|  |  |  |     }, | 
			
		
	
		
			
				
					|  |  |  |     onSubmitImport(formName) { | 
			
		
	
		
			
				
					|  |  |  |       if (this.excelList.length === 0) { | 
			
		
	
		
			
				
					|  |  |  |         this.$message.error('请先上传Excel') | 
			
		
	
		
			
				
					|  |  |  |         return false | 
			
		
	
		
			
				
					|  |  |  |       } | 
			
		
	
		
			
				
					|  |  |  |       this.$refs[formName].validate((valid) => { | 
			
		
	
		
			
				
					|  |  |  |         if (valid) { | 
			
		
	
		
			
				
					|  |  |  |           this.$message('submit!') | 
			
		
	
		
			
				
					|  |  |  |           const params = { | 
			
		
	
		
			
				
					|  |  |  |             'categoryId': this.selectedCategory.id, | 
			
		
	
		
			
				
					|  |  |  |             'categoryLevel': this.collectLevel, | 
			
		
	
		
			
				
					|  |  |  |             'file': this.form.file, | 
			
		
	
		
			
				
					|  |  |  |             'replicated': this.form.replicated.join(',') | 
			
		
	
		
			
				
					|  |  |  |           } | 
			
		
	
		
			
				
					|  |  |  |           console.log(params) | 
			
		
	
		
			
				
					|  |  |  |           BatchImport(this.baseApi + '/api/collect/batchImport', params).then(res => { | 
			
		
	
		
			
				
					|  |  |  |             console.log(res) | 
			
		
	
		
			
				
					|  |  |  |             if (res.data.code !== 500) { | 
			
		
	
		
			
				
					|  |  |  |               this.$message.error('批量导入成功') | 
			
		
	
		
			
				
					|  |  |  |             } else { | 
			
		
	
		
			
				
					|  |  |  |               this.$message.error('批量导入失败') | 
			
		
	
		
			
				
					|  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |           }) | 
			
		
	
		
			
				
					|  |  |  |         } else { | 
			
		
	
		
			
				
					|  |  |  |           console.log('error submit!!') | 
			
		
	
		
			
				
					|  |  |  |           return false | 
			
		
	
	
		
			
				
					|  |  | @ -181,6 +245,7 @@ export default { | 
			
		
	
		
			
				
					|  |  |  |     font-size: 14px; | 
			
		
	
		
			
				
					|  |  |  |     line-height: 30px; | 
			
		
	
		
			
				
					|  |  |  |     color: #0348F3; | 
			
		
	
		
			
				
					|  |  |  |     cursor: pointer; | 
			
		
	
		
			
				
					|  |  |  |     i{ | 
			
		
	
		
			
				
					|  |  |  |       font-size: 12px; | 
			
		
	
		
			
				
					|  |  |  |     } | 
			
		
	
	
		
			
				
					|  |  | 
 |