<!--
 * @Author: 曹捷
 * @Date: 2019-08-20 20:25:19
 * @LastEditors: 曹捷
 * @LastEditTime: 2021-06-09 15:40:01
 * @Description: file content
 -->
<template>
  <a-table :loading="pageLoading" rowKey="id" :columns="tableColumns" :dataSource="pageDataList" :pagination="false"
    class="com-table" highlight-current-row style="width: 100%">
    <template #operation="{ record  }" :key="record.id">
      <a-button type="link" @click="editDialog(record)">编辑</a-button>
      <a-divider type="vertical" style="height: 16px;" />
      <a-button type="link" @click="remove(record)"> 删除</a-button>
    </template>
  </a-table>
  <dictValueAdd :addType="pageType" :selectCode="codeField" v-model:open="pageVisable" :detailsInfo="detailsInfo"
    @reload="pageQuery(true)">
  </dictValueAdd>
</template>

<script>
import { getCurrentInstance, onMounted, reactive, toRefs, watch } from 'vue'
import dictValueAdd from './dictValueAdd.vue'
import page from './../../../hook/page.js'
export default {
  components: { dictValueAdd },
  props: {
    codeField: {
      type: String
    }
  },
  setup (props, contenxt) {
    let { proxy } = getCurrentInstance()
    let _data = reactive({
      tableColumns: [
        // { dataIndex: 'codeField', title: '字典类型' },
        { dataIndex: 'codeValue', title: '字典值' },
        { dataIndex: 'valueDesc', title: '值描述' },
        { title: '操作', slots: { customRender: 'operation' }, width: "200px" },
      ],
      codeValue: ''
    })
    let pageIns = page({
      tableRequest: 'getSystemCodeValueList',
      removeKey: 'removeSystemCodeValue',
      data: {
        pagination: {
          pageSize: 30
        }
      },
      getQueryParam () {
        return {
          codeField: props.codeField
        }
      }
    })
    watch(() => props.codeField, () => {
      pageIns._method.pageQuery(true)
    })
    pageIns._method.pageQuery(true)

    return {
      ...toRefs(pageIns._data),
      ...pageIns._method,
      ...toRefs(_data),
    }
  },
}
</script>

<style>
</style>