Browse Source

日报表排程设置为多选

yuhan 2 months ago
parent
commit
381e7e1b4f

+ 52 - 17
src/views/module_interLock/baseScheduleSet/modules/BaseScheduleSetModal.vue

@@ -26,7 +26,28 @@
           <j-easy-cron v-model="model.cronExpression" />
         </a-form-model-item> -->
         <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="生成报表时间" prop="time">
-          <a-cascader :options="options" v-model="model.time" placeholder="请选择" @change="onChange"/>
+          <template v-if="model.parameter === 'day'">
+            <!-- <a-select default-value="每日" style="width: 120px">
+              <a-select-option v-for="(item, index) in ['每日']" :key="index">
+                {{ item }}
+              </a-select-option>
+            </a-select> -->
+            <span class="day-text">每日</span>
+            <a-select
+              allowClear
+              mode="multiple"
+              v-model="model.time"
+              style="width: calc(100% - 66px)"
+              @change="handleChangeDay"
+              placeholder="请选择">
+              <a-select-option v-for="(item) in dayOptions" :key="item.value" :value="item.value">
+                {{ item.label }}
+              </a-select-option>
+            </a-select>
+          </template>
+          <template v-else>
+            <a-cascader :options="options" v-model="model.time" placeholder="请选择" @change="onChange"/>
+          </template>
         </a-form-model-item>
         <!-- <a-form-model-item  :labelCol="labelCol" :wrapperCol="wrapperCol" label="参数" prop="parameter" >
           <a-textarea placeholder="请输入参数" :rows="5" v-model="model.parameter" />
@@ -68,6 +89,7 @@
           value: ''
         },
         options: [],
+        dayOptions: [],
         confirmLoading: false,
         validatorRules: {
           cronExpression: [
@@ -93,7 +115,7 @@
         })
       },
       edit (record) {
-        console.log(record)
+        // console.log(record)
         if (record.parameter == 'day') {
           this.dayOption()
         }
@@ -107,11 +129,11 @@
         this.$nextTick(() => {
           this.$refs.form.resetFields()
           let cronExpression = record.cronExpression.split(" ");
-          console.log(cronExpression);
+          // console.log(cronExpression);
           this.model = Object.assign({}, record)
           if (record.parameter == 'day') {
-            this.model.time = []
-            this.model.time.push("每日", Number(cronExpression[2]))
+            this.model.time = cronExpression[2].split(',')
+            // this.model.time.push("每日", Number(cronExpression[2]))
           }
           if (record.parameter == 'month') {
             this.model.time = []
@@ -121,22 +143,23 @@
             this.model.time = []
             this.model.time.push("每年", Number(cronExpression[4]), Number(cronExpression[3]), Number(cronExpression[2]))
           }
-           console.log(77,this.model);
+          //  console.log(77,this.model);
         })
       },
       // 日报表
       dayOption(){
         let time = Array.from({length: 24}, (_, index) => ({
-            value: index,
+            value: index + '',
             label: `${index}:00`
         }));
-        this.options = [
-          {
-            value: '每日',
-            label: '每日',
-            children: time,
-          },
-        ]
+        this.dayOptions = time
+        // this.options = [
+        //   {
+        //     value: '每日',
+        //     label: '每日',
+        //     children: time,
+        //   },
+        // ]
       },
       // 月报表
       monthOption(){
@@ -253,7 +276,7 @@
         console.log('提交参数',this.model)
         let time = this.model.time
         if (this.model.parameter == 'day') {
-          this.model.cronExpression = "0 0 " + time[1] +" * * ? *"
+          this.model.cronExpression = "0 0 " + time.join(',') +" * * ? *"
         }
         if (this.model.parameter == 'month') {
           this.model.cronExpression = "0 0 " + time[2] + " " + time[1] +" * ? *"
@@ -280,10 +303,22 @@
       onChange(value) {
         this.model ={...this.model}
       },
+      handleChangeDay(e){
+        this.model = {...this.model}
+      },
     }
   }
 </script>
 
-<style scoped>
-
+<style lang="less" scoped>
+  .day-text{
+    display: inline-block;
+    border: 1px solid #d9d9d9;
+    border-radius: 4px;
+    height: 32px;
+    line-height: 30px;
+    padding-left: 15px ;
+    padding-right: 15px;
+    margin-right: 6px;
+  }
 </style>