xm-law-view-open-handler.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import { message } from 'ant-design-vue'
  2. import crossWindowWatcher from '@/common/services/cross-window-watcher'
  3. import { getUserInfo } from '@/common/store-mixin'
  4. // import XmSingleDataService from './xm-single-data-service'
  5. export default function ({ button, eventScript, context: { args, dataList, fieldInfos } }) {
  6. return new Promise((resolve) => {
  7. const record = args[0]
  8. let href = ''
  9. // 判断当前人是否是起草人
  10. const curuser = getUserInfo().account
  11. const author = fieldInfos.find((f) => f.name === 'REGISTER_USER')?.value
  12. let authoraccount = ''
  13. const flowstatus = fieldInfos.find((f) => f.name === 'FLOW_STATUS')?.value
  14. if (author) {
  15. authoraccount = JSON.parse(author)[0]?.code
  16. }
  17. if (authoraccount !== curuser) {
  18. // 判断是否有查看权限
  19. if (record.openLink) {
  20. href = '/sd-webflow/done-pages/' + record.instId
  21. }
  22. // window.open(href, '_blank')
  23. crossWindowWatcher.waitForChanged(href).then((refreshFlag) => {
  24. if (refreshFlag) {
  25. this.$refs[this.activeKey][0].refresh(true)
  26. }
  27. })
  28. resolve()
  29. } else {
  30. // 所属组织机构没有值时直接打开
  31. if (flowstatus === 0) {
  32. href = '/sd-webflow/pages/draft/' + record.instId
  33. } else {
  34. href = '/sd-webflow/done-pages/' + record.instId
  35. }
  36. // window.open(href, '_blank')
  37. crossWindowWatcher.waitForChanged(href).then((refreshFlag) => {
  38. if (refreshFlag) {
  39. this.$refs[this.activeKey][0].refresh(true)
  40. }
  41. })
  42. resolve()
  43. }
  44. })
  45. }