|
|
@ -35,12 +35,21 @@ |
|
|
|
<el-input v-model="shujuchuliObj.sku" size="large" |
|
|
|
style="width: 200px;display: inline-block;margin-right: 16px;" placeholder="请输入SKU" clearable> |
|
|
|
</el-input> |
|
|
|
<el-date-picker v-model="shujuchuliObj.time" type="datetimerange" :shortcuts="shortcuts" range-separator="至" |
|
|
|
start-placeholder="开始导入时间" end-placeholder="结束导入时间" size="large" |
|
|
|
style="display: inline-block;margin-right: 16px;" value-format="YYYY-MM-DD HH:mm:ss" /> |
|
|
|
<el-button type="primary" @click="updateSeach" size="large"> |
|
|
|
<el-icon> |
|
|
|
<Delete /> |
|
|
|
<Search /> |
|
|
|
</el-icon> |
|
|
|
<span>搜索</span> |
|
|
|
</el-button> |
|
|
|
<el-button type="primary" @click="exportData" size="large"> |
|
|
|
<el-icon> |
|
|
|
<Download /> |
|
|
|
</el-icon> |
|
|
|
<span>导出</span> |
|
|
|
</el-button> |
|
|
|
</el-col> |
|
|
|
</el-row> |
|
|
|
</div> |
|
|
@ -69,6 +78,8 @@ import * as XLSX from 'xlsx'; |
|
|
|
import tableHeaderLocal from '../assets/json/shujuchuli.json' |
|
|
|
import { myDatabase } from '../assets/js/db.js' |
|
|
|
import dayjs from 'dayjs' |
|
|
|
let isBetween = require('dayjs/plugin/isBetween') |
|
|
|
dayjs.extend(isBetween) |
|
|
|
import tablecomponent from "../components/tablecomponent.vue" |
|
|
|
import formcomponent from "../components/formcomponent.vue" |
|
|
|
import { ElMessage, ElMessageBox } from 'element-plus' |
|
|
@ -111,8 +122,59 @@ export default { |
|
|
|
fileOriData: null, |
|
|
|
count: 0, |
|
|
|
shujuchuliObj: { |
|
|
|
sku: "" |
|
|
|
} |
|
|
|
sku: "", |
|
|
|
time: [] |
|
|
|
}, |
|
|
|
shortcuts: [ |
|
|
|
{ |
|
|
|
text: '0-24小时', |
|
|
|
value: () => { |
|
|
|
return [dayjs().subtract(24, 'hour'), dayjs()]; |
|
|
|
} |
|
|
|
}, |
|
|
|
{ |
|
|
|
text: '24-48小时', |
|
|
|
value: () => { |
|
|
|
return [dayjs().subtract(48, 'hour'), dayjs().subtract(24, 'hour')]; |
|
|
|
} |
|
|
|
}, |
|
|
|
{ |
|
|
|
text: '两天内', |
|
|
|
value: () => { |
|
|
|
return [dayjs().subtract(2, 'day'), dayjs()]; |
|
|
|
} |
|
|
|
}, |
|
|
|
{ |
|
|
|
text: '一周内', |
|
|
|
value: () => { |
|
|
|
return [dayjs().subtract(1, 'week'), dayjs()]; |
|
|
|
} |
|
|
|
}, |
|
|
|
{ |
|
|
|
text: '一月内', |
|
|
|
value: () => { |
|
|
|
return [dayjs().subtract(1, 'month'), dayjs()]; |
|
|
|
} |
|
|
|
}, |
|
|
|
{ |
|
|
|
text: '三月内', |
|
|
|
value: () => { |
|
|
|
return [dayjs().subtract(3, 'month'), dayjs()]; |
|
|
|
} |
|
|
|
}, |
|
|
|
{ |
|
|
|
text: '半年内', |
|
|
|
value: () => { |
|
|
|
return [dayjs().subtract(6, 'month'), dayjs()]; |
|
|
|
} |
|
|
|
}, |
|
|
|
{ |
|
|
|
text: '一年内', |
|
|
|
value: () => { |
|
|
|
return [dayjs().subtract(1, 'year'), dayjs()]; |
|
|
|
} |
|
|
|
} |
|
|
|
], |
|
|
|
} |
|
|
|
}, |
|
|
|
methods: { |
|
|
@ -154,10 +216,13 @@ export default { |
|
|
|
async updateSeach() { |
|
|
|
this.loading = true |
|
|
|
let collection = myDatabase.shujuchuli |
|
|
|
if (this.shujuchuliObj.sku) { |
|
|
|
if (_.isEmpty(_.trim(this.shujuchuliObj.sku))) { |
|
|
|
let reg = new RegExp(this.shujuchuliObj.sku, "i") |
|
|
|
collection = collection.filter((equip) => reg.test(equip.SKU)) |
|
|
|
} |
|
|
|
if (!_.isEmpty(this.shujuchuliObj.time)) { |
|
|
|
collection = collection.filter((equip) => dayjs(equip.create_at).isBetween(this.shujuchuliObj.time[0], this.shujuchuliObj.time[1], null, '[)')) |
|
|
|
} |
|
|
|
this.pageVO.total = await collection.count() |
|
|
|
this.tableData = await collection.offset((this.pageVO.currentPage - 1) * this.pageVO.pageSize).limit(this.pageVO.pageSize).toArray() |
|
|
|
if (this.pageVO.total > this.pageVO.pageSizes[3]) { |
|
|
@ -222,8 +287,10 @@ export default { |
|
|
|
"颜色代码": ziliaoItem["颜色"], |
|
|
|
"图片名称": `${ziliaoItem["货号"]}.jpg`, |
|
|
|
"国际码": ziliaoItem["国标码"], |
|
|
|
"数量": `${valueLength}`, |
|
|
|
"数量": `${1}`, |
|
|
|
"总数量": `${valueLength}`, |
|
|
|
"下单数": ``, |
|
|
|
"uniqyKey": `${element["唯一码"]}${element["防伪码"]}`, |
|
|
|
create_at: dayjs().format('YYYY-MM-DD HH:mm:ss'), |
|
|
|
update_at: dayjs().format('YYYY-MM-DD HH:mm:ss') |
|
|
|
} |
|
|
@ -362,6 +429,64 @@ export default { |
|
|
|
}) |
|
|
|
}) |
|
|
|
}, |
|
|
|
// 导出数据 |
|
|
|
async exportData() { |
|
|
|
let collection = myDatabase.shujuchuli |
|
|
|
if (_.isEmpty(_.trim(this.shujuchuliObj.sku))) { |
|
|
|
let reg = new RegExp(this.shujuchuliObj.sku, "i") |
|
|
|
collection = collection.filter((equip) => reg.test(equip.SKU)) |
|
|
|
} |
|
|
|
if (!_.isEmpty(this.shujuchuliObj.time)) { |
|
|
|
collection = collection.filter((equip) => dayjs(equip.create_at).isBetween(this.shujuchuliObj.time[0], this.shujuchuliObj.time[1], null, '[)')) |
|
|
|
} |
|
|
|
let listCopy = await collection.toArray() |
|
|
|
let groupByData = _.groupBy(listCopy, "货号") |
|
|
|
let workBook = { |
|
|
|
SheetNames: [], |
|
|
|
Sheets: {} |
|
|
|
} |
|
|
|
if (listCopy.length) { |
|
|
|
for (let key in groupByData) { |
|
|
|
let list = [] |
|
|
|
let value = groupByData[key] |
|
|
|
for (let i = 0; i < value.length; i++) { |
|
|
|
let element = value[i]; |
|
|
|
list.push({ |
|
|
|
唯一码: element["唯一码"], |
|
|
|
防伪码: element["防伪码"], |
|
|
|
品名: element["品名"], |
|
|
|
货号: element["货号"], |
|
|
|
颜色: element["颜色"], |
|
|
|
颜色代码: element["颜色代码"], |
|
|
|
尺码1: element["尺码1"], |
|
|
|
型号: element["型号"], |
|
|
|
尺码2: element["尺码2"], |
|
|
|
尺码代码: element["尺码代码"], |
|
|
|
SKU: element["SKU"], |
|
|
|
零售价: element["零售价"], |
|
|
|
等级: element["等级"], |
|
|
|
鞋面材料: element["鞋面材料"], |
|
|
|
执行标准: element["执行标准"], |
|
|
|
国际码: element["国际码"], |
|
|
|
数量: element["数量"], |
|
|
|
图片名称: element["图片名称"], |
|
|
|
"": element["总数量"], |
|
|
|
本厂分区: element["本厂分区"], |
|
|
|
下单数: element["下单数"], |
|
|
|
}) |
|
|
|
} |
|
|
|
let jsonWorkSheet = XLSX.utils.json_to_sheet(list) |
|
|
|
workBook.SheetNames.push(key) |
|
|
|
workBook.Sheets[key] = jsonWorkSheet |
|
|
|
} |
|
|
|
XLSX.writeFile(workBook, `生成表格${dayjs().format("YYYY-MM-DD_HH-mm-ss")}.xls`) |
|
|
|
} else { |
|
|
|
ElMessage({ |
|
|
|
type: 'error', |
|
|
|
message: '当前表格无数据,请有数据后在导出', |
|
|
|
}) |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
async mounted() { |
|
|
|
this.tableHeader = _.filter(tableHeaderLocal, o => o.tableShow) |
|
|
|