<!-- @desc:销售退货  @auth:付斌  @time:2023-09-13 10:28 -->
<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>
        <!--销售退货冲正-->
        <BaseIndexButton ref="saleReturnReverse" name="saleReturnReverse" :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"
                  :searchContent="searchContent"
                  @on-switch-change="changeShowItem"></SearchCond>
    </div>
    <!--  表格部分  -->
    <DkSplit mode="vertical" v-model="split" :height="tableHeight">
      <div slot="top">
        <DkTabs v-model="tabsModel" :options="tabsOptions" @on-click="tabsClick"></DkTabs>
        <DkTable :id="'table-'+$options.name" ref="table-select" :data="tableData"
                 :height="this.tableHeight * split - 35" primaryKey="rejectId" :show-footer="true"
                 @pageChange="pageSizeChange"
                 @current-change="currentChangeStandard"
                 name="table">
          <DkTableColumn field="returnNo"></DkTableColumn>
          <DkTableColumn field="orderNo" :tree-node="true"></DkTableColumn>
          <DkTableColumn :type="$libaray.checkButtonHasRight('cus-detail')?'link':''" field="cusName"
                         @on-link="opencusMessage"></DkTableColumn>
          <DkTableColumn field="cusPhone"></DkTableColumn>
          <DkTableColumn field="addressFull"></DkTableColumn>
          <DkTableColumn field="rejectStatusName" title="退货状态"></DkTableColumn>
          <DkTableColumn field="entryStatus" title="入库状态"></DkTableColumn>
          <DkTableColumn field="sumQuantity" :digits="0" sum></DkTableColumn>
          <DkTableColumn field="sumAmount" :digits="2" sum></DkTableColumn>
          <DkTableColumn field="orgName"></DkTableColumn>
          <DkTableColumn field="staffName"></DkTableColumn>
          <DkTableColumn field="makeTime" :dataType="$config.columnType.dateTime"></DkTableColumn>
          <DkTableColumn field="makeStaffName"></DkTableColumn>
        </DkTable>
      </div>

      <div slot="bottom">

        <DkTabs v-model="detailModel" :options="detailOptions" @on-click="detailTabsClick"></DkTabs>
        <!--订单明细(销售退货单)-->
        <div v-show="visGoodsDetailFlag">
          <DkTable :pageFlag="false" :pageTotalFlag="false" primaryKey="itemId"
                   :id="'table-return-'+$options.name" :show-footer="true"
                   :export-url="$libaray.checkButtonHasRight('sale-export')?'/order-server/sale/order_item/export/'+rejectId:''"
                   export-condition="rejectId"
                   name="table" ref="standardGoodsFlag" :data="goodsDetailData" :height="this.tableHeight * (1-split)">
            <DkTableColumn field="outNo"></DkTableColumn>
            <DkTableColumn field="skuName"></DkTableColumn>
            <DkTableColumn field="skuCode"></DkTableColumn>
            <DkTableColumn field="itemQty" :title="$t('returnQty1')" :digits="0" sum></DkTableColumn>
            <DkTableColumn field="priceReturn" :digits="0" sum></DkTableColumn>
            <DkTableColumn field="itemAmt" :title="$t('returnAmt1')":digits="2" sum></DkTableColumn>
            <DkTableColumn field="intoingQty" :digits="0" sum></DkTableColumn>
            <DkTableColumn field="intoingAmt" :digits="0" sum></DkTableColumn>
            <DkTableColumn field="intoQty" :digits="0" sum></DkTableColumn>
            <DkTableColumn field="intoAmt" ></DkTableColumn>
            <DkTableColumn field="whName"></DkTableColumn>
            <DkTableColumn field="nonStdCode"></DkTableColumn>
            <DkTableColumn field="remarks"></DkTableColumn>
          </DkTable>
        </div>
        <!--收款明细-->
        <<div v-show="visCollectionDetailFlag">
          <DkTable :pageFlag="false" :pageTotalFlag="false" primaryKey="receiptId" :id="'table-'+$options.name"
                   :show-footer="true"
                   name="table" ref="receipt-select" :data="tableDataDetail_collectionDetail" :height="this.tableHeight * (1-split)">
            <DkTableColumn
              v-for="(item, index) in tableDataTitle_collectionDetail"
              :key="detailModel+index"
              align="center"
              :type="item.type"
              :field="item.field"
              :title="item.title"
              :sum="item.sum"
              :digits="item.digits"
              :width="item.width"
            >
            </DkTableColumn>
          </DkTable>
        </div>
      </div>
    </DkSplit>
  </div>
</template>

<script>

import {indexMixin} from '@/mixins'

export default {
  name: 'sale-return-ss',
  mixins: [indexMixin],
  data() {
    let self = this
    return {
      rejectStatusFlag: true,
      // 模式切换值
      tabsModel: 'all',
      visGoodsDetailFlag: true,
      visCollectionDetailFlag: false,
      tabsOptions: [
        {label: self.$t('all'), name: 'all'}, //全部
        {label: self.$t('waitIn'), name: 'waitIn'},//退货中
        {label: self.$t('ingIn'), name: 'ingIn'},//已退货
      ],
      //总单导出条件
      tableData: [],
      goodsDetailData: [],
      tableDataDetail_collectionDetail: [], // 用于存放订单收款数据
      tableDataDetail_files: [],  // 用于存放订单附件
      tableDataTitle_collectionDetail: [
        {field: 'receiptNo'},
        {field: 'docCode'},
        {field: 'sumAmount', type: 'number', digits: 2, sum: true},
        {field: 'settlementTypeName'},
        {field: 'apvResult'},
        {field: 'erpPushStatusName'},
        {field: 'erpPushResult'},
      ],
      rejectId: 0,//查询明细需要的订单id
      detailModel: 'goodsDetail',
      detailOptions: [{label: self.$t('goodsDetail'), name: 'goodsDetail'}, //货物明细
        {label: self.$t('collectionDetail'), name: 'collectionDetail'},//收款明细
      ],
      searchContent: [
        {
          itemCode: '订单单号-文本',
          itemName: 'orderNo',
          valueFormat: {code: 'orderNo'},
          valueKind: 'STR'
        },
        {
          itemCode: '订单单号-文本',
          itemName: 'returnNo',
          valueFormat: {code: 'returnNo'},
          valueKind: 'STR'
        },
        {
          itemCode: '客户电话-文本',
          itemName: 'cusPhone',
          valueFormat: {code: 'cusPhone'},
          valueKind: 'STR'
        },
        {
          itemCode: '客户名称-文本',
          itemName: 'cusName',
          valueFormat: {code: 'cusName'},
          valueKind: 'STR'
        },
        {
          itemCode: '家庭住址-文本',
          itemName: 'addressFull',
          valueFormat: {code: 'addressFull'},
          valueKind: 'STR'
        },
        {
          itemCode: '业务部门-文本',
          itemName: 'orgId',
          valueFormat: {
            code: 'orgId',
            data: self.orgList,
            valueKey: 'orgId',
            labelKey: 'orgName',
          },
          valueKind: 'M-CHOICE'
        },
        {
          itemCode: '业务员-文本',
          itemName: 'staffId',
          valueFormat: {
            code: 'staffId',
            data: self.staffList,
            valueKey: 'userId',
            labelKey: 'userName',
          },
          valueKind: 'M-CHOICE'
        },
        {
          itemCode: '制单时间-时间',
          itemName: 'makeTime',
          valueFormat: {
            code: 'makeTime',
            default: [new Date().addMonths(-1).format('yyyy-MM-dd'), new Date().format('yyyy-MM-dd')]
          },
          valueKind: 'DATE_RANGE'
        },
      ],
      entryHandleEnable: null,
      backEnable: null,
    }
  },
  methods: {
    /**
     * @desc   : 入库办理
     * @author : 付斌
     * @date   : 2024-02-21 16:14
     */
    entryHandle(row) {
      this.$router.push('/sale/saleReturn/handle/')
    },

    /**
     * @desc   : 不查冲正单据
     * @author : 付斌
     * @date   : 2023/12/15 15:56
     */
    changeShowItem({code, e}) {

    },
    /**
     * @desc   : 打开附件
     * @author : 付斌
     * @date   : 2022-07-19 19:56
     */
    openFile(row) {
      window.open(this.$config.imgUrl + row.url)
    },

    /**
     *   @desc   : 进入客户页面
     *   @date   : 2022/5/31 15:38
     *   @author : 付斌
     */
    opencusMessage(row) {
      this.$router.push('/sale/cus/detail/' + row['cusId'])
    },

    /**
     * @desc   : 查询销售订单档案资料接口
     * @author : 付斌
     * @date   : 2022/3/29 16:05
     */
    initData(currentPage, StringOrderTab) {

    },

    /**
     * @desc   : 调用api方法进行查询
     * @author : 付斌
     * @date   : 2022/3/29 16:10
     */
    getData(StringOrderTab) {

    },

    setSearchParams(StringOrderTab) {

    },

    /**
     * @desc   : 打印订单
     * @author : 付斌
     * @date   : 2022/6/28 14:08
     */
    printOrder() {

    },
    /**
     * @desc   : 打印组件方法
     * @author : 付斌
     * @date   : 2022/6/28 14:15
     */
    componentPrint() {

    },
    /**
     * @desc   : 跳转页面
     * @author : 付斌
     * @date   : 2022/3/2 15:32
     */
    openForm(type) {

    },
    /**
     * @desc   : 冲正
     * @author : 付斌
     * @date   : 2023/11/7 15:39
     */
    reverse() {

    },
    /**
     * @desc   : 通过id查询
     * @author : 付斌
     * @date   : 2022/06/29 13:17
     */
    selectRetrunForReverse(id) {

    },
    /**
     * @desc   : 入库撤销
     * @author : 付斌
     * @date   : 2023/10/31 16:31
     */
    entryBack() {

    },

    /**
     *   @author : 付斌
     *   @date   : 2022/5/2 14:11
     *   @desc   : 总单tab切换
     */
    tabsClick(val) {

    },

    /***************************列表及其他事件************************************/

    /**
     * @desc   : 分页
     * @author : 付斌
     * @date   : 2022/3/17 15:01
     */
    pageSizeChange(pageInfo) {

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

    },
    /**
     * @desc   : 明细查询
     * @author : 付斌
     * @date   : 2023/8/26 16:24
     */
    getStandardDetail() {

    },

    /***************************设定参数函数************************************/

    /**
     *   @desc   : 页面初始化所需下拉数据
     *   @date   : 2022/5/25 15:53
     *   @author : 付斌
     */
    initSelectData() {

    },
    /**
     *   @desc   : 查询业务部门
     *   @date   : 2022/5/31 18:33
     *   @author : 付斌
     */
    selectOrg() {

    },
    /**
     *   @desc   : 查询业务员
     *   @date   : 2022/5/31 18:34
     *   @author : 付斌
     */
    selectStaff() {

    },
    /**
     * @desc   : 点击Tab进行切换
     * @author : 付斌
     * @date   : 2024-02-19 11:33
     */
    detailTabsClick(val) {
      if (val === 'goodsDetail') {
        this.visGoodsDetailFlag = true
        this.visCollectionDetailFlag = false
      } else if (val === 'collectionDetail') {
        this.visGoodsDetailFlag = false
        this.visCollectionDetailFlag = true
      }
    },
    /***************************created调用数据接口函数************************************/

  },

  /**
   * @desc   : 实例被挂载后调用
   * @author : 付斌
   * @date   : 2022/3/3 10:31
   */
  mounted() {
  },

  /**
   * @desc   : 在实例创建完成后被立即同步调用
   * @author : 付斌
   * @date   : 2022/3/3 10:32
   */
  created() {
    this.primaryKey = 'saleReturnId'  // 设置主键Id
    this.routeObjName = 'saleReturn'  // 设置路由名称
  },
}
</script>
