增加挑战对自定义题库的自持

This commit is contained in:
zhl 2021-05-31 20:47:34 +08:00
parent c9604e7130
commit 5e7a24af26
5 changed files with 62 additions and 12 deletions

View File

@ -19,6 +19,7 @@ export interface IExamData {
icon?: string
banner?: string
qtypes: string[]
shopCates: string[]
qcount: number
timeone: number
beginTime: number
@ -40,6 +41,7 @@ export const defaultExamData: IExamData = {
shop: '',
source: 0,
rewardInfo: [],
shopCates: [],
questions: []
}

View File

@ -137,9 +137,9 @@ import Pagination from '@/components/Pagination/index.vue'
import { getShops } from '@/api/shop'
import { parseTime } from '@/utils'
import { getAllCategory, getAllTags } from '@/api/question'
import { deleteActivity, getActivitys, publishActivity, IActivityData } from '@/api/activity'
import { deleteActivity, getActivitys, IActivityData, publishActivity } from '@/api/activity'
import { UserModule } from '@/store/modules/user'
import { EVENT_ACTIVITY_UPDATE, EVENT_SHOP_PUZZLES_UPDATE, EVENT_SHOP_UPDATE, EventBus } from '@/utils/event-bus'
import { EVENT_ACTIVITY_UPDATE, EVENT_SHOP_UPDATE, EventBus } from '@/utils/event-bus'
@Component({
name: 'ActivityList',

View File

@ -142,6 +142,24 @@
>
<el-option :value="0" label="系统题库">系统题库</el-option>
<el-option :value="1" label="自定义题库">自定义题库</el-option>
<el-option :value="2" :label="$t('main.shop') + '题库'">{{$t('main.shop')}}题库</el-option>
</el-select>
</el-form-item>
<el-form-item label="店铺分类" v-show="postForm.source === 2" prop="shopCates">
<el-select
v-model="postForm.shopCates"
placeholder="选择"
name="typeSelect"
required
class="w100"
multiple
>
<el-option
v-for="item in shopCates"
:key="item"
:label="item"
:value="item"
/>
</el-select>
</el-form-item>
<el-form-item
@ -320,6 +338,7 @@ 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, EVENT_SHOP_UPDATE, EventBus } from '@/utils/event-bus'
import { getShopCategory } from '@/api/shoppuzzle'
@Component({
name: 'ExamEditor',
@ -356,6 +375,7 @@ export default class extends Vue {
private activeName = 'first'
private dataRange: Date[] = []
private shopCates: string[] = []
private postForm = Object.assign({}, defaultExamData)
private loading = false
@ -413,6 +433,7 @@ export default class extends Vue {
} else {
this.postForm.shop = UserModule.department
await this.fetchMyShop()
await this.getRemoteShopCategory()
}
this.tempTagView = Object.assign({}, this.$route)
@ -523,6 +544,7 @@ export default class extends Vue {
private onShopChange() {
if (this.postForm.shop) {
this.getCouponList(this.postForm.shop)
this.getRemoteShopCategory()
}
if (this.postForm.qtypes?.length > 0) {
@ -671,6 +693,15 @@ export default class extends Vue {
this.postForm.banner = imgUrl
this.$forceUpdate()
}
private async getRemoteShopCategory() {
try {
const { data } = await getShopCategory(this.postForm.shop)
this.shopCates = data
this.$forceUpdate()
} catch (err) {
}
}
}
</script>

View File

@ -138,6 +138,7 @@ 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, EVENT_SHOP_UPDATE, EventBus } from '@/utils/event-bus'
import i18n from '@/lang'
@Component({
name: 'ExamList',
@ -298,8 +299,15 @@ export default class extends Vue {
return cellValue ? '是' : '否'
}
private formatSource(row: number, column: number, cellValue: boolean) {
return cellValue ? '自定义' : '系统'
private formatSource(row: number, column: number, cellValue: number) {
switch (cellValue) {
case 0:
return '系统题库'
case 1:
return '自定义'
case 2:
return i18n.tc('main.shop') + '题库'
}
}
}
</script>

View File

@ -107,7 +107,6 @@
allow-create
default-first-option
style="width: 50%"
@change="tagChange"
placeholder="请选择">
<el-option
v-for="item in tagOptions"
@ -159,7 +158,7 @@ import Sticky from '@/components/Sticky/index.vue'
import Tinymce from '@/components/Tinymce/index.vue'
import UploadImage from '@/components/UploadImage/index.vue'
import { defaultQuestionData } from '@/api/question'
import { deleteShopQuestion, getShopQuestion, saveShopQuestion } from '@/api/shoppuzzle'
import { deleteShopQuestion, getShopCategory, getShopQuestion, saveShopQuestion } from '@/api/shoppuzzle'
import { EVENT_SHOP_PUZZLES_UPDATE, EventBus } from '@/utils/event-bus'
@Component({
@ -220,6 +219,7 @@ export default class extends Vue {
this.fetchData(shop, id)
}
this.tempTagView = Object.assign({}, this.$route)
this.getRemoteCategory()
}
private async fetchData(shop: string, id: string) {
@ -257,12 +257,12 @@ export default class extends Vue {
private async tagChange(tags: string[]) {
console.log('tagchange: ', tags)
for (const tag of tags) {
if (!this.tagSet.has(tag)) {
this.tagSet.add(tag)
this.tagOptions.push(tag)
}
}
// for (const tag of tags) {
// if (!this.tagSet.has(tag)) {
// this.tagSet.add(tag)
// this.tagOptions.push(tag)
// }
// }
}
private async submitForm() {
@ -312,6 +312,15 @@ export default class extends Vue {
}
}
private async getRemoteCategory() {
try {
const { data } = await getShopCategory(this.postForm.shop)
this.tagOptions = data
this.$forceUpdate()
} catch (err) {
}
}
private async onCancel() {
try {
await this.$confirm('确认不保存当前记录?', 'Warning', {