Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
basic-uniapp-v3
概览
概览
详情
活动
周期分析
版本库
存储库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
1
合并请求
1
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
Basic
basic-uniapp-v3
Commits
a978aa7d
提交
a978aa7d
authored
12月 08, 2025
作者:
方治民
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'dev' of
https://gitlab.yiring.com/digital-agri/agri-app
into dev
上级
27d7302e
9c9e2ff0
全部展开
显示空白字符变更
内嵌
并排
正在显示
8 个修改的文件
包含
232 行增加
和
99 行删除
+232
-99
nongchang.ts
src/api/model/nongchang.ts
+4
-0
pages.json
src/pages.json
+2
-15
save-dialog.vue
src/pages/device/components/save-dialog.vue
+77
-79
device.vue
src/pages/device/device.vue
+0
-0
login.vue
src/pages/login/login.vue
+1
-0
index.vue
src/pages/nongchang/detail/index.vue
+17
-3
formDataRequest.ts
src/utils/http/formDataRequest.ts
+129
-0
proxy.ts
src/utils/proxy.ts
+2
-2
没有找到文件。
src/api/model/nongchang.ts
浏览文件 @
a978aa7d
import
{
otherHttp
}
from
'/@/utils/http/axios'
import
{
postFormData
}
from
'/@/utils/http/formDataRequest'
enum
Api
{
zoneList
=
'/online/cgform/api/getData/01fd687ecb164aea914e92047e144d66'
,
// 功能菜单数据
...
...
@@ -9,6 +10,9 @@ enum Api {
commonToolsList
=
'/online/cgform/api/getData/3a7fbb877f304b7d83935caa454859c4'
,
// 常用工具数据
getFarmBaseList
=
'/farmbase/getFarmBaseList'
,
}
export
function
queryByType
(
data
=
{})
{
return
postFormData
(
'/device/queryByType'
,
data
).
then
((
res
)
=>
res
.
data
)
}
/**
* 删除设备
* @param id
...
...
src/pages.json
浏览文件 @
a978aa7d
...
...
@@ -546,24 +546,11 @@
{
"path"
:
"pages/device/device"
,
"style"
:
{
"navigationBarTitleText"
:
"
物联
设备"
,
"navigationBarTitleText"
:
"
基地
设备"
,
"enablePullDownRefresh"
:
false
,
"navigationBarBackgroundColor"
:
"#5DB66F"
,
"navigationBarTextStyle"
:
"white"
,
"backgroundColorBottom"
:
"#F2F2F2"
,
"app-plus"
:
{
"titleNView"
:
{
"buttons"
:
[
{
"text"
:
"+ 添加设备"
,
"fontSrc"
:
"/static/uni.ttf"
,
"color"
:
"#fff"
,
"fontSize"
:
"26rpx"
,
"width"
:
"auto"
}
]
}
}
"backgroundColorBottom"
:
"#F2F2F2"
}
},
{
...
...
src/pages/device/components/save-dialog.vue
浏览文件 @
a978aa7d
<
script
setup
lang=
"ts"
>
import
{
computed
,
reactive
,
ref
,
watch
}
from
'vue'
import
{
useDictStore
}
from
'@/store/modules/dict'
import
*
as
NongchangAPI
from
'@/api/model/nongchang'
import
{
computed
,
reactive
,
ref
,
watch
}
from
'vue'
import
{
useDictStore
}
from
'@/store/modules/dict'
import
*
as
NongchangAPI
from
'@/api/model/nongchang'
// 定义Props
interface
Props
{
// 定义Props
interface
Props
{
show
:
boolean
editData
?:
any
farmId
:
any
,
farmBaseId
:
any
,
}
farmId
:
any
farmBaseId
:
any
}
const
props
=
withDefaults
(
defineProps
<
Props
>
(),
{
const
props
=
withDefaults
(
defineProps
<
Props
>
(),
{
show
:
false
,
editData
:
null
,
farmId
:
0
,
farmBaseId
:
0
,
})
farmId
:
0
,
farmBaseId
:
0
,
})
// 定义Emits
const
emit
=
defineEmits
<
{
// 定义Emits
const
emit
=
defineEmits
<
{
'update:show'
:
[
value
:
boolean
]
submit
:
[
data
:
any
]
close
:
[]
}
>
()
}
>
()
// 表单引用
const
formRef
=
ref
()
const
loading
=
ref
(
false
)
const
showDeviceTypePicker
=
ref
(
false
)
// 表单引用
const
formRef
=
ref
()
const
loading
=
ref
(
false
)
const
showDeviceTypePicker
=
ref
(
false
)
// 字典存储
const
dictStore
=
useDictStore
()
// 字典存储
const
dictStore
=
useDictStore
()
// 表单数据
const
formData
=
reactive
({
// 表单数据
const
formData
=
reactive
({
deviceName
:
''
,
deviceType
:
''
,
deviceTypeText
:
''
,
deviceIdentifier
:
''
,
})
})
// 设备类型选项 - 使用字典数据
const
deviceTypeOptions
=
computed
(()
=>
{
// 设备类型选项 - 使用字典数据
const
deviceTypeOptions
=
computed
(()
=>
{
return
(
dictStore
.
getDictList
.
deviceType
?.
map
((
item
:
any
)
=>
({
value
:
item
.
value
,
text
:
item
.
text
,
}))
||
[]
)
})
})
// 设备类型选择器数据 (不再需要,因为fui-picker使用options属性)
// 设备类型选择器数据 (不再需要,因为fui-picker使用options属性)
// 计算属性
const
dialogTitle
=
computed
(()
=>
{
// 计算属性
const
dialogTitle
=
computed
(()
=>
{
return
props
.
editData
?
'编辑设备'
:
'添加设备'
})
})
const
submitButtonText
=
computed
(()
=>
{
const
submitButtonText
=
computed
(()
=>
{
return
props
.
editData
?
'保存'
:
'确认'
})
})
// 表单验证规则
const
rules
=
{
// 表单验证规则
const
rules
=
{
deviceName
:
[
{
required
:
true
,
message
:
'请输入设备名称'
,
trigger
:
'blur'
},
{
min
:
2
,
max
:
50
,
message
:
'设备名称长度在2-50个字符之间'
,
trigger
:
'blur'
},
...
...
@@ -84,10 +83,10 @@
trigger
:
'blur'
,
},
],
}
}
// 监听显示状态
watch
(
// 监听显示状态
watch
(
()
=>
props
.
show
,
(
newVal
)
=>
{
if
(
newVal
&&
props
.
editData
)
{
...
...
@@ -99,10 +98,10 @@
resetFormData
()
}
},
)
)
// 重置表单数据
function
resetFormData
()
{
// 重置表单数据
function
resetFormData
()
{
formData
.
deviceName
=
''
formData
.
deviceType
=
''
formData
.
deviceTypeText
=
''
...
...
@@ -112,12 +111,11 @@
if
(
formRef
.
value
)
{
formRef
.
value
.
resetFields
()
}
}
}
// 加载编辑数据
function
loadEditData
()
{
if
(
!
props
.
editData
)
return
// 加载编辑数据
function
loadEditData
()
{
if
(
!
props
.
editData
)
return
formData
.
deviceName
=
props
.
editData
.
deviceName
||
''
formData
.
deviceType
=
props
.
editData
.
deviceType
||
''
...
...
@@ -135,17 +133,17 @@ return
}
else
{
formData
.
deviceTypeText
=
''
}
}
}
// 设备类型选择确认
function
handleDeviceTypeConfirm
(
e
:
any
)
{
// 设备类型选择确认
function
handleDeviceTypeConfirm
(
e
:
any
)
{
formData
.
deviceType
=
e
.
value
formData
.
deviceTypeText
=
e
.
text
showDeviceTypePicker
.
value
=
false
}
}
// 提交表单
async
function
handleSubmit
()
{
// 提交表单
async
function
handleSubmit
()
{
try
{
console
.
log
(
formData
)
// 先进行表单验证
...
...
@@ -192,21 +190,21 @@ return
}
finally
{
loading
.
value
=
false
}
}
}
// 关闭弹窗
function
handleClose
()
{
// 关闭弹窗
function
handleClose
()
{
emit
(
'update:show'
,
false
)
emit
(
'close'
)
}
}
// 暴露方法给父组件
defineExpose
({
// 暴露方法给父组件
defineExpose
({
resetFormData
,
setLoading
:
(
value
:
boolean
)
=>
{
loading
.
value
=
value
},
})
})
</
script
>
<
template
>
...
...
@@ -271,23 +269,23 @@ return
</
template
>
<
style
lang=
"scss"
scoped
>
.dialog-content
{
.dialog-content
{
padding
:
10
rpx
30
rpx
;
width
:
90%
;
max-height
:
80vh
;
overflow-y
:
auto
;
}
}
.section-title
{
.section-title
{
font-size
:
32
rpx
;
font-weight
:
600
;
color
:
#333
;
margin
:
20
rpx
0
30
rpx
0
;
padding-left
:
20
rpx
;
border-left
:
6
rpx
solid
#5db66f
;
}
}
.dialog-buttons
{
.dialog-buttons
{
display
:
flex
;
gap
:
20
rpx
;
margin-top
:
40
rpx
;
...
...
@@ -310,10 +308,10 @@ return
border
:
2
rpx
solid
#dcdfe6
;
}
}
}
}
//
uview-plus
表单样式调整
::v-deep
.u-form-item
{
//
uview-plus
表单样式调整
::v-deep
.u-form-item
{
margin-bottom
:
40
rpx
;
.u-form-item__body
{
...
...
@@ -336,8 +334,8 @@ return
flex
:
1
;
min-width
:
0
;
}
}
.address-display
{
}
.address-display
{
display
:
flex
;
justify-content
:
space-between
;
align-items
:
center
;
...
...
@@ -357,15 +355,15 @@ return
.placeholder-text
{
color
:
#c0c4cc
;
}
}
}
::v-deep
.u-form-item__body__left__content__required
{
::v-deep
.u-form-item__body__left__content__required
{
position
:
static
;
padding-right
:
10
rpx
;
}
}
//
输入框样式优化
::v-deep
.u-input
{
//
输入框样式优化
::v-deep
.u-input
{
.u-input__content
{
padding
:
0
;
...
...
@@ -390,10 +388,10 @@ return
}
}
}
}
}
//
模态框样式调整
::v-deep
.u-modal
{
//
模态框样式调整
::v-deep
.u-modal
{
.u-modal__content
{
border-radius
:
20
rpx
;
padding
:
20
rpx
0
rpx
;
...
...
@@ -409,5 +407,5 @@ return
color
:
#333
;
}
}
}
}
</
style
>
src/pages/device/device.vue
浏览文件 @
a978aa7d
差异被折叠。
点击展开。
src/pages/login/login.vue
浏览文件 @
a978aa7d
...
...
@@ -286,6 +286,7 @@
:required=
"false"
clearable
trim
type=
"number"
placeholder=
"请输入手机号"
v-model=
"model.form.data.username"
name=
"mobile"
...
...
src/pages/nongchang/detail/index.vue
浏览文件 @
a978aa7d
...
...
@@ -15,6 +15,7 @@ import type { ToolBoxButtonHandleEvent } from '@/components/Map/Widgets/ToolBox'
import
{
ToolBoxWidget
,
useToolBoxWidget
}
from
'@/components/Map/Widgets/ToolBox'
import
*
as
NongchangAPI
from
'@/api/model/nongchang'
import
*
as
farmbaseApi
from
'@/api/model/farmbase'
import
navigate
from
'@/utils/page/navigate'
// 页面参数
const
page
=
reactive
<
Page
>
({
...
...
@@ -343,6 +344,9 @@ onNavigationBarButtonTap((e) => {
Navigate
.
to
(
`/pages/jidiguanli/add?farmId=
${
model
.
id
}
`
)
}
})
const
toDevice
=
(
device
)
=>
{
Navigate
.
to
(
`/pages/device/device?deviceType=
${
device
.
deviceType
}
&farmBaseId=`
+
model
.
farmbaseInfo
?.
id
)
}
</
script
>
<
template
>
...
...
@@ -485,16 +489,20 @@ onNavigationBarButtonTap((e) => {
<view
class=
"box-4"
>
<view
class=
"box-4-title"
>
<view
class=
"box-4-title-text1"
><text>
基地设备
</text></view>
<view
class=
"box-4-title-text2"
@
click=
"showDialog
=
true"
><text>
+ 添加设备
</text></view>
<view
class=
"box-4-title-text2"
@
click=
"showDialog
=
true"
><text>
+ 添加设备
</text></view>
</view>
<view
class=
"box-4-device"
>
<view
class=
"box-4-device-item"
v-for=
"(device, index) in model.deviceTypeCount"
:key=
"index"
@
click=
"toDevice(device)"
>
<view
class=
"box-4-item-icon"
>
<image
class=
"box-4-item-icon-image"
:src=
"`/static/images/nongchang/device$
{device.deviceType}.png`" />
<image
class=
"box-4-item-icon-image"
:src=
"`/static/images/nongchang/device$
{device.deviceType}.png`"
/>
</view>
<view
class=
"box-4-item-content"
>
<text
class=
"box-4-item-text1"
>
{{
device
.
deviceName
}}
</text>
...
...
@@ -506,7 +514,13 @@ onNavigationBarButtonTap((e) => {
</view>
</view>
</view>
<SaveDialog
:show=
"showDialog"
:farmId=
"model.id"
:farmBaseId=
"model.farmbaseInfo?.id"
@
submitSuccess=
"getDeviceTypeCount"
@
close=
"showDialog=false"
/>
<SaveDialog
:show=
"showDialog"
:farmId=
"model.id"
:farmBaseId=
"model.farmbaseInfo?.id"
@
submitSuccess=
"getDeviceTypeCount"
@
close=
"showDialog = false"
/>
</view>
</
template
>
...
...
src/utils/http/formDataRequest.ts
0 → 100644
浏览文件 @
a978aa7d
/**
* uni-app formdata 请求封装
* 使用 uni.request 模拟 formdata 提交
*/
import
{
useGlobSetting
}
from
'/@/hooks/setting'
import
{
useUserStoreWithOut
}
from
'@/store/modules/user'
interface
FormDataRequestOptions
{
url
:
string
data
?:
Record
<
string
,
any
>
method
?:
'GET'
|
'POST'
|
'PUT'
|
'DELETE'
header
?:
Record
<
string
,
any
>
timeout
?:
number
}
interface
FormDataResponse
<
T
=
any
>
{
data
:
T
statusCode
:
number
header
:
Record
<
string
,
any
>
errMsg
:
string
}
/**
* formdata 格式请求
* @param options 请求配置
* @returns Promise
*/
export
function
formDataRequest
<
T
=
any
>
(
options
:
FormDataRequestOptions
):
Promise
<
FormDataResponse
<
T
>>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
const
{
url
,
data
=
{},
method
=
'POST'
,
header
=
{},
timeout
=
60000
}
=
options
// 获取全局配置
const
globSetting
=
useGlobSetting
()
const
urlPrefix
=
globSetting
.
urlPrefix
const
apiUrl
=
globSetting
.
apiUrl
// 获取 token
const
userStore
=
useUserStoreWithOut
()
const
token
=
userStore
.
getToken
// 拼接完整 URL
const
fullUrl
=
`
${
apiUrl
}${
urlPrefix
}${
url
}
`
// 将数据转换为 formdata 格式字符串
const
formDataStr
=
Object
.
keys
(
data
)
.
map
((
key
)
=>
{
const
value
=
data
[
key
]
if
(
value
===
null
||
value
===
undefined
)
{
return
''
}
if
(
Array
.
isArray
(
value
))
{
// 处理数组
return
value
.
map
((
item
)
=>
`
${
encodeURIComponent
(
key
)}
=
${
encodeURIComponent
(
item
)}
`
).
join
(
'&'
)
}
return
`
${
encodeURIComponent
(
key
)}
=
${
encodeURIComponent
(
value
)}
`
})
.
filter
((
item
)
=>
item
!==
''
)
.
join
(
'&'
)
uni
.
request
({
url
:
fullUrl
,
method
,
data
:
formDataStr
,
header
:
{
'Content-Type'
:
'application/x-www-form-urlencoded'
,
'X-Access-Token'
:
token
,
...
header
,
},
timeout
,
success
:
(
res
:
any
)
=>
{
resolve
({
data
:
res
.
data
,
statusCode
:
res
.
statusCode
,
header
:
res
.
header
,
errMsg
:
res
.
errMsg
,
})
},
fail
:
(
err
:
any
)
=>
{
reject
({
data
:
null
,
statusCode
:
err
.
statusCode
||
0
,
header
:
err
.
header
||
{},
errMsg
:
err
.
errMsg
||
'请求失败'
,
})
},
})
})
}
/**
* POST formdata 请求
* @param url 请求地址
* @param data 请求数据
* @param header 请求头
* @returns Promise
*/
export
function
postFormData
<
T
=
any
>
(
url
:
string
,
data
?:
Record
<
string
,
any
>
,
header
?:
Record
<
string
,
any
>
,
):
Promise
<
FormDataResponse
<
T
>>
{
return
formDataRequest
<
T
>
({
url
,
data
,
method
:
'POST'
,
header
,
})
}
/**
* PUT formdata 请求
* @param url 请求地址
* @param data 请求数据
* @param header 请求头
* @returns Promise
*/
export
function
putFormData
<
T
=
any
>
(
url
:
string
,
data
?:
Record
<
string
,
any
>
,
header
?:
Record
<
string
,
any
>
,
):
Promise
<
FormDataResponse
<
T
>>
{
return
formDataRequest
<
T
>
({
url
,
data
,
method
:
'PUT'
,
header
,
})
}
src/utils/proxy.ts
浏览文件 @
a978aa7d
...
...
@@ -11,8 +11,8 @@ const PROXY_LIST: [[string, string]?] = [
// [`http://192.168.0.100:18100`, `https://oss.beta.app.yiring.com`],
// 开发环境(预览)
//
[`http://192.168.0.156:18100`, `http://111.22.182.169:49091`],
[
`http://192.168.0.156:18100`
,
`http://36.133.16.81:42111`
],
[
`http://192.168.0.156:18100`
,
`http://111.22.182.169:49091`
],
//
[`http://192.168.0.156:18100`, `http://36.133.16.81:42111`],
]
/**
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论