<!--
 * @Author: 曹捷
 * @Date: 2019-08-13 10:49:35
 * @LastEditors: 曹捷
 * @LastEditTime: 2021-08-24 19:19:00
 * @Description: 通知公告
 -->
<template>
  <obitUniversalTable name="通知公告" v-if="$fmt(['sys_normal_disable','sys_notice_type'])">
    <template #search>
      <obit-search-form :params="params" :paramList="paramList" @search="pageQuery(true)">
      </obit-search-form>
    </template>
    <template #btn>
      <a-button @click="removeAll" danger class="m-r-15">
        <i class="iconfont icon-ashbin  p-r-5"></i> 删除
      </a-button>
      <a-button type="primary" @click="addDialog(0)">
        <i class="iconfont icon-add-bold p-r-5"></i> 新 增
      </a-button>
    </template>
    <a-table class="obit-atable" :columns="tableColumns" :data-source="pageDataList" :row-selection="rowSelection"
      rowKey="noticeId" :loading="pageLoading">
      <template #operation="{ record  }" :key="record.noticeId">
        <a-button class="operation-btn" type="link" @click.stop="editDialog(record )"> 编辑</a-button>
        <a-button class="operation-btn" type="link" @click.stop="remove(record)"> 删除</a-button>
      </template>
    </a-table>
  </obitUniversalTable>
  <noticeAddVue :addType="pageType" v-model:open="pageVisable" :detailsInfo="detailsInfo" @reload="pageQuery(true)">
  </noticeAddVue>
</template>

<script>
import { getCurrentInstance, inject, onMounted, reactive, toRefs } from 'vue'
import noticeAddVue from './noticeAdd.vue'
import page from './../../../hook/page.js'

export default {
  components: { noticeAddVue },
  setup (props, contenxt) {
    let { proxy } = getCurrentInstance()
    let http = inject('http')
    let pageIns = page({
      url: 'system/notice/pageList',
      key: 'noticeId',
      removeUrl: 'system/notice/remove',
      removeAll: 'system/notice/removeAll'
    })
    let _data = reactive({
      noticeType: {},
      tableColumns: [
        { dataIndex: 'noticeTitle', title: '公告标题', },
        { dataIndex: 'noticeType', customRender: ({ text, record, index }) => proxy.$fmt('sys_notice_type', text), title: '公告类型' },
        { dataIndex: 'status', customRender: ({ text, record, index }) => proxy.$fmt('sys_normal_disable', text), title: '状态' },
        { dataIndex: 'createBy', title: '创建人' },
        { dataIndex: 'createTime', title: '创建时间' },
        { title: '操作', slots: { customRender: 'operation' } },
      ],
      paramList: [
        { name: '公告标题', key: 'noticeTitle' },
        { name: '操作人员', key: 'createBy' },
        {
          type: 'ajax',
          key: 'noticeType',
          name: '通知类型',
          valuename: 'dictValue',
          labelname: 'dictLabel',
          ajaxurl: 'system/dict/data/type/sys_notice_type',
        },
      ],
    })
    let _methods = {
    }

    onMounted(() => {
      pageIns._method.pageQuery()
    })
    return {
      ...toRefs(pageIns._data),
      ...pageIns._method,
      ...toRefs(_data),
      ..._methods,
    }
  },
}
</script>

<style lang="less">
.table-tree {
}
</style>