Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mocp-uniapp
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
pangchong
mocp-uniapp
Commits
caf23611
Commit
caf23611
authored
May 22, 2024
by
pangchong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 提交
parent
93b00d6f
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
284 additions
and
120 deletions
+284
-120
src/api/appraisal-record.js
+9
-3
src/components/global-picker/dictData.js
+5
-0
src/components/global-picker/global-picker.vue
+88
-19
src/components/global-upload/global-upload.vue
+4
-7
src/main.js
+1
-17
src/pages/panel/appraisal-record/add.vue
+6
-6
src/pages/panel/appraisal-record/edit.vue
+105
-38
src/pages/panel/appraisal-record/list.vue
+5
-16
src/pages/panel/index.vue
+2
-2
src/store/appraisal-record.js
+28
-0
src/store/base.js
+8
-1
src/utils/http.js
+23
-11
No files found.
src/api/appraisal-record.js
View file @
caf23611
...
...
@@ -8,7 +8,6 @@ export const getRqmListApi = (data, config) => {
config
})
}
export
const
getRqmOptionsApi
=
(
data
,
config
)
=>
{
return
http
({
method
:
'POST'
,
...
...
@@ -16,4 +15,12 @@ export const getRqmOptionsApi = (data, config) => {
data
,
config
})
}
\ No newline at end of file
}
export
const
updateRqmDataApi
=
(
data
,
config
)
=>
{
return
http
({
method
:
'POST'
,
url
:
'/RepairControl/updateRqmData'
,
data
,
config
})
}
src/components/global-picker/dictData.js
View file @
caf23611
...
...
@@ -9,3 +9,8 @@ export const appealInfo = [
{
label
:
'申诉跟踪'
,
value
:
1
},
{
label
:
'申诉关闭'
,
value
:
2
}
]
export
const
eventType
=
[
{
label
:
'扣分'
,
value
:
0
},
{
label
:
'加分'
,
value
:
1
}
]
src/components/global-picker/global-picker.vue
View file @
caf23611
<
template
>
<picker
mode=
"selector"
:range=
"getRange"
@
change=
"onChange"
:disabled=
"disabled"
:value=
"getPickerValue"
>
<view
class=
"picker placeholder"
:class=
"
{ placeholder: !!getVal }" :style="getStyle">
<text>
{{
getVal
}}
</text>
<uni-icons
type=
"right"
size=
"18"
color=
"#86909C"
></uni-icons>
<picker
:mode=
"mode"
:range=
"getRange"
@
change=
"onChange"
:disabled=
"disabled"
:value=
"mode == 'selector' ? getPickerValue : getVal"
style=
"flex: auto"
>
<view
class=
"picker"
:class=
"
{ placeholder: !!getVal, disabled }" :style="getStyle">
<text
class=
"picker-value"
>
{{
getVal
}}
</text>
<view
class=
"picker-icon"
>
<view
class=
"picker-icon-close"
v-if=
"clearable && selectedValue"
@
tap
.
stop=
"clear"
>
<up-icon
name=
"close-circle-fill"
color=
"#c0c4cc"
size=
"36rpx"
></up-icon>
</view>
<up-icon
name=
"arrow-right"
color=
"#86909C"
size=
"36rpx"
></up-icon>
</view>
</view>
</picker>
</
template
>
<
script
setup
>
import
{
computed
,
onMounted
,
ref
}
from
'vue'
import
{
computed
,
onMounted
,
ref
,
watch
}
from
'vue'
import
*
as
dictData
from
'./dictData'
import
{
cloneDeep
}
from
'lodash'
import
Day
from
'@/utils/dayjs'
const
es
=
defineEmits
([
'update:modelValue'
,
'change'
])
const
ps
=
defineProps
({
// selector,date
mode
:
{
type
:
String
,
default
:
'selector'
},
dictkey
:
{
type
:
String
,
default
:
''
...
...
@@ -26,6 +44,10 @@ const ps = defineProps({
type
:
Array
,
default
:
()
=>
[]
},
clearable
:
{
type
:
Boolean
,
default
:
false
},
labelField
:
{
type
:
String
,
default
:
'label'
...
...
@@ -34,9 +56,9 @@ const ps = defineProps({
type
:
String
,
default
:
'value'
},
a
lign
:
{
pickA
lign
:
{
type
:
String
,
default
:
'
righ
t'
default
:
'
lef
t'
},
placeholder
:
{
type
:
String
,
...
...
@@ -48,30 +70,62 @@ const ps = defineProps({
}
})
const
getStyle
=
computed
(()
=>
{
let
pickAlign
=
'flex-start'
if
(
ps
.
pickAlign
==
'center'
)
{
pickAlign
=
'center'
}
else
if
(
ps
.
pickAlign
==
'right'
)
{
pickAlign
=
'flex-end'
}
return
{
textAlign
:
ps
.
a
lign
justifyContent
:
pickA
lign
}
})
const
selectedValue
=
ref
()
const
selectedValue
=
ref
(
''
)
watch
(
()
=>
ps
.
modelValue
,
(
value
)
=>
{
selectedValue
.
value
=
value
}
)
//获取options
const
getOptions
=
computed
(()
=>
{
if
(
ps
.
dictkey
)
{
return
cloneDeep
(
dictData
[
ps
.
dictkey
])
}
else
{
return
ps
.
options
if
(
ps
.
options
&&
Object
.
prototype
.
toString
.
call
(
ps
.
options
[
0
])
==
'[object object]'
)
{
return
ps
.
options
}
else
{
return
ps
.
options
.
map
((
item
)
=>
{
return
{
[
ps
.
labelField
]:
item
,
[
ps
.
valueField
]:
item
}
})
}
}
})
const
getRange
=
computed
(()
=>
{
return
getOptions
.
value
.
map
((
option
)
=>
option
[
ps
.
labelField
])
})
const
onChange
=
(
event
)
=>
{
const
index
=
event
.
detail
.
value
selectedValue
.
value
=
getOptions
.
value
[
index
][
ps
.
labelField
]
es
(
'update:modelValue'
,
getOptions
.
value
[
index
][
ps
.
valueField
])
es
(
'change'
,
getOptions
.
value
[
index
][
ps
.
valueField
])
if
(
ps
.
mode
==
'selector'
)
{
const
index
=
event
.
detail
.
value
selectedValue
.
value
=
getOptions
.
value
[
index
][
ps
.
labelField
]
es
(
'update:modelValue'
,
getOptions
.
value
[
index
][
ps
.
valueField
])
es
(
'change'
,
getOptions
.
value
[
index
][
ps
.
valueField
])
}
else
{
selectedValue
.
value
=
event
.
detail
.
value
es
(
'update:modelValue'
,
Day
(
selectedValue
.
value
).
valueOf
())
es
(
'change'
,
Day
(
selectedValue
.
value
).
valueOf
())
}
}
const
getVal
=
computed
(()
=>
{
return
selectedValue
.
value
||
ps
.
placeholder
if
(
ps
.
mode
==
'selector'
)
{
return
selectedValue
.
value
||
ps
.
placeholder
}
else
{
//日期
return
uni
.
$tool
.
timeStampFormat
(
selectedValue
.
value
,
{
format
:
'YYYY-MM-DD'
})
||
ps
.
placeholder
}
})
//获取初始值
const
init
=
()
=>
{
...
...
@@ -84,19 +138,34 @@ const getPickerValue = computed(() => {
const
index
=
getOptions
.
value
.
findIndex
((
option
)
=>
String
(
option
[
ps
.
valueField
])
===
String
(
ps
.
modelValue
))
return
index
>
0
?
index
:
0
})
//清空值
const
clear
=
()
=>
{
selectedValue
.
value
=
''
}
onMounted
(()
=>
{
init
()
})
</
script
>
<
style
lang=
"scss"
scoped
>
.picker
{
line-height
:
40
rpx
;
line-height
:
48
rpx
;
display
:
flex
;
align-items
:
center
;
&-value
{
color
:
#1d2129
;
}
&
.placeholder
{
color
:
#86909c
;
}
uni-icons
{
position
:
relative
;
top
:
4
rpx
;
&
.disabled
{
background
:
#f5f7fa
;
}
&
-icon
{
display
:
flex
;
align-items
:
center
;
&-close
{
margin-left
:
4
rpx
;
}
}
}
</
style
>
src/components/global-upload/global-upload.vue
View file @
caf23611
...
...
@@ -28,11 +28,11 @@ const ps = defineProps({
},
width
:
{
type
:
[
String
,
Number
],
default
:
155
default
:
80
},
height
:
{
type
:
[
String
,
Number
],
default
:
155
default
:
80
},
url
:
{
type
:
String
,
...
...
@@ -41,8 +41,8 @@ const ps = defineProps({
})
const
getUploadButtonSize
=
computed
(()
=>
{
return
{
width
:
ps
.
width
+
'
r
px'
,
height
:
ps
.
height
+
'
r
px'
width
:
ps
.
width
+
'px'
,
height
:
ps
.
height
+
'px'
}
})
...
...
@@ -81,9 +81,6 @@ const uploadFilePromise = (url) => {
url
:
ps
.
url
,
filePath
:
url
,
name
:
'file'
,
formData
:
{
user
:
'test'
},
success
:
(
res
)
=>
{
setTimeout
(()
=>
{
resolve
(
res
.
data
.
data
)
...
...
src/main.js
View file @
caf23611
import
{
createSSRApp
}
from
'vue'
import
App
from
'./App.vue'
import
pinia
from
'./store'
import
uviewPlus
,
{
setConfig
}
from
'uview-plus'
import
uviewPlus
from
'uview-plus'
import
*
as
message
from
'@/utils/message'
import
*
as
tool
from
'@/utils/tool'
// 引入字体
...
...
@@ -14,22 +14,6 @@ export function createApp() {
const
app
=
createSSRApp
(
App
)
app
.
use
(
pinia
)
app
.
use
(
uviewPlus
)
setConfig
({
// 修改$u.config对象的属性
config
:
{
// 修改默认单位为rpx,相当于执行 uni.$u.config.unit = 'rpx'
unit
:
'rpx'
},
// 修改$u.props对象的属性
props
:
{
// 修改radio组件的size参数的默认值,相当于执行 uni.$u.props.radio.size = 30
radio
:
{
size
:
15
}
// 其他组件属性配置
// ......
}
})
return
{
app
}
...
...
src/pages/panel/appraisal-record/add.vue
View file @
caf23611
...
...
@@ -2,14 +2,14 @@
<global-page
title=
"添加公司值班信息"
showEdit
@
handleCancel=
"handleCancel"
@
handleSave=
"handleSave"
>
<view
class=
"form"
>
<up-form
labelPosition=
"left"
labelWidth=
"auto"
>
<up-form-item
label=
"公司值班经理"
borderBottom
>
<global-picker
aligh=
"right"
></global-picker>
<up-form-item
label=
"公司值班经理"
:borderBottom=
"true"
>
<global-picker
pickAlign=
"right"
clearable
></global-picker>
</up-form-item>
<up-form-item
label=
"公司值班经理意见"
borderBottom
>
<global-picker
aligh=
"right"
></global-picker>
<up-form-item
label=
"公司值班经理意见"
:borderBottom=
"true"
>
<global-picker
pickAlign=
"right"
clearable
></global-picker>
</up-form-item>
<up-form-item
label=
"公司值班经理意见描述"
borderBottom
labelPosition=
"top"
>
<up-textarea
placeholder=
"一段很长很长的内容文字,长文本自动换行,该选项的描述是一段很长的内容"
></up-textarea>
<up-form-item
label=
"公司值班经理意见描述"
:borderBottom=
"true"
labelPosition=
"top"
>
<up-textarea
placeholder=
"一段很长很长的内容文字,长文本自动换行,该选项的描述是一段很长的内容"
autoHeight
></up-textarea>
</up-form-item>
</up-form>
</view>
...
...
src/pages/panel/appraisal-record/edit.vue
View file @
caf23611
...
...
@@ -2,45 +2,53 @@
<global-page
title=
"考核记录登记"
>
<view
class=
"content"
>
<view
class=
"form"
>
<up-form
labelPosition=
"left"
labelWidth=
"auto"
>
<up-form-item
label=
"事件来源"
borderBottom
>
<up-input
border=
"none"
inputAlign=
"right"
placeholder=
"请输入"
></up-input>
<up-form
labelPosition=
"left"
labelWidth=
"auto"
:model=
"formData"
ref=
"formRef"
:rules=
"rules"
>
<up-form-item
label=
"事件来源"
:borderBottom=
"true"
>
<up-input
border=
"none"
inputAlign=
"right"
placeholder=
"请输入"
clearable
v-model=
"formData.eventSource"
></up-input>
</up-form-item>
<up-form-item
label=
"基地/职能部门"
borderBottom
>
<global-picker
aligh=
"righ
t"
></global-picker>
<up-form-item
label=
"基地/职能部门"
:borderBottom=
"true"
>
<global-picker
pickAlign=
"right"
clearable
v-model=
"formData.department"
:options=
"departmen
t"
></global-picker>
</up-form-item>
<up-form-item
label=
"考核对象"
borderBottom
>
<global-picker
aligh=
"right
"
></global-picker>
<up-form-item
label=
"考核对象"
:borderBottom=
"true"
>
<global-picker
pickAlign=
"right"
clearable
v-model=
"formData.appraisee"
:options=
"appraisee
"
></global-picker>
</up-form-item>
<up-form-item
label=
"机号"
borderBottom
>
<global-picker
aligh=
"right
"
></global-picker>
<up-form-item
label=
"机号"
:borderBottom=
"true"
>
<global-picker
pickAlign=
"right"
clearable
:options=
"deviceNumSelect"
v-model=
"formData.ac
"
></global-picker>
</up-form-item>
<up-form-item
label=
"客户"
borderBottom
>
<global-picker
aligh=
"right"
></global-picker>
<up-form-item
label=
"客户"
:borderBottom=
"true"
>
<global-picker
pickAlign=
"right"
clearable
v-model=
"formData.acOwn"
disabled
></global-picker>
</up-form-item>
<up-form-item
label=
"机型"
borderBottom
>
<global-picker
aligh=
"right"
></global-picker>
<up-form-item
label=
"机型"
:borderBottom=
"true"
>
<global-picker
pickAlign=
"right"
clearable
v-model=
"formData.acType"
disabled
></global-picker>
</up-form-item>
<up-form-item
label=
"日期"
borderBottom
>
<global-picker
aligh=
"right
"
></global-picker>
<up-form-item
label=
"日期"
:borderBottom=
"true"
required
prop=
"eventTime"
>
<global-picker
pickAlign=
"right"
clearable
v-model=
"formData.eventTime"
mode=
"date
"
></global-picker>
</up-form-item>
<up-form-item
label=
"事件描述"
borderBottom
labelPosition=
"top"
>
<up-textarea
placeholder=
"一段很长很长的内容文字,长文本自动换行,该选项的描述是一段很长的内容"
></up-textarea>
<up-form-item
label=
"事件描述"
:borderBottom=
"true"
labelPosition=
"top"
>
<up-textarea
placeholder=
"一段很长很长的内容文字,长文本自动换行,该选项的描述是一段很长的内容"
v-model=
"formData.eventMsg"
:height=
"70"
></up-textarea>
</up-form-item>
<up-form-item
label=
"事件类别"
borderBottom
>
<global-picker
aligh=
"right
"
></global-picker>
<up-form-item
label=
"事件类别"
:borderBottom=
"true"
>
<global-picker
pickAlign=
"right"
clearable
v-model=
"formData.eventType"
dictkey=
"eventType
"
></global-picker>
</up-form-item>
<up-form-item
label=
"考核类型"
borderBottom
>
<global-picker
aligh=
"right
"
></global-picker>
<up-form-item
label=
"考核类型"
:borderBottom=
"true"
>
<global-picker
pickAlign=
"right"
clearable
v-model=
"formData.examineType"
:options=
"examineType
"
></global-picker>
</up-form-item>
<up-form-item
label=
"考核依据"
borderBottom
labelPosition=
"top"
>
<up-textarea
placeholder=
"一段很长很长的内容文字,长文本自动换行,该选项的描述是一段很长的内容"
></up-textarea>
<up-form-item
label=
"考核依据"
:borderBottom=
"true"
labelPosition=
"top"
>
<up-textarea
placeholder=
"一段很长很长的内容文字,长文本自动换行,该选项的描述是一段很长的内容"
v-model=
"formData.examineBasis"
:height=
"70"
></up-textarea>
</up-form-item>
<up-form-item
label=
"分值"
borderBottom
>
<up-input
border=
"none"
inputAlign=
"right"
placeholder=
"请输入"
></up-input>
<up-form-item
label=
"分值"
:borderBottom=
"true"
>
<up-input
border=
"none"
inputAlign=
"right"
placeholder=
"请输入"
v-model
.
number=
"formData.score"
type=
"number"
></up-input>
</up-form-item>
<up-form-item
label=
"当班人员"
borderBottom
>
<up-input
border=
"none"
inputAlign=
"right"
placeholder=
"请输入"
></up-input>
<up-form-item
label=
"当班人员"
:borderBottom=
"true"
>
<up-input
border=
"none"
inputAlign=
"right"
placeholder=
"请输入"
v-model=
"formData.onDutyUser"
></up-input>
</up-form-item>
</up-form>
</view>
...
...
@@ -79,39 +87,98 @@
<view
class=
"appeal"
>
<view
class=
"appeal-title"
>
<text>
申诉情况
</text>
<global-picker></global-picker>
</view>
<view
class=
"appeal-content"
>
<global-upload
v-model=
"fileList"
></global-upload>
<global-picker
pickAlign=
"right"
dictkey=
"appealInfo"
clearable
></global-picker>
</view>
<!--
<view
class=
"appeal-content"
>
<global-upload
v-model=
"formData.file"
url=
"/resource/uploadFile"
></global-upload>
</view>
-->
</view>
</view>
<template
#
bottom
>
<view
class=
"submit-btn"
>
<global-button
type=
"primary"
size=
"large"
>
保存
</global-button>
<global-button
type=
"primary"
size=
"large"
@
tap=
"handleSubmit"
>
保存
</global-button>
</view>
</
template
>
</global-page>
</template>
<
script
setup
>
import
{
ref
}
from
'vue'
import
{
re
active
,
re
f
}
from
'vue'
import
CardDetails
from
'./components/card-details.vue'
import
CardDetailsItem
from
'./components/card-details-item.vue'
import
{
onLoad
}
from
'@dcloudio/uni-app'
import
{
showData
}
from
'@/utils/tool'
import
useBaseStore
from
'@/store/base'
import
{
useGetDictByValue
}
from
'@/components/global-picker/useDict'
import
useAppraisalRecordStore
from
'@/store/appraisal-record'
import
{
updateRqmDataApi
}
from
'@/api/appraisal-record'
// 校验规则
const
rules
=
{
eventTime
:
[
{
required
:
true
,
message
:
'请选择日期'
,
trigger
:
[
'blur'
,
'change'
]
}
]
}
//获取下拉框选项
const
{
selectList
:
{
deviceNumSelect
}
}
=
useBaseStore
()
const
{
selectList
:
{
appraisee
,
department
,
examineType
}
}
=
useAppraisalRecordStore
()
// 表单数据
const
formData
=
reactive
({
id
:
''
,
ac
:
''
,
acOwn
:
''
,
acType
:
''
,
appealInfo
:
''
,
appraisee
:
''
,
department
:
''
,
dmUid
:
''
,
eventMsg
:
''
,
eventSource
:
''
,
eventTime
:
''
,
eventType
:
''
,
examineBasis
:
''
,
examineType
:
''
,
onDutyUser
:
''
,
opinionMsg
:
''
,
opinionType
:
''
,
score
:
null
,
qmUid
:
''
,
qualityOpinionMsg
:
''
,
qualityOpinionType
:
''
,
status
:
''
,
file
:
[],
emailSendTime
:
''
})
//提交表单
const
formRef
=
ref
()
const
handleSubmit
=
async
()
=>
{
await
formRef
.
value
?.
validate
()
const
res
=
await
updateRqmDataApi
(
formData
,
{
loading
:
true
})
if
(
res
.
code
==
200
)
{
}
else
{
uni
.
$message
.
showToast
(
res
.
message
)
}
}
// 添加
const
handleAdd
=
()
=>
{
uni
.
navigateTo
({
url
:
'add'
})
}
//获取页面内容
const
details
=
ref
()
onLoad
(()
=>
{
uni
.
$once
(
'appraisalRecordEdit'
,
(
data
)
=>
{
details
.
value
=
data
Object
.
assign
(
formData
,
data
)
})
})
const
fileList
=
ref
([])
// 添加
const
handleAdd
=
()
=>
{
uni
.
navigateTo
({
url
:
'add'
})
}
</
script
>
<
style
lang=
"scss"
scoped
>
.content
{
...
...
src/pages/panel/appraisal-record/list.vue
View file @
caf23611
...
...
@@ -22,9 +22,10 @@
<
script
setup
>
import
{
ref
}
from
'vue'
import
{
getRqmListApi
,
getRqmOptionsApi
}
from
'@/api/appraisal-record'
import
{
getRqmListApi
}
from
'@/api/appraisal-record'
import
{
onLoad
}
from
'@dcloudio/uni-app'
import
{
showData
}
from
'@/utils/tool'
import
useAppraisalRecordStore
from
'@/store/appraisal-record'
const
tabList
=
ref
([
{
name
:
'OPEN'
,
value
:
1
},
...
...
@@ -40,22 +41,10 @@ const goDetails = (data) => {
}
})
}
//获取选项数据
const
appraisee
=
ref
([])
const
department
=
ref
([])
const
examineType
=
ref
([])
const
getRqmOptions
=
async
()
=>
{
const
res
=
await
getRqmOptionsApi
()
if
(
res
.
code
==
200
)
{
appraisee
.
value
=
res
.
data
.
appraisee
||
[]
department
.
value
=
res
.
data
.
department
||
[]
examineType
.
value
=
res
.
data
.
examineType
||
[]
}
else
{
uni
.
$message
.
showToast
(
res
.
message
)
}
}
//加载下拉框数据
const
appraisalRecordStore
=
useAppraisalRecordStore
()
onLoad
(()
=>
{
getRqmOptions
()
appraisalRecordStore
.
getRqmOptions
()
})
</
script
>
<
style
lang=
"scss"
scoped
>
...
...
src/pages/panel/index.vue
View file @
caf23611
...
...
@@ -15,8 +15,8 @@ import PanelNavbar from './panel-navbar.vue'
import
PanelMenu
from
'./panel-menu.vue'
import
useBaseStore
from
'@/store/base'
const
userBas
e
=
useBaseStore
()
userBas
e
.
getAircraftNumbers
()
const
baseStor
e
=
useBaseStore
()
baseStor
e
.
getAircraftNumbers
()
</
script
>
<
style
lang=
"scss"
scoped
>
.page-bg
{
...
...
src/store/appraisal-record.js
0 → 100644
View file @
caf23611
import
{
getRqmOptionsApi
}
from
'@/api/appraisal-record'
import
{
defineStore
}
from
'pinia'
const
useAppraisalRecordStore
=
defineStore
(
'appraisalRecord'
,
{
state
:
()
=>
{
return
{
selectList
:
{
appraisee
:
[],
department
:
[],
examineType
:
[]
}
}
},
getters
:
{},
actions
:
{
async
getRqmOptions
()
{
const
res
=
await
getRqmOptionsApi
({})
if
(
res
.
code
==
200
)
{
this
.
selectList
.
appraisee
=
res
.
data
.
appraisee
||
[]
this
.
selectList
.
department
=
res
.
data
.
department
||
[]
this
.
selectList
.
examineType
=
res
.
data
.
examineType
||
[]
}
}
},
// 配置持久化
persist
:
false
})
export
default
useAppraisalRecordStore
src/store/base.js
View file @
caf23611
...
...
@@ -3,12 +3,19 @@ import { defineStore } from 'pinia'
const
useBaseStore
=
defineStore
(
'base'
,
{
state
:
()
=>
{
return
{}
return
{
selectList
:
{
deviceNumSelect
:
[]
//机号
}
}
},
getters
:
{},
actions
:
{
async
getAircraftNumbers
()
{
const
res
=
await
getAircraftNumbersApi
({})
if
(
res
.
code
==
200
)
{
this
.
selectList
.
deviceNumSelect
=
res
.
data
}
}
},
// 配置持久化
...
...
src/utils/http.js
View file @
caf23611
...
...
@@ -31,13 +31,13 @@ class ServiceLoading {
uni
.
showLoading
({
title
:
loadingText
,
mask
:
true
})
;
})
}
}
close
()
{
this
.
count
--
if
(
this
.
count
<=
0
)
{
uni
.
hideLoading
()
;
uni
.
hideLoading
()
}
}
}
...
...
@@ -47,6 +47,7 @@ const serviceLoading = new ServiceLoading()
const
httpInterceptor
=
{
// 拦截前触发
invoke
(
options
)
{
const
userStore
=
useUserStore
()
//responseType
if
(
options
.
config
?.
arraybuffer
)
{
options
.
responseType
=
'arraybuffer'
...
...
@@ -60,7 +61,7 @@ const httpInterceptor = {
...
options
.
data
,
apiPwd
:
'Ifar$2_0160_525_Mocp'
,
requestFrom
:
'3'
,
realUserId
:
'21'
realUserId
:
userStore
.
userInfo
?.
id
}
}
// 非 http 开头需拼接地址
...
...
@@ -70,16 +71,28 @@ const httpInterceptor = {
// 请求超时, 默认 60s
options
.
timeout
=
10000
// 添加小程序端请求头标识
options
.
header
=
{
'Content-Type'
:
'application/x-www-form-urlencoded'
,
...
options
.
header
,
if
(
options
.
name
==
'file'
)
{
options
.
formData
=
{
...
options
.
formData
,
apiPwd
:
'Ifar$2_0160_525_Mocp'
,
requestFrom
:
'6'
,
uid
:
userStore
.
userInfo
?.
id
}
options
.
header
=
{
'Content-Type'
:
'multipart/form-data'
,
...
options
.
header
}
}
else
{
options
.
header
=
{
'Content-Type'
:
'application/x-www-form-urlencoded'
,
...
options
.
header
}
}
// 添加 token 请求头标识
const
userStore
=
useUserStore
()
if
(
userStore
.
token
)
{
options
.
header
.
Authorization
=
`Bearer
${
userStore
.
token
}
`
}
}
,
}
}
uni
.
addInterceptor
(
'request'
,
httpInterceptor
)
uni
.
addInterceptor
(
'uploadFile'
,
httpInterceptor
)
...
...
@@ -125,7 +138,7 @@ export const http = (options) => {
serviceLoading
.
close
()
uni
.
$message
.
showToast
(
'网络错误,换个网络试试'
)
reject
(
err
)
}
,
}
})
})
}
\ 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