1239 lines
38 KiB
Vue
1239 lines
38 KiB
Vue
<template>
|
||
<basic-container class="temporary-credit-limit-page">
|
||
<avue-crud
|
||
ref="crud"
|
||
v-model="form"
|
||
v-model:page="page"
|
||
:data="data"
|
||
:option="tableOption"
|
||
:permission="permissionList"
|
||
:table-loading="loading"
|
||
:before-open="beforeOpen"
|
||
@row-save="rowSave"
|
||
@row-update="rowUpdate"
|
||
@row-del="rowDel"
|
||
@search-change="searchChange"
|
||
@search-reset="searchReset"
|
||
@selection-change="selectionChange"
|
||
@current-change="currentChange"
|
||
@size-change="sizeChange"
|
||
@refresh-change="refreshChange"
|
||
@on-load="onLoad"
|
||
>
|
||
<template #menu-left>
|
||
<el-button v-if="canCreate" type="primary" icon="el-icon-plus" @click="$refs.crud.rowAdd()">
|
||
新增
|
||
</el-button>
|
||
<el-button
|
||
v-if="config.exportUrl && hasPermission(`${config.permission}_export`)"
|
||
type="primary"
|
||
icon="el-icon-download"
|
||
plain
|
||
@click="handleExport"
|
||
>
|
||
批量导出
|
||
</el-button>
|
||
<el-button
|
||
v-if="hasPermission(`${config.permission}_delete`)"
|
||
type="danger"
|
||
icon="el-icon-delete"
|
||
plain
|
||
@click="handleDelete"
|
||
>
|
||
批量删除
|
||
</el-button>
|
||
</template>
|
||
|
||
<template #approvalStatus="{ row }">
|
||
<el-tag :type="statusTagType(row.approvalStatus)" class="status-text">
|
||
{{ displayStatus(row, 'approvalStatus') }}
|
||
</el-tag>
|
||
</template>
|
||
|
||
<template #projectQuotaInfoTitle-form>
|
||
<div class="dialog-section-title">项目额度信息</div>
|
||
</template>
|
||
|
||
<template #temporaryCreditInfoTitle-form>
|
||
<div class="dialog-section-title">临时额度信息</div>
|
||
</template>
|
||
|
||
<template #projectName-form>
|
||
<el-select
|
||
v-model="selectedProjectId"
|
||
class="temporary-credit-limit-page__field"
|
||
placeholder="请选择"
|
||
filterable
|
||
clearable
|
||
:loading="projectLoading"
|
||
:disabled="dialogReadonly"
|
||
@visible-change="visible => visible && loadProjectOptions()"
|
||
@change="handleProjectChange"
|
||
>
|
||
<el-option
|
||
v-for="item in projectOptions"
|
||
:key="item.id"
|
||
:label="item.projectName"
|
||
:value="item.id"
|
||
/>
|
||
</el-select>
|
||
</template>
|
||
|
||
<template #applyLimit-form>
|
||
<el-input
|
||
v-model="form.applyLimit"
|
||
class="temporary-credit-limit-page__field"
|
||
placeholder="请输入"
|
||
:disabled="dialogReadonly"
|
||
@input="handleAmountInput"
|
||
/>
|
||
</template>
|
||
|
||
<template #attachmentsJson-form>
|
||
<div class="temporary-credit-limit-page__attachment">
|
||
<div class="temporary-credit-limit-page__attachment-head">
|
||
<el-button type="primary" :disabled="!attachmentRows.length" @click="batchDownload">
|
||
批量下载
|
||
</el-button>
|
||
</div>
|
||
<el-table :data="attachmentRows" border @selection-change="selectedAttachments = $event">
|
||
<el-table-column type="selection" width="55" align="center" />
|
||
<el-table-column type="index" label="序号" width="70" align="center" />
|
||
<el-table-column label="文件名" min-width="240" show-overflow-tooltip>
|
||
<template #default="{ row }">
|
||
<el-link type="primary" @click="previewAttachment(row)">
|
||
{{ attachmentName(row) }}
|
||
</el-link>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column label="文件大小" width="120" align="center">
|
||
<template #default="{ row }">{{ formatFileSize(row.size) }}</template>
|
||
</el-table-column>
|
||
<el-table-column prop="uploadUserName" label="上传人" width="140" align="center" />
|
||
<el-table-column prop="uploadTime" label="上传时间" width="180" align="center" />
|
||
<el-table-column label="操作" width="100" align="center" fixed="right">
|
||
<template #default="{ row, $index }">
|
||
<el-link v-if="!dialogReadonly" type="danger" @click="removeAttachment($index)">
|
||
删除
|
||
</el-link>
|
||
<el-link v-else type="primary" @click="downloadAttachment(row)">下载</el-link>
|
||
</template>
|
||
</el-table-column>
|
||
</el-table>
|
||
<div class="temporary-credit-limit-page__attachment-upload">
|
||
<vehicle-attachment-upload
|
||
v-model="attachmentRows"
|
||
:readonly="dialogReadonly"
|
||
:file-types="attachmentFileTypes"
|
||
:max-size="50"
|
||
:show-file-list="false"
|
||
button-text="上传附件"
|
||
tip="支持pdf、bmp、jpeg、png、jpg、doc、docx、ppt、pptx、xlsx、xls、eml、msg、zip的文件格式,单个文件不超过50M"
|
||
@change="handleAttachmentChange"
|
||
/>
|
||
</div>
|
||
</div>
|
||
</template>
|
||
|
||
<template #menu-form-before>
|
||
<template v-if="!dialogReadonly">
|
||
<el-button @click="closeFormDialog">取消</el-button>
|
||
<el-button type="primary" plain :loading="draftLoading" @click="saveDraft">
|
||
保存
|
||
</el-button>
|
||
</template>
|
||
</template>
|
||
|
||
<template #menu="{ row }">
|
||
<el-link
|
||
v-if="hasPermission(`${config.permission}_view`)"
|
||
type="primary"
|
||
@click="openDetail(row)"
|
||
>
|
||
查看
|
||
</el-link>
|
||
<el-link v-if="canEdit(row)" type="primary" @click="$refs.crud.rowEdit(row)">
|
||
编辑
|
||
</el-link>
|
||
<el-link
|
||
v-for="operation in customOperations(row)"
|
||
:key="operation.action"
|
||
:type="operation.type || 'primary'"
|
||
@click="handleOperation(operation, row)"
|
||
>
|
||
{{ operation.label }}
|
||
</el-link>
|
||
<el-link v-if="canDelete(row)" type="danger" @click="rowDel(row)">删除</el-link>
|
||
</template>
|
||
</avue-crud>
|
||
|
||
<el-dialog
|
||
v-model="detailVisible"
|
||
title="查看临时额度申请"
|
||
append-to-body
|
||
destroy-on-close
|
||
width="96%"
|
||
class="temporary-credit-limit-dialog temporary-credit-limit-detail-dialog"
|
||
>
|
||
<div v-loading="detailLoading" class="business-crud-page__detail-content">
|
||
<section
|
||
v-for="section in detailSections"
|
||
:key="section.title"
|
||
class="temporary-credit-limit-detail-dialog__section"
|
||
>
|
||
<div class="dialog-section-title">{{ section.title }}</div>
|
||
<el-descriptions :column="4" class="temporary-credit-limit-detail-dialog__descriptions">
|
||
<el-descriptions-item
|
||
v-for="field in section.fields"
|
||
:key="field[0]"
|
||
:label="field[1]"
|
||
:span="field[2] || 1"
|
||
>
|
||
{{ formatDetailValue(field[0]) }}
|
||
</el-descriptions-item>
|
||
</el-descriptions>
|
||
<div
|
||
v-if="section.showAttachment"
|
||
class="temporary-credit-limit-detail-dialog__attachment"
|
||
>
|
||
<div class="temporary-credit-limit-page__attachment-head">
|
||
<span class="temporary-credit-limit-detail-dialog__attachment-label">附件</span>
|
||
<el-button type="primary" :disabled="!attachmentRows.length" @click="batchDownload">
|
||
批量下载
|
||
</el-button>
|
||
</div>
|
||
<el-table :data="attachmentRows" empty-text="暂无附件">
|
||
<el-table-column type="index" label="序号" width="70" align="center" />
|
||
<el-table-column label="文件名" min-width="240" show-overflow-tooltip>
|
||
<template #default="{ row }">
|
||
<el-link type="primary" @click="previewAttachment(row)">
|
||
{{ attachmentName(row) }}
|
||
</el-link>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column label="文件大小" width="120" align="center">
|
||
<template #default="{ row }">{{ formatFileSize(row.size) }}</template>
|
||
</el-table-column>
|
||
<el-table-column prop="uploadUserName" label="上传人" width="140" align="center" />
|
||
<el-table-column
|
||
prop="uploadTime"
|
||
label="上传时间"
|
||
:width="config.detailAttachmentUploadTimeWidth || 180"
|
||
align="center"
|
||
/>
|
||
<el-table-column label="操作" width="100" align="center" fixed="right">
|
||
<template #default="{ row }">
|
||
<el-link type="primary" @click="downloadAttachment(row)">下载</el-link>
|
||
</template>
|
||
</el-table-column>
|
||
</el-table>
|
||
</div>
|
||
</section>
|
||
</div>
|
||
<template #footer>
|
||
<el-button @click="detailVisible = false">关闭</el-button>
|
||
</template>
|
||
</el-dialog>
|
||
|
||
<empty-pagination
|
||
:page="page"
|
||
@size-change="sizeChange"
|
||
@current-change="currentChange"
|
||
@load="onLoad(page, query)"
|
||
/>
|
||
|
||
<el-dialog
|
||
v-model="attachmentDocumentPreviewVisible"
|
||
:title="attachmentPreviewFile.name || '附件预览'"
|
||
append-to-body
|
||
destroy-on-close
|
||
width="90%"
|
||
top="4vh"
|
||
class="temporary-credit-limit-page__attachment-viewer-dialog"
|
||
>
|
||
<open-file-viewer
|
||
v-if="attachmentDocumentPreviewVisible && attachmentPreviewFile.url"
|
||
:file="attachmentPreviewFile.url"
|
||
:file-name="attachmentPreviewFile.name"
|
||
:mime-type="attachmentPreviewFile.mimeType"
|
||
width="100%"
|
||
height="72vh"
|
||
fit="contain"
|
||
theme="auto"
|
||
locale="zh-CN"
|
||
:toolbar="attachmentViewerToolbar"
|
||
:plugins="attachmentViewerPlugins"
|
||
@unsupported="handleAttachmentPreviewUnsupported"
|
||
@error="handleAttachmentPreviewError"
|
||
/>
|
||
</el-dialog>
|
||
<el-image-viewer
|
||
v-if="attachmentImagePreviewVisible"
|
||
:url-list="attachmentImagePreviewUrls"
|
||
:initial-index="attachmentImagePreviewIndex"
|
||
@close="attachmentImagePreviewVisible = false"
|
||
/>
|
||
|
||
<flow-design-step
|
||
v-if="website.design.designMode"
|
||
v-model:is-display="flowBox"
|
||
:process-instance-id="processInstanceId"
|
||
/>
|
||
<el-dialog v-else v-model="flowBox" title="流程图" append-to-body fullscreen>
|
||
<iframe class="temporary-credit-limit-page__flow" :src="flowUrl" />
|
||
<template #footer><el-button @click="flowBox = false">关闭</el-button></template>
|
||
</el-dialog>
|
||
</basic-container>
|
||
</template>
|
||
|
||
<script>
|
||
import { exportBlob } from '@/api/common';
|
||
import * as api from '@/api/business/temporary-credit-limit';
|
||
import {
|
||
getDetail as getProjectDetail,
|
||
getList as getProjectList,
|
||
} from '@/api/business/project-apply';
|
||
import { config, option } from '@/option/business/temporary-credit-limit';
|
||
import { getToken } from '@/utils/auth';
|
||
import { downloadFileByUrl, downloadXls } from '@/utils/util';
|
||
import { ElImageViewer } from 'element-plus';
|
||
import { OpenFileViewer } from '@open-file-viewer/vue';
|
||
import {
|
||
fallbackPlugin,
|
||
imagePlugin,
|
||
officePlugin,
|
||
pdfPlugin,
|
||
textPlugin,
|
||
} from '@open-file-viewer/core';
|
||
import '@open-file-viewer/core/style.css';
|
||
import pdfWorkerSrc from 'pdfjs-dist/build/pdf.worker.mjs?url';
|
||
import { mapGetters } from 'vuex';
|
||
import NProgress from 'nprogress';
|
||
import 'nprogress/nprogress.css';
|
||
|
||
const attachmentFileTypes = [
|
||
'pdf',
|
||
'bmp',
|
||
'jpeg',
|
||
'png',
|
||
'jpg',
|
||
'doc',
|
||
'docx',
|
||
'ppt',
|
||
'pptx',
|
||
'xlsx',
|
||
'xls',
|
||
'eml',
|
||
'msg',
|
||
'zip',
|
||
];
|
||
|
||
const attachmentViewerPlugins = [
|
||
imagePlugin(),
|
||
pdfPlugin({ workerSrc: pdfWorkerSrc, useFetchData: true }),
|
||
officePlugin({ pdf: { workerSrc: pdfWorkerSrc, useFetchData: true } }),
|
||
textPlugin(),
|
||
fallbackPlugin(),
|
||
];
|
||
|
||
const extractRecords = res => {
|
||
const data = res?.data?.data || res?.data || {};
|
||
return Array.isArray(data) ? data : data.records || [];
|
||
};
|
||
|
||
export default {
|
||
name: 'TemporaryCreditLimit',
|
||
components: {
|
||
ElImageViewer,
|
||
OpenFileViewer,
|
||
},
|
||
data() {
|
||
return {
|
||
api,
|
||
config,
|
||
form: {},
|
||
data: [],
|
||
query: {},
|
||
loading: true,
|
||
draftLoading: false,
|
||
dialogReadonly: false,
|
||
tableOption: this.buildTableOption(),
|
||
page: {
|
||
currentPage: 1,
|
||
pageSize: 10,
|
||
pageSizes: [10, 20, 50, 100],
|
||
total: 0,
|
||
},
|
||
selectionList: [],
|
||
selectedProjectId: '',
|
||
projectOptions: [],
|
||
projectLoading: false,
|
||
attachmentRows: [],
|
||
selectedAttachments: [],
|
||
attachmentImagePreviewVisible: false,
|
||
attachmentImagePreviewUrls: [],
|
||
attachmentImagePreviewIndex: 0,
|
||
attachmentDocumentPreviewVisible: false,
|
||
attachmentPreviewFile: {},
|
||
attachmentViewerPlugins,
|
||
attachmentViewerToolbar: {
|
||
download: true,
|
||
fullscreen: true,
|
||
print: true,
|
||
rotate: true,
|
||
zoom: true,
|
||
},
|
||
attachmentFileTypes,
|
||
detailVisible: false,
|
||
detailLoading: false,
|
||
detailRow: {},
|
||
flowBox: false,
|
||
flowUrl: '',
|
||
processInstanceId: '',
|
||
};
|
||
},
|
||
computed: {
|
||
...mapGetters(['permission', 'userInfo']),
|
||
permissionList() {
|
||
return { addBtn: this.canCreate };
|
||
},
|
||
detailSections() {
|
||
return this.config.detailSections || [];
|
||
},
|
||
isAdmin() {
|
||
const authority = this.userInfo?.authority;
|
||
return Array.isArray(authority)
|
||
? authority.includes('admin')
|
||
: String(authority || '').includes('admin');
|
||
},
|
||
canCreate() {
|
||
return this.hasPermission(`${this.config.permission}_add`);
|
||
},
|
||
ids() {
|
||
return this.selectionList.map(item => item.id).join(',');
|
||
},
|
||
},
|
||
created() {
|
||
this.loadProjectOptions();
|
||
},
|
||
methods: {
|
||
buildTableOption() {
|
||
const columns = (option.column || []).map(column => ({ ...column }));
|
||
const sectionTitleProps = ['projectQuotaInfoTitle', 'temporaryCreditInfoTitle'];
|
||
const formGroups = [];
|
||
let current = [];
|
||
columns.forEach(col => {
|
||
if (sectionTitleProps.includes(col.prop)) {
|
||
if (current.length) formGroups.push(current);
|
||
current = [col];
|
||
return;
|
||
}
|
||
if (!current.length) return;
|
||
// 列表/搜索专用字段不进入表单分组白卡
|
||
if (col.addDisplay === false && col.editDisplay === false) return;
|
||
current.push(col);
|
||
});
|
||
if (current.length) formGroups.push(current);
|
||
|
||
const formSectionProps = new Set();
|
||
formGroups.forEach(group => {
|
||
group.forEach(col => {
|
||
if (col.prop) formSectionProps.add(col.prop);
|
||
});
|
||
});
|
||
|
||
// 表单字段全部进 group 拆白卡;Avue 会额外生成空的主列 group,由样式隐藏去掉顶部白横条
|
||
return {
|
||
...option,
|
||
addBtn: false,
|
||
viewBtn: false,
|
||
editBtn: false,
|
||
delBtn: false,
|
||
// 隐藏 Avue 默认取消按钮,改由 menu-form-before 按「取消、保存、提交」顺序自定义
|
||
cancelBtn: false,
|
||
menuWidth: 320,
|
||
column: columns.map(col => {
|
||
if (!formSectionProps.has(col.prop)) return col;
|
||
return {
|
||
...col,
|
||
addDisplay: false,
|
||
editDisplay: false,
|
||
viewDisplay: false,
|
||
};
|
||
}),
|
||
group: formGroups.map(group => ({
|
||
label: '',
|
||
arrow: false,
|
||
column: group,
|
||
})),
|
||
};
|
||
},
|
||
hasPermission(code) {
|
||
return this.isAdmin || this.validData(this.permission?.[code], false);
|
||
},
|
||
statusValue(row) {
|
||
return row[this.config.statusProp || 'status'];
|
||
},
|
||
statusTagType(status) {
|
||
if (['approved', 'change_approved'].includes(status)) return 'success';
|
||
if (['draft', 'withdrawn'].includes(status)) return 'info';
|
||
if (['rejected', 'change_rejected'].includes(status)) return 'danger';
|
||
return 'warning';
|
||
},
|
||
displayStatus(row, prop) {
|
||
const textProp = prop === this.config.statusProp ? this.config.statusTextProp : '';
|
||
if (textProp && row[textProp]) return row[textProp];
|
||
const column = this.findColumn(this.tableOption.column, prop);
|
||
const item = column?.dicData?.find(dic => String(dic.value) === String(row[prop]));
|
||
return item?.label || row[prop] || '未知';
|
||
},
|
||
canEdit(row) {
|
||
return (
|
||
this.hasPermission(`${this.config.permission}_edit`) &&
|
||
!row.readonly &&
|
||
(this.config.editStatus || []).includes(this.statusValue(row))
|
||
);
|
||
},
|
||
canDelete(row) {
|
||
return (
|
||
this.hasPermission(`${this.config.permission}_delete`) &&
|
||
!row.readonly &&
|
||
(this.config.deleteStatus || []).includes(this.statusValue(row))
|
||
);
|
||
},
|
||
customOperations(row) {
|
||
return (this.config.operations || []).filter(operation => {
|
||
const permission = operation.permission || `${this.config.permission}_${operation.action}`;
|
||
const statusProp = operation.statusProp || this.config.statusProp || 'status';
|
||
return (
|
||
this.hasPermission(permission) &&
|
||
!row.readonly &&
|
||
(!operation.status?.length || operation.status.includes(row[statusProp]))
|
||
);
|
||
});
|
||
},
|
||
onLoad(page, params = {}) {
|
||
this.loading = true;
|
||
this.api
|
||
.getList(page.currentPage, page.pageSize, { ...params, ...this.query })
|
||
.then(res => {
|
||
const result = res.data?.data || {};
|
||
this.page.total = result.total || 0;
|
||
this.data = result.records || [];
|
||
this.selectionClear();
|
||
})
|
||
.finally(() => {
|
||
this.loading = false;
|
||
});
|
||
},
|
||
searchChange(params, done) {
|
||
this.query = { ...params };
|
||
this.page.currentPage = 1;
|
||
this.onLoad(this.page);
|
||
done();
|
||
},
|
||
searchReset() {
|
||
this.query = {};
|
||
this.page.currentPage = 1;
|
||
this.onLoad(this.page);
|
||
},
|
||
selectionChange(list) {
|
||
this.selectionList = list;
|
||
},
|
||
selectionClear() {
|
||
this.selectionList = [];
|
||
this.$refs.crud?.toggleSelection();
|
||
},
|
||
currentChange(currentPage) {
|
||
this.page.currentPage = currentPage;
|
||
},
|
||
sizeChange(pageSize) {
|
||
this.page.pageSize = pageSize;
|
||
},
|
||
refreshChange() {
|
||
this.onLoad(this.page, this.query);
|
||
},
|
||
beforeOpen(done, type) {
|
||
this.dialogReadonly = type === 'view';
|
||
if (type === 'add') {
|
||
this.form = { ...(this.config.defaultForm || {}) };
|
||
this.selectedProjectId = '';
|
||
this.attachmentRows = [];
|
||
this.selectedAttachments = [];
|
||
done();
|
||
return;
|
||
}
|
||
this.api
|
||
.getDetail(this.form.id)
|
||
.then(res => this.applyDetail(res.data?.data || {}))
|
||
.finally(done);
|
||
},
|
||
openDetail(row) {
|
||
this.detailVisible = true;
|
||
this.detailLoading = true;
|
||
this.detailRow = { ...row };
|
||
this.attachmentRows = [];
|
||
this.selectedAttachments = [];
|
||
this.api
|
||
.getDetail(row.id)
|
||
.then(res => {
|
||
const detail = res.data?.data || {};
|
||
this.detailRow = { ...detail };
|
||
this.attachmentRows = this.parseJsonArray(detail.attachmentsJson);
|
||
})
|
||
.finally(() => {
|
||
this.detailLoading = false;
|
||
});
|
||
},
|
||
formatDetailValue(prop) {
|
||
const row = this.detailRow || {};
|
||
if (prop === 'approvalStatus') {
|
||
return this.displayStatus(row, 'approvalStatus');
|
||
}
|
||
const value = row[prop];
|
||
if (value === undefined || value === null || value === '') return '-';
|
||
return value;
|
||
},
|
||
applyDetail(detail) {
|
||
this.form = { ...detail };
|
||
this.selectedProjectId = detail.projectId || '';
|
||
this.attachmentRows = this.parseJsonArray(detail.attachmentsJson);
|
||
this.selectedAttachments = [];
|
||
this.syncCurrentProjectOption();
|
||
},
|
||
normalizeForm(row = this.form) {
|
||
const { projectQuotaInfoTitle, temporaryCreditInfoTitle, ...payload } = row || {};
|
||
return {
|
||
...payload,
|
||
applyLimit: payload.applyLimit === '' ? '' : Number(payload.applyLimit),
|
||
attachmentsJson: JSON.stringify(this.attachmentRows),
|
||
};
|
||
},
|
||
rowSave(row, done, loading) {
|
||
this.api
|
||
.submit(this.normalizeForm(row))
|
||
.then(() => {
|
||
this.$message.success('新增成功');
|
||
done();
|
||
this.onLoad(this.page, this.query);
|
||
})
|
||
.catch(() => loading());
|
||
},
|
||
rowUpdate(row, index, done, loading) {
|
||
this.api
|
||
.submit(this.normalizeForm(row))
|
||
.then(() => {
|
||
this.$message.success('修改成功');
|
||
done();
|
||
this.onLoad(this.page, this.query);
|
||
})
|
||
.catch(() => loading());
|
||
},
|
||
saveDraft() {
|
||
if (this.draftLoading) return;
|
||
this.draftLoading = true;
|
||
this.api
|
||
.saveDraft(this.normalizeForm())
|
||
.then(() => {
|
||
this.$message.success('保存成功');
|
||
this.closeFormDialog();
|
||
this.onLoad(this.page, this.query);
|
||
})
|
||
.finally(() => {
|
||
this.draftLoading = false;
|
||
});
|
||
},
|
||
closeFormDialog() {
|
||
if (typeof this.$refs.crud?.closeDialog === 'function') {
|
||
this.$refs.crud.closeDialog();
|
||
return;
|
||
}
|
||
this.$refs.crud?.$refs?.dialogForm?.hide?.();
|
||
},
|
||
rowDel(row) {
|
||
this.removeRows([row]);
|
||
},
|
||
handleDelete() {
|
||
if (!this.selectionList.length) {
|
||
this.$message.warning('请选择至少一条数据');
|
||
return;
|
||
}
|
||
const rows = this.selectionList.filter(this.canDelete);
|
||
if (!rows.length) {
|
||
this.$message.warning('所选数据当前状态不可删除');
|
||
return;
|
||
}
|
||
this.removeRows(rows);
|
||
},
|
||
removeRows(rows) {
|
||
this.$confirm('确定将选择数据删除?', '提示', {
|
||
confirmButtonText: '确定',
|
||
cancelButtonText: '取消',
|
||
type: 'warning',
|
||
})
|
||
.then(() => this.api.remove(rows.map(row => row.id).join(',')))
|
||
.then(() => {
|
||
this.$message.success('删除成功');
|
||
this.onLoad(this.page, this.query);
|
||
});
|
||
},
|
||
handleOperation(operation, row) {
|
||
if (operation.action === 'flow') {
|
||
this.openFlow(row);
|
||
return;
|
||
}
|
||
this.$confirm(`确定${operation.label}该${this.config.title}?`, '提示', {
|
||
confirmButtonText: '确定',
|
||
cancelButtonText: '取消',
|
||
type: 'warning',
|
||
})
|
||
.then(() => this.api[operation.action](row.id))
|
||
.then(() => {
|
||
this.$message.success(`${operation.label}成功`);
|
||
this.onLoad(this.page, this.query);
|
||
});
|
||
},
|
||
openFlow(row, loaded = false) {
|
||
const processInstanceId = row.processInstanceId || row.processInstanceID || row.procInstId;
|
||
if (!processInstanceId && !loaded && row.id) {
|
||
this.api.getDetail(row.id).then(res => this.openFlow(res.data?.data || {}, true));
|
||
return;
|
||
}
|
||
if (!processInstanceId) {
|
||
this.$message.warning('流程实例为空,无法查看流程');
|
||
return;
|
||
}
|
||
if (this.website.design.designMode) this.processInstanceId = processInstanceId;
|
||
else
|
||
this.flowUrl = `/api/blade-flow/process/diagram-view?processInstanceId=${processInstanceId}`;
|
||
this.flowBox = true;
|
||
},
|
||
loadProjectOptions() {
|
||
if (this.projectLoading) return;
|
||
this.projectLoading = true;
|
||
getProjectList(1, 9999, this.config.projectQueryParams || {})
|
||
.then(res => {
|
||
this.projectOptions = extractRecords(res);
|
||
this.syncCurrentProjectOption();
|
||
})
|
||
.finally(() => {
|
||
this.projectLoading = false;
|
||
});
|
||
},
|
||
syncCurrentProjectOption() {
|
||
if (!this.form.projectId || !this.form.projectName) return;
|
||
if (this.projectOptions.some(item => String(item.id) === String(this.form.projectId))) return;
|
||
this.projectOptions.unshift({
|
||
id: this.form.projectId,
|
||
projectName: this.form.projectName,
|
||
projectCode: this.form.projectCode,
|
||
undertakeDeptName: this.form.undertakeDeptName,
|
||
fundLimit: this.form.projectFundLimit,
|
||
});
|
||
},
|
||
handleProjectChange(projectId) {
|
||
const project = this.projectOptions.find(item => String(item.id) === String(projectId));
|
||
if (!project) {
|
||
Object.assign(this.form, {
|
||
projectId: '',
|
||
projectName: '',
|
||
projectCode: '',
|
||
undertakeDeptName: '',
|
||
projectFundLimit: '',
|
||
usedFundLimit: 0,
|
||
remainingFundLimit: 0,
|
||
});
|
||
return;
|
||
}
|
||
Object.assign(this.form, {
|
||
projectId: project.id,
|
||
projectName: project.projectName || '',
|
||
projectCode: project.projectCode || '',
|
||
undertakeDeptName: project.undertakeDeptName || '',
|
||
projectFundLimit: project.fundLimit || project.projectFundLimit || 0,
|
||
usedFundLimit: project.usedFundLimit || 0,
|
||
});
|
||
this.form.remainingFundLimit = this.calculateRemainingFundLimit();
|
||
getProjectDetail(project.id).then(res => {
|
||
const detail = res.data?.data || {};
|
||
Object.assign(this.form, {
|
||
projectCode: detail.projectCode || this.form.projectCode,
|
||
undertakeDeptName: detail.undertakeDeptName || this.form.undertakeDeptName,
|
||
projectFundLimit:
|
||
detail.fundLimit ?? detail.projectFundLimit ?? this.form.projectFundLimit,
|
||
usedFundLimit: detail.usedFundLimit ?? this.form.usedFundLimit,
|
||
});
|
||
this.form.remainingFundLimit = this.calculateRemainingFundLimit();
|
||
});
|
||
},
|
||
calculateRemainingFundLimit() {
|
||
const total = Number(this.form.projectFundLimit);
|
||
const used = Number(this.form.usedFundLimit);
|
||
if (!Number.isFinite(total) || !Number.isFinite(used)) return '';
|
||
return Math.round((total - used + Number.EPSILON) * 100) / 100;
|
||
},
|
||
handleAmountInput(value) {
|
||
const text = String(value || '').replace(/[^\d.]/g, '');
|
||
const parts = text.split('.');
|
||
this.form.applyLimit =
|
||
parts.length > 1 ? `${parts[0]}.${parts.slice(1).join('').slice(0, 2)}` : parts[0];
|
||
},
|
||
handleAttachmentChange(list) {
|
||
const uploadUserName = this.userInfo?.realName || this.userInfo?.userName || '';
|
||
const uploadTime = this.$dayjs().format('YYYY-MM-DD HH:mm:ss');
|
||
this.attachmentRows = (list || []).map(item => ({
|
||
...item,
|
||
uploadUserName: item.uploadUserName || uploadUserName,
|
||
uploadTime: item.uploadTime || uploadTime,
|
||
}));
|
||
this.form.attachmentsJson = JSON.stringify(this.attachmentRows);
|
||
},
|
||
removeAttachment(index) {
|
||
this.attachmentRows.splice(index, 1);
|
||
this.form.attachmentsJson = JSON.stringify(this.attachmentRows);
|
||
},
|
||
parseJsonArray(value) {
|
||
if (Array.isArray(value)) return value;
|
||
if (!value) return [];
|
||
try {
|
||
const data = JSON.parse(value);
|
||
return Array.isArray(data) ? data : [];
|
||
} catch (error) {
|
||
return [];
|
||
}
|
||
},
|
||
attachmentName(row = {}) {
|
||
return row.originalName || row.name || row.fileName || '附件';
|
||
},
|
||
attachmentUrl(row = {}) {
|
||
return row.url || row.link || row.fileUrl || row.downloadUrl || row.domain || '';
|
||
},
|
||
attachmentExtension(row = {}) {
|
||
const source = String(this.attachmentName(row) || this.attachmentUrl(row)).split('?')[0];
|
||
const index = source.lastIndexOf('.');
|
||
return index > -1 ? source.slice(index + 1).toLowerCase() : '';
|
||
},
|
||
isAttachmentImage(row) {
|
||
return ['jpg', 'jpeg', 'png', 'gif', 'bmp', 'webp'].includes(
|
||
this.attachmentExtension(row)
|
||
);
|
||
},
|
||
previewAttachment(row) {
|
||
const url = this.attachmentUrl(row);
|
||
if (!url) {
|
||
this.$message.warning('附件地址为空,无法预览');
|
||
return;
|
||
}
|
||
if (this.isAttachmentImage(row)) {
|
||
this.attachmentImagePreviewUrls = this.attachmentRows
|
||
.filter(item => this.isAttachmentImage(item) && this.attachmentUrl(item))
|
||
.map(item => this.attachmentUrl(item));
|
||
this.attachmentImagePreviewIndex = Math.max(
|
||
this.attachmentImagePreviewUrls.indexOf(url),
|
||
0
|
||
);
|
||
this.attachmentImagePreviewVisible = true;
|
||
return;
|
||
}
|
||
this.attachmentPreviewFile = {
|
||
name: this.attachmentName(row),
|
||
url,
|
||
mimeType: row.mimeType || row.contentType || '',
|
||
};
|
||
this.attachmentDocumentPreviewVisible = true;
|
||
},
|
||
handleAttachmentPreviewUnsupported() {
|
||
this.$message.warning('当前文件暂不支持在线预览');
|
||
},
|
||
handleAttachmentPreviewError() {
|
||
this.$message.error('附件预览失败');
|
||
},
|
||
downloadAttachment(row) {
|
||
const url = this.attachmentUrl(row);
|
||
if (!url) {
|
||
this.$message.warning('附件地址为空,无法下载');
|
||
return;
|
||
}
|
||
downloadFileByUrl(url, this.attachmentName(row));
|
||
},
|
||
batchDownload() {
|
||
const rows = this.selectedAttachments.length ? this.selectedAttachments : this.attachmentRows;
|
||
const downloadableRows = rows.filter(row => this.attachmentUrl(row));
|
||
if (!downloadableRows.length) {
|
||
this.$message.warning(
|
||
this.selectedAttachments.length ? '所选附件暂无可下载地址' : '暂无可下载附件'
|
||
);
|
||
return;
|
||
}
|
||
downloadableRows.forEach((row, index) => {
|
||
window.setTimeout(() => this.downloadAttachment(row), index * 300);
|
||
});
|
||
},
|
||
formatFileSize(size) {
|
||
const value = Number(size);
|
||
if (!value) return '';
|
||
if (value < 1024) return `${value}B`;
|
||
if (value < 1024 * 1024) return `${(value / 1024).toFixed(1)}KB`;
|
||
return `${(value / 1024 / 1024).toFixed(1)}MB`;
|
||
},
|
||
handleExport() {
|
||
this.$confirm(`是否导出${this.config.exportName || this.config.title}?`, '提示', {
|
||
confirmButtonText: '确定',
|
||
cancelButtonText: '取消',
|
||
type: 'warning',
|
||
}).then(() => {
|
||
NProgress.start();
|
||
exportBlob(
|
||
this.config.exportUrl,
|
||
{ ...this.query, ids: this.ids, [this.website.tokenHeader]: getToken() },
|
||
{ feedback: true }
|
||
)
|
||
.then(res => {
|
||
downloadXls(
|
||
res.data,
|
||
`${this.config.exportName || this.config.title}${this.$dayjs().format(
|
||
'YYYY-MM-DD HH:mm:ss'
|
||
)}.xlsx`
|
||
);
|
||
})
|
||
.finally(() => NProgress.done());
|
||
});
|
||
},
|
||
},
|
||
};
|
||
</script>
|
||
|
||
<style lang="scss" scoped>
|
||
.temporary-credit-limit-page {
|
||
&__field {
|
||
width: 100%;
|
||
}
|
||
|
||
&__attachment-head {
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: flex-end;
|
||
margin-bottom: 12px;
|
||
}
|
||
|
||
&__attachment-upload {
|
||
display: flex;
|
||
justify-content: flex-start;
|
||
margin-top: 12px;
|
||
|
||
:deep(.vehicle-attachment-upload) {
|
||
display: flex;
|
||
align-items: center;
|
||
width: auto;
|
||
}
|
||
|
||
:deep(.el-upload) {
|
||
display: inline-flex;
|
||
}
|
||
|
||
:deep(.el-upload__tip) {
|
||
display: inline-block;
|
||
margin: 0 0 0 30px;
|
||
color: #909399;
|
||
font-size: 13px;
|
||
line-height: 1.4;
|
||
text-align: left;
|
||
}
|
||
}
|
||
|
||
&__flow {
|
||
width: 100%;
|
||
height: calc(100vh - 150px);
|
||
border: 0;
|
||
}
|
||
|
||
:deep(.avue-crud__header) {
|
||
margin-top: 12px;
|
||
}
|
||
|
||
:deep(.avue-crud__menu) {
|
||
display: flex;
|
||
flex-wrap: wrap;
|
||
gap: 8px;
|
||
}
|
||
}
|
||
</style>
|
||
|
||
<style lang="scss">
|
||
// 弹窗字段 label 允许多行(列宽不足时换行)
|
||
.temporary-credit-limit-dialog .el-form-item__label {
|
||
white-space: normal;
|
||
line-height: 18px;
|
||
}
|
||
|
||
// 多行 label 时,必填星号与第一行首字严格对齐(不被 form-item align-items:center 拉到中间)
|
||
.temporary-credit-limit-dialog {
|
||
.el-form-item {
|
||
align-items: flex-start; // 改:取消上下居中,星号不再被拉到 label 块中央
|
||
}
|
||
|
||
.el-form-item__label {
|
||
height: auto !important;
|
||
line-height: 18px;
|
||
}
|
||
|
||
// 强制必填星号垂直居中于行盒,与第一行汉字字符中心同基线(关键)
|
||
.el-form-item.is-required .el-form-item__label::before {
|
||
display: inline-block;
|
||
line-height: 18px;
|
||
height: 18px;
|
||
vertical-align: middle;
|
||
margin-right: 4px;
|
||
}
|
||
|
||
// 「项目额度信息 / 临时额度信息」小标题:对齐项目管理「项目基本信息」样式
|
||
.avue-form__group:has(.dialog-section-title) {
|
||
.dialog-section-title {
|
||
display: flex;
|
||
align-items: center;
|
||
gap: 8px;
|
||
width: 100%;
|
||
padding: 14px 16px 4px;
|
||
margin-bottom: 0;
|
||
color: #303133;
|
||
font-size: 15px;
|
||
font-weight: 500;
|
||
}
|
||
|
||
.avue-form__group--flex:has(.dialog-section-title),
|
||
.el-form-item:has(.dialog-section-title) {
|
||
margin-bottom: 0;
|
||
}
|
||
|
||
.el-form-item:has(.dialog-section-title) .el-form-item__content {
|
||
margin-left: 0 !important;
|
||
}
|
||
}
|
||
|
||
// 分组白卡:Avue 实际结构为 .avue-form > .el-form > .el-row > .avue-group
|
||
.avue-form {
|
||
background: transparent !important;
|
||
box-shadow: none !important;
|
||
padding: 0 !important;
|
||
margin: 0 !important;
|
||
border-radius: 0 !important;
|
||
min-height: 0 !important;
|
||
}
|
||
|
||
.avue-form > .el-form > .el-row {
|
||
margin-left: 0 !important;
|
||
margin-right: 0 !important;
|
||
}
|
||
|
||
// 无分区标题的空分组(Avue 主列残留)隐藏,去掉顶部白横条
|
||
.avue-form > .el-form > .el-row > .avue-group:not(:has(.dialog-section-title)) {
|
||
display: none !important;
|
||
height: 0 !important;
|
||
margin: 0 !important;
|
||
padding: 0 !important;
|
||
overflow: hidden !important;
|
||
border: none !important;
|
||
}
|
||
|
||
// 有分区标题的分组渲染为独立白卡
|
||
.avue-form > .el-form > .el-row > .avue-group:has(.dialog-section-title) {
|
||
background: #fff;
|
||
border-radius: 6px;
|
||
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
|
||
margin-bottom: 12px;
|
||
padding: 0 0 4px;
|
||
overflow: hidden;
|
||
}
|
||
|
||
.avue-form > .el-form > .el-row > .avue-group:has(.dialog-section-title):last-child {
|
||
margin-bottom: 0;
|
||
}
|
||
|
||
.avue-group .el-collapse {
|
||
border: none !important;
|
||
}
|
||
|
||
.avue-group .el-collapse-item__header {
|
||
display: none !important;
|
||
height: 0 !important;
|
||
min-height: 0 !important;
|
||
line-height: 0 !important;
|
||
padding: 0 !important;
|
||
border: none !important;
|
||
overflow: hidden;
|
||
}
|
||
|
||
.avue-group .avue-group__header {
|
||
display: none !important;
|
||
height: 0 !important;
|
||
min-height: 0 !important;
|
||
padding: 0 !important;
|
||
margin: 0 !important;
|
||
border: none !important;
|
||
}
|
||
|
||
.avue-group .el-collapse-item__wrap {
|
||
border: none !important;
|
||
}
|
||
|
||
.avue-group .el-collapse-item__content {
|
||
padding: 0 !important;
|
||
}
|
||
|
||
// 卡片视觉由外层 avue-group 承担,内层去白底,避免叠卡/顶条
|
||
.avue-group .avue-form__group {
|
||
display: flex !important;
|
||
background: transparent !important;
|
||
box-shadow: none !important;
|
||
margin: 0 !important;
|
||
padding: 0 !important;
|
||
border-radius: 0 !important;
|
||
}
|
||
}
|
||
|
||
.temporary-credit-limit-dialog .business-crud-page__detail-content .el-descriptions__label {
|
||
width: 180px !important;
|
||
}
|
||
|
||
// 新增/编辑/查看:高度随内容自适应,超出时再滚动;去掉强制全屏导致的底部大片空白
|
||
.temporary-credit-limit-dialog.el-dialog {
|
||
margin-top: 20px !important;
|
||
margin-bottom: 20px !important;
|
||
height: auto !important;
|
||
max-height: calc(100vh - 40px) !important;
|
||
display: flex;
|
||
flex-direction: column;
|
||
}
|
||
|
||
.temporary-credit-limit-dialog .el-dialog__header {
|
||
flex: none;
|
||
}
|
||
|
||
.temporary-credit-limit-dialog .el-dialog__body {
|
||
flex: 0 1 auto;
|
||
min-height: 0;
|
||
max-height: calc(100vh - 140px) !important;
|
||
display: block;
|
||
overflow-y: auto;
|
||
}
|
||
|
||
// 覆盖全局 .el-dialog .avue-form 白底内边距,避免顶部出现白横条
|
||
.temporary-credit-limit-dialog:not(.temporary-credit-limit-detail-dialog) .avue-form {
|
||
background: transparent !important;
|
||
box-shadow: none !important;
|
||
padding: 0 !important;
|
||
margin: 0 !important;
|
||
border-radius: 0 !important;
|
||
}
|
||
|
||
.temporary-credit-limit-dialog:not(.temporary-credit-limit-detail-dialog) .avue-dialog__footer,
|
||
.temporary-credit-limit-detail-dialog .el-dialog__footer {
|
||
position: sticky;
|
||
bottom: 0;
|
||
z-index: 5;
|
||
flex: none;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: flex-end;
|
||
gap: 12px;
|
||
margin-top: 0 !important;
|
||
padding: 12px 20px !important;
|
||
background: #fff;
|
||
border-top: 1px solid var(--el-border-color-lighter, #ebeef5) !important;
|
||
border-radius: 0;
|
||
box-shadow: none;
|
||
|
||
.el-button + .el-button {
|
||
margin-left: 0;
|
||
}
|
||
}
|
||
|
||
.temporary-credit-limit-detail-dialog {
|
||
.business-crud-page__detail-content {
|
||
flex: 1 1 auto;
|
||
min-height: 0;
|
||
overflow: auto;
|
||
padding: 0;
|
||
}
|
||
|
||
&__section {
|
||
margin-bottom: 12px;
|
||
padding: 0 0 4px;
|
||
background: #fff;
|
||
border-radius: 6px;
|
||
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
|
||
overflow: hidden;
|
||
|
||
&:last-child {
|
||
margin-bottom: 0;
|
||
}
|
||
}
|
||
|
||
&__descriptions {
|
||
padding: 0 16px 8px;
|
||
|
||
// 取消 Descriptions 表格边框样式,改为纯文本描述列表
|
||
.el-descriptions__body {
|
||
background: transparent;
|
||
}
|
||
|
||
.el-descriptions__table {
|
||
border-collapse: separate;
|
||
border-spacing: 0;
|
||
}
|
||
|
||
.el-descriptions__cell {
|
||
border: none !important;
|
||
background: transparent !important;
|
||
padding: 8px 12px 8px 0;
|
||
vertical-align: top;
|
||
}
|
||
|
||
.el-descriptions__label {
|
||
color: #606266;
|
||
font-weight: 400;
|
||
white-space: normal;
|
||
line-height: 18px;
|
||
}
|
||
|
||
.el-descriptions__content {
|
||
color: #303133;
|
||
line-height: 18px;
|
||
}
|
||
}
|
||
|
||
.dialog-section-title {
|
||
display: flex;
|
||
align-items: center;
|
||
gap: 8px;
|
||
width: 100%;
|
||
padding: 14px 16px 4px;
|
||
margin-bottom: 0;
|
||
color: #303133;
|
||
font-size: 15px;
|
||
font-weight: 500;
|
||
}
|
||
|
||
&__attachment {
|
||
padding: 8px 16px 16px;
|
||
}
|
||
|
||
&__attachment-label {
|
||
color: #606266;
|
||
font-size: 14px;
|
||
}
|
||
|
||
.temporary-credit-limit-page__attachment-head {
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: space-between;
|
||
margin-bottom: 12px;
|
||
}
|
||
}
|
||
|
||
.el-form-item--default .el-form-item__label {
|
||
height: auto !important;
|
||
}
|
||
|
||
</style>
|