feat:打印

This commit is contained in:
dzc committed 2025-01-16 12:08:16 +08:00
1 parent 2acb0eb403
commit 8acb5144fb
5 files changed
+287 -178

No files matched your search

+37 -30
View File
@@ -1,49 +1,56 @@
import request from "/@/utils/request"
export function print(query?: Object) {
return request({
url: "/hard/hard-invoice/print",
method: "get",
params: query,
})
}
export function pageJoin(query?: Object) {
return request({
url: '/hard/hard-invoice/page-join',
method: 'get',
params: query
})
return request({
url: "/hard/hard-invoice/page-join",
method: "get",
params: query,
})
}
export function fetchList(query?: Object) {
return request({
url: '/hard/hard-invoice/page',
method: 'get',
params: query
})
return request({
url: "/hard/hard-invoice/page",
method: "get",
params: query,
})
}
export function addObj(obj?: Object) {
return request({
url: '/hard/hard-invoice',
method: 'post',
data: obj
})
return request({
url: "/hard/hard-invoice",
method: "post",
data: obj,
})
}
export function getObj(id?: string) {
return request({
url: '/hard/hard-invoice/' + id,
method: 'get'
})
return request({
url: "/hard/hard-invoice/" + id,
method: "get",
})
}
export function delObjs(ids?: Object) {
return request({
url: '/hard/hard-invoice',
method: 'delete',
data: ids
})
return request({
url: "/hard/hard-invoice",
method: "delete",
data: ids,
})
}
export function putObj(obj?: Object) {
return request({
url: '/hard/hard-invoice',
method: 'put',
data: obj
})
return request({
url: "/hard/hard-invoice",
method: "put",
data: obj,
})
}
+55 -43
View File
@@ -1,70 +1,82 @@
<template>
<el-select style="width: 100%;" v-model="state.selectId" :placeholder="props.placeholder" clearable
remote-show-suffix filterable remote :remote-method="remoteSearch" :loading="state.loading"
@visible-change="(e: boolean) => e && getOptions()">
<el-option v-for="v in state.options" :key="v.userId" :label="`${v.name}-${v.phone}`" :value="v.userId">
<div class="flex items-center">
<div class="color-primary">{{ v.name }}</div>
<div class="pl5 color-success">{{ v.phone }}</div>
</div>
</el-option>
</el-select>
<el-select
style="width: 100%"
v-model="state.selectId"
:placeholder="props.placeholder"
clearable
remote-show-suffix
filterable
remote
:remote-method="remoteSearch"
:loading="state.loading"
@visible-change="(e: boolean) => e && getOptions()"
>
<el-option v-for="v in state.options" :key="v.userId" :label="`${v.name}-${v.phone}`" :value="v.userId">
<div class="flex items-center">
<div class="color-primary">{{ v.name }}</div>
<div class="pl5 color-success">{{ v.phone }}</div>
</div>
</el-option>
</el-select>
</template>
<script setup lang="ts" name="select-user">
import { reactive, computed, defineModel, withDefaults, defineProps } from 'vue'
import * as userApi from '/@/api/admin/user'
import { reactive, computed, defineModel, withDefaults, defineProps } from "vue"
import * as userApi from "/@/api/admin/user"
const selectId = defineModel()
export type Props = {
placeholder?: string,
placeholder?: string
}
const props = withDefaults(defineProps<Props>(), {
placeholder: "请选择",
placeholder: "请选择",
})
const queryForm = reactive<any>({
name: "",
current: 1,
size: 10,
nameOrPhone: "",
current: 1,
size: 10,
})
const state = reactive<any>({
loading: true,
selectId: selectId,
options: []
loading: true,
selectId: selectId,
options: [],
})
watch(selectId, (newVal, oldValue) => {
if (newVal == oldValue) return
state.selectId = newVal
getOptions()
}, { immediate: true })
watch(
selectId,
(newVal, oldValue) => {
if (newVal == oldValue) return
state.selectId = newVal
getOptions()
},
{ immediate: true },
)
async function getOptions() {
try {
state.loading = true
const _pa = {
...queryForm
}
const { data } = await userApi.pageList(_pa)
state.options = data.records ?? []
} finally {
setTimeout(() => state.loading = false, 500);
}
try {
state.loading = true
const _pa = {
...queryForm,
}
const { data } = await userApi.pageList(_pa)
state.options = data.records ?? []
} finally {
setTimeout(() => (state.loading = false), 500)
}
}
function remoteSearch(params: string) {
if (params != queryForm.name) {
queryForm.name = params
getOptions()
}
if (params != queryForm.nameOrPhone) {
queryForm.nameOrPhone = params
getOptions()
}
}
function clear() {
state.selectId = null
getOptions()
state.selectId = null
getOptions()
}
</script>
</script>
@@ -197,9 +197,10 @@ const agree = async () => {
background: "rgba(0, 0, 0, 0.7)",
})
await hardAfterSaleApi.agree({ id: globalData.afterSaleData.id })
useMessage().success("操作成功")
await getDetail()
} finally {
setTimeout(() => loading.close(), 1000)
setTimeout(() => loading.close(), 500)
}
}
+170 -99
View File
@@ -1,77 +1,122 @@
<template>
<div class="layout-padding">
<div class="layout-padding-auto layout-padding-view">
<el-form ref="queryRef" :inline="true" :model="state.queryForm" @keyup.enter="getDataList">
<el-row :gutter="24">
<el-col :span="4">
<el-form-item class="w100" label="设备名" prop="name">
<el-input v-model="state.queryForm.name" placeholder="设备名" />
</el-form-item>
</el-col>
<el-col :span="4">
<el-form-item class="w100" label="设备类型" prop="type">
<dict-select v-model="state.queryForm.type" dict-code="hard_type" />
</el-form-item>
</el-col>
<el-col :span="4">
<el-form-item class="w100" label="商户" prop="merchantIds">
<select-mch v-model="state.queryForm.merchantIds" />
</el-form-item>
</el-col>
<el-form-item>
<el-button icon="Search" type="primary" @click="getDataList">{{ $t('common.queryBtn')
}}</el-button>
<el-button icon="Refresh" @click="resetQuery">{{ $t('common.resetBtn') }}</el-button>
</el-form-item>
</el-row>
</el-form>
<el-table :data="state.dataList" v-loading="state.loading" border :cell-style="tableStyle.cellStyle"
:header-cell-style="tableStyle.headerCellStyle" @selection-change="selectionChangHandle"
@sort-change="sortChangeHandle">
<el-table-column type="selection" width="40" align="center" />
<el-table-column type="index" label="#" width="40" />
<el-table-column prop="deptId" label="订单编号" />
<el-table-column prop="hardId" label="设备" />
<el-table-column label="商家" prop="merchantStr" />
<el-table-column label="部门" prop="deptName" />
<el-table-column prop="status" label="打印状态">
<template #default="{ row }">
<div class="layout-padding">
<div class="layout-padding-auto layout-padding-view">
<el-form ref="queryRef" :inline="true" :model="state.queryForm" @keyup.enter="getDataList">
<el-row :gutter="24">
<el-col :span="4">
<el-form-item class="w100" label="设备名" prop="name">
<el-input v-model="state.queryForm.name" placeholder="设备名" />
</el-form-item>
</el-col>
<el-col :span="4">
<el-form-item class="w100" label="设备类型" prop="type">
<dict-select v-model="state.queryForm.type" dict-code="hard_type" />
</el-form-item>
</el-col>
<el-col :span="4">
<el-form-item class="w100" label="商户" prop="merchantIds">
<select-mch v-model="state.queryForm.merchantIds" />
</el-form-item>
</el-col>
<el-form-item>
<el-button icon="Search" type="primary" @click="getDataList">{{ $t("common.queryBtn") }}</el-button>
<el-button icon="Refresh" @click="resetQuery">{{ $t("common.resetBtn") }}</el-button>
</el-form-item>
</el-row>
</el-form>
<el-table
:data="state.dataList"
v-loading="state.loading"
border
:cell-style="tableStyle.cellStyle"
:header-cell-style="tableStyle.headerCellStyle"
@selection-change="selectionChangHandle"
@sort-change="sortChangeHandle"
>
<el-table-column type="selection" width="40" align="center" />
<el-table-column type="index" label="#" width="40" />
<el-table-column label="部门" prop="deptName" />
<el-table-column width="250px" label="设备信息">
<template #default="{ row }">
<div class="status">
<span>商户</span>
<span>
{{ row.merchantName }}
</span>
</div>
<div class="status">
<span>设备名</span>
<span>
{{ row.hardName }}
</span>
</div>
<div class="status">
<span>设备类型</span>
<span>
<dict-tag :options="hard_type" :value="row.hardType" />
</span>
</div>
</template>
</el-table-column>
<el-table-column prop="pic" label="发票">
<template #default="{ row }">
<preview-image v-if="row.pic" :src="row.pic" />
</template>
</el-table-column>
<el-table-column prop="status" label="打印状态">
<template #default="{ row }">
<dict-tag :options="hard_print_status" :value="row.status" />
</template>
</el-table-column>
<el-table-column prop="createTime" label="打印时间" />
<el-table-column label="操作" width="150">
<template #default="{ row }">
<el-button icon="InfoFilled" link type="primary" @click="doRefund(row)"> 订单详情 </el-button>
<el-button
v-if="false"
icon="edit-pen"
text
type="primary"
v-auth="'hard_hardInvoice_edit'"
@click="formDialogRef.openDialog(row.id)"
>编辑</el-button
>
<el-button
v-if="false"
icon="delete"
text
type="primary"
v-auth="'hard_hardInvoice_del'"
@click="handleDelete([row.id])"
>删除</el-button
>
</template>
</el-table-column>
</el-table>
<pagination @size-change="sizeChangeHandle" @current-change="currentChangeHandle" v-bind="state.pagination" />
</div>
</template>
</el-table-column>
<el-table-column prop="pic" label="发票">
<template #default="{ row }">
<preview-image v-if="row.pic" :src="row.pic" />
</template>
</el-table-column>
<el-table-column v-if="false" label="操作" width="150">
<template #default="scope">
<el-button icon="edit-pen" text type="primary" v-auth="'hard_hardInvoice_edit'"
@click="formDialogRef.openDialog(scope.row.id)">编辑</el-button>
<el-button icon="delete" text type="primary" v-auth="'hard_hardInvoice_del'"
@click="handleDelete([scope.row.id])">删除</el-button>
</template>
</el-table-column>
</el-table>
<pagination @size-change="sizeChangeHandle" @current-change="currentChangeHandle" v-bind="state.pagination" />
</div>
<!-- 编辑、新增 -->
<form-dialog ref="formDialogRef" @refresh="getDataList(false)" />
</div>
<!-- 编辑、新增 -->
<form-dialog ref="formDialogRef" @refresh="getDataList(false)" />
</div>
</template>
<script setup lang="ts" name="systemHardInvoice">
import { BasicTableProps, useTable } from "/@/hooks/table";
import * as hardInvoiceApi from '/@/api/hard/hard-invoice'
import { useMessage, useMessageBox } from "/@/hooks/message";
import { useDict } from '/@/hooks/dict';
import { BasicTableProps, useTable } from "/@/hooks/table"
import * as hardInvoiceApi from "/@/api/hard/hard-invoice"
import { useMessage, useMessageBox } from "/@/hooks/message"
import { useDict } from "/@/hooks/dict"
// 引入组件
const FormDialog = defineAsyncComponent(() => import('./form.vue'));
const FormDialog = defineAsyncComponent(() => import("./form.vue"))
// 定义查询字典
const { hard_print_status, hard_type, hard_order_type, hard_pay_type, hard_order_status } = useDict(
"hard_print_status",
"hard_type",
"hard_order_type",
"hard_pay_type",
"hard_order_status",
)
// 定义变量内容
const formDialogRef = ref()
// 搜索变量
@@ -81,55 +126,81 @@ const showSearch = ref(true)
const selectObjs = ref([]) as any
const multiple = ref(true)
const { push } = useRouter()
const state: BasicTableProps = reactive<BasicTableProps>({
queryForm: {},
pageList: hardInvoiceApi.pageJoin
queryForm: {},
pageList: hardInvoiceApi.pageJoin,
})
// table hook
const {
getDataList,
currentChangeHandle,
sizeChangeHandle,
sortChangeHandle,
downBlobFile,
tableStyle
} = useTable(state)
const { getDataList, currentChangeHandle, sizeChangeHandle, sortChangeHandle, downBlobFile, tableStyle } =
useTable(state)
// 清空搜索条件
const resetQuery = () => {
// 清空搜索条件
queryRef.value?.resetFields()
// 清空多选
selectObjs.value = []
getDataList()
// 清空搜索条件
queryRef.value?.resetFields()
// 清空多选
selectObjs.value = []
getDataList()
}
const doRefund = (row: any) => {
push({ path: "/hard/hard-after-sale/order-refund", query: { id: row.orderId, type: "view" } })
}
// 导出excel
const exportExcel = () => {
downBlobFile('/hard/hardInvoice/export', Object.assign(state.queryForm, { ids: selectObjs }), 'hardInvoice.xlsx')
downBlobFile("/hard/hardInvoice/export", Object.assign(state.queryForm, { ids: selectObjs }), "hardInvoice.xlsx")
}
// 多选事件
const selectionChangHandle = (objs: { id: string }[]) => {
selectObjs.value = objs.map(({ id }) => id);
multiple.value = !objs.length;
};
selectObjs.value = objs.map(({ id }) => id)
multiple.value = !objs.length
}
// 删除操作
const handleDelete = async (ids: string[]) => {
try {
await useMessageBox().confirm('此操作将永久删除');
} catch {
return;
}
try {
await useMessageBox().confirm("此操作将永久删除")
} catch {
return
}
try {
await hardInvoiceApi.delObjs(ids);
getDataList();
useMessage().success('删除成功');
} catch (err: any) {
useMessage().error(err.msg);
}
};
</script>
try {
await hardInvoiceApi.delObjs(ids)
getDataList()
useMessage().success("删除成功")
} catch (err: any) {
useMessage().error(err.msg)
}
}
</script>
<style scoped lang="scss">
.status {
display: flex;
align-items: center;
margin-bottom: 2px;
span {
display: inline-block;
}
span:nth-child(1) {
min-width: 60px;
max-width: 100px;
text-align: left;
}
span:nth-child(2) {
flex: 1;
min-width: 50px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
}
</style>
+23 -5
View File
@@ -167,11 +167,12 @@
</div>
</template>
</el-table-column>
<el-table-column fixed="right" label="操作" width="200">
<el-table-column fixed="right" label="操作" width="250">
<template #default="{ row }">
<el-button icon="ShoppingCartFull" text type="primary" @click="shopCarDialogRef.openDialog(row.id)"
>购物车</el-button
>
<el-button icon="Printer" text type="primary" @click="print(row)"> 打印发票 </el-button>
<el-button icon="ShoppingCartFull" text type="primary" @click="shopCarDialogRef.openDialog(row.id)">
购物车
</el-button>
<el-button icon="InfoFilled" link type="primary" @click="doRefund(row)"> 详情 </el-button>
<el-button
v-if="false"
@@ -205,11 +206,12 @@
<script setup lang="ts" name="systemHardwareOrder">
import { BasicTableProps, useTable } from "/@/hooks/table"
import * as hardOrder from "/@/api/hard/hard-order"
import * as hardCar from "/@/api/hard/hard-car"
import * as hardInvoice from "/@/api/hard/hard-invoice"
import { getDicts } from "/@/api/admin/dict"
import { useMessage, useMessageBox } from "/@/hooks/message"
import { useDict } from "/@/hooks/dict"
import { displayPrice } from "/@/utils/formatMoney"
import { ElLoading } from "element-plus"
const { push } = useRouter()
@@ -270,6 +272,22 @@ const doRefund = (row: any) => {
push({ path: "/hard/hard-after-sale/order-refund", query: { id: row.id, type: "view" } })
}
const print = async (row: any) => {
let loading: any = null
try {
await useMessage().delConfirm("是否打印发票")
loading = ElLoading.service({
lock: true,
text: "提交中",
background: "rgba(0, 0, 0, 0.7)",
})
await hardInvoice.print({ orderId: row.id })
useMessage().success("打印成功")
} finally {
setTimeout(() => loading.close(), 500)
}
}
// 导出excel
const exportExcel = () => {
downBlobFile("/hard/hardwareOrder/export", Object.assign(state.queryForm, { ids: selectObjs }), "hardwareOrder.xlsx")