Commit 79c7da57 authored by 姬鋆屾's avatar 姬鋆屾

feat:添加二维码预览及下载

parent 9d4d9a8a
......@@ -134,7 +134,7 @@ export default {
const { siteTree } = data;
this.sitelist = siteTree;
let arr = [];
const treeFn = function(e) {
const treeFn = function (e) {
e.forEach((element) => {
arr.push(element);
if (element.children && element.children.length > 0) {
......@@ -152,6 +152,7 @@ export default {
clickSite(obj) {
local.setLocal("siteId", obj.id);
local.setLocal("siteName", obj.label);
local.setLocal("areaCode", obj.areaCode);
this.SET_SITE_ID(obj.id);
this.SET_siteName(obj.label);
this.show = false;
......
......@@ -123,13 +123,16 @@
<div class="header">
<div class="titel">基础事项列表</div>
<div class="control pdr6">
<div>
<div style="margin-right: 15px">
<a-space size="middle">
<a-button type="primary" @click="handleAddAll">
批量加入
</a-button>
<a-button type="primary" @click="addMatter"> 新增事项 </a-button>
<a-button type="primary" @click="handleImport"> 导入 </a-button>
<a-button type="primary" @click="handleDownload">
下载二维码
</a-button>
</a-space>
</div>
<div>
......@@ -211,6 +214,16 @@
<a-tag v-if="record.source == 0" color="green"> 一体化事项 </a-tag>
<a-tag v-else color="blue"> 自建事项 </a-tag>
</template>
<!-- 二维码展示 -->
<template slot="qrCode" slot-scope="{ record }"
><img
class="pointer"
width="30"
height="30"
src="@/assets/img/erweima.png"
@click="handlePreview(record)"
/></template>
<!-- 操作 -->
<template slot="action" slot-scope="{ record }">
<a-space>
......@@ -251,6 +264,8 @@ import {
delSiteMatter,
delMatter,
importDataCustom,
qrDownload,
getQrInfo,
} from "@/services/matter";
import { businessMatterList, delBusinessMatter } from "@/services/business";
import { getDeptList } from "@/services/dept";
......@@ -359,6 +374,14 @@ export default {
customRender: "matterName",
},
},
{
title: "二维码",
// ellipsis: true,
width: "100px",
scopedSlots: {
customRender: "qrCode",
},
},
{
title: "操作",
width: "140px",
......@@ -387,6 +410,67 @@ export default {
methods: {
...mapMutations("site", ["SET_matterDict"]),
// 预览二维码
async handlePreview(val) {
console.log(val);
let res = await getQrInfo({ id: val.id });
console.log(res);
let { data, code } = res.data;
if (code == 1) {
data.qrCode
? this.$viewerApi({
images: ["data:image/png;base64," + data.qrCode],
})
: "";
}
},
// 下载二维码
handleDownload() {
let _this = this;
this.$confirm({
title: "系统提示",
content:
_this.selectedBaseMatterKeys &&
_this.selectedBaseMatterKeys.length > 0
? "确定要下载所选事项的二维码吗?"
: "确定是否要下载所有事项的二维码吗?",
okText: "确定",
cancelText: "取消",
centered: true,
icon: "exclamation-circle",
maskClosable: true,
async onOk() {
console.log(_this.selectedBaseMatterKeys);
let res = await qrDownload(
{
idList: _this.selectedBaseMatterKeys,
areaCode:
_this.selectedBaseMatterKeys &&
_this.selectedBaseMatterKeys.length > 0
? ""
: local.getLocal("areaCode"),
},
{ responseType: "blob" }
);
if (res.status == 200) {
const blob = new Blob([res.data], {
type: "application/zip",
});
let fileName = "二维码" + _this.$moment().format("YYYY-MM-DD");
const link = document.createElement("a");
link.href = URL.createObjectURL(blob);
link.setAttribute("download", `${fileName}.zip`); // 设置下载文件名称
document.body.appendChild(link);
link.click();
URL.revokeObjectURL(link.href); //释放内存
}
},
onCancel() {
console.log("Cancel");
},
});
},
// 获取部门列表
async getDeptListData() {
let res = await getDeptList({
......@@ -470,8 +554,7 @@ export default {
_this.$message.success(msg);
_this.getMatterSiteData();
_this.getMatterListData();
_this.selectSiteMatterData = [];
_this.selectedSiteMatterKeys = [];
_this.selectedBaseMatterKeys = [];
_this.deleteMatterSiteRelevance(row);
}
},
......
......@@ -331,6 +331,7 @@ export default {
let res = await siteInfo({ id: this.siteId });
if (res.data.code === 1) {
let { data, dict } = res.data;
local.setLocal("areaCode", data.areaCode);
data.modelIds = data.modelIds && data.modelIds.split(",");
data.modelData = Object.keys(dict.modelIds)
.reduce(
......
const BASE_URL =
process.env.NODE_ENV === "development"
? "/api"
......@@ -73,6 +74,8 @@ module.exports = {
exportExcel: `${BASE_URL}/base/matter/exportExcel`,
matterList: `${BASE_URL}/base/matter/sublist`,
importDataCustom: `${BASE_URL}/base/matter/importDataCustom`, // 自定义导入
downloadQr: `${BASE_URL}/base/matter/genQrCode`, // 下载二维码
qrInfo: `${BASE_URL}/base/matter/interinfo`, // 获取二维码
},
// 事项申请材料
matterdatum: {
......
......@@ -65,6 +65,15 @@ export async function getMatterInfo(data) {
export async function importDataCustom(data) {
return request(matter.importDataCustom, METHOD.POST, data);
}
// 下载二维码
export async function qrDownload(data, config) {
return request(matter.downloadQr, METHOD.POST, data, config);
}
// 获取二维码
export async function getQrInfo(data) {
return request(matter.qrInfo, METHOD.GET, data);
}
/**
* 事项申请材料
*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment