<!--
 * @Author: 曹捷
 * @Date: 2021-05-25 15:05:30
 * @LastEditors: 曹捷
 * @LastEditTime: 2021-05-26 11:17:03
 * @Description: fileContent
-->
<template>
  <div class="wui-main">
    <obitUniversalTable :name="tableConfig.name" :pagination="pagination">
      <template #search>
        <obit-search-form :params="params" :paramList="paramList" @search="pageQuery(true)">
        </obit-search-form>
      </template>
      <template #btn>
        <a-button v-if="tableConfig.add" type="primary" @click="addDialog">
          <i class="iconfont icon-add-bold p-r-5"></i> 新 增
        </a-button>
      </template>
      <a-table :loading="pageLoading" :rowKey="tableConfig.key" :columns="tableColumns" :dataSource="pageDataList"
        :pagination="false" class="com-table" highlight-current-row style="width: 100%">
        <template #icon="{ record  }">
          <span class=" iconfont obit-link" :class="'icon-'+record.appIcon"></span>
        </template>
        <template #operation="{record}">
          <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>
    </obitUniversalTable>
  </div>
</template>

<script>
import { computed, getCurrentInstance, provide, onMounted, reactive, toRefs, inject } from 'vue'
export default {
  props: {
    tableConfig: {
      type: Object
    },
    tableColumns: {
      type: Array
    },
    paramList: {
      type: Array
    }
  },
  setup (props, context) {
    let { proxy } = getCurrentInstance()
    let hook = inject('hook')
    let pageIns = hook.page({
      url: props.tableConfig.url,
      remove: props.tableConfig.remove,
    })
    let _data = reactive({
      // tableColumns: [
      //   { title: '图标', slots: { customRender: 'icon' }, width: '80px' },
      //   { dataIndex: 'appName', title: '应用名称' },
      //   { dataIndex: 'appCode', title: '应用编码' },
      //   { dataIndex: 'appTypeName', title: '应用类型' },
      //   { dataIndex: 'appDesc', title: '应用描述' },
      //   { title: '操作', slots: { customRender: 'operation' }, width: "160px" },
      // ],
      // paramList: [
      //   { name: '应用名称', key: 'appName' },
      //   { name: '应用编码', key: 'appCode' },
      //   {
      //     type: 'ajax',
      //     key: 'appType',
      //     name: '应用类型',
      //     valuename: 'codeValue',
      //     labelname: 'valueDesc',
      //     ajaxurl: '/manager/sysCode/getValue?code=AppType',
      //   },
      // ],
    })
    let _methods = {
    }
    onMounted(() => {
      pageIns._method.pageQuery()
    })
    return {
      ...toRefs(pageIns._data),
      ...pageIns._method,
      ...toRefs(_data),
      ..._methods,
    }
  }
}
</script>

<style>
</style>