<template>
|
<view class="page" id="pageContent">
|
<view class="search-condition-zone">
|
<view class="form-item">
|
<view class="left">
|
日期:
|
</view>
|
<view class="daterange" style="flex: 1;">
|
<view class="right general">
|
<uni-datetime-picker type="date" :clear-icon="false" v-model="hform.HBeginDate">
|
<view>{{hform.HBeginDate}}</view>
|
</uni-datetime-picker>
|
</view>
|
<view>—</view>
|
<view class="right general">
|
<uni-datetime-picker type="date" :clear-icon="false" v-model="hform.HEndDate">
|
<view>{{hform.HEndDate}}</view>
|
</uni-datetime-picker>
|
</view>
|
</view>
|
</view>
|
<view class="form-item">
|
<view class="left">
|
单据号:
|
</view>
|
<view class="right general">
|
<input type="text" v-model="hform.HBillNo" />
|
</view>
|
</view>
|
</view>
|
<view class="button-zone">
|
<button type="default" class="btn-a" size="mini" @tap="cmdAdd">新增</button>
|
<button type="default" class="btn-a" size="mini" @tap="cmdSearch">查询</button>
|
<button type="default" class="btn-c" size="mini" @tap="exit">退出</button>
|
</view>
|
<view class="info-list-zone" id="scroll-content" :style="{height: scrollContentHeight + 'px'}">
|
<view class="card-item" v-for="(item, index) in listDataShow" :key="index">
|
<uni-card :title="item['单据号']" :extra="'日期:' + item['日期'].split('T')[0]"
|
@tap="showDetail = showDetail==index?-1:index">
|
<view class="card-detail">
|
<view
|
class="detail"
|
v-for="(value, key,keyIndex) in item"
|
:key="key"
|
v-if="keyIndex<=10 && shouldShowField(key, value)"
|
>
|
<text>{{ formatFieldName(key) }}:</text>{{ value }}
|
</view>
|
</view>
|
<view class="card-detail" v-if="showDetail == index">
|
<view
|
class="detail"
|
v-for="(value, key,keyIndex) in item"
|
:key="key"
|
v-if="keyIndex>=11 && shouldShowField(key, value)"
|
>
|
<text>{{ formatFieldName(key) }}:</text>{{ value }}
|
</view>
|
|
</view>
|
<view class="more" v-if="showDetail == index && operations != index">
|
<view class="part" style="border-right: 1px solid #eee;">
|
<uni-icons type="top" style="color: #888;margin-right: 10rpx;" size="14"></uni-icons>收起
|
</view>
|
<view class="part" @tap.stop="operations = operations==index?-1:index">
|
<uni-icons type="more-filled" style="color: #888;margin-right: 10rpx;"
|
size="14"></uni-icons>操作
|
</view>
|
</view>
|
<view class="more" v-if="showDetail != index && operations != index">
|
<view class="part" style="border-right: 1px solid #eee;">
|
<uni-icons type="bottom" style="color: #888;margin-right: 10rpx;" size="14"></uni-icons>更多信息
|
</view>
|
<view class="part" @tap.stop="operations = operations==index?-1:index">
|
<uni-icons type="more-filled" style="color: #888;margin-right: 10rpx;"
|
size="14"></uni-icons>操作
|
</view>
|
</view>
|
<view class="op" v-if="operations == index">
|
<button class="op3" size="mini" plain @tap.stop="edit(item)">编辑</button>
|
<button class="op3" size="mini" plain @tap.stop="audit(item, 0)" v-if="!listDataShow[index]['审核人']">审核</button>
|
<button class="op3" size="mini" plain @tap.stop="audit(item, 1)" v-if="listDataShow[index]['审核人']">反审核</button>
|
<button class="op4" size="mini" plain @tap.stop="del(item)">删除</button>
|
<button class="op5" size="mini" plain @tap.stop="operations = -1">取消操作</button>
|
</view>
|
</uni-card>
|
</view>
|
<view class="over" v-if="listDataShow.length == 0">暂无数据</view>
|
</view>
|
|
<view class="pagination-zone" id="pagination-zone">
|
<uni-pagination show-icon :page-size="paginationMeta.pageSize" :total="paginationMeta.total"
|
:current="paginationMeta.current" @change="onPaginationChangeHandler"></uni-pagination>
|
</view>
|
</view>
|
</template>
|
|
<script>
|
import {
|
CommonUtils
|
} from '@/utils/common'
|
import {
|
getUserInfo
|
} from '@/utils/auth'
|
import dayjs, {
|
Dayjs
|
} from 'dayjs'
|
export default {
|
data() {
|
return {
|
|
navHeight: 0,
|
scrollTop: 0,
|
|
showDetail: -1,
|
operations: -1,
|
|
hform: {
|
HBeginDate: dayjs(new Date).subtract(30, 'd').format('YYYY-MM-DD'),
|
HEndDate: dayjs(new Date).format('YYYY-MM-DD'),
|
HBillNo: ''
|
},
|
|
paginationMeta: {
|
current: 1,
|
total: 0,
|
pageSize: 30,
|
},
|
|
pageMeta: {
|
scrollContentTop: 0,
|
bottomBtnTop: 0,
|
},
|
|
listData: [],
|
listDataShow: [],
|
}
|
},
|
computed: {
|
scrollContentHeight: {
|
get() {
|
return this.pageMeta.bottomBtnTop - this.pageMeta.scrollContentTop
|
}
|
}
|
},
|
methods: {
|
// 判断哪些字段需要显示
|
shouldShowField(key, value) {
|
// 排除不需要显示的字段
|
const excludeKeys = ['单据号', '日期']; // 这些字段已经在其他地方显示了
|
|
// 判断key是否全英文(不包含中文)
|
const isAllEnglish = /^[a-zA-Z]+$/.test(key);
|
|
// 判断key是否包含"ID"(不区分大小写)
|
const containsID = key.toUpperCase().includes('ID');
|
|
return !excludeKeys.includes(key) &&
|
!isAllEnglish && // 排除全英文的key
|
!containsID && // 排除包含ID的key
|
value !== null &&
|
value !== undefined &&
|
value !== '';
|
},
|
|
// 格式化字段名显示
|
formatFieldName(key) {
|
// 你可以根据需求自定义显示名称
|
const nameMap = {
|
'物料代码': '物料代码',
|
'物料名称': '物料名称',
|
'规格型号': '规格型号',
|
// ... 其他字段映射
|
};
|
return nameMap[key] || key;
|
},
|
exit() {
|
uni.navigateBack()
|
},
|
cmdAdd() {
|
uni.redirectTo({
|
url: "/pages/ZLGL/QualityReportStep/QualityReportStepBill"
|
})
|
},
|
async cmdSearch() {
|
let sWhere = ''
|
if (this.hform.HBeginDate != "" && this.hform.HEndDate != "") {
|
sWhere += " and CONVERT(varchar(100),日期, 23) between '" + this.hform.HBeginDate + "' and '" +
|
this.hform.HEndDate + "' ";
|
}
|
if (this.hform.HBillNo != "") {
|
sWhere += " and 单据号 like '%" + this.hform.HBillNo + "%'"
|
}
|
try {
|
let res = await CommonUtils.doRequest2Sync({
|
url: '/Sc_QualityReportBill/getSc_QualityReportBill',
|
data: {
|
"sWhere": sWhere,
|
"user": getUserInfo()["Czymc"]
|
},
|
})
|
|
if (!res) {
|
return
|
}
|
let {
|
data,
|
count,
|
Message
|
} = res.data
|
if (count > 0) {
|
this.listData = data
|
this.paginationMeta.total = data.length
|
this.onPaginationChangeHandler({
|
current: 1
|
})
|
} else {
|
uni.showToast({
|
icon: 'none',
|
title: Message
|
})
|
}
|
} catch (err) {
|
console.warn(err);
|
uni.showToast({
|
title: '接口请求失败:' + err,
|
icon: 'none'
|
})
|
}
|
},
|
async onPaginationChangeHandler({
|
current
|
}) {
|
this.listDataShow =
|
this.listData.slice((current - 1) * this.paginationMeta.pageSize,
|
current * this.paginationMeta.pageSize)
|
|
},
|
async audit(item, mode) {
|
console.log('审核单据: ',item);
|
|
try{
|
let res = await CommonUtils.doRequest2Sync({
|
method: 'GET',
|
url: '/Sc_QualityReportBill/AuditSc_QualityReportBill',
|
data: {
|
HInterID: item["hmainid"],
|
IsAudit: mode,
|
CurUserName: getUserInfo()["Czymc"]
|
}
|
})
|
|
if(!res) {
|
return
|
}
|
|
let {count, data, Message} = res.data
|
|
if(count == 1) {
|
CommonUtils.showTips({
|
message: `${item["审核人"]?'反审核':'审核'}成功`
|
})
|
this.$forceUpdate()
|
setTimeout(() => {
|
this.cmdSearch()
|
}, 2000)
|
}else {
|
CommonUtils.showTips({
|
title: '温馨提示',
|
message: `单据${item["审核人"]?'反审核':'审核'}失败: ${Message}`
|
})
|
}
|
}catch(err) {
|
CommonUtils.showTips({
|
title: '温馨提示',
|
message: `单据${item["审核人"]?'反审核':'审核'}错误: ${err}`
|
})
|
}
|
},
|
async del(item) {
|
console.log("delItem: ", item);
|
uni.showModal({
|
title: '提示',
|
content: '确认要删除记录?删除后不能恢复',
|
success: async (res) => {
|
if (res.confirm) {
|
console.log('用户点击确定');
|
try {
|
let res = await CommonUtils.doRequest2Sync({
|
url: '/Sc_QualityReportBill/DropSc_QualityReportBill',
|
data: {
|
"HInterID": item.hmainid,
|
"user": getUserInfo()["Czymc"]
|
}
|
})
|
|
if (!res) {
|
return
|
}
|
|
let {
|
count,
|
code,
|
Message
|
} = res.data
|
if (count == 0) {
|
return uni.showModal({
|
title: '错误提示',
|
content: `删除错误: ${Message}`,
|
showCancel: false
|
})
|
}
|
uni.showToast({
|
title: '删除成功',
|
icon: 'none'
|
})
|
this.cmdSearch()
|
} catch (err) {
|
uni.showModal({
|
title: '错误提示',
|
content: `接口请求失败: ${err}`,
|
showCancel: false
|
})
|
}
|
}
|
},
|
})
|
|
},
|
edit(item) {
|
console.log("editItem:", item)
|
// uni.navigateTo({
|
// url: `/pages/ZLGL/mojianjianyan/lastPieceCheckBill?operationType=3&linterid=${item.hmainid}`
|
// })
|
}
|
},
|
onShow() {
|
this.$nextTick(() => {
|
this.cmdSearch()
|
})
|
},
|
onReady() {
|
// #ifndef MP-WEIXIN
|
let query = uni.createSelectorQuery().in(this)
|
query.select("#scroll-content").boundingClientRect((data) => {
|
this.pageMeta.scrollContentTop = data.top
|
}).exec()
|
query.select("#pagination-zone").boundingClientRect((data) => {
|
this.pageMeta.bottomBtnTop = data.top
|
}).exec()
|
// #endif
|
// #ifdef MP-WEIXIN
|
// 微信不支持 uni.createSelectorQuery().in(this)
|
// #endif
|
|
},
|
}
|
</script>
|
|
<style lang="scss" scoped>
|
.page {
|
box-sizing: border-box;
|
display: flex;
|
flex-direction: column;
|
gap: 20rpx;
|
padding: 20rpx 0;
|
position: relative;
|
|
.button-zone {
|
height: auto;
|
box-sizing: border-box;
|
padding-top: 20rpx;
|
display: flex;
|
flex-direction: row;
|
justify-content: space-between;
|
flex-wrap: wrap;
|
|
button {
|
border-radius: 50rpx;
|
width: 180rpx;
|
height: 66rpx;
|
line-height: 66rpx;
|
font-size: 28rpx;
|
}
|
|
.btn-a {
|
background-color: #3a78ff;
|
color: #fff;
|
}
|
|
.btn-c {
|
background-color: #ff5722;
|
color: #fff;
|
}
|
}
|
|
.search-condition-zone {
|
height: auto;
|
box-sizing: border-box;
|
padding: 0 60rpx;
|
display: flex;
|
flex-direction: column;
|
gap: 20rpx;
|
|
.form-item {
|
display: flex;
|
flex-direction: row;
|
gap: 20rpx;
|
align-items: center;
|
font-size: 28rpx;
|
|
.left {
|
width: 4rem;
|
}
|
|
.right {
|
flex: 1;
|
padding: 8rpx 16rpx;
|
|
.search {
|
width: 28rpx;
|
height: 28rpx;
|
}
|
|
input {
|
font-size: 28rpx;
|
}
|
|
.uni-combox {
|
padding: 0;
|
margin: 0;
|
|
::v-deep .uni-combox__input {
|
font-size: 28rpx;
|
height: auto;
|
}
|
}
|
}
|
|
.general {
|
border-radius: 22rpx;
|
border: 1px solid #acacac;
|
}
|
|
.disabled {
|
border-radius: 22rpx;
|
border: 1px solid #e4e4e4;
|
background-color: #e4e4e4;
|
}
|
}
|
}
|
|
.info-list-zone {
|
overflow-y: auto;
|
|
.card-item {
|
.card-detail {
|
width: 100%;
|
display: flex;
|
flex-wrap: wrap;
|
justify-content: space-between;
|
line-height: 120%;
|
|
.detail {
|
// width: 50%;
|
font-size: 26rpx;
|
margin-bottom: 12rpx;
|
color: #555;
|
margin-right: 20rpx;
|
|
text {
|
color: #999;
|
font-size: 26rpx;
|
}
|
}
|
}
|
}
|
}
|
|
.daterange {
|
display: flex;
|
flex-direction: row;
|
gap: 10rpx;
|
justify-content: center;
|
align-items: center;
|
}
|
|
.more {
|
color: #888;
|
font-size: 24rpx;
|
display: flex;
|
border-top: 1px solid #eee;
|
padding-top: 20rpx;
|
|
.part {
|
width: 50%;
|
text-align: center;
|
}
|
}
|
|
.op {
|
display: flex;
|
justify-content: space-between;
|
gap: 20rpx;
|
margin-top: 20rpx;
|
flex-wrap: wrap;
|
align-content: flex-start;
|
button {
|
margin: 0;
|
flex-shrink: 0;
|
padding: 0;
|
width: 150rpx;
|
flex-basis: 150rpx;
|
font-size: 25rpx;
|
}
|
|
.op1 {
|
border: 1px solid #41a863;
|
color: #41a863;
|
}
|
|
.op2 {
|
border: 1px solid #d98d00;
|
color: #d98d00;
|
}
|
|
.op3 {
|
border: 1px solid #3a78ff;
|
color: #3a78ff;
|
}
|
|
.op4 {
|
border: 1px solid #da0000;
|
color: #da0000;
|
}
|
|
.op5 {
|
border: 1px solid #888;
|
color: #888;
|
}
|
}
|
|
.pagination-zone {
|
position: fixed;
|
bottom: 0;
|
box-sizing: border-box;
|
background-color: #fff;
|
box-shadow: 0 2rpx 10rpx 2rpx rgba(0, 0, 0, 0.4);
|
padding: 20rpx 40rpx 20rpx 40rpx;
|
display: flex;
|
flex-direction: column;
|
gap: 20rpx;
|
justify-content: space-between;
|
width: 100%;
|
}
|
}
|
</style>
|