Browse Source

能源计划优化——时间段新增

wyh 1 year ago
parent
commit
4f38ec91ad
1 changed files with 18 additions and 3 deletions
  1. 18 3
      src/views/module_base/energyPlan/modules/EnergyPlanForm.vue

+ 18 - 3
src/views/module_base/energyPlan/modules/EnergyPlanForm.vue

@@ -15,7 +15,10 @@
           </a-col>
           </a-col>
           <a-col :span="24">
           <a-col :span="24">
             <a-form-model-item label="计划日期" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="plandate">
             <a-form-model-item label="计划日期" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="plandate">
-              <j-date placeholder="请选择计划日期" v-model="model.plandate"  style="width: 100%" />
+              <!-- 编辑/单天新增 -->
+              <j-date v-if="statusButton == 1" placeholder="请选择计划日期" v-model="model.plandate" style="width: 100%" />
+              <!-- 时间段新增 -->
+              <a-range-picker v-if="statusButton == 2" date-format="YYYY-MM-DD" v-model="model.plandate" @change="onChangeDate" style="width: 100%" />
             </a-form-model-item>
             </a-form-model-item>
           </a-col>
           </a-col>
           <a-col :span="24">
           <a-col :span="24">
@@ -61,6 +64,7 @@
         model:{
         model:{
           equipmentcode: ''
           equipmentcode: ''
         },
         },
+        statusButton: '',
         labelCol: {
         labelCol: {
           xs: { span: 24 },
           xs: { span: 24 },
           sm: { span: 5 },
           sm: { span: 5 },
@@ -85,7 +89,8 @@
            ],
            ],
         },
         },
         url: {
         url: {
-          add: "/energyPlan/energyPlan/add",
+          // add: "/energyPlan/energyPlan/add",
+          add: "/energyPlan/energyPlan/rangeAdd",
           edit: "/energyPlan/energyPlan/edit",
           edit: "/energyPlan/energyPlan/edit",
           queryById: "/energyPlan/energyPlan/queryById",
           queryById: "/energyPlan/energyPlan/queryById",
           queryByDeviceId: "/tpmEquipment/tpmEquipment/queryById"
           queryByDeviceId: "/tpmEquipment/tpmEquipment/queryById"
@@ -102,6 +107,12 @@
       this.modelDefault = JSON.parse(JSON.stringify(this.model));
       this.modelDefault = JSON.parse(JSON.stringify(this.model));
     },
     },
     methods: {
     methods: {
+      // 时间处理
+      onChangeDate(date, dateString){
+        console.log(date, dateString);
+        this.model.beginTime= dateString[0]
+        this.model.endTime= dateString[1]
+      },
       handleChange(value){
       handleChange(value){
         console.log(111,value)
         console.log(111,value)
         getAction(this.url.queryByDeviceId, {id:value}).then((res) => {
         getAction(this.url.queryByDeviceId, {id:value}).then((res) => {
@@ -110,10 +121,13 @@
         })
         })
       },
       },
       add () {
       add () {
-        this.edit(this.modelDefault);
+        // this.edit(this.modelDefault);
+        this.statusButton =2
+        this.visible = true;
       },
       },
       edit (record) {
       edit (record) {
         this.model = Object.assign({}, record);
         this.model = Object.assign({}, record);
+        this.statusButton =1
         this.visible = true;
         this.visible = true;
       },
       },
       submitForm () {
       submitForm () {
@@ -127,6 +141,7 @@
             if(!this.model.id){
             if(!this.model.id){
               httpurl+=this.url.add;
               httpurl+=this.url.add;
               method = 'post';
               method = 'post';
+              this.model.plandate = ''
             }else{
             }else{
               httpurl+=this.url.edit;
               httpurl+=this.url.edit;
                method = 'put';
                method = 'put';