<!--
 * @Author: 曹捷
 * @Date: 2021-03-15 14:54:07
 * @LastEditors: 曹捷
 * @LastEditTime: 2021-05-31 12:48:38
 * @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 @click="removeAll" class="m-r-15">
        <i class="iconfont icon-ashbin  p-r-5"></i> 删除全部
      </a-button>
      <a-button type="primary" @click="addDialog">
        <i class="iconfont icon-add-bold p-r-5"></i> 新 增
      </a-button>
    </template>
    <a-table :loading="pageLoading" rowKey="configId" :columns="tableColumns" :dataSource="pageDataList"
      :scroll="{ x: '100%' }" :pagination="false" :row-selection="rowSelection" class="com-table" highlight-current-row
      style="width: 100%">
      <template #configType="{ record  }" :key="record.configId">
        <span v-if="record.configType=='Y'">是</span>
        <span v-else>否</span>
      </template>
      <template #operation="{ record  }" :key="record.configId">
        <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>
  <paramAdd :addType="pageType" v-model:open="pageVisable" :detailsInfo="detailsInfo" @reload="pageQuery(true)">
  </paramAdd>
</template>

<script>
import { getCurrentInstance, onMounted, reactive, toRefs } from 'vue'
import paramAdd from './paramAdd.vue'
import page from '../../../hook/page.js'
export default {
  components: { paramAdd },
  setup (props, contenxt) {
    let { proxy } = getCurrentInstance()
    let pageIns = page({
      url: 'system/config/pageList',
      key: 'configId',
      removeUrl: 'system/config/remove',
      removeAll: 'system/config/removeAll',
    })
    let _data = reactive({
      tableColumns: [
        { dataIndex: 'configId', title: '参数主键', width: 100 },
        { dataIndex: 'configName', title: '参数名称', width: 150 },
        { dataIndex: 'configKey', title: '参数键名', width: 150 },
        { dataIndex: 'configValue', title: '参数键值', width: 150 },
        { title: '系统内置', slots: { customRender: 'configType' }, width: 100 },
        { dataIndex: 'remark', title: '备注', width: 200 },
        { dataIndex: 'createTime', title: '创建时间', width: 180 },
        { title: '操作', slots: { customRender: 'operation' }, width: 120 },
      ],
      paramList: [
        { name: '参数名称', key: 'configName' },
        { name: '参数键名', key: 'configKey' },
        {
          type: 'ajax',
          key: 'configType',
          name: '系统内置',
          valuename: 'dictValue',
          labelname: 'dictLabel',
          ajaxurl: 'system/dict/data/type/sys_yes_no',
        },
        { name: '操作时间', endKey: 'endTime', startKey: 'beginTime', type: 'dateBetween' },
      ],
    })
    let _methods = {
    }
    onMounted(() => {
      pageIns._method.pageQuery()
    })
    return {
      ...toRefs(pageIns._data),
      ...pageIns._method,
      ...toRefs(_data),
      ..._methods,
    }
  },
}
</script>

<style>
</style>