xm-audit-cpm-checkself-setdept-handler.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. <script>
  2. import auditGroupPicker from '@product/iam/components/picker/audit-group-picker.vue'
  3. import pickValues from '@/common/services/pick-values'
  4. import { message } from '@/common/one-ui'
  5. import axios from '@/common/services/axios-instance'
  6. import components from './_import-components/xm-audit-cpm-checkself-setdept-handler-import'
  7. export default {
  8. name: 'XmAuditCpmCheckselfSetdeptHandler',
  9. components,
  10. data() {
  11. return {
  12. button: {},
  13. initValues: [],
  14. childTable: undefined,
  15. selectedRows: [],
  16. eventScript: undefined,
  17. filterDeptId: undefined,
  18. }
  19. },
  20. methods: {
  21. run({ button, eventScript, context: { args, dataList } }) {
  22. this.button = button
  23. this.childTable = dataList
  24. this.selectedRows = dataList.getSelectedRows()
  25. // 根据需修改的字段,获取字段信息
  26. this.eventScript = eventScript
  27. /// 获取非隐藏 且 包含在事件配置修改字段中的字段
  28. // this.initValues =
  29. // childTable?.fields.filter((f) => !f.attrFD?.hidden && modifyFields.includes(f.name)) || []
  30. this.fnGetProjectChildTable().then((res) => {
  31. // 记录过滤部门ID
  32. if (res) {
  33. this.filterDeptId = res
  34. }
  35. // 获取项目的被检查单位
  36. axios({
  37. method: 'get',
  38. url: `api/xcoa-mobile/v1/cpm-work-paper/getProject?id=${this.$route.query.projectId}`,
  39. }).then((res) => {
  40. const checkdeptnames = res.data[0].checkedDeptNames
  41. const checkdeptcodes = res.data[0].checkedDeptIds
  42. const names = checkdeptnames.split(',')
  43. const codes = checkdeptcodes.split(',')
  44. let orgfw = []
  45. names.forEach((n, index) => {
  46. orgfw.push({
  47. type: 'Group',
  48. name: n,
  49. code: codes[index],
  50. })
  51. })
  52. if (this.filterDeptId) {
  53. orgfw = orgfw.filter((item) => item.code === this.filterDeptId)
  54. }
  55. pickValues(auditGroupPicker, {
  56. single: orgfw.length === 1,
  57. selectchecked: true,
  58. selectcheckfn: () => {
  59. return new Promise((resolve) => {
  60. resolve(orgfw)
  61. })
  62. },
  63. }).then((res) => {
  64. if (!res | (res && res.length === 0)) return
  65. this.deptChange(res.map((item) => item.code))
  66. })
  67. })
  68. })
  69. },
  70. deptChange(deptList) {
  71. const projectId = this.$route.query.projectId
  72. const groupId = this.$route.query.groupId
  73. const deptIds = deptList.join(',')
  74. axios({
  75. url: `api/framework/v1/cpmcheckself/cpmCheckSelfEntitySave?projectId=${projectId}&subProjectId=${groupId}&ids=${deptIds}`,
  76. method: 'get',
  77. }).then((res) => {
  78. if (res.data.success) {
  79. message.success('分配完成')
  80. } else {
  81. message.error(res.data.message)
  82. }
  83. this.childTable.refresh()
  84. })
  85. },
  86. // 获取项目子表数据
  87. fnGetProjectChildTable() {
  88. const groupId = this.$route.query.groupId
  89. // 有gropuId说明是子项目,需要过滤部门
  90. if (groupId.toString() === '1') {
  91. return new Promise((resolve) => {
  92. resolve()
  93. })
  94. }
  95. return axios({
  96. method: 'post',
  97. url: `api/framework/v1/page/wp/onl:cd78040cdda84c6b90b2c688d9bfbaa1`,
  98. data: {
  99. id: this.$route.query.projectId,
  100. },
  101. }).then((res) => {
  102. const list = JSON.parse(
  103. res.data.pageFormData.pageFieldInfos.find((item) => {
  104. return item.name === 'CPM_SUB_PROJECT'
  105. }).value
  106. )
  107. return list.filter((item) => {
  108. return item.id.toString() === groupId.toString()
  109. })[0].CHECKED_DEPT_ID
  110. })
  111. },
  112. },
  113. render: () => {
  114. return ''
  115. },
  116. }
  117. </script>
  118. <style module lang="scss">
  119. @use '@/common/design' as *;
  120. :global(.deptTable) {
  121. :global(.ant-table-tbody > tr > td) {
  122. border-right: none;
  123. border-left: none;
  124. }
  125. :global(.ant-table-thead > tr > th) {
  126. border-right: none;
  127. border-left: none;
  128. }
  129. :global(table) {
  130. border: none !important;
  131. }
  132. :global(.ant-table-placeholder) {
  133. border: none !important;
  134. }
  135. }
  136. </style>