优化打印机
This commit is contained in:
@@ -49,4 +49,17 @@ export function tbPrintMachineDelete(params) {
|
||||
url: "tbPrintMachine",
|
||||
params
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据类型查询打印机列表
|
||||
* @param {*} params
|
||||
* @returns
|
||||
*/
|
||||
export function bySubType(params) {
|
||||
return request({
|
||||
method: "get",
|
||||
url: "/tbPrintMachine/bySubType",
|
||||
params
|
||||
});
|
||||
}
|
||||
@@ -192,7 +192,7 @@ const form = ref({
|
||||
},
|
||||
name: "小票打印机",
|
||||
subType: "cash", // 打印类型
|
||||
status: 0,
|
||||
status: 1,
|
||||
sort: "",
|
||||
shopId: store.userInfo.shopId,
|
||||
});
|
||||
|
||||
@@ -33,8 +33,8 @@
|
||||
inline-prompt
|
||||
active-text="开"
|
||||
inactive-text="关"
|
||||
:active-value="0"
|
||||
:inactive-value="1"
|
||||
:active-value="1"
|
||||
:inactive-value="0"
|
||||
width="90"
|
||||
@change="statusChange($event, item)"
|
||||
/>
|
||||
|
||||
@@ -92,10 +92,11 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref } from "vue";
|
||||
import { onMounted, ref } from "vue";
|
||||
import { useUser } from "@/store/user.js";
|
||||
import payCard from "@/components/payCard/payCard.vue";
|
||||
import { print } from "@/api/pay";
|
||||
import { bySubType } from "@/api/device";
|
||||
import { ElMessage } from "element-plus";
|
||||
import dayjs from "dayjs";
|
||||
|
||||
@@ -133,17 +134,45 @@ const props = defineProps({
|
||||
|
||||
const isPrint = ref(true);
|
||||
|
||||
const printList = ref([]);
|
||||
|
||||
// 获取打印机状态
|
||||
async function bySubTypeAjax() {
|
||||
try {
|
||||
const res = await bySubType({
|
||||
shopId: store.userInfo.shopId,
|
||||
contentType: "local",
|
||||
subType: "cash",
|
||||
});
|
||||
printList.value = res;
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
|
||||
async function printHandle() {
|
||||
if (!isPrint.value) return;
|
||||
const data = {
|
||||
shop_name: store.userInfo.merchantName,
|
||||
carts: props.cart,
|
||||
amount: props.amount,
|
||||
remark: props.remark,
|
||||
orderInfo: props.orderInfo,
|
||||
deviceName: printForm.value.deviceName,
|
||||
};
|
||||
ipcRenderer.send("printerInfoSync", JSON.stringify(data));
|
||||
try {
|
||||
if (!isPrint.value) return;
|
||||
if (printList.value.length) {
|
||||
const data = {
|
||||
shop_name: store.userInfo.merchantName,
|
||||
carts: props.cart,
|
||||
amount: props.amount,
|
||||
remark: props.remark,
|
||||
orderInfo: props.orderInfo,
|
||||
deviceName: printList.value[0].config.deviceName,
|
||||
createdAt: dayjs(props.orderInfo.createdAt).format(
|
||||
"YYYY-MM-DD HH:mm:ss"
|
||||
),
|
||||
printTime: dayjs().format("YYYY-MM-DD HH:mm:ss"),
|
||||
};
|
||||
ipcRenderer.send("printerInfoSync", JSON.stringify(data));
|
||||
} else {
|
||||
ElMessage.error("您还没有添加打印设备");
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
// try {
|
||||
// printLoading.value = true
|
||||
// await print({
|
||||
@@ -162,6 +191,7 @@ async function printHandle() {
|
||||
// 订单已支付
|
||||
function paySuccess() {
|
||||
dialogVisible.value = false;
|
||||
printHandle();
|
||||
emit("paySuccess");
|
||||
}
|
||||
|
||||
@@ -172,6 +202,10 @@ function show() {
|
||||
defineExpose({
|
||||
show,
|
||||
});
|
||||
|
||||
onMounted(() => {
|
||||
bySubTypeAjax();
|
||||
});
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
||||
@@ -331,8 +331,8 @@ async function addCart(params, type = "add") {
|
||||
shopId: store.userInfo.shopId,
|
||||
skuId: type == "add" ? params.id : params.skuId,
|
||||
number: params.number || 1,
|
||||
isPack: allSelected.value ? true : params.isPack || false,
|
||||
isGift: params.isGift || false,
|
||||
isPack: params.isPack || "false",
|
||||
isGift: params.isGift || 'false',
|
||||
cartId: type == "add" ? "" : params.id,
|
||||
uuid: params.uuid || store.userInfo.uuid,
|
||||
type: type,
|
||||
@@ -367,6 +367,8 @@ async function queryCartAjax() {
|
||||
});
|
||||
if (i == res.list.length) {
|
||||
allSelected.value = true;
|
||||
} else {
|
||||
allSelected.value = false;
|
||||
}
|
||||
} catch (error) {
|
||||
console.log("获取购物车商品", error);
|
||||
|
||||
Reference in New Issue
Block a user