You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

195 lines
8.0 KiB

3 years ago
<template>
<div class="main-content">
<div class="form-area">
3 years ago
<el-form size="default" :model="form" label-width="90px">
3 years ago
<el-form-item label="任务标题" style="width: 60%">
3 years ago
<el-input placeholder="请输入" v-model="form.title" />
3 years ago
</el-form-item>
3 years ago
<el-form-item label="简介" style="width: 60%">
3 years ago
<el-input placeholder="请输入" type="textarea" v-model="form.subtitle" />
3 years ago
</el-form-item>
3 years ago
<el-form-item label="时间" style="width: 60%">
3 years ago
<el-date-picker value-format="YYYY-MM-DD HH:mm:ss" @change="timeChange" v-model="selTime" type="daterange"></el-date-picker>
3 years ago
</el-form-item>
<el-form-item label="标签类别">
3 years ago
<el-checkbox-group v-model="form.tagList">
<el-checkbox v-for="(item,index) in tagData" :key="index" :label="item.id">
{{item.title}}
</el-checkbox>
3 years ago
</el-checkbox-group>
</el-form-item>
3 years ago
<el-form-item label="选择车系" style="width: 90%">
<!-- <div style="width: 80%"><el-checkbox :label="false" @change="selectAll"></el-checkbox></div> -->
3 years ago
<div>
3 years ago
<el-checkbox-group v-model="form.brandList">
<el-checkbox v-for="(item,index) in brandData" :key="index" :label="item.id">
{{item.name}}
</el-checkbox>
3 years ago
</el-checkbox-group>
</div>
3 years ago
</el-form-item>
<el-form-item label="封面图片">
3 years ago
<uploadFile @change="handlerUpload" :config="{ limit: 1, accept: '.jpg, .jpeg, .png, .gif'}">
3 years ago
<el-icon v-if="form.coverUrl == ''" class="img-upload"><Plus /></el-icon>
<img v-else class="img-upload" :src="$ImgUrl(form.coverUrl)" />
3 years ago
</uploadFile>
3 years ago
</el-form-item>
3 years ago
<el-form-item label="上传素材">
<uploadFile @change="handlerRefUpload" :config="{ limit: 10, accept: '.jpg, .jpeg, .png, .gif, .mp4'}">
<el-button>上传文件</el-button>
</uploadFile>
<el-link v-for="(item,index) in form.referenceUrlList" :key="index" :href="$ImgUrl(item)" target="_blank">
{{item}}
</el-link>
3 years ago
</el-form-item>
3 years ago
<el-form-item label="选择素材"></el-form-item>
3 years ago
<el-transfer style="padding:0px 0px 16px 30px;text-align: left; display: inline-block"
v-model="form.referenceList" :titles="['素材列表','已选素材']"
:data="refData" :props="{key: 'id',label: 'title'}">
</el-transfer>
3 years ago
<el-form-item label="选择教程">
3 years ago
</el-form-item>
<el-form-item label="奖励规则">
3 years ago
<el-select v-model="form.rewardRuleTemplateId" @change="ruleChange">
3 years ago
<el-option v-for="(item) in ruleData" :key="item.id" :value="item.id" :label="item.title">
3 years ago
</el-option>
3 years ago
</el-select>
<el-table :data="ruleTable.data" border style="margin-top: 16px">
3 years ago
<el-table-column prop="id" label="传播值" :formatter="valueFormatter"></el-table-column>
<el-table-column prop="reward" label="奖励积分"></el-table-column>
3 years ago
</el-table>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="confirm"></el-button>
</el-form-item>
</el-form>
</div>
</div>
</template>
<script>
3 years ago
import {defineComponent, reactive, ref, getCurrentInstance} from 'vue'
3 years ago
import {valueFormatter} from './config.js'
3 years ago
export default defineComponent({
name: 'v-questRelease',
setup() {
const activeId = reactive({
value: 0
});
const form = reactive({
3 years ago
title: '',
subtitle: '',
start: '',
end: '',
coverUrl: '',
3 years ago
rewardRuleTemplateId: null,
3 years ago
brandList: [],
tagList: [],
3 years ago
referenceList: [],
referenceUrlList: [],
3 years ago
});
3 years ago
const selTime = ref([]);
const tagData = ref([]);
const brandData = ref([]);
const ruleData = ref([]);
3 years ago
const refData = ref([]);
3 years ago
const { proxy } = getCurrentInstance();
3 years ago
const ruleTable = reactive({
data: []
});
return {
3 years ago
form,proxy,selTime,valueFormatter,
tagData,brandData,ruleData,refData,
3 years ago
ruleTable,
activeId
}
},
mounted() {
3 years ago
this.getApi();
3 years ago
},
methods: {
3 years ago
getApi() {
this.proxy.$post("/tag/list", {}).then(res => {
this.tagData = res.data.records;
}).catch(() => {});
this.proxy.$post("/brand/list", {}).then(res => {
this.brandData = res.data.records;
}).catch(() => {});
this.proxy.$post("/rewardRuleTemplate/list", {}).then(res => {
3 years ago
this.ruleData = res.data.records;
3 years ago
}).catch(() => {});
3 years ago
this.proxy.$post("/reference/list", {}).then(res => {
this.refData = res.data.records;
}).catch(() => {});
3 years ago
if(this.$route.params.id) {
this.proxy.$post("/task/detail", {id: this.$route.params.id}).then(res => {
this.form.title = res.data.title;
this.form.subtitle = res.data.subtitle;
this.form.start = res.data.start;
this.form.end = res.data.end;
this.form.coverUrl = res.data.coverUrl;
this.selTime = [res.data.start,res.data.end]
this.form.rewardRuleTemplateId = res.data.rewardRuleTemplateId;
this.ruleChange(res.data.rewardRuleTemplateId);
res.data.referenceList.forEach(ele => {this.form.referenceList.push(ele.id)})
res.data.brandList.forEach(ele => {this.form.brandList.push(ele.id)})
res.data.tagList.forEach(ele => {this.form.tagList.push(ele.id)})
}).catch(() => {});
}
3 years ago
},
3 years ago
selectAll(value) {
if(value == true) {
//全选
} else {
this.form.series = []
}
},
ruleChange(value) {
3 years ago
this.proxy.$post("/rewardRuleTemplate/detail", {id: value}).then(res => {
this.ruleTable.data = res.data.ruleList
3 years ago
}).catch(() => {});
3 years ago
},
confirm() {
3 years ago
if(this.$route.params.id) {
let obj = Object.assign(this.form, {id: this.$route.params.id})
this.proxy.$post("/task/upd", obj).then(res => {
this.$message.success(res.data);
this.$router.go(-1);
}).catch(() => {});
} else {
this.proxy.$post("/task/add", this.form).then(res => {
this.$message.success(res.data);
this.$router.go(-1);
}).catch(() => {});
}
3 years ago
},
timeChange(val) {
3 years ago
this.form.start = val[0];
this.form.end = val[1]
3 years ago
},
3 years ago
handlerUpload(data) {
this.form.coverUrl = data.fileUrl
3 years ago
},
3 years ago
handlerRefUpload(data) {
if(data.fileUrl != null) {
this.form.referenceUrlList.push(data.fileUrl)
}
}
3 years ago
}
})
</script>
<style lang="less">
.form-area {
width: 600px
}
3 years ago
.img-upload {
font-size: 28px;
color: #8c939d;
width: 135px;
height: 135px;
text-align: center;
border: 1px solid;
}
3 years ago
</style>