优化打印机配置

This commit is contained in:
gyq
2026-04-22 10:09:50 +08:00
parent e2338b3888
commit 6d09813aa4
16 changed files with 612 additions and 67 deletions

View File

@@ -44,6 +44,7 @@
<span v-if="!downloadLoading">导出Excel</span>
<span v-else>下载中...</span>
</el-button>
<el-button icon="Printer" :loading="printLoading" @click="$refs.printBusinessDialogRef.show()">打印</el-button>
<importData :type="7" @close="getTableData" />
</el-form-item>
</el-form>
@@ -185,6 +186,7 @@
@current-change="paginationChange" @size-change="sizeChange"
layout="total, sizes, prev, pager, next, jumper"></el-pagination>
</div>
<printBusinessDialog ref="printBusinessDialogRef" title="商品报表" @success="printBusinessConfirm" />
</div>
</template>
@@ -197,9 +199,10 @@ import ShopApi from "@/api/account/shop";
import dayjs from "dayjs";
import { downloadFile, multiplyAndFormat } from "@/utils/index";
import { formatDateRange } from './utils/index.js'
import printBusinessDialog from '@/components/printBusinessDialog.vue';
export default {
components: { importData },
components: { importData, printBusinessDialog },
data() {
return {
multiplyAndFormat,
@@ -233,7 +236,8 @@ export default {
// dayjs(time):将原生 Date 转为 dayjs 对象
// isAfter判断目标日期是否在今天之后
return dayjs(time).isAfter(dayjs().startOf('day'));
}
},
printLoading: false
};
},
filters: {
@@ -255,6 +259,34 @@ export default {
this.geiShopList();
},
methods: {
// 确认打印
printBusinessConfirm(res) {
this.printHandle(res.date)
},
// 打印
async printHandle(date) {
try {
const shopStaff = JSON.parse(localStorage.getItem('shopStaff')) || { name: '' }
const shopName = localStorage.getItem('shopName')
this.printLoading = true
await saleSummaryApi.print({
beginDate: date[0],
endDate: date[1],
categoryId: this.query.prodCategoryId,
productName: this.query.productName,
shopId: this.shopId,
rangeType: this.timeValue,
operator: shopStaff.name || shopName
})
ElMessage.success('操作成功')
} catch (error) {
console.log(error);
}
this.printLoading = false
},
/**
* 获取分店列表
*/