<template>
  <div class="app-container">
    <div style="width: 55%">
      <ProductForm
        v-model="form"
        :showTitle="true"
        :isAdd="false"
        :labelWidth="labelWidth"
        ref="productRef"
      />
    </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 ProductForm from "./ProductForm";
export default {
  components: {
    ProductForm,
  },
  data() {
    return {
      labelWidth: 160,
      form: {
        id: undefined,
        title: undefined,
        industrys: [],
        customer: [],
        maturity: undefined,
        lead_standard: undefined,
        cooperation_mode: undefined,
        keywords: [],
        description: undefined,
        introduce: undefined,
        image:
          "http://192.168.0.149:8000/upload/20220323/d60f5a08d8ff0b2a6a837dd98ea70eeb.jpg",
        video:
          "http://192.168.0.149:8000/upload/20220323/6dc38b60c0ba332b4670a02665bb834f.mp4",
        file: undefined,
      },
    };
  },
  methods: {
    submitForm(status) {
      if (this.$refs["productRef"].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>