From 697ebdb9022a24db197a6d6df3a60addec242f2a Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期一, 22 九月 2025 14:07:08 +0800
Subject: [PATCH] 采购修改
---
src/views/inspectionManagement/components/qrCodeDia.vue | 67 +++++++++++++++++++++------------
1 files changed, 43 insertions(+), 24 deletions(-)
diff --git a/src/views/inspectionManagement/components/qrCodeDia.vue b/src/views/inspectionManagement/components/qrCodeDia.vue
index 119d9c5..136c18c 100644
--- a/src/views/inspectionManagement/components/qrCodeDia.vue
+++ b/src/views/inspectionManagement/components/qrCodeDia.vue
@@ -5,15 +5,15 @@
<el-form :model="form" :rules="rules" ref="formRef" label-width="120px">
<el-row>
<el-col :span="24">
- <el-form-item label="璁惧鍚嶇О" prop="name">
- <el-input v-model="form.name" placeholder="璇疯緭鍏ヨ澶囧悕绉�" maxlength="30" />
+ <el-form-item label="璁惧鍚嶇О" prop="deviceName">
+ <el-input v-model="form.deviceName" placeholder="璇疯緭鍏ヨ澶囧悕绉�" maxlength="30" />
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="24">
- <el-form-item label="鍦扮偣" prop="taxTrans">
- <el-input v-model="form.taxTrans" placeholder="璇疯緭鍏ュ湴鐐�" maxlength="30"/>
+ <el-form-item label="鎵�鍦ㄤ綅缃弿杩�" prop="location">
+ <el-input v-model="form.location" placeholder="璇疯緭鍏ユ墍鍦ㄤ綅缃弿杩�" maxlength="30"/>
</el-form-item>
</el-col>
</el-row>
@@ -31,7 +31,8 @@
<script setup>
import useUserStore from "@/store/modules/user.js";
import {reactive, ref} from "vue";
-import printJS from 'print-js'; // 寮曞叆 print.js
+import printJS from 'print-js';
+import {addOrEditQrCode} from "@/api/inspectionUpload/index.js";
const { proxy } = getCurrentInstance()
const emit = defineEmits()
@@ -40,16 +41,18 @@
const isShowQrCode = ref(false);
const operationType = ref('add');
-const qrCodeValue = ref('https://example.com');
+const qrCodeValue = ref('');
const qrCodeSize = ref(100);
const data = reactive({
form: {
- name: '',
- taxTrans: '',
+ deviceName: '',
+ location: '',
+ qrCodeId: '',
+ id: ''
},
rules: {
- name: [{ required: true, message: '璇疯緭鍏ヨ澶囧悕绉�', trigger: 'blur' }],
- taxTrans: [{ required: true, message: '璇疯緭鍏ュ湴鐐�', trigger: 'blur' }]
+ deviceName: [{ required: true, message: '璇疯緭鍏ヨ澶囧悕绉�', trigger: 'blur' }],
+ location: [{ required: true, message: '璇疯緭鍏ュ湴鐐�', trigger: 'blur' }]
}
})
const { form, rules } = toRefs(data)
@@ -58,22 +61,40 @@
// 鎵撳紑寮规
const openDialog = async (type, row) => {
dialogVisitable.value = true
+ qrCodeValue.value = ''
+ isShowQrCode.value = false;
+ if (type === 'edit') {
+ form.value.id = row.id
+ form.value.qrCodeId = row.id
+ form.value.deviceName = row.deviceName
+ form.value.location = row.location
+ // 灏嗚〃鍗曟暟鎹浆涓� JSON 瀛楃涓蹭綔涓轰簩缁寸爜鍐呭
+ qrCodeValue.value = JSON.stringify(form.value);
+ isShowQrCode.value = true;
+ }
}
// 鎻愪氦鍚堝苟琛ㄥ崟
const submitForm = () => {
proxy.$refs["formRef"].validate(valid => {
if (valid) {
+ addOrEditQrCode(form.value).then((res) => {
+ form.value.qrCodeId = res.data
+ })
// 灏嗚〃鍗曟暟鎹浆涓� JSON 瀛楃涓蹭綔涓轰簩缁寸爜鍐呭
qrCodeValue.value = JSON.stringify(form.value);
isShowQrCode.value = true;
-
- // 寤惰繜鎵ц鎵撳嵃锛岄伩鍏� DOM 鏇存柊鍓嶅氨璋冪敤鎵撳嵃
- setTimeout(() => {
- printJS({
- printable: 'qrCodeContainer',//椤甸潰
- type: "html",//鏂囨。绫诲瀷
- maxWidth: 360,
- style: `@page {
+ showQrCode()
+ }
+ })
+}
+const showQrCode = () => {
+ // 寤惰繜鎵ц鎵撳嵃锛岄伩鍏� DOM 鏇存柊鍓嶅氨璋冪敤鎵撳嵃
+ setTimeout(() => {
+ printJS({
+ printable: 'qrCodeContainer',//椤甸潰
+ type: "html",//鏂囨。绫诲瀷
+ maxWidth: 360,
+ style: `@page {
margin:0;
size: 400px 75px collapse;
margin-top:3px;
@@ -89,12 +110,10 @@
height: 75px;
margin:0;
}`,
- targetStyles: ["*"], // 浣跨敤dom鐨勬墍鏈夋牱寮忥紝寰堥噸瑕�
- font_size: '0.20cm',
- });
- }, 300);
- }
- })
+ targetStyles: ["*"], // 浣跨敤dom鐨勬墍鏈夋牱寮忥紝寰堥噸瑕�
+ font_size: '0.20cm',
+ });
+ }, 300);
}
// 鍏抽棴鍚堝苟琛ㄥ崟
const cancel = () => {
--
Gitblit v1.9.3