first commit

This commit is contained in:
2026-09-09 17:47:12 +08:00
commit 0cec79cd76
5672 changed files with 1015928 additions and 0 deletions
@@ -0,0 +1,68 @@
<script>
module.exports = {
name: "TableColumn",
props: {
label: {
type: String,
default: ""
},
value: {
type: [String, Number],
required: false
},
label_suffix:{
type: String,
default: ":"
}
},
}
</script>
<template>
<div class="table-column">
<!-- 左侧 Label -->
<div class="label">
<slot name="label">
{{ label }}
{{label_suffix}}
</slot>
</div>
<!-- 右侧 Value -->
<div class="value">
<slot>{{ value }}</slot>
</div>
</div>
</template>
<style scoped>
.table-column {
display: flex;
width: calc(50% - 6px);
min-width: 0;
padding: 4px 0;
align-items: center;
box-sizing: border-box;
}
.label {
color: #98a3b3;
font-size: 12px;
line-height: 18px;
flex-shrink: 0;
max-width: 50%;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.value {
min-width: 0;
color: #56657a;
font-size: 12px;
line-height: 18px;
flex-grow: 1;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
</style>
@@ -0,0 +1,360 @@
<template>
<van-pull-refresh class="table-list" v-model="tableRefreshing" @refresh="onRefresh">
<div v-if="tableData.length === 0" class="empty-state">
<slot name="empty">
<van-empty description="暂无数据"></van-empty>
</slot>
</div>
<van-list v-if="tableData && tableData.length>0"
v-model="tableLoading"
:finished="tableFinished"
finished-text="没有更多了"
@load="onLoad">
<div class="table-list-container">
<div v-for="(row, index) in tableData" :key="index" class="table-list-item"
:data-row-id="row && row.id ? row.id : ''">
<slot name="header" :index="index" :row="row">
<div class="item-header">
<div class="item-title">{{ calcTitle(row) }}</div>
<enum-tag :value="row.instanceState" name="ProcessInstanceStateEnum" label_key="message"
v-if="row?.instanceState" size="small"></enum-tag>
</div>
</slot>
<div class="table-list-content"
:style="{'max-height':img ? '100px':'unset', 'overflow': img ? 'hidden':'unset' }">
<div class="img-container" v-if="img">
<img :src="row[img]" alt="">
</div>
<div class="table-list-columns">
<slot :index="index" :row="row"></slot>
</div>
</div>
<div class="item-actions">
<slot name="actions" :index="index" :row="row"></slot>
</div>
</div>
</div>
</van-list>
</van-pull-refresh>
</template>
<script>
module.exports = {
name: "TableList",
props: {
api: {
type: String,
required: true
},
page_form: {
type: Object,
required: true,
default: () => {
return {
pageNumber: 1,
pageSize: 10,
totalCount: 0,
searchKeyword: ""
}
}
},
json: {
type: Boolean,
default: false
},
title: {
type: String,
default: ""
},
img: {
type: String,
default: ""
},
show_loading_overlay: {
type: Boolean,
default: true
}
},
watch: {
page_form: {
handler(newVal, oldVal) {
this.localPageForm = {...newVal}
},
deep: true,
immediate: true
}
},
data() {
return {
tableData: [],
tableLoading: false,
tableFinished: false,
tableRefreshing: false,
localPageForm: {...this.page_form}
}
},
methods: {
/**
* 获取当前列表快照。
* 返回值包含已加载记录、分页参数和加载完成状态,供业务页面在进入详情前暂存列表现场。
*/
getListState() {
return {
tableData: JSON.parse(JSON.stringify(this.tableData)),
localPageForm: JSON.parse(JSON.stringify(this.localPageForm)),
tableFinished: this.tableFinished
}
},
/**
* 恢复列表快照。
* state 应包含 tableData、localPageForm 和 tableFinished;返回 true 表示恢复成功。
*/
restoreListState(state) {
if (!state || !Array.isArray(state.tableData)) return false
this.$set(this, "tableData", state.tableData)
this.$set(this, "localPageForm", {...this.localPageForm, ...(state.localPageForm || {})})
this.$set(this, "tableFinished", !!state.tableFinished)
this.$set(this, "tableLoading", false)
this.$set(this, "tableRefreshing", false)
this.$emit("update:page_form", {...this.localPageForm})
return true
},
calcTitle(row) {
if (!this.title) return ""
// 处理key1.key2.key3 这样的形式
const keys = this.title.split(".")
let val = JSON.parse(JSON.stringify(row));
for (let key of keys) {
if (val == null || typeof val !== 'object') {
return "";
}
val = val[key];
}
return val == null ? "" : val;
},
onLoad() {
if (this.tableFinished) return
this.localPageForm.pageNumber++
this.$emit("update:page_form", {...this.localPageForm})
this.pageData()
},
pageData() {
this.tableLoading = true
const isInitialLoad = this.tableData.length === 0
this.$emit("loading-change", {loading: true, initial: isInitialLoad})
const loading = this.show_loading_overlay ? createListLoading() : null
this.$axios.post(
this.api,
this.json ? ({pageForm: JSON.stringify(this.localPageForm)}) : this.localPageForm,
{h5SkeletonLoading: !this.show_loading_overlay}
).then((res) => {
if (res.code === 0) {
// 接口异常返回 null 行时不渲染该行,避免业务插槽读取行字段产生渲染异常。
const responseList = Array.isArray(res.data.list) ? res.data.list.filter((item) => item) : []
this.tableData = this.tableData.concat(responseList)
this.localPageForm.totalCount = res.data.totalCount
if (this.tableData.length >= this.localPageForm.totalCount) {
this.tableFinished = true
}
this.$emit("update:page_form", {...this.localPageForm})
}
}).finally(() => {
if (loading) loading.close()
this.tableLoading = false
this.tableRefreshing = false
this.$emit("loading-change", {loading: false, initial: isInitialLoad})
})
},
doSearch() {
this.tableFinished = false
this.tableData = []
this.localPageForm.pageNumber = 1
this.$emit("update:page_form", {...this.localPageForm})
this.pageData()
},
onRefresh() {
this.localPageForm.pageNumber = 1
this.$emit("update:page_form", {...this.localPageForm})
this.doSearch()
}
},
mounted() {
this.$emit("ready")
}
}
</script>
<style scoped>
.table-list-container {
padding: 0;
margin-top: 12px;
}
.table-list-container .table-list-item {
background-color: #fff;
border: 1px solid #eef1f6;
border-radius: 12px;
box-shadow: 0 7px 20px rgba(55, 85, 126, .08);
padding: 14px;
position: relative;
margin-bottom: 12px;
overflow: hidden;
}
.table-list-container .table-list-item:last-child {
margin-bottom: 0;
}
.table-list-container .table-list-item .item-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 8px;
}
.table-list-container .table-list-item .item-title {
font-size: 15px;
line-height: 22px;
font-weight: 600;
color: #263548;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
flex: 1;
padding-right: 10px;
}
.table-list-container .table-list-item .img-container {
width: 100px;
height: 100px;
flex-shrink: 0;
overflow: hidden;
border-radius: 10px;
}
.table-list-container .table-list-item .img-container img {
width: 100%;
height: 100%;
object-fit: cover;
border-radius: 10px;
}
.table-list-container .table-list-item .table-list-content {
display: flex;
column-gap: 10px;
}
.table-list-container .table-list-item .table-list-columns {
display: flex;
width: 100%;
min-width: 0;
flex-wrap: wrap;
column-gap: 12px;
}
.table-list-container .table-list-item .item-meta {
display: flex;
color: #606266;
font-size: 14px;
margin-bottom: 5px;
padding: 4px 0;
}
.table-list-container .table-list-item .meta-item {
display: flex;
align-items: center;
gap: 8px;
width: 100%;
}
.table-list-container .table-list-item .meta-item i {
font-size: 14px;
color: #909399;
width: 16px;
text-align: center;
}
.table-list-container .table-list-item .item-content {
color: #606266;
font-size: 14px;
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
line-height: 1.5;
}
.table-list-container .table-list-item .item-footer {
display: flex;
justify-content: space-between;
margin-top: 12px;
padding-top: 8px;
border-top: 1px dashed #eaecef;
color: #909399;
font-size: 13px;
}
.table-list-container .table-list-item .item-actions {
display: flex;
gap: 8px;
flex-wrap: wrap;
justify-content: end;
margin-top: 10px;
padding-top: 10px;
border-top: 1px solid #edf1f6;
}
.table-list-container .table-list-item .action-btn {
display: inline-flex;
align-items: center;
justify-content: center;
min-height: 26px;
padding: 4px 10px;
box-sizing: border-box;
border-radius: 14px;
background-color: #eaf4ff;
font-size: 12px;
line-height: 18px;
color: var(--color-primary);
cursor: pointer;
}
.table-list-container .table-list-item .action-btn i {
margin-right: 5px;
font-size: 13px;
}
.table-list-container .table-list-item .action-btn.delete {
color: #f04444;
background-color: #fff0f0;
}
.table-list-container .table-list-item .action-btn.review {
color: #67c23a;
background-color: #eef9e9;
}
.empty-state {
text-align: center;
padding: 60px 20px;
color: #909399;
}
.empty-state i {
font-size: 60px;
margin-bottom: 16px;
color: #dcdee0;
}
.empty-state p {
margin-top: 10px;
font-size: 14px;
}
</style>