Ver código fonte

分页无效的问题

chenjun 1 mês atrás
pai
commit
7bafb410b4

+ 88 - 44
src/components/TenantSelect/src/TenantSelect.vue

@@ -1,31 +1,56 @@
 <template>
-
   <el-form-item
-    label="所属机构" v-if="props.type==0" prop="tenantIds"
-    :rules="[
-      { required: required, message: '所属机构不能为空' },
-    ]">
+    label="所属机构"
+    v-if="props.type == 0"
+    prop="tenantIds"
+    :rules="[{ required: required, message: '所属机构不能为空' }]"
+  >
     <el-cascader
-      v-model="inputValue" :options="options" @change="handleChange" :props="optionProps" collapse-tags
-    collapse-tags-tooltip :show-all-levels="false" class="!w-240px" v-if="multiple && !props.single" :disabled="props.disabled"/>
-    <el-select v-model="inputValue" class="!w-240px" v-else @change="handleChange" :disabled="props.disabled">
-      <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value"/>
+      v-model="inputValue"
+      :options="options"
+      @change="handleChange"
+      :props="optionProps"
+      collapse-tags
+      collapse-tags-tooltip
+      :show-all-levels="false"
+      class="!w-240px"
+      v-if="multiple && !props.single"
+      :disabled="props.disabled"
+    />
+    <el-select
+      v-model="inputValue"
+      class="!w-240px"
+      v-else
+      @change="handleChange"
+      :disabled="props.disabled"
+    >
+      <el-option
+        v-for="item in options"
+        :key="item.value"
+        :label="item.label"
+        :value="item.value"
+      />
     </el-select>
   </el-form-item>
 
-  <el-form-item
-    v-else-if="props.type==1"
-    label="所属机构" prop="tenantIds"
-  >
+  <el-form-item v-else-if="props.type == 1" label="所属机构" prop="tenantIds">
     <el-cascader
-      v-model="inputValue" :options="options" @change="handleChange"  collapse-tags
-                 collapse-tags-tooltip :show-all-levels="false" class="!w-240px"  :disabled="props.disabled"/>
+      v-model="inputValue"
+      :options="options"
+      @change="handleChange"
+      collapse-tags
+      collapse-tags-tooltip
+      :show-all-levels="false"
+      class="!w-240px"
+      :disabled="props.disabled"
+    />
   </el-form-item>
 </template>
 <script setup lang="ts">
 import { useUserStore } from '@/store/modules/user'
 import { findTreeNode } from '@/utils/tree'
-defineOptions({name: 'TenantSelect'})
+import { getUserGroupTenant } from '@/api/system/user'
+defineOptions({ name: 'TenantSelect' })
 const userStore = useUserStore()
 // 最高节点是集团,然后value是所有id
 const props = defineProps({
@@ -33,8 +58,9 @@ const props = defineProps({
     type: Array,
     default: () => []
   },
-  width:{type:String, default:'240px'},
-  single: { // 针对房源,流程模型只能查单个的这种
+  width: { type: String, default: '240px' },
+  single: {
+    // 针对房源,流程模型只能查单个的这种
     type: Boolean,
     defalut: false
   },
@@ -56,63 +82,81 @@ const emit = defineEmits(['update:modelValue', 'change'])
 
 const inputValue = computed({
   get: () => {
-    if(props.modelValue){
+    if (props.modelValue) {
       // 需要加入企业的id
-      if(multiple.value && !props.single && props.type==0){
+      if (multiple.value && !props.single && props.type == 0) {
         const arr = []
-        props.modelValue.map(item=>{
+        props.modelValue.map((item) => {
           const obj = findTreeNode(options.value, item, 'value', 'children')
-          if(obj && !arr.includes(obj.pId)){
+          if (obj && !arr.includes(obj.pId)) {
             arr.push([obj.pId, item])
           }
         })
         return arr
-      }else{
+      } else {
         return Number(props.modelValue[0])
       }
     }
   },
   set: (val: any) => {
-    if(multiple.value && !props.single && props.type==0){
+    if (multiple.value && !props.single && props.type == 0) {
       let arr = []
-      val.map(item => {
+      val.map((item) => {
         arr.push(...item)
       })
 
       // 去重,保证value只存在一个元素
       arr = [...new Set(arr)]
-      const differentArr = arr.filter(item => !groupTenantId.value.includes(item))
-      console.log("ddd", differentArr,props.type)
+      const differentArr = arr.filter((item) => !groupTenantId.value.includes(item))
+      console.log('ddd', differentArr, props.type)
       emit('update:modelValue', differentArr)
-    }else{
+    } else {
       emit('update:modelValue', [val])
     }
   }
 })
 
 const handleChange = (val) => {
-  console.log("ddd", val)
+  console.log('ddd', val)
   emit('change', val)
 }
 
 const options = ref([])
-const groupTenantId= ref([])
+const groupTenantId = ref([])
+let tids = []
 const multiple = ref(false)
-onMounted(async ()=>{
-  multiple.value = userStore.getOrgTenant.multiple
-  if(props.single && multiple.value){
-    const arr = []
-    userStore.getOrgTenant.options.map(item => {
-      if(item.children){
-        item.children.map(c => {
-          arr.push(c)
-        })
-      }
+onMounted(async () => {
+  if (
+    userStore.orgTenantId &&
+    userStore.orgTenantId.length > 0 &&
+    userStore.orgTenantId[0] == 195
+  ) {
+    tids.push({ label: "测试机构", value: 195 })
+    const res = await getUserGroupTenant({
+      userId: 1
     })
-    options.value =  arr
-  }else{
-    options.value = userStore.getOrgTenant.options
+    for (const re of res) {
+      tids.push({ label: re.orgTenantName, value: re.orgTenantId })
+    }
+    options.value = tids
+    console.log('AAAA', options.value)
+    groupTenantId.value = options.value.map((item) => item.value)
+  } else {
+    multiple.value = userStore.getOrgTenant.multiple
+    if (props.single && multiple.value) {
+      const arr = []
+      userStore.getOrgTenant.options.map((item) => {
+        if (item.children) {
+          item.children.map((c) => {
+            arr.push(c)
+          })
+        }
+      })
+      options.value = arr
+    } else {
+      options.value = userStore.getOrgTenant.options
+    }
+    groupTenantId.value = options.value.map((item) => item.value)
   }
-  groupTenantId.value = options.value.map(item => item.value)
 })
 </script>

+ 4 - 2
src/main.ts

@@ -34,6 +34,8 @@ import Logger from '@/utils/Logger'
 import VueDOMPurifyHTML from 'vue-dompurify-html'
 
 import Print from 'vue3-print-nb'
+import { ElInfiniteScroll } from 'element-plus'
+
 
 import Flex from '@/components/Flex/Flex.vue'
 import fetchPlugin from './config/axios/fetch';
@@ -42,8 +44,8 @@ export const MAIN_VERSION = '4.4.9'
 
 const setupAll = async () => {
   const app = createApp(App)
-
-  app.use(fetchPlugin);
+  app.directive('infinite-scroll', ElInfiniteScroll) // 指令名必须为 'infinite-scroll'
+  app.use(fetchPlugin)
 
   await setupI18n(app)
 

+ 135 - 95
src/views/bpm/task/process-list/index.vue

@@ -30,25 +30,25 @@
             </el-tabs>
           </el-col>
           <el-col :span="2">
-            <Icon icon="ep:search" :size="20" @click="show=false"/>
+            <Icon icon="ep:search" :size="20" @click="show = false" />
           </el-col>
         </el-row>
       </div>
       <el-form v-else :inline="true" :model="queryParams" ref="queryFormRef" class="searchContent">
         <el-row>
           <el-col :span="20">
-            <el-input placeholder="请输入审批内容" v-model="queryParams.templateContent" @change="handleQuery"/>
+            <el-input
+              placeholder="请输入审批内容"
+              v-model="queryParams.templateContent"
+              @change="handleQuery"
+            />
           </el-col>
           <el-col :span="4">
-            <el-button class="mt2" @click="show=true" link type="primary">取消</el-button>
+            <el-button class="mt2" @click="show = true" link type="primary">取消</el-button>
           </el-col>
         </el-row>
       </el-form>
-      <div
-        v-if="selectableTaskIds.length"
-        class="batch-select-bar"
-        @click.stop
-      >
+      <div v-if="selectableTaskIds.length" class="batch-select-bar" @click.stop>
         <el-checkbox
           :model-value="isAllSelectableSelected"
           :indeterminate="isPartialSelectableSelected"
@@ -57,31 +57,61 @@
           全选当前列表({{ selectedSelectableCount }}/{{ selectableTaskIds.length }})
         </el-checkbox>
       </div>
-      <div v-infinite-scroll="load" class="infinite-list scrollLeft" v-loading="loading" v-if="list.length">
+      <div
+        v-infinite-scroll="load"
+        style="overflow: auto; height: 70vh; padding: 1vh 0; margin: 0; list-style: none"
+        v-loading="loading"
+        v-show="list.length"
+      >
         <el-checkbox-group v-model="processInstanceIds">
-          <el-card shadow="never" v-for="(item, index) in list" :key="index" :class="['card-item', {'selected': currItem.processInstanceId == item.processInstanceId}]" @click="handleClickCard(item)">
-            <el-badge v-show="item.readStatus == 0 && currItem.processInstanceId != item.processInstanceId" is-dot class="badge" />
+          <el-card
+            shadow="never"
+            v-for="(item, index) in list"
+            :key="index"
+            :class="[
+              'card-item',
+              { selected: currItem.processInstanceId == item.processInstanceId }
+            ]"
+            @click="handleClickCard(item)"
+          >
+            <el-badge
+              v-show="item.readStatus == 0 && currItem.processInstanceId != item.processInstanceId"
+              is-dot
+              class="badge"
+            />
             <div class="title mb5 mt2">
               <span class="lh16 mr-1">{{ item.templateContent }}</span>
-              <dict-tag :type="DICT_TYPE.BPM_TASK_STATUS" :value="item.status"/>
+              <dict-tag :type="DICT_TYPE.BPM_TASK_STATUS" :value="item.status" />
               <span class="ml2">
-                <el-checkbox :value="item.id" v-if="item.status == 1"/>
+                <el-checkbox :value="item.id" v-if="item.status == 1" />
               </span>
             </div>
-          <div class="mb4 c6 lh14">申请类型:<span class="c3">{{ item.applicationType }}</span></div>
-          <div class="mb4 c6 lh14">申请编号:<span class="c3">{{ item.processInstanceId }}</span></div>
-          <div class="mb2 c6 lh14">所属组织:<span class="c3">{{ item.tenantName }}</span></div>
-        </el-card>
+            <div class="mb4 c6 lh14"
+              >申请类型:<span class="c3">{{ item.applicationType }}</span></div
+            >
+            <div class="mb4 c6 lh14"
+              >申请编号:<span class="c3">{{ item.processInstanceId }}</span></div
+            >
+            <div class="mb2 c6 lh14"
+              >所属组织:<span class="c3">{{ item.tenantName }}</span></div
+            >
+          </el-card>
         </el-checkbox-group>
       </div>
-      <div class="no-content" v-else>
+      <div class="no-content" v-show="list.length <= 0">
         <span>暂无数据</span>
       </div>
     </el-col>
     <el-col :span="18" :xs="24">
       <el-button @click="handlePass" type="primary" :loading="batchLoading">批量通过</el-button>
       <div class="content">
-        <ProcessDetail v-if="obj.processInstanceId" :id="obj.processInstanceId" :taskName="obj.templateContent" ref="processDetailRef" @success="getList(false, true)"/>
+        <ProcessDetail
+          v-if="obj.processInstanceId"
+          :id="obj.processInstanceId"
+          :taskName="obj.templateContent"
+          ref="processDetailRef"
+          @success="getList(false, true)"
+        />
         <div v-else class="tc">
           <div></div>
         </div>
@@ -129,17 +159,18 @@ const handleClick = (tab) => {
 }
 
 const currItem: any = ref({})
-const getList = async (flag: boolean = false, refresh=false) => { // flag 存在数据, refresh 是否重载页面数据
+const getList = async (flag: boolean = false, refresh = false) => {
+  // flag 存在数据, refresh 是否重载页面数据
   try {
     loading.value = true
     const res = await ProcessInstanceApi.getMyPage(queryParams)
-    if(refresh){
+    if (refresh) {
       list.value = res.list
-    }else{
+    } else {
       list.value = list.value.concat(res.list)
     }
     total.value = res.total
-    if(flag && res.list[0]){
+    if (flag && res.list[0]) {
       handleClickCard(res.list[0])
       currItem.value = res.list[0]
     }
@@ -149,7 +180,8 @@ const getList = async (flag: boolean = false, refresh=false) => { // flag 存在
 }
 
 const load = () => {
-  if(queryParams.pageNo * queryParams.pageSize < total.value){
+  console.log('加载。。。')
+  if (queryParams.pageNo * queryParams.pageSize < total.value) {
     queryParams.pageNo += 1
     getList()
   }
@@ -181,13 +213,13 @@ const getCount = async () => {
 
 // 标记已读
 const updateRead = async (item) => {
-  if((queryParams.queryType != '3' && queryParams.queryType != '1') && item.messageId){
-      await ProcessInstanceApi.updateReadById(item.messageId)
-      item.readStatus = 1
-    }else if(item.processInstanceId){
-      await ProcessInstanceApi.updateMyCreateReadById(item.processInstanceId)
-      item.readStatus = 1
-    }
+  if (queryParams.queryType != '3' && queryParams.queryType != '1' && item.messageId) {
+    await ProcessInstanceApi.updateReadById(item.messageId)
+    item.readStatus = 1
+  } else if (item.processInstanceId) {
+    await ProcessInstanceApi.updateMyCreateReadById(item.processInstanceId)
+    item.readStatus = 1
+  }
 }
 
 const processDetailRef = ref()
@@ -197,8 +229,8 @@ const selectableTaskIds = computed(() =>
   list.value.filter((item) => item.status == 1).map((item) => item.id)
 )
 
-const selectedSelectableCount = computed(() =>
-  selectableTaskIds.value.filter((id) => processInstanceIds.value.includes(id)).length
+const selectedSelectableCount = computed(
+  () => selectableTaskIds.value.filter((id) => processInstanceIds.value.includes(id)).length
 )
 
 const isAllSelectableSelected = computed(
@@ -215,7 +247,9 @@ const isPartialSelectableSelected = computed(
 
 const onSelectAllChange = (checked: boolean) => {
   if (checked) {
-    processInstanceIds.value = [...new Set([...processInstanceIds.value, ...selectableTaskIds.value])]
+    processInstanceIds.value = [
+      ...new Set([...processInstanceIds.value, ...selectableTaskIds.value])
+    ]
   } else {
     const drop = new Set(selectableTaskIds.value)
     processInstanceIds.value = processInstanceIds.value.filter((id) => !drop.has(id))
@@ -225,40 +259,46 @@ const onSelectAllChange = (checked: boolean) => {
 // 批量通过
 const handlePass = () => {
   batchLoading.value = true
-  let queue = processInstanceIds.value.map(item => {
+  let queue = processInstanceIds.value.map((item) => {
     return new Promise((resolve, reject) => {
-      axios.put({url: base_url + `/bpm/task/approve`, data: {
-        id: item,
-        reason: '批量通过',
-        variables: {} // 审批通过, 把修改的字段值赋于流程实例变量
-      }}).then((res) => {
-            console.log(`获取的code为: ${res}`);
-            resolve(res)
-        }).catch((err) => {
-            reject(err)
-            batchLoading.value = true
+      axios
+        .put({
+          url: base_url + `/bpm/task/approve`,
+          data: {
+            id: item,
+            reason: '批量通过',
+            variables: {} // 审批通过, 把修改的字段值赋于流程实例变量
+          }
+        })
+        .then((res) => {
+          console.log(`获取的code为: ${res}`)
+          resolve(res)
+        })
+        .catch((err) => {
+          reject(err)
+          batchLoading.value = true
         })
     })
   })
- Promise.all(queue).then(async result => {
+  Promise.all(queue).then(async (result) => {
     batchLoading.value = false
     // 判断所有值为0的时候审批成功
-    const allApproved = result.every(item => item === true);
-      if (allApproved) {
-        ElMessage.success('所有审批通过成功')
-        // 这里可以执行审批成功后的逻辑
-      } else {
-        console.log("存在未通过的审批!");
-        // 这里可以执行审批失败后的逻辑
-        ElMessage.error('审批不成功')
-      }
-      // 清空值
-      processInstanceIds.value = []
+    const allApproved = result.every((item) => item === true)
+    if (allApproved) {
+      ElMessage.success('所有审批通过成功')
+      // 这里可以执行审批成功后的逻辑
+    } else {
+      console.log('存在未通过的审批!')
+      // 这里可以执行审批失败后的逻辑
+      ElMessage.error('审批不成功')
+    }
+    // 清空值
+    processInstanceIds.value = []
 
-      await getList(false, true)
-      // 找到对应的id
-      processDetailRef.value.refresh()
-      getCount()
+    await getList(false, true)
+    // 找到对应的id
+    processDetailRef.value.refresh()
+    getCount()
   })
 }
 
@@ -275,39 +315,39 @@ watch(
 )
 
 onMounted(async () => {
-  getCount()
+  await getCount()
   await getList(true)
-})
 
+})
 </script>
 <style lang="scss" scoped>
-.process-list{
+.process-list {
   font-size: 16px;
-  .title{
+  .title {
     font-weight: bold;
   }
 
-  .card-item{
+  .card-item {
     position: relative;
     margin-bottom: 5px;
     border-radius: 8px;
     border: 2px solid #e5e5e5;
-    &:hover{
+    &:hover {
       background-color: #f3f4f6;
     }
-    &.selected{
+    &.selected {
       border: 2px solid var(--el-color-primary);
       background-color: color-mix(in srgb, var(--el-color-primary) 10%, white);
     }
-    .c6{
+    .c6 {
       color: #666;
       font-size: 14px;
     }
-    .c3{
+    .c3 {
       color: #333;
       font-size: 14px;
     }
-    .status-label{
+    .status-label {
       position: absolute;
       right: -15px;
       top: -6px;
@@ -316,51 +356,51 @@ onMounted(async () => {
       background: var(--el-color-primary);
       text-align: center;
       transform: rotate(45deg);
-      .check{
+      .check {
         color: #fff;
         font-size: 12px !important;
         margin-top: 11px;
         transform: rotate(-45deg);
       }
     }
-    .badge{
+    .badge {
       position: absolute;
       top: 10px;
       right: 10px;
     }
   }
-  .content{
+  .content {
     background-color: #fff;
     border-radius: 4px;
   }
 }
 </style>
 <style lang="scss">
-.process-list{
+.process-list {
   position: relative;
-  .searchContent{
+  .searchContent {
     padding: 10px;
     border-radius: 4px;
     background-color: #fff;
   }
-  .header{
+  .header {
     // display: flex;
     // align-items: flex-start;
     border-radius: 4px;
     background-color: #fff;
-    .demo-tabs{
-      .el-tabs__header{
+    .demo-tabs {
+      .el-tabs__header {
         margin: 0;
         padding-bottom: 10px;
       }
     }
-    .el-icon{
+    .el-icon {
       padding-top: 20px;
       padding-left: 10px;
       cursor: pointer;
     }
   }
-  .no-content{
+  .no-content {
     background-color: #fff;
     height: 77vh;
     margin-top: 10px;
@@ -371,18 +411,18 @@ onMounted(async () => {
     align-items: center;
     border-radius: 8px;
   }
-  .el-card{
-    .el-card__body{
+  .el-card {
+    .el-card__body {
       padding: 10px 20px !important;
     }
   }
-  .el-tabs__item{
+  .el-tabs__item {
     padding: 0 10px !important;
   }
-  .el-scrollbar{
+  .el-scrollbar {
     height: auto;
   }
-  .tc{
+  .tc {
     display: flex;
     justify-content: center;
     align-items: center;
@@ -390,32 +430,32 @@ onMounted(async () => {
     font-size: 26px;
     color: #ccc;
   }
-  .batch-select-bar{
+  .batch-select-bar {
     padding: 8px 12px;
     margin-top: 8px;
     background-color: #fff;
     border-radius: 8px;
     font-size: 14px;
   }
-  .scrollLeft{
+  .scrollLeft {
     padding: 10px 0;
     height: 78vh;
     overflow-y: auto;
   }
   ::-webkit-scrollbar {
-  width: 0px; //滚动条宽度
+    width: 0px; //滚动条宽度
   }
   ::-webkit-scrollbar-thumb {
-  //上层
-  border-radius: 10px; //滚动条圆弧半径
-  //-webkit-box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);	//滚动条阴影
-  background: var(--el-border-color-dark); //背景颜色
+    //上层
+    border-radius: 10px; //滚动条圆弧半径
+    //-webkit-box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);	//滚动条阴影
+    background: var(--el-border-color-dark); //背景颜色
   }
 
-  .lh14{
+  .lh14 {
     line-height: 14px;
   }
-  .lh16{
+  .lh16 {
     line-height: 16px;
   }
 }

+ 27 - 6
src/views/elderly/restaurant/satisfactionSurvey/index.vue

@@ -7,7 +7,12 @@
         </el-col>
         <el-col :xs="24" :sm="12" :md="12" :lg="6" :xl="6">
           <el-form-item label="填写身份" prop="role">
-            <el-select v-model="queryParams.role" clearable placeholder="请选择身份" class="!w-full">
+            <el-select
+              v-model="queryParams.role"
+              clearable
+              placeholder="请选择身份"
+              class="!w-full"
+            >
               <el-option
                 v-for="item in roleOptions"
                 :key="item.value"
@@ -40,7 +45,13 @@
               <Icon icon="ep:refresh" class="mr-5px" />
               重置
             </el-button>
-            <el-button v-hasPermi="['satisfactionSurvey:export']" type="warning" plain :loading="exportLoading" @click="handleExport">
+            <el-button
+              v-hasPermi="['satisfactionSurvey:export']"
+              type="warning"
+              plain
+              :loading="exportLoading"
+              @click="handleExport"
+            >
               <Icon icon="ep:download" class="mr-5px" />
               导出
             </el-button>
@@ -110,7 +121,13 @@
       <el-table-column label="操作" width="140" fixed="right" align="center">
         <template #default="{ row }">
           <el-button link type="primary" @click="openDetail(row)">查看详情</el-button>
-          <el-button v-hasPermi="['satisfactionSurvey:delete']" link type="danger" @click="handleDelete(row.id)">删除</el-button>
+          <el-button
+            v-hasPermi="['satisfactionSurvey:delete']"
+            link
+            type="danger"
+            @click="handleDelete(row.id)"
+            >删除</el-button
+          >
         </template>
       </el-table-column>
     </el-table>
@@ -207,6 +224,7 @@ import {
   getFoodSatisfactionSurvey,
   getFoodSatisfactionSurveyPage
 } from '@/api/system/foods'
+import { getUserGroupTenant } from '@/api/system/user'
 
 defineOptions({ name: 'SatisfactionSurvey' })
 
@@ -378,7 +396,10 @@ const handleExport = async () => {
   })
   try {
     const data = await exportFoodSatisfactionSurveyExcel(buildParams(true))
-    download.excel(data as unknown as Blob, `膳食满意度调查_${dayjs().format('YYYY-MM-DD_HH-mm-ss')}.xls`)
+    download.excel(
+      data as unknown as Blob,
+      `膳食满意度调查_${dayjs().format('YYYY-MM-DD_HH-mm-ss')}.xls`
+    )
     message.success('导出成功')
   } catch (error) {
     console.error('导出失败:', error)
@@ -420,7 +441,8 @@ const handleDelete = async (id: number) => {
   } catch {}
 }
 
-onMounted(() => {
+
+onMounted( () => {
   getList()
 })
 </script>
@@ -444,5 +466,4 @@ onMounted(() => {
   font-weight: 600;
   color: #303133;
 }
-
 </style>