Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
郑艺斌
/
emaint-servicer-wechat-app
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
249a005f
authored
Dec 06, 2022
by
郑艺斌
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
优化完成维修
parent
f3c4019d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
112 additions
and
70 deletions
pages/endRepair/repair.js
pages/endRepair/repair.wxml
pages/endRepair/repair.js
View file @
249a005f
...
@@ -6,14 +6,13 @@ Page({
...
@@ -6,14 +6,13 @@ Page({
* 页面的初始数据
* 页面的初始数据
*/
*/
data
:
{
data
:
{
formData
:{
formData
:
{
remarks
:
''
remarks
:
''
},
},
tags
:[
tags
:
[
],
originFiles
:[
],
],
originFiles
:
[],
gridConfig
:
{
gridConfig
:
{
column
:
3
,
column
:
3
,
width
:
220
,
width
:
220
,
...
@@ -22,17 +21,17 @@ Page({
...
@@ -22,17 +21,17 @@ Page({
config
:
{
config
:
{
count
:
6
,
count
:
6
,
},
},
id
:
''
,
id
:
''
,
tagText
:
''
,
tagText
:
''
,
},
},
/**
/**
* 生命周期函数--监听页面加载
* 生命周期函数--监听页面加载
*/
*/
onLoad
(
options
)
{
onLoad
(
options
)
{
if
(
options
&&
options
.
id
)
{
if
(
options
&&
options
.
id
)
{
this
.
setData
({
this
.
setData
({
id
:
options
.
id
id
:
options
.
id
})
})
}
}
},
},
...
@@ -43,7 +42,7 @@ Page({
...
@@ -43,7 +42,7 @@ Page({
onReady
()
{
onReady
()
{
this
.
getTabs
()
this
.
getTabs
()
},
},
getTabs
(){
getTabs
()
{
const
that
=
this
const
that
=
this
wx
.
request
({
wx
.
request
({
url
:
baseUrl
+
'/api/emaint/problem-base/showLabel'
,
url
:
baseUrl
+
'/api/emaint/problem-base/showLabel'
,
...
@@ -58,84 +57,92 @@ Page({
...
@@ -58,84 +57,92 @@ Page({
success
:
function
(
res
)
{
success
:
function
(
res
)
{
console
.
log
(
res
);
console
.
log
(
res
);
if
(
res
.
data
.
statusCode
===
200
)
{
if
(
res
.
data
.
statusCode
===
200
)
{
console
.
log
(
res
);
console
.
log
(
res
);
that
.
setData
({
that
.
setData
({
tags
:
res
.
data
.
responseResult
tags
:
res
.
data
.
responseResult
})
})
}
}
}})
}
})
},
},
addTag
(){
addTag
()
{
const
that
=
this
const
that
=
this
let
pattern1
=
/^
\s
+/g
;
//
let pattern1 = /^\s+/g;
let
pattern2
=
/
\s
+$/g
;
//
let pattern2 = /\s+$/g;
let
tagText
=
this
.
data
.
tagText
//
let tagText = this.data.tagText
if
(
pattern1
.
test
(
tagText
))
{
// if (pattern1.test(tagText))
{
wx
.
showToast
({
//
wx.showToast({
title
:
`文字前不能包含空格!`
,
//
title: `文字前不能包含空格!`,
icon
:
'none'
,
//
icon: 'none',
duration
:
2000
//
duration: 2000
})
//
})
return
//
return
}
else
if
(
pattern2
.
test
(
tagText
))
{
// } else if (pattern2.test(tagText))
{
wx
.
showToast
({
//
wx.showToast({
title
:
`文字后不能包含空格!`
,
//
title: `文字后不能包含空格!`,
icon
:
'none'
,
//
icon: 'none',
duration
:
2000
//
duration: 2000
})
//
})
return
//
return
}
//
}
wx
.
request
({
wx
.
request
({
url
:
baseUrl
+
'/api/emaint/problem-base/addLabel'
,
url
:
baseUrl
+
'/api/emaint/problem-base/addLabel'
,
data
:
{
data
:
{
id
:
that
.
data
.
id
,
id
:
that
.
data
.
id
,
problem
:
that
.
data
.
tagText
problem
:
that
.
data
.
tagText
},
},
method
:
'POST'
,
// OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
method
:
'POST'
,
// OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
header
:
{
header
:
{
"Content-Type"
:
"application/x-www-form-urlencoded"
,
"Content-Type"
:
"application/x-www-form-urlencoded"
,
},
// 设置请求的 header
},
// 设置请求的 header
success
:
function
(
res
)
{
success
:
function
(
res
)
{
if
(
res
.
data
.
statusCode
===
200
)
{
if
(
res
.
data
.
statusCode
===
200
)
{
that
.
setData
({
that
.
setData
({
tagText
:
''
tagText
:
''
})
})
that
.
getTabs
()
}
else
{
}
else
{
wx
.
showToast
({
wx
.
showToast
({
title
:
res
.
data
.
responseResult
,
title
:
res
.
data
.
responseResult
,
icon
:
'none'
,
icon
:
'none'
,
duration
:
2000
duration
:
2000
})
})
}
}
}})
}
})
},
},
onInput
(
e
){
onInput
(
e
)
{
const
{
value
}
=
e
.
detail
const
{
value
}
=
e
.
detail
this
.
setData
({
this
.
setData
({
tagText
:
value
tagText
:
value
})
})
},
},
// 点击标签
// 点击标签
onTag
(
item
){
onTag
(
item
)
{
const
that
=
this
const
that
=
this
let
value
=
item
.
target
.
dataset
let
value
=
item
.
target
.
dataset
console
.
log
(
value
);
console
.
log
(
value
);
that
.
setData
({
that
.
setData
({
[
`tags[
${
value
.
index
}
].checked`
]:
!
value
.
checked
[
`tags[
${
value
.
index
}
].checked`
]:
!
value
.
checked
})
})
},
},
onRemarks
(
e
){
onRemarks
(
e
)
{
const
{
value
}
=
e
.
detail
const
{
value
}
=
e
.
detail
this
.
setData
({
this
.
setData
({
[
`formData.remarks`
]:
value
[
`formData.remarks`
]:
value
})
})
},
},
// 上传图片接口
// 上传图片接口
handleChange
(
e
){
handleChange
(
e
)
{
const
that
=
this
const
that
=
this
const
{
currentSelectedFiles
,
files
}
=
e
.
detail
const
{
currentSelectedFiles
,
files
}
=
e
.
detail
currentSelectedFiles
[
0
].
forEach
(
item
=>
{
currentSelectedFiles
[
0
].
forEach
(
item
=>
{
wx
.
uploadFile
({
wx
.
uploadFile
({
url
:
baseUrl
+
'/api/file/upload'
,
url
:
baseUrl
+
'/api/file/upload'
,
...
@@ -146,54 +153,87 @@ Page({
...
@@ -146,54 +153,87 @@ Page({
},
},
success
:
function
(
res
)
{
success
:
function
(
res
)
{
console
.
log
(
res
);
console
.
log
(
res
);
if
(
res
.
statusCode
===
200
)
{
if
(
res
.
statusCode
===
200
)
{
var
isimg
=
JSON
.
parse
(
res
.
data
).
responseResult
var
isimg
=
JSON
.
parse
(
res
.
data
).
responseResult
console
.
log
(
isimg
);
console
.
log
(
isimg
);
that
.
data
.
originFiles
.
push
({
url
:
item
.
url
,
img
:
isimg
})
that
.
data
.
originFiles
.
push
({
url
:
item
.
url
,
img
:
isimg
})
that
.
setData
({
that
.
setData
({
originFiles
:
that
.
data
.
originFiles
,
originFiles
:
that
.
data
.
originFiles
,
});
});
}
}
}
}
})
})
})
})
},
},
// 删除图片回调函数
// 删除图片回调函数
handleRemove
(
e
)
{
handleRemove
(
e
)
{
const
{
index
}
=
e
.
detail
;
const
{
const
{
originFiles
}
=
this
.
data
;
index
}
=
e
.
detail
;
const
{
originFiles
}
=
this
.
data
;
originFiles
.
splice
(
index
,
1
);
originFiles
.
splice
(
index
,
1
);
this
.
setData
({
this
.
setData
({
originFiles
,
originFiles
,
});
});
},
},
submit
(){
submit
()
{
const
that
=
this
const
that
=
this
let
arr
=
[]
let
arr
=
[]
let
imgs
=
[]
let
pattern1
=
/^
\s
+/g
;
let
pattern2
=
/
\s
+$/g
;
let
tagText
=
this
.
data
.
tagText
this
.
data
.
tags
.
forEach
(
item
=>
{
this
.
data
.
tags
.
forEach
(
item
=>
{
if
(
item
.
checked
)
{
if
(
item
.
checked
)
{
arr
.
push
(
item
.
problem
)
arr
.
push
(
item
.
problem
)
}
}
})
})
if
(
arr
.
length
<=
0
){
if
(
arr
.
length
<=
0
){
wx
.
showToast
({
if
(
pattern1
.
test
(
tagText
))
{
title
:
'请至少选择一个解决办法!'
,
wx
.
showToast
({
icon
:
'none'
,
title
:
`文字前不能包含空格!`
,
duration
:
2000
icon
:
'none'
,
})
duration
:
2000
return
})
return
}
else
if
(
pattern2
.
test
(
tagText
))
{
wx
.
showToast
({
title
:
`文字后不能包含空格!`
,
icon
:
'none'
,
duration
:
2000
})
return
}
else
if
(
tagText
===
''
||
tagText
===
null
){
wx
.
showToast
({
title
:
`解决办法输入不能为空!`
,
icon
:
'none'
,
duration
:
2000
})
return
}
else
{
arr
.
push
(
tagText
)
}
}
else
{
if
(
tagText
!==
''
||
tagText
!==
null
){
arr
.
push
(
tagText
)
}
}
}
let
imgs
=
[]
this
.
data
.
originFiles
.
forEach
(
item
=>
{
this
.
data
.
originFiles
.
forEach
(
item
=>
{
imgs
.
push
(
item
.
img
)
imgs
.
push
(
item
.
img
)
})
})
arr
=
arr
.
filter
(
item
=>
item
!==
''
)
wx
.
request
({
wx
.
request
({
url
:
baseUrl
+
'/api/emaint/repairProblem/complete'
,
url
:
baseUrl
+
'/api/emaint/repairProblem/complete'
,
data
:
{
data
:
{
id
:
that
.
data
.
id
,
id
:
that
.
data
.
id
,
remark
:
that
.
data
.
formData
.
remarks
,
remark
:
that
.
data
.
formData
.
remarks
,
imgs
:
imgs
.
join
(
'|~|'
),
imgs
:
imgs
.
join
(
'|~|'
),
tags
:
arr
.
join
(
','
)
tags
:
arr
.
join
(
','
)
},
},
method
:
'POST'
,
// OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
method
:
'POST'
,
// OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
header
:
{
header
:
{
...
@@ -201,7 +241,8 @@ Page({
...
@@ -201,7 +241,8 @@ Page({
"accessToken"
:
wx
.
getStorageSync
(
'accessToken'
)
"accessToken"
:
wx
.
getStorageSync
(
'accessToken'
)
},
// 设置请求的 header
},
// 设置请求的 header
success
:
function
(
res
)
{
success
:
function
(
res
)
{
if
(
res
.
data
.
statusCode
===
200
){
if
(
res
.
data
.
statusCode
===
200
)
{
that
.
addTag
()
wx
.
showToast
({
wx
.
showToast
({
title
:
'提交成功!'
,
title
:
'提交成功!'
,
icon
:
'success'
,
icon
:
'success'
,
...
@@ -211,7 +252,8 @@ Page({
...
@@ -211,7 +252,8 @@ Page({
delta
:
1
delta
:
1
})
})
}
}
}})
}
})
},
},
/**
/**
* 生命周期函数--监听页面显示
* 生命周期函数--监听页面显示
...
...
pages/endRepair/repair.wxml
View file @
249a005f
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
</view>
</view>
<view class="add">
<view class="add">
<input placeholder="新增解决方案标签(不超过8个字)" bindinput="onInput" value="{{tagText}}" />
<input placeholder="新增解决方案标签(不超过8个字)" bindinput="onInput" value="{{tagText}}" />
<
button bindtap="addTag">新增标签</button
>
<
!-- <button bindtap="addTag">新增标签</button> --
>
</view>
</view>
</view>
</view>
<view class="uploader">
<view class="uploader">
...
...
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