xm-cpm-delete-flow-handler.js 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. import { message, Modal } from 'ant-design-vue'
  2. import xmMultipleDataService from './xm-multiple-data-service'
  3. import { getUserInfo } from '@/common/store-mixin'
  4. export default function ({ button, eventScript, context: { args, dataList } }) {
  5. return new Promise((resolve) => {
  6. const selrows = dataList.selectedRows
  7. if (selrows && selrows[0]) {
  8. // 判断是否均为起草环节单据
  9. if (selrows.some((item) => item.flowStatus !== 0)) {
  10. Modal.error({
  11. title: '删除失败:存在不是起草状态的数据',
  12. })
  13. // } else if (
  14. // selrows.some((item) => item.CREATOR_NAME && item.CREATOR_NAME !== getUserInfo().name)
  15. // ) {
  16. // // 判断当前人不是创建人的不可删除
  17. // Modal.error({
  18. // title: '删除失败:存在不是本人起草的数据',
  19. // })
  20. } else {
  21. const instIds = []
  22. selrows.forEach((sitem) => {
  23. instIds.push(sitem.instId)
  24. })
  25. Modal.confirm({
  26. title: '你确定删除这项内容吗?',
  27. content: '删除这条数据后,就无法恢复初始的状态。',
  28. okText: '删除',
  29. okType: 'danger',
  30. onOk: () => {
  31. this.loading = true
  32. const params = {
  33. flowCallbackBeanName: 'formBeanCleanerCallBack',
  34. processInstanceIds: instIds.join(','),
  35. }
  36. xmMultipleDataService
  37. .fndeleteflow(params)
  38. .then((res) => {
  39. if (res.status === 200) {
  40. message.success('删除成功')
  41. resolve()
  42. setTimeout(() => {
  43. dataList.clearSelection()
  44. dataList.refresh()
  45. this.loading = false
  46. }, 1000)
  47. } else {
  48. message.error('删除失败,请联系管理员')
  49. }
  50. })
  51. .catch((e) => {
  52. if (e?.response?.data?.message?.includes('权限')) {
  53. message.error('删除失败:只能删除本人的草稿文件')
  54. return
  55. }
  56. message.error('删除失败,请联系管理员')
  57. })
  58. },
  59. })
  60. }
  61. } else {
  62. Modal.info({
  63. content: '请选择需要删除的文件',
  64. })
  65. }
  66. resolve()
  67. })
  68. }