dispute-mixins.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. import { Message, Modal } from 'ant-design-vue'
  2. import FlowService from '@/webflow/flow-service'
  3. import crossWindowWatcher from '@/common/services/cross-window-watcher'
  4. import LawService from '../law-service'
  5. const DisputeMixins = {
  6. data() {
  7. return { stage: [], flag: true, create: false, type: '' }
  8. },
  9. created() {
  10. if (this.$route.params.id && this.$route.params.id === '0') {
  11. this.create = true
  12. }
  13. },
  14. methods: {
  15. initDataf() {
  16. if (this.create) {
  17. LawService.getProgressData(this.$route.query.id).then((res) => {
  18. const jfName = res.data[0].text
  19. this.$refs.webflow.setFieldValue('DISPUTE_ID', this.$route.query.id)
  20. this.$refs.webflow.setFieldValue('DISPUTE_NAME', jfName)
  21. })
  22. }
  23. },
  24. initData() {
  25. if (this.create) {
  26. LawService.getAlljfStage().then((res) => {
  27. const stage = []
  28. res.data.data.forEach((d) => {
  29. stage.push({
  30. name: d.STAGE_NAME,
  31. code: d.STAGE_CODE,
  32. })
  33. })
  34. this.stage = [...stage]
  35. LawService.getProgressData(this.$route.query.id).then((res) => {
  36. const jfName = res.data[0].text
  37. this.$refs.webflow.setFieldValue('DISPUTE_ID', this.$route.query.id)
  38. this.$refs.webflow.setFieldValue('PROGRESS_CODE', this.$route.query.stage)
  39. this.$refs.webflow.setFieldValue('DISPUTE_NAME', jfName)
  40. if (this.$route.query.parentid !== '') {
  41. this.$refs.webflow.setFieldValue('PARENT_STEP_ID', this.$route.query.parentid)
  42. }
  43. if (this.stage.length > 0) {
  44. const sobj = this.stage.find((s) => s.code === this.$route.query.stage)
  45. if (sobj) {
  46. this.$refs.webflow.setFieldValue('STEP_NAME', sobj.name)
  47. }
  48. }
  49. })
  50. })
  51. }
  52. },
  53. /**
  54. * 提交后事件
  55. */
  56. afterDispatch(obj) {
  57. // 提交也认为是保存
  58. obj.defaultPrevented = true
  59. Message.success({ content: `提交成功`, duration: 1 }).then(() => {
  60. const e = false
  61. const t = true
  62. const snap = this.$refs.webflow.getFormSnap()
  63. if (
  64. e &&
  65. this.$refs.webflow.FlowData.mode === 'EDIT' &&
  66. (this.$refs.webflow.getFormSnap() !== snap || this.$refs.webflow.disableActionAlert)
  67. )
  68. if (!window.confirm('正在编辑文档或正文附件,确认是否离开此网站')) return
  69. crossWindowWatcher.notifyChange(t)
  70. return FlowService.unLock(this.$refs.webflow.FlowData.instId).finally(() => {
  71. crossWindowWatcher.notifyChange(true)
  72. this.$refs.webflow.close()
  73. const url = window.location.href
  74. const obj = { url: url, type: this.type + 'close' }
  75. window.parent.postMessage(obj, '*')
  76. })
  77. })
  78. return obj
  79. },
  80. save() {
  81. if (this.create) {
  82. if (window.location.href.indexOf('draft/0') === -1) {
  83. if (window.parent) {
  84. const obj = { url: window.location.href, type: this.type }
  85. window.parent.postMessage(obj, '*')
  86. }
  87. this.create = false
  88. }
  89. }
  90. },
  91. actionBtnClick(evt, { button, FlowData }) {
  92. if (button.fakeId === 'we-doc$close') {
  93. this.$refs.webflow.close()
  94. window.parent.opener = null
  95. window.parent.open('', '_self')
  96. window.parent.close()
  97. }
  98. },
  99. },
  100. }
  101. export default DisputeMixins