| | |
| | | <el-table-column type="index" label="序号" width="60" /> |
| | | <el-table-column prop="productName" label="产品大类" min-width="160" /> |
| | | <el-table-column prop="model" label="型号名称" min-width="200" /> |
| | | <el-table-column prop="unit" label="单位" min-width="160" /> |
| | | <el-table-column prop="thickness" label="厚度" min-width="160" :formatter="formatThicknessTo15" /> |
| | | </el-table> |
| | | |
| | | <div class="mt-3 flex justify-end"> |
| | |
| | | <script setup lang="ts"> |
| | | import { computed, onMounted, reactive, ref, watch, nextTick } from "vue"; |
| | | import { ElMessage } from "element-plus"; |
| | | import { productModelList } from '@/api/basicData/productModel' |
| | | import { productModelList } from '@/api/basicData/productModel.js' |
| | | |
| | | export type ProductRow = { |
| | | id: number; |
| | | productName: string; |
| | | model: string; |
| | | unit?: string; |
| | | thickness?: string; |
| | | }; |
| | | |
| | | const props = defineProps<{ |
| | |
| | | const multipleSelection = ref<ProductRow[]>([]); |
| | | const tableRef = ref(); |
| | | |
| | | // 表格展示时统一保留 15 位小数 |
| | | const formatThicknessTo15 = (_row: any, _column: any, cellValue: any) => { |
| | | if (cellValue === null || cellValue === undefined) return ""; |
| | | const s = String(cellValue).trim(); |
| | | if (s === "") return ""; |
| | | const n = Number(s); |
| | | if (Number.isNaN(n)) return s; |
| | | return n.toFixed(15); |
| | | }; |
| | | |
| | | function close() { |
| | | visible.value = false; |
| | | } |
| | |
| | | </el-row> |
| | | <el-row> |
| | | <el-col :span="24"> |
| | | <el-form-item label="单位:" prop="unit"> |
| | | <el-form-item label="厚度:" prop="thickness"> |
| | | <el-input |
| | | v-model="modelForm.unit" |
| | | placeholder="请输入单位" |
| | | v-model="modelForm.thickness" |
| | | placeholder="请输入厚度" |
| | | clearable |
| | | @keydown.enter.prevent |
| | | @blur="modelForm.thickness = formatThicknessTo15(modelForm.thickness)" |
| | | /> |
| | | </el-form-item> |
| | | </el-col> |
| | |
| | | prop: "model", |
| | | }, |
| | | { |
| | | label: "单位", |
| | | prop: "unit", |
| | | label: "厚度", |
| | | prop: "thickness", |
| | | // 列表展示时统一保留 15 位小数 |
| | | formatData: (val) => formatThicknessTo15(val), |
| | | }, |
| | | { |
| | | dataType: "action", |
| | |
| | | }, |
| | | modelForm: { |
| | | model: "", |
| | | unit: "", |
| | | thickness: "", |
| | | }, |
| | | modelRules: { |
| | | model: [{ required: true, message: "请输入", trigger: "blur" }], |
| | | unit: [{ required: true, message: "请输入", trigger: "blur" }], |
| | | thickness: [{ required: true, message: "请输入", trigger: "blur" }], |
| | | }, |
| | | }); |
| | | const { form, rules, modelForm, modelRules } = toRefs(data); |
| | | |
| | | // 把厚度格式化成固定 15 位小数(用于展示/提交) |
| | | const formatThicknessTo15 = (val) => { |
| | | if (val === null || val === undefined) return ""; |
| | | const s = String(val).trim(); |
| | | if (s === "") return ""; |
| | | const n = Number(s); |
| | | if (Number.isNaN(n)) return s; |
| | | return n.toFixed(15); |
| | | }; |
| | | // 查询产品树 |
| | | const getProductTreeList = () => { |
| | | treeLoad.value = true; |
| | |
| | | modelOperationType.value = type; |
| | | modelDia.value = true; |
| | | modelForm.value.model = ""; |
| | | modelForm.value.model = ""; |
| | | modelForm.value.id = ""; |
| | | modelForm.value.thickness = ""; |
| | | if (type === "edit") { |
| | | modelForm.value = { ...data }; |
| | | } |
| | |
| | | proxy.$refs.modelFormRef.validate((valid) => { |
| | | if (valid) { |
| | | modelForm.value.productId = currentId.value; |
| | | modelForm.value.thickness = formatThicknessTo15(modelForm.value.thickness); |
| | | addOrEditProductModel(modelForm.value).then((res) => { |
| | | proxy.$modal.msgSuccess("提交成功"); |
| | | closeModelDia(); |