Authored by 黄敬囿

Merge branch 'feature/ufo-v1202' into 'master'

Feature/ufo v1202

merge to master

See merge request !12
<template>
<div>
<div v-show='templateName === "imageList"'>
<div v-show="templateName === 'imageList'">
<label>显示样式:</label>
<i-radio-group v-model.sync="type_" >
<i-radio label='4'>一行四个
<!-- <span></span> -->
<i-radio-group v-model.sync="type_">
<i-radio label="4">
一行四个
<!-- <span></span> -->
</i-radio>
<i-radio label='5'>一行五个
<!-- <span></span> -->
<i-radio label="5">
一行五个
<!-- <span></span> -->
</i-radio>
</i-radio-group>
</div>
... ... @@ -15,29 +17,32 @@
<tbody>
<draggable v-model="value_" @start="drag=true" @end="drag=false">
<tr v-for="(i, index) in value_" :key="i.id">
<th valign="middle" width="5%">{{+index + 1}}</th>
<th valign="middle">
<div style="display: inline-block;">
<file-upload
:default-file="i.src | removeImageParams"
:id="index"
@success="onUploadSuccess"
@remove="onUploadRemove"
>
</file-upload>
</div>
</th>
<th class="banner-item" valign="middle">
<banner-params v-model="i.url" :type="type" :isSelectAction="isSelectAction"></banner-params>
</th>
<th valign="middle" v-if="!i.hideDeleteButton">
<Button type="error" @click="onDeleteBtnClick(i, index)">删除</Button>
</th>
</tr>
<th valign="middle" width="5%">{{+index + 1}}</th>
<th valign="middle">
<div style="display: inline-block;">
<file-upload
:default-file="i.src | removeImageParams"
:id="index"
@success="onUploadSuccess"
@remove="onUploadRemove"
></file-upload>
</div>
</th>
<th class="banner-item" valign="middle">
<banner-params
ref="addParams"
v-model="i.url"
:type="type"
:isSelectAction="isSelectAction"
></banner-params>
</th>
<th valign="middle" v-if="!i.hideDeleteButton">
<Button type="error" @click="onDeleteBtnClick(i, index)">删除</Button>
</th>
</tr>
</draggable>
</tbody>
</table>
... ... @@ -49,72 +54,80 @@
</template>
<script>
import fileUpload from "./drag-file-upload";
import bannerParams from "./banner-params";
import util from "@/libs/util";
import fileUpload from './drag-file-upload';
import bannerParams from './banner-params';
import util from '@/libs/util';
import draggable from 'vuedraggable';
import draggable from "vuedraggable";
export default {
props: ['value', 'hideAddButton', 'hideDeleteButton','type', 'templateName', 'size', 'isSelectAction'],
props: [
"value",
"hideAddButton",
"hideDeleteButton",
"type",
"templateName",
"size",
"isSelectAction"
],
filters: {
removeImageParams(url) {
if (!url) {
return;
}
return url.split('?')[0];
return url.split("?")[0];
}
},
data() {
// console.log('====='+this.isSelectAction+"////==="+this.type);
return {
type_: this.size || '0',
type_: this.size || "0",
value_: this.handleData(util.clone(this.value)),
itemStyle: '',
itemStyle: ""
};
},
methods: {
onDeleteBtnClick(i, index) {
this.value_.splice(index, 1);
this.$emit('input', this.handleSaveData(this.value_));
this.$emit("input", this.handleSaveData(this.value_));
},
onAddBtnClick() {
let actionValue = 'go.h5';
let urlStr = '';
if(this.templateName === 'tabFloor') {
actionValue = 'go.channel'
}else if(this.templateName === 'guessLike'){
actionValue = 'go.pool',
urlStr = 'https://m.yohobuy.com/?pagename=productList'
let actionValue = "go.h5";
let urlStr = "";
if (this.templateName === "tabFloor") {
actionValue = "go.channel";
} else if (this.templateName === "guessLike") {
(actionValue = "go.pool"),
(urlStr = "https://m.yohobuy.com/?pagename=productList");
}
this.value_.push({
alt: '',
bgColor: '',
imgId: '0',
isFocusRec:'0',
src: '',
title: '',
alt: "",
bgColor: "",
imgId: "0",
isFocusRec: "0",
src: "",
title: "",
business: "new",
hideDeleteButton: false,
url: {
action: actionValue,
url: urlStr,
islogin: 'Y',
islogin: "Y",
headerid: 1
}
});
this.$emit('input', this.handleSaveData(this.value_));
this.$emit("input", this.handleSaveData(this.value_));
},
onUploadSuccess(id, {url}) {
this.value_[id].src = url + '?imageView2/{mode}/w/{width}/h/{height}';
this.$emit('input', this.handleSaveData(this.value_));
onUploadSuccess(id, { url }) {
this.value_[id].src = url + "?imageView2/{mode}/w/{width}/h/{height}";
this.$emit("input", this.handleSaveData(this.value_));
},
onUploadRemove(id) {
this.value_[id].src = '';
this.$emit('input', this.handleSaveData(this.value_));
this.value_[id].src = "";
this.$emit("input", this.handleSaveData(this.value_));
},
handleData(m) {
// console.log('===handleData===')
... ... @@ -123,7 +136,7 @@ export default {
// console.log(this.type_);
let keys = Object.keys(m);
keys.sort((a,b) => {
keys.sort((a, b) => {
a = +a;
b = +b;
... ... @@ -138,78 +151,108 @@ export default {
return 0;
});
let result = [];
for (const i of keys) {
let a = m[i];
if(!a.url){
let action = 'go.h5';
if (!a.url) {
let action = "go.h5";
let url = "https://m.yohobuy.com/";
if(this.templateName === 'tabFloor'){
action = 'go.channel';
url = "https://m.yohobuy.com/?pagename=home&tabName="+a.tabName+"&channelCode="+a.code+"&channelCode="+a.productPool;
}else if(this.templateName === 'guessLike'){
action = 'go.pool';
if (this.templateName === "tabFloor") {
action = "go.channel";
url =
"https://m.yohobuy.com/?pagename=home&tabName=" +
a.tabName +
"&channelCode=" +
a.code +
"&channelCode=" +
a.productPool;
} else if (this.templateName === "guessLike") {
action = "go.pool";
url = "https://m.yohobuy.com/?pagename=productList";
}
a.url = {
action ,
url,
}
action,
url
};
}
this.addId(a);
if (a.url && a.url.action && a.url.action === 'go.ufo') {
if (util.getUrlQueryString(a.url.url, 'pagename') === 'productDetail') {
a.url.action = 'go.detail';
} else if (util.getUrlQueryString(a.url.url, 'pagename') === 'productList') {
a.url.action = 'go.pool';
} else if(util.getUrlQueryString(a.url.url, 'pagename') === 'saleCalendar') {
a.url.action = 'go.calendar';
} else if(util.getUrlQueryString(a.url.url, 'pagename') === 'hotSale') {
a.url.action = 'go.hotlist';
} else if (util.getUrlQueryString(a.url.url, 'pagename') === 'productListNew') {
a.url.action = 'go.list';
if (a.url && a.url.action && a.url.action === "go.ufo") {
if (
util.getUrlQueryString(a.url.url, "pagename") === "productDetail"
) {
a.url.action = "go.detail";
} else if (
util.getUrlQueryString(a.url.url, "pagename") === "productList"
) {
a.url.action = "go.pool";
} else if (
util.getUrlQueryString(a.url.url, "pagename") === "saleCalendar"
) {
a.url.action = "go.calendar";
} else if (
util.getUrlQueryString(a.url.url, "pagename") === "hotSale"
) {
a.url.action = "go.hotlist";
} else if (
util.getUrlQueryString(a.url.url, "pagename") === "productListNew"
) {
a.url.action = "go.list";
} else {
a.url.action = 'go.list';
a.url.action = "go.list";
}
}
// console.log('a')
// console.log(a)
result.push(a);
}
return result;
},
handleSaveData(m) {
let temp = util.clone(m);
for (const i of Object.keys(temp)) {
if (['go.pool', 'go.detail', 'go.list', 'go.calendar', 'go.hotlist', 'go.identifyList'].includes(temp[i].url.action)) {
temp[i].url.action = 'go.ufo';
if (
[
"go.pool",
"go.detail",
"go.list",
"go.calendar",
"go.hotlist",
"go.identifyList"
].includes(temp[i].url.action)
) {
temp[i].url.action = "go.ufo";
}
if (util.getUrlQueryString(temp[i].url.url, 'headerid') === '-1') {
temp[i].url.headerid = '-1';
if (util.getUrlQueryString(temp[i].url.url, "headerid") === "-1") {
temp[i].url.headerid = "-1";
}
if (util.getUrlQueryString(temp[i].url.url, 'islogin') === 'Y') {
temp[i].url.islogin = 'Y'
if (util.getUrlQueryString(temp[i].url.url, "islogin") === "Y") {
temp[i].url.islogin = "Y";
}
if (temp[i].url.action === 'go.channel') {
temp[i].tabName = util.getUrlQueryString(temp[i].url.url, 'tabName')
temp[i].code = util.getUrlQueryString(temp[i].url.url, 'channelCode')
temp[i].productPool = util.getUrlQueryString(temp[i].url.url, 'productPool')
if (temp[i].url.action === "go.channel") {
temp[i].tabName = util.getUrlQueryString(temp[i].url.url, "tabName");
temp[i].code = util.getUrlQueryString(temp[i].url.url, "channelCode");
temp[i].productPool = util.getUrlQueryString(
temp[i].url.url,
"productPool"
);
temp[i].business = util.getUrlQueryString(
temp[i].url.url,
"business"
);
} else {
temp[i].title = util.getUrlQueryString(temp[i].url.url, 'title')
temp[i].alt = util.getUrlQueryString(temp[i].url.url, 'title')
temp[i].title = util.getUrlQueryString(temp[i].url.url, "title");
temp[i].alt = util.getUrlQueryString(temp[i].url.url, "title");
}
}
// array to object
const result = {}
const result = {};
for (const i of Object.keys(temp)) {
result[i] = temp[i];
... ... @@ -217,11 +260,11 @@ export default {
return result;
},
getValue(){
getValue() {
return this.handleSaveData(this.value_);
},
getType(){
return this.type_ || '0';
getType() {
return this.type_ || "0";
},
addId(m) {
m.id = this.$bus.genId();
... ... @@ -230,19 +273,17 @@ export default {
this.value_ = this.handleData(util.clone(newVal));
},
reSetType() {
this.type_ = '0';
this.type_ = "0";
},
reset() {
this.value_ = [];
}
},
watch: {
value(newVal) {
// console.log('watch===newVal'+this.isSelectAction)
// console.log(newVal)
this.type_ = this.size || '0';
value(newVal) {
// console.log("watch===newVal" + this.isSelectAction);
// console.log(newVal);
this.type_ = this.size || "0";
this.value_ = this.handleData(util.clone(newVal));
}
},
... ... @@ -256,7 +297,6 @@ export default {
<style lang="scss" scoped>
.banner-table {
width: 100%;
border-collapse: collapse;
... ... @@ -281,6 +321,5 @@ tr:hover {
padding: 20px;
min-width: 320px;
}
</style>
... ...
<template>
<div>
<Form>
<FormItem>
<Select v-model="action_" :disabled="isSelectAction">
<Option v-for="item in actionList" :value="item.value" :label="item.label"></Option>
</Select>
</FormItem>
<div>
<Form>
<FormItem>
<div>
<label>业务线:</label>
<i-radio-group v-model.sync="lob_">
<i-radio label="new">新品</i-radio>
<i-radio label="used">二手</i-radio>
</i-radio-group>
</div>
</FormItem>
<FormItem>
<Select v-model="action_" :disabled="isSelectAction">
<Option v-for="item in actionList" :value="item.value" :label="item.label"></Option>
</Select>
</FormItem>
<FormItem>
<h5-url v-if="action_ === 'go.h5'" v-model="url_"></h5-url>
<pool-url v-else-if="action_ === 'go.pool'" v-model="url_"></pool-url>
<detail-url v-else-if="action_ === 'go.detail'" v-model="url_"></detail-url>
<list-url v-else-if="action_ === 'go.list'" v-model="url_"></list-url>
<calendar-url v-else-if="action_ === 'go.calendar'" v-model="url_"></calendar-url>
<hotlist-url v-else-if="action_ === 'go.hotlist'" v-model="url_"></hotlist-url>
<tab-url v-else-if="action_ === 'go.channel'" v-model="url_" ></tab-url>
</FormItem>
</Form>
</div>
<FormItem>
<h5-url v-if="action_ === 'go.h5'" v-model="url_"></h5-url>
<pool-url v-else-if="action_ === 'go.pool'" v-model="url_"></pool-url>
<detail-url v-else-if="action_ === 'go.detail'" v-model="url_"></detail-url>
<list-url v-else-if="action_ === 'go.list'" v-model="url_"></list-url>
<calendar-url v-else-if="action_ === 'go.calendar'" v-model="url_"></calendar-url>
<hotlist-url v-else-if="action_ === 'go.hotlist'" v-model="url_"></hotlist-url>
<tab-url v-else-if="action_ === 'go.channel'" v-model="url_"></tab-url>
</FormItem>
</Form>
</div>
</template>
<script>
import h5 from "./banner-h5";
import pool from "./banner-pool";
import detail from "./banner-detail";
import list from "./banner-list";
import calendar from "./banner-calendar";
import tab from "./tab-editor-new";
import hotlist from "./banner-hotlist";
import util from "@/libs/util";
import h5 from './banner-h5';
import pool from './banner-pool';
import detail from './banner-detail';
import list from './banner-list';
import calendar from './banner-calendar';
import tab from './tab-editor-new';
import hotlist from './banner-hotlist';
import util from '@/libs/util';
export default {
props: ["value", "type", "isSelectAction"],
export default {
props: ['value','type', 'isSelectAction'],
data() {
// console.log('this.value')
// console.log(this.value)
return {
url_: this.value.url? this.value.url : '',
action_: this.value.action ? this.value.action : 'go.h5',
islogin: this.value.islogin,
headerid: this.value.headerid,
actionList: this.initAction(),
};
},
methods: {
initAction() {
let action = [];
if(this.type === 'H5'){
action = [
data() {
// console.log("this.value");
// console.log(this.value);
return {
url_: this.value.url ? this.value.url : "",
action_: this.value.action ? this.value.action : "go.h5",
islogin: this.value.islogin,
headerid: this.value.headerid,
actionList: this.initAction(),
lob_: this.getLob() || "new"
};
},
methods: {
initAction() {
let action = [];
if (this.type === "H5") {
action = [
{
value: 'go.h5',
label: 'H5网页',
value: "go.h5",
label: "H5网页"
},
{
value: 'go.pool',
label: '商品池',
value: "go.pool",
label: "商品池"
},
{
value: 'go.list',
label: '商品列表',
value: "go.list",
label: "商品列表"
},
{
value: 'go.detail',
label: '商品详情',
value: "go.detail",
label: "商品详情"
},
{
value: 'go.channel',
label: '首页频道Tab',
},
]
}else {
action = [
value: "go.channel",
label: "首页频道Tab"
}
];
} else {
action = [
{
value: 'go.h5',
label: 'H5网页',
value: "go.h5",
label: "H5网页"
},
{
value: 'go.pool',
label: '商品池',
value: "go.pool",
label: "商品池"
},
{
value: 'go.detail',
label: '商品详情',
value: "go.detail",
label: "商品详情"
},
{
value: 'go.list',
label: '商品列表',
value: "go.list",
label: "商品列表"
},
{
value: 'go.calendar',
label: '发售日历页',
value: "go.calendar",
label: "发售日历页"
},
{
value: 'go.hotlist',
label: '热卖列表页',
value: "go.hotlist",
label: "热卖列表页"
},
{
value: 'go.bargainlist',
label: '砍价列表页',
value: "go.bargainlist",
label: "砍价列表页"
},
{
value: 'go.identifyList',
label: '鉴定服务',
value: "go.identifyList",
label: "鉴定服务"
},
{
value: 'go.channel',
label: '首页频道Tab',
value: "go.channel",
label: "首页频道Tab"
}
]
];
}
return action;
},
updateStatus() {
const data = {url: this.url_, action: this.action_};
getLob() {
// console.log("getLob(url)" + this.value.url);
let params = util.qsParse(this.value.url);
// console.log("getLob()");
// console.log(params);
return params.business || "new";
},
updateStatus() {
// console.log("=updateStatus=this.url==");
// console.log(this.url_);
// console.log(this.lob_);
const data = { url: this.url_, action: this.action_ };
if (this.islogin) {
data.islogin = this.islogin;
}
if (this.islogin) {
data.islogin = this.islogin;
}
if (this.headerid) {
data.headerid = this.headerid;
}
this.$emit('input', data);
if (this.headerid) {
data.headerid = this.headerid;
}
},
watch: {
url_(newVal) {
this.updateStatus();
},
action_(newVal) {
if (newVal === 'go.detail') {
this.url_ = 'https://m.yohobuy.com/?pagename=productDetail';
} else if (newVal === 'go.pool') {
this.url_ = 'https://m.yohobuy.com/?pagename=productList';
} else if (newVal === 'go.list') {
this.url_ = '';
} else if (newVal === 'go.h5') {
this.url_ = '';
} else if (newVal === 'go.calendar') {
this.url_ = 'https://m.yohobuy.com/?pagename=saleCalendar';
} else if (newVal === 'go.hotlist') {
this.url_ = 'https://m.yohobuy.com/?pagename=hotSale';
} else if (newVal === 'go.bargainlist') { // 砍价列表
this.url_ = 'https://m.yohobuy.com/';
} else if('go.identifyList') {
this.url_ = 'https://m.yohobuy.com/?pagename=identifyList';
} else if (newVal === 'go.channel') {
this.url_ = 'https://m.yohobuy.com/?pagename=home';
}
this.updateStatus();
this.$emit("input", data);
}
},
watch: {
url_(newVal) {
// console.log('url_(newVal)')
let host = util.getLink(newVal)
// console.log(host)
let params = util.qsParse(newVal);
// console.log(params)
params.business = this.lob_;
let queryStr = util.qsStringify(params);
// console.log(queryStr)
this.url_ = host+"?" + queryStr;
this.updateStatus();
},
action_(newVal) {
if (newVal === "go.detail") {
this.url_ = "https://m.yohobuy.com/?pagename=productDetail";
} else if (newVal === "go.pool") {
this.url_ = "https://m.yohobuy.com/?pagename=productList";
} else if (newVal === "go.list") {
this.url_ = "";
} else if (newVal === "go.h5") {
this.url_ = "";
} else if (newVal === "go.calendar") {
this.url_ = "https://m.yohobuy.com/?pagename=saleCalendar";
} else if (newVal === "go.hotlist") {
this.url_ = "https://m.yohobuy.com/?pagename=hotSale";
} else if (newVal === "go.bargainlist") {
// 砍价列表
this.url_ = "https://m.yohobuy.com/";
} else if ("go.identifyList") {
this.url_ = "https://m.yohobuy.com/?pagename=identifyList";
} else if (newVal === "go.channel") {
this.url_ = "https://m.yohobuy.com/?pagename=home";
}
this.updateStatus();
},
components: {
h5Url: h5,
poolUrl: pool,
detailUrl: detail,
listUrl: list,
calendarUrl: calendar,
hotlistUrl: hotlist,
tabUrl: tab
lob_(newVal) {
let host = util.getLink(this.value.url)
let params = util.qsParse(this.value.url);
params.business = newVal;
let queryStr = util.qsStringify(params);
this.url_ = host+"?" + queryStr;
// this.updateStatus();
}
};
},
components: {
h5Url: h5,
poolUrl: pool,
detailUrl: detail,
listUrl: list,
calendarUrl: calendar,
hotlistUrl: hotlist,
tabUrl: tab
}
};
</script>
<style>
</style>
... ...
<template>
<i-modal v-model="visiable" :loading="posting" :title="allreadonly ? '查看优惠券' : '创建/编辑优惠券'" @on-ok="onOk" width="600">
<i-modal
v-model="visiable"
:loading="posting"
:title="allreadonly ? '查看优惠券' : '创建/编辑优惠券'"
@on-ok="onOk"
width="600"
>
<i-spin v-if="loading"></i-spin>
<i-form v-else ref="formCoupon" :rules="ruleValidate" :model="formData" :label-width="80">
<i-form-item class="form-group" label="优惠券类型"></i-form-item>
... ... @@ -12,26 +18,53 @@
</i-form-item>
<i-form-item class="form-group" label="基本信息"></i-form-item>
<i-form-item label="Token" v-if="couponToken">
{{couponToken}}
</i-form-item>
<i-form-item label="Token" v-if="couponToken">{{couponToken}}</i-form-item>
<i-form-item label="名称" prop="couponName">
<i-input placeholder="名称建议30字以内" v-model="formData.couponName" :disabled="allreadonly" style="width: 200px"></i-input>
<i-input
placeholder="名称建议30字以内"
v-model="formData.couponName"
:disabled="allreadonly"
style="width: 200px"
></i-input>
</i-form-item>
<i-form-item label="数量" prop="couponNum">
<i-input-number placeholder="数量" v-model="formData.couponNum" :disabled="allreadonly" style="width: 100px;"></i-input-number>
<i-input-number
placeholder="数量"
v-model="formData.couponNum"
:disabled="allreadonly"
style="width: 100px;"
></i-input-number>
</i-form-item>
<i-form-item label="使用次数" prop="useNum">
<i-input placeholder="使用次数" v-model="formData.useNum" disabled style="width: 100px;"></i-input>
</i-form-item>
<i-form-item label="使用期限" prop="time">
<i-date-picker type="datetimerange" v-model="formData.time" :disabled="allreadonly" placeholder="使用期限" format="yyyy-MM-dd HH:mm:ss" style="width: 250px"></i-date-picker>
<i-date-picker
type="datetimerange"
v-model="formData.time"
:disabled="allreadonly"
placeholder="使用期限"
format="yyyy-MM-dd HH:mm:ss"
style="width: 250px"
></i-date-picker>
</i-form-item>
<i-form-item label="领券期限" prop="receiveTime">
<i-date-picker type="datetimerange" v-model="formData.receiveTime" :disabled="readonly" placeholder="领券期限" format="yyyy-MM-dd HH:mm:ss" style="width: 250px"></i-date-picker>
<i-date-picker
type="datetimerange"
v-model="formData.receiveTime"
:disabled="readonly"
placeholder="领券期限"
format="yyyy-MM-dd HH:mm:ss"
style="width: 250px"
></i-date-picker>
</i-form-item>
<i-form-item label="优惠券说明" prop="remark">
<i-input type="textarea" placeholder="优惠券使用条件简介" :disabled="allreadonly" v-model="formData.remark"></i-input>
<i-input
type="textarea"
placeholder="优惠券使用条件简介"
:disabled="allreadonly"
v-model="formData.remark"
></i-input>
</i-form-item>
<i-form-item class="form-group" label="使用条件"></i-form-item>
<i-form-item label="优惠条件" prop="useLimitType" style="display: inline-block; width: 100%">
... ... @@ -42,13 +75,21 @@
<div style="display: inline-block" v-if="formData.useLimitType === 2">
&nbsp;
金额满:
<i-input-number style="width: 100px" :disabled="readonly" placeholder="限制金额" v-model="formData.useLimitValue">
</i-input-number>
<i-input-number
style="width: 100px"
:disabled="readonly"
placeholder="限制金额"
v-model="formData.useLimitValue"
></i-input-number>
</div>
</i-form-item>
<i-form-item label="优惠金额" prop="couponAmount">
<i-input-number placeholder="优惠金额" :disabled="readonly" v-model="formData.couponAmount" style="width: 100px">
</i-input-number>
<i-input-number
placeholder="优惠金额"
:disabled="readonly"
v-model="formData.couponAmount"
style="width: 100px"
></i-input-number>
</i-form-item>
<i-form-item label="适用范围" prop="productLimitType">
... ... @@ -59,15 +100,26 @@
</i-select>
</i-form-item>
<i-form-item prop="productLimitValue" v-if="formData.productLimitType === 1 || formData.productLimitType === 3">
<i-input type="textarea" :disabled="readonly" placeholder="填写商品编码,多个商品编码用英文逗号分隔" v-model="formData.productLimitValue"></i-input>
<i-form-item
prop="productLimitValue"
v-if="formData.productLimitType === 1 || formData.productLimitType === 3"
>
<i-input
type="textarea"
:disabled="readonly"
placeholder="填写商品编码,多个商品编码用英文逗号分隔"
v-model="formData.productLimitValue"
></i-input>
<i-poptip trigger="hover">
<div slot="content">
<p>1.上传文件必须是xlsx文件</p>
<p>2.第一行标题栏:商品编码</p>
<p>3.<a href="javascript:;" @click="onExample">下载样例</a></p>
<p>
3.
<a href="javascript:;" @click="onExample">下载样例</a>
</p>
</div>
<i-upload action="" :format="['xlsx']" :max-size="1024" :before-upload="onBeforeUpload">
<i-upload action :format="['xlsx']" :max-size="1024" :before-upload="onBeforeUpload">
<i-button type="success" size="small" :disabled="readonly">导入</i-button>
<p>{{uploadTxt}}</p>
</i-upload>
... ... @@ -105,392 +157,459 @@
<checkbox label="闲鱼" :disabled="readonly"></checkbox>
</checkbox-group>
</i-form-item>
<i-form-item label="需要校验" prop="checkRequired">
<checkbox v-model="formData.isCheckRequired" :disabled="readonly" @on-change="getCheckRequired"></checkbox>
</i-form-item>
</i-form>
</i-modal>
</template>
<script>
import Api from 'api/api';
import dayjs from 'dayjs';
import XLSX from 'xlsx';
import Api from "api/api";
import dayjs from "dayjs";
import XLSX from "xlsx";
const api = new Api();
const forbidenTypeMap = {
'现货': 1,
'预售': 4,
'二手': 6,
'全新瑕疵': 5,
'闪购': 3
};
const forbidenLabelMap = {
1: '现货',
4: '预售',
6: '二手',
5: '全新瑕疵',
3: '闪购'
};
const api = new Api();
const forbidenTypeMap = {
现货: 1,
预售: 4,
二手: 6,
全新瑕疵: 5,
闪购: 3
};
const forbidenLabelMap = {
1: "现货",
4: "预售",
6: "二手",
5: "全新瑕疵",
3: "闪购"
};
const allowTypeMap = {
// '线下店订单': '2',
'极速发货': '9-N',
'极速寄存': '9-Y',
'预售': '4',
'瑕疵': '5',
'二手' : '6',
// '鉴定': '8',
'海外直邮': '17',
'现货发货': '1-N',
'现货寄存': '1-Y',
'闪购发货': '3-N',
'闪购寄存': '3-Y'
};
const allowLabelMap = {
// '2': '线下店订单',
'9-N': '极速发货',
'9-Y': '极速寄存',
'4': '预售',
'5': '瑕疵',
'6': '二手',
// '8': '鉴定',
'17': '海外直邮',
'1-N': '现货发货',
'1-Y': '现货寄存',
'3-N': '闪购发货',
'3-Y':'闪购寄存'
};
const allowTypeMap = {
// '线下店订单': '2',
极速发货: "9-N",
极速寄存: "9-Y",
预售: "4",
瑕疵: "5",
二手: "6",
// '鉴定': '8',
海外直邮: "17",
现货发货: "1-N",
现货寄存: "1-Y",
闪购发货: "3-N",
闪购寄存: "3-Y"
};
const allowLabelMap = {
// '2': '线下店订单',
"9-N": "极速发货",
"9-Y": "极速寄存",
"4": "预售",
"5": "瑕疵",
"6": "二手",
// '8': '鉴定',
"17": "海外直邮",
"1-N": "现货发货",
"1-Y": "现货寄存",
"3-N": "闪购发货",
"3-Y": "闪购寄存"
};
const businessClientTypeMap = {
'UFO': 'ufo',
'闲鱼': 'h5/xianyu'
};
const businessClientLabelMap = {
'ufo': 'UFO',
'h5/xianyu': '闲鱼',
};
UFO: "ufo",
闲鱼: "h5/xianyu"
};
const businessClientLabelMap = {
ufo: "UFO",
"h5/xianyu": "闲鱼"
};
export default {
components: {},
name: 'ModalCreateCoupon',
data() {
return {
readonly: false,
allreadonly: false,
visiable: false,
loading: false,
posting: true,
uploadTxt: '',
couponToken: '',
formData: {
id: 0,
couponName: '',
couponType: 0,
couponNum: 0,
useNum: 1,
couponAmount: 0,
useLimitType: 0,
remark: '',
productLimitType: 2,
productLimitValue: '',
useLimitValue: 0,
time: ['', ''],
receiveTime: ['', ''],
// skupForbidTypeLable:[],
// skupForbidType: ''
skupAllowTypeLabel: [],
skupAllowType: '',
businessClient: ''
export default {
components: {},
name: "ModalCreateCoupon",
data() {
return {
readonly: false,
allreadonly: false,
visiable: false,
loading: false,
posting: true,
uploadTxt: "",
couponToken: "",
formData: {
id: 0,
couponName: "",
couponType: 0,
couponNum: 0,
useNum: 1,
couponAmount: 0,
useLimitType: 0,
remark: "",
productLimitType: 2,
productLimitValue: "",
useLimitValue: 0,
time: ["", ""],
receiveTime: ["", ""],
// skupForbidTypeLable:[],
// skupForbidType: ''
skupAllowTypeLabel: [],
skupAllowType: "",
businessClient: "",
checkRequired: 0,
isCheckRequired: true,
},
ruleValidate: {
couponType: {
required: true,
validator: (rule, value, callback) => {
if (value === 0 || value === "0") {
callback(new Error("请选择优惠券类型"));
} else {
callback();
}
}
},
ruleValidate: {
couponType: {required: true, validator: (rule, value, callback) => {
if (value === 0 || value === '0') {
callback(new Error('请选择优惠券类型'));
} else {
callback();
}
}},
couponName: {required: true, max: 30, message: '请输入名称'},
couponNum: {type: 'number', required: true, min: 1, message: '请输入数量'},
couponAmount: {type: 'number', required: true, min: 1, message: '请输入优惠金额'},
time: {required: true, validator: (rule, value, callback) => {
if (value.some(v => !v)) {
callback(new Error('请选择使用期限'));
couponName: { required: true, max: 30, message: "请输入名称" },
couponNum: {
type: "number",
required: true,
min: 1,
message: "请输入数量"
},
couponAmount: {
type: "number",
required: true,
min: 1,
message: "请输入优惠金额"
},
time: {
required: true,
validator: (rule, value, callback) => {
if (value.some(v => !v)) {
callback(new Error("请选择使用期限"));
} else {
callback();
}
}
},
receiveTime: {
required: true,
validator: (rule, value, callback) => {
if (value.some(v => !v)) {
callback(new Error("请选择领券期限"));
} else {
let endTime = this.formData.time[1]
? dayjs(this.formData.time[1]).unix()
: void 0;
let receiveEndTime = value[1] ? dayjs(value[1]).unix() : void 0;
// console.log('====/'+endTime+"///===/"+receiveEndTime)
if (endTime < receiveEndTime) {
callback(new Error("请选择领券结束时间小于使用结束时间"));
} else {
callback();
}
}},
receiveTime: {required: true, validator: (rule, value, callback) => {
if (value.some(v => !v)) {
callback(new Error('请选择领券期限'));
} else {
let endTime = this.formData.time[1] ? dayjs(this.formData.time[1]).unix() : void 0;
let receiveEndTime = value[1] ? dayjs(value[1]).unix() : void 0;
// console.log('====/'+endTime+"///===/"+receiveEndTime)
if(endTime < receiveEndTime){
callback(new Error('请选择领券结束时间小于使用结束时间'));
}else {
}
}
},
remark: { required: true, message: "请输入优惠券说明" },
useLimitType: {
required: true,
validator: (rule, value, callback) => {
if (value >= 0) {
if (value === 2) {
if (parseInt(this.formData.useLimitValue) > 0) {
callback();
}
}
}},
remark: {required: true, message: '请输入优惠券说明'},
useLimitType: {required: true, validator: (rule, value, callback) => {
if (value >= 0) {
if (value === 2) {
if (parseInt(this.formData.useLimitValue) > 0) {
callback();
} else {
callback(new Error('请输入限制金额'));
}
} else {
callback();
callback(new Error("请输入限制金额"));
}
} else {
callback(new Error('请选择优惠条件'));
}
}},
productLimitValue: {required: false, validator: (rule, value, callback) => {
const ids = (value || '').split(',');
if (!value || !ids.length) {
callback(new Error('请输入适用范围'));
} else if(ids.some(id => id ? !parseInt(id) : false)) {
callback(new Error('适用范围格式错误'));
} else {
callback();
}
}},
productLimitType: {required: true, validator: (rule, value, callback) => {
if (value === 1 || value === 2 || value === 3) {
callback();
} else {
callback(new Error('请选择类型'));
}
}}
}
};
},
methods: {
async show(id, readonly, allreadonly) {
// console.log(id)
this.readonly = readonly;
this.allreadonly = allreadonly;
this.posting = this.visiable = true;
this.$refs.formCoupon.resetFields();
this.couponToken = '';
let initData = {
id: 0,
couponName: '',
couponNum: 0,
couponType: 0,
useNum: 1,
couponAmount: 0,
useLimitType: 0,
remark: '',
productLimitValue: '',
productLimitType: 2,
useLimitValue: 0,
time: ['', ''],
skupAllowTypeLabel: [],
skupAllowType: '',
businessClientLabel: [],
businessClient: ''
// skupForbidTypeLable:[],
// skupForbidType: ''
};
if (id) {
this.loading = true;
const result = await api._get('/ufoPlatform/coupon/getCouponInfo', {
id
});
// console.log(result);
this.loading = false;
if (result.code === 200) {
const coupon = result.data.coupon;
const productLimits = result.data.productLimits;
this.couponToken = coupon.couponToken;
let skupAllowTypeLabel = [];
if (coupon.skupAllowType) {
let arr = coupon.skupAllowType.split(',');
for(let i = 0; i < arr.length; i++) {
skupAllowTypeLabel.push(allowLabelMap[arr[i]]);
}
} else {
callback(new Error("请选择优惠条件"));
}
}
},
productLimitValue: {
required: false,
validator: (rule, value, callback) => {
const ids = (value || "").split(",");
let businessClientTypeLabel = [];
if (coupon.businessClient) {
let arr = coupon.businessClient.split(',');
for(let i = 0; i < arr.length; i++) {
businessClientTypeLabel.push(businessClientLabelMap[arr[i]]);
}
if (!value || !ids.length) {
callback(new Error("请输入适用范围"));
} else if (ids.some(id => (id ? !parseInt(id) : false))) {
callback(new Error("适用范围格式错误"));
} else {
callback();
}
initData = {
id,
couponName: coupon.couponName,
couponNum: coupon.couponNum,
couponType: coupon.couponType || 0,
useNum: coupon.useNum,
couponAmount: coupon.couponAmount,
useLimitType: coupon.useLimitType,
remark: coupon.remark,
productLimitType: coupon.productLimitType,
productLimitValue: (productLimits || []).map(i => i.productId).join(','),
useLimitValue: coupon.useLimitValue,
time: [dayjs.unix(coupon.startTime).format('YYYY-MM-DD HH:mm:ss'), dayjs.unix(coupon.endTime).format('YYYY-MM-DD HH:mm:ss')],
receiveTime: [dayjs.unix(coupon.receiveStartTime).format('YYYY-MM-DD HH:mm:ss'), dayjs.unix(coupon.receiveEndTime).format('YYYY-MM-DD HH:mm:ss')],
skupAllowTypeLabel: skupAllowTypeLabel,
skupAllowType: coupon.skupAllowType,
businessClientLabel: businessClientTypeLabel,
businessClient: coupon.businessClient, //购买渠道
};
} else {
result.message && this.$Message.warning(result.message);
}
}
this.formData = initData;
},
onOk() {
this.$refs.formCoupon.validate(valid => {
if (!valid) {
this.posting = false;
this.$nextTick(() => {
this.posting = true;
});
} else {
this.saveData(this.formData);
},
productLimitType: {
required: true,
validator: (rule, value, callback) => {
if (value === 1 || value === 2 || value === 3) {
callback();
} else {
callback(new Error("请选择类型"));
}
}
});
},
getCheckBox() { // checkbox勾选取消的监测
let arr = [];
for (let i = 0; i < this.formData.skupAllowTypeLabel.length; i++) {
let allowType = this.formData.skupAllowTypeLabel[i];
// console.log(allowType);
arr.push(allowTypeMap[allowType]);
}
// console.log(arr);
this.formData.skupAllowType = arr.join(',');
},
getChannelCheckBox(){
let arr = [];
for (let i = 0; i < this.formData.businessClientLabel.length; i++) {
let businessClientType = this.formData.businessClientLabel[i];
// console.log(businessClientType);
arr.push(businessClientTypeMap[businessClientType]);
}
// console.log(arr);
this.formData.businessClient = arr.join(',');
},
async saveData(params) {
if (this.allreadonly) {
this.visiable = false;
return;
}
}
};
},
methods: {
async show(id, readonly, allreadonly) {
// console.log(id)
this.readonly = readonly;
this.allreadonly = allreadonly;
this.posting = this.visiable = true;
this.$refs.formCoupon.resetFields();
this.couponToken = "";
let initData = {
id: 0,
couponName: "",
couponNum: 0,
couponType: 0,
useNum: 1,
couponAmount: 0,
useLimitType: 0,
remark: "",
productLimitValue: "",
productLimitType: 2,
useLimitValue: 0,
time: ["", ""],
skupAllowTypeLabel: [],
skupAllowType: "",
businessClientLabel: [],
businessClient: "",
checkRequired: 0
// skupForbidTypeLable:[],
// skupForbidType: ''
};
const result = await api._post('/ufoPlatform/coupon/saveOrUpdateCoupon', {
id: params.id || void 0,
couponName: params.couponName,
couponAmount: params.couponAmount,
couponNum: params.couponNum,
couponType: params.couponType,
useNum: params.useNum,
useLimitValue: params.useLimitValue,
productLimitType: params.productLimitType,
productLimitValue: params.productLimitValue,
remark: params.remark,
useLimitType: parseInt(params.useLimitType) >= 0 ? params.useLimitType : void 0,
startTime: params.time[0] ? dayjs(params.time[0]).unix() : void 0,
endTime: params.time[1] ? dayjs(params.time[1]).unix() : void 0,
skupAllowType: params.skupAllowType,
businessClient: params.businessClient,
receiveStartTime: params.receiveTime[0] ? dayjs(params.receiveTime[0]).unix() : void 0,
receiveEndTime: params.receiveTime[1] ? dayjs(params.receiveTime[1]).unix() : void 0,
if (id) {
this.loading = true;
const result = await api._get("/ufoPlatform/coupon/getCouponInfo", {
id
});
// console.log('result=', result);
// console.log(result);
this.loading = false;
if (result.code === 200) {
this.$Message.success('保存成功');
this.visiable = false;
this.$emit('on-created');
const coupon = result.data.coupon;
const productLimits = result.data.productLimits;
this.couponToken = coupon.couponToken;
let skupAllowTypeLabel = [];
if (coupon.skupAllowType) {
let arr = coupon.skupAllowType.split(",");
for (let i = 0; i < arr.length; i++) {
skupAllowTypeLabel.push(allowLabelMap[arr[i]]);
}
}
let businessClientTypeLabel = [];
if (coupon.businessClient) {
let arr = coupon.businessClient.split(",");
for (let i = 0; i < arr.length; i++) {
businessClientTypeLabel.push(businessClientLabelMap[arr[i]]);
}
}
let isCheckRequired = coupon.checkRequired === 1
console.log('=====:'+isCheckRequired)
initData = {
id,
couponName: coupon.couponName,
couponNum: coupon.couponNum,
couponType: coupon.couponType || 0,
useNum: coupon.useNum,
couponAmount: coupon.couponAmount,
useLimitType: coupon.useLimitType,
remark: coupon.remark,
productLimitType: coupon.productLimitType,
productLimitValue: (productLimits || [])
.map(i => i.productId)
.join(","),
useLimitValue: coupon.useLimitValue,
time: [
dayjs.unix(coupon.startTime).format("YYYY-MM-DD HH:mm:ss"),
dayjs.unix(coupon.endTime).format("YYYY-MM-DD HH:mm:ss")
],
receiveTime: [
dayjs.unix(coupon.receiveStartTime).format("YYYY-MM-DD HH:mm:ss"),
dayjs.unix(coupon.receiveEndTime).format("YYYY-MM-DD HH:mm:ss")
],
skupAllowTypeLabel: skupAllowTypeLabel,
skupAllowType: coupon.skupAllowType,
businessClientLabel: businessClientTypeLabel,
businessClient: coupon.businessClient, //购买渠道
checkRequired: coupon.checkRequired,
isCheckRequired
};
} else {
result.message && this.$Message.warning(result.message);
}
}
this.formData = initData;
},
onOk() {
this.$refs.formCoupon.validate(valid => {
if (!valid) {
this.posting = false;
this.$nextTick(() => {
this.posting = true;
});
} else {
this.saveData(this.formData);
}
},
onBeforeUpload(file) {
const fileExt = file.name.split('.').pop().toLocaleLowerCase();
// console.log(fileExt)
if (fileExt !== 'xlsx') {
this.$Message.warning('文件格式错误');
return false;
}
if (file.size > 1024 * 1024) {
this.$Message.warning('文件大小超过1M');
return false;
}
const reader = new FileReader();
});
},
getCheckRequired(checked) {
if(checked) {
this.formData.checkRequired = 1
}else {
this.formData.checkRequired = 0
}
},
getCheckBox() {
// checkbox勾选取消的监测
let arr = [];
for (let i = 0; i < this.formData.skupAllowTypeLabel.length; i++) {
let allowType = this.formData.skupAllowTypeLabel[i];
// console.log(allowType);
arr.push(allowTypeMap[allowType]);
}
// console.log(arr);
this.formData.skupAllowType = arr.join(",");
},
getChannelCheckBox() {
let arr = [];
for (let i = 0; i < this.formData.businessClientLabel.length; i++) {
let businessClientType = this.formData.businessClientLabel[i];
// console.log(businessClientType);
arr.push(businessClientTypeMap[businessClientType]);
}
reader.readAsArrayBuffer(file);
reader.onloadstart = () => {
this.uploadTxt = '开始读取';
};
reader.onprogress = e => {
this.uploadTxt = `进度:${Math.round(e.loaded / e.total * 100)}...`;
};
reader.onerror = () => {
this.uploadTxt = '文件读取出错';
};
reader.onload = e => {
this.uploadTxt = '';
try {
const data = e.target.result;
const workbook = XLSX.read(data, { type: 'array' });
const firstSheetName = workbook.SheetNames[0];
const worksheet = workbook.Sheets[firstSheetName];
const results = XLSX.utils.sheet_to_json(worksheet);
// console.log(arr);
this.formData.businessClient = arr.join(",");
},
async saveData(params) {
if (this.allreadonly) {
this.visiable = false;
return;
}
this.formData.productLimitValue = results.map(r => r['商品编码']).filter(r => r).join(',');
const result = await api._post("/ufoPlatform/coupon/saveOrUpdateCoupon", {
id: params.id || void 0,
couponName: params.couponName,
couponAmount: params.couponAmount,
couponNum: params.couponNum,
couponType: params.couponType,
useNum: params.useNum,
useLimitValue: params.useLimitValue,
productLimitType: params.productLimitType,
productLimitValue: params.productLimitValue,
remark: params.remark,
useLimitType:
parseInt(params.useLimitType) >= 0 ? params.useLimitType : void 0,
startTime: params.time[0] ? dayjs(params.time[0]).unix() : void 0,
endTime: params.time[1] ? dayjs(params.time[1]).unix() : void 0,
skupAllowType: params.skupAllowType,
businessClient: params.businessClient,
receiveStartTime: params.receiveTime[0]
? dayjs(params.receiveTime[0]).unix()
: void 0,
receiveEndTime: params.receiveTime[1]
? dayjs(params.receiveTime[1]).unix()
: void 0,
checkRequired:params.checkRequired
} catch (error) {
this.uploadTxt = '文件解析失败,请按照格式上传';
}
});
// console.log('result=', result);
};
if (result.code === 200) {
this.$Message.success("保存成功");
this.visiable = false;
this.$emit("on-created");
} else {
result.message && this.$Message.warning(result.message);
this.posting = false;
this.$nextTick(() => {
this.posting = true;
});
}
},
onBeforeUpload(file) {
const fileExt = file.name
.split(".")
.pop()
.toLocaleLowerCase();
// console.log(fileExt)
if (fileExt !== "xlsx") {
this.$Message.warning("文件格式错误");
return false;
},
onExample() {
const wb = XLSX.utils.book_new();
const ws = XLSX.utils.json_to_sheet([{
'商品编码': '123456'
}]);
XLSX.utils.book_append_sheet(wb, ws, '优惠券适用范围示例');
XLSX.writeFile(wb, '优惠券适用范围示例.xlsx');
}
if (file.size > 1024 * 1024) {
this.$Message.warning("文件大小超过1M");
return false;
}
const reader = new FileReader();
reader.readAsArrayBuffer(file);
reader.onloadstart = () => {
this.uploadTxt = "开始读取";
};
reader.onprogress = e => {
this.uploadTxt = `进度:${Math.round((e.loaded / e.total) * 100)}...`;
};
reader.onerror = () => {
this.uploadTxt = "文件读取出错";
};
reader.onload = e => {
this.uploadTxt = "";
try {
const data = e.target.result;
const workbook = XLSX.read(data, { type: "array" });
const firstSheetName = workbook.SheetNames[0];
const worksheet = workbook.Sheets[firstSheetName];
const results = XLSX.utils.sheet_to_json(worksheet);
this.formData.productLimitValue = results
.map(r => r["商品编码"])
.filter(r => r)
.join(",");
} catch (error) {
this.uploadTxt = "文件解析失败,请按照格式上传";
}
};
return false;
},
onExample() {
const wb = XLSX.utils.book_new();
const ws = XLSX.utils.json_to_sheet([
{
商品编码: "123456"
}
]);
XLSX.utils.book_append_sheet(wb, ws, "优惠券适用范围示例");
XLSX.writeFile(wb, "优惠券适用范围示例.xlsx");
}
};
}
};
</script>
<style lang="scss" scoped>
.form-group {
width: 100%;
height: 30px;
background-color: #f5f7f9;
}
.ivu-form-item-label {
width: 90px !important;
}
.form-group {
width: 100%;
height: 30px;
background-color: #f5f7f9;
}
.ivu-form-item-label {
width: 90px !important;
}
</style>
... ...
... ... @@ -179,6 +179,7 @@
imgId: '0',
src: '',
title: '',
// business: "new",
hideDeleteButton: true,
url: {
action: 'go.h5',
... ... @@ -199,6 +200,7 @@
imgId: '0',
src: '',
title: '',
// business: "new",
hideDeleteButton: true,
url: {
action: 'go.h5',
... ... @@ -211,6 +213,7 @@
imgId: '0',
src: '',
title: '',
// business: "new",
hideDeleteButton: true,
url: {
action: 'go.h5',
... ... @@ -231,6 +234,7 @@
imgId: '0',
src: '',
title: '',
// business: "new",
hideDeleteButton: true,
url: {
action: 'go.h5',
... ... @@ -243,6 +247,7 @@
imgId: '0',
src: '',
title: '',
// business: "new",
hideDeleteButton: true,
url: {
action: 'go.h5',
... ... @@ -255,6 +260,7 @@
imgId: '0',
src: '',
title: '',
// business: "new",
hideDeleteButton: true,
url: {
action: 'go.h5',
... ... @@ -276,6 +282,7 @@
imgId: '0',
src: '',
title: '',
// business: "new",
hideDeleteButton: true,
url: {
action: 'go.h5',
... ... @@ -298,6 +305,7 @@
imgId: '0',
src: '',
title: '',
// business: "new",
hideDeleteButton: true,
url: {
action: 'go.pool',
... ... @@ -317,6 +325,8 @@
"0":{
tabName: "",
code: "",
// business: "new",
hideDeleteButton: true,
url: {
action: 'go.channel',
url: ''
... ... @@ -338,6 +348,7 @@
imgId: '0',
src: '',
title: '',
// business: "new",
hideDeleteButton: true,
url: {
action: 'go.h5',
... ...