Przeglądaj źródła

feat(工位管理): 添加工位导入功能及优化用户列表初始化逻辑

yusheng 6 miesięcy temu
rodzic
commit
539934f5d9

+ 15 - 0
src/api/system/file/index.js

@@ -182,6 +182,21 @@ export async function importBatch(data) {
   }
   return Promise.reject(new Error(res.data.message));
 }
+/**
+ * 导入文件 批量
+ * @param file 文件
+ */
+export async function importBatchNew(data) {
+  const formData = new FormData();
+  data.multiPartFiles.forEach((item, index) => {
+    formData.append(`multiPartFiles`, item);
+  });
+  const res = await request.post(data.apiUrl, formData);
+  if (res.data.code === '0') {
+    return res.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}
 
 // 通用上传接口
 export async function commUpload(data) {

+ 5 - 3
src/components/upload/import-dialogNew.vue

@@ -49,7 +49,7 @@
 </template>
 
 <script>
-  import { importBatch } from '@/api/system/file/index.js';
+  import { importBatch,importBatchNew } from '@/api/system/file/index.js';
   // import { download1 } from '@/utils/file';
   import { downLoadTemplateNew } from '@/api/system/file/index.js';
   export default {
@@ -104,9 +104,11 @@
         }
         this.module = this.$props.defModule;
         this.uploading = true;
-        await importBatch({
+        let api=this.apiUrl?importBatchNew: importBatch
+        await api({
           module: this.module,
-          multiPartFiles: this.attaments
+          multiPartFiles: this.attaments,
+          apiUrl:this.apiUrl
         }).finally(() => {
           this.uploading = false;
         });

+ 0 - 1
src/views/factoryModel/jobManagement/index.vue

@@ -291,7 +291,6 @@
           });
       },
       importProfession() {
-        debugger;
         this.$refs.importDialogRef.open();
       },
       exportJobs() {},

+ 7 - 5
src/views/factoryModel/station/components/edit.vue

@@ -590,13 +590,15 @@
       chooseAsset() {
         this.$refs.productRefs.open(this.form.extInfo, '选择设备', '4');
       },
-      userListFn(e) {
+      userListFn(e, init) {
         console.log(e);
         let that = this;
         listUserByIds([e]).then((res) => {
           that.userList = res;
         });
-        that.form.extInfo.userIds = [];
+        if (!init) {
+          that.form.extInfo.userIds = [];
+        }
       },
 
       // 选择可执行工序
@@ -618,8 +620,8 @@
 
       determineChoose(title, row) {
         const equipmentLabel = row.equipmentLabelJson[0];
-        this.form.extInfo.criticalEquipment = equipmentLabel.GJSB;
-        this.form.extInfo.keyEquipment = equipmentLabel.GZSB;
+        this.form.extInfo.criticalEquipment = equipmentLabel?.GJSB;
+        this.form.extInfo.keyEquipment = equipmentLabel?.GZSB;
 
         if (title == '选择设备') {
           this.form.extInfo.assetCode = row.code;
@@ -904,7 +906,7 @@
             this.form?.extInfo?.teamId &&
             typeof this.form?.extInfo?.teamId === 'string'
           ) {
-            this.userListFn(this.form.extInfo.teamId);
+            this.userListFn(this.form.extInfo.teamId, 'init');
           }
           if (res.taskList?.length) {
             this.form.taskNames = res.taskList.map((i) => i.name);

+ 23 - 0
src/views/factoryModel/station/index.vue

@@ -28,6 +28,16 @@
           >
             添加
           </el-button>
+          <el-button
+            size="small"
+            type="primary"
+            icon="el-icon-download"
+            class="ele-btn-icon"
+            @click="importProfession"
+            v-if="$hasPermission('main:factoryworkstation:saveOrUpdate')"
+          >
+            导入
+          </el-button>
         </template>
         <!-- <template v-slot:workshop="{ row }">
         {{ showWorkshop(row) }}
@@ -77,6 +87,13 @@
       </ele-pro-table>
     </el-card>
     <edit ref="edit" @done="done"></edit>
+    <importDialog
+      ref="importDialogRef"
+      :apiUrl="'/main/factoryworkstation/importBatch'"
+      :fileUrl="'/main/factoryworkstation/downLoadTemplate'"
+      fileName="工位导入模板"
+      @success="reload"
+    />
   </div>
 </template>
 <script>
@@ -89,10 +106,13 @@
     getFactoryarea
   } from '@/api/factoryModel';
   import { listOrganizations } from '@/api/system/organization';
+  import importDialog from '@/components/upload/import-dialogNew.vue';
+
   export default {
     mixins: [tabMixins],
     components: {
       search,
+      importDialog,
       edit
     },
     data() {
@@ -247,6 +267,9 @@
           this.dict.factory = res.list;
         });
       },
+      importProfession() {
+        this.$refs.importDialogRef.open();
+      },
       remove(row) {
         deleteFactoryworkstation(row.id)
           .then((message) => {