Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
saas
/
scrm-micro-presale
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 9f6f035e
authored
May 10, 2024
by
zhangquan
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
价格区间
1 parent
9efd79f4
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
63 additions
and
28 deletions
src/util/gradeData.js
src/views/serviceConfig/addService.vue
src/views/serviceConfig/components/ServicesTable/index.vue
src/util/gradeData.js
View file @
9f6f035
...
@@ -3,7 +3,6 @@ const gradeObj = {
...
@@ -3,7 +3,6 @@ const gradeObj = {
gradeConfigList
:
[
gradeConfigList
:
[
{
{
servicePeriod
:
''
,
servicePeriod
:
''
,
priceGrade
:
'0'
,
maxPrice
:
'15'
,
maxPrice
:
'15'
,
minPrice
:
'0'
,
minPrice
:
'0'
,
priceCoefficient
:
''
,
priceCoefficient
:
''
,
...
@@ -12,7 +11,6 @@ const gradeObj = {
...
@@ -12,7 +11,6 @@ const gradeObj = {
},
},
{
{
servicePeriod
:
''
,
servicePeriod
:
''
,
priceGrade
:
'1'
,
maxPrice
:
'30'
,
maxPrice
:
'30'
,
minPrice
:
'15'
,
minPrice
:
'15'
,
priceCoefficient
:
''
,
priceCoefficient
:
''
,
...
@@ -21,13 +19,12 @@ const gradeObj = {
...
@@ -21,13 +19,12 @@ const gradeObj = {
},
},
{
{
servicePeriod
:
''
,
servicePeriod
:
''
,
priceGrade
:
'2'
,
maxPrice
:
'200'
,
maxPrice
:
'200'
,
minPrice
:
'30'
,
minPrice
:
'30'
,
priceCoefficient
:
''
,
priceCoefficient
:
''
,
standardShelfCost
:
''
,
standardShelfCost
:
''
,
standardSalesCost
:
''
standardSalesCost
:
''
},
}
],
],
salePeriodData
:
[],
salePeriodData
:
[],
serviceGrade
:
'A'
,
serviceGrade
:
'A'
,
...
@@ -35,7 +32,7 @@ const gradeObj = {
...
@@ -35,7 +32,7 @@ const gradeObj = {
serviceDetail
:
''
serviceDetail
:
''
}
}
const
deepClone
=
(
obj
)
=>
{
const
deepClone
=
obj
=>
{
// Handle the 3 simple types, and null or undefined or function
// Handle the 3 simple types, and null or undefined or function
if
(
obj
==
null
||
typeof
obj
!==
'object'
)
return
obj
if
(
obj
==
null
||
typeof
obj
!==
'object'
)
return
obj
// Handle Date
// Handle Date
...
@@ -57,18 +54,20 @@ const deepClone = (obj)=> {
...
@@ -57,18 +54,20 @@ const deepClone = (obj)=> {
throw
new
Error
(
"Unable to clone obj! Its type isn't supported."
)
throw
new
Error
(
"Unable to clone obj! Its type isn't supported."
)
}
}
export
const
addGradeItem
=
(
grade
=
'A'
,
salePeriodList
=
[])
=>
{
export
const
addGradeItem
=
(
grade
=
'A'
,
salePeriodList
=
[])
=>
{
let
_gradeObj
=
deepClone
(
gradeObj
)
let
_gradeObj
=
deepClone
(
gradeObj
)
_gradeObj
.
serviceGrade
=
grade
_gradeObj
.
serviceGrade
=
grade
salePeriodList
=
salePeriodList
.
sort
(
function
(
a
,
b
){
return
a
-
b
});
salePeriodList
=
salePeriodList
.
sort
(
function
(
a
,
b
)
{
_gradeObj
.
salePeriodData
=
salePeriodList
.
map
(
item
=>
{
return
a
-
b
return
{
servicePeriod
:
item
,
standardShelfCost
:
''
,
standardSalesCost
:
''
}
})
_gradeObj
.
salePeriodData
=
salePeriodList
.
map
(
item
=>
{
return
{
servicePeriod
:
item
,
standardShelfCost
:
''
,
standardSalesCost
:
''
}
})
})
console
.
log
(
_gradeObj
)
console
.
log
(
_gradeObj
)
return
_gradeObj
return
_gradeObj
}
}
export
const
handleGradeData
=
(
dataFromApi
,
salePeriodList
=
[])
=>
{
export
const
handleGradeData
=
(
dataFromApi
,
salePeriodList
=
[])
=>
{
console
.
log
(
dataFromApi
)
console
.
log
(
dataFromApi
)
const
data
=
deepClone
(
dataFromApi
)
const
data
=
deepClone
(
dataFromApi
)
let
arr
=
[]
let
arr
=
[]
...
@@ -81,20 +80,20 @@ export const handleGradeData = (dataFromApi, salePeriodList=[])=>{
...
@@ -81,20 +80,20 @@ export const handleGradeData = (dataFromApi, salePeriodList=[])=>{
serviceGrade
,
serviceGrade
,
gradeConfigList
:
[]
gradeConfigList
:
[]
}
}
const
gradeList
=
[
'0'
,
'1'
,
'2'
]
//三个区间等级,后端定义的
gradeConfigList
.
forEach
(
item
=>
{
gradeList
.
forEach
(
item
=>
{
let
{
id
,
servicePeriod
,
maxPrice
,
minPrice
,
priceCoefficient
}
=
item
||
{}
const
_target
=
gradeConfigList
.
find
(
o
=>
o
.
priceGrade
==
item
)
let
{
id
,
servicePeriod
,
maxPrice
,
minPrice
,
priceCoefficient
}
=
_target
||
{}
maxPrice
=
NP
.
divide
(
maxPrice
||
0
,
1000000
)
maxPrice
=
NP
.
divide
(
maxPrice
||
0
,
1000000
)
minPrice
=
NP
.
divide
(
minPrice
||
0
,
1000000
)
minPrice
=
NP
.
divide
(
minPrice
||
0
,
1000000
)
_gradeObj
.
gradeConfigList
.
push
({
servicePeriod
,
priceGrade
:
item
,
maxPrice
,
minPrice
,
priceCoefficient
,
id
})
_gradeObj
.
gradeConfigList
.
push
({
servicePeriod
,
maxPrice
,
minPrice
,
priceCoefficient
,
id
})
})
})
salePeriodList
=
salePeriodList
.
sort
(
function
(
a
,
b
){
return
a
-
b
})
salePeriodList
=
salePeriodList
.
sort
(
function
(
a
,
b
)
{
_gradeObj
.
salePeriodData
=
salePeriodList
.
map
(
item
=>
{
return
a
-
b
const
_target
=
element
.
gradeConfigList
.
find
(
o
=>
o
.
servicePeriod
==
item
)
})
return
{
servicePeriod
:
item
,
standardShelfCost
:
NP
.
divide
(
_target
?.
standardShelfCost
||
0
,
100
),
standardSalesCost
:
NP
.
divide
(
_target
?.
standardSalesCost
||
0
,
100
)}
_gradeObj
.
salePeriodData
=
salePeriodList
.
map
(
item
=>
{
const
_target
=
element
.
gradeConfigList
.
find
(
o
=>
o
.
servicePeriod
==
item
)
return
{
servicePeriod
:
item
,
standardShelfCost
:
NP
.
divide
(
_target
?.
standardShelfCost
||
0
,
100
),
standardSalesCost
:
NP
.
divide
(
_target
?.
standardSalesCost
||
0
,
100
)
}
})
})
arr
.
push
(
_gradeObj
)
arr
.
push
(
_gradeObj
)
})
;
})
return
arr
return
arr
}
}
src/views/serviceConfig/addService.vue
View file @
9f6f035
...
@@ -349,8 +349,8 @@ export default {
...
@@ -349,8 +349,8 @@ export default {
this
.
gradeList
.
forEach
(
item
=>
{
this
.
gradeList
.
forEach
(
item
=>
{
const
{
id
,
serviceGrade
,
serviceOverview
,
serviceDetail
,
salePeriodData
,
gradeConfigList
}
=
item
const
{
id
,
serviceGrade
,
serviceOverview
,
serviceDetail
,
salePeriodData
,
gradeConfigList
}
=
item
let
_gradeConfigList
=
[]
let
_gradeConfigList
=
[]
gradeConfigList
.
forEach
(
ele
=>
{
gradeConfigList
.
forEach
(
(
ele
,
eleIdx
)
=>
{
let
{
price
Grade
,
price
Coefficient
,
minPrice
,
maxPrice
}
=
ele
let
{
priceCoefficient
,
minPrice
,
maxPrice
}
=
ele
if
(
this
.
isEmpty
(
minPrice
)
||
this
.
isEmpty
(
maxPrice
)
||
this
.
isEmpty
(
priceCoefficient
))
{
if
(
this
.
isEmpty
(
minPrice
)
||
this
.
isEmpty
(
maxPrice
)
||
this
.
isEmpty
(
priceCoefficient
))
{
throw
new
Error
(
`请输入
${
serviceGrade
}
规格的
${
this
.
isEmpty
(
priceCoefficient
)
?
'价格系数'
:
'价格区间'
}
`
)
throw
new
Error
(
`请输入
${
serviceGrade
}
规格的
${
this
.
isEmpty
(
priceCoefficient
)
?
'价格系数'
:
'价格区间'
}
`
)
}
}
...
@@ -363,7 +363,7 @@ export default {
...
@@ -363,7 +363,7 @@ export default {
let
max_price
=
NP
.
times
(
maxPrice
||
0
,
1000000
)
let
max_price
=
NP
.
times
(
maxPrice
||
0
,
1000000
)
standardSalesCost
=
NP
.
times
(
standardSalesCost
||
0
,
100
)
standardSalesCost
=
NP
.
times
(
standardSalesCost
||
0
,
100
)
standardShelfCost
=
NP
.
times
(
standardShelfCost
||
0
,
100
)
standardShelfCost
=
NP
.
times
(
standardShelfCost
||
0
,
100
)
let
gradeConfigObj
=
{
id
,
priceGrade
,
priceCoefficient
,
minPrice
:
min_price
,
maxPrice
:
max_price
,
servicePeriod
,
standardSalesCost
,
standardShelfCost
}
let
gradeConfigObj
=
{
id
,
priceGrade
:
eleIdx
,
priceCoefficient
,
minPrice
:
min_price
,
maxPrice
:
max_price
,
servicePeriod
,
standardSalesCost
,
standardShelfCost
}
_gradeConfigList
.
push
(
gradeConfigObj
)
_gradeConfigList
.
push
(
gradeConfigObj
)
})
})
})
})
...
...
src/views/serviceConfig/components/ServicesTable/index.vue
View file @
9f6f035
...
@@ -6,6 +6,7 @@
...
@@ -6,6 +6,7 @@
<th
rowspan=
"2"
>
价格区间(万元)
</th>
<th
rowspan=
"2"
>
价格区间(万元)
</th>
<th
rowspan=
"2"
>
价格系数
</th>
<th
rowspan=
"2"
>
价格系数
</th>
<th
colspan=
"2"
v-for=
"(item, index) in tableData.salePeriodData"
:key=
"index"
>
{{
item
.
servicePeriod
}}
年版
</th>
<th
colspan=
"2"
v-for=
"(item, index) in tableData.salePeriodData"
:key=
"index"
>
{{
item
.
servicePeriod
}}
年版
</th>
<th
rowspan=
"2"
>
操作
</th>
</tr>
</tr>
<tr>
<tr>
<template
v-for=
"(item, index) in tableData.salePeriodData"
>
<template
v-for=
"(item, index) in tableData.salePeriodData"
>
...
@@ -24,28 +25,33 @@
...
@@ -24,28 +25,33 @@
</
template
>
</
template
>
</tr>
</tr>
<tr>
<tr>
<td
rowspan=
"4
"
>
{{ tableData.serviceGrade }}
</td>
<td
:rowspan=
"tableData.gradeConfigList.length + 2
"
>
{{ tableData.serviceGrade }}
</td>
<td>
标准
</td>
<td>
标准
</td>
<td>
-
</td>
<td>
-
</td>
<
template
v-for=
"(item, index) in tableData.salePeriodData"
>
<
template
v-for=
"(item, index) in tableData.salePeriodData"
>
<td
:key=
"index"
><el-input
:placeholder=
"placeholder"
@
input=
"changePrice($event, item, 'standardShelfCost')"
:disabled=
"disabled"
v-model=
"item.standardShelfCost"
></el-input></td>
<td
:key=
"index"
><el-input
:placeholder=
"placeholder"
@
input=
"changePrice($event, item, 'standardShelfCost')"
:disabled=
"disabled"
v-model=
"item.standardShelfCost"
></el-input></td>
<td
:key=
"index"
><el-input
:placeholder=
"placeholder"
@
input=
"changePrice($event, item, 'standardSalesCost')"
:disabled=
"disabled"
v-model=
"item.standardSalesCost"
></el-input></td>
<td
:key=
"index"
><el-input
:placeholder=
"placeholder"
@
input=
"changePrice($event, item, 'standardSalesCost')"
:disabled=
"disabled"
v-model=
"item.standardSalesCost"
></el-input></td>
</
template
>
</
template
>
<td></td>
</tr>
</tr>
<tr
v-for=
"(item, index) in tableData.gradeConfigList"
:key=
"index"
>
<tr
v-for=
"(item, index) in tableData.gradeConfigList"
:key=
"index"
>
<td
class=
"price"
>
<td
class=
"price"
>
<el-input
:placeholder=
"placeholder"
@
input=
"changePrice($event, item, 'minPrice')"
@
blur=
"formatPrice($event, item, 'minPrice', 200)"
:disabled=
"disabled"
v-model=
"item.minPrice"
></el-input>
<el-input
:placeholder=
"placeholder"
@
input=
"changePrice($event, item, 'minPrice')"
:disabled=
"disabled"
v-model=
"item.minPrice"
></el-input>
<span
class=
"sign"
>
-
</span>
<span
class=
"sign"
>
-
</span>
<el-input
:placeholder=
"placeholder"
@
input=
"changePrice($event, item, 'maxPrice')"
@
blur=
"formatPrice($event, item, 'maxPrice', 200)"
:disabled=
"disabled"
v-model=
"item.maxPrice"
></el-input>
<el-input
:placeholder=
"placeholder"
@
input=
"changePrice($event, item, 'maxPrice')"
:disabled=
"disabled"
v-model=
"item.maxPrice"
></el-input>
</td>
</td>
<td><el-input
:placeholder=
"placeholder"
@
input=
"changePrice($event, item, 'priceCoefficient')"
:disabled=
"disabled"
@
blur=
"formatPrice($event, item, 'priceCoefficient', 100)"
v-model=
"item.priceCoefficient"
></el-input></td>
<td><el-input
:placeholder=
"placeholder"
@
input=
"changePrice($event, item, 'priceCoefficient')"
:disabled=
"disabled"
@
blur=
"formatPrice($event, item, 'priceCoefficient', 100)"
v-model=
"item.priceCoefficient"
></el-input></td>
<
template
v-for=
"(ele, eIdx) in tableData.salePeriodData"
>
<
template
v-for=
"(ele, eIdx) in tableData.salePeriodData"
>
<td
:key=
"eIdx"
>
{{
calcPrice
(
ele
.
standardShelfCost
,
item
.
priceCoefficient
)
}}
</td>
<td
:key=
"eIdx"
>
{{
calcPrice
(
ele
.
standardShelfCost
,
item
.
priceCoefficient
)
}}
</td>
<td
:key=
"eIdx"
>
{{
calcPrice
(
ele
.
standardSalesCost
,
item
.
priceCoefficient
)
}}
</td>
<td
:key=
"eIdx"
>
{{
calcPrice
(
ele
.
standardSalesCost
,
item
.
priceCoefficient
)
}}
</td>
</
template
>
</
template
>
<td
class=
"del-btn"
><span
v-if=
"index > 2"
class=
"btn"
@
click=
"delSection(index)"
>
删除
</span></td>
</tr>
<tr>
<td
class=
"add-btn"
:colspan=
"tableData.salePeriodData.length * 2 + 3"
><span
class=
"btn"
@
click=
"addSection"
>
新增价格区间
</span></td>
</tr>
</tr>
<tr
class=
"desc-wrap"
>
<tr
class=
"desc-wrap"
>
<td
class=
"desc-td"
:colspan=
"tableData.salePeriodData.length * 2 +
3
"
>
<td
class=
"desc-td"
:colspan=
"tableData.salePeriodData.length * 2 +
4
"
>
<div
class=
"desc"
>
<div
class=
"desc"
>
<label
for=
""
>
服务条款概述:
</label>
<label
for=
""
>
服务条款概述:
</label>
<Editor
:disabled=
"disabled"
:hasTool=
"false"
:editorOption=
"overviewOption"
v-model=
"tableData.serviceOverview"
></Editor>
<Editor
:disabled=
"disabled"
:hasTool=
"false"
:editorOption=
"overviewOption"
v-model=
"tableData.serviceOverview"
></Editor>
...
@@ -53,7 +59,7 @@
...
@@ -53,7 +59,7 @@
</td>
</td>
</tr>
</tr>
<tr
class=
"desc-wrap"
>
<tr
class=
"desc-wrap"
>
<td
class=
"desc-td"
:colspan=
"tableData.salePeriodData.length * 2 +
3
"
>
<td
class=
"desc-td"
:colspan=
"tableData.salePeriodData.length * 2 +
4
"
>
<div
class=
"desc"
>
<div
class=
"desc"
>
<label
for=
""
>
规格详细描述:
</label>
<label
for=
""
>
规格详细描述:
</label>
<Editor
:disabled=
"disabled"
:hasTool=
"false"
:editorOption=
"DetailOption"
v-model=
"tableData.serviceDetail"
></Editor>
<Editor
:disabled=
"disabled"
:hasTool=
"false"
:editorOption=
"DetailOption"
v-model=
"tableData.serviceDetail"
></Editor>
...
@@ -158,12 +164,42 @@ export default {
...
@@ -158,12 +164,42 @@ export default {
})
})
Delta
.
ops
=
ops
Delta
.
ops
=
ops
return
Delta
return
Delta
},
addSection
()
{
// 获取最后一个的最大价格赋值到新增的最小价格
const
minPrice
=
this
.
tableData
.
gradeConfigList
[
this
.
tableData
.
gradeConfigList
.
length
-
1
].
maxPrice
let
sectionItem
=
{
servicePeriod
:
''
,
maxPrice
:
''
,
minPrice
,
priceCoefficient
:
''
,
standardShelfCost
:
''
,
standardSalesCost
:
''
}
this
.
tableData
.
gradeConfigList
.
push
(
sectionItem
)
},
delSection
(
idx
)
{
const
minPrice
=
this
.
tableData
.
gradeConfigList
[
idx
-
1
].
maxPrice
this
.
tableData
.
gradeConfigList
.
splice
(
idx
,
1
)
if
(
this
.
tableData
.
gradeConfigList
.
length
>
idx
)
{
this
.
$set
(
this
.
tableData
.
gradeConfigList
[
idx
],
'minPrice'
,
minPrice
)
}
}
}
}
}
}
}
</
script
>
</
script
>
<
style
lang=
"scss"
scoped
>
<
style
lang=
"scss"
scoped
>
.table-wrap
{
.table-wrap
{
.del-btn
{
color
:
#5f5efb
;
}
.btn
{
cursor
:
pointer
;
}
.add-btn
{
color
:
#5f5efb
;
text-align
:
left
;
}
.tip
{
.tip
{
width
:
14px
;
width
:
14px
;
vertical-align
:
middle
;
vertical-align
:
middle
;
...
...
Write
Preview
Markdown
is supported
Attach a file
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 post a comment