This commit is contained in:
weipengfei 2024-01-26 17:29:25 +08:00
parent 2c6ba3959f
commit 0c36432c23
15 changed files with 680 additions and 603 deletions

View File

@ -42,6 +42,7 @@ export const listForType = (data) => syhttp.get('/action/listForType', data)
//首页 //首页
export const lindexist = (data) => syhttp.get('/index/index', data) export const lindexist = (data) => syhttp.get('/index/index', data)
//产品列表 //产品列表
export const landproduct = (data) => syhttp.get('/land/product', data) export const landproduct = (data) => syhttp.get('/land/product', data)

View File

@ -8,3 +8,10 @@ export const farmTypeLists = () => syhttp.get('/common/dict_data_lists_by_type_v
//养殖种类 //养殖种类
export const breedTypeLists = () => syhttp.get('/common/dict_data_lists_by_type_value', {type_value: 'breed_type'}); export const breedTypeLists = () => syhttp.get('/common/dict_data_lists_by_type_value', {type_value: 'breed_type'});
//栏舍类型
export const fenceHouseTypeLists = () => syhttp.get('/common/dict_data_lists_by_type_value', {type_value: 'fence_house_type'});
//动物类型
export const animalTypeLists = () => syhttp.get('/common/dict_data_lists_by_type_value', {type_value: 'animal_type'});

View File

@ -24,3 +24,7 @@ export const farmTypeLists = (data) => syhttp.get('/farm_type', data);
//新增养殖基地 //新增养殖基地
export const farmAdd = (data) => syhttp.post('/farm/add', data); export const farmAdd = (data) => syhttp.post('/farm/add', data);
//养殖基地列表
export const fenceHouseData = (data) => syhttp.get('/fence_house/datas', data);

13
api/manage.js Normal file
View File

@ -0,0 +1,13 @@
import syhttp from "@/utils/syhttp.js";
import http from "@/utils/http.js";
//新增栏舍
export const fenceHouseAdd = (data) => syhttp.post('/fence_house/add', data);
//栏舍列表
export const fenceHouseList = (data) => syhttp.get('/fence_house/list', data);
//栏舍详情
export const fenceHouseDetail = (data) => syhttp.get('/fence_house/detail', data);

View File

@ -2,32 +2,32 @@
<view class="" style="margin-top: 10rpx;"> <view class="" style="margin-top: 10rpx;">
<view class="" style="display: flex;align-items: center;height: 60rpx;"> <view class="" style="display: flex;align-items: center;height: 60rpx;">
<u-icon name="map"></u-icon> <u-icon name="map"></u-icon>
栏舍一号 {{info.fence_house_name}}
</view> </view>
<view class="info"> <view class="info">
<view class="info-li" style="background-image: url('/static/main/house/dong_wu_ming_cheng.png');"> <view class="info-li" style="background-image: url('/static/main/house/dong_wu_ming_cheng.png');">
动物名称 动物名称
<view class=""> <view class="">
黑山羊 {{info.animal_name}}
</view> </view>
</view> </view>
<view class="info-li" style="background-image: url('/static/main/house/dong_wu_lei_xing.png');"> <view class="info-li" style="background-image: url('/static/main/house/dong_wu_lei_xing.png');">
动物类型 动物类型
<view class=""> <view class="">
哺乳动物 {{getAnimalType(info.animal_type)}}
</view> </view>
</view> </view>
<view class="info-li" style="background-image: url('/static/main/house/lan_she_rong_liang.png');"> <view class="info-li" style="background-image: url('/static/main/house/lan_she_rong_liang.png');">
栏舍容量 栏舍容量
<view class=""> <view class="">
50 {{info.capacity}}
</view> </view>
</view> </view>
<view class="info-li" style="background-image: url('/static/main/house/lan_she_fu_ze_ren.png');"> <view class="info-li" style="background-image: url('/static/main/house/lan_she_fu_ze_ren.png');">
栏舍负责人 栏舍负责人
<view class=""> <view class="">
赵桑 {{info.master}}
</view> </view>
</view> </view>
<view class="info-li" style="background-image: url('/static/main/house/dian_hua.png');"> <view class="info-li" style="background-image: url('/static/main/house/dian_hua.png');">
@ -46,15 +46,29 @@
<script setup> <script setup>
import { import {
reactive, reactive,
watch watch,
ref
} from "vue"; } from "vue";
import {
animalTypeLists
} from "@/api/dict.js"
const props = defineProps({ const props = defineProps({
info: Object, info: Object,
isDetail: Boolean isDetail: Boolean
}) })
const animal_type_lists = ref([])
const initAnimalTypeLists = ()=>{
animalTypeLists().then(res=>{
animal_type_lists.value = res.data;
})
}
initAnimalTypeLists();
const getAnimalType = (type)=>{
return animal_type_lists.value.find(item=>item.value==type)?.name||'';
}
const perviewFn = (url) => { const perviewFn = (url) => {
uni.previewImage({ uni.previewImage({

View File

@ -9,7 +9,7 @@ let HTTP_REQUEST_URL
let HEADER let HEADER
if (env == 'dev') { if (env == 'dev') {
// BASE_URL = 'http://ceshi-suyuan.lihaink.cn/' // BASE_URL = 'http://ceshi-suyuan.lihaink.cn/'
BASE_URL = 'http://192.168.1.6:8084/' BASE_URL = 'http://192.168.1.13:8084/'
} else if (env = 'prod') { } else if (env = 'prod') {
BASE_URL = 'http://ceshi-suyuan.lihaink.cn/' BASE_URL = 'http://ceshi-suyuan.lihaink.cn/'
} }

View File

@ -7,23 +7,19 @@
<Myindex style="float: right;"></Myindex> <Myindex style="float: right;"></Myindex>
<view class="" v-show="false">
<image src="/static/tabs-icon/dk.png"></image>
</view>
<view class="content"> <view class="content">
<view class="tit"> <view class="tit">
您好 您好
</view> </view>
<view class="tit" style="margin-bottom: 60rpx;"> <view class="tit" style="margin-bottom: 60rpx;">
欢迎进入吟龙土壤墒情监测系统! 欢迎进入吟龙养殖测溯系统!
</view> </view>
<view class="input-card"> <view class="input-card">
<view class="card-head"> <view class="card-head">
<!-- <view class="triangle top" /> <!-- <view class="triangle top" />
<view class="triangle bottom" /> --> <view class="triangle bottom" /> -->
<view class="code-login" @click="changeLoginType(0)" :class="{act_code:loginType==0}"> <view class="code-login" @click="changeLoginType(0)" :class="{act_code:loginType==2}">
<span>验证码登录</span> <span>验证码登录</span>
</view> </view>
@ -247,7 +243,7 @@
height: 50px; height: 50px;
background-color: transparent; background-color: transparent;
box-sizing: border-box; box-sizing: border-box;
background-image: url("/static/main/index/white_bg.png"); // background-image: url("/static/main/index/white_bg.png");
background-size: 100% 100%; background-size: 100% 100%;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
@ -255,7 +251,8 @@
align-items: center; align-items: center;
padding: 20rpx; padding: 20rpx;
transition: 500ms; transition: 500ms;
color: black; // color: black;
color: white;
font-weight: bold; font-weight: bold;
position: absolute; position: absolute;
@ -299,9 +296,9 @@
// background-color: white; // background-color: white;
// color: white; // color: white;
color: black; color: black;
font-weight: normal; font-weight: bold;
// background-image: url('/static/main/index/login_ad.png'); // background-image: url('/static/main/index/login_ad.png');
// background-image: url('/static/main/index/white_bg.png'); background-image: url('/static/main/index/white_bg.png');
} }
.act_password { .act_password {
@ -545,8 +542,6 @@
} }
// //
const submitFn = () => { const submitFn = () => {
if (!formData.account) return uni.$u.toast('账号不能为空'); if (!formData.account) return uni.$u.toast('账号不能为空');
if (!formData.password && formData.scene == 1) return uni.$u.toast('密码不能为空'); if (!formData.password && formData.scene == 1) return uni.$u.toast('密码不能为空');
if (!/^1(3|4|5|7|8|9|6)\d{9}$/i.test(formData.account)) return uni.$u.toast( if (!/^1(3|4|5|7|8|9|6)\d{9}$/i.test(formData.account)) return uni.$u.toast(
@ -554,21 +549,19 @@
); );
// console.log(formData) // console.log(formData)
if (!formData.code && formData.scene == 2) return uni.$u.toast('验证码不能为空'); if (!formData.code && formData.scene == 2) return uni.$u.toast('验证码不能为空');
login(formData).then((res) => {
if (res.code == 1) {
uni.showLoading({ uni.showLoading({
title: '登陆中' title: '登陆中'
}) })
login(formData).then((res) => {
if (res.code == 1) {
stores.dispatch('saveUserInfo', res.data) stores.dispatch('saveUserInfo', res.data)
setTimeout(() => {
uni.hideLoading() uni.hideLoading()
store.dispatch('changeTabbar', 0) store.dispatch('changeTabbar', 0)
uni.switchTab({ uni.switchTab({
url: '/pages/index/massif' url: '/pages/index/massif'
}) })
console.log(store.state.tabbrIndex, "tabbar") // console.log(store.state.tabbrIndex, "tabbar")
uni.$u.toast('登录成功'); uni.$u.toast('登录成功');
}, 500)
} }
@ -605,7 +598,5 @@
} }
onMounted(() => { onMounted(() => {
checkUserAgent() checkUserAgent()
}) })
</script> </script>

View File

@ -15,7 +15,7 @@
您好 您好
</view> </view>
<view class="tit"> <view class="tit">
欢迎进入吟龙土壤墒情监测溯系统! 欢迎进入吟龙养殖测溯系统!
</view> </view>
<view class="input-card" style="color: #7A7A7A;"> <view class="input-card" style="color: #7A7A7A;">
<view class="login-type" style="color: black;font-weight: bold;"> <view class="login-type" style="color: black;font-weight: bold;">

View File

@ -28,7 +28,7 @@
style="pointer-events: none;"></up-input> style="pointer-events: none;"></up-input>
</up-form-item> </up-form-item>
<up-form-item label="养殖基地规模(亩)" prop="form_scale" borderBottom required> <up-form-item label="养殖基地规模(亩)" prop="form_scale" borderBottom required>
<up-input input-align="right" placeholder="请输入养殖基地规模" border="none" <up-input input-align="right" placeholder="请输入养殖基地规模" type="number" border="none"
v-model="data.formData.form_scale"></up-input> v-model="data.formData.form_scale"></up-input>
</up-form-item> </up-form-item>
<up-form-item label="负责人" prop="master" borderBottom required> <up-form-item label="负责人" prop="master" borderBottom required>
@ -43,21 +43,33 @@
<view class="c-title">地址信息</view> <view class="c-title">地址信息</view>
<view class="c-box"> <view class="c-box">
<up-form-item label="所在省份" prop="province" borderBottom required @click="isshow1"> <up-form-item label="所在省份" prop="province" borderBottom required @click="isshow">
<up-input input-align="right" placeholder="请选择所在省份" suffixIcon="arrow-down" <up-input input-align="right" placeholder="请选择所在省份" suffixIcon="arrow-down"
suffix-icon-style="color: #b6b6b6;" border="none" v-model="province_name" readonly suffix-icon-style="color: #b6b6b6;" border="none" v-model="province_name" readonly
style="pointer-events: none;"></up-input> style="pointer-events: none;"></up-input>
</up-form-item> </up-form-item>
<up-form-item label="所在城市" prop="city" borderBottom required @click="isshow2"> <up-form-item label="所在城市" prop="city" borderBottom required @click="isshow1">
<up-input input-align="right" placeholder="请选择所在城市" suffixIcon="arrow-down" <up-input input-align="right" placeholder="请选择所在城市" suffixIcon="arrow-down"
suffix-icon-style="color: #b6b6b6;" border="none" v-model="city_name" readonly suffix-icon-style="color: #b6b6b6;" border="none" v-model="city_name" readonly
style="pointer-events: none;"></up-input> style="pointer-events: none;"></up-input>
</up-form-item> </up-form-item>
<up-form-item label="所在区县" prop="area" borderBottom required @click="isshow3"> <up-form-item label="所在区县" prop="area" borderBottom required @click="isshow2">
<up-input input-align="right" placeholder="请选择所在区县" suffixIcon="arrow-down" <up-input input-align="right" placeholder="请选择所在区县" suffixIcon="arrow-down"
suffix-icon-style="color: #b6b6b6;" border="none" v-model="area_name" readonly suffix-icon-style="color: #b6b6b6;" border="none" v-model="area_name" readonly
style="pointer-events: none;"></up-input> style="pointer-events: none;"></up-input>
</up-form-item> </up-form-item>
<up-form-item label="所在镇街" prop="formData.street" borderBottom required @click="isshow3">
<up-input input-align="right" placeholder="请选择所在镇街" suffixIcon="arrow-down"
suffix-icon-style="color: #b6b6b6;" border="none" v-model="street_name"></up-input>
</up-form-item>
<up-form-item label="所在乡村" prop="formData.village" borderBottom required @click="isshow4">
<up-input input-align="right" placeholder="请选择所在乡村" suffixIcon="arrow-down"
suffix-icon-style="color: #b6b6b6;" border="none" v-model="village_name"></up-input>
</up-form-item>
<up-form-item label="所在小队" prop="formData.bridge" borderBottom required @click="isshow5">
<up-input input-align="right" placeholder="请选择所在小队" suffixIcon="arrow-down"
suffix-icon-style="color: #b6b6b6;" border="none" v-model="bridge_name"></up-input>
</up-form-item>
<up-form-item label="养殖基地详细地址" prop="address" style="position: relative;" borderBottom required> <up-form-item label="养殖基地详细地址" prop="address" style="position: relative;" borderBottom required>
<up-input input-align="right" placeholder="请输入养殖基地详细地址" suffixIcon="map" <up-input input-align="right" placeholder="请输入养殖基地详细地址" suffixIcon="map"
suffix-icon-style="color: #b6b6b6;" border="none" v-model="data.formData.address"> suffix-icon-style="color: #b6b6b6;" border="none" v-model="data.formData.address">
@ -100,14 +112,23 @@
</view> </view>
</up-form> </up-form>
<u-action-sheet :show="show" keyName="name" closeOnClickOverlay :actions="columns" title="请选择" <u-action-sheet :show="show" keyName="name" closeOnClickOverlay :actions="columns" title="请选择"
@close="show = false" @select="leavaType1"> @close="show = false" @select="leavaType">
</u-action-sheet> </u-action-sheet>
<u-action-sheet :show="show1" keyName="name" :actions="columns1" title="请选择" @close="show1 = false" <u-action-sheet :show="show1" keyName="name" :actions="columns1" title="请选择" @close="show1 = false"
@select="leavaType2"> @select="leavaType1">
</u-action-sheet> </u-action-sheet>
<u-action-sheet :show="show2" keyName="name" :actions="columns2" title="请选择" @close="show2 = false" <u-action-sheet :show="show2" keyName="name" :actions="columns2" title="请选择" @close="show2 = false"
@select="leavaType2">
</u-action-sheet>
<u-action-sheet :show="show3" keyName="name" :actions="columns3" title="请选择" @close="show3 = false"
@select="leavaType3"> @select="leavaType3">
</u-action-sheet> </u-action-sheet>
<u-action-sheet :show="show4" keyName="name" :actions="columns4" title="请选择" @close="show4 = false"
@select="leavaType4">
</u-action-sheet>
<u-action-sheet :show="show5" keyName="name" :actions="columns5" title="请选择" @close="show5 = false"
@select="leavaType5">
</u-action-sheet>
<u-action-sheet :show="showFarm" keyName="name" :actions="farm_tpye_list" title="请选择" @close="showFarm = false" <u-action-sheet :show="showFarm" keyName="name" :actions="farm_tpye_list" title="请选择" @close="showFarm = false"
@select="selectFarmType"> @select="selectFarmType">
</u-action-sheet> </u-action-sheet>
@ -163,11 +184,14 @@
province: '', province: '',
city: '', city: '',
area: '', area: '',
street: '',
village: '',
bridge: '',
address: '', address: '',
lat: "", lat: "",
lon: "", lon: "",
master_name: '', master_name: '',
pic: [] image: []
}, },
rules: { rules: {
farm_name: [{ farm_name: [{
@ -212,6 +236,24 @@
message: '请选择所在区县', message: '请选择所在区县',
trigger: 'change' trigger: 'change'
}], }],
street: {
type: 'string',
required: true,
message: '请选择所在镇街',
trigger: ['blur', 'change']
},
village: {
type: 'string',
required: true,
message: '请选择所在乡村',
trigger: ['blur', 'change']
},
bridge: {
type: 'string',
required: true,
message: '请选择小队',
trigger: ['blur', 'change']
},
address: [{ address: [{
type: 'string', type: 'string',
required: true, required: true,
@ -247,17 +289,26 @@
const province_name = ref(null) const province_name = ref(null)
const city_name = ref(null) const city_name = ref(null)
const area_name = ref(null) const area_name = ref(null)
const street_name = ref(null)
const village_name = ref(null)
const bridge_name = ref(null)
const farm_type_name = ref(null) const farm_type_name = ref(null)
const breed_type_name = ref(null) const breed_type_name = ref(null)
const show = ref(false) const show = ref(false)
const show1 = ref(false) const show1 = ref(false)
const show2 = ref(false) const show2 = ref(false)
const show3 = ref(false)
const show4 = ref(false)
const show5 = ref(false)
const showFarm = ref(false) const showFarm = ref(false)
const showBreed = ref(false) const showBreed = ref(false)
const columns = reactive([]) const columns = reactive([])
const columns1 = reactive([]) const columns1 = reactive([])
const columns2 = reactive([]) const columns2 = reactive([])
const columns3 = reactive([])
const columns4 = reactive([])
const columns5 = reactive([])
const farm_tpye_list = reactive([]) const farm_tpye_list = reactive([])
const breed_tpye_list = reactive([]) const breed_tpye_list = reactive([])
@ -275,7 +326,6 @@
} }
const cityn = (id) => { const cityn = (id) => {
city({ city({
province_code: id province_code: id
}).then((res) => { }).then((res) => {
@ -302,6 +352,48 @@
}); });
} }
const townsn = (id) => {
towns({
county_code: id
}).then((res) => {
columns3.splice(0, columns.length, ...res.data.map((step, index) => {
return {
name: step.town_name,
id: step.town_code,
};
}));
});
}
const villagesn = (id) => {
villages({
town_code: id
}).then((res) => {
columns4.splice(0, columns.length, ...res.data.map((step, index) => {
return {
name: step.village_name,
id: step.village_code,
};
}));
});
}
const groupsn = () => {
groups().then((res) => {
columns5.splice(0, columns.length, ...res.data.map((step, index) => {
return {
name: step.group_name,
id: step.group_code,
};
}));
});
}
const farmTypeListsn = (id) => { const farmTypeListsn = (id) => {
farmTypeLists().then((res) => { farmTypeLists().then((res) => {
farm_tpye_list.splice(0, farm_tpye_list.length, ...res.data.map((step, index) => { farm_tpye_list.splice(0, farm_tpye_list.length, ...res.data.map((step, index) => {
@ -382,15 +474,24 @@
// //
const isshow1 = () => { const isshow = () => {
show.value = true show.value = true
} }
const isshow2 = () => { const isshow1 = () => {
show1.value = true show1.value = true
} }
const isshow3 = () => { const isshow2 = () => {
show2.value = true show2.value = true
} }
const isshow3 = () => {
show3.value = true
}
const isshow4 = () => {
show4.value = true
}
const isshow5 = () => {
show5.value = true
}
const isshowFarm = () =>{ const isshowFarm = () =>{
showFarm.value = true showFarm.value = true
@ -400,21 +501,39 @@
showBreed.value = true showBreed.value = true
} }
const leavaType1 = (e) => { const leavaType = (e) => {
console.log(e); console.log(e);
province_name.value = e.name province_name.value = e.name
data.formData.province = e.id data.formData.province = e.id
cityn(e.id) cityn(e.id)
} }
const leavaType2 = (e) => { const leavaType1 = (e) => {
city_name.value = e.name city_name.value = e.name
data.formData.city = e.id data.formData.city = e.id
countyn(e.id) countyn(e.id)
} }
const leavaType3 = (e) => { const leavaType2 = (e) => {
area_name.value = e.name area_name.value = e.name
data.formData.area = e.id data.formData.area = e.id
townsn(e.id)
}
const leavaType3 = (e) => {
street_name.value = e.name
data.formData.street = e.id
villagesn(e.id)
}
const leavaType4 = (e) => {
village_name.value = e.name
data.formData.village = e.id
groupsn()
}
const leavaType5 = (e) => {
bridge_name.value = e.name
data.formData.bridge = e.id
} }
@ -453,7 +572,7 @@
uni.$u.toast('请上传图片') uni.$u.toast('请上传图片')
return return
} }
data.formData.pic = JSON.stringify(pic) data.formData.image = JSON.stringify(pic)
// //
farmAdd(data.formData).then((res) => { farmAdd(data.formData).then((res) => {

View File

@ -60,14 +60,14 @@
<view class="land-area"> <view class="land-area">
<view class="land-title">养殖基地规模</view> <view class="land-title">养殖基地规模</view>
<view class=""> <view class="">
{{dataobj.form_scale|| "--"}} {{dataobj.form_scale|| "--"}}
</view> </view>
</view> </view>
<view class="plant-area"> <view class="plant-area">
<view class="land-title">养殖种类</view> <view class="land-title">养殖种类</view>
<view class=""> <view class="">
{{dataobj.total_area-dataobj.residual_area||"--"}} {{farm_type||"--"}}
</view> </view>
</view> </view>
</view> </view>
@ -130,8 +130,7 @@
</view> </view>
<u-loading-page :loading="showLoading"></u-loading-page> <u-loading-page :loading="showLoading"></u-loading-page>
<u-action-sheet :show="show" keyName="name" closeOnClickOverlay :actions="houseList" title="请选择"
<u-action-sheet :show="show" keyName="name" closeOnClickOverlay :actions="columns" title="请选择"
@close="show = false" @select="confirm"> @close="show = false" @select="confirm">
</u-action-sheet> </u-action-sheet>
</view> </view>
@ -178,7 +177,8 @@
<script setup> <script setup>
import { import {
reactive, reactive,
ref ref,
computed
} from 'vue'; } from 'vue';
import { import {
onLoad, onLoad,
@ -192,12 +192,14 @@
plantlist, plantlist,
landproduct landproduct
} from '@/api/api.js' } from '@/api/api.js'
import {farmLists} from "@/api/index.js" import {farmLists, fenceHouseData} from "@/api/index.js"
import {farmTypeLists} from "@/api/dict.js" import {farmTypeLists} from "@/api/dict.js"
import store from "@/store/index.js" import store from "@/store/index.js"
const showPicker = ref(false) const showPicker = ref(false)
const showPicker1 = ref(false) const showPicker1 = ref(false)
const showModal = ref(false) const showModal = ref(false)
const columns1 = reactive([ const columns1 = reactive([
[{ [{
label: '施肥', label: '施肥',
@ -262,7 +264,7 @@
} }
}) })
const dataobj = reactive({}) const dataobj = ref({})
const tdId = ref('') const tdId = ref('')
const palntId = ref('') const palntId = ref('')
// //
@ -306,6 +308,8 @@
const show = ref(false) const show = ref(false)
const showLoading = ref(false) const showLoading = ref(false)
const columns = reactive([]); const columns = reactive([]);
const houseList = reactive([]);
const houseInfo = ref({});
onShow(() => { onShow(() => {
getlist2() getlist2()
@ -363,6 +367,7 @@
} }
const farm_lists = ref([]); const farm_lists = ref([]);
const house_lists = ref([]);
const farm_types_lists = ref([]); const farm_types_lists = ref([]);
const initFarmLists = ()=>{ const initFarmLists = ()=>{
farmTypeLists().then(res=>{ farmTypeLists().then(res=>{
@ -378,6 +383,21 @@
})); }));
if(res.data.length>0) dataobj.value = res.data[0]; if(res.data.length>0) dataobj.value = res.data[0];
else dataobj.value = {}; else dataobj.value = {};
store.commit('setFarm', dataobj.value);
}).catch(err=>{
console.log(err);
})
fenceHouseData().then(res=>{
house_lists.value = res.data;
houseList.splice(0, houseList.length, ...res.data.map((step, index) => {
return {
name: step.animal_name,
id: step.id,
};
}));
if(res.data.length>0) houseInfo.value = res.data[0];
else houseInfo.value = {};
store.commit('setHouse', houseInfo.value);
getlist(); getlist();
}).catch(err=>{ }).catch(err=>{
console.log(err); console.log(err);
@ -385,6 +405,10 @@
} }
initFarmLists(); initFarmLists();
const farm_type = computed(()=>{
return farm_types_lists.value.find(item=>item.value==dataobj.value.farm_type)?.name || ''
})
// //
const getlist = () => { const getlist = () => {
// lindexist({ // lindexist({
@ -482,7 +506,8 @@
const confirm = (e) => { const confirm = (e) => {
// console.log(e) // console.log(e)
tdId.value = e.id; tdId.value = e.id;
dataobj.value = farm_lists.value.find(item=>item.id==e.id); houseInfo.value = house_lists.value.find(item=>item.id==e.id);
store.commit('setHouse', houseInfo.value);
show.value = false show.value = false
showLoading.value = true showLoading.value = true
setTimeout(() => { setTimeout(() => {

View File

@ -32,7 +32,7 @@
</up-form-item> </up-form-item>
<up-form-item label="栏舍" prop="master_phone" borderBottom required> <up-form-item label="栏舍" prop="master_phone" borderBottom required>
<up-input input-align="right" placeholder="请输入栏舍" border="none" <up-input input-align="right" placeholder="请输入栏舍" border="none"
v-model="data.formData.master_phone"></up-input> v-model="data.formData.fence_house_name"></up-input>
</up-form-item> </up-form-item>
<up-form-item label="现估重(kg)" prop="master_phone" borderBottom required> <up-form-item label="现估重(kg)" prop="master_phone" borderBottom required>
<up-input input-align="right" placeholder="请输入现估重" type="number" border="none" <up-input input-align="right" placeholder="请输入现估重" type="number" border="none"
@ -130,6 +130,7 @@
const form1 = ref(null); const form1 = ref(null);
const data = reactive({ const data = reactive({
formData: { formData: {
fence_house_id: '', //id
title: '', title: '',
sex: '', sex: '',
type: 1, type: 1,
@ -292,6 +293,10 @@
data.formData.type = 1; data.formData.type = 1;
data.formData.type_name = '购买'; data.formData.type_name = '购买';
} }
if(options.id) {
data.formData.fence_house_id = options.id;
data.formData.fence_house_name = options.fence_house_name;
}
}) })
</script> </script>

View File

@ -6,25 +6,31 @@
<view class="c-title">栏舍信息</view> <view class="c-title">栏舍信息</view>
<view class="c-box"> <view class="c-box">
<up-form-item label="栏舍名称" prop="title" borderBottom required> <up-form-item label="栏舍名称" prop="fence_house_name" borderBottom required>
<up-input input-align="right" placeholder="请输入栏舍名称" border="none" <up-input input-align="right" placeholder="请输入栏舍名称" border="none"
v-model="data.formData.title"></up-input> v-model="data.formData.fence_house_name"></up-input>
</up-form-item> </up-form-item>
<up-form-item label="动物类型" prop="title" borderBottom required> <up-form-item label="栏舍类型" prop="fence_house_type" borderBottom required @click="isshow">
<up-input input-align="right" placeholder="请输入动物类型" border="none" <up-input input-align="right" placeholder="请选择栏舍类型" suffixIcon="arrow-down"
v-model="data.formData.title"></up-input> suffix-icon-style="color: #b6b6b6;" border="none" v-model="fence_house_type" readonly
style="pointer-events: none;"></up-input>
</up-form-item> </up-form-item>
<up-form-item label="栏舍类型" prop="area" borderBottom required> <up-form-item label="动物名称" prop="animal_name" borderBottom required>
<up-input input-align="right" placeholder="请输入栏舍类型" border="none" <up-input input-align="right" placeholder="请输入动物名称" border="none"
v-model="data.formData.area"></up-input> v-model="data.formData.animal_name"></up-input>
</up-form-item> </up-form-item>
<up-form-item label="容量" prop="master_name" borderBottom required> <up-form-item label="动物类型" prop="animal_type" borderBottom required @click="isshow1">
<up-input input-align="right" placeholder="请选择动物类型" suffixIcon="arrow-down"
suffix-icon-style="color: #b6b6b6;" border="none" v-model="animal_type" readonly
style="pointer-events: none;"></up-input>
</up-form-item>
<up-form-item label="容量" prop="capacity" borderBottom required>
<up-input input-align="right" placeholder="请输入栏舍容量" border="none" <up-input input-align="right" placeholder="请输入栏舍容量" border="none"
v-model="data.formData.master_name"></up-input> v-model="data.formData.capacity"></up-input>
</up-form-item> </up-form-item>
<up-form-item label="负责人" prop="master_phone" borderBottom required> <up-form-item label="负责人" prop="master" borderBottom required>
<up-input input-align="right" placeholder="请输入负责人姓名" type="number" border="none" <up-input input-align="right" placeholder="请输入负责人姓名" border="none"
v-model="data.formData.master_phone"></up-input> v-model="data.formData.master"></up-input>
</up-form-item> </up-form-item>
<up-form-item label="负责人电话" prop="master_phone" borderBottom required> <up-form-item label="负责人电话" prop="master_phone" borderBottom required>
<up-input input-align="right" placeholder="请输入负责人电话" type="number" border="none" <up-input input-align="right" placeholder="请输入负责人电话" type="number" border="none"
@ -34,15 +40,14 @@
<view class="card-li"> <view class="card-li">
<view class="c-title">养殖基地图片</view> <view class="c-title">栏舍图片</view>
<view class="c-box c-box-p"> <view class="c-box c-box-p">
<view class="code-img1"> <view class="code-img1">
<view class="" v-if="pic.length>0" <view class="" v-if="pic.length>0"
style="display: flex;flex-direction: row;flex-wrap: wrap;margin-bottom: 30rpx;"> style="display: flex;flex-direction: row;flex-wrap: wrap;margin-bottom: 30rpx;">
<view class="" v-for="(item,i) in pic" style="margin-right: 30rpx;"> <view class="" v-for="(item,i) in pic" style="margin-right: 30rpx;">
<view class=""> <view class="">
<u-icon name="close" size="15" style="margin-left:120.85rpx;" <u-icon name="close" size="15" style="margin-left:120.85rpx;" @click="delimg(i)"></u-icon>
@click="delimg(i)"></u-icon>
<u-image :src="item" width="150.85rpx" height="150.85rpx"></u-image> <u-image :src="item" width="150.85rpx" height="150.85rpx"></u-image>
</view> </view>
</view> </view>
@ -64,24 +69,12 @@
</view> </view>
</view> </view>
</up-form> </up-form>
<u-action-sheet :show="show" keyName="name" closeOnClickOverlay :actions="columns" title="请选择" <u-action-sheet :show="show" keyName="name" closeOnClickOverlay :actions="fence_house_type_lists" title="请选择"
@close="show = false" @select="leavaType1"> @close="show = false" @select="leavaType">
</u-action-sheet> </u-action-sheet>
<u-action-sheet :show="show1" keyName="name" :actions="columns1" title="请选择" @close="show1 = false" <u-action-sheet :show="show1" keyName="name" :actions="animal_type_lists" title="请选择" @close="show1 = false"
@select="leavaType2"> @select="leavaType1">
</u-action-sheet>
<u-action-sheet :show="show2" keyName="name" :actions="columns2" title="请选择" @close="show2 = false"
@select="leavaType3">
</u-action-sheet>
<u-action-sheet :show="show3" keyName="name" :actions="columns3" title="请选择" @close="show3 = false"
@select="leavaType4">
</u-action-sheet>
<u-action-sheet :show="show4" keyName="name" :actions="columns4" title="请选择" @close="show4 = false"
@select="leavaType5">
</u-action-sheet>
<u-action-sheet :show="show5" keyName="name" :actions="columns5" title="请选择" @close="show5 = false"
@select="leavaType6">
</u-action-sheet> </u-action-sheet>
<u-button class="btn" @click="submit">提交</u-button> <u-button class="btn" @click="submit">提交</u-button>
</view> </view>
@ -97,6 +90,13 @@
computed, computed,
watch watch
} from 'vue'; } from 'vue';
import {
animalTypeLists,
fenceHouseTypeLists
} from "@/api/dict.js"
import {
fenceHouseAdd
} from "@/api/manage.js"
import { import {
onLoad, onLoad,
onReady onReady
@ -104,85 +104,57 @@
import { import {
Uploads Uploads
} from "@/api/upload.js" } from "@/api/upload.js"
import { import store from "@/store/index.js"
addland,
province,
city,
county,
towns,
villages,
groups
} from '@/api/api.js'
const form1 = ref(null); const form1 = ref(null);
const data = reactive({ const data = reactive({
formData: { formData: {
title: '', fence_house_name: '',
area: '', fence_house_type: '',
province_code: '', animal_name: '',
city_code: '', animal_type: '',
county_code: '', capacity: '',
address: '', master: '',
lat: "",
lon: "",
master_name: '',
master_phone: '', master_phone: '',
pic: ['https://img0.baidu.com/it/u=1717510975,3258230326&fm=253&fmt=auto?w=120&h=80', pic: ['https://img0.baidu.com/it/u=1717510975,3258230326&fm=253&fmt=auto?w=120&h=80',
'https://img0.baidu.com/it/u=1717510975,3258230326&fm=253&fmt=auto?w=120&h=80' 'https://img0.baidu.com/it/u=1717510975,3258230326&fm=253&fmt=auto?w=120&h=80'
] ]
}, },
rules: { rules: {
// name: [{ fence_house_name: [{
// required: true,
// message: '',
// //
// trigger: ['change', 'blur'],
// }],
// intro: [{
// min: 5,
// message: '5',
// trigger: 'change'
// }],
title: [{
type: 'string', type: 'string',
required: true, required: true,
message: '请填写养殖基地名称', message: '请填写栏舍名称',
trigger: ['blur', 'change'] trigger: ['blur', 'change']
}], }],
area: [{ fence_house_type: [{
type: 'string', type: 'string',
required: true, required: true,
message: '请填写养殖基地面积', message: '请选择栏舍类型',
trigger: ['blur', 'change'] trigger: ['blur', 'change']
}], }],
province_code: [{ animal_name: [{
type: 'string', type: 'string',
required: true, required: true,
message: '请请选择所在省份', message: '请输入动物名称',
trigger: 'change'
}],
city_code: [{
type: 'string',
required: true,
message: '请选择所在城市',
trigger: 'change'
}],
county_code: [{
type: 'string',
required: true,
message: '请选择所在区县',
trigger: 'change'
}],
address: [{
type: 'string',
required: true,
message: '请输入养殖基地详细地址',
trigger: ['blur', 'change'] trigger: ['blur', 'change']
}], }],
master_name: [{ animal_type: [{
type: 'string', type: 'string',
required: true, required: true,
message: '请输入养殖基地负责人名称', message: '请输入动物类型',
trigger: ['blur', 'change']
}],
capacity: [{
type: 'string',
required: true,
message: '请输入栏舍容量',
trigger: ['blur', 'change']
}],
master: [{
type: 'string',
required: true,
message: '请输入负责人姓名',
trigger: ['blur', 'change'] trigger: ['blur', 'change']
}], }],
master_phone: [{ master_phone: [{
@ -205,59 +177,9 @@
} }
}); });
const pic = reactive([]); const pic = reactive([]);
const province_name = ref(null)
const city_name = ref(null)
const county_name = ref(null)
const show = ref(false) const show = ref(false)
const show1 = ref(false) const show1 = ref(false)
const show2 = ref(false)
const columns = reactive([])
const columns1 = reactive([])
const columns2 = reactive([])
const provincen = () => {
province().then((res) => {
columns.splice(0, columns.length, ...res.data.map((step, index) => {
return {
name: step.province_name,
id: step.province_code,
};
}));
});
}
const cityn = (id) => {
city({
province_code: id
}).then((res) => {
columns1.splice(0, columns.length, ...res.data.map((step, index) => {
return {
name: step.city_name,
id: step.city_code,
};
}));
});
}
const countyn = (id) => {
county({
city_code: id
}).then((res) => {
columns2.splice(0, columns.length, ...res.data.map((step, index) => {
return {
name: step.county_name,
id: step.county_code,
};
}));
});
}
// //
const delimg = (i) => { const delimg = (i) => {
@ -299,92 +221,44 @@
// data.formData.pic = res.data.image // data.formData.pic = res.data.image
} }
const isshow = () => {
//
const isshow1 = () => {
show.value = true show.value = true
} }
const isshow2 = () => { const isshow1 = () => {
show1.value = true show1.value = true
} }
const isshow3 = () => {
show2.value = true
}
const isshow4 = () => {
show3.value = true
}
const isshow5 = () => {
show4.value = true
} const fence_house_type = ref('');
const isshow6 = () => { const animal_type = ref('');
show5.value = true
}
const leavaType = (e) => {
fence_house_type.value = e.name;
data.formData.fence_house_type = e.value;
}
const leavaType1 = (e) => { const leavaType1 = (e) => {
animal_type.value = e.name;
province_name.value = e.name data.formData.animal_type = e.value;
data.formData.province_code = e.id
cityn(e.id)
} }
const leavaType2 = (e) => {
city_name.value = e.name
data.formData.city_code = e.id
countyn(e.id)
}
const leavaType3 = (e) => {
county_name.value = e.name
data.formData.county_code = e.id
}
const location = () => {
uni.showLoading({
title: '获取位置中'
})
uni.getLocation({
type: 'gcj02',
geocode: true,
isHighAccuracy: true,
success: async (res) => {
console.log(res)
data.formData.lat = res.latitude
data.formData.lon = res.longitude
data.formData.address = res.address.street + res
.address.streetNum + res.address.poiName
uni.hideLoading();
console.log(data.formData)
},
fail: (err) => {
// uni.hideLoading();
console.log(err)
console.log("erer")
}
});
}
onReady(() => { onReady(() => {
form1.value.setRules(data.rules); form1.value.setRules(data.rules);
}); });
const animal_type_lists = ref([]);
const initAnimalTypeLists = ()=>{
animalTypeLists().then(res=>{
animal_type_lists.value = res.data;
})
}
initAnimalTypeLists();
const fence_house_type_lists = ref([]);
const initFenceHouseTypeLists = ()=>{
fenceHouseTypeLists().then(res=>{
fence_house_type_lists.value = res.data;
})
}
initFenceHouseTypeLists();
const submit = async () => { const submit = async () => {
try { try {
@ -392,15 +266,13 @@
if (valid) { if (valid) {
// console.log('', data.formData); // console.log('', data.formData);
if (pic.length == 0) { if (pic.length == 0) {
uni.$u.toast('请上传图片') uni.$u.toast('请上传图片')
return return
} }
data.formData.pic = JSON.stringify(pic) data.formData.pic = JSON.stringify(pic)
data.formData.farm_id = store.state.farm.id
// //
addland(data.formData).then((res) => { fenceHouseAdd(data.formData).then((res) => {
console.log(res) console.log(res)
if (res.code == 1) { if (res.code == 1) {
uni.navigateBack({ uni.navigateBack({
@ -422,7 +294,6 @@
onLoad((options) => { onLoad((options) => {
provincen()
}) })
</script> </script>

View File

@ -31,25 +31,25 @@
<view class="tits"> <view class="tits">
栏舍信息 栏舍信息
</view> </view>
<view class="card" v-for="(item,index) in datalist" :key="index" @click="navTo('/pages/plantAdmin/houseDetail?id=23')"> <view class="card" v-for="(item,index) in datalist" :key="index" @click="navTo(`/pages/plantAdmin/houseDetail?id=${item.id}`)">
<image class="img" :src="item.img"></image> <image class="img" :src="parseImg(item.pic)"></image>
<view class="tips"> <view class="tips">
<view class="title">{{item.name}}</view> <view class="title">{{item.fence_house_name}}</view>
<view class="item"> <view class="item">
<view class="tip-name">动物名称: </view> <view class="tip-name">动物名称: </view>
<view>{{item.animal_name}} </view> <view>{{item.animal_name}} </view>
</view> </view>
<view class="item"> <view class="item">
<view class="tip-name">动物类型: </view> <view class="tip-name">动物类型: </view>
<view>{{item.animal_type}} </view> <view>{{getAnimalType(item.animal_type)}} </view>
</view> </view>
<view class="item"> <view class="item">
<view class="tip-name">容量: </view> <view class="tip-name">容量: </view>
<view>{{item.capacity}} </view> <view>{{item.capacity}} </view>
</view> </view>
<view class="item"> <view class="item">
<view class="tip-name">创建: </view> <view class="tip-name">负责: </view>
<view>{{item.create_by}} </view> <view>{{item.master}} </view>
</view> </view>
<view class="item"> <view class="item">
<view class="tip-name">创建时间: </view> <view class="tip-name">创建时间: </view>
@ -73,7 +73,7 @@
</view> </view>
</template> </template>
<script setup lang="ts"> <script setup>
import { import {
onLoad, onLoad,
onShow, onShow,
@ -90,6 +90,13 @@
import { import {
landlist landlist
} from '@/api/api.js' } from '@/api/api.js'
import {
fenceHouseList
} from "@/api/manage.js"
import {
animalTypeLists
} from "@/api/dict.js"
onLoad(() => { onLoad(() => {
if (!store.state.userInfo) { if (!store.state.userInfo) {
uni.redirectTo({ uni.redirectTo({
@ -98,7 +105,7 @@
} }
}) })
onShow(() => { onShow(() => {
// list() list()
}) })
onPullDownRefresh(() => { onPullDownRefresh(() => {
list() list()
@ -107,36 +114,43 @@
onReachBottom(() => { onReachBottom(() => {
getlist() getlist()
}) })
const datalist = reactive([ const datalist = ref([])
{
name: '栏舍一号',
img: 'https://lihai001.oss-cn-chengdu.aliyuncs.com/def/91fb0202311021455371420.jpg',
animal_name: '山羊',
animal_type: '哺乳动物',
capacity: '50只',
create_by: '张三',
create_time: '2023-12-19',
}
])
const fomData = reactive({ const fomData = reactive({
page_no: 1, page_no: 1,
page_size: 15, page_size: 15,
keyword: '' keyword: ''
}) })
const animal_type_lists = ref([])
const initAnimalTypeLists = ()=>{
animalTypeLists().then(res=>{
animal_type_lists.value = res.data;
})
}
initAnimalTypeLists();
const getAnimalType = (type)=>{
return animal_type_lists.value.find(item=>item.value==type)?.name||'';
}
const list = () => { const list = () => {
datalist.splice(0) datalist.value.splice(0)
fomData.page_no = 1 fomData.page_no = 1
getlist() getlist()
} }
const getlist = () => { const getlist = () => {
// landlist(fomData).then((res) => { fenceHouseList(fomData).then(res=>{
// if (res.code == 1) { console.log(res);
// datalist.push(...res.data) datalist.value = [...datalist.value, ...res.data.lists]
// fomData.page_no = fomData.page_no + 1; console.log(datalist.value);
// } })
// }) }
const parseImg = (image)=>{
try{
if(typeof image == 'string') image = JSON.parse(image||'[]');
return image[0];
}catch(e){
return ''
}
} }
// //
@ -151,7 +165,7 @@
const search = () => { const search = () => {
list() list()
} }
const navTo = (url: string)=>{ const navTo = (url)=>{
if(url) uni.navigateTo({ if(url) uni.navigateTo({
url: url url: url
}) })
@ -379,7 +393,7 @@
.item{ .item{
display: flex; display: flex;
color: #999; color: #999;
font-size: 28rpx; font-size: 26rpx;
.tip-name{ .tip-name{
flex-shrink: 0; flex-shrink: 0;
color: #333; color: #333;

View File

@ -144,7 +144,9 @@
plantlist, plantlist,
landdetail landdetail
} from '@/api/api.js' } from '@/api/api.js'
import {
fenceHouseDetail
} from "@/api/manage.js"
import { import {
onLoad, onLoad,
onShow onShow
@ -193,23 +195,22 @@
}] }]
]); ]);
onLoad((option) => { onLoad((option) => {
typeID.value = option.id; typeID.value = option.id;
getFenceHouseDetail();
}); });
onShow(() => { onShow(() => {
// getlist(); // getlist();
// getlist1();
}) })
const getlist1 = () => { const getFenceHouseDetail = () => {
landdetail({ fenceHouseDetail({
land_id: typeID.value id: typeID.value
}).then((res) => { }).then((res) => {
if (res.code == 1) { if (res.code == 1) {
Object.assign(dataobj, res.data); Object.assign(dataobj, res.data);
} }
}); });
}; };
@ -219,7 +220,6 @@
plantlist({ plantlist({
land_id: typeID.value land_id: typeID.value
}).then((res) => { }).then((res) => {
if (res.code == 1) { if (res.code == 1) {
dataList.splice(0, dataList.length, ...res.data); dataList.splice(0, dataList.length, ...res.data);
dataList.forEach(item => { dataList.forEach(item => {
@ -255,7 +255,7 @@
const selectOne = (e)=>{ const selectOne = (e)=>{
if(navType.value==1){ if(navType.value==1){
navTo(`/pages/plantAdmin/addBreed?name=${e.name}&type=${e.name=='购买'?1:2}`) navTo(`/pages/plantAdmin/addBreed?name=${e.name}&type=${e.name=='购买'?1:2}&id=${dataobj.id}&fence_house_name=${dataobj.fence_house_name}`)
}else { }else {
if(e.name=='喂食') return navTo(`/pages/feed/feed?id=23&house_id=1`); if(e.name=='喂食') return navTo(`/pages/feed/feed?id=23&house_id=1`);
if(e.name=='喂水') return navTo(`/pages/feed/water?id=23&house_id=1`); if(e.name=='喂水') return navTo(`/pages/feed/water?id=23&house_id=1`);

View File

@ -4,20 +4,33 @@ import {
const store = createStore({ const store = createStore({
state: { state: {
userInfo:uni.getStorageSync("SY_USER")||null, userInfo:uni.getStorageSync("SY_USER")||null,
farm: JSON.parse(uni.getStorageSync("farm")||"{}"),
house: JSON.parse(uni.getStorageSync("house")||"{}"),
}, },
mutations: { mutations: {
saveUserInfo(state, info) { saveUserInfo(state, info) {
state.userInfo = info state.userInfo = info
uni.setStorageSync("SY_USER", info) uni.setStorageSync("SY_USER", info)
},
setFarm(state, data){
state.farm = data;
uni.setStorageSync('farm', JSON.stringify(data));
},
setHouse(state, data){
state.house = data;
uni.setStorageSync('house', JSON.stringify(data));
} }
}, },
actions: { actions: {
saveUserInfo({commit}, info) { saveUserInfo({commit}, info) {
commit('saveUserInfo', info);
commit('saveUserInfo', info) },
setFarm({commit}, info){
commit('setFarm', info)
},
setHouse({commit}, info){
commit('setHouse', info)
} }
} }
}) })