祖安之光
3 天以前 d4534c231f7c25ca64d40c8bcaadf83f64b640c3
修改新增
已修改2个文件
已删除1个文件
95 ■■■■■ 文件已修改
public/qualityFile.docx 补丁 | 查看 | 原始文档 | blame | 历史
src/views/work/selfProblems/internalAudit/problemMng/noConformanceMng/components/editDialog.vue 91 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/work/selfProblems/internalAudit/problemMng/noConformanceMng/index.vue 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
public/qualityFile.docx
Binary files differ
src/views/work/selfProblems/internalAudit/problemMng/noConformanceMng/components/editDialog.vue
@@ -27,14 +27,14 @@
              placeholder="请选择年份"
          />
        </el-form-item>
        <el-form-item label="文件名称:" prop="inconsistentName">
        <el-form-item label="不符合项内容:" prop="inconsistentName">
          <el-input v-model.trim="state.form.inconsistentName" :disabled="state.title =='查看'" placeholder="文件名称"></el-input>
        </el-form-item>
        <el-form-item label="文件:" prop="filePath">
          <el-upload accept=".doc,.docx,.pdf,.jpg" :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、.pdf、.jpg格式,尺寸小于5M,最多可上传1份</div>
              <div class="el-upload__tip">支持上传.doc、.docx、.pdf、.jpg格式,尺寸小于5M,最多可上传10份</div>
            </template>
          </el-upload>
        </el-form-item>
@@ -81,7 +81,7 @@
    id: null,
    year: '',
    inconsistentName: '',
    filePath: '',
    filePath: [],
    format: '',
    companyId: null
  },
@@ -97,7 +97,7 @@
  header: {
    Authorization: getToken()
  },
  fileLimit: 1,
  fileLimit: 10,
  fileList: []
})
onMounted(() => {
@@ -118,12 +118,26 @@
        state.form[key] = value[key]
      }
    })
    if(value.filePath) {
      const obj = {
        url: value.filePath,
        name: '模板文件'
      }
      state.fileList = [obj]
    if(!value.filePath || value.filePath == ''){
      state.form.filePath = []
    }else{
      const certificatePaths = value.filePath.split(',')
      state.form.filePath = certificatePaths
      state.fileList = certificatePaths.map((path, index) => {
        const fileName = path.split('/').pop() || `文件${index + 1}`
        return {
          name: fileName,
          url: path,
          response: {
            data: {
              path: path,
              fileName: fileName
            }
          },
          status: 'success',
          uid: Date.now() + index
        }
      })
    }
  }
  dialogVisible.value = true
@@ -135,6 +149,9 @@
  if(valid){
    if(state.title == '新增'){
      const {id,...data} = state.form
      data.filePath = state.fileList
          .filter(file => file.response?.data?.path)
          .map(file => file.response.data.path).join(',')
      const res = await addSelectInconsistent(data)
      if(res.code == 200){
        ElMessage.success(res.message)
@@ -145,7 +162,11 @@
        ElMessage.warning(res.message)
      }
    }else{
      const res = await updateSelectInconsistent(state.form)
      const data = JSON.parse(JSON.stringify(state.form))
      data.filePath = state.fileList
          .filter(file => file.response?.data?.path)
          .map(file => file.response.data.path).join(',')
      const res = await updateSelectInconsistent(data)
      if(res.code == 200){
        ElMessage.success(res.message)
        emit('getList')
@@ -158,16 +179,18 @@
  }
}
const handleAvatarSuccess = (res, uploadFile) => {
  if(res.code == 200){
    state.form.filePath = res.data.path
    state.form.format = '.' + res.data.filename.split('.')[1]
  }else{
    state.fileList = []
    ElMessage({
      type: 'warning',
      message: '文件上传失败'
    })
const handleAvatarSuccess = (response, uploadFile) => {
  if(response.code === 200){
    // 设置文件显示名称
    uploadFile.name = response.data.fileName || `文件${state.fileList.length}`
    uploadFile.url = response.data.url || response.data.path
    ElMessage.success('文件上传成功')
  } else {
    const index = state.fileList.findIndex(file => file.uid === uploadFile.uid)
    if (index > -1) {
      state.fileList.splice(index, 1)
    }
    ElMessage.error(response.message || '文件上传失败')
  }
}
@@ -187,24 +210,14 @@
  }
};
const handleRemove = async (file, uploadFiles) => {
  let path = state.form.filePath;
  await delPic({path: path}).then(res => {
    if(res.code == 200){
      // ElMessage({
      //   type: 'success',
      //   message: '文件已删除'
      // })
      state.form.filePath = ''
      state.form.format = ''
    }else{
      ElMessage({
        type: 'warning',
        message: res.message
      })
  try {
    if (file.response?.data?.path) {
      await delPic({ path: file.response.data.path })
      ElMessage.success('文件删除成功')
    }
  }).catch(() => {
    state.form.imgUrl = ''
  });
  } catch (error) {
    ElMessage.error('文件删除失败')
  }
}
const handleClose = () => {
@@ -212,7 +225,7 @@
    id: null,
    year: '',
    inconsistentName: '',
    filePath: '',
    filePath: [],
    format: '',
    companyId: null
  }
src/views/work/selfProblems/internalAudit/problemMng/noConformanceMng/index.vue
@@ -30,11 +30,11 @@
    <!-- 表格数据 -->
    <el-table v-loading="loading" :data="dataList" :border="true">
      <el-table-column label="序号" type="index" align="center" width="80"/>
      <el-table-column label="文件名称" prop="inconsistentName" align="center"/>
      <el-table-column label="不符合项内容" prop="inconsistentName" align="center"/>
      <el-table-column label="年份" prop="year" align="center"/>
      <el-table-column label="文件" align="center">
        <template #default="scope">
          <el-link type="primary" @click="openFile(scope.row.filePath)">{{scope.row.inconsistentName + scope.row.format}}</el-link>
          <el-link v-for="(path,index) in scope.row.filePath?.split(',')" :key="index" type="primary" @click="openFile(path)">{{scope.row.inconsistentName + '文件'+(index + 1) + '.' + path.split('.')[1]}}<span v-if="index < scope.row.filePath?.split(',').length - 1">、</span></el-link>
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width" >