liudan 8 months ago
parent cec9276f4f
commit 317514622e
  1. 8
      view/admin/package.json
  2. 84
      view/admin/src/views/dataStatistic/statistic.vue
  3. 30
      view/admin/src/views/marketing/assets/index.vue
  4. 2
      view/mer/src/api/setting.js
  5. 2
      view/mer/src/views/systemForm/setSystem/modifyStoreInfo.vue

@ -55,11 +55,13 @@
"echarts": "^4.2.1", "echarts": "^4.2.1",
"element-ui": "^2.15.12", "element-ui": "^2.15.12",
"exceljs": "^4.3.0", "exceljs": "^4.3.0",
"file-saver": "2.0.1", "file-saver": "^2.0.5",
"fuse.js": "3.4.4", "fuse.js": "3.4.4",
"html2canvas": "^1.1.0", "html-docx-js": "^0.3.1",
"html2canvas": "^1.4.1",
"js-cookie": "2.2.0", "js-cookie": "2.2.0",
"jsonlint": "1.6.3", "jsonlint": "1.6.3",
"jspdf": "^2.5.1",
"jszip": "3.2.1", "jszip": "3.2.1",
"krry-transfer": "^1.2.21", "krry-transfer": "^1.2.21",
"lowdb": "^1.0.0", "lowdb": "^1.0.0",
@ -86,7 +88,7 @@
"vuedraggable": "2.20.0", "vuedraggable": "2.20.0",
"vuex": "3.1.0", "vuex": "3.1.0",
"wangeditor": "^4.7.12", "wangeditor": "^4.7.12",
"xlsx": "0.14.1" "xlsx": "^0.14.1"
}, },
"devDependencies": { "devDependencies": {
"@babel/core": "7.0.0", "@babel/core": "7.0.0",

@ -1,17 +1,17 @@
<template> <template>
<div class="statistic"> <div class="statistic">
<el-button type="primary">导出数据统计</el-button> <el-button type="primary" @click="exportToWord">导出数据统计</el-button>
<div class="contentContainer"> <div class="contentContainer" id="table" ref="pdfContent">
<div class="section" v-for="(item,index) in list" :key="index"> <div class="section" style=" display: flex;align-items: center;margin: 40px 0;" v-for="(item,index) in list" :key="index">
<div class="sectionTitle">{{item.title}}</div> <div class="sectionTitle" style=" font-size: 18px;font-weight: bold;width: 160px;flex-shrink: 0;">{{item.title}}</div>
<div class="content"> <div class="content" style="display: flex;">
<div v-for="(p,i) in item.data" class="sectionDesc"> <div v-for="(p,i) in item.data" class="sectionDesc" style="width:200px;">
<div class="item">{{p.name}}</div> <div class="item">{{p.name}}</div>
<div class="num" v-if="index==0">{{huitong[p.countText]}}</div> <div class="num" style="font-size: 24px;margin-top: 8px;" v-if="index==0">{{huitong[p.countText]}}</div>
<div class="num" v-if="index==1">{{welfare[p.countText]}}</div> <div class="num" style="font-size: 24px;margin-top: 8px;" v-if="index==1">{{welfare[p.countText]}}</div>
<div class="num" v-if="index==2">{{consume[p.countText]}}</div> <div class="num" style="font-size: 24px;margin-top: 8px;" v-if="index==2">{{consume[p.countText]}}</div>
<div class="num" v-if="index==3">{{contribution[p.countText]}}</div> <div class="num" style="font-size: 24px;margin-top: 8px;" v-if="index==3">{{contribution[p.countText]}}</div>
<div class="num" v-if="index==4">{{share_point[p.countText]}}</div> <div class="num" style="font-size: 24px;margin-top: 8px;" v-if="index==4">{{share_point[p.countText]}}</div>
</div> </div>
</div> </div>
</div> </div>
@ -19,7 +19,12 @@
</div> </div>
</template> </template>
<script> <script>
import {getStatisticList} from '@/api/statistic' import {getStatisticList} from '@/api/statistic';
import htmlDocx from 'html-docx-js/dist/html-docx';
import FileSaver from 'file-saver';
// import html2canvas from 'html2canvas';
// import jsPDF from 'jspdf';
export default{ export default{
data(){ data(){
return{ return{
@ -111,6 +116,37 @@ export default{
} }
}, },
methods:{ methods:{
exportToWord() {
// HTML
const htmlContent = document.querySelector('#table').outerHTML;
// // HTMLDocx
// const docxContent = htmlDocx.asBlob(htmlContent);
// //
// const downloadLink = document.createElement('a');
// downloadLink.href = URL.createObjectURL(docxContent);
// downloadLink.download = '.docx';
// //
// downloadLink.click();
const fullHtmlContent = `
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
${htmlContent}
</body>
</html>
`;
// 使 html-docx-js HTML Word Blob
const converted = htmlDocx.asBlob(fullHtmlContent);
// 使 file-saver Blob Word
FileSaver.saveAs(converted, '数据统计.docx');
},
getStatisticListHandle(){ getStatisticListHandle(){
getStatisticList().then(res=>{ getStatisticList().then(res=>{
@ -121,7 +157,29 @@ export default{
}) })
}) })
} },
// exportPDF() {
// const title = 'PDF';
// const content = this.$refs.pdfContent;
// // 使html2canvasDOM
// html2canvas(content).then(canvas => {
// // jspdf
// const pdf = new jsPDF();
// // canvas
// const imgData = canvas.toDataURL('image/png');
// // PDF
// const imgProps= pdf.getImageProperties(imgData);
// const pdfWidth = pdf.internal.pageSize.getWidth();
// const pdfHeight = (imgProps.height * pdfWidth) / imgProps.width;
// pdf.addImage(imgData, 'PNG', 0, 0, pdfWidth, pdfHeight);
// // PDF
// pdf.save(title + '.pdf');
// });
// }
}, },
created(){ created(){
this.getStatisticListHandle() this.getStatisticListHandle()

@ -65,10 +65,11 @@
/> />
</el-form-item> </el-form-item>
<el-button size="small" type="primary" icon="el-icon-search" @click="getList()">搜索</el-button> <el-button size="small" type="primary" icon="el-icon-search" @click="getList()">搜索</el-button>
<el-button size="small" type="primary" @click="exportTableToExcel('table', 'exported-data')">导出</el-button>
</el-form> </el-form>
</div> </div>
</div> </div>
<el-table v-loading="loading" :data="tableData.data" style="width: 100%" size="small"> <el-table v-loading="loading" :data="tableData.data" style="width: 100%" size="small" id="table">
<el-table-column label="ID" prop="id" min-width="80"/> <el-table-column label="ID" prop="id" min-width="80"/>
<el-table-column label="用户昵称" prop="user_nickname" min-width="120"/> <el-table-column label="用户昵称" prop="user_nickname" min-width="120"/>
<el-table-column label="手机" prop="user_phone" min-width="120"/> <el-table-column label="手机" prop="user_phone" min-width="120"/>
@ -98,6 +99,9 @@ import { mapState } from "vuex";
import {discountsList, discountsChangeStatus, discountsGetDetails, assetsLogList} from "@/api/marketing"; import {discountsList, discountsChangeStatus, discountsGetDetails, assetsLogList} from "@/api/marketing";
import { formatDate } from "@/utils/validate"; import { formatDate } from "@/utils/validate";
import { roterPre } from '@/settings' import { roterPre } from '@/settings'
import { saveAs } from 'file-saver';
import * as XLSX from 'xlsx';
export default { export default {
name: "Discounts", name: "Discounts",
filters: { filters: {
@ -124,7 +128,7 @@ export default {
phone: "", phone: "",
page: 1, page: 1,
asset_type: "", asset_type: "",
limit: 15, limit: 20,
}, },
specsMainData: [], specsMainData: [],
specsData: [], specsData: [],
@ -151,6 +155,28 @@ export default {
this.getList(''); this.getList('');
}, },
methods: { methods: {
exportTableToExcel(tableId, fileName) {
/* 获取表格数据 */
const ws = XLSX.utils.table_to_sheet(document.getElementById(tableId));
/* 新建工作簿并添加工作表 */
const wb = XLSX.utils.book_new();
XLSX.utils.book_append_sheet(wb, ws, "Sheet1");
/* 生成Excel文件 */
const wbout = XLSX.write(wb, { bookType: 'xlsx', type: 'binary' });
/* 字符串转ArrayBuffer */
function s2ab(s) {
const buf = new ArrayBuffer(s.length);
const view = new Uint8Array(buf);
for (let i = 0; i !== s.length; ++i) view[i] = s.charCodeAt(i) & 0xFF;
return buf;
}
/* 保存文件 */
saveAs(new Blob([s2ab(wbout)], { type: 'application/octet-stream' }), fileName + '.xlsx');
},
// //
handleDetail(id) { handleDetail(id) {
this.dialogVisible = true; this.dialogVisible = true;

@ -240,7 +240,7 @@ export function updatedumpDataApi(data) {
} }
//获取区域列表 //获取区域列表
export function getArea(id) { export function getArea(id) {
return request.get(`store/city/lst/${id}`) return request.get(`v2/system/city/lst/${id}`)
} }
// export function getArea() { // export function getArea() {
// return request.get('system/city/lst') // return request.get('system/city/lst')

@ -522,7 +522,7 @@ export default {
value1: "", value1: "",
value2: "", value2: "",
merData: { merData: {
district_id:null, district_id:[],
delivery_way: [], delivery_way: [],
mer_take_name: '', mer_take_name: '',
mer_take_phone: '', mer_take_phone: '',

Loading…
Cancel
Save