ShipmentPickHeaderList.vue 12.6 KB
<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="领料通知单号">
              <a-input placeholder="请输入领料通知单号" v-model="queryParam.lblnr"></a-input>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
              <a @click="handleToggleSearch" style="margin-left: 8px">
                {{ toggleSearchStatus ? '收起' : '展开' }}
                <a-icon :type="toggleSearchStatus ? 'up' : 'down'"/>
              </a>
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END -->

    <!-- 操作按钮区域 -->
    <div class="table-operator">
      <a-button @click="handleAdd" type="primary" icon="plus">新增</a-button>
      <a-button type="primary" icon="download" @click="handleExportXls('领料单主表')">导出</a-button>
      <a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl"
                @change="handleImportExcel">
        <a-button type="primary" icon="import">导入</a-button>
      </a-upload>
      <!-- 高级查询区域 -->
      <j-super-query :fieldList="superFieldList" ref="superQueryModal"
                     @handleSuperQuery="handleSuperQuery"></j-super-query>
    </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"
        class="j-table-force-nowrap"
        :scroll="{x:true}"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange, type:'radio'}"
        :customRow="clickThenSelect"
        @change="handleTableChange">

        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>
        <template slot="imgSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>
          <img v-else :src="getImgView(text)" height="25px" alt=""
               style="max-width:80px;font-size: 12px;font-style: italic;"/>
        </template>
        <template slot="fileSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
          <a-button
            v-else
            :ghost="true"
            type="primary"
            icon="download"
            size="small"
            @click="downloadFile(text)">
            下载
          </a-button>
        </template>

        <span slot="action" slot-scope="text, record">
<!--          <a @click="handleEdit(record)">编辑</a>-->

          <!--          <a-divider type="vertical" />-->
          <!--          <a-dropdown>-->
          <!--            <a class="ant-dropdown-link">更多 <a-icon type="down" /></a>-->
          <!--            <a-menu slot="overlay">-->
          <!--              <a-menu-item>-->
          <!--                <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">-->
          <!--                  <a>删除</a>-->
          <!--                </a-popconfirm>-->
          <!--              </a-menu-item>-->
          <!--            </a-menu>-->
          <!--          </a-dropdown>-->
           <a v-if="(record.lastStatus === 0)" @click="shipmentHeaderBack(record.id)">
            <a-button type="primary">单据回传</a-button>
          </a>
          <a v-if="(record.lastStatus === 200)" @click="shipmentPickQualityAdopt(record.id)">
            <a-button type="primary">审核通过</a-button>
          </a>
          <a v-if="(record.lastStatus === 200)" @click="shipmentPickQualityReject(record.id)">
            <a-button type="primary" >审核驳回</a-button>
          </a>
<!--           <a v-if="(record.lastStatus === 400)" @click="createShipment(record.id)">-->
<!--            <a-button type="primary" >生成入库单</a-button>-->
<!--          </a>-->
        </span>

      </a-table>
    </div>

    <a-tabs defaultActiveKey="1">
      <a-tab-pane tab="领料单明细" key="1">
        <ShipmentPickDetailList :mainId="selectedMainId"/>
      </a-tab-pane>
    </a-tabs>

    <shipmentPickHeader-modal ref="modalForm" @ok="modalFormOk"></shipmentPickHeader-modal>

    <!-- 审核弹窗 -->
    <ReviewModal
      :visible="isReviewModalVisible"
      @close="closeReviewModal"
      @approve="handleApprove"
      @reject="handleReject"
    />
  </a-card>
</template>

<script>
import ReviewModal from './modules/ShipmentPickDetailModal.vue';  // 引入审核弹窗组件
import {JeecgListMixin} from '@/mixins/JeecgListMixin'
import ShipmentPickHeaderModal from './modules/ShipmentPickHeaderModal'
import {getAction} from '@/api/manage'
import ShipmentPickDetailList from './ShipmentPickDetailList'
import '@/assets/less/TableExpand.less'
import {shipmentHeaderBack,shipmentPickQualityReject,shipmentPickQualityAdopt,createShipment} from "@api/api"

export default {
  name: "ShipmentPickHeaderList",
  mixins: [JeecgListMixin],
  components: {
    ShipmentPickDetailList,
    ShipmentPickHeaderModal,
    ReviewModal  // 注册审核弹窗组件
  },
  data() {
    return {
      isReviewModalVisible: false,
      currentRecordId: null,
      description: '领料单主表管理页面',
      // 表头
      columns: [
        {
          title: '领料通知单号',
          align: "center",
          dataIndex: 'lblnr'
        },
        {
          title: '上游单号',
          align: "center",
          dataIndex: 'referCode'
        },
        {
          title: '编码',
          align: "center",
          dataIndex: 'code'
        },
        {
          title: '头状态',
          align: "center",
          dataIndex: 'firstStatus_dictText',
          key: 'firstStatus_dictText',
          scopedSlots: {customRender: 'firstStatus_dictText'}
        },
        {
          title: '尾状态',
          align: "center",
          dataIndex: 'lastStatus_dictText',
          key: 'lastStatus_dictText',
          scopedSlots: {customRender: 'lastStatus_dictText'}
        },
        {
          title: '领料单项目',
          align: "center",
          dataIndex: 'lblpo'
        },
        {
          title: '预留/相关需求的编号',
          align: "center",
          dataIndex: 'rsnum'
        },
        {
          title: '预留/相关需求的项目编号',
          align: "center",
          dataIndex: 'rspos'
        },
        {
          title: '操作',
          dataIndex: 'action',
          align: "center",
          fixed: "right",
          width: 147,
          scopedSlots: {customRender: 'action'},
        }
      ],
      url: {
        list: "/shipment/pick/header/list",
        delete: "/shipment/pick/header/delete",
        deleteBatch: "/shipment/pick/header/deleteBatch",
        exportXlsUrl: "/shipment/pick/header/exportXls",
        importExcelUrl: "shipment/pick/header/importExcel",
      },
      dictOptions: {},
      /* 分页参数 */
      ipagination: {
        current: 1,
        pageSize: 5,
        pageSizeOptions: ['5', '10', '50'],
        showTotal: (total, range) => {
          return range[0] + "-" + range[1] + " 共" + total + "条"
        },
        showQuickJumper: true,
        showSizeChanger: true,
        total: 0
      },
      selectedMainId: '',
      superFieldList: [],
    }
  },
  created() {
    this.getSuperFieldList();
  },
  computed: {
    importExcelUrl: function () {
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
    }
  },
  methods: {
    openReviewModal(recordId) {
      console.log('Open review modal for record:', recordId);
      this.currentRecordId = recordId;
      this.isReviewModalVisible = true;
    },
    closeReviewModal() {
      console.log('Close review modal');
      this.isReviewModalVisible = false;
    },
    handleApprove() {
      console.log('审核通过处理函数被调用');
      shipmentHeaderBack(this.currentRecordId, true).then(res => {
        if (res.success) {
          this.$message.success(res.message);
        } else {
          this.$message.warning(res.message);
        }
        this.searchQuery();  // 更新数据
      });
      this.closeReviewModal();
    },
    handleReject() {
      console.log('审核不通过处理函数被调用');
      shipmentHeaderBack(this.currentRecordId, false).then(res => {
        if (res.success) {
          this.$message.success(res.message);
        } else {
          this.$message.warning(res.message);
        }
        this.searchQuery();  // 更新数据
      });
      this.closeReviewModal();
    },
    initDictConfig() {
    },
    clickThenSelect(record) {
      return {
        on: {
          click: () => {
            this.onSelectChange(record.id.split(","), [record]);
          }
        }
      }
    },
    onClearSelected() {
      this.selectedRowKeys = [];
      this.selectionRows = [];
      this.selectedMainId = ''
    },
    onSelectChange(selectedRowKeys, selectionRows) {
      this.selectedMainId = selectedRowKeys[0]
      this.selectedRowKeys = selectedRowKeys;
      this.selectionRows = selectionRows;
    },
    loadData(arg) {
      if (!this.url.list) {
        this.$message.error("请设置url.list属性!")
        return
      }
      //加载数据 若传入参数1则加载第一页的内容
      if (arg === 1) {
        this.ipagination.current = 1;
      }
      this.onClearSelected()
      var params = this.getQueryParams();//查询条件
      this.loading = true;
      getAction(this.url.list, params).then((res) => {
        if (res.success) {
          this.dataSource = res.result.records;
          this.ipagination.total = res.result.total;
        }
        if (res.code === 510) {
          this.$message.warning(res.message)
        }
        this.loading = false;
      })
    },
    shipmentHeaderBack(record) {
      shipmentHeaderBack(record).then((res) => {
        if (res.success) {
          this.$message.success(res.message)
        } else {
          this.$message.warning(res.message)
        }
        this.searchQuery();
      });
    },
    shipmentPickQualityAdopt(record) {
      shipmentPickQualityAdopt(record).then((res) => {
        if (res.success) {
          this.$message.success(res.message)
        } else {
          this.$message.warning(res.message)
        }
        this.searchQuery();
      });
    },
    shipmentPickQualityReject(record) {
      shipmentPickQualityReject(record).then((res) => {
        if (res.success) {
          this.$message.success(res.message)
        } else {
          this.$message.warning(res.message)
        }
        this.searchQuery();
      });
    },
    createShipment(record) {
      createShipment(record).then((res) => {
        if (res.success) {
          this.$message.success(res.message)
        } else {
          this.$message.warning(res.message)
        }
        this.searchQuery();
      });
    },
    getSuperFieldList() {
      let fieldList = [];
      fieldList.push({type: 'string', value: 'lblnr', text: '领料通知单号', dictCode: ''})
      fieldList.push({type: 'string', value: 'referCode', text: '上游单号', dictCode: ''})
      fieldList.push({type: 'string', value: 'code', text: '编码', dictCode: ''})
      fieldList.push({type: 'int', value: 'firstStatus', text: '头状态', dictCode: "shipment_pick_status,,"})
      fieldList.push({type: 'int', value: 'lastStatus', text: '尾状态', dictCode: "shipment_pick_status,,"})
      fieldList.push({type: 'string', value: 'lblpo', text: '领料单项目', dictCode: ''})
      fieldList.push({type: 'string', value: 'rsnum', text: '预留/相关需求的编号', dictCode: ''})
      fieldList.push({type: 'string', value: 'rspos', text: '预留/相关需求的项目编号', dictCode: ''})
      this.superFieldList = fieldList
    }
  }
}
</script>
<style scoped>
@import '~@assets/less/common.less'
</style>