|
@@ -902,6 +902,7 @@ import { accountBalance, addRecharge } from '@/api/order/examine'
|
|
|
import { parseMoney } from '@/utils/index'
|
|
|
import VDistpicker from 'v-distpicker'
|
|
|
import examine from './examine2'
|
|
|
+import XLSX from 'xlsx-js-style'
|
|
|
const giftList = {
|
|
|
'订单编号': '',
|
|
|
'快递公司': '',
|
|
@@ -2264,20 +2265,23 @@ export default {
|
|
|
// 活动拆单新
|
|
|
exporOrderthuodongNew() {
|
|
|
if (this.chooseList.length) {
|
|
|
- this.$request(chaidans({ id: this.chooseList.map(e => e.id) }), (res) => {
|
|
|
- this.expressData = res
|
|
|
- const exportData = this.getExportModuleNew()
|
|
|
- import('@/vendor/Export2Excel').then(excel => {
|
|
|
- excel.export_json_to_excel({
|
|
|
- header: Object.keys(moduleList),
|
|
|
- data: exportData.map(listItem => Object.keys(exportData[0]).map(j => listItem[j])),
|
|
|
- filename: `${new Date().toLocaleDateString()}活动快递单导出`,
|
|
|
- bookType: 'xlsx',
|
|
|
- isCSV: true
|
|
|
- })
|
|
|
- this.dialog.export_order = false
|
|
|
- })
|
|
|
+ this.$request(chaidan({ id: this.chooseList.map(e => e.id) }), (res) => {
|
|
|
+ this.changeExcelStyle(res)
|
|
|
})
|
|
|
+ // this.$request(chaidans({ id: this.chooseList.map(e => e.id) }), (res) => {
|
|
|
+ // this.expressData = res
|
|
|
+ // const exportData = this.getExportModuleNew()
|
|
|
+ // import('@/vendor/Export2Excel').then(excel => {
|
|
|
+ // excel.export_json_to_excel({
|
|
|
+ // header: Object.keys(moduleList),
|
|
|
+ // data: exportData.map(listItem => Object.keys(exportData[0]).map(j => listItem[j])),
|
|
|
+ // filename: `${new Date().toLocaleDateString()}活动快递单导出`,
|
|
|
+ // bookType: 'xlsx',
|
|
|
+ // isCSV: true
|
|
|
+ // })
|
|
|
+ // this.dialog.export_order = false
|
|
|
+ // })
|
|
|
+ // })
|
|
|
} else {
|
|
|
let query = {}
|
|
|
if (!this.highSearchFlag) {
|
|
@@ -2320,21 +2324,73 @@ export default {
|
|
|
}
|
|
|
}
|
|
|
this.$request(chaidans(query), (res) => {
|
|
|
- this.expressData = res
|
|
|
- const exportData = this.getExportModuleNew()
|
|
|
- import('@/vendor/Export2Excel').then(excel => {
|
|
|
- excel.export_json_to_excel({
|
|
|
- header: Object.keys(moduleList),
|
|
|
- data: exportData.map(listItem => Object.keys(exportData[0]).map(j => listItem[j])),
|
|
|
- filename: `${new Date().toLocaleDateString()}活动快递单导出`,
|
|
|
- bookType: 'xlsx',
|
|
|
- isCSV: true
|
|
|
- })
|
|
|
- this.dialog.export_order = false
|
|
|
- })
|
|
|
+ this.changeExcelStyle(res)
|
|
|
})
|
|
|
}
|
|
|
},
|
|
|
+ // 活动拆单新 改变导出表格 某一行文字颜色
|
|
|
+ changeExcelStyle(res) {
|
|
|
+ this.expressData = res
|
|
|
+ const exportData = this.getExportModuleNew()
|
|
|
+ const data = exportData.map(listItem => Object.keys(exportData[0]).map(j => listItem[j]))
|
|
|
+ const header = Object.keys(moduleList)
|
|
|
+ header.push('是否满箱')
|
|
|
+
|
|
|
+ data.unshift(header) // 表头和表格内容拼在一起
|
|
|
+
|
|
|
+ const aoa = data
|
|
|
+ const date = new Date().toLocaleDateString().replace(/\//g, '-') // 名称不能包含以下任何字符:\ / ? * [
|
|
|
+ const filename = `${date}活动快递单导出.xlsx`
|
|
|
+ const ws_name = `${date}活动快递单`
|
|
|
+ const wb = XLSX.utils.book_new()
|
|
|
+ const ws = XLSX.utils.aoa_to_sheet(aoa)
|
|
|
+ var style = {
|
|
|
+ font: {
|
|
|
+ // bold: true,
|
|
|
+ color: { rgb: 'FFFF0000' }
|
|
|
+ }
|
|
|
+ // alignment: { horizontal: "center" },
|
|
|
+ // fill: { fgColor: { rgb: "FFFF0000" } },
|
|
|
+ }
|
|
|
+ // 获取列名
|
|
|
+ function getColumnName(num) {
|
|
|
+ var columnName = ''
|
|
|
+ while (num) {
|
|
|
+ const remainder = num % 26
|
|
|
+ if (remainder === 0) {
|
|
|
+ columnName = 'Z' + columnName
|
|
|
+ num = Math.floor(num / 26) - 1
|
|
|
+ } else {
|
|
|
+ columnName = String.fromCharCode(64 + remainder) + columnName
|
|
|
+ num = Math.floor(num / 26)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return columnName
|
|
|
+ }
|
|
|
+ const rowsToColor = {} // 保存需要上色的行
|
|
|
+
|
|
|
+ for (const cell in ws) {
|
|
|
+ if (cell[0] === '!') continue
|
|
|
+ const cell_position = XLSX.utils.decode_cell(cell)
|
|
|
+ const colName = getColumnName(cell_position.c + 1)
|
|
|
+
|
|
|
+ if (colName === 'AM' && ws[cell].v) {
|
|
|
+ rowsToColor[cell_position.r] = true // 保存需要上色的行
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 遍历所有单元格,为需要上色的行上色
|
|
|
+ for (const cell in ws) {
|
|
|
+ if (cell[0] === '!') continue
|
|
|
+ const cell_position = XLSX.utils.decode_cell(cell)
|
|
|
+ if (rowsToColor[cell_position.r] && cell_position.r !== 0) { // 不为第一行上色
|
|
|
+ if (!ws[cell].s) ws[cell].s = {}
|
|
|
+ Object.assign(ws[cell].s, style)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ XLSX.utils.book_append_sheet(wb, ws, ws_name) // 将数据添加到工作薄
|
|
|
+ XLSX.writeFile(wb, filename) // 导出Excel
|
|
|
+ this.dialog.export_order = false
|
|
|
+ },
|
|
|
// 非活动拆单
|
|
|
async exporOrdertOrder() {
|
|
|
if (this.chooseList.length) {
|
|
@@ -2684,6 +2740,7 @@ export default {
|
|
|
obj['订单状态'] = info.status
|
|
|
obj['支付状态'] = info.pay_status
|
|
|
obj['体验店或专车'] = info.store
|
|
|
+ obj['是否满箱'] = '精装满箱'
|
|
|
// obj['赠品'] = info.gift.map(item => `${item.name}${item.num}`).join(';')
|
|
|
let num_all = 0
|
|
|
if (item['精装'][a].sec_attr === '男女款') {
|
|
@@ -2733,6 +2790,7 @@ export default {
|
|
|
obj['订单状态'] = info.status
|
|
|
obj['支付状态'] = info.pay_status
|
|
|
obj['体验店或专车'] = info.store
|
|
|
+ obj['是否满箱'] = `${item['普通'][b].main_attr === '高' ? '高腰' : '青春'}满箱`
|
|
|
// obj['赠品'] = info.gift.map(item => `${item.name}${item.num}`).join(';')
|
|
|
let num_all = 0
|
|
|
if (item['普通'][b].sec_attr === '男女款') {
|
|
@@ -2782,6 +2840,7 @@ export default {
|
|
|
obj['订单状态'] = info.status
|
|
|
obj['支付状态'] = info.pay_status
|
|
|
obj['体验店或专车'] = info.store
|
|
|
+ obj['是否满箱'] = ''
|
|
|
// obj['赠品'] = info.gift.map(item => `${item.name}${item.num}`).join(';')
|
|
|
let num_all = 0
|
|
|
if (item['精装混合'][c].sec_attr === '男女款') {
|
|
@@ -2831,6 +2890,7 @@ export default {
|
|
|
obj['订单状态'] = info.status
|
|
|
obj['支付状态'] = info.pay_status
|
|
|
obj['体验店或专车'] = info.store
|
|
|
+ obj['是否满箱'] = ''
|
|
|
// obj['赠品'] = info.gift.map(item => `${item.name}${item.num}`).join(';')
|
|
|
let num_all = 0
|
|
|
if (item['普通混合'][d].sec_attr === '男女款') {
|