diff --git a/src/views/shop/shop_admin.vue b/src/views/shop/shop_admin.vue
index 44f8b43..a8c551b 100644
--- a/src/views/shop/shop_admin.vue
+++ b/src/views/shop/shop_admin.vue
@@ -20,31 +20,15 @@
/>
-
-
- 所有
- 未指定
-
-
-
查询
重置
{{$t('admin.addAdmin')}}
@@ -54,21 +38,26 @@
:data="tableData"
style="width: 100%;margin-top:30px;"
border
+ :row-class-name="tableRowClassName"
>
- {{row.username}}
+ {{row.showname}}({{row.username}})
- {{row.showname}}
+ {{ formStatus(row.locked) }}
-
+
{{ formatRole(item) }}
-
-
-
{{$t('permission.delete')}}
+
+
+ {{scope.row.locked? '解锁' : '锁定'}}
+
@@ -183,15 +174,15 @@
/>
-
- 未指定
- 男
- 女
+
+ 未指定
+ 男
+ 女
-
-
+
-
-
-
-
+
+
+ 店铺
+
-
+
+
+
+
import { cloneDeep } from 'lodash'
import { Component, Vue } from 'vue-property-decorator'
+import UploadImage from '@/components/UploadImage/index.vue'
import { getRoles } from '@/api/roles'
import {
+ changeLocker,
defaultAdmin,
deleteAdmin,
getUsers,
@@ -261,12 +245,13 @@ import {
saveAdmin
} from '@/api/admins'
import { IRole } from '@/views/system/role.vue'
-import { getShops } from '@/api/shop'
import { IShopData } from '@/api/types'
+import { UserModule } from '@/store/modules/user'
@Component({
name: 'ShopAdmin',
components: {
+ UploadImage
}
})
export default class extends Vue {
@@ -316,7 +301,6 @@ export default class extends Vue {
}
async created() {
- this.allDepts = await this.getRemoteDeptList('')
await this.getRecords()
await this.getAllRole()
}
@@ -340,7 +324,11 @@ export default class extends Vue {
})
}
if (this.filterForm.department) {
- if (this.filterForm.department === '未指定') {
+ if (this.filterForm.department === '系统帐号') {
+ result = result.filter(user => {
+ return user.level === 1
+ })
+ } else if (this.filterForm.department === '未指定') {
result = result.filter(user => {
return !user.department
})
@@ -376,11 +364,15 @@ export default class extends Vue {
(this.currentPage - 1) * this.pageSize,
this.currentPage * this.pageSize
)
+ if (this.tableData.length === 0 && this.currentPage > 1) {
+ this.currentPage -= 1
+ this.sliceData()
+ }
}
private async getRecords() {
this.isLoad = true
- const { data } = await getUsers({ /* Your params here */ })
+ const { data } = await getUsers({ dept: UserModule.department })
this.adminList = data
this.dataCount = data.length
this.sliceData()
@@ -388,7 +380,7 @@ export default class extends Vue {
}
private async getAllRole() {
- const { data } = await getRoles({ /* Your params here */ })
+ const { data } = await getRoles({ level: UserModule.level })
this.roleList = data
}
@@ -405,6 +397,10 @@ export default class extends Vue {
}
}
+ private formStatus(cellValue: boolean) {
+ return cellValue ? '已锁定' : '正常'
+ }
+
private formatRole(val: string) {
const data = this.roleList.find(o => {
return o.key === val
@@ -426,24 +422,50 @@ export default class extends Vue {
this.record = cloneDeep(scope.row)
}
- private handleDelete(scope: any) {
+ private async 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!'
- })
+ console.log($index, row)
+ try {
+ await this.$confirm('确定删除当前帐号?', 'Warning', {
+ confirmButtonText: '确定',
+ cancelButtonText: '取消',
+ type: 'warning'
})
- .catch(err => {
- console.log(err)
+ await deleteAdmin(row.id)
+ const index = this.adminList.indexOf(row)
+ this.adminList.splice(index, 1)
+ this.sliceData()
+ this.$message({
+ type: 'success',
+ message: 'Deleted!'
})
+ } catch (err) {
+ console.log(err)
+ }
+ }
+
+ private async handleLock(scope: any) {
+ const { row } = scope
+ try {
+ let txt = '确定锁定当前帐号?'
+ if (row.locked) {
+ txt = '确定解锁当前帐号?'
+ }
+ await this.$confirm(txt, 'Warning', {
+ confirmButtonText: '确定',
+ cancelButtonText: '取消',
+ type: 'warning'
+ })
+ await changeLocker(row.id, !row.locked)
+ row.locked = !row.locked
+ this.sliceData()
+ this.$message({
+ type: 'success',
+ message: 'Deleted!'
+ })
+ } catch (err) {
+ console.log(err)
+ }
}
private closeModal() {
@@ -485,22 +507,31 @@ export default class extends Vue {
})
}
- private async getRemoteDeptList(name: string) {
- const { data } = await getShops({ key: name })
- if (!data.records) return
- this.deptListOptions = data.records
- return data.records
- }
-
- private formatDept(row: number, column: number, cellValue: string) {
+ private formatDept(row: any) {
+ if (row.level === 1) {
+ return '系统帐号'
+ }
let result = '未指定'
for (const dep of this.allDepts) {
- if (dep._id === cellValue) {
+ if (dep._id === row.department) {
result = dep.name
break
}
}
return result
}
+
+ private tableRowClassName({ row }: {row: any}) {
+ if (row.level === 1) {
+ return 'shop-row'
+ }
+ return ''
+ }
}
+
+