huang_an 2 лет назад
Родитель
Сommit
e80a8f9032

+ 15 - 5
src/api/material/list.js

@@ -11,10 +11,8 @@ export async function getGroupPage(data) {
   return Promise.reject(new Error(res.data.message));
 }
 
-
 //  ==========  物料管理   =============/
 
-
 // 根据分类组编码查询分类树信息
 export async function getTreeByPid(pid) {
   const res = await request.get(`/main/categoryLevel/getTreeByPid/${pid}`);
@@ -80,7 +78,6 @@ export async function getBomRoutingList(categoryId) {
   return Promise.reject(new Error(res.data.message));
 }
 
-
 // 产品工序与模具关联
 export async function categoryTaskPallet(data) {
   const res = await request.post(`/main/category/categoryTaskPallet`, data);
@@ -90,12 +87,25 @@ export async function categoryTaskPallet(data) {
   return Promise.reject(new Error(res.data.message));
 }
 
-
 // 获取产品工序与模具关联
 export async function getCategoryTaskPallet(categoryId) {
-  const res = await request.get(`/main/category/getCategoryTaskPallet/${categoryId}`);
+  const res = await request.get(
+    `/main/category/getCategoryTaskPallet/${categoryId}`
+  );
   if (res.data.code == 0) {
     return res.data.data;
   }
   return Promise.reject(new Error(res.data.message));
 }
+
+// 导入备品备件
+export async function importCategorySparePart(data) {
+  const res = await request.post(
+    `/main/excelUpload/importCategorySparePart`,
+    data
+  );
+  if (res.data.code == 0) {
+    return res.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}

+ 380 - 261
src/views/material/product/components/index-data.vue

@@ -1,22 +1,83 @@
 <template>
   <div>
     <!-- 数据表格 -->
-    <ele-pro-table ref="table" :columns="columns" :datasource="datasource" :need-page="true" :selection.sync="selection"
-      :current.sync="rowCurrent" highlight-current-row height="calc(100vh - 412px)" full-height="calc(100vh - 116px)"
-      tool-class="ele-toolbar-form" cache-key="systemDictDataTable">
+    <ele-pro-table
+      ref="table"
+      :columns="columns"
+      :datasource="datasource"
+      :need-page="true"
+      :selection.sync="selection"
+      :current.sync="rowCurrent"
+      highlight-current-row
+      height="calc(100vh - 412px)"
+      full-height="calc(100vh - 116px)"
+      tool-class="ele-toolbar-form"
+      cache-key="systemDictDataTable"
+    >
       <!-- 表头工具栏 -->
       <template v-slot:toolbar>
-        <el-button size="small" type="primary" icon="el-icon-plus" class="ele-btn-icon" @click="openEdit({}, 2)">
+        <el-button
+          size="small"
+          type="primary"
+          icon="el-icon-plus"
+          class="ele-btn-icon"
+          @click="openEdit({}, 2)"
+        >
           新建
         </el-button>
-
-        <el-button v-if="rootTreeId == 9" size="small" type="primary" @click="handleLink('4')">关联设备</el-button>
-        <el-button v-if="rootTreeId == 9" size="small" type="primary" @click="handleLink('5')">关联模具</el-button>
-        <el-button v-if="rootTreeId == 9" size="small" type="primary" @click="handleLink('8')">关联舟皿</el-button>
-
-        <el-button v-if="rootTreeId == 4" size="small" type="primary" @click="handleLink('5')">关联模具</el-button>
-        <el-button v-if="rootTreeId == 4" size="small" type="primary" @click="handleLink('6')">关联备品备件</el-button>
-
+        <div class="upload" v-if="rootTreeId == 6">
+          <el-upload
+            v-if="!isLoading"
+            :show-file-list="false"
+            class="upload-demo"
+            action="#"
+            :before-upload="beforeUpload"
+            :on-success="suuccessUpload"
+          >
+            <slot>
+              <el-button size="small" type="primary">导入</el-button>
+            </slot>
+          </el-upload>
+          <el-button v-else size="small" type="primary" :loading="isLoading"
+            >导入</el-button
+          >
+        </div>
+        <el-button
+          v-if="rootTreeId == 9"
+          size="small"
+          type="primary"
+          @click="handleLink('4')"
+          >关联设备</el-button
+        >
+        <el-button
+          v-if="rootTreeId == 9"
+          size="small"
+          type="primary"
+          @click="handleLink('5')"
+          >关联模具</el-button
+        >
+        <el-button
+          v-if="rootTreeId == 9"
+          size="small"
+          type="primary"
+          @click="handleLink('8')"
+          >关联舟皿</el-button
+        >
+
+        <el-button
+          v-if="rootTreeId == 4"
+          size="small"
+          type="primary"
+          @click="handleLink('5')"
+          >关联模具</el-button
+        >
+        <el-button
+          v-if="rootTreeId == 4"
+          size="small"
+          type="primary"
+          @click="handleLink('6')"
+          >关联备品备件</el-button
+        >
       </template>
       <template v-slot:action="{ row }">
         <el-link type="primary" :underline="false" @click="openEdit(row, 1)">
@@ -25,53 +86,85 @@
         <el-link type="primary" :underline="false" @click="openEdit(row, 0)">
           修改
         </el-link>
-        <el-popconfirm class="ele-action" title="确定要删除此物料吗?" @confirm="remove(row)">
+        <el-popconfirm
+          class="ele-action"
+          title="确定要删除此物料吗?"
+          @confirm="remove(row)"
+        >
           <template v-slot:reference>
-            <el-link type="danger" :underline="false">
-              删除
-            </el-link>
+            <el-link type="danger" :underline="false"> 删除 </el-link>
           </template>
         </el-popconfirm>
 
-
-        <el-link type="primary" v-if="row.isProduct == 1" :underline="false" @click="openParam(row)">
+        <el-link
+          type="primary"
+          v-if="row.isProduct == 1"
+          :underline="false"
+          @click="openParam(row)"
+        >
           工艺参数
         </el-link>
 
-
-        <el-link type="primary" v-if="row.isProduct == 1" :underline="false" @click="openMaterial(row)">
+        <el-link
+          type="primary"
+          v-if="row.isProduct == 1"
+          :underline="false"
+          @click="openMaterial(row)"
+        >
           物料BOM
         </el-link>
 
-
-        <el-link type="primary" v-if="row.isProduct == 1" :underline="false" @click="openMould(row)">
+        <el-link
+          type="primary"
+          v-if="row.isProduct == 1"
+          :underline="false"
+          @click="openMould(row)"
+        >
           模具
         </el-link>
 
-
-        <el-link type="primary" v-if="row.categoryLevelPathIdParent == 7" :underline="false" @click="handAllocation(row)">
+        <el-link
+          type="primary"
+          v-if="row.categoryLevelPathIdParent == 7"
+          :underline="false"
+          @click="handAllocation(row)"
+        >
           货位
         </el-link>
 
-        <el-link type="primary" v-if="row.categoryLevelPathIdParent == 11" :underline="false"
-          @click="handleAridRegion(row)">
+        <el-link
+          type="primary"
+          v-if="row.categoryLevelPathIdParent == 11"
+          :underline="false"
+          @click="handleAridRegion(row)"
+        >
           干燥区
         </el-link>
-
-
       </template>
     </ele-pro-table>
     <!-- 编辑弹窗 -->
     <!--    <dict-edit :visible.sync="showEdit" :id="id" @done="reload" /> -->
 
     <!-- 选择物料 -->
-    <MaterialModal :visible.sync="materialEdit" :data="current" ref="materialRefs"></MaterialModal>
+    <MaterialModal
+      :visible.sync="materialEdit"
+      :data="current"
+      ref="materialRefs"
+    ></MaterialModal>
 
     <!-- 工艺参数 -->
-    <ParamEdit :visible.sync="paramEditShow" :paramData="current" ref="paramRefs"></ParamEdit>
+    <ParamEdit
+      :visible.sync="paramEditShow"
+      :paramData="current"
+      ref="paramRefs"
+    ></ParamEdit>
 
     <!-- 模具 -->
-    <mouldDialog :visible.sync="mouldShow" :data="current" ref="mouldRefs"></mouldDialog>
+    <mouldDialog
+      :visible.sync="mouldShow"
+      :data="current"
+      ref="mouldRefs"
+    ></mouldDialog>
 
     <linkMaterialDialog ref="linkMaterialDialogRef" @success="success" />
 
@@ -80,250 +173,276 @@
 
     <!-- 干燥区 -->
     <aridRegion ref="aridRegionRef"></aridRegion>
-
   </div>
 </template>
 
 <script>
-import { getMaterialList, removeMaterial } from '@/api/material/list.js';
-import MaterialModal from './MaterialModal.vue'
-import ParamEdit from '@/views/technology/productParam/components/user-edit.vue'
-import mouldDialog from './mouldDialog'
-import linkMaterialDialog from './link-material-dialog.vue';
-import goodsAllocation from './goodsAllocation.vue'
-import aridRegion from './aridRegion'
-export default {
-  components: {
-    MaterialModal,
-    ParamEdit,
-    mouldDialog,
-    linkMaterialDialog,
-    goodsAllocation,
-    aridRegion
-  },
-  props: {
-    // 物料组id
-    currentId: [Number, String],
-    data: Object,
-    rootId: [Number, String],
-
-    rootTreeId: [Number, String],
-  },
-  data() {
-    return {
-      // 表格列配置
-      columns: [
-        {
-          columnKey: 'index',
-          type: 'index',
-          width: 50,
-          align: 'center',
-          showOverflowTooltip: true,
-          label: '序号'
-        },
-        {
-          prop: 'code',
-          label: '编码',
-          align: 'center',
-          showOverflowTooltip: true,
-          minWidth: 110
-        },
-        {
-          prop: 'name',
-          label: '名称',
-          align: 'center',
-          showOverflowTooltip: true,
-          minWidth: 110
-        },
-
-        {
-          prop: 'brandNum',
-          align: 'center',
-          label: '牌号',
-          showOverflowTooltip: true
-        },
-        {
-          prop: 'modelType',
-          label: '型号',
-          align: 'center',
-          showOverflowTooltip: true
-        },
-        {
-          prop: 'specification',
-          label: '规格',
-          align: 'center',
-          showOverflowTooltip: true
-        },
-        {
-          prop: 'measuringUnit',
-          label: '计量单位',
-          showOverflowTooltip: true,
-          minWidth: 90
-        },
-
-        {
-          prop: 'weightUnit',
-          label: '重量单位',
-          showOverflowTooltip: true,
-          minWidth: 90
-        },
-
-        {
-          prop: 'roughWeight',
-          label: '毛重',
-          showOverflowTooltip: true,
-          minWidth: 90
-        },
-
-        {
-          prop: 'netWeight',
-          label: '净重',
-          showOverflowTooltip: true,
-          minWidth: 90
-        },
-
-
-        {
-          prop: 'packingUnit',
-          align: 'center',
-          label: '包装单位',
-          showOverflowTooltip: true
-        },
-        {
-          prop: 'categoryLevelPath',
-          label: '分类',
-          align: 'center',
-          showOverflowTooltip: true
-        },
-        {
-          columnKey: 'action',
-          label: '操作',
-          width: 200,
-          align: 'center',
-          resizable: false,
-          slot: 'action',
-          fixed: 'right'
-        }
-      ],
-
-      // 表格选中数据
-      selection: [],
-      // 是否显示编辑弹窗
-      showEdit: false,
-      id: null,
-
-      materialEdit: false,
-      paramEditShow: false,
-      mouldShow: false,
-      current: null,
-
-      rowCurrent: null,
-
-
-
-    };
-  },
-
-  methods: {
-    /* 表格数据源 */
-    datasource({ page, limit, where, order }) {
-      return getMaterialList({
-        pageNum: page,
-        size: limit,
-        ...where,
-        categoryLevelId: this.currentId
-      });
-    },
-    /* 刷新表格 */
-    reload(where) {
-      this.$refs.table.reload({
-        page: 1,
-        where: where,
-        categoryLevelId: this.currentId
-      });
+  import {
+    getMaterialList,
+    removeMaterial,
+    importCategorySparePart
+  } from '@/api/material/list.js';
+  import MaterialModal from './MaterialModal.vue';
+  import ParamEdit from '@/views/technology/productParam/components/user-edit.vue';
+  import mouldDialog from './mouldDialog';
+  import linkMaterialDialog from './link-material-dialog.vue';
+  import goodsAllocation from './goodsAllocation.vue';
+  import aridRegion from './aridRegion';
+  export default {
+    components: {
+      MaterialModal,
+      ParamEdit,
+      mouldDialog,
+      linkMaterialDialog,
+      goodsAllocation,
+      aridRegion
     },
-    /* 显示编辑 */
-    openEdit(row, status) {
-      this.$router.push({
-        path: '/material/product/detail',
-        query: {
-          id: row.id ? row.id : null,
-          status: status,
-          rootId: this.rootId,
-          t: new Date().getTime()
-        }
-      });
-    },
-    /* 删除 */
-    remove(row) {
-      const loading = this.$loading({ lock: true });
-      removeMaterial(row.id)
-        .then((msg) => {
-          loading.close();
-          this.$message.success('删除' + msg);
-          this.reload();
-        })
-        .catch((e) => {
-          loading.close();
-          // this.$message.error(e.message);
-        });
-    },
-
+    props: {
+      // 物料组id
+      currentId: [Number, String],
+      data: Object,
+      rootId: [Number, String],
 
-    openMaterial(row) {
-      this.current = row;
-      this.materialEdit = true;
-      this.$refs.materialRefs.$refs.form &&
-        this.$refs.materialRefs.$refs.form.clearValidate();
+      rootTreeId: [Number, String]
     },
-
-
-    openParam(row) {
-      this.paramEditShow = true;
-      this.current = row;
-      this.$refs.paramRefs.$refs.form &&
-        this.$refs.paramRefs.$refs.form.clearValidate();
-
+    data() {
+      return {
+        // 表格列配置
+        columns: [
+          {
+            columnKey: 'index',
+            type: 'index',
+            width: 50,
+            align: 'center',
+            showOverflowTooltip: true,
+            label: '序号'
+          },
+          {
+            prop: 'code',
+            label: '编码',
+            align: 'center',
+            showOverflowTooltip: true,
+            minWidth: 110
+          },
+          {
+            prop: 'name',
+            label: '名称',
+            align: 'center',
+            showOverflowTooltip: true,
+            minWidth: 110
+          },
+
+          {
+            prop: 'brandNum',
+            align: 'center',
+            label: '牌号',
+            showOverflowTooltip: true
+          },
+          {
+            prop: 'modelType',
+            label: '型号',
+            align: 'center',
+            showOverflowTooltip: true
+          },
+          {
+            prop: 'specification',
+            label: '规格',
+            align: 'center',
+            showOverflowTooltip: true
+          },
+          {
+            prop: 'measuringUnit',
+            label: '计量单位',
+            showOverflowTooltip: true,
+            minWidth: 90
+          },
+
+          {
+            prop: 'weightUnit',
+            label: '重量单位',
+            showOverflowTooltip: true,
+            minWidth: 90
+          },
+
+          {
+            prop: 'roughWeight',
+            label: '毛重',
+            showOverflowTooltip: true,
+            minWidth: 90
+          },
+
+          {
+            prop: 'netWeight',
+            label: '净重',
+            showOverflowTooltip: true,
+            minWidth: 90
+          },
+
+          {
+            prop: 'packingUnit',
+            align: 'center',
+            label: '包装单位',
+            showOverflowTooltip: true
+          },
+          {
+            prop: 'categoryLevelPath',
+            label: '分类',
+            align: 'center',
+            showOverflowTooltip: true
+          },
+          {
+            columnKey: 'action',
+            label: '操作',
+            width: 200,
+            align: 'center',
+            resizable: false,
+            slot: 'action',
+            fixed: 'right'
+          }
+        ],
+
+        // 表格选中数据
+        selection: [],
+        // 是否显示编辑弹窗
+        showEdit: false,
+        id: null,
+
+        materialEdit: false,
+        paramEditShow: false,
+        mouldShow: false,
+        current: null,
+
+        rowCurrent: null,
+        isLoading: false
+      };
     },
 
-    openMould(row) {
-      this.current = row;
-      this.mouldShow = true;
-      this.$refs.mouldRefs.$refs.form &&
-        this.$refs.mouldRefs.$refs.form.clearValidate();
-    },
+    methods: {
+      suuccessUpload() {
+        this.isLoading = false;
+      },
+      // 上传备品备件
+      beforeUpload(file) {
+        if (file.size / 1024 / 1024 > this.size) {
+          this.$message.error(`大小不能超过 ${this.size}MB`);
+          return false;
+        }
 
-    handleLink(type) {
-      if (!this.rowCurrent) {
-        return this.$message.error(this.rootTreeId == 9 ? '请选择产品!' : this.rootTreeId == 4 ? '请选择设备!' : '');
-      }
+        if (this.limit > 0 && this.fileList.length === this.limit) {
+          this.$message.error(`最多上传 ${this.limit}个文件`);
+          return false;
+        }
+        let formData = new FormData();
+        formData.append('file', file);
+        this.isLoading = true;
+        return importCategorySparePart(formData).then((res) => {
+          this.isLoading = false;
+          return res.data;
+        });
+      },
+      /* 表格数据源 */
+      datasource({ page, limit, where, order }) {
+        return getMaterialList({
+          pageNum: page,
+          size: limit,
+          ...where,
+          categoryLevelId: this.currentId
+        });
+      },
+      /* 刷新表格 */
+      reload(where) {
+        this.$refs.table.reload({
+          page: 1,
+          where: where,
+          categoryLevelId: this.currentId
+        });
+      },
+      /* 显示编辑 */
+      openEdit(row, status) {
+        this.$router.push({
+          path: '/material/product/detail',
+          query: {
+            id: row.id ? row.id : null,
+            status: status,
+            rootId: this.rootId,
+            t: new Date().getTime()
+          }
+        });
+      },
+      /* 删除 */
+      remove(row) {
+        const loading = this.$loading({ lock: true });
+        removeMaterial(row.id)
+          .then((msg) => {
+            loading.close();
+            this.$message.success('删除' + msg);
+            this.reload();
+          })
+          .catch((e) => {
+            loading.close();
+            // this.$message.error(e.message);
+          });
+      },
+
+      openMaterial(row) {
+        this.current = row;
+        this.materialEdit = true;
+        this.$refs.materialRefs.$refs.form &&
+          this.$refs.materialRefs.$refs.form.clearValidate();
+      },
+
+      openParam(row) {
+        this.paramEditShow = true;
+        this.current = row;
+        this.$refs.paramRefs.$refs.form &&
+          this.$refs.paramRefs.$refs.form.clearValidate();
+      },
+
+      openMould(row) {
+        this.current = row;
+        this.mouldShow = true;
+        this.$refs.mouldRefs.$refs.form &&
+          this.$refs.mouldRefs.$refs.form.clearValidate();
+      },
+
+      handleLink(type) {
+        if (!this.rowCurrent) {
+          return this.$message.error(
+            this.rootTreeId == 9
+              ? '请选择产品!'
+              : this.rootTreeId == 4
+              ? '请选择设备!'
+              : ''
+          );
+        }
 
-      this.$refs.linkMaterialDialogRef.open(type, this.rowCurrent);
-    },
+        this.$refs.linkMaterialDialogRef.open(type, this.rowCurrent);
+      },
 
-    success() {
-      this.reload();
-    },
+      success() {
+        this.reload();
+      },
 
+      handAllocation(row) {
+        this.$refs.allocationRef.open(row);
+      },
 
-    handAllocation(row) {
-      this.$refs.allocationRef.open(row)
+      handleAridRegion(row) {
+        this.$refs.aridRegionRef.open(row);
+      }
     },
-
-    handleAridRegion(row) {
-      this.$refs.aridRegionRef.open(row)
-    }
-
-
-
-
-
-  },
-  watch: {
-    // 监听物料组id变化
-    currentId() {
-      this.reload();
+    watch: {
+      // 监听物料组id变化
+      currentId() {
+        this.reload();
+      }
     }
-  }
-};
+  };
 </script>
+<style lang="scss" scoped>
+  .upload {
+    display: inline-block;
+    width: 100px;
+    margin-left: 10px;
+  }
+</style>

+ 31 - 4
src/views/rulesManagement/components/programRulesDialog.vue

@@ -68,7 +68,19 @@
             </div>
           </el-form-item>
         </el-col>
-
+        <el-col :span="8">
+          <el-form-item label="类型" prop="autoOrder">
+            <el-select
+              v-model="addForm.type"
+              size="small"
+              @change="typeChange"
+              style="width: 100%"
+            >
+              <el-option :value="1" label="班组"></el-option>
+              <el-option :value="0" label="个人"></el-option>
+            </el-select>
+          </el-form-item>
+        </el-col>
         <el-col
           :span="8"
           v-if="addForm.autoOrder && !dialogTitle.includes('量具送检')"
@@ -83,7 +95,11 @@
         </el-col>
         <el-col
           :span="8"
-          v-if="addForm.autoOrder && !dialogTitle.includes('量具送检')"
+          v-if="
+            addForm.autoOrder &&
+            !dialogTitle.includes('量具送检') &&
+            addForm.type == 0
+          "
         >
           <el-form-item label="负责人" prop="executeIdList">
             <el-select
@@ -451,6 +467,7 @@
         addForm: {
           code: '', // 计划配置单号
           name: '', // 计划配置名称
+          type: 0, // 默认个人
           autoOrder: 1, // 自动派单
           ruleId: '', // 规则id
           ruleName: '', // 规则名称
@@ -629,6 +646,7 @@
             code: '', // 计划配置单号
             name: '', // 计划配置名称
             autoOrder: 1, // 自动派单
+            type: 0, // 默认个人
             ruleId: '', // 规则id
             ruleName: '', // 规则名称
             duration: null, // 计划完成时长
@@ -647,6 +665,10 @@
           //   this.matterRulesList = [];
         }
       },
+      typeChange() {
+        this.addForm.groupId = '';
+        this.addForm.executeIdList = [];
+      },
       ruleChange(item) {
         this.ruleObj.name = item.name;
         this.ruleObj.code = item.code;
@@ -865,12 +887,17 @@
         }
       },
       //选择部门(搜索)
-      searchDeptNodeClick(info, data) {
+      async searchDeptNodeClick(info, data) {
         if (info) {
           // 根据部门获取人员
           this.addForm.groupName = data.name;
           const params = { groupId: info };
-          this.getUserList(params);
+          await this.getUserList(params);
+          if (this.addForm.type == 1) {
+            this.addForm.executeIdList = this.executorList.map(
+              (item) => item.id
+            );
+          }
         } else {
           this.addForm.groupId = null;
         }