yusheng 1 год назад
Родитель
Сommit
c17457f524

+ 1 - 0
src/api/classifyManage/index.js

@@ -87,3 +87,4 @@ export async function getList(params) {
   }
   return Promise.reject(new Error(res.data.message));
 }
+

+ 18 - 0
src/api/inspectionTemplate/index.js

@@ -57,3 +57,21 @@ export async function getList(data) {
   }
   return Promise.reject(new Error(res.data.message));
 }
+
+
+export async function templatecategoryPage(params) {
+  const res = await request.get(`/qms/templatecategory/page`, {params});
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}
+
+// 通过方案ids获取质检项
+export async function getQualityTemplateByIds(data) {
+  const res = await request.post(`/qms/qualitytemplate/getQualityTemplateByIds`, data);
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}

+ 128 - 113
src/components/AssetTree/index.vue

@@ -2,139 +2,154 @@
   <div class="tree-wrapper">
     <!-- <el-input placeholder="输入关键字进行过滤" v-model="filterText">
     </el-input> -->
-    <el-tree :data="treeList" :props="defaultProps" v-loading="treeLoading" :node-key="nodeKey" ref="tree"
-      :highlight-current="true" :expand-on-click-node="false" @node-click="handleNodeClick" v-bind="$attrs"
-      :default-expand-all="defaultExpandAll" :filter-node-method="filterNode">
+    <el-tree
+      :data="treeList"
+      :props="defaultProps"
+      v-loading="treeLoading"
+      :node-key="nodeKey"
+      ref="tree"
+      :highlight-current="true"
+      :expand-on-click-node="false"
+      @node-click="handleNodeClick"
+      v-bind="$attrs"
+      :default-expand-all="defaultExpandAll"
+      :filter-node-method="filterNode"
+    >
     </el-tree>
   </div>
 </template>
 
 <script>
-import { getTreeByIds } from '@/api/classifyManage';
+  import { getTreeByIds, getProduceTreeByPid } from '@/api/classifyManage';
 
-export default {
-  props: {
-    // treeList私有化处理
-    treeFormate: {
-      type: Function,
-      default: null
-    },
-    defaultProps: {
-      type: Object,
-      default: function () {
-        return {
-          children: 'children',
-          value: 'id',
-          label: 'name'
-        };
-      }
-    },
-    defaultExpandAll: {
-      type: Boolean,
-      default: function () {
-        return true;
+  export default {
+    props: {
+      // treeList私有化处理
+      treeFormate: {
+        type: Function,
+        default: null
+      },
+      defaultProps: {
+        type: Object,
+        default: function () {
+          return {
+            children: 'children',
+            value: 'id',
+            label: 'name'
+          };
+        }
+      },
+      defaultExpandAll: {
+        type: Boolean,
+        default: function () {
+          return true;
+        }
+      },
+      // 初始请求treeList
+      init: {
+        type: Boolean,
+        default: true
+      },
+      treeIds: {
+        type: Array,
+        default: () => []
+      },
+      typeS: {
+        type: Array,
+        default: () => []
+      },
+      nodeKey: {
+        type: String,
+        default: 'id'
       }
     },
-    // 初始请求treeList
-    init: {
-      type: Boolean,
-      default: true
+    watch: {
+      // filterText(val) {
+      //   this.$refs.tree.filter(val);
+      // }
     },
-    treeIds: {
-      type: Array,
-      default: () => []
+    data() {
+      return {
+        // filterText: '',
+        treeList: [],
+        treeLoading: false,
+        parentName: '',
+        parentId: '',
+        currentKey: ''
+      };
     },
-    nodeKey: {
-      type: String,
-      default: 'id'
-    }
-  },
-  watch: {
-    // filterText(val) {
-    //   this.$refs.tree.filter(val);
-    // }
-  },
-  data() {
-    return {
-      // filterText: '',
-      treeList: [],
-      treeLoading: false,
-      parentName: '',
-      parentId: '',
-      currentKey: ''
-    };
-  },
-  mounted() {
-    if (this.init) {
-      this.getTreeData();
-    }
-  },
-  methods: {
-    filterNode(value, data) {
-      if (!value) return true;
-      return data.name.indexOf(value) !== -1;
-    },
-    getInstance() {
-      return this.$refs.tree;
+    mounted() {
+      if (this.init) {
+        this.getTreeData();
+      }
     },
-    // 获取树结构数据
-    async getTreeData() {
-      try {
-        this.treeLoading = true;
+    methods: {
+      filterNode(value, data) {
+        if (!value) return true;
+        return data.name.indexOf(value) !== -1;
+      },
+      getInstance() {
+        return this.$refs.tree;
+      },
+      // 获取树结构数据
+      async getTreeData() {
+        try {
+          this.treeLoading = true;
 
-        const res = await getTreeByIds({ ids: this.treeIds.join(',') });
-        this.treeLoading = false;
-        if (res?.code === '0') {
-          this.treeList = res.data;
-          this.$emit('setRootId', res.data[0].id);
-          if (this.treeFormate) {
-            this.treeList = this.treeFormate(this.treeList);
-          }
-          this.$nextTick(() => {
-            // 默认高亮第一级树节点
-            if (this.treeList[0]) {
-              this.setCurrentKey(this.treeList[0].id);
-              this.handleNodeClick(
-                this.treeList[0],
-                this.$refs.tree.getCurrentNode()
-              );
+          const res =this.typeS.length>0?await getProduceTreeByPid(this.typeS.toString()): await getTreeByIds({ ids: this.treeIds.join(',') });
+      
+          this.treeLoading = false;
+          if (res?.code === '0') {
+            this.treeList = res.data;
+            this.$emit('setRootId', res.data[0].id);
+            if (this.treeFormate) {
+              this.treeList = this.treeFormate(this.treeList);
             }
-          });
-          return this.treeList;
+            this.$nextTick(() => {
+              // 默认高亮第一级树节点
+              if (this.treeList[0]) {
+                this.setCurrentKey(this.treeList[0].id);
+                this.handleNodeClick(
+                  this.treeList[0],
+                  this.$refs.tree.getCurrentNode()
+                );
+              }
+            });
+            return this.treeList;
+          }
+        } catch (error) {
+          console.log(error);
         }
-      } catch (error) {
-        console.log(error);
-      }
-      this.treeLoading = false;
-    },
+        this.treeLoading = false;
+      },
 
-    handleNodeClick(data, node) {
-      this.$emit('handleNodeClick', data, node);
-    },
-    // 设置默认高亮行
-    setCurrentKey(id) {
-      this.currentKey = id;
-      this.$refs.tree.setCurrentKey(this.currentKey);
-    },
+      handleNodeClick(data, node) {
+        this.$emit('handleNodeClick', data, node);
+      },
+      // 设置默认高亮行
+      setCurrentKey(id) {
+        this.currentKey = id;
+        this.$refs.tree.setCurrentKey(this.currentKey);
+      },
 
-    // 获取树的选中状态
-    getSelectList() {
-      const selectList = this.$refs.tree.getCurrentNode();
-      return selectList;
+      // 获取树的选中状态
+      getSelectList() {
+        const selectList = this.$refs.tree.getCurrentNode();
+        return selectList;
+      }
     }
-  }
-};
+  };
 </script>
 
 <style lang="scss" scoped>
-.tree-wrapper {
-  width: 100%;
-  height: 100%;
-  overflow: auto;
+  .tree-wrapper {
+    width: 100%;
+    height: 100%;
+    overflow: auto;
 
-  :deep(.el-tree) {
-    display: inline-block;
-    min-width: 100%;
+    :deep(.el-tree) {
+      display: inline-block;
+      min-width: 100%;
+    }
   }
-}
 </style>

+ 17 - 4
src/views/inspectionPlan/components/edit.vue

@@ -66,6 +66,7 @@
           </ele-pro-table>
         </el-tab-pane>
         <el-tab-pane label="样品清单" name="2">
+          
           <el-table v-show="activeName === '2'" v-if="sampleList.length > 0" ref="showSampleListTable"
             :data="paginatedSampleList" tooltip-effect="dark" :max-height="300" border row-key="id">
             <el-table-column label="序号" type="index" width="50" align="center"></el-table-column>
@@ -81,6 +82,7 @@
             style="margin-top: 10px"></el-pagination>
         </el-tab-pane>
         <el-tab-pane label="质检方案" name="3">
+          <el-button @click="addInspectionTemplate" type="primary" style="margin-top: 5px;">选择质检方案</el-button>
           <el-table v-show="activeName === '3'" v-if="schemeList.length > 0" ref="showSchemeListTable"
             :data="paginatedSchemeList" tooltip-effect="dark" :max-height="300" border row-key="id">
             <el-table-column label="序号" type="index" width="50" align="center"></el-table-column>
@@ -111,13 +113,14 @@
       <el-button v-if="btnType != 'detail'" type="primary" :loading="loading" @click="handleIssued">
         下发
       </el-button>
+      <inspectionTemplateDialog ref="inspectionTemplateRef" @choose="inspectionTemplateSuccess"></inspectionTemplateDialog>
     </template>
   </ele-modal>
 </template>
 
 <script>
 import baseInfo from './baseInfo.vue';
-
+import inspectionTemplateDialog from '@/views/inspectionTemplate/components/inspectionTemplateDialog.vue';
 import { getCode } from '@/api/login';
 import { save, update, planIssued } from '@/api/inspectionPlan';
 import {
@@ -128,10 +131,12 @@ import {
   outInRecordsPage,
   getBatchInfoData
 } from '@/api/inspectionPlan/index.js';
+import { getQualityTemplateByIds } from '@/api/inspectionTemplate';
+
 
 export default {
   components: {
-    baseInfo
+    baseInfo,inspectionTemplateDialog
   },
   data() {
     const defaultForm = function () {
@@ -408,6 +413,13 @@ export default {
       }
 
     },
+    addInspectionTemplate(){
+       this.$refs.inspectionTemplateRef.open()
+    },
+    async inspectionTemplateSuccess(select){
+      let data= await getQualityTemplateByIds({templateIds:select.map(item=>item.id)})
+          this.schemeList.push(...data)
+    },
     async handleEditOrDetail(row) {
       console.log('row====', row);
       row.accessory = row.accessory || [];
@@ -472,7 +484,8 @@ export default {
 
     async getTemplateList(id) {
       let res = await getTemplateListByPlanId({
-        planId: id
+        planId: id,
+        size:-1
       });
       console.log(res.list, 'fffffffffffffff方案--------------------------');
       this.schemeList = res?.list || [];
@@ -638,7 +651,7 @@ export default {
 
       await getQualityTemplateList({
         productCode: productCode,
-        qualityQlanId: ids
+        qualityQlanId: ids,
       }).then((res) => {
         if (Object.keys(res).length === 0) {
           this.$message.error('请确认该物品是否配置质检方案!');

+ 346 - 170
src/views/inspectionTemplate/AddorUpdate.vue

@@ -5,40 +5,80 @@
   <!--    :visible.sync="visible"-->
   <!--    width="60%"-->
   <!--  >-->
-  <ele-modal :title="!dataForm.id ? '新增' : '修改'" :visible.sync="visible" :before-close="handleClose"
-    :close-on-click-modal="false" :close-on-press-escape="false" append-to-body width="80%" :maxable="true">
-    <el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmit()"
-      label-width="80px">
+  <ele-modal
+    :title="!dataForm.id ? '新增' : '修改'"
+    :visible.sync="visible"
+    :before-close="handleClose"
+    :close-on-click-modal="false"
+    :close-on-press-escape="false"
+    append-to-body
+    width="80%"
+    :maxable="true"
+  >
+    <el-form
+      :model="dataForm"
+      :rules="dataRule"
+      ref="dataForm"
+      @keyup.enter.native="dataFormSubmit()"
+      label-width="80px"
+    >
       <el-row>
         <el-col :span="8">
           <el-form-item label="名称" prop="qualitySchemeTemplateName">
-            <el-input v-model="dataForm.qualitySchemeTemplateName" placeholder="质检方案名称"></el-input>
+            <el-input
+              v-model="dataForm.qualitySchemeTemplateName"
+              placeholder="质检方案名称"
+            ></el-input>
           </el-form-item>
         </el-col>
         <el-col :span="8">
           <el-form-item label="编码" prop="qualitySchemeTemplateCode">
-            <el-input v-model="dataForm.qualitySchemeTemplateCode" placeholder="质检方案编码" disabled></el-input>
+            <el-input
+              v-model="dataForm.qualitySchemeTemplateCode"
+              placeholder="质检方案编码"
+              disabled
+            ></el-input>
           </el-form-item>
         </el-col>
-        <el-col :span="8"><el-form-item label="状态 " prop="status">
-            <el-select clearable class="ele-block" v-model="dataForm.status" placeholder="请选择">
+        <el-col :span="8"
+          ><el-form-item label="状态 " prop="status">
+            <el-select
+              clearable
+              class="ele-block"
+              v-model="dataForm.status"
+              placeholder="请选择"
+            >
               <el-option label="失效" :value="0" />
               <el-option label="有效" :value="1" />
-            </el-select> </el-form-item></el-col>
+            </el-select> </el-form-item
+        ></el-col>
       </el-row>
       <el-row>
         <el-col :span="24">
           <el-form-item label="备注" prop="templateRemark">
-            <el-input type="textarea" v-model="dataForm.templateRemark" placeholder="请输入"></el-input>
+            <el-input
+              type="textarea"
+              v-model="dataForm.templateRemark"
+              placeholder="请输入"
+            ></el-input>
           </el-form-item>
         </el-col>
       </el-row>
       <el-row>
-        <ele-pro-table ref="table" :columns="columns" :datasource="list" height="calc(100vh - 605px)"
-          tool-class="ele-toolbar-form" cache-key="inspectionClassify" row-key="qualityLevelId"
-          @selection-change="selectionChange">
+        <ele-pro-table
+          ref="table"
+          :columns="columns"
+          :datasource="list"
+          height="400px"
+          tool-class="ele-toolbar-form"
+          cache-key="inspectionClassify"
+          row-key="qualityLevelId"
+          @selection-change="selectionChange"
+        >
           <template v-slot:toolbar>
-            <el-button @click="handAdd" size="mini" type="primary">新增质检项</el-button>
+            <el-button @click="handAdd(1)" size="mini" type="primary"
+              >新增质检项</el-button
+            >
           </template>
 
           <template v-slot:textType="{ row }">
@@ -46,18 +86,18 @@
               row.textType == 1
                 ? '数值'
                 : row.textType == 2
-                  ? '选择'
-                  : row.textType == 3
-                    ? '上下限'
-                    : row.textType == 4
-                      ? '规格'
-                      : row.textType == 5
-                        ? '时间'
-                        : row.textType == 6
-                          ? '范围'
-                          : row.textType == 7
-                            ? '文本'
-                            : ''
+                ? '选择'
+                : row.textType == 3
+                ? '上下限'
+                : row.textType == 4
+                ? '规格'
+                : row.textType == 5
+                ? '时间'
+                : row.textType == 6
+                ? '范围'
+                : row.textType == 7
+                ? '文本'
+                : ''
             }}
           </template>
 
@@ -69,7 +109,9 @@
             <div style="width: 100%; display: flex; justify-content: center">
               {{ row.symbol }}
 
-              <span v-if="row.textType == 3">{{ row.minValue }}- {{ row.maxValue }}</span>
+              <span v-if="row.textType == 3"
+                >{{ row.minValue }}- {{ row.maxValue }}</span
+              >
 
               <div v-else>
                 {{ row.defaultValue }}
@@ -80,7 +122,44 @@
           </template>
 
           <template v-slot:action="{ row, $index }">
-            <el-popconfirm class="ele-action" title="确定要删除当前质检项吗?" @confirm="handDel($index)">
+            <el-popconfirm
+              class="ele-action"
+              title="确定要删除当前质检项吗?"
+              @confirm="handDel($index, 1)"
+            >
+              <template v-slot:reference>
+                <el-link type="danger" :underline="false" icon="el-icon-delete">
+                  删除
+                </el-link>
+              </template>
+            </el-popconfirm>
+          </template>
+        </ele-pro-table>
+      </el-row>
+      <el-row>
+        <ele-pro-table
+          ref="table"
+          :columns="categoryColumns"
+          :datasource="templateCategoryList"
+          height="300px"
+          tool-class="ele-toolbar-form"
+          cache-key="inspectionClassify"
+          row-key="qualityLevelId"
+          @selection-change="selectionChange"
+          :need-page="false"
+        >
+          <template v-slot:toolbar>
+            <el-button @click="handAdd(2)" size="mini" type="primary"
+              >选择物品</el-button
+            >
+          </template>
+
+          <template v-slot:action="{ row, $index }">
+            <el-popconfirm
+              class="ele-action"
+              title="确定要删除当前物品吗?"
+              @confirm="handDel($index, 2)"
+            >
               <template v-slot:reference>
                 <el-link type="danger" :underline="false" icon="el-icon-delete">
                   删除
@@ -96,160 +175,257 @@
       <el-button type="primary" @click="dataFormSubmit()">保存</el-button>
     </span>
     <termPop ref="termRef" @selectChange="selectChange"></termPop>
+
+    <!-- 选择产品 -->
+    <EquipmentDialog
+      ref="equipmentRefs"
+      @choose="confirmChoose"
+      :typeS="['1']"
+      :disabledCode="templateCategoryList.map((item) => item.code)"
+    >
+    </EquipmentDialog>
   </ele-modal>
 </template>
 
 <script>
-import termPop from '@/views/inspectionTemplate/inspectionClassify/index.vue';
-import { save, update, getById } from '@/api/inspectionTemplate';
-import { getCode } from '@/api/login';
-export default {
-  components: { termPop },
-  data() {
-    return {
-      visible: false,
-      dataForm: {
-        id: 0,
-        qualitySchemeTemplateName: '',
-        qualitySchemeTemplateCode: '',
-        inspectionItemVOList: [],
-        status: 1,
-        templateRemark: ''
-      },
-      columns: [
-        {
-          width: 45,
-          type: 'selection',
-          columnKey: 'selection',
-          align: 'center',
-          reserveSelection: true
-        },
-        {
-          columnKey: 'index',
-          label: '序号',
-          type: 'index',
-          width: 55,
-          align: 'center',
-          showOverflowTooltip: true,
-          fixed: 'left'
-        },
-        {
-          prop: 'categoryLevelClassName',
-          label: '质检类型',
-          align: 'center',
-          minWidth: 150
-        },
-        {
-          prop: 'inspectionCode',
-          label: '编码',
-          showOverflowTooltip: true,
-          align: 'center',
-          minWidth: 150
-        },
-        {
-          prop: 'inspectionName',
-          label: '名称',
-          showOverflowTooltip: true,
-          align: 'center',
-          minWidth: 150
-        },
-        {
-          prop: 'defaultValue',
-          slot: 'defaultValue',
-          label: '工艺参数',
-          align: 'center',
-          width: 400
+  import termPop from '@/views/inspectionTemplate/inspectionClassify/index.vue';
+  import EquipmentDialog from '@/views/unqualifiedProduct/unqualifiedList/components/EquipmentDialog.vue';
+
+  import { save, update, getById,templatecategoryPage } from '@/api/inspectionTemplate';
+  import { getCode } from '@/api/login';
+  export default {
+    components: { termPop, EquipmentDialog },
+    data() {
+      return {
+        visible: false,
+        dataForm: {
+          id: 0,
+          qualitySchemeTemplateName: '',
+          qualitySchemeTemplateCode: '',
+          inspectionItemVOList: [],
+          status: 1,
+          templateRemark: ''
         },
+        columns: [
+          {
+            width: 45,
+            type: 'selection',
+            columnKey: 'selection',
+            align: 'center',
+            reserveSelection: true
+          },
+          {
+            columnKey: 'index',
+            label: '序号',
+            type: 'index',
+            width: 55,
+            align: 'center',
+            showOverflowTooltip: true,
+            fixed: 'left'
+          },
+          {
+            prop: 'categoryLevelClassName',
+            label: '质检类型',
+            align: 'center',
+            minWidth: 150
+          },
+          {
+            prop: 'inspectionCode',
+            label: '编码',
+            showOverflowTooltip: true,
+            align: 'center',
+            minWidth: 150
+          },
+          {
+            prop: 'inspectionName',
+            label: '名称',
+            showOverflowTooltip: true,
+            align: 'center',
+            minWidth: 150
+          },
+          {
+            prop: 'defaultValue',
+            slot: 'defaultValue',
+            label: '工艺参数',
+            align: 'center',
+            width: 400
+          },
 
-        {
-          columnKey: 'action',
-          label: '操作',
-          width: 80,
-          align: 'center',
-          resizable: false,
-          slot: 'action',
-          fixed: 'right'
-        }
-      ],
-      dataRule: {
-        qualitySchemeTemplateName: [
-          { required: true, message: '请输入质检方案名称', trigger: 'blur' }
+          {
+            columnKey: 'action',
+            label: '操作',
+            width: 80,
+            align: 'center',
+            resizable: false,
+            slot: 'action',
+            fixed: 'right'
+          }
         ],
-        status: [
+        categoryColumns: [
+          {
+            width: 45,
+            type: 'selection',
+            columnKey: 'selection',
+            align: 'center',
+            reserveSelection: true
+          },
           {
-            required: true,
-            message: '请选择状态',
-            trigger: 'blur'
+            columnKey: 'index',
+            label: '序号',
+            type: 'index',
+            width: 55,
+            align: 'center',
+            showOverflowTooltip: true,
+            fixed: 'left'
+          },
+          {
+            prop: 'categoryLevelPath',
+            label: '分类',
+            align: 'center',
+            minWidth: 150
+          },
+          {
+            prop: 'code',
+            label: '编码',
+            showOverflowTooltip: true,
+            align: 'center',
+            minWidth: 150
+          },
+          {
+            prop: 'name',
+            label: '名称',
+            showOverflowTooltip: true,
+            align: 'center',
+            minWidth: 150
+          },
+          {
+            prop: 'specification',
+            label: '规格',
+            align: 'center',
+            minWidth: 150
+          },
+          {
+            prop: 'modelType',
+            label: '型号',
+            align: 'center',
+            minWidth: 150
+          },
+          {
+            prop: 'brandNum',
+            label: '牌号',
+            align: 'center',
+            minWidth: 150
+          },
+          {
+            columnKey: 'action',
+            label: '操作',
+            width: 80,
+            align: 'center',
+            resizable: false,
+            slot: 'action',
+            fixed: 'right'
           }
-        ]
-      },
-      list: []
-    };
-  },
-  methods: {
-    handAdd() {
-      this.$refs.termRef.open(this.list);
-    },
-    handleClose() {
-      this.visible = false;
-    },
-    selectionChange(selection) {
-      console.log(selection, 'selection');
-    },
-    selectChange(list) {
-      this.list = list;
+        ],
+        dataRule: {
+          qualitySchemeTemplateName: [
+            { required: true, message: '请输入质检方案名称', trigger: 'blur' }
+          ],
+          status: [
+            {
+              required: true,
+              message: '请选择状态',
+              trigger: 'blur'
+            }
+          ]
+        },
+        list: [],
+        templateCategoryList: []
+      };
     },
-    handDel(index) {
-      this.$confirm('是否删除该质检项', '删除', {
-        type: 'warning'
-      })
-        .then(() => {
+    methods: {
+      handAdd(type) {
+        if (type == 1) {
+          this.$refs.termRef.open(this.list);
+        }
+        if (type == 2) {
+          this.$refs.equipmentRefs.open();
+        }
+      },
+      handleClose() {
+        this.visible = false;
+      },
+      selectionChange(selection) {
+        console.log(selection, 'selection');
+      },
+      selectChange(list) {
+        this.list = list;
+      },
+      handDel(index, type) {
+        if (type == 1) {
           this.list.splice(index, 1);
-        })
-        .catch(() => { });
-    },
-    init(id) {
-      this.dataForm.id = id || 0;
-      this.visible = true;
-      this.$nextTick(async () => {
-        this.$refs['dataForm'].resetFields();
-        if (this.dataForm.id) {
-          getById(this.dataForm.id).then(({ data }) => {
-            this.dataForm = data;
-            this.list = data.inspectionItemVOList;
-          });
-        } else {
-          const code = await getCode('template_code');
-          this.dataForm.qualitySchemeTemplateCode = code;
-          this.list = [];
         }
-      });
-    },
-    // 表单提交
-    dataFormSubmit() {
-      this.$refs['dataForm'].validate((valid) => {
-        if (valid) {
-          if (!this.dataForm.id) {
-            delete this.dataForm.id;
-          }
-          const saveOrUpdate = this.dataForm.id ? update : save;
-          this.dataForm.inspectionItemVOList = this.list;
-          saveOrUpdate(this.dataForm)
-            .then((msg) => {
-              this.loading = false;
-              this.dataForm = {};
-              const info = this.dataForm.id ? '修改成功' : '新增成功';
-              this.$message.success(info);
-              this.visible = false;
-              // this.updateVisible(false);
-              this.$emit('refreshDataList');
-            })
-            .catch((e) => {
-              this.loading = false;
-            });
+        if (type == 2) {
+          this.templateCategoryList.splice(index, 1);
         }
-      });
+      },
+      confirmChoose(list) {
+        let categoryList = list.map((item) => {
+          item['name'] = item.categoryLevelName;
+          item['id'] = ''
+          return item;
+        });
+        this.templateCategoryList.push(...categoryList);
+      },
+      init(id) {
+        this.dataForm.id = id || 0;
+        this.visible = true;
+        this.$nextTick(async () => {
+          this.$refs['dataForm'].resetFields();
+          if (this.dataForm.id) {
+            getById(this.dataForm.id).then(({ data }) => {
+              this.dataForm = data;
+              this.list = data.inspectionItemVOList;
+
+            });
+            templatecategoryPage({ templateId:this.dataForm.id,size:-1 }).then((data) => {
+              console.log(data,'data')
+              this.templateCategoryList = data.list;
+
+            });
+            // this.templateCategoryList=data.templateCategoryList||[];
+          } else {
+            const code = await getCode('template_code');
+            this.dataForm.qualitySchemeTemplateCode = code;
+            this.list = [];
+          }
+        });
+      },
+      // 表单提交
+      dataFormSubmit() {
+        this.$refs['dataForm'].validate((valid) => {
+          if (valid) {
+            if (!this.dataForm.id) {
+              delete this.dataForm.id;
+            }
+            const saveOrUpdate = this.dataForm.id ? update : save;
+            this.dataForm.inspectionItemVOList = this.list;
+            this.dataForm.templateCategoryList = this.templateCategoryList;
+            saveOrUpdate(this.dataForm)
+              .then((msg) => {
+                this.loading = false;
+                this.dataForm = {};
+                const info = this.dataForm.id ? '修改成功' : '新增成功';
+                this.$message.success(info);
+                this.visible = false;
+                // this.updateVisible(false);
+                this.$emit('refreshDataList');
+              })
+              .catch((e) => {
+                this.loading = false;
+              });
+          }
+        });
+      }
     }
-  }
-};
+  };
 </script>

+ 128 - 0
src/views/inspectionTemplate/components/inspectionTemplateDialog.vue

@@ -0,0 +1,128 @@
+<template>
+  <el-dialog
+    :visible.sync="equipmentdialog"
+    :before-close="handleClose"
+    :close-on-click-modal="true"
+    :close-on-press-escape="false"
+    append-to-body
+    width="60%"
+  >
+    <search ref="search" @search="search"></search>
+    <ele-pro-table
+      ref="table"
+      :columns="columns"
+      :datasource="datasource"
+      height="calc(100vh - 605px)"
+      tool-class="ele-toolbar-form"
+      row-key="qualityLevelId"
+      v-if="equipmentdialog"
+      :selection.sync="selection"
+    >
+      <template v-slot:status="{ row }">
+        {{ row.status ? '启用' : '停用' }}
+      </template>
+    </ele-pro-table>
+    <div class="btns">
+      <el-button type="primary" size="small" @click="selected">选择</el-button>
+      <el-button size="small" @click="handleClose">关闭</el-button>
+    </div>
+  </el-dialog>
+</template>
+
+<script>
+  import search from './search.vue';
+  import { getList } from '@/api/inspectionTemplate';
+
+  export default {
+    components: { search },
+
+    data() {
+      return {
+        equipmentdialog: false,
+        selection: [],
+        columns: [
+          {
+            width: 45,
+            type: 'selection',
+            columnKey: 'selection',
+            align: 'center',
+            reserveSelection: true
+          },
+          {
+            columnKey: 'index',
+            label: '序号',
+            type: 'index',
+            width: 55,
+            align: 'center',
+            showOverflowTooltip: true,
+            fixed: 'left'
+          },
+          {
+            prop: 'qualitySchemeTemplateCode',
+            label: '质检方案编码',
+            showOverflowTooltip: true,
+            align: 'center',
+            minWidth: 110
+          },
+          {
+            prop: 'qualitySchemeTemplateName',
+            label: '质检方案名称',
+            align: 'center',
+            minWidth: 150
+          },
+          {
+            label: '状态',
+            prop: 'status',
+            slot: 'status',
+            align: 'center'
+          },
+          {
+            prop: 'templateRemark',
+            label: '备注',
+            showOverflowTooltip: true,
+            align: 'center',
+            minWidth: 110
+          },
+          {
+            columnKey: 'action',
+            label: '操作',
+            width: 150,
+            align: 'center',
+            resizable: false,
+            slot: 'action',
+            fixed: 'right'
+          }
+        ]
+      };
+    },
+
+    watch: {},
+    methods: {
+      datasource({ page, where, limit }) {
+        return getList({
+          ...where,
+          pageNum: page,
+          size: limit
+        });
+      },
+      open() {
+        this.equipmentdialog = true;
+      },
+      handleClose() {
+        this.equipmentdialog = false;
+      },
+      // 选择
+      selected() {
+        if (!this.selection.length) {
+            this.$message.error('至少选择一条数据');
+
+          return;
+        }
+        this.$emit('choose', this.selection);
+        this.handleClose();
+      }
+    }
+  };
+</script>
+
+<style lang="scss" scoped></style>

+ 221 - 175
src/views/unqualifiedProduct/unqualifiedList/components/EquipmentDialog.vue

@@ -1,29 +1,59 @@
 <template>
-  <el-dialog title="选择产品" :visible.sync="equipmentdialog" :before-close="handleClose" :close-on-click-modal="true"
-    :close-on-press-escape="false" append-to-body width="60%">
+  <el-dialog
+    title="选择产品"
+    :visible.sync="equipmentdialog"
+    :before-close="handleClose"
+    :close-on-click-modal="true"
+    :close-on-press-escape="false"
+    append-to-body
+    width="60%"
+  >
     <div>
       <el-row>
         <el-col :span="24" class="topsearch">
           <el-form>
             <el-row>
               <el-col :span="6">
-                <el-input v-model="searchKey" placeholder="关键词" size="small"></el-input>
+                <el-input
+                  v-model="searchKey"
+                  placeholder="关键词"
+                  size="small"
+                ></el-input>
               </el-col>
 
               <el-col :span="6" style="margin-left: 10px">
-                <el-button type="primary" size="small" @click="reload">搜索</el-button>
+                <el-button type="primary" size="small" @click="reload"
+                  >搜索</el-button
+                >
                 <el-button size="small" @click="reset">重置</el-button>
               </el-col>
             </el-row>
           </el-form>
         </el-col>
         <el-col :span="6" class="tree_col">
-          <AssetTree @handleNodeClick="handleNodeClick" :treeIds="treeIds" :paramsType="'type'" ref="treeList" />
+          <AssetTree
+            @handleNodeClick="handleNodeClick"
+            :treeIds="treeIds"
+            :typeS="typeS"
+            :paramsType="'type'"
+            ref="treeList"
+          />
         </el-col>
         <el-col :span="18" class="table_col" v-if="equipmentdialog">
-          <ele-pro-table ref="equiTable" :columns="columns" :datasource="datasource" :selection.sync="selection"
-            :current.sync="current" highlight-current-row @select="handleSelect" cache-key="systemRoleTable3" aaaaaa
-            row-key="id" height="50vh" @done="setSelect">
+          <ele-pro-table
+            ref="equiTable"
+            :columns="columns"
+            :datasource="datasource"
+            :selection.sync="selection"
+            :current.sync="current"
+            highlight-current-row
+            @select="handleSelect"
+            cache-key="systemRoleTable3"
+            aaaaaa
+            row-key="id"
+            height="50vh"
+            @done="setSelect"
+          >
           </ele-pro-table>
         </el-col>
       </el-row>
@@ -36,188 +66,204 @@
 </template>
 
 <script>
-import AssetTree from '@/components/AssetTree/index.vue';
-import { getList } from '@/api/classifyManage/index';
-export default {
-  components: {
-    AssetTree
-  },
-  props: {
-    selectList: Array,
-    type: {
-      default: 1 //1多选 2单选
+  import AssetTree from '@/components/AssetTree/index.vue';
+  import { getList } from '@/api/classifyManage/index';
+  export default {
+    components: {
+      AssetTree
     },
-    treeIds: {
-      default: () => {
-        return ['9'];
-      }
-    }
-  },
-  data() {
-    return {
-      equipmentdialog: false,
-      current: null,
-      columns: [
-        {
-          width: 45,
-          type: 'selection',
-          columnKey: 'selection',
-          align: 'center',
-          reserveSelection: true,
-          show: this.type == 1
-        },
-        {
-          columnKey: 'index',
-          label: '序号',
-          type: 'index',
-          width: 55,
-          align: 'center',
-          showOverflowTooltip: true
-        },
-        {
-          prop: 'code',
-          label: '物品编码',
-          align: 'center',
-          showOverflowTooltip: true,
-          minWidth: 110,
-          slot: 'code'
-        },
-        {
-          prop: 'name',
-          label: '物品名称',
-          align: 'center',
-          showOverflowTooltip: true,
-          minWidth: 110
-        },
-        {
-          prop: 'brandNum',
-          label: '牌号',
-          align: 'center',
-          showOverflowTooltip: true,
-          minWidth: 110
-        },
-        {
-          prop: 'specification',
-          label: '规格',
-          align: 'center',
-          showOverflowTooltip: true,
-          minWidth: 110
-        },
-        {
-          prop: 'modelType',
-          label: '型号',
-          align: 'center',
-          showOverflowTooltip: true,
-          minWidth: 110
+    props: {
+      selectList: Array,
+      type: {
+        default: 1 //1多选 2单选
+      },
+      treeIds: {
+        default: () => {
+          return ['9'];
+        }
+      },
+      typeS: {
+        default: () => {
+          return [];
         }
-      ],
-      tableList: [],
-      categoryLevelId: null,
-      code: null,
-      searchKey: '',
-      selection: []
-    };
-  },
+      },
+      disabledCode: {
+        default: () => {
+          return [];
+        }
+      }
+    },
+    data() {
+      return {
+        equipmentdialog: false,
+        current: null,
 
-  watch: {},
-  methods: {
-    async datasource({ page, limit }) {
-      const params = {
-        code: this.code,
-        searchKey: this.searchKey,
-        pageNum: page,
-        size: limit,
-        categoryLevelId: this.categoryLevelId,
-        isProduct: true
+        tableList: [],
+        categoryLevelId: null,
+        code: null,
+        searchKey: '',
+        selection: []
       };
-      const data = await getList(params);
-      this.tableList = data.list;
-      return data;
-    },
-    open() {
-      this.equipmentdialog = true;
-      this.setSelect();
-    },
-    handleNodeClick(data) {
-      this.categoryLevelId = data.id;
-      this.reload();
-    },
-    reload() {
-      this.$refs.equiTable.reload();
-    },
-    handleClose() {
-      this.equipmentdialog = false;
-      this.code = '';
-      this.$refs.equiTable.clearSelection();
-    },
-    reset() {
-      this.code = null;
-      this.reload();
     },
-    // 设置选中
-    setSelect() {
-      // this.$nextTick(() => {
-      //   this.tableList.forEach((row) => {
-      //     this.selectList?.forEach((selected, index) => {
-      //       if (selected.productCode === row.code) {
-      //         this.$refs.equiTable.toggleRowSelection(row, true);
-      //       }
-      //     });
-      //   });
-      // });
-    },
-    // 取消选中
-    handleSelect(selection, row) {
-      // if (!selection.find((i) => i.id === row.id)) {
-      //   const index = this.selectList.findIndex(
-      //     (itm) => row.code == itm.productCode
-      //   );
-      //   console.log(index);
-      //   if (index > -1) {
-      //     this.selectList.splice(index, 1);
-      //   }
-      // }
+    computed:{
+      columns(){
+        return [
+          {
+            width: 45,
+            type: 'selection',
+            columnKey: 'selection',
+            align: 'center',
+            reserveSelection: true,
+            show: this.type == 1,
+            selectable: (row, index) => {
+              return !this.disabledCode.includes(row.code)
+            }
+          },
+          {
+            columnKey: 'index',
+            label: '序号',
+            type: 'index',
+            width: 55,
+            align: 'center',
+            showOverflowTooltip: true
+          },
+          {
+            prop: 'code',
+            label: '物品编码',
+            align: 'center',
+            showOverflowTooltip: true,
+            minWidth: 110,
+            slot: 'code'
+          },
+          {
+            prop: 'name',
+            label: '物品名称',
+            align: 'center',
+            showOverflowTooltip: true,
+            minWidth: 110
+          },
+          {
+            prop: 'brandNum',
+            label: '牌号',
+            align: 'center',
+            showOverflowTooltip: true,
+            minWidth: 110
+          },
+          {
+            prop: 'specification',
+            label: '规格',
+            align: 'center',
+            showOverflowTooltip: true,
+            minWidth: 110
+          },
+          {
+            prop: 'modelType',
+            label: '型号',
+            align: 'center',
+            showOverflowTooltip: true,
+            minWidth: 110
+          }
+        ]
+      }
     },
-    // 选择
-    selected() {
-
 
-      let list = this.type == 1 ? this.selection : [this.current]
-      this.$emit('choose', JSON.parse(JSON.stringify(list)));
-      this.handleClose();
+    watch: {},
+    methods: {
+      async datasource({ page, limit }) {
+        const params = {
+          code: this.code,
+          searchKey: this.searchKey,
+          pageNum: page,
+          size: limit,
+          categoryLevelId: this.categoryLevelId,
+          isProduct: true
+        };
+        const data = await getList(params);
+        this.tableList = data.list;
+        return data;
+      },
+      open() {
+        this.equipmentdialog = true;
+        this.setSelect();
+      },
+      handleNodeClick(data) {
+        this.categoryLevelId = data.id;
+        this.reload();
+      },
+      reload() {
+        this.$refs.equiTable.reload();
+      },
+      handleClose() {
+        this.equipmentdialog = false;
+        this.code = '';
+        this.$refs.equiTable.clearSelection();
+      },
+      reset() {
+        this.code = null;
+        this.reload();
+      },
+      // 设置选中
+      setSelect() {
+        // this.$nextTick(() => {
+        //   this.tableList.forEach((row) => {
+        //     this.selectList?.forEach((selected, index) => {
+        //       if (selected.productCode === row.code) {
+        //         this.$refs.equiTable.toggleRowSelection(row, true);
+        //       }
+        //     });
+        //   });
+        // });
+      },
+      // 取消选中
+      handleSelect(selection, row) {
+        // if (!selection.find((i) => i.id === row.id)) {
+        //   const index = this.selectList.findIndex(
+        //     (itm) => row.code == itm.productCode
+        //   );
+        //   console.log(index);
+        //   if (index > -1) {
+        //     this.selectList.splice(index, 1);
+        //   }
+        // }
+      },
+      // 选择
+      selected() {
+        let list = this.type == 1 ? this.selection : [this.current];
+        this.$emit('choose', JSON.parse(JSON.stringify(list)));
+        this.handleClose();
+      }
     }
-  }
-};
+  };
 </script>
 
 <style lang="scss" scoped>
-.tree_col {
-  border: 1px solid #eee;
-  padding: 10px 0;
-  box-sizing: border-box;
-  max-height: 530px;
-  overflow: auto;
-}
+  .tree_col {
+    border: 1px solid #eee;
+    padding: 10px 0;
+    box-sizing: border-box;
+    max-height: 530px;
+    overflow: auto;
+  }
 
-.table_col {
-  padding-left: 10px;
+  .table_col {
+    padding-left: 10px;
 
-  ::v-deep .el-table th.el-table__cell {
-    background: #f2f2f2;
+    ::v-deep .el-table th.el-table__cell {
+      background: #f2f2f2;
+    }
   }
-}
 
-.pagination {
-  text-align: right;
-  padding: 10px 0;
-}
+  .pagination {
+    text-align: right;
+    padding: 10px 0;
+  }
 
-.btns {
-  text-align: center;
-  padding: 10px 0;
-}
+  .btns {
+    text-align: center;
+    padding: 10px 0;
+  }
 
-.topsearch {
-  margin-bottom: 15px;
-}
+  .topsearch {
+    margin-bottom: 15px;
+  }
 </style>