xm-law-progress-open-task-handler.js 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500
  1. import qs from 'qs'
  2. import { router } from '@/common/router-ready'
  3. import { Modal, message } from 'ant-design-vue'
  4. import LawService from '../../../../../src_product/iam/law/law-service'
  5. export default function({ button, eventScript, context }) {
  6. return new Promise((resolve) => {
  7. const strtype = eventScript.strtype === '1' // true纠纷 否则案件
  8. // 打开新建页面
  9. const isNewWindow = eventScript.newWindow === '1'
  10. console.log(eventScript)
  11. if (strtype) {
  12. const strjftype = eventScript.strjftype === '1' // true 进展 否则结案
  13. LawService.getAlljfStage().then((res) => {
  14. const stage = []
  15. res.data.data.forEach((d) => {
  16. stage.push({
  17. name: d.STAGE_NAME,
  18. code: d.STAGE_CODE,
  19. })
  20. })
  21. var s = this
  22. this.valueChange = function(value) {
  23. this.stagef = value
  24. }
  25. const { fieldInfos } = context
  26. const jfid = fieldInfos.find((f) => f.name === 'DISPUTE_ID')?.value
  27. // 判断打开新建页面 还是打开正在处理中的纠纷进展
  28. LawService.getProgressData(jfid).then((res1) => {
  29. let flag = true // true 是弹出纠纷登记 false 是不弹出纠纷登记
  30. let djurl = ''
  31. let jfjzid = ''
  32. if (res1.data.length > 1) {
  33. // 有纠纷登记
  34. if (res1.data[1].children && res1.data[1].children.length > 0) {
  35. if (
  36. res1.data[1].children[res1.data[1].children.length - 1].props.stepStatus === '0'
  37. ) {
  38. // 有纠纷登记并且未办结
  39. djurl =
  40. res1.data[1].children[res1.data[1].children.length - 1].props.detailUrl +
  41. '/' +
  42. res1.data[1].children[res1.data[1].children.length - 1].props.detailInstid
  43. flag = false
  44. } else {
  45. // 有纠纷登记且办结
  46. }
  47. jfjzid = res1.data[1].id
  48. }
  49. } else {
  50. // 无纠纷登记 弹出选择阶段名称
  51. }
  52. if (flag && strjftype) {
  53. Modal.confirm({
  54. title: '请选择阶段名称',
  55. content: (h) => {
  56. const info = []
  57. stage.forEach((s) => {
  58. info.push(h('a-select-option', { props: { value: s.code }, key: s.code }, s.name))
  59. })
  60. this.stage = stage
  61. this.stagef = ''
  62. return h(
  63. 'a-form-model',
  64. { props: { labelCol: { span: 7 }, wrapperCol: { span: 15 } } },
  65. [
  66. h('a-form-model-item', { props: { label: '阶段名称' }, required: true }, [
  67. h(
  68. 'a-select',
  69. {
  70. attrs: { model: { value: s.stagef } },
  71. on: { change: (e) => s.valueChange(e) },
  72. },
  73. info
  74. ),
  75. ]),
  76. ]
  77. )
  78. },
  79. okText: '确定',
  80. okType: 'danger',
  81. onOk: () => {
  82. if (this.stagef === '') {
  83. Modal.warning({
  84. title: '提示',
  85. content: '请选择阶段名称',
  86. })
  87. return false
  88. } else {
  89. // 获取设置的默认值
  90. const id = fieldInfos.find((f) => f.name === 'id')?.value
  91. // 业务类型
  92. const businessTypeId = eventScript.businessTypeId
  93. // 模块表单id
  94. const appModuleId = eventScript.appModuleId
  95. // 打开新建页面
  96. const extobj = { moduleId: appModuleId }
  97. const ext = qs.stringify('&extParams=' + extobj)
  98. const url =
  99. '/law-progress-page/pages/draft/0?businessTypeId=' +
  100. businessTypeId +
  101. ext +
  102. '&zt=2&jfid=' +
  103. jfid +
  104. '&stage=' +
  105. this.stagef +
  106. '&parentid=' +
  107. jfjzid
  108. const query = {}
  109. const oRoute = router.resolve({
  110. path: url,
  111. query: {
  112. ...query,
  113. },
  114. })
  115. if (isNewWindow) {
  116. const s = window.open(oRoute.href, '_blank')
  117. s.opener = null
  118. } else {
  119. router.push(oRoute.route.fullPath)
  120. }
  121. resolve()
  122. }
  123. },
  124. onCancel() {
  125. resolve(false)
  126. },
  127. })
  128. } else {
  129. let zt = '2'
  130. let url = ''
  131. if (!strjftype) {
  132. zt = '3'
  133. // 判断返回的是否有结案数据,无则打开结案新建页面,否则打开历史
  134. let jaflag = true // true 新建 false 为打开历史
  135. if (res1.data.length > 2) {
  136. if (res1.data[2].props.stepType === 'finish') {
  137. jaflag = false
  138. }
  139. }
  140. if (jaflag) {
  141. // 业务类型
  142. const businessTypeId = eventScript.businessTypeId
  143. // 模块表单id
  144. const appModuleId = eventScript.appModuleId
  145. // 打开新建页面
  146. const extobj = { moduleId: appModuleId }
  147. console.log(extobj)
  148. const ext = qs.stringify('&extParams=' + extobj)
  149. console.log(ext)
  150. url =
  151. '/law-progress-page/pages/draft/0?businessTypeId=' +
  152. businessTypeId +
  153. ext +
  154. '&zt=' +
  155. zt +
  156. '&jfid=' +
  157. jfid
  158. } else {
  159. url = res1.data[2].props.detailUrl + '/' + res1.data[2].props.detailInstid
  160. url = url.replace('#/sd-webflow', '/law-progress-page')
  161. url = url + '?zt=' + zt + '&jfid=' + jfid // 打开结案页面
  162. }
  163. } else {
  164. // 打开正在处理中的文档
  165. djurl = djurl.replace('#/sd-webflow', '/law-progress-page')
  166. url = djurl + '?zt=' + zt + '&jfid=' + jfid // 打开登记页面
  167. }
  168. const query = {}
  169. const oRoute = router.resolve({
  170. path: url,
  171. query: {
  172. ...query,
  173. },
  174. })
  175. if (isNewWindow) {
  176. const s = window.open(oRoute.href, '_blank')
  177. s.opener = null
  178. } else {
  179. router.push(oRoute.route.fullPath)
  180. }
  181. resolve()
  182. }
  183. })
  184. })
  185. } else {
  186. // 案件 判断目前是 案件进展 案件结案 案件执行?
  187. const strcasetype = eventScript.strcasetype // 进展1 否则结案2 执行3
  188. console.log('strcasetype---' + strcasetype)
  189. // 打开新建页面
  190. var s = this
  191. this.selectjd = []
  192. this.dataList = []
  193. this.treeData = []
  194. this.expandedKeys = ['0']
  195. this.selectedKeys = ['0']
  196. let parentid = ''
  197. console.log(eventScript)
  198. this.onLoadData = function(treeNode) {
  199. console.log('---1-onLoadData')
  200. if (treeNode.dataRef.children) return Promise.resolve()
  201. // let caseType = ''
  202. // let caseStage = ''
  203. // if (treeNode.dataRef.props.parentId === 'root') {
  204. // caseType = treeNode.dataRef.id
  205. // } else {
  206. // caseType = treeNode.dataRef.props.parentId
  207. // caseStage = treeNode.dataRef.id
  208. // }
  209. // return LawService.getCaseTree(caseType, caseStage).then((res) => {
  210. // res.data.forEach((d) => {
  211. // d.props.parentName = treeNode.dataRef.text
  212. // d.props.caseType = treeNode.dataRef.props.parentId
  213. // })
  214. // treeNode.dataRef.children = res.data
  215. // // console.log(this.treeData)
  216. // return treeNode
  217. // // this.treeData = this.transformData([...this.treeData])
  218. // // this.generateList(this.treeData)
  219. // })
  220. }
  221. this.transformData = function(data) {
  222. return data.map((d) => {
  223. const { children, ...rest } = d
  224. return {
  225. ...rest,
  226. children: children && this.transformData(children),
  227. scopedSlots: { title: 'title' },
  228. }
  229. })
  230. }
  231. // 处理搜索用的dataList
  232. this.generateList = function(data) {
  233. for (let i = 0; i < data.length; i++) {
  234. const node = data[i]
  235. const key = node.id
  236. const title = node.text
  237. const props = node.props
  238. this.dataList.push({ key, id: key, title: title, props })
  239. if (node.children) {
  240. if (node.children) {
  241. node.leaf = true
  242. }
  243. this.generateList(node.children)
  244. }
  245. }
  246. }
  247. this.treeCheck = function(allKeys, echecked) {
  248. console.log('--1')
  249. }
  250. this.onExpand = function(expandedKeys) {
  251. // 用户点击展开时,取消自动展开效果
  252. this.expandedKeys = expandedKeys
  253. this.autoExpandParent = false
  254. }
  255. // 拖拽节点方法
  256. this.onDrop = function(info) {
  257. // 被插入节点信息
  258. }
  259. this.treeSelect = function treeSelect(key, item) {
  260. console.log('--t')
  261. console.log(key)
  262. console.log(item)
  263. if (
  264. item.selectedNodes[0].data.props.props.businessTypeId &&
  265. item.selectedNodes[0].data.props.props.businessTypeId !== ''
  266. ) {
  267. console.log(item.selectedNodes[0].data)
  268. this.selectjd = [
  269. {
  270. url: item.selectedNodes[0].data.props.props.pageUrl,
  271. businessTypeId: item.selectedNodes[0].data.props.props.businessTypeId,
  272. stage: item.selectedNodes[0].data.props.id,
  273. stagename: item.selectedNodes[0].data.props.text,
  274. jdname: item.selectedNodes[0].data.props.props.parentName,
  275. caseStage: item.selectedNodes[0].data.props.props.parentId,
  276. caseType: item.selectedNodes[0].data.props.props.caseType,
  277. },
  278. ]
  279. } else {
  280. this.selectjd = []
  281. }
  282. }
  283. const { fieldInfos } = context
  284. const caseid = fieldInfos.find((f) => f.name === 'CASE_ID')?.value
  285. LawService.getProgressData(caseid).then((res1) => {
  286. console.log(res1)
  287. let zt = ''
  288. // 打开列表页面
  289. if (strcasetype === '1') {
  290. // 判断进展数据是否有未办结的
  291. zt = '2'
  292. let flag = true // true 才新建案件进展,弹出选择树,否则展示进展页面
  293. let casesburl = ''
  294. let url = ''
  295. if (res1.data.length > 1) {
  296. // 有案件登记
  297. if (res1.data[1].children && res1.data[1].children.length > 0) {
  298. if (
  299. res1.data[1].children[res1.data[1].children.length - 1].props.stepStatus === '0'
  300. ) {
  301. // 有案件登记并且未办结
  302. casesburl =
  303. res1.data[1].children[res1.data[1].children.length - 1].props.detailUrl +
  304. '/' +
  305. res1.data[1].children[res1.data[1].children.length - 1].props.detailInstid
  306. flag = false
  307. } else {
  308. // 有纠纷登记且办结
  309. }
  310. }
  311. parentid = res1.data[1].id
  312. }
  313. // 获取设置的默认值
  314. // const caseid = fieldInfos.find((f) => f.name === 'id')?.value
  315. // LawService.getAllCaseTree().then((r) => {
  316. if (flag) {
  317. LawService.getAllCaseTree().then((r) => {
  318. const treeNode = [
  319. {
  320. id: '0',
  321. text: '阶段',
  322. leaf: false,
  323. props: {},
  324. children: r.data,
  325. key: '0',
  326. },
  327. ]
  328. this.treeData = this.transformData(treeNode)
  329. this.generateList(this.treeData)
  330. console.log('--数据')
  331. console.log(this.treeData)
  332. // 弹出选择树
  333. Modal.confirm({
  334. title: '请选择阶段名称',
  335. content: (h) => {
  336. const info = []
  337. // stage.forEach((s) => {
  338. // info.push(h('a-select-option', { props: { value: s.code }, key: s.code }, s.name))
  339. // })
  340. // this.stage = stage
  341. // this.selectjd = []
  342. // return h('law-case-tree', {
  343. // on: { treeSelect: (key, item) => s.treeSelect(key, item) },
  344. // })
  345. // const treeData = this.treeData
  346. return h('div', null, [
  347. h('a-tree', {
  348. ref: 'tree',
  349. props: {
  350. 'block-node': false,
  351. 'show-icon': true,
  352. 'show-line': true,
  353. 'check-strictly': true,
  354. checkable: false,
  355. draggable: false,
  356. 'tree-data': this.treeData,
  357. 'replace-fields': {
  358. title: 'text',
  359. key: 'id',
  360. },
  361. 'expanded-keys': ['0'],
  362. 'default-expanded-keys': this.expandedKeys,
  363. 'selected-keys': this.$attrs['selected-keys'] || this.selectedKeys,
  364. 'load-data': this.onLoadData,
  365. },
  366. on: {
  367. select: this.treeSelect,
  368. check: this.treeCheck,
  369. expand: this.onExpand,
  370. drop: this.onDrop,
  371. },
  372. // on:{select:this.treeSelect,"update:selectedKeys":t.setSelectedKeys},
  373. // on: {
  374. // select: (key, item) => s.treeSelect(key, item),
  375. // check: (e) => s.treeCheck(e),
  376. // expand: (e) => s.onExpand(e),
  377. // drop: (e) => s.onDrop(e),
  378. // },
  379. }),
  380. ])
  381. },
  382. okText: '确定',
  383. okType: 'danger',
  384. onOk: () => {
  385. if (this.selectjd.length === 0) {
  386. Modal.warning({
  387. title: '提示',
  388. content: '请选择案件程序信息',
  389. })
  390. return false
  391. } else {
  392. // 获取设置的默认值
  393. // 业务类型
  394. const businessTypeId = this.selectjd[0].businessTypeId
  395. // 模块表单id
  396. // const appModuleId = eventScript.appModuleId
  397. // 打开新建页面
  398. // const extobj = { moduleId: appModuleId }
  399. // const ext = qs.stringify('&extParams=' + extobj)
  400. const url =
  401. '/case-progress-page/pages/draft/0?businessTypeId=' +
  402. businessTypeId +
  403. '&zt=2&caseid=' +
  404. caseid +
  405. '&stage=' +
  406. this.stagef +
  407. '&parentid='
  408. const query = {}
  409. const oRoute = router.resolve({
  410. path: url,
  411. query: {
  412. ...query,
  413. },
  414. })
  415. if (isNewWindow) {
  416. const s = window.open(oRoute.href, '_blank')
  417. s.opener = null
  418. } else {
  419. router.push(oRoute.route.fullPath)
  420. }
  421. resolve()
  422. }
  423. },
  424. onCancel() {
  425. resolve(false)
  426. },
  427. })
  428. })
  429. } else {
  430. // 展示信息
  431. // 打开正在处理中的文档
  432. casesburl = casesburl.replace('#/sd-webflow', '/law-progress-page')
  433. url = casesburl + '?zt=' + zt + '&caseid=' + caseid // 打开登记页面
  434. const query = {}
  435. const oRoute = router.resolve({
  436. path: url,
  437. query: {
  438. ...query,
  439. },
  440. })
  441. if (isNewWindow) {
  442. const s = window.open(oRoute.href, '_blank')
  443. s.opener = null
  444. } else {
  445. router.push(oRoute.route.fullPath)
  446. }
  447. resolve()
  448. }
  449. } else if (strcasetype === '2') {
  450. // 结案
  451. } else {
  452. // 执行 3
  453. }
  454. // 业务类型
  455. // const businessTypeId = '200800'
  456. // // 模块表单id
  457. // const appModuleId = eventScript.appModuleId
  458. // const zt = '1'
  459. // // 打开新建页面
  460. // // let url = res1.data[2].props.detailUrl + '/' + res1.data[2].props.detailInstid
  461. // // url = url.replace('#/sd-webflow', '/case-progress-page')
  462. // // url = url + '?zt=' + zt + '&caseid=' + caseid // 打开结案页面
  463. // // const extobj = { moduleId: appModuleId }
  464. // // const ext = qs.stringify('&extParams=' + extobj)
  465. // const url =
  466. // '/case-progress-page/pages/draft/0?businessTypeId=' +
  467. // businessTypeId +
  468. // '&zt=2&caseid=' +
  469. // caseid +
  470. // '&stage=' +
  471. // this.stagef +
  472. // '&parentid=' +
  473. // caseid
  474. // const query = {}
  475. // const oRoute = router.resolve({
  476. // path: url,
  477. // query: {
  478. // ...query,
  479. // },
  480. // })
  481. // if (isNewWindow) {
  482. // window.open(oRoute.href, '_blank')
  483. // } else {
  484. // router.push(oRoute.route.fullPath)
  485. // }
  486. // resolve()
  487. })
  488. }
  489. })
  490. }