yyb
6 天以前 90459eef4842501cbb2f14f715b737f071016997
产品维护页面计量单位变更,逻辑变更
已修改2个文件
46 ■■■■ 文件已修改
src/views/basicData/product/ProductSelectDialog.vue 16 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/basicData/product/index.vue 30 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/basicData/product/ProductSelectDialog.vue
@@ -22,7 +22,7 @@
      <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">
@@ -43,13 +43,13 @@
<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<{
@@ -80,6 +80,16 @@
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;
}
src/views/basicData/product/index.vue
@@ -152,12 +152,13 @@
        </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>
@@ -206,8 +207,10 @@
    prop: "model",
  },
  {
    label: "单位",
    prop: "unit",
    label: "厚度",
    prop: "thickness",
    // 列表展示时统一保留 15 位小数
    formatData: (val) => formatThicknessTo15(val),
  },
  {
    dataType: "action",
@@ -245,14 +248,24 @@
  },
  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;
@@ -286,8 +299,8 @@
  modelOperationType.value = type;
  modelDia.value = true;
  modelForm.value.model = "";
  modelForm.value.model = "";
  modelForm.value.id = "";
  modelForm.value.thickness = "";
  if (type === "edit") {
    modelForm.value = { ...data };
  }
@@ -359,6 +372,7 @@
  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();