|
@@ -1,8 +1,40 @@
|
|
|
<template>
|
|
|
<div>
|
|
|
- <dw-survey-dcs-wrapper :id="id" is-sugar-item="true" >
|
|
|
- <template v-slot:dw-dcs-main-slot="{survey}" >
|
|
|
- <dw-survey-sugar-main v-if="survey" :survey="survey"></dw-survey-sugar-main>
|
|
|
+ <dw-survey-dcs-wrapper is-sugar-item="true" >
|
|
|
+ <template v-slot:dw-dcs-main-slot >
|
|
|
+ <div>
|
|
|
+ <div class="dw-dcs-main-title">
|
|
|
+ <h4>奖品配置</h4>
|
|
|
+ <div class="dw-dcs-main-p">配置奖品</div>
|
|
|
+ </div>
|
|
|
+ <div class="dw-dcs-main-content">
|
|
|
+ <div style="padding: 0px 30px;">
|
|
|
+ <el-form>
|
|
|
+ <el-row>
|
|
|
+ <el-col :span="16">
|
|
|
+ <h5>奖品条目<span style="color: red;">(总概率数不要超过100%)</span><span></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>
|
|
|
+ <el-input v-model="item.alias" placeholder="奖品别名" style="width: 160px;"></el-input>
|
|
|
+ <el-input v-model="item.pr" placeholder="中奖概率" style="width: 100px;" @change="computePr(item.pr, $event)"></el-input>%
|
|
|
+ <el-input v-model="item.sort" placeholder="序号" style="width: 100px;"></el-input>
|
|
|
+ <el-input v-model="item.img" placeholder="图片地址" style="width: 260px;"></el-input>
|
|
|
+ <el-button plain icon="el-icon-delete" type="danger" @click="removeSugarItem(index)">删除</el-button>
|
|
|
+ </el-form-item>
|
|
|
+ </div>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ <el-form-item>
|
|
|
+ <el-button type="primary" @click="addSugarItem"> 增加奖品条目 </el-button>
|
|
|
+ <el-button type="primary" @click="onSubmit"> 保存修改 </el-button>
|
|
|
+ <el-button @click="initSugarItems">取消</el-button>
|
|
|
+ <el-button type="primary" @click="findRouletteIndex"> 查看网址 </el-button>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
</template>
|
|
|
</dw-survey-dcs-wrapper>
|
|
|
</div>
|
|
@@ -10,12 +42,83 @@
|
|
|
<script>
|
|
|
|
|
|
import DwSurveyDcsWrapper from '@/components/common/DwSurveyDcsWrapper'
|
|
|
+import {dwSurveySugarItems, dwSurveySugarItemsSave} from '@/api/dw-sugar'
|
|
|
|
|
|
export default {
|
|
|
name: 'DwSugarItem',
|
|
|
components: {
|
|
|
DwSurveyDcsWrapper
|
|
|
+ },
|
|
|
+ data () {
|
|
|
+ return {
|
|
|
+ survey: {
|
|
|
+ sugarItems: []
|
|
|
+ },
|
|
|
+ group: this.$route.params.id,
|
|
|
+ pr: 0
|
|
|
+ }
|
|
|
+ },
|
|
|
+ watch: {
|
|
|
+ },
|
|
|
+ mounted () {
|
|
|
+ this.initSugarItems()
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ initSugarItems () {
|
|
|
+ this.survey.sugarItems = []
|
|
|
+ dwSurveySugarItems(this.group).then((response) => {
|
|
|
+ const resultData = response.data.data
|
|
|
+ resultData.forEach(element => {
|
|
|
+ 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
|
|
|
+ })
|
|
|
+ },
|
|
|
+ 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 () {
|
|
|
+ dwSurveySugarItemsSave(this.survey.sugarItems, this.group).then((response) => {
|
|
|
+ console.log(response)
|
|
|
+ const data = response.data
|
|
|
+ if (data.resultCode === 200) {
|
|
|
+ this.$message({type: 'success', message: '保存成功'})
|
|
|
+ } else {
|
|
|
+ this.$message({type: 'error', message: data.data})
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ findRouletteIndex () {
|
|
|
+ alert('http://localhost:8080/static/roulette/index.html?sugarGroup=' + this.group)
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
</script>
|
|
|
+
|
|
|
+<style scoped>
|
|
|
+ .dw-dcs-main-p{
|
|
|
+ font-size: 12px;
|
|
|
+ color: rgba(0, 0, 0, 0.45);
|
|
|
+ }
|
|
|
+ .dw-dcs-main-content{
|
|
|
+ padding: 20px 0px;
|
|
|
+ }
|
|
|
+</style>
|