| | |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="工序" prop="productProcessId"> |
| | | <el-select |
| | | v-model="form.productProcessId" |
| | | placeholder="请选择工序" |
| | | clearable |
| | | filterable |
| | | style="width: 100%" |
| | | > |
| | | <el-option |
| | | v-for="item in processOptions" |
| | | :key="item.value" |
| | | :label="item.label" |
| | | :value="item.value" |
| | | /> |
| | | </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> |
| | |
| | | @change="mathNum" |
| | | > |
| | | <el-option label="1" :value="1" /> |
| | | <el-option label="3" :value="3" /> |
| | | <el-option label="6" :value="6" /> |
| | | <el-option label="9" :value="9" /> |
| | | <el-option label="13" :value="13" /> |
| | | </el-select> |
| | | </el-form-item> |
| | |
| | | import useFormData from "@/hooks/useFormData"; |
| | | // import useUserStore from "@/store/modules/user"; |
| | | import { getLedgerById } from "@/api/equipmentManagement/ledger"; |
| | | import { processList } from "@/api/productionManagement/productionProcess"; |
| | | import dayjs from "dayjs"; |
| | | import { |
| | | calculateTaxIncludeTotalPrice, |
| | | calculateTaxExclusiveTotalPrice, |
| | | } from "@/utils/summarizeTable"; |
| | | import { ElMessage } from "element-plus"; |
| | | import {ref} from "vue"; |
| | | import { ref, onMounted } from "vue"; |
| | | |
| | | defineOptions({ |
| | | name: "设备台账表单", |
| | |
| | | '运输设备', |
| | | '其他设备' |
| | | ]); |
| | | const processOptions = ref([]); |
| | | const formRules = { |
| | | deviceName: [{ required: true, trigger: "blur", message: "请输入" }], |
| | | deviceModel: [{ required: true, trigger: "blur", message: "请输入" }], |
| | | type: [{ required: true, trigger: "change", message: "请选择或输入设备类型" }], |
| | | productProcessId: [{ required: true, trigger: "change", message: "请选择工序" }], |
| | | supplierName: [{ required: true, trigger: "blur", message: "请输入" }], |
| | | unit: [{ required: true, trigger: "blur", message: "请输入" }], |
| | | number: [{ required: true, trigger: "blur", message: "请输入" }], |
| | |
| | | deviceModel: undefined, // 规格型号 |
| | | deviceBrand: undefined, // 设备品牌 |
| | | type: undefined, // 设备类型 |
| | | productProcessId: undefined, // 工序ID |
| | | supplierName: undefined, // 供应商 |
| | | storageLocation: undefined, // 存放位置 |
| | | isDepr: 2, // 是否启用折旧 1-是 2-否 |
| | |
| | | form.deviceModel = data.deviceModel; |
| | | form.deviceBrand = data.deviceBrand; |
| | | form.type = data.type; |
| | | const processName = data.productProcessName || data.processName || data.process; |
| | | form.productProcessId = data.productProcessId; |
| | | if (!form.productProcessId && processName) { |
| | | const matched = processOptions.value.find(item => item.label === processName); |
| | | form.productProcessId = matched?.value; |
| | | } |
| | | ensureProcessOptionExists(form.productProcessId, processName); |
| | | form.supplierName = data.supplierName; |
| | | form.storageLocation = data.storageLocation; |
| | | form.isDepr = data.isDepr; |
| | |
| | | } else { |
| | | form.planRuntimeTime = undefined; |
| | | } |
| | | } |
| | | }; |
| | | |
| | | const ensureProcessOptionExists = (id, name) => { |
| | | if (!id) return; |
| | | if (!processOptions.value.some(item => item.value === id)) { |
| | | processOptions.value.push({ |
| | | value: id, |
| | | label: name || `${id}`, |
| | | }); |
| | | } |
| | | }; |
| | | |
| | | const getProcessOptions = async () => { |
| | | try { |
| | | const { code, data } = await processList({}); |
| | | if (code === 200 && Array.isArray(data)) { |
| | | processOptions.value = data |
| | | .filter(item => item?.id !== undefined && item?.id !== null) |
| | | .map(item => ({ |
| | | value: item.id, |
| | | label: item?.name || `${item.id}`, |
| | | })); |
| | | ensureProcessOptionExists(form.productProcessId); |
| | | } |
| | | } catch (error) { |
| | | processOptions.value = []; |
| | | } |
| | | }; |
| | | |
| | |
| | | clearValidate(); |
| | | }; |
| | | |
| | | onMounted(() => { |
| | | getProcessOptions(); |
| | | }); |
| | | |
| | | defineExpose({ |
| | | form, |
| | | loadForm, |