workbench.vue 33 KB

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