问题描述:
后台订单列表导出数量不对。
解决方法:
src/pages/order/orderList/components/tableList.vue,找到这个文件,修改exports()方法。
async exports(value) {
this.exportListOn = this.exportList.findIndex(
(item) => item.name === value
)
let [th, filekey, data, fileName] = [[], [], [], '']
let excelData = {
...this.where,
page: 1,
export_type: value,
ids: this.checkUidList.join(),
plat_type: this.currentTab,
}
for (let i = 0; i < excelData.page; i++) {
let lebData = await this.downOrderData(excelData)
if (!lebData.export.length) {
break;
}
if (!fileName) {
fileName = lebData.filename
}
if (!filekey.length) {
filekey = lebData.filekey
}
if (!th.length) {
th = lebData.header
}
data = data.concat(lebData.export)
excelData.page++
}
let sheetData = []
for (let j = 0; j < data.length; j++) {
let goodsList = data[j].goods_name.split('\n')
for (let k = 0; k < goodsList.length; k++) {
let row = {...data[j]}
row.goods_name = goodsList[k]
if (k) {
for (const key in row) {
if (Object.hasOwnProperty.call(row, key)) {
if (key !== 'goods_name') {
row[key] = null
}
}
}
}
sheetData.push(row)
}
}
exportExcel(th, filekey, fileName, sheetData)
},
修改完成后需要重新打包。
打包文档: https://doc.crmeb.com/pro/crmebprov2/2354
后台文件修改:app\controller\admin\v1\other\export\ExportExcel
修改方法:storeOrder()
public function storeOrder(StoreOrderServices $services)
{
$where_tmp = $this->request->getMore([
['status', ''],
['real_name', ''],
['is_del', ''],
['data', '', '', 'time'],
['type', ''],
['export_type', ''],
['pay_type', ''],
['plat_type', -1],
['order', ''],
['field_key', ''],
['store_id', ''],
['supplier_id', ''],
['ids', '']
]);
$type = $where_tmp['export_type'];
unset($where_tmp['export_type']);
$with = [];
if ($where_tmp['ids']) {
$where['id'] = explode(',', $where_tmp['ids']);
}
if ($type) {
$where['status'] = 1;
$where['paid'] = 1;
$where['is_del'] = 0;
$where['shipping_type'] = 1;
$where['pid'] = 0;
$with = ['pink', 'refund' => function ($query) {
$query->whereIn('refund_type', [0, 1, 2, 4, 5])->where('is_cancel', 0)->where('is_del', 0)->field('id,store_order_id');
}];
}
if (!$where_tmp['ids'] && !$type) {
unset($where_tmp['ids']);
$where = $where_tmp;
}
$where['is_system_del'] = 0;
$where['plat_type'] = $where_tmp['plat_type'];
$where['store_id'] = $where_tmp['store_id'];
$where['supplier_id'] = $where_tmp['supplier_id'];
if ($where['store_id'] || $where['supplier_id'] || $where['plat_type'] != '' && in_array($where['plat_type'], [0, 1, 2])) {
$where['pid'] = 0;
} elseif (!in_array($where['status'], [-1, -2, -3])) {
$where['pid'] = [0, -1];
}
$data = $services->getExportList($where, $with, $this->service->limit);
return $this->success($this->service->storeOrder($data, $type));
}
后台文件修改:app\services\order\StoreOrderServices
修改方法:getExportList()
public function getExportList(array $where, array $with = [], int $limit = 0)
{
if ($limit) {
[$page] = $this->getPageValue();
} else {
[$page, $limit] = $this->getPageValue();
}
$list = $this->dao->search($where)->with($with)->page($page, $limit)->order('add_time DESC,id DESC')->select()->toArray();
if ($list) {
/** @var $userServices */
$userServices = app()->make(UserServices::class);
$userSex = $userServices->getColumn([['uid', 'IN', array_unique(array_column($list, 'uid'))]], 'uid,sex', 'uid');
foreach ($list as &$item) {
/** @var StoreOrderCartInfoServices $orderCart */
$orderCart = app()->make(StoreOrderCartInfoServices::class);
$_info = $orderCart->getCartColunm(['oid' => $item['id']], 'cart_info', 'unique');
foreach ($_info as $k => $v) {
$cart_info = is_string($v) ? json_decode($v, true) : $v;
if (!isset($cart_info['productInfo'])) $cart_info['productInfo'] = [];
$_info[$k] = $cart_info;
unset($cart_info);
}
$item['_info'] = $_info;
$item['sex'] = $userSex[$item['uid']]['sex'] ?? '';
[$pink_name, $color] = $this->tidyOrderType($item);
$item['pink_name'] = $pink_name;
$item['color'] = $color;
}
}
return $list;
}
{{item.user_info.nickname ? item.user_info.nickname : item.user_name}}
作者 管理员 企业
{{itemf.name}}
{{itemc.user_info.nickname}}
{{itemc.user_name}}
回复 {{itemc.comment_user_info.nickname}}
{{itemf.name}}