<template>
  <div style="width:400px">
    <div>
      <div style="display: flex;align-items: center;margin-bottom: 16px;">
        <label style="width: 70px;">单据类型</label>
        <!-- clearable -->
        <Select
          v-model="billType"
          @on-query-change="selectBillType"
        >
          <Option
            v-for="(option,index) in billTypeArr"
            :key="index"
            :value="option.value"
          >
            {{ option.label }}
          </Option>
        </Select>
      </div>
      <footer style="display: flex; justify-content: flex-end; margin-top: 16px">
        <Button
          type="fcdefault"
          style="width: 80px; height: 34px; font-size: 14px"
          @click="cancelModal({ isFresh: true })"
        >
          取消
        </Button>
        <Button
          type="posdefault"
          style="width: 80px; height: 34px; font-size: 14px; margin-left: 8px"
          @click="okToAddBill"
        >
          确定
        </Button>
      </footer>
    </div>
  </div>
</template>
<script>
  const R3 = window.R3;
  // const { network, urlSearchParams, store } = R3;
  export default {
    props: {
      idArray: { // 获取ID用于多选
        type: Array,
        default: () => []
      },
    },
    data() {
      return {
        billType: '1', // 选择的单据类型
        billTypeArr: [
          {
            label: '退货单',
            value: '1'
          },
          {
            label: '退换货单',
            value: '2'
          }
        ],
      };
    },
    methods: {
      selectBillType(val) {
        console.log(val);
      },
      //   取消按钮
      cancelModal(option) {
        const { isFresh } = option;
        this.$emit('closeActionDialog', isFresh);
      },
      // 确定添加赠品
      okToAddBill() {
        this.cancelModal({ isFresh: false });
        if (!this.billType) {
          return this.$Message.warning('没有选择单据类型');
        }
        if (this.billType == 1) {
          R3.store.commit('global/tabOpen', {
            type: 'tableDetailAction' || 'C',
            label: '新增退货单',
            customizedModuleName: 'ADDRETURNORDER',
            customizedModuleId: this.idArray[0]
          });
        } else if (this.billType == 2) {
          R3.store.commit('global/tabOpen', {
            type: 'tableDetailAction' || 'C',
            label: '新增换货单',
            customizedModuleName: 'ADDEXCHANGEORDER',
            customizedModuleId: this.idArray[0]
          });
        }
      }
    }
  };
</script>
<style lang="less" scoped>

</style>
