罗斌杰 11 months ago
parent
commit
e1bed3fc67
  1. 3
      package.json
  2. 38
      src/components/order_statistics/orderStatistics.vue

3
package.json

@ -21,7 +21,8 @@
"vue": "^3.4.21",
"vue-router": "^4.3.0",
"vue3-print-nb": "^0.1.4",
"vuex": "^4.1.0"
"vuex": "^4.1.0",
"xlsx": "^0.18.5"
},
"devDependencies": {
"@vitejs/plugin-vue": "^5.0.4",

38
src/components/order_statistics/orderStatistics.vue

@ -52,6 +52,9 @@
<el-button :icon="Search" @click="btnQuery"
:style="`margin-left: 0px;min-width:40px;color:#67C23A;font-size: ${state.winForm.icon.size}px;`" />
</el-tooltip>
<div style="margin-left:15px">
<el-button type="primary" @click="exportToExcel">导出Excel</el-button>
</div>
</div>
<!-- 数据表格 -->
<div :id="`el_${data.base.name}_table`">
@ -85,7 +88,8 @@ import { reactive, ref, getCurrentInstance, computed, onMounted, watch, nextTick
import { ElTable, ElMessage, ElMessageBox } from 'element-plus'
import { Plus, Operation, Message, MoreFilled, Search, Setting, Edit, Delete } from '@element-plus/icons-vue'
import { useStore } from 'vuex'
import { saveAs } from 'file-saver';
import * as XLSX from 'xlsx';
//
import { abcfun } from 'abcfun'
@ -166,6 +170,38 @@ const disabledWeeks = (rowIndex: number, weekId: number) => {
const menuSelect = (key: string, keyPath: string[]) => {
console.log(key, keyPath)
}
const exportToExcel=()=>{
var wb = XLSX.utils.table_to_book(document.querySelector('#tableId'),{ raw: true });//dom
var wbout = XLSX.write(wb, {
bookType: 'xlsx',
bookSST: true,
type: 'array'
})
let fileName = formatDate(new Date())
try {
saveAs(new Blob([wbout], {
type: 'text/plain;charset=utf-8'
}), fileName+'.xlsx')//
} catch (e) {
if (typeof console !== 'undefined') console.log(e, wbout);
}
return wbout
}
const formatDate=(date)=> {
let year = date.getFullYear();
// year = year.toString().slice(2, 4); //
let month = date.getMonth() + 1; // 0+1
month = month < 10 ? '0' + month : month; // 100
let day = date.getDate();
day = day < 10 ? '0' + day : day; // 100
let h = date.getHours(); //
let m = date.getMinutes(); //
let s = date.getSeconds(); //
return `${year}${month}${day}${h}${m}${s}`;
}
// --
const btnQuery = () => {
axios.post(appConfig, '/api/app/AppointPatientRegister/GetAppointPatientRegisterList', {

Loading…
Cancel
Save