refactor(equipment): 优化设备台账表单结构并更新质管检验选项
- 移除设备类型、供应商、单位及税务相关价格计算字段
- 删除税务计算工具函数和相关表单验证规则
- 简化设备台账表单布局减少冗余字段
- 更新保养任务表单日期时间标签为日期/时间格式
- 将质检过程检验和原料检验结果选项改为已检/未检
- 优化原料检验表单的条件渲染和组件结构
| | |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="设备类型" prop="type"> |
| | | <el-select |
| | | v-model="form.type" |
| | | placeholder="请选择或输入设备类型" |
| | | clearable |
| | | filterable |
| | | allow-create |
| | | default-first-option |
| | | style="width: 100%" |
| | | @change="handleDeviceTypeChange" |
| | | > |
| | | <el-option |
| | | v-for="item in deviceTypeOptions" |
| | | :key="item" |
| | | :label="item" |
| | | :value="item" |
| | | /> |
| | | </el-select> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="供应商" prop="supplierName"> |
| | | <el-input v-model="form.supplierName" placeholder="请输入供应商" /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="存放位置" prop="storageLocation"> |
| | | <el-input v-model="form.storageLocation" placeholder="请输入存放位置" /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="单位" prop="unit"> |
| | | <el-input v-model="form.unit" placeholder="请输入单位" /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | |
| | | v-model="form.number" |
| | | disabled |
| | | placeholder="请输入数量" |
| | | @change="mathNum" |
| | | /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="含税单价" prop="taxIncludingPriceUnit"> |
| | | <el-input-number :step="0.01" :min="0" style="width: 100%" |
| | | v-model="form.taxIncludingPriceUnit" |
| | | placeholder="请输入含税单价" |
| | | maxlength="10" |
| | | @change="mathNum" |
| | | /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="含税总价" prop="taxIncludingPriceTotal"> |
| | | <el-input |
| | | v-model="form.taxIncludingPriceTotal" |
| | | placeholder="自动生成" |
| | | type="number" |
| | | disabled |
| | | /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="税率(%)" prop="taxRate"> |
| | | <!-- <el-input |
| | | v-model="form.taxRate" |
| | | placeholder="请输入税率" |
| | | type="number" |
| | | > |
| | | <template #append> % </template> |
| | | </el-input> --> |
| | | <el-select |
| | | v-model="form.taxRate" |
| | | placeholder="请选择" |
| | | clearable |
| | | @change="mathNum" |
| | | > |
| | | <el-option label="1" :value="1" /> |
| | | <el-option label="6" :value="6" /> |
| | | <el-option label="13" :value="13" /> |
| | | </el-select> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="不含税总价" prop="unTaxIncludingPriceTotal"> |
| | | <el-input |
| | | v-model="form.unTaxIncludingPriceTotal" |
| | | placeholder="自动生成" |
| | | type="number" |
| | | disabled |
| | | /> |
| | | </el-form-item> |
| | | </el-col> |
| | |
| | | // import useUserStore from "@/store/modules/user"; |
| | | import { getLedgerById } from "@/api/equipmentManagement/ledger"; |
| | | import dayjs from "dayjs"; |
| | | import { |
| | | calculateTaxIncludeTotalPrice, |
| | | calculateTaxExclusiveTotalPrice, |
| | | } from "@/utils/summarizeTable"; |
| | | import { ElMessage } from "element-plus"; |
| | | import {ref} from "vue"; |
| | | |
| | | defineOptions({ |
| | |
| | | }); |
| | | const formRef = ref(null); |
| | | const operationType = ref(''); |
| | | // 设备类型固定选项 |
| | | const deviceTypeOptions = ref([ |
| | | '生产设备', |
| | | '办公设备', |
| | | '检测设备', |
| | | '运输设备', |
| | | '其他设备' |
| | | ]); |
| | | const formRules = { |
| | | deviceName: [{ required: true, trigger: "blur", message: "请输入" }], |
| | | deviceModel: [{ required: true, trigger: "blur", message: "请输入" }], |
| | | type: [{ required: true, trigger: "change", message: "请选择或输入设备类型" }], |
| | | supplierName: [{ required: true, trigger: "blur", message: "请输入" }], |
| | | unit: [{ required: true, trigger: "blur", message: "请输入" }], |
| | | number: [{ required: true, trigger: "blur", message: "请输入" }], |
| | | taxIncludingPriceUnit: [{ required: true, trigger: "blur", message: "请输入" }], |
| | | taxRate: [{ required: true, trigger: "change", message: "请输入" }], |
| | | planRuntimeTime: [{ required: true, trigger: "change", message: "请选择" }], |
| | | annualDepreciationAmount: [ |
| | | { |
| | |
| | | deviceName: undefined, // 设备名称 |
| | | deviceModel: undefined, // 规格型号 |
| | | deviceBrand: undefined, // 设备品牌 |
| | | type: undefined, // 设备类型 |
| | | supplierName: undefined, // 供应商 |
| | | storageLocation: undefined, // 存放位置 |
| | | isDepr: 2, // 是否启用折旧 1-是 2-否 |
| | | annualDepreciationAmount: undefined, // 每年折旧金额 |
| | | unit: undefined, // 单位 |
| | | number: 1, // 数量 |
| | | taxIncludingPriceUnit: undefined, // 含税单价 |
| | | taxIncludingPriceTotal: undefined, // 含税总价 |
| | | taxRate: undefined, // 税率 |
| | | unTaxIncludingPriceTotal: undefined, // 不含税总价 |
| | | // createUser: useUserStore().nickName, // 录入人 |
| | | createTime: dayjs().format("YYYY-MM-DD HH:mm:ss"), // 录入日期 |
| | | planRuntimeTime: dayjs().format("YYYY-MM-DD"), // 录入日期 |
| | |
| | | form.deviceName = data.deviceName; |
| | | form.deviceModel = data.deviceModel; |
| | | form.deviceBrand = data.deviceBrand; |
| | | form.type = data.type; |
| | | form.supplierName = data.supplierName; |
| | | form.storageLocation = data.storageLocation; |
| | | form.isDepr = data.isDepr; |
| | | form.annualDepreciationAmount = data.annualDepreciationAmount; |
| | | form.unit = data.unit; |
| | | form.number = 1; |
| | | form.taxIncludingPriceUnit = data.taxIncludingPriceUnit; |
| | | form.taxIncludingPriceTotal = data.taxIncludingPriceTotal; |
| | | form.taxRate = data.taxRate; |
| | | form.unTaxIncludingPriceTotal = data.unTaxIncludingPriceTotal; |
| | | form.createTime = data.createTime; |
| | | // 预计运行时间:后端返回后转为 YYYY-MM-DD 以便日期选择器正确展示 |
| | | if (data.planRuntimeTime) { |
| | |
| | | } else { |
| | | form.planRuntimeTime = undefined; |
| | | } |
| | | } |
| | | }; |
| | | |
| | | const handleDeviceTypeChange = (value) => { |
| | | // 如果输入的新值不在固定选项中,则添加到选项列表 |
| | | if (value && !deviceTypeOptions.value.includes(value)) { |
| | | deviceTypeOptions.value.push(value); |
| | | } |
| | | }; |
| | | |
| | | const mathNum = () => { |
| | | if (!form.taxIncludingPriceUnit) { |
| | | ElMessage.error("请输入单价"); |
| | | return; |
| | | } |
| | | form.taxIncludingPriceTotal = calculateTaxIncludeTotalPrice( |
| | | form.taxIncludingPriceUnit, |
| | | form.number |
| | | ); |
| | | if (form.taxRate) { |
| | | form.unTaxIncludingPriceTotal = calculateTaxExclusiveTotalPrice( |
| | | form.taxIncludingPriceTotal, |
| | | form.taxRate |
| | | ); |
| | | } |
| | | }; |
| | | |
| | |
| | | resetFormAndValidate, |
| | | formRef, |
| | | }); |
| | | </script> |
| | | </script> |
| | |
| | | </el-form-item> |
| | | <el-form-item label="规格型号"> |
| | | <el-input |
| | | v-model="filters.deviceModel" |
| | | style="width: 240px" |
| | | placeholder="请输入规格型号" |
| | | clearable |
| | | @change="getTableData" |
| | | /> |
| | | </el-form-item> |
| | | <el-form-item label="供应商"> |
| | | <el-input |
| | | v-model="filters.supplierName" |
| | | style="width: 240px" |
| | | placeholder="请输入供应商" |
| | | clearable |
| | | @change="getTableData" |
| | | v-model="filters.deviceModel" |
| | | style="width: 240px" |
| | | placeholder="请输入规格型号" |
| | | clearable |
| | | @change="getTableData" |
| | | /> |
| | | </el-form-item> |
| | | <el-form-item label="录入日期:"> |
| | | <el-date-picker v-model="filters.entryDate" value-format="YYYY-MM-DD" format="YYYY-MM-DD" type="daterange" |
| | | placeholder="请选择" clearable @change="changeDaterange" /> |
| | | <el-date-picker |
| | | v-model="filters.entryDate" |
| | | value-format="YYYY-MM-DD" |
| | | format="YYYY-MM-DD" |
| | | type="daterange" |
| | | placeholder="请选择" |
| | | clearable |
| | | @change="changeDaterange" |
| | | /> |
| | | </el-form-item> |
| | | <el-form-item> |
| | | <el-button type="primary" @click="getTableData">搜索</el-button> |
| | |
| | | </div> |
| | | <Modal ref="modalRef" @success="getTableData"></Modal> |
| | | <el-dialog v-model="qrDialogVisible" title="二维码" width="300px" draggable> |
| | | <div style="text-align:center;"> |
| | | <img :src="qrCodeUrl" alt="二维码" style="width:200px;height:200px;" /> |
| | | <div style="margin:10px 0;"> |
| | | <el-button type="primary" @click="downloadQRCode">下载二维码图片</el-button> |
| | | <div style="text-align: center"> |
| | | <img |
| | | :src="qrCodeUrl" |
| | | alt="二维码" |
| | | style="width: 200px; height: 200px" |
| | | /> |
| | | <div style="margin: 10px 0"> |
| | | <el-button type="primary" @click="downloadQRCode" |
| | | >下载二维码图片</el-button |
| | | > |
| | | </div> |
| | | </div> |
| | | </el-dialog> |
| | |
| | | label: "设备品牌", |
| | | prop: "deviceBrand", |
| | | }, |
| | | { |
| | | label: "设备类型", |
| | | prop: "type", |
| | | }, |
| | | { |
| | | label: "供应商", |
| | | prop: "supplierName", |
| | | }, |
| | | // { |
| | | // label: "设备类型", |
| | | // prop: "type", |
| | | // }, |
| | | // { |
| | | // label: "供应商", |
| | | // prop: "supplierName", |
| | | // }, |
| | | { |
| | | label: "存放位置", |
| | | prop: "storageLocation", |
| | |
| | | label: "录入日期", |
| | | prop: "createTime", |
| | | formatData: (v) => { |
| | | if (!v) return ''; |
| | | if (!v) return ""; |
| | | // 如果包含时分秒,只取日期部分 |
| | | if (v.includes(' ')) { |
| | | return v.split(' ')[0]; |
| | | if (v.includes(" ")) { |
| | | return v.split(" ")[0]; |
| | | } |
| | | return v; |
| | | }, |
| | | }, |
| | | { |
| | | dataType: "action", |
| | | label: "操作", |
| | | align: "center", |
| | | fixed: 'right', |
| | | width: 150, |
| | | operation: [ |
| | | { |
| | | name: "编辑", |
| | | clickFun: (row) => { |
| | | edit(row.id) |
| | | }, |
| | | }, |
| | | { |
| | | name: "生成二维码", |
| | | clickFun: (row) => { |
| | | showQRCode(row) |
| | | }, |
| | | }, |
| | | ], |
| | | }, |
| | | { |
| | | dataType: "action", |
| | | label: "操作", |
| | | align: "center", |
| | | fixed: "right", |
| | | width: 150, |
| | | operation: [ |
| | | { |
| | | name: "编辑", |
| | | clickFun: (row) => { |
| | | edit(row.id); |
| | | }, |
| | | }, |
| | | { |
| | | name: "生成二维码", |
| | | clickFun: (row) => { |
| | | showQRCode(row); |
| | | }, |
| | | }, |
| | | ], |
| | | }, |
| | | ] |
| | | ); |
| | | |
| | |
| | | }; |
| | | const changePage = ({ page, limit }) => { |
| | | pagination.currentPage = page; |
| | | pagination.pageSize = limit; |
| | | pagination.pageSize = limit; |
| | | onCurrentChange(page); |
| | | }; |
| | | const deleteRow = (id) => { |
| | |
| | | |
| | | const showQRCode = async (row) => { |
| | | // 直接使用URL,不要用JSON.stringify包装 |
| | | const qrContent = proxy.javaApi + '/device-info?deviceId=' + row.id; |
| | | const qrContent = proxy.javaApi + "/device-info?deviceId=" + row.id; |
| | | qrCodeUrl.value = await QRCode.toDataURL(qrContent); |
| | | qrRowData.value = row; |
| | | qrDialogVisible.value = true; |
| | |
| | | <el-form :model="filters" :inline="true"> |
| | | <el-form-item label="设备名称"> |
| | | <el-input |
| | | v-model="filters.deviceName" |
| | | style="width: 240px" |
| | | placeholder="请输入设备名称" |
| | | clearable |
| | | :prefix-icon="Search" |
| | | @change="getTableData" |
| | | v-model="filters.deviceName" |
| | | style="width: 240px" |
| | | placeholder="请输入设备名称" |
| | | clearable |
| | | :prefix-icon="Search" |
| | | @change="getTableData" |
| | | /> |
| | | </el-form-item> |
| | | <el-form-item label="规格型号"> |
| | | <el-input |
| | | v-model="filters.deviceModel" |
| | | style="width: 240px" |
| | | placeholder="请选择规格型号" |
| | | clearable |
| | | :prefix-icon="Search" |
| | | @change="getTableData" |
| | | v-model="filters.deviceModel" |
| | | style="width: 240px" |
| | | placeholder="请选择规格型号" |
| | | clearable |
| | | :prefix-icon="Search" |
| | | @change="getTableData" |
| | | /> |
| | | </el-form-item> |
| | | <el-form-item label="故障现象"> |
| | | <el-input |
| | | v-model="filters.remark" |
| | | style="width: 240px" |
| | | placeholder="请输入故障现象" |
| | | clearable |
| | | :prefix-icon="Search" |
| | | @change="getTableData" |
| | | v-model="filters.remark" |
| | | style="width: 240px" |
| | | placeholder="请输入故障现象" |
| | | clearable |
| | | :prefix-icon="Search" |
| | | @change="getTableData" |
| | | /> |
| | | </el-form-item> |
| | | <el-form-item label="维修人"> |
| | | <el-input |
| | | v-model="filters.maintenanceName" |
| | | style="width: 240px" |
| | | placeholder="请输入维修人" |
| | | clearable |
| | | :prefix-icon="Search" |
| | | @change="getTableData" |
| | | v-model="filters.maintenanceName" |
| | | style="width: 240px" |
| | | placeholder="请输入维修人" |
| | | clearable |
| | | :prefix-icon="Search" |
| | | @change="getTableData" |
| | | /> |
| | | </el-form-item> |
| | | <el-form-item label="报修日期"> |
| | | <el-date-picker |
| | | v-model="filters.repairTimeStr" |
| | | type="date" |
| | | placeholder="请选择报修日期" |
| | | size="default" |
| | | @change="(date) => handleDateChange(date,2)" |
| | | v-model="filters.repairTimeStr" |
| | | type="date" |
| | | placeholder="请选择报修日期" |
| | | size="default" |
| | | @change="(date) => handleDateChange(date, 2)" |
| | | /> |
| | | </el-form-item> |
| | | <el-form-item label="维修日期"> |
| | | <el-date-picker |
| | | v-model="filters.maintenanceTimeStr" |
| | | type="date" |
| | | placeholder="请选择维修日期" |
| | | size="default" |
| | | @change="(date) => handleDateChange(date,1)" |
| | | v-model="filters.maintenanceTimeStr" |
| | | type="date" |
| | | placeholder="请选择维修日期" |
| | | size="default" |
| | | @change="(date) => handleDateChange(date, 1)" |
| | | /> |
| | | </el-form-item> |
| | | <el-form-item> |
| | |
| | | <el-button type="success" icon="Van" @click="addRepair"> |
| | | 新增报修 |
| | | </el-button> |
| | | <el-button @click="handleOut"> |
| | | 导出 |
| | | </el-button> |
| | | <el-button @click="handleOut"> 导出 </el-button> |
| | | <el-button |
| | | type="danger" |
| | | icon="Delete" |
| | |
| | | </div> |
| | | </div> |
| | | <PIMTable |
| | | rowKey="id" |
| | | isSelection |
| | | :column="columns" |
| | | :tableData="dataList" |
| | | :page="{ |
| | | rowKey="id" |
| | | isSelection |
| | | :column="columns" |
| | | :tableData="dataList" |
| | | :page="{ |
| | | current: pagination.currentPage, |
| | | size: pagination.pageSize, |
| | | total: pagination.total, |
| | | }" |
| | | @selection-change="handleSelectionChange" |
| | | @pagination="changePage" |
| | | @selection-change="handleSelectionChange" |
| | | @pagination="changePage" |
| | | > |
| | | <template #statusRef="{ row }"> |
| | | <el-tag v-if="row.status === 2" type="danger">失败</el-tag> |
| | |
| | | > |
| | | 编辑 |
| | | </el-button> |
| | | <el-button |
| | | type="info" |
| | | link |
| | | @click="viewAttachments(row)" |
| | | > |
| | | <el-button type="info" link @click="viewAttachments(row)"> |
| | | 查看附件 |
| | | </el-button> |
| | | <el-button |
| | |
| | | <el-button |
| | | type="danger" |
| | | link |
| | | :disabled="row.status === 1" |
| | | :disabled="row.status === 1 && !isAdmin" |
| | | @click="delRepairByIds(row.id)" |
| | | > |
| | | 删除 |
| | |
| | | </template> |
| | | </PIMTable> |
| | | </div> |
| | | <RepairModal ref="repairModalRef" @ok="getTableData"/> |
| | | <MaintainModal ref="maintainModalRef" @ok="getTableData"/> |
| | | <RepairModal ref="repairModalRef" @ok="getTableData" /> |
| | | <MaintainModal ref="maintainModalRef" @ok="getTableData" /> |
| | | <FileListDialog |
| | | ref="fileListDialogRef" |
| | | v-model="fileDialogVisible" |
| | |
| | | |
| | | <script setup> |
| | | import { onMounted, getCurrentInstance, computed } from "vue"; |
| | | import {usePaginationApi} from "@/hooks/usePaginationApi"; |
| | | import {getRepairPage, delRepair, getRepairById} from "@/api/equipmentManagement/repair"; |
| | | import { usePaginationApi } from "@/hooks/usePaginationApi"; |
| | | import { |
| | | getRepairPage, |
| | | delRepair, |
| | | getRepairById, |
| | | } from "@/api/equipmentManagement/repair"; |
| | | import RepairModal from "./Modal/RepairModal.vue"; |
| | | import {ElMessageBox, ElMessage} from "element-plus"; |
| | | import { ElMessageBox, ElMessage } from "element-plus"; |
| | | import dayjs from "dayjs"; |
| | | import MaintainModal from "./Modal/MaintainModal.vue"; |
| | | import FileListDialog from "@/components/Dialog/FileListDialog.vue"; |
| | | import useUserStore from "@/store/modules/user"; |
| | | import auth from "@/plugins/auth"; |
| | | |
| | | defineOptions({ |
| | | name: "设备报修", |
| | | }); |
| | | |
| | | const {proxy} = getCurrentInstance(); |
| | | const { proxy } = getCurrentInstance(); |
| | | const userStore = useUserStore(); |
| | | |
| | | // 模态框实例 |
| | | const repairModalRef = ref(); |
| | |
| | | resetFilters, |
| | | onCurrentChange, |
| | | } = usePaginationApi( |
| | | getRepairPage, |
| | | getRepairPage, |
| | | { |
| | | deviceName: undefined, |
| | | deviceModel: undefined, |
| | | remark: undefined, |
| | | maintenanceName: undefined, |
| | | repairTimeStr: undefined, |
| | | maintenanceTimeStr: undefined, |
| | | }, |
| | | [ |
| | | { |
| | | deviceName: undefined, |
| | | deviceModel: undefined, |
| | | remark: undefined, |
| | | maintenanceName: undefined, |
| | | repairTimeStr: undefined, |
| | | maintenanceTimeStr: undefined, |
| | | label: "设备名称", |
| | | align: "center", |
| | | prop: "deviceName", |
| | | }, |
| | | [ |
| | | { |
| | | label: "设备名称", |
| | | align: "center", |
| | | prop: "deviceName", |
| | | }, |
| | | { |
| | | label: "规格型号", |
| | | align: "center", |
| | | prop: "deviceModel", |
| | | }, |
| | | { |
| | | label: "报修日期", |
| | | align: "center", |
| | | prop: "repairTime", |
| | | formatData: (cell) => dayjs(cell).format("YYYY-MM-DD"), |
| | | }, |
| | | { |
| | | label: "报修人", |
| | | align: "center", |
| | | prop: "repairName", |
| | | }, |
| | | { |
| | | label: "故障现象", |
| | | align: "center", |
| | | prop: "remark", |
| | | }, |
| | | { |
| | | label: "维修人", |
| | | align: "center", |
| | | prop: "maintenanceName", |
| | | }, |
| | | { |
| | | label: "维修结果", |
| | | align: "center", |
| | | prop: "maintenanceResult", |
| | | }, |
| | | { |
| | | label: "维修日期", |
| | | align: "center", |
| | | prop: "maintenanceTime", |
| | | formatData: (cell) => (cell ? dayjs(cell).format("YYYY-MM-DD") : ""), |
| | | }, |
| | | { |
| | | label: "状态", |
| | | align: "center", |
| | | prop: "status", |
| | | dataType: "slot", |
| | | slot: "statusRef", |
| | | }, |
| | | { |
| | | fixed: "right", |
| | | label: "操作", |
| | | dataType: "slot", |
| | | slot: "operation", |
| | | align: "center", |
| | | width: "360px", |
| | | }, |
| | | ] |
| | | { |
| | | label: "规格型号", |
| | | align: "center", |
| | | prop: "deviceModel", |
| | | }, |
| | | { |
| | | label: "报修日期", |
| | | align: "center", |
| | | prop: "repairTime", |
| | | formatData: (cell) => dayjs(cell).format("YYYY-MM-DD"), |
| | | }, |
| | | { |
| | | label: "报修人", |
| | | align: "center", |
| | | prop: "repairName", |
| | | }, |
| | | { |
| | | label: "故障现象", |
| | | align: "center", |
| | | prop: "remark", |
| | | }, |
| | | { |
| | | label: "维修人", |
| | | align: "center", |
| | | prop: "maintenanceName", |
| | | }, |
| | | { |
| | | label: "维修结果", |
| | | align: "center", |
| | | prop: "maintenanceResult", |
| | | }, |
| | | { |
| | | label: "维修日期", |
| | | align: "center", |
| | | prop: "maintenanceTime", |
| | | formatData: (cell) => (cell ? dayjs(cell).format("YYYY-MM-DD") : ""), |
| | | }, |
| | | { |
| | | label: "状态", |
| | | align: "center", |
| | | prop: "status", |
| | | dataType: "slot", |
| | | slot: "statusRef", |
| | | }, |
| | | { |
| | | fixed: "right", |
| | | label: "操作", |
| | | dataType: "slot", |
| | | slot: "operation", |
| | | align: "center", |
| | | width: "360px", |
| | | }, |
| | | ] |
| | | ); |
| | | |
| | | // type === 1 维修 2报修间 |
| | | const handleDateChange = (value, type) => { |
| | | filters.maintenanceTimeStr = null |
| | | filters.c = null |
| | | filters.maintenanceTimeStr = null; |
| | | filters.c = null; |
| | | if (type === 1) { |
| | | if (value) { |
| | | filters.maintenanceTimeStr = dayjs(value).format("YYYY-MM-DD"); |
| | |
| | | multipleList.value = selectionList; |
| | | }; |
| | | |
| | | // 检查选中的记录中是否有完结状态的 |
| | | // 是否是管理员 |
| | | const isAdmin = computed(() => auth.hasRole("admin")); |
| | | |
| | | // 检查选中的记录中是否有完结状态的(管理员可以删除完结状态的记录) |
| | | const hasFinishedStatus = computed(() => { |
| | | return multipleList.value.some(item => item.status === 1) |
| | | }) |
| | | if (isAdmin.value) return false; |
| | | return multipleList.value.some((item) => item.status === 1); |
| | | }); |
| | | |
| | | // 新增报修 |
| | | const addRepair = () => { |
| | |
| | | maintainModalRef.value.open(row.id, row); |
| | | }; |
| | | |
| | | const changePage = ({page, limit}) => { |
| | | const changePage = ({ page, limit }) => { |
| | | pagination.currentPage = page; |
| | | pagination.pageSize = limit; |
| | | onCurrentChange(page); |
| | |
| | | |
| | | // 单行删除 |
| | | const delRepairByIds = async (ids) => { |
| | | // 检查是否有完结状态的记录 |
| | | // 检查是否有完结状态的记录(管理员可以删除) |
| | | const idsArray = Array.isArray(ids) ? ids : [ids]; |
| | | const hasFinished = idsArray.some(id => { |
| | | const record = dataList.value.find(item => item.id === id); |
| | | const hasFinished = idsArray.some((id) => { |
| | | const record = dataList.value.find((item) => item.id === id); |
| | | return record && record.status === 1; |
| | | }); |
| | | |
| | | if (hasFinished) { |
| | | ElMessage.warning('不能删除状态为完结的记录'); |
| | | if (hasFinished && !isAdmin.value) { |
| | | ElMessage.warning("不能删除状态为完结的记录"); |
| | | return; |
| | | } |
| | | |
| | |
| | | cancelButtonText: "取消", |
| | | type: "warning", |
| | | }).then(async () => { |
| | | const {code} = await delRepair(ids); |
| | | const { code } = await delRepair(ids); |
| | | if (code === 200) { |
| | | ElMessage.success("删除成功"); |
| | | getTableData(); |
| | |
| | | cancelButtonText: "取消", |
| | | type: "warning", |
| | | }) |
| | | .then(() => { |
| | | proxy.download("/device/repair/export", {}, "设备报修.xlsx"); |
| | | }) |
| | | .catch(() => { |
| | | ElMessage.info("已取消"); |
| | | }); |
| | | .then(() => { |
| | | proxy.download("/device/repair/export", {}, "设备报修.xlsx"); |
| | | }) |
| | | .catch(() => { |
| | | ElMessage.info("已取消"); |
| | | }); |
| | | }; |
| | | |
| | | onMounted(() => { |
| | |
| | | <template> |
| | | <FormDialog |
| | | v-model="dialogVisitable" |
| | | :title="operationType === 'add' ? '新增保养任务' : '编辑保养任务'" |
| | | width="800px" |
| | | :operation-type="operationType" |
| | | @confirm="submitForm" |
| | | @cancel="cancel" |
| | | @close="cancel" |
| | | > |
| | | <el-form ref="formRef" :model="form" :rules="rules" label-width="120px"> |
| | | <el-row> |
| | | <el-col :span="12"> |
| | | <el-form-item label="任务名称" prop="taskName"> |
| | | <el-input v-model="form.taskName" placeholder="请输入任务名称" clearable /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="设备名称" prop="deviceIds"> |
| | | <el-select |
| | | v-model="form.deviceIds" |
| | | multiple |
| | | filterable |
| | | placeholder="请选择设备" |
| | | @change="handleDeviceChange" |
| | | > |
| | | <el-option |
| | | v-for="(item, index) in deviceOptions" |
| | | :key="index" |
| | | :label="item.deviceName" |
| | | :value="item.id" |
| | | ></el-option> |
| | | </el-select> |
| | | </el-form-item> |
| | | </el-col> |
| | | |
| | | <el-col :span="12"> |
| | | <el-form-item label="录入人" prop="inspector"> |
| | | <el-select |
| | | v-model="form.inspector" |
| | | filterable |
| | | default-first-option |
| | | :reserve-keyword="false" |
| | | placeholder="请选择" |
| | | clearable |
| | | > |
| | | <el-option |
| | | v-for="item in userList" |
| | | :label="item.nickName" |
| | | :value="item.userId" |
| | | :key="item.userId" |
| | | /> |
| | | </el-select> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="登记时间" prop="registrationDate"> |
| | | <el-date-picker |
| | | v-model="form.registrationDate" |
| | | type="date" |
| | | placeholder="选择登记日期" |
| | | format="YYYY-MM-DD" |
| | | value-format="YYYY-MM-DD" |
| | | style="width: 100%" |
| | | /> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row> |
| | | <el-col :span="12"> |
| | | <el-form-item label="任务频率" prop="frequencyType"> |
| | | <el-select v-model="form.frequencyType" placeholder="请选择" clearable> |
| | | <el-option label="每日" value="DAILY"/> |
| | | <el-option label="每周" value="WEEKLY"/> |
| | | <el-option label="每月" value="MONTHLY"/> |
| | | <el-option label="季度" value="QUARTERLY"/> |
| | | </el-select> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12" v-if="form.frequencyType === 'DAILY' && form.frequencyType"> |
| | | <el-form-item label="日期" prop="frequencyDetail"> |
| | | <el-time-picker v-model="form.frequencyDetail" placeholder="选择时间" format="HH:mm" |
| | | value-format="HH:mm" /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12" v-if="form.frequencyType === 'WEEKLY' && form.frequencyType"> |
| | | <el-form-item label="日期" prop="frequencyDetail"> |
| | | <el-select v-model="form.week" placeholder="请选择" clearable style="width: 50%"> |
| | | <el-option label="周一" value="MON"/> |
| | | <el-option label="周二" value="TUE"/> |
| | | <el-option label="周三" value="WED"/> |
| | | <el-option label="周四" value="THU"/> |
| | | <el-option label="周五" value="FRI"/> |
| | | <el-option label="周六" value="SAT"/> |
| | | <el-option label="周日" value="SUN"/> |
| | | </el-select> |
| | | <el-time-picker v-model="form.time" placeholder="选择时间" format="HH:mm" |
| | | value-format="HH:mm" style="width: 50%"/> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12" v-if="form.frequencyType === 'MONTHLY' && form.frequencyType"> |
| | | <el-form-item label="日期" prop="frequencyDetail"> |
| | | <el-date-picker |
| | | v-model="form.frequencyDetail" |
| | | type="datetime" |
| | | clearable |
| | | placeholder="选择开始日期" |
| | | format="DD,HH:mm" |
| | | value-format="DD,HH:mm" |
| | | /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12" v-if="form.frequencyType === 'QUARTERLY' && form.frequencyType"> |
| | | <el-form-item label="日期" prop="frequencyDetail"> |
| | | <el-date-picker |
| | | v-model="form.frequencyDetail" |
| | | type="datetime" |
| | | clearable |
| | | placeholder="选择开始日期" |
| | | format="MM,DD,HH:mm" |
| | | value-format="MM,DD,HH:mm" |
| | | /> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row> |
| | | <el-col :span="12"> |
| | | <el-form-item label="备注" prop="remarks"> |
| | | <el-input v-model="form.remarks" placeholder="请输入备注" type="textarea" /> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | </el-form> |
| | | </FormDialog> |
| | | <FormDialog |
| | | v-model="dialogVisitable" |
| | | :title="operationType === 'add' ? '新增保养任务' : '编辑保养任务'" |
| | | width="800px" |
| | | :operation-type="operationType" |
| | | @confirm="submitForm" |
| | | @cancel="cancel" |
| | | @close="cancel" |
| | | > |
| | | <el-form ref="formRef" :model="form" :rules="rules" label-width="120px"> |
| | | <el-row> |
| | | <el-col :span="12"> |
| | | <el-form-item label="任务名称" prop="taskName"> |
| | | <el-input |
| | | v-model="form.taskName" |
| | | placeholder="请输入任务名称" |
| | | clearable |
| | | /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="设备名称" prop="deviceIds"> |
| | | <el-select |
| | | v-model="form.deviceIds" |
| | | multiple |
| | | filterable |
| | | placeholder="请选择设备" |
| | | @change="handleDeviceChange" |
| | | > |
| | | <el-option |
| | | v-for="(item, index) in deviceOptions" |
| | | :key="index" |
| | | :label="item.deviceName" |
| | | :value="item.id" |
| | | ></el-option> |
| | | </el-select> |
| | | </el-form-item> |
| | | </el-col> |
| | | |
| | | <el-col :span="12"> |
| | | <el-form-item label="录入人" prop="inspector"> |
| | | <el-select |
| | | v-model="form.inspector" |
| | | filterable |
| | | default-first-option |
| | | :reserve-keyword="false" |
| | | placeholder="请选择" |
| | | clearable |
| | | > |
| | | <el-option |
| | | v-for="item in userList" |
| | | :label="item.nickName" |
| | | :value="item.userId" |
| | | :key="item.userId" |
| | | /> |
| | | </el-select> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="登记时间" prop="registrationDate"> |
| | | <el-date-picker |
| | | v-model="form.registrationDate" |
| | | type="date" |
| | | placeholder="选择登记日期" |
| | | format="YYYY-MM-DD" |
| | | value-format="YYYY-MM-DD" |
| | | style="width: 100%" |
| | | /> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row> |
| | | <el-col :span="12"> |
| | | <el-form-item label="任务频率" prop="frequencyType"> |
| | | <el-select |
| | | v-model="form.frequencyType" |
| | | placeholder="请选择" |
| | | clearable |
| | | > |
| | | <el-option label="每日" value="DAILY" /> |
| | | <el-option label="每周" value="WEEKLY" /> |
| | | <el-option label="每月" value="MONTHLY" /> |
| | | <el-option label="季度" value="QUARTERLY" /> |
| | | </el-select> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col |
| | | :span="12" |
| | | v-if="form.frequencyType === 'DAILY' && form.frequencyType" |
| | | > |
| | | <el-form-item label="日期/时间" prop="frequencyDetail"> |
| | | <el-time-picker |
| | | v-model="form.frequencyDetail" |
| | | placeholder="选择时间" |
| | | format="HH:mm" |
| | | value-format="HH:mm" |
| | | /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col |
| | | :span="12" |
| | | v-if="form.frequencyType === 'WEEKLY' && form.frequencyType" |
| | | > |
| | | <el-form-item label="日期/时间" prop="frequencyDetail"> |
| | | <el-select |
| | | v-model="form.week" |
| | | placeholder="请选择" |
| | | clearable |
| | | style="width: 50%" |
| | | > |
| | | <el-option label="周一" value="MON" /> |
| | | <el-option label="周二" value="TUE" /> |
| | | <el-option label="周三" value="WED" /> |
| | | <el-option label="周四" value="THU" /> |
| | | <el-option label="周五" value="FRI" /> |
| | | <el-option label="周六" value="SAT" /> |
| | | <el-option label="周日" value="SUN" /> |
| | | </el-select> |
| | | <el-time-picker |
| | | v-model="form.time" |
| | | placeholder="选择时间" |
| | | format="HH:mm" |
| | | value-format="HH:mm" |
| | | style="width: 50%" |
| | | /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col |
| | | :span="12" |
| | | v-if="form.frequencyType === 'MONTHLY' && form.frequencyType" |
| | | > |
| | | <el-form-item label="日期/时间" prop="frequencyDetail"> |
| | | <el-date-picker |
| | | v-model="form.frequencyDetail" |
| | | type="datetime" |
| | | clearable |
| | | placeholder="选择开始日期" |
| | | format="DD,HH:mm" |
| | | value-format="DD,HH:mm" |
| | | /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col |
| | | :span="12" |
| | | v-if="form.frequencyType === 'QUARTERLY' && form.frequencyType" |
| | | > |
| | | <el-form-item label="日期/时间" prop="frequencyDetail"> |
| | | <el-date-picker |
| | | v-model="form.frequencyDetail" |
| | | type="datetime" |
| | | clearable |
| | | placeholder="选择开始日期" |
| | | format="MM,DD,HH:mm" |
| | | value-format="MM,DD,HH:mm" |
| | | /> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row> |
| | | <el-col :span="12"> |
| | | <el-form-item label="备注" prop="remarks"> |
| | | <el-input |
| | | v-model="form.remarks" |
| | | placeholder="请输入备注" |
| | | type="textarea" |
| | | /> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | </el-form> |
| | | </FormDialog> |
| | | </template> |
| | | |
| | | <script setup> |
| | | import FormDialog from "@/components/Dialog/FormDialog.vue"; |
| | | import { reactive, ref, getCurrentInstance, toRefs } from "vue"; |
| | | import {userListNoPageByTenantId} from "@/api/system/user.js"; |
| | | import { userListNoPageByTenantId } from "@/api/system/user.js"; |
| | | import { getDeviceLedger } from "@/api/equipmentManagement/ledger"; |
| | | import { deviceMaintenanceTaskAdd, deviceMaintenanceTaskEdit } from "@/api/equipmentManagement/upkeep"; |
| | | import { |
| | | deviceMaintenanceTaskAdd, |
| | | deviceMaintenanceTaskEdit, |
| | | } from "@/api/equipmentManagement/upkeep"; |
| | | import { getCurrentDate } from "@/utils/index.js"; |
| | | import useUserStore from "@/store/modules/user.js"; |
| | | |
| | | const { proxy } = getCurrentInstance() |
| | | const emit = defineEmits() |
| | | const { proxy } = getCurrentInstance(); |
| | | const emit = defineEmits(); |
| | | const dialogVisitable = ref(false); |
| | | const operationType = ref('add'); |
| | | const operationType = ref("add"); |
| | | const deviceOptions = ref([]); |
| | | const userStore = useUserStore(); |
| | | const data = reactive({ |
| | | form: { |
| | | taskId: undefined, |
| | | deviceIds: [], |
| | | taskName: "", |
| | | // 录入人:单选一个用户 id |
| | | inspector: undefined, |
| | | remarks: '', |
| | | frequencyType: '', |
| | | frequencyDetail: '', |
| | | week: '', |
| | | time: '', |
| | | deviceModel: undefined, // 规格型号 |
| | | registrationDate: '' |
| | | }, |
| | | rules: { |
| | | deviceIds: [{ required: true, message: "请选择设备", trigger: "change" }], |
| | | taskName: [{ required: true, message: "请输入任务名称", trigger: "blur" }], |
| | | inspector: [{ required: true, message: "请选择录入人", trigger: "blur" },], |
| | | registrationDate: [{ required: true, message: "请选择登记时间", trigger: "change" }] |
| | | } |
| | | }) |
| | | const { form, rules } = toRefs(data) |
| | | const userList = ref([]) |
| | | form: { |
| | | taskId: undefined, |
| | | deviceIds: [], |
| | | taskName: "", |
| | | // 录入人:单选一个用户 id |
| | | inspector: undefined, |
| | | remarks: "", |
| | | frequencyType: "", |
| | | frequencyDetail: "", |
| | | week: "", |
| | | time: "", |
| | | deviceModel: undefined, // 规格型号 |
| | | registrationDate: "", |
| | | }, |
| | | rules: { |
| | | deviceIds: [{ required: true, message: "请选择设备", trigger: "change" }], |
| | | taskName: [{ required: true, message: "请输入任务名称", trigger: "blur" }], |
| | | inspector: [{ required: true, message: "请选择录入人", trigger: "blur" }], |
| | | registrationDate: [ |
| | | { required: true, message: "请选择登记时间", trigger: "change" }, |
| | | ], |
| | | }, |
| | | }); |
| | | const { form, rules } = toRefs(data); |
| | | const userList = ref([]); |
| | | |
| | | const loadDeviceName = async () => { |
| | | const { data } = await getDeviceLedger(); |
| | | deviceOptions.value = data; |
| | | const { data } = await getDeviceLedger(); |
| | | deviceOptions.value = data; |
| | | }; |
| | | |
| | | const normalizeIdList = (val) => { |
| | | if (!val) return [] |
| | | if (Array.isArray(val)) return val |
| | | if (typeof val === 'string') { |
| | | const s = val.trim() |
| | | // JSON 字符串:"[1,2,3]" |
| | | if (s.startsWith('[') && s.endsWith(']')) { |
| | | try { |
| | | const arr = JSON.parse(s) |
| | | return Array.isArray(arr) ? arr : [] |
| | | } catch { |
| | | return [] |
| | | } |
| | | } |
| | | // 逗号分隔:"1,2,3" |
| | | return s.split(',').map(v => v.trim()).filter(Boolean) |
| | | } |
| | | return [] |
| | | } |
| | | if (!val) return []; |
| | | if (Array.isArray(val)) return val; |
| | | if (typeof val === "string") { |
| | | const s = val.trim(); |
| | | // JSON 字符串:"[1,2,3]" |
| | | if (s.startsWith("[") && s.endsWith("]")) { |
| | | try { |
| | | const arr = JSON.parse(s); |
| | | return Array.isArray(arr) ? arr : []; |
| | | } catch { |
| | | return []; |
| | | } |
| | | } |
| | | // 逗号分隔:"1,2,3" |
| | | return s |
| | | .split(",") |
| | | .map((v) => v.trim()) |
| | | .filter(Boolean); |
| | | } |
| | | return []; |
| | | }; |
| | | |
| | | // 选择设备时,顺带回填规格型号(多选时取第一个设备的规格型号) |
| | | const handleDeviceChange = () => { |
| | | const selectedIds = form.value.deviceIds || [] |
| | | const firstId = Array.isArray(selectedIds) ? selectedIds[0] : undefined |
| | | const firstDevice = deviceOptions.value.find(d => String(d.id) === String(firstId)) |
| | | form.value.deviceModel = firstDevice?.deviceModel || firstDevice?.model || form.value.deviceModel |
| | | } |
| | | const selectedIds = form.value.deviceIds || []; |
| | | const firstId = Array.isArray(selectedIds) ? selectedIds[0] : undefined; |
| | | const firstDevice = deviceOptions.value.find( |
| | | (d) => String(d.id) === String(firstId) |
| | | ); |
| | | form.value.deviceModel = |
| | | firstDevice?.deviceModel || firstDevice?.model || form.value.deviceModel; |
| | | }; |
| | | |
| | | // 打开弹框 |
| | | const openDialog = async (type, row) => { |
| | | dialogVisitable.value = true |
| | | operationType.value = type |
| | | |
| | | // 重置表单 |
| | | resetForm(); |
| | | |
| | | // 加载用户列表 |
| | | userListNoPageByTenantId().then((res) => { |
| | | userList.value = res.data; |
| | | }); |
| | | |
| | | // 加载设备列表 |
| | | await loadDeviceName(); |
| | | |
| | | if (type === 'edit' && row) { |
| | | form.value = { ...form.value, ...row } |
| | | // 编辑时用接口返回的 registrantId 回显录入人 |
| | | if (row.registrantId) { |
| | | form.value.inspector = row.registrantId |
| | | } |
| | | dialogVisitable.value = true; |
| | | operationType.value = type; |
| | | |
| | | // 编辑回显:deviceIds 可能是 JSON 字符串 / 逗号分隔 / 数组 |
| | | const ids = normalizeIdList(row.deviceIds ?? row.taskIds) |
| | | form.value.deviceIds = ids.map(v => { |
| | | const n = Number(v) |
| | | return Number.isNaN(n) ? v : n |
| | | }) |
| | | handleDeviceChange() |
| | | } else if (type === 'add') { |
| | | // 新增时设置登记日期为当天 |
| | | form.value.registrationDate = getCurrentDate(); |
| | | // 新增时设置录入人为当前登录账户 |
| | | form.value.inspector = userStore.id; |
| | | } |
| | | } |
| | | // 重置表单 |
| | | resetForm(); |
| | | |
| | | // 加载用户列表 |
| | | userListNoPageByTenantId().then((res) => { |
| | | userList.value = res.data; |
| | | }); |
| | | |
| | | // 加载设备列表 |
| | | await loadDeviceName(); |
| | | |
| | | if (type === "edit" && row) { |
| | | form.value = { ...form.value, ...row }; |
| | | // 编辑时用接口返回的 registrantId 回显录入人 |
| | | if (row.registrantId) { |
| | | form.value.inspector = row.registrantId; |
| | | } |
| | | |
| | | // 编辑回显:deviceIds 可能是 JSON 字符串 / 逗号分隔 / 数组 |
| | | const ids = normalizeIdList(row.deviceIds ?? row.taskIds); |
| | | form.value.deviceIds = ids.map((v) => { |
| | | const n = Number(v); |
| | | return Number.isNaN(n) ? v : n; |
| | | }); |
| | | handleDeviceChange(); |
| | | } else if (type === "add") { |
| | | // 新增时设置登记日期为当天 |
| | | form.value.registrationDate = getCurrentDate(); |
| | | // 新增时设置录入人为当前登录账户 |
| | | form.value.inspector = userStore.id; |
| | | } |
| | | }; |
| | | |
| | | // 关闭对话框 |
| | | const cancel = () => { |
| | | resetForm() |
| | | dialogVisitable.value = false |
| | | emit('closeDia') |
| | | } |
| | | resetForm(); |
| | | dialogVisitable.value = false; |
| | | emit("closeDia"); |
| | | }; |
| | | |
| | | // 重置表单函数 |
| | | const resetForm = () => { |
| | | if (proxy.$refs.formRef) { |
| | | proxy.$refs.formRef.resetFields() |
| | | } |
| | | // 重置表单数据确保设备信息正确重置 |
| | | form.value = { |
| | | taskId: undefined, |
| | | deviceIds: [], |
| | | taskName: "", |
| | | inspector: undefined, |
| | | remarks: '', |
| | | frequencyType: '', |
| | | frequencyDetail: '', |
| | | week: '', |
| | | time: '', |
| | | deviceModel: undefined, |
| | | registrationDate: '' |
| | | } |
| | | } |
| | | if (proxy.$refs.formRef) { |
| | | proxy.$refs.formRef.resetFields(); |
| | | } |
| | | // 重置表单数据确保设备信息正确重置 |
| | | form.value = { |
| | | taskId: undefined, |
| | | deviceIds: [], |
| | | taskName: "", |
| | | inspector: undefined, |
| | | remarks: "", |
| | | frequencyType: "", |
| | | frequencyDetail: "", |
| | | week: "", |
| | | time: "", |
| | | deviceModel: undefined, |
| | | registrationDate: "", |
| | | }; |
| | | }; |
| | | |
| | | // 提交表单 |
| | | const submitForm = () => { |
| | | proxy.$refs["formRef"].validate(async valid => { |
| | | if (valid) { |
| | | try { |
| | | const payload = { ...form.value } |
| | | // 后端要求:deviceIds 以 JSON.stringify([1,2,3]) 形式传参 |
| | | payload.deviceIds = JSON.stringify(form.value.deviceIds || []) |
| | | // 不再向后端传保养人字段,仅使用接口要求的 registrant / registrantId |
| | | // 根据选择的"录入人"设置 registrant / registrantId |
| | | if (payload.inspector) { |
| | | const selectedUser = userList.value.find( |
| | | (u) => String(u.userId) === String(payload.inspector) |
| | | ) |
| | | if (selectedUser) { |
| | | payload.registrantId = selectedUser.userId |
| | | payload.registrant = selectedUser.nickName |
| | | } |
| | | } |
| | | delete payload.inspector |
| | | delete payload.inspectorIds |
| | | delete payload.taskIds |
| | | |
| | | if (payload.frequencyType === 'WEEKLY') { |
| | | let frequencyDetail = '' |
| | | frequencyDetail = payload.week + ',' + payload.time |
| | | payload.frequencyDetail = frequencyDetail |
| | | } |
| | | |
| | | // 录入日期:直接使用表单里的 registrationDate 字段 |
| | | // 一些默认状态字段 |
| | | if (payload.status === undefined || payload.status === null || payload.status === '') { |
| | | payload.status = '0' // 默认状态,可按实际枚举调整 |
| | | } |
| | | payload.active = true |
| | | payload.deleted = 0 |
| | | |
| | | if (operationType.value === 'edit') { |
| | | await deviceMaintenanceTaskEdit(payload) |
| | | } else { |
| | | await deviceMaintenanceTaskAdd(payload) |
| | | } |
| | | cancel() |
| | | proxy.$modal.msgSuccess('提交成功') |
| | | } catch (error) { |
| | | proxy.$modal.msgError('提交失败,请重试') |
| | | } |
| | | } |
| | | }) |
| | | } |
| | | defineExpose({ openDialog }) |
| | | proxy.$refs["formRef"].validate(async (valid) => { |
| | | if (valid) { |
| | | try { |
| | | const payload = { ...form.value }; |
| | | // 后端要求:deviceIds 以 JSON.stringify([1,2,3]) 形式传参 |
| | | payload.deviceIds = JSON.stringify(form.value.deviceIds || []); |
| | | // 不再向后端传保养人字段,仅使用接口要求的 registrant / registrantId |
| | | // 根据选择的"录入人"设置 registrant / registrantId |
| | | if (payload.inspector) { |
| | | const selectedUser = userList.value.find( |
| | | (u) => String(u.userId) === String(payload.inspector) |
| | | ); |
| | | if (selectedUser) { |
| | | payload.registrantId = selectedUser.userId; |
| | | payload.registrant = selectedUser.nickName; |
| | | } |
| | | } |
| | | delete payload.inspector; |
| | | delete payload.inspectorIds; |
| | | delete payload.taskIds; |
| | | |
| | | if (payload.frequencyType === "WEEKLY") { |
| | | let frequencyDetail = ""; |
| | | frequencyDetail = payload.week + "," + payload.time; |
| | | payload.frequencyDetail = frequencyDetail; |
| | | } |
| | | |
| | | // 录入日期:直接使用表单里的 registrationDate 字段 |
| | | // 一些默认状态字段 |
| | | if ( |
| | | payload.status === undefined || |
| | | payload.status === null || |
| | | payload.status === "" |
| | | ) { |
| | | payload.status = "0"; // 默认状态,可按实际枚举调整 |
| | | } |
| | | payload.active = true; |
| | | payload.deleted = 0; |
| | | |
| | | if (operationType.value === "edit") { |
| | | await deviceMaintenanceTaskEdit(payload); |
| | | } else { |
| | | await deviceMaintenanceTaskAdd(payload); |
| | | } |
| | | cancel(); |
| | | proxy.$modal.msgSuccess("提交成功"); |
| | | } catch (error) { |
| | | proxy.$modal.msgError("提交失败,请重试"); |
| | | } |
| | | } |
| | | }); |
| | | }; |
| | | defineExpose({ openDialog }); |
| | | </script> |
| | | |
| | | <style scoped> |
| | | |
| | | </style> |
| | | <style scoped></style> |
| | |
| | | <el-col :span="12"> |
| | | <el-form-item label="检测结果:" prop="checkResult"> |
| | | <el-select v-model="form.checkResult"> |
| | | <el-option label="合格" value="合格" /> |
| | | <el-option label="不合格" value="不合格" /> |
| | | <el-option label="已检" value="已检" /> |
| | | <el-option label="未检" value="未检" /> |
| | | </el-select> |
| | | </el-form-item> |
| | | </el-col> |
| | |
| | | prop: "checkResult", |
| | | dataType: "tag", |
| | | formatType: (params) => { |
| | | if (params == '不合格') { |
| | | if (params == '未检') { |
| | | return "danger"; |
| | | } else if (params == '合格') { |
| | | } else if (params == '已检') { |
| | | return "success"; |
| | | } else { |
| | | return null; |
| | | return "danger"; |
| | | } |
| | | }, |
| | | }, |
| | |
| | | }); |
| | | </script> |
| | | |
| | | <style scoped></style> |
| | | <style scoped></style> |
| | |
| | | <template> |
| | | <div> |
| | | <el-dialog |
| | | v-model="dialogFormVisible" |
| | | :title="operationType === 'add' ? '新增原料' : operationType === 'view' ? '原料详情' : '编辑原料'" |
| | | width="70%" |
| | | @close="closeDia" |
| | | v-model="dialogFormVisible" |
| | | :title=" |
| | | operationType === 'add' |
| | | ? '新增原料' |
| | | : operationType === 'view' |
| | | ? '原料详情' |
| | | : '编辑原料' |
| | | " |
| | | width="70%" |
| | | @close="closeDia" |
| | | > |
| | | <el-form |
| | | v-if="operationType !== 'view'" |
| | | :model="form" |
| | | label-width="140px" |
| | | label-position="top" |
| | | :rules="rules" |
| | | ref="formRef" |
| | | v-if="operationType !== 'view'" |
| | | :model="form" |
| | | label-width="140px" |
| | | label-position="top" |
| | | :rules="rules" |
| | | ref="formRef" |
| | | > |
| | | <el-row :gutter="30"> |
| | | <el-col :span="12"> |
| | | <el-form-item label="产品名称:" prop="productId"> |
| | | <el-tree-select |
| | | v-model="form.productId" |
| | | placeholder="请选择" |
| | | clearable |
| | | check-strictly |
| | | @change="getModels" |
| | | :data="productOptions" |
| | | :render-after-expand="false" |
| | | :disabled="operationType === 'edit' || operationType === 'view'" |
| | | style="width: 100%" |
| | | v-model="form.productId" |
| | | placeholder="请选择" |
| | | clearable |
| | | check-strictly |
| | | @change="getModels" |
| | | :data="productOptions" |
| | | :render-after-expand="false" |
| | | :disabled="operationType === 'edit' || operationType === 'view'" |
| | | style="width: 100%" |
| | | /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="规格型号:" prop="productModelId"> |
| | | <el-select v-model="form.productModelId" placeholder="请选择" clearable |
| | | :disabled="operationType === 'edit' || operationType === 'view'" |
| | | filterable readonly @change="handleChangeModel"> |
| | | <el-option v-for="item in modelOptions" :key="item.id" :label="item.model" :value="item.id"/> |
| | | <el-select |
| | | v-model="form.productModelId" |
| | | placeholder="请选择" |
| | | clearable |
| | | :disabled="operationType === 'edit' || operationType === 'view'" |
| | | filterable |
| | | readonly |
| | | @change="handleChangeModel" |
| | | > |
| | | <el-option |
| | | v-for="item in modelOptions" |
| | | :key="item.id" |
| | | :label="item.model" |
| | | :value="item.id" |
| | | /> |
| | | </el-select> |
| | | </el-form-item> |
| | | </el-col> |
| | |
| | | <el-row :gutter="30"> |
| | | <el-col :span="12"> |
| | | <el-form-item label="单位:" prop="unit"> |
| | | <el-input v-model="form.unit" disabled/> |
| | | <el-input v-model="form.unit" disabled /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="批号:" prop="batchNo"> |
| | | <el-input |
| | | style="width: 100%" |
| | | v-model="form.batchNo" |
| | | placeholder="请输入" |
| | | clearable |
| | | :disabled="operationType === 'view'" |
| | | style="width: 100%" |
| | | v-model="form.batchNo" |
| | | placeholder="请输入" |
| | | clearable |
| | | :disabled="operationType === 'view'" |
| | | /> |
| | | </el-form-item> |
| | | </el-col> |
| | |
| | | <el-row :gutter="30"> |
| | | <el-col :span="12"> |
| | | <el-form-item label="检验类型:" prop="checkType"> |
| | | <el-select v-model="form.checkType" :disabled="operationType === 'view'"> |
| | | <el-option label="入厂检" :value="0"/> |
| | | <el-option label="车间检" :value="1"/> |
| | | <el-option label="出厂检" :value="2"/> |
| | | <el-select |
| | | v-model="form.checkType" |
| | | :disabled="operationType === 'view'" |
| | | > |
| | | <el-option label="入厂检" :value="0" /> |
| | | <el-option label="车间检" :value="1" /> |
| | | <el-option label="出厂检" :value="2" /> |
| | | </el-select> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="检测结果:" prop="checkResult"> |
| | | <el-select v-model="form.checkResult" :disabled="operationType === 'view'"> |
| | | <el-option label="合格" :value="1"/> |
| | | <el-option label="不合格" :value="0"/> |
| | | <el-select |
| | | v-model="form.checkResult" |
| | | :disabled="operationType === 'view'" |
| | | > |
| | | <el-option label="已检" :value="1" /> |
| | | <el-option label="未检" :value="0" /> |
| | | </el-select> |
| | | </el-form-item> |
| | | </el-col> |
| | |
| | | <el-col :span="12"> |
| | | <el-form-item label="检验员:" prop="checkUserName"> |
| | | <el-select |
| | | v-model="form.checkUserName" |
| | | placeholder="请选择" |
| | | clearable |
| | | filterable |
| | | style="width: 100%" |
| | | :disabled="operationType === 'view'" |
| | | v-model="form.checkUserName" |
| | | placeholder="请选择" |
| | | clearable |
| | | filterable |
| | | style="width: 100%" |
| | | :disabled="operationType === 'view'" |
| | | > |
| | | <el-option v-for="item in userList" :key="item.nickName" :label="item.nickName" |
| | | :value="item.nickName"/> |
| | | <el-option |
| | | v-for="item in userList" |
| | | :key="item.nickName" |
| | | :label="item.nickName" |
| | | :value="item.nickName" |
| | | /> |
| | | </el-select> |
| | | |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="检测日期:" prop="checkTime"> |
| | | <el-date-picker |
| | | v-model="form.checkTime" |
| | | type="date" |
| | | placeholder="请选择日期" |
| | | value-format="YYYY-MM-DD" |
| | | format="YYYY-MM-DD" |
| | | clearable |
| | | style="width: 100%" |
| | | :disabled="operationType === 'view'" |
| | | v-model="form.checkTime" |
| | | type="date" |
| | | placeholder="请选择日期" |
| | | value-format="YYYY-MM-DD" |
| | | format="YYYY-MM-DD" |
| | | clearable |
| | | style="width: 100%" |
| | | :disabled="operationType === 'view'" |
| | | /> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | </el-form> |
| | | <el-descriptions |
| | | v-else |
| | | :column="2" |
| | | border |
| | | size="small" |
| | | style="margin-bottom: 12px;" |
| | | v-else |
| | | :column="2" |
| | | border |
| | | size="small" |
| | | style="margin-bottom: 12px" |
| | | > |
| | | <el-descriptions-item label="产品名称">{{ viewProductName }}</el-descriptions-item> |
| | | <el-descriptions-item label="规格型号">{{ viewProductModel }}</el-descriptions-item> |
| | | <el-descriptions-item label="单位">{{ form.unit || '-' }}</el-descriptions-item> |
| | | <el-descriptions-item label="批号">{{ form.batchNo || '-' }}</el-descriptions-item> |
| | | <el-descriptions-item label="检验类型">{{ viewCheckType }}</el-descriptions-item> |
| | | <el-descriptions-item label="检测结果">{{ viewCheckResult }}</el-descriptions-item> |
| | | <el-descriptions-item label="检验员">{{ form.checkUserName || '-' }}</el-descriptions-item> |
| | | <el-descriptions-item label="检测日期">{{ form.checkTime || '-' }}</el-descriptions-item> |
| | | <el-descriptions-item label="产品名称">{{ |
| | | viewProductName |
| | | }}</el-descriptions-item> |
| | | <el-descriptions-item label="规格型号">{{ |
| | | viewProductModel |
| | | }}</el-descriptions-item> |
| | | <el-descriptions-item label="单位">{{ |
| | | form.unit || "-" |
| | | }}</el-descriptions-item> |
| | | <el-descriptions-item label="批号">{{ |
| | | form.batchNo || "-" |
| | | }}</el-descriptions-item> |
| | | <el-descriptions-item label="检验类型">{{ |
| | | viewCheckType |
| | | }}</el-descriptions-item> |
| | | <el-descriptions-item label="检测结果">{{ |
| | | viewCheckResult |
| | | }}</el-descriptions-item> |
| | | <el-descriptions-item label="检验员">{{ |
| | | form.checkUserName || "-" |
| | | }}</el-descriptions-item> |
| | | <el-descriptions-item label="检测日期">{{ |
| | | form.checkTime || "-" |
| | | }}</el-descriptions-item> |
| | | </el-descriptions> |
| | | <div style="margin-bottom: 10px"> |
| | | <el-button |
| | | v-if="operationType !== 'view'" |
| | | type="primary" |
| | | @click="isShowItems = true" |
| | | >添加检测项目</el-button> |
| | | v-if="operationType !== 'view'" |
| | | type="primary" |
| | | @click="isShowItems = true" |
| | | >添加检测项目</el-button |
| | | > |
| | | </div> |
| | | <PIMTable |
| | | rowKey="id" |
| | | :column="tableColumn" |
| | | :tableData="tableData" |
| | | :tableLoading="tableLoading" |
| | | :is-show-pagination="false" |
| | | height="400" |
| | | rowKey="id" |
| | | :column="tableColumn" |
| | | :tableData="tableData" |
| | | :tableLoading="tableLoading" |
| | | :is-show-pagination="false" |
| | | height="400" |
| | | > |
| | | <template #slot="{ row }"> |
| | | <span v-if="operationType === 'view'">{{ row.testValue }}</span> |
| | | <el-input |
| | | v-else |
| | | v-model="row.testValue" |
| | | clearable |
| | | /> |
| | | <el-input v-else v-model="row.testValue" clearable /> |
| | | </template> |
| | | </PIMTable> |
| | | <template #footer> |
| | | <div class="dialog-footer"> |
| | | <el-button v-if="operationType !== 'view'" type="primary" @click="submitForm">确认</el-button> |
| | | <el-button @click="closeDia">{{ operationType === 'view' ? '关闭' : '取消' }}</el-button> |
| | | <el-button |
| | | v-if="operationType !== 'view'" |
| | | type="primary" |
| | | @click="submitForm" |
| | | >确认</el-button |
| | | > |
| | | <el-button @click="closeDia">{{ |
| | | operationType === "view" ? "关闭" : "取消" |
| | | }}</el-button> |
| | | </div> |
| | | </template> |
| | | </el-dialog> |
| | | |
| | | <item-select v-model="isShowItems" @confirm="handleItemSelect"/> |
| | | <item-select v-model="isShowItems" @confirm="handleItemSelect" /> |
| | | </div> |
| | | </template> |
| | | |
| | | <script setup> |
| | | import {ref, reactive, toRefs, getCurrentInstance, nextTick, computed} from "vue"; |
| | | import {modelList, productTreeList} from "@/api/basicData/product.js"; |
| | | import {qualityInspectParamInfo} from "@/api/qualityManagement/qualityInspectParam.js"; |
| | | import {qualityInspectDetailByProductId} from "@/api/qualityManagement/metricMaintenance.js"; |
| | | import {userListNoPage} from "@/api/system/user.js"; |
| | | import {createRawMaterial, findRawMaterialDetail, updateRawMaterial} from "@/api/qualityManagement/rawMaterial.js"; |
| | | import { |
| | | ref, |
| | | reactive, |
| | | toRefs, |
| | | getCurrentInstance, |
| | | nextTick, |
| | | computed, |
| | | } from "vue"; |
| | | import { modelList, productTreeList } from "@/api/basicData/product.js"; |
| | | import { qualityInspectParamInfo } from "@/api/qualityManagement/qualityInspectParam.js"; |
| | | import { qualityInspectDetailByProductId } from "@/api/qualityManagement/metricMaintenance.js"; |
| | | import { userListNoPage } from "@/api/system/user.js"; |
| | | import { |
| | | createRawMaterial, |
| | | findRawMaterialDetail, |
| | | updateRawMaterial, |
| | | } from "@/api/qualityManagement/rawMaterial.js"; |
| | | import ProductSelectDialog from "@/views/basicData/product/ProductSelectDialog.vue"; |
| | | |
| | | const {proxy} = getCurrentInstance() |
| | | const emit = defineEmits(['close']) |
| | | const ItemSelect = defineAsyncComponent(() => import("@/views/qualityManagement/rawMaterial/components/itemSelect.vue")); |
| | | const { proxy } = getCurrentInstance(); |
| | | const emit = defineEmits(["close"]); |
| | | const ItemSelect = defineAsyncComponent(() => |
| | | import("@/views/qualityManagement/rawMaterial/components/itemSelect.vue") |
| | | ); |
| | | |
| | | const dialogFormVisible = ref(false); |
| | | const operationType = ref('') |
| | | const isShowItems = ref(false) |
| | | const operationType = ref(""); |
| | | const isShowItems = ref(false); |
| | | const data = reactive({ |
| | | form: { |
| | | checkTime: "", |
| | |
| | | checkUserName: "", |
| | | }, |
| | | rules: { |
| | | checkTime: [{required: true, message: "请输入", trigger: "blur"},], |
| | | checkUserName: [{required: false, message: "请选择检验员", trigger: "blur"}], |
| | | productId: [{required: true, message: "请输入", trigger: "blur"}], |
| | | productModelId: [{required: true, message: "请选择产品型号", trigger: "change"}], |
| | | batchNo: [{required: true, message: "请输入批次", trigger: "blur"}], |
| | | checkType: [{required: true, message: "请选择检验类型", trigger: "change"}], |
| | | checkResult: [{required: true, message: "请选择检测结果", trigger: "change"}], |
| | | checkTime: [{ required: true, message: "请输入", trigger: "blur" }], |
| | | checkUserName: [ |
| | | { required: false, message: "请选择检验员", trigger: "blur" }, |
| | | ], |
| | | productId: [{ required: true, message: "请输入", trigger: "blur" }], |
| | | productModelId: [ |
| | | { required: true, message: "请选择产品型号", trigger: "change" }, |
| | | ], |
| | | batchNo: [{ required: true, message: "请输入批次", trigger: "blur" }], |
| | | checkType: [ |
| | | { required: true, message: "请选择检验类型", trigger: "change" }, |
| | | ], |
| | | checkResult: [ |
| | | { required: true, message: "请选择检测结果", trigger: "change" }, |
| | | ], |
| | | }, |
| | | }); |
| | | const tableColumn = ref([ |
| | |
| | | { |
| | | label: "化验值", |
| | | prop: "testValue", |
| | | dataType: 'slot', |
| | | slot: 'slot', |
| | | dataType: "slot", |
| | | slot: "slot", |
| | | }, |
| | | { |
| | | dataType: 'action', |
| | | label: '操作', |
| | | align: 'center', |
| | | fixed: 'right', |
| | | dataType: "action", |
| | | label: "操作", |
| | | align: "center", |
| | | fixed: "right", |
| | | width: 140, |
| | | operation: [ |
| | | { |
| | | name: '删除', |
| | | type: 'text', |
| | | name: "删除", |
| | | type: "text", |
| | | clickFun: (row) => handleDelete(row.id), |
| | | disabled: () => operationType.value === 'view', |
| | | } |
| | | ] |
| | | } |
| | | disabled: () => operationType.value === "view", |
| | | }, |
| | | ], |
| | | }, |
| | | ]); |
| | | const tableData = ref([]); |
| | | const tableLoading = ref(false); |
| | | |
| | | const {form, rules} = toRefs(data); |
| | | const { form, rules } = toRefs(data); |
| | | const userList = ref([]); |
| | | const productOptions = ref([]); |
| | | const currentProductId = ref(0); |
| | |
| | | // 打开弹框 |
| | | const openDialog = async (type, row) => { |
| | | operationType.value = type; |
| | | userListNoPage().then(res => { |
| | | userListNoPage().then((res) => { |
| | | userList.value = res.data || []; |
| | | }) |
| | | }); |
| | | // 先重置表单数据(保持字段完整,避免弹窗首次渲染时触发必填红框“闪一下”) |
| | | form.value = { |
| | | checkTime: getTodayStr(), |
| | |
| | | checkResult: "", |
| | | unit: "", |
| | | checkUserName: "", |
| | | } |
| | | }; |
| | | tableData.value = []; |
| | | // 先确保产品树已加载,否则编辑时产品/规格型号无法反显 |
| | | await getProductOptions(); |
| | | if (operationType.value === 'edit') { |
| | | if (operationType.value === "edit") { |
| | | await fetchData(row.id); |
| | | currentProductId.value = row.productId || 0 |
| | | currentProductId.value = row.productId || 0; |
| | | // 关键:编辑时加载规格型号下拉选项,才能反显 productModelId |
| | | if (currentProductId.value) { |
| | | try { |
| | | const res = await modelList({id: currentProductId.value}); |
| | | const res = await modelList({ id: currentProductId.value }); |
| | | modelOptions.value = res || []; |
| | | // 同步回填 model / unit(有些接口返回的 row 里可能没带全) |
| | | if (form.value.productModelId) { |
| | |
| | | } |
| | | // 编辑模式下,先加载指标选项,然后加载参数列表 |
| | | if (currentProductId.value) { |
| | | |
| | | } else { |
| | | getQualityInspectParamList(row.id); |
| | | } |
| | | } |
| | | if (operationType.value === 'view') { |
| | | if (operationType.value === "view") { |
| | | await fetchData(row.id); |
| | | currentProductId.value = row.productId || 0 |
| | | currentProductId.value = row.productId || 0; |
| | | if (currentProductId.value) { |
| | | try { |
| | | const res = await modelList({id: currentProductId.value}); |
| | | const res = await modelList({ id: currentProductId.value }); |
| | | modelOptions.value = res || []; |
| | | if (form.value.productModelId) { |
| | | handleChangeModel(form.value.productModelId); |
| | |
| | | nextTick(() => { |
| | | proxy.$refs?.formRef?.clearValidate?.(); |
| | | }); |
| | | } |
| | | }; |
| | | const getProductOptions = () => { |
| | | return productTreeList().then((res) => { |
| | | productOptions.value = convertIdToValue(res); |
| | |
| | | form.value.productModelId = undefined; |
| | | form.value.unit = undefined; |
| | | modelOptions.value = []; |
| | | currentProductId.value = value |
| | | currentProductId.value = value; |
| | | form.value.productName = findNodeById(productOptions.value, value); |
| | | modelList({id: value}).then((res) => { |
| | | modelList({ id: value }).then((res) => { |
| | | modelOptions.value = res; |
| | | }) |
| | | }); |
| | | if (currentProductId.value) { |
| | | getList(); |
| | | } |
| | |
| | | |
| | | const handleItemSelect = (value) => { |
| | | // 过滤已存在的指标 |
| | | value = value.filter(item => !tableData.value.some(existingItem => existingItem.id === item.id)); |
| | | tableData.value.push(...value) |
| | | } |
| | | value = value.filter( |
| | | (item) => |
| | | !tableData.value.some((existingItem) => existingItem.id === item.id) |
| | | ); |
| | | tableData.value.push(...value); |
| | | }; |
| | | |
| | | const handleChangeModel = (value) => { |
| | | form.value.model = modelOptions.value.find(item => item.id == value)?.model || ''; |
| | | form.value.unit = modelOptions.value.find(item => item.id == value)?.unit || ''; |
| | | } |
| | | form.value.model = |
| | | modelOptions.value.find((item) => item.id == value)?.model || ""; |
| | | form.value.unit = |
| | | modelOptions.value.find((item) => item.id == value)?.unit || ""; |
| | | }; |
| | | |
| | | const findNodeById = (nodes, productId) => { |
| | | for (let i = 0; i < nodes.length; i++) { |
| | |
| | | |
| | | // 详情模式展示字段(不使用表单控件) |
| | | const viewProductName = computed(() => { |
| | | const id = form.value?.productId |
| | | const label = id ? findNodeById(productOptions.value || [], id) : null |
| | | return label || id || '-' |
| | | }) |
| | | const id = form.value?.productId; |
| | | const label = id ? findNodeById(productOptions.value || [], id) : null; |
| | | return label || id || "-"; |
| | | }); |
| | | |
| | | const viewProductModel = computed(() => { |
| | | const modelId = form.value?.productModelId |
| | | const matched = (modelOptions.value || []).find((x) => String(x.id) === String(modelId)) |
| | | return matched?.model || modelId || '-' |
| | | }) |
| | | const modelId = form.value?.productModelId; |
| | | const matched = (modelOptions.value || []).find( |
| | | (x) => String(x.id) === String(modelId) |
| | | ); |
| | | return matched?.model || modelId || "-"; |
| | | }); |
| | | |
| | | const viewCheckType = computed(() => { |
| | | const t = form.value?.checkType |
| | | if (t === 0 || t === '0') return '入厂检' |
| | | if (t === 1 || t === '1') return '车间检' |
| | | if (t === 2 || t === '2') return '出厂检' |
| | | return '-' |
| | | }) |
| | | const t = form.value?.checkType; |
| | | if (t === 0 || t === "0") return "入厂检"; |
| | | if (t === 1 || t === "1") return "车间检"; |
| | | if (t === 2 || t === "2") return "出厂检"; |
| | | return "-"; |
| | | }); |
| | | |
| | | const viewCheckResult = computed(() => { |
| | | const r = form.value?.checkResult |
| | | if (r === 1 || r === '1') return '合格' |
| | | if (r === 0 || r === '0') return '不合格' |
| | | return '-' |
| | | }) |
| | | const r = form.value?.checkResult; |
| | | if (r === 1 || r === "1") return "合格"; |
| | | if (r === 0 || r === "0") return "不合格"; |
| | | return "-"; |
| | | }); |
| | | |
| | | function convertIdToValue(data) { |
| | | return data.map((item) => { |
| | | const {id, children, ...rest} = item; |
| | | const { id, children, ...rest } = item; |
| | | const newItem = { |
| | | ...rest, |
| | | value: id, // 将 id 改为 value |
| | |
| | | |
| | | // 提交产品表单 |
| | | const submitForm = () => { |
| | | if (operationType.value === 'view') return; |
| | | proxy.$refs.formRef.validate(valid => { |
| | | if (operationType.value === "view") return; |
| | | proxy.$refs.formRef.validate((valid) => { |
| | | if (valid) { |
| | | const data = {...form.value, qualityInspectItem: tableData.value} |
| | | const data = { ...form.value, qualityInspectItem: tableData.value }; |
| | | if (operationType.value === "add") { |
| | | createRawMaterial(data).then(res => { |
| | | createRawMaterial(data).then((res) => { |
| | | proxy.$modal.msgSuccess("提交成功"); |
| | | closeDia(); |
| | | }) |
| | | }); |
| | | } else { |
| | | updateRawMaterial(data).then(res => { |
| | | updateRawMaterial(data).then((res) => { |
| | | proxy.$modal.msgSuccess("提交成功"); |
| | | closeDia(); |
| | | }) |
| | | }); |
| | | } |
| | | } |
| | | }) |
| | | } |
| | | }); |
| | | }; |
| | | |
| | | const getList = () => { |
| | | if (!currentProductId.value) { |
| | |
| | | } |
| | | let params = { |
| | | productId: currentProductId.value, |
| | | } |
| | | qualityInspectDetailByProductId(params).then(res => { |
| | | }; |
| | | qualityInspectDetailByProductId(params).then((res) => { |
| | | // 清空表格数据,等待用户选择指标 |
| | | tableData.value = []; |
| | | }) |
| | | } |
| | | }); |
| | | }; |
| | | |
| | | const getQualityInspectParamList = (id) => { |
| | | qualityInspectParamInfo(id).then(res => { |
| | | qualityInspectParamInfo(id).then((res) => { |
| | | tableData.value = res.data; |
| | | }) |
| | | } |
| | | }); |
| | | }; |
| | | // 关闭弹框 |
| | | const closeDia = () => { |
| | | proxy.resetForm("formRef"); |
| | | tableData.value = []; |
| | | dialogFormVisible.value = false; |
| | | emit('close') |
| | | emit("close"); |
| | | }; |
| | | |
| | | const handleDelete = (id) => { |
| | | if (operationType.value === 'view') return; |
| | | tableData.value = tableData.value.filter(item => item.id !== id); |
| | | } |
| | | if (operationType.value === "view") return; |
| | | tableData.value = tableData.value.filter((item) => item.id !== id); |
| | | }; |
| | | |
| | | const fetchData = (id) => { |
| | | tableLoading.value = true; |
| | | findRawMaterialDetail(id).then(res => { |
| | | form.value = res.data; |
| | | tableData.value = res.data.qualityInspectItem; |
| | | }).finally(() => { |
| | | tableLoading.value = false; |
| | | }) |
| | | } |
| | | findRawMaterialDetail(id) |
| | | .then((res) => { |
| | | form.value = res.data; |
| | | tableData.value = res.data.qualityInspectItem; |
| | | }) |
| | | .finally(() => { |
| | | tableLoading.value = false; |
| | | }); |
| | | }; |
| | | defineExpose({ |
| | | openDialog, |
| | | }); |
| | | </script> |
| | | |
| | | <style scoped> |
| | | |
| | | </style> |
| | | <style scoped></style> |