<template>
  <div class="dialog">
    <el-dialog
      :title="formData.JGMC"
      width="40%"
      :visible.sync="dialogVisible"
      :before-close="close"
      :modal-append-to-body="false"
      :close-on-click-modal="false"
    >
      <div class="content">
        <div v-if="modelType === 'info'">
          <el-tabs
            type="border-card"
            class="xz_box"
            v-model="activeTabs"
            stretch
          >
            <el-tab-pane label="申请记录" name="sqjl">
              <CustomDetails :model="formData" :config="detailInfos">
                <template #attachment>
                  <span>{{ formData.attachment }}</span>
                  <i class="usable el-icon-tickets" @click="download"></i>
                </template>
              </CustomDetails>
            </el-tab-pane>
            <el-tab-pane
              label="审核记录"
              name="shjl"
              v-if="formData.state == 3 || formData.state == 4"
            >
              <!-- <el-tabs
                type="border-card"
                class="xz_box"
                v-model="activetime"
                stretch
              >
                <el-tab-pane
                  v-for="(il, i) in formData.list"
                  :key="i"
                  :label="il.spTime"
                  :name="il.spTime"
                > -->
              <CustomDetails :model="formData" :config="shjlInfos">
                <template #jg>
                  <span> {{ stateMap[formData.state].name }}</span>
                </template>
              </CustomDetails>
              <!-- </el-tab-pane>
              </el-tabs> -->
            </el-tab-pane>
            <el-tab-pane
              label="撤回记录"
              name="chjl"
              v-if="formData.state == 2"
            >
              <CustomDetails :model="formData" :config="chInfos">
              </CustomDetails>
            </el-tab-pane>
          </el-tabs>
        </div>
        <div v-else-if="modelType === 'withdraw'">
          <!-- :rules="rules" -->
          <el-form :model="ruleForm" ref="ruleForm" label-width="100px">
            <el-form-item label="撤回原因:" prop="sqRevokeReason">
              <el-input
                v-model="ruleForm.sqRevokeReason"
                :rows="5"
                type="textarea"
                placeholder="理由描述"
              ></el-input>
            </el-form-item>
            <div class="tip">
              说明：输入撤回原因，确定撤回后，系统会自动撤回，无需申请，系统后台会记录撤回信息。
            </div>
          </el-form>
        </div>
      </div>
      <span slot="footer" class="dialog-footer">
        <!-- <span class="clearBtn" @click="submit(true)">保存至模板</span> -->
        <el-button size="small" type="primary" plain @click="close">关闭</el-button>
        <el-button size="small" type="primary" v-if="modelType !== 'info'" @click="submit"
          >确 定</el-button
        >
      </span>
    </el-dialog>
  </div>
</template>

<script>
import CustomDetails from "@/components/mapView/custom-detailsInfo.vue";
import { detailInfos, shjlInfos, chInfos, stateMap } from "../config";
import { revoke } from "@/api/shared.js";
export default {
  components: {
    CustomDetails,
  },
  props: {},
  data() {
    return {
      detailInfos: detailInfos,
      shjlInfos: shjlInfos,
      chInfos: chInfos,
      modelType: "info",
      formData: {},
      ruleForm: { id: "", sqRevokeReason: "" },
      dialogVisible: false,
      activeTabs: "sqjl",
      activetime: "",
      stateMap: stateMap,
    };
  },
  created() {},
  methods: {
    download(obj) {
      window.open(obj.fileUrl);
    },
    // 关闭弹窗
    close() {
      this.dialogVisible = false;
      this.$emit("close");
    },
    reset(id) {
      this.ruleForm = {
        id: id,
        sqRevokeReason: "",
      };
    },
    Init(type, rowdata) {
      this.dialogVisible = true;
      this.activeTabs = "sqjl";
      this.modelType = type;
      this.formData = rowdata;
      this.reset(rowdata.id);
      // this.formData.list = [rowdata];
      // this.activetime = this.formData.list[0].spTime;
    },
    async submit() {
      revoke(this.ruleForm).then((res) => {
        if (res.code == 200) {
          this.$message.success("撤回成功！");
          this.close();
        }
      });
    },
  },
};
</script>

<style lang="scss" scoped>
.dialog {
  .content {
    height: 400px;
    overflow-y: auto;
    overflow-x: hidden;
  }
  .tip {
    color: #f56c6c;
    margin-left: 25px;
  }
  .is-plain{
    background-color: #3f94f53f ;
    border-color: #3f93f5;
  }
}
</style>
<style lang="scss" >
</style>
