index.vue 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  1. <template>
  2. <div :class="{'ibps-fixed-toolbar':checkMode}">
  3. <van-sticky>
  4. <van-nav-bar :title="generateTitle($route.name,$route.params.title||$route.meta.title)"
  5. :left-text="$t('common.button.back')" :right-text="$utils.isNotEmpty(listData)?rightText:''" left-arrow
  6. @click-left="$router.push({ name: 'dashboard' })" @click-right="toCheckMode()" />
  7. <van-search v-model="subject" show-action placeholder="请输入搜索关键词" @search="onSearch">
  8. <template #left>
  9. <van-icon name="bars" :class="{'ibps-active':$utils.isNotEmpty(typeId)}" class="ibps-pr-5"
  10. @click="clickType" />
  11. </template>
  12. <template #action>
  13. <van-icon name="filter-o" :class="{'ibps-active':stateActive}" @click="clickMoreSearch" />
  14. </template>
  15. </van-search>
  16. </van-sticky>
  17. <van-pull-refresh v-model="refreshing" @refresh="onRefresh">
  18. <van-list v-model="loading" :finished="finished" @load="loadData">
  19. <van-checkbox-group v-model="checkedIds">
  20. <van-cell v-for="(item,index) in listData" :key="item.id+index" :title="item.procDefName"
  21. :label="getTaskDesc(item.subject)" @click="onClick(item,index)">
  22. <template slot="icon">
  23. <van-checkbox v-if="checkMode" ref="checkboxes" :name="item.id" class="ibps-mr-10" />
  24. <ibps-avatar v-else :icon="_randomIcon(index)" :text="item.name" :bg-color="_randomColor(index)"
  25. radius="4" icon-prefix="ibps-icon" class="ibps-mr-10" />
  26. </template>
  27. <span>{{ item.createTime|formatRelativeTime }}</span>
  28. <div>
  29. <!-- <van-tag plain :type=" item.status | optionsFilter(bpmnStatusOptions,'type')">{{ item.status | optionsFilter(bpmnStatusOptions) }}</van-tag> -->
  30. <van-tag size="medium"
  31. :color="item.status | optionsFilter(bpmnStatusOptions,'type') | optionsFilter(colorOptions,'color','type')"
  32. :text-color="item.status | optionsFilter(bpmnStatusOptions,'type') | optionsFilter(colorOptions,'textColor','type')">
  33. {{ item.status| optionsFilter(bpmnStatusOptions) }}</van-tag>
  34. </div>
  35. </van-cell>
  36. </van-checkbox-group>
  37. <ibps-list-result-page :result-type="resultType" :error-type="errorType" :result-message="resultMessage" />
  38. </van-list>
  39. </van-pull-refresh>
  40. <ibps-toolbar v-show="checkMode" :actions="mainActions" />
  41. <ibps-more-search :show="moreSearchPopup" :search-forms="searchForms" @callback="onMoreSearch"
  42. @close="show => moreSearchPopup = show" @reset-form="resetForm" />
  43. <ibps-type-tree v-model="typeTreePopup" title="流程分类" category-key="FLOW_TYPE" @node-click="clickTypeNode"
  44. @close="visible => typeTreePopup = visible" />
  45. <ibps-bpmn-formrender-dialog :visible="formrenderVisible" :title="formrenderTitle" :pro-inst-id="proInstId"
  46. :def-id="defId" @close="visible => formrenderVisible = visible" @callback="onSearch" />
  47. </div>
  48. </template>
  49. <script>
  50. import { myDraft, removeDraft } from '@/api/platform/office/bpmInitiated'
  51. import ActionUtils from '@/utils/action'
  52. import i18n from '@/utils/i18n'
  53. import random from '@/mixins/random'
  54. import bpmnStatus from '@/mixins/bpmnStatus'
  55. import IbpsMoreSearch from '@/components/ibps-more-search'
  56. import IbpsTypeTree from '@/business/platform/cat/type/tree'
  57. import IbpsAvatar from '@/components/ibps-avatar'
  58. import IbpsToolbar from '@/components/ibps-toolbar'
  59. import IbpsListResultPage from '@/components/ibps-list-result-page'
  60. import IbpsBpmnFormrenderDialog from '@/business/platform/bpmn/form/dialog'
  61. export default {
  62. components: {
  63. IbpsMoreSearch,
  64. IbpsTypeTree,
  65. IbpsAvatar,
  66. IbpsToolbar,
  67. IbpsListResultPage,
  68. IbpsBpmnFormrenderDialog
  69. },
  70. mixins: [random, bpmnStatus],
  71. data() {
  72. return {
  73. stateActive: false,
  74. moreSearchPopup: false,
  75. typeTreePopup: false,
  76. searchForms: {
  77. forms: [
  78. { prop: 'Q^subject_^SL', label: '事务名称', fieldType: 'text' },
  79. // { prop: 'Q^proc_def_name_^SL', label: '事务说明', fieldType: 'text' },
  80. { prop: 'Q^inst.subject_^SL', label: '事务说明', fieldType: 'text' },
  81. { prop: ['Q^create_time_^DL', 'Q^create_time_^DG'], label: '创建时间', fieldType: 'dateRange', options: { datefmt: 'yyyy-MM-dd' } }
  82. ]
  83. },
  84. subject: '',
  85. typeId: '',
  86. moreParams: {},
  87. listData: [],
  88. pagination: {},
  89. sorts: {},
  90. loading: false,
  91. finished: false,
  92. refreshing: false,
  93. resultType: 'init',
  94. errorType: null,
  95. resultMessage: null,
  96. checkMode: false,
  97. checkedIds: [],
  98. mainActions: [{
  99. 'name': this.$t('common.button.remove'),
  100. 'type': 'danger',
  101. 'callback': this.onRemove
  102. }],
  103. proInstId: '',
  104. defId: '',
  105. formrenderVisible: false,
  106. formrenderTitle: ''
  107. }
  108. },
  109. computed: {
  110. rightText() {
  111. return this.checkMode ? this.$t('common.button.cancel') : this.$t('common.button.manage')
  112. },
  113. selectedIds() {
  114. return this.checkedIds.join(',')
  115. }
  116. },
  117. methods: {
  118. generateTitle(name, title) { // generateTitle by vue-i18n
  119. return i18n.generateTitle(name, title)
  120. },
  121. /**
  122. * 加载数据
  123. *
  124. */
  125. loadData() {
  126. this.loading = true
  127. myDraft(this.getSearcFormData()).then(response => {
  128. // 处理数据
  129. ActionUtils.handleListData(this, response.data)
  130. }).catch((e) => {
  131. ActionUtils.handleErrorData(this, e)
  132. })
  133. },
  134. /**
  135. * 获取格式化参数
  136. */
  137. getSearcFormData() {
  138. let params = {}
  139. if (this.$utils.isNotEmpty(this.subject)) {
  140. params['Q^subject_^SL'] = this.subject
  141. }
  142. if (this.$utils.isNotEmpty(this.moreParams)) {
  143. params = Object.assign(params, this.moreParams)
  144. }
  145. return ActionUtils.formatParams(
  146. params,
  147. this.pagination,
  148. this.sorts)
  149. },
  150. /**
  151. * 下拉刷新
  152. */
  153. onRefresh() {
  154. this.refreshing = true
  155. this.finished = false
  156. this.loading = true
  157. this.onSearch()
  158. },
  159. /**
  160. * 查询
  161. */
  162. onSearch() {
  163. this.stateActive = false
  164. ActionUtils.initListData(this)
  165. this.loadData()
  166. },
  167. /**
  168. * 高级查询
  169. */
  170. onMoreSearch(params) {
  171. console.log("params", params, this.typeId);
  172. if (this.$utils.isNotEmpty(this.typeId)) {
  173. params['Q^type_id_^SL'] = this.typeId
  174. }
  175. this.moreParams = params
  176. this.onSearch()
  177. if (this.$utils.isNotEmpty(params)) {
  178. this.stateActive = true
  179. }
  180. },
  181. /**
  182. * 弹窗更多查询条件
  183. */
  184. clickMoreSearch() {
  185. this.moreSearchPopup = true
  186. this.stateActive = false
  187. },
  188. /**
  189. * 重置表单
  190. */
  191. resetForm() {
  192. this.typeId = ''
  193. },
  194. getTaskDesc(v) {
  195. if (!v.includes('#')) {
  196. return ''
  197. }
  198. return v.split('#')[1] || ''
  199. },
  200. // 点击左边显示
  201. clickType() {
  202. this.typeTreePopup = true
  203. },
  204. clickTypeNode(data) {
  205. this.typeId = data.id
  206. this.onMoreSearch({})
  207. },
  208. onClick(item, index) {
  209. if (this.checkMode) {
  210. this.$refs.checkboxes[index].toggle()
  211. } else {
  212. this.proInstId = item.id
  213. this.defId = item.procDefId
  214. this.formrenderTitle = item.procDefName
  215. this.formrenderVisible = true
  216. }
  217. },
  218. onRefreshPage() {
  219. this.checkedIds = []
  220. this.checkMode = false
  221. this.onRefresh()
  222. },
  223. toCheckMode() {
  224. if (this.$utils.isEmpty(this.listData)) {
  225. return
  226. }
  227. if (this.checkMode) {
  228. // this.show = true
  229. this.checkedIds = []
  230. }
  231. this.checkMode = !this.checkMode
  232. },
  233. onRemove() {
  234. if (this.checkedIds.length === 0) {
  235. this.$notify({
  236. type: 'warning',
  237. message: this.$t('common.dialog.selectedRecords')
  238. })
  239. return
  240. }
  241. this.$dialog.confirm({
  242. title: this.$t('common.dialog.warn'),
  243. message: this.$t('common.operate.makeSure')
  244. }).then(() => {
  245. removeDraft({ ids: this.selectedIds }).then(response => {
  246. this.$notify({
  247. type: 'success',
  248. message: '删除草稿成功!'
  249. })
  250. this.onRefreshPage()
  251. }).catch((e) => {
  252. console.error(e)
  253. })
  254. })
  255. }
  256. }
  257. }
  258. </script>
  259. <style lang="scss" scoped>
  260. ::v-deep .van-cell__title {
  261. width: 65%;
  262. .van-cell__label {
  263. overflow-wrap: break-word;
  264. }
  265. }
  266. </style>