Browse Source

:sparkles:增加导出文件时间

limengbo 3 years ago
parent
commit
541e89949d

+ 1 - 1
build/webpack.base.conf.js

@@ -8,7 +8,7 @@ const AutoDllPlugin = require('autodll-webpack-plugin');
 
 module.exports = {
   entry: {
-    bundle: path.resolve(__dirname, '../src/main.js')
+    bundle: [path.resolve(__dirname, '../src/main.js')]
   },
   output: {
     path: path.resolve(__dirname, '../resourcesWeb'),

+ 1 - 1
build/webpack.dev.conf.js

@@ -43,7 +43,7 @@ module.exports = merge(baseConfig, {
     contentBase: path.resolve(__dirname, '../dist'), //告诉服务其从哪提供内容
     hot: true,
     open: true,
-    // host: '192.168.1.128'
+    host: '192.168.1.226'
   },
   plugins: [
     new webpack.HotModuleReplacementPlugin(), // 开启热更新

+ 4 - 2
src/pages/mobile/Mobile.vue

@@ -276,7 +276,9 @@ export default {
     },
     // 导出表格
     onExportExcel() {
-      const name = this.efunChannelList.filter((item) => item.code === this.efunParams.channel)[0].name
+      const nameList = this.efunChannelList.filter((item) => item.code === this.efunParams.channel)[0]
+      const name = (nameList && nameList.name) || ''
+      const date = new Date().toLocaleDateString()
       downTable('table', [
           {wch: 15}, // "characters"
           {wch: 6},
@@ -293,7 +295,7 @@ export default {
           {wch: 10},
           {wch: 10},
           {wch: 25}
-        ], name)
+        ], name + date)
     }
   }
 };

+ 4 - 2
src/pages/order/Order.vue

@@ -338,9 +338,11 @@ export default {
     },
     // 导出表格
     onExportExcel() {
-        const name = this.channeList.list.filter((item) => item.code === this.orderParams.channelCode)[0].title
+        const nameList = this.channeList.list.filter((item) => item.code === this.orderParams.channelCode)[0]
+        const name = (nameList && nameList.title) || ''
         const list = this.productList.filter((item) => item.id === this.orderParams.packageId)[0]
         const productName = list && list.title ? '-' + list.title : ''
+        const date = new Date().toLocaleDateString()
         downTable('table', [
           {wch: 15}, // "characters"
           {wch: 6},
@@ -360,7 +362,7 @@ export default {
           {wch: 10},
           {wch: 20},
           {wch: 25}
-        ], name + productName)
+        ], name + productName + date)
     },
   }
 };

+ 5 - 3
src/pages/skill/Skill.vue

@@ -596,9 +596,11 @@ export default {
     },
     // 导出表格
     onExportExcel() {
-        const name = this.skillChanneList.filter((item) => item.code === this.skillParams.channel)[0].title
-        const list = this.skillList.filter((item) => item.skillId === this.skillParams.skillId)[0]
+        const nameList = this.skillChanneList.filter((item) => item.code === this.skillParams.channel)[0]
+        const name = (nameList && nameList.title) || ''
+        const list = this.skillList.filter((item) => item.skillId === this.skillParams.skillId)[0] || ''
         const productName = list && list.skillName ? '-' + list.skillName : ''
+        const date = new Date().toLocaleDateString()
         downTable('table', [
           {wch: 15}, // "characters"
           {wch: 6},
@@ -618,7 +620,7 @@ export default {
           {wch: 10},
           {wch: 20},
           {wch: 25}
-        ], name + productName)
+        ], name + productName + date)
     }
   }
 };

+ 4 - 2
src/pages/tv/TV.vue

@@ -275,7 +275,9 @@ export default {
     },
     // 导出表格
     onExportExcel() {
-      const name = this.efunChannelList.filter((item) => item.code === this.efunParams.channel)[0].name
+      const nameList = this.efunChannelList.filter((item) => item.code === this.efunParams.channel)[0]
+      const name = (nameList && nameList.name) || ''
+      const date = new Date().toLocaleDateString()
         downTable('table', [
           {wch: 15}, // "characters"
           {wch: 6},
@@ -292,7 +294,7 @@ export default {
           {wch: 10},
           {wch: 10},
           {wch: 25}
-        ], name)
+        ], name + date)
     }
   }
 };

+ 19 - 1
src/utils/downTable.js

@@ -9,7 +9,6 @@ import { Message, MessageBox } from 'element-ui'
  */
  const downTable = (id, width, name) => {
     name = name + '.xlsx' || 'test.xlsx'
-    console.log(document.getElementById(id))
     const excel = exportExcel(document.getElementById(id), width, name)
     if (excel) {
         Message({
@@ -34,7 +33,26 @@ import { Message, MessageBox } from 'element-ui'
       } else {
         wb = XLSX.utils.table_to_book(ele);
       }
+      console.log(wb.Sheets.Sheet1, Object.keys(wb.Sheets.Sheet1).filter(item => /^\D\d$/.test(item)))
+      // 修改表格内容宽度
       wb.Sheets.Sheet1['!cols'] = wscols;
+      // 新增样式 xlsl-style引入有问题暂时注释
+      // const Sheet1Key = wb.Sheets.Sheet1
+      // Object.keys(Sheet1Key).forEach(item => {
+      //   if (/^\D\d$/.test(item)) {
+      //     Sheet1Key[item].s =  {
+      //       font: {
+      //         color: {
+      //           rgb: 'FF4F81BD'  //字体颜色
+      //         }
+      //       },
+      //       alignment: {
+      //         horizontal: 'center'
+      //       }
+      //     }
+      //   }
+      // })
+      console.log(wb.Sheets.Sheet1)
       /* 获取二进制字符串作为输出 */
       const wbout = XLSX.write(wb, { bookType: 'xlsx', bookSST: true, type: 'array', cellDates: true })
       try {