diff --git a/src/api/eqpt/device/model.ts b/src/api/eqpt/device/model.ts index 04da2af..452933c 100644 --- a/src/api/eqpt/device/model.ts +++ b/src/api/eqpt/device/model.ts @@ -19,6 +19,14 @@ data: params, }) } +// 获取设备规格 +export function getModelByname(params: any) { + return request({ + url: '/equipment/model/listModel', + method: 'get', + params, + }) +} // 设备名称列表/equipment/model/listEquipmentName export function getDeviceNameList() { return request({ diff --git a/src/api/eqpt/device/model.ts b/src/api/eqpt/device/model.ts index 04da2af..452933c 100644 --- a/src/api/eqpt/device/model.ts +++ b/src/api/eqpt/device/model.ts @@ -19,6 +19,14 @@ data: params, }) } +// 获取设备规格 +export function getModelByname(params: any) { + return request({ + url: '/equipment/model/listModel', + method: 'get', + params, + }) +} // 设备名称列表/equipment/model/listEquipmentName export function getDeviceNameList() { return request({ diff --git a/src/views/tested/device/info/components/edit.vue b/src/views/tested/device/info/components/edit.vue index 24890fb..526a338 100644 --- a/src/views/tested/device/info/components/edit.vue +++ b/src/views/tested/device/info/components/edit.vue @@ -27,6 +27,7 @@ const ruleFormRef2 = ref() // from组件 const statusName = $route.query.statusName as string const title = ref('') +const isFrist = ref(true) // 显示标题 const textMap: { [key: string]: string } = { update: '编辑', @@ -163,43 +164,64 @@ // 规格型号及辅助字段 getModelAllList({}).then((res) => { allList.value = res.data - modelList.value = res.data - helpList.value = res.data.filter((item: any) => item.helpInstruction) + modelList.value = Array.from(new Set(res.data.filter((item: any) => item.model).map((item: any) => item.model))) + helpList.value = Array.from(new Set(res.data.filter((item: any) => item.helpInstruction).map((item: any) => item.helpInstruction))) }) } fetchSelectData() // 监听设备名称下拉框,修改规格型号和辅助字段 watch(() => ruleForm.value.equipmentName, (newVal) => { + if ($route.path.includes('detail') || isFrist.value) { + return + } if (newVal) { ruleForm.value.helpInstruction = '' ruleForm.value.model = '' // 修改规格型号和辅助字段列表 const data = allList.value.filter(item => item.equipmentName === newVal) - modelList.value = data - helpList.value = data.filter(item => item.helpInstruction) + modelList.value = Array.from(new Set(data.filter(item => item.model).map(item => item.model))) + helpList.value = Array.from(new Set(data.filter(item => item.helpInstruction).map(item => item.helpInstruction))) } }) // 监听规格型号下拉框,修改辅助字段 watch(() => ruleForm.value.model, (newVal) => { + if ($route.path.includes('detail') || isFrist.value) { + return + } if (newVal) { ruleForm.value.helpInstruction = '' // 修改规格型号和辅助字段列表 - helpList.value = helpList.value.filter(item => item.model === newVal) + helpList.value = Array.from(new Set(allList.value.filter(item => item.helpInstruction).filter(item => item.equipmentName === ruleForm.value.equipmentName && item.model === newVal).map(item => item.helpInstruction))) } }) // 设备相关,填充数据 watch(() => ruleForm.value, (newVal) => { - if (ruleForm.value.helpInstruction && ruleForm.value.model && ruleForm.value.equipmentName) { + if ($route.path.includes('detail') || isFrist.value) { + return + } + if ((ruleForm.value.helpInstruction && ruleForm.value.model && ruleForm.value.equipmentName)) { const arr = allList.value.filter((item: any) => item.helpInstruction === ruleForm.value.helpInstruction && item.model === ruleForm.value.model && item.equipmentName === ruleForm.value.equipmentName) if (arr.length) { const data = arr[0] ruleForm.value.category = data.category - ruleForm.value.remark = data.remark + // ruleForm.value.remark = data.remark ruleForm.value.technicalTargetList = data.technicalTargetList ruleForm.value.checkCycle = data.checkCycle ruleForm.value.modelId = data.id } } + if ((helpList.value.length === 0 || (helpList.value.length === 1 && helpList.value[0].helpInstruction === '/')) && ruleForm.value.model && ruleForm.value.equipmentName) { + const arr = allList.value.filter((item: any) => item.model === ruleForm.value.model && item.equipmentName === ruleForm.value.equipmentName) + if (arr.length) { + const data = arr[0] + ruleForm.value.category = data.category + // ruleForm.value.remark = data.remark + ruleForm.value.technicalTargetList = data.technicalTargetList + ruleForm.value.checkCycle = data.checkCycle + ruleForm.value.modelId = data.id + ruleForm.value.helpInstruction = '/' + } + } }, { deep: true, // immediate: true, @@ -263,11 +285,17 @@ ruleForm.value.createUserName = userStore.name ruleForm.value.createTime = dayjs().format('YYYY-MM-DD HH:mm:ss') // 创建时间 } + setTimeout(() => { + isFrist.value = false + }, 2000); }) } else { getApprovalDetail({ id: $route.query.id as string }).then((res) => { ruleForm.value = res.data + setTimeout(() => { + isFrist.value = false + }, 2000); // if (ruleForm.value.testTask) { // if (ruleForm.value.testTask.includes(',')) { // testTask.value = ruleForm.value.testTask.split(',') @@ -568,7 +596,7 @@ - + @@ -576,7 +604,7 @@ - + diff --git a/src/api/eqpt/device/model.ts b/src/api/eqpt/device/model.ts index 04da2af..452933c 100644 --- a/src/api/eqpt/device/model.ts +++ b/src/api/eqpt/device/model.ts @@ -19,6 +19,14 @@ data: params, }) } +// 获取设备规格 +export function getModelByname(params: any) { + return request({ + url: '/equipment/model/listModel', + method: 'get', + params, + }) +} // 设备名称列表/equipment/model/listEquipmentName export function getDeviceNameList() { return request({ diff --git a/src/views/tested/device/info/components/edit.vue b/src/views/tested/device/info/components/edit.vue index 24890fb..526a338 100644 --- a/src/views/tested/device/info/components/edit.vue +++ b/src/views/tested/device/info/components/edit.vue @@ -27,6 +27,7 @@ const ruleFormRef2 = ref() // from组件 const statusName = $route.query.statusName as string const title = ref('') +const isFrist = ref(true) // 显示标题 const textMap: { [key: string]: string } = { update: '编辑', @@ -163,43 +164,64 @@ // 规格型号及辅助字段 getModelAllList({}).then((res) => { allList.value = res.data - modelList.value = res.data - helpList.value = res.data.filter((item: any) => item.helpInstruction) + modelList.value = Array.from(new Set(res.data.filter((item: any) => item.model).map((item: any) => item.model))) + helpList.value = Array.from(new Set(res.data.filter((item: any) => item.helpInstruction).map((item: any) => item.helpInstruction))) }) } fetchSelectData() // 监听设备名称下拉框,修改规格型号和辅助字段 watch(() => ruleForm.value.equipmentName, (newVal) => { + if ($route.path.includes('detail') || isFrist.value) { + return + } if (newVal) { ruleForm.value.helpInstruction = '' ruleForm.value.model = '' // 修改规格型号和辅助字段列表 const data = allList.value.filter(item => item.equipmentName === newVal) - modelList.value = data - helpList.value = data.filter(item => item.helpInstruction) + modelList.value = Array.from(new Set(data.filter(item => item.model).map(item => item.model))) + helpList.value = Array.from(new Set(data.filter(item => item.helpInstruction).map(item => item.helpInstruction))) } }) // 监听规格型号下拉框,修改辅助字段 watch(() => ruleForm.value.model, (newVal) => { + if ($route.path.includes('detail') || isFrist.value) { + return + } if (newVal) { ruleForm.value.helpInstruction = '' // 修改规格型号和辅助字段列表 - helpList.value = helpList.value.filter(item => item.model === newVal) + helpList.value = Array.from(new Set(allList.value.filter(item => item.helpInstruction).filter(item => item.equipmentName === ruleForm.value.equipmentName && item.model === newVal).map(item => item.helpInstruction))) } }) // 设备相关,填充数据 watch(() => ruleForm.value, (newVal) => { - if (ruleForm.value.helpInstruction && ruleForm.value.model && ruleForm.value.equipmentName) { + if ($route.path.includes('detail') || isFrist.value) { + return + } + if ((ruleForm.value.helpInstruction && ruleForm.value.model && ruleForm.value.equipmentName)) { const arr = allList.value.filter((item: any) => item.helpInstruction === ruleForm.value.helpInstruction && item.model === ruleForm.value.model && item.equipmentName === ruleForm.value.equipmentName) if (arr.length) { const data = arr[0] ruleForm.value.category = data.category - ruleForm.value.remark = data.remark + // ruleForm.value.remark = data.remark ruleForm.value.technicalTargetList = data.technicalTargetList ruleForm.value.checkCycle = data.checkCycle ruleForm.value.modelId = data.id } } + if ((helpList.value.length === 0 || (helpList.value.length === 1 && helpList.value[0].helpInstruction === '/')) && ruleForm.value.model && ruleForm.value.equipmentName) { + const arr = allList.value.filter((item: any) => item.model === ruleForm.value.model && item.equipmentName === ruleForm.value.equipmentName) + if (arr.length) { + const data = arr[0] + ruleForm.value.category = data.category + // ruleForm.value.remark = data.remark + ruleForm.value.technicalTargetList = data.technicalTargetList + ruleForm.value.checkCycle = data.checkCycle + ruleForm.value.modelId = data.id + ruleForm.value.helpInstruction = '/' + } + } }, { deep: true, // immediate: true, @@ -263,11 +285,17 @@ ruleForm.value.createUserName = userStore.name ruleForm.value.createTime = dayjs().format('YYYY-MM-DD HH:mm:ss') // 创建时间 } + setTimeout(() => { + isFrist.value = false + }, 2000); }) } else { getApprovalDetail({ id: $route.query.id as string }).then((res) => { ruleForm.value = res.data + setTimeout(() => { + isFrist.value = false + }, 2000); // if (ruleForm.value.testTask) { // if (ruleForm.value.testTask.includes(',')) { // testTask.value = ruleForm.value.testTask.split(',') @@ -568,7 +596,7 @@ - + @@ -576,7 +604,7 @@ - + diff --git a/src/views/tested/device/info/components/list.vue b/src/views/tested/device/info/components/list.vue index afe7c62..db7feb1 100644 --- a/src/views/tested/device/info/components/list.vue +++ b/src/views/tested/device/info/components/list.vue @@ -234,7 +234,7 @@ listQuery.model = '' // 修改规格型号和辅助字段列表 const data = allList.value.filter(item => item.equipmentName === newVal) - modelList.value = data + modelList.value = Array.from(new Set(data.filter(item => item.model).map(item => item.model))) } }) // 查询数据 @@ -684,7 +684,7 @@ - + diff --git a/src/api/eqpt/device/model.ts b/src/api/eqpt/device/model.ts index 04da2af..452933c 100644 --- a/src/api/eqpt/device/model.ts +++ b/src/api/eqpt/device/model.ts @@ -19,6 +19,14 @@ data: params, }) } +// 获取设备规格 +export function getModelByname(params: any) { + return request({ + url: '/equipment/model/listModel', + method: 'get', + params, + }) +} // 设备名称列表/equipment/model/listEquipmentName export function getDeviceNameList() { return request({ diff --git a/src/views/tested/device/info/components/edit.vue b/src/views/tested/device/info/components/edit.vue index 24890fb..526a338 100644 --- a/src/views/tested/device/info/components/edit.vue +++ b/src/views/tested/device/info/components/edit.vue @@ -27,6 +27,7 @@ const ruleFormRef2 = ref() // from组件 const statusName = $route.query.statusName as string const title = ref('') +const isFrist = ref(true) // 显示标题 const textMap: { [key: string]: string } = { update: '编辑', @@ -163,43 +164,64 @@ // 规格型号及辅助字段 getModelAllList({}).then((res) => { allList.value = res.data - modelList.value = res.data - helpList.value = res.data.filter((item: any) => item.helpInstruction) + modelList.value = Array.from(new Set(res.data.filter((item: any) => item.model).map((item: any) => item.model))) + helpList.value = Array.from(new Set(res.data.filter((item: any) => item.helpInstruction).map((item: any) => item.helpInstruction))) }) } fetchSelectData() // 监听设备名称下拉框,修改规格型号和辅助字段 watch(() => ruleForm.value.equipmentName, (newVal) => { + if ($route.path.includes('detail') || isFrist.value) { + return + } if (newVal) { ruleForm.value.helpInstruction = '' ruleForm.value.model = '' // 修改规格型号和辅助字段列表 const data = allList.value.filter(item => item.equipmentName === newVal) - modelList.value = data - helpList.value = data.filter(item => item.helpInstruction) + modelList.value = Array.from(new Set(data.filter(item => item.model).map(item => item.model))) + helpList.value = Array.from(new Set(data.filter(item => item.helpInstruction).map(item => item.helpInstruction))) } }) // 监听规格型号下拉框,修改辅助字段 watch(() => ruleForm.value.model, (newVal) => { + if ($route.path.includes('detail') || isFrist.value) { + return + } if (newVal) { ruleForm.value.helpInstruction = '' // 修改规格型号和辅助字段列表 - helpList.value = helpList.value.filter(item => item.model === newVal) + helpList.value = Array.from(new Set(allList.value.filter(item => item.helpInstruction).filter(item => item.equipmentName === ruleForm.value.equipmentName && item.model === newVal).map(item => item.helpInstruction))) } }) // 设备相关,填充数据 watch(() => ruleForm.value, (newVal) => { - if (ruleForm.value.helpInstruction && ruleForm.value.model && ruleForm.value.equipmentName) { + if ($route.path.includes('detail') || isFrist.value) { + return + } + if ((ruleForm.value.helpInstruction && ruleForm.value.model && ruleForm.value.equipmentName)) { const arr = allList.value.filter((item: any) => item.helpInstruction === ruleForm.value.helpInstruction && item.model === ruleForm.value.model && item.equipmentName === ruleForm.value.equipmentName) if (arr.length) { const data = arr[0] ruleForm.value.category = data.category - ruleForm.value.remark = data.remark + // ruleForm.value.remark = data.remark ruleForm.value.technicalTargetList = data.technicalTargetList ruleForm.value.checkCycle = data.checkCycle ruleForm.value.modelId = data.id } } + if ((helpList.value.length === 0 || (helpList.value.length === 1 && helpList.value[0].helpInstruction === '/')) && ruleForm.value.model && ruleForm.value.equipmentName) { + const arr = allList.value.filter((item: any) => item.model === ruleForm.value.model && item.equipmentName === ruleForm.value.equipmentName) + if (arr.length) { + const data = arr[0] + ruleForm.value.category = data.category + // ruleForm.value.remark = data.remark + ruleForm.value.technicalTargetList = data.technicalTargetList + ruleForm.value.checkCycle = data.checkCycle + ruleForm.value.modelId = data.id + ruleForm.value.helpInstruction = '/' + } + } }, { deep: true, // immediate: true, @@ -263,11 +285,17 @@ ruleForm.value.createUserName = userStore.name ruleForm.value.createTime = dayjs().format('YYYY-MM-DD HH:mm:ss') // 创建时间 } + setTimeout(() => { + isFrist.value = false + }, 2000); }) } else { getApprovalDetail({ id: $route.query.id as string }).then((res) => { ruleForm.value = res.data + setTimeout(() => { + isFrist.value = false + }, 2000); // if (ruleForm.value.testTask) { // if (ruleForm.value.testTask.includes(',')) { // testTask.value = ruleForm.value.testTask.split(',') @@ -568,7 +596,7 @@ - + @@ -576,7 +604,7 @@ - + diff --git a/src/views/tested/device/info/components/list.vue b/src/views/tested/device/info/components/list.vue index afe7c62..db7feb1 100644 --- a/src/views/tested/device/info/components/list.vue +++ b/src/views/tested/device/info/components/list.vue @@ -234,7 +234,7 @@ listQuery.model = '' // 修改规格型号和辅助字段列表 const data = allList.value.filter(item => item.equipmentName === newVal) - modelList.value = data + modelList.value = Array.from(new Set(data.filter(item => item.model).map(item => item.model))) } }) // 查询数据 @@ -684,7 +684,7 @@ - + diff --git a/src/views/tested/device/model/components/edit.vue b/src/views/tested/device/model/components/edit.vue index 891c07b..e8fdbb7 100644 --- a/src/views/tested/device/model/components/edit.vue +++ b/src/views/tested/device/model/components/edit.vue @@ -5,7 +5,7 @@ import dayjs from 'dayjs' import tableList from './technology.vue' import { getDictByCode } from '@/api/system/dict' -import { handlerFunApi } from '@/api/eqpt/device/model' +import { getDeviceNameList, getModelAllList, handlerFunApi } from '@/api/eqpt/device/model' import useUserStore from '@/store/modules/user' import { getUserDept } from '@/api/system/user' import { uploadApi } from '@/api/system/notice' @@ -40,11 +40,13 @@ technicalTargetList: [], // 技术指标 updateTime: '', }) // 表单 +// 设备名称验证规则 + const rules = ref({ - equipmentName: [{ required: true, message: '设备名称名称必填', trigger: 'blur' }], - category: [{ required: true, message: '设备分类必选', trigger: 'blur' }], - model: [{ required: true, message: '规格型号必填', trigger: 'blur' }], - checkCycle: [{ required: true, message: '检定周期必填', trigger: 'blur' }], + equipmentName: [{ required: true, message: '设备名称名称必填', trigger: ['blur', 'change'] }], + category: [{ required: true, message: '设备分类必选', trigger: ['blur', 'change'] }], + model: [{ required: true, message: '规格型号必填', trigger: ['blur', 'change'] }], + checkCycle: [{ required: true, message: '检定周期必填', trigger: ['blur', 'change'] }], }) // 表单验证规则 // 弹窗初始化 const initDialog = () => { @@ -76,6 +78,7 @@ $router.back() } const tableRef = ref() + // 保存 const saveForm = async (formEl: FormInstance | undefined) => { if (!formEl) { return } @@ -90,7 +93,10 @@ type: 'warning', }, ).then((res) => { - ruleForm.value.equipmentList = tableRef.value.list + if (!ruleForm.value.helpInstruction) { + ruleForm.value.helpInstruction = '/' + } + ruleForm.value.technicalTargetList = tableRef.value.list if ($route.params.type === 'create') { handlerFunApi('create', ruleForm.value).then((res) => { ElMessage.success('添加成功') @@ -98,6 +104,8 @@ }) } else { + // ruleForm.value.technicalTargetList = tableRef.value.list + console.log(ruleForm.value) handlerFunApi('update', ruleForm.value).then((res) => { ElMessage.success('修改成功') close() @@ -155,6 +163,17 @@ getDictByCode('eqptDeviceType').then((res) => { deviceTypeList.value = res.data }) + // 设备名称 + getDeviceNameList().then((res) => { + console.log(res.data, '设备名称') + deviceNameList.value = res.data + }) + // 规格型号及辅助字段 + getModelAllList({}).then((res) => { + console.log(res.data, '规格型号') + modelList.value = res.data.filter((item: any) => item.model) + helpList.value = res.data.filter((item: any) => item.helpInstruction) + }) } fetchSelect() diff --git a/src/api/eqpt/device/model.ts b/src/api/eqpt/device/model.ts index 04da2af..452933c 100644 --- a/src/api/eqpt/device/model.ts +++ b/src/api/eqpt/device/model.ts @@ -19,6 +19,14 @@ data: params, }) } +// 获取设备规格 +export function getModelByname(params: any) { + return request({ + url: '/equipment/model/listModel', + method: 'get', + params, + }) +} // 设备名称列表/equipment/model/listEquipmentName export function getDeviceNameList() { return request({ diff --git a/src/views/tested/device/info/components/edit.vue b/src/views/tested/device/info/components/edit.vue index 24890fb..526a338 100644 --- a/src/views/tested/device/info/components/edit.vue +++ b/src/views/tested/device/info/components/edit.vue @@ -27,6 +27,7 @@ const ruleFormRef2 = ref() // from组件 const statusName = $route.query.statusName as string const title = ref('') +const isFrist = ref(true) // 显示标题 const textMap: { [key: string]: string } = { update: '编辑', @@ -163,43 +164,64 @@ // 规格型号及辅助字段 getModelAllList({}).then((res) => { allList.value = res.data - modelList.value = res.data - helpList.value = res.data.filter((item: any) => item.helpInstruction) + modelList.value = Array.from(new Set(res.data.filter((item: any) => item.model).map((item: any) => item.model))) + helpList.value = Array.from(new Set(res.data.filter((item: any) => item.helpInstruction).map((item: any) => item.helpInstruction))) }) } fetchSelectData() // 监听设备名称下拉框,修改规格型号和辅助字段 watch(() => ruleForm.value.equipmentName, (newVal) => { + if ($route.path.includes('detail') || isFrist.value) { + return + } if (newVal) { ruleForm.value.helpInstruction = '' ruleForm.value.model = '' // 修改规格型号和辅助字段列表 const data = allList.value.filter(item => item.equipmentName === newVal) - modelList.value = data - helpList.value = data.filter(item => item.helpInstruction) + modelList.value = Array.from(new Set(data.filter(item => item.model).map(item => item.model))) + helpList.value = Array.from(new Set(data.filter(item => item.helpInstruction).map(item => item.helpInstruction))) } }) // 监听规格型号下拉框,修改辅助字段 watch(() => ruleForm.value.model, (newVal) => { + if ($route.path.includes('detail') || isFrist.value) { + return + } if (newVal) { ruleForm.value.helpInstruction = '' // 修改规格型号和辅助字段列表 - helpList.value = helpList.value.filter(item => item.model === newVal) + helpList.value = Array.from(new Set(allList.value.filter(item => item.helpInstruction).filter(item => item.equipmentName === ruleForm.value.equipmentName && item.model === newVal).map(item => item.helpInstruction))) } }) // 设备相关,填充数据 watch(() => ruleForm.value, (newVal) => { - if (ruleForm.value.helpInstruction && ruleForm.value.model && ruleForm.value.equipmentName) { + if ($route.path.includes('detail') || isFrist.value) { + return + } + if ((ruleForm.value.helpInstruction && ruleForm.value.model && ruleForm.value.equipmentName)) { const arr = allList.value.filter((item: any) => item.helpInstruction === ruleForm.value.helpInstruction && item.model === ruleForm.value.model && item.equipmentName === ruleForm.value.equipmentName) if (arr.length) { const data = arr[0] ruleForm.value.category = data.category - ruleForm.value.remark = data.remark + // ruleForm.value.remark = data.remark ruleForm.value.technicalTargetList = data.technicalTargetList ruleForm.value.checkCycle = data.checkCycle ruleForm.value.modelId = data.id } } + if ((helpList.value.length === 0 || (helpList.value.length === 1 && helpList.value[0].helpInstruction === '/')) && ruleForm.value.model && ruleForm.value.equipmentName) { + const arr = allList.value.filter((item: any) => item.model === ruleForm.value.model && item.equipmentName === ruleForm.value.equipmentName) + if (arr.length) { + const data = arr[0] + ruleForm.value.category = data.category + // ruleForm.value.remark = data.remark + ruleForm.value.technicalTargetList = data.technicalTargetList + ruleForm.value.checkCycle = data.checkCycle + ruleForm.value.modelId = data.id + ruleForm.value.helpInstruction = '/' + } + } }, { deep: true, // immediate: true, @@ -263,11 +285,17 @@ ruleForm.value.createUserName = userStore.name ruleForm.value.createTime = dayjs().format('YYYY-MM-DD HH:mm:ss') // 创建时间 } + setTimeout(() => { + isFrist.value = false + }, 2000); }) } else { getApprovalDetail({ id: $route.query.id as string }).then((res) => { ruleForm.value = res.data + setTimeout(() => { + isFrist.value = false + }, 2000); // if (ruleForm.value.testTask) { // if (ruleForm.value.testTask.includes(',')) { // testTask.value = ruleForm.value.testTask.split(',') @@ -568,7 +596,7 @@ - + @@ -576,7 +604,7 @@ - + diff --git a/src/views/tested/device/info/components/list.vue b/src/views/tested/device/info/components/list.vue index afe7c62..db7feb1 100644 --- a/src/views/tested/device/info/components/list.vue +++ b/src/views/tested/device/info/components/list.vue @@ -234,7 +234,7 @@ listQuery.model = '' // 修改规格型号和辅助字段列表 const data = allList.value.filter(item => item.equipmentName === newVal) - modelList.value = data + modelList.value = Array.from(new Set(data.filter(item => item.model).map(item => item.model))) } }) // 查询数据 @@ -684,7 +684,7 @@ - + diff --git a/src/views/tested/device/model/components/edit.vue b/src/views/tested/device/model/components/edit.vue index 891c07b..e8fdbb7 100644 --- a/src/views/tested/device/model/components/edit.vue +++ b/src/views/tested/device/model/components/edit.vue @@ -5,7 +5,7 @@ import dayjs from 'dayjs' import tableList from './technology.vue' import { getDictByCode } from '@/api/system/dict' -import { handlerFunApi } from '@/api/eqpt/device/model' +import { getDeviceNameList, getModelAllList, handlerFunApi } from '@/api/eqpt/device/model' import useUserStore from '@/store/modules/user' import { getUserDept } from '@/api/system/user' import { uploadApi } from '@/api/system/notice' @@ -40,11 +40,13 @@ technicalTargetList: [], // 技术指标 updateTime: '', }) // 表单 +// 设备名称验证规则 + const rules = ref({ - equipmentName: [{ required: true, message: '设备名称名称必填', trigger: 'blur' }], - category: [{ required: true, message: '设备分类必选', trigger: 'blur' }], - model: [{ required: true, message: '规格型号必填', trigger: 'blur' }], - checkCycle: [{ required: true, message: '检定周期必填', trigger: 'blur' }], + equipmentName: [{ required: true, message: '设备名称名称必填', trigger: ['blur', 'change'] }], + category: [{ required: true, message: '设备分类必选', trigger: ['blur', 'change'] }], + model: [{ required: true, message: '规格型号必填', trigger: ['blur', 'change'] }], + checkCycle: [{ required: true, message: '检定周期必填', trigger: ['blur', 'change'] }], }) // 表单验证规则 // 弹窗初始化 const initDialog = () => { @@ -76,6 +78,7 @@ $router.back() } const tableRef = ref() + // 保存 const saveForm = async (formEl: FormInstance | undefined) => { if (!formEl) { return } @@ -90,7 +93,10 @@ type: 'warning', }, ).then((res) => { - ruleForm.value.equipmentList = tableRef.value.list + if (!ruleForm.value.helpInstruction) { + ruleForm.value.helpInstruction = '/' + } + ruleForm.value.technicalTargetList = tableRef.value.list if ($route.params.type === 'create') { handlerFunApi('create', ruleForm.value).then((res) => { ElMessage.success('添加成功') @@ -98,6 +104,8 @@ }) } else { + // ruleForm.value.technicalTargetList = tableRef.value.list + console.log(ruleForm.value) handlerFunApi('update', ruleForm.value).then((res) => { ElMessage.success('修改成功') close() @@ -155,6 +163,17 @@ getDictByCode('eqptDeviceType').then((res) => { deviceTypeList.value = res.data }) + // 设备名称 + getDeviceNameList().then((res) => { + console.log(res.data, '设备名称') + deviceNameList.value = res.data + }) + // 规格型号及辅助字段 + getModelAllList({}).then((res) => { + console.log(res.data, '规格型号') + modelList.value = res.data.filter((item: any) => item.model) + helpList.value = res.data.filter((item: any) => item.helpInstruction) + }) } fetchSelect() diff --git a/src/views/tested/device/model/components/list.vue b/src/views/tested/device/model/components/list.vue index 30b1789..0cfef0f 100644 --- a/src/views/tested/device/model/components/list.vue +++ b/src/views/tested/device/model/components/list.vue @@ -2,7 +2,7 @@ @@ -220,12 +219,12 @@ - + - +