Skip to content

Commit e5d303a

Browse files
committed
fix: $dialog and table-list modal
1 parent e50d66d commit e5d303a

File tree

10 files changed

+235
-143
lines changed

10 files changed

+235
-143
lines changed

src/api/manage.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,11 @@ export function saveService (parameter) {
6060
data: parameter
6161
})
6262
}
63+
64+
export function saveSub (sub) {
65+
return request({
66+
url: '/sub',
67+
method: sub.id === 0 ? 'post' : 'put',
68+
data: sub
69+
})
70+
}

src/components/Table/index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@ export default {
8585
pageNo: val
8686
})
8787
})
88+
// change pagination, reset total data
89+
this.needTotalList = this.initTotalList(this.columns)
90+
this.selectedRowKeys = []
91+
this.selectedRows = []
8892
},
8993
pageNum (val) {
9094
Object.assign(this.localPagination, {
@@ -110,7 +114,6 @@ export default {
110114
pageSize: this.pageSize,
111115
showSizeChanger: this.showSizeChanger
112116
}) || false
113-
console.log('this.localPagination', this.localPagination)
114117
this.needTotalList = this.initTotalList(this.columns)
115118
this.loadData()
116119
},
@@ -149,7 +152,6 @@ export default {
149152
...filters
150153
}
151154
)
152-
console.log('parameter', parameter)
153155
const result = this.data(parameter)
154156
// 对接自己的通用数据接口需要修改下方代码中的 r.pageNo, r.totalCount, r.data
155157
// eslint-disable-next-line
@@ -178,7 +180,6 @@ export default {
178180
} catch (e) {
179181
this.localPagination = false
180182
}
181-
console.log('loadData -> this.localPagination', this.localPagination)
182183
this.localDataSource = r.data // 返回结果中的数组数据
183184
this.localLoading = false
184185
})
@@ -280,7 +281,6 @@ export default {
280281
if (k === 'rowSelection') {
281282
if (showAlert && this.rowSelection) {
282283
// 如果需要使用alert,则重新绑定 rowSelection 事件
283-
console.log('this.rowSelection', this.rowSelection)
284284
props[k] = {
285285
...this.rowSelection,
286286
selectedRows: this.selectedRows,

src/core/lazy_use.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ import Viser from 'viser-vue'
5050

5151
// ext library
5252
import VueCropper from 'vue-cropper'
53+
import Dialog from '@/components/Dialog'
5354
import MultiTab from '@/components/MultiTab'
5455
import PageLoading from '@/components/PageLoading'
5556
import PermissionHelper from '@/utils/helper/permission'
@@ -106,6 +107,7 @@ Vue.prototype.$error = Modal.error
106107
Vue.prototype.$warning = Modal.warning
107108

108109
Vue.use(Viser)
110+
Vue.use(Dialog) // this.$dialog func
109111
Vue.use(MultiTab)
110112
Vue.use(PageLoading)
111113
Vue.use(PermissionHelper)

src/locales/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ const messages = {
1717
}
1818

1919
const i18n = new VueI18n({
20+
silentTranslationWarn: true,
2021
locale: defaultLang,
2122
fallbackLocale: defaultLang,
2223
messages

src/mock/services/auth.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { builder, getBody } from '../util'
44
const username = ['admin', 'super']
55
// 强硬要求 ant.design 相同密码
66
// '21232f297a57a5a743894a0e4a801fc3',
7-
const password = ['8914de686ab28dc22f30d3d8e107ff6c'] // admin, ant.design
7+
const password = ['8914de686ab28dc22f30d3d8e107ff6c', '21232f297a57a5a743894a0e4a801fc3'] // admin, ant.design
88

99
const login = (options) => {
1010
const body = getBody(options)

src/permission.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ router.beforeEach((to, from, next) => {
2525
} else {
2626
// check login user.roles is null
2727
if (store.getters.roles.length === 0) {
28+
// request login userInfo
2829
store
2930
.dispatch('GetInfo')
3031
.then(res => {

src/views/list/BasicList.vue

Lines changed: 39 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
</div>
3030

3131
<div class="operate">
32-
<a-button type="dashed" style="width: 100%" icon="plus" @click="$refs.taskForm.add()">添加</a-button>
32+
<a-button type="dashed" style="width: 100%" icon="plus" @click="add">添加</a-button>
3333
</div>
3434

3535
<a-list size="large" :pagination="{showSizeChanger: true, showQuickJumper: true, pageSize: 5, total: 50}">
@@ -70,6 +70,7 @@
7070
</template>
7171

7272
<script>
73+
// 演示如何使用 this.$dialog 封装 modal 组件
7374
import TaskForm from './modules/TaskForm'
7475
import Info from './components/Info'
7576
@@ -139,15 +140,48 @@ export default {
139140
}
140141
},
141142
methods: {
143+
add () {
144+
this.$dialog(TaskForm,
145+
// component props
146+
{
147+
record: {},
148+
on: {
149+
ok () {
150+
console.log('ok 回调')
151+
},
152+
cancel () {
153+
console.log('cancel 回调')
154+
},
155+
close () {
156+
console.log('modal close 回调')
157+
}
158+
}
159+
},
160+
// modal props
161+
{
162+
title: '新增',
163+
width: 700,
164+
centered: true,
165+
maskClosable: false
166+
})
167+
},
142168
edit (record) {
143169
console.log('record', record)
144-
// mockdata
145-
record.taskName = '测试'
146-
// mockend
147170
this.$dialog(TaskForm,
148171
// component props
149172
{
150-
record
173+
record,
174+
on: {
175+
ok () {
176+
console.log('ok 回调')
177+
},
178+
cancel () {
179+
console.log('cancel 回调')
180+
},
181+
close () {
182+
console.log('modal close 回调')
183+
}
184+
}
151185
},
152186
// modal props
153187
{

0 commit comments

Comments
 (0)