inleft
2022-03-01 88f419df77ade235ea5e5e24be204842a24b7b33
commit | author | age
9bcb19 1 <template>
I 2   <div>
3     <x-card v-if="hasPerm('sysConfig:page')">
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="参数名称">
9                 <a-input v-model="queryParam.name" allow-clear placeholder="请输入参数名称"/>
10               </a-form-item>
11             </a-col>
12             <a-col :md="8" :sm="24">
13               <a-form-item label="唯一编码">
14                 <a-input v-model="queryParam.code" allow-clear placeholder="请输入唯一编码"/>
15               </a-form-item>
16             </a-col>
17             <template v-if="advanced">
18               <a-col :md="8" :sm="24">
19                 <a-form-item label="所属分类">
20                   <a-select v-model="queryParam.groupCode" placeholder="请选择所属分类" allow-clear>
21                     <a-select-option v-for="(item,index) in groupCodeDictTypeDropDown" :key="index" :value="item.code" >{{ item.name }}</a-select-option>
22                   </a-select>
23                 </a-form-item>
24               </a-col>
25             </template>
26             <a-col :md="!advanced && 8 || 24" :sm="24" >
27               <span class="table-page-search-submitButtons" :style="advanced && { float: 'right', overflow: 'hidden' } || {} ">
28                 <a-button type="primary" @click="$refs.table.refresh(true)" >查询</a-button>
29                 <a-button style="margin-left: 8px" @click="() => queryParam = {}">重置</a-button>
30                 <a @click="toggleAdvanced" style="margin-left: 8px">
31                   {{ advanced ? '收起' : '展开' }}
32                   <a-icon :type="advanced ? 'up' : 'down'"/>
33                 </a>
34               </span>
35             </a-col>
36           </a-row>
37         </a-form>
38       </div>
39     </x-card>
40     <a-card :bordered="false">
41       <s-table
42         ref="table"
43         :columns="columns"
44         :data="loadData"
45         :alert="false"
46         :rowKey="(record) => record.code"
47       >
48         <template slot="operator" v-if="hasPerm('sysConfig:add')">
49           <a-button @click="$refs.addForm.add()" icon="plus" type="primary" v-if="hasPerm('sysConfig:add')">新增配置</a-button>
50         </template>
51         <span slot="name" slot-scope="text">
52           <ellipsis :length="20" tooltip>{{ text }}</ellipsis>
53         </span>
54         <span slot="code" slot-scope="text">
55           <ellipsis :length="10" tooltip>{{ text }}</ellipsis>
56         </span>
57         <span slot="value" slot-scope="text">
58           <ellipsis :length="16" tooltip>{{ text }}</ellipsis>
59         </span>
60         <span slot="remark" slot-scope="text">
61           <ellipsis :length="16" tooltip>{{ text }}</ellipsis>
62         </span>
63         <span slot="groupCode" slot-scope="text">
64           {{ 'consts_type' | dictType(text) }}
65         </span>
66         <span slot="action" slot-scope="text, record">
67           <a v-if="hasPerm('sysConfig:edit')" @click="$refs.editForm.edit(record)">编辑</a>
68           <a-divider type="vertical" v-if="hasPerm('sysConfig:edit') & hasPerm('sysConfig:delete')"/>
69           <a-popconfirm v-if="hasPerm('sysConfig:delete')" placement="topRight" title="确认删除?" @confirm="() => sysConfigDelete(record)">
70             <a>删除</a>
71           </a-popconfirm>
72         </span>
73       </s-table>
74       <add-form ref="addForm" @ok="handleOk" v-if="hasPerm('sysConfig:add')"/>
75       <edit-form ref="editForm" @ok="handleOk" v-if="hasPerm('sysConfig:edit')"/>
76     </a-card>
77   </div>
78 </template>
79 <script>
80   import { STable, Ellipsis, XCard } from '@/components'
81   import { sysConfigPage, sysConfigDelete } from '@/api/modular/system/configManage'
82   import addForm from './addForm'
83   import editForm from './editForm'
84   export default {
85     components: {
86       XCard,
87       STable,
88       Ellipsis,
89       addForm,
90       editForm
91     },
92     data () {
93       return {
94         // 高级搜索 展开/关闭
95         advanced: false,
96         // 查询参数
97         queryParam: {},
98         // 表头
99         columns: [
100           {
101             title: '参数名称',
102             dataIndex: 'name',
103             scopedSlots: { customRender: 'name' }
104           },
105           {
106             title: '唯一编码',
107             dataIndex: 'code',
108             scopedSlots: { customRender: 'code' }
109           },
110           {
111             title: '参数值',
112             dataIndex: 'value',
113             scopedSlots: { customRender: 'value' }
114           },
115           {
116             title: '所属分类',
117             dataIndex: 'groupCode',
118             scopedSlots: { customRender: 'groupCode' }
119           },
120           {
121             title: '备注',
122             dataIndex: 'remark',
123             scopedSlots: { customRender: 'remark' }
124           }
125         ],
126         // 加载数据方法 必须为 Promise 对象
127         loadData: parameter => {
128           return sysConfigPage(Object.assign(parameter, this.queryParam)).then((res) => {
129             return res.data
130           })
131         },
132         groupCodeDictTypeDropDown: []
133       }
134     },
135     /**
136      * 初始化判断按钮权限是否拥有,没有则不现实列
137      */
138     created () {
139       this.sysDictTypeDropDown()
140       if (this.hasPerm('sysConfig:edit') || this.hasPerm('sysConfig:delete')) {
141         this.columns.push({
142           title: '操作',
143           width: '150px',
144           dataIndex: 'action',
145           scopedSlots: { customRender: 'action' }
146         })
147       }
148     },
149     methods: {
150       /**
151        * 获取字典数据
152        */
153       sysDictTypeDropDown () {
154         this.groupCodeDictTypeDropDown = this.$options.filters['dictData']('consts_type')
155       },
156       sysConfigDelete (record) {
157         sysConfigDelete(record).then((res) => {
158           if (res.success) {
159             this.$message.success('删除成功')
160             this.$refs.table.refresh()
161           } else {
162             this.$message.error('删除失败:' + res.message)
163           }
164         }).catch((err) => {
165           this.$message.error('删除错误:' + err.message)
166         })
167       },
168       toggleAdvanced () {
169         this.advanced = !this.advanced
170       },
171       handleOk () {
172         this.$refs.table.refresh()
173       }
174     }
175   }
176 </script>
177 <style lang="less">
178   .table-operator {
179     margin-bottom: 18px;
180   }
181   button {
182     margin-right: 8px;
183   }
184 </style>