{
- let reg = new RegExp(this.filterForm.key)
+ const reg = new RegExp(this.filterForm.key)
return (reg.test(user.showname)) || (reg.test(user.username))
})
}
@@ -306,9 +313,8 @@ export default class extends Vue {
return result
}
- private resetForm(formName: string) {
- const ref: any = this.$refs[formName]
- ref.resetFields()
+ private resetFilterForm() {
+ this.$refs.filterForm.resetFields()
}
// pagination
@@ -326,8 +332,8 @@ export default class extends Vue {
// 满足过滤条件 -> 分页
const data = this.filterData()
this.tableData = data.slice(
- (this.currentPage - 1) * this.pageSize,
- this.currentPage * this.pageSize
+ (this.currentPage - 1) * this.pageSize,
+ this.currentPage * this.pageSize
)
}
@@ -345,7 +351,7 @@ export default class extends Vue {
this.roleList = data
}
- private formSex(row: number, column: number, cellValue: string, index: number) {
+ private formSex(row: number, column: number, cellValue: string) {
switch (cellValue) {
case '0':
return '未指定'
@@ -355,12 +361,12 @@ export default class extends Vue {
return '女'
default:
return '未指定'
-
}
}
- formatRole(val: string) {
- let data = this.roleList.find(o => {
- return o.key === val
+
+ private formatRole(val: string) {
+ const data = this.roleList.find(o => {
+ return o.key === val
})
return data?.name || ''
}
@@ -382,32 +388,31 @@ export default class extends Vue {
private handleDelete(scope: any) {
const { $index, row } = scope
this.$confirm('Confirm to remove the record?', 'Warning', {
- confirmButtonText: 'Confirm',
- cancelButtonText: 'Cancel',
- type: 'warning'
- })
- .then(async () => {
- await deleteAdmin(row.id)
- this.adminList.splice($index, 1)
- this.$message({
- type: 'success',
- message: 'Deleted!'
- })
- })
- .catch(err => {
- console.log(err)
+ confirmButtonText: 'Confirm',
+ cancelButtonText: 'Cancel',
+ type: 'warning'
+ })
+ .then(async() => {
+ await deleteAdmin(row.id)
+ this.adminList.splice($index, 1)
+ this.$message({
+ type: 'success',
+ message: 'Deleted!'
})
+ })
+ .catch(err => {
+ console.log(err)
+ })
}
+
private closeModal() {
this.dialogVisible = false
- let modalForm: any = this.$refs['modalForm']
- modalForm.clearValidate()
+ this.$refs.modalForm.clearValidate()
}
- // TODO: 验证数据完整性
+
private async confirmRole() {
const isEdit = this.dialogType === 'edit'
- const modalForm: any = this.$refs['modalForm']
- modalForm.validate(async (valid: boolean) => {
+ this.$refs.modalForm.validate(async(valid: boolean) => {
if (!valid) {
this.$message.error('请按要求填写表单')
return false
@@ -431,13 +436,12 @@ export default class extends Vue {
title: 'Success',
dangerouslyUseHTMLString: true,
message: `
- Admin Username: ${ username }
- Admin Showname: ${ showname }
+ Admin Username: ${username}
+ Admin Showname: ${showname}
`,
type: 'success'
})
})
-
}
}