<template>
  <!-- 审核详情 -->
  <el-dialog :title="diatitle" v-model="open" width="500px" append-to-body>
    <!-- <div v-if="tjform.decide == '1'">
      <div>提交数据要求通过审核且完成合法性判定。</div>
      <div>
        当前图斑数据(图斑编号：{{ tjform.dkbh }})不满足上报要求，无法进行提交。
      </div>
      <div>请核实数据后，再进行操作。</div>
    </div>v-else -->
    <div class="tjdiv">
      <div class="tit">图斑编号：{{ tjform.dkbh }}</div>
      <div class="tit" v-if="action">
        确定对该图斑数据进行提交吗？提交后无法进行修改。
      </div>
      <div v-for="(note, nkey) in JSON.parse(tjform.notes)" :key="nkey">
        {{ note.stepValue }}：{{ note.notes }}
      </div>
      <div>提交数据包括图斑核查数据、审核数据、合法性判定数据。</div>
    </div>
    <template #footer>
      <div class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="open = false">取 消</el-button>
      </div>
    </template>
  </el-dialog>
</template>

<script setup name="details">
import { scinfo, tjinfo, scDkjbxx, tjDkjbxx } from "@/api/rsmonitoring/dkjbxx";
const { proxy } = getCurrentInstance();
const emit = defineEmits([""]);
const resultdata = reactive({
  open: false,
  action: false,
  diatitle: "",
  tjform: {},
});
const { open, action, diatitle, tjform } = toRefs(resultdata);
function moreAct(actitem, infoObj) {
  diatitle.value = `提交结果`;
  action.value = false;
  getinfo(actitem, infoObj);
}
function getinfo(actitem, infoObj) {
  let pram = {
    dkid: infoObj.id,
    auditflowStep: actitem.auditflowStep,
    auditflowId: actitem.id,
  };
  tjinfo(pram).then((res) => {
    tjform.value = {
      ...res.data,
      dkbh: infoObj.dkbh,
      auditflowStep: actitem.auditflowStep,
    };

    open.value = true;
  });
}
function operate(infoObj, auditflowStep) {
  diatitle.value = `提交`;
  action.value = true;
  getinfo({ auditflowStep }, infoObj);
}

// 审核;
function submitForm() {
  if (!action.value) {
    open.value = false;
    return;
  }

  tjDkjbxx(tjform.value).then((res) => {
    proxy.$modal.msgSuccess("提交成功");
    open.value = false;
    emit("");
  });
}

defineExpose({ moreAct, operate });
</script>

<style scoped>
.tjdiv {
  line-height: 28px;
}
.tit {
  font-weight: bold;
}
</style>