| | |
| | | <template> |
| | | <el-form :model="form" label-width="100px"> |
| | | <el-form :model="form" label-width="100px" :rules="formRules" ref="formRef"> |
| | | <el-row :gutter="20"> |
| | | <el-col :span="12"> |
| | | <el-form-item label="设备名称" prop="deviceName"> |
| | |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="规格型号" prop="deviceModel"> |
| | | <el-input v-model="form.deviceModel" placeholder="请输入规格型号" /> |
| | | <el-input v-model="form.deviceModel" :disabled="(form.deviceModel != null && operationType === 'edit')" placeholder="请输入规格型号" /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="设备品牌" prop="deviceBrand"> |
| | | <el-input v-model="form.deviceBrand" placeholder="请输入设备品牌" /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | |
| | | </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"> |
| | | <el-form-item label="启用折旧" prop="enableDepreciation"> |
| | | <el-switch v-model="form.enableDepreciation" :active-value="true" :inactive-value="false" /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | |
| | | placeholder="请输入含税单价" |
| | | maxlength="10" |
| | | @change="mathNum" |
| | | @input="handleNumberInput" |
| | | /> |
| | | </el-form-item> |
| | | </el-col> |
| | |
| | | <el-form-item label="含税总价" prop="taxIncludingPriceTotal"> |
| | | <el-input |
| | | v-model="form.taxIncludingPriceTotal" |
| | | placeholder="请输入含税总价" |
| | | placeholder="自动生成" |
| | | type="number" |
| | | disabled |
| | | /> |
| | |
| | | <el-form-item label="不含税总价" prop="unTaxIncludingPriceTotal"> |
| | | <el-input |
| | | v-model="form.unTaxIncludingPriceTotal" |
| | | placeholder="请输入不含税总价" |
| | | placeholder="自动生成" |
| | | type="number" |
| | | disabled |
| | | /> |
| | |
| | | calculateTaxExclusiveTotalPrice, |
| | | } from "@/utils/summarizeTable"; |
| | | import { ElMessage } from "element-plus"; |
| | | import {ref} from "vue"; |
| | | |
| | | defineOptions({ |
| | | name: "设备台账表单", |
| | | }); |
| | | const formRef = ref(null); |
| | | const operationType = ref(''); |
| | | const formRules = { |
| | | deviceName: [{ required: true, trigger: "blur", message: "请输入" }], |
| | | deviceModel: [{ required: true, trigger: "blur", 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: "请输入" }], |
| | | } |
| | | |
| | | const { form, resetForm } = useFormData({ |
| | | deviceName: undefined, // 设备名称 |
| | | deviceModel: undefined, // 规格型号 |
| | | deviceBrand: undefined, // 设备品牌 |
| | | supplierName: undefined, // 供应商 |
| | | storageLocation: undefined, // 存放位置 |
| | | enableDepreciation: false, // 是否启用折旧 |
| | | unit: undefined, // 单位 |
| | | number: undefined, // 数量 |
| | | taxIncludingPriceUnit: undefined, // 含税单价 |
| | |
| | | }); |
| | | |
| | | const loadForm = async (id) => { |
| | | if (id) { |
| | | operationType.value = 'edit' |
| | | } |
| | | const { code, data } = await getLedgerById(id); |
| | | if (code == 200) { |
| | | form.deviceName = data.deviceName; |
| | | form.deviceModel = data.deviceModel; |
| | | form.deviceBrand = data.deviceBrand; |
| | | form.supplierName = data.supplierName; |
| | | form.storageLocation = data.storageLocation; |
| | | form.enableDepreciation = data.enableDepreciation; |
| | | form.unit = data.unit; |
| | | form.number = data.number; |
| | | form.taxIncludingPriceUnit = data.taxIncludingPriceUnit; |
| | |
| | | } |
| | | }; |
| | | |
| | | const handleNumberInput = (value) => { |
| | | // 移除所有非数字字符 |
| | | let num = value.replace(/[^\d.]/g, ""); |
| | | // 清除表单校验状态 |
| | | const clearValidate = () => { |
| | | formRef.value?.clearValidate(); |
| | | }; |
| | | |
| | | // 限制长度为10 |
| | | if (num.length > 10) { |
| | | num = num.slice(0, 10); |
| | | } |
| | | |
| | | // 更新值 |
| | | form.taxIncludingPriceUnit = num; |
| | | // 重置表单数据和校验状态 |
| | | const resetFormAndValidate = () => { |
| | | resetForm(); |
| | | clearValidate(); |
| | | }; |
| | | |
| | | defineExpose({ |
| | | form, |
| | | loadForm, |
| | | resetForm, |
| | | clearValidate, |
| | | resetFormAndValidate, |
| | | formRef, |
| | | }); |
| | | </script> |