zhouwenxuan
2024-02-21 eee656c8d1aab0b5aa8935bf1630f782321fc7f4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
<template>
  <div class="riskBox">
    <el-form ref="formRef" :model="state.formData" :rules="state.rules" class="register-form" label-position="top">
      <el-row :gutter="30">
        <el-col :span="6">
          <el-form-item prop="auditDate" label="审核日期">
            <el-date-picker
                style="width: 100%"
                v-model="state.formData.auditDate"
                type="date"
                value-format="YYYY-MM-DD 00:00:00"
                placeholder="选择日期"
                size="large"
            />
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item prop="processLeader.name" label="过程控制负责人">
            <el-input
                v-model="state.formData.processLeader.name"
                size="large"
                placeholder="请选择过程控制负责人"
                @focus="openExperts('过程控制负责人')"
            >
              <template #append>
                <el-button :icon="Search" @click="openExperts('过程控制负责人')"/>
              </template>
            </el-input>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item prop="isFullProcess" label="审核结论:是否满足过程控制要求">
            <el-radio-group v-model="state.formData.isFullProcess" >
              <el-radio :label="1">是</el-radio>
              <el-radio :label="0">否</el-radio>
            </el-radio-group>
          </el-form-item>
        </el-col>
      </el-row>
      <el-table  :data="state.tableData" :border="true" style="margin: 20px 0">
        <el-table-column label="序号" width="60" align="center" type="index"></el-table-column>
        <el-table-column label="过程控制关键点" prop="content" header-align="center" :show-overflow-tooltip="true"/>
        <el-table-column label="审核结果" header-align="center" class-name="small-padding fixed-width" width="175">
          <template #default="scope">
            <el-radio-group v-model="scope.row.status" @change="changeStatus(scope.row)">
              <el-radio :label="1">符合</el-radio>
              <el-radio :label="0">不符合</el-radio>
            </el-radio-group>
          </template>
        </el-table-column>
        <el-table-column label="不符合描述" header-align="center" class-name="small-padding fixed-width" width="700">
          <template #default="scope">
            <el-input
                v-model="scope.row.reason"
                size="large"
                :disabled="scope.row.status == 1"
                placeholder="如不符合,请填写不符合描述"
            />
          </template>
        </el-table-column>
      </el-table>
      <el-form-item prop="suggestions" label="存在问题及建议">
        <el-input
            v-model="state.formData.suggestions"
            :autosize="{ minRows: 6 }"
            maxlength="500"
            show-word-limit
            type="textarea">
        </el-input>
      </el-form-item>
      <el-row :gutter="30">
        <el-col :span="18">
          <el-form-item label="附件上传" prop="assAccessoryFiles">
            <el-upload accept="image/*,.pdf,.doc,.docx,.xlsx,.xls" :action="state.uploadUrl" :data="{moduleType: 8,projectId: props.projectId}" :headers="state.header" method="post" :on-success="handleAvatarSuccess" :on-exceed="showTip" :on-preview="handlePictureCardPreview" :limit='1' v-model:file-list="state.fileList" :before-upload="picSize" :disabled="state.disabled" :on-remove="handleRemove" >
              <el-button type="primary">附件上传</el-button>
              <template #tip>
                <div class="el-upload__tip">上传文件尺寸小于5M,最多可上传1份</div>
              </template>
            </el-upload>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <el-dialog v-model="state.dialogImg">
      <el-image style="width: 100%; height: 100%" :src="state.dialogImageUrl"/>
    </el-dialog>
    <experts-list ref="expertsListRef" @getName="getSelected"></experts-list>
  </div>
</template>
<script setup>
 
import {defineEmits, onMounted, reactive, ref} from "vue";
import {ElMessage, ElMessageBox} from "element-plus";
import {Search} from '@element-plus/icons-vue'
import {delFile, getFiles} from "@/api/projectManage/siteCheckRcd"
import {addProcessCtrl, editProcessCtrl,getProcessCtrlDetail} from "@/api/projectManage/processCtrl"
import {delPic} from "@/api/login"
import { getToken } from "@/utils/auth";
import Cookies from "js-cookie"
import ExpertsList from "./expertsList";
import axios from "axios";
const props = defineProps(['projectId'])
const emit = defineEmits(["getNextStatus"]);
 
const state = reactive({
  formData: {
    id: null,
    projectId: null,
    auditDate: '',
    processLeader: {name: ''},
    processLeaderId: null,
    isFullProcess: null,
    suggestions: ''
  },
  rules: {
    auditDate: [{required: true, message: '请选择审核日期', trigger: 'blur'}],
    'processLeader.name': [{required: true, message: '请选择过程控制负责人', trigger: 'change'}],
    isFullProcess: [{required: true, message: '请选择审核结论', trigger: 'blur'}]
  },
  tableData: [
    {id: 1, content: '风险分析', status: 1, key:'isRiskAnalyse', reasonKey: 'riskAnalyseDes', reason: ''},
    {id: 2, content: '签订合同', status: 1, key:'isSignContract', reasonKey: 'signContractDes', reason: ''},
    {id: 3, content: '评价任务通知书', status: 1, key:'isEstimateTask', reasonKey: 'estimateTaskDes', reason: ''},
    {id: 4, content: '编制安全评价项目计划书', status: 1, key:'isEstimatePlan', reasonKey: 'estimatePlanDes', reason: ''},
    {id: 5, content: '被评价单位提供材料清单', status: 1, key:'isProvideMaterials', reasonKey: 'provideMaterialsDes', reason: ''},
    {id: 6, content: '从业告知', status: 1, key:'isWorkNotification', reasonKey: 'workNotificationDes', reason: ''},
    {id: 7, content: '现场勘验记录及影像资料', status: 1, key:'isInvestigationSite', reasonKey: 'investigationSiteDes', reason: ''},
    {id: 8, content: '评价报告内部审核', status: 1, key:'isInteriorAudit', reasonKey: 'interiorAuditDes', reason: ''},
    {id: 9, content: '技术负责人审核', status: 1, key:'isTechnolgyAudit', reasonKey: 'technolgyAuditDes', reason: ''},
    {id: 6, content: '评价报告外审意见', status: 1, key:'isExteriorAudit', reasonKey: 'exteriorAuditDes', reason: ''},
    {id: 7, content: '评价项目网上信息公开', status: 1, key:'isOpenInformation', reasonKey: 'openInformationDes', reason: ''},
    {id: 8, content: '二维码的使用', status: 1, key:'isUseQrcode', reasonKey: 'useQrcodeDes', reason: ''},
    {id: 9, content: '报告归档材料完整性', status: 1, key:'isFullMaterials', reasonKey: 'fullMaterialsDes', reason: ''}
  ],
  uploadUrl: import.meta.env.VITE_APP_BASE_API + '/manage/accessory-file/uploadFile',
  header: {
    Authorization: getToken()
  },
  disabled:false
})
 
const isAmin = ref(false)
const formRef = ref()
const expertsListRef = ref()
onMounted(() => {
  const userInfo = JSON.parse(Cookies.get('userInfo'))
  if(userInfo.identity === 0){
    isAmin.value = true;
  }
  getProcessFiles(props.projectId)
})
 
const riskOpen = async (type,val) => {
  state.formData.projectId = val
  if(type === 'detail' || type === 'edit' ){
    if(type === 'detail'){
      state.disabled = true
    }
    const res = await getProcessCtrlDetail({projectId: val});
    if(res.code == 200){
      state.formData = res.data
      state.formData.isFullProcess = res.data.isFullProcess==true?1:0
      for(let key in res.data){
        for(let item of state.tableData){
          if(item.key == key){
            item.status = res.data[key]==true?1:0
          }
          if(item.reasonKey == key){
            item.reason = res.data[key]
          }
        }
      }
    }else {
      ElMessage.warning(res.message)
    }
  }
  if(type === 'add' || type === 'clickEdit') {
    const valid = await formRef.value.validate();
    if(valid){
      if (isAmin.value) {
        ElMessage.warning("当前用户暂无权限");
        return;
      }
      if(type === 'add'){
        const {id,processLeader, ...data} = JSON.parse(JSON.stringify(state.formData))
        for(let i of state.tableData){
          if(i.status == 1){
            i.reason = ''
          }else{
            if(i.reason == ''){
              ElMessage.warning("请完善不符合项描述");
              return
            }
          }
          data[i.key] = i.status
          data[i.reasonKey] = i.reason
        }
        const res = await addProcessCtrl(data);
        if (res.code == 200) {
          ElMessage.success('保存成功')
          formRef.value.clearValidate();
          emit('getNextStatus', val);
 
        } else {
          ElMessage.warning(res.message)
        }
      }else if(type === 'clickEdit'){
        const {processLeader, ...data} = JSON.parse(JSON.stringify(state.formData))
        for(let i of state.tableData){
          data[i.key] = i.status
          data[i.reasonKey] = i.reason
          if(i.status == 1){
            i.reason = ''
          }
        }
        const res = await editProcessCtrl(data);
        if (res.code == 200) {
          ElMessage.success('变更成功')
          formRef.value.clearValidate();
          // emit('getNextStatus', data.project.id);
        } else {
          ElMessage.warning(res.message)
        }
      }
    }
  }
}
const changeStatus = (val) => {
  if(val.status == 1 && val.reason != "") {
    const index = state.tableData.findIndex(item => item.id == val.id)
    state.tableData[index].reason = ""
  }
}
 
const openExperts = (type) =>{
  expertsListRef.value.openDialog(type)
}
 
const getSelected = (type,obj)=>{
  state.formData.processLeader.name = obj.name
  state.formData.processLeaderId = obj.id
}
 
const getProcessFiles = async (id)=>{
  const res = await getFiles({projectId: id ? id : props.projectId,moduleType: 8})
  if(res.code == 200){
    if(res.data && res.data.length>0){
      state.fileList = res.data.map(i=>{
        return {
          name: i.originName,
          url: import.meta.env.VITE_APP_BASE_API + '/' + i.path,
          id: i.id,
          projectId: i.projectId,
          moduleType: i.moduleType
        }
      })
    }else{
      state.fileList = []
    }
  }else {
    ElMessage.warning(res.message)
  }
}
 
// 图片上传
const showTip =()=>{
  ElMessage({
    type: 'warning',
    message: '超出文件上传数量'
  });
}
 
const picSize = async (rawFile) => {
  if(rawFile.size / 1024 / 1024 > 5){
    ElMessage({
      type: 'warning',
      message: '文件大小不能超过5M'
    });
    return false
  }
};
 
const handlePictureCardPreview = (uploadFile) => {
  axios.get(uploadFile.url,{headers:{'Content-Type': 'application/json','Authorization': `${getToken()}`,'uid':`${Cookies.get('uid')}`},responseType: 'blob'}).then(res=>{
    if (res) {
      const link = document.createElement('a')
      let blob = new Blob([res.data],{type: res.data.type})
      link.style.display = "none";
      link.href = URL.createObjectURL(blob); // 创建URL
      window.open(link.href)
    } else {
      ElMessage({
        type: 'warning',
        message: '文件读取失败'
      });
    }
  })
};
 
 
const handleAvatarSuccess = (res, uploadFile) => {
  if(res.code == 200){
    getProcessFiles()
  }else{
    ElMessage({
      type: 'warning',
      message: '文件上传失败'
    })
  }
}
 
const handleRemove = async (file, uploadFile) => {
  ElMessageBox.confirm(
      '确定删除该附件?',
      '提示',
      {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
      })
      .then( async() => {
        const res = await delFile(file.id)
        if(res.code == 200){
          ElMessage({
            type: 'success',
            message: '文件已删除'
          })
          await getProcessFiles()
        }else{
          ElMessage({
            type: 'warning',
            message: res.message
          })
        }
      })
      .catch(()=>{
        getProcessFiles()
      })
}
 
defineExpose({
  riskOpen
});
 
 
</script>
<style scoped lang="scss">
.riskBox{
  :deep(.el-form .el-form-item__label) {
    font-size: 15px;
  }
}
 
</style>