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

272 lines
7.8 KiB
Vue

6 years ago
<template>
5 years ago
<Modal v-model="dispalyModal"
width="1000"
:loading="loading"
:mask-closable="false"
@on-cancel="cancel"
@on-ok="save">
<p slot="header"
style="color:#f60;text-align:left">
5 years ago
<span>配置活动</span>
6 years ago
</p>
<div>基本配置</div>
5 years ago
<Form ref="formValidate"
:model="formValidate"
:rules="ruleValidate"
:label-width="80">
6 years ago
<Row>
5 years ago
<i-col style="text-align: left;"
span="8">
<FormItem label=""
prop="logo">
<Upload ref="upload"
:show-upload-list="false"
:on-success="uploadImgSuccess"
:format="['jpg', 'jpeg', 'png']"
:max-size="2048"
:before-upload="handleBeforeUpload"
multiple
type="drag"
action=""
style="display: inline-block;">
6 years ago
<div style="width: 200px;height:200px;line-height: 200px;">
5 years ago
<span v-if="!formValidate.logo"></span>
5 years ago
<img v-if="formValidate.logo"
:src="`/kiisoo-ic` + formValidate.logo"
alt=""
style="width: 100%; height: auto" />
6 years ago
</div>
5 years ago
</Upload>
6 years ago
</FormItem>
</i-col>
5 years ago
<i-col span="15"
offset="1">
<FormItem label="活动名称"
prop="name">
<i-input type="text"
v-model="formValidate.name"
placeholder="请输入活动名称"></i-input>
6 years ago
</FormItem>
5 years ago
<Form-item label="活动描述"
prop="description">
<i-input v-model="formValidate.description"
type="textarea"
:autosize="{ minRows: 3 }"
placeholder="请输入活动描述"></i-input>
6 years ago
</Form-item>
5 years ago
<FormItem label="APPID"
prop="appId">
<i-input type="text"
v-model="formValidate.appId"
placeholder="请输入appid"></i-input>
6 years ago
</FormItem>
5 years ago
<FormItem label="URI"
prop="uri">
<i-input type="text"
v-model="formValidate.uri"
placeholder="请输入URI"></i-input>
6 years ago
</FormItem>
</i-col>
</Row>
</Form>
<div class="topic">活动类型</div>
5 years ago
<Row :gutter="10"
class="inputItem"
v-for="(item, index) in formValidate.params"
:key="index">
5 years ago
<i-col :span="2"> 类型{{ index + 1 }} </i-col>
<i-col :span="9">
5 years ago
<i-input class="inputClass"
type="text"
v-model="item.name"
placeholder="参数名称"></i-input>
5 years ago
</i-col>
<i-col :span="9">
5 years ago
<i-input class="inputClass"
type="text"
style="margin-left: 20px"
v-model="item.key"
placeholder="默认值"></i-input>
6 years ago
</i-col>
5 years ago
<i-col :span="4">
5 years ago
<Button style="margin-left: 20px"
type="error"
@click="delActivityInput(index)">删除</Button>
6 years ago
</i-col>
</Row>
5 years ago
<Button style="margin-top: 10px"
type="primary"
@click="addActivityInput">+添加活动类型</Button>
5 years ago
</Modal>
6 years ago
</template>
<script>
import ActivityManager from "../../services/ActivityManager/ActivityManager";
5 years ago
import axios from "axios";
6 years ago
export default {
name: "addActivity",
5 years ago
data () {
5 years ago
return {
6 years ago
dispalyModal: false,
currentStep: 0,
modal_loading: false,
5 years ago
imageName: "212",
formValidate: {},
5 years ago
loading: true,
6 years ago
ruleValidate: {
5 years ago
name: [
{ required: true, message: "活动名称不能为空", trigger: "blur" },
6 years ago
],
5 years ago
description: [
{ required: true, message: "活动描述不能为空", trigger: "blur" },
6 years ago
],
5 years ago
appId: [{ required: true, message: "appId不能为空", trigger: "blur" }],
uri: [{ required: true, message: "URI不能为空", trigger: "blur" }],
6 years ago
// uploadImg: [
// { required: true, message: '请上传活动图片', trigger: 'blur' }
// ]
5 years ago
},
};
6 years ago
},
props: {
addActivityModal: Boolean,
5 years ago
id: String,
6 years ago
},
watch: {
5 years ago
addActivityModal (val) {
5 years ago
console.log(111, val);
5 years ago
this.dispalyModal = val;
if (val === true && this.id) {
this.getActivityData();
}
if (this.id == null || this.id.length <= 0) {
this.formValidate = {};
}
if (
typeof this.formValidate.params == "undefined" ||
this.formValidate.params.length <= 0
) {
this.formValidate.params = [
{
defaultVal: "",
description: "",
id: 0,
isRequired: 0,
key: "",
limitLower: "",
limitUpper: "",
name: "",
type: 0,
},
];
6 years ago
}
},
},
5 years ago
mounted () { },
6 years ago
methods: {
5 years ago
addActivityInput () {
5 years ago
let params = [...this.formValidate.params];
params.push({
5 years ago
defaultVal: "",
description: "",
id: 0,
isRequired: 0,
key: "",
limitLower: "",
limitUpper: "",
name: "",
type: 0,
});
5 years ago
this.$set(this.formValidate, "params", params);
this.$forceUpdate();
6 years ago
},
5 years ago
delActivityInput (index) {
5 years ago
if (this.formValidate.params.length <= 1) {
this.$Message.error("至少需要填写一个活动类型!");
return;
}
this.formValidate.params.splice(index, 1);
5 years ago
this.$forceUpdate();
6 years ago
},
5 years ago
cancel () {
5 years ago
this.$emit("dispalyAddActivityModal", false, false);
6 years ago
},
5 years ago
getActivityData () {
5 years ago
let that = this;
6 years ago
let data = {
5 years ago
id: that.id,
};
5 years ago
ActivityManager.getActivityInfo(data, function (data) {
5 years ago
that.formValidate = data.data.results;
});
6 years ago
},
5 years ago
uploadImgSuccess (res, file) {
5 years ago
this.imageName = file.name;
6 years ago
},
5 years ago
handleBeforeUpload (res) {
6 years ago
const me = this;
let data = new FormData();
5 years ago
data.append("file", res);
6 years ago
axios({
5 years ago
method: "post",
url: "/upload",
6 years ago
data: data,
headers: {
5 years ago
"Content-Type": "multipart/form-data",
},
5 years ago
}).then(function (res) {
6 years ago
if (res.data.success) {
5 years ago
// me.formValidate.logo = res.data.results;
me.$set(me.formValidate, "logo", res.data.results);
console.log(me.formValidate.logo);
6 years ago
}
6 years ago
});
return false;
6 years ago
},
5 years ago
save () {
5 years ago
let that = this;
if (that.formValidate.params.length <= 0) {
that.$Message.error("至少需要填写一个活动类型!");
5 years ago
that.loading = false;
5 years ago
return false;
5 years ago
}
5 years ago
if (
typeof that.formValidate.logo == "undefined" ||
that.formValidate.logo == "" ||
that.formValidate.logo.length <= 0
) {
that.$Message.error("请上传活动封面!");
5 years ago
that.loading = false;
5 years ago
return false;
5 years ago
}
5 years ago
this.loading = true;
6 years ago
this.$refs["formValidate"].validate((valid) => {
5 years ago
if (valid) {
// param = JSON.stringify(param)
let data = { ...that.formValidate, isGetActivityInfo: true };
5 years ago
ActivityManager.addOreditActivity(data, function (data) {
5 years ago
that.addActivityModal = false;
that.formValidate = {};
that.$emit("dispalyAddActivityModal", false, true);
});
} else {
that.$Message.error("表单验证失败!");
}
5 years ago
that.loading = false;
5 years ago
});
},
},
};
6 years ago
</script>
5 years ago
<style scoped>
.inputClass {
width: 100%;
6 years ago
}
5 years ago
.inputItem {
margin-top: 20px;
6 years ago
}
5 years ago
.topic {
margin-top: 20px;
6 years ago
}
5 years ago
</style>