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