<!-- @desc:采购入库  @auth:付斌 @time:2024/02/20 15:15 -->
<template>
  <div class="main-div">
    <!--按钮区-->
    <BaseIndexButtonGroup id="BaseIndexButtonGroup">
      <template #left>
        <BaseIndexButton ref="search" name="search"></BaseIndexButton>
        <BaseIndexButton ref="clear" name="clear"></BaseIndexButton>
        <BaseIndexButton ref="entryHandle" name="entryHandle" :isMustChooseFlag="false"></BaseIndexButton>
        <BaseIndexButton ref="completeRevocation" name="completeRevocation" :isMustChooseFlag="false"></BaseIndexButton>
      </template>
    </BaseIndexButtonGroup>

    <!--  查询条件区域  -->
    <div id="search-cond-div" ref="search-cond-div" style="margin-top: 1px;padding: 0">
      <SearchCond ref="searchCond" v-model="searchCond"
                  @collapse-change="collapseChange" :setFlag="false"
                  :search-content="searchContent"
                  @on-switch-change="changeShowItem"></SearchCond>
    </div>

    <!--  表格部分  -->
    <DkSplit mode="vertical" v-model="split" :height="tableHeight">
      <div slot="top">
        <!--      商品标价列表-->
        <DkTabs v-model="tableModel" :options="tabsOptions" @on-click="initData(1)"></DkTabs>
        <!-- 列表总单  -->
        <!--待入库Tbale-->
        <DkTable :id="'table-'+$options.name"
                 ref="table-select"
                 :data="tableData"
                 :height="this.tableHeight * split - 60"
                 primaryKey="entryId"
                 @current-change="currentChangeStandard"
                 @pageChange="pageSizeChange">
          <!-- 采购入库单号-->
          <DkTableColumn :type="$libaray.checkButtonHasRight('entryHandle')?'link':''"
                         field="intoNo" @on-link="entryHandle"></DkTableColumn>
          <!-- 来源单号-->
          <DkTableColumn field="fromNo"></DkTableColumn>
          <!--部门-->
          <DkTableColumn field="orgName"></DkTableColumn>
          <!--员工-->
          <DkTableColumn field="staffName"></DkTableColumn>
          <!--客户-->
          <DkTableColumn field="cusName"></DkTableColumn>
          <!--入库状态-->
          <DkTableColumn field="intoStatusName" :color-cards="['未入库','入库中','入库完成']"></DkTableColumn>
          <!-- 入库中数量-->
          <DkTableColumn field="intoingQty" :digits="0" sum></DkTableColumn>
          <!-- 入库中金额-->
          <DkTableColumn field="intoingAmt" :digits="0" sum></DkTableColumn>
          <!--已入库数量-->
          <DkTableColumn field="intoQty"></DkTableColumn>
          <!--已入库金额-->
          <DkTableColumn field="intoAmt"></DkTableColumn>
          <!--已入库退货数量-->
          <DkTableColumn field="returnQty" :title="$t('returnIntoQty')"></DkTableColumn>
          <!--已入库退货金额-->
          <DkTableColumn field="returnAmt" :title="$t('returnIntoAmt')"></DkTableColumn>
          <!--制单人-->
          <DkTableColumn field="makeStaffName"></DkTableColumn>
          <!--制单时间-->
          <DkTableColumn field="makeTime"></DkTableColumn>
          <!--备注-->
          <DkTableColumn field="remarks"></DkTableColumn>
        </DkTable>
      </div>
      <div slot="bottom">
        <DkTabs v-model="tabsModel" :options="detailTabsOptions" @on-click="tabsClick"></DkTabs>
        <!-- 货物明细-->
        <div v-show="standardGoodsFlag">
          <DkTable ref="standardGoodsFlag"
                   primaryKey="itemId"
                   :id="'table-'+$options.name"
                   name="table2" :data="goodsDetailData"
                   :height="this.tableHeight * (1-split)"
                   showFooter
                   :select-flag="false"
                   :pageFlag="false"
                   :pageTotalFlag="false"
                   v-if="this.tableModel === 'waitEntry'">
            <!-- 来源单号-->
            <DkTableColumn field="fromNo"></DkTableColumn>
            <!-- 商品名称-->
            <DkTableColumn field="skuName"></DkTableColumn>
            <!-- 商品数量-->
            <DkTableColumn field="itemQty"></DkTableColumn>
            <!-- 入库价-->
            <DkTableColumn field="priceInto"></DkTableColumn>
            <!-- 入库金额-->
            <DkTableColumn field="itemAmt" :title="$t('itemIntoAmt')"></DkTableColumn>
            <!--非标号-->
            <DkTableColumn field="nonStandardCode"></DkTableColumn>
            <!--入库中数量-->
            <DkTableColumn field="intoingQty"></DkTableColumn>
            <!--入库中金额-->
            <DkTableColumn field="intoingAmt"></DkTableColumn>
            <!--已入库数量-->
            <DkTableColumn field="intoQty"></DkTableColumn>
            <!--已入库金额-->
            <DkTableColumn field="intoAmt"></DkTableColumn>
            <!--已入库退货数量-->
            <DkTableColumn field="returnQty" :title="$t('returnIntoQty')"></DkTableColumn>
            <!--已入库退货金额-->
            <DkTableColumn field="returnAmt" :title="$t('returnIntoAmt')"></DkTableColumn>
            <!--备注-->
            <DkTableColumn field="remarks"></DkTableColumn>
          </DkTable>

          <DkTable ref="standardGoodsFlag"
                   primaryKey="itemId"
                   :id="'table-'+$options.name"
                   name="table2" :data="goodsDetailData"
                   :height="this.tableHeight * (1-split)"
                   showFooter
                   :select-flag="false"
                   :pageFlag="false"
                   :pageTotalFlag="false"
                   v-if="this.tableModel === 'ingEntry'">
            <!-- 来源单号-->
            <DkTableColumn field="fromNo"></DkTableColumn>
            <!-- 商品名称-->
            <DkTableColumn field="skuName"></DkTableColumn>
            <!-- 商品数量-->
            <DkTableColumn field="itemQty"></DkTableColumn>
            <!-- 入库价-->
            <DkTableColumn field="priceInto"></DkTableColumn>
            <!-- 入库金额-->
            <DkTableColumn field="itemAmt" :title="$t('itemIntoAmt')"></DkTableColumn>
            <!--非标号-->
            <DkTableColumn field="nonStandardCode"></DkTableColumn>
            <!--入库中数量-->
            <DkTableColumn field="intoingQty"></DkTableColumn>
            <!--入库中金额-->
            <DkTableColumn field="intoingAmt"></DkTableColumn>
            <!--已入库数量-->
            <DkTableColumn field="intoQty"></DkTableColumn>
            <!--已入库金额-->
            <DkTableColumn field="intoAmt"></DkTableColumn>
            <!--已入库退货数量-->
            <DkTableColumn field="returnQty" :title="$t('returnIntoQty')"></DkTableColumn>
            <!--已入库退货金额-->
            <DkTableColumn field="returnAmt" :title="$t('returnIntoAmt')"></DkTableColumn>
            <!--备注-->
            <DkTableColumn field="remarks"></DkTableColumn>
          </DkTable>
        </div>
        <!--  附件明细-->
        <div v-show="reviewResumeFlag">
          <DkTable ref="reviewResumeFlag"
                   primaryKey="reviewResumeId"
                   :id="'table-'+$options.name"
                   name="table4" :data="reviewResumeData"
                   :height="this.tableHeight * (1-split)"
                   @pageChange="itemPageChange"
                   :select-flag="false">
            <DkTableColumn field="remarks"></DkTableColumn>
          </DkTable>
        </div>
      </div>
    </DkSplit>
  </div>
</template>

<script>
import {indexMixin} from '@/mixins'

export default {
  name: "procure-entry",
  mixins: [indexMixin],
  data() {
    let self = this
    return {
      standardGoodsFlag: true,
      barcodeDetailsFlag: false,
      reviewResumeFlag: false,
      tableModel: 'waitEntry',
      tabsModel: 'goodsDetail',
      tabsOptions: [
        {
          label: this.$t('waitEntry'),
          name: 'waitEntry'
        },
        {
          label: this.$t('ingEntry'),
          name: 'ingEntry'
        }
      ],
      detailTabsOptions: [
        {
          label: this.$t('goodsDetail'),
          name: 'goodsDetail'
        },
        {
          label: this.$t('filesDetail'),
          name: 'filesDetail'
        }
      ],
      tableData: [],
      goodsDetailData: [],//商品明细
      barCodeData: [],//条码明细
      reviewResumeData: [],//附件明细
      entryId: null,//入库Id
      searchContent: [
        {
          itemCode: 'entryNo',
        },
        {
          itemCode: 'orderNo',
        },
        {
          itemCode: 'supplierName',
        },
        {
          itemCode: '商品型号-文本',
          itemName: 'skuModel',
          valueFormat: {code: 'skuModel'},
          valueKind: 'STR'
        },
        {
          itemCode: '商品名称-文本',
          itemName: 'skuName',
          valueFormat: {code: 'skuName'},
          valueKind: 'STR'
        },
        {
          itemCode: '商品编码-文本',
          itemName: 'skuCode',
          valueFormat: {code: 'skuCode'},
          valueKind: 'STR'
        },
        {
          itemCode: '仓库名称-文本',
          itemName: 'whName',
          valueFormat: {code: 'whName'},
          valueKind: 'STR'
        },
        {
          itemCode: '编码-日期',
          itemName: 'sale1OutDate',
          valueFormat: {
            code: 'sale1OutDate',
            default: [new Date().addMonths(-1).format('yyyy-MM-dd'), new Date().format('yyyy-MM-dd')]
          },
          valueKind: 'DATE_RANGE'
        },
        {
          itemCode: '编码-日期',
          itemName: 'WarehousingData',
          valueFormat: {
            code: 'entryDate',
            default: [new Date().addMonths(-1).format('yyyy-MM-dd'), new Date().format('yyyy-MM-dd')]
          },
          valueKind: 'DATE_RANGE'
        },
        {
          itemCode: '查看冲正单据',
          itemName: '查看冲正单据',
          valueFormat: {code: 'showItem', default: false},
          valueKind: 'SWITCH'
        },
      ],
    }
  },
  methods: {
    /**
     * @desc   : 点击Tab进行切换
     * @author : 付斌
     * @date   : 2024-02-19 11:33
     */
    tabsClick(val) {
      if (val === 'goodsDetail') {
        this.standardGoodsFlag = true
        this.barcodeDetailsFlag = false
        this.reviewResumeFlag = false
      }
      if (val === 'filesDetail') {
        this.standardGoodsFlag = false
        this.barcodeDetailsFlag = false
        this.reviewResumeFlag = true
      }
    },
    /**
     * @desc   : 查询
     * @author : 付斌
     * @date   : 2024-02-19 11:34
     */
    initData(currentPage) {
    },
    /**
     * @desc   : 查看冲正单据
     * @author : 付斌
     * @date   : 2024-02-19 11:34
     */
    changeShowItem({code, e}) {

    },
    /**
     * @desc   : 获取数据
     * @author : 付斌
     * @date   : 2024-02-19 11:34
     */
    getData() {

    },
    /**
     * @desc   : 列表行变化事件
     * @author : 付斌
     * @date   : 2024-02-19 16:26
     */
    currentChangeStandard({row}) {

    },
    /**
     * @desc   : 入库处理
     * @author : 付斌
     * @date   : 2023/8/25 14:22
     */
    entryHandle() {
      this.$router.push('/pur/purEnter/entryHandle?entryId=' + this.$refs['table-select'].batchKeys[0])
    },
    /**
     * @desc   : 完成撤销
     * @author : 付斌
     * @date   : 2023/8/30 14:02
     */
    completeRevocation() {

    },
    /**
     * @desc   : 分页
     * @author : 付斌
     * @date   : 2024-02-19 16:26
     */
    pageSizeChange(pageInfo) {

    },

    /**
     * @desc   : 分页事件
     * @author : 付斌
     * @date   : 2024-02-19 16:26
     */
    itemPageChange(page) {

    },
  },
  created() {
    this.primaryKey = 'purEnterId'  // 设置主键Id
    this.routeObjName = 'purEnter'  // 设置路由名称
  },
}
</script>
