修改店铺信息后, 更新其他页面上的店铺信息
This commit is contained in:
parent
23df15dfad
commit
fab2137eb4
@ -403,7 +403,7 @@ import { IShopData } from '@/api/types'
|
||||
import { ElTree } from 'element-ui/types/tree'
|
||||
import { UserModule } from '@/store/modules/user'
|
||||
import UploadCorpImage from '@/components/UploadCorpImage/index.vue'
|
||||
import { EVENT_ACTIVITY_UPDATE, EVENT_COUPON_UPDATE, EventBus } from '@/utils/event-bus'
|
||||
import { EVENT_ACTIVITY_UPDATE, EVENT_COUPON_UPDATE, EVENT_SHOP_UPDATE, EventBus } from '@/utils/event-bus'
|
||||
|
||||
@Component({
|
||||
name: 'ActivityEditor',
|
||||
@ -509,6 +509,9 @@ export default class extends Vue {
|
||||
}
|
||||
if (UserModule.level === 1) {
|
||||
await this.getRemoteDeptList()
|
||||
EventBus.$on(EVENT_SHOP_UPDATE, () => {
|
||||
this.getRemoteDeptList()
|
||||
})
|
||||
} else {
|
||||
this.postForm.shop = UserModule.department
|
||||
await this.fetchMyShop()
|
||||
@ -524,6 +527,9 @@ export default class extends Vue {
|
||||
|
||||
beforeDestory() {
|
||||
EventBus.$off(EVENT_COUPON_UPDATE)
|
||||
if (UserModule.level === 1) {
|
||||
EventBus.$off(EVENT_SHOP_UPDATE)
|
||||
}
|
||||
}
|
||||
|
||||
private async fetchData(id: string) {
|
||||
|
@ -139,7 +139,7 @@ import { parseTime } from '@/utils'
|
||||
import { getAllCategory, getAllTags } from '@/api/question'
|
||||
import { deleteActivity, getActivitys, publishActivity, IActivityData } from '@/api/activity'
|
||||
import { UserModule } from '@/store/modules/user'
|
||||
import { EVENT_ACTIVITY_UPDATE, EVENT_SHOP_PUZZLES_UPDATE, EventBus } from '@/utils/event-bus'
|
||||
import { EVENT_ACTIVITY_UPDATE, EVENT_SHOP_PUZZLES_UPDATE, EVENT_SHOP_UPDATE, EventBus } from '@/utils/event-bus'
|
||||
|
||||
@Component({
|
||||
name: 'ActivityList',
|
||||
@ -196,6 +196,9 @@ export default class extends Vue {
|
||||
async created() {
|
||||
if (UserModule.level === 1) {
|
||||
await this.getRemoteDeptList()
|
||||
EventBus.$on(EVENT_SHOP_UPDATE, () => {
|
||||
this.getRemoteDeptList()
|
||||
})
|
||||
} else {
|
||||
this.filterForm.shop = UserModule.department
|
||||
this.listQuery.shop = UserModule.department
|
||||
@ -209,6 +212,9 @@ export default class extends Vue {
|
||||
|
||||
beforeDestory() {
|
||||
EventBus.$off(EVENT_ACTIVITY_UPDATE)
|
||||
if (UserModule.level === 1) {
|
||||
EventBus.$off(EVENT_SHOP_UPDATE)
|
||||
}
|
||||
}
|
||||
|
||||
private async getList() {
|
||||
|
@ -305,6 +305,7 @@ import { cloneDeep } from 'lodash'
|
||||
import { UserModule } from '@/store/modules/user'
|
||||
import { IShopData } from '@/api/types'
|
||||
import { getShops } from '@/api/shop'
|
||||
import { EVENT_SHOP_UPDATE, EventBus } from '@/utils/event-bus'
|
||||
|
||||
declare module 'vue/types/vue' {
|
||||
interface Vue {
|
||||
@ -361,11 +362,20 @@ export default class extends Vue {
|
||||
async created() {
|
||||
if (UserModule.level === 1) {
|
||||
await this.getRemoteDeptList()
|
||||
EventBus.$on(EVENT_SHOP_UPDATE, () => {
|
||||
this.getRemoteDeptList()
|
||||
})
|
||||
} else if (UserModule.department) {
|
||||
this.shop = UserModule.department
|
||||
}
|
||||
}
|
||||
|
||||
beforeDestory() {
|
||||
if (UserModule.level === 1) {
|
||||
EventBus.$off(EVENT_SHOP_UPDATE)
|
||||
}
|
||||
}
|
||||
|
||||
private modalRules = {
|
||||
question: [{ required: true, message: '请输入题目', trigger: 'blur' },
|
||||
{ min: 2, max: 35, message: '长度在 2 到 35 个字符', trigger: 'blur' }],
|
||||
|
@ -319,7 +319,7 @@ import { UserModule } from '@/store/modules/user'
|
||||
import { defaultRewardData, IRewardData } from '@/api/activity'
|
||||
import PuzzleList from './components/PuzzleList.vue'
|
||||
import UploadCorpImage from '@/components/UploadCorpImage/index.vue'
|
||||
import { EVENT_COUPON_UPDATE, EVENT_EXAM_UPDATE, EventBus } from '@/utils/event-bus'
|
||||
import { EVENT_COUPON_UPDATE, EVENT_EXAM_UPDATE, EVENT_SHOP_UPDATE, EventBus } from '@/utils/event-bus'
|
||||
|
||||
@Component({
|
||||
name: 'ExamEditor',
|
||||
@ -407,6 +407,9 @@ export default class extends Vue {
|
||||
}
|
||||
if (UserModule.level === 1) {
|
||||
await this.getRemoteDeptList()
|
||||
EventBus.$on(EVENT_SHOP_UPDATE, () => {
|
||||
this.getRemoteDeptList()
|
||||
})
|
||||
} else {
|
||||
this.postForm.shop = UserModule.department
|
||||
await this.fetchMyShop()
|
||||
@ -422,6 +425,9 @@ export default class extends Vue {
|
||||
|
||||
beforeDestory() {
|
||||
EventBus.$off(EVENT_COUPON_UPDATE)
|
||||
if (UserModule.level === 1) {
|
||||
EventBus.$off(EVENT_SHOP_UPDATE)
|
||||
}
|
||||
}
|
||||
|
||||
private async fetchData(id: string) {
|
||||
|
@ -137,7 +137,7 @@ import { parseTime } from '@/utils'
|
||||
import { getAllCategory, getAllTags, IQuestionData } from '@/api/question'
|
||||
import { deleteExam, getExams } from '@/api/exam'
|
||||
import { UserModule } from '@/store/modules/user'
|
||||
import { EVENT_EXAM_UPDATE, EVENT_SHOP_PUZZLES_UPDATE, EventBus } from '@/utils/event-bus'
|
||||
import { EVENT_EXAM_UPDATE, EVENT_SHOP_PUZZLES_UPDATE, EVENT_SHOP_UPDATE, EventBus } from '@/utils/event-bus'
|
||||
|
||||
@Component({
|
||||
name: 'ExamList',
|
||||
@ -193,6 +193,9 @@ export default class extends Vue {
|
||||
async created() {
|
||||
if (UserModule.level === 1) {
|
||||
await this.getRemoteDeptList()
|
||||
EventBus.$on(EVENT_SHOP_UPDATE, () => {
|
||||
this.getRemoteDeptList()
|
||||
})
|
||||
} else {
|
||||
this.filterForm.shop = UserModule.department
|
||||
this.listQuery.shop = UserModule.department
|
||||
@ -206,6 +209,9 @@ export default class extends Vue {
|
||||
|
||||
beforeDestory() {
|
||||
EventBus.$off(EVENT_EXAM_UPDATE)
|
||||
if (UserModule.level === 1) {
|
||||
EventBus.$off(EVENT_SHOP_UPDATE)
|
||||
}
|
||||
}
|
||||
|
||||
private async getList() {
|
||||
|
@ -114,6 +114,7 @@ import {
|
||||
saveShopGameInfo
|
||||
} from '@/api/shop'
|
||||
import { UserModule } from '@/store/modules/user'
|
||||
import { EVENT_SHOP_UPDATE, EventBus } from '@/utils/event-bus'
|
||||
|
||||
@Component({
|
||||
name: 'GameSetting',
|
||||
@ -156,11 +157,20 @@ export default class extends Vue {
|
||||
await this.getList()
|
||||
if (UserModule.level === 1) {
|
||||
await this.getRemoteDeptList('')
|
||||
EventBus.$on(EVENT_SHOP_UPDATE, () => {
|
||||
this.getRemoteDeptList()
|
||||
})
|
||||
} else {
|
||||
this.shop = UserModule.department
|
||||
}
|
||||
}
|
||||
|
||||
beforeDestory() {
|
||||
if (UserModule.level === 1) {
|
||||
EventBus.$off(EVENT_SHOP_UPDATE)
|
||||
}
|
||||
}
|
||||
|
||||
@Watch('shop')
|
||||
private onShopChange() {
|
||||
if (this.shop) {
|
||||
@ -224,7 +234,7 @@ export default class extends Vue {
|
||||
}
|
||||
}
|
||||
|
||||
private async getRemoteDeptList(name: string) {
|
||||
private async getRemoteDeptList(name?: string) {
|
||||
if (UserModule.level > 1) {
|
||||
return
|
||||
}
|
||||
|
@ -133,7 +133,7 @@ import { getShops } from '@/api/shop'
|
||||
import { parseTime } from '@/utils'
|
||||
import { deleteCoupon, getCoupons } from '@/api/coupon'
|
||||
import { UserModule } from '@/store/modules/user'
|
||||
import { EVENT_COUPON_UPDATE, EventBus } from '@/utils/event-bus'
|
||||
import { EVENT_COUPON_UPDATE, EVENT_SHOP_UPDATE, EventBus } from '@/utils/event-bus'
|
||||
|
||||
@Component({
|
||||
name: 'CouponList',
|
||||
@ -187,6 +187,9 @@ export default class extends Vue {
|
||||
async created() {
|
||||
if (UserModule.level === 1) {
|
||||
await this.getRemoteDeptList()
|
||||
EventBus.$on(EVENT_SHOP_UPDATE, () => {
|
||||
this.getRemoteDeptList()
|
||||
})
|
||||
} else {
|
||||
this.filterForm.department = UserModule.department
|
||||
this.listQuery.shop = UserModule.department
|
||||
@ -208,6 +211,9 @@ export default class extends Vue {
|
||||
|
||||
beforeDestory() {
|
||||
EventBus.$off(EVENT_COUPON_UPDATE)
|
||||
if (UserModule.level === 1) {
|
||||
EventBus.$off(EVENT_SHOP_UPDATE)
|
||||
}
|
||||
}
|
||||
|
||||
private async handleDelete(scope: any) {
|
||||
|
@ -134,7 +134,7 @@ import Tinymce from '@/components/Tinymce/index.vue'
|
||||
import { getShops } from '@/api/shop'
|
||||
import { defaultCouponData, getCoupon, saveCoupon } from '@/api/coupon'
|
||||
import { UserModule } from '@/store/modules/user'
|
||||
import { EVENT_COUPON_UPDATE, EVENT_SHOP_PUZZLES_UPDATE, EventBus } from '@/utils/event-bus'
|
||||
import { EVENT_COUPON_UPDATE, EVENT_SHOP_PUZZLES_UPDATE, EVENT_SHOP_UPDATE, EventBus } from '@/utils/event-bus'
|
||||
|
||||
@Component({
|
||||
name: 'CouponEditor',
|
||||
@ -194,6 +194,9 @@ export default class extends Vue {
|
||||
const id = this.$route.params?.id
|
||||
if (UserModule.level === 1) {
|
||||
this.getRemoteDeptList('')
|
||||
EventBus.$on(EVENT_SHOP_UPDATE, () => {
|
||||
this.getRemoteDeptList()
|
||||
})
|
||||
} else {
|
||||
this.postForm.shop = UserModule.department
|
||||
}
|
||||
@ -203,6 +206,12 @@ export default class extends Vue {
|
||||
this.tempTagView = Object.assign({}, this.$route)
|
||||
}
|
||||
|
||||
beforeDestory() {
|
||||
if (UserModule.level === 1) {
|
||||
EventBus.$off(EVENT_SHOP_UPDATE)
|
||||
}
|
||||
}
|
||||
|
||||
@Watch('dataRange')
|
||||
private onDataRangeChange(val: Date[]) {
|
||||
console.log(`onDataRangeChange ${val}`)
|
||||
|
@ -251,12 +251,6 @@ export default class extends Vue {
|
||||
this.$refs.filterForm.resetFields()
|
||||
}
|
||||
|
||||
private async getRemoteDeptList(name: string) {
|
||||
const { data } = await getShops({ key: name })
|
||||
if (!data.records) return
|
||||
this.allDepts = data.records
|
||||
}
|
||||
|
||||
private async getRemoteTags() {
|
||||
const { data } = await getAllTags()
|
||||
console.log(data)
|
||||
|
@ -57,6 +57,7 @@ import { getAllCategory } from '@/api/question'
|
||||
import { ElTree } from 'element-ui/types/tree'
|
||||
import { IShopData } from '@/api/types'
|
||||
import { UserModule } from '@/store/modules/user'
|
||||
import { EVENT_COUPON_UPDATE, EVENT_SHOP_UPDATE, EventBus } from '@/utils/event-bus'
|
||||
|
||||
@Component({
|
||||
name: 'QuestionSetting',
|
||||
@ -92,7 +93,10 @@ export default class extends Vue {
|
||||
async created() {
|
||||
await this.getRemoteCategory()
|
||||
if (UserModule.level === 1) {
|
||||
await this.getRemoteDeptList('')
|
||||
await this.getRemoteDeptList()
|
||||
EventBus.$on(EVENT_SHOP_UPDATE, () => {
|
||||
this.getRemoteDeptList()
|
||||
})
|
||||
} else {
|
||||
this.shop = UserModule.department
|
||||
await this.fetchMyShop()
|
||||
@ -100,6 +104,12 @@ export default class extends Vue {
|
||||
this.loading = false
|
||||
}
|
||||
|
||||
beforeDestory() {
|
||||
if (UserModule.level === 1) {
|
||||
EventBus.$off(EVENT_SHOP_UPDATE)
|
||||
}
|
||||
}
|
||||
|
||||
@Watch('shop')
|
||||
private onShopChange() {
|
||||
if (this.shop && UserModule.level === 1) {
|
||||
@ -120,7 +130,7 @@ export default class extends Vue {
|
||||
}
|
||||
}
|
||||
|
||||
private async getRemoteDeptList(name: string) {
|
||||
private async getRemoteDeptList(name?: string) {
|
||||
const { data } = await getShops({ key: name })
|
||||
if (!data.records) return
|
||||
this.allDepts = data.records
|
||||
|
@ -157,7 +157,7 @@ import { IQuestionData } from '@/api/question'
|
||||
import { UserModule } from '@/store/modules/user'
|
||||
import { deleteShopQuestion, getShopCategory, getShopQuestions } from '@/api/shoppuzzle'
|
||||
import { IShopData } from '@/api/types'
|
||||
import { EVENT_SHOP_PUZZLES_UPDATE, EventBus } from '@/utils/event-bus'
|
||||
import { EVENT_SHOP_PUZZLES_UPDATE, EVENT_SHOP_UPDATE, EventBus } from '@/utils/event-bus'
|
||||
|
||||
@Component({
|
||||
name: 'ShopPuzzles',
|
||||
@ -217,6 +217,9 @@ export default class extends Vue {
|
||||
async created() {
|
||||
if (UserModule.level === 1) {
|
||||
await this.getRemoteDeptList()
|
||||
EventBus.$on(EVENT_SHOP_UPDATE, () => {
|
||||
this.getRemoteDeptList()
|
||||
})
|
||||
} else {
|
||||
this.filterForm.shop = UserModule.department
|
||||
this.listQuery.shop = UserModule.department
|
||||
@ -230,6 +233,9 @@ export default class extends Vue {
|
||||
|
||||
beforeDestory() {
|
||||
EventBus.$off(EVENT_SHOP_PUZZLES_UPDATE)
|
||||
if (UserModule.level === 1) {
|
||||
EventBus.$off(EVENT_SHOP_UPDATE)
|
||||
}
|
||||
}
|
||||
|
||||
private async getList() {
|
||||
|
@ -237,6 +237,7 @@ export default class extends Vue {
|
||||
})
|
||||
await updateShopPublish({ id: row._id, publish: !row.publish })
|
||||
row.publish = !row.publish
|
||||
EventBus.$emit(EVENT_SHOP_UPDATE, {})
|
||||
} catch (err) {
|
||||
console.log(err)
|
||||
}
|
||||
|
@ -295,6 +295,7 @@ import { IRole } from '@/views/system/role.vue'
|
||||
import { IShopData } from '@/api/types'
|
||||
import { UserModule } from '@/store/modules/user'
|
||||
import { getShops } from '@/api/shop'
|
||||
import { EVENT_SHOP_UPDATE, EventBus } from '@/utils/event-bus'
|
||||
|
||||
@Component({
|
||||
name: 'ShopAdmin',
|
||||
@ -353,9 +354,16 @@ export default class extends Vue {
|
||||
}
|
||||
|
||||
async created() {
|
||||
this.allDepts = await this.getRemoteDeptList('')
|
||||
await this.getRemoteDeptList()
|
||||
await this.getRecords()
|
||||
await this.getAllRole()
|
||||
EventBus.$on(EVENT_SHOP_UPDATE, () => {
|
||||
this.getRemoteDeptList()
|
||||
})
|
||||
}
|
||||
|
||||
beforeDestory() {
|
||||
EventBus.$off(EVENT_SHOP_UPDATE)
|
||||
}
|
||||
|
||||
private search() {
|
||||
@ -571,7 +579,7 @@ export default class extends Vue {
|
||||
const { data } = await getShops({ key: name })
|
||||
if (!data.records) return
|
||||
this.deptListOptions = data.records
|
||||
return data.records
|
||||
this.allDepts = data.records
|
||||
}
|
||||
|
||||
private formatDept(row: any) {
|
||||
|
@ -229,10 +229,8 @@
|
||||
>
|
||||
<el-select
|
||||
v-model="record.department"
|
||||
:remote-method="getRemoteDeptList"
|
||||
filterable
|
||||
default-first-option
|
||||
remote
|
||||
placeholder=""
|
||||
>
|
||||
<el-option
|
||||
@ -295,6 +293,8 @@ import {
|
||||
import { IRole } from '@/views/system/role.vue'
|
||||
import { getShops } from '@/api/shop'
|
||||
import { IShopData } from '@/api/types'
|
||||
import { EVENT_SHOP_UPDATE, EventBus } from '@/utils/event-bus'
|
||||
import { UserModule } from '@/store/modules/user'
|
||||
|
||||
@Component({
|
||||
name: 'AdminSystem',
|
||||
@ -349,9 +349,16 @@ export default class extends Vue {
|
||||
}
|
||||
|
||||
async created() {
|
||||
this.allDepts = await this.getRemoteDeptList('')
|
||||
await this.getRemoteDeptList('')
|
||||
await this.getRecords()
|
||||
await this.getAllRole()
|
||||
EventBus.$on(EVENT_SHOP_UPDATE, () => {
|
||||
this.getRemoteDeptList()
|
||||
})
|
||||
}
|
||||
|
||||
beforeDestory() {
|
||||
EventBus.$off(EVENT_SHOP_UPDATE)
|
||||
}
|
||||
|
||||
private search() {
|
||||
@ -556,11 +563,11 @@ export default class extends Vue {
|
||||
})
|
||||
}
|
||||
|
||||
private async getRemoteDeptList(name: string) {
|
||||
private async getRemoteDeptList(name?: string) {
|
||||
const { data } = await getShops({ key: name })
|
||||
if (!data.records) return
|
||||
this.deptListOptions = data.records
|
||||
return data.records
|
||||
this.allDepts = data.records
|
||||
}
|
||||
|
||||
private formatDept(row: any) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user