联调普测计划管理页面

This commit is contained in:
GGJ
2024-05-15 12:27:13 +08:00
parent bb67695943
commit 5095592df4
6 changed files with 286 additions and 62 deletions

View File

@@ -49,7 +49,6 @@
<el-form-item label="上传文件:">
<el-upload
v-model:file-list="formdata.fileList"
v-if="title != '查看计划'"
ref="upload"
action=""
:limit="5"
@@ -60,13 +59,6 @@
<el-button type="primary">上传文件</el-button>
</template>
</el-upload>
<div v-else>
<div v-for="(item, index) in aList">
<el-button type="primary" link @click="downloadFile(item.url, item.fileName)">
{{ item.fileName }}
</el-button>
</div>
</div>
</el-form-item>
</el-form>
</el-form>
@@ -76,7 +68,7 @@
<generalTestTree ref="treeRef" />
</el-col>
</el-row>
<div
<!-- <div
v-if="
(title == '查看计划' || title == '计划审核') &&
(title == '计划审核' || formdata.status == 1 || formdata.status == 3 || formdata.status == 4)
@@ -89,7 +81,7 @@
:autosize="{ minRows: 2, maxRows: 4 }"
v-model="formdata.checkComment"
></el-input>
</div>
</div> -->
<template #footer v-if="title != '查看计划'">
<div class="dialog-footer pd10">
<el-button type="primary" @click="submitFn">提交</el-button>
@@ -101,7 +93,7 @@
<script setup lang="ts">
import generalTestTree from '@/components/tree/pqs/generalTestTree.vue'
import { ref, reactive, nextTick } from 'vue'
import { addSurvey } from '@/api/process-boot/generalTest'
import { addSurvey, auditSurvey } from '@/api/process-boot/generalTest'
import Area from '@/components/form/area/index.vue'
import { ElMessage, UploadProps } from 'element-plus'
import { uploadFile, getFileNameAndFilePath } from '@/api/system-boot/file'
@@ -127,7 +119,6 @@ const formdata: any = ref({
checkComment: '',
filePath: ''
})
const aList: any = ref([])
const formRef = ref()
const treeRef = ref()
const rules = {
@@ -147,17 +138,30 @@ const submitFn = () => {
formRef.value.validate(async (valid: any) => {
if (valid) {
let filePath = ''
formdata.value.subIds = ['123', '3123'] //treeRef.value.treeRef.getCheckedKeys(false)
formdata.value.subIds = treeRef.value.treeRef.getCheckedKeys(false)
for (let i = 0; i < formdata.value.fileList.length; i++) {
await uploadFile(formdata.value.fileList[i].raw, 'supervision/').then(res => {
filePath = filePath + res.data.name + ','
})
if (i == formdata.value.fileList.length - 1) {
await addSurvey({ ...formdata.value, filePath: filePath }).then((res: any) => {
ElMessage.success('新增成功!')
cancelFn()
emit('onsubmit')
if (formdata.value.fileList[i].raw) {
await uploadFile(formdata.value.fileList[i].raw, 'supervision/').then(res => {
filePath = filePath + res.data.name + ','
})
} else {
filePath = filePath + formdata.value.fileList[i].supervision + ','
}
if (i == formdata.value.fileList.length - 1) {
if (title.value == '普测计划新增') {
await addSurvey({ ...formdata.value, filePath: filePath }).then((res: any) => {
ElMessage.success('新增成功!')
cancelFn()
emit('onsubmit')
})
} else if (title.value == '重新发起计划') {
await auditSurvey({ ...formdata.value, filePath: filePath }).then((res: any) => {
ElMessage.success('重新发起计划成功!')
cancelFn()
emit('onsubmit')
})
}
}
}
}
@@ -194,10 +198,19 @@ const open = (text: string, row?: any) => {
if (row) {
formdata.value = JSON.parse(JSON.stringify(row))
nextTick(() => {
getFilePath()
formdata.value.fileList = []
treeRef.value.loadData()
treeRef.value.setKey(row.subIds || [], text)
// formdata.value.filePath.join(',')
let arr = row.filePath.split(',')
arr.slice(0, -1).forEach((item: any) => {
getFileNameAndFilePath({ filePath: item }).then((res: any) => {
formdata.value.fileList.push({
name: res.data.fileName,
supervision: res.data.name,
url: res.data.url
})
})
})
})
} else {
nextTick(() => {
@@ -205,24 +218,6 @@ const open = (text: string, row?: any) => {
})
}
}
const getFilePath = () => {
aList.value = []
let arr = formdata.value.filePath.split(',')
arr.slice(0, -1).forEach((item: any) => {
getFileNameAndFilePath({ filePath: item }).then((res: any) => {
aList.value.push(res.data)
})
})
}
const downloadFile = (url: string, fileName: string) => {
const link = document.createElement('a')
link.href = url
link.download = fileName
document.body.appendChild(link)
link.click()
document.body.removeChild(link)
}
defineExpose({ open })
</script>