Sfoglia il codice sorgente

fix::日程调整

liujiayin 2 anni fa
parent
commit
1e61621a18

+ 1 - 0
src/views/platform/desktop/column/preview.vue

@@ -25,6 +25,7 @@
                 :ref="desktopColumn.alias"
                 :alias="desktopColumn.alias"
                 :visible="componentVisible"
+                :full-calendar="true"
                 @action-event="actionEvent"
             />
 

+ 75 - 3
src/views/system/dashboard/components/util.js

@@ -7,6 +7,7 @@ import Utils from '@/utils/util'
 import { findAllByCurrUserId, saveCalendarInfos, removeCalendarInfos } from '@/api/detection/newHomeApi'
 import { delQuickNavigation, addQuickNavigation, getQuickNavigation } from '@/api/platform/message/innerMessage'
 import newPng from '@/assets/images/homepage/new.png'
+import ScheduleAdd from '@/views/system/dashboard/templates/scheduleAdd'
 
 /**
  * 创建组件
@@ -16,7 +17,8 @@ export function buildComponent (name, column, preview) {
         return {
             name: name,
             components: {
-                VueDraggable: () => import('vuedraggable')
+                VueDraggable: () => import('vuedraggable'),
+                ScheduleAdd
             },
             props: {
                 params: {
@@ -30,6 +32,10 @@ export function buildComponent (name, column, preview) {
                 visible: {
                     type: Boolean,
                     default: false
+                },
+                fullCalendar: {
+                    type: Boolean,
+                    default: false
                 }
             },
             filters: {
@@ -136,7 +142,10 @@ export function buildComponent (name, column, preview) {
                         disabled: false,
                         animation: 200,
                         axis: 'y'
-                    }
+                    },
+                    calendarToolbar:this.fullCalendar ? [{key: 'refresh'}]: [{key: 'refresh'}, {key: 'fullscreen'}, {key: 'collapse'}],
+                    calendarDialogVisible: false,
+                    calendarDialogForm: {},
                 }
             },
             computed: {
@@ -288,7 +297,7 @@ export function buildComponent (name, column, preview) {
                         config.headerToolbar = {
                             start: '',
                             center: 'title',
-                            end: 'prev,next,today,dayGridMonth,listMonth'
+                            end: 'prev,next,today'
                             //  end: 'prev,next,today,month,agendaWeek,agendaDay,listWeek'
                         }
                         delete config['dayMaxEvents']
@@ -490,6 +499,69 @@ export function buildComponent (name, column, preview) {
                         return val.slice(0, length - 2) + '...'
                     }
                     return val
+                },
+                // 关闭指定弹框
+                handleCloseCalendarDialog (state) {
+                    switch (state) {
+                        case 'calendar':
+                            this.calendarDialogVisible = false
+                            break
+                        default:
+                            break
+                    }
+                },
+                // 打开指定弹框
+                handleOpen (state, dateArr, events) {
+                    const status = ['急', '重', '轻', '缓']
+                    const eventTrees = []
+                    console.log('517 events',events)
+                    switch (state) {
+                        case 'calendar':
+                            this.calendarDialogVisible = true
+                            for (const i of events) {
+                                // 根据指定日期A获取A在时间区间内的数据
+                                if (!((this.compareDates(i.start, dateArr[1]) > 0) || (this.compareDates(i.jieShuShiJian, dateArr[0]) < 0))) {
+                                    i.label = i.zhuangTai?`【${status[Number(i.zhuangTai) - 1] ? status[Number(i.zhuangTai) - 1] : ''}】` + i.title:i.title
+                                    eventTrees.push(i)
+                                }
+                            }
+                            if (eventTrees.length) {
+                                this.calendarDialogForm = {
+                                    eventTrees
+                                }
+                            } else {
+                                this.calendarDialogForm = {
+                                    eventTrees: []
+                                }
+                            }
+                            this.calendarDialogForm.clickedDate = dateArr[0]
+                            this.calendarDialogForm.clickedId = events.
+                            break
+                        default:
+                            break
+                    }
+                },
+                /**
+                 * date1(2024-01-01) 大于 date2(2023-01-01) 返回 1
+                 * date1 小于 date2 返回 -1
+                 * date1 等于 date2 返回 0
+                 */
+                compareDates (date1, date2) {
+                    var time1 = new Date(date1).getTime()
+                    var time2 = new Date(date2).getTime()
+                    return Math.sign(time1 - time2) // 使用Math.sign()函数返回值为 -1, 0, 1
+                },
+                // 日历弹框组件保存时候的回调
+                handleSaveData (param) {
+                    if (param.state === 'calendar') {
+                        this.$refs.myCalendar[0].setCalendarEvents(param)
+                    }
+                },
+                // 日历弹框组件删除日程时候的回调
+                handleDelData (param) {
+                    if (param.state === 'calendar') {
+                        this.$refs.myCalendar[0].hanldeCalendardel(param)
+                    }
                 }
             },
             template: column.templateHtml !== '' ? `${column.templateHtml}` : `<div></div>`

+ 18 - 13
src/views/system/dashboard/templates/myCalendar.vue

@@ -1,18 +1,23 @@
 <template>
     <el-card :style="{height: cardHeight}" class="home-card changeShadow">
-        <div slot="header" class="clearfix">
-            <i class="el-icon-date" />
-            <span>{{ title }}</span>
-            <ibps-desktop-toolbar
-                ref="toolbar"
-                :actions="[{key: 'refresh'}, {key: 'fullscreen'}, {key: 'collapse'}]"
-                @action-event="handleActionEvent"
+    <div slot="header" class="clearfix">
+        <i class="el-icon-date" />
+        <span>{{ title }}</span>
+        <ibps-desktop-toolbar
+            ref="toolbar"
+            :actions="calendarToolbar"
+            @action-event="handleActionEvent"
+        />
+    </div>
+    <transition name="draw" mode="in-out" appear>
+        <div ref="body" :style="{height: showHeight, width: '100%'}" class="text item">
+            <v-full-calendar
+                ref="calendar"
+                :options="getFullCalendarConfig(data)"
+                :style="{height: getHeight(), width: '100%'}"
             />
         </div>
-        <transition name="draw" mode="in-out" appear>
-            <div ref="body" :style="{height: showHeight, width:'100%'}" class="text item">
-                <v-full-calendar :options="getFullCalendarConfig(data)" :style="{height:getHeight(),width:'100%'}" />
-            </div>
-        </transition>
-    </el-card>
+    </transition>
+  <schedule-add :visible="calendarDialogVisible" :form="calendarDialogForm" @close="handleCloseCalendarDialog" @saveData="handleSaveData" @delData="handleDelData" />
+</el-card>
 </template>

+ 24 - 5
src/views/system/dashboard/templates/scheduleAdd.vue

@@ -60,7 +60,7 @@
                         value-format="yyyy-MM-dd"
                     />
                 </el-form-item>
-                <el-form-item label="紧急状态:">
+                <el-form-item label="紧急状态:" prop="zhuangTai">
                     <el-radio-group
                         v-model="calendarForm.zhuangTai"
                         size="small"
@@ -79,10 +79,11 @@
             </el-col>
         </el-form>
         <div slot="footer" class="dialog-footer">
+            <el-button  plain @click="clear">清 空</el-button>
             <el-button type="success" plain @click="saveAndAdd">保存并新增</el-button>
             <el-button type="primary" plain @click="saveEvent">保 存</el-button>
             <el-button type="danger" plain @click="delEvent">删 除</el-button>
-            <el-button style="float: rihgt" plain @click="closeDialog">取 消</el-button>
+            <el-button style="float: rihgt" plain @click="closeDialog">关 闭</el-button>
         </div>
     </el-dialog>
 </template>
@@ -109,14 +110,23 @@ export default {
                     { required: true, message: this.$t('validate.required') },
                     {
                         min: 1,
-                        max: 20,
-                        message: '长度不能超过20个字符',
+                        max: 200,
+                        message: '长度不能超过200个字符',
                         trigger: 'blur'
                     }
                 ],
                 formDate: [
                     { required: true, message: this.$t('validate.required') }
-                ]
+                ],
+                zhuangTai: [
+                    { required: true, message: this.$t('validate.required') },
+                    {
+                        min: 1,
+                        max: 2000,
+                        message: '长度不能超过2000个字符',
+                        trigger: 'blur'
+                    }
+                ],
             },
             pickerOptions: {
                 shortcuts: [
@@ -200,6 +210,15 @@ export default {
         }
     },
     methods: {
+        clear(){
+            this.calendarForm = {
+                id: '',
+                biaoTi: '',
+                neiRong: '',
+                formDate: [],
+                zhuangTai: ''
+            } 
+        },
         saveAndAdd () {
             this.$refs.form.validate((valid) => {
                 if (valid) {

+ 2 - 1
src/views/system/homepage/index.vue

@@ -591,13 +591,14 @@ export default {
         handleOpen (state, dateArr, events) {
             const status = ['急', '重', '轻', '缓']
             const eventTrees = []
+            console.log('594 events',events)
             switch (state) {
                 case 'calendar':
                     this.calendarDialogVisible = true
                     for (const i of events) {
                         // 根据指定日期A获取A在时间区间内的数据
                         if (!((this.compareDates(i.start, dateArr[1]) > 0) || (this.compareDates(i.jieShuShiJian, dateArr[0]) < 0))) {
-                            i.label = `(${status[Number(i.zhuangTai) - 1] ? status[Number(i.zhuangTai) - 1] : ''})` + i.title
+                            i.label = i.zhuangTai?`(${status[Number(i.zhuangTai) - 1] ? status[Number(i.zhuangTai) - 1] : ''})` + i.title:i.title
                             eventTrees.push(i)
                         }
                     }