Skip to content

Commit c5cdf68

Browse files
committed
feat: add step-by-step modal
1 parent f62348a commit c5cdf68

File tree

6 files changed

+546
-95
lines changed

6 files changed

+546
-95
lines changed

src/config/router.config.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,12 @@ export const asyncRouterMap = [
7373
path: '/list',
7474
name: 'list',
7575
component: PageView,
76-
redirect: '/list/query-list',
76+
redirect: '/list/table-list',
7777
meta: { title: '列表页', icon: 'table', permission: [ 'table' ] },
7878
children: [
7979
{
80-
path: '/list/query-list',
81-
name: 'QueryListWrapper',
80+
path: '/list/table-list',
81+
name: 'TableListWrapper',
8282
hideChildrenInMenu: true, // 强制显示 MenuItem 而不是 SubMenu
8383
component: () => import('@/views/list/TableList'),
8484
meta: { title: '查询表格', keepAlive: true, permission: [ 'table' ] }

src/views/list/QueryList.vue

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<template>
2+
<a-card :bordered="false">
3+
<component @onEdit="handleEdit" @onGoBack="handleGoBack" :record="record" :is="currentComponet"></component>
4+
</a-card>
5+
</template>
6+
7+
<script>
8+
9+
import ATextarea from 'ant-design-vue/es/input/TextArea'
10+
import AInput from 'ant-design-vue/es/input/Input'
11+
// 动态切换组件
12+
import List from '@/views/list/table/List'
13+
import Edit from '@/views/list/table/Edit'
14+
15+
export default {
16+
name: 'TableListWrapper',
17+
components: {
18+
AInput,
19+
ATextarea,
20+
List,
21+
Edit
22+
},
23+
data () {
24+
return {
25+
currentComponet: 'List',
26+
record: ''
27+
}
28+
},
29+
created () {
30+
31+
},
32+
methods: {
33+
handleEdit (record) {
34+
this.record = record || ''
35+
this.currentComponet = 'Edit'
36+
console.log(record)
37+
},
38+
handleGoBack () {
39+
this.record = ''
40+
this.currentComponet = 'List'
41+
}
42+
},
43+
watch: {
44+
'$route.path' () {
45+
this.record = ''
46+
this.currentComponet = 'List'
47+
}
48+
}
49+
}
50+
</script>

src/views/list/TableList.vue

Lines changed: 243 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,267 @@
11
<template>
22
<a-card :bordered="false">
3-
<component @onEdit="handleEdit" @onGoBack="handleGoBack" :record="record" :is="currentComponet"></component>
3+
<div class="table-page-search-wrapper">
4+
<a-form layout="inline">
5+
<a-row :gutter="48">
6+
<a-col :md="8" :sm="24">
7+
<a-form-item label="规则编号">
8+
<a-input v-model="queryParam.id" placeholder=""/>
9+
</a-form-item>
10+
</a-col>
11+
<a-col :md="8" :sm="24">
12+
<a-form-item label="使用状态">
13+
<a-select v-model="queryParam.status" placeholder="请选择" default-value="0">
14+
<a-select-option value="0">全部</a-select-option>
15+
<a-select-option value="1">关闭</a-select-option>
16+
<a-select-option value="2">运行中</a-select-option>
17+
</a-select>
18+
</a-form-item>
19+
</a-col>
20+
<template v-if="advanced">
21+
<a-col :md="8" :sm="24">
22+
<a-form-item label="调用次数">
23+
<a-input-number v-model="queryParam.callNo" style="width: 100%"/>
24+
</a-form-item>
25+
</a-col>
26+
<a-col :md="8" :sm="24">
27+
<a-form-item label="更新日期">
28+
<a-date-picker v-model="queryParam.date" style="width: 100%" placeholder="请输入更新日期"/>
29+
</a-form-item>
30+
</a-col>
31+
<a-col :md="8" :sm="24">
32+
<a-form-item label="使用状态">
33+
<a-select v-model="queryParam.useStatus" placeholder="请选择" default-value="0">
34+
<a-select-option value="0">全部</a-select-option>
35+
<a-select-option value="1">关闭</a-select-option>
36+
<a-select-option value="2">运行中</a-select-option>
37+
</a-select>
38+
</a-form-item>
39+
</a-col>
40+
<a-col :md="8" :sm="24">
41+
<a-form-item label="使用状态">
42+
<a-select placeholder="请选择" default-value="0">
43+
<a-select-option value="0">全部</a-select-option>
44+
<a-select-option value="1">关闭</a-select-option>
45+
<a-select-option value="2">运行中</a-select-option>
46+
</a-select>
47+
</a-form-item>
48+
</a-col>
49+
</template>
50+
<a-col :md="!advanced && 8 || 24" :sm="24">
51+
<span class="table-page-search-submitButtons" :style="advanced && { float: 'right', overflow: 'hidden' } || {} ">
52+
<a-button type="primary" @click="$refs.table.refresh(true)">查询</a-button>
53+
<a-button style="margin-left: 8px" @click="() => queryParam = {}">重置</a-button>
54+
<a @click="toggleAdvanced" style="margin-left: 8px">
55+
{{ advanced ? '收起' : '展开' }}
56+
<a-icon :type="advanced ? 'up' : 'down'"/>
57+
</a>
58+
</span>
59+
</a-col>
60+
</a-row>
61+
</a-form>
62+
</div>
63+
64+
<div class="table-operator">
65+
<a-button type="primary" icon="plus" @click="$refs.createModal.add()">新建</a-button>
66+
<a-button type="dashed" @click="tableOption">{{ optionAlertShow && '关闭' || '开启' }} alert</a-button>
67+
<a-dropdown v-action:edit v-if="selectedRowKeys.length > 0">
68+
<a-menu slot="overlay">
69+
<a-menu-item key="1"><a-icon type="delete" />删除</a-menu-item>
70+
<!-- lock | unlock -->
71+
<a-menu-item key="2"><a-icon type="lock" />锁定</a-menu-item>
72+
</a-menu>
73+
<a-button style="margin-left: 8px">
74+
批量操作 <a-icon type="down" />
75+
</a-button>
76+
</a-dropdown>
77+
</div>
78+
79+
<s-table
80+
ref="table"
81+
size="default"
82+
rowKey="key"
83+
:columns="columns"
84+
:data="loadData"
85+
:alert="options.alert"
86+
:rowSelection="options.rowSelection"
87+
>
88+
<span slot="serial" slot-scope="text, record, index">
89+
{{ index + 1 }}
90+
</span>
91+
<span slot="status" slot-scope="text">
92+
<a-badge :status="text | statusTypeFilter" :text="text | statusFilter" />
93+
</span>
94+
95+
<span slot="action" slot-scope="text, record">
96+
<template>
97+
<a @click="handleEdit(record)">配置</a>
98+
<a-divider type="vertical" />
99+
<a @click="handleSub(record)">订阅报警</a>
100+
</template>
101+
</span>
102+
</s-table>
103+
<create-form ref="createModal" @ok="handleOk" />
104+
<step-by-step-modal ref="modal" @ok="handleOk"/>
4105
</a-card>
5106
</template>
6107

7108
<script>
109+
import moment from 'moment'
110+
import { STable } from '@/components'
111+
import StepByStepModal from './modules/StepByStepModal'
112+
import CreateForm from './modules/CreateForm'
113+
import { getRoleList, getServiceList } from '@/api/manage'
8114
9-
import ATextarea from 'ant-design-vue/es/input/TextArea'
10-
import AInput from 'ant-design-vue/es/input/Input'
11-
// 动态切换组件
12-
import List from '@/views/list/table/List'
13-
import Edit from '@/views/list/table/Edit'
115+
const statusMap = {
116+
0: {
117+
status: 'default',
118+
text: '关闭'
119+
},
120+
1: {
121+
status: 'processing',
122+
text: '运行中'
123+
},
124+
2: {
125+
status: 'success',
126+
text: '已上线'
127+
},
128+
3: {
129+
status: 'error',
130+
text: '异常'
131+
}
132+
}
14133
15134
export default {
16-
name: 'TableListWrapper',
135+
name: 'TableList',
17136
components: {
18-
AInput,
19-
ATextarea,
20-
List,
21-
Edit
137+
STable,
138+
CreateForm,
139+
StepByStepModal
22140
},
23141
data () {
24142
return {
25-
currentComponet: 'List',
26-
record: ''
143+
mdl: {},
144+
// 高级搜索 展开/关闭
145+
advanced: false,
146+
// 查询参数
147+
queryParam: {},
148+
// 表头
149+
columns: [
150+
{
151+
title: '#',
152+
scopedSlots: { customRender: 'serial' }
153+
},
154+
{
155+
title: '规则编号',
156+
dataIndex: 'no'
157+
},
158+
{
159+
title: '描述',
160+
dataIndex: 'description'
161+
},
162+
{
163+
title: '服务调用次数',
164+
dataIndex: 'callNo',
165+
sorter: true,
166+
needTotal: true,
167+
customRender: (text) => text + ''
168+
},
169+
{
170+
title: '状态',
171+
dataIndex: 'status',
172+
scopedSlots: { customRender: 'status' }
173+
},
174+
{
175+
title: '更新时间',
176+
dataIndex: 'updatedAt',
177+
sorter: true
178+
},
179+
{
180+
title: '操作',
181+
dataIndex: 'action',
182+
width: '150px',
183+
scopedSlots: { customRender: 'action' }
184+
}
185+
],
186+
// 加载数据方法 必须为 Promise 对象
187+
loadData: parameter => {
188+
console.log('loadData.parameter', parameter)
189+
return getServiceList(Object.assign(parameter, this.queryParam))
190+
.then(res => {
191+
return res.result
192+
})
193+
},
194+
selectedRowKeys: [],
195+
selectedRows: [],
196+
197+
// custom table alert & rowSelection
198+
options: {
199+
alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
200+
rowSelection: {
201+
selectedRowKeys: this.selectedRowKeys,
202+
onChange: this.onSelectChange
203+
}
204+
},
205+
optionAlertShow: false
206+
}
207+
},
208+
filters: {
209+
statusFilter (type) {
210+
return statusMap[type].text
211+
},
212+
statusTypeFilter (type) {
213+
return statusMap[type].status
27214
}
28215
},
29216
created () {
30-
217+
this.tableOption()
218+
getRoleList({ t: new Date() })
31219
},
32220
methods: {
221+
tableOption () {
222+
if (!this.optionAlertShow) {
223+
this.options = {
224+
alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
225+
rowSelection: {
226+
selectedRowKeys: this.selectedRowKeys,
227+
onChange: this.onSelectChange
228+
}
229+
}
230+
this.optionAlertShow = true
231+
} else {
232+
this.options = {
233+
alert: false,
234+
rowSelection: null
235+
}
236+
this.optionAlertShow = false
237+
}
238+
},
239+
33240
handleEdit (record) {
34-
this.record = record || ''
35-
this.currentComponet = 'Edit'
36241
console.log(record)
242+
this.$refs.modal.edit(record)
37243
},
38-
handleGoBack () {
39-
this.record = ''
40-
this.currentComponet = 'List'
41-
}
42-
},
43-
watch: {
44-
'$route.path' () {
45-
this.record = ''
46-
this.currentComponet = 'List'
244+
handleSub (record) {
245+
if (record.status !== 0) {
246+
this.$message.info(`${record.no} 订阅成功`)
247+
} else {
248+
this.$message.error(`${record.no} 订阅失败,规则已关闭`)
249+
}
250+
},
251+
handleOk () {
252+
this.$refs.table.refresh()
253+
},
254+
onSelectChange (selectedRowKeys, selectedRows) {
255+
this.selectedRowKeys = selectedRowKeys
256+
this.selectedRows = selectedRows
257+
},
258+
toggleAdvanced () {
259+
this.advanced = !this.advanced
260+
},
261+
resetSearchForm () {
262+
this.queryParam = {
263+
date: moment(new Date())
264+
}
47265
}
48266
}
49267
}

0 commit comments

Comments
 (0)