This commit is contained in:
@jyuhsin
2025-09-15 16:14:07 +08:00
parent 204deed9d6
commit 7a062e63ea
63 changed files with 25503 additions and 44428 deletions
@@ -0,0 +1,62 @@
<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;
padding: 6px 0;
align-items: center;
}
.label {
color: #333;
font-size: 14px;
flex-shrink: 0;
max-width: 120px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.value {
color: #555;
font-size: 14px;
flex-grow: 1; /* 动态占据剩余部分 */
white-space: nowrap; /* 防止换行 */
overflow: hidden; /* 隐藏溢出的部分 */
text-overflow: ellipsis; /* 省略号 */
}
</style>
@@ -0,0 +1,278 @@
<template>
<van-pull-refresh v-model="tableRefreshing" @refresh="onRefresh">
<div v-if="tableData.length === 0" class="empty-state">
<van-empty description="暂无数据"></van-empty>
</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">
<slot name="header" :index="index" :row="row">
<div class="item-header">
<div class="item-title">{{ row[title] }}</div>
<enum-tag :value="row.instanceState" name="ProcessInstanceStateEnum" label_key="message"
size="small"></enum-tag>
</div>
</slot>
<div style="display: flex;column-gap: 10px"
:style="{'max-height':img ? '100px':'unset', 'overflow': img ? 'hidden':'unset' }">
<div class="img-container" v-if="img">
<img :src="row[img]" alt="" style="object-fit: cover">
</div>
<div class="">
<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: ""
}
},
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: {
onLoad() {
if (this.tableFinished) return
this.localPageForm.pageNumber++
this.$emit("update:page_form", { ...this.localPageForm })
this.pageData()
},
pageData() {
this.tableLoading = true
const loading = createListLoading()
this.$axios.post(this.api, this.json ? ({ pageForm: JSON.stringify(this.localPageForm) }) : this.localPageForm).then((res) => {
if (res.code === 0) {
this.tableData = this.tableData.concat(res.data.list)
this.localPageForm.totalCount = res.data.totalCount
if (this.tableData.length >= this.localPageForm.totalCount) {
this.tableFinished = true
}
this.$emit("update:page_form", { ...this.localPageForm })
}
}).finally(() => {
loading.close()
console.log(this.tableLoading)
this.tableLoading = false
console.log(this.tableLoading)
this.tableRefreshing = false
})
},
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: 10px;
}
.table-list-container .table-list-item {
background-color: #fff;
border-bottom: 1px solid #eaecef;
padding: 16px;
position: relative;
margin-bottom: 10px;
}
.table-list-container .table-list-item:last-child {
border-bottom: none;
margin-bottom: 0;
}
.table-list-container .table-list-item .item-header {
display: flex;
justify-content: space-between;
align-items: flex-start;
margin-bottom: 10px;
}
.table-list-container .table-list-item .item-title {
font-size: 16px;
font-weight: 500;
color: #1f2f3d;
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;
border-radius: 6px;
}
.table-list-container .table-list-item .img-container img {
width: 100%;
height: 100%;
border-radius: 6px;
}
.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;
column-gap: 20px;
justify-content: end;
margin-top: 15px;
padding-top: 12px;
border-top: 1px solid #eaecef;
}
.table-list-container .table-list-item .action-btn {
display: flex;
align-items: center;
justify-content: end;
font-size: 14px;
color: var(--color-primary);
padding: 4px 0;
}
.table-list-container .table-list-item .action-btn i {
margin-right: 6px;
font-size: 16px;
}
.table-list-container .table-list-item .action-btn.delete {
color: #ff0000;
}
.table-list-container .table-list-item .action-btn.review {
color: #67c23a;
}
.table-list-container .empty-state {
text-align: center;
padding: 60px 20px;
color: #909399;
}
.table-list-container .empty-state i {
font-size: 60px;
margin-bottom: 16px;
color: #dcdee0;
}
.table-list-container .empty-state p {
margin-top: 10px;
font-size: 14px;
}
</style>
@@ -0,0 +1,118 @@
<template>
<div>
<template v-for="item in options">
<component :key="item[value_key]" v-if="item[value_key] === value" v-bind="$attrs"
:is="isMobile ? 'van-tag' : 'el-tag'" :type="item.type"
>{{ item[label_key] }}
</component>
</template>
</div>
</template>
<script>
// 全局缓存和请求Promise缓存
const enumCache = {}
const requestPromises = {}
module.exports = {
name: "DictTag",
props: {
value: { type: String | Number },
name: { type: String },
value_key: {
type: String,
default: "code"
},
label_key: {
type: String,
default: "name"
},
},
data() {
return {
options: [],
isMobile: true,
}
},
watch: {
code: {
handler(val) {
this.getEnumOptions()
},
immediate: true
}
},
methods: {
isMobileDevice() {
return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(
navigator.userAgent
);
},
getEnumOptions() {
// // 检查数据缓存
// if (enumCache[this.name]) {
// this.options = enumCache[this.name]
// return
// }
//
// // 检查是否已有相同请求在进行中
// if (requestPromises[this.name]) {
// requestPromises[this.name].then(data => {
// this.options = data
// })
// return
// }
// 创建请求Promise并缓存
requestPromises[this.name] = $.get("/open/common/dictEnumOptions", { name: this.name })
.then(res => {
if (res.code === 0) {
// 存入数据缓存
enumCache[this.name] = res.data
// 清除请求Promise缓存
delete requestPromises[this.name]
return res.data
}
})
requestPromises[this.name].then(data => {
this.options = data
})
}
},
created() {
this.isMobile = this.isMobileDevice()
}
}
</script>
<style scoped>
.el-tag + .el-tag {
margin-left: 10px;
}
.van-tag {
height: 24px;
padding: 0 8px;
line-height: 22px;
}
.van-tag--success {
background-color: #f0f9eb;
border-color: #e1f3d8;
color: #67c23a;
}
.van-tag--primary {
color: var(--color-primary);
background-color: #ecf5ff;
border-color: #d9ecff;
}
.van-tag--danger{
background-color: #fef0f0;
border-color: #fde2e2;
color: #f56c6c;
}
.van-tag--warning{
background-color: #fdf6ec;
border-color: #faecd8;
color: #e6a23c;
}
</style>
@@ -0,0 +1,75 @@
<template>
<div>
<div v-if="pdf" id="pdf-container"></div>
<div v-else v-html="content" class="content"></div>
</div>
</template>
<script>
module.exports = {
name: "PdfIndex",
props: {
content: {
type: String,
default: '',
required: true
},
height: {
type: Number,
default: 300,
required: false
},
},
watch: {
},
data() {
return {
pdf: true,
pdfObj: null,
}
},
methods: {
init() {
try {
const parser = new DOMParser();
const doc = parser.parseFromString(this.content, 'text/html');
const link = doc.querySelector('a');
const href = link.getAttribute('href');
this.$nextTick(() => {
this.pdfObj = new Pdfh5('#pdf-container', {
pdfurl: href,
});
this.pdfObj.on("complete", function () {
const elements = document.querySelectorAll('[class*="canvasImg"]')
let classArray = []
elements.forEach(element => {
classArray.push(element.getAttribute('src'))
})
elements.forEach((element,index) => {
element.addEventListener('click', function() {
vant.ImagePreview({
images: classArray,
startPosition: index,
closeable: true,
})
})
})
})
})
}catch (e) {
this.pdf = false
}
},
},
created() {
this.init()
},
}
</script>
<style scoped>
.content {
padding: 10px;
}
</style>
@@ -0,0 +1,125 @@
<template>
<div class="sign-container">
<template v-if="Object.keys(res).length === 0">
<div class="reader-container">
<div id="reader"></div>
</div>
</template>
<template v-else>
<div class="weui-msg">
<div class="weui-msg__icon-area">
<i v-if="res?.code !== 0" class="weui-icon-warn weui-icon_msg"></i>
<i v-if="res?.code === 0" class="weui-icon-success weui-icon_msg"></i>
</div>
<div class="weui-msg__text-area">
<div class="weui-msg__title">温馨提醒</div>
<div v-html="res?.msg"></div>
</div>
<div class="weui-msg__opr-area">
<p class="weui-btn-area">
<a @click="res = {}; getCameras()"
class="weui-btn weui-btn_primary">重新扫描</a>
</p>
</div>
</div>
</template>
</div>
</template>
<script>
module.exports = {
name: "scanCode",
props: {
},
watch: {
},
data() {
return {
html5QrCode: null,
scanStatus: true,
cameraId: '',
res: {},
}
},
methods: {
getCameras() {
Html5Qrcode.getCameras()
.then((devices) => {
if (devices && devices.length) {
// 如果有2个摄像头,1为前置的
if (devices.length > 1) {
this.cameraId = devices[1].id;
} else {
this.cameraId = devices[0].id;
}
let isHuawei = navigator.userAgent.toLowerCase().match(/huawei/i) === 'huawei';
if(isHuawei) {
const backCamera = devices.filter(o => o.label.includes('back'))
this.cameraId = backCamera[0].id;
}
this.start();
}
})
.catch((err) => {
console.log(err)
})
},
start() {
this.html5QrCode = new Html5Qrcode("reader");
this.html5QrCode.start(
this.cameraId, // retreived in the previous step.
{
fps: 100, // sets the framerate to 10 frame per second,
qrbox: {width: 1000, height: 1000}, // sets only 250 X 250 region of viewfinder to
},
async (decodedText, decodedResult) => {
this.res = await this.$axios.post(decodedText)
this.closeScan()
},
(errorMessage) => {
console.log(errorMessage);
}
)
.catch((err) => {
alert(err)
console.log(`Unable to start scanning, error: ` + err);
});
},
closeScan() {
this.html5QrCode.stop()
.then((ignore) => {
console.log("QR Code scanning stopped.");
})
.catch((err) => {
console.log("Unable to stop scanning.");
});
},
init() {
this.getCameras()
}
},
created() {
},
}
</script>
<style scoped>
.sign-container{
width: 100%;
height: 100%;
}
.reader-container {
padding-top: 50px;
}
#reader {
width: 90%;
margin: 0 auto;
text-align: center;
}
.weui-msg__icon-area {
margin-top: 30px;
}
</style>