- 新增 invoice_title、showcase、wallet_log 模型及对应语言包 - 新增后台控制器、视图及搜索字段配置 - 修复服务类目删除保护逻辑 - 优化后台登录页面文案及样式 - 新增前端角色切换逻辑及页面拦截 - 新增 SVG 图标及样式变量 - 修复接口权限及下拉框默认值问题
600 行
13 KiB
Vue
600 行
13 KiB
Vue
<template>
|
||
<view class="page">
|
||
<YjyfNavBar theme="orange" title="按订单开票" :fixed="true" :placeholder="true" />
|
||
|
||
<!-- 顶部精简辅助栏 -->
|
||
<view class="sub-head" v-if="list.length > 0">
|
||
<text class="sh-count">共 {{ total }} 笔已完成订单</text>
|
||
<view class="sh-link clickable-hover" @tap="goRecords">
|
||
<text class="sh-link-txt">开票记录</text>
|
||
<image class="sh-arrow" src="/static/icons/arrow-right-orange.svg" mode="aspectFit" />
|
||
</view>
|
||
</view>
|
||
|
||
<!-- 待开票订单票根卡片列表 -->
|
||
<view class="order-list" v-if="list.length > 0">
|
||
<view
|
||
class="ord-card clickable-hover"
|
||
:class="{ checked: selectedMap[item.id] }"
|
||
v-for="item in list"
|
||
:key="item.id"
|
||
@tap="toggleSelect(item.id)"
|
||
>
|
||
<view class="ord-upper">
|
||
<image
|
||
class="chk-ico"
|
||
:src="selectedMap[item.id] ? '/static/icons/invoice-check-on.svg' : '/static/icons/invoice-check-off.svg'"
|
||
mode="aspectFit"
|
||
/>
|
||
|
||
<image
|
||
class="svc-thumb"
|
||
:src="item.service_image || '/static/icons/service-default.svg'"
|
||
mode="aspectFill"
|
||
/>
|
||
|
||
<view class="ord-info">
|
||
<text class="ord-title">{{ item.service_name }}</text>
|
||
<text class="ord-spec" v-if="item.goods_model">{{ item.goods_model }} × {{ item.goods_num }}</text>
|
||
<text class="ord-spec muted" v-else>× {{ item.goods_num || 1 }}</text>
|
||
</view>
|
||
</view>
|
||
|
||
<view class="ord-divider">
|
||
<view class="notch notch-l"></view>
|
||
<view class="dash-line"></view>
|
||
<view class="notch notch-r"></view>
|
||
</view>
|
||
|
||
<view class="ord-lower">
|
||
<text class="ord-meta">{{ item.time_text }} · {{ item.order_no }}</text>
|
||
<view class="ord-amt-box">
|
||
<text class="amt-sym">¥</text>
|
||
<text class="amt-int">{{ splitAmt(item.invoiceable_amount).int }}</text>
|
||
<text class="amt-dec">.{{ splitAmt(item.invoiceable_amount).dec }}</text>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
|
||
<view class="list-foot" v-if="loading || !hasMore">
|
||
<text class="foot-txt">{{ loading ? '加载中...' : '没有更多了' }}</text>
|
||
</view>
|
||
</view>
|
||
|
||
<!-- 初次加载态 -->
|
||
<view class="state-box" v-else-if="loading">
|
||
<text class="state-txt">加载中...</text>
|
||
</view>
|
||
|
||
<!-- 接口异常重试态 -->
|
||
<view class="state-box" v-else-if="loadError">
|
||
<image class="empty-ico" src="/static/icons/empty-invoice-records.svg" mode="aspectFit" />
|
||
<text class="state-title">订单加载失败</text>
|
||
<view class="retry-btn clickable-hover" @tap="reload">重新加载</view>
|
||
</view>
|
||
|
||
<!-- 空状态 -->
|
||
<view class="state-box" v-else>
|
||
<image class="empty-ico" src="/static/icons/empty-invoice-records.svg" mode="aspectFit" />
|
||
<text class="state-title">暂无可开票订单</text>
|
||
<text class="state-desc">订单完成验收后可在此合并开票</text>
|
||
<view class="ghost-btn clickable-hover" @tap="goRecords">开票记录</view>
|
||
</view>
|
||
|
||
<!-- 底部毛玻璃悬浮结算栏 -->
|
||
<view class="bottom-bar" v-if="list.length > 0">
|
||
<view class="select-all clickable-hover" @tap="toggleAll">
|
||
<image
|
||
class="chk-ico-bar"
|
||
:src="isAllSelected ? '/static/icons/invoice-check-on.svg' : '/static/icons/invoice-check-off.svg'"
|
||
mode="aspectFit"
|
||
/>
|
||
<text class="all-txt">全选</text>
|
||
</view>
|
||
|
||
<view class="bar-right">
|
||
<view class="sum-info">
|
||
<view class="sum-line">
|
||
<text class="sum-label">合计</text>
|
||
<text class="sum-sym">¥</text>
|
||
<text class="sum-int">{{ splitAmt(selectedTotal).int }}</text>
|
||
<text class="sum-dec">.{{ splitAmt(selectedTotal).dec }}</text>
|
||
</view>
|
||
<text class="sum-count" v-if="selectedIds.length > 0">已选 {{ selectedIds.length }} 笔</text>
|
||
</view>
|
||
<view
|
||
class="next-btn clickable-hover"
|
||
:class="{ disabled: selectedIds.length === 0 }"
|
||
@tap="goNext"
|
||
>
|
||
下一步
|
||
</view>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
</template>
|
||
|
||
<script setup>
|
||
import { ref, computed } from 'vue';
|
||
import { onLoad, onShow, onReachBottom } from '@dcloudio/uni-app';
|
||
import YjyfNavBar from '@/components/YjyfNavBar.vue';
|
||
import api from '@/utils/api.js';
|
||
import { isLogin, toLogin } from '@/utils/request.js';
|
||
|
||
const list = ref([]);
|
||
const total = ref(0);
|
||
const page = ref(1);
|
||
const hasMore = ref(false);
|
||
const loading = ref(false);
|
||
const loadError = ref(false);
|
||
const selectedIds = ref([]);
|
||
const presetIds = ref([]);
|
||
|
||
const selectedMap = computed(() => {
|
||
const m = {};
|
||
for (const id of selectedIds.value) {
|
||
m[id] = true;
|
||
}
|
||
return m;
|
||
});
|
||
|
||
const isAllSelected = computed(() => {
|
||
if (!list.value.length) return false;
|
||
return list.value.every((item) => selectedMap.value[item.id]);
|
||
});
|
||
|
||
const selectedTotal = computed(() => {
|
||
let sum = 0;
|
||
for (const item of list.value) {
|
||
if (selectedMap.value[item.id]) {
|
||
sum += Number(item.invoiceable_amount || 0);
|
||
}
|
||
}
|
||
return Math.round(sum * 100) / 100;
|
||
});
|
||
|
||
function splitAmt(v) {
|
||
const n = Number(v || 0);
|
||
const s = (Number.isFinite(n) ? n : 0).toFixed(2);
|
||
const p = s.split('.');
|
||
return { int: p[0] || '0', dec: p[1] || '00' };
|
||
}
|
||
|
||
onLoad((q) => {
|
||
if (q && q.preselect) {
|
||
const ids = String(q.preselect)
|
||
.split(',')
|
||
.map((v) => Number(v.trim()))
|
||
.filter((n) => n > 0);
|
||
presetIds.value = ids;
|
||
}
|
||
});
|
||
|
||
onShow(() => {
|
||
if (!isLogin()) {
|
||
toLogin();
|
||
return;
|
||
}
|
||
reload();
|
||
});
|
||
|
||
onReachBottom(() => {
|
||
if (hasMore.value && !loading.value) {
|
||
fetchPage(page.value + 1);
|
||
}
|
||
});
|
||
|
||
async function reload() {
|
||
await fetchPage(1);
|
||
}
|
||
|
||
async function fetchPage(targetPage) {
|
||
loading.value = true;
|
||
loadError.value = false;
|
||
try {
|
||
const res = await api.invoiceOrders({ page: targetPage, limit: 20 });
|
||
const rows = (res && res.list) || [];
|
||
if (targetPage === 1) {
|
||
list.value = rows;
|
||
const validSet = new Set(rows.map((r) => r.id));
|
||
if (presetIds.value.length > 0) {
|
||
selectedIds.value = presetIds.value.filter((id) => validSet.has(id));
|
||
presetIds.value = [];
|
||
} else {
|
||
selectedIds.value = selectedIds.value.filter((id) => validSet.has(id));
|
||
}
|
||
} else {
|
||
const existSet = new Set(list.value.map((r) => r.id));
|
||
for (const r of rows) {
|
||
if (!existSet.has(r.id)) list.value.push(r);
|
||
}
|
||
}
|
||
total.value = Number((res && res.total) || list.value.length);
|
||
page.value = targetPage;
|
||
hasMore.value = Boolean(res && res.has_more);
|
||
} catch (e) {
|
||
if (targetPage === 1) loadError.value = true;
|
||
} finally {
|
||
loading.value = false;
|
||
}
|
||
}
|
||
|
||
function toggleSelect(id) {
|
||
const idx = selectedIds.value.indexOf(id);
|
||
if (idx >= 0) {
|
||
selectedIds.value.splice(idx, 1);
|
||
} else {
|
||
selectedIds.value.push(id);
|
||
}
|
||
}
|
||
|
||
function toggleAll() {
|
||
if (isAllSelected.value) {
|
||
selectedIds.value = [];
|
||
} else {
|
||
selectedIds.value = list.value.map((item) => item.id);
|
||
}
|
||
}
|
||
|
||
function goNext() {
|
||
if (!selectedIds.value.length) {
|
||
uni.showToast({ title: '请先勾选需要开票的订单', icon: 'none' });
|
||
return;
|
||
}
|
||
const idsStr = selectedIds.value.join(',');
|
||
uni.navigateTo({ url: `/pages/invoice/apply?order_ids=${idsStr}` });
|
||
}
|
||
|
||
function goRecords() {
|
||
uni.navigateTo({ url: '/pages/invoice/records' });
|
||
}
|
||
</script>
|
||
|
||
<style lang="scss" scoped>
|
||
.page {
|
||
min-height: 100vh;
|
||
background: $yjyf-bg-page;
|
||
padding-bottom: calc(176rpx + env(safe-area-inset-bottom));
|
||
box-sizing: border-box;
|
||
}
|
||
|
||
.sub-head {
|
||
padding: $yjyf-space-md $yjyf-space-lg $yjyf-space-sm;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: space-between;
|
||
}
|
||
|
||
.sh-count {
|
||
font-size: $yjyf-font-sub;
|
||
color: $yjyf-text-secondary;
|
||
}
|
||
|
||
.sh-link {
|
||
display: inline-flex;
|
||
align-items: center;
|
||
}
|
||
|
||
.sh-link-txt {
|
||
font-size: $yjyf-font-sub;
|
||
color: $yjyf-primary;
|
||
font-weight: 600;
|
||
}
|
||
|
||
.sh-arrow {
|
||
width: 24rpx;
|
||
height: 24rpx;
|
||
margin-left: 4rpx;
|
||
}
|
||
|
||
.order-list {
|
||
padding: 0 $yjyf-space-lg;
|
||
}
|
||
|
||
.ord-card {
|
||
position: relative;
|
||
overflow: hidden;
|
||
background: $yjyf-bg-card;
|
||
border-radius: $yjyf-radius-card;
|
||
margin-bottom: 20rpx;
|
||
border: 2rpx solid transparent;
|
||
box-shadow: 0 6rpx 20rpx rgba(31, 31, 31, 0.04);
|
||
transition: border-color 0.18s ease, box-shadow 0.18s ease;
|
||
|
||
&.checked {
|
||
border-color: $yjyf-primary;
|
||
box-shadow: 0 8rpx 24rpx rgba(240, 113, 13, 0.12);
|
||
|
||
.ord-lower {
|
||
background: $yjyf-primary-bg;
|
||
}
|
||
}
|
||
}
|
||
|
||
.ord-upper {
|
||
padding: $yjyf-space-md $yjyf-space-md 16rpx;
|
||
display: flex;
|
||
align-items: center;
|
||
}
|
||
|
||
.chk-ico {
|
||
width: 42rpx;
|
||
height: 42rpx;
|
||
flex-shrink: 0;
|
||
margin-right: 20rpx;
|
||
}
|
||
|
||
.svc-thumb {
|
||
width: 96rpx;
|
||
height: 96rpx;
|
||
border-radius: 14rpx;
|
||
background: $yjyf-bg-page;
|
||
flex-shrink: 0;
|
||
margin-right: 20rpx;
|
||
}
|
||
|
||
.ord-info {
|
||
flex: 1;
|
||
min-width: 0;
|
||
}
|
||
|
||
.ord-title {
|
||
display: block;
|
||
font-size: $yjyf-font-body;
|
||
font-weight: 600;
|
||
color: $yjyf-text-main;
|
||
overflow: hidden;
|
||
text-overflow: ellipsis;
|
||
white-space: nowrap;
|
||
}
|
||
|
||
.ord-spec {
|
||
display: block;
|
||
font-size: $yjyf-font-sub;
|
||
color: $yjyf-text-secondary;
|
||
margin-top: 8rpx;
|
||
white-space: nowrap;
|
||
overflow: hidden;
|
||
text-overflow: ellipsis;
|
||
|
||
&.muted {
|
||
color: $yjyf-text-muted;
|
||
}
|
||
}
|
||
|
||
.ord-divider {
|
||
position: relative;
|
||
height: 20rpx;
|
||
display: flex;
|
||
align-items: center;
|
||
}
|
||
|
||
.dash-line {
|
||
flex: 1;
|
||
margin: 0 20rpx;
|
||
border-top: 2rpx dashed $yjyf-border-color;
|
||
}
|
||
|
||
.notch {
|
||
position: absolute;
|
||
top: 0;
|
||
width: 20rpx;
|
||
height: 20rpx;
|
||
border-radius: $yjyf-radius-pill;
|
||
background: $yjyf-bg-page;
|
||
}
|
||
|
||
.notch-l {
|
||
left: -10rpx;
|
||
}
|
||
|
||
.notch-r {
|
||
right: -10rpx;
|
||
}
|
||
|
||
.ord-lower {
|
||
padding: 12rpx $yjyf-space-md 18rpx;
|
||
display: flex;
|
||
align-items: baseline;
|
||
justify-content: space-between;
|
||
transition: background-color 0.18s ease;
|
||
}
|
||
|
||
.ord-meta {
|
||
font-size: $yjyf-font-micro;
|
||
color: $yjyf-text-muted;
|
||
font-variant-numeric: tabular-nums;
|
||
overflow: hidden;
|
||
text-overflow: ellipsis;
|
||
white-space: nowrap;
|
||
margin-right: $yjyf-space-sm;
|
||
}
|
||
|
||
.ord-amt-box {
|
||
display: flex;
|
||
align-items: baseline;
|
||
flex-shrink: 0;
|
||
}
|
||
|
||
.amt-sym {
|
||
font-size: $yjyf-font-micro;
|
||
font-weight: 700;
|
||
color: $yjyf-primary;
|
||
margin-right: 2rpx;
|
||
}
|
||
|
||
.amt-int {
|
||
font-size: $yjyf-font-title;
|
||
font-weight: 700;
|
||
color: $yjyf-primary;
|
||
font-variant-numeric: tabular-nums;
|
||
}
|
||
|
||
.amt-dec {
|
||
font-size: $yjyf-font-micro;
|
||
font-weight: 700;
|
||
color: $yjyf-primary;
|
||
font-variant-numeric: tabular-nums;
|
||
}
|
||
|
||
.list-foot {
|
||
padding: $yjyf-space-md 0;
|
||
text-align: center;
|
||
}
|
||
|
||
.foot-txt {
|
||
font-size: $yjyf-font-micro;
|
||
color: $yjyf-text-muted;
|
||
}
|
||
|
||
.state-box {
|
||
padding: 150rpx $yjyf-space-lg;
|
||
display: flex;
|
||
flex-direction: column;
|
||
align-items: center;
|
||
}
|
||
|
||
.empty-ico {
|
||
width: 168rpx;
|
||
height: 168rpx;
|
||
margin-bottom: $yjyf-space-md;
|
||
}
|
||
|
||
.state-title {
|
||
font-size: $yjyf-font-title;
|
||
font-weight: 600;
|
||
color: $yjyf-text-main;
|
||
}
|
||
|
||
.state-desc {
|
||
font-size: $yjyf-font-sub;
|
||
color: $yjyf-text-secondary;
|
||
margin-top: $yjyf-space-xs;
|
||
}
|
||
|
||
.state-txt {
|
||
font-size: $yjyf-font-sub;
|
||
color: $yjyf-text-secondary;
|
||
}
|
||
|
||
.ghost-btn,
|
||
.retry-btn {
|
||
margin-top: $yjyf-space-lg;
|
||
height: 72rpx;
|
||
padding: 0 $yjyf-space-xl;
|
||
border-radius: $yjyf-radius-pill;
|
||
border: 2rpx solid $yjyf-primary;
|
||
background: $yjyf-bg-card;
|
||
color: $yjyf-primary;
|
||
font-size: $yjyf-font-sub;
|
||
font-weight: 600;
|
||
display: inline-flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
}
|
||
|
||
.bottom-bar {
|
||
position: fixed;
|
||
left: 0;
|
||
right: 0;
|
||
bottom: 0;
|
||
background: rgba(255, 255, 255, 0.95);
|
||
backdrop-filter: blur(16px);
|
||
border-top: 1rpx solid $yjyf-border-color;
|
||
box-shadow: $yjyf-shadow-bar;
|
||
padding: 20rpx $yjyf-space-lg calc(20rpx + env(safe-area-inset-bottom));
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: space-between;
|
||
z-index: 20;
|
||
}
|
||
|
||
.select-all {
|
||
min-height: 72rpx;
|
||
display: flex;
|
||
align-items: center;
|
||
padding-right: $yjyf-space-sm;
|
||
}
|
||
|
||
.chk-ico-bar {
|
||
width: 42rpx;
|
||
height: 42rpx;
|
||
margin-right: 12rpx;
|
||
}
|
||
|
||
.all-txt {
|
||
font-size: $yjyf-font-body;
|
||
color: $yjyf-text-main;
|
||
}
|
||
|
||
.bar-right {
|
||
display: flex;
|
||
align-items: center;
|
||
}
|
||
|
||
.sum-info {
|
||
display: flex;
|
||
flex-direction: column;
|
||
align-items: flex-end;
|
||
margin-right: $yjyf-space-md;
|
||
}
|
||
|
||
.sum-line {
|
||
display: flex;
|
||
align-items: baseline;
|
||
}
|
||
|
||
.sum-label {
|
||
font-size: $yjyf-font-sub;
|
||
color: $yjyf-text-regular;
|
||
margin-right: 6rpx;
|
||
}
|
||
|
||
.sum-sym {
|
||
font-size: $yjyf-font-sub;
|
||
font-weight: 700;
|
||
color: $yjyf-primary;
|
||
margin-right: 2rpx;
|
||
}
|
||
|
||
.sum-int {
|
||
font-size: 40rpx;
|
||
font-weight: 700;
|
||
color: $yjyf-primary;
|
||
font-variant-numeric: tabular-nums;
|
||
}
|
||
|
||
.sum-dec {
|
||
font-size: $yjyf-font-body;
|
||
font-weight: 700;
|
||
color: $yjyf-primary;
|
||
font-variant-numeric: tabular-nums;
|
||
}
|
||
|
||
.sum-count {
|
||
font-size: $yjyf-font-micro;
|
||
color: $yjyf-text-secondary;
|
||
margin-top: 2rpx;
|
||
}
|
||
|
||
.next-btn {
|
||
min-width: 216rpx;
|
||
height: 84rpx;
|
||
padding: 0 $yjyf-space-lg;
|
||
border-radius: $yjyf-radius-pill;
|
||
background: $yjyf-gradient-primary;
|
||
box-shadow: $yjyf-shadow-button;
|
||
color: $yjyf-text-inverse;
|
||
font-size: $yjyf-font-body;
|
||
font-weight: 700;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
|
||
&.disabled {
|
||
background: $yjyf-text-disabled;
|
||
box-shadow: none;
|
||
}
|
||
}
|
||
</style>
|