<template>
    <div
      class="taoboResumeReasonDialog"
    >
        <div class="useResumeReason">
            <Form
                ref="formModel"
                :model="formModel"
                :label-width="110"
                >
                <FormItem
                    label="拒绝退货原因"
                    prop="ResumneReasonId"
                >
                    <Select
                    v-model="formModel.choosedResumneReason"
                    clearable
                    placeholder="请选择"
                    filterable
                    >
                    <Option
                        v-for="(option,index) in externalOptions.refusalReasonList"
                        :key="index"
                        :value="option.REFUSALREASON_CODE.val"
                    >
                        {{ option.REFUSALREASON.val }}
                    </Option>
                    </Select>
                </FormItem>
            </Form>
            <!-- 拒绝退货原因 -->
            <!-- <Select v-model="choosedResumneReason" clearable class="input_box resumeReasonSelect" @on-change="checkchoosed">
                <Option v-for="d in externalOptions.INTERCEPTREASONLIST" :value="d.causeId" :key="d.causeId">{{ d.reasonVal }}</Option>
            </Select> -->
        </div>
        <div class="bottomBtnBox">
            <Button
                size="small"
                class="cancelBtn"
                ghost
                @click="close()"
            >
                取消
            </Button>
            <Button
                type="primary"
                size="small"
                class="sureBtn"
                @click="sureResume"
            >
                确定
            </Button>
        </div>
    </div>
  </template>
  
  
  <script>
    const R3 = window.R3;
  
    const { network } = R3;
    export default {
      props: {
        externalOptions: {
            type: Object,
            default: ()=>{}
        },
      },
      data() {
        return {
            formModel: {
                choosedResumneReason:'',
            }
        };
      },
      created() {
        console.log(12345,this.externalOptions)
      },
      methods: {
        checkchoosed() {
            console.log(this.formModel.choosedResumneReason)
        },
        close() {
            // 成功关闭弹框
            this.$parent.close();
        },
        sureResume() {
            if(!this.formModel.choosedResumneReason || this.formModel.choosedResumneReason.length == 0){
                return this.$Message.warning('请选择拒绝退货原因！');
            }
            let params = {
              "tableName": "T_OMSREFUNDPRIMEVAL",
              "ids": this.externalOptions.idArray,
              "actionName": "T_OMSREFUNDPRIMEVAL_拒绝退换货",
              "refusalreason_code": this.formModel.choosedResumneReason,
            }
            network.post('/p/cs/exchange/refuseReturnGoodsAudit',params).then(res => {
              if(res.data.code == 0){
                this.externalOptions.refresh();// 手动刷新页面
                this.$emit('cancel');
                this.$Modal.fcWarning({
                  title: '提示',
                  mask: true,
                  content: res.data.message,
                });
              }
            })
        }
      }
    };
  </script>
  <style>
    .taoboResumeReasonDialog .ark-select-single .ark-select-selection {
        height: 34px;
    }
  </style>
  
  <style scoped lang='less'>
    .taoboResumeReasonDialog {
        width:400px;
    }
    .useResumeReason {
        margin-top: 10px;
    }
    .resumeReasonSelect {
        margin-top: 8px;
        width: 350px;
    }
    .bottomBtnBox {
        width: calc(100% - 48px);
        margin: 16px auto 0px;
        text-align: center;
        .cancelBtn,.sureBtn {
        width: 72px;
        height: 32px;
        font-size: 12px;
        }
        .cancelBtn {
        color: #909399;
        border: 1px solid #DADADA;
        margin-right: 8px;
        }
    }
  </style>
  