Files
console-dev/app/pages/invoices/index.vue
T
2026-11-06 00:04:38 +08:00

2380 lines
103 KiB
Vue

<script>
import "~/assets/styles/PageInfoNotice._16xRFrB.css";
import "~/assets/styles/PaymentDialog.BNFKQF1U.css";
import "~/assets/styles/invoices.t1P1GXOx.css";
import { toDisplayString } from "vue";
import { renderList } from "vue";
import { onMounted } from "vue";
import { normalizeClass } from "vue";
import { watch } from "vue";
import { createBlock } from "vue";
import { ref } from "vue";
import { withCtx } from "vue";
import { createCommentVNode } from "vue";
import { computed } from "vue";
import { reactive } from "vue";
import { isRef } from "vue";
import { createElementBlock } from "vue";
import { Fragment } from "vue";
import { createElementVNode } from "vue";
import { createTextVNode } from "vue";
import { unref } from "vue";
import { defineComponent } from "vue";
import { createVNode } from "vue";
import { openBlock } from "vue";
import { useRoute } from "#app";
import { useRouter } from "#app";
import { NuxtLink } from "#components";
import { sanitizeMessage } from "~/lib/auth.js";
import { useApi } from "~/lib/auth.js";
import dialog from "primevue/dialog";
import button from "primevue/button";
import { t as _plugin_vue_export_helper_t } from "~/lib/_plugin-vue_export-helper.js";
import message from "primevue/message";
import { n as product_name_n } from "~/lib/product-name.js";
import { n as dict_n } from "~/lib/dict.js";
import { r as dict_r } from "~/lib/dict.js";
import { s as dict_s } from "~/lib/dict.js";
import datatable from "primevue/datatable";
import paginator from "primevue/paginator";
import select from "primevue/select";
import checkbox from "primevue/checkbox";
import column from "primevue/column";
import ListEmpty from "~/components/ListEmpty.vue";
import PaymentDialog from "~/components/PaymentDialog.vue";
import { t as useListPage_t } from "~/lib/useListPage.js";
import tag from "primevue/tag";
import PageInfoNotice from "~/components/PageInfoNotice.vue";
import { t as invoice_t } from "~/lib/invoice.js";
var Ce = {
class: `list-page`,
},
we = {
class: `list-head`,
},
Te = {
class: `list-head-actions`,
},
Ee = {
class: `list-table`,
},
De = {
class: `invoice-row-actions`,
},
Oe = {
key: 2,
class: `list-foot`,
},
ke = {
key: 1,
class: `request-page`,
},
Ae = {
class: `apply`,
},
je = {
key: 0,
role: `status`,
"aria-live": `polite`,
},
Me = {
class: `apply-section`,
},
Ne = {
class: `list-table`,
},
Pe = {
class: `apply-grid`,
},
Fe = {
class: `field`,
},
Ie = {
class: `field`,
},
Le = {
class: `field`,
},
Re = {
key: 0,
class: `field`,
},
ze = {
class: `field`,
},
Be = {
key: 1,
class: `field`,
},
Ve = {
class: `request-actions`,
},
He = {
key: 0,
},
Ue = {
key: 1,
},
We = {
class: `apply`,
},
Ge = {
key: 0,
role: `status`,
"aria-live": `polite`,
},
Ke = {
class: `apply-section`,
},
qe = {
key: 0,
class: `order-list`,
},
Je = {
class: `order-main`,
},
Ye = {
class: `order-title`,
},
Xe = {
class: `order-time`,
},
Ze = {
class: `order-amount`,
},
Qe = {
key: 1,
class: `no-data`,
},
$e = {
class: `apply-grid`,
},
et = {
class: `field`,
},
tt = {
class: `field`,
},
nt = {
class: `field`,
},
rt = {
key: 0,
class: `field`,
},
it = {
class: `field`,
},
at = {
key: 1,
class: `field`,
},
ot = {
key: 6,
class: `price-breakdown`,
},
st = {
key: 0,
},
ct = {
key: 1,
},
lt = {
class: `total-tip`,
},
x = _plugin_vue_export_helper_t(
defineComponent({
__name: `index`,
setup(g) {
let y = useApi(),
x = useRouter(),
ut = useRoute(),
S = computed(() => ut.path === `/invoices/request`),
dt = {
pending: {
label: `待审核`,
severity: `warn`,
},
approved: {
label: `已审核`,
severity: `info`,
},
rejected: {
label: `已驳回`,
severity: `danger`,
},
issued: {
label: `已开具`,
severity: `success`,
},
sent: {
label: `已寄出`,
severity: `success`,
},
cancel: {
label: `已取消`,
severity: `secondary`,
},
unpaid: {
label: `待支付`,
severity: `warn`,
},
wait_create: {
label: `待开具`,
severity: `info`,
},
creating: {
label: `开具中`,
severity: `info`,
},
create_fail: {
label: `开具失败`,
severity: `danger`,
},
reject: {
label: `已驳回`,
severity: `danger`,
},
wait_send: {
label: `待寄出`,
severity: `info`,
},
flushed: {
label: `已冲红`,
severity: `secondary`,
},
},
{
list: ft,
total: pt,
loading: mt,
error: ht,
page: gt,
limit: C,
load: w,
onPage: _t,
} = useListPage_t(`/invoice`, {
limit: 15,
}),
T = ref(!1),
E = ref(!1),
D = ref(!1),
O = ref(!1),
k = ref(``),
A = ref(!1),
j = ref(``),
M = ref(null),
N = ref(``),
P = ref(0),
F = ref(!1),
vt = ref(null),
I = ref(null),
L = ref(``),
yt = ref([]),
R = ref([]),
z = ref([]),
bt = ref([]),
B = ref({}),
V = reactive({
order_id: [],
invoice_title_id: null,
invoice_address_id: null,
invoice_project_id: null,
invoice_format: `pdf`,
parcel_id: null,
tax_rate: ``,
}),
H = computed(() =>
(Array.isArray(B.value.parcel) ? B.value.parcel : []).flatMap(
(e) => {
if (!e || typeof e != `object`) return [];
let t = e,
n = Number(t.id ?? t.parcel_id);
return !Number.isInteger(n) || n <= 0
? []
: [
{
id: n,
label: String(
t.name ?? t.title ?? t.parcel_name ?? `快递 #${n}`,
),
price: t.price ?? t.amount,
},
];
},
),
),
U = computed(() => X.value?.rec_type === `paper`),
xt = computed(() => R.value.find((e) => e.id === V.invoice_title_id)),
W = computed(() =>
bt.value
.filter(
(e) =>
xt.value?.invoice_type !== `special` ||
Number(e.special_tax_switch) === 1,
)
.map((e) => ({
...e,
label: `${e.name}${e.tax_included === void 0 ? `` : Number(e.tax_included) === 1 ? `(含税)` : `(不含税)`}`,
})),
),
G = computed(() => {
let e =
xt.value?.invoice_type === `special`
? B.value.special_tax_rate
: B.value.normal_tax_rate;
return Array.isArray(e)
? [
...new Set(
e
.filter(
(e) =>
String(e).trim() !== `` &&
Number.isFinite(Number(e)) &&
Number(e) >= 0,
)
.map(String),
),
].map((e) => ({
value: e,
label: `${e}%`,
}))
: [];
}),
St = computed(() =>
z.value.filter(
(e) =>
![`ofd`, `xml`].includes(V.invoice_format) ||
e.rec_type === `email`,
),
),
Ct = computed(() =>
U.value
? [
{
label: `纸质发票`,
value: ``,
},
]
: [
{
label: `PDF`,
value: `pdf`,
},
{
label: `OFD`,
value: `ofd`,
},
{
label: `XML`,
value: `xml`,
},
],
),
K = computed(
() =>
[
`invoice_manage`,
`tax_rate`,
`normal_tax_rate`,
`special_tax_rate`,
].some((e) => Object.prototype.hasOwnProperty.call(B.value, e)) ||
H.value.length > 0,
),
wt = computed(() =>
!O.value || Z.value || A.value
? !1
: !K.value || (!!M.value && N.value === q.value),
),
q = computed(() =>
JSON.stringify({
order: [...V.order_id].sort((e, t) => e - t),
title: V.invoice_title_id,
address: V.invoice_address_id,
project: V.invoice_project_id,
format: V.invoice_format,
parcel: V.parcel_id,
tax: V.tax_rate,
}),
);
async function J() {
if (!(D.value || E.value)) {
((T.value = !0),
(k.value = ``),
(D.value = !0),
(O.value = !1),
(yt.value = []),
(R.value = []),
(z.value = []),
(bt.value = []),
(V.order_id = []),
(V.invoice_title_id = null),
(V.invoice_address_id = null),
(V.invoice_project_id = null),
(V.parcel_id = null),
(V.tax_rate = ``),
(M.value = null),
(N.value = ``),
(j.value = ``));
try {
let [e, t, n, r, i] = await Promise.all([
invoice_t((e, t) =>
y.get(`/invoice_request`, {
page: e,
limit: t,
}),
),
invoice_t((e, t) =>
y.get(`/invoice_title`, {
page: e,
limit: t,
}),
),
invoice_t((e, t) =>
y.get(`/invoice_address`, {
page: e,
limit: t,
}),
),
invoice_t((e, t) =>
y.get(`/invoice_project`, {
page: e,
limit: t,
}),
),
y.get(`/invoice_config`),
]);
((yt.value = e),
(R.value = t),
(z.value = n),
(bt.value = r),
(B.value = i ?? {}),
(V.invoice_title_id = R.value.find((e) => e.id)?.id ?? null),
(V.invoice_address_id =
z.value.find((e) => e.rec_type === `email`)?.id ??
z.value[0]?.id ??
null),
(V.invoice_project_id = W.value[0]?.id ?? null),
(V.tax_rate = G.value[0]?.value ?? ``),
(V.parcel_id = H.value[0]?.id ?? null),
(O.value = !0),
await Q());
} catch (e) {
k.value = e instanceof Error ? e.message : `加载开票数据失败`;
} finally {
D.value = !1;
}
}
}
let Y = computed(() =>
yt.value.filter((e) => {
let t = e.status === `Paid`,
n = e.status === `Unpaid` && Number(B.value.pre_invoice) === 1;
return (!t && !n) ||
Number(e.invoice_enabled) === 0 ||
Number(e.invoice_id) > 0
? !1
: (e.is_cross_year !== !0 &&
e.is_cross_year !== `true` &&
Number(e.is_cross_year) !== 1) ||
Number(B.value.across_year_invoice) === 1;
}),
),
X = computed(() =>
z.value.find((e) => e.id === V.invoice_address_id),
),
Tt = (e) =>
e.is_cross_year === !0 ||
e.is_cross_year === `true` ||
Number(e.is_cross_year) === 1,
Z = computed(() => {
if (!V.order_id.length) return `请选择要开票的订单`;
let e = V.order_id.map((e) => Y.value.find((t) => t.id === e));
if (e.some((e) => !e))
return `所选订单已失效或不符合当前开票条件,请重新选择`;
let t = e;
return t.some(Tt) && t.some((e) => !Tt(e))
? `跨年订单与本年订单不能混合开票,请分开申请`
: t.some(
(e) =>
!Number.isFinite(Number(e.amount)) ||
Number(e.amount) < 0,
)
? `所选订单金额无效,请重新加载`
: xt.value
? W.value.some((e) => e.id === V.invoice_project_id)
? G.value.length &&
!G.value.some((e) => e.value === V.tax_rate)
? `请选择当前抬头支持的税率`
: X.value
? U.value && V.invoice_format !== ``
? `纸质收票地址不支持电子发票格式`
: !U.value &&
![`pdf`, `ofd`, `xml`].includes(V.invoice_format)
? `请选择有效的电子发票格式`
: K.value &&
U.value &&
!H.value.some((e) => e.id === V.parcel_id)
? `请选择有效的快递方式`
: ``
: `请选择有效的收票地址`
: `请选择当前抬头支持的开票项目`
: `请选择有效的发票抬头`;
});
async function Q() {
let e = ++P.value;
if (
((M.value = null),
(N.value = ``),
(j.value = ``),
!K.value || !O.value || Z.value)
) {
A.value = !1;
return;
}
let t = q.value;
((A.value = !0), (j.value = ``));
try {
let n = await y.post(`/invoice/price`, {
invoice_title_id: V.invoice_title_id,
invoice_address_id: V.invoice_address_id,
invoice_project_id: V.invoice_project_id,
invoice_format: V.invoice_format,
parcel_id: V.parcel_id ?? ``,
tax_rate: V.tax_rate,
order_id: [...new Set(V.order_id)],
rec_type: X.value?.rec_type,
});
if (e !== P.value || t !== q.value) return;
let r = n;
if (
!r ||
r.total === void 0 ||
[r.total, r.price, r.tax_price, r.parcel_price].some(
(e) =>
e !== void 0 &&
(e === null ||
String(e).trim() === `` ||
!Number.isFinite(Number(e)) ||
Number(e) < 0),
)
)
throw Error(`未获得有效的发票费用报价,请重试`);
((M.value = r), (N.value = t));
} catch (n) {
if (e !== P.value || t !== q.value) return;
((M.value = null),
(N.value = ``),
(j.value =
n instanceof Error ? n.message : `发票费用报价失败,请重试`));
} finally {
e === P.value && (A.value = !1);
}
}
let $ = computed(() => {
let e = new Set(V.order_id);
return Y.value
.filter((t) => e.has(t.id))
.reduce((e, t) => e + Number(t.amount || 0), 0)
.toFixed(2);
});
async function Et() {
if (E.value || D.value || !O.value) return;
if (((k.value = ``), Z.value)) {
k.value = Z.value;
return;
}
if (!V.order_id.length) {
k.value = `请选择要开票的订单`;
return;
}
let e = new Set(Y.value.map((e) => e.id));
if (V.order_id.some((t) => !e.has(t))) {
k.value = `所选订单已失效或不符合当前开票条件,请重新选择`;
return;
}
if (!V.invoice_title_id) {
k.value = `请选择发票抬头(无抬头可先在发票设置中添加)`;
return;
}
if (!X.value) {
k.value = `请选择收票地址(无地址可先在发票设置中添加)`;
return;
}
if (K.value && U.value && !V.parcel_id) {
k.value = `请选择快递方式`;
return;
}
if (K.value && !wt.value) {
((k.value = j.value || `请先获取最新费用报价`), await Q());
return;
}
E.value = !0;
try {
let e = await y.post(`/invoice`, {
invoice_title_id: V.invoice_title_id,
invoice_address_id: V.invoice_address_id,
invoice_project_id: V.invoice_project_id,
order_id: [...new Set(V.order_id)],
rec_type: X.value.rec_type,
invoice_format: V.invoice_format,
parcel_id: V.parcel_id ?? ``,
tax_rate: V.tax_rate,
});
((O.value = !1), (T.value = !1), await w());
let t = e?.data && typeof e.data == `object` ? e.data : e,
n = t?.id ?? t?.order_id ?? t?.invoice_order_id;
Dt(n)
? ((vt.value = n), (F.value = !0))
: S.value && x.push(`/invoices`);
} catch (e) {
k.value = e instanceof Error ? e.message : `申请失败`;
} finally {
E.value = !1;
}
}
function Dt(e) {
return (
(typeof e == `string` || typeof e == `number`) &&
/^[1-9]\d*$/.test(String(e))
);
}
function Ot(e) {
return (
Dt(e.invoice_order_id) &&
[`Unpaid`, `WaitUpload`, `WaitReview`, `ReviewFail`].includes(
e.order_status || ``,
)
);
}
function kt(e) {
if (Ot(e)) {
if (e.order_status !== `Unpaid`) {
x.push(`/orders/${e.invoice_order_id}`);
return;
}
((vt.value = e.invoice_order_id), (F.value = !0));
}
}
function At() {
((F.value = !1), S.value ? x.push(`/invoices`) : w());
}
function jt(e) {
!e && S.value && !O.value && x.push(`/invoices`);
}
let Mt = new Set([
`pending`,
`reject`,
`rejected`,
`unpaid`,
`wait_create`,
`create_fail`,
]);
function Nt(e) {
return Mt.has(String(e.status || ``).toLowerCase());
}
async function Pt(e) {
if (
Nt(e) &&
I.value === null &&
(typeof window > `u` ||
window.confirm(`确定撤回并删除这条发票申请吗?`))
) {
((I.value = e.id), (L.value = ``));
try {
(await y.del(`/invoice/${e.id}`), await w());
} catch (e) {
L.value = e instanceof Error ? e.message : `删除发票失败,请重试`;
} finally {
I.value = null;
}
}
}
return (
onMounted(() => {
S.value ? J() : w();
}),
watch(
() => V.invoice_title_id,
() => {
(W.value.some((e) => e.id === V.invoice_project_id) ||
(V.invoice_project_id = W.value[0]?.id ?? null),
G.value.some((e) => e.value === V.tax_rate) ||
(V.tax_rate = G.value[0]?.value ?? ``));
},
{
flush: `sync`,
},
),
watch(
() => X.value?.rec_type,
(e) => {
e === `paper`
? (V.invoice_format = ``)
: e === `email` &&
!V.invoice_format &&
(V.invoice_format = `pdf`);
},
{
flush: `sync`,
},
),
watch(
() => V.invoice_format,
(e) => {
[`ofd`, `xml`].includes(e) &&
X.value?.rec_type !== `email` &&
(V.invoice_address_id =
z.value.find(
(e) => e.rec_type === `email` && Number(e.is_default) === 1,
)?.id ??
z.value.find((e) => e.rec_type === `email`)?.id ??
null);
},
{
flush: `sync`,
},
),
watch(q, () => {
O.value && Q();
}),
(n, i) => {
let o = NuxtLink,
l = PageInfoNotice,
u = button,
g = column,
te = tag,
ne = ListEmpty,
ae = datatable,
y = message,
be = paginator,
b = checkbox,
x = select,
ut = dialog,
w = PaymentDialog;
return (
openBlock(),
createElementBlock(`div`, Ce, [
createVNode(
l,
{
class: `invoice-guide`,
"aria-label": `发票申请指南`,
},
{
default: withCtx(() => [
(i[18] ||= createTextVNode(
` 申请发票前,请先设置好 `,
-1,
)),
createVNode(
o,
{
to: `/invoices/settings`,
},
{
default: withCtx(() => [
...(i[17] ||= [
createTextVNode(`发票抬头与收件地址`, -1),
]),
]),
_: 1,
},
),
(i[19] ||= createTextVNode(
`。提交申请后,可在发票列表查看审核和交付进度。 `,
-1,
)),
]),
_: 1,
},
),
unref(S)
? createCommentVNode(``, !0)
: (openBlock(),
createElementBlock(
Fragment,
{
key: 0,
},
[
createElementVNode(`div`, we, [
(i[22] ||= createElementVNode(
`h2`,
null,
`发票`,
-1,
)),
createElementVNode(`div`, Te, [
createVNode(
u,
{
"as-child": ``,
icon: `pi pi-cog`,
label: `发票设置`,
severity: `secondary`,
outlined: ``,
},
{
default: withCtx((e) => [
createVNode(
o,
{
to: `/invoices/settings`,
class: normalizeClass(e.class),
},
{
default: withCtx(() => [
...(i[20] ||= [
createElementVNode(
`i`,
{
class: `pi pi-cog`,
},
null,
-1,
),
createTextVNode(` 发票设置`, -1),
]),
]),
_: 1,
},
8,
[`class`],
),
]),
_: 1,
},
),
createVNode(
u,
{
"as-child": ``,
},
{
default: withCtx((e) => [
createVNode(
o,
{
to: `/invoices/request`,
class: normalizeClass(e.class),
},
{
default: withCtx(() => [
...(i[21] ||= [
createElementVNode(
`i`,
{
class: `pi pi-plus`,
},
null,
-1,
),
createTextVNode(` 申请发票`, -1),
]),
]),
_: 1,
},
8,
[`class`],
),
]),
_: 1,
},
),
]),
]),
createElementVNode(`div`, Ee, [
createVNode(
ae,
{
value: unref(ft),
loading: unref(mt),
lazy: ``,
rows: unref(C),
totalRecords: unref(pt),
first: (unref(gt) - 1) * unref(C),
dataKey: `id`,
},
{
empty: withCtx(() => [
createVNode(ne, {
icon: `pi pi-print`,
title: `还没有发票`,
description: `点击右上角「申请开票」提交申请`,
}),
]),
default: withCtx(() => [
createVNode(
g,
{
header: `项目`,
style: {
"min-width": `160px`,
},
},
{
body: withCtx(({ data: t }) => [
createVNode(
o,
{
to: `/invoices/invoice?id=${t.id}`,
class: `invoice-link`,
},
{
default: withCtx(() => [
createTextVNode(
toDisplayString(
t.invoice_project ||
`发票 #${t.id}`,
),
1,
),
]),
_: 2,
},
1032,
[`to`],
),
]),
_: 1,
},
),
createVNode(
g,
{
header: `发票抬头`,
style: {
"min-width": `210px`,
},
},
{
body: withCtx(({ data: t }) => [
createTextVNode(
toDisplayString(t.title || `—`),
1,
),
]),
_: 1,
},
),
createVNode(
g,
{
header: `收件地址`,
style: {
"min-width": `160px`,
},
},
{
body: withCtx(({ data: t }) => [
createTextVNode(
toDisplayString(
t.email || t.address || `—`,
),
1,
),
]),
_: 1,
},
),
createVNode(
g,
{
header: `格式`,
style: {
width: `80px`,
},
},
{
body: withCtx(({ data: t }) => [
createTextVNode(
toDisplayString(
t.invoice_format || `—`,
),
1,
),
]),
_: 1,
},
),
createVNode(
g,
{
header: `申请时间`,
style: {
"min-width": `130px`,
},
},
{
body: withCtx(({ data: t }) => [
createTextVNode(
toDisplayString(
(`formatDate` in n
? n.formatDate
: unref(dict_n))(t.create_time),
),
1,
),
]),
_: 1,
},
),
createVNode(
g,
{
header: `状态`,
style: {
"min-width": `110px`,
},
},
{
body: withCtx(({ data: e }) => [
createVNode(
te,
{
value:
e.invoice_project ===
`历史已开票登记`
? `历史已开票登记`
: dt[e.status]?.label || e.status,
severity:
dt[e.status]?.severity ||
`secondary`,
},
null,
8,
[`value`, `severity`],
),
]),
_: 1,
},
),
createVNode(
g,
{
header: `驳回原因`,
style: {
"min-width": `110px`,
},
},
{
body: withCtx(({ data: t }) => [
createTextVNode(
toDisplayString(
unref(sanitizeMessage)(
t.reject_reason,
),
),
1,
),
]),
_: 1,
},
),
createVNode(
g,
{
header: `含税金额`,
style: {
"min-width": `130px`,
},
},
{
body: withCtx(({ data: t }) => [
createElementVNode(
`b`,
null,
`¥` + toDisplayString(t.price),
1,
),
]),
_: 1,
},
),
createVNode(
g,
{
header: `操作`,
style: {
"min-width": `180px`,
},
},
{
body: withCtx(({ data: e }) => [
createElementVNode(`div`, De, [
createVNode(
u,
{
"as-child": ``,
text: ``,
severity: `secondary`,
},
{
default: withCtx((t) => [
createVNode(
o,
{
to: `/invoices/invoice?id=${e.id}`,
class: normalizeClass(
t.class,
),
"aria-label": `查看发票 ${e.id}`,
},
{
default: withCtx(() => [
...(i[23] ||= [
createElementVNode(
`i`,
{
class: `pi pi-file`,
},
null,
-1,
),
]),
]),
_: 1,
},
8,
[`to`, `class`, `aria-label`],
),
]),
_: 2,
},
1024,
),
Ot(e)
? (openBlock(),
createBlock(
u,
{
key: 0,
label:
e.order_status === `Unpaid`
? `支付费用`
: `查看付款`,
text: ``,
size: `small`,
disabled: unref(I) !== null,
onClick: (t) => kt(e),
},
null,
8,
[`label`, `disabled`, `onClick`],
))
: createCommentVNode(``, !0),
Nt(e)
? (openBlock(),
createBlock(
u,
{
key: 1,
label: `撤回`,
icon: `pi pi-trash`,
text: ``,
severity: `danger`,
size: `small`,
loading: unref(I) === e.id,
disabled: unref(I) !== null,
onClick: (t) => Pt(e),
},
null,
8,
[
`loading`,
`disabled`,
`onClick`,
],
))
: createCommentVNode(``, !0),
]),
]),
_: 1,
},
),
]),
_: 1,
},
8,
[
`value`,
`loading`,
`rows`,
`totalRecords`,
`first`,
],
),
]),
unref(ht)
? (openBlock(),
createBlock(
y,
{
key: 0,
severity: `error`,
closable: !1,
},
{
default: withCtx(() => [
createTextVNode(
toDisplayString(unref(ht)),
1,
),
]),
_: 1,
},
))
: createCommentVNode(``, !0),
unref(L)
? (openBlock(),
createBlock(
y,
{
key: 1,
severity: `error`,
closable: !1,
},
{
default: withCtx(() => [
createTextVNode(toDisplayString(unref(L)), 1),
]),
_: 1,
},
))
: createCommentVNode(``, !0),
unref(pt) > 0
? (openBlock(),
createElementBlock(`div`, Oe, [
(i[24] ||= createElementVNode(
`div`,
{
class: `list-bulk`,
},
null,
-1,
)),
createVNode(
be,
{
rows: unref(C),
totalRecords: unref(pt),
first: (unref(gt) - 1) * unref(C),
rowsPerPageOptions: [15, 30, 50],
onPage: unref(_t),
},
null,
8,
[`rows`, `totalRecords`, `first`, `onPage`],
),
]))
: createCommentVNode(``, !0),
],
64,
)),
unref(S)
? (openBlock(),
createElementBlock(`section`, ke, [
(i[36] ||= createElementVNode(
`h2`,
null,
`申请发票`,
-1,
)),
(i[37] ||= createTextVNode()),
createElementVNode(`div`, Ae, [
unref(D)
? (openBlock(),
createElementBlock(`div`, je, `正在加载开票资料…`))
: unref(O)
? createCommentVNode(``, !0)
: (openBlock(),
createBlock(u, {
key: 1,
label: `重新加载开票资料`,
icon: `pi pi-refresh`,
severity: `secondary`,
outlined: ``,
onClick: J,
})),
unref(O)
? (openBlock(),
createElementBlock(
Fragment,
{
key: 2,
},
[
createElementVNode(`div`, Me, [
(i[25] ||= createElementVNode(
`div`,
{
class: `section-label`,
},
`选择订单`,
-1,
)),
createElementVNode(`div`, Ne, [
createVNode(
ae,
{
value: unref(Y),
dataKey: `id`,
},
{
empty: withCtx(() => [
createVNode(ne, {
icon: `pi pi-receipt`,
title: `暂无符合当前开票条件的订单`,
}),
]),
default: withCtx(() => [
createVNode(
g,
{
header: ``,
style: {
width: `42px`,
},
},
{
body: withCtx(({ data: e }) => [
createVNode(
b,
{
modelValue:
unref(V).order_id,
"onUpdate:modelValue":
(i[0] ||= (e) =>
(unref(V).order_id =
e)),
value: e.id,
"aria-label": `选择订单 ${e.id}`,
},
null,
8,
[
`modelValue`,
`value`,
`aria-label`,
],
),
]),
_: 1,
},
),
createVNode(
g,
{
header: `下单时间`,
},
{
body: withCtx(({ data: t }) => [
createTextVNode(
toDisplayString(
(`formatTime` in n
? n.formatTime
: unref(dict_r))(
t.create_time,
),
),
1,
),
]),
_: 1,
},
),
createVNode(
g,
{
header: `订单 ID`,
},
{
body: withCtx(({ data: t }) => [
createTextVNode(
`#` + toDisplayString(t.id),
1,
),
]),
_: 1,
},
),
createVNode(
g,
{
header: `类型`,
},
{
body: withCtx(({ data: t }) => [
createTextVNode(
toDisplayString(
(`orderTypeLabel` in n
? n.orderTypeLabel
: unref(dict_s))(t.type),
),
1,
),
]),
_: 1,
},
),
createVNode(
g,
{
header: `商品`,
},
{
body: withCtx(({ data: t }) => [
createTextVNode(
toDisplayString(
(t.host || [])
.map((e) =>
unref(product_name_n)(
e.product_name,
),
)
.join(`、`) || `—`,
),
1,
),
]),
_: 1,
},
),
createVNode(
g,
{
header: `金额`,
},
{
body: withCtx(({ data: t }) => [
createElementVNode(
`b`,
null,
`¥` +
toDisplayString(t.amount),
1,
),
]),
_: 1,
},
),
]),
_: 1,
},
8,
[`value`],
),
]),
]),
createElementVNode(`div`, Pe, [
createElementVNode(`div`, Fe, [
(i[27] ||= createElementVNode(
`label`,
null,
`发票抬头`,
-1,
)),
createVNode(
x,
{
modelValue: unref(V).invoice_title_id,
"onUpdate:modelValue": (i[1] ||= (e) =>
(unref(V).invoice_title_id = e)),
options: unref(R),
optionLabel: `title`,
optionValue: `id`,
placeholder: `请选择抬头`,
fluid: ``,
},
null,
8,
[`modelValue`, `options`],
),
unref(R).length
? createCommentVNode(``, !0)
: (openBlock(),
createBlock(
o,
{
key: 0,
to: `/invoices/settings`,
class: `field-tip`,
},
{
default: withCtx(() => [
...(i[26] ||= [
createTextVNode(
`去添加抬头`,
-1,
),
]),
]),
_: 1,
},
)),
]),
createElementVNode(`div`, Ie, [
(i[29] ||= createElementVNode(
`label`,
null,
`收票地址`,
-1,
)),
createVNode(
x,
{
modelValue: unref(V).invoice_address_id,
"onUpdate:modelValue": (i[2] ||= (e) =>
(unref(V).invoice_address_id = e)),
options: unref(St),
optionLabel: (e) =>
e.rec_name ||
e.email ||
e.address ||
`地址 #${e.id}`,
optionValue: `id`,
placeholder: `请选择地址`,
fluid: ``,
},
null,
8,
[`modelValue`, `options`, `optionLabel`],
),
unref(z).length
? createCommentVNode(``, !0)
: (openBlock(),
createBlock(
o,
{
key: 0,
to: `/invoices/settings`,
class: `field-tip`,
},
{
default: withCtx(() => [
...(i[28] ||= [
createTextVNode(
`去添加地址`,
-1,
),
]),
]),
_: 1,
},
)),
]),
createElementVNode(`div`, Le, [
(i[30] ||= createElementVNode(
`label`,
null,
`开票项目`,
-1,
)),
createVNode(
x,
{
modelValue: unref(V).invoice_project_id,
"onUpdate:modelValue": (i[3] ||= (e) =>
(unref(V).invoice_project_id = e)),
options: unref(W),
optionLabel: `label`,
optionValue: `id`,
placeholder: `请选择项目`,
fluid: ``,
},
null,
8,
[`modelValue`, `options`],
),
]),
unref(G).length
? (openBlock(),
createElementBlock(`div`, Re, [
(i[31] ||= createElementVNode(
`label`,
null,
`税率`,
-1,
)),
createVNode(
x,
{
modelValue: unref(V).tax_rate,
"onUpdate:modelValue": (i[4] ||= (
e,
) => (unref(V).tax_rate = e)),
options: unref(G),
"option-label": `label`,
"option-value": `value`,
placeholder: `请选择税率`,
fluid: ``,
},
null,
8,
[`modelValue`, `options`],
),
]))
: createCommentVNode(``, !0),
createElementVNode(`div`, ze, [
(i[32] ||= createElementVNode(
`label`,
null,
`发票格式`,
-1,
)),
createVNode(
x,
{
modelValue: unref(V).invoice_format,
"onUpdate:modelValue": (i[5] ||= (e) =>
(unref(V).invoice_format = e)),
options: unref(Ct),
optionLabel: `label`,
optionValue: `value`,
fluid: ``,
},
null,
8,
[`modelValue`, `options`],
),
]),
unref(U)
? (openBlock(),
createElementBlock(`div`, Be, [
(i[33] ||= createElementVNode(
`label`,
null,
`快递方式`,
-1,
)),
createVNode(
x,
{
modelValue: unref(V).parcel_id,
"onUpdate:modelValue": (i[6] ||= (
e,
) => (unref(V).parcel_id = e)),
options: unref(H),
"option-label": `label`,
"option-value": `id`,
placeholder: `请选择快递方式`,
fluid: ``,
},
null,
8,
[`modelValue`, `options`],
),
]))
: createCommentVNode(``, !0),
]),
],
64,
))
: createCommentVNode(``, !0),
unref(k)
? (openBlock(),
createBlock(
y,
{
key: 3,
severity: `error`,
closable: !1,
},
{
default: withCtx(() => [
createTextVNode(toDisplayString(unref(k)), 1),
]),
_: 1,
},
))
: unref(V).order_id.length && unref(Z)
? (openBlock(),
createBlock(
y,
{
key: 4,
severity: `warn`,
closable: !1,
},
{
default: withCtx(() => [
createTextVNode(
toDisplayString(unref(Z)),
1,
),
]),
_: 1,
},
))
: createCommentVNode(``, !0),
]),
createElementVNode(`div`, Ve, [
createElementVNode(`span`, null, [
(i[34] ||= createTextVNode(`开票金额:`, -1)),
createElementVNode(
`b`,
null,
`¥` + toDisplayString(unref(M)?.total ?? unref($)),
1,
),
]),
unref(M)?.tax_price
? (openBlock(),
createElementBlock(
`span`,
He,
`含税费 ¥` + toDisplayString(unref(M).tax_price),
1,
))
: createCommentVNode(``, !0),
unref(M)?.parcel_price
? (openBlock(),
createElementBlock(
`span`,
Ue,
`快递费 ¥` +
toDisplayString(unref(M).parcel_price),
1,
))
: createCommentVNode(``, !0),
createVNode(
u,
{
"as-child": ``,
severity: `secondary`,
outlined: ``,
},
{
default: withCtx((e) => [
createVNode(
o,
{
to: `/invoices`,
class: normalizeClass(e.class),
},
{
default: withCtx(() => [
...(i[35] ||= [
createTextVNode(`取消`, -1),
]),
]),
_: 1,
},
8,
[`class`],
),
]),
_: 1,
},
),
createVNode(
u,
{
label: `提交申请`,
icon: `pi pi-check`,
loading: unref(E) || unref(A),
disabled: unref(D) || !unref(O) || !unref(wt),
onClick: Et,
},
null,
8,
[`loading`, `disabled`],
),
]),
unref(j)
? (openBlock(),
createBlock(
y,
{
key: 0,
severity: `warn`,
closable: !1,
},
{
default: withCtx(() => [
createTextVNode(
toDisplayString(unref(j)) + ` `,
1,
),
createVNode(u, {
label: `重试报价`,
text: ``,
size: `small`,
onClick: Q,
}),
]),
_: 1,
},
))
: createCommentVNode(``, !0),
]))
: createCommentVNode(``, !0),
unref(S)
? createCommentVNode(``, !0)
: (openBlock(),
createBlock(
ut,
{
key: 2,
visible: unref(T),
"onUpdate:visible": (i[15] ||= (e) =>
isRef(T) ? (T.value = e) : null),
header: `申请开票`,
modal: ``,
draggable: !1,
style: {
width: `min(680px, calc(100vw - 28px))`,
},
},
{
footer: withCtx(() => [
createElementVNode(`span`, lt, [
(i[47] ||= createTextVNode(`开票金额:`, -1)),
createElementVNode(
`b`,
null,
`¥` +
toDisplayString(unref(M)?.total ?? unref($)),
1,
),
]),
createVNode(u, {
label: `取消`,
severity: `secondary`,
text: ``,
onClick: (i[14] ||= (e) => (T.value = !1)),
}),
createVNode(
u,
{
label: `提交申请`,
loading: unref(E) || unref(A),
disabled: unref(D) || !unref(O) || !unref(wt),
onClick: Et,
},
null,
8,
[`loading`, `disabled`],
),
]),
default: withCtx(() => [
createElementVNode(`div`, We, [
unref(D)
? (openBlock(),
createElementBlock(
`div`,
Ge,
`正在加载开票资料…`,
))
: unref(O)
? createCommentVNode(``, !0)
: (openBlock(),
createBlock(u, {
key: 1,
label: `重新加载开票资料`,
icon: `pi pi-refresh`,
severity: `secondary`,
outlined: ``,
onClick: J,
})),
unref(O)
? (openBlock(),
createElementBlock(
Fragment,
{
key: 2,
},
[
createElementVNode(`div`, Ke, [
(i[38] ||= createElementVNode(
`div`,
{
class: `section-label`,
},
`选择订单`,
-1,
)),
unref(Y).length
? (openBlock(),
createElementBlock(`div`, qe, [
(openBlock(!0),
createElementBlock(
Fragment,
null,
renderList(
unref(Y),
(r) => (
openBlock(),
createElementBlock(
`label`,
{
key: r.id,
class: `order-item`,
},
[
createVNode(
b,
{
modelValue:
unref(V).order_id,
"onUpdate:modelValue":
(i[7] ||= (e) =>
(unref(
V,
).order_id = e)),
value: r.id,
},
null,
8,
[`modelValue`, `value`],
),
createElementVNode(
`div`,
Je,
[
createElementVNode(
`span`,
Ye,
[
createTextVNode(
` #` +
toDisplayString(
r.id,
) +
` `,
1,
),
(openBlock(!0),
createElementBlock(
Fragment,
null,
renderList(
r.host || [],
(t) => (
openBlock(),
createElementBlock(
`span`,
{
key: t.id,
class: `order-host`,
},
toDisplayString(
unref(
product_name_n,
)(
t.product_name,
),
),
1,
)
),
),
128,
)),
],
),
createElementVNode(
`span`,
Xe,
toDisplayString(
(`formatDate` in n
? n.formatDate
: unref(
dict_n,
))(
r.create_time,
),
),
1,
),
],
),
createElementVNode(
`span`,
Ze,
`¥` +
toDisplayString(
r.amount,
),
1,
),
],
)
),
),
128,
)),
]))
: (openBlock(),
createElementBlock(
`div`,
Qe,
`暂无符合当前开票条件的订单`,
)),
]),
createElementVNode(`div`, $e, [
createElementVNode(`div`, et, [
(i[40] ||= createElementVNode(
`label`,
null,
`发票抬头`,
-1,
)),
createVNode(
x,
{
modelValue:
unref(V).invoice_title_id,
"onUpdate:modelValue": (i[8] ||= (
e,
) =>
(unref(V).invoice_title_id = e)),
options: unref(R),
optionLabel: `title`,
optionValue: `id`,
placeholder: `请选择抬头`,
fluid: ``,
},
null,
8,
[`modelValue`, `options`],
),
unref(R).length
? createCommentVNode(``, !0)
: (openBlock(),
createBlock(
o,
{
key: 0,
to: `/invoices/settings`,
class: `field-tip`,
},
{
default: withCtx(() => [
...(i[39] ||= [
createTextVNode(
`去添加抬头`,
-1,
),
]),
]),
_: 1,
},
)),
]),
createElementVNode(`div`, tt, [
(i[42] ||= createElementVNode(
`label`,
null,
`收票地址`,
-1,
)),
createVNode(
x,
{
modelValue:
unref(V).invoice_address_id,
"onUpdate:modelValue": (i[9] ||= (
e,
) =>
(unref(V).invoice_address_id =
e)),
options: unref(St),
optionLabel: (e) =>
e.rec_name ||
e.email ||
e.address ||
`地址 #${e.id}`,
optionValue: `id`,
placeholder: `请选择地址`,
fluid: ``,
},
null,
8,
[
`modelValue`,
`options`,
`optionLabel`,
],
),
unref(z).length
? createCommentVNode(``, !0)
: (openBlock(),
createBlock(
o,
{
key: 0,
to: `/invoices/settings`,
class: `field-tip`,
},
{
default: withCtx(() => [
...(i[41] ||= [
createTextVNode(
`去添加地址`,
-1,
),
]),
]),
_: 1,
},
)),
]),
createElementVNode(`div`, nt, [
(i[43] ||= createElementVNode(
`label`,
null,
`开票项目`,
-1,
)),
createVNode(
x,
{
modelValue:
unref(V).invoice_project_id,
"onUpdate:modelValue": (i[10] ||= (
e,
) =>
(unref(V).invoice_project_id =
e)),
options: unref(W),
optionLabel: `label`,
optionValue: `id`,
placeholder: `请选择项目`,
fluid: ``,
},
null,
8,
[`modelValue`, `options`],
),
]),
unref(G).length
? (openBlock(),
createElementBlock(`div`, rt, [
(i[44] ||= createElementVNode(
`label`,
null,
`税率`,
-1,
)),
createVNode(
x,
{
modelValue: unref(V).tax_rate,
"onUpdate:modelValue":
(i[11] ||= (e) =>
(unref(V).tax_rate = e)),
options: unref(G),
"option-label": `label`,
"option-value": `value`,
placeholder: `请选择税率`,
fluid: ``,
},
null,
8,
[`modelValue`, `options`],
),
]))
: createCommentVNode(``, !0),
createElementVNode(`div`, it, [
(i[45] ||= createElementVNode(
`label`,
null,
`发票格式`,
-1,
)),
createVNode(
x,
{
modelValue: unref(V).invoice_format,
"onUpdate:modelValue": (i[12] ||= (
e,
) => (unref(V).invoice_format = e)),
options: unref(Ct),
optionLabel: `label`,
optionValue: `value`,
fluid: ``,
},
null,
8,
[`modelValue`, `options`],
),
]),
unref(U)
? (openBlock(),
createElementBlock(`div`, at, [
(i[46] ||= createElementVNode(
`label`,
null,
`快递方式`,
-1,
)),
createVNode(
x,
{
modelValue: unref(V).parcel_id,
"onUpdate:modelValue":
(i[13] ||= (e) =>
(unref(V).parcel_id = e)),
options: unref(H),
"option-label": `label`,
"option-value": `id`,
placeholder: `请选择快递方式`,
fluid: ``,
},
null,
8,
[`modelValue`, `options`],
),
]))
: createCommentVNode(``, !0),
]),
],
64,
))
: createCommentVNode(``, !0),
unref(k)
? (openBlock(),
createBlock(
y,
{
key: 3,
severity: `error`,
closable: !1,
},
{
default: withCtx(() => [
createTextVNode(
toDisplayString(unref(k)),
1,
),
]),
_: 1,
},
))
: unref(V).order_id.length && unref(Z)
? (openBlock(),
createBlock(
y,
{
key: 4,
severity: `warn`,
closable: !1,
},
{
default: withCtx(() => [
createTextVNode(
toDisplayString(unref(Z)),
1,
),
]),
_: 1,
},
))
: createCommentVNode(``, !0),
unref(j)
? (openBlock(),
createBlock(
y,
{
key: 5,
severity: `warn`,
closable: !1,
},
{
default: withCtx(() => [
createTextVNode(
toDisplayString(unref(j)) + ` `,
1,
),
createVNode(u, {
label: `重试报价`,
text: ``,
size: `small`,
onClick: Q,
}),
]),
_: 1,
},
))
: createCommentVNode(``, !0),
unref(M)
? (openBlock(),
createElementBlock(`div`, ot, [
createElementVNode(
`span`,
null,
`订单金额 ¥` +
toDisplayString(
unref(M).price ?? unref($),
),
1,
),
unref(M).tax_price
? (openBlock(),
createElementBlock(
`span`,
st,
`税费 ¥` +
toDisplayString(unref(M).tax_price),
1,
))
: createCommentVNode(``, !0),
unref(M).parcel_price
? (openBlock(),
createElementBlock(
`span`,
ct,
`快递费 ¥` +
toDisplayString(
unref(M).parcel_price,
),
1,
))
: createCommentVNode(``, !0),
createElementVNode(
`strong`,
null,
`应付 ¥` +
toDisplayString(
unref(M).total ?? unref($),
),
1,
),
]))
: createCommentVNode(``, !0),
]),
]),
_: 1,
},
8,
[`visible`],
)),
createVNode(
w,
{
modelValue: unref(F),
"onUpdate:modelValue": [
(i[16] ||= (e) => (isRef(F) ? (F.value = e) : null)),
jt,
],
"order-id": unref(vt),
onSuccess: At,
},
null,
8,
[`modelValue`, `order-id`],
),
])
);
}
);
},
}),
[[`__scopeId`, `data-v-86fc6dc2`]],
);
export {};
export default x;
</script>