提交 032ca494 作者: 宇宙超人

1

上级 45e70da5
...@@ -546,24 +546,11 @@ ...@@ -546,24 +546,11 @@
{ {
"path": "pages/device/device", "path": "pages/device/device",
"style": { "style": {
"navigationBarTitleText": "物联设备", "navigationBarTitleText": "基地设备",
"enablePullDownRefresh": false, "enablePullDownRefresh": false,
"navigationBarBackgroundColor": "#5DB66F", "navigationBarBackgroundColor": "#5DB66F",
"navigationBarTextStyle": "white", "navigationBarTextStyle": "white",
"backgroundColorBottom": "#F2F2F2", "backgroundColorBottom": "#F2F2F2"
"app-plus": {
"titleNView": {
"buttons": [
{
"text": "+ 添加设备",
"fontSrc": "/static/uni.ttf",
"color": "#fff",
"fontSize": "26rpx",
"width": "auto"
}
]
}
}
} }
}, },
{ {
......
<script setup lang="ts"> <script setup lang="ts">
import { computed, reactive, ref, watch } from 'vue' import { computed, reactive, ref, watch } from 'vue'
import { useDictStore } from '@/store/modules/dict' import { useDictStore } from '@/store/modules/dict'
import * as NongchangAPI from '@/api/model/nongchang' import * as NongchangAPI from '@/api/model/nongchang'
// 定义Props // 定义Props
interface Props { interface Props {
show: boolean show: boolean
editData?: any editData?: any
farmId:any, farmId: any
farmBaseId:any, farmBaseId: any
} }
const props = withDefaults(defineProps<Props>(), { const props = withDefaults(defineProps<Props>(), {
show: false, show: false,
editData: null, editData: null,
farmId:0, farmId: 0,
farmBaseId:0, farmBaseId: 0,
})
})
// 定义Emits // 定义Emits
const emit = defineEmits<{ const emit = defineEmits<{
'update:show': [value: boolean] 'update:show': [value: boolean]
submit: [data: any] submit: [data: any]
close: [] close: []
}>() }>()
// 表单引用 // 表单引用
const formRef = ref() const formRef = ref()
const loading = ref(false) const loading = ref(false)
const showDeviceTypePicker = ref(false) const showDeviceTypePicker = ref(false)
// 字典存储 // 字典存储
const dictStore = useDictStore() const dictStore = useDictStore()
// 表单数据 // 表单数据
const formData = reactive({ const formData = reactive({
deviceName: '', deviceName: '',
deviceType: '', deviceType: '',
deviceTypeText: '', deviceTypeText: '',
deviceIdentifier: '', deviceIdentifier: '',
}) })
// 设备类型选项 - 使用字典数据 // 设备类型选项 - 使用字典数据
const deviceTypeOptions = computed(() => { const deviceTypeOptions = computed(() => {
return ( return (
dictStore.getDictList.deviceType?.map((item: any) => ({ dictStore.getDictList.deviceType?.map((item: any) => ({
value: item.value, value: item.value,
text: item.text, text: item.text,
})) || [] })) || []
) )
}) })
// 设备类型选择器数据 (不再需要,因为fui-picker使用options属性) // 设备类型选择器数据 (不再需要,因为fui-picker使用options属性)
// 计算属性 // 计算属性
const dialogTitle = computed(() => { const dialogTitle = computed(() => {
return props.editData ? '编辑设备' : '添加设备' return props.editData ? '编辑设备' : '添加设备'
}) })
const submitButtonText = computed(() => { const submitButtonText = computed(() => {
return props.editData ? '保存' : '确认' return props.editData ? '保存' : '确认'
}) })
// 表单验证规则 // 表单验证规则
const rules = { const rules = {
deviceName: [ deviceName: [
{ required: true, message: '请输入设备名称', trigger: 'blur' }, { required: true, message: '请输入设备名称', trigger: 'blur' },
{ min: 2, max: 50, message: '设备名称长度在2-50个字符之间', trigger: 'blur' }, { min: 2, max: 50, message: '设备名称长度在2-50个字符之间', trigger: 'blur' },
...@@ -84,10 +83,10 @@ ...@@ -84,10 +83,10 @@
trigger: 'blur', trigger: 'blur',
}, },
], ],
} }
// 监听显示状态 // 监听显示状态
watch( watch(
() => props.show, () => props.show,
(newVal) => { (newVal) => {
if (newVal && props.editData) { if (newVal && props.editData) {
...@@ -99,10 +98,10 @@ ...@@ -99,10 +98,10 @@
resetFormData() resetFormData()
} }
}, },
) )
// 重置表单数据 // 重置表单数据
function resetFormData() { function resetFormData() {
formData.deviceName = '' formData.deviceName = ''
formData.deviceType = '' formData.deviceType = ''
formData.deviceTypeText = '' formData.deviceTypeText = ''
...@@ -112,12 +111,11 @@ ...@@ -112,12 +111,11 @@
if (formRef.value) { if (formRef.value) {
formRef.value.resetFields() formRef.value.resetFields()
} }
} }
// 加载编辑数据 // 加载编辑数据
function loadEditData() { function loadEditData() {
if (!props.editData) if (!props.editData) return
return
formData.deviceName = props.editData.deviceName || '' formData.deviceName = props.editData.deviceName || ''
formData.deviceType = props.editData.deviceType || '' formData.deviceType = props.editData.deviceType || ''
...@@ -135,17 +133,17 @@ return ...@@ -135,17 +133,17 @@ return
} else { } else {
formData.deviceTypeText = '' formData.deviceTypeText = ''
} }
} }
// 设备类型选择确认 // 设备类型选择确认
function handleDeviceTypeConfirm(e: any) { function handleDeviceTypeConfirm(e: any) {
formData.deviceType = e.value formData.deviceType = e.value
formData.deviceTypeText = e.text formData.deviceTypeText = e.text
showDeviceTypePicker.value = false showDeviceTypePicker.value = false
} }
// 提交表单 // 提交表单
async function handleSubmit() { async function handleSubmit() {
try { try {
console.log(formData) console.log(formData)
// 先进行表单验证 // 先进行表单验证
...@@ -192,21 +190,21 @@ return ...@@ -192,21 +190,21 @@ return
} finally { } finally {
loading.value = false loading.value = false
} }
} }
// 关闭弹窗 // 关闭弹窗
function handleClose() { function handleClose() {
emit('update:show', false) emit('update:show', false)
emit('close') emit('close')
} }
// 暴露方法给父组件 // 暴露方法给父组件
defineExpose({ defineExpose({
resetFormData, resetFormData,
setLoading: (value: boolean) => { setLoading: (value: boolean) => {
loading.value = value loading.value = value
}, },
}) })
</script> </script>
<template> <template>
...@@ -271,23 +269,23 @@ return ...@@ -271,23 +269,23 @@ return
</template> </template>
<style lang="scss" scoped> <style lang="scss" scoped>
.dialog-content { .dialog-content {
padding: 10rpx 30rpx; padding: 10rpx 30rpx;
width: 90%; width: 90%;
max-height: 80vh; max-height: 80vh;
overflow-y: auto; overflow-y: auto;
} }
.section-title { .section-title {
font-size: 32rpx; font-size: 32rpx;
font-weight: 600; font-weight: 600;
color: #333; color: #333;
margin: 20rpx 0 30rpx 0; margin: 20rpx 0 30rpx 0;
padding-left: 20rpx; padding-left: 20rpx;
border-left: 6rpx solid #5db66f; border-left: 6rpx solid #5db66f;
} }
.dialog-buttons { .dialog-buttons {
display: flex; display: flex;
gap: 20rpx; gap: 20rpx;
margin-top: 40rpx; margin-top: 40rpx;
...@@ -310,10 +308,10 @@ return ...@@ -310,10 +308,10 @@ return
border: 2rpx solid #dcdfe6; border: 2rpx solid #dcdfe6;
} }
} }
} }
// uview-plus 表单样式调整 // uview-plus 表单样式调整
::v-deep .u-form-item { ::v-deep .u-form-item {
margin-bottom: 40rpx; margin-bottom: 40rpx;
.u-form-item__body { .u-form-item__body {
...@@ -336,8 +334,8 @@ return ...@@ -336,8 +334,8 @@ return
flex: 1; flex: 1;
min-width: 0; min-width: 0;
} }
} }
.address-display { .address-display {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
align-items: center; align-items: center;
...@@ -357,15 +355,15 @@ return ...@@ -357,15 +355,15 @@ return
.placeholder-text { .placeholder-text {
color: #c0c4cc; color: #c0c4cc;
} }
} }
::v-deep .u-form-item__body__left__content__required { ::v-deep .u-form-item__body__left__content__required {
position: static; position: static;
padding-right: 10rpx; padding-right: 10rpx;
} }
// 输入框样式优化 // 输入框样式优化
::v-deep .u-input { ::v-deep .u-input {
.u-input__content { .u-input__content {
padding: 0; padding: 0;
...@@ -390,10 +388,10 @@ return ...@@ -390,10 +388,10 @@ return
} }
} }
} }
} }
// 模态框样式调整 // 模态框样式调整
::v-deep .u-modal { ::v-deep .u-modal {
.u-modal__content { .u-modal__content {
border-radius: 20rpx; border-radius: 20rpx;
padding: 20rpx 0rpx; padding: 20rpx 0rpx;
...@@ -409,5 +407,5 @@ return ...@@ -409,5 +407,5 @@ return
color: #333; color: #333;
} }
} }
} }
</style> </style>
...@@ -286,6 +286,7 @@ ...@@ -286,6 +286,7 @@
:required="false" :required="false"
clearable clearable
trim trim
type="number"
placeholder="请输入手机号" placeholder="请输入手机号"
v-model="model.form.data.username" v-model="model.form.data.username"
name="mobile" name="mobile"
......
...@@ -15,6 +15,7 @@ import type { ToolBoxButtonHandleEvent } from '@/components/Map/Widgets/ToolBox' ...@@ -15,6 +15,7 @@ import type { ToolBoxButtonHandleEvent } from '@/components/Map/Widgets/ToolBox'
import { ToolBoxWidget, useToolBoxWidget } from '@/components/Map/Widgets/ToolBox' import { ToolBoxWidget, useToolBoxWidget } from '@/components/Map/Widgets/ToolBox'
import * as NongchangAPI from '@/api/model/nongchang' import * as NongchangAPI from '@/api/model/nongchang'
import * as farmbaseApi from '@/api/model/farmbase' import * as farmbaseApi from '@/api/model/farmbase'
import navigate from '@/utils/page/navigate'
// 页面参数 // 页面参数
const page = reactive<Page>({ const page = reactive<Page>({
...@@ -343,6 +344,9 @@ onNavigationBarButtonTap((e) => { ...@@ -343,6 +344,9 @@ onNavigationBarButtonTap((e) => {
Navigate.to(`/pages/jidiguanli/add?farmId=${model.id}`) Navigate.to(`/pages/jidiguanli/add?farmId=${model.id}`)
} }
}) })
const toDevice = (device)=>{
Navigate.to(`/pages/device/device?deviceType=${device.deviceType}`)
}
</script> </script>
<template> <template>
...@@ -485,16 +489,20 @@ onNavigationBarButtonTap((e) => { ...@@ -485,16 +489,20 @@ onNavigationBarButtonTap((e) => {
<view class="box-4"> <view class="box-4">
<view class="box-4-title"> <view class="box-4-title">
<view class="box-4-title-text1"><text>基地设备</text></view> <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>
<view class="box-4-device"> <view class="box-4-device">
<view <view
class="box-4-device-item" class="box-4-device-item"
v-for="(device, index) in model.deviceTypeCount" v-for="(device, index) in model.deviceTypeCount"
:key="index" :key="index"
@click="toDevice(device)"
> >
<view class="box-4-item-icon"> <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>
<view class="box-4-item-content"> <view class="box-4-item-content">
<text class="box-4-item-text1">{{ device.deviceName }}</text> <text class="box-4-item-text1">{{ device.deviceName }}</text>
...@@ -506,7 +514,13 @@ onNavigationBarButtonTap((e) => { ...@@ -506,7 +514,13 @@ onNavigationBarButtonTap((e) => {
</view> </view>
</view> </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> </view>
</template> </template>
......
...@@ -11,8 +11,8 @@ const PROXY_LIST: [[string, string]?] = [ ...@@ -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.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://111.22.182.169:49091`],
[`http://192.168.0.156:18100`, `http://36.133.16.81:42111`], // [`http://192.168.0.156:18100`, `http://36.133.16.81:42111`],
] ]
/** /**
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论