inleft
2022-02-15 91dc6cdda0548ff7f6e473a81933fa206d912cef
commit | author | age
9bcb19 1 <template>
I 2   <div>
3     <x-card v-if="hasPerm('sysNotice:received')">
4       <div slot="content" class="table-page-search-wrapper">
5         <a-form layout="inline">
6           <a-row :gutter="48">
7             <a-col :md="8" :sm="24">
8               <a-form-item label="关键词" v-if="hasPerm('sysNotice:received')">
9                 <a-input v-model="queryParam.searchValue" allow-clear placeholder="请输入标题、内容"/>
10               </a-form-item>
11             </a-col>
12             <a-col :md="8" :sm="24">
13               <a-form-item label="类型" v-if="hasPerm('sysNotice:received')">
14                 <a-select v-model="queryParam.type" placeholder="请选择类型" allow-clear >
15                   <a-select-option v-for="(item,index) in typeDictTypeDropDown" :key="index" :value="item.code" >{{ item.name }}</a-select-option>
16                 </a-select>
17               </a-form-item>
18             </a-col>
19             <a-col :md="!advanced && 8 || 24" :sm="24">
20               <span class="table-page-search-submitButtons" >
21                 <a-button type="primary" @click="$refs.table.refresh(true)">查询</a-button>
22                 <a-button style="margin-left: 8px" @click="() => queryParam = {}">重置</a-button>
23               </span>
24             </a-col>
25           </a-row>
26         </a-form>
27       </div>
28     </x-card>
29     <a-card :bordered="false">
30       <s-table
31         ref="table"
32         :columns="columns"
33         :data="loadData"
34         :alert="false"
35         :rowKey="(record) => record.id"
36         :rowSelection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange }"
37       >
38         <span slot="status" slot-scope="text">
39           {{ 'notice_status' | dictType(text) }}
40         </span>
41         <span slot="type" slot-scope="text">
42           {{ 'notice_type' | dictType(text) }}
43         </span>
44         <span slot="action" slot-scope="text, record">
45           <a v-if="hasPerm('sysNotice:received')" @click="$refs.detailForm.detail(record)">查看</a>
46         </span>
47       </s-table>
48       <detail-form ref="detailForm" @ok="handleOk" />
49       <div ref="editor"></div>
50     </a-card>
51   </div>
52 </template>
53 <script>
54   import { STable, XCard } from '@/components'
55   // eslint-disable-next-line no-unused-vars
56   import { sysNoticeReceived } from '@/api/modular/system/noticeReceivedManage'
57   import detailForm from './detailForm'
58   export default {
59     components: {
60       XCard,
61       STable,
62       detailForm
63     },
64     data () {
65       return {
66         // 高级搜索 展开/关闭
67         advanced: false,
68         // 查询参数
69         queryParam: {},
70         // 表头
71         columns: [
72           {
73             title: '标题',
74             dataIndex: 'title'
75           },
76           {
77             title: '类型',
78             dataIndex: 'type',
79             scopedSlots: { customRender: 'type' }
80           },
81           {
82             title: '状态',
83             dataIndex: 'status',
84             scopedSlots: { customRender: 'status' }
85           }
86         ],
87         // 加载数据方法 必须为 Promise 对象
88         loadData: parameter => {
89           return sysNoticeReceived(Object.assign(parameter, this.queryParam)).then((res) => {
90             return res.data
91           })
92         },
93         selectedRowKeys: [],
94         selectedRows: [],
95         statusDictTypeDropDown: [], // 0草稿 1发布 2撤回 3删除
96         typeDictTypeDropDown: []// 0通知 1公告
97       }
98     },
99     created () {
100       this.sysDictTypeDropDown()// 先注释
101       if (this.hasPerm('sysNotice:received')) {
102         this.columns.push({
103           title: '操作',
104           width: '200px',
105           dataIndex: 'action',
106           scopedSlots: { customRender: 'action' }
107         })
108       }
109     },
110     methods: {
111       /**
112        * 获取字典数据
113        */
114       sysDictTypeDropDown () {
115         this.statusDictTypeDropDown = this.$options.filters['dictData']('notice_status')
116         this.typeDictTypeDropDown = this.$options.filters['dictData']('notice_type')
117       },
118       handleOk () {
119         this.$refs.table.refresh()
120       },
121       onSelectChange (selectedRowKeys, selectedRows) {
122         this.selectedRowKeys = selectedRowKeys
123         this.selectedRows = selectedRows
124       }
125     }
126   }
127 </script>
128
129 <style lang="less">
130   .table-operator {
131     margin-bottom: 18px;
132   }
133   button {
134     margin-right: 8px;
135   }
136 </style>