zhouwx
4 天以前 592c1750b148874737cdfba4b22b6229f9805fe6
src/views/build/conpanyFunctionConsult/qualityManage/rangeManage/range/components/recordDialog.vue
@@ -9,10 +9,10 @@
        :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>
@@ -39,6 +39,7 @@
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)
@@ -47,13 +48,15 @@
  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: [],
@@ -69,13 +72,11 @@
});
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 = 2
  if(state.title == '编辑'||state.title == '查看'){
    Object.keys(state.form).forEach(key => {
      if (key in value) {
@@ -85,7 +86,7 @@
    if(value.filePath) {
      const obj = {
        url: value.filePath,
        name: '模板文件'
        name: value.fileName
      }
      state.fileList = [obj]
    }
@@ -93,13 +94,12 @@
  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')
@@ -109,7 +109,8 @@
        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')
@@ -124,8 +125,8 @@
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({
@@ -158,8 +159,8 @@
      //   type: 'success',
      //   message: '文件已删除'
      // })
      state.form.fileName = ''
      state.form.filePath = ''
      state.form.format = ''
    }else{
      ElMessage({
        type: 'warning',
@@ -167,19 +168,22 @@
      })
    }
  }).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;