<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",
      title: "明细",
      width: "100%",
      column: 3,
      visible: false,
      loading: false,
      columns: Columns,
      params: initParams(Columns),
    };
  },
  computed: {},
  watch: {},
  methods: {
    //
    open(prop) {
      this.visible = true;
      this.fetchItem(prop);
    },
    // 查 询
    async fetchItem(prop) {
      try {
        this.loading = true;
        const { code, data } = await ITEM(prop);
        if (code === 200) {
          this.params = data;
        } else {
          this.$notify.warning({ title: msg });
        }
      } catch (err) {
        // catch
      } finally {
        // finally
        this.loading = false;
      }
    },
  },
  created() {},
  mounted() {},
  destroyed() {},
};
</script>
<template>
  <el-drawer :visible.sync="visible" :size="width" :title="title">
    <el-descriptions :size="size" :column="column" border style="margin: 10px">
      <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-drawer>
</template>
