This commit is contained in:
zmj 2023-12-17 19:34:37 +08:00
parent 2e59072b30
commit c72ae97d2d
16 changed files with 2525 additions and 2369 deletions

View File

@ -22,7 +22,7 @@
</view> </view>
</view> </view>
<view class="info-li" style="background-image: url('/static/main/index/tdfzr.png');"> <view class="info-li" style="background-image: url('/static/main/index/tdfzr.png');">
地负责人 地负责人
<view class=""> <view class="">
{{info.master_name}} {{info.master_name}}
</view> </view>

View File

@ -1,112 +1,113 @@
{ {
"name" : "种植溯源", "name": "种植溯源",
"appid" : "__UNI__D087881", "appid": "__UNI__D087881",
"description" : "", "description": "",
"versionName" : "1.0.1", "versionName": "1.0.2",
"versionCode" : "100", "versionCode": 102,
"transformPx" : false, "transformPx": false,
/* 5+App */ /* 5+App */
"app-plus" : { "app-plus": {
"usingComponents" : true, "usingComponents": true,
"nvueStyleCompiler" : "uni-app", "nvueStyleCompiler": "uni-app",
"compilerVersion" : 3, "compilerVersion": 3,
"screenOrientation" : [ "screenOrientation": [
"portrait-primary", "portrait-primary",
"portrait-secondary", "portrait-secondary",
"landscape-primary", "landscape-primary",
"landscape-secondary" "landscape-secondary"
], ],
"splashscreen" : { "splashscreen": {
"alwaysShowBeforeRender" : true, "alwaysShowBeforeRender": true,
"waiting" : true, "waiting": true,
"autoclose" : true, "autoclose": true,
"delay" : 0 "delay": 0
}, },
/* */ /* */
"modules" : { "modules": {
"Geolocation" : {}, "Geolocation": {},
"Maps" : {}, "Maps": {},
"LivePusher" : {}, "LivePusher": {},
"VideoPlayer" : {}, "VideoPlayer": {},
"Barcode" : {}, "Barcode": {},
"Camera" : {}, "Camera": {},
"UniMP" : { "UniMP": {
"description" : "uni小程序" "description": "uni小程序"
} }
}, },
/* */ /* */
"distribute" : { "distribute": {
/* android */ /* android */
"android" : { "android": {
"permissions" : [ "permissions": [
"<uses-feature android:name=\"android.hardware.camera\"/>", "<uses-feature android:name=\"android.hardware.camera\"/>",
"<uses-feature android:name=\"android.hardware.camera.autofocus\"/>", "<uses-feature android:name=\"android.hardware.camera.autofocus\"/>",
"<uses-permission android:name=\"android.permission.ACCESS_NETWORK_STATE\"/>", "<uses-permission android:name=\"android.permission.ACCESS_NETWORK_STATE\"/>",
"<uses-permission android:name=\"android.permission.ACCESS_WIFI_STATE\"/>", "<uses-permission android:name=\"android.permission.ACCESS_WIFI_STATE\"/>",
"<uses-permission android:name=\"android.permission.CAMERA\"/>", "<uses-permission android:name=\"android.permission.CAMERA\"/>",
"<uses-permission android:name=\"android.permission.CHANGE_NETWORK_STATE\"/>", "<uses-permission android:name=\"android.permission.CHANGE_NETWORK_STATE\"/>",
"<uses-permission android:name=\"android.permission.CHANGE_WIFI_STATE\"/>", "<uses-permission android:name=\"android.permission.CHANGE_WIFI_STATE\"/>",
"<uses-permission android:name=\"android.permission.FLASHLIGHT\"/>", "<uses-permission android:name=\"android.permission.FLASHLIGHT\"/>",
"<uses-permission android:name=\"android.permission.GET_ACCOUNTS\"/>", "<uses-permission android:name=\"android.permission.GET_ACCOUNTS\"/>",
"<uses-permission android:name=\"android.permission.MOUNT_UNMOUNT_FILESYSTEMS\"/>", "<uses-permission android:name=\"android.permission.MOUNT_UNMOUNT_FILESYSTEMS\"/>",
"<uses-permission android:name=\"android.permission.READ_LOGS\"/>", "<uses-permission android:name=\"android.permission.READ_LOGS\"/>",
"<uses-permission android:name=\"android.permission.READ_PHONE_STATE\"/>", "<uses-permission android:name=\"android.permission.READ_PHONE_STATE\"/>",
"<uses-permission android:name=\"android.permission.RECORD_AUDIO\"/>", "<uses-permission android:name=\"android.permission.RECORD_AUDIO\"/>",
"<uses-permission android:name=\"android.permission.VIBRATE\"/>", "<uses-permission android:name=\"android.permission.USE_FINGERPRINT\"/>",
"<uses-permission android:name=\"android.permission.WAKE_LOCK\"/>", "<uses-permission android:name=\"android.permission.VIBRATE\"/>",
"<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>" "<uses-permission android:name=\"android.permission.WAKE_LOCK\"/>",
], "<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>"
"minSdkVersion" : 21 ],
}, "minSdkVersion": 21
/* ios */ },
"ios" : { /* ios */
"dSYMs" : false "ios": {
}, "dSYMs": false
/* SDK */ },
"sdkConfigs" : { /* SDK */
"ad" : {}, "sdkConfigs": {
"geolocation" : { "ad": {},
"amap" : { "geolocation": {
"name" : "amap_18982406440DFVLElaO", "amap": {
"__platform__" : [ "android" ], "name": "amap_18982406440DFVLElaO",
"appkey_ios" : "4e6789b864fe1a2d76b98e38158f20f2", "__platform__": ["ios", "android"],
"appkey_android" : "a230d943475443eb29fc3871fbef8605" "appkey_ios": "d2a3f66e130d2315fb72846db0d25197",
}, "appkey_android": "d2a3f66e130d2315fb72846db0d25197"
"system" : { },
"__platform__" : [ "ios", "android" ] "system": {
} "__platform__": ["ios", "android"]
}, }
"maps" : { },
"amap" : { "maps": {
"name" : "4e6789b864fe1a2d76b98e38158f20f2", "amap": {
"appkey_ios" : "a230d943475443eb29fc3871fbef8605", "name": "4e6789b864fe1a2d76b98e38158f20f2",
"appkey_android" : "a230d943475443eb29fc3871fbef8605" "appkey_ios": "d2a3f66e130d2315fb72846db0d25197",
} "appkey_android": "d2a3f66e130d2315fb72846db0d25197"
} }
} }
} }
}, }
/* */ },
"quickapp" : {}, /* */
/* */ "quickapp": {},
"mp-weixin" : { /* */
"appid" : "", "mp-weixin": {
"setting" : { "appid": "",
"urlCheck" : false "setting": {
}, "urlCheck": false
"usingComponents" : true },
}, "usingComponents": true
"mp-alipay" : { },
"usingComponents" : true "mp-alipay": {
}, "usingComponents": true
"mp-baidu" : { },
"usingComponents" : true "mp-baidu": {
}, "usingComponents": true
"mp-toutiao" : { },
"usingComponents" : true "mp-toutiao": {
}, "usingComponents": true
"uniStatistics" : { },
"enable" : false "uniStatistics": {
}, "enable": false
"vueVersion" : "3" },
} "vueVersion": "3"
}

View File

@ -5,74 +5,81 @@
<up-form labelWidth='100' :model="data.formData" ref="form1"> <up-form labelWidth='100' :model="data.formData" ref="form1">
<!-- <up-form-item label="姓名" prop="name"><u-input v-model="data.formData.name" /></up-form-item> <!-- <up-form-item label="姓名" prop="name"><u-input v-model="data.formData.name" /></up-form-item>
<up-form-item label="简介" prop="intro"><u-input v-model="data.formData.intro" /></up-form-item> --> <up-form-item label="简介" prop="intro"><u-input v-model="data.formData.intro" /></up-form-item> -->
<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="title" borderBottom required>
<up-input input-align="right" placeholder="请输入土地名称" border="none" v-model="data.formData.title"></up-input> <up-input input-align="right" placeholder="请输入土地名称" border="none"
</up-form-item> v-model="data.formData.title"></up-input>
<up-form-item label="土地面积" prop="area" borderBottom required> </up-form-item>
<up-input input-align="right" placeholder="请输入土地面积" border="none" v-model="data.formData.area"></up-input> <up-form-item label="土地面积" prop="area" borderBottom required>
</up-form-item> <up-input input-align="right" placeholder="请输入土地面积" border="none"
<up-form-item label="土地负责人" prop="master_name" borderBottom required> v-model="data.formData.area"></up-input>
<up-input input-align="right" placeholder="请输入土地负责人名称" border="none" v-model="data.formData.master_name"></up-input> </up-form-item>
</up-form-item> <up-form-item label="土地负责人" prop="master_name" 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="请输入负责人电话" type="number" border="none" v-model="data.formData.master_name"></up-input>
v-model="data.formData.master_phone"></up-input> </up-form-item>
</up-form-item> <up-form-item label="负责人电话" prop="master_phone" borderBottom required>
</view> <up-input input-align="right" placeholder="请输入负责人电话" type="number" border="none"
v-model="data.formData.master_phone"></up-input>
<view class="c-title">地址信息</view> </up-form-item>
<view class="c-box"> </view>
<up-form-item label="所在省份" prop="province_code" borderBottom required @click="isshow1">
<up-input input-align="right" placeholder="请选择所在省份" suffixIcon="arrow-down" suffix-icon-style="color: #b6b6b6;" border="none" v-model="province_name" readonly <view class="c-title">地址信息</view>
style="pointer-events: none;"></up-input> <view class="c-box">
</up-form-item> <up-form-item label="所在省份" prop="province_code" borderBottom required @click="isshow1">
<up-form-item label="所在城市" prop="city_code" 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="city_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="county_code" borderBottom required @click="isshow3"> <up-form-item label="所在城市" prop="city_code" borderBottom required @click="isshow2">
<up-input input-align="right" placeholder="请选择所在区县" suffixIcon="arrow-down" suffix-icon-style="color: #b6b6b6;" border="none" v-model="county_name" readonly <up-input input-align="right" placeholder="请选择所在城市" suffixIcon="arrow-down"
style="pointer-events: none;"></up-input> suffix-icon-style="color: #b6b6b6;" border="none" v-model="city_name" readonly
</up-form-item> style="pointer-events: none;"></up-input>
<up-form-item label="土地详细地址" prop="town_code" borderBottom required> </up-form-item>
<up-input input-align="right" placeholder="请输入土地详细地址" suffixIcon="map" suffix-icon-style="color: #b6b6b6;" border="none" v-model="data.formData.address"> <up-form-item label="所在区县" prop="county_code" borderBottom required @click="isshow3">
</up-input> <up-input input-align="right" placeholder="请选择所在区县" suffixIcon="arrow-down"
</up-form-item> suffix-icon-style="color: #b6b6b6;" border="none" v-model="county_name" readonly
</view> style="pointer-events: none;"></up-input>
</up-form-item>
<up-form-item label="土地详细地址" prop="town_code" borderBottom required @click="location">
<up-input input-align="right" placeholder="请输入土地详细地址" suffixIcon="map"
suffix-icon-style="color: #b6b6b6;" border="none" v-model="data.formData.address">
</up-input>
</up-form-item>
</view>
<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>
</view> </view>
</view> </view>
<view class="code-img"> <view class="code-img">
<view class="" @click="updateImgFn"> <view class="" @click="updateImgFn">
<view class="carime-icon"> <view class="carime-icon">
<u-image src="/static/img/DJSC.png" width="91.12rpx" height="91.12rpx"></u-image> <u-image src="/static/img/DJSC.png" width="91.12rpx" height="91.12rpx"></u-image>
<view class=""> <view class="">
点击上传图片 点击上传图片
</view> </view>
</view> </view>
</view> </view>
</view> </view>
</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="columns" title="请选择"
@ -354,32 +361,34 @@
} }
const location = () => { const location = () => {
//#ifdef APP console.log(99)
uni.showLoading({ // uni.showLoading({
title: '获取位置中' // title: ''
}) // })
uni.getLocation({ uni.getLocation({
type: 'gcj02', type: 'gcj02',
geocode: true, geocode: true,
isHighAccuracy: true, isHighAccuracy: true,
success: async (res) => { success: async (res) => {
// console.log(res)
data.formData.address = res.address.city + res.address.district + res.address.street + res
.address.streetNum + res.address.poiName
uni.hideLoading(); console.log(545)
console.log(res)
// data.formData.address = res.address.city + res.address.district + res.address.street + res
// .address.streetNum + res.address.poiName
// uni.hideLoading();
}, },
fail: (err) => { fail: (err) => {
uni.hideLoading(); // uni.hideLoading();
console.log(err) console.log(err)
console.log("erer")
} }
}); });
//#endif
//#ifdef H5
uni.$u.toast('暂不支持')
//#endif
} }
@ -434,54 +443,60 @@
</script> </script>
<style lang="scss"> <style lang="scss">
page{ page {
background-color: #f7fffc; background-color: #f7fffc;
} }
.card{ .card {
background-color: #f7fffc; background-color: #f7fffc;
padding: 0; padding: 0;
padding-bottom: 80rpx; padding-bottom: 80rpx;
.c-title{
font-weight: bold; .c-title {
display: flex; font-weight: bold;
align-items: center; display: flex;
padding: 30rpx; align-items: center;
padding-bottom: 15rpx; padding: 30rpx;
&:before{ padding-bottom: 15rpx;
content: '';
display: inline-block; &:before {
height: 0.8rem; content: '';
width: 6rpx; display: inline-block;
margin-top: 0.2rem; height: 0.8rem;
margin-right: 10rpx; width: 6rpx;
background-color: #35d190; margin-top: 0.2rem;
border-radius: 6rpx; margin-right: 10rpx;
} background-color: #35d190;
} border-radius: 6rpx;
.c-box{ }
background-color: #fff; }
padding-left: 30rpx;
padding-right: 20rpx; .c-box {
padding-bottom: 20rpx; background-color: #fff;
box-shadow: 0px 2px 8px rgba(0, 0, 0, 0.1); padding-left: 30rpx;
} padding-right: 20rpx;
.c-box-p{ padding-bottom: 20rpx;
padding: 20rpx; box-shadow: 0px 2px 8px rgba(0, 0, 0, 0.1);
} }
.btn{
margin: 20rpx auto; .c-box-p {
width: 694rpx; padding: 20rpx;
height: 80rpx; }
border-radius: 80rpx;
background-color: #4ad69b; .btn {
color: #fff; margin: 20rpx auto;
} width: 694rpx;
} height: 80rpx;
border-radius: 80rpx;
background-color: #4ad69b;
color: #fff;
}
}
.card-li-tit { .card-li-tit {
position: relative; position: relative;
span { span {
position: absolute; position: absolute;
left: -9px; left: -9px;
@ -490,9 +505,10 @@
font-size: 20px; font-size: 20px;
top: 3px; top: 3px;
} }
margin-bottom: 20rpx; margin-bottom: 20rpx;
} }
.confim-btn { .confim-btn {
margin: 0 auto; margin: 0 auto;
width: 196.26rpx; width: 196.26rpx;

View File

@ -3,103 +3,104 @@
<view class="content"> <view class="content">
<view class="card"> <view class="card">
<u--form labelWidth='130' :model="formData" :rules="rules" ref="form"> <u--form labelWidth='130' :model="formData" :rules="rules" ref="form">
<view class="c-title">除虫信息</view> <view class="c-title">除虫信息</view>
<view class="c-box"> <view class="c-box">
<u-form-item label="除虫剂种类" prop="kind" borderBottom ref='item1' required> <u-form-item label="除虫剂种类" prop="kind" borderBottom ref='item1' required>
<up-input input-align="right" placeholder="请输入除虫剂种类" :disabled="mode=='detail'" border="none" <up-input input-align="right" placeholder="请输入除虫剂种类" :disabled="mode=='detail'" border="none"
v-model="formData.kind"></up-input> v-model="formData.kind"></up-input>
</u-form-item> </u-form-item>
<u-form-item label="除虫剂品牌" prop="breed" borderBottom required> <u-form-item label="除虫剂品牌" prop="breed" borderBottom required>
<up-input input-align="right" placeholder="请输入除虫剂品牌" :disabled="mode=='detail'" border="none" <up-input input-align="right" placeholder="请输入除虫剂品牌" :disabled="mode=='detail'" border="none"
v-model="formData.breed"></up-input> v-model="formData.breed"></up-input>
</u-form-item> </u-form-item>
<u-form-item label="除虫剂用量(升)" prop="dosage" borderBottom required> <u-form-item label="除虫剂用量(升)" prop="dosage" borderBottom required>
<up-input input-align="right" placeholder="请输入除虫剂用量" type='number' border="none" :disabled="mode=='detail'" <up-input input-align="right" placeholder="请输入除虫剂用量" type='number' border="none"
v-model="formData.dosage"></up-input> :disabled="mode=='detail'" v-model="formData.dosage"></up-input>
</u-form-item> </u-form-item>
<u-form-item label="作业面积(亩)" prop="area" borderBottom required> <u-form-item label="作业面积(亩)" prop="area" borderBottom required>
<up-input input-align="right" placeholder="请输入作业面积" :disabled="mode=='detail'" type="number" border="none" <up-input input-align="right" placeholder="请输入作业面积" :disabled="mode=='detail'" type="number"
v-model="formData.area"></up-input> border="none" v-model="formData.area"></up-input>
</u-form-item> </u-form-item>
<u-form-item label="参与人员" prop="user" borderBottom required> <u-form-item label="参与人员" prop="user" borderBottom required>
<up-input input-align="right" placeholder="请输入参与人姓名" :disabled="mode=='detail'" type="txt" border="none" <up-input input-align="right" placeholder="请输入参与人姓名" :disabled="mode=='detail'" type="txt"
v-model="formData.user"></up-input> border="none" v-model="formData.user"></up-input>
</u-form-item> </u-form-item>
<view class="" v-if="mode=='add'"> <view class="" v-if="mode=='add'">
<u-form-item label="开始日期" @click="openDate" prop="start_date" borderBottom required> <u-form-item label="开始日期" @click="openDate" prop="start_date" borderBottom required>
<up-input input-align="right" placeholder="请选择日期" suffixIcon="arrow-down" <up-input input-align="right" placeholder="请选择日期" suffixIcon="arrow-down"
suffix-icon-style="color: #b6b6b6;" readonly border="none" v-model="formData.start_date" suffix-icon-style="color: #b6b6b6;" readonly border="none" v-model="formData.start_date"
style="pointer-events: none;"></up-input> style="pointer-events: none;"></up-input>
</u-form-item> </u-form-item>
<u-form-item label="结束日期" prop="end_date" @click="openDate1" borderBottom required> <u-form-item label="结束日期" prop="end_date" @click="openDate1" borderBottom required>
<up-input input-align="right" placeholder="请选择日期" suffixIcon="arrow-down" <up-input input-align="right" placeholder="请选择日期" suffixIcon="arrow-down"
suffix-icon-style="color: #b6b6b6;" readonly border="none" v-model="formData.end_date" suffix-icon-style="color: #b6b6b6;" readonly border="none" v-model="formData.end_date"
style="pointer-events: none;"></up-input> style="pointer-events: none;"></up-input>
</u-form-item> </u-form-item>
</view> </view>
<view class="" v-else> <view class="" v-else>
<u-form-item label="开始日期" prop="start_date" borderBottom required> <u-form-item label="开始日期" prop="start_date" borderBottom required>
<up-input input-align="right" placeholder="请选择日期" suffixIcon="arrow-down" <up-input input-align="right" placeholder="请选择日期" suffixIcon="arrow-down"
suffix-icon-style="color: #b6b6b6;" readonly border="none" v-model="formData.start_date" suffix-icon-style="color: #b6b6b6;" readonly border="none" v-model="formData.start_date"
style="pointer-events: none;"></up-input> style="pointer-events: none;"></up-input>
</u-form-item> </u-form-item>
<u-form-item label="结束日期" prop="end_date" borderBottom required> <u-form-item label="结束日期" prop="end_date" borderBottom required>
<up-input input-align="right" placeholder="请选择日期" suffixIcon="arrow-down" <up-input input-align="right" placeholder="请选择日期" suffixIcon="arrow-down"
suffix-icon-style="color: #b6b6b6;" readonly border="none" v-model="formData.end_date" suffix-icon-style="color: #b6b6b6;" readonly border="none" v-model="formData.end_date"
style="pointer-events: none;"></up-input> style="pointer-events: none;"></up-input>
</u-form-item> </u-form-item>
</view>
</view>
<view class="card-li">
<view class="c-title">除虫图片</view>
<view class="c-box c-box-p">
<view class="code-img1">
<view class="" v-if="pic.length>0"
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="">
<u-icon name="close" size="15" style="margin-left:120.85rpx;" @click="delimg(i)"
v-show="mode=='add'"></u-icon>
<u-image :src="item" width="150.85rpx" height="150.85rpx"
@click="perviewFn(item)"></u-image>
</view>
</view>
</view>
</view>
<view class="code-img" v-if="mode=='add'">
<view class="" @click="updateImgFn">
<view class="carime-icon">
<u-image src="/static/img/DJSC.png" width="91.12rpx" height="91.12rpx"></u-image>
<view class="">
点击上传图片
</view>
</view>
</view>
</view>
</view> </view>
</view> </view>
<view class="card-li">
<view class="c-title">备注信息</view> <view class="c-title">除虫图片</view>
<view class="c-box" style="padding: 0 20rpx;"> <view class="c-box c-box-p">
<u-form-item prop="remark" borderBottom> <view class="code-img1">
<u--textarea v-model="formData.remark" :disabled="mode=='detail'" placeholder="请输入内容"></u--textarea> <view class="" v-if="pic.length>0"
</u-form-item> style="display: flex;flex-direction: row;flex-wrap: wrap;margin-bottom: 30rpx;">
</view> <view class="" v-for="(item,i) in pic" style="margin-right: 30rpx;">
<view class="">
<u-icon name="close" size="15" style="margin-left:120.85rpx;" @click="delimg(i)"
v-show="mode=='add'"></u-icon>
<u-image :src="item" width="150.85rpx" height="150.85rpx"
@click="perviewFn(item)"></u-image>
</view>
</view>
</view>
</view>
<view class="code-img" v-if="mode=='add'">
<view class="" @click="updateImgFn">
<view class="carime-icon">
<u-image src="/static/img/DJSC.png" width="91.12rpx" height="91.12rpx"></u-image>
<view class="">
点击上传图片
</view>
</view>
</view>
</view>
</view>
</view>
<view class="c-title">备注信息</view>
<view class="c-box" style="padding: 0 20rpx;">
<u-form-item prop="remark" borderBottom>
<u--textarea v-model="formData.remark" :disabled="mode=='detail'"
placeholder="请输入内容"></u--textarea>
</u-form-item>
</view>
</u--form> </u--form>
<view> <view>
<!-- <uni-calendar ref="calendar" :showMonth="true" :lunar="true" :insert="false" @confirm="dateConfirmfn" /> <!-- <uni-calendar ref="calendar" :showMonth="true" :lunar="true" :insert="false" @confirm="dateConfirmfn" />
<uni-calendar ref="calendar1" :showMonth="true" :lunar="true" :insert="false" <uni-calendar ref="calendar1" :showMonth="true" :lunar="true" :insert="false"
@confirm="dateConfirmfn1" /> --> @confirm="dateConfirmfn1" /> -->
<u-datetime-picker :show="show1" v-model="value1" mode="datetime" @confirm="dateConfirmfn" <u-datetime-picker :show="show1" :max-date="getNowTime()" v-model="value1" mode="datetime"
:formatter="formatter" @cancel="show1=false"></u-datetime-picker> @confirm="dateConfirmfn" :formatter="formatter" @cancel="show1=false"></u-datetime-picker>
<u-datetime-picker :show="show2" v-model="value1" mode="datetime" @confirm="dateConfirmfn1" <u-datetime-picker :show="show2" :max-date="getNowTime()" v-model="value1" mode="datetime"
:formatter="formatter" @cancel="show2=false"></u-datetime-picker> @confirm="dateConfirmfn1" :formatter="formatter" @cancel="show2=false"></u-datetime-picker>
</view> </view>
<u-button class="btn" v-if="mode=='add'" @click="addFn">完成添加</u-button> <u-button class="btn" v-if="mode=='add'" @click="addFn">完成添加</u-button>
</view> </view>
@ -137,7 +138,7 @@
// calendar.value.open() // calendar.value.open()
show1.value = true show1.value = true
} }
const dataobj = reactive({}) const dataobj = reactive({})
const openDate1 = () => { const openDate1 = () => {
// calendar1.value.open() // calendar1.value.open()
show2.value = true show2.value = true
@ -207,7 +208,7 @@
'area': { 'area': {
type: 'string', type: 'string',
required: true, required: true,
message: '请填写土地面积', message: '请填写作业面积',
trigger: ['blur', 'change'] trigger: ['blur', 'change']
}, },
'user': { 'user': {
@ -384,142 +385,151 @@
getlist() getlist()
}) })
const getNowTime = () => {
const now = new Date();
const timestamp = now.getTime();
// console.log(timestamp)
return timestamp
}
</script> </script>
<style lang='scss' scoped> <style lang='scss' scoped>
page { page {
background-color: #f7fffc; background-color: #f7fffc;
} }
.card { .card {
background-color: #f7fffc; background-color: #f7fffc;
padding: 0; padding: 0;
padding-bottom: 80rpx; padding-bottom: 80rpx;
.c-title { .c-title {
font-weight: bold; font-weight: bold;
display: flex; display: flex;
align-items: center; align-items: center;
padding: 30rpx; padding: 30rpx;
padding-bottom: 15rpx; padding-bottom: 15rpx;
&:before { &:before {
content: ''; content: '';
display: inline-block; display: inline-block;
height: 0.8rem; height: 0.8rem;
width: 6rpx; width: 6rpx;
margin-top: 0.2rem; margin-top: 0.2rem;
margin-right: 10rpx; margin-right: 10rpx;
background-color: #35d190; background-color: #35d190;
border-radius: 6rpx; border-radius: 6rpx;
} }
} }
.c-box { .c-box {
background-color: #fff; background-color: #fff;
padding-left: 30rpx; padding-left: 30rpx;
padding-right: 20rpx; padding-right: 20rpx;
padding-bottom: 20rpx; padding-bottom: 20rpx;
box-shadow: 0px 2px 8px rgba(0, 0, 0, 0.1); box-shadow: 0px 2px 8px rgba(0, 0, 0, 0.1);
} }
.c-box-p { .c-box-p {
padding: 20rpx; padding: 20rpx;
} }
.btn { .btn {
margin: 20rpx auto; margin: 20rpx auto;
width: 694rpx; width: 694rpx;
height: 80rpx; height: 80rpx;
border-radius: 80rpx; border-radius: 80rpx;
background-color: #4ad69b; background-color: #4ad69b;
color: #fff; color: #fff;
} }
} }
.tit { .tit {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
} }
.card-li { .card-li {
position: relative; position: relative;
margin-bottom: 0; margin-bottom: 0;
span { span {
position: absolute; position: absolute;
left: -9px; left: -9px;
color: #f56c6c; color: #f56c6c;
line-height: 20px; line-height: 20px;
font-size: 20px; font-size: 20px;
top: 3px; top: 3px;
} }
} }
.confim-btn { .confim-btn {
margin: 0 auto; margin: 0 auto;
width: 196.26rpx; width: 196.26rpx;
height: 66.59rpx; height: 66.59rpx;
/* border: ; */ /* border: ; */
border: #00A15E 1px solid; border: #00A15E 1px solid;
color: #00A15E; color: #00A15E;
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
border-radius: 42.06rpx 42.06rpx 42.06rpx 42.06rpx; border-radius: 42.06rpx 42.06rpx 42.06rpx 42.06rpx;
} }
.up-img { .up-img {
width: 341.71rpx width: 341.71rpx
} }
.today-btn { .today-btn {
width: 588.79rpx; width: 588.79rpx;
background-color: #00A15E; background-color: #00A15E;
color: white; color: white;
position: fixed; position: fixed;
bottom: 40rpx; bottom: 40rpx;
/* transform: ; */ /* transform: ; */
left: 50%; left: 50%;
transform: translateX(-50%); transform: translateX(-50%);
background: linear-gradient(to right, #00A15E, #4CC593); background: linear-gradient(to right, #00A15E, #4CC593);
/* margin: 0 auto; */ /* margin: 0 auto; */
} }
.code-img { .code-img {
background-color: #F4F4F4; background-color: #F4F4F4;
height: 350.47rpx; height: 350.47rpx;
position: relative; position: relative;
/* margin-bottom: 100rpx; */ /* margin-bottom: 100rpx; */
.carime-icon { .carime-icon {
position: absolute; position: absolute;
top: 50%; top: 50%;
left: 50%; left: 50%;
transform: translate(-50%, -50%); transform: translate(-50%, -50%);
display: flex; display: flex;
flex-direction: column; flex-direction: column;
align-items: center; align-items: center;
} }
} }
.confirm { .confirm {
position: fixed; position: fixed;
height: 84.11rpx; height: 84.11rpx;
display: flex; display: flex;
bottom: 30rpx; bottom: 30rpx;
width: 750rpx; width: 750rpx;
.confirm-btn { .confirm-btn {
width: 315.42rpx; width: 315.42rpx;
height: 84.11rpx; height: 84.11rpx;
border: #00A15E 1px solid; border: #00A15E 1px solid;
margin: 0 auto; margin: 0 auto;
border-radius: 80rpx; border-radius: 80rpx;
text-align: center; text-align: center;
line-height: 84rpx; line-height: 84rpx;
} }
} }
</style> </style>

View File

@ -1,530 +1,546 @@
<template> <template>
<!-- 播种 --> <!-- 播种 -->
<view class="content"> <view class="content">
<view class="card"> <view class="card">
<u--form labelWidth='100' :model="formData" :rules="rules" ref="form"> <u--form labelWidth='100' :model="formData" :rules="rules" ref="form">
<view class="c-title">施肥信息</view> <view class="c-title">施肥信息</view>
<view class="c-box"> <view class="c-box">
<u-form-item label="肥料种类" prop="kind" borderBottom ref='item1' required> <u-form-item label="肥料种类" prop="kind" borderBottom ref='item1' required>
<up-input input-align="right" placeholder="请输入肥料种类" :disabled="mode=='detail'" border="none" <up-input input-align="right" placeholder="请输入肥料种类" :disabled="mode=='detail'" border="none"
v-model="formData.kind"></up-input> v-model="formData.kind"></up-input>
</u-form-item> </u-form-item>
<u-form-item label="肥料品牌" prop="breed" borderBottom required> <u-form-item label="肥料品牌" prop="breed" borderBottom required>
<up-input input-align="right" placeholder="请输入肥料品牌" :disabled="mode=='detail'" border="none" <up-input input-align="right" placeholder="请输入肥料品牌" :disabled="mode=='detail'" border="none"
v-model="formData.breed"></up-input> v-model="formData.breed"></up-input>
</u-form-item> </u-form-item>
<u-form-item label="肥料用量(斤)" prop="dosage" borderBottom required> <u-form-item label="肥料用量(斤)" prop="dosage" borderBottom required>
<up-input input-align="right" placeholder="请输入肥料用量" border="none" type='number' :disabled="mode=='detail'" <up-input input-align="right" placeholder="请输入肥料用量" border="none" type='number'
v-model="formData.dosage"></up-input> :disabled="mode=='detail'" v-model="formData.dosage"></up-input>
</u-form-item> </u-form-item>
<u-form-item label="作业面积(亩)" prop="area" borderBottom required> <u-form-item label="作业面积(亩)" prop="area" borderBottom required>
<up-input input-align="right" placeholder="请输入作业面积" :disabled="mode=='detail'" type="number" border="none" <up-input input-align="right" placeholder="请输入作业面积" :disabled="mode=='detail'" type="number"
v-model="formData.area"></up-input> border="none" v-model="formData.area"></up-input>
</u-form-item> </u-form-item>
<u-form-item label="参与人员" prop="user" borderBottom required> <u-form-item label="参与人员" prop="user" borderBottom required>
<up-input input-align="right" placeholder="请输入参与人姓名" :disabled="mode=='detail'" type="txt" border="none" <up-input input-align="right" placeholder="请输入参与人姓名" :disabled="mode=='detail'" type="txt"
v-model="formData.user"></up-input> border="none" v-model="formData.user"></up-input>
</u-form-item><view class="" v-if="mode=='add'"> </u-form-item>
<u-form-item label="开始日期" @click="openDate" prop="start_date" borderBottom required> <view class="" v-if="mode=='add'">
<up-input input-align="right" placeholder="请选择日期" suffixIcon="arrow-down" suffix-icon-style="color: #b6b6b6;" readonly border="none" v-model="formData.start_date" <u-form-item label="开始日期" @click="openDate" prop="start_date" borderBottom required>
style="pointer-events: none;"></up-input> <up-input input-align="right" placeholder="请选择日期" suffixIcon="arrow-down"
</u-form-item> suffix-icon-style="color: #b6b6b6;" readonly border="none" v-model="formData.start_date"
<u-form-item label="结束日期" prop="end_date" @click="openDate1" borderBottom required> style="pointer-events: none;"></up-input>
<up-input input-align="right" placeholder="请选择日期" suffixIcon="arrow-down" suffix-icon-style="color: #b6b6b6;" readonly border="none" v-model="formData.end_date" </u-form-item>
style="pointer-events: none;"></up-input> <u-form-item label="结束日期" prop="end_date" @click="openDate1" borderBottom required>
</u-form-item> <up-input input-align="right" placeholder="请选择日期" suffixIcon="arrow-down"
</view> suffix-icon-style="color: #b6b6b6;" readonly border="none" v-model="formData.end_date"
<view class="" v-else> style="pointer-events: none;"></up-input>
<u-form-item label="开始日期" prop="start_date" borderBottom required> </u-form-item>
<up-input input-align="right" placeholder="请选择日期" suffixIcon="arrow-down" suffix-icon-style="color: #b6b6b6;" readonly border="none" v-model="formData.start_date" </view>
style="pointer-events: none;"></up-input> <view class="" v-else>
</u-form-item> <u-form-item label="开始日期" prop="start_date" borderBottom required>
<u-form-item label="结束日期" prop="end_date" borderBottom required> <up-input input-align="right" placeholder="请选择日期" suffixIcon="arrow-down"
<up-input input-align="right" placeholder="请选择日期" suffixIcon="arrow-down" suffix-icon-style="color: #b6b6b6;" readonly border="none" v-model="formData.end_date" suffix-icon-style="color: #b6b6b6;" readonly border="none" v-model="formData.start_date"
style="pointer-events: none;"></up-input> style="pointer-events: none;"></up-input>
</u-form-item> </u-form-item>
</view> <u-form-item label="结束日期" prop="end_date" borderBottom required>
</view> <up-input input-align="right" placeholder="请选择日期" suffixIcon="arrow-down"
<view class="card-li"> suffix-icon-style="color: #b6b6b6;" readonly border="none" v-model="formData.end_date"
<view class="c-title">施肥图片</view> style="pointer-events: none;"></up-input>
<view class="c-box c-box-p"> </u-form-item>
<view class="code-img1"> </view>
<view class="" v-if="pic.length>0" </view>
style="display: flex;flex-direction: row;flex-wrap: wrap;margin-bottom: 30rpx;"> <view class="card-li">
<view class="c-title">施肥图片</view>
<view class="c-box c-box-p">
<view class="code-img1">
<view class="" v-if="pic.length>0"
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;" @click="delimg(i)" <u-icon name="close" size="15" style="margin-left:120.85rpx;" @click="delimg(i)"
v-show="mode=='add'"></u-icon> v-show="mode=='add'"></u-icon>
<u-image :src="item" width="150.85rpx" height="150.85rpx" @click="perviewFn(item)"></u-image> <u-image :src="item" width="150.85rpx" height="150.85rpx"
</view> @click="perviewFn(item)"></u-image>
</view> </view>
</view> </view>
</view>
</view> </view>
<view class="code-img" v-if="mode=='add'"> <view class="code-img" v-if="mode=='add'">
<view class="" @click="updateImgFn"> <view class="" @click="updateImgFn">
<view class="carime-icon"> <view class="carime-icon">
<u-image src="/static/img/DJSC.png" width="91.12rpx" height="91.12rpx"></u-image> <u-image src="/static/img/DJSC.png" width="91.12rpx" height="91.12rpx"></u-image>
<view class=""> <view class="">
点击上传图片 点击上传图片
</view> </view>
</view> </view>
</view> </view>
</view> </view>
</view> </view>
</view> </view>
<view class="c-title">备注信息</view> <view class="c-title">备注信息</view>
<view class="c-box" style="padding: 0 20rpx;"> <view class="c-box" style="padding: 0 20rpx;">
<u-form-item prop="remark" borderBottom> <u-form-item prop="remark" borderBottom>
<u--textarea v-model="formData.remark" :disabled="mode=='detail'" placeholder="请输入内容"></u--textarea> <u--textarea v-model="formData.remark" :disabled="mode=='detail'"
</u-form-item> placeholder="请输入内容"></u--textarea>
</view> </u-form-item>
</view>
</u--form> </u--form>
<view> <view>
<!-- <uni-calendar ref="calendar" :showMonth="true" :lunar="true" :insert="false" @confirm="dateConfirmfn" /> <!-- <uni-calendar ref="calendar" :showMonth="true" :lunar="true" :insert="false" @confirm="dateConfirmfn" />
<uni-calendar ref="calendar1" :showMonth="true" :lunar="true" :insert="false" <uni-calendar ref="calendar1" :showMonth="true" :lunar="true" :insert="false"
@confirm="dateConfirmfn1" /> --> @confirm="dateConfirmfn1" /> -->
<u-datetime-picker :show="show1" v-model="value1" mode="datetime" @confirm="dateConfirmfn" <u-datetime-picker :show="show1" :max-date="getNowTime()" v-model="value1" mode="datetime"
:formatter="formatter" @cancel="show1=false"></u-datetime-picker> @confirm="dateConfirmfn" :formatter="formatter" @cancel="show1=false"></u-datetime-picker>
<u-datetime-picker :show="show2" v-model="value1" mode="datetime" @confirm="dateConfirmfn1" <u-datetime-picker :show="show2" :max-date="getNowTime()" v-model="value1" mode="datetime"
:formatter="formatter" @cancel="show2=false"></u-datetime-picker> @confirm="dateConfirmfn1" :formatter="formatter" @cancel="show2=false"></u-datetime-picker>
</view> </view>
<u-button class="btn" v-if="mode=='add'" @click="addFn">完成添加</u-button> <u-button class="btn" v-if="mode=='add'" @click="addFn">完成添加</u-button>
</view> </view>
</view> </view>
</template> </template>
<script setup> <script setup>
import { import {
Uploads Uploads
} from "@/api/upload.js" } from "@/api/upload.js"
import { import {
reactive, reactive,
ref ref
} from "vue"; } from "vue";
import { import {
onLoad, onLoad,
onReady onReady
} from '@dcloudio/uni-app'; } from '@dcloudio/uni-app';
import { import {
addaction, addaction,
plantdetail plantdetail
} from '@/api/api.js' } from '@/api/api.js'
const pic = reactive([]); const pic = reactive([]);
const calendar = ref(null) const calendar = ref(null)
const calendar1 = ref(null) const calendar1 = ref(null)
const form = ref(null) const form = ref(null)
const task_id = ref(''); const task_id = ref('');
const value1 = ref(Date.now()); const value1 = ref(Date.now());
const show1 = ref(false); const show1 = ref(false);
const show2 = ref(false); const show2 = ref(false);
const dataobj = reactive({}); const dataobj = reactive({});
const openDate = () => { const openDate = () => {
// calendar.value.open() // calendar.value.open()
show1.value = true show1.value = true
} }
const openDate1 = () => { const openDate1 = () => {
// calendar1.value.open() // calendar1.value.open()
show2.value = true show2.value = true
} }
// console.log() // console.log()
const formData = reactive({ const formData = reactive({
kind: "", kind: "",
breed: "", breed: "",
dosage: "", dosage: "",
start_date: "", start_date: "",
dosage: "", dosage: "",
end_date: "", end_date: "",
}) })
const dateConfirmfn = (e) => { const dateConfirmfn = (e) => {
formData.start_date = uni.$u.timeFormat(e.value, 'yyyy-mm-dd hh:MM ') formData.start_date = uni.$u.timeFormat(e.value, 'yyyy-mm-dd hh:MM ')
show1.value = false show1.value = false
} }
const dateConfirmfn1 = (e) => { const dateConfirmfn1 = (e) => {
formData.end_date = uni.$u.timeFormat(e.value, 'yyyy-mm-dd hh:MM ') formData.end_date = uni.$u.timeFormat(e.value, 'yyyy-mm-dd hh:MM ')
show2.value = false show2.value = false
} }
const rules = ref({ const rules = ref({
'kind': { 'kind': {
type: 'string', type: 'string',
required: true, required: true,
message: '请填写肥料种类', message: '请填写肥料种类',
trigger: ['blur', 'change'] trigger: ['blur', 'change']
}, },
'breed': { 'breed': {
type: 'string', type: 'string',
required: true, required: true,
message: '请填写肥料品牌', message: '请填写肥料品牌',
trigger: ['blur', 'change'] trigger: ['blur', 'change']
}, },
'dosage': { 'dosage': {
type: 'string', type: 'string',
required: true, required: true,
message: '请填写肥料用量', message: '请填写肥料用量',
trigger: ['blur', 'change'] trigger: ['blur', 'change']
}, },
'start_date': { 'start_date': {
type: 'string', type: 'string',
required: true, required: true,
message: '请填写开始日期', message: '请填写开始日期',
trigger: ['blur', 'change'] trigger: ['blur', 'change']
}, },
'end_date': { 'end_date': {
type: 'string', type: 'string',
required: true, required: true,
message: '请填写结束日期', message: '请填写结束日期',
trigger: ['blur', 'change'] trigger: ['blur', 'change']
}, },
'area': { 'area': {
type: 'string', type: 'string',
required: true, required: true,
message: '请填写土地面积', message: '请填写作业面积',
trigger: ['blur', 'change'] trigger: ['blur', 'change']
}, },
'user': { 'user': {
type: 'string', type: 'string',
required: true, required: true,
message: '请填写参与人', message: '请填写参与人',
trigger: ['blur', 'change'] trigger: ['blur', 'change']
} }
// , // ,
// 'remark': { // 'remark': {
// type: 'string', // type: 'string',
// required: true, // required: true,
// message: '', // message: '',
// trigger: ['blur', 'change'] // trigger: ['blur', 'change']
// }, // },
}) })
onReady(() => { onReady(() => {
form.value.setRules(rules); form.value.setRules(rules);
}); });
const formatter = (type, value) => { const formatter = (type, value) => {
if (type === 'year') { if (type === 'year') {
return `${value}`; return `${value}`;
} }
if (type === 'month') { if (type === 'month') {
return `${value}`; return `${value}`;
} }
if (type === 'day') { if (type === 'day') {
return `${value}`; return `${value}`;
} }
return value; return value;
}; };
// //
const updateImgFn = async () => { const updateImgFn = async () => {
uni.chooseImage({ uni.chooseImage({
count: 1, count: 1,
sizeType: ['original', 'compressed'], sizeType: ['original', 'compressed'],
sourceType: ['album', 'camera'], sourceType: ['album', 'camera'],
success: (res) => { success: (res) => {
Uploads(res.tempFilePaths[0], 'img').then(res => { Uploads(res.tempFilePaths[0], 'img').then(res => {
console.log(res) console.log(res)
if (res.code == 1) { if (res.code == 1) {
pic.push(res.data.url) pic.push(res.data.url)
console.log(pic) console.log(pic)
uni.$u.toast('上传成功') uni.$u.toast('上传成功')
} }
}).catch(err => { }).catch(err => {
//console.log('err', err); //console.log('err', err);
// uni.$u.toast('') // uni.$u.toast('')
}) })
}, },
fail: function(err) { fail: function(err) {
//console.log('choose'); //console.log('choose');
uni.$u.toast('添加失败') uni.$u.toast('添加失败')
} }
}); });
// let res = await Uploads() // let res = await Uploads()
// data.formData.pic = res.data.image // data.formData.pic = res.data.image
} }
const navgo = (url) => { const navgo = (url) => {
uni.navigateTo({ uni.navigateTo({
url url
}) })
} }
const addFn = () => { const addFn = () => {
form.value.validate().then(res => { form.value.validate().then(res => {
// console.log(res) // console.log(res)
if (res) { if (res) {
if (formData.area > dataobj.area) { if (formData.area > dataobj.area) {
uni.$u.toast('作业面积不能超过种植面积') uni.$u.toast('作业面积不能超过种植面积')
return return
} }
formData.pic = pic formData.pic = pic
let data1 = { let data1 = {
plant_id: task_id.value, plant_id: task_id.value,
type: 1, type: 1,
detail: JSON.stringify(formData) detail: JSON.stringify(formData)
}; };
if (formData.pic.length == 0) { if (formData.pic.length == 0) {
uni.$u.toast('请上传图片') uni.$u.toast('请上传图片')
return return
} }
let endTime = new Date(formData.end_date) let endTime = new Date(formData.end_date)
let startTime = new Date(formData.start_date) let startTime = new Date(formData.start_date)
let plantTime = new Date(dataobj.plant_date) let plantTime = new Date(dataobj.plant_date)
console.log(startTime < plantTime, endTime < plantTime) console.log(startTime < plantTime, endTime < plantTime)
if (startTime < plantTime) { if (startTime < plantTime) {
uni.$u.toast("施肥时间必须超过种植的时间"); uni.$u.toast("施肥时间必须超过种植的时间");
return return
} }
if (endTime < plantTime) { if (endTime < plantTime) {
uni.$u.toast("施肥时间必须超过种植的时间"); uni.$u.toast("施肥时间必须超过种植的时间");
return return
} }
if (endTime < startTime) { if (endTime < startTime) {
uni.$u.toast("结束时间不能小于开始时间"); uni.$u.toast("结束时间不能小于开始时间");
return return
} else if (startTime > endTime) { } else if (startTime > endTime) {
uni.$u.toast("开始时间不能大于结束时间"); uni.$u.toast("开始时间不能大于结束时间");
return return
} else { } else {
console.log("开始时间和结束时间合法"); console.log("开始时间和结束时间合法");
} }
console.log('表单通过'); console.log('表单通过');
// //
addaction(data1).then((res) => { addaction(data1).then((res) => {
// console.log(res) // console.log(res)
if (res.code == 1) { if (res.code == 1) {
uni.$u.toast(res.msg) uni.$u.toast(res.msg)
uni.navigateBack({ uni.navigateBack({
delta: 1 delta: 1
}) })
} }
}) })
// uni.$u.toast('') // uni.$u.toast('')
} }
}).catch((err) => { }).catch((err) => {
console.log(err) console.log(err)
}) })
} }
// //
const perviewFn = (url) => { const perviewFn = (url) => {
uni.previewImage({ uni.previewImage({
urls: [url] urls: [url]
}) })
} }
// //
const delimg = (i) => { const delimg = (i) => {
pic.splice(i, 1); pic.splice(i, 1);
} }
const getlist = () => { const getlist = () => {
plantdetail({ plantdetail({
plant_id: task_id.value plant_id: task_id.value
}).then((res) => { }).then((res) => {
if (res.code == 1) { if (res.code == 1) {
// console.log(res) // console.log(res)
Object.assign(dataobj, res.data) Object.assign(dataobj, res.data)
} }
}); });
}; };
const mode = ref('add') const mode = ref('add')
onLoad((options) => { onLoad((options) => {
if (options.task) { if (options.task) {
let data = options.task ? JSON.parse(decodeURIComponent(options.task)) : null; let data = options.task ? JSON.parse(decodeURIComponent(options.task)) : null;
// console.log(data, data.detail) // console.log(data, data.detail)
Object.assign(formData, data.detail); Object.assign(formData, data.detail);
pic.splice(0, pic.length, ...data.detail.pic); pic.splice(0, pic.length, ...data.detail.pic);
mode.value = 'detail' mode.value = 'detail'
uni.setNavigationBarTitle({ uni.setNavigationBarTitle({
title: '施肥详情' title: '施肥详情'
}) })
// formData=data.detail // formData=data.detail
} else { } else {
task_id.value = options.id task_id.value = options.id
} }
getlist() getlist()
}) })
const getNowTime = () => {
const now = new Date();
const timestamp = now.getTime();
// console.log(timestamp)
return timestamp
}
</script> </script>
<style lang='scss' scoped> <style lang='scss' scoped>
page { page {
background-color: #f7fffc; background-color: #f7fffc;
} }
.card { .card {
background-color: #f7fffc; background-color: #f7fffc;
padding: 0; padding: 0;
padding-bottom: 80rpx; padding-bottom: 80rpx;
.c-title { .c-title {
font-weight: bold; font-weight: bold;
display: flex; display: flex;
align-items: center; align-items: center;
padding: 30rpx; padding: 30rpx;
padding-bottom: 15rpx; padding-bottom: 15rpx;
&:before { &:before {
content: ''; content: '';
display: inline-block; display: inline-block;
height: 0.8rem; height: 0.8rem;
width: 6rpx; width: 6rpx;
margin-top: 0.2rem; margin-top: 0.2rem;
margin-right: 10rpx; margin-right: 10rpx;
background-color: #35d190; background-color: #35d190;
border-radius: 6rpx; border-radius: 6rpx;
} }
} }
.c-box { .c-box {
background-color: #fff; background-color: #fff;
padding-left: 30rpx; padding-left: 30rpx;
padding-right: 20rpx; padding-right: 20rpx;
padding-bottom: 20rpx; padding-bottom: 20rpx;
box-shadow: 0px 2px 8px rgba(0, 0, 0, 0.1); box-shadow: 0px 2px 8px rgba(0, 0, 0, 0.1);
} }
.c-box-p { .c-box-p {
padding: 20rpx; padding: 20rpx;
} }
.btn { .btn {
margin: 20rpx auto; margin: 20rpx auto;
width: 694rpx; width: 694rpx;
height: 80rpx; height: 80rpx;
border-radius: 80rpx; border-radius: 80rpx;
background-color: #4ad69b; background-color: #4ad69b;
color: #fff; color: #fff;
} }
} }
.tit { .tit {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
} }
.card-li { .card-li {
position: relative; position: relative;
margin-bottom: 0; margin-bottom: 0;
span { span {
position: absolute; position: absolute;
left: -9px; left: -9px;
color: #f56c6c; color: #f56c6c;
line-height: 20px; line-height: 20px;
font-size: 20px; font-size: 20px;
top: 3px; top: 3px;
} }
} }
.confim-btn { .confim-btn {
margin: 0 auto; margin: 0 auto;
width: 196.26rpx; width: 196.26rpx;
height: 66.59rpx; height: 66.59rpx;
/* border: ; */ /* border: ; */
border: #00A15E 1px solid; border: #00A15E 1px solid;
color: #00A15E; color: #00A15E;
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
border-radius: 42.06rpx 42.06rpx 42.06rpx 42.06rpx; border-radius: 42.06rpx 42.06rpx 42.06rpx 42.06rpx;
} }
.up-img { .up-img {
width: 341.71rpx width: 341.71rpx
} }
.today-btn { .today-btn {
width: 588.79rpx; width: 588.79rpx;
background-color: #00A15E; background-color: #00A15E;
color: white; color: white;
position: fixed; position: fixed;
bottom: 40rpx; bottom: 40rpx;
/* transform: ; */ /* transform: ; */
left: 50%; left: 50%;
transform: translateX(-50%); transform: translateX(-50%);
background: linear-gradient(to right, #00A15E, #4CC593); background: linear-gradient(to right, #00A15E, #4CC593);
/* margin: 0 auto; */ /* margin: 0 auto; */
} }
.code-img { .code-img {
background-color: #F4F4F4; background-color: #F4F4F4;
height: 350.47rpx; height: 350.47rpx;
position: relative; position: relative;
/* margin-bottom: 100rpx; */ /* margin-bottom: 100rpx; */
.carime-icon { .carime-icon {
position: absolute; position: absolute;
top: 50%; top: 50%;
left: 50%; left: 50%;
transform: translate(-50%, -50%); transform: translate(-50%, -50%);
display: flex; display: flex;
flex-direction: column; flex-direction: column;
align-items: center; align-items: center;
} }
} }
.confirm { .confirm {
position: fixed; position: fixed;
height: 84.11rpx; height: 84.11rpx;
display: flex; display: flex;
bottom: 30rpx; bottom: 30rpx;
width: 750rpx; width: 750rpx;
.confirm-btn { .confirm-btn {
width: 315.42rpx; width: 315.42rpx;
height: 84.11rpx; height: 84.11rpx;
border: #00A15E 1px solid; border: #00A15E 1px solid;
margin: 0 auto; margin: 0 auto;
border-radius: 80rpx; border-radius: 80rpx;
text-align: center; text-align: center;
line-height: 84rpx; line-height: 84rpx;
} }
} }
</style> </style>

View File

@ -4,70 +4,73 @@
<view class="card"> <view class="card">
<u--form labelWidth='100' :model="formData" :rules="rules" ref="form"> <u--form labelWidth='100' :model="formData" :rules="rules" ref="form">
<view class="c-title">收获信息</view> <view class="c-title">收获信息</view>
<view class="c-box"> <view class="c-box">
<!-- <u-form-item label="作业地块" prop="formData.breed" borderBottom required> <!-- <u-form-item label="作业地块" prop="formData.breed" borderBottom required>
<up-input input-align="right" placeholder="请输入作业地块" :disabled="mode=='detail'" border="none" <up-input input-align="right" placeholder="请输入作业地块" :disabled="mode=='detail'" border="none"
v-model="formData.breed"></up-input> v-model="formData.breed"></up-input>
</u-form-item> --> </u-form-item> -->
<u-form-item label="参与人员" prop="user" borderBottom required> <u-form-item label="参与人员" prop="user" borderBottom required>
<up-input input-align="right" placeholder="请输入参与人姓名" :disabled="mode=='detail'" type="txt" border="none" <up-input input-align="right" placeholder="请输入参与人姓名" :disabled="mode=='detail'" type="txt"
v-model="formData.user"></up-input> border="none" v-model="formData.user"></up-input>
</u-form-item> </u-form-item>
<u-form-item label="作业面积" prop="formData.breed" borderBottom required> <u-form-item label="作业面积" prop="formData.breed" borderBottom required>
<up-input input-align="right" placeholder="请输入作业面积" :disabled="mode=='detail'" type="number" border="none" <up-input input-align="right" placeholder="请输入作业面积" :disabled="mode=='detail'" type="number"
v-model="formData.breed"></up-input> border="none" v-model="formData.breed"></up-input>
</u-form-item> </u-form-item>
<u-form-item label="收获日期" prop="start_date" borderBottom required> <u-form-item label="收获日期" prop="start_date" @click="openDate" borderBottom required>
<up-input input-align="right" placeholder="请选择日期" suffixIcon="arrow-down" <up-input input-align="right" placeholder="请选择日期" suffixIcon="arrow-down"
suffix-icon-style="color: #b6b6b6;" readonly border="none" v-model="formData.start_date" suffix-icon-style="color: #b6b6b6;" readonly border="none" v-model="formData.start_date"
style="pointer-events: none;"></up-input> style="pointer-events: none;"></up-input>
</u-form-item> </u-form-item>
</view> </view>
<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;" @click="delimg(i)" <u-icon name="close" size="15" style="margin-left:120.85rpx;" @click="delimg(i)"
v-show="mode=='add'"></u-icon> v-show="mode=='add'"></u-icon>
<u-image :src="item" width="150.85rpx" height="150.85rpx" @click="perviewFn(item)"></u-image> <u-image :src="item" width="150.85rpx" height="150.85rpx"
</view> @click="perviewFn(item)"></u-image>
</view> </view>
</view> </view>
</view>
</view>
<view class="code-img" v-if="mode=='add'"> </view>
<view class="" @click="updateImgFn"> <view class="code-img" v-if="mode=='add'">
<view class="carime-icon"> <view class="" @click="updateImgFn">
<u-image src="/static/img/DJSC.png" width="91.12rpx" height="91.12rpx"></u-image> <view class="carime-icon">
<view class=""> <u-image src="/static/img/DJSC.png" width="91.12rpx" height="91.12rpx"></u-image>
点击上传图片 <view class="">
</view> 点击上传图片
</view> </view>
</view>
</view>
</view>
</view>
</view>
</view> </view>
</view> </view>
<view class="c-title">备注信息</view> <view class="c-title">备注信息</view>
<view class="c-box" style="padding: 0 20rpx;"> <view class="c-box" style="padding: 0 20rpx;">
<u-form-item prop="remark" borderBottom> <u-form-item prop="remark" borderBottom>
<u--textarea v-model="formData.remark" :disabled="mode=='detail'" placeholder="请输入内容"></u--textarea> <u--textarea v-model="formData.remark" :disabled="mode=='detail'"
</u-form-item> placeholder="请输入内容"></u--textarea>
</view> </u-form-item>
</view>
</u--form> </u--form>
<u-button class="btn" v-if="mode=='add'" @click="addFn">完成添加</u-button> <u-button class="btn" v-if="mode=='add'" @click="addFn">完成添加</u-button>
</view> </view>
<u-datetime-picker :show="show1" :max-date="getNowTime()" v-model="value1" mode="datetime"
@confirm="dateConfirmfn" :formatter="formatter" @cancel="show1=false"></u-datetime-picker>
</view> </view>
@ -93,15 +96,29 @@
const form = ref(null) const form = ref(null)
const task_id = ref(''); const task_id = ref('');
const pic = reactive([]); const pic = reactive([]);
const show1 = ref(false)
const formData = reactive({ const formData = reactive({
user: "", user: "",
remark: "", remark: "",
pic: [], pic: [],
start_date: '' start_date: ''
}) })
const dateConfirmfn = (e) => { const dateConfirmfn = (e) => {
console.log(e) formData.start_date = uni.$u.timeFormat(e.value, 'yyyy-mm-dd hh:MM ')
show1.value = false
} }
const formatter = (type, value) => {
if (type === 'year') {
return `${value}`;
}
if (type === 'month') {
return `${value}`;
}
if (type === 'day') {
return `${value}`;
}
return value;
};
const rules = { const rules = {
'user': { 'user': {
type: 'string', type: 'string',
@ -125,6 +142,21 @@
url url
}) })
} }
const openDate = () => {
// calendar.value.open()
show1.value = true
// alert(455)
}
const value1 = ref(Date.now());
const getNowTime = () => {
const now = new Date();
const timestamp = now.getTime();
// console.log(timestamp)
return timestamp
}
const addFn = () => { const addFn = () => {
form.value.validate().then(res => { form.value.validate().then(res => {
console.log(res) console.log(res)
@ -161,8 +193,8 @@
// uni.$u.toast('') // uni.$u.toast('')
} }
}).catch((err)=>{ }).catch((err) => {
uni.$u.toast(err[0].message) uni.$u.toast(err[0].message)
console.log(err) console.log(err)
}) })
@ -171,7 +203,7 @@
} }
// //
const perviewFn = (url) => { const perviewFn = (url) => {
uni.previewImage({ uni.previewImage({
urls: [url] urls: [url]
}) })
@ -221,156 +253,156 @@
// console.log(data, data.detail) // console.log(data, data.detail)
Object.assign(formData, data.detail); Object.assign(formData, data.detail);
pic.splice(0, pic.length, ...data.detail.pic); pic.splice(0, pic.length, ...data.detail.pic);
mode.value = 'detail' mode.value = 'detail'
uni.setNavigationBarTitle({ uni.setNavigationBarTitle({
title: '收获详情' title: '收获详情'
}) })
// formData=data.detail // formData=data.detail
} else { } else {
task_id.value = options.id task_id.value = options.id
} }
}) })
</script> </script>
<style lang='scss' scoped> <style lang='scss' scoped>
page { page {
background-color: #f7fffc; background-color: #f7fffc;
} }
.card { .card {
background-color: #f7fffc; background-color: #f7fffc;
padding: 0; padding: 0;
padding-bottom: 80rpx; padding-bottom: 80rpx;
.c-title { .c-title {
font-weight: bold; font-weight: bold;
display: flex; display: flex;
align-items: center; align-items: center;
padding: 30rpx; padding: 30rpx;
padding-bottom: 15rpx; padding-bottom: 15rpx;
&:before { &:before {
content: ''; content: '';
display: inline-block; display: inline-block;
height: 0.8rem; height: 0.8rem;
width: 6rpx; width: 6rpx;
margin-top: 0.2rem; margin-top: 0.2rem;
margin-right: 10rpx; margin-right: 10rpx;
background-color: #35d190; background-color: #35d190;
border-radius: 6rpx; border-radius: 6rpx;
} }
} }
.c-box { .c-box {
background-color: #fff; background-color: #fff;
padding-left: 30rpx; padding-left: 30rpx;
padding-right: 20rpx; padding-right: 20rpx;
padding-bottom: 20rpx; padding-bottom: 20rpx;
box-shadow: 0px 2px 8px rgba(0, 0, 0, 0.1); box-shadow: 0px 2px 8px rgba(0, 0, 0, 0.1);
} }
.c-box-p { .c-box-p {
padding: 20rpx; padding: 20rpx;
} }
.btn { .btn {
margin: 20rpx auto; margin: 20rpx auto;
width: 694rpx; width: 694rpx;
height: 80rpx; height: 80rpx;
border-radius: 80rpx; border-radius: 80rpx;
background-color: #4ad69b; background-color: #4ad69b;
color: #fff; color: #fff;
} }
} }
.tit { .tit {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
} }
.card-li { .card-li {
position: relative; position: relative;
margin-bottom: 0; margin-bottom: 0;
span { span {
position: absolute; position: absolute;
left: -9px; left: -9px;
color: #f56c6c; color: #f56c6c;
line-height: 20px; line-height: 20px;
font-size: 20px; font-size: 20px;
top: 3px; top: 3px;
} }
} }
.confim-btn { .confim-btn {
margin: 0 auto; margin: 0 auto;
width: 196.26rpx; width: 196.26rpx;
height: 66.59rpx; height: 66.59rpx;
/* border: ; */ /* border: ; */
border: #00A15E 1px solid; border: #00A15E 1px solid;
color: #00A15E; color: #00A15E;
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
border-radius: 42.06rpx 42.06rpx 42.06rpx 42.06rpx; border-radius: 42.06rpx 42.06rpx 42.06rpx 42.06rpx;
} }
.up-img { .up-img {
width: 341.71rpx width: 341.71rpx
} }
.today-btn { .today-btn {
width: 588.79rpx; width: 588.79rpx;
background-color: #00A15E; background-color: #00A15E;
color: white; color: white;
position: fixed; position: fixed;
bottom: 40rpx; bottom: 40rpx;
/* transform: ; */ /* transform: ; */
left: 50%; left: 50%;
transform: translateX(-50%); transform: translateX(-50%);
background: linear-gradient(to right, #00A15E, #4CC593); background: linear-gradient(to right, #00A15E, #4CC593);
/* margin: 0 auto; */ /* margin: 0 auto; */
} }
.code-img { .code-img {
background-color: #F4F4F4; background-color: #F4F4F4;
height: 350.47rpx; height: 350.47rpx;
position: relative; position: relative;
/* margin-bottom: 100rpx; */ /* margin-bottom: 100rpx; */
.carime-icon { .carime-icon {
position: absolute; position: absolute;
top: 50%; top: 50%;
left: 50%; left: 50%;
transform: translate(-50%, -50%); transform: translate(-50%, -50%);
display: flex; display: flex;
flex-direction: column; flex-direction: column;
align-items: center; align-items: center;
} }
} }
.confirm { .confirm {
position: fixed; position: fixed;
height: 84.11rpx; height: 84.11rpx;
display: flex; display: flex;
bottom: 30rpx; bottom: 30rpx;
width: 750rpx; width: 750rpx;
.confirm-btn { .confirm-btn {
width: 315.42rpx; width: 315.42rpx;
height: 84.11rpx; height: 84.11rpx;
border: #00A15E 1px solid; border: #00A15E 1px solid;
margin: 0 auto; margin: 0 auto;
border-radius: 80rpx; border-radius: 80rpx;
text-align: center; text-align: center;
line-height: 84rpx; line-height: 84rpx;
} }
} }
</style> </style>

View File

@ -1,520 +1,532 @@
<template> <template>
<!-- 灌溉 --> <!-- 灌溉 -->
<view class="content"> <view class="content">
<view class="card"> <view class="card">
<u--form labelWidth='100' :model="formData" :rules="rules" ref="form"> <u--form labelWidth='100' :model="formData" :rules="rules" ref="form">
<view class="c-title">灌溉信息</view> <view class="c-title">灌溉信息</view>
<view class="c-box"> <view class="c-box">
<u-form-item label="灌溉方式" prop="type" borderBottom required @click="showggai"> <u-form-item label="灌溉方式" prop="type" borderBottom required @click="showggai">
<!-- <uni-data-select v-model="formData.type" :disabled="mode=='detail'" <!-- <uni-data-select v-model="formData.type" :disabled="mode=='detail'"
:localdata="range"></uni-data-select> --> :localdata="range"></uni-data-select> -->
<up-input input-align="right" placeholder="请选择灌溉方式" readonly border="none" v-model="formDatatype" <up-input input-align="right" placeholder="请选择灌溉方式" readonly border="none"
style="pointer-events: none;"></up-input> v-model="formDatatype" style="pointer-events: none;"></up-input>
</u-form-item> </u-form-item>
<u-form-item label="灌溉面积(亩)" prop="area" borderBottom required> <u-form-item label="灌溉面积(亩)" prop="area" borderBottom required>
<up-input input-align="right" placeholder="请输入作业面积" :disabled="mode=='detail'" type="number" border="none" <up-input input-align="right" placeholder="请输入作业面积" :disabled="mode=='detail'" type="number"
v-model="formData.area"></up-input> border="none" v-model="formData.area"></up-input>
</u-form-item> </u-form-item>
<u-form-item label="参与人员" prop="user" borderBottom required> <u-form-item label="参与人员" prop="user" borderBottom required>
<up-input input-align="right" placeholder="请输入参与人姓名" :disabled="mode=='detail'" type="txt" border="none" <up-input input-align="right" placeholder="请输入参与人姓名" :disabled="mode=='detail'" type="txt"
v-model="formData.user"></up-input> border="none" v-model="formData.user"></up-input>
</u-form-item> </u-form-item>
<view class="" v-if="mode=='add'"> <view class="" v-if="mode=='add'">
<u-form-item label="开始日期" @click="openDate" prop="start_date" borderBottom required> <u-form-item label="开始日期" @click="openDate" prop="start_date" borderBottom required>
<up-input input-align="right" placeholder="请选择日期" suffixIcon="arrow-down" <up-input input-align="right" placeholder="请选择日期" suffixIcon="arrow-down"
suffix-icon-style="color: #b6b6b6;" readonly border="none" v-model="formData.start_date" suffix-icon-style="color: #b6b6b6;" readonly border="none" v-model="formData.start_date"
style="pointer-events: none;"></up-input> style="pointer-events: none;"></up-input>
</u-form-item> </u-form-item>
<u-form-item label="结束日期" prop="end_date" @click="openDate1" borderBottom required> <u-form-item label="结束日期" prop="end_date" @click="openDate1" borderBottom required>
<up-input input-align="right" placeholder="请选择日期" suffixIcon="arrow-down" <up-input input-align="right" placeholder="请选择日期" suffixIcon="arrow-down"
suffix-icon-style="color: #b6b6b6;" readonly border="none" v-model="formData.end_date" suffix-icon-style="color: #b6b6b6;" readonly border="none" v-model="formData.end_date"
style="pointer-events: none;"></up-input> style="pointer-events: none;"></up-input>
</u-form-item> </u-form-item>
</view> </view>
<view class="" v-else> <view class="" v-else>
<u-form-item label="开始日期" prop="start_date" borderBottom required> <u-form-item label="开始日期" prop="start_date" borderBottom required>
<up-input input-align="right" placeholder="请选择日期" suffixIcon="arrow-down" <up-input input-align="right" placeholder="请选择日期" suffixIcon="arrow-down"
suffix-icon-style="color: #b6b6b6;" readonly border="none" v-model="formData.start_date" suffix-icon-style="color: #b6b6b6;" readonly border="none" v-model="formData.start_date"
style="pointer-events: none;"></up-input> style="pointer-events: none;"></up-input>
</u-form-item> </u-form-item>
<u-form-item label="结束日期" prop="end_date" borderBottom required> <u-form-item label="结束日期" prop="end_date" borderBottom required>
<up-input input-align="right" placeholder="请选择日期" suffixIcon="arrow-down" <up-input input-align="right" placeholder="请选择日期" suffixIcon="arrow-down"
suffix-icon-style="color: #b6b6b6;" readonly border="none" v-model="formData.end_date" suffix-icon-style="color: #b6b6b6;" readonly border="none" v-model="formData.end_date"
style="pointer-events: none;"></up-input> style="pointer-events: none;"></up-input>
</u-form-item> </u-form-item>
</view> </view>
</view> </view>
<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;" @click="delimg(i)" <u-icon name="close" size="15" style="margin-left:120.85rpx;" @click="delimg(i)"
v-show="mode=='add'"></u-icon> v-show="mode=='add'"></u-icon>
<u-image :src="item" width="150.85rpx" height="150.85rpx" @click="perviewFn(item)"></u-image> <u-image :src="item" width="150.85rpx" height="150.85rpx"
</view> @click="perviewFn(item)"></u-image>
</view> </view>
</view> </view>
</view>
</view>
<view class="code-img" v-if="mode=='add'">
<view class="" @click="updateImgFn">
<view class="carime-icon">
<u-image src="/static/img/DJSC.png" width="91.12rpx" height="91.12rpx"></u-image>
<view class="">
点击上传图片
</view>
</view>
</view>
</view>
</view>
</view>
<view class="c-title">备注信息</view>
<view class="c-box" style="padding: 0 20rpx;">
<u-form-item prop="remark" borderBottom>
<u--textarea v-model="formData.remark" :disabled="mode=='detail'" placeholder="请输入内容"></u--textarea>
</u-form-item>
</view>
</u--form> </view>
<view> <view class="code-img" v-if="mode=='add'">
<!-- <uni-calendar ref="calendar" :showMonth="true" :lunar="true" :insert="false" @confirm="dateConfirmfn" /> <view class="" @click="updateImgFn">
<view class="carime-icon">
<u-image src="/static/img/DJSC.png" width="91.12rpx" height="91.12rpx"></u-image>
<view class="">
点击上传图片
</view>
</view>
</view>
</view>
</view>
</view>
<view class="c-title">备注信息</view>
<view class="c-box" style="padding: 0 20rpx;">
<u-form-item prop="remark" borderBottom>
<u--textarea v-model="formData.remark" :disabled="mode=='detail'"
placeholder="请输入内容"></u--textarea>
</u-form-item>
</view>
</u--form>
<view>
<!-- <uni-calendar ref="calendar" :showMonth="true" :lunar="true" :insert="false" @confirm="dateConfirmfn" />
<uni-calendar ref="calendar1" :showMonth="true" :lunar="true" :insert="false" <uni-calendar ref="calendar1" :showMonth="true" :lunar="true" :insert="false"
@confirm="dateConfirmfn1" /> --> @confirm="dateConfirmfn1" /> -->
<u-datetime-picker :show="show1" v-model="value1" mode="datetime" @confirm="dateConfirmfn" <u-datetime-picker :show="show1" v-model="value1" :max-date="getNowTime()" mode="datetime"
:formatter="formatter" @cancel="show1=false"></u-datetime-picker> @confirm="dateConfirmfn" :formatter="formatter" @cancel="show1=false"></u-datetime-picker>
<u-datetime-picker :show="show2" v-model="value1" mode="datetime" @confirm="dateConfirmfn1" <u-datetime-picker :show="show2" :max-date="getNowTime()" v-model="value1" mode="datetime"
:formatter="formatter" @cancel="show2=false"></u-datetime-picker> @confirm="dateConfirmfn1" :formatter="formatter" @cancel="show2=false"></u-datetime-picker>
<u-action-sheet :show="showgg" :actions="range" title="请选择灌溉方式" @close="showgg = false" @select="ggSelect"> <u-action-sheet :show="showgg" :actions="range" title="请选择灌溉方式" @close="showgg = false"
</u-action-sheet> @select="ggSelect">
</view> </u-action-sheet>
<u-button class="btn" v-if="mode=='add'" @click="addFn">完成添加</u-button> </view>
</view> <u-button class="btn" v-if="mode=='add'" @click="addFn">完成添加</u-button>
</view>
</view> </view>
</template> </template>
<script setup> <script setup>
import { import {
Uploads Uploads
} from "@/api/upload.js" } from "@/api/upload.js"
import { import {
reactive, reactive,
ref ref
} from "vue"; } from "vue";
import { import {
onLoad, onLoad,
onReady, onReady,
} from "@dcloudio/uni-app" } from "@dcloudio/uni-app"
import { import {
addaction, addaction,
plantdetail plantdetail
} from '@/api/api.js' } from '@/api/api.js'
const range = reactive([{ const range = reactive([{
value: 1, value: 1,
name: "喷灌" name: "喷灌"
}, },
{ {
value: 2, value: 2,
name: "滴灌" name: "滴灌"
}, },
{ {
value: 3, value: 3,
name: "沟灌" name: "沟灌"
}, },
]) ])
const task_id = ref(''); const task_id = ref('');
const pic = reactive([]); const pic = reactive([]);
const calendar = ref(null) const calendar = ref(null)
const calendar1 = ref(null) const calendar1 = ref(null)
const formDatatype = ref('') const formDatatype = ref('')
const showgg = ref(false) const showgg = ref(false)
const form = ref(null) const form = ref(null)
const value1 = ref(Date.now()); const value1 = ref(Date.now());
const show1 = ref(false); const show1 = ref(false);
const show2 = ref(false); const show2 = ref(false);
const dataobj = reactive({}) const dataobj = reactive({})
const openDate = () => { const openDate = () => {
// calendar.value.open() // calendar.value.open()
show1.value = true show1.value = true
} }
const openDate1 = () => { const openDate1 = () => {
// calendar1.value.open() // calendar1.value.open()
show2.value = true show2.value = true
} }
const formatter = (type, value) => { const formatter = (type, value) => {
if (type === 'year') { if (type === 'year') {
return `${value}`; return `${value}`;
} }
if (type === 'month') { if (type === 'month') {
return `${value}`; return `${value}`;
} }
if (type === 'day') { if (type === 'day') {
return `${value}`; return `${value}`;
} }
return value; return value;
}; };
// console.log() // console.log()
const formData = reactive({ const formData = reactive({
type: "", type: "",
}) })
// //
const ggSelect = (e) => { const ggSelect = (e) => {
formDatatype.value = e.name formDatatype.value = e.name
formData.type = e.value formData.type = e.value
} }
// //
const showggai = () => { const showggai = () => {
showgg.value = true showgg.value = true
} }
// //
const dateConfirmfn = (e) => { const dateConfirmfn = (e) => {
formData.start_date = uni.$u.timeFormat(e.value, 'yyyy-mm-dd hh:MM ') formData.start_date = uni.$u.timeFormat(e.value, 'yyyy-mm-dd hh:MM ')
show1.value = false show1.value = false
} }
const dateConfirmfn1 = (e) => { const dateConfirmfn1 = (e) => {
formData.end_date = uni.$u.timeFormat(e.value, 'yyyy-mm-dd hh:MM ') formData.end_date = uni.$u.timeFormat(e.value, 'yyyy-mm-dd hh:MM ')
show2.value = false show2.value = false
} }
const rules = { const rules = {
'type': { 'type': {
type: 'number', type: 'number',
required: true, required: true,
message: '请选择灌溉方式', message: '请选择灌溉方式',
trigger: ['change'] trigger: ['change']
}, },
'start_date': { 'start_date': {
type: 'string', type: 'string',
required: true, required: true,
message: '请填写开始日期', message: '请填写开始日期',
trigger: ['blur', 'change'] trigger: ['blur', 'change']
}, },
'end_date': { 'end_date': {
type: 'string', type: 'string',
required: true, required: true,
message: '请填写结束日期', message: '请填写结束日期',
trigger: ['blur', 'change'] trigger: ['blur', 'change']
}, },
'area': { 'area': {
type: 'string', type: 'string',
required: true, required: true,
message: '请填写土地面积', message: '请填写土地面积',
trigger: ['blur', 'change'] trigger: ['blur', 'change']
}, },
'user': { 'user': {
type: 'string', type: 'string',
required: true, required: true,
message: '请填写参与人', message: '请填写参与人',
trigger: ['blur', 'change'] trigger: ['blur', 'change']
} }
// , // ,
// 'remark': { // 'remark': {
// type: 'string', // type: 'string',
// required: true, // required: true,
// message: '', // message: '',
// trigger: ['blur', 'change'] // trigger: ['blur', 'change']
// }, // },
} }
onReady(() => { onReady(() => {
form.value.setRules(rules); form.value.setRules(rules);
}); });
const navgo = (url) => { const navgo = (url) => {
uni.navigateTo({ uni.navigateTo({
url url
}) })
} }
const addFn = () => { const addFn = () => {
// console.log(formData) // console.log(formData)
form.value.validate().then(res => { form.value.validate().then(res => {
if (res) { if (res) {
if (formData.area > dataobj.area) { if (formData.area > dataobj.area) {
uni.$u.toast('灌溉面积不能超过种植面积') uni.$u.toast('灌溉面积不能超过种植面积')
return return
} }
formData.pic = pic formData.pic = pic
let data1 = { let data1 = {
plant_id: task_id.value, plant_id: task_id.value,
type: 3, type: 3,
detail: JSON.stringify(formData) detail: JSON.stringify(formData)
}; };
if (formData.pic.length == 0) { if (formData.pic.length == 0) {
uni.$u.toast('请上传图片') uni.$u.toast('请上传图片')
return return
} }
let endTime = new Date(formData.end_date) let endTime = new Date(formData.end_date)
let startTime = new Date(formData.start_date) let startTime = new Date(formData.start_date)
let plantTime = new Date(dataobj.plant_date) let plantTime = new Date(dataobj.plant_date)
if (startTime < plantTime) { if (startTime < plantTime) {
uni.$u.toast("灌溉时间必须超过种植的时间"); uni.$u.toast("灌溉时间必须超过种植的时间");
return return
} }
if (endTime < plantTime) { if (endTime < plantTime) {
uni.$u.toast("灌溉时间必须超过种植的时间"); uni.$u.toast("灌溉时间必须超过种植的时间");
return return
} }
if (endTime < startTime) { if (endTime < startTime) {
uni.$u.toast("结束时间不能小于开始时间"); uni.$u.toast("结束时间不能小于开始时间");
return return
} else if (startTime > endTime) { } else if (startTime > endTime) {
uni.$u.toast("开始时间不能大于结束时间"); uni.$u.toast("开始时间不能大于结束时间");
return return
} else { } else {
console.log("开始时间和结束时间合法"); console.log("开始时间和结束时间合法");
} }
// //
addaction(data1).then((res) => { addaction(data1).then((res) => {
console.log(res) console.log(res)
if (res.code == 1) { if (res.code == 1) {
uni.$u.toast(res.msg) uni.$u.toast(res.msg)
uni.navigateBack({ uni.navigateBack({
delta: 1 delta: 1
}) })
} }
}) })
// uni.$u.toast('') // uni.$u.toast('')
} }
}).catch((err) => { }).catch((err) => {
uni.$u.toast(err[0].message) uni.$u.toast(err[0].message)
console.log(err) console.log(err)
}) })
} }
// //
const perviewFn = (url) => { const perviewFn = (url) => {
console.log(url) console.log(url)
uni.previewImage({ uni.previewImage({
urls: [url] urls: [url]
}) })
} }
// //
const delimg = (i) => { const delimg = (i) => {
pic.splice(i, 1); pic.splice(i, 1);
} }
// //
const updateImgFn = async () => { const updateImgFn = async () => {
uni.chooseImage({ uni.chooseImage({
count: 1, count: 1,
sizeType: ['original', 'compressed'], sizeType: ['original', 'compressed'],
sourceType: ['album', 'camera'], sourceType: ['album', 'camera'],
success: (res) => { success: (res) => {
Uploads(res.tempFilePaths[0], 'img').then(res => { Uploads(res.tempFilePaths[0], 'img').then(res => {
console.log(res) console.log(res)
if (res.code == 1) { if (res.code == 1) {
pic.push(res.data.url) pic.push(res.data.url)
console.log(data.formData) console.log(data.formData)
uni.$u.toast('上传成功') uni.$u.toast('上传成功')
} }
}).catch(err => { }).catch(err => {
//console.log('err', err); //console.log('err', err);
// uni.$u.toast('') // uni.$u.toast('')
}) })
}, },
fail: function(err) { fail: function(err) {
//console.log('choose'); //console.log('choose');
uni.$u.toast('添加失败') uni.$u.toast('添加失败')
} }
}); });
// let res = await Uploads() // let res = await Uploads()
// data.formData.pic = res.data.image // data.formData.pic = res.data.image
} }
const getlist = () => { const getlist = () => {
plantdetail({ plantdetail({
plant_id: task_id.value plant_id: task_id.value
}).then((res) => { }).then((res) => {
if (res.code == 1) { if (res.code == 1) {
// console.log(res) // console.log(res)
Object.assign(dataobj, res.data) Object.assign(dataobj, res.data)
} }
}); });
}; };
const mode = ref('add') const mode = ref('add')
onLoad((options) => { onLoad((options) => {
if (options.task) { if (options.task) {
let data = options.task ? JSON.parse(decodeURIComponent(options.task)) : null; let data = options.task ? JSON.parse(decodeURIComponent(options.task)) : null;
console.log(data, data.detail) console.log(data, data.detail)
Object.assign(formData, data.detail); Object.assign(formData, data.detail);
pic.splice(0, pic.length, ...data.detail.pic); pic.splice(0, pic.length, ...data.detail.pic);
formDatatype.value = range.find(item => item.value === formData.type).name; formDatatype.value = range.find(item => item.value === formData.type).name;
mode.value = 'detail' mode.value = 'detail'
uni.setNavigationBarTitle({ uni.setNavigationBarTitle({
title: '灌溉详情' title: '灌溉详情'
}) })
// formData=data.detail // formData=data.detail
} else { } else {
task_id.value = options.id task_id.value = options.id
} }
getlist() getlist()
}) })
const getNowTime = () => {
const now = new Date();
const timestamp = now.getTime();
// console.log(timestamp)
return timestamp
}
</script> </script>
<style lang='scss' scoped> <style lang='scss' scoped>
page { page {
background-color: #f7fffc; background-color: #f7fffc;
} }
.card { .card {
background-color: #f7fffc; background-color: #f7fffc;
padding: 0; padding: 0;
padding-bottom: 80rpx; padding-bottom: 80rpx;
.c-title { .c-title {
font-weight: bold; font-weight: bold;
display: flex; display: flex;
align-items: center; align-items: center;
padding: 30rpx; padding: 30rpx;
padding-bottom: 15rpx; padding-bottom: 15rpx;
&:before { &:before {
content: ''; content: '';
display: inline-block; display: inline-block;
height: 0.8rem; height: 0.8rem;
width: 6rpx; width: 6rpx;
margin-top: 0.2rem; margin-top: 0.2rem;
margin-right: 10rpx; margin-right: 10rpx;
background-color: #35d190; background-color: #35d190;
border-radius: 6rpx; border-radius: 6rpx;
} }
} }
.c-box { .c-box {
background-color: #fff; background-color: #fff;
padding-left: 30rpx; padding-left: 30rpx;
padding-right: 20rpx; padding-right: 20rpx;
padding-bottom: 20rpx; padding-bottom: 20rpx;
box-shadow: 0px 2px 8px rgba(0, 0, 0, 0.1); box-shadow: 0px 2px 8px rgba(0, 0, 0, 0.1);
} }
.c-box-p { .c-box-p {
padding: 20rpx; padding: 20rpx;
} }
.btn { .btn {
margin: 20rpx auto; margin: 20rpx auto;
width: 694rpx; width: 694rpx;
height: 80rpx; height: 80rpx;
border-radius: 80rpx; border-radius: 80rpx;
background-color: #4ad69b; background-color: #4ad69b;
color: #fff; color: #fff;
} }
} }
.tit { .tit {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
} }
.card-li { .card-li {
position: relative; position: relative;
margin-bottom: 0; margin-bottom: 0;
span { span {
position: absolute; position: absolute;
left: -9px; left: -9px;
color: #f56c6c; color: #f56c6c;
line-height: 20px; line-height: 20px;
font-size: 20px; font-size: 20px;
top: 3px; top: 3px;
} }
} }
.confim-btn { .confim-btn {
margin: 0 auto; margin: 0 auto;
width: 196.26rpx; width: 196.26rpx;
height: 66.59rpx; height: 66.59rpx;
/* border: ; */ /* border: ; */
border: #00A15E 1px solid; border: #00A15E 1px solid;
color: #00A15E; color: #00A15E;
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
border-radius: 42.06rpx 42.06rpx 42.06rpx 42.06rpx; border-radius: 42.06rpx 42.06rpx 42.06rpx 42.06rpx;
} }
.up-img { .up-img {
width: 341.71rpx width: 341.71rpx
} }
.today-btn { .today-btn {
width: 588.79rpx; width: 588.79rpx;
background-color: #00A15E; background-color: #00A15E;
color: white; color: white;
position: fixed; position: fixed;
bottom: 40rpx; bottom: 40rpx;
/* transform: ; */ /* transform: ; */
left: 50%; left: 50%;
transform: translateX(-50%); transform: translateX(-50%);
background: linear-gradient(to right, #00A15E, #4CC593); background: linear-gradient(to right, #00A15E, #4CC593);
/* margin: 0 auto; */ /* margin: 0 auto; */
} }
.code-img { .code-img {
background-color: #F4F4F4; background-color: #F4F4F4;
height: 350.47rpx; height: 350.47rpx;
position: relative; position: relative;
/* margin-bottom: 100rpx; */ /* margin-bottom: 100rpx; */
.carime-icon { .carime-icon {
position: absolute; position: absolute;
top: 50%; top: 50%;
left: 50%; left: 50%;
transform: translate(-50%, -50%); transform: translate(-50%, -50%);
display: flex; display: flex;
flex-direction: column; flex-direction: column;
align-items: center; align-items: center;
} }
} }
.confirm { .confirm {
position: fixed; position: fixed;
height: 84.11rpx; height: 84.11rpx;
display: flex; display: flex;
bottom: 30rpx; bottom: 30rpx;
width: 750rpx; width: 750rpx;
.confirm-btn { .confirm-btn {
width: 315.42rpx; width: 315.42rpx;
height: 84.11rpx; height: 84.11rpx;
border: #00A15E 1px solid; border: #00A15E 1px solid;
margin: 0 auto; margin: 0 auto;
border-radius: 80rpx; border-radius: 80rpx;
text-align: center; text-align: center;
line-height: 84rpx; line-height: 84rpx;
} }
} }
</style> </style>

View File

@ -1,419 +1,438 @@
<template> <template>
<!-- 播种 --> <!-- 播种 -->
<view class="content"> <view class="content">
<view class="card"> <view class="card">
<u-form labelWidth='100' :model="data.formData" ref="form1"> <u-form labelWidth='100' :model="data.formData" ref="form1">
<view class="c-title">种植信息</view> <view class="c-title">种植信息</view>
<view class="c-box"> <view class="c-box">
<u-form-item label="种植种类" prop="kind" borderBottom ref='item1' required> <u-form-item label="种植种类" prop="kind" borderBottom ref='item1' required>
<up-input input-align="right" placeholder="请输入种类" :disabled="mode=='detail'" border="none" <up-input input-align="right" placeholder="请输入种类" :disabled="mode=='detail'" border="none"
v-model="data.formData.kind"></up-input> v-model="data.formData.kind"></up-input>
</u-form-item> </u-form-item>
<u-form-item label="种植品种" prop="breed" borderBottom required> <u-form-item label="种植品种" prop="breed" borderBottom required>
<up-input input-align="right" placeholder="请输入品种" :disabled="mode=='detail'" border="none" <up-input input-align="right" placeholder="请输入品种" :disabled="mode=='detail'" border="none"
v-model="data.formData.breed"></up-input> v-model="data.formData.breed"></up-input>
</u-form-item> </u-form-item>
<u-form-item label="种植面积(亩)" prop="area" borderBottom required> <u-form-item label="种植面积(亩)" prop="area" borderBottom required>
<up-input input-align="right" placeholder="请输入种植面积" :disabled="mode=='detail'" type="number" border="none" <up-input input-align="right" placeholder="请输入种植面积" :disabled="mode=='detail'" type="number"
v-model="data.formData.area"></up-input> border="none" v-model="data.formData.area"></up-input>
</u-form-item> </u-form-item>
<u-form-item label="参与人员" prop="user" borderBottom required> <u-form-item label="参与人员" prop="user" borderBottom required>
<up-input input-align="right" placeholder="请输入参与人姓名" :disabled="mode=='detail'" type="txt" border="none" <up-input input-align="right" placeholder="请输入参与人姓名" :disabled="mode=='detail'" type="txt"
v-model="data.formData.user"></up-input> border="none" v-model="data.formData.user"></up-input>
</u-form-item> </u-form-item>
<u-form-item label="种植开始日期" prop="date" borderBottom required @click="openDate"> <u-form-item label="种植开始日期" prop="date" borderBottom required @click="openDate">
<up-input input-align="right" placeholder="请选择日期" suffixIcon="arrow-down" suffix-icon-style="color: #b6b6b6;" readonly border="none" v-model="data.formData.date" <up-input input-align="right" placeholder="请选择日期" suffixIcon="arrow-down"
style="pointer-events: none;"></up-input> suffix-icon-style="color: #b6b6b6;" readonly border="none" v-model="data.formData.date"
</u-form-item> style="pointer-events: none;"></up-input>
</view> </u-form-item>
</view>
<view class="card-li">
<view class="c-title">种植图片</view>
<view class="c-box c-box-p">
<view class="code-img1">
<view class="" v-if="pic.length>0"
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="">
<u-icon name="close" size="15" style="margin-left:120.85rpx;" @click="delimg(i)"
v-show="mode=='add'"></u-icon>
<u-image :src="item" width="150.85rpx" height="150.85rpx" @click="perviewFn(item)"></u-image>
</view>
</view>
</view>
</view>
<view class="code-img">
<view class="" @click="updateImgFn">
<view class="carime-icon">
<u-image src="/static/img/DJSC.png" width="91.12rpx" height="91.12rpx"></u-image>
<view class="">
点击上传图片
</view>
</view>
</view>
</view>
</view>
</view>
<view class="c-title">备注信息</view>
<view class="c-box" style="padding: 0 20rpx;">
<u-form-item borderBottom>
<u--textarea v-model="data.formData.remark" :disabled="mode=='detail'" placeholder="请输入内容"></u--textarea>
</u-form-item>
</view>
</u-form> <view class="card-li">
<view> <view class="c-title">种植图片</view>
<!-- <uni-calendar ref="calendar" :showMonth="true" :lunar="true" :insert="false" @confirm="dateConfirmfn" /> --> <view class="c-box c-box-p">
<u-datetime-picker :show="show" v-model="value1" mode="date" @confirm="dateConfirmfn" :formatter="formatter" <view class="code-img1">
@cancel="show=false"></u-datetime-picker> <view class="" v-if="pic.length>0"
</view> style="display: flex;flex-direction: row;flex-wrap: wrap;margin-bottom: 30rpx;">
<view class="" v-for="(item,i) in pic" style="margin-right: 30rpx;">
<u-button class="btn" v-if="mode=='add'" @click="addFn">完成添加</u-button> <view class="">
</view> <u-icon name="close" size="15" style="margin-left:120.85rpx;" @click="delimg(i)"
</view> v-show="mode=='add'"></u-icon>
<u-image :src="item" width="150.85rpx" height="150.85rpx"
@click="perviewFn(item)"></u-image>
</view>
</view>
</view>
</view>
<view class="code-img">
<view class="" @click="updateImgFn">
<view class="carime-icon">
<u-image src="/static/img/DJSC.png" width="91.12rpx" height="91.12rpx"></u-image>
<view class="">
点击上传图片
</view>
</view>
</view>
</view>
</view>
</view>
<view class="c-title">备注信息</view>
<view class="c-box" style="padding: 0 20rpx;">
<u-form-item borderBottom>
<u--textarea v-model="data.formData.remark" :disabled="mode=='detail'"
placeholder="请输入内容"></u--textarea>
</u-form-item>
</view>
</u-form>
<view>
<!-- <uni-calendar ref="calendar" :showMonth="true" :lunar="true" :insert="false" @confirm="dateConfirmfn" /> -->
<u-datetime-picker :show="show" v-model="value1" :maxDate="getNowTime()" mode="date"
@confirm="dateConfirmfn" :formatter="formatter" @cancel="show=false"></u-datetime-picker>
</view>
<u-button class="btn" v-if="mode=='add'" @click="addFn">完成添加</u-button>
</view>
</view>
</template> </template>
<script setup> <script setup>
import { import {
Uploads Uploads
} from "@/api/upload.js" } from "@/api/upload.js"
import { import {
reactive, reactive,
ref ref
} from "vue"; } from "vue";
import { import {
onLoad, onLoad,
onReady onReady
} from "@dcloudio/uni-app" } from "@dcloudio/uni-app"
import { import {
addplant addplant
} from '@/api/api.js' } from '@/api/api.js'
const calendar = ref(null) const calendar = ref(null)
const form1 = ref(null); const form1 = ref(null);
const task_id = ref(''); const task_id = ref('');
const pic = reactive([]); const pic = reactive([]);
const value1 = ref(Date.now()); const value1 = ref(Date.now());
const show = ref(false); const show = ref(false);
const data = reactive({ const data = reactive({
formData: { formData: {
kind: '', kind: '',
breed: '', breed: '',
area: '', area: '',
user: '', user: '',
date: '', date: '',
remark: '', remark: '',
pic: [] pic: []
}, },
rules: { rules: {
kind: [{ kind: [{
type: 'string', type: 'string',
required: true, required: true,
message: '请填写种植种类', message: '请填写种植种类',
trigger: ['blur', 'change'] trigger: ['blur', 'change']
}], }],
breed: [{ breed: [{
type: 'string', type: 'string',
required: true, required: true,
message: '请填写种植品种', message: '请填写种植品种',
trigger: ['blur', 'change'] trigger: ['blur', 'change']
}], }],
area: [{ area: [{
type: 'string', type: 'string',
required: true, required: true,
message: '请填写种植面积', message: '请填写种植面积',
trigger: ['blur', 'change'] trigger: ['blur', 'change']
}], }],
user: [{ user: [{
type: 'string', type: 'string',
required: true, required: true,
message: '请填写参与人员', message: '请填写参与人员',
trigger: ['blur', 'change'] trigger: ['blur', 'change']
}], }],
date: [{ date: [{
type: 'string', type: 'string',
required: true, required: true,
message: '请填写开始日期', message: '请填写开始日期',
trigger: ['blur', 'change'] trigger: ['blur', 'change']
}] }]
} }
}) })
onReady(() => { onReady(() => {
form1.value.setRules(data.rules); form1.value.setRules(data.rules);
}); });
const openDate = () => { const openDate = () => {
// calendar.value.open() // calendar.value.open()
show.value = true show.value = true
} }
const formatter = (type, value) => { const formatter = (type, value) => {
if (type === 'year') { if (type === 'year') {
return `${value}`; return `${value}`;
} }
if (type === 'month') { if (type === 'month') {
return `${value}`; return `${value}`;
} }
if (type === 'day') { if (type === 'day') {
return `${value}`; return `${value}`;
} }
return value; return value;
}; };
const dateConfirmfn = (e) => { const dateConfirmfn = (e) => {
data.formData.date = uni.$u.timeFormat(e.value, 'yyyy-mm-dd') data.formData.date = uni.$u.timeFormat(e.value, 'yyyy-mm-dd')
show.value = false show.value = false
} }
// //
const delimg = (i) => { const delimg = (i) => {
pic.splice(i, 1); pic.splice(i, 1);
} }
const navgo = (url) => { const navgo = (url) => {
uni.navigateTo({ uni.navigateTo({
url url
}) })
} }
// //
const perviewFn = (url) => { const perviewFn = (url) => {
console.log(url) console.log(url)
uni.previewImage({ uni.previewImage({
urls: [url] urls: [url]
}) })
} }
const addFn = async () => { const addFn = async () => {
console.log(form1.value) console.log(form1.value)
try { try {
const valid = await form1.value.validate(); const valid = await form1.value.validate();
if (valid) { if (valid) {
data.formData.land_id = task_id.value data.formData.land_id = task_id.value
console.log('表单通过'); console.log('表单通过');
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)
// //
addplant(data.formData).then((res) => { addplant(data.formData).then((res) => {
if (res.code == 1) { if (res.code == 1) {
uni.navigateBack({ uni.navigateBack({
delta: 1 delta: 1
}) })
uni.$u.toast(res.msg) uni.$u.toast(res.msg)
} }
}) })
} else { } else {
// //
console.log('表单验证未通过'); console.log('表单验证未通过');
} }
} catch (error) { } catch (error) {
// //
console.error(error); console.error(error);
} }
// form.value.validate().then(res => { // form.value.validate().then(res => {
// console.log(6) // console.log(6)
// }).catch(errors => { // }).catch(errors => {
// uni.$u.toast('') // uni.$u.toast('')
// }) // })
// console.log() // console.log()
} }
// //
const updateImgFn = async () => { const updateImgFn = async () => {
uni.chooseImage({ uni.chooseImage({
count: 1, count: 1,
sizeType: ['original', 'compressed'], sizeType: ['original', 'compressed'],
sourceType: ['album', 'camera'], sourceType: ['album', 'camera'],
success: (res) => { success: (res) => {
Uploads(res.tempFilePaths[0], 'img').then(res => { Uploads(res.tempFilePaths[0], 'img').then(res => {
console.log(res) console.log(res)
if (res.code == 1) { if (res.code == 1) {
pic.push(res.data.url) pic.push(res.data.url)
console.log(pic) console.log(pic)
uni.$u.toast('上传成功') uni.$u.toast('上传成功')
} }
}).catch(err => { }).catch(err => {
//console.log('err', err); //console.log('err', err);
// uni.$u.toast('') // uni.$u.toast('')
}) })
}, },
fail: function(err) { fail: function(err) {
//console.log('choose'); //console.log('choose');
uni.$u.toast('添加失败') uni.$u.toast('添加失败')
} }
}); });
// let res = await Uploads() // let res = await Uploads()
// data.formData.pic = res.data.image // data.formData.pic = res.data.image
} }
const mode = ref('add') const mode = ref('add')
onLoad((options) => {
task_id.value = options.id
// if (options.task_id) {
// mode.value = "detail"
// }
}) const getNowTime = () => {
const now = new Date();
now.setHours(0, 0, 0, 0);
const timestamp = now.getTime();
// console.log(timestamp)
return timestamp
}
onLoad((options) => {
task_id.value = options.id
// if (options.task_id) {
// mode.value = "detail"
// }
})
</script> </script>
<style lang='scss' scoped> <style lang='scss' scoped>
page{ page {
background-color: #f7fffc; background-color: #f7fffc;
}
.card{
background-color: #f7fffc;
padding: 0;
padding-bottom: 80rpx;
.c-title{
font-weight: bold;
display: flex;
align-items: center;
padding: 30rpx;
padding-bottom: 15rpx;
&:before{
content: '';
display: inline-block;
height: 0.8rem;
width: 6rpx;
margin-top: 0.2rem;
margin-right: 10rpx;
background-color: #35d190;
border-radius: 6rpx;
}
}
.c-box{
background-color: #fff;
padding-left: 30rpx;
padding-right: 20rpx;
padding-bottom: 20rpx;
box-shadow: 0px 2px 8px rgba(0, 0, 0, 0.1);
}
.c-box-p{
padding: 20rpx;
}
.btn{
margin: 20rpx auto;
width: 694rpx;
height: 80rpx;
border-radius: 80rpx;
background-color: #4ad69b;
color: #fff;
}
}
.tit { }
display: flex;
justify-content: space-between;
}
.card-li { .card {
position: relative; background-color: #f7fffc;
margin-bottom: 0; padding: 0;
padding-bottom: 80rpx;
span { .c-title {
position: absolute; font-weight: bold;
left: -9px; display: flex;
color: #f56c6c; align-items: center;
line-height: 20px; padding: 30rpx;
font-size: 20px; padding-bottom: 15rpx;
top: 3px;
}
} &:before {
content: '';
display: inline-block;
height: 0.8rem;
width: 6rpx;
margin-top: 0.2rem;
margin-right: 10rpx;
background-color: #35d190;
border-radius: 6rpx;
}
}
.confim-btn { .c-box {
margin: 0 auto; background-color: #fff;
width: 196.26rpx; padding-left: 30rpx;
height: 66.59rpx; padding-right: 20rpx;
/* border: ; */ padding-bottom: 20rpx;
border: #00A15E 1px solid; box-shadow: 0px 2px 8px rgba(0, 0, 0, 0.1);
color: #00A15E; }
display: flex;
align-items: center;
justify-content: center;
border-radius: 42.06rpx 42.06rpx 42.06rpx 42.06rpx;
}
.up-img { .c-box-p {
width: 341.71rpx padding: 20rpx;
} }
.today-btn { .btn {
width: 588.79rpx; margin: 20rpx auto;
background-color: #00A15E; width: 694rpx;
color: white; height: 80rpx;
position: fixed; border-radius: 80rpx;
bottom: 40rpx; background-color: #4ad69b;
/* transform: ; */ color: #fff;
left: 50%; }
transform: translateX(-50%); }
background: linear-gradient(to right, #00A15E, #4CC593);
/* margin: 0 auto; */
}
.code-img { .tit {
background-color: #F4F4F4; display: flex;
height: 350.47rpx; justify-content: space-between;
position: relative; }
/* margin-bottom: 100rpx; */
.carime-icon { .card-li {
position: absolute; position: relative;
top: 50%; margin-bottom: 0;
left: 50%;
transform: translate(-50%, -50%);
display: flex;
flex-direction: column;
align-items: center;
}
} span {
position: absolute;
left: -9px;
color: #f56c6c;
line-height: 20px;
font-size: 20px;
top: 3px;
}
.confirm { }
position: fixed;
height: 84.11rpx;
display: flex;
bottom: 30rpx;
width: 750rpx;
.confirm-btn { .confim-btn {
width: 315.42rpx; margin: 0 auto;
height: 84.11rpx; width: 196.26rpx;
border: #00A15E 1px solid; height: 66.59rpx;
margin: 0 auto; /* border: ; */
border-radius: 80rpx; border: #00A15E 1px solid;
text-align: center; color: #00A15E;
line-height: 84rpx; display: flex;
} align-items: center;
} justify-content: center;
border-radius: 42.06rpx 42.06rpx 42.06rpx 42.06rpx;
}
.up-img {
width: 341.71rpx
}
.today-btn {
width: 588.79rpx;
background-color: #00A15E;
color: white;
position: fixed;
bottom: 40rpx;
/* transform: ; */
left: 50%;
transform: translateX(-50%);
background: linear-gradient(to right, #00A15E, #4CC593);
/* margin: 0 auto; */
}
.code-img {
background-color: #F4F4F4;
height: 350.47rpx;
position: relative;
/* margin-bottom: 100rpx; */
.carime-icon {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
display: flex;
flex-direction: column;
align-items: center;
}
}
.confirm {
position: fixed;
height: 84.11rpx;
display: flex;
bottom: 30rpx;
width: 750rpx;
.confirm-btn {
width: 315.42rpx;
height: 84.11rpx;
border: #00A15E 1px solid;
margin: 0 auto;
border-radius: 80rpx;
text-align: center;
line-height: 84rpx;
}
}
</style> </style>

View File

@ -1,516 +1,531 @@
<template> <template>
<!-- 播种 --> <!-- 播种 -->
<view class="content"> <view class="content">
<view class="card"> <view class="card">
<u--form labelWidth='120' :model="formData" :rules="rules" ref="form"> <u--form labelWidth='120' :model="formData" :rules="rules" ref="form">
<view class="c-title">除草信息</view> <view class="c-title">除草信息</view>
<view class="c-box"> <view class="c-box">
<u-form-item label="除草剂种类" prop="kind" borderBottom ref='item1' required> <u-form-item label="除草剂种类" prop="kind" borderBottom ref='item1' required>
<up-input input-align="right" placeholder="请输入除草剂种类" :disabled="mode=='detail'" border="none" <up-input input-align="right" placeholder="请输入除草剂种类" :disabled="mode=='detail'" border="none"
v-model="formData.kind"></up-input> v-model="formData.kind"></up-input>
</u-form-item> </u-form-item>
<u-form-item label="除草剂品牌" prop="breed" borderBottom required> <u-form-item label="除草剂品牌" prop="breed" borderBottom required>
<up-input input-align="right" placeholder="请输入除草剂品牌" :disabled="mode=='detail'" border="none" <up-input input-align="right" placeholder="请输入除草剂品牌" :disabled="mode=='detail'" border="none"
v-model="formData.breed"></up-input> v-model="formData.breed"></up-input>
</u-form-item> </u-form-item>
<u-form-item label="除草剂用量(斤)" prop="dosage" borderBottom required> <u-form-item label="除草剂用量(斤)" prop="dosage" borderBottom required>
<up-input input-align="right" placeholder="请输入除草剂用量" border="none" type='number' :disabled="mode=='detail'" <up-input input-align="right" placeholder="请输入除草剂用量" border="none" type='number'
v-model="formData.dosage"></up-input> :disabled="mode=='detail'" v-model="formData.dosage"></up-input>
</u-form-item> </u-form-item>
<u-form-item label="作业面积(亩)" prop="area" borderBottom required>
<up-input input-align="right" placeholder="请输入作业面积" :disabled="mode=='detail'" type="number" border="none"
v-model="formData.area"></up-input>
</u-form-item>
<u-form-item label="参与人员" prop="user" borderBottom required>
<up-input input-align="right" placeholder="请输入参与人姓名" :disabled="mode=='detail'" type="txt" border="none"
v-model="formData.user"></up-input>
</u-form-item>
<view class="" v-if="mode=='add'">
<u-form-item label="开始日期" @click="openDate" prop="start_date" borderBottom required>
<up-input input-align="right" placeholder="请选择日期" suffixIcon="arrow-down" suffix-icon-style="color: #b6b6b6;" readonly border="none" v-model="formData.start_date"
style="pointer-events: none;"></up-input>
</u-form-item>
<u-form-item label="结束日期" prop="end_date" @click="openDate1" borderBottom required>
<up-input input-align="right" placeholder="请选择日期" suffixIcon="arrow-down" suffix-icon-style="color: #b6b6b6;" readonly border="none" v-model="formData.end_date"
style="pointer-events: none;"></up-input>
</u-form-item>
</view>
<view class="" v-else>
<u-form-item label="开始日期" prop="start_date" borderBottom required>
<up-input input-align="right" placeholder="请选择日期" suffixIcon="arrow-down" suffix-icon-style="color: #b6b6b6;" readonly border="none" v-model="formData.start_date"
style="pointer-events: none;"></up-input>
</u-form-item>
<u-form-item label="结束日期" prop="end_date" borderBottom required>
<up-input input-align="right" placeholder="请选择日期" suffixIcon="arrow-down" suffix-icon-style="color: #b6b6b6;" readonly border="none" v-model="formData.end_date"
style="pointer-events: none;"></up-input>
</u-form-item>
</view>
</view>
<view class="card-li">
<view class="c-title">除草图片</view>
<view class="c-box c-box-p">
<view class="code-img1">
<view class="" v-if="pic.length>0"
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="">
<u-icon name="close" size="15" style="margin-left:120.85rpx;" @click="delimg(i)"
v-show="mode=='add'"></u-icon>
<u-image :src="item" width="150.85rpx" height="150.85rpx" @click="perviewFn(item)"></u-image>
</view>
</view>
</view>
</view>
<view class="code-img" v-if="mode=='add'">
<view class="" @click="updateImgFn">
<view class="carime-icon">
<u-image src="/static/img/DJSC.png" width="91.12rpx" height="91.12rpx"></u-image>
<view class="">
点击上传图片
</view>
</view>
</view>
</view>
</view>
</view>
<view class="c-title">备注信息</view>
<view class="c-box" style="padding: 0 20rpx;">
<u-form-item prop="remark" borderBottom>
<u--textarea v-model="formData.remark" :disabled="mode=='detail'" placeholder="请输入内容"></u--textarea>
</u-form-item>
</view>
</u--form> <u-form-item label="作业面积(亩)" prop="area" borderBottom required>
<view> <up-input input-align="right" placeholder="请输入作业面积" :disabled="mode=='detail'" type="number"
<!-- <uni-calendar ref="calendar" :showMonth="true" :lunar="true" :insert="false" @confirm="dateConfirmfn" /> border="none" v-model="formData.area"></up-input>
</u-form-item>
<u-form-item label="参与人员" prop="user" borderBottom required>
<up-input input-align="right" placeholder="请输入参与人姓名" :disabled="mode=='detail'" type="txt"
border="none" v-model="formData.user"></up-input>
</u-form-item>
<view class="" v-if="mode=='add'">
<u-form-item label="开始日期" @click="openDate" prop="start_date" borderBottom required>
<up-input input-align="right" placeholder="请选择日期" suffixIcon="arrow-down"
suffix-icon-style="color: #b6b6b6;" readonly border="none" v-model="formData.start_date"
style="pointer-events: none;"></up-input>
</u-form-item>
<u-form-item label="结束日期" prop="end_date" @click="openDate1" borderBottom required>
<up-input input-align="right" placeholder="请选择日期" suffixIcon="arrow-down"
suffix-icon-style="color: #b6b6b6;" readonly border="none" v-model="formData.end_date"
style="pointer-events: none;"></up-input>
</u-form-item>
</view>
<view class="" v-else>
<u-form-item label="开始日期" prop="start_date" borderBottom required>
<up-input input-align="right" placeholder="请选择日期" suffixIcon="arrow-down"
suffix-icon-style="color: #b6b6b6;" readonly border="none" v-model="formData.start_date"
style="pointer-events: none;"></up-input>
</u-form-item>
<u-form-item label="结束日期" prop="end_date" borderBottom required>
<up-input input-align="right" placeholder="请选择日期" suffixIcon="arrow-down"
suffix-icon-style="color: #b6b6b6;" readonly border="none" v-model="formData.end_date"
style="pointer-events: none;"></up-input>
</u-form-item>
</view>
</view>
<view class="card-li">
<view class="c-title">除草图片</view>
<view class="c-box c-box-p">
<view class="code-img1">
<view class="" v-if="pic.length>0"
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="">
<u-icon name="close" size="15" style="margin-left:120.85rpx;" @click="delimg(i)"
v-show="mode=='add'"></u-icon>
<u-image :src="item" width="150.85rpx" height="150.85rpx"
@click="perviewFn(item)"></u-image>
</view>
</view>
</view>
</view>
<view class="code-img" v-if="mode=='add'">
<view class="" @click="updateImgFn">
<view class="carime-icon">
<u-image src="/static/img/DJSC.png" width="91.12rpx" height="91.12rpx"></u-image>
<view class="">
点击上传图片
</view>
</view>
</view>
</view>
</view>
</view>
<view class="c-title">备注信息</view>
<view class="c-box" style="padding: 0 20rpx;">
<u-form-item prop="remark" borderBottom>
<u--textarea v-model="formData.remark" :disabled="mode=='detail'"
placeholder="请输入内容"></u--textarea>
</u-form-item>
</view>
</u--form>
<view>
<!-- <uni-calendar ref="calendar" :showMonth="true" :lunar="true" :insert="false" @confirm="dateConfirmfn" />
<uni-calendar ref="calendar1" :showMonth="true" :lunar="true" :insert="false" <uni-calendar ref="calendar1" :showMonth="true" :lunar="true" :insert="false"
@confirm="dateConfirmfn1" /> --> @confirm="dateConfirmfn1" /> -->
<u-datetime-picker :show="show1" v-model="value1" mode="datetime" @confirm="dateConfirmfn" <u-datetime-picker :show="show1" v-model="value1" :max-date="getNowTime()" mode="datetime"
:formatter="formatter" @cancel="show1=false"></u-datetime-picker> @confirm="dateConfirmfn" :formatter="formatter" @cancel="show1=false"></u-datetime-picker>
<u-datetime-picker :show="show2" v-model="value1" mode="datetime" @confirm="dateConfirmfn1" <u-datetime-picker :show="show2" v-model="value1" :max-date="getNowTime()" mode="datetime"
:formatter="formatter" @cancel="show2=false"></u-datetime-picker> @confirm="dateConfirmfn1" :formatter="formatter" @cancel="show2=false"></u-datetime-picker>
</view> </view>
<u-button class="btn" v-if="mode=='add'" @click="addFn">完成添加</u-button> <u-button class="btn" v-if="mode=='add'" @click="addFn">完成添加</u-button>
</view> </view>
</view> </view>
</template> </template>
<script setup> <script setup>
import { import {
Uploads Uploads
} from "@/api/upload.js" } from "@/api/upload.js"
import { import {
reactive, reactive,
ref ref
} from "vue"; } from "vue";
import { import {
onLoad, onLoad,
onReady onReady
} from '@dcloudio/uni-app'; } from '@dcloudio/uni-app';
import { import {
addaction, addaction,
plantdetail plantdetail
} from '@/api/api.js' } from '@/api/api.js'
const pic = reactive([]); const pic = reactive([]);
const calendar = ref(null) const calendar = ref(null)
const calendar1 = ref(null) const calendar1 = ref(null)
const form = ref(null) const form = ref(null)
const task_id = ref(''); const task_id = ref('');
const value1 = ref(Date.now()); const value1 = ref(Date.now());
const show1 = ref(false); const show1 = ref(false);
const show2 = ref(false); const show2 = ref(false);
const openDate = () => { const openDate = () => {
// calendar.value.open() // calendar.value.open()
show1.value = true show1.value = true
} }
const dataobj = reactive({}) const dataobj = reactive({})
const openDate1 = () => { const openDate1 = () => {
// calendar1.value.open() // calendar1.value.open()
show2.value = true show2.value = true
} }
const formatter = (type, value) => { const formatter = (type, value) => {
if (type === 'year') { if (type === 'year') {
return `${value}`; return `${value}`;
} }
if (type === 'month') { if (type === 'month') {
return `${value}`; return `${value}`;
} }
if (type === 'day') { if (type === 'day') {
return `${value}`; return `${value}`;
} }
return value; return value;
}; };
// console.log() // console.log()
const formData = reactive({ const formData = reactive({
kind: "", kind: "",
breed: "", breed: "",
dosage: "", dosage: "",
start_date: "", start_date: "",
dosage: "", dosage: "",
end_date: "", end_date: "",
}) })
// //
const dateConfirmfn = (e) => { const dateConfirmfn = (e) => {
formData.start_date = uni.$u.timeFormat(e.value, 'yyyy-mm-dd hh:MM ') formData.start_date = uni.$u.timeFormat(e.value, 'yyyy-mm-dd hh:MM ')
show1.value = false show1.value = false
} }
const dateConfirmfn1 = (e) => { const dateConfirmfn1 = (e) => {
formData.end_date = uni.$u.timeFormat(e.value, 'yyyy-mm-dd hh:MM ') formData.end_date = uni.$u.timeFormat(e.value, 'yyyy-mm-dd hh:MM ')
show2.value = false show2.value = false
} }
const rules = ref({ const rules = ref({
'kind': { 'kind': {
type: 'string', type: 'string',
required: true, required: true,
message: '请填写除草剂种类', message: '请填写除草剂种类',
trigger: ['blur', 'change'] trigger: ['blur', 'change']
}, },
'breed': { 'breed': {
type: 'string', type: 'string',
required: true, required: true,
message: '请填写除草剂品牌', message: '请填写除草剂品牌',
trigger: ['blur', 'change'] trigger: ['blur', 'change']
}, },
'dosage': { 'dosage': {
type: 'string', type: 'string',
required: true, required: true,
message: '请填写除草剂用量', message: '请填写除草剂用量',
trigger: ['blur', 'change'] trigger: ['blur', 'change']
}, },
'start_date': { 'start_date': {
type: 'string', type: 'string',
required: true, required: true,
message: '请填写开始日期', message: '请填写开始日期',
trigger: ['blur', 'change'] trigger: ['blur', 'change']
}, },
'end_date': { 'end_date': {
type: 'string', type: 'string',
required: true, required: true,
message: '请填写结束日期', message: '请填写结束日期',
trigger: ['blur', 'change'] trigger: ['blur', 'change']
}, },
'area': { 'area': {
type: 'string', type: 'string',
required: true, required: true,
message: '请填写土地面积', message: '请填写作业面积',
trigger: ['blur', 'change'] trigger: ['blur', 'change']
}, },
'user': { 'user': {
type: 'string', type: 'string',
required: true, required: true,
message: '请填写参与人', message: '请填写参与人',
trigger: ['blur', 'change'] trigger: ['blur', 'change']
} }
// , // ,
// 'remark': { // 'remark': {
// type: 'string', // type: 'string',
// required: true, // required: true,
// message: '', // message: '',
// trigger: ['blur', 'change'] // trigger: ['blur', 'change']
// }, // },
}) })
onReady(() => { onReady(() => {
form.value.setRules(rules); form.value.setRules(rules);
}); });
// //
const updateImgFn = async () => { const updateImgFn = async () => {
uni.chooseImage({ uni.chooseImage({
count: 1, count: 1,
sizeType: ['original', 'compressed'], sizeType: ['original', 'compressed'],
sourceType: ['album', 'camera'], sourceType: ['album', 'camera'],
success: (res) => { success: (res) => {
Uploads(res.tempFilePaths[0], 'img').then(res => { Uploads(res.tempFilePaths[0], 'img').then(res => {
console.log(res) console.log(res)
if (res.code == 1) { if (res.code == 1) {
pic.push(res.data.url) pic.push(res.data.url)
console.log(data.formData) console.log(data.formData)
uni.$u.toast('上传成功') uni.$u.toast('上传成功')
} }
}).catch(err => { }).catch(err => {
//console.log('err', err); //console.log('err', err);
// uni.$u.toast('') // uni.$u.toast('')
}) })
}, },
fail: function(err) { fail: function(err) {
//console.log('choose'); //console.log('choose');
uni.$u.toast('添加失败') uni.$u.toast('添加失败')
} }
}); });
// let res = await Uploads() // let res = await Uploads()
// data.formData.pic = res.data.image // data.formData.pic = res.data.image
} }
// //
const perviewFn = (url) => { const perviewFn = (url) => {
uni.previewImage({ uni.previewImage({
urls: [url] urls: [url]
}) })
} }
// //
const delimg = (i) => { const delimg = (i) => {
pic.splice(i, 1); pic.splice(i, 1);
} }
const addFn = () => { const addFn = () => {
form.value.validate().then(res => { form.value.validate().then(res => {
// console.log(res) // console.log(res)
if (res) { if (res) {
if (formData.area > dataobj.area) { if (formData.area > dataobj.area) {
uni.$u.toast('作业面积不能超过种植面积') uni.$u.toast('作业面积不能超过种植面积')
return return
} }
formData.pic = pic formData.pic = pic
let data1 = { let data1 = {
plant_id: task_id.value, plant_id: task_id.value,
type: 2, type: 2,
detail: JSON.stringify(formData) detail: JSON.stringify(formData)
}; };
if (formData.pic.length == 0) { if (formData.pic.length == 0) {
uni.$u.toast('请上传图片') uni.$u.toast('请上传图片')
return return
} }
let endTime = new Date(formData.end_date) let endTime = new Date(formData.end_date)
let startTime = new Date(formData.start_date) let startTime = new Date(formData.start_date)
let plantTime = new Date(dataobj.plant_date) let plantTime = new Date(dataobj.plant_date)
if (startTime < plantTime) { if (startTime < plantTime) {
uni.$u.toast("除草时间必须超过种植的时间"); uni.$u.toast("除草时间必须超过种植的时间");
return return
} }
if (endTime < plantTime) { if (endTime < plantTime) {
uni.$u.toast("除草时间必须超过种植的时间"); uni.$u.toast("除草时间必须超过种植的时间");
return return
} }
if (endTime < startTime) { if (endTime < startTime) {
uni.$u.toast("结束时间不能小于开始时间"); uni.$u.toast("结束时间不能小于开始时间");
return return
} else if (startTime > endTime) { } else if (startTime > endTime) {
uni.$u.toast("开始时间不能大于结束时间"); uni.$u.toast("开始时间不能大于结束时间");
return return
} else { } else {
console.log("开始时间和结束时间合法"); console.log("开始时间和结束时间合法");
} }
console.log('表单通过'); console.log('表单通过');
// //
addaction(data1).then((res) => { addaction(data1).then((res) => {
console.log(res) console.log(res)
if (res.code == 1) { if (res.code == 1) {
uni.$u.toast(res.msg) uni.$u.toast(res.msg)
uni.navigateBack({ uni.navigateBack({
delta: 1 delta: 1
}) })
} }
}) })
// uni.$u.toast('') // uni.$u.toast('')
} }
}).catch((err) => { }).catch((err) => {
uni.$u.toast(err[0].message) uni.$u.toast(err[0].message)
console.log(err) console.log(err)
}) })
} }
const getlist = () => { const getlist = () => {
plantdetail({ plantdetail({
plant_id: task_id.value plant_id: task_id.value
}).then((res) => { }).then((res) => {
if (res.code == 1) { if (res.code == 1) {
// console.log(res) // console.log(res)
Object.assign(dataobj, res.data) Object.assign(dataobj, res.data)
} }
}); });
}; };
const mode = ref('add') const mode = ref('add')
onLoad((options) => { onLoad((options) => {
if (options.task) { if (options.task) {
let data = options.task ? JSON.parse(decodeURIComponent(options.task)) : null; let data = options.task ? JSON.parse(decodeURIComponent(options.task)) : null;
// console.log(data, data.detail) // console.log(data, data.detail)
Object.assign(formData, data.detail); Object.assign(formData, data.detail);
pic.splice(0, pic.length, ...data.detail.pic); pic.splice(0, pic.length, ...data.detail.pic);
mode.value = 'detail' mode.value = 'detail'
uni.setNavigationBarTitle({ uni.setNavigationBarTitle({
title: '除草详情' title: '除草详情'
}) })
// formData=data.detail // formData=data.detail
} else { } else {
task_id.value = options.id task_id.value = options.id
} }
getlist() getlist()
}) })
const getNowTime = () => {
const now = new Date();
const timestamp = now.getTime();
// console.log(timestamp)
return timestamp
}
</script> </script>
<style lang='scss' scoped> <style lang='scss' scoped>
page { page {
background-color: #f7fffc; background-color: #f7fffc;
} }
.card { .card {
background-color: #f7fffc; background-color: #f7fffc;
padding: 0; padding: 0;
padding-bottom: 80rpx; padding-bottom: 80rpx;
.c-title { .c-title {
font-weight: bold; font-weight: bold;
display: flex; display: flex;
align-items: center; align-items: center;
padding: 30rpx; padding: 30rpx;
padding-bottom: 15rpx; padding-bottom: 15rpx;
&:before { &:before {
content: ''; content: '';
display: inline-block; display: inline-block;
height: 0.8rem; height: 0.8rem;
width: 6rpx; width: 6rpx;
margin-top: 0.2rem; margin-top: 0.2rem;
margin-right: 10rpx; margin-right: 10rpx;
background-color: #35d190; background-color: #35d190;
border-radius: 6rpx; border-radius: 6rpx;
} }
} }
.c-box { .c-box {
background-color: #fff; background-color: #fff;
padding-left: 30rpx; padding-left: 30rpx;
padding-right: 20rpx; padding-right: 20rpx;
padding-bottom: 20rpx; padding-bottom: 20rpx;
box-shadow: 0px 2px 8px rgba(0, 0, 0, 0.1); box-shadow: 0px 2px 8px rgba(0, 0, 0, 0.1);
} }
.c-box-p { .c-box-p {
padding: 20rpx; padding: 20rpx;
} }
.btn { .btn {
margin: 20rpx auto; margin: 20rpx auto;
width: 694rpx; width: 694rpx;
height: 80rpx; height: 80rpx;
border-radius: 80rpx; border-radius: 80rpx;
background-color: #4ad69b; background-color: #4ad69b;
color: #fff; color: #fff;
} }
} }
.tit { .tit {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
} }
.card-li { .card-li {
position: relative; position: relative;
margin-bottom: 0; margin-bottom: 0;
span { span {
position: absolute; position: absolute;
left: -9px; left: -9px;
color: #f56c6c; color: #f56c6c;
line-height: 20px; line-height: 20px;
font-size: 20px; font-size: 20px;
top: 3px; top: 3px;
} }
} }
.confim-btn { .confim-btn {
margin: 0 auto; margin: 0 auto;
width: 196.26rpx; width: 196.26rpx;
height: 66.59rpx; height: 66.59rpx;
/* border: ; */ /* border: ; */
border: #00A15E 1px solid; border: #00A15E 1px solid;
color: #00A15E; color: #00A15E;
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
border-radius: 42.06rpx 42.06rpx 42.06rpx 42.06rpx; border-radius: 42.06rpx 42.06rpx 42.06rpx 42.06rpx;
} }
.up-img { .up-img {
width: 341.71rpx width: 341.71rpx
} }
.today-btn { .today-btn {
width: 588.79rpx; width: 588.79rpx;
background-color: #00A15E; background-color: #00A15E;
color: white; color: white;
position: fixed; position: fixed;
bottom: 40rpx; bottom: 40rpx;
/* transform: ; */ /* transform: ; */
left: 50%; left: 50%;
transform: translateX(-50%); transform: translateX(-50%);
background: linear-gradient(to right, #00A15E, #4CC593); background: linear-gradient(to right, #00A15E, #4CC593);
/* margin: 0 auto; */ /* margin: 0 auto; */
} }
.code-img { .code-img {
background-color: #F4F4F4; background-color: #F4F4F4;
height: 350.47rpx; height: 350.47rpx;
position: relative; position: relative;
/* margin-bottom: 100rpx; */ /* margin-bottom: 100rpx; */
.carime-icon { .carime-icon {
position: absolute; position: absolute;
top: 50%; top: 50%;
left: 50%; left: 50%;
transform: translate(-50%, -50%); transform: translate(-50%, -50%);
display: flex; display: flex;
flex-direction: column; flex-direction: column;
align-items: center; align-items: center;
} }
} }
.confirm { .confirm {
position: fixed; position: fixed;
height: 84.11rpx; height: 84.11rpx;
display: flex; display: flex;
bottom: 30rpx; bottom: 30rpx;
width: 750rpx; width: 750rpx;
.confirm-btn { .confirm-btn {
width: 315.42rpx; width: 315.42rpx;
height: 84.11rpx; height: 84.11rpx;
border: #00A15E 1px solid; border: #00A15E 1px solid;
margin: 0 auto; margin: 0 auto;
border-radius: 80rpx; border-radius: 80rpx;
text-align: center; text-align: center;
line-height: 84rpx; line-height: 84rpx;
} }
} }
</style> </style>

View File

@ -75,7 +75,7 @@
<view v-if="(dataobj.total_area-dataobj.residual_area)==0" @click="palnt(dataobj.id)"> <view v-if="(dataobj.total_area-dataobj.residual_area)==0" @click="palnt(dataobj.id)">
<view class="empty-land" style="background-image: url('static/main/index/xzzh.png');"> <view class="empty-land" style="background-image: url('static/main/index/xzzh.png');">
<text></text> <text></text>
<text @click="navto('/pages/addLand/addLand')">去新增</text> <text>去新增</text>
</view> </view>
</view> </view>
<view class="note" v-else> <view class="note" v-else>

View File

@ -134,11 +134,14 @@
padding-top: 30rpx; padding-top: 30rpx;
position: relative; position: relative;
border-radius: 0 0 50rpx 50rpx; border-radius: 0 0 50rpx 50rpx;
// background-color: red;
position: relative;
.head-con { .head-con {
display: flex; display: flex;
align-items: center; align-items: center;
margin-top: 150rpx; position: absolute;
bottom: 100rpx // margin-top: 150rpx;
} }
.head-li { .head-li {

View File

@ -6,7 +6,7 @@
<view class="content-con-a" v-if="Object.keys(dataobj).length>0"> <view class="content-con-a" v-if="Object.keys(dataobj).length>0">
<view class="shop_detail"> <view class="shop_detail">
<view class="shop_detail-top"> <view class="tit">
品类信息 品类信息
</view> </view>
<view class="shop_detail-botm"> <view class="shop_detail-botm">
@ -69,13 +69,14 @@
<view class="shop_action"> <view class="shop_action">
<view class="" v-for="(item,i) in dataobj.actions"> <view class="" v-for="(item,i) in dataobj.actions">
<view class="shop_action-title"> <view class="tit">
{{item.type_text}} {{item.type_text}}
</view> </view>
<view class="shop_action-detail" v-if="item.type!=3&&item.type!=5"> <view class="shop_action-detail" v-if="item.type!=3&&item.type!=5">
<view class="action-detail"> <view class="action-detail">
<view class="title"> <view class="title">
{{item.type_text.slice(0, -2)}}<text class="" v-if="item.type==2||item.type==4"></text>品种 {{item.type_text.slice(0, -2)}}<text class=""
v-if="item.type==2||item.type==4"></text>品种
</view> </view>
<view class="detail"> <view class="detail">
{{item.detail.kind}} {{item.detail.kind}}
@ -83,7 +84,8 @@
</view> </view>
<view class="action-detail" v-if="item.detail.breed"> <view class="action-detail" v-if="item.detail.breed">
<view class="title"> <view class="title">
{{item.type_text.slice(0, -2)}}<text class="" v-if="item.type==2||item.type==4"></text>品牌 {{item.type_text.slice(0, -2)}}<text class=""
v-if="item.type==2||item.type==4"></text>品牌
</view> </view>
<view class="detail"> <view class="detail">
{{item.detail.breed}} {{item.detail.breed}}
@ -91,7 +93,8 @@
</view> </view>
<view class="action-detail"> <view class="action-detail">
<view class="title"> <view class="title">
{{item.type_text.slice(0, -2)}}<text class="" v-if="item.type==2||item.type==4"></text>用量 {{item.type_text.slice(0, -2)}}<text class=""
v-if="item.type==2||item.type==4"></text>用量
</view> </view>
<view class="detail"> <view class="detail">
{{item.detail.dosage}}<text v-if='item.type==4'></text> {{item.detail.dosage}}<text v-if='item.type==4'></text>
@ -111,8 +114,11 @@
{{item.type_text.slice(0, -2)}}图片 {{item.type_text.slice(0, -2)}}图片
</view> </view>
<view class="detail-img" v-if="item.detail&&item.detail.pic&&item.detail.pic.length>0"> <view class="detail-img" v-if="item.detail&&item.detail.pic&&item.detail.pic.length>0">
<image @click="perviewFn(item.detail.pic)" :src="item.detail.pic[0]" mode="aspectFit"> <!-- <image @click="perviewFn(item.detail.pic)" :src="item.detail.pic[0]" mode="aspectFit">
</image> </image> -->
<u-swiper :list="item.detail.pic" @click="hdClick" indicator indicatorMode="dot"
circular></u-swiper>
</view> </view>
</view> </view>
</view> </view>
@ -147,8 +153,10 @@
灌溉图片 灌溉图片
</view> </view>
<view class="detail-img" v-if="item.detail&&item.detail.pic&&item.detail.pic.length>0"> <view class="detail-img" v-if="item.detail&&item.detail.pic&&item.detail.pic.length>0">
<image @click="perviewFn(item.detail.pic)" :src="item.detail.pic[0]" mode="aspectFit"> <!-- <image @click="perviewFn(item.detail.pic)" :src="item.detail.pic[0]" mode="aspectFit">
</image> </image> -->
<u-swiper :list="item.detail.pic" @click="hdClick" indicator indicatorMode="dot"
circular></u-swiper>
</view> </view>
</view> </view>
@ -176,8 +184,10 @@
收获图片 收获图片
</view> </view>
<view class="detail-img" v-if="item.detail&&item.detail.pic&&item.detail.pic.length>0"> <view class="detail-img" v-if="item.detail&&item.detail.pic&&item.detail.pic.length>0">
<image @click="perviewFn(item.detail.pic)" :src="item.detail.pic[0]" mode="aspectFit"> <!-- <image @click="perviewFn(item.detail.pic)" :src="item.detail.pic[0]" mode="aspectFit">
</image> </image> -->
<u-swiper :list="item.detail.pic" @click="hdClick" indicator indicatorMode="dot"
circular></u-swiper>
</view> </view>
</view> </view>
</view> </view>
@ -240,7 +250,7 @@
} }
// //
const perviewFn = (url) => { const perviewFn = (url) => {
console.log(url) console.log(url)
uni.previewImage({ uni.previewImage({
urls: url urls: url
@ -277,8 +287,9 @@
.shop_detail-botm { .shop_detail-botm {
width: 694rpx; width: 694rpx;
padding: 35rpx 0; padding: 35rpx 0;
background: #FFFFFF; background: white;
border-radius: 21rpx 21rpx; border-radius: 21rpx 21rpx;
box-shadow: 1rpx 1rpx 10rpx 1rpx rgba(0, 0, 0, 0.1);
.detail { .detail {
display: flex; display: flex;
@ -314,6 +325,7 @@
background: #FFFFFF; background: #FFFFFF;
border-radius: 21rpx 21rpx; border-radius: 21rpx 21rpx;
margin-bottom: 30rpx; margin-bottom: 30rpx;
box-shadow: 1rpx 1rpx 10rpx 1rpx rgba(0, 0, 0, 0.1);
.action-detail { .action-detail {
display: flex; display: flex;
@ -340,7 +352,7 @@
.detail-img { .detail-img {
width: 627rpx; width: 627rpx;
height: 529rpx; // height: 529rpx;
image { image {
width: 100%; width: 100%;
@ -353,4 +365,23 @@
} }
} }
.tit {
position: relative;
padding-left: 20rpx;
font-weight: bold;
margin-bottom: 20rpx;
}
.tit::before {
content: "";
position: absolute;
top: 50%;
transform: translateY(-50%);
left: 0;
width: 3px;
/* 左边框的宽度 */
height: 30rpx;
background-color: #34D08D;
}
</style> </style>

Binary file not shown.

File diff suppressed because one or more lines are too long

View File

@ -7,8 +7,8 @@
"id": "__UNI__D087881", "id": "__UNI__D087881",
"name": "种植溯源", "name": "种植溯源",
"version": { "version": {
"name": "1.0.1", "name": "1.0.2",
"code": "100" "code": 102
}, },
"description": "", "description": "",
"developer": { "developer": {
@ -67,6 +67,7 @@
"<uses-permission android:name=\"android.permission.READ_LOGS\"/>", "<uses-permission android:name=\"android.permission.READ_LOGS\"/>",
"<uses-permission android:name=\"android.permission.READ_PHONE_STATE\"/>", "<uses-permission android:name=\"android.permission.READ_PHONE_STATE\"/>",
"<uses-permission android:name=\"android.permission.RECORD_AUDIO\"/>", "<uses-permission android:name=\"android.permission.RECORD_AUDIO\"/>",
"<uses-permission android:name=\"android.permission.USE_FINGERPRINT\"/>",
"<uses-permission android:name=\"android.permission.VIBRATE\"/>", "<uses-permission android:name=\"android.permission.VIBRATE\"/>",
"<uses-permission android:name=\"android.permission.WAKE_LOCK\"/>", "<uses-permission android:name=\"android.permission.WAKE_LOCK\"/>",
"<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>" "<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>"
@ -84,8 +85,8 @@
"__platform__": [ "__platform__": [
"android" "android"
], ],
"appkey_ios": "4e6789b864fe1a2d76b98e38158f20f2", "appkey_ios": "a8c8821159c1781d4ea4651df856b872",
"appkey_android": "a230d943475443eb29fc3871fbef8605" "appkey_android": "a8c8821159c1781d4ea4651df856b872"
}, },
"system": { "system": {
"__platform__": [ "__platform__": [
@ -97,8 +98,8 @@
"maps": { "maps": {
"amap": { "amap": {
"name": "4e6789b864fe1a2d76b98e38158f20f2", "name": "4e6789b864fe1a2d76b98e38158f20f2",
"appkey_ios": "a230d943475443eb29fc3871fbef8605", "appkey_ios": "a8c8821159c1781d4ea4651df856b872",
"appkey_android": "a230d943475443eb29fc3871fbef8605" "appkey_android": "a8c8821159c1781d4ea4651df856b872"
} }
}, },
"audio": { "audio": {

File diff suppressed because one or more lines are too long