Jelajahi Sumber

feat: 增加库存批次拆合审批中心组件

mlchen 1 Minggu lalu
induk
melakukan
7ce8f5ec22

+ 10 - 0
src/api/bpm/components/stockBatchChange/index.js

@@ -0,0 +1,10 @@
+import request from '@/utils/request';
+
+/** 查询库存拆合批申请详情。 */
+export async function getStockBatchChangeDetail(id) {
+  const res = await request.get(`/wms/stockBatchChangeApprove/getById/${id}`);
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}

+ 172 - 0
src/views/bpm/handleTask/components/stockBatchChange/detailDialog.vue

@@ -0,0 +1,172 @@
+<template>
+  <div v-loading="loading" class="stock-batch-change-detail">
+    <el-descriptions :column="3" border size="small">
+      <el-descriptions-item label="审核代码">
+        {{ formData.changeNo || '-' }}
+      </el-descriptions-item>
+      <el-descriptions-item label="变更类型">
+        {{ changeTypeText(formData.changeType) }}
+      </el-descriptions-item>
+      <el-descriptions-item label="审批状态">
+        <el-tag :type="statusType(formData.verifyStatus)" size="small">
+          {{ statusText(formData.verifyStatus) }}
+        </el-tag>
+      </el-descriptions-item>
+      <el-descriptions-item label="仓库">
+        {{ formData.warehouseName || '-' }}
+      </el-descriptions-item>
+      <el-descriptions-item label="申请时间">
+        {{ formData.createTime || '-' }}
+      </el-descriptions-item>
+      <el-descriptions-item label="执行状态">
+        {{ formData.executeStatus === 2 ? '已执行' : '未执行' }}
+      </el-descriptions-item>
+      <el-descriptions-item label="申请说明" :span="3">
+        {{ formData.remark || '-' }}
+      </el-descriptions-item>
+    </el-descriptions>
+
+    <div class="section-title">批次变更明细</div>
+    <el-table
+      :data="formData.details || []"
+      border
+      size="mini"
+      max-height="420"
+    >
+      <el-table-column type="index" label="序号" width="55" align="center" />
+      <el-table-column
+        prop="systemBatchNo"
+        label="来源系统批次"
+        min-width="145"
+        show-overflow-tooltip
+      />
+      <el-table-column
+        prop="batchNo"
+        label="业务批次"
+        min-width="120"
+        show-overflow-tooltip
+      />
+      <el-table-column label="目标批次" min-width="145" show-overflow-tooltip>
+        <template slot-scope="{ row }">
+          {{ row.targetSystemBatchNo || targetText(row) }}
+        </template>
+      </el-table-column>
+      <el-table-column prop="measureQuantity" label="计量数量" width="105" />
+      <el-table-column prop="packageQuantity" label="包装数量" width="105" />
+      <el-table-column prop="weight" label="重量" width="95" />
+      <el-table-column prop="lockQuantity" label="锁库数量" width="105" />
+      <el-table-column label="整包装分配" min-width="150" show-overflow-tooltip>
+        <template slot-scope="{ row }">
+          {{ formatPackingIds(row.packingStockIds) }}
+        </template>
+      </el-table-column>
+      <el-table-column
+        label="锁定明细分配"
+        min-width="190"
+        show-overflow-tooltip
+      >
+        <template slot-scope="{ row }">
+          {{ formatLockAllocations(row.lockAllocations) }}
+        </template>
+      </el-table-column>
+    </el-table>
+  </div>
+</template>
+
+<script>
+  import { getStockBatchChangeDetail } from '@/api/bpm/components/stockBatchChange';
+
+  export default {
+    name: 'StockBatchChangeDetail',
+    props: {
+      businessId: {
+        default: ''
+      }
+    },
+    data() {
+      return {
+        loading: false,
+        formData: {}
+      };
+    },
+    watch: {
+      businessId: {
+        immediate: true,
+        handler(id) {
+          if (id) {
+            this.getInfo(id);
+          }
+        }
+      }
+    },
+    methods: {
+      /** 加载审批业务快照,审批中不读取实时库存替换申请数据。 */
+      async getInfo(id) {
+        this.loading = true;
+        try {
+          this.formData = (await getStockBatchChangeDetail(id)) || {};
+        } finally {
+          this.loading = false;
+        }
+      },
+      changeTypeText(value) {
+        return { 1: '拆批', 2: '合批' }[value] || '-';
+      },
+      statusText(value) {
+        return (
+          { 0: '未提交', 1: '审批中', 2: '已通过', 3: '已驳回', 4: '已撤回' }[
+            value
+          ] || '-'
+        );
+      },
+      statusType(value) {
+        return value === 2 ? 'success' : value === 3 ? 'danger' : 'info';
+      },
+      targetText(row) {
+        return row.targetDetailId
+          ? `目标 ${row.targetDetailId}(审批通过后生成)`
+          : '审批通过后生成';
+      },
+      formatPackingIds(value) {
+        const ids = this.parseArray(value);
+        return ids.length ? ids.join('、') : '-';
+      },
+      formatLockAllocations(value) {
+        const allocations = this.parseArray(value);
+        if (!allocations.length) {
+          return '-';
+        }
+        return allocations
+          .map(
+            (item) => `${item.lockOrderDetailId || '-'}:${item.quantity || 0}`
+          )
+          .join(';');
+      },
+      parseArray(value) {
+        if (Array.isArray(value)) {
+          return value;
+        }
+        if (!value) {
+          return [];
+        }
+        try {
+          const result = JSON.parse(value);
+          return Array.isArray(result) ? result : [];
+        } catch (error) {
+          return [];
+        }
+      }
+    }
+  };
+</script>
+
+<style scoped lang="scss">
+  .stock-batch-change-detail {
+    min-height: 120px;
+  }
+
+  .section-title {
+    margin: 16px 0 8px;
+    font-weight: 600;
+  }
+</style>

+ 116 - 0
src/views/bpm/handleTask/components/stockBatchChange/submit.vue

@@ -0,0 +1,116 @@
+<template>
+  <el-col :span="16" :offset="6" v-loading="loading">
+    <el-form ref="formRef" :model="form" :rules="rules" label-width="100px">
+      <el-form-item label="审批建议" prop="reason" style="margin-bottom: 20px">
+        <el-input
+          v-model="form.reason"
+          type="textarea"
+          :rows="3"
+          maxlength="500"
+          show-word-limit
+          placeholder="请输入审批建议"
+        />
+      </el-form-item>
+    </el-form>
+    <div class="actions">
+      <el-button
+        v-click-once
+        type="success"
+        size="mini"
+        icon="el-icon-check"
+        :loading="loading"
+        @click="handleAudit(1)"
+      >
+        通过
+      </el-button>
+      <el-button
+        v-click-once
+        type="danger"
+        size="mini"
+        icon="el-icon-close"
+        :loading="loading"
+        @click="handleAudit(0)"
+      >
+        驳回
+      </el-button>
+    </div>
+  </el-col>
+</template>
+
+<script>
+  import { approveTaskWithVariables, rejectTask } from '@/api/bpm/task';
+
+  export default {
+    name: 'StockBatchChangeSubmit',
+    props: {
+      businessId: {
+        default: ''
+      },
+      taskId: {
+        default: ''
+      },
+      id: {
+        default: ''
+      },
+      taskDefinitionKey: {
+        default: ''
+      }
+    },
+    data() {
+      return {
+        loading: false,
+        form: {
+          reason: '同意'
+        },
+        rules: {
+          reason: [
+            {
+              required: true,
+              whitespace: true,
+              message: '请输入审批建议',
+              trigger: 'blur'
+            }
+          ]
+        }
+      };
+    },
+    methods: {
+      /** 校验审批意见后执行当前流程任务。 */
+      handleAudit(status) {
+        this.$refs.formRef.validate((valid) => {
+          if (valid) {
+            this.submitTask(status);
+          }
+        });
+      },
+      async submitTask(status) {
+        const API = status ? approveTaskWithVariables : rejectTask;
+        this.loading = true;
+        try {
+          const res = await API({
+            id: this.taskId,
+            reason: this.form.reason,
+            variables: {
+              pass: !!status
+            }
+          });
+          if (res.data.code != '-1') {
+            this.$emit('handleAudit', {
+              status,
+              title: status === 0 ? '驳回' : ''
+            });
+          }
+        } finally {
+          this.loading = false;
+        }
+      }
+    }
+  };
+</script>
+
+<style scoped lang="scss">
+  .actions {
+    margin: 0 0 20px 10%;
+    font-size: 14px;
+  }
+</style>