From fee1948081e9cecc1de29ee5029f737aef2dcb38 Mon Sep 17 00:00:00 2001
From: lzhe <lzhe@example.com>
Date: 星期二, 01 十月 2024 20:43:43 +0800
Subject: [PATCH] Merge branch 'release' of http://122.9.151.159:9090/r/smart-web into release

---
 src/views/console/base/Add.vue |   36 +++++++++++++++++++++++++++++-------
 1 files changed, 29 insertions(+), 7 deletions(-)

diff --git a/src/views/console/base/Add.vue b/src/views/console/base/Add.vue
index 6c89b54..7af35ce 100644
--- a/src/views/console/base/Add.vue
+++ b/src/views/console/base/Add.vue
@@ -1,8 +1,8 @@
 <!--
  * @Date: 2024-05-04 16:37:48
- * @LastEditors: Sneed
- * @LastEditTime: 2024-05-05 21:02:54
- * @FilePath: /belleson-frontend/Users/mache/Documents/demo/cps-web/src/views/console/base/Add.vue
+ * @LastEditors: gaoshp
+ * @LastEditTime: 2024-10-01 20:21:11
+ * @FilePath: /cps-web/src/views/console/base/Add.vue
 -->
 <template>
     <el-container>
@@ -23,7 +23,7 @@
                         </el-col>
                         <el-col :span="8">
                             <el-form-item label="搴旂敤骞翠唤" prop="year">
-                                <el-select v-model="form.year" placeholder="" size="" @change="change">
+                                <el-select v-model="form.year" placeholder="" size="" @change="changeYear">
                                     <el-option v-for="item in options" :key="item.value" :label="item.label"
                                         :value="item.value" />
                                 </el-select>
@@ -196,16 +196,31 @@
         }
     },
     watch: {
+
         holiday() {
             this.setDay()
         },
         checkboxGroup1() {
             this.setDay()
         },
+        dateDTOList(val) {
+            this.months.forEach(month => {
+                if (val.length > 0) {
+                    month.attributes[1].highlight = 'yellow'
+                } else {
+                    month.attributes[1].highlight = true
+                }
+
+            })
+        },
         'form.year'(val) {
             this.months = []
             let currentYear = moment(val, 'YYYY').format('YYYY') - 0
 
+            this.form.date = [`${currentYear}-01-01`, `${currentYear}-12-31`]
+            if (currentYear == moment().format('YYYY')) {
+                this.form.date[0] = moment().format('YYYY-MM-DD')
+            }
             // console.log(this.months)
             this.$HTTP.post('/api/blade-cps/shift-off-day/list', {
                 year: currentYear,
@@ -228,7 +243,7 @@
                         year: currentYear,
                         month: i,
                         id: `${currentYear}${i}`,
-                        min: new Date('2024-01-01'),
+                        min: new Date(`${currentYear}-01-01`),
                         attributes: [
                             {
                                 dot: 'yellow',
@@ -284,7 +299,7 @@
             let currentYear = moment(this.form.year, 'YYYY').format('YYYY') - 0
             this.months.forEach((item, i) => {
                 let start = moment(`${currentYear}-${i + 1}-01`)
-                let end = moment(`${currentYear}-${i + 2}-01`)
+                let end = i == 11 ? moment(`${currentYear + 1}-${i + 1}-01`) : moment(`${currentYear}-${i + 2}-01`)
                 let dates = []
                 console.log(start.format('YYYY-MM-DD'), start.unix() >= moment(this.form.date[0]).unix() && start.unix() <= moment(this.form.date[1]).unix())
                 while (start.unix() < end.unix()) {
@@ -302,6 +317,7 @@
                     start.add(1, 'd')
                 }
                 this.months[i].attributes[1].dates = dates
+                console.log(this.months, 'jieguo')
             })
         },
         pushDate(start) {
@@ -322,7 +338,11 @@
             console.log(index, item.attributes[1].dates)
         },
         plan() {
+            if (!this.modelId) {
+                return this.$message.warning('璇烽�夋嫨鐝鏂规');
+            }
             let dateDTOList = this.months.map(item => item.attributes[1].dates)
+            console.log(this.months, '>>>>>>>>>>', dateDTOList.flat(2))
             let list = dateDTOList.flat(2).map(v => {
                 return {
                     modelId: this.modelId,
@@ -343,7 +363,7 @@
             }
         },
         planCancel() {
-
+            this.dateDTOList = []
         },
         save() {
             this.$refs.dialogForm.validate(async (valid) => {
@@ -367,6 +387,8 @@
                         }
                     })
                     console.log(this.form, this.dateDTOList)
+                } else {
+                    this.$message.warning('璇锋鏌ュ繀濉」');
                 }
             })
         }

--
Gitblit v1.9.3