修改获取建制接口
This commit is contained in:
parent
a463bdde89
commit
8f1d5ff473
|
|
@ -1,5 +1,5 @@
|
||||||
// 建制相关API
|
// 建制相关API
|
||||||
import { get, post, put, del } from '@/utils/request'
|
import { del, get, post, put } from "@/utils/request";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取建制数据列表
|
* 获取建制数据列表
|
||||||
|
|
@ -14,11 +14,12 @@ export function getInstitutionalList(params = {}) {
|
||||||
const defaultParams = {
|
const defaultParams = {
|
||||||
pageNum: 1,
|
pageNum: 1,
|
||||||
pageSize: 10,
|
pageSize: 10,
|
||||||
orderByColumn: 'createTime',
|
orderByColumn: "createTime",
|
||||||
isAsc: 'descending',
|
isAsc: "descending",
|
||||||
}
|
states: "",
|
||||||
|
};
|
||||||
|
|
||||||
return get('/app/formed/listFormed', { ...defaultParams, ...params })
|
return get("/app/formed/listFormed", { ...defaultParams, ...params });
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -27,7 +28,7 @@ export function getInstitutionalList(params = {}) {
|
||||||
* @returns {Promise} 返回建制详情
|
* @returns {Promise} 返回建制详情
|
||||||
*/
|
*/
|
||||||
export function getInstitutionalDetail(id) {
|
export function getInstitutionalDetail(id) {
|
||||||
return get(`/app/formed/getFormed/${id}`)
|
return get(`/app/formed/getFormed/${id}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -36,7 +37,7 @@ export function getInstitutionalDetail(id) {
|
||||||
* @returns {Promise} 返回创建结果
|
* @returns {Promise} 返回创建结果
|
||||||
*/
|
*/
|
||||||
export function createInstitutional(data) {
|
export function createInstitutional(data) {
|
||||||
return post('/app/formed/createFormed', data)
|
return post("/app/formed/createFormed", data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -45,7 +46,7 @@ export function createInstitutional(data) {
|
||||||
* @returns {Promise} 返回更新结果
|
* @returns {Promise} 返回更新结果
|
||||||
*/
|
*/
|
||||||
export function updateInstitutional(data) {
|
export function updateInstitutional(data) {
|
||||||
return put('/app/formed/updateFormed', data)
|
return put("/app/formed/updateFormed", data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -54,5 +55,5 @@ export function updateInstitutional(data) {
|
||||||
* @returns {Promise} 返回删除结果
|
* @returns {Promise} 返回删除结果
|
||||||
*/
|
*/
|
||||||
export function deleteInstitutional(id) {
|
export function deleteInstitutional(id) {
|
||||||
return del(`/app/formed/deleteFormed/${id}`)
|
return del(`/app/formed/deleteFormed/${id}`);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,59 +2,60 @@
|
||||||
<view class="page">
|
<view class="page">
|
||||||
<custom-navbar ref="customNavbar" title="基础页面" />
|
<custom-navbar ref="customNavbar" title="基础页面" />
|
||||||
<tile-grid />
|
<tile-grid />
|
||||||
<view class="header" :style="{ backgroundColor: CommonEnum.BASE_COLOR }">
|
<view :style="{ backgroundColor: CommonEnum.BASE_COLOR }" class="header">
|
||||||
<!-- 状态展示 -->
|
<!-- 状态展示 -->
|
||||||
<status-display v-if="loading" type="loading" loading-text="加载中..." />
|
<status-display v-if="loading" loading-text="加载中..." type="loading" />
|
||||||
<!-- 页面内容将在这里添加 -->
|
<!-- 页面内容将在这里添加 -->
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import CommonEnum from '../../enum/common'
|
import CommonEnum from "../../enum/common";
|
||||||
export default {
|
|
||||||
components: {},
|
export default {
|
||||||
data() {
|
components: {},
|
||||||
return {
|
data() {
|
||||||
CommonEnum,
|
return {
|
||||||
loading: false,
|
CommonEnum,
|
||||||
|
loading: false,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
onLoad() {
|
||||||
|
// 页面加载时获取数据
|
||||||
|
this.loadPageData();
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
// 加载页面数据
|
||||||
|
async loadPageData() {
|
||||||
|
this.loading = true;
|
||||||
|
try {
|
||||||
|
// TODO: 调用页面数据API
|
||||||
|
// const response = await getPageData()
|
||||||
|
// 模拟加载
|
||||||
|
setTimeout(() => {
|
||||||
|
this.loading = false;
|
||||||
|
}, 1000);
|
||||||
|
} catch (error) {
|
||||||
|
console.error("获取页面数据失败:", error);
|
||||||
|
this.loading = false;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onLoad() {
|
},
|
||||||
// 页面加载时获取数据
|
};
|
||||||
this.loadPageData()
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
// 加载页面数据
|
|
||||||
async loadPageData() {
|
|
||||||
this.loading = true
|
|
||||||
try {
|
|
||||||
// TODO: 调用页面数据API
|
|
||||||
// const response = await getPageData()
|
|
||||||
// 模拟加载
|
|
||||||
setTimeout(() => {
|
|
||||||
this.loading = false
|
|
||||||
}, 1000)
|
|
||||||
} catch (error) {
|
|
||||||
console.error('获取页面数据失败:', error)
|
|
||||||
this.loading = false
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
.page {
|
.page {
|
||||||
background: #f5f0e7;
|
background: #f5f0e7;
|
||||||
}
|
}
|
||||||
.header {
|
|
||||||
width: 100%;
|
.header {
|
||||||
//min-height: 100vh;//可能导致页面留白
|
width: 100%;
|
||||||
display: flex;
|
//min-height: 100vh;//可能导致页面留白
|
||||||
align-items: flex-start;
|
display: flex;
|
||||||
flex-direction: column;
|
align-items: flex-start;
|
||||||
padding: 0 15rpx;
|
flex-direction: column;
|
||||||
padding-bottom: 40rpx;
|
padding: 0 15rpx 40rpx;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
||||||
|
|
@ -4,19 +4,19 @@
|
||||||
<tile-grid />
|
<tile-grid />
|
||||||
<view class="header">
|
<view class="header">
|
||||||
<!-- 状态展示 -->
|
<!-- 状态展示 -->
|
||||||
<status-display v-if="loading" type="loading" loading-text="加载中..." />
|
<status-display v-if="loading" loading-text="加载中..." type="loading" />
|
||||||
<status-display
|
<status-display
|
||||||
v-else-if="institutionalData.length === 0"
|
v-else-if="institutionalData.length === 0"
|
||||||
type="empty"
|
|
||||||
empty-text="暂无数据"
|
empty-text="暂无数据"
|
||||||
|
type="empty"
|
||||||
/>
|
/>
|
||||||
<!-- 数据列表 -->
|
<!-- 数据列表 -->
|
||||||
<institutional-item
|
<institutional-item
|
||||||
v-else
|
|
||||||
v-for="(item, index) in institutionalData"
|
v-for="(item, index) in institutionalData"
|
||||||
|
v-else
|
||||||
:key="index"
|
:key="index"
|
||||||
:item="item"
|
|
||||||
:index="index"
|
:index="index"
|
||||||
|
:item="item"
|
||||||
@view-detail="handleViewDetail"
|
@view-detail="handleViewDetail"
|
||||||
/>
|
/>
|
||||||
</view>
|
</view>
|
||||||
|
|
@ -24,104 +24,88 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { getInstitutionalList } from '@/api/institutionalStructure/institutionalStructure.js'
|
import { getInstitutionalList } from "@/api/institutionalStructure/institutionalStructure.js";
|
||||||
import CustomNavbar from '../../components/custom-navbar/custom-navbar.vue'
|
import CustomNavbar from "../../components/custom-navbar/custom-navbar.vue";
|
||||||
import TileGrid from '../../components/tile-grid/tile-grid.vue'
|
import TileGrid from "../../components/tile-grid/tile-grid.vue";
|
||||||
import InstitutionalItem from './components/institutional-item.vue'
|
import InstitutionalItem from "./components/institutional-item.vue";
|
||||||
import StatusDisplay from '../../components/status-display/status-display.vue'
|
import StatusDisplay from "../../components/status-display/status-display.vue";
|
||||||
import { InstitutionalDataFormatter } from './utils/data-formatter.js'
|
import { InstitutionalDataFormatter } from "./utils/data-formatter.js";
|
||||||
import { dataManagerMixin } from './mixins/data-manager.js'
|
import { dataManagerMixin } from "./mixins/data-manager.js";
|
||||||
import CommonEnum from '../../enum/common'
|
import CommonEnum from "../../enum/common";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
mixins: [dataManagerMixin],
|
mixins: [dataManagerMixin],
|
||||||
components: {
|
components: {
|
||||||
CustomNavbar,
|
CustomNavbar,
|
||||||
TileGrid,
|
TileGrid,
|
||||||
InstitutionalItem,
|
InstitutionalItem,
|
||||||
StatusDisplay,
|
StatusDisplay,
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
CommonEnum,
|
CommonEnum,
|
||||||
bgc: {
|
bgc: {
|
||||||
backgroundColor: CommonEnum.BASE_COLOR,
|
backgroundColor: CommonEnum.BASE_COLOR,
|
||||||
},
|
},
|
||||||
// 动态数据数组
|
// 动态数据数组
|
||||||
institutionalData: [],
|
institutionalData: [],
|
||||||
|
pageStatus: "",
|
||||||
|
};
|
||||||
|
},
|
||||||
|
onLoad() {
|
||||||
|
// 页面加载时获取数据
|
||||||
|
this.getInstitutionalData();
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
// 获取建制数据
|
||||||
|
async getInstitutionalData() {
|
||||||
|
const res = await getInstitutionalList(this.pageStatus);
|
||||||
|
const rawData = res.rows;
|
||||||
|
this.institutionalData =
|
||||||
|
InstitutionalDataFormatter.transformData(rawData);
|
||||||
|
try {
|
||||||
|
console.log("建制数据已更新, 数量:", this.institutionalData.length);
|
||||||
|
} catch (error) {
|
||||||
|
console.error("获取建制数据失败:", error);
|
||||||
|
uni.showToast({
|
||||||
|
title: "获取数据失败",
|
||||||
|
icon: "none",
|
||||||
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onLoad() {
|
|
||||||
// 页面加载时获取数据
|
|
||||||
this.getInstitutionalData()
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
// 获取建制数据
|
|
||||||
async getInstitutionalData(isLoadMore = false) {
|
|
||||||
console.log('开始获取建制数据, isLoadMore:', isLoadMore)
|
|
||||||
|
|
||||||
try {
|
// 处理查看详细
|
||||||
if (isLoadMore) {
|
handleViewDetail(data) {
|
||||||
await this.loadMoreData({
|
console.log("查看详细:", data.item);
|
||||||
apiCall: getInstitutionalList,
|
// 跳转到捐款记录页面,传递建制ID
|
||||||
dataTransformer: InstitutionalDataFormatter.transformData,
|
uni.navigateTo({
|
||||||
onSuccess: (data, response) => {
|
url: `/pages/institutionalStructure/donationRecord?formedId=${data.item.formedId}`,
|
||||||
console.log('建制数据加载更多成功:', data.length, '条')
|
fail: (err) => {
|
||||||
this.institutionalData = this.dataList
|
console.error("跳转失败:", err);
|
||||||
},
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
await this.refreshData({
|
|
||||||
apiCall: getInstitutionalList,
|
|
||||||
dataTransformer: InstitutionalDataFormatter.transformData,
|
|
||||||
onSuccess: (data, response) => {
|
|
||||||
console.log('建制数据刷新成功:', data.length, '条')
|
|
||||||
this.institutionalData = this.dataList
|
|
||||||
},
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log('建制数据已更新, 数量:', this.institutionalData.length)
|
|
||||||
} catch (error) {
|
|
||||||
console.error('获取建制数据失败:', error)
|
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: '获取数据失败',
|
title: "页面跳转失败",
|
||||||
icon: 'none',
|
icon: "none",
|
||||||
})
|
});
|
||||||
}
|
},
|
||||||
},
|
});
|
||||||
|
|
||||||
// 处理查看详细
|
|
||||||
handleViewDetail(data) {
|
|
||||||
console.log('查看详细:', data.item)
|
|
||||||
// 跳转到捐款记录页面,传递建制ID
|
|
||||||
uni.navigateTo({
|
|
||||||
url: `/pages/institutionalStructure/donationRecord?formedId=${data.item.formedId}`,
|
|
||||||
fail: err => {
|
|
||||||
console.error('跳转失败:', err)
|
|
||||||
uni.showToast({
|
|
||||||
title: '页面跳转失败',
|
|
||||||
icon: 'none',
|
|
||||||
})
|
|
||||||
},
|
|
||||||
})
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
}
|
},
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
page {
|
page {
|
||||||
background: #f5f0e7;
|
background: #f5f0e7;
|
||||||
}
|
}
|
||||||
.header {
|
|
||||||
width: 100%;
|
.header {
|
||||||
min-height: 100vh;
|
width: 100%;
|
||||||
display: flex;
|
min-height: 100vh;
|
||||||
align-items: flex-start;
|
display: flex;
|
||||||
flex-direction: column;
|
align-items: flex-start;
|
||||||
background-color: #fffbf5;
|
flex-direction: column;
|
||||||
padding: 0 15rpx;
|
background-color: #fffbf5;
|
||||||
padding-bottom: 40rpx;
|
padding: 0 15rpx;
|
||||||
}
|
padding-bottom: 40rpx;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user