123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185 |
- <template>
- <view class="start-workflow">
- <view class="start-workflow-search">
- <u-search
- placeholder="查询流程"
- v-model="keyword"
- bg-color="#fff"
- margin="16rpx 24rpx"
- :input-style="{
- fontSize: variables.mainFontSize,
- padding: '0rpx 40rpx',
- }"
- :action-style="{fontSize: variables.mainFontSize}"
- :border-color="'#F2F2F2'"
- :bg-color="'#F2F2F2'"
- :height="74"
- @search="() => searchKeyWord = keyword"
- @custom="() => searchKeyWord = keyword"
- :show-action="false"
- input-align="center"
- />
-
- <u-tabs
- font-size="30"
- :active-color="variables.mainColor"
- inactive-color="#606266"
- :current="current"
- :list="tabList"
- @change="handleChange"/>
- <!-- 移动端只分两级, -->
- <u-tabs
- font-size="30"
- :active-color="variables.mainColor"
- inactive-color="#606266"
- :current="childCurrent"
- :list="tabChildrenList"
- @change="handleChildChange"/>
- </view>
- <view class="process-definition-list" >
- <process-definition-list :search-key-word="searchKeyWord" :category="category" :process-definition-height='processDefinitionHeight'/>
- </view>
- </view>
- </template>
- <script>
- import processDefinitionList from './processDefinitionList.vue'
- import variables from '@/styles/variables.scss'
- export default {
- components: {
- processDefinitionList
- },
- computed: {
- processDefinitionHeight() {
- return this.startWorkflowHeight - this.searchHeight
- }
- },
- data() {
- return {
- category: '',
- parentCategoryInfo: {},
- current:0,
- childrenCurrent: '',
- keyword: '',
- categoryList: [],
- tabList: [],
- childCurrent: 0,
- tabChildrenList: [],
- childCartegoryList: [],
- startWorkflowHeight: 0,
- searchHeight: 0,
- variables,
- searchKeyWord: ''
- };
- },
- created() {
- this.loadCategory()
- },
- methods: {
- async loadCategory() {
- try{
- uni.showLoading({
- title: '加载中'
- })
- const res = await this.$dibootApi.get('/mobile/workflow/processDefinition/getAuthorizedCategoryTree')
- if(res.code === 0 && res.data ) {
- this.categoryList = res.data
- this.tabList = [{
- name: '全部'
- }, ...this.categoryList.map(item => {
- return {
- name: item.name
- }
- })]
- this.handleChange(0)
- }
- } catch(e){
- //TODO handle the exception
- } finally {
- uni.hideLoading()
- }
-
- },
- /**
- * 切换一级分类
- * @param {Object} index
- */
- handleChange(index) {
- this.keyword = ''
- this.searchKeyWord = ''
- this.current = index
- this.tabChildrenList = []
- this.childCartegoryList = []
- this.childrenCurrent = 0
- this.resetHeight()
- if(this.tabList[index].name === '全部') {
- this.parentCategoryInfo = {}
- this.category = ''
- return
- }
- this.parentCategoryInfo = this.categoryList[index - 1]
- this.category = this.parentCategoryInfo.id
- this.childCartegoryList = this.parentCategoryInfo.children || []
- if(this.childCartegoryList && this.childCartegoryList.length > 0) {
- this.tabChildrenList = [{
- name: '全部'
- }, ...this.childCartegoryList.map(item => {
- return {
- name: item.name
- }
- })]
- }
- },
- /**
- * 切换二级分类
- * @param {Object} index
- */
- handleChildChange(index) {
- this.keyword = ''
- this.searchKeyWord = ''
- this.childCurrent = index
- if(this.tabChildrenList[index].name === '全部') {
- this.category = this.parentCategoryInfo.id
- return
- }
- const categoryInfo = this.childCartegoryList[index - 1]
- this.category = categoryInfo.id
- this.resetHeight()
- },
- async resetHeight() {
- await this.$nextTick()
- const query = uni.createSelectorQuery().in(this)
- query.select(".start-workflow")
- .boundingClientRect(data => {
- this.startWorkflowHeight = data && data.height || 0
- }).exec()
-
- query.select(".start-workflow-search")
- .boundingClientRect(data => {
- this.searchHeight = data && data.height || 0
- }).exec()
- }
- }
- }
- </script>
- <style lang="scss">
- .start-workflow {
- height: 100%;
- display: flex;
- flex-direction: column;
-
-
-
- .start-workflow-search {
- background-color: #fff;
- padding: 0 10rpx;
- }
- }
-
- ::v-deep {
- .u-content {
- background-color: #F2F2F2 !important;
- }
- }
- </style>
|