applyHome.vue 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  1. <template>
  2. <a-card :bordered="false">
  3. <!--流程申请选择-->
  4. <a-input-search
  5. style="margin-bottom: 10px;margin-right:10px;width: 200px"
  6. v-model="searchProcessKey"
  7. placeholder="输入流程名称"
  8. @search="onSearchProcess"
  9. />
  10. <a-button @click="onSearchProcess(searchProcessKey)" type="primary">查询</a-button>
  11. <a-button @click="onSearchProcess('')">重置</a-button>
  12. <a-button @click="handleToApplyList" type="primary" style="float: right;">前往我的申请列表</a-button>
  13. <a-empty description="无流程可供选择" v-if="activeKeyAll.length==0" />
  14. <div v-else>
  15. <a-collapse v-model="activeKey">
  16. <a-collapse-panel
  17. v-for="(value, index) in activeKeyAll"
  18. :header="filterDictText(dictOptions,value)||'未分类'"
  19. :key="value"
  20. >
  21. <a-list :grid="{ gutter: 10,column:4}" :dataSource="processDataMap[value]">
  22. <a-list-item slot="renderItem" slot-scope="item">
  23. <a-card>
  24. <div slot="title">
  25. <a-row>
  26. <a-col span="12" :title="item.name">{{item.name}}</a-col>
  27. <a-col span="12" style="text-align: right;">
  28. <a href="javascript:void (0)" @click="chooseProcess(item)">发起申请</a>
  29. </a-col>
  30. </a-row>
  31. </div>
  32. <b>版本:</b>
  33. v.{{item.version}}
  34. <br />
  35. <b>说明:</b>
  36. {{item.description}}
  37. </a-card>
  38. </a-list-item>
  39. </a-list>
  40. </a-collapse-panel>
  41. </a-collapse>
  42. </div>
  43. <!--流程表单-->
  44. <a-modal :title="lcModa.title" v-model="lcModa.visible" :maskClosable="false" width="80%">
  45. <!-- <component
  46. :disabled="lcModa.disabled"
  47. v-if="lcModa.visible"
  48. :is="lcModa.formComponent"
  49. :processData="lcModa.processData"
  50. :isNew="lcModa.isNew"
  51. @afterSubmit="afterSub"
  52. @close="lcModa.visible=false,lcModa.disabled = false"
  53. ></component>-->
  54. <template slot="footer">
  55. <a-button @click="lcModa.visible=false">关闭</a-button>
  56. <a-button key="back" @click="close">重置</a-button>
  57. <a-button key="submit" type="primary" @click="handleOkAll" :loading="loadingElse">提交</a-button>
  58. </template>
  59. <k-form-build v-if="lcModa.visible" :defaultValue="defaultValue" :value="jsonData" ref="kfb" />
  60. </a-modal>
  61. </a-card>
  62. </template>
  63. <script>
  64. import { activitiMixin } from '@/views/activiti/mixins/activitiMixin'
  65. import JEllipsis from '@/components/jeecg/JEllipsis'
  66. import JTreeSelect from '@/components/jeecg/JTreeSelect'
  67. import { initDictOptions, filterDictText } from '@/components/dict/JDictSelectUtil'
  68. import historicDetail from '@/views/activiti/historicDetail'
  69. import { deleteAction, getAction, downFile,postAction } from '@/api/manage'
  70. export default {
  71. name: 'applyHome',
  72. mixins: [activitiMixin],
  73. components: {
  74. JEllipsis,
  75. JTreeSelect,
  76. historicDetail,
  77. },
  78. data() {
  79. return {
  80. loadingElse: false,
  81. typeList: [
  82. 'input',
  83. 'textarea',
  84. 'number',
  85. 'select',
  86. 'checkbox',
  87. 'radio',
  88. 'date',
  89. 'time',
  90. 'rate',
  91. 'slider',
  92. 'uploadFile',
  93. 'uploadImg',
  94. 'switch',
  95. 'button',
  96. 'text',
  97. 'card',
  98. 'grid',
  99. 'table',
  100. ], //"alert","html", "divider",
  101. description: '所有',
  102. dictOptions: [],
  103. url: {
  104. getProcessDataList: '/activiti_process/listData',
  105. getFirstNode: '/actProcessIns/getFirstNode',
  106. applyBusiness: '/actBusiness/apply',
  107. },
  108. // 查询条件
  109. queryParam: {
  110. createTimeRange: [],
  111. keyWord: '',
  112. },
  113. // 表头
  114. labelCol: {
  115. xs: {
  116. span: 4,
  117. },
  118. sm: {
  119. span: 4,
  120. },
  121. },
  122. wrapperCol: {
  123. xs: {
  124. span: 20,
  125. },
  126. sm: {
  127. span: 20,
  128. },
  129. },
  130. processModalVisible: null,
  131. activeKeyAll: [],
  132. activeKey: [],
  133. processDataMap: {},
  134. searchProcessKey: null,
  135. addApplyLoading: false,
  136. lcModa: {
  137. title: '',
  138. disabled: false,
  139. visible: false,
  140. formComponent: null,
  141. isNew: false,
  142. },
  143. jsonData: {},
  144. defaultValue: {},
  145. }
  146. },
  147. computed: {},
  148. mounted() {
  149. this.initDictConfig()
  150. this.getProcessList()
  151. },
  152. methods: {
  153. handleOkAll() {
  154. this.loadingElse = true
  155. var that = this
  156. this.$refs.kfb
  157. .getData()
  158. .then((values) => {
  159. console.log('验证通过', values,this.lcModa.processData)
  160. var formData = {}
  161. formData.tableId = this.lcModa.processData.customTableId
  162. formData.procDefId = this.lcModa.processData.id
  163. formData.procDeTitle = this.lcModa.processData.name
  164. formData.formText = JSON.stringify(values)
  165. postAction('/actBusiness/add', formData)
  166. .then((res) => {
  167. if (res.success) {
  168. that.lcModa.visible=false
  169. that.$message.success('保存成功!')
  170. that.loadingElse = false
  171. } else {
  172. that.$message.error(res.message)
  173. that.loadingElse = false
  174. }
  175. })
  176. .finally(() => {
  177. that.loadingElse = false
  178. })
  179. })
  180. },
  181. close() {
  182. this.$refs.kfb.reset()
  183. },
  184. saveJson(json) {
  185. console.log(json)
  186. },
  187. initDictConfig() {
  188. //初始化字典 - 流程分类
  189. initDictOptions('bpm_process_type').then((res) => {
  190. if (res.success) {
  191. this.dictOptions = res.result
  192. }
  193. })
  194. },
  195. filterDictText(dictOptions, text) {
  196. if (dictOptions instanceof Array) {
  197. for (let dictItem of dictOptions) {
  198. if (text === dictItem.value) {
  199. return dictItem.text
  200. }
  201. }
  202. }
  203. return text || text == 'null' ? '' : text
  204. },
  205. /*加载流程列表*/
  206. getProcessList() {
  207. this.addApplyLoading = true
  208. this.getAction(this.url.getProcessDataList, {
  209. status: 1,
  210. roles: true,
  211. })
  212. .then((res) => {
  213. this.activeKeyAll = []
  214. if (res.success) {
  215. var result = res.result || []
  216. if (result.length > 0) {
  217. let searchProcessKey = this.searchProcessKey
  218. if (searchProcessKey) {
  219. //过滤条件
  220. result = _.filter(result, function (o) {
  221. return o.name.indexOf(searchProcessKey) > -1
  222. })
  223. }
  224. this.processDataMap = _.groupBy(result, 'categoryId')
  225. for (const categoryId in this.processDataMap) {
  226. this.activeKeyAll.push(categoryId)
  227. }
  228. this.activeKey = this.activeKeyAll
  229. }
  230. this.processModalVisible = true
  231. } else {
  232. this.$message.warning(res.message)
  233. }
  234. })
  235. .finally(() => (this.addApplyLoading = false))
  236. },
  237. onSearchProcess(value) {
  238. this.searchProcessKey = value
  239. this.getProcessList()
  240. },
  241. chooseProcess(v) {
  242. getAction('/ctop/actCustomForm/queryById', { id: v.customTableId }).then((res) => {
  243. if (res.success) {
  244. this.jsonData = JSON.parse(res.result.text)
  245. } else {
  246. this.$message.warning('该流程信息未配置表单,请联系开发人员!')
  247. return
  248. }
  249. })
  250. this.loadingElse = false
  251. // this.lcModa.formComponent = this.getFormComponent(v.routeName).component
  252. this.lcModa.title = '发起流程:' + v.name
  253. this.lcModa.isNew = true
  254. this.lcModa.processData = v
  255. this.lcModa.visible = true
  256. console.log('发起', v)
  257. },
  258. /*提交成功申请后*/
  259. afterSub(formData) {
  260. this.lcModa.visible = false
  261. this.$message('请前往我的申请列表提交审批!')
  262. },
  263. /*前往我的申请页面*/
  264. handleToApplyList() {
  265. this.$router.push({
  266. path: '/activiti/applyList',
  267. })
  268. },
  269. },
  270. }
  271. </script>
  272. <style scoped>
  273. @import '~@assets/less/common.less';
  274. </style>