|
@@ -0,0 +1,571 @@
|
|
|
|
|
+import {
|
|
|
|
|
+ getMemoList,
|
|
|
|
|
+ getMemoDetail,
|
|
|
|
|
+ addMemo,
|
|
|
|
|
+ updateMemo,
|
|
|
|
|
+ deleteMemo,
|
|
|
|
|
+ deleteMemoBatch,
|
|
|
|
|
+} from '@/api/memoManage.js'
|
|
|
|
|
+import { getAuditTaskList } from '@/api/auditInitiation.js'
|
|
|
|
|
+import moment from 'moment'
|
|
|
|
|
+
|
|
|
|
|
+export const memoManageMixin = {
|
|
|
|
|
+ data() {
|
|
|
|
|
+ // 表格列配置
|
|
|
|
|
+ const tableColumns = [
|
|
|
|
|
+ {
|
|
|
|
|
+ prop: 'reminderType',
|
|
|
|
|
+ label: '提醒',
|
|
|
|
|
+ width: 80,
|
|
|
|
|
+ headerAlign: 'center',
|
|
|
|
|
+ align: 'center',
|
|
|
|
|
+ slotName: 'reminder-type',
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ prop: 'projectName',
|
|
|
|
|
+ label: '成本监审任务',
|
|
|
|
|
+ width: 160,
|
|
|
|
|
+ headerAlign: 'center',
|
|
|
|
|
+ align: 'center',
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ prop: 'memoDate',
|
|
|
|
|
+ label: '日期',
|
|
|
|
|
+ width: 120,
|
|
|
|
|
+ headerAlign: 'center',
|
|
|
|
|
+ align: 'center',
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ prop: 'title',
|
|
|
|
|
+ label: '标题',
|
|
|
|
|
+ width: 120,
|
|
|
|
|
+ headerAlign: 'center',
|
|
|
|
|
+ align: 'center',
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ prop: 'content',
|
|
|
|
|
+ label: '内容',
|
|
|
|
|
+ minWidth: 200,
|
|
|
|
|
+ headerAlign: 'center',
|
|
|
|
|
+ align: 'center',
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ prop: 'action',
|
|
|
|
|
+ label: '操作',
|
|
|
|
|
+ width: 150,
|
|
|
|
|
+ headerAlign: 'center',
|
|
|
|
|
+ align: 'center',
|
|
|
|
|
+ slotName: 'action-buttons',
|
|
|
|
|
+ showOverflowTooltip: false,
|
|
|
|
|
+ },
|
|
|
|
|
+ ]
|
|
|
|
|
+
|
|
|
|
|
+ // 按项目查询标签页的表格列配置(项目名称列宽更大)
|
|
|
|
|
+ const projectTableColumns = [
|
|
|
|
|
+ ...tableColumns.map((col) => {
|
|
|
|
|
+ if (col.prop === 'projectName') {
|
|
|
|
|
+ return { ...col, width: 220 }
|
|
|
|
|
+ } else if (col.prop === 'title') {
|
|
|
|
|
+ return { ...col, width: 200 }
|
|
|
|
|
+ } else if (col.prop === 'content') {
|
|
|
|
|
+ return { ...col, minWidth: 300 }
|
|
|
|
|
+ }
|
|
|
|
|
+ return col
|
|
|
|
|
+ }),
|
|
|
|
|
+ ]
|
|
|
|
|
+
|
|
|
|
|
+ return {
|
|
|
|
|
+ dictData: {
|
|
|
|
|
+ reminderType: [],
|
|
|
|
|
+ },
|
|
|
|
|
+ activeTab: 'calendar',
|
|
|
|
|
+ selectedDate: new Date(),
|
|
|
|
|
+ today: new Date(),
|
|
|
|
|
+ // 表格配置
|
|
|
|
|
+ tableColumns,
|
|
|
|
|
+ projectTableColumns,
|
|
|
|
|
+ searchParams: {
|
|
|
|
|
+ year: '',
|
|
|
|
|
+ projectId: '',
|
|
|
|
|
+ content: '',
|
|
|
|
|
+ startTime: '',
|
|
|
|
|
+ endTime: '',
|
|
|
|
|
+ pageNum: 1,
|
|
|
|
|
+ pageSize: 50,
|
|
|
|
|
+ },
|
|
|
|
|
+ listTotal: 0,
|
|
|
|
|
+
|
|
|
|
|
+ memoList: [],
|
|
|
|
|
+ formTitle: '',
|
|
|
|
|
+ formDisabled: false,
|
|
|
|
|
+ formRules: {
|
|
|
|
|
+ projectId: [
|
|
|
|
|
+ {
|
|
|
|
|
+ required: true,
|
|
|
|
|
+ message: '请选择成本监审项目',
|
|
|
|
|
+ trigger: 'change',
|
|
|
|
|
+ },
|
|
|
|
|
+ ],
|
|
|
|
|
+ title: [{ required: true, message: '请输入标题', trigger: 'blur' }],
|
|
|
|
|
+ content: [{ required: true, message: '请输入内容', trigger: 'blur' }],
|
|
|
|
|
+ memoDate: [
|
|
|
|
|
+ { required: true, message: '请选择日期', trigger: 'change' },
|
|
|
|
|
+ ],
|
|
|
|
|
+ startTime: [
|
|
|
|
|
+ { required: true, message: '请选择开始时间', trigger: 'change' },
|
|
|
|
|
+ ],
|
|
|
|
|
+ endTime: [
|
|
|
|
|
+ { required: true, message: '请选择结束时间', trigger: 'change' },
|
|
|
|
|
+ ],
|
|
|
|
|
+ reminderType: [
|
|
|
|
|
+ { required: true, message: '请选择提醒方式', trigger: 'change' },
|
|
|
|
|
+ ],
|
|
|
|
|
+ // attachmentName: [
|
|
|
|
|
+ // { required: true, message: '请上传附件', trigger: 'change' },
|
|
|
|
|
+ // ],
|
|
|
|
|
+ },
|
|
|
|
|
+ editForm: {
|
|
|
|
|
+ attachmentName: '',
|
|
|
|
|
+ attachmentSize: 0,
|
|
|
|
|
+ attachmentUrl: '',
|
|
|
|
|
+ content: '',
|
|
|
|
|
+ memoDate: '',
|
|
|
|
|
+ projectId: 0,
|
|
|
|
|
+ reminderType: '0',
|
|
|
|
|
+ task: '',
|
|
|
|
|
+ startTime: '',
|
|
|
|
|
+ endTime: '',
|
|
|
|
|
+ title: '',
|
|
|
|
|
+ },
|
|
|
|
|
+ // 时间数据字段已移除,改为直接使用editForm中的startTime和endTime
|
|
|
|
|
+ fileList: [],
|
|
|
|
|
+ isEditDialogOpen: false,
|
|
|
|
|
+ auditTaskList: [],
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ computed: {
|
|
|
|
|
+ // 获取指定日期的任务列表
|
|
|
|
|
+ getTasksByDate() {
|
|
|
|
|
+ return (date) => {
|
|
|
|
|
+ const dateStr = moment(date).format('YYYY-MM-DD')
|
|
|
|
|
+ return this.memoList.filter((task) => task.memoDate === dateStr)
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ },
|
|
|
|
|
+ watch: {
|
|
|
|
|
+ // // 监听选中日期变化,更新搜索参数
|
|
|
|
|
+ // selectedDate: {
|
|
|
|
|
+ // handler(newVal) {
|
|
|
|
|
+ // if (newVal) {
|
|
|
|
|
+ // const monthMoment = moment(newVal).startOf('month')
|
|
|
|
|
+ // }
|
|
|
|
|
+ // },
|
|
|
|
|
+ // deep: true,
|
|
|
|
|
+ // },
|
|
|
|
|
+ },
|
|
|
|
|
+ methods: {
|
|
|
|
|
+ // 根据提醒类型获取对应的颜色
|
|
|
|
|
+ getReminderTypeColor(type) {
|
|
|
|
|
+ const colorMap = {
|
|
|
|
|
+ 1: '#c0c4cc', // 不提醒 - 浅灰色
|
|
|
|
|
+ 2: '#f56c6c', // 提前1小时 - 红色
|
|
|
|
|
+ 3: '#e6a23c', // 提前2小时 - 橙色
|
|
|
|
|
+ 4: '#e6a23c', // 提前3小时 - 橙色
|
|
|
|
|
+ 5: '#73c0de', // 提前1天 - 天蓝色
|
|
|
|
|
+ 6: '#98fb98', // 提前2天 - 浅绿色
|
|
|
|
|
+ 7: '#c0c4cc', // 提前3天 - 浅灰色
|
|
|
|
|
+ }
|
|
|
|
|
+ return colorMap[type] || '#c0c4cc'
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
|
|
+ // 时间处理逻辑已移除,改为直接使用editForm中的startTime和endTime
|
|
|
|
|
+ // 优化 saveFiles 方法
|
|
|
|
|
+ saveFiles(data) {
|
|
|
|
|
+ console.log('saveFiles', data)
|
|
|
|
|
+ this.fileList = data
|
|
|
|
|
+ this.editForm.attachmentName = data[0].fileName
|
|
|
|
|
+ this.editForm.attachmentSize = data[0].fileSize
|
|
|
|
|
+ this.editForm.attachmentUrl = data[0].savePath
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
|
|
+ // 优化 removeFile 方法
|
|
|
|
|
+ removeFile(index, removedFile, currentFiles) {
|
|
|
|
|
+ this.fileList = []
|
|
|
|
|
+ this.editForm.attachmentName = ''
|
|
|
|
|
+ this.editForm.attachmentSize = 0
|
|
|
|
|
+ this.editForm.attachmentUrl = ''
|
|
|
|
|
+ },
|
|
|
|
|
+ // 获取监审任务列表
|
|
|
|
|
+ async getAuditTaskList() {
|
|
|
|
|
+ try {
|
|
|
|
|
+ let params = {
|
|
|
|
|
+ projectName: '',
|
|
|
|
|
+ }
|
|
|
|
|
+ const res = await getAuditTaskList(params)
|
|
|
|
|
+ console.log('监审任务列表数据:', res)
|
|
|
|
|
+ if (res.code == 200) {
|
|
|
|
|
+ this.auditTaskList = res.value || []
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (error) {
|
|
|
|
|
+ console.error('获取监审任务列表数据失败:', error)
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ // 日历选择日期
|
|
|
|
|
+ handleDateClick(date, data) {
|
|
|
|
|
+ const dateStr = moment(date).format('YYYY-MM-DD')
|
|
|
|
|
+ const tasks = this.memoList.filter((task) => task.memoDate === dateStr)
|
|
|
|
|
+
|
|
|
|
|
+ this.searchParams.memoDate = dateStr
|
|
|
|
|
+ this.handleSearch()
|
|
|
|
|
+ // if (tasks.length > 0) {
|
|
|
|
|
+ // this.searchParams.startTime = dateStr
|
|
|
|
|
+ // this.searchParams.endTime = dateStr
|
|
|
|
|
+ // }
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
|
|
+ // 获取提醒类型的文本描述
|
|
|
|
|
+ getReminderTypeText(type) {
|
|
|
|
|
+ const textMap = {
|
|
|
|
|
+ 0: '不提醒',
|
|
|
|
|
+ 1: '提前1小时',
|
|
|
|
|
+ 2: '提前2小时',
|
|
|
|
|
+ 3: '提前3小时',
|
|
|
|
|
+ 4: '提前1天',
|
|
|
|
|
+ 5: '提前2天',
|
|
|
|
|
+ 6: '提前3天',
|
|
|
|
|
+ }
|
|
|
|
|
+ return textMap[type] || '不提醒'
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 获取指定日期的农历信息,包括节日和节气信息
|
|
|
|
|
+ * @param {Date} date - 日期对象
|
|
|
|
|
+ * @returns {Object|null} 包含公历农历详细信息的对象,如果超出范围则返回基本信息对象
|
|
|
|
|
+ */
|
|
|
|
|
+ getLunarInfo(date) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ // 从日期对象获取年月日
|
|
|
|
|
+ const year = date.getFullYear()
|
|
|
|
|
+ const month = date.getMonth() + 1 // 月份从1开始
|
|
|
|
|
+ const day = date.getDate()
|
|
|
|
|
+
|
|
|
|
|
+ // 检查是否在solar2lunar支持的范围内 (1900.1.31~3000.12.31)
|
|
|
|
|
+ const isInRange =
|
|
|
|
|
+ (year > 1900 ||
|
|
|
|
|
+ (year === 1900 && month > 1) ||
|
|
|
|
|
+ (year === 1900 && month === 1 && day >= 31)) &&
|
|
|
|
|
+ (year < 3000 ||
|
|
|
|
|
+ (year === 3000 && month < 12) ||
|
|
|
|
|
+ (year === 3000 && month === 12 && day <= 31))
|
|
|
|
|
+
|
|
|
|
|
+ if (window.calendar && window.calendar.solar2lunar && isInRange) {
|
|
|
|
|
+ // 在范围内,调用calendar-converter.js中的solar2lunar函数
|
|
|
|
|
+ const lunarDate = window.calendar.solar2lunar(year, month, day)
|
|
|
|
|
+ if (lunarDate !== -1) {
|
|
|
|
|
+ return lunarDate || { IDayCn: '' }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 超出范围时,返回基本日期信息
|
|
|
|
|
+ console.warn(
|
|
|
|
|
+ `日期 ${year}-${month}-${day} 超出了农历转换支持的范围(1900.1.31~3000.12.31)`
|
|
|
|
|
+ )
|
|
|
|
|
+ return this._getBasicDateInfo(year, month, day)
|
|
|
|
|
+ } catch (error) {
|
|
|
|
|
+ console.warn('农历转换出错:', error)
|
|
|
|
|
+ // 出错时也返回基本日期信息
|
|
|
|
|
+ return this._getBasicDateInfo(
|
|
|
|
|
+ date.getFullYear(),
|
|
|
|
|
+ date.getMonth() + 1,
|
|
|
|
|
+ date.getDate()
|
|
|
|
|
+ )
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 获取基本的日期信息,当超出solar2lunar范围时使用
|
|
|
|
|
+ * @private
|
|
|
|
|
+ * @param {number} year - 阳历年
|
|
|
|
|
+ * @param {number} month - 阳历月
|
|
|
|
|
+ * @param {number} day - 阳历日
|
|
|
|
|
+ * @returns {Object} 基本日期信息对象
|
|
|
|
|
+ */
|
|
|
|
|
+ _getBasicDateInfo(year, month, day) {
|
|
|
|
|
+ const dateStr = `${year}-${month}-${day}`
|
|
|
|
|
+ // 创建基本信息对象,格式尽量与solar2lunar返回的一致
|
|
|
|
|
+ return {
|
|
|
|
|
+ date: dateStr,
|
|
|
|
|
+ lunarDate: '超出转换范围',
|
|
|
|
|
+ festival: null,
|
|
|
|
|
+ lunarFestival: null,
|
|
|
|
|
+ lYear: null,
|
|
|
|
|
+ lMonth: null,
|
|
|
|
|
+ lDay: null,
|
|
|
|
|
+ Animal: null,
|
|
|
|
|
+ IMonthCn: '',
|
|
|
|
|
+ IDayCn: '',
|
|
|
|
|
+ cYear: year,
|
|
|
|
|
+ cMonth: month,
|
|
|
|
|
+ cDay: day,
|
|
|
|
|
+ gzYear: '',
|
|
|
|
|
+ gzMonth: '',
|
|
|
|
|
+ gzDay: '',
|
|
|
|
|
+ isToday: false,
|
|
|
|
|
+ isLeap: false,
|
|
|
|
|
+ nWeek: new Date(year, month - 1, day).getDay() || 7, // 周日为7
|
|
|
|
|
+ ncWeek: `星期${
|
|
|
|
|
+ ['日', '一', '二', '三', '四', '五', '六'][
|
|
|
|
|
+ new Date(year, month - 1, day).getDay()
|
|
|
|
|
+ ]
|
|
|
|
|
+ }`,
|
|
|
|
|
+ isTerm: false,
|
|
|
|
|
+ Term: null,
|
|
|
|
|
+ astro: '',
|
|
|
|
|
+ outOfRange: true, // 标记为超出范围
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
|
|
+ // 上一个月
|
|
|
|
|
+ prevMonth() {
|
|
|
|
|
+ this.selectedDate = moment(this.selectedDate)
|
|
|
|
|
+ .subtract(1, 'month')
|
|
|
|
|
+ .toDate()
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
|
|
+ // 下一个月
|
|
|
|
|
+ nextMonth() {
|
|
|
|
|
+ this.selectedDate = moment(this.selectedDate).add(1, 'month').toDate()
|
|
|
|
|
+ },
|
|
|
|
|
+ // 获取备忘录列表
|
|
|
|
|
+ async handleSearch() {
|
|
|
|
|
+ try {
|
|
|
|
|
+ let params = {
|
|
|
|
|
+ ...this.searchParams,
|
|
|
|
|
+ }
|
|
|
|
|
+ const res = await getMemoList(params)
|
|
|
|
|
+ if (res.code == 200) {
|
|
|
|
|
+ this.memoList = res.value.records || []
|
|
|
|
|
+ this.memoList.forEach((item) => {
|
|
|
|
|
+ const date = new Date(item.memoDate)
|
|
|
|
|
+ item.day = date.getDate()
|
|
|
|
|
+ })
|
|
|
|
|
+ this.listTotal = res.value.total || 0
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (error) {
|
|
|
|
|
+ console.error('获取数据失败:', error)
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ handleReset() {
|
|
|
|
|
+ this.searchParams = {
|
|
|
|
|
+ pageNum: 1,
|
|
|
|
|
+ pageSize: 10,
|
|
|
|
|
+ startTime: '',
|
|
|
|
|
+ endTime: '',
|
|
|
|
|
+ year: '',
|
|
|
|
|
+ projectId: '',
|
|
|
|
|
+ content: '',
|
|
|
|
|
+ }
|
|
|
|
|
+ this.handleSearch()
|
|
|
|
|
+ },
|
|
|
|
|
+ handleCurrentChange(val) {
|
|
|
|
|
+ this.searchParams.pageNum = val
|
|
|
|
|
+ this.handleSearch()
|
|
|
|
|
+ },
|
|
|
|
|
+ handleSizeChange(val) {
|
|
|
|
|
+ this.searchParams.pageSize = val
|
|
|
|
|
+ this.handleSearch()
|
|
|
|
|
+ },
|
|
|
|
|
+ // 处理分页变化
|
|
|
|
|
+ handlePaginationChange({ currentPage, pageSize }) {
|
|
|
|
|
+ this.searchParams.pageNum = currentPage
|
|
|
|
|
+ this.searchParams.pageSize = pageSize
|
|
|
|
|
+ this.handleSearch()
|
|
|
|
|
+ },
|
|
|
|
|
+ // 初始化日历相关数据
|
|
|
|
|
+ initCalendarData() {
|
|
|
|
|
+ this.handleSearch()
|
|
|
|
|
+ },
|
|
|
|
|
+ onTabChange(tab) {
|
|
|
|
|
+ this.searchParams.startTime = ''
|
|
|
|
|
+ this.searchParams.endTime = ''
|
|
|
|
|
+ this.searchParams.year = ''
|
|
|
|
|
+ this.searchParams.projectId = ''
|
|
|
|
|
+ this.searchParams.content = ''
|
|
|
|
|
+ this.searchParams.pageNum = 1
|
|
|
|
|
+ if (tab.name == 'calendar') {
|
|
|
|
|
+ ;(this.currentYear = new Date().getFullYear()),
|
|
|
|
|
+ (this.currentMonth = new Date().getMonth() + 1), // 月份从1开始
|
|
|
|
|
+ this.setCalendarTitle()
|
|
|
|
|
+ } else {
|
|
|
|
|
+ this.handleSearch()
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
|
|
+ // prevMonth() {
|
|
|
|
|
+ // console.log('日历切换:上一个月')
|
|
|
|
|
+ // if (this.currentMonth === 1) {
|
|
|
|
|
+ // this.currentYear--
|
|
|
|
|
+ // this.currentMonth = 12
|
|
|
|
|
+ // } else {
|
|
|
|
|
+ // this.currentMonth--
|
|
|
|
|
+ // }
|
|
|
|
|
+ // this.setCalendarTitle()
|
|
|
|
|
+ // },
|
|
|
|
|
+
|
|
|
|
|
+ // nextMonth() {
|
|
|
|
|
+ // console.log('日历切换:下一个月')
|
|
|
|
|
+ // if (this.currentMonth === 12) {
|
|
|
|
|
+ // this.currentYear++
|
|
|
|
|
+ // this.currentMonth = 1
|
|
|
|
|
+ // } else {
|
|
|
|
|
+ // this.currentMonth++
|
|
|
|
|
+ // }
|
|
|
|
|
+ // this.setCalendarTitle()
|
|
|
|
|
+ // },
|
|
|
|
|
+
|
|
|
|
|
+ handleAdd() {
|
|
|
|
|
+ this.getAuditTaskList()
|
|
|
|
|
+ this.formTitle = '添加备忘录'
|
|
|
|
|
+ this.formDisabled = false
|
|
|
|
|
+ this.editForm = {
|
|
|
|
|
+ attachmentName: '',
|
|
|
|
|
+ attachmentSize: 0,
|
|
|
|
|
+ attachmentUrl: '',
|
|
|
|
|
+ content: '',
|
|
|
|
|
+ memoDate: '',
|
|
|
|
|
+ projectId: '',
|
|
|
|
|
+ reminderType: '0',
|
|
|
|
|
+ task: '',
|
|
|
|
|
+ startTime: '',
|
|
|
|
|
+ endTime: '',
|
|
|
|
|
+ title: '',
|
|
|
|
|
+ }
|
|
|
|
|
+ this.fileList = []
|
|
|
|
|
+ this.isEditDialogOpen = true
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
|
|
+ // 获取备忘录详情
|
|
|
|
|
+ async getMemoDetail(row) {
|
|
|
|
|
+ this.getAuditTaskList()
|
|
|
|
|
+ try {
|
|
|
|
|
+ let params = {
|
|
|
|
|
+ id: row.id,
|
|
|
|
|
+ }
|
|
|
|
|
+ const res = await getMemoDetail(params)
|
|
|
|
|
+ if (res.code == 200) {
|
|
|
|
|
+ // 处理时间范围
|
|
|
|
|
+ let startTime = ''
|
|
|
|
|
+ let endTime = ''
|
|
|
|
|
+ const data = { ...row, ...res.value }
|
|
|
|
|
+ if (data.timePeriod) {
|
|
|
|
|
+ const timeRange = data.timePeriod.split('-')
|
|
|
|
|
+ if (timeRange.length === 2) {
|
|
|
|
|
+ startTime = timeRange[0]
|
|
|
|
|
+ endTime = timeRange[1]
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ this.editForm = {
|
|
|
|
|
+ ...data,
|
|
|
|
|
+ startTime: startTime,
|
|
|
|
|
+ endTime: endTime,
|
|
|
|
|
+ }
|
|
|
|
|
+ // 删除timePeriod字段避免混淆
|
|
|
|
|
+ delete this.editForm.timePeriod
|
|
|
|
|
+ this.fileList = this.editForm.attachmentUrl
|
|
|
|
|
+ ? [res.value.attachmentUrl]
|
|
|
|
|
+ : []
|
|
|
|
|
+ this.isEditDialogOpen = true
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (error) {
|
|
|
|
|
+ console.error('获取详情数据失败:', error)
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
|
|
+ handleView(row) {
|
|
|
|
|
+ this.formTitle = '查看备忘录详情'
|
|
|
|
|
+ this.formDisabled = true
|
|
|
|
|
+ this.getMemoDetail(row)
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
|
|
+ handleEdit(row) {
|
|
|
|
|
+ this.formTitle = '编辑备忘录'
|
|
|
|
|
+ this.formDisabled = false
|
|
|
|
|
+ this.getMemoDetail(row)
|
|
|
|
|
+ },
|
|
|
|
|
+ handleDelete(row) {
|
|
|
|
|
+ this.$confirm('确定要删除该数据吗?', '提示', {
|
|
|
|
|
+ confirmButtonText: '确定',
|
|
|
|
|
+ cancelButtonText: '取消',
|
|
|
|
|
+ type: 'warning',
|
|
|
|
|
+ })
|
|
|
|
|
+ .then(async () => {
|
|
|
|
|
+ const response = await deleteMemo(row.id)
|
|
|
|
|
+ this.$message.success('删除成功')
|
|
|
|
|
+ // 重新加载数据
|
|
|
|
|
+ this.handleSearch()
|
|
|
|
|
+ })
|
|
|
|
|
+ .catch(() => {
|
|
|
|
|
+ this.$message.info('已取消删除')
|
|
|
|
|
+ })
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
|
|
+ handleSave() {
|
|
|
|
|
+ this.$refs['ruleForm'].validate((valid) => {
|
|
|
|
|
+ if (valid) {
|
|
|
|
|
+ const formData = { ...this.editForm }
|
|
|
|
|
+ // 合并开始时间和结束时间为timePeriod格式
|
|
|
|
|
+ formData.timePeriod = `${formData.startTime}-${formData.endTime}`
|
|
|
|
|
+ // 删除单独的时间字段,避免后端接收多余数据
|
|
|
|
|
+ delete formData.startTime
|
|
|
|
|
+ delete formData.endTime
|
|
|
|
|
+
|
|
|
|
|
+ if (formData.id) {
|
|
|
|
|
+ this.updateMemo(formData)
|
|
|
|
|
+ } else {
|
|
|
|
|
+ this.addMemo(formData)
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
|
|
+ console.log('表单验证失败')
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
|
|
+ // 添加备忘录
|
|
|
|
|
+ async addMemo(formData) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ const res = await addMemo(formData)
|
|
|
|
|
+ if (res.code == 200) {
|
|
|
|
|
+ this.$message.success('添加成功')
|
|
|
|
|
+ this.handleSearch()
|
|
|
|
|
+ this.isEditDialogOpen = false
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (error) {
|
|
|
|
|
+ console.error('添加失败:', error)
|
|
|
|
|
+ this.$message.error('添加失败')
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
|
|
+ // 更新备忘录
|
|
|
|
|
+ async updateMemo(formData) {
|
|
|
|
|
+ delete formData.day
|
|
|
|
|
+ delete formData.projectName
|
|
|
|
|
+ try {
|
|
|
|
|
+ const res = await updateMemo(formData)
|
|
|
|
|
+ if (res.code == 200) {
|
|
|
|
|
+ this.$message.success('更新成功')
|
|
|
|
|
+ this.handleSearch()
|
|
|
|
|
+ this.isEditDialogOpen = false
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (error) {
|
|
|
|
|
+ console.error('更新失败:', error)
|
|
|
|
|
+ this.$message.error('更新失败')
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
|
|
+ // 设置日历标题
|
|
|
|
|
+ setCalendarTitle() {
|
|
|
|
|
+ // 可以在这里添加设置日历标题的逻辑
|
|
|
|
|
+ console.log(`当前显示: ${this.currentYear}年${this.currentMonth}月`)
|
|
|
|
|
+ },
|
|
|
|
|
+ },
|
|
|
|
|
+}
|