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

export default {
  name: "SeeDialog",
  dicts: initDicts(TableColumns),
  data() {
    return {
      size: "mini",
      visible: false,
      loading: false,
      columns: TableColumns,
      params: initParams(TableColumns),
    };
  },
  computed: {},
  watch: {},
  methods: {
    //
    open(prop) {
      this.visible = true;
      this.fetchItem(prop);
    },
    //
    hide() {
      this.visible = false;
      this.params = initParams(Columns);
    },
    //
    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) {
        //
      } finally {
        this.loading = false;
      }
    },
  },
  created() {},
  mounted() {},
  destroyed() {},
};
</script>
<template>
  <el-dialog :visible.sync="visible" title="明细" @close="hide">
    <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.inputType === 'Select'"
          :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>
