<template>
  <div>
    <el-drawer
      title="反馈"
      :visible.sync="drawer"
      direction="rtl"
      append-to-body
      size="660px">
      <div style="padding: 10px 20px;">
        <xy-table ref="xyTable"
                  height="64rem"
                  :action="index"
                  :req-opt="select"
                  :table-item="table"
                  :is-first-req="false">
        </xy-table>
      </div>
    </el-drawer>
  </div>
</template>

<script>
import { index, save } from "@/api/system/baseForm"
import { show } from "@/api/system/customFormField";
export default {
  data() {
    return {
      drawer: false,
      select: {
        table_name: 'feedbacks',
        filter: [
          {
            key: "transfer_id",
            op: "eq",
            value: ""
          }
        ]
      },
      table: [
        {
          prop: "content",
          label: "内容",
          minWidth: 200,
          align: "left"
        },
        {
          prop: "type",
          label: "反馈类型",
          width: 160,
          formatter: (t1, t2, val) => {
            return this.types.get(val)
          }
        },
        {
          prop: "feedback_department_id_departments_id_relation.name",
          label: "反馈科室",
          width: 160
        },
        {
          prop: "status",
          label: "状态",
          width: 120,
          formatter: (t1, t2, val) => {
            return val ? '正常' : '退回'
          }
        }
      ],
      types: []
    }
  },
  methods: {
    index,
    show () {
      this.drawer = true
    },
    hide () {
      this.drawer = false
    },
    setId (id) {
      this.select.filter[0].value = id
    },
    async getType() {
      const obj = (await show({ id: 23 }, false))?.select_item;
      if (obj && typeof obj === "object") {
        let keys = Object.keys(obj);
        if (keys.length > 0) {
          this.types = new Map(keys.map(key => [/^\d*$/.test(obj[key]) ? Number(obj[key]) : obj[key],key]))
        }
      }
    },
  },
  computed: {


  },
  watch: {
    drawer (newVal) {
      if (newVal) {
        this.$nextTick(() => {
          this.$refs['xyTable'].getTableData(true)
        })
      }
    }
  },
  created() {
    this.getType()
  }
}
</script>

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