|
@@ -12,7 +12,7 @@
|
|
|
<el-form>
|
|
|
<el-row>
|
|
|
<el-col :span="16">
|
|
|
- <h5>奖品条目<span style="color: red;">(总概率数不要超过100%)</span><span></span></h5>
|
|
|
+ <h5>奖品条目<span style="color: red;">(总概率数不要超过100%)</span><span style="color: #0000cc">当前概率:{{ pr() }}</span></h5>
|
|
|
<div style="padding-left: 10px;">
|
|
|
<el-form-item v-for="(item, index) in survey.sugarItems" :key="index">
|
|
|
<el-input v-model="item.name" placeholder="奖品名称" style="width: 160px;"></el-input>
|
|
@@ -55,7 +55,13 @@ export default {
|
|
|
sugarItems: []
|
|
|
},
|
|
|
group: this.$route.params.id,
|
|
|
- pr: 0
|
|
|
+ pr: function () {
|
|
|
+ let pr = 0
|
|
|
+ this.survey.sugarItems.forEach(element => {
|
|
|
+ pr += Number(element.pr)
|
|
|
+ })
|
|
|
+ return pr.toFixed(2)
|
|
|
+ }
|
|
|
}
|
|
|
},
|
|
|
watch: {
|
|
@@ -72,31 +78,35 @@ export default {
|
|
|
this.survey.sugarItems.push(element)
|
|
|
})
|
|
|
})
|
|
|
- /* console.log(this.survey.sugarItems.length)
|
|
|
- if (this.survey.sugarItems.length === 0) {
|
|
|
- } */
|
|
|
},
|
|
|
addSugarItem () {
|
|
|
- this.survey.sugarItems.push({
|
|
|
- name: '',
|
|
|
- alias: '',
|
|
|
- pr: '',
|
|
|
- img: '',
|
|
|
- remove: 1
|
|
|
- })
|
|
|
+ if (this.survey.sugarItems.length < 10) {
|
|
|
+ this.survey.sugarItems.push({
|
|
|
+ name: '',
|
|
|
+ alias: '',
|
|
|
+ pr: '',
|
|
|
+ img: '',
|
|
|
+ remove: 1
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ this.$message({type: 'error', message: '奖品条目数量过多,请删减后重试!'})
|
|
|
+ }
|
|
|
},
|
|
|
removeSugarItem (index) {
|
|
|
- if (this.survey.sugarItems[index].remove === 0) {
|
|
|
- this.$message({type: 'error', message: '概率范围设置异常!'})
|
|
|
- return
|
|
|
- }
|
|
|
this.survey.sugarItems.splice(index, 1)
|
|
|
},
|
|
|
computePr (now_pr, $event) {
|
|
|
},
|
|
|
onSubmit () {
|
|
|
+ if (this.pr() > 100) {
|
|
|
+ this.$message({type: 'error', message: '总概率总概率不能超过100!'})
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ if (this.survey.sugarItems.filter(o => { return o.pr === '' }).length > 0) {
|
|
|
+ this.$message({type: 'error', message: '奖品概率不能为空,请检查后重试!'})
|
|
|
+ return false
|
|
|
+ }
|
|
|
dwSurveySugarItemsSave(this.survey.sugarItems, this.group).then((response) => {
|
|
|
- console.log(response)
|
|
|
const data = response.data
|
|
|
if (data.resultCode === 200) {
|
|
|
this.$message({type: 'success', message: '保存成功'})
|
|
@@ -106,7 +116,14 @@ export default {
|
|
|
})
|
|
|
},
|
|
|
findRouletteIndex () {
|
|
|
- alert('http://localhost:8080/static/roulette/index.html?sugarGroup=' + this.group)
|
|
|
+ // // 获取当前页面地址,如http://localhost:8080/admin/index
|
|
|
+ // const wPath = window.document.location.href
|
|
|
+ // // 获取当前页面主机地址之后的目录,如:/admin/index
|
|
|
+ // const pathName = this.$route.path
|
|
|
+ // const pos = wPath.indexOf(pathName)
|
|
|
+ // // 获取主机地址,如:http://localhost:8080
|
|
|
+ // const localhostPath = wPath.substring(0, pos)
|
|
|
+ alert('http://localhost:8080/static/roulette/index.html')
|
|
|
}
|
|
|
}
|
|
|
}
|