zhouwenxuan
2024-02-21 eee656c8d1aab0b5aa8935bf1630f782321fc7f4
src/views/safetyReview/projectManage/components/projectArchive.vue
@@ -3,7 +3,8 @@
    <el-form ref="formRef" :model="state.formData" :rules="state.rules" class="register-form" label-position="top">
      <el-row :gutter="30">
        <el-col :span="10">
          <el-button type="primary" :disabled="projectType === 'edit'" @click="addUpload">新增附件列表</el-button>
<!--          <el-button type="primary" :disabled="projectType === 'edit'" @click="addUpload">新增附件列表</el-button>-->
          <span style="font-size: 20px;font-weight: 600">附件列表</span>
          <span style="font-size: 13px;color: rgb(232, 78, 79);font-weight: 400;margin-left: 10px">项目列表仅支持pdf、jpg、jpeg 等格式上传</span>
        </el-col>
      </el-row>
@@ -24,7 +25,7 @@
        </el-table-column>
        <el-table-column label="原因说明" align="center" class-name="small-padding fixed-width">
          <template #default="scope">
            <el-input v-model="scope.row.remark"  show-word-limit type="text" size="large"/>
            <el-input v-model="scope.row.remark"  show-word-limit type="text" size="large"  />
          </template>
        </el-table-column>
        <el-table-column label="附件上传" align="center" class-name="small-padding fixed-width">
@@ -44,11 +45,11 @@
            </el-upload>
          </template>
        </el-table-column>
        <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
          <template #default="scope">
            <el-button link type="danger" @click="delUpload(scope.$index)">删除</el-button>
          </template>
        </el-table-column>
<!--        <el-table-column label="操作" align="center" class-name="small-padding fixed-width">-->
<!--          <template #default="scope">-->
<!--            <el-button link type="danger" @click="delUpload(scope.$index)">删除</el-button>-->
<!--          </template>-->
<!--        </el-table-column>-->
      </el-table>
      <el-row :gutter="30">
        <el-col :span="6">
@@ -94,7 +95,7 @@
</template>
<script setup>
import {defineEmits, onMounted, reactive, ref} from "vue";
import {defineEmits, defineProps, onMounted, reactive, ref} from "vue";
import {ElMessage} from "element-plus";
import {addRecord, editRecord, getDetail} from "@/api/projectManage/contractMng";
import Cookies from "js-cookie";
@@ -102,7 +103,7 @@
import axios from "axios";
import {delAccessoryFile, getAccessoryFile} from "@/api/projectManage/project";
import {addProcessMaterial, getProcessMaterialDetail, editProcessMaterial} from "@/api/projectManage/riskAnalysis";
const props = defineProps(['projectId'])
const emit = defineEmits(["getNextStatus"]);
const state = reactive({
  formData: {
@@ -148,18 +149,16 @@
const isAmin = ref(false)
const formRef = ref();
onMounted(async () => {
  const userInfo = JSON.parse(Cookies.get('userInfo'))
  if(userInfo.identity === 0){
    isAmin.value = true;
  }
  if(Cookies.get('projectId')){
    state.uploadData.projectId = Cookies.get('projectId');
    getRecord(state.uploadData.projectId);
  if(props.projectId){
    state.uploadData.projectId = props.projectId;
    await getRecord(state.uploadData.projectId);
    // const res = await  getAccessoryFile({projectId: val,moduleType: 9});
    // console.log('res',res)
  }
});
const getRecord = async (val) =>{
@@ -192,7 +191,6 @@
    }else {
      ElMessage.warning(res.message)
    }
    getRecord(val);
  }
  if(type === 'add' || type === 'clickEdit') {
    const valid = await formRef.value.validate();
@@ -205,13 +203,28 @@
      const file = state.uploadList.map(item => {
        return{
          id: item.id ? item.id : null,
          fileId: item.fileList ? item.fileList[0].response ? item.fileList[0].response.data.id : item.fileList[0].id : '',
          fileId: item.fileList && item.fileList.length>0 ? item.fileList[0].response ? item.fileList[0].response.data.id : item.fileList[0].id : '',
          name: item.name,
          type: item.type,
          remark: item.remark,
          projectId: val
        }
      })
      let isOk = false;
      try{
        state.uploadList.forEach(item => {
          if(item.type == 1 && (!item.fileList || item.fileList .length == 0) && item.remark == ""){
            isOk = true;
            throw Error();
          }
        })
      }catch (e) {}
      if(isOk){
        ElMessage.warning("请完善原因说明或上传附件!");
        return;
      }
      const { ...data} = JSON.parse(JSON.stringify(state.formData))
      data.actualContractMoney = state.actualContract.actualContractMoney;
      data.actualContractIntroduction = state.actualContract.actualContractIntroduction;
@@ -234,6 +247,7 @@
        const res = await editProcessMaterial(params);
        if (res.code == 200) {
          ElMessage.success('变更成功')
          projectType.value='edit';
          formRef.value.clearValidate();
          // emit('getNextStatus', data.project.id);
        } else {
@@ -279,10 +293,10 @@
const handleAvatarSuccess = (res, uploadFile) => {
  if(res.code === 200){
    console.log("if",state.uploadList)
    ElMessage({
      type: 'success',
      message: '文件上传成功'
    })
    // ElMessage({
    //   type: 'success',
    //   message: '文件上传成功'
    // })
  }else {
    ElMessage({
      type: 'warning',
@@ -335,10 +349,10 @@
  }
  const res = await delAccessoryFile(accessoryFileId)
  if(res.code == 200){
    ElMessage({
      type: 'success',
      message: '文件已删除'
    })
    // ElMessage({
    //   type: 'success',
    //   message: '文件已删除'
    // })
  }else{
    ElMessage({
      type: 'warning',