zhouwx
2025-11-20 a390dbc5239ac26f093c6670c12cfd6a49ca6037
src/views/build/conpanyFunctionConsult/standardSysTemp/appStandardModule/components/editDialog.vue
@@ -9,10 +9,23 @@
        :close-on-click-modal="false"
    >
      <el-form :model="state.form" size="default" ref="superRef" :rules="state.formRules" label-width="150px" >
        <el-form-item v-if="state.isAdmin" label="企业:" prop="companyId">
        <el-form-item v-if="state.isAdmin" label="单位:" prop="companyId">
          <el-select v-model="state.form.companyId" placeholder="请选择" clearable>
            <el-option
                v-for="item in state.companyList"
                :key="item.id"
                :label="item.name"
                :value="item.id">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="阶段:" prop="stage">
          <el-input v-model.trim="state.form.stage" :disabled="state.title =='查看'" placeholder="阶段"></el-input>
        </el-form-item>
        <el-form-item label="行业:" prop="industryTypeId">
          <el-select v-model="state.form.industryTypeId" placeholder="请选择" clearable style="width: 100%">
            <el-option
                v-for="item in state.industryList"
                :key="item.id"
                :label="item.name"
                :value="item.id">
@@ -26,7 +39,7 @@
          <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>
              <div class="el-upload__tip">支持上传.doc、.docx格式文档,尺寸小于5M,最多可上传1张</div>
              <div class="el-upload__tip">支持上传.doc、.docx格式文档,尺寸小于30M,最多可上传1份</div>
            </template>
          </el-upload>
        </el-form-item>
@@ -50,6 +63,7 @@
import {getToken} from "@/utils/auth";
import {delPic} from "@/api/onlineEducation/banner";
import {saveStandardTemp, updateStandardTemp} from "@/api/standardSys/standardSys";
import {getIndustry} from "@/api/system/industry";
const emit = defineEmits(["getList"]);
const dialogVisible = ref(false)
@@ -68,16 +82,21 @@
    templateName: '',
    filePath: '',
    format: '',
    stage:'',
    industryTypeId:'',
    companyId: null,
    templateType: 3
  },
  formRules:{
    companyId: [{ required: true, message: '请选择企业', trigger: 'blur' }],
    templateName: [{ required: true, message: '请输入模板名称', trigger: 'blur' }],
    filePath: [{ required: true, validator: checkFiles, trigger: 'blur' }]
    filePath: [{ required: true, validator: checkFiles, trigger: 'blur' }],
    stage: [{ required: true, message: '请输入阶段', trigger: 'blur' }],
    industryTypeId: [{ required: true, message: '请选择行业', trigger: 'blur' }],
  },
  isAdmin: false,
  companyList: [],
  industryList: [],
  uploadUrl: import.meta.env.VITE_APP_BASE_API + '/system/common/uploadFile',
  header: {
    Authorization: getToken()
@@ -96,23 +115,32 @@
  }
  state.title = type === 'add' ? '新增' : type ==='edit' ? '编辑' : '查看'
  state.form.companyId = companyId
  await getIndustryList()
  if(state.title == '编辑'||state.title == '查看'){
    Object.keys(state.form).forEach(key => {
      if (key in value) {
        state.form[key] = value[key]
      }
    })
    state.form.industryTypeId = value.industryTypeId ? value.industryTypeId : null
    if(value.filePath) {
      const obj = {
        url: value.filePath,
        name: '模板文件'
        name: value.templateName+value.format
      }
      state.fileList = [obj]
    }
  }
  dialogVisible.value = true
}
const getIndustryList = async () => {
  const res = await getIndustry()
  if(res.code == 200){
    state.industryList = res.data.data
  }else{
    ElMessage.warning(res.message)
  }
}
const onSubmit = async () => {
  const valid = await superRef.value.validate();
@@ -162,10 +190,10 @@
  });
}
const picSize = async (rawFile) => {
  if(rawFile.size / 1024 / 1024 > 5){
  if(rawFile.size / 1024 / 1024 > 30){
    ElMessage({
      type: 'warning',
      message: '文件大小不能超过5M'
      message: '文件大小不能超过30M'
    });
    return false
  }
@@ -197,6 +225,8 @@
    templateName: '',
    filePath: '',
    format: '',
    industryTypeId:'',
    stage:'',
    companyId: null,
    templateType: 3
  }