浏览代码

feat:【bpm】优化“审批” tab 的简化,去掉 active、isFirstLoad 变量

YunaiV 4 月之前
父节点
当前提交
194a09bf93

+ 0 - 1
src/pages-system/sms/index.vue

@@ -15,7 +15,6 @@
         <wd-tab title="短信日志" />
       </wd-tabs>
     </view>
-
     <!-- 列表内容 -->
     <ChannelList v-show="tabType === 'channel'" />
     <TemplateList v-show="tabType === 'template'" />

+ 1 - 16
src/pages/bpm/components/copy-list.vue

@@ -53,20 +53,15 @@
 import type { ProcessInstanceCopy } from '@/api/bpm/processInstance'
 import type { LoadMoreState } from '@/http/types'
 import { onReachBottom } from '@dcloudio/uni-app'
-import { onMounted, ref, watch } from 'vue'
+import { onMounted, ref } from 'vue'
 import { getProcessInstanceCopyPage } from '@/api/bpm/processInstance'
 import { formatDateTime } from '@/utils/date'
 import CopySearchForm from './copy-search-form.vue'
 import '../styles/index.scss'
 
-const props = defineProps<{
-  active?: boolean
-}>()
-
 const total = ref(0)
 const list = ref<ProcessInstanceCopy[]>([])
 const loadMoreState = ref<LoadMoreState>('loading')
-const isFirstLoad = ref(true)
 const queryParams = ref({
   pageNo: 1,
   pageSize: 10,
@@ -121,18 +116,8 @@ onReachBottom(() => {
   loadMore()
 })
 
-/** 监听激活状态,刷新数据 */
-watch(() => props.active, (val) => {
-  if (val && !isFirstLoad.value) {
-    queryParams.value.pageNo = 1
-    list.value = []
-    getList()
-  }
-})
-
 /** 初始化 */
 onMounted(() => {
   getList()
-  isFirstLoad.value = false
 })
 </script>

+ 1 - 16
src/pages/bpm/components/done-list.vue

@@ -51,21 +51,16 @@
 import type { Task } from '@/api/bpm/task'
 import type { LoadMoreState } from '@/http/types'
 import { onReachBottom } from '@dcloudio/uni-app'
-import { onMounted, ref, watch } from 'vue'
+import { onMounted, ref } from 'vue'
 import { getTaskDonePage } from '@/api/bpm/task'
 import { DICT_TYPE } from '@/utils/constants'
 import { formatDateTime } from '@/utils/date'
 import DoneSearchForm from './done-search-form.vue'
 import '../styles/index.scss'
 
-const props = defineProps<{
-  active?: boolean
-}>()
-
 const total = ref(0)
 const list = ref<Task[]>([])
 const loadMoreState = ref<LoadMoreState>('loading')
-const isFirstLoad = ref(true)
 const queryParams = ref({
   pageNo: 1,
   pageSize: 10,
@@ -120,18 +115,8 @@ onReachBottom(() => {
   loadMore()
 })
 
-/** 监听激活状态,刷新数据 */
-watch(() => props.active, (val) => {
-  if (val && !isFirstLoad.value) {
-    queryParams.value.pageNo = 1
-    list.value = []
-    getList()
-  }
-})
-
 /** 初始化 */
 onMounted(() => {
   getList()
-  isFirstLoad.value = false
 })
 </script>

+ 1 - 16
src/pages/bpm/components/my-list.vue

@@ -62,7 +62,7 @@
 import type { ProcessInstance } from '@/api/bpm/processInstance'
 import type { LoadMoreState } from '@/http/types'
 import { onReachBottom } from '@dcloudio/uni-app'
-import { computed, onMounted, ref, watch } from 'vue'
+import { computed, onMounted, ref } from 'vue'
 import { getProcessInstanceMyPage } from '@/api/bpm/processInstance'
 import { useUserStore } from '@/store'
 import { DICT_TYPE } from '@/utils/constants'
@@ -70,17 +70,12 @@ import { formatDateTime } from '@/utils/date'
 import MySearchForm from './my-search-form.vue'
 import '../styles/index.scss'
 
-const props = defineProps<{
-  active?: boolean
-}>()
-
 const userStore = useUserStore()
 const userNickname = computed(() => userStore.userInfo?.nickname || '')
 
 const total = ref(0)
 const list = ref<ProcessInstance[]>([])
 const loadMoreState = ref<LoadMoreState>('loading')
-const isFirstLoad = ref(true)
 
 const queryParams = ref({
   pageNo: 1,
@@ -141,18 +136,8 @@ onReachBottom(() => {
   loadMore()
 })
 
-/** 监听激活状态,刷新数据 */
-watch(() => props.active, (val) => {
-  if (val && !isFirstLoad.value) {
-    queryParams.value.pageNo = 1
-    list.value = []
-    getList()
-  }
-})
-
 /** 初始化 */
 onMounted(() => {
   getList()
-  isFirstLoad.value = false
 })
 </script>

+ 1 - 16
src/pages/bpm/components/todo-list.vue

@@ -62,20 +62,15 @@
 import type { Task } from '@/api/bpm/task'
 import type { LoadMoreState } from '@/http/types'
 import { onReachBottom } from '@dcloudio/uni-app'
-import { onMounted, ref, watch } from 'vue'
+import { onMounted, ref } from 'vue'
 import { getTaskTodoPage } from '@/api/bpm/task'
 import { formatPast } from '@/utils/date'
 import TodoSearchForm from './todo-search-form.vue'
 import '../styles/index.scss'
 
-const props = defineProps<{
-  active?: boolean
-}>()
-
 const total = ref(0)
 const list = ref<Task[]>([])
 const loadMoreState = ref<LoadMoreState>('loading')
-const isFirstLoad = ref(true)
 const queryParams = ref({
   pageNo: 1,
   pageSize: 10,
@@ -140,18 +135,8 @@ onReachBottom(() => {
   loadMore()
 })
 
-/** 监听激活状态,刷新数据 */
-watch(() => props.active, (val) => {
-  if (val && !isFirstLoad.value) {
-    queryParams.value.pageNo = 1
-    list.value = []
-    getList()
-  }
-})
-
 /** 初始化 */
 onMounted(() => {
   getList()
-  isFirstLoad.value = false
 })
 </script>

+ 4 - 4
src/pages/bpm/index.vue

@@ -16,10 +16,10 @@
       </wd-tabs>
     </view>
     <!-- 列表内容 -->
-    <TodoList v-show="tabType === 'todo'" :active="tabType === 'todo'" />
-    <DoneList v-show="tabType === 'done'" :active="tabType === 'done'" />
-    <MyList v-show="tabType === 'my'" :active="tabType === 'my'" />
-    <CopyList v-show="tabType === 'copy'" :active="tabType === 'copy'" />
+    <TodoList v-show="tabType === 'todo'" />
+    <DoneList v-show="tabType === 'done'" />
+    <MyList v-show="tabType === 'my'" />
+    <CopyList v-show="tabType === 'copy'" />
   </view>
 </template>