导出名称修改
This commit is contained in:
parent
1663548147
commit
3ee06ecfce
@ -154,11 +154,11 @@ abstract class AbstractExport implements WithEvents, WithTitle, ShouldAutoSize
|
||||
$title = $this->tag();
|
||||
|
||||
if (($conditions = $this->conditions) && $conditions['starttime'] && $conditions['endtime']) {
|
||||
$title .= Carbon::parse($conditions['starttime'])->format('Ymd') . '-' . Carbon::parse($conditions['endtime'])->format('Ymd');
|
||||
$title = Carbon::parse($conditions['starttime'])->format('Ymd') . '-' . Carbon::parse($conditions['endtime'])->format('Ymd') . ' ' . $title;
|
||||
}
|
||||
|
||||
if (($conditions = $this->conditions) && $conditions['month']) {
|
||||
$title .= Carbon::parse($conditions['month'])->format('Ym');
|
||||
$title = Carbon::parse($conditions['month'])->format('Ym') . ' ' . $title;
|
||||
}
|
||||
|
||||
return $title ?? '列表';
|
||||
@ -171,7 +171,7 @@ abstract class AbstractExport implements WithEvents, WithTitle, ShouldAutoSize
|
||||
*/
|
||||
protected function sn(): string
|
||||
{
|
||||
return date('YmdHis') .sprintf('%04d', explode('.', microtime(true))[1]) . sprintf('%02d', rand(0, 99));
|
||||
return date('YmdHis') . sprintf('%04d', explode('.', microtime(true))[1]) . sprintf('%02d', rand(0, 99));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -181,9 +181,9 @@ abstract class AbstractExport implements WithEvents, WithTitle, ShouldAutoSize
|
||||
*/
|
||||
protected function filename(): string
|
||||
{
|
||||
$title = $this->tag();
|
||||
$title = $this->title();
|
||||
|
||||
$filename = $title . date('YmdHis');
|
||||
$filename = $title . ' ' . date('YmdHis');
|
||||
|
||||
return "export/{$filename}.xlsx";
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Export\Services;
|
||||
|
||||
use App\Dicts;
|
||||
@ -8,6 +9,7 @@ use Dipper\Excel\Facades\Excel;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use App\Domains\Export\Repositories\ExportRepository;
|
||||
use function GuzzleHttp\json_encode;
|
||||
|
||||
class ExportService extends Service
|
||||
{
|
||||
@ -50,19 +52,20 @@ class ExportService extends Service
|
||||
|
||||
$url = $item->status === 3 ? Storage::disk($item->disk)->url($item->filename) : '';
|
||||
|
||||
$conditions = json_encode(array_except($item->conditions ?? [], ['page', 'limit', 'orderBy', 'sortedBy']), 256);
|
||||
$conditions = array_except($item->conditions ?? [], ['page', 'limit', 'orderBy', 'sortedBy']);
|
||||
|
||||
return [
|
||||
'id' => $item->id,
|
||||
'tag' => $item->tag,
|
||||
'filename' => basename($url),
|
||||
'filesize' => human_filesize($item->filesize),
|
||||
'dateline' => !$item->conditions['starttime'] ? '所有' : $item->conditions['starttime'] . ' 至 ' . $item->conditions['endtime'],
|
||||
'conditions' => $conditions,
|
||||
'conditions' => json_encode($conditions, JSON_PRETTY_PRINT),
|
||||
'status' => $item->status,
|
||||
'status_name' => $status[$item->status],
|
||||
'url' => $url,
|
||||
'created_at' => (string)$item->created_at,
|
||||
'updated_at' => (string)$item->updated_at,
|
||||
'created_at' => (string) $item->created_at,
|
||||
'updated_at' => (string) $item->updated_at,
|
||||
];
|
||||
});
|
||||
|
||||
|
@ -81,7 +81,7 @@ class CompanyReportDetailExport extends AbstractExport implements FromQuery, Wit
|
||||
foreach ($rows as $item) {
|
||||
$company = CompanyService::load($item->company_id);
|
||||
$package = PackageService::load($item->package_id);
|
||||
$month_price = sprintf('%.02f', $item->unit_price/100/$package['service_months']);
|
||||
$month_price = sprintf('%.02f', $item->unit_price / 100 / $package['service_months']);
|
||||
|
||||
$array[] = [
|
||||
$item['sim'],
|
||||
@ -118,7 +118,7 @@ class CompanyReportDetailExport extends AbstractExport implements FromQuery, Wit
|
||||
$title = $this->tag();
|
||||
|
||||
if (($conditions = $this->conditions) && $conditions['month']) {
|
||||
$title .= Carbon::parse($conditions['month'])->format('Ym');
|
||||
$title = Carbon::parse($conditions['month'])->format('Ym') . ' ' . $title;
|
||||
}
|
||||
|
||||
return $title ?? '列表';
|
||||
|
@ -77,7 +77,7 @@ class CompanyReportExport extends AbstractExport implements FromCollection, With
|
||||
$title = $this->tag();
|
||||
|
||||
if (($conditions = $this->conditions) && $conditions['month']) {
|
||||
$title .= Carbon::parse($conditions['month'])->format('Ym');
|
||||
$title = Carbon::parse($conditions['month'])->format('Ym') . ' ' . $title;
|
||||
}
|
||||
|
||||
return $title ?? '列表';
|
||||
|
@ -1,9 +1,9 @@
|
||||
export default {
|
||||
name: 'Exports',
|
||||
name: "Exports",
|
||||
data() {
|
||||
return {
|
||||
params: {
|
||||
request_param: ''
|
||||
request_param: ""
|
||||
},
|
||||
other: {
|
||||
time: [],
|
||||
@ -16,84 +16,100 @@ export default {
|
||||
selection: [], // 复选框选中项
|
||||
table_titles: [
|
||||
{
|
||||
type: 'selection',
|
||||
type: "selection",
|
||||
width: 60,
|
||||
align: 'center'
|
||||
align: "center"
|
||||
},
|
||||
{
|
||||
title: '序号',
|
||||
key: '',
|
||||
title: "序号",
|
||||
key: "",
|
||||
width: 80,
|
||||
render: (h, { row, column, index }) => {
|
||||
return h('span', index + 1);
|
||||
return h("span", index + 1);
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '类型',
|
||||
key: 'tag',
|
||||
title: "文件名称",
|
||||
key: "filename",
|
||||
render: (h, { row, column, index }) => {
|
||||
return h(
|
||||
"Tooltip",
|
||||
{ props: { content: row.conditions, "max-width": 300 } },
|
||||
row.filename
|
||||
);
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "类型",
|
||||
key: "tag",
|
||||
width: 150
|
||||
},
|
||||
{
|
||||
title: '查询条件',
|
||||
key: '',
|
||||
render: (h, { row, column, index }) => {
|
||||
return h('pre', row.conditions);
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '文件大小',
|
||||
key: 'filesize',
|
||||
title: "文件大小",
|
||||
key: "filesize",
|
||||
width: 120
|
||||
},
|
||||
{
|
||||
title: '状态',
|
||||
key: 'status_name',
|
||||
title: "状态",
|
||||
key: "status_name",
|
||||
width: 120
|
||||
},
|
||||
{
|
||||
title: '创建时间',
|
||||
key: 'created_at',
|
||||
title: "创建时间",
|
||||
key: "created_at",
|
||||
width: 170
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
key: 'action',
|
||||
title: "操作",
|
||||
key: "action",
|
||||
render: (h, { row, column, index }) => {
|
||||
let html = [];
|
||||
|
||||
if (row.status === 3) {
|
||||
html.push(h('Button', {
|
||||
props: {
|
||||
type: 'success',
|
||||
size: 'small',
|
||||
disabled: false,
|
||||
icon: 'md-trash',
|
||||
target: '_blank',
|
||||
to: row.url
|
||||
},
|
||||
class: ['btn']
|
||||
}, '下载'));
|
||||
html.push(
|
||||
h(
|
||||
"Button",
|
||||
{
|
||||
props: {
|
||||
type: "success",
|
||||
size: "small",
|
||||
disabled: false,
|
||||
icon: "md-trash",
|
||||
target: "_blank",
|
||||
to: row.url
|
||||
},
|
||||
class: ["btn"]
|
||||
},
|
||||
"下载"
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if (this.haveJurisdiction('destroy')) {
|
||||
html.push(h('Button', {
|
||||
props: {
|
||||
type: 'error',
|
||||
size: 'small',
|
||||
disabled: false,
|
||||
icon: 'md-trash'
|
||||
},
|
||||
class: ['btn'],
|
||||
on: {
|
||||
click: () => {
|
||||
this.destroy({ ids: row.id });
|
||||
}
|
||||
}
|
||||
}, '删除'));
|
||||
if (this.haveJurisdiction("destroy")) {
|
||||
html.push(
|
||||
h(
|
||||
"Button",
|
||||
{
|
||||
props: {
|
||||
type: "error",
|
||||
size: "small",
|
||||
disabled: false,
|
||||
icon: "md-trash"
|
||||
},
|
||||
class: ["btn"],
|
||||
on: {
|
||||
click: () => {
|
||||
this.destroy({ ids: row.id });
|
||||
}
|
||||
}
|
||||
},
|
||||
"删除"
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if (html.length) {
|
||||
return h('div', html);
|
||||
return h("div", html);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -113,16 +129,19 @@ export default {
|
||||
this.scrollTop();
|
||||
let data = this.searchDataHandle(this.params, { page }, this.other);
|
||||
this.isShowLoading(true);
|
||||
service.get('api/exports', { params: data }).then(res => {
|
||||
this.isShowLoading(false);
|
||||
if (res.code == 0) {
|
||||
let result = res.data;
|
||||
result.data = this.tableCheckboxHandle(result.data, this.selection);
|
||||
this.list_data = result;
|
||||
}
|
||||
}).catch(err => {
|
||||
this.isShowLoading(false);
|
||||
});
|
||||
service
|
||||
.get("api/exports", { params: data })
|
||||
.then(res => {
|
||||
this.isShowLoading(false);
|
||||
if (res.code == 0) {
|
||||
let result = res.data;
|
||||
result.data = this.tableCheckboxHandle(result.data, this.selection);
|
||||
this.list_data = result;
|
||||
}
|
||||
})
|
||||
.catch(err => {
|
||||
this.isShowLoading(false);
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
@ -142,9 +161,9 @@ export default {
|
||||
let arry = this.selection.map(item => {
|
||||
return item.id;
|
||||
});
|
||||
this.destroy({ ids: arry.join(',') });
|
||||
this.destroy({ ids: arry.join(",") });
|
||||
} else {
|
||||
this.$Message.info('请勾选要删除的项');
|
||||
this.$Message.info("请勾选要删除的项");
|
||||
}
|
||||
},
|
||||
|
||||
@ -155,13 +174,13 @@ export default {
|
||||
*/
|
||||
destroy(data) {
|
||||
this.$Modal.confirm({
|
||||
title: '提示',
|
||||
content: '确认执行删除操作?',
|
||||
title: "提示",
|
||||
content: "确认执行删除操作?",
|
||||
onOk: () => {
|
||||
service.post('api/exports/destroy', data).then(res => {
|
||||
service.post("api/exports/destroy", data).then(res => {
|
||||
if (res.code == 0) {
|
||||
// 当有勾选项,删除操作的地方为每行的按钮,将复选框勾选项去除此id
|
||||
const ids = data.ids.toString().split(',');
|
||||
const ids = data.ids.toString().split(",");
|
||||
if (ids.length == 1) {
|
||||
for (let i = 0, len = this.selection.length; i < len; i++) {
|
||||
if (ids[0] == this.selection[i].id) {
|
||||
@ -170,7 +189,7 @@ export default {
|
||||
}
|
||||
}
|
||||
}
|
||||
this.$Message.success('删除成功');
|
||||
this.$Message.success("删除成功");
|
||||
this.request();
|
||||
}
|
||||
});
|
||||
@ -187,7 +206,11 @@ export default {
|
||||
let page = result.current_page;
|
||||
|
||||
if (this.list_data.data.length == 1) {
|
||||
page = this.returnPage(result.total, result.current_page, result.per_page);
|
||||
page = this.returnPage(
|
||||
result.total,
|
||||
result.current_page,
|
||||
result.per_page
|
||||
);
|
||||
}
|
||||
|
||||
this.index(page);
|
||||
@ -195,7 +218,7 @@ export default {
|
||||
|
||||
resetSearch() {
|
||||
for (let k in this.params) {
|
||||
this.params[k] = '';
|
||||
this.params[k] = "";
|
||||
}
|
||||
this.other.tag = null;
|
||||
this.other.time = [];
|
||||
|
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user