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

修改批记录工艺文件

lucw пре 8 месеци
родитељ
комит
4edd05a02a

+ 9 - 0
src/api/produce/workOrder.js

@@ -376,3 +376,12 @@ export async function getAllProductInWorkOrder(body) {
   }
   return Promise.reject(new Error(res.data.message));
 }
+
+// /mes/workorder/craftFiles/batchRecordPage
+export async function batchRecordPage(data) {
+  const res = await request.post('/mes/workorder/craftFiles/batchRecordPage', data);
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}

+ 274 - 0
src/views/batchRecord/components/EquipmentDialog.vue

@@ -0,0 +1,274 @@
+<template>
+  <ele-modal
+    title="选择产品"
+    :visible.sync="equipmentdialog"
+    :before-close="handleClose"
+    :close-on-click-modal="true"
+    :close-on-press-escape="false"
+    append-to-body
+    width="60%"
+    :maxable="true"
+  >
+    <div>
+      <el-row>
+        <el-col :span="24" class="topsearch">
+          <el-form>
+            <el-row>
+              <el-col :span="6">
+                <el-input
+                  v-model="code"
+                  placeholder="请输入物料编码"
+                  size="small"
+                ></el-input>
+              </el-col>
+
+              <el-col :span="6" style="margin-left: 10px">
+                <el-input
+                  v-model="name"
+                  placeholder="请输入物料名称"
+                  size="small"
+                ></el-input>
+              </el-col>
+              <el-col :span="6" style="margin-left: 10px">
+                <el-input
+                  v-model="searchKey"
+                  placeholder="请输入关键字"
+                  size="small"
+                ></el-input>
+              </el-col>
+
+              <el-col :span="4" style="margin-left: 10px">
+                <el-button type="primary" size="small" @click="reload"
+                  >搜索</el-button
+                >
+                <el-button size="small" @click="reset">重置</el-button>
+              </el-col>
+            </el-row>
+          </el-form>
+        </el-col>
+        <el-col :span="6" class="tree_col">
+          <AssetTree
+            @handleNodeClick="handleNodeClick"
+            :treeIds="treeType"
+            ref="treeList"
+          />
+        </el-col>
+        <el-col :span="18" class="table_col" v-if="equipmentdialog">
+          <ele-pro-table
+            ref="equiTable"
+            :columns="columns"
+            :datasource="datasource"
+            :selection.sync="selection"
+            @select="handleSelect"
+            cache-key="systemRoleTable3"
+            row-key="id"
+            height="50vh"
+            @done="setSelect"
+          >
+          </ele-pro-table>
+        </el-col>
+      </el-row>
+    </div>
+    <div class="btns">
+      <el-button type="primary" size="small" @click="selected">选择</el-button>
+      <el-button size="small" @click="handleClose">关闭</el-button>
+    </div>
+  </ele-modal>
+</template>
+
+<script>
+  import AssetTree from '@/components/AssetTree/newIndex.vue';
+import { getList } from '@/api/classifyManage/index';
+
+  export default {
+    components: {
+      AssetTree
+    },
+    props: {
+      selectList: {
+        type: Array,
+        default: () => []
+      },
+      // 是否多选 1:是 0:否
+      isMultiple: {
+        type: String,
+        default: '1' 
+      },
+      treeType: {
+        type: Array,
+        default: () => ['9']
+
+
+      }
+    },
+
+    data() {
+      return {
+        equipmentdialog: false,
+        columns: [
+          {
+            width: 45,
+            type: 'selection',
+            columnKey: 'selection',
+            align: 'center',
+            reserveSelection: true
+          },
+          {
+            columnKey: 'index',
+            label: '序号',
+            type: 'index',
+            width: 55,
+            align: 'center',
+            showOverflowTooltip: true
+          },
+          {
+            prop: 'code',
+            label: '物品编码',
+            align: 'center',
+            showOverflowTooltip: true,
+            minWidth: 110,
+            slot: 'code'
+          },
+          {
+            prop: 'name',
+            label: '物品名称',
+            align: 'center',
+            showOverflowTooltip: true,
+            minWidth: 110
+          },
+          {
+            prop: 'brandNum',
+            label: '牌号',
+            align: 'center',
+            showOverflowTooltip: true,
+            minWidth: 110
+          },
+          {
+            prop: 'specification',
+            label: '规格',
+            align: 'center',
+            showOverflowTooltip: true,
+            minWidth: 110
+          },
+          {
+            prop: 'modelType',
+            label: '型号',
+            align: 'center',
+            showOverflowTooltip: true,
+            minWidth: 110
+          }
+        ],
+        tableList: [],
+        categoryLevelId: null,
+        searchKey: null,
+        code: null,
+        name: null,
+        selection: []
+      };
+    },
+
+    watch: {},
+    methods: {
+      async datasource({ page, limit }) {
+        const params = {
+          code: this.code,
+          name: this.name,
+          searchKey: this.searchKey,
+          pageNum: page,
+          size: limit,
+          categoryLevelId: this.categoryLevelId,
+          isProduct: true
+        };
+        const data = await getList(params);
+        this.tableList = data.list;
+        return data;
+      },
+      open() {
+        this.equipmentdialog = true;
+        this.setSelect();
+      },
+      handleNodeClick(data) {
+        this.categoryLevelId = data.id;
+        this.reload();
+      },
+      reload() {
+        this.$refs.equiTable.reload();
+      },
+      handleClose() {
+        this.equipmentdialog = false;
+        this.code = '';
+        this.$refs.equiTable.clearSelection();
+      },
+      reset() {
+        this.code = null;
+        this.searchKey = null;
+        this.name = null;
+        this.reload();
+      },
+      // 设置选中
+      setSelect() {
+        this.$nextTick(() => {
+          this.tableList.forEach((row) => {
+            this.selectList.forEach((selected, index) => {
+              if (selected.productCode === row.code) {
+                this.$refs.equiTable.toggleRowSelection(row, true);
+              }
+            });
+          });
+        });
+      },
+      // 取消选中
+      handleSelect(selection, row) {
+        if (!selection.find((i) => i.id === row.id)) {
+          const index = this.selectList.findIndex(
+            (itm) => row.code == itm.productCode
+          );
+          console.log(index);
+          if (index > -1) {
+            this.selectList.splice(index, 1);
+          }
+        }
+      },
+      // 选择
+      selected() {
+        if (this.isMultiple == '0' && this.selection.length > 1) {
+          return this.$message.warning('只能选择一条产品');
+        }
+        this.$emit('choose', [
+          ...this.selection,
+          ...this.selectList.filter(
+            (i) => !this.selection.find((p) => p.code === i.productCode)
+          )
+        ]);
+        this.handleClose();
+      }
+    }
+  };
+</script>
+
+<style lang="scss" scoped>
+  .tree_col {
+    border: 1px solid #eee;
+    padding: 10px 0;
+    box-sizing: border-box;
+    max-height: 530px;
+    overflow: auto;
+  }
+  .table_col {
+    padding-left: 10px;
+    ::v-deep .el-table th.el-table__cell {
+      background: #f2f2f2;
+    }
+  }
+  .pagination {
+    text-align: right;
+    padding: 10px 0;
+  }
+  .btns {
+    text-align: center;
+    padding: 10px 0;
+  }
+  .topsearch {
+    margin-bottom: 15px;
+  }
+</style>

+ 45 - 12
src/views/batchRecord/components/editModal.vue

@@ -166,20 +166,32 @@
         <el-row style="margin-bottom: 20px">
           <el-col :span="8">
             <el-form-item label="产品编码" required prop="productCode">
-              <el-input
-                v-model="form.productCode"
-                placeholder="请选择产品信息"
-                :disabled="Boolean(form.workOrderId)"
-              ></el-input>
+              <div class="mask-box" @click="openProductDialog">
+                <el-input
+                  v-model="form.productCode"
+                  placeholder="请选择产品信息"
+                  disabled
+                >
+                  <template #append>
+                    <el-button size="small">选择产品</el-button>
+                  </template>
+                </el-input>
+              </div>
             </el-form-item>
           </el-col>
           <el-col :span="8">
             <el-form-item label="产品名称" required prop="productName">
-              <el-input
-                v-model="form.productName"
-                placeholder="请输入"
-                :disabled="Boolean(form.workOrderId)"
-              ></el-input>
+              <div class="mask-box" @click="openProductDialog">
+                <el-input
+                  v-model="form.productName"
+                  placeholder="请选择产品信息"
+                  disabled
+                >
+                  <template #append>
+                    <el-button size="small">选择产品</el-button>
+                  </template>
+                </el-input>
+              </div>
             </el-form-item>
           </el-col>
           <el-col :span="8">
@@ -305,6 +317,8 @@
       @reload="reload"
       :isTempRecord="1"
     />
+
+    <EquipmentDialog ref="EquipmentDialogRef" isMultiple="0" @choose="choose" />
   </ele-modal>
 </template>
 
@@ -321,6 +335,7 @@
   import releaseRulesDialog from '@/views/produce/components/prenatalExamination/releaseRulesDialog.vue';
   import { saveOrUpdate } from '@/api/producetaskrecordrulesrecord/index';
   import { getById } from '@/api/produceOrder/index.js';
+  import EquipmentDialog from './EquipmentDialog.vue';
 
   export default {
     name: 'editModal',
@@ -331,7 +346,8 @@
       selectReleaseRules,
       selectDevices,
       programRulesDialog,
-      releaseRulesDialog
+      releaseRulesDialog,
+      EquipmentDialog
     },
     props: {
       // 1-产前准备,2-过程监测,3-产后检查
@@ -546,8 +562,8 @@
         console.log('code', code);
         if (code) {
           const workOrder = this.workOrderList.find((i) => i.code == code);
-          this.workOrderInfo = workOrder;
           console.log('workOrder', workOrder);
+          this.workOrderInfo = workOrder;
           this.form.workOrderId = workOrder.id;
           // 赋值产品信息
           this.form.productCode = workOrder.productCode;
@@ -658,6 +674,23 @@
         const data = await getById(id);
         console.log('工单详情', data);
         this.workOrderInfo = data;
+      },
+      openProductDialog() {
+        if (this.form.workOrderId) {
+          return this.$message.warning('已选择生产工单,不能修改产品信息');
+        }
+        this.$refs.EquipmentDialogRef.open();
+      },
+      // 选择产品
+      choose(data) {
+        console.log('data', data);
+        const info = data[0];
+        if (info) {
+          this.form.productCode = info.code;
+          this.form.productName = info.name;
+          this.form.productModel = info.model;
+          this.form.specification = info.specification;
+        }
       }
     }
   };

+ 3 - 5
src/views/batchRecord/components/list.vue

@@ -60,10 +60,7 @@
           执行
         </el-link>
         <el-link
-          v-if="
-            row.approvalStatus != null &&
-            (row.approvalStatus === 0 || row.approvalStatus === 3)
-          "
+          v-if="row.approvalStatus === 0"
           type="primary"
           :underline="false"
           @click="openApproval(row)"
@@ -112,6 +109,8 @@
       @reload="reload"
       :isNotNeedProcess="false"
     ></process-submit-dialog>
+
+
   </el-card>
 </template>
 
@@ -127,7 +126,6 @@
   import { parameterGetByCode } from '@/api/system/dictionary-data';
   import releaseRulesDialog from '@/views/produce/components/prenatalExamination/releaseRulesDialog.vue';
   import programRulesDialog from '@/views/produce/components/prenatalExamination/programRulesDialog.vue';
-  import { getById } from '@/api/produceOrder/index.js';
   import processSubmitDialog from '@/components/processSubmitDialog/processSubmitDialog.vue';
 
   export default {

+ 30 - 7
src/views/batchRecord/components/tables/craftFilesTable.vue

@@ -3,11 +3,10 @@
     <seek-page :seekList="seekList" @search="search"></seek-page>
     <ele-pro-table
       ref="table"
-      row-key="id"
       :columns="columns"
       :datasource="datasource"
       :cache-key="cacheKeyUrl"
-      autoAmendPage
+      :needPage="false"
     >
       <template v-slot:action="{ row }">
         <el-link type="primary" :underline="false" @click="goToDetail(row)">
@@ -23,7 +22,7 @@
 <script>
   import dictMixins from '@/mixins/dictMixins';
   import tableColumnsMixin from '@/mixins/tableColumnsMixin';
-  import { craftFiles } from '@/api/produce/workOrder.js';
+  import { batchRecordPage, filePageAPI } from '@/api/produce/workOrder.js';
   import fileBrowse from '@/views/produce/components/picking/fileBrowse.vue';
 
   export default {
@@ -72,10 +71,9 @@
             showOverflowTooltip: true,
             minWidth: 200,
             formatter: (_row, _column, cellValue) => {
-              return cellValue[0]?.name;
+              return cellValue && cellValue[0]?.name;
             }
           },
-
           {
             prop: 'version',
             label: '版本',
@@ -134,13 +132,38 @@
           size: limit,
           ...this.tableQuery
         };
-        return craftFiles(body);
+        return this.getDataList(body);
+      },
+      // 查询数据
+      async getDataList(body) {
+        let data = await batchRecordPage(body);
+        const fileIds = data.map((i) => i.fileId);
+
+        if (data.length === 0 || fileIds.length === 0) {
+          return data;
+        }
+
+        const files = await filePageAPI({ ids: fileIds.join(',') });
+
+        data = data
+          .map((item) => {
+            const file = files.find((f) => f.id === item.fileId);
+            return {
+              ...file,
+              ...item
+            };
+          })
+          .filter((i) => i.id);
+
+        console.log('data', data);
+
+        return data;
       },
       search(where) {
         this.reload(where);
       },
       goToDetail(row) {
-        console.log('row', row);
+        // 查询文件信息
         this.$refs.fileBrowseRef.setFileUrl(row);
       }
     }