ShipmentDetailList.vue 11.7 KB
<template>
  <a-card :bordered="false" :class="'cust-erp-sub-tab'">
    <!-- 操作按钮区域 -->
    <div class="table-operator" v-if="mainId">
      <a-button v-if="headStatus === 0 && headReferCode === null" @click="handleAdd" v-has="'shipmentDetail:add'" type="primary" icon="plus">新增
      </a-button>
      <a-upload
        v-has="'shipmentDetail:import'"
        name="file"
        :showUploadList="false"
        :multiple="false"
        :headers="tokenHeader"
        :action="importExcelUrl"
        @change="handleImportExcel">
        <a-button v-if="headStatus === 0 && headReferCode === null" type="primary" icon="import">导入</a-button>
      </a-upload>
      <a-button v-has="'shipmentDetail:export'" type="primary" icon="download" @click="handleExportXls('出库单详情')">导出</a-button>
      <!--      <a-button @click="batchPrint()" type="primary">打印</a-button>-->
      <a-dropdown v-if="selectedRowKeys.length > 0 && headStatus === 0 && headReferCode == null">
        <a-menu slot="overlay" v-has="'shipmentDetail:deleteBatch'">
          <a-menu-item key="1" @click="batchDel">
            <a-icon type="delete"/>
            删除
          </a-menu-item>
        </a-menu>
        <a-button style="margin-left: 8px"> 批量操作
          <a-icon type="down"/>
        </a-button>
      </a-dropdown>
    </div>

    <!-- table区域-begin -->
    <div>
      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a
        style="font-weight: 600">{{ selectedRowKeys.length }}</a> 项
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div>
      <a-table
        ref="table"
        size="middle"
        bordered
        rowKey="id"
        :scroll="{x:true}"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
        @change="handleTableChange">

        <span slot="zoneCode" slot-scope="zoneCode">
          <a-tag :key="zoneCode" color="blue">
            {{ solutionZoneCode(zoneCode) }}
          </a-tag>
        </span>

        <span slot="status_dictText" slot-scope="status_dictText">
            <a-tag :key="status_dictText" :color="getStatusColor(status_dictText)">
              {{ status_dictText }}
            </a-tag>
        </span>

        <span slot="inventoryStatus_dictText" slot-scope="inventoryStatus_dictText">
          <a-tag :key="inventoryStatus_dictText" :color="getStatusColor(inventoryStatus_dictText)">
            {{ inventoryStatus_dictText }}
          </a-tag>
        </span>

        <span slot="action" slot-scope="text, record">
          <a
            v-if="(record.status<=300&&record.taskQty<=record.qty) " @click="combine(record)">配盘
          </a>
          <a v-has="'shipmentDetail:edit'" v-if="record.status < 900" @click="handleEdit(record)">
            <a-divider v-if="(headStatus >= 15 && headStatus !== 20 && record.status <= 300)" type="vertical"/>编辑
          </a>
          <a-popconfirm v-has="'shipmentDetail:delete'" v-if="record.status === 0 && record.referCode == null"
                        title="确定删除吗?" @confirm="() => handleDelete(record.id)">
            <a-divider type="vertical"/><a>删除</a>
          </a-popconfirm>
        </span>

      </a-table>
    </div>

    <shipmentDetail-modal ref="modalForm" @ok="modalFormOk" :mainId="mainId"></shipmentDetail-modal>
    <shipment-detail-edit-modal ref="modalEditForm" @ok="modalFormOk" :mainId="mainId"></shipment-detail-edit-modal>
    <shipment-detail-combine-modal ref="modalCombineForm" @ok="modalFormOk" @close="searchQuery" :mainId="mainId"></shipment-detail-combine-modal>

  </a-card>
</template>

<script>

import {JeecgListMixin} from '@/mixins/JeecgListMixin'
import ShipmentDetailModal from './modules/ShipmentDetailModal'
import ShipmentDetailEditModal from './modules/ShipmentDetailEditModal'
import ShipmentDetailCombineModal from './modules/ShipmentDetailCombineModal'
import {getZoneList} from '@/api/api'
import {deleteAction} from "@api/manage";

export default {
  name: "ShipmentDetailList",
  mixins: [JeecgListMixin],
  components: {ShipmentDetailCombineModal, ShipmentDetailEditModal, ShipmentDetailModal},
  props: {
    mainId: {
      type: Number,
      default: '',
      required: false
    }
  },
  watch: {
    mainId: {
      immediate: true,
      handler(val) {
        if (!this.mainId) {
          this.clearList()
        } else {
          this.queryParam['shipmentId'] = val
          this.loadData(1);
          this.onClearSelected();
        }
      }
    }
  },
  data() {
    return {
      description: '出库单详情管理页面',
      disableMixinCreated: true,
      zoneList: [],
      headStatus: null,
      headReferCode: null,
      // 表头
      columns: [
        {
          title: '单据详情ID',
          align: "center",
          sorter: true,
          dataIndex: 'id'
        },
        {
          title: '仓库',
          align: "center",
          dataIndex: 'zoneCode',
          scopedSlots: {customRender: 'zoneCode'}
        },
        {
          title: '物料编码',
          align: "center",
          dataIndex: 'materialCode'
        },
        {
          title: '物料名称',
          align: "center",
          dataIndex: 'materialName'
        },
        {
          title: '物料规格',
          align: "center",
          dataIndex: 'materialSpec'
        },
        {
          title: '物料单位',
          align: "center",
          dataIndex: 'materialUnit'
        },
        {
          title: '数量|平方|长度',
          align: "center",
          dataIndex: 'qty'
        },
        {
          title: '配盘数量',
          align: "center",
          dataIndex: 'taskQty'
        },
        {
          title: '已出数量',
          align: "center",
          dataIndex: 'shipmentQty'
        },
        {
          title: '可出数量',
          align: "center",
          dataIndex: 'availableQty'
        },
        {
          title: '库存数量',
          align: "center",
          dataIndex: 'inventoryQty'
        },
        {
          title: '计划号',
          align: "center",
          dataIndex: 'referCode',
        },
        {
          title: '对象',
          align: "center",
          dataIndex: 'userdef1',
        },

        {
          title: '单据状态',
          align: "center",
          dataIndex: 'status_dictText',
          scopedSlots: {customRender: 'status_dictText'}
        },
        {
          title: '创建人',
          align: "center",
          dataIndex: 'createBy'
        },
        {
          title: '创建日期',
          align: "center",
          dataIndex: 'createTime'
        },
        {
          title: '更新人',
          align: "center",
          dataIndex: 'updateBy'
        },
        {
          title: '更新日期',
          align: "center",
          dataIndex: 'updateTime'
        },
        {
          title: '操作',
          dataIndex: 'action',
          align: "center",
          fixed: "right",
          width: 147,
          scopedSlots: {customRender: 'action'},
        }
      ],
      url: {
        list: "/shipment/shipmentHeader/listShipmentDetailByMainId",
        delete: "/shipment/shipmentHeader/deleteShipmentDetail",
        deleteBatch: "/shipment/shipmentHeader/deleteBatchShipmentDetail",
        exportXlsUrl: "/shipment/shipmentHeader/exportShipmentDetail",
        importUrl: "/shipment/shipmentHeader/importShipmentDetail",
      },
      dictOptions: {
        firstStatus: [],
        lastStatus: [],
      }
    }
  },
  created() {
    // this.loadFrom();
  },
  computed: {
    importExcelUrl() {
      return `${window._CONFIG['domianURL']}/${this.url.importUrl}/${this.mainId}`;
    }
  },
  methods: {
    getStatusColor(status) {
      const colors = {
        '新建': 'green',
        '出库组盘': 'Skyblue',
        '等待下架': 'blue',
        '下架': 'darkorange',
        '过账': 'purple',
        '回传': 'grey',
        '回传失败': 'red',
        '良品': 'green',
        '报废品': 'purple',
        '待确认	': 'grey',
        '次品': 'red',
        default: 'blue'
      };
      return colors[status] || colors.default;
    },
    loadFrom() {
      getZoneList().then(res => {
        if (res.success) {
          this.zoneList = res.result
        }
      })
    },
    modalFormOk() {
      this.loadData();
      this.onClearSelected()
      this.$emit("refresh", this.queryParam['shipmentId']);
    },
    solutionZoneCode(value) {
      let actions = []
      Object.keys(this.zoneList).some(key => {
        if (this.zoneList[key].code === '' + value) {
          actions.push(this.zoneList[key].name)
          return true
        }
      })
      return actions.join('')
    },
    clearList() {
      this.dataSource = []
      this.onClearSelected();
      this.ipagination.current = 1
    },
    combine(record) {
      this.$refs.modalCombineForm.edit(record);
      this.$refs.modalCombineForm.title = "配盘";
      this.$refs.modalCombineForm.disableSubmit = false;
    },
    handleAdd(val) {
      this.$refs.modalForm.add();
      this.$refs.modalForm.title = "新增";
      this.$refs.modalForm.disableSubmit = false;
      // this.$refs.modalForm.zoneList = this.zoneList;
    },
    handleEdit(record) {
      this.$refs.modalForm.edit(record);
      this.$refs.modalForm.title = "编辑";
      this.$refs.modalForm.disableSubmit = false;
      //this.$refs.modalEditForm.zoneList = this.zoneList;
    },
    batchPrint() {
      if (this.selectedRowKeys.length <= 0) {
        this.$message.warning('请选择一条记录!');
      } else {
        let ids = "";
        ids = this.selectedRowKeys[0];
        window.open(window._CONFIG['domianURL'] + "/jmreport/view/797678301889273856/?id=" + ids, "newWindow", "toolbar=no,scrollbars=no,menubar=no,screenX=100,screenY=100");
      }
    },
    batchDel: function () {
      if (!this.url.deleteBatch) {
        this.$message.error("请设置url.deleteBatch属性!")
        return
      }
      if (this.selectedRowKeys.length <= 0) {
        this.$message.warning('请选择一条记录!');
      } else {
        let that = this;
        this.$confirm({
          title: "确认删除",
          content: "是否删除选中数据?",
          onOk: function () {
            that.loading = true;
            deleteAction(that.url.deleteBatch, {ids: that.selectedRowKeys.join(",")}).then((res) => {
              if (res.success) {
                //重新计算分页问题
                that.reCalculatePage(that.selectedRowKeys.length)
                that.$message.success(res.message);
                that.loadData();
                that.onClearSelected();
                this.$emit("refresh", this.queryParam['shipmentId']);
              } else {
                that.$message.warning(res.message);
              }
            }).finally(() => {
              that.loading = false;
            });
          }
        });
      }
    },
    handleDelete: function (id) {
      if (!this.url.delete) {
        this.$message.error("请设置url.delete属性!")
        return
      }
      let that = this;
      deleteAction(that.url.delete, {id: id}).then((res) => {
        if (res.success) {
          //重新计算分页问题
          that.reCalculatePage(1)
          that.$message.success(res.message);
          that.loadData();
          this.$emit("refresh", this.queryParam['shipmentId']);
        } else {
          that.$message.warning(res.message);
        }
      });
    },
  }
}
</script>
<style scoped>
@import '~@assets/less/common.less';
</style>