Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
marketing
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
marketing-web
marketing
Commits
2f0ac6b0
Commit
2f0ac6b0
authored
Apr 22, 2019
by
chenxin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix:细节优化
parent
5b3417c6
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
788 additions
and
741 deletions
+788
-741
reset.scss
src/assets/style/base/reset.scss
+3
-0
strlen.js
src/utils/strlen.js
+16
-0
batch-dialog.vue
src/views/ecm/batch-dialog.vue
+2
-0
batch-list.vue
src/views/ecm/batch-list.vue
+3
-1
current-list.vue
src/views/ecm/current-list.vue
+2
-0
form.js
src/views/ecm/form.js
+752
-0
form.vue
src/views/ecm/form.vue
+10
-740
No files found.
src/assets/style/base/reset.scss
View file @
2f0ac6b0
...
@@ -221,6 +221,9 @@ a:hover {
...
@@ -221,6 +221,9 @@ a:hover {
cursor
:
no-drop
;
cursor
:
no-drop
;
}
}
.red
{
color
:
$danger-color
;
}
.blue
{
.blue
{
color
:
$primary-color
;
color
:
$primary-color
;
// cursor: pointer;
// cursor: pointer;
...
...
src/utils/strlen.js
View file @
2f0ac6b0
...
@@ -112,3 +112,19 @@ export default {
...
@@ -112,3 +112,19 @@ export default {
export
const
isEmpty
=
function
(
v
)
{
export
const
isEmpty
=
function
(
v
)
{
return
v
===
null
||
v
===
undefined
||
v
===
''
;
return
v
===
null
||
v
===
undefined
||
v
===
''
;
};
};
/**
* 判断小数点后有几位小数
* -- 正整数返回0
* */
export
const
numOfDecimal
=
function
(
v
)
{
if
(
isEmpty
(
v
)
||
isNaN
(
v
))
{
return
-
1
;
}
const
decimal
=
v
.
toString
().
split
(
'.'
);
if
(
decimal
.
length
===
1
)
{
return
0
;
}
else
{
return
decimal
[
1
].
length
;
}
};
src/views/ecm/batch-dialog.vue
View file @
2f0ac6b0
...
@@ -74,6 +74,8 @@ export default {
...
@@ -74,6 +74,8 @@ export default {
return
row
.
errCode
===
'0'
?
'满足'
:
'不满足'
;
return
row
.
errCode
===
'0'
?
'满足'
:
'不满足'
;
}
}
},
},
{
label
:
'主门店'
,
prop
:
'mainClerkCode'
,
minWidth
:
'120'
,
align
:
'left'
},
{
label
:
'专属导购'
,
prop
:
'mainStoreName'
,
minWidth
:
'120'
,
align
:
'left'
},
{
label
:
'备注'
,
prop
:
'errMsg'
,
minWidth
:
'120'
,
align
:
'left'
}
{
label
:
'备注'
,
prop
:
'errMsg'
,
minWidth
:
'120'
,
align
:
'left'
}
],
],
tableList
:
[],
tableList
:
[],
...
...
src/views/ecm/batch-list.vue
View file @
2f0ac6b0
...
@@ -80,7 +80,9 @@ export default {
...
@@ -80,7 +80,9 @@ export default {
{
label
:
'营销内容'
,
prop
:
'title'
,
minWidth
:
'120'
,
align
:
'left'
,
fixed
:
'left'
},
{
label
:
'营销内容'
,
prop
:
'title'
,
minWidth
:
'120'
,
align
:
'left'
,
fixed
:
'left'
},
{
label
:
'批次人次'
,
prop
:
'totalCount'
,
width
:
'120'
,
align
:
'left'
},
{
label
:
'批次人次'
,
prop
:
'totalCount'
,
width
:
'120'
,
align
:
'left'
},
{
label
:
'预计发送人次'
,
prop
:
'filterCount'
,
width
:
'120'
,
align
:
'left'
},
{
label
:
'预计发送人次'
,
prop
:
'filterCount'
,
width
:
'120'
,
align
:
'left'
},
{
label
:
'实际送达人次'
,
prop
:
'successCount'
,
width
:
'120'
,
align
:
'left'
}
{
label
:
'实际送达人次'
,
prop
:
'successCount'
,
width
:
'120'
,
align
:
'left'
},
{
label
:
'主门店'
,
prop
:
'mainClerkCode'
,
minWidth
:
'120'
,
align
:
'left'
},
{
label
:
'专属导购'
,
prop
:
'mainStoreName'
,
minWidth
:
'120'
,
align
:
'left'
}
],
],
tableList
:
[],
tableList
:
[],
dialogShow
:
false
,
dialogShow
:
false
,
...
...
src/views/ecm/current-list.vue
View file @
2f0ac6b0
...
@@ -106,6 +106,8 @@ export default {
...
@@ -106,6 +106,8 @@ export default {
},
},
{
label
:
'会员信息'
,
prop
:
'marketingType'
,
minWidth
:
'120'
,
align
:
'left'
,
component
:
'member-info'
},
{
label
:
'会员信息'
,
prop
:
'marketingType'
,
minWidth
:
'120'
,
align
:
'left'
,
component
:
'member-info'
},
{
label
:
'手机号码'
,
prop
:
'phoneNumber'
,
minWidth
:
'120'
,
align
:
'left'
},
{
label
:
'手机号码'
,
prop
:
'phoneNumber'
,
minWidth
:
'120'
,
align
:
'left'
},
{
label
:
'主门店'
,
prop
:
'mainClerkCode'
,
minWidth
:
'120'
,
align
:
'left'
},
{
label
:
'专属导购'
,
prop
:
'mainStoreName'
,
minWidth
:
'120'
,
align
:
'left'
},
{
{
label
:
'状态'
,
label
:
'状态'
,
prop
:
'errCode'
,
prop
:
'errCode'
,
...
...
src/views/ecm/form.js
0 → 100644
View file @
2f0ac6b0
import
{
getEcmInfo
,
saveEcmInfo
}
from
'@/service/api/ecmApi.js'
;
import
{
listTemplateVariables
}
from
'@/service/api/msgApi.js'
;
import
{
sceneSettingList
}
from
'@/service/api/commonApi.js'
;
import
{
klflStrategy
}
from
'@/service/api/gameApi.js'
;
// 会员等级列表接口
import
marketingEvent
from
'./marketing-event/index.vue'
;
import
{
formatDateTimeByType
}
from
'@/utils/index.js'
;
import
{
isEmpty
,
numOfDecimal
}
from
'@/utils/strlen.js'
;
import
itemCard
from
'./partials/item-card.vue'
;
import
varDialog
from
'./partials/variables.vue'
;
export
default
{
name
:
'ecm-manage'
,
data
()
{
return
{
ecmPlanId
:
''
,
// 必传,
code
:
'1001'
,
loading
:
false
,
effectActionOptions
:
[{
value
:
'subscribe'
,
label
:
'关注触发'
},
{
value
:
'authentication'
,
label
:
'认证触发'
},
{
value
:
'consume'
,
label
:
'消费触发'
},
{
value
:
'upgrade'
,
label
:
'会员卡升级触发'
},
{
value
:
'degrade'
,
label
:
'会员卡降级触发'
}],
marketingTimesTypeOptions
:
[{
value
:
0
,
label
:
'总共触发'
},
{
value
:
1
,
label
:
'每天触发'
},
{
value
:
2
,
label
:
'每周触发'
},
{
value
:
3
,
label
:
'每月触发'
},
{
value
:
4
,
label
:
'每年触发'
},
{
value
:
-
1
,
label
:
'无限次触发'
}],
dayOptions
:
Array
(
24
)
.
fill
()
.
map
((
v
,
i
)
=>
({
value
:
i
,
label
:
i
+
':00'
})),
sceneSettingIdOptions
:
[],
// 消费触发错误提示
error_cost_info
:
''
,
error_cost_count_info
:
''
,
form
:
{
memberType
:
0
,
ecmPlanName
:
''
,
effectType
:
0
,
effectTime
:
0
,
effectAction
:
'subscribe'
,
sceneSettingId
:
''
,
sceneSettingName
:
''
,
expireType
:
0
,
cardId
:
''
,
mediaId
:
''
,
imageTextId
:
''
,
textContent
:
''
,
title
:
''
,
describe
:
''
,
lateDays
:
''
,
brithday_day
:
''
,
attention_day
:
''
,
lastCost_day
:
''
,
memberSearchDTO
:
''
,
memberGroupIds
:
''
,
beginDate
:
''
,
endDate
:
''
,
cardNoticeType
:
2
,
templateNoticeFlag
:
0
,
// 判断模板消息能否使用
templateUseEnable
:
1
,
marketingTimesType
:
0
,
marketingTimes
:
1
,
gradeIds
:
[],
//消费触发
lowest_cost
:
''
,
max_cost
:
''
,
lowest_cost_count
:
''
,
max_cost_count
:
''
,
store_mode
:
0
,
order_store
:
''
},
template
:
{
headerColor
:
'#173177'
,
remarkColor
:
'#173177'
,
headerText
:
''
,
remarkText
:
''
,
templateKeyDataList
:
[]
},
copyTemplate
:
{
headerColor
:
'#173177'
,
remarkColor
:
'#173177'
,
headerText
:
''
,
remarkText
:
''
,
templateKeyDataList
:
[]
},
dateTime
:
[
''
,
''
],
endDatePickerOptions
:
{
disabledDate
(
time
)
{
return
time
.
getTime
()
<
Date
.
now
()
-
8.64e7
;
}
},
checked
:
[],
rules
:
{
ecmPlanName
:
{
type
:
'string'
,
required
:
true
,
message
:
'计划名称不能为空'
,
trigger
:
'blur'
}
},
isEdit
:
this
.
$route
.
meta
.
type
===
'edit'
,
isAdd
:
this
.
$route
.
meta
.
type
===
'add'
,
// 人群筛选器可传参数
sceneValue
:
'member'
,
// 场景值
useId
:
''
,
// 模板id
hasSearchData
:
''
,
// 当前页回显的数据(接口返回)
toggleTag
:
false
,
// 控制按钮显示的参数,仅供参考,可自行修改
getSaveData
:
''
,
saveTag
:
false
,
enabledMessageState
:
0
,
// 能否发送短信,接口获取
showMessage
:
false
,
// 有效时间展示错误信息flag
currentCard
:
{},
varDialogShow
:
false
,
// 常量弹窗show
currentTxet
:
''
,
options
:
[],
editDialogShow
:
false
,
gradeList
:
[],
// 会员分组可传参数
defaltSelected
:
[],
// 默认穿梭窗已选入数据
projectName
:
'marketing'
,
// 默认是memberTag
headerList
:
[
'isRealTime'
,
'latestUpdateTime'
,
'updateType'
,
'effectiveStatus'
,
'effectiveDate'
],
effectiveStatus
:
1
,
// 不传: 所有状态 1: 有效 0: 失效
templateOptions
:
[],
triggerCode
:
''
};
},
components
:
{
'marketing-event'
:
marketingEvent
,
'item-card'
:
itemCard
,
'var-dialog'
:
varDialog
},
watch
:
{
checked
(
val
)
{
switch
(
val
[
0
])
{
case
'brithday_day'
:
if
(
!
this
.
form
.
brithday_day
)
{
this
.
form
.
brithday_day
=
1
;
}
this
.
form
.
attention_day
=
0
;
this
.
form
.
lastCost_day
=
0
;
break
;
case
'attention_day'
:
if
(
!
this
.
form
.
attention_day
)
{
this
.
form
.
attention_day
=
1
;
}
this
.
form
.
brithday_day
=
0
;
this
.
form
.
lastCost_day
=
0
;
break
;
case
'lastCost_day'
:
if
(
!
this
.
form
.
lastCost_day
)
{
this
.
form
.
lastCost_day
=
1
;
}
this
.
form
.
brithday_day
=
0
;
this
.
form
.
attention_day
=
0
;
break
;
default
:
this
.
form
.
brithday_day
=
0
;
this
.
form
.
attention_day
=
0
;
this
.
form
.
lastCost_day
=
0
;
break
;
}
}
},
computed
:
{
asideShow
()
{
return
this
.
$store
.
state
.
marketing
.
asideShow
;
},
marketingTimesTips
()
{
let
tips
=
''
;
switch
(
this
.
form
.
marketingTimesType
)
{
case
0
:
tips
=
`总共对同个会员触发
${
this
.
form
.
marketingTimes
}
次`
;
break
;
case
1
:
tips
=
`在一天内对同个会员触发
${
this
.
form
.
marketingTimes
}
次,每天0:00刷新触发次数`
;
break
;
case
2
:
tips
=
`在一周内对同个会员触发
${
this
.
form
.
marketingTimes
}
次,每周一0:00刷新触发次数`
;
break
;
case
3
:
tips
=
`在一个月内对同个会员触发
${
this
.
form
.
marketingTimes
}
次,每月1号0:00刷新触发次数`
;
break
;
case
4
:
tips
=
`在一年内对同个会员触发
${
this
.
form
.
marketingTimes
}
次,每年1月1号0:00刷新触发次数`
;
break
;
case
5
:
tips
=
`对同个会员触发无限次`
;
break
;
}
return
tips
;
}
},
created
()
{
// 设置面包屑
let
breadcrumbName
=
'智能营销编辑'
;
if
(
this
.
isAdd
)
{
this
.
sceneSettingList
();
breadcrumbName
=
'智能营销新增'
;
}
this
.
$store
.
commit
(
'mutations_breadcrumb'
,
[{
name
:
'营销管理'
,
path
:
''
},
{
name
:
'智能营销'
,
path
:
'/ecm'
},
{
name
:
breadcrumbName
,
path
:
''
}]);
this
.
listTemplateVariables
();
},
methods
:
{
/* ----------------核心方法--------------- */
// 获取变量列表
async
listTemplateVariables
()
{
this
.
loading
=
true
;
try
{
let
res
=
await
listTemplateVariables
();
if
(
res
.
errorCode
===
0
)
{
const
result
=
res
.
result
;
this
.
options
=
Object
.
keys
(
result
).
map
(
v
=>
({
label
:
result
[
v
],
value
:
v
}));
}
this
.
getEcmInfo
();
}
catch
(
err
)
{
console
.
log
(
err
);
}
},
// 获取营销场景
async
sceneSettingList
()
{
let
res
=
await
sceneSettingList
();
this
.
sceneSettingIdOptions
=
res
.
result
||
[];
},
// 获取ecm信息
async
getEcmInfo
(
isResetTemplate
=
false
)
{
this
.
loading
=
true
;
let
res
=
await
getEcmInfo
({
ecmPlanId
:
this
.
$route
.
params
.
id
});
this
.
loading
=
false
;
// 如果是模板重置不需要重置基本信息
if
(
!
isResetTemplate
)
{
const
result
=
res
.
result
.
ecmDTO
;
const
commonScene
=
res
.
result
.
commonScene
;
const
consumTrigger
=
res
.
result
.
consumTrigger
;
this
.
enabledMessageState
=
res
.
result
.
enabledMessageState
||
0
;
if
(
result
&&
this
.
isEdit
)
{
this
.
ecmPlanId
=
this
.
form
.
ecmPlanId
=
result
.
ecmPlanId
||
''
;
this
.
form
.
ecmPlanName
=
result
.
ecmPlanName
;
this
.
form
.
effectType
=
result
.
effectType
;
this
.
form
.
effectTime
=
result
.
effectTime
;
this
.
form
.
effectAction
=
result
.
effectAction
;
this
.
form
.
sceneSettingId
=
result
.
sceneSettingId
;
this
.
form
.
sceneSettingName
=
result
.
sceneSettingName
;
this
.
form
.
memberType
=
result
.
memberType
;
this
.
form
.
expireType
=
result
.
expireType
;
//处理会员等级
this
.
form
.
gradeIds
=
(
result
.
gradeIds
&&
result
.
gradeIds
.
split
(
','
).
filter
(
v
=>
v
))
||
[];
//营销次数配置
this
.
form
.
marketingTimesType
=
result
.
marketingTimesType
||
0
;
this
.
form
.
marketingTimes
=
result
.
marketingTimes
||
1
;
//'0-不通知 1-微信对话框 2-模板消息 补发通知 0-不补发 1-补发'
this
.
form
.
cardNoticeType
=
result
.
cardNoticeType
||
0
;
this
.
form
.
templateNoticeFlag
=
result
.
templateNoticeFlag
||
0
;
// 判断回显
if
(
this
.
form
.
memberType
===
0
)
{
this
.
form
.
memberSearchDTO
=
result
.
filterJson
;
}
else
{
//会员分组
this
.
form
.
memberGroupIds
=
result
.
filterJson
||
''
;
this
.
defaltSelected
=
res
.
result
.
tagGroupList
||
[];
}
if
(
this
.
form
.
expireType
)
{
this
.
form
.
beginDate
=
result
.
beginDate
||
''
;
this
.
form
.
endDate
=
result
.
endDate
||
''
;
}
if
(
res
.
result
.
searchId
)
{
this
.
useId
=
res
.
result
.
searchId
||
''
;
// console.log(this.useId, 'useid');
this
.
hasSearchData
=
result
.
filterJson
||
'{}'
;
}
if
(
this
.
form
.
effectType
===
1
)
{
this
.
form
.
brithday_day
=
commonScene
.
brithday_day
;
this
.
form
.
attention_day
=
commonScene
.
attention_day
;
this
.
form
.
lastCost_day
=
commonScene
.
lastCost_day
;
if
(
this
.
form
.
brithday_day
)
{
this
.
checked
=
[
'brithday_day'
];
}
else
if
(
this
.
form
.
attention_day
)
{
this
.
checked
=
[
'attention_day'
];
}
else
if
(
this
.
form
.
lastCost_day
)
{
this
.
checked
=
[
'lastCost_day'
];
}
}
}
else
if
(
this
.
isAdd
)
{
this
.
ecmPlanId
=
res
.
result
.
templateEcmPlanId
||
''
;
}
this
.
form
.
templateUseEnable
=
res
.
result
.
templateUseEnable
;
this
.
$nextTick
(
_
=>
{
this
.
effectActionChange
(
true
);
});
// 处理消费触发
if
(
consumTrigger
)
{
const
_mapConsumeArr
=
[
'lowest_cost'
,
'max_cost'
,
'lowest_cost_count'
,
'max_cost_count'
];
_mapConsumeArr
.
map
(
v
=>
{
// 为空为null代表无限制
if
(
isEmpty
(
consumTrigger
[
v
]))
{
this
.
form
[
v
]
=
undefined
;
}
else
{
this
.
form
[
v
]
=
consumTrigger
[
v
];
}
});
this
.
form
.
store_mode
=
consumTrigger
.
store_mode
||
0
;
/** 门店类型: 0: 所有门店, 1: 部分(包含部分门店, 部分分组等) **/
this
.
form
.
order_store
=
consumTrigger
.
order_store
||
''
;
/** 消费门店key值 **/
}
// 触发门店初始化
if
(
this
.
form
.
effectAction
===
'consume'
&&
this
.
form
.
store_mode
)
{
this
.
$nextTick
(
_
=>
{
this
.
$refs
.
storeCard
.
init
();
});
}
}
if
(
!
this
.
form
.
templateUseEnable
)
return
;
let
template
=
null
;
this
.
templateOptions
=
res
.
result
.
marketingTemplateList
||
[];
if
(
!
this
.
isAdd
)
{
template
=
res
.
result
.
customMarketingTemplate
;
}
else
{
template
=
res
.
result
.
marketingTemplateList
[
0
];
}
this
.
triggerCode
=
template
.
triggerCode
;
// 模板消息
if
(
template
)
{
this
.
templateInit
(
template
);
}
},
// 模板消息初始化
templateInit
(
template
)
{
this
.
template
.
templateKeyDataList
=
template
.
templateKeyDataList
;
this
.
template
.
templateKeyDataList
.
map
((
v
,
i
)
=>
{
v
.
type
=
v
.
datas
?
v
.
datas
.
split
(
'#'
)[
0
]
:
''
;
v
.
color
=
v
.
datas
?
'#'
+
(
v
.
datas
.
split
(
'#'
)[
1
]
||
'173177'
)
:
'#173177'
;
this
.
$set
(
this
.
template
.
templateKeyDataList
,
i
,
{
color
:
v
.
color
,
type
:
v
.
type
,
createTime
:
v
.
createTime
,
datas
:
v
.
datas
,
keyName
:
v
.
keyName
,
keywords
:
v
.
keywords
,
orders
:
v
.
orders
,
queryMap
:
v
.
queryMap
,
queryOrder
:
v
.
queryOrder
,
querySize
:
v
.
querySize
,
querySort
:
v
.
querySort
,
queryStart
:
v
.
queryStart
,
templateId
:
v
.
templateId
,
templateKeyDataId
:
v
.
templateKeyDataId
,
updateTime
:
v
.
updateTime
});
});
this
.
template
.
weixinTemplateId
=
template
.
weixinTemplateId
;
this
.
template
.
templateBusiness
=
template
.
templateBusiness
;
this
.
template
.
typeCode
=
template
.
typeCode
;
this
.
template
.
templateName
=
template
.
templateName
;
this
.
template
.
title
=
template
.
title
;
this
.
template
.
urlType
=
template
.
urlType
;
this
.
template
.
header
=
template
.
header
;
this
.
template
.
remark
=
template
.
remark
;
this
.
template
.
headerText
=
this
.
template
.
header
?
this
.
template
.
header
.
split
(
'#'
)[
0
]
:
''
;
this
.
template
.
headerColor
=
this
.
template
.
header
?
'#'
+
(
this
.
template
.
header
.
split
(
'#'
)[
1
]
||
'173177'
)
:
'#173177'
;
this
.
template
.
remarkText
=
this
.
template
.
remark
?
this
.
template
.
remark
.
split
(
'#'
)[
0
]
:
''
;
this
.
template
.
remarkColor
=
this
.
template
.
remark
?
'#'
+
(
this
.
template
.
remark
.
split
(
'#'
)[
1
]
||
'173177'
)
:
'#173177'
;
this
.
template
.
updateTime
=
template
.
updateTime
;
this
.
template
.
jumpUrl
=
template
.
jumpUrl
;
this
.
template
.
jumpUrlInfo
=
template
.
jumpUrlInfo
;
this
.
template
.
triggerCode
=
template
.
triggerCode
;
this
.
options
.
map
(
v
=>
{
console
.
log
(
this
.
template
.
headerText
.
indexOf
(
v
.
value
)
>
-
1
);
if
(
this
.
template
.
headerText
.
indexOf
(
v
.
value
)
>
-
1
)
{
this
.
template
.
headerText
=
this
.
template
.
headerText
.
replace
(
v
.
value
,
v
.
label
);
}
if
(
this
.
template
.
remarkText
.
indexOf
(
v
.
value
)
>
-
1
)
{
this
.
template
.
remarkText
=
this
.
template
.
remarkText
.
replace
(
v
.
value
,
v
.
label
);
}
});
},
// 下拉触发模板消息的改变
changeTemplate
()
{
let
template
=
null
;
this
.
templateOptions
.
map
(
v
=>
{
if
(
this
.
triggerCode
===
v
.
triggerCode
)
{
template
=
v
;
}
});
this
.
templateInit
(
template
);
},
// 预修改模板
editTemplatePre
()
{
this
.
editDialogShow
=
true
;
this
.
copyTemplate
=
JSON
.
parse
(
JSON
.
stringify
(
this
.
template
));
},
// 修改模板
editTemplate
()
{
this
.
editDialogShow
=
false
;
this
.
template
=
JSON
.
parse
(
JSON
.
stringify
(
this
.
copyTemplate
));
},
// 预插入变量
insetVarPre
(
val
)
{
this
.
varDialogShow
=
true
;
this
.
currentTxet
=
val
;
},
// 插入变量
insetVar
(
val
)
{
console
.
log
(
val
,
this
.
copyTemplate
[
this
.
currentTxet
]);
if
(
typeof
this
.
currentTxet
===
'number'
)
{
this
.
copyTemplate
.
templateKeyDataList
[
this
.
currentTxet
].
type
+=
val
;
}
this
.
copyTemplate
[
this
.
currentTxet
]
+=
val
;
},
// 重置模板
resetTemplate
()
{
this
.
getEcmInfo
(
true
);
},
// 变量弹窗关闭
close
()
{
this
.
editDialogShow
=
false
;
},
// 保存 校验
async
submit
(
formName
)
{
// // 这里强制获取人群筛选器的配置项
// await this.$refs.peopleFilter.confirmSet();
// 判断时间
if
(
this
.
checkBeginEndTime
())
return
;
const
hasMessageInList
=
this
.
$refs
.
marketingEvent
.
hasMessageInList
();
// 判断是否能发送短信
if
(
hasMessageInList
&&
this
.
isMessageForbidden
())
return
;
if
(
this
.
form
.
expireType
&&
(
!
this
.
form
.
beginDate
||
!
this
.
form
.
endDate
))
{
this
.
$tips
({
type
:
'warning'
,
message
:
'固定期限不能为空'
});
return
;
}
if
(
this
.
form
.
memberType
===
0
&&
this
.
toggleTag
&&
!
this
.
getSaveData
)
{
this
.
$tips
({
type
:
'warning'
,
message
:
'人群筛选未保存条件'
});
return
;
}
if
(
this
.
form
.
memberType
===
1
&&
!
this
.
form
.
memberGroupIds
)
{
this
.
$tips
({
type
:
'warning'
,
message
:
'会员分组不能为空'
});
return
;
}
// 如果是消费触发
if
(
this
.
form
.
effectAction
===
'consume'
)
{
const
errorLowestCost
=
this
.
handleLowestCost
();
const
errorLowestCostCount
=
this
.
handleLowestCostCount
();
if
(
errorLowestCost
!==
''
||
errorLowestCostCount
!==
''
)
{
this
.
$tips
({
type
:
'warning'
,
message
:
'会员分组不能为空'
});
return
;
}
}
let
params
=
{
ecmPlanId
:
this
.
form
.
ecmPlanId
||
''
,
templateEcmPlanId
:
this
.
isAdd
?
this
.
ecmPlanId
:
''
,
ecmPlanName
:
this
.
form
.
ecmPlanName
,
// 是 int 计划名称不能为空,且最多9个汉字
effectType
:
this
.
form
.
effectType
,
//是 int 时效: 实时: 0; 每天: 1
effectTime
:
this
.
form
.
effectTime
,
//否 int effectType = 1每天时必填, 时效为时间为0-23
effectAction
:
this
.
form
.
effectAction
,
// 否 string effectType = 0实时时必填, 关注触发: ‘subscribe’; 认证触发: ‘authentication’
marketingType
:
this
.
form
.
marketingType
,
//是 String 营销方式: 卡券营销: ‘card’; 短信营销 : ‘message’; 图文营销: ‘teletext’; 文本营销: ‘text’; 话务: ‘teltask’; 微信图片: ‘image’
memberType
:
this
.
form
.
memberType
,
memberSearchDTO
:
this
.
form
.
memberType
?
this
.
form
.
memberGroupIds
:
this
.
form
.
memberSearchDTO
,
searchJson
:
this
.
getSaveData
,
expireType
:
this
.
form
.
expireType
,
beginDate
:
this
.
form
.
expireType
?
formatDateTimeByType
(
this
.
form
.
beginDate
,
'yyyy-MM-dd-HH-mm-ss'
)
:
''
,
endDate
:
this
.
form
.
expireType
?
formatDateTimeByType
(
this
.
form
.
endDate
,
'yyyy-MM-dd-HH-mm-ss'
)
:
''
,
cardNoticeType
:
this
.
form
.
cardNoticeType
,
templateNoticeFlag
:
this
.
form
.
templateNoticeFlag
,
gradeIds
:
this
.
form
.
gradeIds
.
join
(
','
)
||
''
,
marketingTimesType
:
this
.
form
.
marketingTimesType
,
marketingTimes
:
this
.
form
.
marketingTimes
};
// 如果是消费触发
// 不填代表没有上下限,不传该字段
if
(
this
.
form
.
effectAction
===
'consume'
)
{
const
_mapConsumeArr
=
[
'lowest_cost'
,
'max_cost'
,
'lowest_cost_count'
,
'max_cost_count'
];
let
consumeObj
=
{
store_mode
:
this
.
form
.
store_mode
,
order_store
:
this
.
form
.
order_store
};
_mapConsumeArr
.
map
(
v
=>
{
// 保存的消费触发上下限数据,没有填写的字段不传
let
val
=
this
.
form
[
v
];
if
(
!
isEmpty
(
val
))
{
consumeObj
[
v
]
=
val
;
}
});
params
=
Object
.
assign
(
params
,
consumeObj
);
}
if
(
this
.
form
.
effectType
)
{
params
[
this
.
checked
[
0
]]
=
this
.
form
[
this
.
checked
[
0
]]
||
0
;
}
if
(
this
.
isAdd
)
{
params
.
sceneSettingId
=
this
.
form
.
sceneSettingId
;
// 否 String 营销场景
}
/* 模板消息的处理 */
if
(
this
.
currentCard
.
comName
===
'item-card'
&&
((
this
.
form
.
cardNoticeType
===
1
&&
this
.
form
.
effectType
===
0
&&
this
.
form
.
templateNoticeFlag
===
1
)
||
this
.
form
.
cardNoticeType
===
2
))
{
let
marketingTemplate
=
{};
let
header
=
this
.
template
.
headerText
;
let
remark
=
this
.
template
.
remarkText
;
this
.
options
.
map
(
v
=>
{
if
(
header
.
indexOf
(
v
.
label
)
>
-
1
)
{
// console.log(new RegExp((v.label+'/g')))
header
=
header
.
replace
(
v
.
label
,
v
.
value
);
}
if
(
remark
.
indexOf
(
v
.
label
)
>
-
1
)
{
remark
=
remark
.
replace
(
v
.
label
,
v
.
value
);
}
});
this
.
template
.
templateKeyDataList
=
this
.
template
.
templateKeyDataList
.
map
(
v
=>
({
keyName
:
v
.
keyName
,
keywords
:
v
.
keywords
,
datas
:
v
.
type
+
v
.
color
,
orders
:
v
.
orders
}));
marketingTemplate
=
{
weixinTemplateId
:
this
.
template
.
weixinTemplateId
,
templateBusiness
:
this
.
template
.
templateBusiness
,
typeCode
:
this
.
template
.
typeCode
,
templateName
:
this
.
template
.
templateName
,
title
:
this
.
template
.
title
,
urlType
:
this
.
template
.
urlType
,
jumpUrl
:
this
.
template
.
jumpUrl
,
jumpUrlInfo
:
this
.
template
.
jumpUrlInfo
,
triggerCode
:
this
.
template
.
triggerCode
,
header
:
header
+
this
.
template
.
headerColor
,
remark
:
remark
+
this
.
template
.
remarkColor
,
templateKeyDataList
:
this
.
template
.
templateKeyDataList
};
params
.
marketingTemplate
=
JSON
.
stringify
(
marketingTemplate
);
}
// 这里判断部分门店是否为空
if
(
this
.
form
.
store_mode
)
{
let
data
=
await
this
.
$refs
.
storeCard
.
getRightList
();
if
(
!
data
.
length
)
{
this
.
$tips
({
type
:
'warning'
,
message
:
'部分门店不能为空'
});
return
;
}
}
this
.
$refs
[
formName
].
validate
(
valid
=>
{
if
(
valid
)
{
this
.
saveEcmInfo
(
params
);
}
else
{
this
.
$tips
({
type
:
'warning'
,
message
:
'表单填写不完整'
});
return
false
;
}
});
},
// 保存
saveEcmInfo
(
params
)
{
this
.
loading
=
true
;
saveEcmInfo
(
params
)
.
then
(
res
=>
{
this
.
loading
=
false
;
if
(
res
.
errorCode
===
0
)
{
if
(
this
.
isEdit
)
{
this
.
$confirm
(
'操作成功, 是否返回列表?'
,
'提示'
,
{
confirmButtonText
:
'确定'
,
cancelButtonText
:
'取消'
,
type
:
'warning'
})
.
then
(()
=>
{
this
.
$router
.
go
(
-
1
);
})
.
catch
(
err
=>
{
this
.
getEcmInfo
();
});
}
else
{
this
.
$router
.
go
(
-
1
);
}
}
else
{
this
.
$tips
({
type
:
'error'
,
message
:
res
.
message
||
'操作失败'
});
}
})
.
catch
(
err
=>
{
this
.
loading
=
false
;
});
},
//加载会员卡等级
getGradeList
()
{
return
new
Promise
((
resolve
,
reject
)
=>
{
klflStrategy
({}).
then
(
res
=>
{
if
(
res
.
errorCode
===
0
)
{
resolve
(
res
.
result
.
gradeList
||
[]);
}
reject
();
});
});
},
// 触发行为变化 会员卡升降级
effectActionChange
(
isInit
=
false
)
{
if
(
this
.
form
.
effectAction
===
'upgrade'
)
{
if
(
isInit
!==
true
)
this
.
form
.
gradeIds
=
[];
this
.
getGradeList
().
then
(
data
=>
{
this
.
gradeList
=
data
.
map
((
v
,
i
)
=>
{
if
(
!
i
)
{
v
.
disabled
=
true
;
}
return
v
;
});
// console.log(this.gradeList)
});
}
else
if
(
this
.
form
.
effectAction
===
'degrade'
)
{
if
(
isInit
!==
true
)
this
.
form
.
gradeIds
=
[];
this
.
getGradeList
().
then
(
data
=>
{
this
.
gradeList
=
data
.
reverse
().
map
((
v
,
i
)
=>
{
if
(
!
i
)
{
v
.
disabled
=
true
;
}
return
v
;
});
// console.log(this.gradeList )
});
}
},
// 消费触发
handleLowestCost
()
{
const
{
lowest_cost
,
max_cost
}
=
this
.
form
;
let
info
=
''
;
if
(
isEmpty
(
lowest_cost
)
&&
isEmpty
(
max_cost
))
{
info
=
'消费金额上下限必填一个'
;
}
else
if
(
lowest_cost
>
max_cost
&&
max_cost
)
{
info
=
'消费金额区间设置错误'
;
}
else
if
(
numOfDecimal
(
lowest_cost
)
>
2
||
numOfDecimal
(
max_cost
)
>
2
)
{
info
=
'消费金额最多保留两位小数'
;
}
this
.
error_cost_info
=
info
;
return
info
;
},
handleLowestCostCount
()
{
const
{
lowest_cost_count
,
max_cost_count
}
=
this
.
form
;
let
info
=
''
;
if
(
isEmpty
(
lowest_cost_count
)
&&
isEmpty
(
max_cost_count
))
{
info
=
'消费件数上下限必填一个'
;
}
else
if
(
lowest_cost_count
>
max_cost_count
&&
max_cost_count
)
{
info
=
'消费件数区间设置错误'
;
}
else
if
(
numOfDecimal
(
lowest_cost_count
)
>
0
||
numOfDecimal
(
max_cost_count
)
>
0
)
{
info
=
'消费件数必须为正整数'
;
}
this
.
error_cost_count_info
=
info
;
return
info
;
},
changeChecked
(
e
)
{
console
.
log
(
e
);
},
/* ----------------辅助方法--------------- */
// 对比开始时间结束时间
checkBeginEndTime
()
{
let
beginDate
=
this
.
form
.
beginDate
&&
new
Date
(
this
.
form
.
beginDate
);
let
endDate
=
this
.
form
.
endDate
&&
new
Date
(
this
.
form
.
endDate
);
if
(
this
.
form
.
expireType
&&
beginDate
&&
endDate
&&
beginDate
.
getTime
()
>
endDate
.
getTime
())
{
this
.
$tips
({
type
:
'warning'
,
message
:
'开始时间不能大于结束时间'
});
// this.form.beginDate = this.form.endDate;
this
.
showMessage
=
true
;
return
true
;
}
else
{
this
.
showMessage
=
false
;
return
false
;
}
},
// 是否禁止发短信 逻辑 => 当用户选择每天发送,且短信模板选择为营销短信时,需要判断定时发送时间是否在08:00至22:00之间,若否则停留在新建计划页面,禁止短信群发并进行提醒。
isMessageForbidden
()
{
// console.log(this.$refs.marketingEvent.hasMessageInList(),this.form.effectType === 1,this.form.effectTime)
if
(
this
.
form
.
effectType
===
1
&&
(
this
.
form
.
effectTime
>=
22
||
this
.
form
.
effectTime
<=
8
))
{
this
.
$alert
(
`<div>
<i class="el-icon-warning warning-color fz30 vertical-middle mr20"></i>
<p class="inline-block vertical-middle w300">短信运营商限制:为避免骚扰用户,营销短信只允许在8点到22点发送</p>
</div>`
,
'提示'
,
{
dangerouslyUseHTMLString
:
true
,
showCancelButton
:
true
,
showConfirmButton
:
false
,
cancelButtonText
:
'关闭'
}
);
return
true
;
}
else
{
return
false
;
}
},
// 接收的子方法 是否有卡券 value为卡券
hasCard
(
value
)
{
this
.
currentCard
=
value
;
},
// 初始化门店左侧数据
initStoreCardLeft
()
{
if
(
this
.
form
.
store_mode
)
{
if
(
this
.
isAdd
)
{
// 这里新增的情况下也要初始化 门店组件
this
.
$nextTick
(
_
=>
{
this
.
$refs
.
storeCard
.
init
();
});
}
else
{
this
.
$nextTick
(
_
=>
{
this
.
$refs
.
storeCard
.
initLeftList
();
});
}
}
},
/* ----------------人群筛选器的方法--------------- */
getData
()
{
this
.
$refs
.
peopleFilter
.
confirmSet
();
},
// 子组件触发父组件事件,返回过滤条件数据
findFilter
(
value
)
{
this
.
form
.
memberSearchDTO
=
value
;
},
// 取消
cancelFilter
()
{
this
.
$refs
.
peopleFilter
.
cancelSet
();
},
// 获取需要回显的数据, 供保存时候使用
getBackData
(
val
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
this
.
getSaveData
=
val
;
console
.
log
(
this
.
getSaveData
,
val
);
resolve
();
});
},
// 显示编辑,保存按钮隐藏,确认按钮显示 (子组件会调用)
editShow
()
{
this
.
toggleTag
=
true
;
this
.
saveTag
=
false
;
},
// 显示保存按钮,隐藏确认按钮显示 (子组件会调用)
editHide
()
{
this
.
toggleTag
=
false
;
this
.
saveTag
=
true
;
},
// 隐藏保存按钮和确认按钮 (子组件会调用)
hideBtn
()
{
this
.
toggleTag
=
false
;
this
.
saveTag
=
false
;
},
handleDataTransferred
(
data
)
{
// 会员分组 情况下 memberSearchDTO 传数组字符串
if
(
this
.
form
.
memberType
===
1
)
{
this
.
form
.
memberGroupIds
=
data
.
map
(
v
=>
v
.
memberTagGroupId
)
.
filter
(
v
=>
v
)
.
join
(
','
);
}
},
handleDataLeft
(
selectedData
,
selectionToRemove
)
{
console
.
log
(
selectedData
,
selectionToRemove
);
}
},
filters
:
{
filterDate
(
val
)
{
if
(
val
)
{
return
`
${
new
Date
(
val
).
getMonth
()
+
1
}
月
${
new
Date
(
val
).
getDate
()}
日`
;
}
else
{
return
'未知时间'
;
}
}
}
};
src/views/ecm/form.vue
View file @
2f0ac6b0
...
@@ -62,19 +62,20 @@
...
@@ -62,19 +62,20 @@
<span
class=
"gray fz13"
>
仅适用于线下单笔消费
</span>
<span
class=
"gray fz13"
>
仅适用于线下单笔消费
</span>
</h3>
</h3>
<el-form-item
label=
"消费金额"
>
<el-form-item
label=
"消费金额"
>
<el-input-number
:disabled=
"isEdit"
controls-position=
"right"
:min=
"0"
style=
"width:150px;"
v-model=
"form.lowest_cost
"
></el-input-number>
<el-input-number
:disabled=
"isEdit"
controls-position=
"right"
min=
""
style=
"width:150px;"
v-model=
"form.lowest_cost"
@
change=
"handleLowestCost()
"
></el-input-number>
<span
class=
"ml5 mr5"
>
至
</span>
<span
class=
"ml5 mr5"
>
至
</span>
<el-input-number
:disabled=
"isEdit"
controls-position=
"right"
:min=
"0"
style=
"width:150px;"
v-model=
"form.max_cost
"
></el-input-number>
<el-input-number
:disabled=
"isEdit"
controls-position=
"right"
min=
""
style=
"width:150px;"
v-model=
"form.max_cost"
@
change=
"handleLowestCost()
"
></el-input-number>
<span
class=
"pl5"
>
元
</span>
<span
class=
"pl5"
>
元
</span>
<el-popover
placement=
"right"
title=
""
width=
"200"
trigger=
"hover"
content=
"最大值最小值可选填其一或两个都填写,包含边界值"
><i
class=
"el-icon-info ml5 gray"
slot=
"reference"
></i></el-popover>
<el-popover
placement=
"right"
title=
""
width=
"200"
trigger=
"hover"
content=
"最大值最小值可选填其一或两个都填写,包含边界值"
><i
class=
"el-icon-info ml5 gray"
slot=
"reference"
></i></el-popover>
<
!--
<span
class=
"pl20 fz13 gray"
>
</span>
--
>
<
span
class=
"pl20 fz13 red"
v-show=
"error_cost_info!==''"
>
*
{{
error_cost_info
}}
</span
>
</el-form-item>
</el-form-item>
<el-form-item
label=
"消费件数"
>
<el-form-item
label=
"消费件数"
>
<el-input-number
:disabled=
"isEdit"
controls-position=
"right"
:min=
"0"
style=
"width:150px;"
v-model=
"form.lowest_cost_count
"
></el-input-number>
<el-input-number
:disabled=
"isEdit"
controls-position=
"right"
min=
""
style=
"width:150px;"
v-model=
"form.lowest_cost_count"
@
change=
"handleLowestCostCount()
"
></el-input-number>
<span
class=
"ml5 mr5"
>
至
</span>
<span
class=
"ml5 mr5"
>
至
</span>
<el-input-number
:disabled=
"isEdit"
controls-position=
"right"
:min=
"0"
style=
"width:150px;"
v-model=
"form.max_cost_count
"
></el-input-number>
<el-input-number
:disabled=
"isEdit"
controls-position=
"right"
min=
""
style=
"width:150px;"
v-model=
"form.max_cost_count"
@
change=
"handleLowestCostCount()
"
></el-input-number>
<span
class=
"pl5"
>
件
</span>
<span
class=
"pl5"
>
件
</span>
<el-popover
placement=
"right"
title=
""
width=
"200"
trigger=
"hover"
content=
"最大值最小值可选填其一或两个都填写,包含边界值,不包含赠品"
><i
class=
"el-icon-info ml5 gray"
slot=
"reference"
></i></el-popover>
<el-popover
placement=
"right"
title=
""
width=
"200"
trigger=
"hover"
content=
"最大值最小值可选填其一或两个都填写,包含边界值,不包含赠品"
><i
class=
"el-icon-info ml5 gray"
slot=
"reference"
></i></el-popover>
<span
class=
"pl20 fz13 red"
v-show=
"error_cost_count_info!==''"
>
*
{{
error_cost_count_info
}}
</span>
</el-form-item>
</el-form-item>
<el-form-item
label=
"指定消费门店"
>
<el-form-item
label=
"指定消费门店"
>
<el-radio-group
v-model=
"form.store_mode"
@
change=
"initStoreCardLeft"
:disabled=
"isEdit"
>
<el-radio-group
v-model=
"form.store_mode"
@
change=
"initStoreCardLeft"
:disabled=
"isEdit"
>
...
@@ -130,13 +131,13 @@
...
@@ -130,13 +131,13 @@
<el-radio
:disabled=
"isEdit"
:label=
"1"
>
会员分组
</el-radio>
<el-radio
:disabled=
"isEdit"
:label=
"1"
>
会员分组
</el-radio>
</el-radio-group>
</el-radio-group>
<div
class=
"mb20"
v-if=
"form.memberType === 0"
>
<div
class=
"mb20"
v-if=
"form.memberType === 0"
>
<vue-gic-people
:
class=
"isEdit ? 'el-view-mask' : ''"
:
projectName=
"projectName"
:isAdd=
"isAdd"
:triggerReset=
"true"
:useId=
"useId"
:hasSearchData=
"hasSearchData"
:sceneValue=
"sceneValue"
ref=
"peopleFilter"
@
findFilter=
"findFilter"
@
getBackData=
"getBackData"
@
editHide=
"editHide"
@
editShow=
"editShow"
@
hideBtn=
"hideBtn"
/>
<vue-gic-people
:projectName=
"projectName"
:isAdd=
"isAdd"
:triggerReset=
"true"
:useId=
"useId"
:hasSearchData=
"hasSearchData"
:sceneValue=
"sceneValue"
ref=
"peopleFilter"
@
findFilter=
"findFilter"
@
getBackData=
"getBackData"
@
editHide=
"editHide"
@
editShow=
"editShow"
@
hideBtn=
"hideBtn"
/>
<div
class=
"gic-people--button"
v-show=
"toggleTag"
>
<div
class=
"gic-people--button"
v-show=
"toggleTag"
>
<el-button
size=
"small"
type=
"primary"
@
click=
"getData"
>
确 定
</el-button>
<el-button
size=
"small"
type=
"primary"
@
click=
"getData"
>
确 定
</el-button>
<el-button
size=
"small"
@
click=
"cancelFilter"
>
取 消
</el-button>
<el-button
size=
"small"
@
click=
"cancelFilter"
>
取 消
</el-button>
</div>
</div>
</div>
</div>
<vue-gic-member-group
:class=
"isEdit ? 'el-view-mask' : ''"
v-if=
"form.memberType === 1"
:defaltSelected=
"defaltSelected"
:height=
"500"
:projectName=
"projectName"
:headerList=
"headerList"
@
handleDataTransferred=
"handleDataTransferred"
@
handleDataLeft=
"handleDataLeft"
></vue-gic-member-group>
<vue-gic-member-group
v-if=
"form.memberType === 1"
:defaltSelected=
"defaltSelected"
:height=
"500"
:projectName=
"projectName"
:headerList=
"headerList"
@
handleDataTransferred=
"handleDataTransferred"
@
handleDataLeft=
"handleDataLeft"
></vue-gic-member-group>
</section>
</section>
<!-- 营销事件组件 -->
<!-- 营销事件组件 -->
<section
class=
"dm-form__wrap"
>
<section
class=
"dm-form__wrap"
>
...
@@ -262,739 +263,8 @@
...
@@ -262,739 +263,8 @@
</el-form>
</el-form>
</template>
</template>
<
script
>
<
script
>
import
{
getEcmInfo
,
saveEcmInfo
}
from
'@/service/api/ecmApi.js'
;
import
ecmForm
from
'./form.js'
;
import
{
listTemplateVariables
}
from
'@/service/api/msgApi.js'
;
export
default
ecmForm
;
import
{
sceneSettingList
}
from
'@/service/api/commonApi.js'
;
import
{
klflStrategy
}
from
'@/service/api/gameApi.js'
;
// 会员等级列表接口
import
marketingEvent
from
'./marketing-event/index.vue'
;
import
{
formatDateTimeByType
}
from
'@/utils/index.js'
;
import
{
isEmpty
}
from
'@/utils/strlen.js'
;
import
itemCard
from
'./partials/item-card.vue'
;
import
varDialog
from
'./partials/variables.vue'
;
export
default
{
name
:
'ecm-manage'
,
data
()
{
return
{
ecmPlanId
:
''
,
// 必传,
code
:
'1001'
,
loading
:
false
,
effectActionOptions
:
[{
value
:
'subscribe'
,
label
:
'关注触发'
},
{
value
:
'authentication'
,
label
:
'认证触发'
},
{
value
:
'consume'
,
label
:
'消费触发'
},
{
value
:
'upgrade'
,
label
:
'会员卡升级触发'
},
{
value
:
'degrade'
,
label
:
'会员卡降级触发'
}],
marketingTimesTypeOptions
:
[{
value
:
0
,
label
:
'总共触发'
},
{
value
:
1
,
label
:
'每天触发'
},
{
value
:
2
,
label
:
'每周触发'
},
{
value
:
3
,
label
:
'每月触发'
},
{
value
:
4
,
label
:
'每年触发'
},
{
value
:
-
1
,
label
:
'无限次触发'
}],
dayOptions
:
Array
(
24
)
.
fill
()
.
map
((
v
,
i
)
=>
({
value
:
i
,
label
:
i
+
':00'
})),
sceneSettingIdOptions
:
[],
form
:
{
memberType
:
0
,
ecmPlanName
:
''
,
effectType
:
0
,
effectTime
:
0
,
effectAction
:
'subscribe'
,
sceneSettingId
:
''
,
sceneSettingName
:
''
,
expireType
:
0
,
cardId
:
''
,
mediaId
:
''
,
imageTextId
:
''
,
textContent
:
''
,
title
:
''
,
describe
:
''
,
lateDays
:
''
,
brithday_day
:
''
,
attention_day
:
''
,
lastCost_day
:
''
,
memberSearchDTO
:
''
,
memberGroupIds
:
''
,
beginDate
:
''
,
endDate
:
''
,
cardNoticeType
:
2
,
templateNoticeFlag
:
0
,
// 判断模板消息能否使用
templateUseEnable
:
1
,
marketingTimesType
:
0
,
marketingTimes
:
1
,
gradeIds
:
[],
//消费触发
lowest_cost
:
''
,
max_cost
:
''
,
lowest_cost_count
:
''
,
max_cost_count
:
''
,
store_mode
:
0
,
order_store
:
''
},
template
:
{
headerColor
:
'#173177'
,
remarkColor
:
'#173177'
,
headerText
:
''
,
remarkText
:
''
,
templateKeyDataList
:
[]
},
copyTemplate
:
{
headerColor
:
'#173177'
,
remarkColor
:
'#173177'
,
headerText
:
''
,
remarkText
:
''
,
templateKeyDataList
:
[]
},
dateTime
:
[
''
,
''
],
endDatePickerOptions
:
{
disabledDate
(
time
)
{
return
time
.
getTime
()
<
Date
.
now
()
-
8.64e7
;
}
},
checked
:
[],
rules
:
{
ecmPlanName
:
{
type
:
'string'
,
required
:
true
,
message
:
'计划名称不能为空'
,
trigger
:
'blur'
}
},
isEdit
:
this
.
$route
.
meta
.
type
===
'edit'
,
isAdd
:
this
.
$route
.
meta
.
type
===
'add'
,
// 人群筛选器可传参数
sceneValue
:
'member'
,
// 场景值
useId
:
''
,
// 模板id
hasSearchData
:
''
,
// 当前页回显的数据(接口返回)
toggleTag
:
false
,
// 控制按钮显示的参数,仅供参考,可自行修改
getSaveData
:
''
,
saveTag
:
false
,
enabledMessageState
:
0
,
// 能否发送短信,接口获取
showMessage
:
false
,
// 有效时间展示错误信息flag
currentCard
:
{},
varDialogShow
:
false
,
// 常量弹窗show
currentTxet
:
''
,
options
:
[],
editDialogShow
:
false
,
gradeList
:
[],
// 会员分组可传参数
defaltSelected
:
[],
// 默认穿梭窗已选入数据
projectName
:
'marketing'
,
// 默认是memberTag
headerList
:
[
'isRealTime'
,
'latestUpdateTime'
,
'updateType'
,
'effectiveStatus'
,
'effectiveDate'
],
effectiveStatus
:
1
,
// 不传: 所有状态 1: 有效 0: 失效
templateOptions
:
[],
triggerCode
:
''
};
},
components
:
{
'marketing-event'
:
marketingEvent
,
'item-card'
:
itemCard
,
'var-dialog'
:
varDialog
},
watch
:
{
checked
(
val
)
{
switch
(
val
[
0
])
{
case
'brithday_day'
:
if
(
!
this
.
form
.
brithday_day
)
{
this
.
form
.
brithday_day
=
1
;
}
this
.
form
.
attention_day
=
0
;
this
.
form
.
lastCost_day
=
0
;
break
;
case
'attention_day'
:
if
(
!
this
.
form
.
attention_day
)
{
this
.
form
.
attention_day
=
1
;
}
this
.
form
.
brithday_day
=
0
;
this
.
form
.
lastCost_day
=
0
;
break
;
case
'lastCost_day'
:
if
(
!
this
.
form
.
lastCost_day
)
{
this
.
form
.
lastCost_day
=
1
;
}
this
.
form
.
brithday_day
=
0
;
this
.
form
.
attention_day
=
0
;
break
;
default
:
this
.
form
.
brithday_day
=
0
;
this
.
form
.
attention_day
=
0
;
this
.
form
.
lastCost_day
=
0
;
break
;
}
}
},
computed
:
{
asideShow
()
{
return
this
.
$store
.
state
.
marketing
.
asideShow
;
},
marketingTimesTips
()
{
let
tips
=
''
;
switch
(
this
.
form
.
marketingTimesType
)
{
case
0
:
tips
=
`总共对同个会员触发
${
this
.
form
.
marketingTimes
}
次`
;
break
;
case
1
:
tips
=
`在一天内对同个会员触发
${
this
.
form
.
marketingTimes
}
次,每天0:00刷新触发次数`
;
break
;
case
2
:
tips
=
`在一周内对同个会员触发
${
this
.
form
.
marketingTimes
}
次,每周一0:00刷新触发次数`
;
break
;
case
3
:
tips
=
`在一个月内对同个会员触发
${
this
.
form
.
marketingTimes
}
次,每月1号0:00刷新触发次数`
;
break
;
case
4
:
tips
=
`在一年内对同个会员触发
${
this
.
form
.
marketingTimes
}
次,每年1月1号0:00刷新触发次数`
;
break
;
case
5
:
tips
=
`对同个会员触发无限次`
;
break
;
}
return
tips
;
}
},
created
()
{
// 设置面包屑
let
breadcrumbName
=
'智能营销编辑'
;
if
(
this
.
isAdd
)
{
this
.
sceneSettingList
();
breadcrumbName
=
'智能营销新增'
;
}
this
.
$store
.
commit
(
'mutations_breadcrumb'
,
[{
name
:
'营销管理'
,
path
:
''
},
{
name
:
'智能营销'
,
path
:
'/ecm'
},
{
name
:
breadcrumbName
,
path
:
''
}]);
this
.
listTemplateVariables
();
},
methods
:
{
/* ----------------核心方法--------------- */
// 获取变量列表
async
listTemplateVariables
()
{
this
.
loading
=
true
;
try
{
let
res
=
await
listTemplateVariables
();
if
(
res
.
errorCode
===
0
)
{
const
result
=
res
.
result
;
this
.
options
=
Object
.
keys
(
result
).
map
(
v
=>
({
label
:
result
[
v
],
value
:
v
}));
}
this
.
getEcmInfo
();
}
catch
(
err
)
{
console
.
log
(
err
);
}
},
// 获取营销场景
async
sceneSettingList
()
{
let
res
=
await
sceneSettingList
();
this
.
sceneSettingIdOptions
=
res
.
result
||
[];
},
// 获取ecm信息
async
getEcmInfo
(
isResetTemplate
=
false
)
{
this
.
loading
=
true
;
let
res
=
await
getEcmInfo
({
ecmPlanId
:
this
.
$route
.
params
.
id
});
this
.
loading
=
false
;
// 如果是模板重置不需要重置基本信息
if
(
!
isResetTemplate
)
{
const
result
=
res
.
result
.
ecmDTO
;
const
commonScene
=
res
.
result
.
commonScene
;
const
consumTrigger
=
res
.
result
.
consumTrigger
;
this
.
enabledMessageState
=
res
.
result
.
enabledMessageState
||
0
;
if
(
result
&&
this
.
isEdit
)
{
this
.
ecmPlanId
=
this
.
form
.
ecmPlanId
=
result
.
ecmPlanId
||
''
;
this
.
form
.
ecmPlanName
=
result
.
ecmPlanName
;
this
.
form
.
effectType
=
result
.
effectType
;
this
.
form
.
effectTime
=
result
.
effectTime
;
this
.
form
.
effectAction
=
result
.
effectAction
;
this
.
form
.
sceneSettingId
=
result
.
sceneSettingId
;
this
.
form
.
sceneSettingName
=
result
.
sceneSettingName
;
this
.
form
.
memberType
=
result
.
memberType
;
this
.
form
.
expireType
=
result
.
expireType
;
//处理会员等级
this
.
form
.
gradeIds
=
(
result
.
gradeIds
&&
result
.
gradeIds
.
split
(
','
).
filter
(
v
=>
v
))
||
[];
//营销次数配置
this
.
form
.
marketingTimesType
=
result
.
marketingTimesType
||
0
;
this
.
form
.
marketingTimes
=
result
.
marketingTimes
||
1
;
//'0-不通知 1-微信对话框 2-模板消息 补发通知 0-不补发 1-补发'
this
.
form
.
cardNoticeType
=
result
.
cardNoticeType
||
0
;
this
.
form
.
templateNoticeFlag
=
result
.
templateNoticeFlag
||
0
;
// 判断回显
if
(
this
.
form
.
memberType
===
0
)
{
this
.
form
.
memberSearchDTO
=
result
.
filterJson
;
}
else
{
//会员分组
this
.
form
.
memberGroupIds
=
result
.
filterJson
||
''
;
this
.
defaltSelected
=
res
.
result
.
tagGroupList
||
[];
}
if
(
this
.
form
.
expireType
)
{
this
.
form
.
beginDate
=
result
.
beginDate
||
''
;
this
.
form
.
endDate
=
result
.
endDate
||
''
;
}
if
(
res
.
result
.
searchId
)
{
this
.
useId
=
res
.
result
.
searchId
||
''
;
// console.log(this.useId, 'useid');
this
.
hasSearchData
=
result
.
filterJson
||
'{}'
;
}
if
(
this
.
form
.
effectType
===
1
)
{
this
.
form
.
brithday_day
=
commonScene
.
brithday_day
;
this
.
form
.
attention_day
=
commonScene
.
attention_day
;
this
.
form
.
lastCost_day
=
commonScene
.
lastCost_day
;
if
(
this
.
form
.
brithday_day
)
{
this
.
checked
=
[
'brithday_day'
];
}
else
if
(
this
.
form
.
attention_day
)
{
this
.
checked
=
[
'attention_day'
];
}
else
if
(
this
.
form
.
lastCost_day
)
{
this
.
checked
=
[
'lastCost_day'
];
}
}
}
else
if
(
this
.
isAdd
)
{
this
.
ecmPlanId
=
res
.
result
.
templateEcmPlanId
||
''
;
}
this
.
form
.
templateUseEnable
=
res
.
result
.
templateUseEnable
;
this
.
$nextTick
(
_
=>
{
this
.
effectActionChange
(
true
);
});
// 处理消费触发
if
(
consumTrigger
)
{
const
_mapConsumeArr
=
[
'lowest_cost'
,
'max_cost'
,
'lowest_cost_count'
,
'max_cost_count'
];
_mapConsumeArr
.
map
(
v
=>
{
// 为空为null代表无限制
if
(
isEmpty
(
consumTrigger
[
v
]))
{
this
.
form
[
v
]
=
undefined
;
}
else
{
this
.
form
[
v
]
=
consumTrigger
[
v
];
}
});
this
.
form
.
store_mode
=
consumTrigger
.
store_mode
||
0
;
/** 门店类型: 0: 所有门店, 1: 部分(包含部分门店, 部分分组等) **/
this
.
form
.
order_store
=
consumTrigger
.
order_store
||
''
;
/** 消费门店key值 **/
}
// 触发门店初始化
if
(
this
.
form
.
effectAction
===
'consume'
&&
this
.
form
.
store_mode
)
{
this
.
$nextTick
(
_
=>
{
this
.
$refs
.
storeCard
.
init
();
});
}
}
if
(
!
this
.
form
.
templateUseEnable
)
return
;
let
template
=
null
;
this
.
templateOptions
=
res
.
result
.
marketingTemplateList
||
[];
if
(
!
this
.
isAdd
)
{
template
=
res
.
result
.
customMarketingTemplate
;
}
else
{
template
=
res
.
result
.
marketingTemplateList
[
0
];
}
this
.
triggerCode
=
template
.
triggerCode
;
// 模板消息
if
(
template
)
{
this
.
templateInit
(
template
);
}
},
// 模板消息初始化
templateInit
(
template
)
{
this
.
template
.
templateKeyDataList
=
template
.
templateKeyDataList
;
this
.
template
.
templateKeyDataList
.
map
((
v
,
i
)
=>
{
v
.
type
=
v
.
datas
?
v
.
datas
.
split
(
'#'
)[
0
]
:
''
;
v
.
color
=
v
.
datas
?
'#'
+
(
v
.
datas
.
split
(
'#'
)[
1
]
||
'173177'
)
:
'#173177'
;
this
.
$set
(
this
.
template
.
templateKeyDataList
,
i
,
{
color
:
v
.
color
,
type
:
v
.
type
,
createTime
:
v
.
createTime
,
datas
:
v
.
datas
,
keyName
:
v
.
keyName
,
keywords
:
v
.
keywords
,
orders
:
v
.
orders
,
queryMap
:
v
.
queryMap
,
queryOrder
:
v
.
queryOrder
,
querySize
:
v
.
querySize
,
querySort
:
v
.
querySort
,
queryStart
:
v
.
queryStart
,
templateId
:
v
.
templateId
,
templateKeyDataId
:
v
.
templateKeyDataId
,
updateTime
:
v
.
updateTime
});
});
this
.
template
.
weixinTemplateId
=
template
.
weixinTemplateId
;
this
.
template
.
templateBusiness
=
template
.
templateBusiness
;
this
.
template
.
typeCode
=
template
.
typeCode
;
this
.
template
.
templateName
=
template
.
templateName
;
this
.
template
.
title
=
template
.
title
;
this
.
template
.
urlType
=
template
.
urlType
;
this
.
template
.
header
=
template
.
header
;
this
.
template
.
remark
=
template
.
remark
;
this
.
template
.
headerText
=
this
.
template
.
header
?
this
.
template
.
header
.
split
(
'#'
)[
0
]
:
''
;
this
.
template
.
headerColor
=
this
.
template
.
header
?
'#'
+
(
this
.
template
.
header
.
split
(
'#'
)[
1
]
||
'173177'
)
:
'#173177'
;
this
.
template
.
remarkText
=
this
.
template
.
remark
?
this
.
template
.
remark
.
split
(
'#'
)[
0
]
:
''
;
this
.
template
.
remarkColor
=
this
.
template
.
remark
?
'#'
+
(
this
.
template
.
remark
.
split
(
'#'
)[
1
]
||
'173177'
)
:
'#173177'
;
this
.
template
.
updateTime
=
template
.
updateTime
;
this
.
template
.
jumpUrl
=
template
.
jumpUrl
;
this
.
template
.
jumpUrlInfo
=
template
.
jumpUrlInfo
;
this
.
template
.
triggerCode
=
template
.
triggerCode
;
this
.
options
.
map
(
v
=>
{
console
.
log
(
this
.
template
.
headerText
.
indexOf
(
v
.
value
)
>
-
1
);
if
(
this
.
template
.
headerText
.
indexOf
(
v
.
value
)
>
-
1
)
{
this
.
template
.
headerText
=
this
.
template
.
headerText
.
replace
(
v
.
value
,
v
.
label
);
}
if
(
this
.
template
.
remarkText
.
indexOf
(
v
.
value
)
>
-
1
)
{
this
.
template
.
remarkText
=
this
.
template
.
remarkText
.
replace
(
v
.
value
,
v
.
label
);
}
});
},
// 下拉触发模板消息的改变
changeTemplate
()
{
let
template
=
null
;
this
.
templateOptions
.
map
(
v
=>
{
if
(
this
.
triggerCode
===
v
.
triggerCode
)
{
template
=
v
;
}
});
this
.
templateInit
(
template
);
},
// 预修改模板
editTemplatePre
()
{
this
.
editDialogShow
=
true
;
this
.
copyTemplate
=
JSON
.
parse
(
JSON
.
stringify
(
this
.
template
));
},
// 修改模板
editTemplate
()
{
this
.
editDialogShow
=
false
;
this
.
template
=
JSON
.
parse
(
JSON
.
stringify
(
this
.
copyTemplate
));
},
// 预插入变量
insetVarPre
(
val
)
{
this
.
varDialogShow
=
true
;
this
.
currentTxet
=
val
;
},
// 插入变量
insetVar
(
val
)
{
console
.
log
(
val
,
this
.
copyTemplate
[
this
.
currentTxet
]);
if
(
typeof
this
.
currentTxet
===
'number'
)
{
this
.
copyTemplate
.
templateKeyDataList
[
this
.
currentTxet
].
type
+=
val
;
}
this
.
copyTemplate
[
this
.
currentTxet
]
+=
val
;
},
// 重置模板
resetTemplate
()
{
this
.
getEcmInfo
(
true
);
},
// 变量弹窗关闭
close
()
{
this
.
editDialogShow
=
false
;
},
// 保存 校验
async
submit
(
formName
)
{
// // 这里强制获取人群筛选器的配置项
// await this.$refs.peopleFilter.confirmSet();
// 判断时间
if
(
this
.
checkBeginEndTime
())
return
;
const
hasMessageInList
=
this
.
$refs
.
marketingEvent
.
hasMessageInList
();
// 判断是否能发送短信
if
(
hasMessageInList
&&
this
.
isMessageForbidden
())
return
;
if
(
this
.
form
.
expireType
&&
(
!
this
.
form
.
beginDate
||
!
this
.
form
.
endDate
))
{
this
.
$tips
({
type
:
'warning'
,
message
:
'固定期限不能为空'
});
return
;
}
if
(
this
.
form
.
memberType
===
0
&&
this
.
toggleTag
&&
!
this
.
getSaveData
)
{
this
.
$tips
({
type
:
'warning'
,
message
:
'人群筛选未保存条件'
});
return
;
}
if
(
this
.
form
.
memberType
===
1
&&
!
this
.
form
.
memberGroupIds
)
{
this
.
$tips
({
type
:
'warning'
,
message
:
'会员分组不能为空'
});
return
;
}
// 如果是消费触发
if
(
this
.
form
.
effectAction
===
'consume'
)
{
const
{
max_cost
,
lowest_cost
,
max_cost_count
,
lowest_cost_count
}
=
this
.
form
;
if
(
isEmpty
(
max_cost
)
&&
isEmpty
(
lowest_cost
))
{
this
.
$tips
({
type
:
'warning'
,
message
:
'消费金额上下限必填一个'
});
return
;
}
if
(
max_cost
<
lowest_cost
)
{
this
.
$tips
({
type
:
'warning'
,
message
:
'消费金额区间设置错误'
});
return
;
}
if
(
isEmpty
(
max_cost_count
)
&&
isEmpty
(
lowest_cost_count
))
{
this
.
$tips
({
type
:
'warning'
,
message
:
'消费金额上下限必填一个'
});
return
;
}
if
(
max_cost_count
<
lowest_cost_count
)
{
this
.
$tips
({
type
:
'warning'
,
message
:
'消费件数区间设置错误'
});
return
;
}
}
let
params
=
{
ecmPlanId
:
this
.
form
.
ecmPlanId
||
''
,
templateEcmPlanId
:
this
.
isAdd
?
this
.
ecmPlanId
:
''
,
ecmPlanName
:
this
.
form
.
ecmPlanName
,
// 是 int 计划名称不能为空,且最多9个汉字
effectType
:
this
.
form
.
effectType
,
//是 int 时效: 实时: 0; 每天: 1
effectTime
:
this
.
form
.
effectTime
,
//否 int effectType = 1每天时必填, 时效为时间为0-23
effectAction
:
this
.
form
.
effectAction
,
// 否 string effectType = 0实时时必填, 关注触发: ‘subscribe’; 认证触发: ‘authentication’
marketingType
:
this
.
form
.
marketingType
,
//是 String 营销方式: 卡券营销: ‘card’; 短信营销 : ‘message’; 图文营销: ‘teletext’; 文本营销: ‘text’; 话务: ‘teltask’; 微信图片: ‘image’
memberType
:
this
.
form
.
memberType
,
memberSearchDTO
:
this
.
form
.
memberType
?
this
.
form
.
memberGroupIds
:
this
.
form
.
memberSearchDTO
,
searchJson
:
this
.
getSaveData
,
expireType
:
this
.
form
.
expireType
,
beginDate
:
this
.
form
.
expireType
?
formatDateTimeByType
(
this
.
form
.
beginDate
,
'yyyy-MM-dd-HH-mm-ss'
)
:
''
,
endDate
:
this
.
form
.
expireType
?
formatDateTimeByType
(
this
.
form
.
endDate
,
'yyyy-MM-dd-HH-mm-ss'
)
:
''
,
cardNoticeType
:
this
.
form
.
cardNoticeType
,
templateNoticeFlag
:
this
.
form
.
templateNoticeFlag
,
gradeIds
:
this
.
form
.
gradeIds
.
join
(
','
)
||
''
,
marketingTimesType
:
this
.
form
.
marketingTimesType
,
marketingTimes
:
this
.
form
.
marketingTimes
};
// 如果是消费触发
// 不填代表没有上下限,不传该字段
if
(
this
.
form
.
effectAction
===
'consume'
)
{
const
_mapConsumeArr
=
[
'lowest_cost'
,
'max_cost'
,
'lowest_cost_count'
,
'max_cost_count'
];
let
consumeObj
=
{
store_mode
:
this
.
form
.
store_mode
,
order_store
:
this
.
form
.
order_store
};
_mapConsumeArr
.
map
(
v
=>
{
// 保存的消费触发上下限数据,没有填写的字段不传
let
val
=
this
.
form
[
v
];
if
(
!
isEmpty
(
val
))
{
consumeObj
[
v
]
=
val
;
}
});
params
=
Object
.
assign
(
params
,
consumeObj
);
}
if
(
this
.
form
.
effectType
)
{
params
[
this
.
checked
[
0
]]
=
this
.
form
[
this
.
checked
[
0
]]
||
0
;
}
if
(
this
.
isAdd
)
{
params
.
sceneSettingId
=
this
.
form
.
sceneSettingId
;
// 否 String 营销场景
}
/* 模板消息的处理 */
if
(
this
.
currentCard
.
comName
===
'item-card'
&&
((
this
.
form
.
cardNoticeType
===
1
&&
this
.
form
.
effectType
===
0
&&
this
.
form
.
templateNoticeFlag
===
1
)
||
this
.
form
.
cardNoticeType
===
2
))
{
let
marketingTemplate
=
{};
let
header
=
this
.
template
.
headerText
;
let
remark
=
this
.
template
.
remarkText
;
this
.
options
.
map
(
v
=>
{
if
(
header
.
indexOf
(
v
.
label
)
>
-
1
)
{
// console.log(new RegExp((v.label+'/g')))
header
=
header
.
replace
(
v
.
label
,
v
.
value
);
}
if
(
remark
.
indexOf
(
v
.
label
)
>
-
1
)
{
remark
=
remark
.
replace
(
v
.
label
,
v
.
value
);
}
});
this
.
template
.
templateKeyDataList
=
this
.
template
.
templateKeyDataList
.
map
(
v
=>
({
keyName
:
v
.
keyName
,
keywords
:
v
.
keywords
,
datas
:
v
.
type
+
v
.
color
,
orders
:
v
.
orders
}));
marketingTemplate
=
{
weixinTemplateId
:
this
.
template
.
weixinTemplateId
,
templateBusiness
:
this
.
template
.
templateBusiness
,
typeCode
:
this
.
template
.
typeCode
,
templateName
:
this
.
template
.
templateName
,
title
:
this
.
template
.
title
,
urlType
:
this
.
template
.
urlType
,
jumpUrl
:
this
.
template
.
jumpUrl
,
jumpUrlInfo
:
this
.
template
.
jumpUrlInfo
,
triggerCode
:
this
.
template
.
triggerCode
,
header
:
header
+
this
.
template
.
headerColor
,
remark
:
remark
+
this
.
template
.
remarkColor
,
templateKeyDataList
:
this
.
template
.
templateKeyDataList
};
params
.
marketingTemplate
=
JSON
.
stringify
(
marketingTemplate
);
}
// 这里判断部分门店是否为空
if
(
this
.
form
.
store_mode
)
{
let
data
=
await
this
.
$refs
.
storeCard
.
getRightList
();
if
(
!
data
.
length
)
{
this
.
$tips
({
type
:
'warning'
,
message
:
'部分门店不能为空'
});
return
;
}
}
this
.
$refs
[
formName
].
validate
(
valid
=>
{
if
(
valid
)
{
this
.
saveEcmInfo
(
params
);
}
else
{
this
.
$tips
({
type
:
'warning'
,
message
:
'表单填写不完整'
});
return
false
;
}
});
},
// 保存
saveEcmInfo
(
params
)
{
this
.
loading
=
true
;
saveEcmInfo
(
params
)
.
then
(
res
=>
{
this
.
loading
=
false
;
if
(
res
.
errorCode
===
0
)
{
if
(
this
.
isEdit
)
{
this
.
$confirm
(
'操作成功, 是否返回列表?'
,
'提示'
,
{
confirmButtonText
:
'确定'
,
cancelButtonText
:
'取消'
,
type
:
'warning'
})
.
then
(()
=>
{
this
.
$router
.
go
(
-
1
);
})
.
catch
(
err
=>
{
this
.
getEcmInfo
();
});
}
else
{
this
.
$router
.
go
(
-
1
);
}
}
else
{
this
.
$tips
({
type
:
'error'
,
message
:
res
.
message
||
'操作失败'
});
}
})
.
catch
(
err
=>
{
this
.
loading
=
false
;
});
},
//加载会员卡等级
getGradeList
()
{
return
new
Promise
((
resolve
,
reject
)
=>
{
klflStrategy
({}).
then
(
res
=>
{
if
(
res
.
errorCode
===
0
)
{
resolve
(
res
.
result
.
gradeList
||
[]);
}
reject
();
});
});
},
// 触发行为变化 会员卡升降级
effectActionChange
(
isInit
=
false
)
{
if
(
this
.
form
.
effectAction
===
'upgrade'
)
{
if
(
isInit
!==
true
)
this
.
form
.
gradeIds
=
[];
this
.
getGradeList
().
then
(
data
=>
{
this
.
gradeList
=
data
.
map
((
v
,
i
)
=>
{
if
(
!
i
)
{
v
.
disabled
=
true
;
}
return
v
;
});
// console.log(this.gradeList)
});
}
else
if
(
this
.
form
.
effectAction
===
'degrade'
)
{
if
(
isInit
!==
true
)
this
.
form
.
gradeIds
=
[];
this
.
getGradeList
().
then
(
data
=>
{
this
.
gradeList
=
data
.
reverse
().
map
((
v
,
i
)
=>
{
if
(
!
i
)
{
v
.
disabled
=
true
;
}
return
v
;
});
// console.log(this.gradeList )
});
}
},
changeChecked
(
e
)
{
console
.
log
(
e
);
},
/* ----------------辅助方法--------------- */
// 对比开始时间结束时间
checkBeginEndTime
()
{
let
beginDate
=
this
.
form
.
beginDate
&&
new
Date
(
this
.
form
.
beginDate
);
let
endDate
=
this
.
form
.
endDate
&&
new
Date
(
this
.
form
.
endDate
);
if
(
this
.
form
.
expireType
&&
beginDate
&&
endDate
&&
beginDate
.
getTime
()
>
endDate
.
getTime
())
{
this
.
$tips
({
type
:
'warning'
,
message
:
'开始时间不能大于结束时间'
});
// this.form.beginDate = this.form.endDate;
this
.
showMessage
=
true
;
return
true
;
}
else
{
this
.
showMessage
=
false
;
return
false
;
}
},
// 是否禁止发短信 逻辑 => 当用户选择每天发送,且短信模板选择为营销短信时,需要判断定时发送时间是否在08:00至22:00之间,若否则停留在新建计划页面,禁止短信群发并进行提醒。
isMessageForbidden
()
{
// console.log(this.$refs.marketingEvent.hasMessageInList(),this.form.effectType === 1,this.form.effectTime)
if
(
this
.
form
.
effectType
===
1
&&
(
this
.
form
.
effectTime
>=
22
||
this
.
form
.
effectTime
<=
8
))
{
this
.
$alert
(
`<div>
<i class="el-icon-warning warning-color fz30 vertical-middle mr20"></i>
<p class="inline-block vertical-middle w300">短信运营商限制:为避免骚扰用户,营销短信只允许在8点到22点发送</p>
</div>`
,
'提示'
,
{
dangerouslyUseHTMLString
:
true
,
showCancelButton
:
true
,
showConfirmButton
:
false
,
cancelButtonText
:
'关闭'
}
);
return
true
;
}
else
{
return
false
;
}
},
// 接收的子方法 是否有卡券 value为卡券
hasCard
(
value
)
{
this
.
currentCard
=
value
;
},
// 初始化门店左侧数据
initStoreCardLeft
()
{
if
(
this
.
form
.
store_mode
)
{
if
(
this
.
isAdd
)
{
// 这里新增的情况下也要初始化 门店组件
this
.
$nextTick
(
_
=>
{
this
.
$refs
.
storeCard
.
init
();
});
}
else
{
this
.
$nextTick
(
_
=>
{
this
.
$refs
.
storeCard
.
initLeftList
();
});
}
}
},
/* ----------------人群筛选器的方法--------------- */
getData
()
{
this
.
$refs
.
peopleFilter
.
confirmSet
();
},
// 子组件触发父组件事件,返回过滤条件数据
findFilter
(
value
)
{
this
.
form
.
memberSearchDTO
=
value
;
},
// 取消
cancelFilter
()
{
this
.
$refs
.
peopleFilter
.
cancelSet
();
},
// 获取需要回显的数据, 供保存时候使用
getBackData
(
val
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
this
.
getSaveData
=
val
;
console
.
log
(
this
.
getSaveData
,
val
);
resolve
();
});
},
// 显示编辑,保存按钮隐藏,确认按钮显示 (子组件会调用)
editShow
()
{
this
.
toggleTag
=
true
;
this
.
saveTag
=
false
;
},
// 显示保存按钮,隐藏确认按钮显示 (子组件会调用)
editHide
()
{
this
.
toggleTag
=
false
;
this
.
saveTag
=
true
;
},
// 隐藏保存按钮和确认按钮 (子组件会调用)
hideBtn
()
{
this
.
toggleTag
=
false
;
this
.
saveTag
=
false
;
},
handleDataTransferred
(
data
)
{
// 会员分组 情况下 memberSearchDTO 传数组字符串
if
(
this
.
form
.
memberType
===
1
)
{
this
.
form
.
memberGroupIds
=
data
.
map
(
v
=>
v
.
memberTagGroupId
)
.
filter
(
v
=>
v
)
.
join
(
','
);
}
},
handleDataLeft
(
selectedData
,
selectionToRemove
)
{
console
.
log
(
selectedData
,
selectionToRemove
);
}
},
filters
:
{
filterDate
(
val
)
{
if
(
val
)
{
return
`
${
new
Date
(
val
).
getMonth
()
+
1
}
月
${
new
Date
(
val
).
getDate
()}
日`
;
}
else
{
return
'未知时间'
;
}
}
}
};
</
script
>
</
script
>
<
style
lang=
"scss"
scoped
>
<
style
lang=
"scss"
scoped
>
.ecm-msg__edit
{
.ecm-msg__edit
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment