<template>
    <div style="width:500px">
      <div class="customerAuditCancel">
        <div style="display: flex;align-items: center;margin-bottom: 16px;">
          <Form
            ref="formValidate"
            :model="VarianceForm"
            :label-width="78"
          >
            <FormItem
              label="驳回原因"
              required
              width="420"
            >
              <Input
                v-model="VarianceForm.reason"
                type="textarea"
                :rows="4"
                placeholder=""
              />
            </FormItem>
          </Form>
        </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"
          >
            取消
          </Button>
          <Button
            type="posdefault"
            style="width: 80px; height: 34px; font-size: 14px; margin-left: 8px"
            @click="okToAddBill"
          >
            确定
          </Button>
        </footer>
      </div>
      <!-- <Modal
        v-model="errorModal"
        title="驳回结果"
        :mask="mask"
        closable
        true
        class-name="cancelResult"
      >
        <div
          v-if="errorMsg.errorList.length>0"
          class="error-content"
        >
          <div class="error-message">
            <div class="left-icon">
              <i class="iconfont">&#xecd0;</i>
            </div>
            <div class="right-content">
              <div class="content-message">
                <p class="title">
                  {{ errorMsg.message }}
                </p>
                <p
                  v-for="(msg,index) in errorMsg.errorList"
                  :key="index"
                >
                  {{ msg.message }}
                </p>
              </div>
            </div>
          </div>
        </div>
      </Modal> -->
    </div>
  </template>
  <script>
    const R3 = window.R3;
    const { network } = R3;
    export default {
      props: {
        idArray: { // 获取ID用于多选
          type: Array,
          default: () => []
        },
      },
      data() {
        return {
          VarianceForm: {
            reason: ''
          },
          errorModal: false, // 替换失败
          errorMsg: {
            message: '',
            errorList: []
          },
          mask: 'true',
          showCancel: true,
        };
      },
      methods: {
        //   取消按钮
        cancelModal() {
          this.$emit('closeActionDialog', true);
        },
        // 确定取消原因
        okToAddBill() {
          if (!this.VarianceForm.reason) {
            return this.$Message.warning('驳回原因不能为空！');
          }
          let params = {
            ids: this.idArray,
            reject_reason: this.VarianceForm.reason
          };
          network.post('/p/cs/returnmoney/customerAudit/cancel', params).then((res)=>{
            if(res.data.code == 0){
                this.$emit('closeActionDialog', true);
                document.querySelector('#refresh').click(); // 标准列表刷新按钮
                return this.$Message.success(res.data.message);
            }
            // if (res.data.data.errors.length) {
            //   this.errorMsg.errorList = res.data.data.errors;
            //   this.errorMsg.message = res.data.message;
            //   this.errorModal = true;
            // } else {
            //   this.$Modal.fcSuccess({
            //     title: '订单取消结果',
            //     content: res.data.message,
            //     mask: true,
            //     closable: true
            //   });
            // }
          });
        },
        onOk() {
          this.$emit('closeActionDialog', true);
        }
      }
    };
  </script>
  <style lang="less">
    .customerAuditCancel textarea.ark-input {
      width: 420px;
      max-width: 420px;
    }
    .cancelResult .ark-btn-text {
      display: none;
    }
  </style>
  