Просмотр исходного кода

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

liujt 2 недель назад
Родитель
Сommit
a23a63e6c3

+ 16 - 0
src/api/technology/production/index.js

@@ -45,6 +45,22 @@ export default {
       return res.data;
       return res.data;
     }
     }
   },
   },
+  //发布
+  publish: async (data) => {
+    const res = await request.post('/main/producetask/publish', data);
+    if (res.data.code == 0) {
+      return res.data;
+    }
+    return Promise.reject(new Error(res.data.message));
+  },
+  //历史版本
+  history: async (taskId) => {
+    const res = await request.get(`/main/producetask/history/${taskId}`);
+    if (res.data.code == 0) {
+      return res.data.data;
+    }
+    return Promise.reject(new Error(res.data.message));
+  },
   //删除
   //删除
   delete: async (data) => {
   delete: async (data) => {
     const res = await request.delete('/main/producetask/delete', { data });
     const res = await request.delete('/main/producetask/delete', { data });

+ 0 - 1
src/views/factoryModel/station/components/edit.vue

@@ -985,7 +985,6 @@
               factoryName: res.factoryName
               factoryName: res.factoryName
             }
             }
           };
           };
-
           // this.form = this.deepCopy(Object.assign({}, this.form, res));
           // this.form = this.deepCopy(Object.assign({}, this.form, res));
 
 
           // console.log(this.form, 'this.form1');
           // console.log(this.form, 'this.form1');

+ 205 - 0
src/views/technology/production/components/history-modal.vue

@@ -0,0 +1,205 @@
+<template>
+  <ele-modal
+    title="历史版本"
+    :visible.sync="visible"
+    :close-on-click-modal="false"
+    width="900px"
+    :maxable="true"
+    @close="handleClose"
+  >
+    <ele-pro-table
+      ref="table"
+      :columns="columns"
+      :datasource="historyList"
+      :need-page="false"
+      row-key="id"
+      max-height="520"
+    >
+      <template v-slot:isPublished="{ row }">
+        <el-tag v-if="row.isPublished == 1" type="success">已发布</el-tag>
+        <el-tag v-else type="info">未发布</el-tag>
+      </template>
+
+      <template v-slot:action="{ row }">
+        <el-link type="primary" :underline="false" @click="openDetail(row)">
+          详情
+        </el-link>
+      </template>
+    </ele-pro-table>
+
+    <user-edit
+      :visible.sync="showDetail"
+      :data="current"
+      :controlList="controlList"
+      :typeList="typeList"
+      :detail="true"
+      ref="userEdit"
+    />
+
+    <template v-slot:footer>
+      <el-button @click="handleClose">关闭</el-button>
+    </template>
+  </ele-modal>
+</template>
+
+<script>
+  import producetask from '@/api/technology/production';
+  import control from '@/api/technology/control';
+  import UserEdit from './user-edit.vue';
+
+  export default {
+    components: {
+      UserEdit
+    },
+    data() {
+      return {
+        visible: false,
+        showDetail: false,
+        current: null,
+        currentTask: null,
+        historyList: [],
+        controlList: [],
+        typeList: [
+          {
+            value: 99,
+            label: '关键工序'
+          },
+          {
+            value: 1,
+            label: '普通工序'
+          },
+          {
+            value: 3,
+            label: '抽样质检'
+          },
+          {
+            value: 4,
+            label: '包装工序'
+          },
+          {
+            value: 6,
+            label: '质检工序'
+          }
+        ],
+        columns: [
+          {
+            columnKey: 'index',
+            type: 'index',
+            width: 55,
+            align: 'center',
+            label: '序号'
+          },
+          {
+            prop: 'versionNumber',
+            label: '版本号',
+            align: 'center',
+            showOverflowTooltip: true,
+            minWidth: 90,
+            formatter: (row) => this.formatVersion(row.versionNumber)
+          },
+          {
+            prop: 'isPublished',
+            slot: 'isPublished',
+            label: '发布状态',
+            align: 'center',
+            showOverflowTooltip: true,
+            minWidth: 100
+          },
+          {
+            prop: 'publishedName',
+            label: '发布人',
+            align: 'center',
+            showOverflowTooltip: true,
+            minWidth: 110
+          },
+          {
+            prop: 'publishedTime',
+            label: '发布时间',
+            align: 'center',
+            showOverflowTooltip: true,
+            minWidth: 160,
+            formatter: (row) => this.formatDate(row.publishedTime)
+          },
+          {
+            prop: 'createTime',
+            label: '创建时间',
+            align: 'center',
+            showOverflowTooltip: true,
+            minWidth: 160,
+            formatter: (row) => this.formatDate(row.createTime)
+          },
+          {
+            prop: 'action',
+            slot: 'action',
+            label: '操作',
+            align: 'center',
+            width: 90
+          }
+        ]
+      };
+    },
+    methods: {
+      async open(row) {
+        this.visible = true;
+        this.currentTask = row || null;
+        await this.getControlList();
+        await this.getHistoryList();
+      },
+
+      handleClose() {
+        this.visible = false;
+        this.showDetail = false;
+        this.current = null;
+        this.currentTask = null;
+        this.historyList = [];
+      },
+
+      async getHistoryList() {
+        if (!this.currentTask || !this.currentTask.id) {
+          this.historyList = [];
+          return;
+        }
+        this.historyList =
+          (await producetask.history(this.currentTask.id)) || [];
+      },
+
+      async getControlList() {
+        const res = await control.list({
+          pageNum: 1,
+          size: -1
+        });
+        this.controlList = (res && res.list) || [];
+      },
+
+      openDetail(row) {
+        this.current = {
+          ...row,
+          id: row.taskId || row.id
+        };
+        this.showDetail = true;
+      },
+
+      formatVersion(versionNumber) {
+        if (
+          versionNumber === undefined ||
+          versionNumber === null ||
+          versionNumber === ''
+        ) {
+          return '';
+        }
+        const version = String(versionNumber).trim();
+        if (!version) {
+          return '';
+        }
+        if (/^v\s*/i.test(version)) {
+          return version;
+        }
+        return `V ${version.includes('.') ? version : version + '.0'}`;
+      },
+
+      formatDate(value) {
+        return value ? this.$util.toDateString(value) : '';
+      }
+    }
+  };
+</script>

+ 15 - 5
src/views/technology/production/components/user-edit.vue

@@ -742,11 +742,12 @@
     },
     },
     computed: {
     computed: {
       totalTime() {
       totalTime() {
+        const workBeat = this.form.workBeat || {};
         let to =
         let to =
-          (-this.form.workBeat.restTimes +
-            -this.form.workBeat.preTimes +
-            -this.form.workBeat.proTimes +
-            -this.form.workBeat.otherTimes) *
+          (-workBeat.restTimes +
+            -workBeat.preTimes +
+            -workBeat.proTimes +
+            -workBeat.otherTimes) *
           -1;
           -1;
         return to;
         return to;
       },
       },
@@ -825,9 +826,18 @@
           console.log(this.form, 'this.form');
           console.log(this.form, 'this.form');
           if (this.data) {
           if (this.data) {
             const res = await producetask.getById(this.data.id);
             const res = await producetask.getById(this.data.id);
+            const defaultData = this.defaultForm();
 
 
             this.$util.assignObject(this.form, {
             this.$util.assignObject(this.form, {
-              ...res
+              ...res,
+              intervalTime: {
+                ...defaultData.intervalTime,
+                ...((res && res.intervalTime) || {})
+              },
+              workBeat: {
+                ...defaultData.workBeat,
+                ...((res && res.workBeat) || {})
+              }
             });
             });
 
 
             this.isUpdate = true;
             this.isUpdate = true;

+ 21 - 7
src/views/technology/production/index.vue

@@ -108,6 +108,10 @@
           {{ typeLabel(row.type) }}
           {{ typeLabel(row.type) }}
         </template>
         </template>
 
 
+        <template v-slot:version="{ row }">
+          <span v-if="row.version">{{ 'V ' + row.version + '.0' }}</span>
+        </template>
+
         <template v-slot:processLabel="{ row }">
         <template v-slot:processLabel="{ row }">
           <el-tag v-if="row.processLabel == 1">自制</el-tag>
           <el-tag v-if="row.processLabel == 1">自制</el-tag>
           <el-tag v-if="row.processLabel == 2" type="success">委外</el-tag>
           <el-tag v-if="row.processLabel == 2" type="success">委外</el-tag>
@@ -177,6 +181,10 @@
               <el-link type="primary" :underline="false"> 发布 </el-link>
               <el-link type="primary" :underline="false"> 发布 </el-link>
             </template>
             </template>
           </el-popconfirm>
           </el-popconfirm>
+
+          <el-link type="primary" :underline="false" @click="openHistory(row)">
+            历史版本
+          </el-link>
         </template>
         </template>
       </ele-pro-table>
       </ele-pro-table>
     </el-card>
     </el-card>
@@ -225,6 +233,8 @@
     <userSettingMatterProcessDrawer
     <userSettingMatterProcessDrawer
       ref="userSettingMatterProcessDrawerRef"
       ref="userSettingMatterProcessDrawerRef"
     ></userSettingMatterProcessDrawer>
     ></userSettingMatterProcessDrawer>
+
+    <history-modal ref="historyModalRef" />
   </div>
   </div>
 </template>
 </template>
 
 
@@ -244,6 +254,7 @@
   import dictMixins from '@/mixins/dictMixins';
   import dictMixins from '@/mixins/dictMixins';
   import productionCheck from './components/productionCheck.vue';
   import productionCheck from './components/productionCheck.vue';
   import { getFactoryarea } from '@/api/factoryModel';
   import { getFactoryarea } from '@/api/factoryModel';
+  import HistoryModal from './components/history-modal.vue';
 
 
   export default {
   export default {
     name: 'technologyProduction',
     name: 'technologyProduction',
@@ -257,7 +268,8 @@
       WorkCenter,
       WorkCenter,
       userSettingMatter,
       userSettingMatter,
       userSettingMatterProcessDrawer,
       userSettingMatterProcessDrawer,
-      productionCheck
+      productionCheck,
+      HistoryModal
     },
     },
     data() {
     data() {
       return {
       return {
@@ -357,7 +369,7 @@
           {
           {
             columnKey: 'action',
             columnKey: 'action',
             label: '操作',
             label: '操作',
-            width: 230,
+            width: 300,
             align: 'center',
             align: 'center',
             resizable: false,
             resizable: false,
             slot: 'action',
             slot: 'action',
@@ -566,15 +578,17 @@
         this.openEdit(row, true);
         this.openEdit(row, true);
       },
       },
 
 
+      openHistory(row) {
+        this.$refs.historyModalRef.open(row);
+      },
+
       async release(row) {
       async release(row) {
         const loading = this.$loading({ lock: true });
         const loading = this.$loading({ lock: true });
         try {
         try {
-          const detail = await producetask.getById(row.id);
-          await producetask.save({
-            ...detail,
-            isRelease: 1
+          const res = await producetask.publish({
+            taskId: row.id
           });
           });
-          this.$message.success('发布成功');
+          this.$message.success((res && res.message) || '发布成功');
           this.reload();
           this.reload();
         } finally {
         } finally {
           loading.close();
           loading.close();