zhouwenxuan
2024-03-15 68cd58de3a45d79ea241fa4d79e550217072e494
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
<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-button type="primary" @click="addRectify('add',{})" :disabled="projectType ==='view' || isEnd ">新增整改</el-button>
        </el-col>
      </el-row>
      <el-table :data="state.recitificationList" :border="true" style="margin: 20px 0">
        <el-table-column label="序号" width="60" align="center" type="index"></el-table-column>
        <el-table-column label="整改时间" prop="rectifyTime" align="center"></el-table-column>
        <el-table-column label="提交时间" prop="updateTime" align="center"></el-table-column>
        <el-table-column label="整改说明" prop="reason" align="center"></el-table-column>
        <el-table-column label="整改人" prop="rectifyPerson" align="center"></el-table-column>
        <el-table-column label="附件" prop="" align="center">
          <template #default="scope">
            <span @click="handlePreview(scope.row.accessoryFile)" style="color: #3b82f6;cursor:pointer">{{scope.row.accessoryFile.originName}}</span>
          </template>
        </el-table-column>
        <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
          <template #default="scope">
            <el-button link type="primary" @click="addRectify('edit',scope.row)" :disabled="projectType ==='view' || isEnd ">编辑</el-button>
            <el-button link type="danger" @click="del(scope.row)" :disabled="projectType ==='view' || isEnd ">删除</el-button>
          </template>
        </el-table-column>
      </el-table>
    </el-form>
    <div class="pag-container">
      <el-pagination
          v-model:current-page="state.queryParams.pageNum"
          v-model:page-size="state.queryParams.pageSize"
          :page-sizes="[10,15,20,25]"
          layout="total, sizes, prev, pager, next, jumper"
          :total="total"
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
      />
    </div>
    <confirm-end-dialog ref="confirmRef" @getList="getList(props.projectId)"></confirm-end-dialog>
  </div>
 
</template>
<script setup>
 
import {defineEmits, defineProps, onMounted, reactive, ref} from "vue";
import {ElMessage, ElMessageBox} from "element-plus";
import {addRecord, editRecord, getDetail} from "@/api/projectManage/contractMng";
import Cookies from "js-cookie";
import { getToken } from "@/utils/auth";
import confirmEndDialog from './confirmEndDialog.vue'
import {delProject, getAccessoryFile} from "@/api/projectManage/project";
import {delRecitification, doConfirm, getRecognitionList} from "@/api/projectManage/riskAnalysis";
import axios from "axios";
import { useRoute } from 'vue-router'
const route = useRoute()
const confirmRef = ref(null);
const emit = defineEmits(["getNextStatus"]);
const props = defineProps(['projectId'])
const state = reactive({
  formData: {},
  queryParams: {
    pageNum: 1,
    pageSize: 10,
  },
  recitificationList: [],
})
 
const total = ref(0);
const isAmin = ref(false)
const formRef = ref();
onMounted(() => {
  const userInfo = JSON.parse(Cookies.get('userInfo'))
  if(userInfo.identity === 0){
    isAmin.value = true;
  }
  if(props.projectId){
    state.formData.projectId = props.projectId;
    getList(state.formData.projectId);
  }
});
 
 
const getList = async (val) => {
  const res = await getRecognitionList({projectId: val});
  if(res.code == 200){
    state.recitificationList = res.data.list;
    total.value = res.data.total;
  }else {
    ElMessage.warning(res.message)
  }
}
 
const projectType = ref('')
const isEnd = ref(false)
const riskOpen = async (type,val) => {
  // await  getList(val);
  projectType.value = route.query.type;
  state.formData.projectId = val;
 
  if(type === 'confirm') {
    const res = await doConfirm({projectId: val});
    if (res.code == 200) {
      ElMessage.success('保存成功')
      Cookies.set('end',true)
      isEnd.value = true;
      formRef.value.clearValidate();
      emit('getNextStatus', state.formData.projectId);
    } else {
      ElMessage.warning(res.message)
    }
  }
}
 
const addRectify = (type,val)=>{
  val.projectId =  state.formData.projectId;
  confirmRef.value.openDialog(type,val)
}
 
const delRectify = (index)=>{
  state.rectifyList.splice(index,1)
}
const handleSizeChange = (val) => {
  state.queryParams.pageNum = 1;
  state.queryParams.pageSize = val
  getList(props.projectId)
}
const handleCurrentChange = (val) => {
  state.queryParams.pageNum = val
  getList(props.projectId)
}
 
// 图片上传
const showTip =()=>{
  ElMessage({
    type: 'warning',
    message: '超出文件上传数量'
  });
}
 
const picSize = async (rawFile) => {
  if(rawFile.size / 1024 / 1024 > 5){
    ElMessage({
      type: 'warning',
      message: '文件大小不能超过5M'
    });
    return false
  }
};
 
const handleAvatarSuccess = (res, uploadFile) => {
  if(res.code == 200){
    // state.registerForm.agency.reportPath = res.data.path
  }else{
    ElMessage({
      type: 'warning',
      message: '文件上传失败'
    })
  }
}
 
const handleRemove = async (file, uploadFiles) => {
  const res = await delPic({path: state.registerForm.agency.reportPath})
  if(res.code == 200){
    ElMessage({
      type: 'success',
      message: '文件已删除'
    })
  }else{
    ElMessage({
      type: 'warning',
      message: res.message
    })
  }
}
const handlePreview = (file) => {
  const url = import.meta.env.VITE_APP_BASE_API + '/' + file.path
  axios.get( url,{
        headers:
            {
              'Content-Type': 'application/json',
              'Authorization':getToken(),
            },
        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
      link.setAttribute("download", file.originName);
      document.body.appendChild(link);
      link.click();
      document.body.removeChild(link);
    } else {
      this.$message.error('获取文件失败')
    }
  })
}
const del = (val) => {
  ElMessageBox.confirm(
      '确定删除此条数据?',
      '提示',
      {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
      })
      .then( async() => {
        const res = await delRecitification(val)
        if(res.code == 200){
          ElMessage.success('数据删除成功')
          getList(props.projectId)
        }else{
          ElMessage.warning(res.message)
        }
      })
}
 
defineExpose({
  riskOpen
});
 
 
</script>
<style scoped lang="scss">
.riskBox{
  :deep(.el-form .el-form-item__label) {
    font-size: 15px;
  }
}
.pag-container{
  float: right;
  margin-top: 20px;
}
 
</style>