Преглед изворни кода

BOM的工艺路线可以新增工艺文件

695593266@qq.com пре 6 месеци
родитељ
комит
2b2d044491

+ 184 - 0
src/views/material/BOMmanage/components/craftFile.vue

@@ -0,0 +1,184 @@
+<template>
+  <ele-modal
+    width="75vw"
+    :visible.sync="visible"
+    v-if="visible"
+    :close-on-click-modal="false"
+    custom-class="ele-dialog-form"
+    title="工艺文件"
+    append-to-body
+    :maxable="true"
+    @closed="onClose"
+  >
+    <ele-pro-table
+      ref="fileTable"
+      :columns="jobColumns1"
+      :datasource="tableData"
+      :need-page="false"
+      :immediate="true"
+      row-key="code"
+    >
+      <!-- 表头工具栏 -->
+      <template v-slot:toolbar v-if="canEdit">
+        <el-button type="primary" @click="addFile">添加</el-button>
+      </template>
+
+      <!-- 操作列 -->
+      <template v-slot:action="{ row, $index }">
+        <el-link v-if="canEdit" type="primary" @click="handleDel($index)">
+          删除
+        </el-link>
+        <el-link type="primary" @click="fileDetails(row)"> 详情 </el-link>
+      </template>
+    </ele-pro-table>
+
+    <!-- 底部按钮 -->
+    <span slot="footer" class="dialog-footer" v-if="canEdit">
+      <el-button @click="visible = false">取 消</el-button>
+      <el-button type="primary" @click="saveFile">保 存</el-button>
+    </span>
+
+    <fileIndex v-if="fileShow" @close="fileClose" />
+  </ele-modal>
+</template>
+
+<script>
+  import dictMixins from '@/mixins/dictMixins';
+  import { newFilePageAPI } from '@/api/material/file';
+  import fileIndex from '../file/index.vue';
+  import { setFileUrl } from '@/components/addDoc/util.js';
+
+  export default {
+    components: { fileIndex },
+    mixins: [dictMixins],
+
+    props: {
+      attributeData: {
+        type: Object,
+        default: () => ({})
+      },
+      isWt: {
+        type: Boolean,
+        default: false
+      }
+    },
+
+    data() {
+      return {
+        visible: false,
+        fileShow: false,
+        routeData: null,
+        tableData: [],
+
+        jobColumns1: [
+          {
+            label: '编码',
+            prop: 'code',
+            width: 180,
+            align: 'center',
+            showOverflowTooltip: true
+          },
+          {
+            label: '文档名称',
+            prop: 'name',
+            align: 'center',
+            minWidth: 200,
+            showOverflowTooltip: true
+          },
+          {
+            label: '文件名称',
+            prop: 'storagePath',
+            align: 'center',
+            minWidth: 200,
+            showOverflowTooltip: true,
+            formatter: (_, __, val) =>
+              Array.isArray(val) && val.length ? val[0].name : '-'
+          },
+          { label: '版本', prop: 'version', align: 'center', minWidth: 100 },
+          {
+            label: '创建时间',
+            prop: 'createTime',
+            align: 'center',
+            minWidth: 110,
+            showOverflowTooltip: true
+          },
+          {
+            label: '操作',
+            columnKey: 'action',
+            slot: 'action',
+            width: 260,
+            align: 'center'
+          }
+        ]
+      };
+    },
+
+    computed: {
+      /** 是否可编辑 */
+      canEdit() {
+        const { approvalStatus, parentId, resourceBomId } = this.attributeData;
+        const notApproved = approvalStatus !== 1 && approvalStatus !== 2;
+
+        return (
+          (!this.isWt && parentId === '0' && notApproved) ||
+          (!resourceBomId && !this.isWt && notApproved)
+        );
+      }
+    },
+
+    methods: {
+      open(item) {
+        this.routeData = item;
+        this.visible = true;
+        this.fetchFiles();
+      },
+
+      async fetchFiles() {
+        const ids = this.routeData?.fileParam?.map((i) => i.id) || [];
+
+        if (!ids.length) {
+          this.tableData = [];
+          return;
+        }
+
+        const res = await newFilePageAPI({
+          ids: `'${ids.join(',')}'`
+        });
+
+        this.tableData = res || [];
+      },
+
+      addFile() {
+        this.fileShow = true;
+      },
+
+      fileClose(list) {
+        this.tableData = list || [];
+        this.fileShow = false;
+      },
+
+      handleDel(index) {
+        this.tableData.splice(index, 1);
+      },
+
+      fileDetails(row) {
+        window.open(setFileUrl(row));
+      },
+
+      saveFile() {
+        if (!this.tableData.length) {
+          return this.$message.warning('请添加工艺路线');
+        }
+
+        this.$emit('updataFile', this.tableData);
+        this.visible = false;
+      },
+
+      onClose() {
+        this.visible = false;
+      }
+    }
+  };
+</script>
+
+<style></style>

+ 50 - 10
src/views/material/BOMmanage/components/routing.vue

@@ -69,6 +69,15 @@
           }}
         </template>
 
+        <template v-slot:fileParam="{ row, $index }">
+          <el-link
+            type="primary"
+            :underline="false"
+            @click="fileBtn(row, $index)"
+            >文件
+          </el-link></template
+        >
+
         <template v-slot:action="{ row, $index }">
           <el-link
             type="danger"
@@ -90,6 +99,13 @@
     </el-card>
     <routingDialog ref="routingDialogRef" @reload="reload"></routingDialog>
 
+    <craft-file
+      ref="craftFileRef"
+      @updataFile="updataFile"
+      :attributeData="attributeData"
+      :isWt="isWt"
+    ></craft-file>
+
     <!-- 编辑弹窗 -->
     <user-edit
       :visible.sync="showEdit"
@@ -112,12 +128,14 @@
     workingProcedureUpdate,
     workingProcedureSave
   } from '@/api/material/BOM';
+  import craftFile from './craftFile.vue';
   // import { workingProcedureUpdate } from '@/api/material/BOM';
   export default {
     name: 'technologyRoute',
     components: {
       routingDialog,
-      UserEdit
+      UserEdit,
+      craftFile
     },
     props: {
       taskParam: Object,
@@ -182,6 +200,13 @@
             align: 'center',
             showOverflowTooltip: true
           },
+          {
+            prop: 'fileParam',
+            label: '工艺文件',
+            slot: 'fileParam',
+            align: 'center',
+            showOverflowTooltip: true
+          },
 
           {
             prop: 'status',
@@ -222,7 +247,8 @@
         ],
         loading: false,
         isBomRoute: false,
-        isCategory: false
+        isCategory: false,
+        routeIndex: ''
       };
     },
 
@@ -278,11 +304,9 @@
       },
 
       selected(dataList) {
-        console.log(dataList, 'dataList');
         let routingId = dataList.map((it) => it.id);
 
         route.getProcessById(routingId).then((data) => {
-          console.log(this.tableData);
           if (this.tableData.taskParam) {
             let newArr = [];
             for (let i = 0; i < data.length; i++) {
@@ -376,6 +400,12 @@
               this.getAllRouteList();
             }
           }
+          // console.log(this.tableData, 'tableData');
+          // console.log(data[0].processRoute.list, 'data[0].processRoute.list');
+          data[0].processRoute.list.forEach((item) => {
+            item.fileParam = item.fileParam ? item.fileParam : [];
+          });
+
           return data[0].processRoute.list || [];
         } else {
           this.tableData = {};
@@ -383,6 +413,21 @@
         }
       },
 
+      fileBtn(item, index) {
+        this.routeIndex = index;
+        this.$refs.craftFileRef.open(item);
+      },
+
+      updataFile(fileList) {
+        this.$set(
+          this.tableData.processRoute.list[this.routeIndex],
+          'fileParam',
+          fileList
+        );
+
+        this.selected([]);
+      },
+
       async getAllRouteList() {
         await route
           .list({
@@ -392,6 +437,7 @@
           .then((res) => {
             let routeList = [];
             let routeItem = [];
+
             this.tableData.routingIdList.forEach((id) => {
               routeItem = res.list.find((item) => item.id == id);
               if (routeItem) {
@@ -406,12 +452,6 @@
       },
 
       handleDel(row) {
-        // route.getProcessById([row.id]).then((data) => {
-
-        // })
-
-        // console.log(row,'41444444',this.tableData.processRoute.list);
-        // return
         this.$confirm('是否删除?', '提示', {
           confirmButtonText: '确定',
           cancelButtonText: '取消',

+ 8 - 6
src/views/material/BOMmanage/components/workingProcedure.vue

@@ -757,7 +757,6 @@
             :need-page="false"
             :immediate="true"
           >
-            <!-- 表头工具栏 -->
             <template v-if="!isView" v-slot:toolbar>
               <el-button type="primary" @click="addFile">添加</el-button>
             </template>
@@ -1247,7 +1246,7 @@
         },
 
         qualityParam: [],
-        firstArticleDualInspectionParam:[],
+        firstArticleDualInspectionParam: [],
         qualityPointParam: [],
 
         fileShow: false,
@@ -1611,10 +1610,11 @@
         } else if (this.activeName === '质检项参数') {
           this.qualityParam =
             this.tableData.taskParam[this.currentIndex].qualityParam || [];
-        }else if (this.activeName === '首件两检') {
+        } else if (this.activeName === '首件两检') {
           this.firstArticleDualInspectionParam =
-            this.tableData.taskParam[this.currentIndex].firstArticleDualInspectionParam || [];
-        }  else if (this.activeName === '生产节拍') {
+            this.tableData.taskParam[this.currentIndex]
+              .firstArticleDualInspectionParam || [];
+        } else if (this.activeName === '生产节拍') {
           this.beatParam =
             this.tableData.taskParam[this.currentIndex].beatParam ||
             this.beatParam;
@@ -1889,7 +1889,9 @@
                   this.$refs.qualityParamRef.getDate() || [];
               }
               if (this.$refs.firstArticleDualInspectionParamRef) {
-                this.tableData.taskParam[this.currentIndex].firstArticleDualInspectionParam =
+                this.tableData.taskParam[
+                  this.currentIndex
+                ].firstArticleDualInspectionParam =
                   this.$refs.firstArticleDualInspectionParamRef.getDate() || [];
               }
               //工艺文件只传id