完善题库编辑的权限设置

This commit is contained in:
zhl 2021-05-08 15:52:57 +08:00
parent 3ee310513b
commit 35220eb0f6
3 changed files with 29 additions and 22 deletions

View File

@ -22,6 +22,12 @@ export const getShop = (id: string, params: any) =>
params
})
export const getMyShop = () =>
request({
url: '/myshop',
method: 'get'
})
export const saveShop = (data: any) =>
request({
url: '/shop/save',

View File

@ -72,7 +72,6 @@ import { Component, Vue, Watch } from 'vue-property-decorator'
import { getGames, IGameData } from '@/api/game'
import Sticky from '@/components/Sticky/index.vue'
import { getShopGameInfo, getShops, saveShopGameInfo } from '@/api/shop'
import { checkPermission } from '@/utils/permission'
import { UserModule } from '@/store/modules/user'
@Component({

View File

@ -7,6 +7,7 @@
name="shop"
required
class="w100"
v-if="userLevel === 1"
>
<el-option
v-for="item in allDepts"
@ -50,12 +51,12 @@
<script lang="ts">
import { Component, Vue, Watch } from 'vue-property-decorator'
import { getGames, IGameData } from '@/api/game'
import Sticky from '@/components/Sticky/index.vue'
import { getShops, updateShopQtypes } from '@/api/shop'
import { getMyShop, getShops, updateShopQtypes } from '@/api/shop'
import { getAllCategory } from '@/api/question'
import { ElTree } from 'element-ui/types/tree'
import { IShopData } from '@/api/types'
import { UserModule } from '@/store/modules/user'
@Component({
name: 'QuestionSetting',
@ -69,17 +70,9 @@ import { IShopData } from '@/api/types'
}
})
export default class extends Vue {
private total = 0
private list: IGameData[] = []
private loading = true
private shop = ''
private allDepts: IShopData[] = []
private listQuery = {
page: 1,
limit: 20,
key: '',
hasVersion: 1
}
private typeSelected: string[] = []
private typeOptions: {id: string, label: string, children?: any[]}[] = []
@ -92,15 +85,24 @@ export default class extends Vue {
tree: ElTree<any, any>
}
get userLevel() {
return UserModule.level
}
async created() {
await this.getList()
await this.getRemoteDeptList('')
await this.getRemoteCategory()
if (UserModule.level === 1) {
await this.getRemoteDeptList('')
} else {
this.shop = UserModule.department
await this.fetchMyShop()
}
this.loading = false
}
@Watch('shop')
private onShopChange() {
if (this.shop) {
if (this.shop && UserModule.level === 1) {
let currentShop
for (const p of this.allDepts) {
if (p._id === this.shop) {
@ -113,24 +115,24 @@ export default class extends Vue {
} else {
this.typeSelected = []
}
console.log(this.typeSelected)
this.$refs.tree.setCheckedKeys(this.typeSelected)
}
}
private async getList() {
this.loading = true
const { data } = await getGames(this.listQuery)
this.loading = false
this.list = data.records
this.total = data.total
}
private async getRemoteDeptList(name: string) {
const { data } = await getShops({ key: name })
if (!data.records) return
this.allDepts = data.records
}
private async fetchMyShop() {
const { data } = await getMyShop()
this.typeSelected = data.qtypes
console.log(this.typeSelected)
this.$refs.tree.setCheckedKeys(this.typeSelected)
}
private async onCancel() {
try {
await this.$confirm('确认不保存当前信息?', 'Warning', {