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.

276 lines
7.2 KiB
Vue

6 years ago
<template>
5 years ago
<Modal
v-model="dispalyModal"
width="1000"
:mask-closable="false"
@on-cancel="cancel"
@on-ok="save"
>
6 years ago
<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">
6 years ago
<FormItem label="" prop="uploadImg">
<Upload
5 years ago
ref="upload"
6 years ago
:show-upload-list="false"
:on-success="uploadImgSuccess"
5 years ago
:format="['jpg', 'jpeg', 'png']"
6 years ago
:max-size="2048"
:before-upload="handleBeforeUpload"
multiple
type="drag"
action=""
5 years ago
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>
<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>
<i-col span="15" offset="1">
<FormItem label="活动名称" prop="activityName">
5 years ago
<i-input
type="text"
v-model="formValidate.name"
placeholder="请输入活动名称"
></i-input>
6 years ago
</FormItem>
<Form-item label="活动描述" prop="activityDsc">
5 years ago
<i-input
v-model="formValidate.description"
type="textarea"
:autosize="{ minRows: 3 }"
placeholder="请输入活动描述"
></i-input>
6 years ago
</Form-item>
<FormItem label="APPID" prop="appId">
5 years ago
<i-input
type="text"
v-model="formValidate.appId"
placeholder="请输入appid"
></i-input>
6 years ago
</FormItem>
<FormItem label="URI" prop="uri">
5 years ago
<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"
>
<i-col :span="2"> 类型{{ index + 1 }} </i-col>
<i-col :span="9">
<i-input
class="inputClass"
type="text"
v-model="item.name"
placeholder="参数名称"
></i-input>
</i-col>
<i-col :span="9">
<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">
<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
>
</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",
data() {
5 years ago
return {
6 years ago
dispalyModal: false,
currentStep: 0,
modal_loading: false,
5 years ago
imageName: "212",
formValidate: {},
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: {
addActivityModal(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: {
addActivityInput() {
5 years ago
this.formValidate.params.push({
defaultVal: "",
description: "",
id: 0,
isRequired: 0,
key: "",
limitLower: "",
limitUpper: "",
name: "",
type: 0,
});
6 years ago
},
delActivityInput(index) {
5 years ago
if (this.formValidate.params.length <= 1) {
this.$Message.error("至少需要填写一个活动类型!");
return;
}
this.formValidate.params.splice(index, 1);
6 years ago
},
cancel() {
5 years ago
this.$emit("dispalyAddActivityModal", false, false);
6 years ago
},
getActivityData() {
5 years ago
let that = this;
6 years ago
let data = {
5 years ago
id: that.id,
};
ActivityManager.getActivityInfo(data, function(data) {
that.formValidate = data.data.results;
});
6 years ago
},
uploadImgSuccess(res, file) {
5 years ago
this.imageName = file.name;
6 years ago
},
6 years ago
handleBeforeUpload(res) {
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",
},
}).then(function(res) {
6 years ago
if (res.data.success) {
me.formValidate.logo = res.data.results;
}
6 years ago
});
return false;
6 years ago
},
5 years ago
save() {
let that = this;
if (that.formValidate.params.length <= 0) {
that.$Message.error("至少需要填写一个活动类型!");
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
return false;
5 years ago
}
6 years ago
this.$refs["formValidate"].validate((valid) => {
5 years ago
if (valid) {
// param = JSON.stringify(param)
let data = { ...that.formValidate, isGetActivityInfo: true };
ActivityManager.addOreditActivity(data, function(data) {
that.addActivityModal = false;
that.formValidate = {};
that.$emit("dispalyAddActivityModal", false, true);
});
} else {
that.$Message.error("表单验证失败!");
}
});
},
},
};
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>