<!--
 * @Author: 曹捷
 * @Date: 2021-03-15 14:54:07
 * @LastEditors: 曹捷
 * @LastEditTime: 2021-08-26 22:17:32
 * @Description: 应用管理
-->
<template>
  <obitUniversalTable name="查询结果" :pagination="pagination">
    <template #search>
      <obit-search-form :params="params" :paramList="paramList" @search="pageQuery(true)">
      </obit-search-form>
    </template>
    <template #btn>
      <a-button type="primary" @click="addDialog">
        <i class="iconfont icon-add-bold p-r-5"></i> 新 增
      </a-button>
    </template>
    <a-table :loading="pageLoading" rowKey="appId" :columns="tableColumns" :dataSource="pageDataList"
      :pagination="false" class="com-table" highlight-current-row style="width: 100%">
      <template #icon="{ record  }" :key="record.appId">
        <span class=" iconfont obit-link" :class="'icon-'+record.appIcon"></span>
      </template>
      <template #operation="{ record  }" :key="record.appId">
        <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>
  <appAdd :addType="pageType" v-model:open="pageVisable" :detailsInfo="detailsInfo" @reload="pageQuery(true)">
  </appAdd>
</template>

<script>
import { getCurrentInstance, onMounted, reactive, toRefs } from 'vue'
import appAdd from './appAdd.vue'
import page from './../../../hook/page.js'
export default {
  components: { appAdd },
  setup (props, contenxt) {
    let { proxy } = getCurrentInstance()
    let pageIns = page({
      tableRequest: 'getSystemAppList',
      removeKey: 'removeSystemAppInfo'
    })
    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>