ActivitiUserModelTable.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. <template>
  2. <a-modal
  3. :title="modalTitle"
  4. :width="1200"
  5. :visible="visible"
  6. :confirmLoading="confirmLoading"
  7. class="ant-modal2"
  8. @cancel="handleCancel"
  9. >
  10. <div class="table-operator" style="margin-bottom: 8px;">
  11. </div>
  12. <a-table
  13. bordered
  14. :data-source="data"
  15. :columns="columns"
  16. tableLayout="auto"
  17. rowKey="id"
  18. :row-selection="rowSelection">
  19. <span slot="action" slot-scope="record">
  20. <template>
  21. <a @click="handleView(record)">查看</a>
  22. <a-divider type="vertical" />
  23. <a @click="handleEdit(record)">修改</a>
  24. </template>
  25. </span>
  26. </a-table>
  27. <template slot="footer">
  28. <a-button :loading="confirmLoading" type="primary" @click="save()">保存</a-button>
  29. </template>
  30. <base-form ref="baseModal" :roleList="roleList" @ok="handleOk"/>
  31. <detail ref="detailModal" @ok="handleOk"/>
  32. </a-modal>
  33. </template>
  34. <script>
  35. import {
  36. fetchActivitiUserModel,
  37. fetchActivitiUserModelByModelId,
  38. updateActivitiUserModelBatch
  39. } from '@/api/activiti/user-model'
  40. import BaseForm from './BaseForm'
  41. import Detail from './Detail'
  42. import { queryRole } from '@/api/upms/role'
  43. export default {
  44. name: 'ActivitiUserModelTable',
  45. components: {
  46. BaseForm,
  47. Detail
  48. },
  49. data () {
  50. return {
  51. roleList: [],
  52. confirmLoading: false,
  53. modalTitle: null,
  54. form: this.$form.createForm(this),
  55. visible: false,
  56. maskClosable: false,
  57. model: null,
  58. storeId: null,
  59. typeMap: {},
  60. userList: {},
  61. storeTreeDate: [],
  62. rowSelection: {
  63. onChange: (selectedRowKeys, selectedRows) => {
  64. this.selectedRowKeys = selectedRowKeys
  65. this.selectedRows = selectedRows
  66. }
  67. },
  68. // 表头
  69. columns: [
  70. {
  71. title: '序号',
  72. dataIndex: 'index',
  73. customRender: (text, record, index) => {
  74. return `${index + 1}`
  75. }
  76. },
  77. {
  78. title: '模型id',
  79. dataIndex: 'reModelId'
  80. },
  81. {
  82. title: '节点名称',
  83. dataIndex: 'name'
  84. },
  85. {
  86. title: '类型',
  87. dataIndex: 'type',
  88. customRender: (text, record, index) => {
  89. return this.BaseTool.Object.getField(this.typeMap, text)
  90. }
  91. },
  92. {
  93. title: '流程变量',
  94. dataIndex: 'formVariable'
  95. },
  96. {
  97. title: '备注',
  98. dataIndex: 'remark'
  99. },
  100. {
  101. title: '操作',
  102. key: 'action',
  103. width: '200px',
  104. align: 'center',
  105. scopedSlots: { customRender: 'action' }
  106. }
  107. ],
  108. data: [],
  109. user: this.$store.getters.userInfo,
  110. selectedRowKeys: [],
  111. selectedRows: [],
  112. options: {
  113. rowSelection: {
  114. selectedRowKeys: this.selectedRowKeys
  115. }
  116. }
  117. }
  118. },
  119. props: {
  120. },
  121. created () {
  122. // 下拉框map
  123. this.typeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.ACTIVITI_USER_MODEL_TYPE)
  124. this.getRoles()
  125. },
  126. methods: {
  127. getRoles () {
  128. queryRole({ status: 1 }).then(res => {
  129. this.roleList = res.data
  130. })
  131. },
  132. base (record) {
  133. this.visible = true
  134. this.model = record
  135. this.modalTitle = '节点设置'
  136. fetchActivitiUserModelByModelId({ id: record.id }).then(res => {
  137. this.data = res.data
  138. })
  139. },
  140. handleEdit (record) {
  141. fetchActivitiUserModel({ id: record.id }).then(res => {
  142. const modal = this.$refs.baseModal
  143. modal.base(res.data)
  144. })
  145. },
  146. handleView (record) {
  147. fetchActivitiUserModel({ id: record.id }).then(res => {
  148. const modal = this.$refs.detailModal
  149. modal.base(res.data)
  150. })
  151. },
  152. save () {
  153. this.confirmLoading = true
  154. updateActivitiUserModelBatch({ list: this.data, modelId: this.model.id })
  155. .then(() => {
  156. this.handleCancel()
  157. }).catch(() => {
  158. this.confirmLoading = false
  159. })
  160. },
  161. handleOk () {
  162. this.visible = true
  163. this.base(this.model)
  164. },
  165. handleCancel (values) {
  166. this.visible = false
  167. this.confirmLoading = false
  168. this.form.resetFields()
  169. if (this.BaseTool.Object.isNotBlank(values)) {
  170. this.$emit('ok', values)
  171. } else {
  172. this.$emit('ok')
  173. }
  174. }
  175. }
  176. }
  177. </script>