liding
昨天 298a75f485465ad049c1d5922a94026f81ca40d1
feat: 优化下单-检验
已修改7个文件
206 ■■■■ 文件已修改
src/api/standard/standardLibrary.js 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/utils/standardTree.js 5 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/business/inspectionTask/inspection.vue 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/business/inspectionView/index.vue 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/business/productOrder/components/addOrder.vue 79 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/business/productOrder/components/addView.vue 35 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/standard/standardLibrary/index.vue 49 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/api/standard/standardLibrary.js
@@ -132,6 +132,14 @@
  });
}
export function selectTemplateBindings(query) {
  return request({ url: "/standardTree/selectTemplateBindings", method: "get", params: query });
}
export function saveTemplateBindings(data) {
  return request({ url: "/standardTree/saveTemplateBindings", method: "post", data });
}
// 获取标准方法枚举
export function selectStandardMethods(query) {
  return request({
src/utils/standardTree.js
@@ -1,7 +1,8 @@
/**
 * 标准库树通用工具
 *
 * 层级不固定:children 为 null / undefined / 空数组的节点即为「标准」叶子。
 * 标准库固定两级:code=[1] 为行业,code=[2] 为标准。
 * 兼容没有 code 的旧接口数据时,再回退到 children 判断叶子。
 * 树路径统一由 " - " 连接,格式与历史实现逐字节保持一致:
 * 顶层真实节点的 parent 是 Element UI 的虚拟根,因此根节点会进入路径。
 */
@@ -9,6 +10,8 @@
// 是否叶子(标准)
export function isLeaf(data) {
  if (!data) return true;
  if (data.code === '[1]') return false;
  if (data.code === '[2]') return true;
  const children = data.children;
  return children === null || children === undefined || children.length === 0;
}
src/views/business/inspectionTask/inspection.vue
@@ -1974,6 +1974,21 @@
      });
      // 本次循环主要是控制合并,以及控制检验项信息是否展示出来,以便后续检验
      this.tableList.forEach((a) => {
        // 新聚订单直接按“模板ID + 模板行号”绑定检验记录,不再匹配分类和检验子项。
        const directProducts = this.currentSample.insProduct.filter(
          (product) => product.templateId === a.templateId &&
            product.templateRowIndex !== null && product.templateRowIndex !== undefined
        );
        if (directProducts.length > 0) {
          directProducts.forEach((product) => {
            a.template.forEach((cell) => {
              if (cell.r === product.templateRowIndex) {
                cell.i = product.id;
              }
            });
          });
          return;
        }
        let dels = new Set(); //需要删除的行
        let ids = []; //所有检验项的id
        let set3 = new Set();
src/views/business/inspectionView/index.vue
@@ -1756,6 +1756,21 @@
      });
      // 本次循环主要是控制合并,以及控制检验项信息是否展示出来,以便后续检验
      this.tableList.forEach((a) => {
        // 新聚订单直接按“模板ID + 模板行号”绑定检验记录,不再匹配分类和检验子项。
        const directProducts = this.currentSample.insProduct.filter(
          (product) => product.templateId === a.templateId &&
            product.templateRowIndex !== null && product.templateRowIndex !== undefined
        );
        if (directProducts.length > 0) {
          directProducts.forEach((product) => {
            a.template.forEach((cell) => {
              if (cell.r === product.templateRowIndex) {
                cell.i = product.id;
              }
            });
          });
          return;
        }
        let dels = new Set(); //需要删除的行
        let ids = []; //所有检验项的id
        let set3 = new Set();
src/views/business/productOrder/components/addOrder.vue
@@ -42,7 +42,28 @@
    </div>
    <div v-show="!cableConfigShow&&!auxiliaryShow" style="margin-top: 10px">
      <div class="search">
        <el-form ref="addObj" :inline="true" :model="addObj" :rules="addObjRules" label-width="108px" label-position="right">
        <el-form ref="newJuOrder" :inline="true" :model="addObj" label-width="108px" label-position="right">
          <el-row>
            <el-col :span="6"><el-form-item label="产品名称"><el-input v-model="addObj.sample" disabled size="small"><template slot="append"><el-button :disabled="active>1" icon="el-icon-search" @click="selectStandardTree = true" /></template></el-input></el-form-item></el-col>
            <el-col :span="6"><el-form-item label="生产单位"><el-input v-model="addObj.production" :disabled="active>1" size="small" /></el-form-item></el-col>
            <el-col :span="6"><el-form-item label="委托单位"><el-input v-model="addObj.company" disabled size="small"><template slot="append"><el-button :disabled="active>1" icon="el-icon-search" @click="openCompanyList" /></template></el-input></el-form-item></el-col>
            <el-col :span="6"><el-form-item label="检验类别"><el-select v-model="addObj.orderType" :disabled="active>1" size="small"><el-option v-for="item in dict.type.check_type1" :key="item.value" :label="item.label" :value="item.value" /></el-select></el-form-item></el-col>
          </el-row>
          <el-row>
            <el-col :span="6"><el-form-item label="样品数量"><el-input v-model="addObj.testQuantity" :disabled="active>1" placeholder="如:2桶、500mL" size="small" /></el-form-item></el-col>
            <el-col :span="6"><el-form-item label="样品编号"><el-input v-model="sampleCode" :disabled="active>1" size="small" /></el-form-item></el-col>
            <el-col :span="6"><el-form-item label="样品外观"><el-input v-model="addObj.sampleStatus" :disabled="active>1" size="small" /></el-form-item></el-col>
            <el-col :span="6"><el-form-item label="送样人"><el-input v-model="addObj.prepareUser" :disabled="active>1" size="small" /></el-form-item></el-col>
          </el-row>
          <el-row>
            <el-col :span="6"><el-form-item label="生产日期"><el-date-picker v-model="addObj.productionDate" type="date" value-format="yyyy-MM-dd" :disabled="active>1" size="small" /></el-form-item></el-col>
            <el-col :span="6"><el-form-item label="生产批号"><el-input v-model="addObj.productionBatch" :disabled="active>1" size="small" /></el-form-item></el-col>
            <el-col :span="6"><el-form-item label="送样日期"><el-date-picker v-model="addObj.sampleDate" type="date" value-format="yyyy-MM-dd" :disabled="active>1" size="small" /></el-form-item></el-col>
            <el-col :span="6"><el-form-item label="联系方式"><el-input v-model="addObj.phone" :disabled="active>1" size="small" /></el-form-item></el-col>
          </el-row>
          <el-row><el-col :span="6"><el-form-item label="环境条件"><el-input v-model="addObj.temperature" :disabled="active>1" placeholder="温度" size="small" /></el-form-item></el-col><el-col :span="6"><el-form-item label="湿度"><el-input v-model="addObj.humidity" :disabled="active>1" size="small" /></el-form-item></el-col><el-col :span="6"><el-form-item label="备注"><el-input v-model="addObj.remark" :disabled="active>1" size="small" /></el-form-item></el-col></el-row>
        </el-form>
        <el-form v-if="false" ref="addObj" :inline="true" :model="addObj" :rules="addObjRules" label-width="108px" label-position="right">
          <el-row>
            <el-col :span="6">
              <el-form-item label="委托编号:" prop="entrustCode">
@@ -205,7 +226,7 @@
          </el-row>
        </el-form>
      </div>
      <div>
      <div v-if="false">
        <div style="display: flex;justify-content: space-between;background-color: #F5F7FB;margin-bottom: 6px">
          <div v-if="active==1">
            <el-form :inline="true" :model="addObj1" label-width="90px">
@@ -427,7 +448,7 @@
              <el-col :span="24">
                <span><i
                    :class="`node_i ${data.children != undefined ? (data.code==='[1]'?'el-icon-folder-opened':'el-icon-folder') : 'el-icon-tickets'}`"></i>
                  {{ data.code }} {{ data.label }}</span>
                  {{ data.label }}</span>
              </el-col>
            </el-row>
          </div>
@@ -615,7 +636,6 @@
import {
  isLeafPath,
  buildSelectTree,
  deriveTreeFields,
  dropLastLabel,
} from "@/utils/standardTree";
@@ -644,6 +664,7 @@
      active: '',
      tabIndex: '',
      currentId: '',
      sampleCode: '',
      sampleSelectionList: [],//样品表格选中数据
      editTable:[],
      template: null,
@@ -1157,6 +1178,14 @@
        return str.replaceAll(find, value);
      },
      save() {
        if (this.addObj.standardTreeId) {
          if (!this.addObj.sample || !this.addObj.company || !this.addObj.orderType || !this.addObj.testQuantity) {
            this.$message.error('请填写产品名称、委托单位、检验类别和样品数量');
            return;
          }
          this.saveData([]);
          return;
        }
        this.$refs['addObj'].validate((valid) => {
          if (valid) {
            this.sampleList.forEach(item => {
@@ -1337,6 +1366,10 @@
        }
      },
      saveMethod(sampleList){
        if (this.addObj.standardTreeId) {
          this.saveData([]);
          return;
        }
        if (this.addObj.quarterItemId) {
          this.addObj.quarterItemId = this.addObj.quarterItemId[1]
        }
@@ -1383,7 +1416,10 @@
        })
      }else{
        // 常规提交
        addInsOrder({insOrder: {...this.addObj,typeSource:-1}, sampleList: sampleList}).then(res => {
        const payload = this.addObj.standardTreeId
          ? { insOrder: {...this.addObj,typeSource:-1}, standardTreeId: this.addObj.standardTreeId, sampleCode: this.sampleCode }
          : { insOrder: {...this.addObj,typeSource:-1}, sampleList: sampleList }
        addInsOrder(payload).then(res => {
          this.saveLoad = false
          this.$message.success('已提交')
          this.bsm3Dia = false;
@@ -1512,38 +1548,15 @@
        return data.label.indexOf(value) !== -1;
      },
      activeStandardTree() {
        const fields = deriveTreeFields(this.selectTreeNode)
        if (fields.labels.length < 2) {
          this.$message.error('未选择对象')
        if (!this.selectTreeNode || this.selectTreeNode.data.code !== '[2]') {
          this.$message.error('请选择二级产品')
          return
        }
        this.addObj.factory = fields.factory
        this.addObj.laboratory = fields.laboratory
        this.addObj.sampleType = fields.sampleType
        this.addObj.sample = fields.sample || fields.sampleType
        this.addObj.sampleView = this.addObj.sample
        this.addObj.sampleViewEn = this.sampleViewEn
        this.addObj.model = fields.model
        const productName = this.selectTreeNode.data.label
        this.addObj.sample = productName
        this.addObj.standardTreeId = this.selectTreeNode.data.id
        this.selectStandardTree = false
        this.sampleList = []
        for (var i = 0; i < this.addObj.sampleNum; i++) {
          this.sample.joinName = null
          this.sample.joinModel = null
          this.sample.joinNum = 1
          this.sample.sample = this.addObj.sample
          this.sample.model = this.addObj.model
          this.sample.unit = this.addObj.unit
          this.sample.standardMethodListId = null
          this.sample.insProduct = []
          this.sample.id = this.count
          this.sample.childSampleList = []
          this.sample.insulating = null
          this.sample.sheath = null
          this.sampleList.push(this.HaveJson(this.sample))
          this.count++
        }
        this.$refs.sampleTable.doLayout()
        // this.selectsStandardMethodByFLSSM()
      },
      // 用指定型号替换树路径末段(末段即标准/型号)
      buildFactoryPath(model) {
src/views/business/productOrder/components/addView.vue
@@ -4,7 +4,7 @@
      <div style="display: flex;justify-content: space-between;align-items:center;">
        <div>委托单信息</div>
        <div>
          <el-cascader
          <el-cascader v-if="false"
            v-model="addObj.quarterItemId"
            :disabled="active>1"
            :options="quarterItemOptions"
@@ -38,7 +38,32 @@
    </div>
    <div v-show="!cableConfigShow&&!auxiliaryShow" style="margin-top: 10px">
      <div class="search">
        <el-form ref="addObj" :inline="true" :model="addObj" :rules="addObjRules" label-width="108px" label-position="right">
        <el-form :inline="true" :model="addObj" label-width="108px" label-position="right">
          <el-row>
            <el-col :span="6"><el-form-item label="产品名称"><el-input v-model="addObj.sample" disabled size="small" /></el-form-item></el-col>
            <el-col :span="6"><el-form-item label="生产单位"><el-input v-model="addObj.production" disabled size="small" /></el-form-item></el-col>
            <el-col :span="6"><el-form-item label="委托单位"><el-input v-model="addObj.company" disabled size="small" /></el-form-item></el-col>
            <el-col :span="6"><el-form-item label="检验类别"><el-select v-model="addObj.orderType" disabled size="small"><el-option v-for="item in dict.type.check_type1" :key="item.value" :label="item.label" :value="item.value" /></el-select></el-form-item></el-col>
          </el-row>
          <el-row>
            <el-col :span="6"><el-form-item label="样品数量"><el-input v-model="addObj.testQuantity" disabled size="small" /></el-form-item></el-col>
            <el-col :span="6"><el-form-item label="样品编号"><el-input v-model="sampleCode" disabled size="small" /></el-form-item></el-col>
            <el-col :span="6"><el-form-item label="样品外观"><el-input v-model="addObj.sampleStatus" disabled size="small" /></el-form-item></el-col>
            <el-col :span="6"><el-form-item label="送样人"><el-input v-model="addObj.prepareUser" disabled size="small" /></el-form-item></el-col>
          </el-row>
          <el-row>
            <el-col :span="6"><el-form-item label="生产日期"><el-date-picker v-model="addObj.productionDate" type="date" value-format="yyyy-MM-dd" disabled size="small" /></el-form-item></el-col>
            <el-col :span="6"><el-form-item label="生产批号"><el-input v-model="addObj.productionBatch" disabled size="small" /></el-form-item></el-col>
            <el-col :span="6"><el-form-item label="送样日期"><el-date-picker v-model="addObj.sampleDate" type="date" value-format="yyyy-MM-dd" disabled size="small" /></el-form-item></el-col>
            <el-col :span="6"><el-form-item label="联系方式"><el-input v-model="addObj.phone" disabled size="small" /></el-form-item></el-col>
          </el-row>
          <el-row>
            <el-col :span="6"><el-form-item label="环境条件"><el-input v-model="addObj.temperature" disabled placeholder="温度" size="small" /></el-form-item></el-col>
            <el-col :span="6"><el-form-item label="湿度"><el-input v-model="addObj.humidity" disabled size="small" /></el-form-item></el-col>
            <el-col :span="12"><el-form-item label="备注"><el-input v-model="addObj.remark" disabled size="small" style="width: 520px" /></el-form-item></el-col>
          </el-row>
        </el-form>
        <el-form v-show="false" ref="addObj" :inline="true" :model="addObj" :rules="addObjRules" label-width="108px" label-position="right">
          <el-row>
            <el-col :span="6">
              <el-form-item label="委托编号:" prop="entrustCode">
@@ -201,7 +226,7 @@
          </el-row>
        </el-form>
      </div>
      <div>
      <div v-show="false">
        <div style="display: flex;justify-content: space-between;background-color: #F5F7FB;margin-bottom: 6px">
          <div v-if="active==1">
            <el-form :inline="true" :model="addObj1" label-width="90px">
@@ -415,7 +440,7 @@
              <el-col :span="24">
                <span><i
                    :class="`node_i ${data.children != undefined ? (data.code==='[1]'?'el-icon-folder-opened':'el-icon-folder') : 'el-icon-tickets'}`"></i>
                  {{ data.code }} {{ data.label }}</span>
                  {{ data.label }}</span>
              </el-col>
            </el-row>
          </div>
@@ -618,6 +643,7 @@
      active: '',
      tabIndex: '',
      currentId: '',
      sampleCode: '',
      sampleSelectionList: [],//样品表格选中数据
      editTable:[],
      template: null,
@@ -862,6 +888,7 @@
          };
          this.addObj.type = String(this.addObj.type)
          this.sampleList = this.HaveJson(res.data.sampleProduct);
          this.sampleCode = this.sampleList.length ? this.sampleList[0].sampleCode : ''
          this.specialStandardMethod = this.sampleList[0].specialStandardMethod
          this.getProNum()
          this.addObj.sampleNum = this.sampleList.length
src/views/standard/standardLibrary/index.vue
@@ -56,6 +56,17 @@
        </pane>
        <!--用户数据-->
        <pane size="88">
          <el-card v-if="selected.isLeaf" shadow="never" class="template-binding-card">
            <div slot="header"><span>原始记录模板</span><el-button v-if="checkPermi(['standard:standardLibrary:upStandardProduct'])" type="primary" size="mini" style="float:right" @click="saveBindings">保存绑定</el-button></div>
            <p v-if="!templateBindings.length" class="binding-tip">请为当前标准绑定原始记录模板;模板中须使用“检验项”标记。</p>
            <el-table :data="templateBindings" border size="small">
              <el-table-column type="index" label="顺序" width="70" /><el-table-column label="模板编号" prop="number" width="180" /><el-table-column label="模板名称" prop="name" /><el-table-column label="检测依据(模板备注)" prop="remark" />
              <el-table-column v-if="checkPermi(['standard:standardLibrary:upStandardProduct'])" label="操作" width="150"><template slot-scope="scope"><el-button type="text" :disabled="scope.$index === 0" @click="moveBinding(scope.$index, -1)">上移</el-button><el-button type="text" :disabled="scope.$index === templateBindings.length - 1" @click="moveBinding(scope.$index, 1)">下移</el-button><el-button type="text" @click="removeBinding(scope.$index)">移除</el-button></template></el-table-column>
            </el-table>
            <el-select v-if="checkPermi(['standard:standardLibrary:upStandardProduct'])" v-model="templateToBind" filterable placeholder="选择原始记录模板" size="small" style="width:320px;margin-top:16px" @change="addBinding"><el-option v-for="template in templateList.filter(item => !templateBindings.some(binding => binding.templateId === item.id))" :key="template.id" :label="template.number ? template.number + ' - ' + template.name : template.name" :value="template.id" /></el-select>
          </el-card>
          <el-empty v-else description="请选择二级标准,维护其原始记录模板" />
          <div v-if="false">
          <div class="search_form">
            <div style="height:37px">
              <p style="font-size: 14px; color: #999;margin-left: 10px">{{ selectTree }}</p>
@@ -192,6 +203,7 @@
              <p style="text-align: right;margin-right: 20px;color: #333;">共{{ total }}条</p>
            </el-row>
          </el-col>
          </div>
        </pane>
      </splitpanes>
    </el-row>
@@ -321,6 +333,8 @@
  selectStandardProductListByMethodId,
  updateSection,
  getStandardTemplate,
  selectTemplateBindings,
  saveTemplateBindings,
} from "@/api/standard/standardLibrary";
import bindSupplierDensityDialogAsk from "./components/bindSupplierDensityDialogAsk.vue";
import BatchCopy from "./components/BatchCopy.vue";
@@ -391,6 +405,8 @@
      sectionRow: null,
      sectionList: [],
      templateList: [],
      templateBindings: [],
      templateToBind: null,
      total: 0,
      currentPage: 1,
      standardId: 0,
@@ -495,6 +511,7 @@
      this.currentPage = 1;
      this.selectTree = buildSelectTree(node, "null");
      this.selected = {
        id: val.id,
        label: val.label,
        tree: this.selectTree,
        isLeaf: leaf,
@@ -504,10 +521,11 @@
      this.standardList = [];
      this.productList = [];
      if (leaf) {
        this.selectsStandardMethodByFLSSM();
        this.loadTemplateBindings(val.id);
      } else {
        this.standardId = 0;
        this.syncSortable();
        this.templateBindings = [];
      }
    },
    remove(node, data) {
@@ -965,6 +983,35 @@
        this.templateList = res.data;
      });
    },
    loadTemplateBindings(standardTreeId) {
      selectTemplateBindings({ standardTreeId }).then((res) => {
        this.templateBindings = res.data || [];
        this.templateToBind = null;
      });
    },
    addBinding(templateId) {
      const template = this.templateList.find((item) => item.id === templateId);
      if (template && !this.templateBindings.some((item) => item.templateId === templateId)) {
        this.templateBindings.push({ ...template, templateId, sort: this.templateBindings.length });
      }
      this.templateToBind = null;
    },
    removeBinding(index) {
      this.templateBindings.splice(index, 1);
    },
    moveBinding(index, offset) {
      const target = index + offset;
      const item = this.templateBindings.splice(index, 1)[0];
      this.templateBindings.splice(target, 0, item);
    },
    saveBindings() {
      saveTemplateBindings({ standardTreeId: this.selected.id,
        templates: this.templateBindings.map((item, index) => ({ templateId: item.templateId, sort: index }))
      }).then(() => {
        this.$message.success("模板绑定已保存");
        this.loadTemplateBindings(this.selected.id);
      });
    },
    handleCurrentChange(val) {
      this.currentPage = val;
      this.tableLoad2 = true;