FenXiNspUniapp/packDetail/pages/fwtz/edit.vue

445 lines
10 KiB
Vue

<template>
<view class="container">
<view class="form">
<view class="form_item">
<view class="form_top">
养殖场名称:
</view>
<view class="form_bot">
<input type="text" placeholder="请输入养殖场名称" v-model="details.farmName">
</view>
</view>
<view class="form_item">
<view class="form_top">
养殖品种:
</view>
<view class="form_bot">
<uni-section type="line">
<view class="uni-px-5 uni-pb-5">
<uni-data-checkbox @change="change1" selectedColor="#47c693" mode="tag" v-model="details.breedVariety" :localdata="hobby"></uni-data-checkbox>
</view>
</uni-section>
</view>
</view>
<view class="form_item">
<view class="form_top">
现有存栏:
</view>
<view class="form_bot" style="display: flex;">
<input type="number" placeholder="请输入现有存栏" v-model="details.breedScale" style="width: 85%;">
<span class="dw">头 / 只</span>
</view>
</view>
<view class="form_item">
<view class="form_top">
年份:
</view>
<view class="form_bot">
<picker mode="date" fields="year" :value="date" :start="startDate" :end="endDate" @change="bindDateChangeyear">
<view class="dates">
<view class="uni-input" style="color: #808080;" v-if="!details.countYear">请选择年份</view>
<view class="uni-input" v-else>{{details.countYear}}</view>
</view>
<image class="dateimg" src="../../static/data.png" mode=""></image>
</picker>
</view>
</view>
<view class="form_item">
<view class="form_top">
固体粪便产生量:
</view>
<view class="form_bot" style="display: flex;">
<input type="number" placeholder="请输入固体粪便产生量" v-model="details.fecesQuantity" style="width: 85%;">
<span class="dw">吨 / 年</span>
</view>
</view>
<view class="form_item">
<view class="form_top">
液体产生量:
</view>
<view class="form_bot" style="display: flex;">
<input type="number" placeholder="请输入液体产生量" v-model="details.urineQuantity" style="width: 85%;">
<span class="dw">立方米</span>
</view>
</view>
<view class="form_item">
<view class="form_top">
混合产生量:
</view>
<view class="form_bot" style="display: flex;">
<input type="number" placeholder="请输入混合产生量" v-model="details.mixQuantity" style="width: 85%;">
<span class="dw">立方米</span>
</view>
</view>
<view class="form_item">
<view class="form_top">
治污模式:
</view>
<view class="form_bot">
<uni-section type="line">
<view class="uni-px-5 uni-pb-5">
<uni-data-checkbox @change="change2" selectedColor="#47c693" mode="tag" v-model="details.controlMode" :localdata="hobby2"></uni-data-checkbox>
</view>
</uni-section>
</view>
</view>
<view class="form_item">
<view class="form_top">
利用模式:
</view>
<view class="form_bot">
<uni-section type="line">
<view class="uni-px-5 uni-pb-5">
<uni-data-checkbox @change="change3" selectedColor="#47c693" mode="tag" v-model="details.useMode" :localdata="hobby3"></uni-data-checkbox>
</view>
</uni-section>
</view>
</view>
<view class="form_item">
<view class="form_top">
收入金额:
</view>
<view class="form_bot" style="display: flex;">
<input type="number" placeholder="请输入收入金额" v-model="details.chargeAmount" style="width: 85%;">
<span class="dw">元</span>
</view>
</view>
<view class="bz_item">
<view class="bz_top">
备<span class="bz">注:</span>
</view>
<view class="bz_bot">
<textarea v-model="details.sNote" style="width: 100%;"/>
</view>
</view>
</view>
<view class="bot_btn">
<button class="primary" @click="tosubmit()">提 交</button>
</view>
<view class="pagebot"></view>
</view>
</template>
<script>
export default{
data(){
return{
array:['生猪1号养殖场','生猪2号养殖场','生猪3号养殖场','生猪4号养殖场'],
details:{
breedScale: "",
breedVariety: "",
chargeAmount: "",
controlMode: "",
countYear: "",
createTime: "",
createdBy: "",
entId: "",
entName: "",
farmName: "",
fecesQuantity: "",
id: "",
isDel: 0,
mixQuantity: "",
reVision: 0,
sNote: "",
tenantId: "",
updatedBy: "",
updatedTime: "",
urineQuantity: "",
useMode: "",
},
index:'',
date:'',
year:'',
number:'',
tag:'',
hobby: [],
hobby2: [],
hobby3: [],
reload:'true'
}
},
onLoad(options) {
this.details = JSON.parse(decodeURIComponent(options.item));
},
onShow() {
this.getazsurvMulchRecord()
this.getazsurvMulchRecord1()
this.getazsurvMulchRecord2()
},
methods:{
// 养殖品种
getazsurvMulchRecord(){
this.hobby = []
let params = {}
params.dictCode = 'dict_breed_type'
this.$http.get('/applet/Dict/getDictByType',{params:params}).then(res=>{
for(var i=0;i<res.data.data.length;i++){
this.hobby.push({
text:res.data.data[i].itemText,
value:res.data.data[i].itemValue
})
console.log(this.hobby)
}
})
},
// 治污模式
getazsurvMulchRecord1(){
this.hobby2 = []
let params = {}
params.dictCode = 'surv_control_mode'
this.$http.get('/applet/Dict/getDictByType',{params:params}).then(res=>{
for(var i=0;i<res.data.data.length;i++){
this.hobby2.push({
text:res.data.data[i].itemText,
value:res.data.data[i].itemValue
})
}
})
},
// 利用模式
getazsurvMulchRecord2(){
this.hobby3 = []
let params = {}
params.dictCode = 'surv_use_mode'
this.$http.get('/applet/Dict/getDictByType',{params:params}).then(res=>{
for(var i=0;i<res.data.data.length;i++){
this.hobby3.push({
text:res.data.data[i].itemText,
value:res.data.data[i].itemValue
})
console.log(this.hobby3)
}
})
},
// 选择年
bindDateChangeyear(e){
this.details.countYear = e.detail.value
},
// 选择养殖品种
change1(e){
console.log(e)
this.details.breedVariety = e.detail.value
},
// 选择治污模式
change2(e){
console.log(e)
this.details.controlMode = e.detail.value
},
// 选择利用模式
change3(e){
console.log(e)
this.details.useMode = e.detail.value
},
// 提交
tosubmit(){
if(!this.details.farmName){
uni.showToast({
title: "请输入养殖场名称",
icon: 'none',
duration: 2000
})
return
}
if(!this.details.breedVariety){
uni.showToast({
title: "请选择养殖品种",
icon: 'none',
duration: 2000
})
return
}
if(!this.details.breedScale){
uni.showToast({
title: "请输入现有存栏",
icon: 'none',
duration: 2000
})
return
}
if(!this.details.countYear){
uni.showToast({
title: "请选择年份",
icon: 'none',
duration: 2000
})
return
}
if(!this.details.fecesQuantity){
uni.showToast({
title: "请输入固体粪便产生量",
icon: 'none',
duration: 2000
})
return
}
if(!this.details.urineQuantity){
uni.showToast({
title: "请输入液体产生量",
icon: 'none',
duration: 2000
})
return
}
if(!this.details.mixQuantity){
uni.showToast({
title: "请输入混合产生量",
icon: 'none',
duration: 2000
})
return
}
if(!this.details.controlMode){
uni.showToast({
title: "请选择治污模式",
icon: 'none',
duration: 2000
})
return
}
if(!this.details.useMode){
uni.showToast({
title: "请选择利用模式",
icon: 'none',
duration: 2000
})
return
}
if(!this.details.chargeAmount){
uni.showToast({
title: "请输入收入金额",
icon: 'none',
duration: 2000
})
return
}
this.$http.post('/applet/survFecesLedger/edit',this.details).then(res=>{
uni.showLoading({
title: '正在提交...'
});
if(res.data.code == 0){
uni.hideLoading();
uni.navigateBack()
let pages = getCurrentPages();
let prevPage = pages[ pages.length - 2 ];
prevPage.$vm.reload = this.reload;
}
})
}
}
}
</script>
<style lang="scss">
page{
height: 100%;
background-color: white;
}
.form{
padding: 0 30rpx;
}
.form_item{
padding-top: 33rpx;
padding-bottom: 25rpx;
border-bottom: 1rpx solid #e6e6e6;
}
.form_top{
margin-bottom: 26rpx;
font-weight: bold;
}
.form_bot{
position: relative;
}
.dates{
display: flex;
align-items: center;
justify-content: space-between;
}
.dateimg{
height: 32rpx;
width: 32rpx;
position: absolute;
right: 0;
top: 50%;
transform: translateY(-50%);
}
.dw{
color: #2ac066;
}
.item_pic{
border-bottom:1rpx solid #e4e4e4;
padding: 30rpx 0rpx;
font-weight: 500;
}
.imgList{
display: flex;
flex-wrap: wrap;
}
.imgList image{
width: 130rpx;
height: 130rpx;
margin-right: 24rpx;
margin-top: 20rpx;
}
.imgList image:nth-child(4n){
margin-right: 0rpx;
}
.bz_item{
padding: 40rpx 0rpx;
}
.bz_top{
font-weight: bold;
margin-bottom: 26rpx;
}
.bz{
margin-left: 30rpx;
}
.bz_bot{
color: #767676;
line-height: 50rpx;
border: 1rpx solid #ececec;
border-radius: 10rpx;
padding: 16rpx;
}
.bot_btn{
padding: 0 30rpx;
margin-top: 30rpx;
}
.primary{
width: 100%;
height: 90rpx;
background-color: #0F6EFF;
border: none;
border-radius: 50rpx;
color:#fff;
font-weight: bold;
}
.pagebot{
height: 200rpx;
}
.text {
font-size: 12px;
color: #666;
margin-top: 5px;
}
.uni-px-5 {
padding-left: 10px;
padding-right: 10px;
}
.uni-pb-5 {
padding-bottom: 10px;
}
.checkpeople{
width: 187rpx;
height: 57rpx;
border: 1rpx dashed #0472e3;
line-height: 57rpx;
text-align: center;
color: #0472e3;
}
.dw{
color: #2ac066;
flex: 1;
text-align: right;
}
</style>