<!-- 转派记录 -->
<script>
import { RECORD } from "@/api/business/purchase/task";
export default {
  name: "Record",
  props: {
    selectData: {
      type: [Array],
      default: () => [],
    },
  },
  components: {
    ElSuperUxTable: () => import("@/components/super-ux-table/index.vue"),
  },
  data() {
    return {
      title: "转派记录",
      visible: false,
      columns: [
        {
          item: {
            title: "转派人名称",
            key: "redeployName",
          },
          attr: {},
        },
        {
          item: {
            title: "被转派人名称",
            key: "redeployByName",
          },
          attr: {},
        },
        {
          item: {
            title: "来源单据号",
            key: "source",
          },
          attr: {},
        },
        {
          item: {
            title: "改派时间",
            key: "createTime",
          },
          attr: {},
        },
      ],
      record: [],
    };
  },
  computed: {
    disabled: {
      get() {
        return this.selectData.length !== 1;
      },
      set() {},
    },
  },
  methods: {
    async open() {
      try {
        let { code, rows } = await RECORD({ source: this.selectData[0].code });

        if (code == 200) {
          this.record = rows;

          rows.length && (this.visible = true);

          !rows.length &&
            this.$notify.warning({
              title: "无转派记录",
            });
        }
      } catch (error) {}
    },
    close() {
      this.visible = false;
    },
  },
  created() {},
};
</script>

<template>
  <el-button :size="$attrs.size" @click="open" :disabled="disabled">
    {{ title }}
    <el-dialog
      class="zhuan-pai-record"
      :title="title"
      :visible.sync="visible"
      append-to-body
      @close="close"
    >
      <el-super-ux-table
        v-model="record"
        index
        :size="$attrs.size"
        :height="300"
        :columns="columns"
        style="width: 100%"
      >
      </el-super-ux-table>
    </el-dialog>
  </el-button>
</template>

<style lang="scss" scoped>
::v-deep.zhuan-pai-record .el-dialog__body {
  padding: 10px 20px 20px;
}
</style>
