优化新增本地打印交班小票
This commit is contained in:
@@ -1,40 +1,53 @@
|
||||
import request from "@/utils/request.js"
|
||||
import request from "@/utils/request.js";
|
||||
|
||||
/**
|
||||
* 当前用户交班详情
|
||||
* @param {*} params
|
||||
* @returns
|
||||
* @param {*} params
|
||||
* @returns
|
||||
*/
|
||||
export function shopInfoqueryDuty(params) {
|
||||
return request({
|
||||
method: "get",
|
||||
url: "shopInfo/queryDuty",
|
||||
params
|
||||
});
|
||||
return request({
|
||||
method: "get",
|
||||
url: "shopInfo/queryDuty",
|
||||
params,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 交班记录
|
||||
* @param {*} params
|
||||
* @returns
|
||||
* @param {*} params
|
||||
* @returns
|
||||
*/
|
||||
export function shopinfoqueryDutyFlow(params) {
|
||||
return request({
|
||||
method: "get",
|
||||
url: "shopInfo/queryDutyFlow",
|
||||
params
|
||||
});
|
||||
return request({
|
||||
method: "get",
|
||||
url: "shopInfo/queryDutyFlow",
|
||||
params,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 登出
|
||||
|
||||
* @param {*} params
|
||||
* @returns
|
||||
* @param {*} params
|
||||
* @returns
|
||||
*/
|
||||
export function loginlogout(params) {
|
||||
return request({
|
||||
method: "post",
|
||||
url: "login/logout",
|
||||
params
|
||||
});
|
||||
}
|
||||
return request({
|
||||
method: "post",
|
||||
url: "login/logout",
|
||||
params,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取交班数据
|
||||
* @param {*} params
|
||||
* @returns
|
||||
*/
|
||||
export function handoverData(params) {
|
||||
return request({
|
||||
method: "get",
|
||||
url: "/data/handoverData",
|
||||
params,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<div class="orderbox_left">
|
||||
<div class="demo_tabs" v-if="props.membershow == '0'">
|
||||
<div class="demo_tabs_div">
|
||||
<el-input v-model="tableData.phone" placeholder="请输入手机号或编号" @input="inputChange" clearable />
|
||||
<el-input v-model="tableData.phone" placeholder="请输入手机号" @input="inputChange" clearable />
|
||||
<el-button style="margin-left: 10px;" type="primary" @click="memberaddshow = true">添加</el-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -3,10 +3,10 @@
|
||||
<div class="box">
|
||||
<div class="box_top">
|
||||
<router-link to="/" class="box_top_left">
|
||||
<el-icon size="20">
|
||||
<ArrowLeft />
|
||||
</el-icon>
|
||||
<div style="margin-left: 10px;">返回</div>
|
||||
<el-icon size="20">
|
||||
<ArrowLeft />
|
||||
</el-icon>
|
||||
<div style="margin-left: 10px;">返回</div>
|
||||
</router-link>
|
||||
<router-link to='/workrecord' class="box_top_right">
|
||||
交班记录
|
||||
@@ -18,7 +18,7 @@
|
||||
<div class="box_content_left_top_item">
|
||||
<div class="box_content_left_top_item_top">
|
||||
<div style="color:#ff5252; font-size: 30px;">
|
||||
{{ infoData.orderNum || 0}}
|
||||
{{ infoData.orderNum || 0 }}
|
||||
</div>
|
||||
<div style="margin-top: 6px; color: #666;">
|
||||
总订单
|
||||
@@ -26,7 +26,7 @@
|
||||
</div>
|
||||
<div class="box_content_left_top_item_top">
|
||||
<div style="color:#ff5252; font-size: 30px;">
|
||||
{{ infoData.amount || 0}}
|
||||
{{ infoData.amount || 0 }}
|
||||
</div>
|
||||
<div style="margin-top: 6px; color: #666;">
|
||||
营业额
|
||||
@@ -36,7 +36,7 @@
|
||||
<div class="box_content_left_top_item">
|
||||
<div class="box_content_left_top_item_botton">
|
||||
<div style=" font-size: 20px;">
|
||||
{{ infoData.cashAmount|| 0}}
|
||||
{{ infoData.cashAmount || 0 }}
|
||||
</div>
|
||||
<div style="margin-top: 6px;">
|
||||
现金支付
|
||||
@@ -47,7 +47,7 @@
|
||||
</div>
|
||||
<div class="box_content_left_top_item_botton">
|
||||
<div style=" font-size: 20px;">
|
||||
{{ infoData.returnAmount || 0}}
|
||||
{{ infoData.returnAmount || 0 }}
|
||||
</div>
|
||||
<div style="margin-top: 6px;">
|
||||
退款金额
|
||||
@@ -60,9 +60,9 @@
|
||||
</div>
|
||||
<div class="box_content_left_bottom">
|
||||
<el-table :data="infoData.detailList" style="width: 100%;" height="400px">
|
||||
<el-table-column prop="productName" label="商品名称"/>
|
||||
<el-table-column prop="skuName" label="规格名称"/>
|
||||
<el-table-column prop="num" label="商品数量"/>
|
||||
<el-table-column prop="productName" label="商品名称" />
|
||||
<el-table-column prop="skuName" label="规格名称" />
|
||||
<el-table-column prop="num" label="商品数量" />
|
||||
<el-table-column prop="amount" label="商品金额" />
|
||||
</el-table>
|
||||
</div>
|
||||
@@ -89,7 +89,7 @@
|
||||
终端名称:
|
||||
</div>
|
||||
<div class="box_content_right_tiemright">
|
||||
{{ infoData.equipment || '无'}}
|
||||
{{ infoData.equipment || '无' }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="box_content_right_tiem">
|
||||
@@ -97,7 +97,7 @@
|
||||
备用金:
|
||||
</div>
|
||||
<div class="box_content_right_tiemright">
|
||||
{{ infoData.pettyCash || '无'}}
|
||||
{{ infoData.pettyCash || '无' }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="box_content_right_tiem">
|
||||
@@ -105,7 +105,7 @@
|
||||
收营员:
|
||||
</div>
|
||||
<div class="box_content_right_tiemright">
|
||||
{{ infoData.userName || '无'}}
|
||||
{{ infoData.userName || '无' }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="box_content_right_tiembutton" :loading="loading" @click="exit">
|
||||
@@ -121,12 +121,18 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ipcRenderer } from "electron";
|
||||
|
||||
import { ref, onMounted } from 'vue'
|
||||
import { useRoute } from 'vue-router'
|
||||
import { ElMessage, dayjs } from 'element-plus'
|
||||
import { shopInfoqueryDuty, loginlogout } from '@/api/work/index.js'
|
||||
import { shopInfoqueryDuty, loginlogout, handoverData } from '@/api/work/index.js'
|
||||
import useStorage from '@/utils/useStorage'
|
||||
import { useRouter } from "vue-router";
|
||||
import { bySubType } from "@/api/device";
|
||||
import { useUser } from "@/store/user.js";
|
||||
|
||||
const store = useUser();
|
||||
|
||||
const router = useRouter();
|
||||
|
||||
@@ -135,20 +141,85 @@ const dialogVisible = ref(true) //交班
|
||||
const infoData = ref({})
|
||||
const loading = ref(false);
|
||||
|
||||
const printList = ref([]);
|
||||
const localPrintList = 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);
|
||||
}
|
||||
}
|
||||
|
||||
// 获取本地打印机列表
|
||||
function getPrintList() {
|
||||
ipcRenderer.send("getPrintList");
|
||||
ipcRenderer.on("printList", (event, arg) => {
|
||||
localPrintList.value = arg;
|
||||
console.log(localPrintList.value);
|
||||
});
|
||||
}
|
||||
|
||||
// 检查本地打印机是否能正常使用
|
||||
function checkLocalPrint(deviceName) {
|
||||
let print = ''
|
||||
for (let item of localPrintList.value) {
|
||||
if (item.name == deviceName) {
|
||||
print = item
|
||||
}
|
||||
}
|
||||
|
||||
if (!print.name) {
|
||||
return false
|
||||
} else {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
const exit = async () => {
|
||||
try {
|
||||
loading.value = true;
|
||||
let res = await loginlogout({
|
||||
status:1
|
||||
})
|
||||
useStorage.clear()
|
||||
ElMessage.success("交班成功");
|
||||
setTimeout(() => {
|
||||
router.replace({
|
||||
name: "login",
|
||||
});
|
||||
}, 1000);
|
||||
loading.value = false;
|
||||
if (printList.value.length) {
|
||||
if (!checkLocalPrint(printList.value[0].config.deviceName)) {
|
||||
ElMessage.error("本地打印机无法使用,请检查打印机是否正确连接");
|
||||
} else {
|
||||
// 获取交班打印小票数据
|
||||
const data = await handoverData({
|
||||
id: infoData.value.id
|
||||
})
|
||||
data.deviceName = printList.value[0].config.deviceName
|
||||
data.printTime = dayjs().format('YYYY-MM-DD HH:mm:ss')
|
||||
ipcRenderer.send("printerWorkSync", JSON.stringify(data));
|
||||
// return
|
||||
useStorage.clear()
|
||||
ElMessage.success("交班成功");
|
||||
setTimeout(() => {
|
||||
router.replace({
|
||||
name: "login",
|
||||
});
|
||||
}, 1000);
|
||||
loading.value = false;
|
||||
}
|
||||
} else {
|
||||
loading.value = true;
|
||||
let res = await loginlogout({
|
||||
status: 1
|
||||
})
|
||||
useStorage.clear()
|
||||
ElMessage.success("交班成功");
|
||||
setTimeout(() => {
|
||||
router.replace({
|
||||
name: "login",
|
||||
});
|
||||
}, 1000);
|
||||
loading.value = false;
|
||||
}
|
||||
} catch (error) {
|
||||
loading.value = false;
|
||||
}
|
||||
@@ -166,6 +237,8 @@ const infoshopInfoqueryDutys = async () => {
|
||||
|
||||
}
|
||||
onMounted(() => {
|
||||
getPrintList()
|
||||
bySubTypeAjax()
|
||||
infoshopInfoqueryDutys()
|
||||
})
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user