diff --git a/src/api/shop.ts b/src/api/shop.ts index b911fed..148998b 100644 --- a/src/api/shop.ts +++ b/src/api/shop.ts @@ -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', diff --git a/src/views/game/game_setting.vue b/src/views/game/game_setting.vue index 855382b..0cec5f4 100644 --- a/src/views/game/game_setting.vue +++ b/src/views/game/game_setting.vue @@ -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({ diff --git a/src/views/question/setting.vue b/src/views/question/setting.vue index 5dce367..00e86be 100644 --- a/src/views/question/setting.vue +++ b/src/views/question/setting.vue @@ -7,6 +7,7 @@ name="shop" required class="w100" + v-if="userLevel === 1" > 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 } + 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', {