|
|
@@ -17,13 +17,16 @@
|
|
|
size="small"
|
|
|
>
|
|
|
<el-row>
|
|
|
- <el-col :span="24" style="background:#F5F7FA;padding-top:20px;margin-bottom:20px;">
|
|
|
+ <el-col
|
|
|
+ :span="24"
|
|
|
+ style="background: #f5f7fa; padding-top: 20px; margin-bottom: 20px"
|
|
|
+ >
|
|
|
<el-form-item label="所属区域" prop="areaId">
|
|
|
<el-row>
|
|
|
- <el-col :span="24" style="padding-right:5%">
|
|
|
- <select-tree
|
|
|
- :placeholder="'请选择区域'"
|
|
|
- style="width:100%"
|
|
|
+ <el-col :span="24" style="padding-right: 5%">
|
|
|
+ <select-tree
|
|
|
+ :placeholder="'请选择区域'"
|
|
|
+ style="width: 100%"
|
|
|
:treeData="treeData"
|
|
|
@handlerClick="handlerClick"
|
|
|
:checkVal="cusareaName"
|
|
|
@@ -33,17 +36,11 @@
|
|
|
</el-form-item>
|
|
|
<el-col>
|
|
|
<el-row class="area">
|
|
|
+ <el-col> <label>总面积:</label>{{ areaAll }}亩 </el-col>
|
|
|
+ <el-col> <label>总水权:</label>{{ waterRightAll }}m³ </el-col>
|
|
|
+ <el-col> <label>亩产水权:</label>{{ yieldPer }} m³/亩 </el-col>
|
|
|
<el-col>
|
|
|
- <label>总面积:</label>{{ areaAll }}亩
|
|
|
- </el-col>
|
|
|
- <el-col>
|
|
|
- <label>总水权:</label>{{ waterRightAll }}m³
|
|
|
- </el-col>
|
|
|
- <el-col>
|
|
|
- <label>亩产水权:</label>{{ yieldPer }}亩/m³
|
|
|
- </el-col>
|
|
|
- <el-col>
|
|
|
- <label>剩余水权:</label>{{ residualWaterRight }}m³
|
|
|
+ <label>剩余水权:</label>{{ residualWaterRight }}m³
|
|
|
</el-col>
|
|
|
</el-row>
|
|
|
</el-col>
|
|
|
@@ -102,23 +99,25 @@
|
|
|
</el-row>
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
- <el-col :span="12">
|
|
|
- <el-form-item label="土地面积" prop="farmerAreasize">
|
|
|
- <el-row>
|
|
|
- <el-col style="position:relative">
|
|
|
- <el-input
|
|
|
- v-model="baseForm.farmerAreasize"
|
|
|
- type="number"
|
|
|
- filterable
|
|
|
- style="width: 90%"
|
|
|
- placeholder="请输入土地面积"
|
|
|
- >
|
|
|
- </el-input>
|
|
|
- <span style="position:absolute;margin-left:10px">亩</span>
|
|
|
- </el-col>
|
|
|
- </el-row>
|
|
|
- </el-form-item>
|
|
|
- </el-col>
|
|
|
+ <el-col :span="12">
|
|
|
+ <el-form-item label="土地面积" prop="farmerAreasize">
|
|
|
+ <el-row>
|
|
|
+ <el-col style="position: relative">
|
|
|
+ <el-input
|
|
|
+ v-model="baseForm.farmerAreasize"
|
|
|
+ type="number"
|
|
|
+ filterable
|
|
|
+ style="width: 90%"
|
|
|
+ placeholder="请输入土地面积"
|
|
|
+ >
|
|
|
+ </el-input>
|
|
|
+ <span style="position: absolute; margin-left: 10px"
|
|
|
+ >亩</span
|
|
|
+ >
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
</el-row>
|
|
|
</el-col>
|
|
|
<el-col :span="24">
|
|
|
@@ -149,7 +148,7 @@
|
|
|
>
|
|
|
<el-button
|
|
|
type="primary"
|
|
|
- style="margin-left:16px;"
|
|
|
+ style="margin-left: 16px"
|
|
|
@click="submitForm('baseForm')"
|
|
|
:disabled="dialogSubmitLoading"
|
|
|
:loading="dialogSubmitLoading"
|
|
|
@@ -160,14 +159,14 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import { Message } from 'element-ui'
|
|
|
-import { isValidIDCard, checkPhone } from '@/utils/index.js'
|
|
|
+import { Message } from 'element-ui';
|
|
|
+import { isValidIDCard, checkPhone } from '@/utils/index.js';
|
|
|
import SelectTree from '@/components/SelectTree';
|
|
|
-import { addFarmer,editFarmer, getAreaInfo } from '@/api/farmer/list.js'
|
|
|
+import { addFarmer, editFarmer, getAreaInfo } from '@/api/farmer/list.js';
|
|
|
|
|
|
export default {
|
|
|
name: 'addedFarmers',
|
|
|
- components:{
|
|
|
+ components: {
|
|
|
SelectTree
|
|
|
},
|
|
|
props: {
|
|
|
@@ -183,7 +182,7 @@ export default {
|
|
|
type: Object,
|
|
|
default: () => {}
|
|
|
},
|
|
|
- isEdit:{
|
|
|
+ isEdit: {
|
|
|
type: Boolean,
|
|
|
default: false
|
|
|
},
|
|
|
@@ -214,74 +213,114 @@ export default {
|
|
|
],
|
|
|
farmerIdcard: [
|
|
|
{
|
|
|
- required: true, validator: (rule, value, callback) => {
|
|
|
+ required: true,
|
|
|
+ validator: (rule, value, callback) => {
|
|
|
if (!value) callback(new Error('请输入农户身份证号'));
|
|
|
- const vaild = isValidIDCard(value)
|
|
|
+ const vaild = isValidIDCard(value);
|
|
|
if (vaild) {
|
|
|
- callback()
|
|
|
- } else {
|
|
|
+ callback();
|
|
|
+ } else {
|
|
|
callback(new Error('请正确输入农户身份证号'));
|
|
|
}
|
|
|
-
|
|
|
- }, trigger: 'blur' }
|
|
|
+ },
|
|
|
+ trigger: 'blur'
|
|
|
+ }
|
|
|
],
|
|
|
farmerPhone: [
|
|
|
- { required: true, validator: (rule, value, callback) => {
|
|
|
+ {
|
|
|
+ required: true,
|
|
|
+ validator: (rule, value, callback) => {
|
|
|
if (!value) callback(new Error('请输入联系电话'));
|
|
|
- const vaild = checkPhone(value)
|
|
|
+ const vaild = checkPhone(value);
|
|
|
if (vaild) {
|
|
|
- callback()
|
|
|
+ callback();
|
|
|
} else {
|
|
|
callback(new Error('请正确输入联系电话'));
|
|
|
}
|
|
|
-
|
|
|
- }, trigger: 'blur' }
|
|
|
+ },
|
|
|
+ trigger: 'blur'
|
|
|
+ }
|
|
|
],
|
|
|
farmerAreasize: [
|
|
|
{
|
|
|
- required: true, validator: (rule, value, callback) => {
|
|
|
- if (!value) { callback(new Error('请输入土地面积')); return }
|
|
|
- if (+value < 0) { callback(new Error('土地面积不能为负数')); return }
|
|
|
- if (isNaN(value)) { callback(new Error('请正确输入您的土地面积')); return }
|
|
|
+ required: true,
|
|
|
+ validator: (rule, value, callback) => {
|
|
|
+ console.log(
|
|
|
+ value,
|
|
|
+ this.areasizeResidue,
|
|
|
+ '------------------- farmer area size'
|
|
|
+ );
|
|
|
+ if (!value) {
|
|
|
+ callback(new Error('请输入土地面积'));
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (+value < 0) {
|
|
|
+ callback(new Error('土地面积不能为负数'));
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (isNaN(value)) {
|
|
|
+ callback(new Error('请正确输入您的土地面积'));
|
|
|
+ return;
|
|
|
+ }
|
|
|
if (this.isEdit) {
|
|
|
- if (+value > (+this.areasizeResidue) + (+this.editFarmerData.farmerAreasize)) {
|
|
|
- callback(new Error('输入的土地面积不能大于总面积'))
|
|
|
- return
|
|
|
+ if (
|
|
|
+ +value >
|
|
|
+ +this.areasizeResidue + +this.editFarmerData.farmerAreasize
|
|
|
+ ) {
|
|
|
+ callback(new Error('输入的土地面积不能大于总面积'));
|
|
|
+ return;
|
|
|
} else {
|
|
|
- callback()
|
|
|
+ callback();
|
|
|
}
|
|
|
} else {
|
|
|
if (+value > +this.areasizeResidue) {
|
|
|
- callback(new Error('输入的水权不能大于剩余面积'))
|
|
|
- return
|
|
|
+ callback(new Error('输入的水权不能大于剩余面积'));
|
|
|
+ return;
|
|
|
} else {
|
|
|
- callback()
|
|
|
+ callback();
|
|
|
}
|
|
|
}
|
|
|
- }, trigger: 'blur' }
|
|
|
+ },
|
|
|
+ trigger: 'blur'
|
|
|
+ }
|
|
|
],
|
|
|
farmerWramount: [
|
|
|
{
|
|
|
- required: true, validator: (rule, value, callback) => {
|
|
|
- if (value == 0) { callback(new Error('请输入水权')); return }
|
|
|
- if (+value < 0) { callback(new Error('水权不能为负数')); return }
|
|
|
- if (isNaN(value)) { callback(new Error('请正确输入您的水权')); return }
|
|
|
+ required: true,
|
|
|
+ validator: (rule, value, callback) => {
|
|
|
+ if (value == 0) {
|
|
|
+ callback(new Error('请输入水权'));
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (+value < 0) {
|
|
|
+ callback(new Error('水权不能为负数'));
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (isNaN(value)) {
|
|
|
+ callback(new Error('请正确输入您的水权'));
|
|
|
+ return;
|
|
|
+ }
|
|
|
if (this.isEdit) {
|
|
|
- if (+value > (+this.residualWaterRight) + (+this.editFarmerData.farmerWramount)) {
|
|
|
- callback(new Error('输入的水权不能大于剩余水权'))
|
|
|
- return
|
|
|
- } else {
|
|
|
- callback()
|
|
|
+ if (
|
|
|
+ +value >
|
|
|
+ +this.residualWaterRight + +this.editFarmerData.farmerWramount
|
|
|
+ ) {
|
|
|
+ callback(new Error('输入的水权不能大于剩余水权'));
|
|
|
+ return;
|
|
|
+ } else {
|
|
|
+ callback();
|
|
|
}
|
|
|
- } else {
|
|
|
+ } else {
|
|
|
if (+value > +this.residualWaterRight) {
|
|
|
- callback(new Error('输入的水权不能大于剩余水权'))
|
|
|
- return
|
|
|
- } else {
|
|
|
- callback()
|
|
|
+ callback(new Error('输入的水权不能大于剩余水权'));
|
|
|
+ return;
|
|
|
+ } else {
|
|
|
+ callback();
|
|
|
}
|
|
|
}
|
|
|
- }, trigger: 'blur' }
|
|
|
+ },
|
|
|
+ trigger: 'blur'
|
|
|
+ }
|
|
|
]
|
|
|
}
|
|
|
};
|
|
|
@@ -292,17 +331,17 @@ export default {
|
|
|
this.dialogVisible = val;
|
|
|
}
|
|
|
if (!val) {
|
|
|
- this.$refs.baseForm?.clearValidate()
|
|
|
- this.baseForm = { areaId:'' }
|
|
|
- this.$emit('closeHandler')
|
|
|
- this.cusareaName = ''
|
|
|
- this.clearItem()
|
|
|
+ this.$refs.baseForm?.clearValidate();
|
|
|
+ this.baseForm = { areaId: '' };
|
|
|
+ this.$emit('closeHandler');
|
|
|
+ this.cusareaName = '';
|
|
|
+ this.clearItem();
|
|
|
}
|
|
|
},
|
|
|
'baseForm.farmerAreasize': {
|
|
|
handler(val) {
|
|
|
- if (this.yieldPer > 0) {
|
|
|
- this.baseForm.farmerWramount = Number(this.yieldPer) * val
|
|
|
+ if (this.yieldPer > 0) {
|
|
|
+ this.baseForm.farmerWramount = Number(this.yieldPer) * val;
|
|
|
}
|
|
|
},
|
|
|
deep: true,
|
|
|
@@ -310,12 +349,12 @@ export default {
|
|
|
},
|
|
|
editFarmerData: {
|
|
|
handler(val) {
|
|
|
- if (this.isEdit && val?.areaId) {
|
|
|
- this.baseForm = { ...val }
|
|
|
- this.handlerClick(val)
|
|
|
+ if (this.isEdit && val?.areaId) {
|
|
|
+ this.baseForm = { ...val };
|
|
|
+ this.handlerClick(val);
|
|
|
} else {
|
|
|
- this.baseForm = { areaId: '' }
|
|
|
- this.cusareaName = ''
|
|
|
+ this.baseForm = { areaId: '' };
|
|
|
+ this.cusareaName = '';
|
|
|
}
|
|
|
},
|
|
|
deep: true
|
|
|
@@ -329,79 +368,85 @@ export default {
|
|
|
},
|
|
|
'baseForm.areaId': {
|
|
|
handler(val) {
|
|
|
- val && this.$refs.baseForm?.clearValidate('areaId')
|
|
|
+ val && this.$refs.baseForm?.clearValidate('areaId');
|
|
|
},
|
|
|
deep: true
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
- setItem(value) {
|
|
|
- this.areaAll = value?.waterrightAreasize || '0'
|
|
|
- this.areaAll = (+this.areaAll).toFixed(2)
|
|
|
- this.waterRightAll = value?.waterrightAmount || '0'
|
|
|
- this.waterRightAll = (+this.waterRightAll).toFixed(2)
|
|
|
- this.yieldPer = value ? value?.waterrightAmount == 0 ? 0 : (value?.waterrightAreasize) / (value?.waterrightAmount) : 0
|
|
|
- this.yieldPer = (+this.yieldPer).toFixed(2)
|
|
|
- this.residualWaterRight = value?.amountResidue ?? 0
|
|
|
- this.areasizeResidue = value?.areasizeResidue ?? 0
|
|
|
- this.residualWaterRight = (+this.residualWaterRight).toFixed(2)
|
|
|
+ setItem(value) {
|
|
|
+ this.areaAll = value?.waterrightAreasize || '0';
|
|
|
+ this.areaAll = (+this.areaAll).toFixed(2);
|
|
|
+ this.waterRightAll = value?.waterrightAmount || '0';
|
|
|
+ this.waterRightAll = (+this.waterRightAll).toFixed(2);
|
|
|
+ this.yieldPer = value
|
|
|
+ ? value?.waterrightAreasize == 0
|
|
|
+ ? 0
|
|
|
+ : value?.waterrightAmount / value?.waterrightAreasize
|
|
|
+ : 0;
|
|
|
+ this.yieldPer = (+this.yieldPer).toFixed(2);
|
|
|
+ this.residualWaterRight = value?.amountResidue ?? 0;
|
|
|
+ this.areasizeResidue = value?.areasizeResidue ?? 0;
|
|
|
+
|
|
|
+ console.log(value, 'set item ------ 1212333');
|
|
|
+ this.residualWaterRight = (+this.residualWaterRight).toFixed(2);
|
|
|
},
|
|
|
- clearItem() {
|
|
|
- this.areaAll = 0.00
|
|
|
- this.waterRightAll = 0.00
|
|
|
- this.yieldPer = 0.00
|
|
|
- this.residualWaterRight = 0.00
|
|
|
+ clearItem() {
|
|
|
+ this.areaAll = 0.0;
|
|
|
+ this.waterRightAll = 0.0;
|
|
|
+ this.yieldPer = 0.0;
|
|
|
+ this.residualWaterRight = 0.0;
|
|
|
},
|
|
|
- findItemByAreaId(areaId,list) {
|
|
|
- return list.find(item => item.areaId === areaId)
|
|
|
+ findItemByAreaId(areaId, list) {
|
|
|
+ return list.find((item) => item.areaId === areaId);
|
|
|
},
|
|
|
async handlerClick(item) {
|
|
|
const res = await getAreaInfo({
|
|
|
waterrightYear: new Date().getFullYear(),
|
|
|
areaId: item.areaId
|
|
|
- })
|
|
|
- this.currentItem = item
|
|
|
- const value = res?.data
|
|
|
- this.cusareaName = item?.cusareaName
|
|
|
- const areaId = item?.areaId || ''
|
|
|
- this.baseForm.areaId = areaId
|
|
|
- this.$set(this.baseForm,'areaId', areaId)
|
|
|
- this.setItem(value)
|
|
|
+ });
|
|
|
+ this.currentItem = item;
|
|
|
+ const value = res?.data;
|
|
|
+ this.cusareaName = item?.cusareaName;
|
|
|
+ const areaId = item?.areaId || '';
|
|
|
+ this.baseForm.areaId = areaId;
|
|
|
+ this.$set(this.baseForm, 'areaId', areaId);
|
|
|
+ this.setItem(value);
|
|
|
},
|
|
|
resetForm() {
|
|
|
this.dialogVisible = false;
|
|
|
- this.cusareaName = ''
|
|
|
+ this.cusareaName = '';
|
|
|
},
|
|
|
async handlerAddFarmer() {
|
|
|
if (this.currentItem?.children?.length > 0) {
|
|
|
- Message.warning('请选择最小行政区块')
|
|
|
- return
|
|
|
- }
|
|
|
- if(!this.isEdit){
|
|
|
- const res = await addFarmer(this.baseForm)
|
|
|
- if(res?.code === "000000") {
|
|
|
- this.handleClose()
|
|
|
- this.cusareaName = ''
|
|
|
- this.$emit('refresh')
|
|
|
+ Message.warning('请选择最小行政区块');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (!this.isEdit) {
|
|
|
+ const res = await addFarmer(this.baseForm);
|
|
|
+ if (res?.code === '000000') {
|
|
|
+ this.handleClose();
|
|
|
+ this.cusareaName = '';
|
|
|
+ this.$emit('refresh');
|
|
|
}
|
|
|
- }else{
|
|
|
- const res = await editFarmer(this.baseForm)
|
|
|
- if(res?.code === "000000") {
|
|
|
- this.handleClose()
|
|
|
- this.cusareaName = ''
|
|
|
- this.$emit('refresh')
|
|
|
+ } else {
|
|
|
+ const res = await editFarmer(this.baseForm);
|
|
|
+ if (res?.code === '000000') {
|
|
|
+ this.handleClose();
|
|
|
+ this.cusareaName = '';
|
|
|
+ this.$emit('refresh');
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
submitForm(formName) {
|
|
|
this.$refs[formName].validate((valid) => {
|
|
|
- valid && this.handlerAddFarmer()
|
|
|
- })
|
|
|
+ valid && this.handlerAddFarmer();
|
|
|
+ });
|
|
|
},
|
|
|
handleClose() {
|
|
|
this.$emit('update:visible', false);
|
|
|
this.resetForm('baseForm');
|
|
|
- },
|
|
|
+ }
|
|
|
}
|
|
|
};
|
|
|
</script>
|
|
|
@@ -410,18 +455,18 @@ export default {
|
|
|
.input-number {
|
|
|
width: 100%;
|
|
|
}
|
|
|
-.el-col-5{
|
|
|
- width:auto;
|
|
|
+.el-col-5 {
|
|
|
+ width: auto;
|
|
|
min-width: 20%;
|
|
|
}
|
|
|
-.area{
|
|
|
- margin:0 0 20px 20px;
|
|
|
+.area {
|
|
|
+ margin: 0 0 20px 20px;
|
|
|
display: flex;
|
|
|
- .el-col{
|
|
|
+ .el-col {
|
|
|
min-width: 25%;
|
|
|
}
|
|
|
- label{
|
|
|
- color:#999;
|
|
|
+ label {
|
|
|
+ color: #999;
|
|
|
font-weight: 400;
|
|
|
font-size: 14px;
|
|
|
}
|
|
|
@@ -432,11 +477,11 @@ export default {
|
|
|
overflow-x: hidden;
|
|
|
padding: 0 20px;
|
|
|
}
|
|
|
-.history{
|
|
|
+.history {
|
|
|
text-align: right;
|
|
|
line-height: 32px;
|
|
|
- span{
|
|
|
- color:rgb(20, 164, 120);
|
|
|
+ span {
|
|
|
+ color: rgb(20, 164, 120);
|
|
|
cursor: pointer;
|
|
|
}
|
|
|
}
|