293 lines
11 KiB
Vue
293 lines
11 KiB
Vue
<template>
|
|
<el-dialog draggable :title="title" v-model="planAddition" width="500px" :before-close="cancelFn">
|
|
<el-form :model="form" ref="formRef" :rules="rules" label-width="auto" scroll-to-error :validate-on-rule-change="false" class="form-one">
|
|
<el-form-item for="-" label="普测负责单位:">
|
|
<Area v-model="form.deptId" />
|
|
</el-form-item>
|
|
<el-form-item for="-" label="计划名称:" prop="planName">
|
|
<el-input v-model="form.planName" placeholder="请输入计划名称"></el-input>
|
|
</el-form-item>
|
|
<el-form-item for="-" label="计划开始时间:" prop="planStartTime">
|
|
<el-date-picker
|
|
v-model="form.planStartTime"
|
|
type="date"
|
|
placeholder="选择计划开始时间"
|
|
value-format="YYYY-MM-DD"
|
|
></el-date-picker>
|
|
</el-form-item>
|
|
<el-form-item for="-" label="计划结束时间:" prop="planEndTime">
|
|
<el-date-picker
|
|
v-model="form.planEndTime"
|
|
type="date"
|
|
placeholder="选择计划结束时间"
|
|
value-format="YYYY-MM-DD"
|
|
></el-date-picker>
|
|
</el-form-item>
|
|
<!-- <el-form-item for="-" label="实际完成时间:" prop="planComplateTime">
|
|
<el-date-picker
|
|
v-model="form.planComplateTime"
|
|
type="date"
|
|
placeholder="选择实际完成时间"
|
|
value-format="YYYY-MM-DD"
|
|
></el-date-picker>
|
|
</el-form-item> -->
|
|
<!-- <el-form-item for="-" label="测试负责人:" prop="leader">
|
|
<el-input v-model="form.leader" placeholder="请输入测试负责人"></el-input>
|
|
</el-form-item> -->
|
|
<el-form-item for="-" label="系统电站:" prop="customSubstationFlag">
|
|
<!-- 默认值 开启 -->
|
|
<el-radio-group v-model="form.customSubstationFlag" @change="changeSubstationFlag">
|
|
<el-radio value="0">是</el-radio>
|
|
<el-radio value="1">否</el-radio>
|
|
</el-radio-group>
|
|
</el-form-item>
|
|
<el-form-item
|
|
for="-"
|
|
label="关联电站:"
|
|
v-if="form.customSubstationFlag == '0'"
|
|
prop="substation"
|
|
style="display: flex; align-items: center"
|
|
>
|
|
<el-cascader
|
|
v-model="form.substation"
|
|
:options="treeList"
|
|
:props="defaultProps"
|
|
clearable
|
|
filterable
|
|
collapse-tags
|
|
placeholder="请选择关联电站"
|
|
/>
|
|
<!-- <el-tree-select
|
|
accordion
|
|
ref="treeRef"
|
|
:default-expand-all="false"
|
|
show-checkbox
|
|
check-strictly
|
|
:highlight-current="true"
|
|
readonly
|
|
node-key="id"
|
|
:props="defaultProps"
|
|
v-model="form.substation"
|
|
:data="treeList"
|
|
:render-after-expand="false"
|
|
/> -->
|
|
</el-form-item>
|
|
<el-form-item for="-" label="关联电站:" v-if="form.customSubstationFlag == '1'" prop="substation">
|
|
<el-input v-model="form.substation" placeholder="请输入关联电站"></el-input>
|
|
</el-form-item>
|
|
<!-- <el-form :model="form" label-width="auto"> -->
|
|
<!-- <el-form-item for="-" class="uploadFile" label="普测报告:" prop="fileList">
|
|
<el-upload
|
|
v-model:file-list="form.fileList"
|
|
ref="upload"
|
|
action=""
|
|
:limit="5"
|
|
:on-exceed="handleExceed"
|
|
:auto-upload="false"
|
|
:on-remove="removeFile"
|
|
>
|
|
<template #trigger>
|
|
<el-button type="primary">上传文件</el-button>
|
|
</template>
|
|
</el-upload>
|
|
</el-form-item> -->
|
|
<!-- </el-form> -->
|
|
</el-form>
|
|
<!-- <el-divider content-position="left" style="font-size: 18px; font-weight: bolder">添加电站</el-divider> -->
|
|
<!-- <generalTestTree ref="treeRef" /> -->
|
|
<!-- <div
|
|
v-if="
|
|
(title == '查看计划' || title == '计划审核') &&
|
|
(title == '计划审核' || form.status == 1 || form.status == 3 || form.status == 4)
|
|
"
|
|
>
|
|
<el-divider content-position="left" style="font-size: 18px; font-weight: bolder">审核意见</el-divider>
|
|
<el-input
|
|
:disabled="title != '计划审核'"
|
|
type="textarea"
|
|
:autosize="{ minRows: 2, maxRows: 4 }"
|
|
v-model="form.checkComment"
|
|
></el-input>
|
|
</div> -->
|
|
<template #footer v-if="title != '查看计划'">
|
|
<div class="dialog-footer">
|
|
<el-button @click="cancelFn">取消</el-button>
|
|
<el-button type="primary" @click="submitFn">确定</el-button>
|
|
</div>
|
|
</template>
|
|
</el-dialog>
|
|
</template>
|
|
<script setup lang="ts">
|
|
import generalTestTree from '@/components/tree/pqs/generalTestTree.vue'
|
|
import { ref, reactive, nextTick } from 'vue'
|
|
import { addSurvey, auditSurvey, addSurveyPlan } 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'
|
|
import { useDictData } from '@/stores/dictData'
|
|
import { initDetpStataionTree } from '@/api/process-boot/generalTest'
|
|
const emit = defineEmits(['onsubmit'])
|
|
const dictData = useDictData()
|
|
const title = ref('')
|
|
const planAddition = ref(false)
|
|
const defaultProps = ref({
|
|
label: 'name',
|
|
value: 'id',
|
|
checkStrictly: true,
|
|
emitPath: false,
|
|
expandTrigger: 'hover' as const,
|
|
multiple: true
|
|
})
|
|
const obj = {
|
|
customSubstationFlag: '0',
|
|
deptId: '0d52f9f6e43ec0ee83013cd32da93f66',
|
|
planEndTime: '2024-05-31',
|
|
planName: '5.31计划',
|
|
planStartTime: '2024-05-01',
|
|
substation: '3c175083dbc1e870365dd12d79c837ec,5487bd33c24007aad7af4882b455203b'
|
|
}
|
|
const form: any = ref({
|
|
// orgName: '',
|
|
deptId: dictData.state.area[0].id,
|
|
planStartTime: '',
|
|
planEndTime: '',
|
|
planName: '',
|
|
// fileList: [],
|
|
// checkComment: '',
|
|
// filePath: '',
|
|
substation: '', //关联电站
|
|
customSubstationFlag: '0' //电站类型
|
|
})
|
|
const props = {
|
|
expandTrigger: 'hover' as const
|
|
}
|
|
const formRef = ref()
|
|
const treeRef = ref()
|
|
const rules = ref({
|
|
planStartTime: [{ required: true, message: '选择计划开始时间', trigger: 'change' }],
|
|
planEndTime: [{ required: true, message: '选择计划结束时间', trigger: 'change' }],
|
|
planComplateTime: [{ required: true, message: '选择实际完成时间 ', trigger: 'change' }],
|
|
planName: [{ required: true, message: '请输入计划名称', trigger: 'blur' }],
|
|
leader: [{ required: true, message: '请输入测试负责人', trigger: 'blur' }],
|
|
substation: [{ required: true, message: '请选择关联电站', trigger: 'change' }]
|
|
// fileList: [{ required: true, message: '请上传文件', trigger: 'change' }],
|
|
})
|
|
const changeSubstationFlag = () => {
|
|
console.log(form.value.customSubstationFlag)
|
|
//处理所属变电站手都输入1/下拉数据0
|
|
if (form.value.customSubstationFlag == '0') {
|
|
rules.value.substation[0].message = '请选择关联电站'
|
|
form.value.substation = ''
|
|
} else {
|
|
rules.value.substation[0].message = '请输入关联电站'
|
|
form.value.substation = []
|
|
}
|
|
}
|
|
const cancelFn = () => {
|
|
formRef.value.resetFields()
|
|
// treeRef.value.setKey([])
|
|
planAddition.value = false
|
|
}
|
|
const treeList = ref()
|
|
const loadData = () => {
|
|
initDetpStataionTree({ orgId: dictData.state.area[0].id }).then(res => {
|
|
treeList.value = res.data
|
|
console.log(treeList.value)
|
|
})
|
|
}
|
|
// 提交
|
|
const submitFn = () => {
|
|
formRef.value.validate(async (valid: any) => {
|
|
if (valid) {
|
|
let filePath = ''
|
|
audit(filePath)
|
|
// form.value.substation = treeRef.value.treeRef.getCheckedKeys(false)
|
|
// form.value.substation = typeof form.value.substation == 'string' ? [form.value.substation] : form.value.substation
|
|
// if (form.value.fileList.length == 0) {
|
|
// audit(filePath)
|
|
// } else {
|
|
// for (let i = 0; i < form.value.fileList.length; i++) {
|
|
// if (form.value.fileList[i].raw) {
|
|
// await uploadFile(form.value.fileList[i].raw, 'supervision/').then(res => {
|
|
// filePath = filePath + res.data.name + ','
|
|
// })
|
|
// } else {
|
|
// filePath = filePath + form.value.fileList[i].supervision + ','
|
|
// }
|
|
// if (i == form.value.fileList.length - 1) {
|
|
// audit(filePath)
|
|
// }
|
|
// }
|
|
// }
|
|
}
|
|
})
|
|
}
|
|
const audit = (filePath: any) => {
|
|
//选择系统变电站
|
|
const addForm = JSON.parse(JSON.stringify(form.value))
|
|
if (form.value.customSubstationFlag == '0') {
|
|
addForm.substation = addForm.substation.join(',')
|
|
}
|
|
addSurveyPlan(addForm).then(res => {
|
|
cancelFn()
|
|
emit('onsubmit')
|
|
})
|
|
return
|
|
}
|
|
// 上传文件
|
|
// 文件数超出提示
|
|
const handleExceed: UploadProps['onExceed'] = (): void => {
|
|
ElMessage.error(`上传文件数量不能超过5个!`)
|
|
}
|
|
//移除文件上传
|
|
const removeFile = (file: any, uploadFiles: any) => {
|
|
console.log(file, uploadFiles)
|
|
}
|
|
const open = (text: string, row?: any) => {
|
|
loadData()
|
|
form.value = Object.assign({
|
|
// orgName: '',
|
|
deptId: dictData.state.area[0].id,
|
|
planStartTime: '',
|
|
planEndTime: '',
|
|
planName: '',
|
|
substation: '', //关联电站
|
|
// fileList: [],
|
|
// checkComment: '',
|
|
// filePath: '',
|
|
customSubstationFlag: '0' //电站类型
|
|
})
|
|
title.value = text
|
|
planAddition.value = true
|
|
formRef.value?.resetFields()
|
|
// if (row) {
|
|
// form.value = JSON.parse(JSON.stringify(row))
|
|
// nextTick(() => {
|
|
// form.value.fileList = []
|
|
// treeRef.value.loadData()
|
|
// treeRef.value.setKey(row.substation || [], text)
|
|
// let arr = row.filePath.split(',')
|
|
// arr.slice(0, -1).forEach((item: any) => {
|
|
// getFileNameAndFilePath({ filePath: item }).then((res: any) => {
|
|
// form.value.fileList.push({
|
|
// name: res.data.fileName,
|
|
// supervision: res.data.name,
|
|
// url: res.data.url
|
|
// })
|
|
// })
|
|
// })
|
|
// })
|
|
// } else {
|
|
// nextTick(() => {
|
|
// treeRef.value.loadData()
|
|
// })
|
|
// }
|
|
}
|
|
defineExpose({ open })
|
|
</script>
|
|
<style lang="scss" scoped>
|
|
// :deep(.el-upload-list__item-info) {
|
|
// width: 250px;
|
|
// }
|
|
</style>
|