| | |
| | | :close-on-click-modal="false" |
| | | > |
| | | <el-form :model="state.form" size="default" ref="superRef" :rules="state.formRules" label-width="150px" > |
| | | <el-form-item label="材料名称:" prop="templateName"> |
| | | <el-input v-model.trim="state.form.templateName" :disabled="state.title =='查看'" placeholder="材料名称"></el-input> |
| | | <el-form-item label="材料名称:" prop="name"> |
| | | <el-input v-model.trim="state.form.name" :disabled="state.title =='查看'" placeholder="材料名称"></el-input> |
| | | </el-form-item> |
| | | <el-form-item label="模板文件:" prop="filePath"> |
| | | <el-form-item label="材料模板:" prop="filePath"> |
| | | <el-upload accept=".doc,.docx" :action="state.uploadUrl" :headers="state.header" method="post" :on-success="(res, uploadFile)=>handleAvatarSuccess(res, uploadFile)" :on-exceed="showTip" :limit='state.fileLimit' v-model:file-list="state.fileList" :before-upload="picSize" :on-remove="(file, uploadFiles)=>handleRemove(file, uploadFiles)" > |
| | | <el-button type="primary">点击上传</el-button> |
| | | <template #tip> |
| | |
| | | import {addIndustryTemp, updateIndustryTemp, updateInfoPlatforms} from "@/api/staffManage/staff"; |
| | | import {getToken} from "@/utils/auth"; |
| | | import {delPic} from "@/api/onlineEducation/banner"; |
| | | import {addFile, editFile} from "@/api/qualityManage/range"; |
| | | |
| | | const emit = defineEmits(["getList"]); |
| | | const dialogVisible = ref(false) |
| | |
| | | title: '', |
| | | form: { |
| | | id: null, |
| | | templateName: '', |
| | | name: '', |
| | | filePath: '', |
| | | format: '', |
| | | companyId: null |
| | | fileName: '', |
| | | companyId: null, |
| | | catalogueId: null, |
| | | type:null |
| | | }, |
| | | formRules:{ |
| | | templateName: [{ required: true, message: '请输入材料名称', trigger: 'blur' }], |
| | | name: [{ required: true, message: '请输入材料名称', trigger: 'blur' }], |
| | | }, |
| | | isAdmin: false, |
| | | companyList: [], |
| | |
| | | |
| | | }); |
| | | |
| | | const openDialog = async (type, value,companyId, isAdmin, companyList) => { |
| | | state.isAdmin = isAdmin |
| | | if(isAdmin){ |
| | | state.companyList = companyList |
| | | } |
| | | const openDialog = async (type, value,companyId,catalogueId) => { |
| | | state.title = type === 'add' ? '新增' : type ==='edit' ? '编辑' : '查看' |
| | | state.form.companyId = companyId |
| | | state.form.catalogueId = catalogueId |
| | | state.form.type = 1 |
| | | if(state.title == '编辑'||state.title == '查看'){ |
| | | Object.keys(state.form).forEach(key => { |
| | | if (key in value) { |
| | |
| | | if(value.filePath) { |
| | | const obj = { |
| | | url: value.filePath, |
| | | name: '模板文件' |
| | | name: value.fileName |
| | | } |
| | | state.fileList = [obj] |
| | | } |
| | |
| | | dialogVisible.value = true |
| | | } |
| | | |
| | | |
| | | const onSubmit = async () => { |
| | | const valid = await superRef.value.validate(); |
| | | if(valid){ |
| | | if(state.title == '新增'){ |
| | | const {id,...data} = state.form |
| | | const res = await addIndustryTemp(data) |
| | | const res = await addFile(data) |
| | | if(res.code == 200){ |
| | | ElMessage.success(res.message) |
| | | emit('getList') |
| | |
| | | ElMessage.warning(res.message) |
| | | } |
| | | }else{ |
| | | const res = await updateIndustryTemp(state.form) |
| | | |
| | | const res = await editFile(state.form) |
| | | if(res.code == 200){ |
| | | ElMessage.success(res.message) |
| | | emit('getList') |
| | |
| | | |
| | | const handleAvatarSuccess = (res, uploadFile) => { |
| | | if(res.code == 200){ |
| | | state.form.fileName = res.data.originName |
| | | state.form.filePath = res.data.path |
| | | state.form.format = '.' + res.data.filename.split('.')[1] |
| | | }else{ |
| | | state.fileList = [] |
| | | ElMessage({ |
| | |
| | | // type: 'success', |
| | | // message: '文件已删除' |
| | | // }) |
| | | state.form.fileName = '' |
| | | state.form.filePath = '' |
| | | state.form.format = '' |
| | | }else{ |
| | | ElMessage({ |
| | | type: 'warning', |
| | |
| | | }) |
| | | } |
| | | }).catch(() => { |
| | | state.form.imgUrl = '' |
| | | state.form.fileName = '' |
| | | state.form.filePath = '' |
| | | }); |
| | | } |
| | | |
| | | const handleClose = () => { |
| | | state.form = { |
| | | id: null, |
| | | templateName: '', |
| | | industryType: '', |
| | | name: '', |
| | | filePath: '', |
| | | format: '', |
| | | companyId: null |
| | | fileName: '', |
| | | companyId: null, |
| | | catalogueId: null, |
| | | type:null |
| | | } |
| | | state.fileList = [] |
| | | superRef.value.clearValidate(); |
| | | superRef.value.resetFields() |
| | | dialogVisible.value = false; |