|
@@ -99,6 +99,60 @@
|
|
|
</el-button>
|
|
|
</template>
|
|
|
</el-dialog>
|
|
|
+
|
|
|
+ <el-dialog
|
|
|
+ title="打印"
|
|
|
+ v-if="printDialog"
|
|
|
+ v-model="printDialog"
|
|
|
+ width="500"
|
|
|
+ >
|
|
|
+ <div
|
|
|
+ style="height: calc(100vh - 300px); overflow: auto; padding-right: 20px"
|
|
|
+ >
|
|
|
+ <div id="pdfDom">
|
|
|
+ <div
|
|
|
+ v-for="item in qrList"
|
|
|
+ :key="item.productSn"
|
|
|
+ style="border: 1px solid #000; padding: 10px; margin-bottom: 20px"
|
|
|
+ >
|
|
|
+ <div style="display: flex">
|
|
|
+ <div :ref="item.productSn"></div>
|
|
|
+ <div
|
|
|
+ style="
|
|
|
+ margin-left: 20px;
|
|
|
+ display: flex;
|
|
|
+ padding: 10px 0;
|
|
|
+ flex-direction: column;
|
|
|
+ justify-content: space-between;
|
|
|
+ "
|
|
|
+ >
|
|
|
+ <div class="print-row">产品:{{ printData.productName }}</div>
|
|
|
+ <div class="print-row">客户:{{ printData.customerName }}</div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div
|
|
|
+ style="
|
|
|
+ font-size: 16px;
|
|
|
+ font-weight: 700;
|
|
|
+ color: #000;
|
|
|
+ margin-top: 10px;
|
|
|
+ "
|
|
|
+ >
|
|
|
+ {{ item.productSn }}
|
|
|
+ </div>
|
|
|
+ <!-- 换页 -->
|
|
|
+ <div style="page-break-after: always"></div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <template #footer>
|
|
|
+ <el-button @click="printDialog = false" size="large">取 消</el-button>
|
|
|
+ <el-button type="primary" v-print="printObj" size="large"
|
|
|
+ >打 印</el-button
|
|
|
+ >
|
|
|
+ </template>
|
|
|
+ </el-dialog>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
@@ -107,6 +161,7 @@ import { ElMessage, ElMessageBox } from "element-plus";
|
|
|
import byTable from "@/components/byTable/index";
|
|
|
import byForm from "@/components/byForm/index";
|
|
|
import useUserStore from "@/store/modules/user";
|
|
|
+import QRCode from "qrcodejs2-fix";
|
|
|
|
|
|
const { proxy } = getCurrentInstance();
|
|
|
const loading = ref(false);
|
|
@@ -192,7 +247,7 @@ const config = computed(() => {
|
|
|
{
|
|
|
attrs: {
|
|
|
label: "操作",
|
|
|
- width: "80",
|
|
|
+ width: "120",
|
|
|
align: "center",
|
|
|
},
|
|
|
renderHTML(row) {
|
|
@@ -208,6 +263,17 @@ const config = computed(() => {
|
|
|
getDtl(row);
|
|
|
},
|
|
|
},
|
|
|
+ {
|
|
|
+ attrs: {
|
|
|
+ label: "打印",
|
|
|
+ type: "primary",
|
|
|
+ text: true,
|
|
|
+ },
|
|
|
+ el: "button",
|
|
|
+ click() {
|
|
|
+ handlePrint(row);
|
|
|
+ },
|
|
|
+ },
|
|
|
];
|
|
|
},
|
|
|
},
|
|
@@ -529,7 +595,7 @@ const changeFn = (val) => {
|
|
|
// const index = formConfig.value.findIndex(
|
|
|
// (x) => x.slotName === changeId.value
|
|
|
// );
|
|
|
- formConfig.value.splice(5, productionProcessesList.value.length);
|
|
|
+ formConfig.value.splice(6, productionProcessesList.value.length);
|
|
|
productionProcessesList.value = [];
|
|
|
productionObj.value = {};
|
|
|
}
|
|
@@ -557,12 +623,55 @@ const handleClose = () => {
|
|
|
productionProcessesList.value &&
|
|
|
productionProcessesList.value.length > 0
|
|
|
) {
|
|
|
- formConfig.value.splice(5, productionProcessesList.value.length);
|
|
|
+ formConfig.value.splice(6, productionProcessesList.value.length);
|
|
|
}
|
|
|
productionProcessesList.value = [];
|
|
|
productionObj.value = {};
|
|
|
dialogVisible.value = false;
|
|
|
};
|
|
|
+
|
|
|
+const printDialog = ref(false);
|
|
|
+const printData = ref({});
|
|
|
+const qrList = ref([]);
|
|
|
+const handlePrint = (row) => {
|
|
|
+ const { code, quantity } = row;
|
|
|
+ const arr = [];
|
|
|
+ for (let i = 0; i < quantity; i++) {
|
|
|
+ let key = i + 1 + "";
|
|
|
+ key = key.padStart(3, "0");
|
|
|
+ let obj = {
|
|
|
+ productSn: code + "-" + key,
|
|
|
+ };
|
|
|
+ arr.push(obj);
|
|
|
+ }
|
|
|
+ qrList.value = arr;
|
|
|
+ printData.value = {
|
|
|
+ customerName: row.customerName,
|
|
|
+ productName: row.productName + `(${row.productSpec})`,
|
|
|
+ };
|
|
|
+ printDialog.value = true;
|
|
|
+ nextTick(() => {
|
|
|
+ for (let i = 0; i < qrList.value.length; i++) {
|
|
|
+ const ele = qrList.value[i];
|
|
|
+ proxy.$refs[ele.productSn][0].innerHTML = ""; //清除二维码方法一
|
|
|
+ new QRCode(proxy.$refs[ele.productSn][0], {
|
|
|
+ text: ele.productSn, //页面地址 ,如果页面需要参数传递请注意哈希模式#
|
|
|
+ width: 100,
|
|
|
+ height: 100,
|
|
|
+ colorDark: "#000000",
|
|
|
+ colorLight: "#ffffff",
|
|
|
+ correctLevel: QRCode.CorrectLevel.H,
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+};
|
|
|
+const printObj = ref({
|
|
|
+ id: "pdfDom",
|
|
|
+ popTitle: "",
|
|
|
+ extraCss:
|
|
|
+ "https://cdn.bootcdn.net/ajax/libs/animate.css/4.1.1/animate.compat.css, https://cdn.bootcdn.net/ajax/libs/hover.css/2.3.1/css/hover-min.css",
|
|
|
+ extraHead: '<meta http-equiv="Content-Language"content="zh-cn"/>',
|
|
|
+});
|
|
|
</script>
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
@@ -572,4 +681,9 @@ const handleClose = () => {
|
|
|
::v-deep(.el-input-number .el-input__inner) {
|
|
|
text-align: left;
|
|
|
}
|
|
|
+.print-row {
|
|
|
+ font-size: 14px;
|
|
|
+ font-weight: 700;
|
|
|
+ color: #000;
|
|
|
+}
|
|
|
</style>
|