<script>
import { TableColumns as Columns } from "../column";
import { ITEM } from "@/api/business/purchase/task";
import { initDicts, initParams } from "@/utils/init";

export default {
  name: "SeeDialog",
  dicts: initDicts(Columns),
  components: {},
  data() {
    return {
      size: "mini",
      visible: false,
      loading: false,
      columns: Columns,
      params: initParams(Columns),
    };
  },
  computed: {},
  watch: {},
  methods: {
    setVisible(prop) {
      this.visible = prop;
    },
    // 查询详细
    async beforeOpenDoSome(prop) {
      try {
        this.loading = true;
        const { code, msg, data } = await ITEM(prop);
        if (code === 200) {
          this.params = data;
          this.$notify.success({ title: msg });
        } else {
          this.$notify.warning({ title: msg });
        }
      } catch (err) {
        //
      } finally {
        this.loading = false;
      }
    },
  },
  created() {},
  mounted() {},
  destroyed() {},
};
</script>
<template>
  <el-dialog
    :visible.sync="visible"
    title="明细"
    append-to-body
    destroy-on-close
  >
    <el-descriptions :column="2" border>
      <el-descriptions-item
        v-if="params[column.key]"
        v-for="(column, index) in columns"
        :key="index"
        :label="column.title"
      >
        <dict-tag
          v-if="column.referName"
          :size="size"
          :value="params[column.key]"
          :options="dict.type[column.referName]"
        />
        <span v-else>{{ params[column.key] }}</span>
      </el-descriptions-item>
    </el-descriptions>
  </el-dialog>
</template>
