From 7c194e9147ea56ee47cd1100b1167331c37b8206 Mon Sep 17 00:00:00 2001
From: guoshilong <123456>
Date: Mon, 17 Oct 2022 11:42:57 +0800
Subject: [PATCH] 设置结束时间不能在种植之前
---
src/views/farmplant/farmplant.vue | 110 ++++++++++++++++++++----------------------------------
1 files changed, 41 insertions(+), 69 deletions(-)
diff --git a/src/views/farmplant/farmplant.vue b/src/views/farmplant/farmplant.vue
index 1a333b1..e88c529 100644
--- a/src/views/farmplant/farmplant.vue
+++ b/src/views/farmplant/farmplant.vue
@@ -42,11 +42,12 @@
<div class="block">
<span class="demonstration">结束时间</span>
<el-date-picker
- v-model="endPlantTime"
- type="date"
- placeholder="选择日期"
- value-format="yyyy-MM-dd"
- align="center">
+ v-model="endPlantTime"
+ type="date"
+ placeholder="选择日期"
+ value-format="yyyy-MM-dd"
+ align="center"
+ :picker-options="pickOptions">
</el-date-picker>
</div>
<span slot="footer" class="dialog-footer">
@@ -106,7 +107,7 @@
},
selectionList: [],
landList: [],
- landId: 0,
+ landId: "",
option: {
tip: false,
height: 520,
@@ -125,25 +126,6 @@
expandFixed: false,
menuFixed: false,
column: [
- // {
- // label: "类型",
- // prop: "farmType",
- // type: "select",
- // labelWidth:110,
- // dicUrl: "/api/blade-system/dict-biz/dictionary?code=strainType",
- // props: {
- // label: "dictValue",
- // value: "dictKey"
- // },
- // cascader: ["strainId"],
- // rules: [
- // {
- // required: true,
- // message: "请输入类型",
- // trigger: "blur",
- // },
- // ],
- // },
{
label: "种养品",
prop: "strainId",
@@ -184,9 +166,10 @@
// search:true,
// searchSpan:5,
labelWidth: 110,
+ maxlength:40,
rules: [
{
- required: true,
+ required: false,
message: "请输入种养品名称",
trigger: "blur",
},
@@ -309,7 +292,7 @@
labelWidth: 110,
rules: [
{
- required: true,
+ required: false,
message: "请选择所属农场",
trigger: "blur",
},
@@ -331,7 +314,7 @@
labelWidth: 110,
rules: [
{
- required: true,
+ required: false,
message: "请选择农产品",
trigger: "blur",
},
@@ -499,7 +482,9 @@
data: [],
endPlantTime:"",
//结束种养时的传输数据
- overData:""
+ overData:"",
+ //选择结束种养时的日期范围
+ pickOptions:{},
}
},
watch: {
@@ -778,17 +763,14 @@
if (["edit", "view"].includes(type)) {
getDetail(this.form.id).then((res) => {
var data = res.data.data
- if(data.per == -1){
- data.per = ""
+ if(data.per <= 0){
+ data.per = undefined
}
- if(data.plantNumber == -1){
- data.plantNumber = ""
+ if(data.plantNumber <= 0){
+ data.plantNumber = undefined
}
- if(data.plantSpacing == -1){
- data.plantSpacing = ""
- }
- if(data.breed == -1){
- data.breed = ""
+ if(data.plantSpacing <= 0){
+ data.plantSpacing = undefined
}
this.form = data
})
@@ -822,10 +804,13 @@
this.onLoad(this.page, this.query)
},
onLoad (page, params = {}) {
- var datas = this.$route.query.id
- params.landId = datas
- if (this.landId) {
- params['landId'] = this.landId
+ // var datas = this.$route.query.id
+ // params.landId = datas
+ // if (this.landId) {
+ // params['landId'] = this.landId
+ // }
+ if (this.$route.query.id){
+ params.landId = this.$route.query.id
}
params['tenantId'] = this.userInfo.tenant_id
params['farmId'] = this.$farmId
@@ -856,29 +841,6 @@
this.$refs.recovery.init(data)
})
},
- // 结束种植
- // over(id) {
- // var that = this
- // that.$confirm("确定结束当前种植的农产品?", {
- // confirmButtonText: "确定",
- // cancelButtonText: "取消",
- // type: "warning",
- // })
- // .then(() => {
- // const data = {
- // id: id,
- // status: 2,
- // }
- // return update(data)
- // })
- // .then(() => {
- // that.onLoad(this.page, this.query)
- // that.$message({
- // type: "success",
- // message: "操作成功!",
- // })
- // })
- // },
//结束种植
over(){
this.overData.endPlantTime = this.endPlantTime
@@ -887,16 +849,26 @@
status:2,
endPlantTime:this.overData.endPlantTime
}
- update(data).then((res)=>{
+ if (!data.endPlantTime){
+ this.$message.warning("请选择结束时间")
+ }else {
+ update(data).then((res)=>{
if(res.data.code == 200){
- this.onLoad(this.page, this.query)
+ this.onLoad(this.page, this.query)
}
- })
- this.overVisible = false
+ })
+ this.overVisible = false
+ }
+
},
getData(row){
this.overVisible = true
this.overData = row
+ this.pickOptions = {
+ disabledDate(time) {
+ return time.getTime() < new Date(row.transplanTime).getTime() - 8.64e6;
+ }
+ }
}
},
};
--
Gitblit v1.9.3