ysy 2 jaren geleden
bovenliggende
commit
3ece9f1c37

+ 15 - 11
src/api/inspectionClassify/index.js

@@ -1,11 +1,11 @@
 import request from '@/utils/request';
 
-/*  干燥区台账  */
+
 
 
 // 列表 
 export async function getList (params) {
-    const res = await request.get(`/main/aridregion/page?`, params);
+    const res = await request.get(`/qms/qualitylevel/page?`, params);
     if (res.data.code == 0) {
       return res.data.data;
     }
@@ -13,14 +13,7 @@ export async function getList (params) {
   }
   
 
-  // 新增
-  export async function save (data) {
-    const res = await request.post(`/main/aridregion/save`, data);
-    if (res.data.code == 0) {
-      return res.data;
-    }
-    return Promise.reject(new Error(res.data.message));
-  }
+
 
   // 编辑
   export async function update (data) {
@@ -33,9 +26,20 @@ export async function getList (params) {
   
 // 删除
 export async function removeItem (data) {
-  const res = await request.delete('/main/aridregion/delete', { data });
+  const res = await request.delete('/qms/qualitylevel/delete', { data });
   if (res.data.code == 0) {
     return res.data.message;
   }
   return Promise.reject(new Error(res.data.message));
 }
+
+
+// 批量保存
+export async function saveBatch (data) {
+  const res = await request.post(`/qms/qualitylevel/saveBatch`, data);
+  if (res.data.code == 0) {
+    return res.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}
+

+ 253 - 0
src/views/inspectionClassify/components/ProductModal.vue

@@ -0,0 +1,253 @@
+<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: 15,
+
+      });
+      return res;
+    },
+
+    open(item) {
+      this.processData = item || []
+      this.visible = true
+
+      this.getTreeData();
+
+    },
+
+
+
+    async getTreeData() {
+      try {
+        this.treeLoading = true;
+
+        const res = await getTreeByPid(15);
+        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
+        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>

+ 6 - 6
src/views/inspectionClassify/components/user-edit.vue → src/views/inspectionClassify/components/add.vue

@@ -1,6 +1,6 @@
 <template>
-  <el-dialog :title="title" v-if="visible" :visible.sync="visible" :before-close="handleClose" :close-on-click-modal="false"
-    :close-on-press-escape="false" append-to-body width="70%">
+  <el-dialog :title="title" v-if="visible" :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">
       <userEditSearch @search="reload" />
@@ -153,12 +153,12 @@ export default {
       _arr = this.selection.map(m => {
 
         return {
-          name: m.name,
-          code: m.code,
           qualityStandardId: m.id,
-          status: true,
+          status: 1,
           mode: null,
-          version: null
+          version: null,
+          categoryLevelId: this.categoryId,
+          rootCategoryLevelId: '12'
 
         }
       })

+ 296 - 0
src/views/inspectionClassify/components/edit.vue

@@ -0,0 +1,296 @@
+<!-- 用户编辑弹窗 -->
+<template>
+  <el-dialog class="ele-dialog-form" :title="title" :visible.sync="visible" :before-close="handleClose"
+    :close-on-click-modal="false" :close-on-press-escape="false" width="1000px">
+    <el-form ref="form" :model="form" :rules="rules" label-width="100px">
+      <el-row>
+
+
+        <el-col :span="12">
+          <el-form-item label="质检名称:" prop="name">
+            <el-input clearable v-model="form.name" placeholder="请输入" />
+          </el-form-item>
+        </el-col>
+        <el-col :span="12">
+          <el-form-item label="版本号:" prop="version">
+            <el-input v-model="form.version"></el-input>
+          </el-form-item>
+        </el-col>
+        <el-col :span="12">
+          <el-form-item label="状态:" prop="status">
+            <el-select v-model="form.status" placeholder="请选择" style="width: 100%">
+              <el-option label="停用" :value="0" />
+              <el-option label="启用" :value="1" />
+            </el-select>
+          </el-form-item>
+        </el-col>
+
+        <el-col :span="12">
+          <el-form-item label="标准类型:" prop="type">
+            <DictSelection dictName="质检标准类型" v-model="form.type"></DictSelection>
+          </el-form-item>
+        </el-col>
+
+        <el-col :span="12">
+          <el-form-item label="标准代码:" prop="standardCode">
+            <el-input v-model="form.standardCode"></el-input>
+          </el-form-item>
+        </el-col>
+
+
+
+      </el-row>
+    </el-form>
+
+    <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="操作" 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="220">
+        <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">
+        <template slot-scope="{ $index, row }">
+          <el-button type="text" @click="removePostscript($index, row)">删除</el-button>
+        </template>
+      </el-table-column>
+
+
+    </el-table>
+
+
+
+    <template v-slot:footer>
+      <el-button @click="handleClose">取消</el-button>
+      <el-button type="primary" :loading="loading" @click="save">
+        保存
+      </el-button>
+    </template>
+
+
+    <ProductModal ref="productRefs" @chooseModal="chooseModal" />
+
+  </el-dialog>
+</template>
+
+<script>
+
+import { save, update, getById } from '@/api/inspectionStandard';
+import ProductModal from './ProductModal.vue'
+export default {
+  components: {
+    ProductModal
+  },
+
+
+
+  data() {
+    const defaultForm = function () {
+      return {
+        id: '',
+        name: '',
+        status: '',
+        type: '',
+        version: '',
+        standardCode: '',
+        toolList: [],
+        postscriptList: [],
+        toolRemoveIds: [],
+        postscriptRemoveIds: []
+      };
+    };
+    return {
+      defaultForm,
+      // 表单数据
+      form: { ...defaultForm() },
+      // 表单验证规则
+      rules: {
+
+        name: [{ required: true, message: '请输入', trigger: 'blur' }],
+        version: [{ required: true, message: '请输入', trigger: 'blur' }],
+        type: {
+          required: true,
+          message: '请选择',
+          trigger: 'change'
+        },
+
+        status: {
+          required: true,
+          message: '请选择',
+          trigger: 'change'
+        },
+
+      },
+      visible: false,
+      type: null,
+      title: null,
+      loading: false,
+
+    };
+  },
+
+  created() {
+
+  },
+  methods: {
+    open(type, row) {
+      this.title = type == 'add' ? '新增' : '编辑'
+      this.type = type;
+      if (this.type == 'edit') {
+
+        this.getDetail(row.id)
+      }
+      this.visible = true;
+
+
+    },
+
+    getDetail(id) {
+      getById(id).then(res => {
+        this.form = res.data
+        this.form.postscriptRemoveIds = []
+        this.form.toolRemoveIds = []
+      })
+    },
+
+    /* 保存编辑 */
+    save() {
+      this.$refs.form.validate((valid) => {
+        if (!valid) {
+          return false;
+        }
+        this.loading = true;
+        if (this.type == 'add') {
+          delete this.form.id;
+        }
+        let URL = this.type == 'add' ? save : update
+        URL(this.form)
+          .then((msg) => {
+            this.loading = false;
+            this.$message.success(msg);
+            this.handleClose();
+            this.$emit('done');
+          })
+          .catch((e) => {
+            this.loading = false;
+          });
+      });
+    },
+    restForm() {
+      this.form = { ...this.defaultForm() };
+      this.$nextTick(() => {
+        this.$refs.form.clearValidate();
+      });
+    },
+    handleClose() {
+      this.restForm();
+      this.visible = false;
+    },
+
+    handleAdd() {
+      this.$refs.productRefs.open(this.form.toolList)
+    },
+
+    chooseModal(data) {
+      this.form.toolList = data
+      console.log(data)
+    },
+
+    removeItem(idx, row) {
+      if (this.form.toolList.length == 1) {
+        return this.$message.error('至少保留一个设备!');
+      }
+
+      this.$confirm(`是否删除这个设备?`).then(async () => {
+        this.form.toolList.splice(idx, 1)
+
+
+        this.form.toolRemoveIds.push(row.id)
+
+      })
+    },
+
+    addPostscript() {
+      this.form.postscriptList.push({ sort: null, content: '' })
+    },
+    removePostscript(idx, row) {
+      if (this.form.postscriptList.length == 1) {
+        return this.$message.error('至少保留一个事项!');
+      }
+
+      this.$confirm(`是否删除这个事项?`).then(async () => {
+        this.form.postscriptList.splice(idx, 1)
+
+
+        this.form.postscriptRemoveIds.push(row.id)
+
+      })
+    },
+
+
+  }
+};
+</script>
+<style lang="scss" scoped>
+.location-warp {
+  display: flex;
+
+  .detail {
+    margin-left: 10px;
+  }
+}
+
+:deep(.el-dialog:not(.ele-dialog-form) .el-dialog__body .el-form .el-form-item:last-child) {
+  margin-bottom: 22px;
+}
+</style>

+ 102 - 0
src/views/inspectionClassify/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>

+ 45 - 21
src/views/inspectionClassify/components/user-list.vue

@@ -7,34 +7,43 @@
       full-height="calc(100vh - 116px)" tool-class="ele-toolbar-form" cache-key="systemOrgUserTable">
       <!-- 表头工具栏 -->
       <template v-slot:toolbar>
-        <el-button size="small" type="primary" icon="el-icon-plus" class="ele-btn-icon" @click="openEdit()">
+        <el-button size="small" type="primary" icon="el-icon-plus" class="ele-btn-icon" @click="openAdd()">
           新增
         </el-button>
       </template>
       <!-- 编码列 -->
 
+      <template v-slot:name="{ row }">
+        {{ row.qualityStandard.name }}
+      </template>
+
+
+      <template v-slot:code="{ row }">
+        {{ row.qualityStandard.code }}
+      </template>
+
+
 
       <template v-slot:status="{ row }">
-        <el-switch v-model="row.status" active-color="#13ce66" inactive-color="#ff4949" :active-value="1"
-          :inactive-value="0" @change="changeEnable(row)">
-        </el-switch>
+        {{ row.qualityStandard.status }}
       </template>
 
 
       <template v-slot:mode="{ row }">
-        <DictSelection dictName="质检方式" v-model="row.mode"></DictSelection>
+        {{ row.qualityStandard.mode }}
+
       </template>
 
 
 
       <template v-slot:version="{ row }">
-        <el-input v-model="row.version"></el-input>
+        {{ row.qualityStandard.version }}
       </template>
 
 
 
       <template v-slot:action="{ row }">
-        <el-link type="primary" :underline="false" icon="el-icon-edit">
+        <el-link type="primary" :underline="false" icon="el-icon-edit" @click="openEdit(orw)">
           编辑
         </el-link>
         <el-popconfirm class="ele-action" title="确定要删除此干燥区吗?" @confirm="remove(row)">
@@ -49,20 +58,23 @@
 
     </ele-pro-table>
 
-    <user-edit @chooseProcess="chooseProcess" ref="userEdit" />
+    <Add @chooseProcess="chooseProcess" ref="addRef" />
+
+    <edit ref="edit" @done="done"></edit>
 
   </div>
 </template>
 
 <script>
 import userSearch from './user-search.vue';
-import { getList, removeItem } from '@/api/inspectionClassify/index';
+import { getList, removeItem, saveBatch } from '@/api/inspectionClassify/index';
 import dictMixins from '@/mixins/dictMixins';
-import UserEdit from './user-edit.vue';
+import Add from './add.vue';
+import Edit from './edit.vue'
 
 export default {
   mixins: [dictMixins],
-  components: { userSearch, UserEdit },
+  components: { userSearch, Add, Edit },
   props: {
     // 类别id
     categoryId: [Number, String],
@@ -89,14 +101,16 @@ export default {
           prop: 'name',
           label: '质检标准名称',
           showOverflowTooltip: true,
-          minWidth: 110
+          minWidth: 110,
+          slot: 'name',
         },
 
         {
           prop: 'code',
           label: '质检标准编码',
           showOverflowTooltip: true,
-          minWidth: 110
+          minWidth: 110,
+          slot: 'code',
         },
 
 
@@ -135,6 +149,7 @@ export default {
 
 
 
+
       ]
     };
   },
@@ -158,13 +173,23 @@ export default {
     },
 
     /* 打开编辑弹窗 */
-    openEdit() {
-      this.$refs.userEdit.open(this.categoryId);
+    openAdd() {
+      this.$refs.addRef.open(this.categoryId);
+    },
+
+    openEdit(row) {
+      this.$refs.edit.open(row);
     },
 
     chooseProcess(data) {
-      console.log(data)
-      this.$refs.table.setData(data);
+      saveBatch(data).then(res => {
+        console.log(res)
+        if (res.code == 0) {
+          this.$message.success(res.message)
+          this.reload()
+        }
+      })
+
     },
 
 
@@ -181,10 +206,9 @@ export default {
           loading.close();
         });
     },
-
-    async changeEnable(row) {
-      console.log(row)
-    },
+    done() {
+      this.$refs.search.search();
+    }