Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
basic-uniapp-v3
概览
概览
详情
活动
周期分析
版本库
存储库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
1
合并请求
1
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
Basic
basic-uniapp-v3
Commits
a5aa2470
提交
a5aa2470
authored
11月 06, 2025
作者:
宇宙超人
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
基地管理
上级
52cdf723
显示空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
260 行增加
和
128 行删除
+260
-128
nongchang.ts
src/api/model/nongchang.ts
+22
-0
add.vue
src/pages/jidiguanli/add.vue
+124
-28
jidiguanli.vue
src/pages/jidiguanli/jidiguanli.vue
+114
-100
没有找到文件。
src/api/model/nongchang.ts
浏览文件 @
a5aa2470
...
...
@@ -10,6 +10,17 @@ enum Api {
getFarmBaseList
=
'/farmbase/getFarmBaseList'
,
}
/**
* 农场基地管理-通过id查询
* @param params
* @returns
*/
export
function
getFarmbaseInfoById
(
params
:
any
=
{})
{
return
otherHttp
.
get
({
url
:
'/farmbase/queryById'
,
params
,
})
}
/**
* 删除基地
* @param id
* @returns
...
...
@@ -31,6 +42,17 @@ export function addFarmbase(params = {}) {
})
}
/**
* 编辑基地
* @param params
* @returns
*/
export
function
editFarmbase
(
params
=
{})
{
return
otherHttp
.
post
({
url
:
'/farmbase/edit'
,
params
,
})
}
/**
* 基地列表
* @param {any} params
* @return
...
...
src/pages/jidiguanli/add.vue
浏览文件 @
a5aa2470
...
...
@@ -185,8 +185,18 @@ const rules = {
{
required
:
true
,
message
:
'请选择基地类型'
,
trigger
:
'change'
}
],
scale
:
[
{
required
:
true
,
message
:
'请输入规模'
,
trigger
:
'blur'
},
{
pattern
:
/^
[
1-9
]\d
*$/
,
message
:
'规模必须为正整数'
,
trigger
:
'blur'
}
{
validator
:
(
rule
:
any
,
value
:
any
,
callback
:
any
)
=>
{
if
(
!
value
||
value
===
''
)
{
callback
(
new
Error
(
'请输入规模'
))
}
else
if
(
!
/^
[
1-9
]\d
*$/
.
test
(
value
.
toString
()))
{
callback
(
new
Error
(
'规模必须为正整数'
))
}
else
{
callback
()
}
},
trigger
:
[
'blur'
,
'change'
]
}
],
province
:
[
{
...
...
@@ -218,17 +228,26 @@ const rules = {
{
min
:
2
,
max
:
100
,
message
:
'种植作物长度在2-100个字符之间'
,
trigger
:
'blur'
}
],
operationYears
:
[
{
required
:
true
,
message
:
'请输入经营年限'
,
trigger
:
'blur'
},
{
pattern
:
/^
[
1-9
]\d
*$/
,
message
:
'经营年限必须为正整数'
,
trigger
:
'blur'
}
{
validator
:
(
rule
:
any
,
value
:
any
,
callback
:
any
)
=>
{
if
(
value
&&
!
/^
[
1-9
]\d
*$/
.
test
(
value
.
toString
()))
{
callback
(
new
Error
(
'经营年限必须为正整数'
))
}
else
{
callback
()
}
},
message
:
'经营年限必须为正整数'
,
trigger
:
[
'blur'
,
'change'
]
}
],
identityProveUrl
:
[
{
required
:
true
,
message
:
'请上传身份证明'
,
trigger
:
'change'
,
type
:
'array'
}
identityProveUrl
:
[
{
required
:
true
,
message
:
'请上传身份证明'
,
trigger
:
'change'
,
type
:
'array'
}
],
landProveUrl
:
[
{
required
:
true
,
message
:
'请上传场地证明'
,
trigger
:
'change'
,
type
:
'array'
}
landProveUrl
:
[
{
required
:
true
,
message
:
'请上传场地证明'
,
trigger
:
'change'
,
type
:
'array'
}
],
productionProveUrl
:
[
{
required
:
true
,
message
:
'请上传生产证明'
,
trigger
:
'change'
,
type
:
'array'
}
productionProveUrl
:
[
{
required
:
true
,
message
:
'请上传生产证明'
,
trigger
:
'change'
,
type
:
'array'
}
]
}
function
handleChangeFarmType
(
e
)
{
...
...
@@ -305,46 +324,123 @@ const deletePic = (event: any, key) => {
// 提交表单
const
submitForm
=
async
()
=>
{
try
{
// 先进行表单验证
const
valid
=
await
formRef
.
value
.
validate
()
if
(
valid
)
{
if
(
!
valid
)
{
return
}
loading
.
value
=
true
// 这里应该调用提交API
let
paramData
=
{
...
formData
};
paramData
.
baseImages
=
paramData
.
baseImages
.
join
(
','
);
paramData
.
identityProveUrl
=
paramData
.
identityProveUrl
.
join
(
','
);
paramData
.
landProveUrl
=
paramData
.
landProveUrl
.
join
(
','
);
paramData
.
productionProveUrl
=
paramData
.
productionProveUrl
.
join
(
','
);
paramData
.
qualityCertificateUrl
=
paramData
.
qualityCertificateUrl
.
join
(
','
);
paramData
.
otherMaterialUrl
=
paramData
.
otherMaterialUrl
.
join
(
','
);
NongchangAPI
.
addFarmbase
(
paramData
).
then
(
res
=>
{
loading
.
value
=
false
uni
.
showToast
({
title
:
'提交成功'
,
icon
:
'success'
})
// 准备提交数据
const
submitData
=
{
...
formData
}
// 将数组字段转换为逗号分隔的字符串
const
arrayFields
=
[
'baseImages'
,
'identityProveUrl'
,
'landProveUrl'
,
'productionProveUrl'
,
'qualityCertificateUrl'
,
'otherMaterialUrl'
]
arrayFields
.
forEach
(
field
=>
{
if
(
Array
.
isArray
(
submitData
[
field
]))
{
submitData
[
field
]
=
submitData
[
field
].
filter
(
item
=>
item
?.
trim
()).
join
(
','
)
}
})
// 根据是否有ID决定调用编辑还是新增接口
const
apiCall
=
submitData
.
id
?
NongchangAPI
.
editFarmbase
:
NongchangAPI
.
addFarmbase
try
{
await
apiCall
(
submitData
)
uni
.
showToast
({
title
:
'提交成功'
,
icon
:
'success'
,
duration
:
1500
})
// 延迟返回上一页
setTimeout
(()
=>
{
uni
.
navigateBack
()
},
800
)
}).
catch
(
err
=>
{
loading
.
value
=
false
;
Message
.
toast
(
err
.
message
)
},
1500
)
}
catch
(
error
)
{
console
.
error
(
'API调用失败:'
,
error
)
uni
.
showToast
({
title
:
error
.
message
||
'提交失败,请重试'
,
icon
:
'none'
,
duration
:
2000
})
}
finally
{
loading
.
value
=
false
}
}
catch
(
error
)
{
console
.
log
(
'表单验证失败:'
,
error
)
uni
.
showToast
({
title
:
'请完善表单信息'
,
icon
:
'none'
})
loading
.
value
=
false
uni
.
showToast
({
title
:
'请完善表单信息'
,
icon
:
'none'
,
duration
:
2000
})
}
}
const
farmStore
=
useFarmStore
()
onLoad
(()
=>
{
onLoad
((
pageOptions
)
=>
{
// 页面加载时的初始化操作
const
farmInfo
=
farmStore
.
getFarm
if
(
farmInfo
)
{
formData
.
farmId
=
farmInfo
.
id
}
// 修复:修改页面上定义的 options 对象中的 farmType
options
.
farmType
=
dictStore
.
getDictList
[
'farm_type'
].
map
((
item
)
=>
{
return
{
value
:
item
.
value
,
text
:
item
.
text
,
}
})
if
(
pageOptions
.
id
)
{
NongchangAPI
.
getFarmbaseInfoById
({
id
:
pageOptions
.
id
}).
then
(
res
=>
{
if
(
res
)
{
// 将 res 中的数据赋值到 formData 中,key 保持一致
Object
.
keys
(
res
).
forEach
(
key
=>
{
if
(
key
in
formData
)
{
// 如果是数组类型的字段且返回的是字符串,需要转换为数组
if
([
'baseImages'
,
'identityProveUrl'
,
'landProveUrl'
,
'productionProveUrl'
,
'qualityCertificateUrl'
,
'otherMaterialUrl'
].
includes
(
key
)
&&
typeof
res
[
key
]
===
'string'
)
{
formData
[
key
]
=
res
[
key
].
split
(
','
).
filter
(
item
=>
item
.
trim
()
!==
''
)
}
else
{
formData
[
key
]
=
res
[
key
]
}
}
})
formData
.
id
=
res
.
id
formData
.
province
=
res
.
provinceName
+
res
.
cityName
+
res
.
districtName
// 根据 res.baseType 的值从 options.farmType 中查找对应的文本
if
(
res
.
baseType
&&
options
.
farmType
.
length
>
0
)
{
const
foundItem
=
options
.
farmType
.
find
((
item
:
any
)
=>
item
.
value
===
res
.
baseType
)
if
(
foundItem
)
{
formData
.
baseTypeText
=
foundItem
.
text
}
}
// 数据赋值完成后,延迟触发表单验证更新
setTimeout
(()
=>
{
if
(
formRef
.
value
)
{
// 逐个验证可能存在问题的字段
formRef
.
value
.
validateField
(
'scale'
)
formRef
.
value
.
validateField
(
'operationYears'
)
// 重新验证整个表单
formRef
.
value
.
validate
()
}
},
200
)
}
})
}
})
</
script
>
...
...
src/pages/jidiguanli/jidiguanli.vue
浏览文件 @
a5aa2470
<
script
setup
lang=
"ts"
>
import
{
reactive
,
ref
}
from
'vue'
import
{
onPullDownRefresh
,
onLoad
,
onShow
,
onNavigationBarButtonTap
}
from
'@dcloudio/uni-app'
import
*
as
NongchangAPI
from
'@/api/model/nongchang'
const
isOnePage
=
ref
(
true
)
const
paging
=
ref
(
null
)
const
pageData
=
reactive
({
import
{
nextTick
,
reactive
,
ref
}
from
'vue'
import
{
onLoad
,
onNavigationBarButtonTap
,
onShow
}
from
'@dcloudio/uni-app'
import
*
as
NongchangAPI
from
'@/api/model/nongchang'
const
isOnePage
=
ref
(
true
)
const
paging
=
ref
(
null
)
const
pageData
=
reactive
({
param
:
{
pageNo
:
1
,
pageSize
:
10
,
baseName
:
''
baseName
:
''
,
},
list
:
[],
total
:
0
,
//
基地总数
type_success_total
:
0
,
//
已认证
type_unverified_total
:
0
,
//
未认证
})
onNavigationBarButtonTap
((
e
)
=>
{
total
:
0
,
//
基地总数
type_success_total
:
0
,
//
已认证
type_unverified_total
:
0
,
//
未认证
})
onNavigationBarButtonTap
((
e
)
=>
{
console
.
log
(
'onNavigationBarButtonTap'
,
e
)
})
onLoad
(()
=>
{
})
onShow
(()
=>
{
})
onLoad
(()
=>
{})
onShow
(()
=>
{
nextTick
(()
=>
{
if
(
!
isOnePage
.
value
)
paging
.
value
.
refresh
();
if
(
!
isOnePage
.
value
&&
paging
.
value
)
{
paging
.
value
.
reload
()
}
isOnePage
.
value
=
false
})
})
})
function
getList
()
{
NongchangAPI
.
getFarmbaseList
(
pageData
.
param
).
then
(
res
=>
{
pageData
.
total
=
res
.
total
;
paging
.
value
.
complete
(
res
.
records
);
}).
catch
(
err
=>
{
paging
.
value
.
complete
(
false
);
if
(
!
paging
.
value
)
return
NongchangAPI
.
getFarmbaseList
(
pageData
.
param
)
.
then
((
res
)
=>
{
pageData
.
total
=
res
.
total
paging
.
value
.
complete
(
res
.
records
)
})
.
catch
(()
=>
{
paging
.
value
.
complete
(
false
)
})
}
onNavigationBarButtonTap
((
e
)
=>
{
onNavigationBarButtonTap
((
_
)
=>
{
uni
.
navigateTo
({
url
:
'./add'
url
:
'./add'
,
})
})
const
queryList
=
(
pageNo
,
pageSize
)
=>
{
pageData
.
param
.
pageNo
=
pageNo
;
pageData
.
param
.
pageSize
=
pageSize
;
})
function
queryList
(
pageNo
,
pageSize
)
{
pageData
.
param
.
pageNo
=
pageNo
pageData
.
param
.
pageSize
=
pageSize
getList
()
}
}
const
handleSearch
=
()
=>
{
function
handleSearch
()
{
// 重置页码为1,重新搜索
pageData
.
param
.
pageNo
=
1
;
paging
.
value
.
reload
();
}
const
del
=
(
id
,
index
)
=>
{
pageData
.
param
.
pageNo
=
1
if
(
paging
.
value
)
{
paging
.
value
.
reload
()
}
}
const
goDetail
=
(
id
)
=>
{
uni
.
navigateTo
({
url
:
'./add?id='
+
id
,
})
}
function
del
(
id
)
{
uni
.
showModal
({
title
:
'提示'
,
content
:
'确定删除吗?'
,
success
:
(
res
)
=>
{
if
(
res
.
confirm
)
{
NongchangAPI
.
delFarmbase
(
id
).
then
(
res
=>
{
NongchangAPI
.
delFarmbase
(
id
).
then
(()
=>
{
uni
.
showToast
({
title
:
'删除成功'
,
icon
:
'none'
})
paging
.
value
.
refresh
();
icon
:
'none'
,
})
if
(
paging
.
value
)
{
paging
.
value
.
reload
()
}
})
}
},
})
}
}
</
script
>
<
template
>
<view
class=
"codefun-flex-col page"
>
<!--
<view
class=
"codefun-flex-col section"
>
<view
class=
"codefun-flex-row codefun-justify-between codefun-items-center"
>
<image
class=
"image"
src=
"/static/images/codefun/187b02e95cf1f33e4fa03b784305e21d.png"
/>
<view
class=
"codefun-flex-row group"
>
<image
class=
"image_2"
src=
"/static/images/codefun/5095bac6e3d752cba3708a4aaae4995a.png"
/>
<image
class=
"image_3 ml-5"
src=
"/static/images/codefun/568ef7f0e1d4af85ed9e599afdc74d20.png"
/>
<image
class=
"image_4 ml-5"
src=
"/static/images/codefun/21fe98696f0027c988d25f6121cc2831.png"
/>
</view>
</view>
<view
class=
"codefun-mt-22 codefun-flex-row codefun-justify-center codefun-items-center codefun-relative group_2"
>
<image
class=
"image_5 pos"
src=
"/static/images/codefun/8e086590d7d14994e1d62cf41c8ccff9.png"
/>
<text
class=
"font text"
>
农场基地管理
</text>
<view
class=
"codefun-flex-row codefun-items-center pos_2"
>
<image
class=
"codefun-shrink-0 image_6"
src=
"/static/images/codefun/09abef094d235d5ac956a89c6f8a3835.png"
/>
<text
class=
"font_2 text_2 ml-5"
>
添加基地
</text>
</view>
</view>
</view>
-->
<z-paging
ref=
"paging"
v-model=
"pageData.list"
@
query=
"queryList"
>
<view
class=
"codefun-flex-col group_3"
>
<view
class=
"codefun-flex-row codefun-items-center section_2"
>
...
...
@@ -108,10 +101,13 @@ const del = (id, index) => {
<view
class=
"codefun-mt-12 codefun-flex-col section_3"
>
<view
class=
"codefun-flex-row codefun-justify-between group_4"
>
<view
class=
"codefun-flex-row codefun-self-start"
>
<image
class=
"codefun-shrink-0 image_7"
src=
"/static/images/codefun/db26a8ae3f4d5f1e0a3f11d8fb5bc491.png"
/>
<image
class=
"codefun-shrink-0 image_7"
src=
"/static/images/codefun/db26a8ae3f4d5f1e0a3f11d8fb5bc491.png"
/>
<view
class=
"codefun-flex-col codefun-items-start codefun-shrink-0 codefun-self-center group_7"
>
class=
"codefun-flex-col codefun-items-start codefun-shrink-0 codefun-self-center group_7"
>
<text
class=
"text_5"
>
{{
pageData
.
total
}}
</text>
<text
class=
"font_4 text_7 mt-5"
>
总基地数
</text>
</view>
...
...
@@ -119,26 +115,34 @@ const del = (id, index) => {
</view>
<view
class=
"codefun-flex-col codefun-self-center group_5"
>
<view
class=
"codefun-flex-row codefun-items-center group_6"
>
<image
class=
"image_6"
src=
"/static/images/codefun/118c884c539aaba710313f0682db00e1.png"
/>
<image
class=
"image_6"
src=
"/static/images/codefun/118c884c539aaba710313f0682db00e1.png"
/>
<view
class=
"codefun-ml-4 codefun-flex-col codefun-justify-start codefun-items-center text-wrapper"
>
class=
"codefun-ml-4 codefun-flex-col codefun-justify-start codefun-items-center text-wrapper"
>
<text
class=
"font_3 text_6"
>
已认证:
</text>
</view>
<view
class=
"codefun-ml-4 codefun-flex-col codefun-justify-start codefun-items-center text-wrapper_2"
>
class=
"codefun-ml-4 codefun-flex-col codefun-justify-start codefun-items-center text-wrapper_2"
>
<text
class=
"font_5"
>
{{
pageData
.
type_success_total
}}
个
</text>
</view>
</view>
<view
class=
"codefun-flex-row codefun-items-center group_8"
>
<image
class=
"image_6"
src=
"/static/images/codefun/27ef797870c2085d1a14446c50cf53e0.png"
/>
<image
class=
"image_6"
src=
"/static/images/codefun/27ef797870c2085d1a14446c50cf53e0.png"
/>
<view
class=
"codefun-ml-4 codefun-flex-col codefun-justify-start codefun-items-center text-wrapper"
>
class=
"codefun-ml-4 codefun-flex-col codefun-justify-start codefun-items-center text-wrapper"
>
<text
class=
"font_3 text_6"
>
待认证:
</text>
</view>
<view
class=
"codefun-ml-4 codefun-flex-col codefun-justify-start codefun-items-center text-wrapper_3"
>
class=
"codefun-ml-4 codefun-flex-col codefun-justify-start codefun-items-center text-wrapper_3"
>
<text
class=
"font_3 text_8"
>
{{
pageData
.
type_unverified_total
}}
个
</text>
</view>
</view>
...
...
@@ -148,7 +152,8 @@ const del = (id, index) => {
<view
class=
"codefun-flex-row"
>
<image
class=
"image_8"
src=
"/static/images/codefun/c24e87154a833caadfcb70fb24ae52dc.png"
/>
<view
class=
"codefun-ml-4 codefun-flex-col codefun-justify-start codefun-items-start text-wrapper_4"
>
class=
"codefun-ml-4 codefun-flex-col codefun-justify-start codefun-items-start text-wrapper_4"
>
<text
class=
"font_5"
>
基地认证指南
</text>
</view>
</view>
...
...
@@ -157,11 +162,15 @@ const del = (id, index) => {
</view>
<view
class=
"codefun-mt-12 codefun-flex-col section_4"
v-if=
"pageData.list.length"
>
<view
class=
"codefun-flex-col codefun-self-stretch list"
>
<view
class=
"codefun-flex-row codefun-items-center list-item"
v-for=
"(item, index) in pageData.list"
:key=
"index"
>
<view
class=
"codefun-flex-row codefun-items-center list-item"
v-for=
"(item, index) in pageData.list"
:key=
"index"
>
<view
class=
"codefun-flex-col codefun-justify-start codefun-items-start section_5"
>
<view
class=
"codefun-flex-col codefun-justify-start codefun-items-center text-wrapper_5"
>
class=
"codefun-flex-col codefun-justify-start codefun-items-center text-wrapper_5"
>
<text
class=
"font_6"
>
{{
item
.
auditStatus_dictText
}}
</text>
</view>
</view>
...
...
@@ -174,18 +183,24 @@ const del = (id, index) => {
</view>
</view>
<view
class=
"codefun-mt-18 codefun-flex-row codefun-justify-between codefun-items-center group_11"
>
<view
class=
"codefun-flex-row"
>
<image
class=
"image_10"
src=
"/static/images/codefun/3566724e23f8a91e60ae87c2744e4090.png"
/>
class=
"codefun-mt-18 codefun-flex-row codefun-justify-between codefun-items-center group_11"
>
<view
class=
"codefun-flex-row"
@
click=
"goDetail(item.id)"
>
<image
class=
"image_10"
src=
"/static/images/codefun/3566724e23f8a91e60ae87c2744e4090.png"
/>
<view
class=
"codefun-ml-4 codefun-flex-col codefun-justify-start codefun-items-center text-wrapper_6"
>
class=
"codefun-ml-4 codefun-flex-col codefun-justify-start codefun-items-center text-wrapper_6"
>
<text
class=
"font_7 text_11"
>
详情
</text>
</view>
</view>
<view
class=
"codefun-flex-row codefun-items-center"
@
click=
"del(item.id, index)"
>
<image
class=
"codefun-shrink-0 image_10"
src=
"/static/images/codefun/8630d19ebb6334e2028daa7d7b8b5983.png"
/>
<view
class=
"codefun-flex-row codefun-items-center"
@
click=
"del(item.id)"
>
<image
class=
"codefun-shrink-0 image_10"
src=
"/static/images/codefun/8630d19ebb6334e2028daa7d7b8b5983.png"
/>
<text
class=
"font_8 ml-5"
>
删除
</text>
</view>
</view>
...
...
@@ -195,36 +210,35 @@ const del = (id, index) => {
</view>
</view>
</z-paging>
</view>
</
template
>
<
style
scoped
lang=
"scss"
>
body
{
body
{
background-color
:
#e6f5e8
;
}
}
.mt-5
{
.mt-5
{
margin-top
:
10
rpx
;
}
}
.mt-11
{
.mt-11
{
margin-top
:
22
rpx
;
}
}
.ml-5
{
.ml-5
{
margin-left
:
10
rpx
;
}
}
.ml-13
{
.ml-13
{
margin-left
:
26
rpx
;
}
}
.ml-9
{
.ml-9
{
margin-left
:
18
rpx
;
}
}
.page
{
.page
{
background-color
:
#e6f5e8
;
mix-blend-mode
:
NOTTHROUGH
;
width
:
100%
;
...
...
@@ -687,5 +701,5 @@ body {
line-height
:
25.76
rpx
;
color
:
#ffffff
;
}
}
}
</
style
>
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论