util.js 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691
  1. import { getData } from '@/api/platform/desktop/column'
  2. import { getFile } from '@/utils/avatar'
  3. import { mapState } from 'vuex'
  4. import { taskTypeOptions, dashboardStatus, genderOptions, favoritesOptions, noticeOptions, unreadMessageOptions, imgOptionsData } from '@/business/platform/bpmn/constants'
  5. import ActionUtils from '@/utils/action'
  6. import Utils from '@/utils/util'
  7. import { findAllByCurrUserId, saveCalendarInfos, removeCalendarInfos, delNavigation, addNavigation, getNavigation, sortNavigation } from '@/api/detection/newHomeApi'
  8. import { isEqual } from 'lodash'
  9. import Bus from '@/utils/EventBus'
  10. import newPng from '@/assets/images/homepage/new.png'
  11. import { BASE_URL } from '@/constant'
  12. import dayjs from 'dayjs'
  13. import { scheduleType } from '@/views/constants/schedule'
  14. /**
  15. * 创建组件
  16. */
  17. export function buildComponent (name, column, preview, vm) {
  18. try {
  19. return {
  20. name,
  21. components: {
  22. VueDraggable: () => import('vuedraggable')
  23. },
  24. props: {
  25. params: {
  26. type: Object,
  27. default: () => {}
  28. },
  29. height: {
  30. type: Number,
  31. default: column.height || 300
  32. },
  33. visible: {
  34. type: Boolean,
  35. default: false
  36. },
  37. fullScreen: {
  38. type: Boolean,
  39. default: false
  40. }
  41. },
  42. filters: {
  43. filterStatus (val, type) {
  44. if (Utils.isEmpty(val)) {
  45. return ''
  46. }
  47. const typeMap = {
  48. pending: taskTypeOptions,
  49. already: dashboardStatus,
  50. myRequest: dashboardStatus,
  51. gender: genderOptions,
  52. favorites: favoritesOptions,
  53. notice: noticeOptions,
  54. unreadMessage: unreadMessageOptions
  55. }
  56. if (!typeMap[type]) {
  57. return val
  58. }
  59. return typeMap[type].find(x => x['value'] === val) ? typeMap[type].find(x => x['value'] === val).label : val
  60. }
  61. },
  62. data () {
  63. const { first = '', second = '' } = this.$store.getters.level
  64. const { userId, userList = [], deptList = [], menus, userInfo } = this.$store.getters
  65. const t1 = deptList.find(i => i.positionId === first) || {}
  66. const t2 = deptList.find(i => i.positionId === second) || {}
  67. const locationName = second ? t1.positionName + t2.positionName : t1.positionName
  68. return {
  69. userId,
  70. userList,
  71. deptList,
  72. menus,
  73. locationName,
  74. newPng,
  75. imgOptionsData,
  76. positions: userInfo.positions,
  77. loading: false,
  78. title: `${column.name}`,
  79. alias: `${column.alias}`,
  80. attrs: this.getAttrs(),
  81. variables: {}, // 一些变量,比如分页信息
  82. data: null,
  83. totalCount: 0,
  84. quickNavigationData: [],
  85. navigationList: [],
  86. stautusOptions: [],
  87. bpmnFormrenderDialogVisible: false, // 表单
  88. editId: '',
  89. bodyShow: true,
  90. show: false,
  91. showHeight: '',
  92. cardHeight: '100%',
  93. activeName: 'innerMessage',
  94. unreadMessageOption: {},
  95. formName: 'quickNavform',
  96. dialogFormVisible: false,
  97. formLabelWidth: '120px',
  98. quickNavform: {
  99. urlName: '',
  100. urlAddr: '',
  101. display: '_blank',
  102. diDian: second || first
  103. },
  104. defaultForm: {},
  105. pendingTabActiveName: 'user-type',
  106. bodyParams: ActionUtils.formatParams({}, {}, {}),
  107. pendingBusinessOption: {},
  108. bpmn: [],
  109. rules: {
  110. urlName: [
  111. {
  112. required: true,
  113. message: this.$t('validate.required')
  114. }
  115. ],
  116. urlAddr: [
  117. {
  118. required: true,
  119. message: this.$t('validate.required')
  120. }
  121. ],
  122. display: [
  123. {
  124. required: true,
  125. message: this.$t('validate.required')
  126. }
  127. ]
  128. },
  129. calendarDialogForm: {
  130. id: '',
  131. biaoTi: '',
  132. neiRong: '',
  133. kaiShiShiJian: '',
  134. jieShuShiJian: '',
  135. formDate: []
  136. },
  137. colorStatus: ['#e7505a', '#f3c200', '#578ebe', '#1BBC9B'],
  138. // const status = ['急', '重', '轻','缓']
  139. isDragging: false,
  140. draggableOptions: {
  141. handle: '.draggable',
  142. ghostClass: 'sortable-ghost',
  143. distance: 1,
  144. disabled: false,
  145. animation: 200,
  146. axis: 'y'
  147. },
  148. calendarToolbar: this.fullScreen ? [{ key: 'refresh' }] : [{ key: 'refresh' }, { key: 'fullscreen' }, { key: 'collapse' }],
  149. isFirstAlert: true, // 是否首次日程提醒
  150. scheduleData: [],
  151. scheduleShift: [],
  152. todaySchedule: []
  153. }
  154. },
  155. computed: {
  156. ...mapState({
  157. userInfo: state => state.ibps.user.info
  158. })
  159. },
  160. mounted () {
  161. this.defaultForm = JSON.parse(JSON.stringify(this.quickNavform))
  162. this.$nextTick(async () => {
  163. this.fetchData()
  164. this.scheduleData = await this.getScheduleData()
  165. })
  166. },
  167. methods: {
  168. fetchData (columns, params = {}) {
  169. this.loading = true
  170. this.data = []
  171. this.showHeight = this.getHeight()
  172. const param = Utils.isNotEmpty(columns) && (column.alias === 'unreadMessage' || column.alias === 'pendingBusiness')
  173. ? { dataMode: column.dataMode, dataFrom: column.dataFrom }
  174. : column
  175. if (param.alias === 'myCalendar') {
  176. const { getFormatDate, getDate } = this.$common
  177. findAllByCurrUserId().then(res => {
  178. const { data = [] } = res || {}
  179. if (this.isFirstAlert) {
  180. this.isFirstAlert = false
  181. this.showAlert(data)
  182. }
  183. this.data = data.map(i => ({
  184. id: i.id,
  185. title: i.title,
  186. content: i.content,
  187. start: i.startTime,
  188. // 日期组件日程显示里,end的时间需要多加一天,end:2024-01-02时,日程条只到2024-01-01的日期位置上
  189. end: getFormatDate('string', 10, getDate('day', 1, i.endTime)),
  190. jieShuShiJian: i.endTime,
  191. zhuangTai: i.emergencyState,
  192. color: this.colorStatus[Number(i.emergencyState) - 1]
  193. }))
  194. }).catch(() => {
  195. this.$message.error('获取日历日程失败!')
  196. })
  197. } else if (param.alias === 'quickNavigation') {
  198. getNavigation().then(res => {
  199. const { data = [] } = res || {}
  200. data.forEach(item => {
  201. if (!item.userId) {
  202. item.urlAddr = `${BASE_URL}#${item.urlAddr}`
  203. }
  204. })
  205. this.quickNavigationData = data
  206. })
  207. } else {
  208. getData(param, params).then(res => {
  209. let { data } = res || {}
  210. if (Utils.isNotEmpty(data) && Utils.isString(data)) {
  211. data = Utils.parseData(res.data)
  212. }
  213. this.data = data && data.dataResult ? data.dataResult : data
  214. this.totalCount = data && data.pageResult ? data.pageResult.totalCount : 0
  215. // 更新小铃铛消息数量
  216. if (param.alias === 'unreadMessage') {
  217. Bus.$emit('getMessageCount', this.totalCount)
  218. }
  219. this.variables = res.variables
  220. this.loading = false
  221. }).catch((e) => {
  222. this.loading = false
  223. })
  224. }
  225. },
  226. // 过滤日程提醒数据
  227. filterAlertData (data, dayNumber = 3) {
  228. if (dayNumber <= 0) return
  229. const today = dayjs()
  230. const tempCalendarAlertData = data.filter(day => {
  231. const startTime = dayjs(day.startTime)
  232. const endTime = dayjs(day.endTime)
  233. if (day.popUp) {
  234. if ((startTime.diff(today, 'day') <= 0 && endTime.diff(today, 'day') >= 0) || (startTime.diff(today, 'day') <= dayNumber - 2 && startTime.diff(today, 'day') >= 0)) {
  235. return true
  236. }
  237. }
  238. })
  239. tempCalendarAlertData.sort((a, b) => new Date(a.startTime) - new Date(b.startTime))
  240. const calendarIds = tempCalendarAlertData.map(item => item.id)
  241. const calendarAlertData = {}
  242. tempCalendarAlertData.forEach(item => {
  243. if (calendarAlertData[item.startTime]) {
  244. calendarAlertData[item.startTime].push(item)
  245. } else {
  246. calendarAlertData[item.startTime] = []
  247. calendarAlertData[item.startTime].push(item)
  248. }
  249. })
  250. return { calendarAlertData, calendarIds }
  251. },
  252. // 日程提醒
  253. showAlert (data) {
  254. const calendarAlertData = this.filterAlertData(data)
  255. this.$emit('action-event', 'calendarAlert', calendarAlertData)
  256. },
  257. getPhoto (photo) {
  258. return getFile(photo)
  259. },
  260. getTaskDesc (v) {
  261. if (!v.includes('#')) {
  262. return ''
  263. }
  264. return v.split('#')[1] || ''
  265. },
  266. getTaskInfo (val, arg) {
  267. const arr = val.split('#')
  268. if (!arr[2]) {
  269. return ''
  270. }
  271. // 中文冒号转英文冒号 防止流程定义时输入的冒号格式错误导致转换报错
  272. arr[2] = arr[2].replace(':', ':')
  273. const result = JSON.parse(`{${arr[2]}}`)
  274. if (!result.dept) {
  275. return ''
  276. }
  277. const depts = result.dept.split(',')
  278. const deptNames = []
  279. depts.forEach(item => {
  280. const t = this.deptList.find(i => i.positionId === item)
  281. deptNames.push(t ? t.positionName : result.dept)
  282. })
  283. result.deptName = deptNames.join(',')
  284. return result[arg]
  285. },
  286. transformData (val, dataset, from, to) {
  287. if (!val) {
  288. return ''
  289. }
  290. const temp = this[dataset].find(u => u[from] === val)
  291. return temp ? temp[to] : ''
  292. },
  293. getHeightNoUnit () {
  294. // 高度 - header - 边框
  295. if (!this.visible) {
  296. return this.height ? (this.height - 60 - 20) : 150
  297. } else {
  298. return 150
  299. }
  300. },
  301. getHeight (h = 20) {
  302. // 高度 - header - 边框
  303. if (!this.visible) {
  304. return this.height ? `${(this.height - 60 - h)}px` : '150px'
  305. } else {
  306. return '100%'
  307. }
  308. },
  309. getDashboardHeight () {
  310. return this.height ? `${this.height + 20}px` : '150px'
  311. },
  312. getAttrs () {
  313. const item = JSON.parse(JSON.stringify(column))
  314. item.templateHtml = null
  315. return item
  316. },
  317. /**
  318. * 构建首页日期组件的参数
  319. * @param {*} data
  320. * @returns
  321. */
  322. getFullCalendarConfig (data) {
  323. const events = data === null ? [] : Utils.parseJSON(data)
  324. const config = {
  325. height: preview ? '100%' : (this.height ? this.height : 180),
  326. // editable: true, // 允许拖动缩放,不写默认就是false
  327. selectable: true,
  328. dayMaxEvents: 1, // 最多显示3个日程
  329. locale: this.$i18n.locale ? this.$i18n.locale.toLowerCase() : 'zh-cn',
  330. events: events,
  331. buttonText: {
  332. today: '今天',
  333. dayGridMonth: '月',
  334. listMonth: '日程'
  335. // week: '周视图',
  336. // day: '日视图',
  337. // prev: '<i class="icon-chevron-left">后退</i>',
  338. // next: '<i class="icon-chevron-right">前进</i>'
  339. },
  340. dateClick: this.handleDateClick, // 日期点击
  341. eventClick: this.handleEventClick,
  342. moreLinkClick: this.handleMoreLinkClick
  343. }
  344. if (preview) {
  345. config.headerToolbar = {
  346. start: '',
  347. center: 'title',
  348. end: 'prev,next,today'
  349. // end: 'prev,next,today,month,agendaWeek,agendaDay,listWeek'
  350. }
  351. delete config['dayMaxEvents']
  352. }
  353. return config
  354. },
  355. handleDateClick (param) {
  356. this.$emit(
  357. 'open',
  358. 'calendar',
  359. [param.dateStr, param.dateStr],
  360. this.data
  361. )
  362. },
  363. handleEventClick (param) {
  364. this.$emit(
  365. 'open',
  366. 'calendar',
  367. [param.event.startStr, param.event._def.extendedProps.jieShuShiJian],
  368. this.data,
  369. param.event.id
  370. )
  371. },
  372. handleMoreLinkClick (date) {
  373. this.$emit(
  374. 'open',
  375. 'calendar',
  376. [date.allSegs[0].event.startStr, date.allSegs[0].event._def.extendedProps.jieShuShiJian],
  377. this.data,
  378. date.allSegs[0].event.id
  379. )
  380. },
  381. refreshData () {
  382. this.fetchData()
  383. },
  384. /**
  385. * 处理按钮事件
  386. * @param {*} command
  387. * @param {*} position
  388. * @param {*} data
  389. * @param {*} actions
  390. */
  391. handleActionEvent (command, position, data, actions) {
  392. switch (command) {
  393. case 'refresh': // 刷新
  394. this.refreshData()
  395. break
  396. case 'fullscreen': // 全屏
  397. this.handleFullscreen()
  398. break
  399. case 'more': // 更多
  400. this.handleMore()
  401. break
  402. case 'collapse': // 收缩
  403. case 'expansion': // 展开
  404. this.handleCollapseExpand(command, data, actions)
  405. break
  406. case 'add': // 新增
  407. this.getFormData()
  408. break
  409. default:
  410. break
  411. }
  412. },
  413. emitActionEventHandler (command) {
  414. this.$emit('action-event', command, ...Array.from(arguments).slice(1))
  415. },
  416. // 公告栏目点击事件
  417. handleApprove (id, title) {
  418. this.$emit('action-event', 'approve', {
  419. id, title
  420. })
  421. },
  422. handleUnreadMessage (id, tableId, tableName) {
  423. this.$emit('action-event', 'unRead', { id, tableId, tableName })
  424. },
  425. // 处理全屏
  426. handleFullscreen () {
  427. this.emitActionEventHandler('fullscreen', { id: this.attrs.id })
  428. },
  429. openPlate (url) {
  430. const menuMap = {
  431. myTraining: 'rygl/rypx/wdpx',
  432. myTesting: 'rygl/kszx/wdks',
  433. myDevices: 'sbgls/mywh',
  434. myDiscard: 'lhjcgl/ypgl/ypgqcl',
  435. notice: 'tygl/tzgg',
  436. myFacility: 'sshjgl/sshjjk/sshjkzzl',
  437. quickNavigation: 'xtgl/xtsjpz/tyglpz/kjdhpz'
  438. }
  439. if (menuMap[url]) {
  440. const alias = menuMap[url].split('/')[0]
  441. const resInfo = this.menus.find(i => i.alias === alias)
  442. this.$store.dispatch('ibps/menu/activeHeaderSet', { activeHeader: resInfo.id, vm: this })
  443. }
  444. this.$router.push(`/${menuMap[url] || url}`)
  445. },
  446. /**
  447. * 处理更多
  448. */
  449. handleMore () {
  450. if (this.attrs.alias === 'quickNavigation') {
  451. return this.openPlate('quickNavigation')
  452. }
  453. if (!this.attrs.colUrl) {
  454. return this.$message.warning('未设置更多路径的url')
  455. }
  456. this.openPlate(this.attrs.colUrl)
  457. },
  458. // 未读消息
  459. handleClick (option) {
  460. this.unreadMessageOption = option
  461. option[this.activeName].dataMode = column.dataMode
  462. this.fetchData(option[this.activeName])
  463. },
  464. // 待办事务
  465. handleTabClick (option) {
  466. this.pendingBusinessOption = option
  467. option[this.pendingTabActiveName].dataMode = column.dataMode
  468. this.fetchData(option[this.pendingTabActiveName])
  469. },
  470. handleFlowClick (params) {
  471. params.$alias = this.alias
  472. this.emitActionEventHandler('flow', params)
  473. },
  474. handleCollapseExpand (command, data, actions) {
  475. this.bodyShow = !this.bodyShow
  476. const index = actions.findIndex((action) => action.key === data.key)
  477. actions[index].key = this.bodyShow ? 'collapse' : 'expansion'
  478. if (!this.visible) {
  479. this.emitActionEventHandler(command, {})
  480. return
  481. }
  482. this.showHeight = this.bodyShow ? this.getHeight() : 0
  483. this.$refs['toolbar'].callback(actions)
  484. },
  485. formValidate (formName) {
  486. this.$nextTick(() => {
  487. this.$refs[formName].validate(() => {})
  488. })
  489. },
  490. getFormData () {
  491. this.quickNavform = JSON.parse(JSON.stringify(this.defaultForm))
  492. this.formValidate('quickNavform')
  493. this.dialogFormVisible = true
  494. },
  495. handleNavRemove (navId, i) {
  496. this.$confirm('是否确认删除该快捷导航?', '提示', {
  497. confirmButtonText: '确认',
  498. cancelButtonText: '取消',
  499. type: 'warning',
  500. showClose: false,
  501. closeOnClickModal: false
  502. }).then(() => {
  503. delNavigation({ navigateIds: navId }).then(() => {
  504. this.$message.success('删除成功')
  505. this.quickNavigationData.splice(i, 1)
  506. })
  507. })
  508. },
  509. // 错误头像的照片
  510. errorAvatarHandler (data) {
  511. // data.photo = require('https://cube.elemecdn.com/e/fd/0fc7d20532fdaf769a25683617711png.png')
  512. return true
  513. },
  514. close () {
  515. this.$refs[this.formName].resetFields()
  516. this.dialogFormVisible = false
  517. },
  518. saveQuickNav () {
  519. this.$refs[this.formName].validate(valid => {
  520. if (valid) {
  521. addNavigation({ id: '', ...this.quickNavform }).then(res => {
  522. this.$message.success('添加成功!')
  523. const { id } = res.variables || {}
  524. this.quickNavigationData.unshift({ id, ...this.quickNavform, userId: this.userId })
  525. this.dialogFormVisible = false
  526. })
  527. } else {
  528. ActionUtils.saveErrorMessage()
  529. }
  530. })
  531. },
  532. handleSortChange () {
  533. this.isDragging = false
  534. const newSort = this.quickNavigationData.map(i => i.id)
  535. if (isEqual(this.navigationList, newSort)) {
  536. return
  537. }
  538. this.navigationList = newSort
  539. sortNavigation({ orders: this.navigationList.join(',') }).then(() => {
  540. this.$message.success('排序成功!')
  541. })
  542. },
  543. // 父组件调用该方法给日程添加数据
  544. async setCalendarEvents (param) {
  545. const { name = '' } = this.$store.getters
  546. const form = param.form
  547. const paramObject = {
  548. id: form.id ? form.id : '11111',
  549. // diDian: "string", // 地点
  550. userId: this.userId, // 用户id
  551. userName: name, // 用户名
  552. title: form.biaoTi, // 标题
  553. content: form.neiRong, // 内容
  554. startTime: form.formDate[0], // 开始时间
  555. endTime: form.formDate[1], // 结束时间
  556. emergencyState: form.zhuangTai // 紧急状态
  557. }
  558. await saveCalendarInfos(paramObject)
  559. this.refreshData()
  560. },
  561. async hanldeCalendardel (param) {
  562. if (param.form.id) {
  563. await removeCalendarInfos({
  564. calendarIds: param.form.id
  565. })
  566. }
  567. this.refreshData()
  568. },
  569. // 公告栏是否显示new图标
  570. showNewIcon (date, days) {
  571. const nowDate = new Date().getTime()
  572. const targetDate = new Date(date).getTime()
  573. return targetDate + days * 24 * 60 * 60 * 1000 > nowDate
  574. },
  575. handleOverflow (val, length) {
  576. if (val.length > length) {
  577. return val.slice(0, length - 2) + '...'
  578. }
  579. return val
  580. },
  581. getDays (start, end) {
  582. if (!start || !end) {
  583. return 0
  584. }
  585. return Math.ceil((new Date(end) - new Date(start)) / (1000 * 60 * 60 * 24))
  586. },
  587. getScheduleData () {
  588. const { first, second } = this.$store.getters.level || {}
  589. // const sql = `select a.*, b.title_,b.type_, b.start_date_, b.end_date_, b.config_, b.overview_ from t_schedule_detail a, t_schedule b where a.parent_id_ = b.id_ and b.di_dian_ = '${second || first}' and a.user_id_ = '${this.userId}'`
  590. return new Promise((resolve, reject) => {
  591. this.$common.request('query', {
  592. key: 'getScheduleDetailByUid',
  593. params: [second || first, this.userId]
  594. }).then(res => {
  595. const { data = [] } = res.variables || {}
  596. const eventList = []
  597. const self = this
  598. data.forEach(item => {
  599. const days = this.getDays(item.start_date_, item.end_date_)
  600. const config = item.config_ ? JSON.parse(item.config_) : {}
  601. const scheduleTypeLabel = scheduleType.filter(obj => obj.value === item.type_)[0]?.label || ''
  602. const scheduleCreateBy = self.userList.filter(obj => obj.userId === item.create_by_)[0]?.userName || ''
  603. const { scheduleShift } = config
  604. this.scheduleShift = scheduleShift
  605. for (let i = 1; i <= days; i++) {
  606. const shift = item[`d${i}_`]
  607. if (shift) {
  608. const date = this.$common.getFormatDate('string', 10, this.$common.getDate('day', i - 1, item.start_date_))
  609. const shiftList = shift.split(',')
  610. shiftList.forEach(s => {
  611. const t = scheduleShift.find(i => i.alias === s)
  612. eventList.push({
  613. scheduleName: item.title_ ? item.title_ : '', // 排班表名字
  614. scheduleTypeLabel: scheduleTypeLabel || '', // 排班类型
  615. scheduleCreateBy: scheduleCreateBy || '', // 排班创建人
  616. content: t.dateRange.map(d => {
  617. return d.type === 'allday' ? '全天' : (`当天 ${d.startTime}` + ' 至 ' + `${d.isSecondDay === 'Y' ? '第二天' : '当天'} ${d.endTime}`)
  618. }).join('\n'),
  619. title: s,
  620. start: date,
  621. end: date,
  622. jieShuShiJian: date,
  623. zhuangTai: '',
  624. id: i,
  625. bcolor: t.color,
  626. ...t
  627. })
  628. })
  629. }
  630. }
  631. })
  632. const today = this.$common.getDateNow()
  633. this.todaySchedule = eventList.filter(i => i.start === today).map(i => i.title)
  634. console.log(this.todaySchedule)
  635. resolve(eventList)
  636. }).catch(error => {
  637. reject(error)
  638. })
  639. })
  640. },
  641. handleScheduleEventClick (param) { // 排班点击事件
  642. this.$emit(
  643. 'open',
  644. 'banci',
  645. param.event._def.extendedProps,
  646. this.scheduleShift,
  647. param.event._def.title
  648. )
  649. },
  650. showMySchedule () {
  651. const scheduleConfig = {
  652. height: '100%',
  653. locale: 'zh-cn', // 语言
  654. selectable: true, // 是否可以选中日历格
  655. buttonText: { // 日历头部按钮中文转换
  656. today: '今天',
  657. dayGridMonth: '月',
  658. listMonth: '',
  659. month: '月',
  660. week: '周视图',
  661. day: '日视图',
  662. list: '表'
  663. // prev: '<i class="icon-chevron-left">后退</i>',
  664. // next: '<i class="icon-chevron-right">前进</i>'
  665. },
  666. headerToolbar: { // 日历头部按钮位置
  667. // left: 'prev,next today',
  668. // start: '',
  669. right: 'prev,next today',
  670. center: 'title'
  671. // right: 'dayGridMonth,timeGridWeek,timeGridDay'
  672. // end: 'prev,next,today,month,agendaWeek,agendaDay,listWeek'
  673. },
  674. events: this.scheduleData, // 排班数组
  675. eventClick: this.handleScheduleEventClick, // 排班点击信息展示
  676. scheduleShift: this.scheduleShift
  677. }
  678. this.$emit('action-event', 'mySchedule', scheduleConfig)
  679. }
  680. },
  681. template: column.templateHtml !== '' ? `${column.templateHtml}` : `<div></div>`
  682. }
  683. } catch (error) {
  684. console.error(error)
  685. }
  686. }