Commit fbba72d4 by crushh

update: 编辑

parent 148c1eff
......@@ -3,7 +3,7 @@
<dm-sub-title type="line">基本信息</dm-sub-title>
<div class="mt20">
<el-form-item label="游戏名称" prop="gameName"> <el-input maxlength="10" class="w382" @change="handleNameChange" v-model.trim="baseForm.gameName" show-word-limit :disabled="isDisabled" placeholder="请输入游戏名称" /> </el-form-item>
<el-form-item label="游戏时间" prop="gameTime"><el-date-picker class="w382" v-model="baseForm.gameTime" :picker-options="pickerOptions" value-format="yyyy-MM-dd" @change="refresh" type="daterange" range-separator="~" start-placeholder="开始日期" end-placeholder="结束日期"> </el-date-picker></el-form-item>
<el-form-item label="游戏时间" prop="gameTime"><el-date-picker class="w382" v-model="baseForm.gameTime" :picker-options="pickerOptions" value-format="timestamp" @change="refresh" type="daterange" range-separator="~" start-placeholder="开始日期" end-placeholder="结束日期"> </el-date-picker></el-form-item>
<el-form-item label="游戏说明" prop="gameRule"> <el-input maxlength="500" class="w382" v-model.trim="baseForm.gameRule" show-word-limit :disabled="isDisabled" :autosize="{ minRows: 4 }" type="textarea" /> </el-form-item>
</div>
<dm-sub-title type="line">展示信息配置</dm-sub-title>
......@@ -182,7 +182,6 @@ export default {
},
watch: {
templateArr(val) {
console.log(val);
this.templateData = val;
const data = val[0];
......@@ -194,34 +193,31 @@ export default {
},
echoData(val) {
console.log(val);
if (Object.keys(val).length) {
let { gameExt } = val;
this.baseForm = Object.assign(this.baseForm, val);
this.handleTemplateArr(Object.values(gameExt), true);
this.adsImageUrl = { imgUrl: this.baseForm.adsImageUrl, code: this.baseForm.adsImageUrl };
console.log(this.adsImageUrl);
const currentTemp = this.templateData.filter(item => item.templateId == this.baseForm.templateId)[0];
currentTemp.gameTemplateMaterialList.forEach(item => {
if (item.materialKey == 'backMusicUrl') {
this.backMusicOptions.push(item);
}
});
console.log(this.baseForm);
this.$emit('change', this.baseForm);
}
let { gameExt } = val;
this.baseForm = Object.assign(this.baseForm, val);
this.handleTemplateArr(Object.values(gameExt), true);
this.adsImageUrl = { imgUrl: this.baseForm.adsImageUrl, code: this.baseForm.adsImageUrl };
const currentTemp = this.templateData.filter(item => item.templateId == this.baseForm.templateId)[0];
console.log(currentTemp);
currentTemp.gameTemplateMaterialList.forEach(item => {
if (item.materialKey == 'backMusicUrl') {
this.backMusicOptions.push(item);
}
});
this.selectLink.linkData = this.baseForm.mpUrlView ? JSON.parse(this.baseForm.mpUrlView) : {};
this.$emit('change', this.baseForm);
}
},
methods: {
handleTemplateChange(val) {
console.log(val);
this.baseForm.templateId = val;
const data = this.templateArr.filter(item => item.templateId == val)[0].gameTemplateMaterialList;
this.customMusicOptions = [];
this.backMusicOptions = [];
this.handleTemplateArr(data);
this.$emit('change', this.baseForm);
},
beforeAvatarUpload(file, key, size1 = 1) {
console.log(file);
console.log(size1);
const arr = ['image/gif', 'image/jpeg', 'image/png'];
const limit = file.size / 1024 / 1024 < 2;
if (!arr.includes(file.type)) {
......@@ -247,7 +243,6 @@ export default {
this.baseForm[key] = data.result.qcloudImageUrl;
}
this.baseForm = Object.assign({}, this.baseForm);
console.log(this.baseForm);
this.$message({
type: 'success',
message: '上传成功'
......@@ -264,10 +259,8 @@ export default {
return true;
},
handleTemplateArr(data, echo) {
console.log(data);
this.gameExt = data;
data.forEach(item => {
console.log(item.materialKey);
if (item.materialSize) {
const { width, height, size } = JSON.parse(item.materialSize);
this.baseForm[item.materialKey + 'Size0'] = width + '*' + height + 'px';
......@@ -313,12 +306,10 @@ export default {
// this.baseForm['shareReport'] = data.materialMap['shareReport'][0].materialValue;
// }
});
console.log(this.baseForm);
},
handleListen() {
this.isPlay = !this.isPlay;
console.log(this.isPlay);
this.backMusicOptions.forEach(item => {
if (item.materialValue == this.baseForm.backMusicUrlObj.materialValue) {
music.src = this.baseForm.backMusicUrlObj.materialValue;
......@@ -331,7 +322,6 @@ export default {
this.baseForm.backMusicUrlObj = this.backMusicOptions[0];
},
setAudioList(obj) {
console.log(obj);
const { name, url } = obj;
this.customMusicOptions = [
{
......@@ -344,7 +334,6 @@ export default {
this.baseForm.backMusicUrlObj = this.customMusicOptions[0];
},
handleAdsChange(obj) {
console.log(obj);
this.baseForm.adsImageUrl = obj.imgUrl;
this.$emit('change', this.baseForm);
},
......@@ -355,12 +344,11 @@ export default {
},
// 保存链接小工具返回的链接数据
onSaveLink(linkData) {
console.log(linkData);
this.selectLink.linkData = linkData;
this.baseForm.mpUrlView = JSON.stringify(linkData);
this.baseForm.adsLinkUrl = linkData.url;
},
handleNameChange(val) {
console.log(val);
this.$emit('change', this.baseForm);
},
submit() {
......@@ -379,7 +367,6 @@ export default {
obj.backMusicUrl = data.backMusicUrlObj;
data.gameExt = obj;
data.gameExt.prizeStyleJson.materialValue = JSON.stringify(data.gameExt.prizeStyleJson.materialValue);
console.log(data);
this.$emit('nextStep', data);
} else {
this.scrollToError(this);
......
......@@ -34,8 +34,8 @@
</dm-steps>
<div class="formContent">
<baseConfig :templateArr="templateData" :echoData="baseForm" v-show="active == 0" @change="handleBaseConfigChange" @nextStep="data => nextStep(1, data)" />
<prizeConfig :prizeMax="prizeMax" :prizeMin="prizeMin" v-show="active == 1" @nextStep="data => nextStep(2, data)" />
<ruleConfig :shareCard="shareCard" :shareReport="shareReport" v-show="active == 2" @nextStep="data => submit(3, data)" :btnLoading="btnLoading" />
<prizeConfig :prizeMax="prizeMax" :echoData="prizeForm" :prizeMin="prizeMin" v-show="active == 1" @nextStep="data => nextStep(2, data)" @prevStep="step => (active = step)" />
<ruleConfig :shareCard="shareCard" :shareReport="shareReport" :echoData="ruleForm" v-show="active == 2" @nextStep="data => submit(3, data)" @prevStep="step => (active = step)" :btnLoading="btnLoading" />
</div>
</div>
</div>
......@@ -70,7 +70,10 @@ export default {
isEdit: this.$route.meta.type === 'edit',
isAdd: this.$route.meta.type === 'add',
isCopy: this.$route.meta.type === 'copy',
baseForm: {}
baseForm: {},
prizeForm: {},
ruleForm: {},
gameId: ''
};
},
computed: {
......@@ -128,13 +131,17 @@ export default {
gameRule,
startDate,
endDate,
gameName
gameName,
memberWeightView,
creatorId,
gameId
} = result;
const { winChance, filterJson, memberDesc, memberType, playConditionFlag, playTimes, shareFlag, shareImageUrl, shareRuleDesc } = gameRuleInfo;
this.gameId = gameId;
const { winChance, filterJson, filterJsonView, memberDesc, memberType, playConditionFlag, playTimes, shareFlag, shareImageUrl, shareRuleDesc } = gameRuleInfo;
gameRuleConditionList.forEach(item => {
item.conditionJson = JSON.parse(item.conditionJson);
});
this.ruleForm = { filterJson, gameRuleConditionList, memberDesc, memberType, playConditionFlag, playTimes, shareFlag, shareImageUrl, shareRuleDesc };
this.ruleForm = { filterJson, gameRuleConditionList, memberDesc, memberType, playConditionFlag, playTimes, shareFlag, shareImageUrl, shareRuleDesc, memberWeightView, creatorId, filterJsonView };
this.prizeForm = { winChance, prizeNoticeStock, gamePrizeList, prizeNoticeFlag };
this.baseForm = { adsFlag, backMusicFlag, bulletFlag, templateId, gameTime: [startDate, endDate], gameName, gameRule, gameExt };
});
......@@ -182,14 +189,14 @@ export default {
nextStep(step, data) {
this.active = step;
console.log(data);
this.submitData = { ...data, ...this.submitData };
this.submitData = { ...this.submitData, ...data };
},
submit(step, data) {
this.submitData = { ...data, ...this.submitData };
this.submitData = { ...this.submitData, ...data };
console.log(this.submitData);
this.submitData = JSON.parse(JSON.stringify(this.submitData));
const { winChance, filterJson, memberDesc, memberType, playConditionFlag, playTimes, shareFlag, shareImageUrl, gameRuleConditionList, gameName, gamePrizeList, prizeNoticeStock, prizeNoticeFlag, adsFlag, bulletFlag, backMusicFlag, templateId, gameRule, gameTime, gameExt } = this.submitData;
const gameRuleInfo = { winChance, filterJson, memberDesc, memberType, playConditionFlag, playTimes, shareFlag, shareImageUrl, shareRuleDesc: gameName };
const { winChance, filterJson, filterJsonView, memberDesc, memberType, playConditionFlag, playTimes, shareFlag, shareImageUrl, gameRuleConditionList, gameName, gamePrizeList, prizeNoticeStock, prizeNoticeFlag, adsFlag, bulletFlag, backMusicFlag, templateId, gameRule, gameTime, gameExt } = this.submitData;
const gameRuleInfo = { winChance, filterJson, filterJsonView, memberDesc, memberType, playConditionFlag, playTimes, shareFlag, shareImageUrl, shareRuleDesc: gameName };
gameRuleConditionList.forEach(item => {
delete item.index;
item.conditionJson = JSON.stringify(item.conditionJson);
......@@ -212,6 +219,9 @@ export default {
gameName
};
console.log(submitData);
if (!this.isAdd) {
submitData.gameId = this.gameId;
}
this.btnLoading = true;
initActivity(submitData)
.then(res => {
......
......@@ -78,11 +78,11 @@
</el-form-item>
</template>
</el-table-column>
<el-table-column min-width="118px" prop="optNum">
<el-table-column min-width="118px" prop="prizeStock">
<template slot="header"> <span class="needCell">奖品数量</span> </template>
<template slot-scope="{ row, $index }">
<div v-if="row.prizeType == 1 || row.prizeType == 2">
<el-form-item :prop="'gamePrizeList.' + $index + '.' + 'optNum'" :rules="rules.optNum" label-width="0"> <el-input class="w80" v-model.number="row.optNum" @change="calculateRate" /></el-form-item>
<el-form-item :prop="'gamePrizeList.' + $index + '.' + 'prizeStock'" :rules="rules.prizeStock" label-width="0"> <el-input class="w80" v-model.number="row.prizeStock" @change="calculateRate" /></el-form-item>
</div>
<el-form-item label-width="0" v-else>
- -
......@@ -140,6 +140,7 @@
</el-form-item>
</el-form-item>
<dm-form-bottom class="footer">
<el-button @click="prevStep">上一步</el-button>
<el-button type="primary" @click="submit">保存并下一步</el-button>
</dm-form-bottom>
<libCard :show.sync="show" @sendItem="sendItem" :cardLimitType="-1" :cardLimit="1" />
......@@ -157,7 +158,7 @@ export default {
rules: {
winChance: { type: 'number', required: true, message: '请输入不超过100的数字', max: 100, min: 0 },
prizeNumber: { type: 'number', required: true, message: '请输入不超过1000000的数字', max: 1000000, min: 1 },
optNum: { type: 'number', required: true, message: '请输入不超过1000000的数字', max: 1000000, min: 0 },
prizeStock: { type: 'number', required: true, message: '请输入不超过1000000的数字', max: 1000000, min: 0 },
prizeNoticeStock: { type: 'number', message: '请输入不超过1000000的数字', max: 1000000, min: 0 },
prizeName: { type: 'string', required: true, message: '请输入奖品名称' },
prizeType: { required: true, message: '请选择奖品类型' }
......@@ -180,7 +181,7 @@ export default {
prizeName: '谢谢参与',
prizeImageUrl: '-',
prizeNumber: 1,
optNum: -1,
prizeStock: -1,
exchangeType: 0
}
]
......@@ -199,12 +200,17 @@ export default {
label: '卡券'
}
],
index: 0
index: 0,
isAdd: this.$route.meta.type === 'add'
};
},
props: {
prizeMax: 0,
prizeMin: 0
prizeMin: 0,
echoData: {
type: Object,
default: () => {}
}
},
components: {
dmUploadAvatar,
......@@ -213,6 +219,20 @@ export default {
mounted() {
this.drag();
},
watch: {
echoData(val) {
this.prizeForm = Object.assign(this.prizeForm, val);
this.prizeForm.gamePrizeList.forEach(item => {
if (item.prizeImageUrl) {
item.prizeImageUrl = { imgUrl: item.prizeImageUrl, code: item.prizeImageUrl };
}
item.prizeStockOriginal = item.prizeStock;
});
this.calculateRate();
this.prizeForm.gamePrizeList = this.prizeForm.gamePrizeList.splice(0);
console.log(this.prizeForm);
}
},
methods: {
cardView(ids) {
cardView({ ids }).then(res => {
......@@ -248,6 +268,7 @@ export default {
data.prizeRelationId = selectedData.coupCardId;
data.prizeName = selectedData.cardName.length > 10 ? selectedData.cardName.slice(0, 10) : selectedData.cardName;
data.prizeImageUrl = { imgUrl: this.imgeType[selectedData.cardType], code: this.imgeType[selectedData.cardType] };
data.prizeNumber = 1;
this.prizeForm.gamePrizeList = this.prizeForm.gamePrizeList.splice(0);
},
addPrize() {
......@@ -285,10 +306,10 @@ export default {
this.prizeForm.gamePrizeList = this.prizeForm.gamePrizeList.splice(0);
},
calculateRate() {
const prizeNumTotal = this.prizeForm.gamePrizeList.map(item => (item.prizeType != 0 ? item.optNum : 0)).reduce((pre, current) => pre + current);
const prizeNumTotal = this.prizeForm.gamePrizeList.map(item => (item.prizeType != 0 ? item.prizeStock : 0)).reduce((pre, current) => pre + current);
this.prizeForm.gamePrizeList.forEach(item => {
if (item.prizeType != 0) {
const prizeRate = this.prizeForm.winChance * (item.optNum / prizeNumTotal);
const prizeRate = this.prizeForm.winChance * (item.prizeStock / prizeNumTotal);
item.prizeRate = prizeRate.toFixed(2);
}
});
......@@ -302,7 +323,9 @@ export default {
});
this.prizeForm.gamePrizeList = this.prizeForm.gamePrizeList.splice(0);
},
prevStep() {
this.$emit('prevStep', 0);
},
submit() {
this.$refs.prizeForm.validate(val => {
if (val) {
......@@ -311,6 +334,16 @@ export default {
if (item.prizeImageUrl) {
item.prizeImageUrl = item.prizeImageUrl.imgUrl || '-';
}
if (item.prizeType != 0) {
if (this.isAdd) {
item.optNum = item.prizeStock;
} else {
let num = item.prizeStock - item.prizeStockOriginal;
item.optNum = num;
}
} else {
item.optNum = -1;
}
});
this.$emit('nextStep', data);
} else {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment