Ver Fonte

蛋糕券

fanzherong_v há 4 meses atrás
pai
commit
e17757b625

+ 96 - 1
snowy-admin-web/src/views/biz/couponrecord/index.vue

@@ -54,17 +54,40 @@
 							record.couponStatus === '0'
 								? '#87d068'
 								: record.couponStatus === '1'
-								  ? '#f50'
+								  ? '#2db7f5b '
 								      : '#f50'
 						"
 					>
 						{{ $TOOL.dictTypeData('is_destroy', record.couponStatus) }}
 					</a-tag>
 				</template>
+
+				<template v-if="column.dataIndex === 'userName'">
+					<span @click="showModal(record)">{{record.userName}}</span>
+				</template>
 			</template>
 		</s-table>
 	</a-card>
 	<Form ref="formRef" @successful="tableRef.refresh()" />
+
+	<a-modal v-model:visible="open" title="二维码">
+		<div id="qrcode" style="text-align: center; margin: 15px;">
+			<a-row>
+				<a-col :span="24">
+					<a-image width="206" :src="qrCodeUrl.codeUrl">
+						<template #default>
+							<img src="https://www.antdv.com/assets/logo.1ef800a8.svg" class="icon" alt="Icon" />
+						</template>
+					</a-image>
+				</a-col>
+			</a-row>
+
+		</div>
+		<template #footer>
+			<a-button @click="closeQrCode">关闭</a-button>
+			<a-button type="primary" @click="downloadFile">下载</a-button>
+		</template>
+	</a-modal>
 </template>
 
 <script setup name="couponrecord">
@@ -77,7 +100,10 @@
 	const tableRef = ref()
 	const formRef = ref()
 	const toolConfig = { refresh: true, height: true, columnSetting: true, striped: false }
+	import QRCode from 'qrcode'
+	import html2canvas from 'html2canvas'
 	const couponStatusList = tool.dictList('is_destroy')
+
 	const columns = [
 		{
 			title: '序号',
@@ -150,6 +176,75 @@
 			width: 150
 		})
 	}*/
+
+	//二维码
+	const open = ref(false);
+	const qrCodeUrl = ref({})
+	const qrcodeCanvasRef = ref();
+	const nowRecord = ref({})
+
+	const showModal = (record) => {
+		nowRecord.value = record
+		open.value = true;
+		getQrCode(record)
+
+	};
+
+	const getQrCode = (record) => {
+		//QRCode.toDataURL("id:"+record.id+"saleCode:"+record.saleCode, {
+		let param = {
+			id:record.couponNo
+		}
+		QRCode.toDataURL(JSON.stringify(param), {
+			errorCorrectionLevel: 'H',
+			margin: 1,
+			height: 206,
+			width: 206,
+			type: '10',
+			scal: 177,
+			color: {
+				dark: '#000' // 二维码背景颜色
+			},
+			rendererOpts: {
+				quality: 0.9
+			},
+			icon:'/public/img/tanglogo.png'
+		})
+			.then((url) => {
+				qrCodeUrl.value.codeUrl = url
+			})
+			.catch((err) => {
+				console.error(err)
+			})
+	}
+
+	const closeQrCode = () => {
+		open.value = false;
+	}
+
+	// 下载二维码
+	const downloadFile = () => {
+		html2canvas(qrcode, {
+			logging: false,
+			allowTaint: true,
+			scale: window.devicePixelRatio,
+			scrollY: 0,
+			scrollX: 0,
+			useCORS: true,
+			backgroundColor: '#ffffff'
+		})
+			.then(function (canvas) {
+				const a = window.document.createElement('a')
+				a.href = canvas.toDataURL('image/png')
+				a.download = '二维码'
+				a.click()
+				this.$message.success('正在进行下载保存')
+			})
+			.catch((err) => {
+				console.log(err)
+			})
+	}
+
 	const selectedRowKeys = ref([])
 	// 列表选择配置
 	const options = {

+ 1 - 1
snowy-plugin/snowy-plugin-biz/src/main/java/vip/xiaonuo/biz/modular/couponrecord/param/BizCouponRecordPageParam.java

@@ -54,7 +54,7 @@ public class BizCouponRecordPageParam {
 
     /** 是否核销: 0.否 1.是 */
     @Schema(description = "是否核销: 0.否 1.是")
-    private Boolean couponStatus;
+    private String couponStatus;
 
     private String beginTime;
     private String endTime;