|
@@ -4,7 +4,8 @@
|
|
|
<div class="flex flex-col h-full">
|
|
|
<!-- 搜索 -->
|
|
|
<div class="mx-1">
|
|
|
- <van-search v-model="searchVal" background="#F8F8F8" :placeholder="`请输入${queryParameters?.name}关键词`">
|
|
|
+ <van-search v-model.trim="searchVal" background="#F8F8F8" :placeholder="`请输入${queryParameters?.name}关键词`"
|
|
|
+ @search="onRefresh(true)" @clear="onRefresh(true)">
|
|
|
<template v-slot:left-icon>
|
|
|
<van-icon name="search" class="themeTextColor font-bold" />
|
|
|
</template>
|
|
@@ -12,7 +13,7 @@
|
|
|
</div>
|
|
|
<!-- 主题内容 -->
|
|
|
<div class="flex-1 overflow-y-auto">
|
|
|
- <template v-if="listData?.records && listData.records.length">
|
|
|
+ <template v-if="listData?.records && listData.records.length && !loadingList">
|
|
|
<van-pull-refresh v-model="refreshing" @refresh="onRefresh">
|
|
|
<van-list v-model:loading="isLoading" :finished="finished" finished-text="没有更多了" @load="onLoad">
|
|
|
<div v-for="item in listData.records" :key="item.id" @click="toDetail(item)">
|
|
@@ -55,12 +56,16 @@
|
|
|
</van-list>
|
|
|
</van-pull-refresh>
|
|
|
</template>
|
|
|
+ <template v-else>
|
|
|
+ <van-skeleton title :row="20" class="w-full h-full" />
|
|
|
+ </template>
|
|
|
</div>
|
|
|
</div>
|
|
|
|
|
|
<!-- 可拖拽添加 -->
|
|
|
<DragBox>
|
|
|
- <div class="addButton backgroundThemeColor rounded-full flex items-center justify-center text-white" @click="toAddEditor">
|
|
|
+ <div class="addButton backgroundThemeColor rounded-full flex items-center justify-center text-white"
|
|
|
+ @click="toAddEditor()">
|
|
|
添加
|
|
|
</div>
|
|
|
</DragBox>
|
|
@@ -70,13 +75,15 @@
|
|
|
|
|
|
<script setup>
|
|
|
import { ref, onActivated } from 'vue';
|
|
|
+import { showConfirmDialog } from 'vant';
|
|
|
import { useLifecycle } from '@hooks/useCommon.js';
|
|
|
import { resetListData, getListFieldKey } from '@components/common/formForm/formCorrespondenceProcessing'
|
|
|
+import useShowToast from '@hooks/useToast'
|
|
|
import { GET_CUSTOM_FORM_JSON } from '@hooks/useApi'
|
|
|
import requests from "@common/requests";
|
|
|
import useRouterStore from "@store/useRouterStore.js";
|
|
|
import useFixedData from "@store/useFixedData.js"
|
|
|
-import ElementLongPress from "@components/common/elementLongPress.vue";
|
|
|
+// import ElementLongPress from "@components/common/elementLongPress.vue";
|
|
|
import DragBox from '@components/common/dragBox.vue';
|
|
|
|
|
|
const TRANSFER = 'transfer';
|
|
@@ -84,10 +91,12 @@ const DELETE = 'delete';
|
|
|
const EDIT = 'edit';
|
|
|
const TOP_MOUNTED = 'topMounted';
|
|
|
|
|
|
+const { toastSuccess, toastFail } = useShowToast()
|
|
|
const router = useRouterStore()
|
|
|
const fixedData = useFixedData()
|
|
|
const searchVal = ref()
|
|
|
const queryParameters = ref()
|
|
|
+const loadingList = ref(false)
|
|
|
const popUpWindowArray = ref([
|
|
|
{ text: '转移', event: TRANSFER, bg: '#FFA359', removeModule: ['contacts', 'tasks', 'product', 'contract', 'order'] },
|
|
|
{ text: '顶置', event: TOP_MOUNTED, bg: '#075985', removeModule: [] },
|
|
@@ -141,7 +150,18 @@ function transfer(row) {
|
|
|
|
|
|
// 删除事件
|
|
|
function deleteRow(row) {
|
|
|
- console.log(row, '<======= 删除事件')
|
|
|
+ const { name = '', searchFiled = {}, deteleFiled = '' } = queryParameters.value
|
|
|
+ showConfirmDialog({
|
|
|
+ title: `删除${name}`,
|
|
|
+ message: `确定删除【${row[searchFiled?.search]}】${name}吗?`,
|
|
|
+ }).then(() => {
|
|
|
+ requests.post(deteleFiled, { ids: row.id }).then((res) => {
|
|
|
+ toastSuccess('删除成功')
|
|
|
+ onRefresh(true)
|
|
|
+ }).catch((err) => {
|
|
|
+ toastFail(err.msg ? err.msg : '删除失败')
|
|
|
+ })
|
|
|
+ })
|
|
|
}
|
|
|
|
|
|
// 顶置事件
|
|
@@ -173,11 +193,11 @@ function toAddEditor(value) {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
-function onRefresh() {
|
|
|
+function onRefresh(flag = false) {
|
|
|
finished.value = false;
|
|
|
isLoading.value = true;
|
|
|
listData.value.pageIndex = 1;
|
|
|
- fetchListData();
|
|
|
+ fetchListData(flag);
|
|
|
}
|
|
|
|
|
|
function onLoad() {
|
|
@@ -186,7 +206,7 @@ function onLoad() {
|
|
|
fetchListData()
|
|
|
}
|
|
|
|
|
|
-async function fetchListData() {
|
|
|
+async function fetchListData(flag = false) {
|
|
|
console.log(listData.value.totalPage, listData.value.pageIndex)
|
|
|
if (
|
|
|
// 如果总页数小于等于现页数,并且不是第一次加载, 或者正在加载数据 直接跳出不请求
|
|
@@ -196,7 +216,7 @@ async function fetchListData() {
|
|
|
finished.value = true;
|
|
|
return;
|
|
|
}
|
|
|
- const res = await getListData()
|
|
|
+ const res = await getListData(flag)
|
|
|
if (res.code === 'ok') {
|
|
|
const list = res.data.data || res.data.records || res.data.record
|
|
|
const total = res.data.total
|
|
@@ -214,12 +234,20 @@ async function fetchListData() {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-async function getListData() {
|
|
|
+async function getListData(flag = false) {
|
|
|
const url = queryParameters.value.listUrl
|
|
|
+ if (flag) {
|
|
|
+ loadingList.value = true
|
|
|
+ }
|
|
|
const res = await requests.post(url, {
|
|
|
pageIndex: listData.value.pageIndex,
|
|
|
pageSize: listData.value.pageSize,
|
|
|
- pageFrom: listData.value.pageSize
|
|
|
+ pageFrom: listData.value.pageSize,
|
|
|
+ [queryParameters.value?.searchFiled?.search]: searchVal.value
|
|
|
+ }).finally(() => {
|
|
|
+ if (flag) {
|
|
|
+ loadingList.value = false
|
|
|
+ }
|
|
|
})
|
|
|
return res
|
|
|
}
|
|
@@ -265,6 +293,10 @@ useLifecycle({
|
|
|
width: 37px;
|
|
|
height: 37px;
|
|
|
margin-left: 10px;
|
|
|
+
|
|
|
+ &:last-child {
|
|
|
+ margin-right: 10px;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
.addButton {
|