startWorkflow.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. <template>
  2. <view class="start-workflow">
  3. <view class="start-workflow-search">
  4. <u-search
  5. placeholder="查询流程"
  6. v-model="keyword"
  7. bg-color="#fff"
  8. margin="16rpx 24rpx"
  9. :input-style="{
  10. fontSize: variables.mainFontSize,
  11. padding: '0rpx 40rpx',
  12. }"
  13. :action-style="{fontSize: variables.mainFontSize}"
  14. :border-color="'#F2F2F2'"
  15. :bg-color="'#F2F2F2'"
  16. :height="74"
  17. @search="() => searchKeyWord = keyword"
  18. @custom="() => searchKeyWord = keyword"
  19. :show-action="false"
  20. input-align="center"
  21. />
  22. <u-tabs
  23. font-size="30"
  24. :active-color="variables.mainColor"
  25. inactive-color="#606266"
  26. :current="current"
  27. :list="tabList"
  28. @change="handleChange"/>
  29. <!-- 移动端只分两级, -->
  30. <u-tabs
  31. font-size="30"
  32. :active-color="variables.mainColor"
  33. inactive-color="#606266"
  34. :current="childCurrent"
  35. :list="tabChildrenList"
  36. @change="handleChildChange"/>
  37. </view>
  38. <view class="process-definition-list" >
  39. <process-definition-list :search-key-word="searchKeyWord" :category="category" :process-definition-height='processDefinitionHeight'/>
  40. </view>
  41. </view>
  42. </template>
  43. <script>
  44. import processDefinitionList from './processDefinitionList.vue'
  45. import variables from '@/styles/variables.scss'
  46. export default {
  47. components: {
  48. processDefinitionList
  49. },
  50. computed: {
  51. processDefinitionHeight() {
  52. return this.startWorkflowHeight - this.searchHeight
  53. }
  54. },
  55. data() {
  56. return {
  57. category: '',
  58. parentCategoryInfo: {},
  59. current:0,
  60. childrenCurrent: '',
  61. keyword: '',
  62. categoryList: [],
  63. tabList: [],
  64. childCurrent: 0,
  65. tabChildrenList: [],
  66. childCartegoryList: [],
  67. startWorkflowHeight: 0,
  68. searchHeight: 0,
  69. variables,
  70. searchKeyWord: ''
  71. };
  72. },
  73. created() {
  74. this.loadCategory()
  75. },
  76. methods: {
  77. async loadCategory() {
  78. try{
  79. uni.showLoading({
  80. title: '加载中'
  81. })
  82. const res = await this.$dibootApi.get('/mobile/workflow/processDefinition/getAuthorizedCategoryTree')
  83. if(res.code === 0 && res.data ) {
  84. this.categoryList = res.data
  85. this.tabList = [{
  86. name: '全部'
  87. }, ...this.categoryList.map(item => {
  88. return {
  89. name: item.name
  90. }
  91. })]
  92. this.handleChange(0)
  93. }
  94. } catch(e){
  95. //TODO handle the exception
  96. } finally {
  97. uni.hideLoading()
  98. }
  99. },
  100. /**
  101. * 切换一级分类
  102. * @param {Object} index
  103. */
  104. handleChange(index) {
  105. this.keyword = ''
  106. this.searchKeyWord = ''
  107. this.current = index
  108. this.tabChildrenList = []
  109. this.childCartegoryList = []
  110. this.childrenCurrent = 0
  111. this.resetHeight()
  112. if(this.tabList[index].name === '全部') {
  113. this.parentCategoryInfo = {}
  114. this.category = ''
  115. return
  116. }
  117. this.parentCategoryInfo = this.categoryList[index - 1]
  118. this.category = this.parentCategoryInfo.id
  119. this.childCartegoryList = this.parentCategoryInfo.children || []
  120. if(this.childCartegoryList && this.childCartegoryList.length > 0) {
  121. this.tabChildrenList = [{
  122. name: '全部'
  123. }, ...this.childCartegoryList.map(item => {
  124. return {
  125. name: item.name
  126. }
  127. })]
  128. }
  129. },
  130. /**
  131. * 切换二级分类
  132. * @param {Object} index
  133. */
  134. handleChildChange(index) {
  135. this.keyword = ''
  136. this.searchKeyWord = ''
  137. this.childCurrent = index
  138. if(this.tabChildrenList[index].name === '全部') {
  139. this.category = this.parentCategoryInfo.id
  140. return
  141. }
  142. const categoryInfo = this.childCartegoryList[index - 1]
  143. this.category = categoryInfo.id
  144. this.resetHeight()
  145. },
  146. async resetHeight() {
  147. await this.$nextTick()
  148. const query = uni.createSelectorQuery().in(this)
  149. query.select(".start-workflow")
  150. .boundingClientRect(data => {
  151. this.startWorkflowHeight = data && data.height || 0
  152. }).exec()
  153. query.select(".start-workflow-search")
  154. .boundingClientRect(data => {
  155. this.searchHeight = data && data.height || 0
  156. }).exec()
  157. }
  158. }
  159. }
  160. </script>
  161. <style lang="scss">
  162. .start-workflow {
  163. height: 100%;
  164. display: flex;
  165. flex-direction: column;
  166. .start-workflow-search {
  167. background-color: #fff;
  168. padding: 0 10rpx;
  169. }
  170. }
  171. ::v-deep {
  172. .u-content {
  173. background-color: #F2F2F2 !important;
  174. }
  175. }
  176. </style>