<template>
  <el-dialog v-model="visible" title="设置包保责任类型">
    <el-descriptions :column="2" border class="mb-10">
      <el-descriptions-item label="风险点">
        {{ info.RISKUNITNAME }}
      </el-descriptions-item>
      <el-descriptions-item label="辨识部位">
        {{ info.PARTSNAME }}
      </el-descriptions-item>
      <el-descriptions-item label="存在风险">
        {{ info.RISK_DESCR }}
      </el-descriptions-item>
      <el-descriptions-item label="风险分级">
        {{ info.DNAME5 }}
      </el-descriptions-item>
      <el-descriptions-item label="检查内容">
        {{ info.CHECK_CONTENT }}
      </el-descriptions-item>
    </el-descriptions>
    <layout-table :data="list" :show-pagination="false">
      <el-table-column type="index" label="序号" width="55" />
      <el-table-column prop="DESCRIBE" label="描述" />
      <el-table-column label="操作" width="100px">
        <template v-slot="{ row }">
          <el-button type="primary" text link @click="fnCheck(row)">
            选择
          </el-button>
        </template>
      </el-table-column>
    </layout-table>
    <template #footer>
      <el-button @click="fnClose">关闭</el-button>
    </template>
  </el-dialog>
</template>

<script setup>
import { useVModel } from "@vueuse/core";
import useListData from "@/assets/js/useListData.js";
import { setInventoryManagementInsuranceCoverageList } from "@/request/hazard_investigation.js";
import { watchEffect } from "vue";

const props = defineProps({
  visible: {
    type: Boolean,
    required: true,
    default: false,
  },
  info: {
    type: Object,
    required: true,
    default: () => ({}),
  },
});
const emits = defineEmits(["update:visible", "check"]);
const visible = useVModel(props, "visible", emits);
const { list, fnGetData } = useListData(
  setInventoryManagementInsuranceCoverageList,
  {
    usePagination: false,
    immediate: false,
  }
);
watchEffect(() => {
  if (props.visible)
    fnGetData({
      WORK_TYPE: props.info.TASK_TYPE_NUM,
    });
});
const fnClose = () => {
  visible.value = false;
};
const fnCheck = (row) => {
  emits("check", row);
  fnClose();
};
</script>

<style scoped lang="scss"></style>
