ysy 1 год назад
Родитель
Сommit
6069a2056a

+ 102 - 125
src/components/AssetTree/index.vue

@@ -17,146 +17,123 @@
 </template>
 
 <script>
-import { getTreeByPid } from '@/api/classifyManage';
-// let originId = '';
-// let originType = '';
-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;
+  import { getTreeByPid } 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;
+        }
+      },
+      // 初始请求treeList
+      init: {
+        type: Boolean,
+        default: true
+      },
+      id: {
+        type: String,
+        default: '0'
+      },
+      nodeKey: {
+        type: String,
+        default: 'id'
       }
+
     },
-    // 初始请求treeList
-    init: {
-      type: Boolean,
-      default: true
+    data() {
+      return {
+        treeList: [],
+        treeLoading: false,
+        parentName: '',
+        parentId: '',
+        currentKey: ''
+      };
     },
-
-    id: {
-      type: Array |  String,
-      default: () => {
-        return ['9'];
+    mounted() {
+      if (this.init) {
+        this.getTreeData();
       }
     },
-    nodeKey: {
-      type: String,
-      default: 'id'
-    }
-    // appendRoot: {
-    //   type: Boolean,
-    //   default: false
-    // },
-  },
-  data() {
-    return {
-      treeList: [],
-      treeLoading: false,
-      parentName: '',
-      parentId: '',
-      currentKey: ''
-    };
-  },
-  mounted() {
-    if (this.init) {
-      this.getTreeData();
-    }
-  },
-  methods: {
-    getInstance() {
-      return this.$refs.tree;
-    },
-    // 获取树结构数据
-    async getTreeData() {
-      try {
-        this.treeLoading = true;
+    methods: {
+      getInstance() {
+        return this.$refs.tree;
+      },
+      // 获取树结构数据
+      async getTreeData() {
+        try {
+          this.treeLoading = true;
 
-        const res = await getTreeByPid(0);
-        this.treeLoading = false;
-        if (res?.code === '0') {
-          this.treeList = res.data.filter(item=>this.id.includes(item.id));
-          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 = await getTreeByPid(this.id);
+          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) {}
-      this.treeLoading = false;
-    },
-    // 递归 - 往树children里面添加parentName
-    // _setParentName (tree) {
-    //   let data = tree;
-    //   for (let i = 0; i < data.length; i++) {
-    //     if (data[i].parentId === '0') {
-    //       this.parentName = data[i].name;
-    //       originId = data[i].id;
-    //       originType = data[i].type;
-    //     }
+        this.treeLoading = false;
+      },
 
-    //     data[i]['originId'] = originId;
-    //     data[i]['originType'] = originType;
-    //     data[i]['parentId'] = data[i]['parentId'];
-    //     if (data[i].children && data[i].children.length > 0) {
-    //       this._setParentName(data[i].children);
-    //     }
-    //   }
-    //   return data;
-    // },
 
-    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>

+ 7 - 0
src/styles/transition/common.scss

@@ -57,3 +57,10 @@
   border-top: 4px solid #157a2c;
   color: #157a2c;
 }
+
+
+
+.el-dialog {
+
+  margin-top: 5vh !important;
+}

+ 5 - 5
src/views/inspectionClassify/components/user-list.vue

@@ -91,7 +91,7 @@
       </template>
     </ele-pro-table>
 
-    <!-- <Add @chooseProcess="chooseProcess" ref="addRef" /> -->
+    <Add @chooseProcess="chooseProcess" ref="addRef" />
 
     <edit ref="edit" @done="done"></edit>
     <Detail ref="detailRef"></Detail>
@@ -107,14 +107,14 @@
     saveBatch
   } from '@/api/inspectionClassify/index';
   import dictMixins from '@/mixins/dictMixins';
-  // import Add from './add.vue';
+  import Add from './add.vue';
   import Edit from './edit.vue';
   import Detail from '@/views/inspectionStandard/components/edit.vue';
   import qualityItem from './qualityItem.vue'
 
   export default {
     mixins: [dictMixins],
-    components: { userSearch, Edit, Detail , qualityItem},
+    components: { userSearch, Edit, Detail , qualityItem, Add},
     props: {
       // 类别id
 
@@ -214,8 +214,8 @@
 
       /* 打开编辑弹窗 */
       openAdd() {
-        // this.$refs.addRef.open(this.categoryLevelId || 12);
-        this.$refs.qualityItemRef.open()
+        this.$refs.addRef.open(this.categoryLevelId || 12);
+        // this.$refs.qualityItemRef.open()
       },
 
       openEdit(row) {

+ 254 - 0
src/views/inspectionProject/components/ProductModal.vue

@@ -0,0 +1,254 @@
+<template>
+  <el-dialog :title="title" :visible.sync="visible" :before-close="handleClose" :close-on-click-modal="false"
+    :close-on-press-escape="false" append-to-body width="70%">
+
+    <el-card shadow="never">
+      <ProductSearch @search="reload" ref="searchRef" />
+
+      <ele-split-layout width="244px" allow-collapse :right-style="{ overflow: 'hidden' }">
+        <div class="ele-border-lighter split-layout-right-content">
+          <el-tree :data="treeList" :props="defaultProps" ref="treeRef"
+            :default-expanded-keys="categoryId ? [categoryId] : []" :highlight-current="true" node-key="id"
+            @node-click="handleNodeClick"></el-tree>
+        </div>
+
+
+        <!-- 数据表格 -->
+        <template v-slot:content>
+          <ele-pro-table style="min-height: 400px;" ref="table" :columns="columns" :datasource="datasource"
+            :selection.sync="selection" row-key="id">
+          </ele-pro-table>
+        </template>
+      </ele-split-layout>
+
+    </el-card>
+
+
+
+
+
+    <div class="rx-sc">
+
+      <el-button type="primary" size="small" @click="selected">选择</el-button>
+      <el-button size="small" @click="handleClose">关闭</el-button>
+
+    </div>
+  </el-dialog>
+</template>
+
+<script>
+
+
+
+import ProductSearch from './product-search.vue'
+import { getTreeByPid, getList } from '@/api/classifyManage';
+export default {
+  components: {
+    ProductSearch
+  },
+  data() {
+    return {
+      visible: false,
+      title: '选择工具',
+
+      categoryLevelId: null,
+      categoryId: 1,
+      treeList: [],
+      treeLoading: false,
+
+      defaultProps: {
+        children: 'children',
+        label: 'name'
+      },
+      type: null,
+
+      // 表格列配置
+      columns: [
+        {
+          columnKey: 'selection',
+          type: 'selection',
+          width: 45,
+          align: 'center',
+          selectable: (row, index) => {
+            return !this.processData.some((it) => row.id == it.categoryId);
+          },
+          reserveSelection: true,
+          fixed: 'left'
+        },
+
+        {
+          label: '物料名称',
+          prop: 'name',
+        },
+
+        {
+          label: '物料编码',
+          prop: 'code'
+        },
+        {
+          label: '牌号',
+          prop: 'brandNum'
+        },
+        {
+          label: '型号',
+          prop: 'modelType'
+        },
+
+        {
+          prop: 'availableCountBase',
+          label: '包装库存',
+          sortable: 'custom',
+        },
+        {
+          label: '单位',
+          prop: 'weightUnit'
+        },
+
+        {
+          prop: 'packingCountBase',
+          label: '计量库存',
+          sortable: 'custom',
+        },
+
+        {
+          label: '计量单位',
+          prop: 'unit'
+        },
+
+
+
+        {
+          label: '数量',
+          prop: 'count'
+        },
+
+
+
+
+
+      ],
+
+      // 表格选中数据
+      selection: [],
+
+      processData: [],
+      current: null,
+
+
+
+
+
+    }
+  },
+
+  watch: {
+
+  },
+  methods: {
+
+
+    /* 表格数据源 */
+    async datasource({ page, limit, where }) {
+      const res = await getList({
+        ...where,
+        pageNum: page,
+        size: limit,
+        categoryLevelId: this.categoryLevelId,
+
+      });
+      return res;
+    },
+
+    open(item) {
+      this.processData = item || []
+      this.visible = true
+
+      this.getTreeData();
+
+    },
+
+
+
+    async getTreeData() {
+      try {
+        this.treeLoading = true;
+
+        const res = await getTreeByPid(4);
+        this.treeLoading = false;
+        if (res?.code === '0') {
+          this.treeList = res.data;
+
+          this.$nextTick(() => {
+            // 默认高亮第一级树节点
+            if (this.treeList[0]) {
+              this.rootTreeId = this.treeList[0].id
+              this.$nextTick(() => {
+                this.$refs.treeRef.setCurrentKey(this.treeList[0].id);
+              });
+
+            }
+          });
+          return this.treeList;
+        }
+      } catch (error) { }
+      this.treeLoading = false;
+    },
+
+
+
+
+    handleNodeClick(data) {
+      this.categoryLevelId = data.id;
+      this.$refs.table.reload({ pageNum: 1, where: {} });
+
+    },
+
+
+    /* 刷新表格 */
+    reload(where) {
+      this.$refs.table.reload({ page: 1, where: where });
+    },
+
+
+
+    handleClose() {
+      this.visible = false
+      this.$refs.table.setSelectedRows([]);
+      this.selection = []
+
+    },
+    selected() {
+      let _arr = []
+      if (!this.selection.length) {
+        this.$message.error('请至少选择一条数据');
+        return;
+      }
+
+      _arr = this.selection.map(m => {
+        m.categoryId = m.id
+        delete  m.id
+        return {
+          ...m
+        }
+      })
+
+
+      this.$emit('chooseModal', _arr)
+      this.handleClose()
+    },
+  }
+}
+</script>
+
+<style lang="scss" scoped>
+.rx-sc {
+
+  display: flex;
+  align-items: center;
+  justify-content: center;
+}
+
+.ml60 {
+  margin-left: 60px;
+}
+</style>

+ 102 - 0
src/views/inspectionProject/components/product-search.vue

@@ -0,0 +1,102 @@
+<!-- 搜索表单 -->
+<template>
+  <el-form
+    label-width="77px"
+    class="ele-form-search"
+    @keyup.enter.native="search"
+    @submit.native.prevent
+  >
+    <el-row :gutter="10">
+      <el-col v-bind="styleResponsive ? { md: 6 } : { span: 6 }">
+        <el-form-item label="编码">
+          <el-input clearable v-model="where.code" placeholder="请输入" />
+        </el-form-item>
+      </el-col>
+      <el-col v-bind="styleResponsive ? { md: 6 } : { span: 6 }">
+        <el-form-item label="名称">
+          <el-input clearable v-model="where.name" placeholder="请输入" />
+        </el-form-item>
+      </el-col>
+
+      <el-col v-bind="styleResponsive ? { md: 6 } : { span: 6 }">
+        <el-form-item label="型号">
+          <el-input clearable v-model="where.modelType" placeholder="请输入" />
+        </el-form-item>
+      </el-col>
+      <el-col v-bind="styleResponsive ? { md: 4 } : { md: 4 }">
+        <div class="ele-form-actions">
+          <el-button
+            type="primary"
+            icon="el-icon-search"
+            class="ele-btn-icon"
+            @click="search"
+          >
+            查询
+          </el-button>
+
+          <el-button
+            @click="reset"
+            icon="el-icon-refresh"
+            class="ele-btn-icon"
+            size="medium"
+            >重置</el-button
+          >
+        </div>
+      </el-col>
+    </el-row>
+  </el-form>
+</template>
+
+<script>
+  export default {
+    data () {
+      // 默认表单数据
+      const defaultWhere = {
+        name: '',
+        code: '',
+        modelType: ''
+      };
+      return {
+        defaultWhere,
+        // 表单数据
+        where: { ...defaultWhere },
+        treeData:[]
+      };
+    },
+    computed: {
+      // 是否开启响应式布局
+      styleResponsive () {
+        return this.$store.state.theme.styleResponsive;
+      }
+    },
+    created() {
+    },
+    methods: {
+
+      /* 搜索 */
+      search () {
+        if (this.where.appType === 0) {
+          this.where.appType = '';
+        }
+        this.$emit('search', this.where);
+      },
+      /*  重置 */
+      reset () {
+        this.where = { ...this.defaultWhere };
+        this.search();
+      },
+      reset2 () {
+        this.where = { ...this.defaultWhere };
+
+      }
+    }
+  };
+</script>
+
+<style>
+  .ele-form-actions {
+    display: inline-block;
+    transform: translate(0);
+    transition: all;
+  }
+</style>

+ 137 - 4
src/views/inspectionProject/components/user-edit.vue

@@ -1,19 +1,19 @@
 <!-- 用户编辑弹窗 -->
 <template>
   <ele-modal
-    width="960px"
+    width="1000px"
     :visible="visible"
     :append-to-body="true"
     :close-on-click-modal="false"
     custom-class="ele-dialog-form"
-    :title="isUpdate ? '修改参数' : '添加参数'"
+    :title="isUpdate ? '修改质检项' : '新建质检项'"
     @update:visible="updateVisible"
   >
     <header-title title="基本信息"></header-title>
     <el-form ref="form" :model="form" :rules="rules" label-width="120px">
       <el-row>
         <el-col :span="12">
-          <el-form-item label="质检标准:" prop="qualityStandardId">
+          <el-form-item label="标准名称:" prop="qualityStandardId">
             <el-select
               v-model="form.qualityStandardId"
               placeholder="请选择"
@@ -182,6 +182,97 @@
           <el-form-item label="附件:" prop="imgUrl"> </el-form-item>
         </el-col>
       </el-row>
+
+      <headerTitle title="质检工具">
+        <el-button type="primary" size="small" @click="handleAdd"
+          >新增</el-button
+        >
+      </headerTitle>
+
+      <el-table
+        ref="multipleTable"
+        :data="form.toolList"
+        tooltip-effect="dark"
+        style="width: 100%"
+        stripe
+        :header-cell-style="{ background: '#EEEEEE', border: 'none' }"
+      >
+        <el-table-column label="设备名称" prop="code" min-width="120">
+          <template slot-scope="{ row }">
+            {{ row.name }}
+          </template></el-table-column
+        >
+
+        <el-table-column label="设备编码" prop="code" min-width="120">
+          <template slot-scope="{ row }">
+            {{ row.code }}
+          </template></el-table-column
+        >
+
+        <el-table-column label="牌号" prop="brandNum" min-width="120">
+          <template slot-scope="{ row }">
+            {{ row.brandNum }}
+          </template></el-table-column
+        >
+
+        <el-table-column label="型号" prop="modelType" min-width="120">
+          <template slot-scope="{ row }">
+            {{ row.modelType }}
+          </template></el-table-column
+        >
+
+        <el-table-column label="操作" fixed="right">
+          <template slot-scope="{ $index, row }">
+            <el-button type="text" @click="removeItem($index, row)"
+              >删除设备</el-button
+            >
+          </template>
+        </el-table-column>
+      </el-table>
+
+      <headerTitle title="注意事项">
+        <el-button type="primary" size="small" @click="addPostscript"
+          >新增</el-button
+        >
+      </headerTitle>
+
+      <el-table
+        ref="multipleTable"
+        :data="form.postscriptList"
+        tooltip-effect="dark"
+        style="width: 100%"
+        stripe
+        :header-cell-style="{ background: '#EEEEEE', border: 'none' }"
+      >
+        <el-table-column label="排序" prop="" width="100">
+          <template slot-scope="{ row }">
+            <el-input
+              placeholder="请输入"
+              type="number"
+              v-model.number="row.sort"
+              clearable
+            ></el-input> </template
+        ></el-table-column>
+
+        <el-table-column label="注意事项" prop="" min-width="120">
+          <template slot-scope="{ row }">
+            <el-input
+              placeholder="请输入"
+              type="textarea"
+              :rows="1"
+              v-model="row.content"
+              clearable
+            ></el-input> </template
+        ></el-table-column>
+
+        <el-table-column label="操作" fixed="right" width="100">
+          <template slot-scope="{ $index, row }">
+            <el-button type="text" @click="removePostscript($index, row)"
+              >删除</el-button
+            >
+          </template>
+        </el-table-column>
+      </el-table>
     </el-form>
 
     <template v-slot:footer>
@@ -190,6 +281,8 @@
         保存
       </el-button>
     </template>
+
+    <ProductModal ref="productRefs" @chooseModal="chooseModal" />
   </ele-modal>
 </template>
 
@@ -197,8 +290,13 @@
   import { save, update, getById } from '@/api/inspectionProject';
 
   import { getList } from '@/api/inspectionStandard';
+  import ProductModal from './ProductModal.vue';
 
   export default {
+    components: {
+      ProductModal
+    },
+
     props: {
       // 弹窗是否打开
       visible: Boolean,
@@ -223,7 +321,12 @@
         unit: '',
         symbol: '',
         inspectionRemark: '',
-        imgUrl: []
+        imgUrl: [],
+
+        toolList: [],
+        postscriptList: [],
+        toolRemoveIds: [],
+        postscriptRemoveIds: []
       };
       return {
         defaultForm,
@@ -364,6 +467,36 @@
         getList(param).then((res) => {
           this.qualityStandardList = res.list;
         });
+      },
+
+      handleAdd() {
+        this.$refs.productRefs.open(this.form.toolList);
+      },
+
+      chooseModal(data) {
+        this.form.toolList = [...this.form.toolList, ...data];
+      },
+
+      removeItem(idx, row) {
+        this.$confirm(`是否删除这个设备?`).then(async () => {
+          this.form.toolList.splice(idx, 1);
+
+          if (row.id) {
+            this.form.toolRemoveIds.push(row.id);
+          }
+        });
+      },
+
+      addPostscript() {
+        this.form.postscriptList.push({ sort: null, content: '' });
+      },
+      removePostscript(idx, row) {
+        this.$confirm(`是否删除这个事项?`).then(async () => {
+          this.form.postscriptList.splice(idx, 1);
+          if (row.id) {
+            this.form.postscriptRemoveIds.push(row.id);
+          }
+        });
       }
     },
 

+ 1 - 1
src/views/inspectionProject/components/user-search.vue

@@ -37,7 +37,7 @@
       </el-col>
 
       <el-col v-bind="styleResponsive ? { lg: 4, md: 10 } : { span: 4 }">
-        <el-form-item label="质检标准:">
+        <el-form-item label="标准名称:">
           <el-select
             v-model="where.qualityStandardId"
             placeholder="请选择"

+ 19 - 1
src/views/inspectionProject/index.vue

@@ -53,6 +53,10 @@
           }}
         </template>
 
+        <template v-slot:type="{ row }">
+          {{ getDictValue('质检标准类型', row.type) }}
+        </template>
+
         <!-- 操作列 -->
         <template v-slot:action="{ row }">
           <el-link
@@ -101,7 +105,7 @@
   import importDialog from '@/components/upload/import-dialog.vue';
 
   import { getList, removeItem } from '@/api/inspectionProject';
-
+import dictMixins from '@/mixins/dictMixins'
   export default {
     name: 'inspectionProject',
     components: {
@@ -109,6 +113,7 @@
       UserEdit,
       importDialog
     },
+    mixins: [dictMixins],
     data() {
       return {
         // 表格列配置
@@ -164,6 +169,19 @@
             minWidth: 150
           },
 
+          {
+            label: '标准类型',
+            prop: 'type',
+            slot: 'type'
+          },
+
+          {
+            prop: 'qualityStandardName',
+            label: '标准名称',
+            align: 'center',
+            minWidth: 110
+          },
+
           {
             label: '状态',
             prop: 'status',