<template>
  <div class="app-container">
    <div style="width: 50%">
      <EnterpriseDemandForm
        v-model="form"
        :showTitle="true"
        :isAdd="false"
        :labelWidth="labelWidth"
        ref="enterpriseDemandRef"
      />
    </div>
    <div :style="{ marginLeft: labelWidth + 'px' }">
      <el-button @click="submitForm(3)">审核拒绝</el-button>
      <el-button type="primary" @click="submitForm(2)">通过审核</el-button>
    </div>
  </div>
</template>
<script>
import EnterpriseDemandForm from "@/views/components/EnterpriseDemandForm";
export default {
  components: {
    EnterpriseDemandForm,
  },
  data() {
    return {
      labelWidth: 160,
      form: {
        id: undefined,
        title: undefined,
        name: undefined,
        check: [],
        add: undefined,
        industrys: [],
        status: false,
        amount: 0,
        work_at: undefined,
        bankAccount: undefined,
        bankPhone: undefined,
        username: undefined,
        userPhone: undefined,
        customer: [],
      },
    };
  },
  methods: {
    submitForm(status) {
      if (this.$refs["enterpriseDemandRef"].submitForm()) {
        const str =
          status == 2
            ? "<span style='color:green'>通过</span>"
            : "<span class='el-message-box__errormsg'>拒绝</span>";
        this.$prompt(`您将 ${str} 该数据审核，请输入处理备注`, "审核", {
          dangerouslyUseHTMLString: true,
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          closeOnClickModal: false,
          inputType: "textarea",
          inputPattern: status == 2 ? "" : /^.{1,30}$/,
          inputErrorMessage: "请输入拒绝原因",
        })
          .then(({ value }) => {
            console.log(value);
            // expertEdit(this.form).then((res) => {
            //   if (res.code == 200) {
            //     const query = {
            //       id: this.form.id,
            //       status,
            //       remark: value,
            //     };
            //     expertExamine(query).then((res) => {
            //       this.$store.dispatch("tagsView/delView", this.$route);
            //       this.$router.go(-1);
            //       this.$modal.msgSuccess("处理成功");
            //     });
            //   }
            // });
          })
          .catch(() => {});
      } else {
        console.log(this.form);
        console.log("校验未通过");
      }
    },
  },
  created() {
    const { id } = this.$route.query;
    if (id) {
      agentDetail({ id }).then((res) => {
        this.form = res.data;
      });
    }
  },
};
</script>