feature_0521
郑皇 6 years ago
parent 1757e67184
commit fdfd6fc320

@ -1,182 +1,132 @@
<template> <template>
<div class=""> <div class>
<Row> <Row>
<i-col :span="12"> <i-col :span="12">
<Form ref="welcomeForm" <Form ref="welcomeForm" :model="welcome" :rules="welcomeRules">
:model="welcome" <FormItem label="欢迎语内容" prop="content">
:rules="welcomeRules"> <i-input
<FormItem label="欢迎语内容" v-model="welcome.content"
prop="content"> type="textarea"
<i-input v-model="welcome.content" style="height: 220px"
type="textarea" :autosize="{ minRows: 10, maxRows: 10 }"
style="height: 220px" placeholder="请输入欢迎语内容,最多100个字"
:autosize="{ minRows: 10, maxRows: 10 }" ></i-input>
placeholder="请输入欢迎语内容,最多100个字"></i-input>
</FormItem> </FormItem>
<Row style="margin-bottom: 10px" <Row
:gutter="10" style="margin-bottom: 10px"
class="inputItem" :gutter="10"
v-for="(item, index) in welcome.params" class="inputItem"
:key="index"> v-for="(item, index) in welcome.params"
:key="index"
>
<div v-if="item.type == 3"> <div v-if="item.type == 3">
<i-col style="line-height: 32px" <i-col style="line-height: 32px" :span="4">APPID {{ index + 1 }}</i-col>
:span="4">
APPID {{ index + 1 }}
</i-col>
<i-col :span="6"> <i-col :span="6">
<i-input class="inputClass" <i-input class="inputClass" type="text" disabled v-model="item.defaultVal"></i-input>
type="text"
disabled
v-model="item.defaultVal"></i-input>
</i-col>
<i-col style="line-height: 32px"
:span="4">
URI {{ index + 1 }}
</i-col> </i-col>
<i-col style="line-height: 32px" :span="4">URI {{ index + 1 }}</i-col>
<i-col :span="6"> <i-col :span="6">
<i-input class="inputClass" <i-input class="inputClass" type="text" disabled v-model="item.description"></i-input>
type="text"
disabled
v-model="item.description"></i-input>
</i-col> </i-col>
</div> </div>
<div v-else> <div v-else>
<i-col style="line-height: 32px" <i-col style="line-height: 32px" :span="4">{{ item.name }}{{ index + 1 }}</i-col>
:span="4">
{{ item.name }}{{ index + 1 }}
</i-col>
<i-col :span="16"> <i-col :span="16">
<i-input class="inputClass" <i-input class="inputClass" type="text" disabled v-model="item.defaultVal"></i-input>
type="text"
disabled
v-model="item.defaultVal"></i-input>
</i-col> </i-col>
</div> </div>
<i-col :span="4"> <i-col :span="4">
<Button type="error" <Button type="error" @click="delActivityInput(index)"></Button>
@click="delActivityInput(index)">删除</Button>
</i-col> </i-col>
</Row> </Row>
<FormItem> <FormItem>
<Button type="text" <Button type="text" @click="() => (showMessageTypes = true)" icon="md-add">添加图片/网页/小程序消息</Button>
@click="() => (showMessageTypes = true)"
icon="md-add">添加图片/网页/小程序消息</Button>
</FormItem> </FormItem>
<FormItem label="配置范围: "> <FormItem label="配置范围: ">
<span v-if="welcome.stores.length > 0"> <span
{{ welcome.stores[0].name }}{{ welcome.stores.length }}家店铺 v-if="welcome.stores.length > 0"
</span> >{{ welcome.stores[0].name }}{{ welcome.stores.length }}家店铺</span>
<Button type="text" <Button type="text" @click="showStores" icon="md-add">全部店铺</Button>
@click="showStores"
icon="md-add">全部店铺</Button>
</FormItem> </FormItem>
<FormItem> <FormItem>
<Button type="primary" <Button type="primary" long @click="submit"></Button>
long
@click="submit">确定</Button>
</FormItem> </FormItem>
</Form> </Form>
</i-col> </i-col>
</Row> </Row>
<Modal v-model="showMessageTypes" <Modal v-model="showMessageTypes" title="添加图片/网页/小程序消息" :footer-hide="true">
title="添加图片/网页/小程序消息"
:footer-hide="true">
<Row :gutter="24"> <Row :gutter="24">
<i-col :span="8"> <i-col :span="8">
<Upload ref="upload" <Upload
:show-upload-list="false" ref="upload"
:on-success="uploadImgSuccess" :show-upload-list="false"
:format="['jpg', 'jpeg', 'png']" :on-success="uploadImgSuccess"
:max-size="2048" :format="['jpg', 'jpeg', 'png']"
:before-upload="handleBeforeUpload" :max-size="2048"
multiple :before-upload="handleBeforeUpload"
type="drag" multiple
action="" type="drag"
style="width: 100%;"> action
style="width: 100%;"
>
<div style="width: 100%;"> <div style="width: 100%;">
<Button long <Button long type="primary">图片</Button>
type="primary">图片</Button>
</div> </div>
</Upload> </Upload>
</i-col> </i-col>
<i-col :span="8"> <i-col :span="8">
<Button long <Button long @click="doShowWeb" type="primary">网页</Button>
@click="doShowWeb" </i-col>
type="primary">网页</Button></i-col>
<i-col :span="8"> <i-col :span="8">
<Button long <Button long @click="doShowMini" type="primary">小程序</Button>
@click="doShowMini" </i-col>
type="primary">小程序</Button></i-col>
</Row> </Row>
</Modal> </Modal>
<Modal v-model="showWeb" <Modal v-model="showWeb" title="添加网页消息" :loading="true">
title="添加网页消息" <Form ref="webForm" :model="webForm" :rules="webFormRules">
:loading="true"> <FormItem label="添加网页消息" prop="url">
<Form ref="webForm" <i-input v-model="webForm.url" type="text" placeholder="以http或https开头"></i-input>
:model="webForm"
:rules="webFormRules">
<FormItem label="添加网页消息"
prop="url">
<i-input v-model="webForm.url"
type="text"
placeholder="以http或https开头"></i-input>
</FormItem> </FormItem>
</Form> </Form>
<div slot="footer"> <div slot="footer">
<Button type="primary" <Button type="primary" @click="cancelWeb"></Button>
@click="cancelWeb">取消</Button> <Button type="primary" @click="okWeb"></Button>
<Button type="primary"
@click="okWeb">确定</Button>
</div> </div>
</Modal> </Modal>
<Modal v-model="showMini" <Modal v-model="showMini" title="添加小程序消息" :loading="true">
title="添加小程序消息" <Form ref="miniForm" :model="miniForm" :rules="miniFormRules">
:loading="true"> <FormItem label="APPID" prop="appid">
<Form ref="miniForm" <i-input v-model="miniForm.appid" type="text" placeholder="请输入appid"></i-input>
:model="miniForm"
:rules="miniFormRules">
<FormItem label="APPID"
prop="appid">
<i-input v-model="miniForm.appid"
type="text"
placeholder="请输入appid"></i-input>
</FormItem> </FormItem>
<FormItem label="APPID" <FormItem label="URI" prop="uri">
prop="uri"> <i-input v-model="miniForm.uri" type="text" placeholder="请输入URl"></i-input>
<i-input v-model="miniForm.uri"
type="text"
placeholder="请输入URl"></i-input>
</FormItem> </FormItem>
</Form> </Form>
<div slot="footer"> <div slot="footer">
<Button type="primary" <Button type="primary" @click="cancelMini"></Button>
@click="cancelMini">取消</Button> <Button type="primary" @click="okMini"></Button>
<Button type="primary"
@click="okMini">确定</Button>
</div> </div>
</Modal> </Modal>
<selectStoreStep @doShow="doShow" <selectStoreStep @doShow="doShow" :schedule="welcome" :show="showStoreCheck"></selectStoreStep>
:schedule="welcome"
:show="showStoreCheck"></selectStoreStep>
</div> </div>
</template> </template>
<script type="text/javascript"> <script type="text/javascript">
import axios from 'axios' import axios from "axios";
import { isURL } from '../../utils/Common' import { isURL } from "../../utils/Common";
import store from '../../store' import store from "../../store";
import selectStoreStep from '../activity/selectStoreStep' import selectStoreStep from "../activity/selectStoreStep";
import ActivityManager from "../../services/ActivityManager/ActivityManager"; import ActivityManager from "../../services/ActivityManager/ActivityManager";
const validateUrl = (rule, value, callback) => { const validateUrl = (rule, value, callback) => {
const is = isURL(value) const is = isURL(value);
if (is) { if (is) {
callback() callback();
} else { } else {
callback(new Error('URL非法,请以http或https开头')) callback(new Error("URL非法,请以http或https开头"));
} }
} };
export default { export default {
data () { data() {
return { return {
showStoreCheck: false, showStoreCheck: false,
showWeb: false, showWeb: false,
@ -184,54 +134,54 @@ export default {
id: 0, id: 0,
showMessageTypes: false, showMessageTypes: false,
welcome: { welcome: {
content: '', content: "",
params: [], params: [],
company: [], company: [],
stores: [], stores: []
}, },
welcomeRules: { welcomeRules: {
content: [ content: [
{ required: true, message: '请输入欢迎语内容', trigger: 'blur' }, { required: true, message: "请输入欢迎语内容", trigger: "blur" },
{ {
type: 'string', type: "string",
max: 100, max: 100,
message: '欢迎语最长100个字符', message: "欢迎语最长100个字符",
trigger: 'blur', trigger: "blur"
}, }
], ]
}, },
webFormRules: { webFormRules: {
url: [ url: [
{ required: true, message: '请输入url', trigger: 'blur' }, { required: true, message: "请输入url", trigger: "blur" },
{ validator: validateUrl, trigger: 'blur' }, { validator: validateUrl, trigger: "blur" }
], ]
}, },
webForm: { url: '' }, webForm: { url: "" },
miniFormRules: { miniFormRules: {
appid: [{ required: true, message: '请输入url', trigger: 'blur' }], appid: [{ required: true, message: "请输入url", trigger: "blur" }],
uri: [{ required: true, message: '请输入url', trigger: 'blur' }], uri: [{ required: true, message: "请输入url", trigger: "blur" }]
}, },
miniForm: { appid: '', uri: '' }, miniForm: { appid: "", uri: "" }
} };
}, },
created () { created() {
this.id = this.$route.query.id this.id = this.$route.query.id;
store.commit('SET_useData', { ...store.getters.useData, ...this.welcome }) store.commit("SET_useData", { ...store.getters.useData, ...this.welcome });
console.log(this.$route) console.log(this.$route);
if (this.id) { if (this.id) {
this.getDetail(this.id) this.getDetail(this.id);
} }
}, },
components: { components: {
selectStoreStep, selectStoreStep
}, },
methods: { methods: {
doShow () { doShow() {
this.showStoreCheck = false this.showStoreCheck = false;
this.welcome = store.getters.useData this.welcome = store.getters.useData;
console.log(this.welcome) console.log(this.welcome);
}, },
getDetail (instanceId) { getDetail(instanceId) {
let _this = this; let _this = this;
ActivityManager.instanceDetail( ActivityManager.instanceDetail(
{ {
@ -242,85 +192,88 @@ export default {
} }
); );
}, },
showStores () { showStores() {
console.log({ ...store.getters.useData, ...this.welcome }) console.log({ ...store.getters.useData, ...this.welcome });
store.commit('SET_useData', { ...store.getters.useData, ...this.welcome }) store.commit("SET_useData", {
this.showStoreCheck = true ...store.getters.useData,
...this.welcome
});
this.showStoreCheck = true;
}, },
uploadImgSuccess (res, file) { }, uploadImgSuccess(res, file) {},
cancelWeb () { cancelWeb() {
this.showWeb = false this.showWeb = false;
}, },
doShowWeb () { doShowWeb() {
this.showWeb = true this.showWeb = true;
this.webForm = { url: '' } this.webForm = { url: "" };
}, },
doShowMini () { doShowMini() {
this.showMini = true this.showMini = true;
this.miniForm = { this.miniForm = {
appid: '', appid: "",
uri: '', uri: ""
} };
}, },
cancelMini () { cancelMini() {
this.showMini = false this.showMini = false;
}, },
okWeb () { okWeb() {
let _this = this let _this = this;
this.$refs['webForm'].validate((valid) => { this.$refs["webForm"].validate(valid => {
if (valid) { if (valid) {
_this.welcome.params.push({ _this.welcome.params.push({
attr: 2, attr: 2,
defaultVal: this.webForm.url, defaultVal: this.webForm.url,
description: this.webForm.url, description: this.webForm.url,
isRequired: 1, isRequired: 1,
key: 'url', key: "url",
limitLower: null, limitLower: null,
limitUpper: null, limitUpper: null,
name: '网页', name: "网页",
type: 2, type: 2
}) });
this.showWeb = false this.showWeb = false;
this.showMessageTypes = false this.showMessageTypes = false;
} }
}) });
}, },
okMini () { okMini() {
let _this = this let _this = this;
this.$refs['miniForm'].validate((valid) => { this.$refs["miniForm"].validate(valid => {
if (valid) { if (valid) {
_this.welcome.params.push({ _this.welcome.params.push({
attr: 2, attr: 2,
defaultVal: this.miniForm.appid, defaultVal: this.miniForm.appid,
description: this.miniForm.uri, description: this.miniForm.uri,
isRequired: 1, isRequired: 1,
key: 'mini', key: "mini",
limitLower: null, limitLower: null,
limitUpper: null, limitUpper: null,
name: '小程序消息', name: "小程序消息",
type: 3, type: 3
}) });
this.showMini = false this.showMini = false;
this.showMessageTypes = false this.showMessageTypes = false;
} }
}) });
}, },
delActivityInput (index) { delActivityInput(index) {
this.welcome.params.splice(index, 1) this.welcome.params.splice(index, 1);
this.$forceUpdate() this.$forceUpdate();
}, },
handleBeforeUpload (res) { handleBeforeUpload(res) {
const me = this const me = this;
let data = new FormData() let data = new FormData();
data.append('file', res) data.append("file", res);
axios({ axios({
method: 'post', method: "post",
url: '/upload', url: "/upload",
data: data, data: data,
headers: { headers: {
'Content-Type': 'multipart/form-data', "Content-Type": "multipart/form-data"
}, }
}).then(function (res) { }).then(function(res) {
if (res.data.success) { if (res.data.success) {
// me.formValidate.logo = res.data.results; // me.formValidate.logo = res.data.results;
me.welcome.params.push({ me.welcome.params.push({
@ -328,44 +281,44 @@ export default {
defaultVal: res.data.results, defaultVal: res.data.results,
description: res.data.results, description: res.data.results,
isRequired: 1, isRequired: 1,
key: 'image', key: "image",
limitLower: null, limitLower: null,
limitUpper: null, limitUpper: null,
name: '图片', name: "图片",
type: 1, type: 1
}) });
me.showMessageTypes = false me.showMessageTypes = false;
} }
}) });
return false return false;
}, },
submit () { submit() {
let _this = this let _this = this;
if (this.welcome.params.length <= 0) { if (this.welcome.params.length <= 0) {
_this.$Message.error('请添加图片/网页/小程序消息') _this.$Message.error("请添加图片/网页/小程序消息");
} }
if (this.welcome.stores.length <= 0) { if (this.welcome.stores.length <= 0) {
_this.$Message.error('请至少选择一个店铺') _this.$Message.error("请至少选择一个店铺");
} }
this.$refs['welcomeForm'].validate((valid) => { this.$refs["welcomeForm"].validate(valid => {
if (valid) { if (valid) {
let data = _this.welcome let data = _this.welcome;
data.isGetActivityInfo = true data.isGetActivityInfo = true;
axios({ axios({
method: 'post', method: "post",
url: '/activity/instance/saveWelcome', url: "/activity/instance/saveWelcome",
data: data, data: data,
headers: { headers: {
'Content-Type': 'applications/json', "Content-Type": "applications/json"
}, }
}).then((res) => { }).then(res => {
console.log(res) _this.$router.push("/shop/increase/welcome/list");
}) });
} }
}) });
}, }
}, }
} };
</script> </script>
<style scope> <style scope>

@ -1,50 +1,42 @@
<template> <template>
<div> <div>
<Row class="search-row"> <Row class="search-row">
<i-col span="24" <i-col span="24" class="search-col">
class="search-col">
<Row class="row-style"> <Row class="row-style">
<Button @click="handleEdit" <Button @click="handleEdit" type="primary">配置欢迎语</Button>
type="primary">配置欢迎语</Button>
</Row> </Row>
</i-col> </i-col>
</Row> </Row>
<Table :columns="columns1" <Table :columns="columns1" :data="data" style="margin-top: 20px;" size="small">
:data="data" <template slot-scope="{ row, index }" slot="action">
style="margin-top: 20px;" <Button type="primary" size="small" @click="handleEdit(row, index)">修改</Button>
size="small"> <Button type="error" size="small" @click="handleDelete(row, index)">删除</Button>
<template slot-scope="{ row, index }"
slot="action">
<Button type="primary"
size="small"
@click="handleEdit(row, index)">修改</Button>
<Button type="error"
size="small"
@click="handleDelete(row, index)">删除</Button>
</template> </template>
</Table> </Table>
<Page :total="total" <Page
:current="pageNum" :total="total"
:page-size="pageSize" :current="pageNum"
show-elevator :page-size="pageSize"
show-total show-elevator
placement="top" show-total
@on-change="handlePage" placement="top"
class="ks-page"></Page> @on-change="handlePage"
class="ks-page"
></Page>
</div> </div>
</template> </template>
<script> <script>
import data from '../../utils/PhoneRegionData' import data from "../../utils/PhoneRegionData";
import http from '../../services/store/IncreaseStoreManager' import http from "../../services/store/IncreaseStoreManager";
import staff from '../../services/staff/staff' import staff from "../../services/staff/staff";
export default { export default {
name: 'IncreaseWelcomeList', name: "IncreaseWelcomeList",
inject: ['setMenuName'], inject: ["setMenuName"],
data () { data() {
let _this = this let _this = this;
return { return {
loading: true, loading: true,
// //
@ -55,92 +47,91 @@ export default {
columns1: [ columns1: [
{ {
width: 60, width: 60,
align: 'center', align: "center",
title: '序号', title: "序号",
render (h, params) { render(h, params) {
console.log(params) console.log(params);
let num = parseInt(params.index) + 1 let num = parseInt(params.index) + 1;
console.log(_this.pageSize) console.log(_this.pageSize);
if (_this.pageSize > 1) { if (_this.pageSize > 1) {
num += (_this.pageNum - 1) * _this.pageSize num += (_this.pageNum - 1) * _this.pageSize;
} }
return h('span', num) return h("span", num);
}, }
}, },
{ {
title: '欢迎语', title: "欢迎语",
key: 'scheduleVO.description', key: "scheduleVO.description",
render (h, params) { render(h, params) {
return h('span', params.row.scheduleVO.description) return h("span", params.row.content);
}, }
}, },
{ {
title: '配置范围', title: "配置范围",
key: 'shop', key: "shop",
render (h, params) { render(h, params) {
return h( return h(
'span', "span",
params.row.companyName + params.row.storeName +
'等' + "等" +
(params.row.companyCount || 0) + (params.row.storeCount || 0) +
'家公司' "家公司"
) );
}, }
}, },
{ title: '配置时间', key: 'createTime' }, { title: "配置时间", key: "createTime" },
{ title: '修改时间', key: 'updateTime' }, { title: "修改时间", key: "updateTime" },
{ title: '操作', slot: 'action' }, { title: "操作", slot: "action" }
], ],
formValidate: {}, formValidate: {}
} };
}, },
mounted () { mounted() {
this.setMenuName('门店推广', '欢迎语') this.setMenuName("门店推广", "欢迎语");
this.handlePaginate() this.handlePaginate();
}, },
methods: { methods: {
// //
handlePaginate () { handlePaginate() {
this.loading = true this.loading = true;
let params = { let params = {
pageNum: this.pageNum, pageNum: this.pageNum,
pageSize: this.pageSize, pageSize: this.pageSize,
userId: JSON.parse(sessionStorage.getItem('loginInfo')).userId, userId: JSON.parse(sessionStorage.getItem("loginInfo")).userId,
categoryCode: 'welcome', categoryCode: "welcome"
} };
http.getWelcomeList(params, (res) => { http.getWelcomeList(params, res => {
const data = res.data.results.this || {} const data = res.data.results.this || {};
this.data = data.list || [] this.data = data.list || [];
this.totalSize = data.total || 0 this.totalSize = data.total || 0;
this.loading = false this.loading = false;
}) });
}, },
// //
handlePage: function (value) { handlePage: function(value) {
this.pageNum = value this.pageNum = value;
}, },
// //
handleEdit (row) { handleEdit(row) {
this.$router.push({ this.$router.push({
path: '/shop/increase/welcome/edit', path: "/shop/increase/welcome/edit",
query: { id: row.id }, query: { id: row.id }
}) });
}, },
// //
handleDelete (row) { handleDelete(row) {
let _this = this; let _this = this;
this.$Modal.confirm({ this.$Modal.confirm({
title: '删除欢迎语', title: "删除欢迎语",
content: '您确定要删除该欢迎语?', content: "您确定要删除该欢迎语?",
onOk: () => { onOk: () => {
http.deleteWelcome({ id: row.scheduleId }).then(_this.handlePaginate) http.deleteWelcome({ id: row.scheduleId }).then(_this.handlePaginate);
}, },
onCancel: () => { onCancel: () => {}
}
}); });
}, }
}, }
} };
</script> </script>
<style scoped></style> <style scoped></style>

Loading…
Cancel
Save