Browse Source

新增零担标签打印

dev
qb 1 month ago
parent
commit
97d38a4260
  1. 11
      src/api/waybill/WaybillOrderList.js
  2. 454
      src/components/MyPrintZero/MyPrintZero.vue
  3. 3
      src/main.js
  4. 2
      src/option/waybill/WaybillOrderList.js
  5. 14
      src/views/distribution/inventory/BookingNote.vue
  6. 17
      src/views/waybill/CreateZeroOrder.vue
  7. 26
      src/views/waybill/WaybillOrderList.vue

11
src/api/waybill/WaybillOrderList.js

@ -92,3 +92,14 @@ export const postUpdateWaybillTypeService = data => {
data,
});
};
/**
* 修改服务类型
*/
export const postFindZeroWaybillLabelInfo = data => {
return request({
url: '/apilogpm-trunkline/openOrder/findZeroWaybillLabelInfo',
method: 'post',
data,
});
};

454
src/components/MyPrintZero/MyPrintZero.vue

@ -0,0 +1,454 @@
<template>
<div>
<el-dialog
v-model="details.popUpShow.visible"
destroy-on-close
align-center
:title="props.title"
:width="props.width"
:fullscreen="props.isFullscreen && details.isFullscreen"
:show-close="!props.isFullscreen"
>
<!-- 标题 -- 头部控件区 -->
<template v-if="props.isFullscreen" #header="{ close, titleId, titleClass }">
<div class="my-header flex-c-sb">
<div class="fwb" :id="titleId" :class="titleClass">{{ props.title }}</div>
<div class="flex-c-c">
<!-- 全屏显示按钮 -->
<el-button type="text" @click="handleFullScrean()" v-if="!details.isFullscreen">
<el-icon class=""><FullScreen /></el-icon>
</el-button>
<el-button type="text" @click="handleFullScrean()" v-else>
<el-icon class=""><CopyDocument /></el-icon>
</el-button>
<!-- 弹窗关闭按钮 -->
<el-button type="text">
<el-icon class="" @click="close"><Close /></el-icon>
</el-button>
</div>
</div>
</template>
<div class="printCode" ref="printNodeRef">
<template v-if="details.html">
<div v-html="details.html"></div>
</template>
<div>
<slot></slot>
</div>
</div>
<div class="flex-c-c mt10">
<el-button @click="handleClose" icon="CircleClose"> </el-button>
<el-button type="primary" v-if="props.isShowExport" @click="handleExport" icon="Download">
</el-button>
<el-button
type="primary"
@click="printTemplate"
icon="Printer"
:disabled="details.printLoading"
:loading="details.printLoading"
>
</el-button>
<el-button
type="primary"
@click="handleShowEdit"
icon="Edit"
:disabled="details.printLoading"
:loading="details.printLoading"
>
编辑打印机
</el-button>
<!-- <el-select
v-model="activeIndex"
placeholder="打印机"
style="width: 200px; margin-left: 10px"
>
<el-option
v-for="item in $store.state.print.printList"
:label="item.label"
:value="item.value"
:key="item.label"
/>
</el-select> -->
</div>
</el-dialog>
<!-- 确认打印机 -->
<el-dialog v-model="isShow" title="确认打印机" align-center width="fit-content">
<div style="margin-bottom: 40px" class="flex-c-c">
<div class="flex-none">编辑打印机</div>
<el-select
v-model="activeIndex"
placeholder="打印机"
style="width: 200px; margin-left: 10px"
>
<el-option
v-for="item in $store.state.print.printList"
:label="item.label"
:value="item.value"
:key="item.label"
/>
</el-select>
</div>
</el-dialog>
<el-dialog
v-model="details.popUpShow.setNum"
title="确认打印标签数"
align-center
width="50%"
destroy-on-close
>
<template v-for="item in details.waybillInfo.detailList">
<div class="fwb">品类名{{ item.productName }}</div>
<div class="flex mt10 mb20">
<div class="flex1 align-center mr20">
<div class="mr10">开始索引</div>
<el-input-number
class="flex1"
v-model="item.start"
:min="1"
:max="item.num"
></el-input-number>
</div>
<div class="flex1 align-center">
<div class="mr10">结束索引</div>
<el-input-number
class="flex1"
v-model="item.end"
:min="isNumber(item.start > 1) ? item.start : 0"
:max="item.num"
></el-input-number>
</div>
</div>
</template>
<div class="flex-c-sb">
<div></div>
<div>
<el-button @click="details.popUpShow.setNum = false">取消</el-button>
<el-button type="primary" @click="handleShowPrint" icon="Printer">确认</el-button>
</div>
</div>
</el-dialog>
</div>
</template>
<script setup lang="ts">
import { defineProps, computed, ref, nextTick, reactive, watch } from 'vue';
import print from '@/utils/print';
import { ElMessage, ElMessageBox } from 'element-plus';
import { getObjType } from '@/utils/util';
import * as XLSX from 'xlsx';
import { exportExcelByDom } from '@/utils/export';
import { dateNow } from '@/utils/date';
import { postFindZeroWaybillLabelInfo } from '@/api/waybill/WaybillOrderList.js';
import { useStore } from 'vuex';
import { isNumber } from '@antfu/utils';
const $store = useStore();
const props = defineProps({
/** 弹窗宽度 */
width: {
type: String,
default: '780px',
},
/** 标题 */
title: {
type: String,
default: '二维码',
},
/** 是否显示导出按钮 */
isShowExport: {
type: Boolean,
default: true,
},
/** 打印函数 */
printFn: {
type: Function,
default: null,
},
/** 打印类型 */
type: {
type: String,
default: 'titlePrint',
},
/** 导出名称 */
exportName: {
type: String,
default: '导出',
},
/** 是否开启全屏按钮 */
isFullscreen: {
type: Boolean,
default: false,
},
});
const $emit = defineEmits(['update:modelValue']);
const isShow = ref(false);
const activeIndex = computed({
get() {
return $store.state.print[props.type + 'ActiveIndex'];
},
set(activeIndex) {
//
$store.commit('SET_PRINT_ACTIVE', { activeIndex, type: props.type });
},
});
const details = reactive({
/** 打印loading */
printLoading: false,
/** 是否全屏 */
isFullscreen: false,
/** 运单信息 */
waybillInfo: {} as any,
popUpShow: {
/** 打印 */
visible: false,
setNum: false,
},
html: '',
waybillNo: '',
});
const handleClose = () => {
details.popUpShow.visible = false;
};
const printNodeRef = ref();
/** 生成Excel */
const createExcel = () => {
// const table = this.$refs.tableRef;
/* 将表格转换为 Workbook 对象 */
const wb = XLSX.utils.table_to_book(printNodeRef.value);
console.log('wb :>> ', wb);
wb.Sheets.Sheet1;
//线
const borderAll = {
top: {
style: 'thin',
},
bottom: {
style: 'thin',
},
left: {
style: 'thin',
},
right: {
style: 'thin',
},
};
for (const key in wb.Sheets.Sheet1) {
const item = wb.Sheets.Sheet1[key];
const type = getObjType(item);
console.log('type :>> ', type);
if (type !== 'object') continue;
item.s = {
border: borderAll,
font: {
// name: "",
// sz: 16,
color: { rgb: '000000' },
bold: true,
italic: false,
underline: false,
},
fill: {
fgColor: { rgb: 'C5D9F1' },
},
alignment: {
horizontal: 'center',
vertical: 'center',
wrapText: false, //
},
};
item.t = 's';
}
/* 导出 Workbook 到 Excel 文件 */
XLSX.writeFile(wb, 'data.xlsx');
};
/** 导出 */
const handleExport = () => {
if (!printNodeRef.value) return ElMessage.warning('数据暂未请求完成, 请稍等');
ElMessageBox.confirm('确认导出?', '', {
confirmButtonText: '确认',
cancelButtonText: '关闭',
type: 'warning',
}).then(() => {
console.log('printNodeRef.value :>> ', printNodeRef.value);
props.type === 'titlePrint'
? createExcel()
: exportExcelByDom(printNodeRef.value, props.exportName + ' - ' + dateNow() + '.xlsx');
});
};
/** 打印 */
const printTemplate = () => {
if (props.printFn) return props.printFn();
details.printLoading = true;
const nodeArr = document.querySelectorAll('.printSmallText');
for (let i = 0; i < nodeArr.length; i++) {
const val = nodeArr[i] as any;
val.style.fontSize = '0.5rem';
val.style.lineHeight = '0.7rem';
}
const timer = setTimeout(() => {
const printNode = document.querySelectorAll('.printCode > div > div');
console.log('printNode :>> ', printNode);
print(printNode, props.type);
handleClose();
details.printLoading = false;
clearTimeout(timer);
}, 500);
};
/**
* 是否开启床车明细全屏
* @params(_type) 开启或关闭
*/
const handleFullScrean = () => {
details.isFullscreen = !details.isFullscreen;
};
const handleGetWaybillInfo = async (waybillNo, loading, loadingKey = 'pageLoading') => {
try {
loading[loadingKey] = true;
details.waybillNo = waybillNo;
const res = await postFindZeroWaybillLabelInfo({ waybillNo });
const { code, data } = res.data;
if (code !== 200) return;
if (getObjType(data) !== 'object') return;
details.waybillInfo = data;
if (getObjType(details.waybillInfo.detailList) !== 'array') details.waybillInfo.detailList = [];
for (let i = 0; i < details.waybillInfo.detailList.length; i++) {
const value = details.waybillInfo.detailList[i];
value.start = value.num > 1 ? 1 : 0;
value.end = value.num > 1 ? value.num : 0;
}
details.popUpShow.setNum = true;
} catch (error) {
console.log('error :>> ', error);
} finally {
loading[loadingKey] = false;
}
};
const handleShowPrint = () => {
let flag = true;
let html = '';
let waybillProductName = '';
for (let i = 0; i < details.waybillInfo.detailList.length; i++) {
const value = details.waybillInfo.detailList[i];
waybillProductName += value.productName + ' - ' + value.num + '<br />';
}
for (let i = 0; i < details.waybillInfo.detailList.length; i++) {
const value = details.waybillInfo.detailList[i];
if (value.end <= 0) continue;
flag = false;
for (let index = value.start; index <= value.end; index++) {
let template = details.waybillInfo.template;
template = template.replace('发站仓信息', details.waybillInfo.destinationWarehouseName);
template = template.replace('目的仓信息', details.waybillInfo.departureWarehouseName);
template = template.replace('发站信息', details.waybillInfo.destination);
template = template.replace('到站信息', details.waybillInfo.departure);
template = template.replace('运单号', details.waybillNo);
template = template.replace('订单号', details.waybillInfo.orderNo);
template = template.replace('运单地址', details.waybillInfo.waybillNoCode);
template = template.replace('总件数值', details.waybillInfo.totalCount);
template = template.replace('总重量值', details.waybillInfo.totalWeight);
template = template.replace('总方数值', details.waybillInfo.total_volume);
template = template.replace('货物单项信息', value.productName + ' - ' + index);
template = template.replace(
'寄件人信息',
details.waybillInfo.shipperName +
details.waybillInfo.shipperMobile +
details.waybillInfo.shipperAddress
);
template = template.replace('货物信息', waybillProductName);
template = template.replace(
'收件人信息',
details.waybillInfo.consigneeName +
details.waybillInfo.consigneeMobile +
details.waybillInfo.consigneeAddress
);
template = template.replace('送货方式值', details.waybillInfo.delivery_way);
template = template.replace('送货时间值', details.waybillInfo.createDate.split(' ')[0]);
html += template;
}
}
if (flag) return ElMessage.warning('请输入需要打印的范围');
details.html = html;
details.popUpShow.visible = true;
};
const handleShowEdit = () => {
$store.commit('GET_PRINT_LIST');
isShow.value = true;
};
defineExpose({ handleGetWaybillInfo });
</script>
<style scoped lang="scss">
.printCode {
max-height: 80vh;
overflow-y: scroll;
}
.my-header {
:deep(.el-icon) {
font-size: 20px;
}
}
</style>

3
src/main.js

@ -32,6 +32,7 @@ import ArteryPrintTemplate from './components/ArteryPrintTemplate/ArteryPrintTem
import TripartiteTransferPrintTemplate from './components/TripartiteTransferPrintTemplate/TripartiteTransferPrintTemplate.vue';
import ImgList from './components/ImgList/ImgList.vue';
import MyPrint from './components/MyPrint/MyPrint.vue';
import MyPrintZero from './components/MyPrintZero/MyPrintZero.vue';
import MyUpload from './components/MyUpload/MyUpload.vue';
import DeleteWarningDialog from './components/popupnotification/popupnotification.vue';
import { message } from './utils/resetMessage';
@ -65,6 +66,8 @@ app.component('SelectBox', SelectBox);
app.component('HeaderSearch', HeaderSearch);
/** 打印 */
app.component('MyPrint', MyPrint);
/** 零担标签打印 */
app.component('MyPrintZero', MyPrintZero);
/** 上传Excel */
app.component('MyUpload', MyUpload);
/** 运单打印模版 */

2
src/option/waybill/WaybillOrderList.js

@ -997,7 +997,7 @@ export const columnList = [
label: '操作',
type: 6,
values: '',
width: '150',
width: '200',
checkarr: [],
fixed: 'right',
sortable: false,

14
src/views/distribution/inventory/BookingNote.vue

@ -1053,6 +1053,11 @@
<!-- 打印 -->
<el-button type="primary" icon="el-icon-printer" @click="handlePrint"> </el-button>
<!-- 打印标签 -->
<el-button type="primary" icon="el-icon-printer" @click="handleShowTip">
打印标签
</el-button>
<!-- 关闭 -->
<el-button type="primary" icon="el-icon-close" @click="back()"> </el-button>
</div>
@ -1228,6 +1233,9 @@
width="fit-content"
/>
<!-- 查看标签 -->
<MyPrintZero ref="printZeroRef" />
<edittablehead
@closce="showdrawer"
:drawerShow="drawerShow"
@ -1302,6 +1310,7 @@ const $route = useRoute();
const $store = useStore();
const tableOrderPackgeNodeRef = ref();
const printZeroRef = ref();
const details = reactive<any>({
/** 表格表头 */
@ -2054,6 +2063,11 @@ const handlePrint = async () => {
}
};
/** 查看零担标签 */
const handleShowTip = () => {
printZeroRef.value.handleGetWaybillInfo($route.query.waybillNo, details.loadingObj);
};
watch(
() => $route.query,
() => {

17
src/views/waybill/CreateZeroOrder.vue

@ -1087,6 +1087,9 @@
<el-button type="primary" icon="Printer" v-if="details.waybillId" @click="handlePrint">
</el-button>
<el-button type="primary" icon="Printer" v-if="details.waybillId" @click="handleShowTip">
打印标签
</el-button>
</div>
</div>
</el-dialog>
@ -1153,6 +1156,9 @@
:html="details.html"
width="fit-content"
/>
<!-- 查看标签 -->
<MyPrintZero ref="printZeroRef" />
</div>
</template>
@ -1211,6 +1217,7 @@ const causeFormRef = ref<FormInstance>();
//
const tableNode = ref();
const printZeroRef = ref();
// vuex
const $store = useStore();
@ -3087,6 +3094,7 @@ const handleSubmit = async (formEl: FormInstance | undefined) => {
});
details.waybillId = getObjType(data) === 'object' ? data.waybillId || '' : '';
details.waybillNo = getObjType(data) === 'object' ? data.waybillNo || '' : '';
// ,
if (details.pageInfo.type !== 'edit') details.popUpShow.titleVisited = true;
@ -3853,6 +3861,15 @@ const handlePrint = async () => {
}
};
/** 打印标签 */
const handleShowTip = () => {
printZeroRef.value.handleGetWaybillInfo(
details.waybillNo,
details.loadingObj,
'submitLoadingBtn'
);
};
watch(
() => $route.query,
() => {

26
src/views/waybill/WaybillOrderList.vue

@ -166,18 +166,29 @@
slotProps.scope.row.freezeStatus + '' !== '1'
"
>
<!-- 查看订单 -->
<el-text
@click="handleViewOrderDetails(slotProps.scope)"
v-if="permissionObj.WaybillOrderList_view"
v-if="permissionObj.WaybillOrderList_view && slotProps.scope.row.orderNo"
>
查看订单
</el-text>
<!-- 上传回单 -->
<el-text
@click="handleUploadReceipt(slotProps.scope)"
v-if="permissionObj.WaybillOrderList_uploadReceipt"
>
上传回单
</el-text>
<!-- 打印标签 -->
<el-text
v-if="!slotProps.scope.row.orderNo"
@click="() => handleShowTip(slotProps.scope)"
>
查看标签
</el-text>
</template>
</template>
</tablecmt>
@ -292,6 +303,10 @@
@dialogSearchSubmit="handleSearchSubmit"
>
</MultiConditionSearch>
<!-- 查看标签 -->
<MyPrintZero ref="printZeroRef" />
<!-- 列表配置显示 -->
<edittablehead
@closce="showdrawer"
@ -335,12 +350,15 @@ import { getToken } from '@/utils/auth';
import { getListName } from '@/api/basicdata/basicdataVehicle';
import type { UploadProps, UploadUserFile } from 'element-plus';
import { exportExcel } from '@/utils/exportData';
import MyPrintZero from '@/components/MyPrintZero/MyPrintZero.vue';
const $store = useStore();
//
const $router = useRouter();
const printZeroRef = ref();
const details = reactive<any>({
/** 是否开启搜索 */
search: true,
@ -428,6 +446,7 @@ const details = reactive<any>({
}),
html: '',
warehouseOption: [],
waybillZeroInfo: {},
});
const tableNodeRef = ref();
@ -1043,6 +1062,11 @@ getListName({ name: '' }).then(res => {
const handleExportData = () => {
exportExcel(details.columnList, details.data, '运单列表 - ' + new Date().getTime());
};
/** 查看零担标签 */
const handleShowTip = async ({ row }) => {
printZeroRef.value.handleGetWaybillInfo(row.waybillNo, details.loadingObj);
};
</script>
<style scoped lang="scss">

Loading…
Cancel
Save