<template>
  <div class="sidelip-box">
    <Form :model="formData" ref="RefuseContentForm" :label-width="120">
      <Row :gutter="20" class="code-row-bg">
        <Col span="24">
          <Form-item 
            prop="refuseDescr" 
            label="拒付原因"
            :rules="[{required: true, message: '请输入拒付原因'}]"
          >
            <Input v-model="formData.refuseDescr" type="textarea" :rows="5" />
          </Form-item>
        </Col>
      </Row>
    </Form>
  </div>
</template>
<script>
export default {
  components: {},
  props: {
    server: {
      type: Object,
      default() {
        return {};
      }
    },
    payHeadId: {
      type: String,
      default() {
        return "";
      }
    },
    payLineDetailIds: {
      type: String,
      default() {
        return "";
      }
    },
    refuseDescr: {
      type: String,
      default() {
        return "";
      }
    }
  },
  data() {
    return {
      formData: {
        payHeadId: "",
        payLineDetailIds: "",
        refuseDescr:""
      }
    };
  },
  computed: {},
  created: function() {
    this.init();
  },
  beforeMount: function() {},
  mounted: function() {},
  beforeDestroy: function() {},
  destroyed: function() {},
  methods: {
    init() {
      this.formData.payHeadId = this.payHeadId;
      this.formData.payLineDetailIds = this.payLineDetailIds;
      this.$emit("SetTitle", "拒付原因");
      this.$emit("SetPageActions", [
        {
          text: "确定",
          theme: "primary",
          icon: "edit",
          action: "saveLoading",
          handle: this.refuseContent
        }
      ]);
    },

    // 确定
    refuseContent() {
      this.$refs["RefuseContentForm"].validate(valid => {
        if (valid) {
          this.$emit("SetActionsState", {
            btn: "saveLoading",
            state: true
          });
          this.server.rufusePayPreparation(this.formData).then(response => {
            if (response.code == "0") {
              this.$Message.error({
                content: response.msg || "拒付失败",
                duration: 3
              });
              this.$emit("SetActionsState", {
                btn: "saveLoading",
                state: false
              });
            } else {
              this.$Message.success({
                content: "拒付成功",
                duration: 3
              });
              this.$emit("Close", "success");
            }
          });
        }
      });
    }
  },
  watch: {},
  directives: {}
};
</script>
// <style lang="less" scoped>
// .sidelip-box {
//   margin-bottom: 25px;
// }
// </style>