Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
taobao-mini-template
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
2
Issues
2
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
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
qinhaitao
taobao-mini-template
Commits
cb09d474
Commit
cb09d474
authored
Jul 22, 2020
by
秦海涛
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
b46e643a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
56 additions
and
53 deletions
+56
-53
mixins.js
client/pages/activity/add/mixins.js
+56
-53
No files found.
client/pages/activity/add/mixins.js
View file @
cb09d474
export
const
methods
=
{
// 根据dataName 改变值
onInputChangeByDataName
(
e
)
{
const
{
name
}
=
e
.
target
.
dataset
;
const
{
value
}
=
e
.
detail
;
this
.
setDataByKey
(
value
,
name
);
},
onTimeChange
(
timeRange
,
error
)
{
const
{
formState
}
=
this
.
data
;
methods
:
{
// 根据dataName 改变值
onInputChangeByDataName
(
e
)
{
const
{
name
}
=
e
.
target
.
dataset
;
const
{
value
}
=
e
.
detail
;
this
.
setDataByKey
(
value
,
name
);
},
onTimeChange
(
timeRange
,
error
)
{
const
{
formState
}
=
this
.
data
;
this
.
setData
({
timeRange
,
startTime
:
timeRange
[
0
],
endTime
:
timeRange
[
1
],
formState
:
{
...
formState
,
timeRange
:
{
status
:
error
?
'error'
:
'success'
,
message
:
error
||
''
}
}
})
},
onChangeByDataName
(
val
,
key
)
{
this
.
setDataByKey
(
val
,
key
)
},
/**
*根据key值改变数据, 支持key a/a.b/a.b.c的形式
*
* @param {*} val
* @param {string} key
*/
setDataByKey
(
val
,
key
)
{
const
keys
=
key
.
split
(
'.'
);
if
(
keys
.
length
===
1
)
{
this
.
setData
({
[
keys
[
0
]]:
val
})
}
if
(
keys
.
length
===
2
)
{
let
targetKey
=
this
.
data
[
keys
[
0
]];
targetKey
[
keys
[
1
]]
=
val
;
let
newVal
=
Object
.
assign
({},
targetKey
)
this
.
setData
({
[
keys
[
0
]]:
newVal
})
}
if
(
keys
.
length
===
3
)
{
let
targetKey
=
this
.
data
[
keys
[
0
]];
targetKey
[
keys
[
1
]][
keys
[
2
]]
=
val
;
let
newVal
=
Object
.
assign
({},
targetKey
)
this
.
setData
({
[
keys
[
0
]]:
newVal
timeRange
,
startTime
:
timeRange
[
0
],
endTime
:
timeRange
[
1
],
formState
:
{
...
formState
,
timeRange
:
{
status
:
error
?
'error'
:
'success'
,
message
:
error
||
''
}
}
})
},
onChangeByDataName
(
val
,
key
)
{
this
.
setDataByKey
(
val
,
key
)
},
/**
*根据key值改变数据, 支持key a/a.b/a.b.c的形式
*
* @param {*} val
* @param {string} key
*/
setDataByKey
(
val
,
key
)
{
const
keys
=
key
.
split
(
'.'
);
if
(
keys
.
length
===
1
)
{
this
.
setData
({
[
keys
[
0
]]:
val
})
}
if
(
keys
.
length
===
2
)
{
let
targetKey
=
this
.
data
[
keys
[
0
]];
targetKey
[
keys
[
1
]]
=
val
;
let
newVal
=
Object
.
assign
({},
targetKey
)
this
.
setData
({
[
keys
[
0
]]:
newVal
})
}
if
(
keys
.
length
===
3
)
{
let
targetKey
=
this
.
data
[
keys
[
0
]];
targetKey
[
keys
[
1
]][
keys
[
2
]]
=
val
;
let
newVal
=
Object
.
assign
({},
targetKey
)
this
.
setData
({
[
keys
[
0
]]:
newVal
})
}
}
},
}
}
\ No newline at end of file
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