Kaynağa Gözat

Merge branch 'dev' of http://110.41.163.243:9980/kd-aiot/kd-aiot-frontend-aps into dengfei

695593266@qq.com 6 ay önce
ebeveyn
işleme
acee1fe7e0

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

@@ -407,3 +407,21 @@ export async function updatePreReleaseOrder(data) {
   }
   return Promise.reject(new Error(res.data.message));
 }
+
+// 根据bomId和工艺路线id获取工艺文件/nc代码
+export async function listBomTaskFile(bomCategoryId, routingId) {
+  const res = await request.get(
+    `/main/categoryparam/listBomTaskFile/${bomCategoryId}/${routingId}`
+  );
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}
+export async function newFilePageAPI(data) {
+  const res = await request.post('/fm/file/queryIds', data);
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}

+ 211 - 4
src/views/productionPlan/components/checkProductionPreparations.vue

@@ -123,6 +123,36 @@
         <el-button type="primary" @click="batchConfirm">确 定</el-button>
       </span>
     </el-dialog>
+    <ele-modal
+      width="65vw"
+      :visible.sync="fileVisible"
+      v-if="visible"
+      append-to-body
+      :maxable="true"
+      :title="fileTitle"
+    >
+      <ele-pro-table
+        ref="ncFileTable"
+        :columns="fileTitle == 'NC代码' ? jobColumns2 : jobColumns1"
+        :datasource="fileList"
+        :need-page="false"
+        :immediate="true"
+      >
+        <template v-slot:action="{ row, $index }">
+          <el-link
+            type="primary"
+            @click="fileDetails(row, fileTitle == 'NC代码' ? 'nc' : '')"
+            >详情</el-link
+          >
+        </template>
+
+      </ele-pro-table>
+              <template v-slot:footer v-if="fileTitle == 'NC代码'">
+          <el-button size="small" @click="fileVisible=false">返回</el-button>
+          <el-button type="primary" size="small" @click="save('齐套')">齐套</el-button>
+          <el-button type="primary" size="small" @click="save('缺料')">不齐套</el-button>
+        </template>
+    </ele-modal>
 
     <kitting-complete ref="kittingCompleteRef"></kitting-complete>
   </ele-modal>
@@ -133,10 +163,14 @@
     completenessCheck,
     taskReleaseWork,
     updatePreRelease,
-    updatePreReleaseOrder
+    updatePreReleaseOrder,
+    listBomTaskFile,
+    newFilePageAPI
   } from '@/api/productionPlan';
   import { listOrganizations, getUserPage } from '@/api/system/organization';
   import kittingComplete from './kittingComplete.vue';
+  import { setFileUrl } from '@/components/addDoc/util.js';
+
   export default {
     components: { kittingComplete },
     props: {
@@ -153,6 +187,8 @@
         selection: [],
         planId: '',
         preReleaseList: [],
+        fileTitle: '',
+        fileVisible: false,
         typeList: [
           {
             value: 1,
@@ -179,6 +215,132 @@
             label: '人员齐套'
           }
         ],
+        // 表格选中数据
+        jobColumns1: [
+          {
+            label: '编码',
+            prop: 'code',
+            width: 180,
+            align: 'center',
+            showOverflowTooltip: true
+          },
+
+          {
+            prop: 'name',
+            label: '文档名称',
+            align: 'center',
+            slot: 'name',
+            showOverflowTooltip: true,
+            minWidth: 200
+          },
+
+          {
+            prop: 'storagePath',
+            label: '文件名称',
+            align: 'center',
+
+            showOverflowTooltip: true,
+            minWidth: 200,
+            formatter: (_row, _column, cellValue) => {
+              return cellValue[0]?.name;
+            }
+          },
+
+          {
+            prop: 'version',
+            label: '版本',
+            align: 'center',
+            showOverflowTooltip: true,
+            minWidth: 100
+          },
+
+          {
+            prop: 'createTime',
+            label: '创建时间',
+            showOverflowTooltip: true,
+            align: 'center',
+            minWidth: 110
+          },
+          {
+            columnKey: 'action',
+            label: '操作',
+            width: 100,
+            align: 'center',
+            resizable: false,
+            slot: 'action',
+            showOverflowTooltip: true
+          }
+        ],
+        // 表格选中数据
+        jobColumns2: [
+          {
+            columnKey: 'index',
+            label: '序号',
+            type: 'index',
+            width: 55,
+            align: 'center',
+            showOverflowTooltip: true
+          },
+          {
+            label: '编码',
+            prop: 'code',
+            width: 180,
+            align: 'center',
+            showOverflowTooltip: true
+          },
+          {
+            prop: 'name',
+            label: '名称',
+            align: 'center',
+            slot: 'name',
+            showOverflowTooltip: true,
+            minWidth: 200
+          },
+          {
+            prop: 'versions',
+            label: '版本',
+            align: 'center',
+            showOverflowTooltip: true,
+            minWidth: 100
+          },
+          {
+            prop: 'remark',
+            label: '文本描述',
+            align: 'center',
+            showOverflowTooltip: true,
+            minWidth: 200
+          },
+          {
+            prop: 'ncSize',
+            label: '文件大小',
+            align: 'center',
+            showOverflowTooltip: true,
+            minWidth: 100
+          },
+          {
+            prop: 'createName',
+            label: '创建人',
+            showOverflowTooltip: true,
+            align: 'center',
+            minWidth: 110
+          },
+          {
+            prop: 'createTime',
+            label: '创建时间',
+            showOverflowTooltip: true,
+            align: 'center',
+            minWidth: 110
+          },
+          {
+            columnKey: 'action',
+            label: '操作',
+            width: 100,
+            align: 'center',
+            resizable: false,
+            slot: 'action',
+            showOverflowTooltip: true
+          }
+        ],
         groupList: [],
         leaderList: [],
         form: {
@@ -284,7 +446,19 @@
           });
         });
       },
-
+      fileDetails(row, type) {
+        if (type == 'nc') {
+          newFilePageAPI({
+            ids: "'" + row.fileId + "'"
+          }).then((res) => {
+            if (res.length) {
+              window.open(setFileUrl(res[0]));
+            }
+          });
+        } else {
+          window.open(setFileUrl(row));
+        }
+      },
       getTypeLabel(value) {
         const item = this.typeList.find((it) => it.value === value);
         return item ? item.label : '';
@@ -314,6 +488,13 @@
       handleClose() {
         this.dialogVisible = false;
       },
+      save(statusStr){
+        let data=this.preReleaseList.find(item=>item.preType==5)
+        console.log(data)
+        data.statusStr=statusStr
+        this.updatePreRelease(data);
+        this.fileVisible=false
+      },
       updatePreRelease(item) {
         if (this.type == 'plan') {
           updatePreRelease(item);
@@ -323,8 +504,8 @@
         }
         this.$emit('update');
       },
-      kittingComplete(item) {
-        if (item.preType == '5' || item.preType == '6') {
+      async kittingComplete(item) {
+        if (item.preType == '6') {
           this.$confirm('是否确认齐套?', '提示', {
             confirmButtonText: '齐套',
             cancelButtonText: '不齐套',
@@ -341,7 +522,33 @@
                 this.updatePreRelease(item);
               }
             });
+        } else if (item.preType == '4' || item.preType == '5') {
+          const res = await listBomTaskFile(
+            this.itemData.bomCategoryId,
+            this.itemData.produceRoutingId
+          );
+          let fileParam = [];
+          let ncCodeList = [];
+          res.forEach((row) => {
+            fileParam.push(row.fileParam.map((item) => item.id));
+            ncCodeList.push(row.ncCodeList);
+          });
+          if (item.preType == '4') {
+            fileParam = fileParam.flatMap((subarray) => subarray);
+            if (fileParam.length) {
+              this.fileList = await newFilePageAPI({
+                ids: "'" + fileParam + "'"
+              });
+            }
+
+            this.fileTitle = '工艺文件';
+          } else {
+            this.fileTitle = 'NC代码';
+            this.fileList = ncCodeList.flatMap((subarray) => subarray);
+          }
+          this.fileVisible = true;
         } else {
+          this.itemData.productionPlanId=this.itemData.productionPlanId||this.itemData.id
           const list = [this.itemData];
           this.$refs.kittingCompleteRef.open(list);
         }

+ 54 - 0
tests/setup.js

@@ -0,0 +1,54 @@
+/**
+ * Jest 测试环境设置文件
+ */
+
+// 配置测试环境
+import { config } from '@vue/test-utils';
+import ElementUI from 'element-ui';
+
+// 全局注册ElementUI
+config.global.plugins = [ElementUI];
+
+// Mock window对象
+Object.defineProperty(window, 'location', {
+  value: {
+    href: 'http://localhost:8080',
+    origin: 'http://localhost:8080',
+    protocol: 'http:',
+    host: 'localhost:8080',
+    hostname: 'localhost',
+    port: '8080',
+    pathname: '/',
+    search: '',
+    hash: ''
+  },
+  writable: true
+});
+
+// Mock localStorage
+const localStorageMock = {
+  getItem: jest.fn(),
+  setItem: jest.fn(),
+  removeItem: jest.fn(),
+  clear: jest.fn()
+};
+global.localStorage = localStorageMock;
+
+// Mock sessionStorage
+const sessionStorageMock = {
+  getItem: jest.fn(),
+  setItem: jest.fn(),
+  removeItem: jest.fn(),
+  clear: jest.fn()
+};
+global.sessionStorage = sessionStorageMock;
+
+// Mock console方法以避免测试输出污染
+global.console = {
+  ...console,
+  log: jest.fn(),
+  debug: jest.fn(),
+  info: jest.fn(),
+  warn: jest.fn(),
+  error: jest.fn()
+};