<template>
    <div class="filterConditionToPOS">
        <p style="line-height: 14px;margin-bottom: 6px;">符合以下设置条件（闭区间）的中间表明细数据，是否生成传POS明细自动标记为无需生成，不参与后续传输逻辑。</p>
        <Form
            ref="formModel"
            :model="formModel"
            :label-width="200"
        >
            <FormItem label="订/退单（含唯品会）商品金额范围">
                <Input
                style = 'width: 120px;height: 32px;'
                placeholder=""
                v-model="formModel.start"
                @on-blur = 'changeDIFFERENCESOFFLINE'
                :regx="regx"
                >
                </Input>
                <span style='display: inline-block;width: 30px;height:32px;line-height: 32px;text-align: center;'>至</span>
                <Input
                style = 'width: 120px;height: 32px;'
                placeholder=""
                v-model="formModel.end"
                @on-blur = 'changeDIFFERENCESUPPER'
                :regx="regx"
                ></Input>
            </FormItem>
        </Form>
        <footer style="display: flex; justify-content: center; margin-top: 16px">
            <Button
            type="posdefault"
            style="margin-right: 10px;"
            @click="submit()"
            >
            保存
            </Button>
            <Button
            type="fcdefault"
            @click="cancel()"
            >
            返回
            </Button>
        </footer>
    </div>
  </template>
  
  <script>
    const R3 = window.R3;
    const { network, urlSearchParams, store } = R3;
    export default {
      name: 'filterConditionToPOS',
      props: {
        selectRowData: { // 获取选择行的数据
          type: Array,
          default: () => []
        },
        idArray: {// 获取ID用于多选
          type: [Array, Object],
          default: () => {
          }
        },
      },
      data() {
        return {
          formModel: {
            start: '',
            end:'',
          },
          regx: /^-?\d{0,15}(\.[0-9]{0,4})?$/,
        };
      },
      created() {
        this.getDefaultArea();
      },
      methods: {
        getDefaultArea() {
          let params = {
            DIFFERENCETYPE: ['20']
          }
          network.post('/p/c/getDifferencesn', params).then(res => {
            if(res.data.code == 0){
              this.formModel.start = res.data.data[0].DIFFERENCESUPPER
              this.formModel.end = res.data.data[0].DIFFERENCESOFFLINE
            }
          })
        },
        changeDIFFERENCESOFFLINE(val) {
            this.formModel.start = !val.target.value?"":val.target.value
        },
        changeDIFFERENCESUPPER(val) {
            this.formModel.end = !val.target.value?"":val.target.value
        },
        submit() {
          let params = {
            DIFFERENCESUPPER:this.formModel.start,
            DIFFERENCESOFFLINE:this.formModel.end,
          };
          network.post('/p/cs/update/statement/details/amount-range', params).then(res => {
            if (res.data.code == 0) {
              this.$Modal.fcSuccess({
                title: '提示',
                mask: true,
                content: res.data.message,
              });
              document.querySelector('#refresh').click(); // 标准列表刷新按钮
              this.$emit('cancel');
            }
          });
        },
  
        cancel() {
          this.closeDialog();
        },
        closeDialog() { // 关闭弹窗
          this.$emit('closeActionDialog', true);
        },
      }
    };
  </script>
  <style>
    .filterConditionToPOS .ark-select-single .ark-select-selection {
      height: 34px;
    }
  </style>
  <style scoped>
    /* .filterConditionToPOS form {
      margin-right: 30px;
    } */
  </style>
  