完善题库编辑的权限设置
This commit is contained in:
parent
3ee310513b
commit
35220eb0f6
@ -22,6 +22,12 @@ export const getShop = (id: string, params: any) =>
|
|||||||
params
|
params
|
||||||
})
|
})
|
||||||
|
|
||||||
|
export const getMyShop = () =>
|
||||||
|
request({
|
||||||
|
url: '/myshop',
|
||||||
|
method: 'get'
|
||||||
|
})
|
||||||
|
|
||||||
export const saveShop = (data: any) =>
|
export const saveShop = (data: any) =>
|
||||||
request({
|
request({
|
||||||
url: '/shop/save',
|
url: '/shop/save',
|
||||||
|
@ -72,7 +72,6 @@ import { Component, Vue, Watch } from 'vue-property-decorator'
|
|||||||
import { getGames, IGameData } from '@/api/game'
|
import { getGames, IGameData } from '@/api/game'
|
||||||
import Sticky from '@/components/Sticky/index.vue'
|
import Sticky from '@/components/Sticky/index.vue'
|
||||||
import { getShopGameInfo, getShops, saveShopGameInfo } from '@/api/shop'
|
import { getShopGameInfo, getShops, saveShopGameInfo } from '@/api/shop'
|
||||||
import { checkPermission } from '@/utils/permission'
|
|
||||||
import { UserModule } from '@/store/modules/user'
|
import { UserModule } from '@/store/modules/user'
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
name="shop"
|
name="shop"
|
||||||
required
|
required
|
||||||
class="w100"
|
class="w100"
|
||||||
|
v-if="userLevel === 1"
|
||||||
>
|
>
|
||||||
<el-option
|
<el-option
|
||||||
v-for="item in allDepts"
|
v-for="item in allDepts"
|
||||||
@ -50,12 +51,12 @@
|
|||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { Component, Vue, Watch } from 'vue-property-decorator'
|
import { Component, Vue, Watch } from 'vue-property-decorator'
|
||||||
import { getGames, IGameData } from '@/api/game'
|
|
||||||
import Sticky from '@/components/Sticky/index.vue'
|
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 { getAllCategory } from '@/api/question'
|
||||||
import { ElTree } from 'element-ui/types/tree'
|
import { ElTree } from 'element-ui/types/tree'
|
||||||
import { IShopData } from '@/api/types'
|
import { IShopData } from '@/api/types'
|
||||||
|
import { UserModule } from '@/store/modules/user'
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
name: 'QuestionSetting',
|
name: 'QuestionSetting',
|
||||||
@ -69,17 +70,9 @@ import { IShopData } from '@/api/types'
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
export default class extends Vue {
|
export default class extends Vue {
|
||||||
private total = 0
|
|
||||||
private list: IGameData[] = []
|
|
||||||
private loading = true
|
private loading = true
|
||||||
private shop = ''
|
private shop = ''
|
||||||
private allDepts: IShopData[] = []
|
private allDepts: IShopData[] = []
|
||||||
private listQuery = {
|
|
||||||
page: 1,
|
|
||||||
limit: 20,
|
|
||||||
key: '',
|
|
||||||
hasVersion: 1
|
|
||||||
}
|
|
||||||
|
|
||||||
private typeSelected: string[] = []
|
private typeSelected: string[] = []
|
||||||
private typeOptions: {id: string, label: string, children?: any[]}[] = []
|
private typeOptions: {id: string, label: string, children?: any[]}[] = []
|
||||||
@ -92,15 +85,24 @@ export default class extends Vue {
|
|||||||
tree: ElTree<any, any>
|
tree: ElTree<any, any>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get userLevel() {
|
||||||
|
return UserModule.level
|
||||||
|
}
|
||||||
|
|
||||||
async created() {
|
async created() {
|
||||||
await this.getList()
|
|
||||||
await this.getRemoteDeptList('')
|
|
||||||
await this.getRemoteCategory()
|
await this.getRemoteCategory()
|
||||||
|
if (UserModule.level === 1) {
|
||||||
|
await this.getRemoteDeptList('')
|
||||||
|
} else {
|
||||||
|
this.shop = UserModule.department
|
||||||
|
await this.fetchMyShop()
|
||||||
|
}
|
||||||
|
this.loading = false
|
||||||
}
|
}
|
||||||
|
|
||||||
@Watch('shop')
|
@Watch('shop')
|
||||||
private onShopChange() {
|
private onShopChange() {
|
||||||
if (this.shop) {
|
if (this.shop && UserModule.level === 1) {
|
||||||
let currentShop
|
let currentShop
|
||||||
for (const p of this.allDepts) {
|
for (const p of this.allDepts) {
|
||||||
if (p._id === this.shop) {
|
if (p._id === this.shop) {
|
||||||
@ -113,24 +115,24 @@ export default class extends Vue {
|
|||||||
} else {
|
} else {
|
||||||
this.typeSelected = []
|
this.typeSelected = []
|
||||||
}
|
}
|
||||||
|
console.log(this.typeSelected)
|
||||||
this.$refs.tree.setCheckedKeys(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) {
|
private async getRemoteDeptList(name: string) {
|
||||||
const { data } = await getShops({ key: name })
|
const { data } = await getShops({ key: name })
|
||||||
if (!data.records) return
|
if (!data.records) return
|
||||||
this.allDepts = data.records
|
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() {
|
private async onCancel() {
|
||||||
try {
|
try {
|
||||||
await this.$confirm('确认不保存当前信息?', 'Warning', {
|
await this.$confirm('确认不保存当前信息?', 'Warning', {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user