| | |
| | | :close-on-click-modal="false" |
| | | width="60%" |
| | | center |
| | | :show-close="false" |
| | | @close="resetForm('workForm')" |
| | | > |
| | | <el-upload |
| | | class="upload-demo" |
| | | action |
| | | :http-request="uploadFile" |
| | | :on-preview="handlePreview" |
| | | :on-remove="handleRemove" |
| | | :before-upload="beforeUpload" |
| | | :before-remove="beforeRemove" |
| | | multiple |
| | | :limit="1" |
| | | :on-exceed="handleExceed" |
| | | accept=".pdf, .doc, .docx" |
| | | :file-list="fileList"> |
| | | <div style="display: flex;align-items: center"> |
| | | <el-button type="primary" style="margin-right: 80px">检查内容上传</el-button> |
| | | <div slot="tip" class="el-upload__tip">只能上传doc/docx文件</div> |
| | | </div> |
| | | </el-upload> |
| | | <el-form :model="workForm" :rules="rules" ref="workForm" label-width="80px"> |
| | | <el-form-item label="专项检查任务名称:" label-width="180px" prop="taskName"> |
| | | <el-input v-model="workForm.taskName"></el-input> |
| | |
| | | </el-row> |
| | | </div> |
| | | <div class="form-part"> |
| | | <h3>市州级检查指标</h3> |
| | | <h3>地(州、市)级检查指标</h3> |
| | | <!-- <p>批发企业:</p>--> |
| | | <el-divider content-position="left">批发企业</el-divider> |
| | | <el-row> |
| | |
| | | </el-form-item> |
| | | </el-form> |
| | | <span slot="footer" class="dialog-footer"> |
| | | <el-button type="warning" @click="cancleSend" plain>取消</el-button> |
| | | <el-button @click="resetForm('workForm')">重置</el-button> |
| | | <el-button type="primary" v-stop-re-click @click="confirmSend('workForm')">确认下发</el-button> |
| | | </span> |
| | |
| | | |
| | | <script> |
| | | import {computePageCount} from "@/utils"; |
| | | import{sendCheckTask} from "@/api/specialCheck" |
| | | import{sendCheckTask, uploadFile, delateFile} from "@/api/specialCheck" |
| | | export default { |
| | | name: "sendWork", |
| | | data(){ |
| | | return{ |
| | | dialogVisible:false, |
| | | fileList: [], |
| | | fileType: ['pdf','doc','docx'], |
| | | workForm: { |
| | | taskName: '', |
| | | provinceWholesaleCheckTarget: null, |
| | |
| | | areaWholesaleCheckDeadline: '', |
| | | areaRetailCheckTarget: null, |
| | | areaRetailCheckDeadline: '', |
| | | enterpriseSelfCheckDeadline: '' |
| | | enterpriseSelfCheckDeadline: '', |
| | | taskDescFileName: null |
| | | }, |
| | | rules: { |
| | | taskName: [{ required: true, message: '请输入任务名称', trigger: 'blur' }], |
| | |
| | | watch: { |
| | | }, |
| | | methods:{ |
| | | //上传文件的事件 |
| | | async uploadFile(item){ |
| | | const t = this |
| | | const loading = this.$loading({ |
| | | lock: true, |
| | | text: '正在上传文件...', |
| | | spinner: 'el-icon-loading' |
| | | }); |
| | | //上传文件的需要formdata类型;所以要转 |
| | | let FormDatas = new FormData() |
| | | FormDatas.append('taskDescFile',item.file); |
| | | const res = await uploadFile(FormDatas) |
| | | if(res.data.code == '200'){ |
| | | loading.close(); |
| | | t.$message({ |
| | | type:'success', |
| | | message: '上传成功' |
| | | }) |
| | | t.fileList.push(item.file) |
| | | console.log(t.fileList,'fileList') |
| | | t.workForm.taskDescFileName = res.data.result |
| | | }else{ |
| | | loading.close(); |
| | | t.$message({ |
| | | type:'warning', |
| | | message:res.data.message |
| | | }) |
| | | } |
| | | // axios({ |
| | | // method: 'post', |
| | | // url: 'http://192.168.0.29:8100/checkTask/upload/taskDescFile', |
| | | // headers:this.headers, |
| | | // timeout: 30000, |
| | | // data: FormDatas |
| | | // }).then(res=>{ |
| | | // if(res.data.id != '' || res.data.id != null){ |
| | | // this.fileList.push(item.file);//成功过后手动将文件添加到展示列表里 |
| | | // let i = this.fileList.indexOf(item.file) |
| | | // this.fileList[i].id = res.data.id;//id也添加进去,最后整个大表单提交的时候需要的 |
| | | // if(this.fileList.length > 0){//如果上传了附件就把校验规则给干掉 |
| | | // this.fileflag = false; |
| | | // this.$set(this.rules.url,0,'') |
| | | // } |
| | | // //this.handleSuccess(); |
| | | // } |
| | | // }) |
| | | }, |
| | | //上传文件之前 |
| | | beforeUpload(file){ |
| | | // const t = this |
| | | // if (file.type != "" || file.type != null || file.type != undefined){ |
| | | // //截取文件的后缀,判断文件类型 |
| | | // console.log(t.fileType,file.name,'666') |
| | | // const FileExt = file.name.replace(/.+\./, "").toLowerCase(); |
| | | // // //计算文件的大小 |
| | | // // const isLt5M = file.size / 1024 / 1024 < 50; //这里做文件大小限制 |
| | | // // //如果大于50M |
| | | // // if (!isLt5M) { |
| | | // // this.$showMessage('上传文件大小不能超过 50MB!'); |
| | | // // return false; |
| | | // // } |
| | | // //如果文件类型不在允许上传的范围内 |
| | | // if(t.fileType.indexOf(FileExt) !== -1){ |
| | | // return true; |
| | | // } |
| | | // else { |
| | | // t.$message.error("上传文件格式不正确!"); |
| | | // return false; |
| | | // } |
| | | // } |
| | | }, |
| | | async handleRemove(file, fileList) { |
| | | const t = this |
| | | const res = await delateFile({taskDescFileName: t.workForm.taskDescFileName}) |
| | | if(res.data.code == '200'){ |
| | | t.$message({ |
| | | type:'success', |
| | | message: '删除成功' |
| | | }) |
| | | t.fileList = [] |
| | | }else{ |
| | | t.$message({ |
| | | type:'warning', |
| | | message:res.data.message |
| | | }) |
| | | } |
| | | }, |
| | | handlePreview(file) { |
| | | console.log(file); |
| | | }, |
| | | handleExceed(files, fileList) { |
| | | this.$message.warning(`当前限制选择 1 个文件,本次选择了 ${files.length} 个文件,共选择了 ${files.length + fileList.length} 个文件`); |
| | | }, |
| | | beforeRemove(file, fileList) { |
| | | return this.$confirm(`确定移除 ${ file.name }?`); |
| | | }, |
| | | confirmSend(formName){ |
| | | const t = this |
| | | t.$refs[formName].validate((valid) => { |
| | |
| | | }).then(async () => { |
| | | const loading = this.$loading({ |
| | | lock: true, |
| | | text: '正在下发', |
| | | text: '正在下发...', |
| | | spinner: 'el-icon-loading' |
| | | }); |
| | | let res = await sendCheckTask(t.workForm) |
| | | if(res.data.code === "200"){ |
| | | loading.close(); |
| | | t.$message({ |
| | | type:'success', |
| | | message: '任务下发成功' |
| | | }) |
| | | }else{ |
| | | loading.close(); |
| | | t.$message({ |
| | | type:'warning', |
| | | message:res.data.message |
| | | }) |
| | | } |
| | | loading.close(); |
| | | t.fileList = [] |
| | | t.dialogVisible = false |
| | | t.$parent.getSpecialCheckTask(); |
| | | }).catch(() => { |
| | |
| | | } |
| | | }); |
| | | }, |
| | | resetForm(formName) { |
| | | this.$refs[formName].resetFields(); |
| | | cancleSend(){ |
| | | this.resetForm('workForm') |
| | | this.dialogVisible = false |
| | | }, |
| | | async resetForm(formName) { |
| | | const t = this |
| | | if(t.workForm.taskDescFileName !== null){ |
| | | const res = await delateFile({taskDescFileName: t.workForm.taskDescFileName}) |
| | | if(res.data.code == '200'){ |
| | | t.$message({ |
| | | type:'success', |
| | | message: '已取消下发' |
| | | }) |
| | | }else{ |
| | | t.$message({ |
| | | type:'warning', |
| | | message:res.data.message |
| | | }) |
| | | } |
| | | } |
| | | t.$refs[formName].resetFields() |
| | | t.fileList = [] |
| | | } |
| | | }, |
| | | } |
| | |
| | | background-color: #fafafa; |
| | | color: #034EA2; |
| | | } |
| | | .upload-demo{ |
| | | margin-bottom: 20px; |
| | | background: #fafafa; |
| | | padding: 20px 15px; |
| | | border-radius: 8px; |
| | | |
| | | .el-upload__tip{ |
| | | font-size: 14px; |
| | | color: #999; |
| | | } |
| | | |
| | | .el-upload-list{ |
| | | background-color: #ccc !important; |
| | | } |
| | | } |
| | | .form-part{ |
| | | background: #fafafa; |
| | | padding: 10px 15px; |