workbench.vue 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836
  1. <template>
  2. <div class="app-container">
  3. <el-tabs v-model="activeTab" class="tabs" :before-leave="handleChange" @tab-click="changeTab">
  4. <el-tab-pane v-for="item in tabList" :key="item.key" :name="item.key">
  5. <span slot="label"><i :class="item.icon" /> {{ item.label }}</span>
  6. <div v-if="activeTab === item.key" class="tab-container">
  7. <div class="table-container">
  8. <ibps-crud
  9. :ref="item.key"
  10. :data="dataList"
  11. :toolbars="item.key === 'save' ? listConfig.darftTool : listConfig.toolbars"
  12. :search-form="listConfig.searchForm[item.key]"
  13. :pk-key="pkKey"
  14. :columns="listConfig.columns[item.key]"
  15. :pagination="pagination"
  16. :loading="loading"
  17. :index-row="false"
  18. :selection-row="item.key === 'save'"
  19. @row-click="handleRowClick"
  20. @action-event="handleAction"
  21. @sort-change="handleSortChange"
  22. @pagination-change="handlePaginationChange"
  23. >
  24. <template slot="name" slot-scope="scope">{{ scope.row.subject | getWorkInfo('name') }}</template>
  25. <template slot="desc" slot-scope="scope">{{ scope.row.subject | getWorkInfo('desc') }}</template>
  26. <!-- 待办字段处理 -->
  27. <template slot="waitStatus" slot-scope="scope">{{ '待' + scope.row.name }}</template>
  28. <template slot="stateLabel" slot-scope="scope">
  29. <span>{{ scope.column.label }}</span>
  30. <el-tooltip effect="dark" placement="top">
  31. <div slot="content">
  32. 普通事务:接收三天之内为待办理,三天之后为已超时
  33. <br>
  34. 计划事务:月底前七天内为即将超时,超过接收当月月底为已超时,其余为待办理
  35. </div>
  36. <i class="el-icon-info" />
  37. </el-tooltip>
  38. </template>
  39. <template slot="state" slot-scope="scope">
  40. <el-tag :type="scope.row.state ? stateOption[scope.row.state].type : ''">{{ scope.row.state ? stateOption[scope.row.state].label : '待办理' }}</el-tag>
  41. </template>
  42. <template slot="submitBy" slot-scope="scope">
  43. <span>{{ scope.column.label }}</span>
  44. <el-tooltip effect="dark" placement="top">
  45. <div slot="content">
  46. 该事务对应流程的发起人
  47. </div>
  48. <i class="el-icon-info" />
  49. </el-tooltip>
  50. </template>
  51. <template slot="forwardBy" slot-scope="scope">
  52. <span>上节点</span><br>
  53. <span>提交人</span>
  54. <el-tooltip effect="dark" placement="top">
  55. <div slot="content">
  56. 该事务对应流程上一节点的提交人
  57. </div>
  58. <i class="el-icon-info" />
  59. </el-tooltip>
  60. </template>
  61. <!-- 已办、办结字段处理 -->
  62. <template slot="overStatus" slot-scope="scope">{{ getStatus(scope.row.status) }}</template>
  63. <template slot="overDept" slot-scope="scope">{{ getParenthesesStr(scope.row.subject)[1] }}</template>
  64. <template slot="creator" slot-scope="scope">{{ scope.row.createBy | getUserName(userList) }}</template>
  65. <template slot="updateBy" slot-scope="scope">{{ getName(scope.row) }}</template>
  66. </ibps-crud>
  67. </div>
  68. </div>
  69. </el-tab-pane>
  70. </el-tabs>
  71. <bpmn-formrender
  72. :visible="dialogFormVisible"
  73. :task-id="activeTab === 'wait' ? taskId : null"
  74. :wai-jian="activeTab === 'wait' ? waiJian : null"
  75. :instance-id="['over', 'finish'].includes(activeTab) ? instanceId : null"
  76. :def-id="activeTab === 'save' ? defId : null"
  77. :pro-inst-id="activeTab === 'save' ? proInstId : null"
  78. :title="['wait', 'save'].includes(activeTab) ? FlowName : null"
  79. @callback="updateList"
  80. @close="visible => (dialogFormVisible = visible)"
  81. />
  82. <news-detail
  83. :id="newsId"
  84. title="公告明细"
  85. :visible="newsDialogVisible"
  86. readonly
  87. @close="visible => newsDialogVisible = visible"
  88. />
  89. </div>
  90. </template>
  91. <script>
  92. import { pending, handledTask } from '@/api/platform/office/bpmReceived'
  93. import { myDraft, removeDraft } from '@/api/platform/office/bpmInitiated'
  94. import { queryPageList as newsList } from '@/api/platform/system/news'
  95. import { queryOrgManager } from '@/api/platform/org/employee'
  96. import { save } from '@/api/platform/message/innerMessage'
  97. import BpmnFormrender from '@/business/platform/bpmn/form/dialog'
  98. import ActionUtils from '@/utils/action'
  99. import { typeOptions } from '@/views/platform/system/news/constants'
  100. import NewsDetail from '@/views/platform/system/news/detail'
  101. const tabList = [
  102. {
  103. label: '待办事宜',
  104. key: 'wait',
  105. icon: 'el-icon-edit'
  106. },
  107. {
  108. label: '已办事宜',
  109. key: 'over',
  110. icon: 'el-icon-document-remove'
  111. },
  112. {
  113. label: '办结事宜',
  114. key: 'finish',
  115. icon: 'el-icon-paperclip'
  116. },
  117. {
  118. label: '暂存事宜',
  119. key: 'save',
  120. icon: 'el-icon-receiving'
  121. },
  122. {
  123. label: '通知公告',
  124. key: 'news',
  125. icon: 'el-icon-message'
  126. }
  127. ]
  128. const taskState = {
  129. running: '已发起',
  130. end: '已结束',
  131. manualend: '人工结束'
  132. }
  133. const paramsType = {
  134. wait: 'temp.',
  135. over: '',
  136. finish: 'inst.',
  137. save: '',
  138. news: ''
  139. }
  140. const stateOption = {
  141. wait: {
  142. label: '待办理',
  143. type: ''
  144. },
  145. soon: {
  146. label: '即将超时',
  147. type: 'warning'
  148. },
  149. overtime: {
  150. label: '已超时',
  151. type: 'danger'
  152. }
  153. }
  154. const operate = {
  155. wait: pending,
  156. over: handledTask,
  157. finish: handledTask,
  158. save: myDraft,
  159. news: newsList
  160. }
  161. export default {
  162. name: 'calendar',
  163. components: { BpmnFormrender, NewsDetail },
  164. filters: {
  165. getWorkInfo (v, type) {
  166. const hasDesc = v.includes('#')
  167. const res = {
  168. name: {
  169. '0': v.includes('{') ? v.split('{')[0] : v.includes('(') ? v.split('(')[0] : v,
  170. '1': v.split('#')[0]
  171. },
  172. // 无#返回空,有#返回(左边的字符串,
  173. desc: {
  174. '0': '',
  175. '1': v.split('#')[1]
  176. }
  177. }
  178. if (!hasDesc) {
  179. return res[type]['0']
  180. }
  181. return res[type]['1']
  182. },
  183. getUserName (v, list) {
  184. const user = list.find(i => i.userId === v)
  185. return user ? user.userName : ''
  186. }
  187. },
  188. props: {
  189. plan: {
  190. type: Array,
  191. default: () => []
  192. }
  193. },
  194. data () {
  195. return {
  196. tabList,
  197. stateOption,
  198. pkKey: 'id',
  199. taskId: '', // 编辑dialog需要使用
  200. waiJian: '', // 编辑dialog需要使用
  201. instanceId: '',
  202. defId: '',
  203. proInstId: '',
  204. newsId: '',
  205. loading: false,
  206. dialogFormVisible: false,
  207. newsDialogVisible: false,
  208. orgName: '',
  209. roleName: '',
  210. FlowName: '',
  211. posName: '',
  212. timer: null,
  213. userList: [],
  214. orgInfo: {},
  215. activeTab: tabList[0].key,
  216. height: document.body.clientHeight,
  217. selection: [],
  218. defaultPagination: { page: 1, limit: 15 },
  219. sorts: { CREATE_TIME_: 'DESC' },
  220. dataList: [],
  221. pagination: {},
  222. searchParams: {
  223. typeId: '',
  224. subject: '',
  225. createTime: ''
  226. },
  227. listConfig: {
  228. searchForm: {
  229. wait: {
  230. forms: [
  231. { prop: 'Q^subject_^SL', name: 'Q^temp.subject_^SL', label: '事务名称', fieldType: 'input' },
  232. { prop: ['Q^temp.create_time_^DL', 'Q^temp.create_time_^DG'], label: '提交时间', fieldType: 'daterange' }
  233. ]
  234. },
  235. over: {
  236. forms: [
  237. { prop: 'Q^subject_^SL', label: '事务名称', fieldType: 'input' },
  238. { prop: ['Q^create_time_^DL', 'Q^create_time_^DG'], label: '创建时间', fieldType: 'daterange' }
  239. ]
  240. },
  241. finish: {
  242. forms: [
  243. { prop: 'Q^subject_^SL', name: 'Q^inst.subject_^SL', label: '事务名称', fieldType: 'input' },
  244. { prop: ['Q^create_time_^DL', 'Q^create_time_^DG'], name: ['Q^inst.create_time_^DL', 'Q^inst.create_time_^DG'], label: '结束时间', fieldType: 'daterange' }
  245. ]
  246. },
  247. save: {
  248. forms: [
  249. { prop: 'Q^subject_^SL', label: '事务名称', fieldType: 'input' },
  250. { prop: ['Q^create_time_^DL', 'Q^create_time_^DG'], label: '提交时间', fieldType: 'daterange' }
  251. ]
  252. },
  253. news: {
  254. forms: [
  255. { prop: 'Q^title_^SL', label: '标题', fieldType: 'input' },
  256. { prop: 'Q^user_name_^SL', label: '发布人', fieldType: 'input' },
  257. { prop: ['Q^public_date_^DL', 'Q^public_date_^DG'], label: '发布时间', fieldType: 'daterange' }
  258. ]
  259. }
  260. },
  261. toolbars: [
  262. {
  263. key: 'search'
  264. }
  265. ],
  266. darftTool: [
  267. {
  268. key: 'search'
  269. },
  270. {
  271. key: 'remove'
  272. }
  273. ],
  274. // 表格字段配置
  275. columns: {
  276. wait: [
  277. { prop: 'scope', label: '事务名称', slotName: 'name', width: 250 },
  278. { prop: 'scope', label: '事务说明', slotName: 'desc', minWidth: 250 },
  279. { prop: 'scope', label: '事务状态', slotName: 'waitStatus', width: 120 },
  280. { prop: 'scope', label: '办理进度', headerName: 'stateLabel', slotName: 'state', width: 120 },
  281. { prop: 'startDept', label: '发起部门', width: 120 },
  282. { prop: 'submitBy', label: '发起人', headerName: 'submitBy', width: 100 },
  283. { prop: 'forwardBy', label: `上节点提交人`, headerName: 'forwardBy', width: 100 },
  284. { prop: 'createTime', label: '上节点提交时间', width: 150 }
  285. ],
  286. over: [
  287. { prop: 'scope', label: '事务名称', slotName: 'name', width: 250 },
  288. { prop: 'scope', label: '事务说明', slotName: 'desc', minWidth: 250 },
  289. { prop: 'scope', label: '事务状态', slotName: 'overStatus', width: 120 },
  290. { prop: 'scope', label: '发起部门', slotName: 'overDept', width: 120 },
  291. { prop: 'scope', label: '发起人', headerName: 'submitBy', slotName: 'creator', width: 100 },
  292. { prop: 'scope', label: `提交人`, slotName: 'updateBy', width: 100 },
  293. { prop: 'createTime', label: '创建时间', width: 150 }
  294. ],
  295. finish: [
  296. { prop: 'scope', label: '事务名称', slotName: 'name', width: 250 },
  297. { prop: 'scope', label: '事务说明', slotName: 'desc', minWidth: 250 },
  298. { prop: 'scope', label: '事务状态', slotName: 'overStatus', width: 120 },
  299. { prop: 'scope', label: '发起部门', slotName: 'overDept', width: 120 },
  300. { prop: 'scope', label: '发起人', headerName: 'submitBy', slotName: 'creator', width: 100 },
  301. { prop: 'scope', label: `提交人`, slotName: 'updateBy', width: 100 },
  302. { prop: 'createTime', label: '结束时间', width: 150 }
  303. ],
  304. save: [
  305. { prop: 'scope', label: '事务名称', slotName: 'name', width: 250 },
  306. { prop: 'scope', label: '事务说明', slotName: 'desc', minWidth: 250 },
  307. { prop: 'createTime', label: '暂存时间', width: 150 }
  308. ],
  309. news: [
  310. { prop: 'title', label: '标题', minWidth: 250 },
  311. { prop: 'userName', label: '发布人', width: 120 },
  312. { prop: 'publicDate', label: '发布时间', dateFormat: 'yyyy-MM-dd', width: 120 },
  313. { prop: 'loseDate', label: '失效时间', dateFormat: 'yyyy-MM-dd', width: 120 },
  314. { prop: 'status', label: '发布状态', tags: typeOptions, width: 100 }
  315. ]
  316. }
  317. }
  318. }
  319. },
  320. mounted: function () {
  321. this.getData(this.activeTab)
  322. this.getUserList()
  323. this.getOrgInfo()
  324. if (this.timer) {
  325. clearInterval(this.timer)
  326. }
  327. // 轮询刷新公告数据和任务数据
  328. this.timer = setInterval(() => {
  329. // this.getMessage()
  330. this.getData(this.activeTab)
  331. }, 30 * 1000)
  332. },
  333. beforeDestroy () {
  334. clearInterval(this.timer)
  335. },
  336. // 路由离开时
  337. beforeRouteLeave (to, from, next) {
  338. clearInterval(this.timer)
  339. },
  340. methods: {
  341. // 获取系统用户信息
  342. getUserList () {
  343. const { userList } = this.$store.getters
  344. // store中有则无需请求
  345. if (userList && userList.length) {
  346. this.userList = userList
  347. return
  348. }
  349. const sql = `select id_ as userId, name_ as userName, mobile_ as phone from ibps_party_employee where status_ = 'actived'`
  350. this.$common.request('sql', sql).then(res => {
  351. this.userList = res.variables && res.variables.data
  352. })
  353. },
  354. // 获取用户部门信息
  355. getOrgInfo () {
  356. const { org = {}} = this.$store.getters
  357. if (!org || !org.id) {
  358. return
  359. }
  360. const params = {
  361. parameters: [{ key: 'Q^MANAGER_ORG_ID_^S', value: org.id }]
  362. }
  363. queryOrgManager(params).then(res => {
  364. this.orgInfo = {}
  365. const data = res.data.dataResult
  366. if (data && data.length) {
  367. const { id, name, mobile, account, gender, groupID } = data[0]
  368. this.orgInfo = { id, name, mobile, account, gender, groupID, orgName: org.name }
  369. }
  370. })
  371. },
  372. getName ({ createBy, updateBy }) {
  373. const id = updateBy || createBy
  374. const { name = '' } = this.$store.getters
  375. if (this.activeTab === 'finish') {
  376. const t = this.userList.find(i => i.userId === id)
  377. return t ? t.userName : ''
  378. }
  379. return name
  380. },
  381. getStatus (val) {
  382. const s = taskState[val]
  383. return s || '暂停'
  384. },
  385. tableRowClassName ({ row, rowIndex }) {
  386. if (rowIndex % 2 === 1) return 'warning-row'
  387. return 'success-row'
  388. },
  389. // 获取表格数据
  390. getData (type) {
  391. this.loading = true
  392. const pageParams = this.pagination.page ? this.pagination : this.defaultPagination
  393. operate[this.activeTab](this.getFormatParams(null, pageParams)).then(response => {
  394. const { dataResult, pageResult } = response.data
  395. if (dataResult && dataResult.length) {
  396. // 待办事宜对任务发起人做额外处理
  397. if (type === 'wait') {
  398. const instList = []
  399. dataResult.forEach(item => {
  400. instList.push(item.bpmnInstId)
  401. })
  402. const sql = `select b.bpmn_inst_id_, b.create_by_, a.name_ from ibps_bpm_inst b left join ibps_party_employee a on a.id_ = b.create_by_ where b.bpmn_inst_id_ in (${instList.join(',')}) order by find_in_set(b.bpmn_inst_id_,'${instList.join(',')}')`
  403. const currentTime = Date.now()
  404. this.$common.request('sql', sql).then(res => {
  405. const data = res.variables && res.variables.data
  406. data.forEach((item, index) => {
  407. dataResult[index].submitBy = item.name_
  408. dataResult[index].workName = dataResult[index].subject.includes('#') ? dataResult[index].subject.split('#')[0] : dataResult[index].subject.split('(')[0]
  409. dataResult[index].workType = this.plan.includes(dataResult[index].procDefKey) ? 'plan' : 'normal'
  410. dataResult[index].state = this.judgeExpire(dataResult[index].createTime, currentTime, dataResult[index].workType, '1')
  411. })
  412. this.dataList = dataResult.sort((a, b) => b.createTime.localeCompare(a.createTime))
  413. this.pagination = pageResult
  414. })
  415. this.urgeToManager()
  416. } else {
  417. this.dataList = dataResult
  418. this.pagination = pageResult
  419. }
  420. }
  421. this.loading = false
  422. }).catch(() => {
  423. this.loading = false
  424. })
  425. },
  426. // 延迟更新列表数据
  427. updateList () {
  428. setTimeout(() => {
  429. this.getData(this.activeTab)
  430. }, 1000)
  431. },
  432. // 查询
  433. search () {
  434. this.dataList = []
  435. this.pagination = {}
  436. this.getData(this.activeTab)
  437. },
  438. handleChange (activeName, oldActiveName) {
  439. // this.$refs[oldActiveName][0].handleReset()
  440. },
  441. // 切换tab
  442. changeTab () {
  443. // 数据、筛选条件初始化
  444. this.dataList = []
  445. this.selection = []
  446. this.pagination = {}
  447. this.getData(this.activeTab)
  448. },
  449. handleSortChange (sort) {
  450. console.log(sort)
  451. ActionUtils.setSorts(this.sorts, sort)
  452. this.getData(this.activeTab)
  453. },
  454. handlePaginationChange (page) {
  455. ActionUtils.setPagination(this.pagination, page)
  456. this.getData(this.activeTab)
  457. },
  458. getFormatParams (v, page) {
  459. const params = this.$refs[this.activeTab] && this.$refs[this.activeTab].length ? this.$refs[this.activeTab][0].getSearcFormData() : {}
  460. if (this.activeTab === 'finish') {
  461. params.end = '1'
  462. }
  463. const s = this.activeTab === 'news' ? { 'PUBLIC_DATE_': 'DESC' } : this.sorts
  464. return ActionUtils.formatParams(params, page, s)
  465. },
  466. // 处理表格点击事件
  467. handleRowClick (data) {
  468. if (this.activeTab === 'news') {
  469. this.newsId = data.id
  470. this.newsDialogVisible = true
  471. return
  472. }
  473. this.taskId = data.id || ''
  474. this.waiJian = data.waiJian || ''
  475. this.instanceId = data.id || ''
  476. this.defId = data.procDefId || ''
  477. this.proInstId = data.id || ''
  478. this.FlowName = data.name
  479. this.dialogFormVisible = true
  480. },
  481. handleAction (command, position, selection, data) {
  482. switch (command) {
  483. case 'search':// 查询
  484. ActionUtils.setFirstPagination(this.pagination)
  485. this.search()
  486. break
  487. case 'remove':// 删除
  488. ActionUtils.removeRecord(selection).then((ids) => {
  489. console.log(ids)
  490. this.handleRemove(ids)
  491. }).catch(() => { })
  492. break
  493. default:
  494. break
  495. }
  496. },
  497. // 删除暂存数据
  498. handleRemove (ids) {
  499. removeDraft({ ids }).then(() => {
  500. ActionUtils.removeSuccessMessage()
  501. this.selection = []
  502. this.search()
  503. })
  504. },
  505. // 数组去重
  506. unique (arr) {
  507. const res = new Map()
  508. return arr.filter(arr => !res.has(arr.id) && res.set(arr.id, 1))
  509. },
  510. // 文字替换
  511. getParenthesesStr (text) {
  512. let result = ''
  513. if (!text) return result
  514. const regex1 = /\{(.+?)\}/g
  515. const regex2 = /\((.+?)\)/g
  516. const options1 = text.match(regex1)
  517. const options2 = text.match(regex2)
  518. const options = options1 && options1.length ? options1 : options2
  519. if (options) {
  520. const option = options[0]
  521. if (option) {
  522. result = option.substring(1, option.length - 1)
  523. }
  524. if (options[1]) {
  525. const yersOption = options[1]
  526. if (yersOption) {
  527. result = result + '/' + yersOption.substring(1, yersOption.length - 1)
  528. }
  529. }
  530. }
  531. return result.split('/')
  532. },
  533. /**
  534. * 主管提醒
  535. * 数据处理,将所有待办数据根据是否过期处理为两个数组
  536. * 过期判断依据:普通事务-创建时间到当前时间超过三天即为过期;计划事务【事务名称中含计划】-创建当月月末前七天
  537. * 逻辑说明:过期数组中不存于在主管提醒表中的数据插入主管提醒表,并发送内部通知,主管提醒表删除不存在于未过期数组中的数据
  538. */
  539. urgeToManager () {
  540. const { userId } = this.$store.getters
  541. const params = {
  542. parameters: [],
  543. sorts: []
  544. }
  545. const sql = `select id_, shi_wu_id_ as taskId from t_gqswb where position('${userId}' in chu_li_ren_id_) FOR UPDATE`
  546. // Promise.all([pending(params), this.$common.request('sql', sql)]).then(([res1, res2]) => {
  547. // let workData = res1.data && res1.data.dataResult
  548. // let noticeData = res2.variables && res2.variables.data
  549. // if (!workData || !workData.length) {
  550. // return
  551. // }
  552. // this.dealData(workData, noticeData)
  553. // })
  554. pending(params).then(res1 => {
  555. const workData = res1.data && res1.data.dataResult
  556. this.$common.request('sql', sql).then(res2 => {
  557. const noticeData = res2.variables && res2.variables.data
  558. if (!workData || !workData.length) {
  559. return
  560. }
  561. this.dealData(workData, noticeData)
  562. })
  563. })
  564. },
  565. // 处理数据
  566. dealData (workList, noticeList) {
  567. const result = {
  568. expire: [],
  569. unexpire: [],
  570. all: []
  571. }
  572. const currentTime = Date.now()
  573. // 筛选已过期数据
  574. workList.forEach(item => {
  575. // 截取流程名
  576. item.workName = item.subject.includes('#') ? item.subject.split('#')[0] : item.subject.split('(')[0]
  577. item.workType = this.plan.includes(item.procDefKey) ? 'plan' : 'normal'
  578. const isExpire = this.judgeExpire(item.createTime, currentTime, item.workType)
  579. if (isExpire) {
  580. result.expire.push(item)
  581. } else {
  582. result.unexpire.push(item)
  583. }
  584. result.all.push(item)
  585. })
  586. // console.log('处理后数据:', result)
  587. // 有过期数据才执行过期数据处理
  588. if (result.expire.length) {
  589. this.dealExpile(result.expire, noticeList)
  590. }
  591. // 主管提醒表中有数据才执行数据删除
  592. if (noticeList && noticeList.length) {
  593. this.dealUnexpile(result.all, noticeList)
  594. }
  595. },
  596. // 判断是否过期、获取办理状态
  597. judgeExpire (time, current, type, isState) {
  598. const D = new Date(time)
  599. const a = new Date(time).getTime()
  600. const b = new Date(current).getTime()
  601. // 创建时间当月最后一天的时间戳
  602. const c = new Date(D.getFullYear(), D.getMonth() + 1, 0).getTime() + 86400000
  603. // 返回办理状态
  604. if (isState) {
  605. let state = ''
  606. if (type === 'plan') {
  607. state = b >= c ? 'overtime' : b + (86400000 * 7) > c ? 'soon' : 'wait'
  608. } else {
  609. state = a + (86400000 * 3) < b ? 'overtime' : 'wait'
  610. }
  611. return state
  612. }
  613. // 返回是否过期
  614. if (type === 'plan') {
  615. return b + (86400000 * 7) > c
  616. } else {
  617. return a + (86400000 * 3) < b
  618. }
  619. },
  620. // 处理已过期数据
  621. dealExpile (data, noticeList) {
  622. // console.log('已过期流程数据:', data)
  623. // console.log('过期事务表数据:', noticeList)
  624. const { userId } = this.$store.getters
  625. const addList = []
  626. const sendList = []
  627. const msgContent = {
  628. plan: '距离过期还剩七天,请及时处理!',
  629. normal: '至今三天未处理,已超时,请及时处理!'
  630. }
  631. const msgTitle = {
  632. plan: '计划事务即将到期提醒',
  633. normal: '事务超时提醒'
  634. }
  635. const nowTime = new Date(new Date().getTime() + 28800000).toJSON().slice(0, 16).replace('T', ' ')
  636. data.forEach(item => {
  637. const isExist = !!noticeList.find(i => i.taskId === item.taskId)
  638. // 筛选出不存在于主管提醒表的过期数据
  639. if (!isExist) {
  640. // 无部门信息的用户不往过期事务表加数据
  641. if (this.orgInfo.groupID) {
  642. const obj = {
  643. // 事务ID
  644. shi_wu_id_: item.taskId,
  645. // 完整名称
  646. wan_zheng_ming_ch: item.subject,
  647. // 事务说明
  648. shi_wu_shuo_ming_: item.subject.includes('#') ? item.subject.split('#')[1] : '',
  649. // 事务名称
  650. shi_wu_ming_cheng: item.workName,
  651. // 事务状态
  652. shi_wu_zhuang_tai: `待${item.name}`,
  653. // 事务类型
  654. shi_wu_lei_xing_: item.workType,
  655. chu_li_ren_ming_: item.ownerName,
  656. chu_li_ren_id_: this.getInfoByName(item.ownerName, 'id'),
  657. chu_li_ren_dian_h: this.getInfoByName(item.ownerName, 'phone'),
  658. bu_men_: this.orgInfo.orgName,
  659. bu_men_id_: this.orgInfo.groupID,
  660. // 主管ID与当前用户id相等时将主管ID设置为主任【】的ID,主管电话设为空
  661. zhu_guan_id_: this.orgInfo.id === userId ? '990927120278487040' : this.orgInfo.id,
  662. zhu_guan_dian_hua: this.orgInfo.id === userId ? '' : this.orgInfo.mobile,
  663. bian_zhi_shi_jian: item.createTime,
  664. ti_xing_ci_shu_: 1,
  665. duan_xin_ci_shu_: 0,
  666. ti_xing_shi_jian_: nowTime
  667. }
  668. addList.push(obj)
  669. }
  670. const msg = {
  671. subject: msgTitle[item.workType],
  672. content: `<p>事务【${item.workName}】${msgContent[item.workType]}<p>`,
  673. receiverId: userId,
  674. canreply: '0',
  675. taskId: item.taskId
  676. }
  677. sendList.push(msg)
  678. }
  679. })
  680. const addParams = {
  681. tableName: 't_gqswb',
  682. paramWhere: addList
  683. }
  684. // console.log('新增过期事务表数据:', addList, '发送消息数据', sendList)
  685. if (addList.length) {
  686. this.$common.request('add', addParams)
  687. }
  688. if (sendList.length) {
  689. this.sendMsg(sendList)
  690. }
  691. },
  692. // 删除已办的提醒表数据
  693. dealUnexpile (data, noticeList) {
  694. // 清除存在于主管提醒表中【处理人含我】,但是不存在于待办中的数据
  695. const deleteList = []
  696. noticeList.forEach(item => {
  697. const isExist = !!data.find(i => i.taskId === item.taskId)
  698. if (!isExist) {
  699. deleteList.push(item.id_)
  700. }
  701. })
  702. // console.log('过期事务表中需删除的数据:', deleteList)
  703. if (!deleteList.length) {
  704. return
  705. }
  706. const params = {
  707. tableName: 't_gqswb',
  708. paramWhere: {
  709. id_: deleteList.join(',')
  710. }
  711. }
  712. this.$common.request('delete', params).then(() => {}).catch(err => {
  713. console.log(err)
  714. })
  715. },
  716. // 发送站内消息
  717. sendMsg (data) {
  718. data.forEach(item => {
  719. save(item).then(() => {}).catch(err => {
  720. console.log(err)
  721. })
  722. })
  723. },
  724. // 通过名字获取id/电话
  725. getInfoByName (names, type) {
  726. const res = {
  727. id: [],
  728. phone: []
  729. }
  730. const temp = names.split(',')
  731. temp.forEach(item => {
  732. const t = this.userList.find(i => i.userName === item)
  733. if (t) {
  734. res.id.push(t.userId)
  735. res.phone.push(t.phone)
  736. }
  737. })
  738. return res[type].filter(i => i).join(',')
  739. }
  740. }
  741. }
  742. </script>
  743. <style lang="scss" scoped>
  744. ::v-deep .el-table__row {
  745. cursor: pointer;
  746. }
  747. ::v-deep .el-tabs__header {
  748. margin-bottom: 0;
  749. }
  750. .el-completing {
  751. background: #409eff !important;
  752. }
  753. .el-col {
  754. min-height: 1px;
  755. }
  756. .firstcol {
  757. padding-right: 10px;
  758. }
  759. .el-nothing {
  760. font-size: 13px;
  761. }
  762. .calendar-day {
  763. text-align: center;
  764. color: #202535;
  765. line-height: 30px;
  766. font-size: 12px;
  767. }
  768. .is-selected {
  769. color: #f8a535;
  770. font-size: 10px;
  771. margin-top: 5px;
  772. }
  773. #calendar .el-button-group > .el-button:not(:first-child):not(:last-child):after {
  774. content: '当月';
  775. }
  776. #calendar .item {
  777. position: relative;
  778. margin: 0;
  779. padding: 0;
  780. height: auto;
  781. border-radius: 4px;
  782. -webkit-box-sizing: border-box;
  783. box-sizing: border-box;
  784. overflow: hidden;
  785. color: #f8a535;
  786. }
  787. .ibps-list-split .ibps-list-item {
  788. border-bottom: 1px solid #dcdfe6;
  789. padding: 6px 0;
  790. }
  791. .jbd-font-style {
  792. font-weight: bold;
  793. }
  794. .home-text-border {
  795. color: #999999;
  796. box-shadow: 0 0 0 0 rgba(0, 0, 0, 0.1), 0 0 0 0 rgba(0, 0, 0, 0.1), 0 0 0 0 rgba(0, 0, 0, 0.1), 0 1px 0px 0 rgba(0, 0, 0, 0.1);
  797. min-height: 20px;
  798. font-size: 14px;
  799. margin-left: 60px;
  800. margin-bottom: 5px;
  801. }
  802. .jbd-home-card {
  803. overflow: auto;
  804. }
  805. .jbd-home-task {
  806. width: 100%;
  807. padding: 10px;
  808. cursor: pointer;
  809. font-size: 12px;
  810. margin-bottom: 35px;
  811. }
  812. .jbd-home-card::-webkit-scrollbar {
  813. display: none;
  814. }
  815. .jbd-control-cont {
  816. text-align: center;
  817. position: absolute;
  818. z-index: 10;
  819. right: 0px;
  820. top: 50%;
  821. }
  822. .tab-container {
  823. height: calc(100vh - 160px);
  824. min-height: 600px;
  825. >div {
  826. display: inline-block;
  827. }
  828. .table-container {
  829. width: 100%;
  830. vertical-align: top;
  831. }
  832. }
  833. </style>