695593266@qq.com il y a 1 semaine
Parent
commit
56f8b029e0
1 fichiers modifiés avec 205 ajouts et 0 suppressions
  1. 205 0
      src/views/technology/production/components/history-modal.vue

+ 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>