startWorkflow.vue 4.0 KB

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