更新0731

This commit is contained in:
xyc 2025-07-31 13:32:51 +08:00
parent d5124852d0
commit 9a9e3f6487
5 changed files with 677 additions and 0 deletions

View File

@ -6,6 +6,7 @@ VUE_APP_TITLE = "车联通"后台管理系统
# 芋道管理系统/开发环境
VUE_APP_BASE_API = 'http://localhost:48080'
#VUE_APP_BASE_API = 'https://www.nuoyunr.com'
#VUE_APP_BASE_API = 'http://122.51.230.86:48080'
# 附件请求地址前缀
# VUE_APP_FILE_API = 'https://www.nuoyunr.com/minio/'

View File

@ -252,3 +252,19 @@ export function getPath(path) {
}
return Math.floor(divisor/dividend*100)/100;
}
/**
* 获取当前路由路径的最后一个路径段例如/workReport/jiance => jiance
* @param {String} path 当前路由路径不传则默认取 this.$route.path
* @param {Number} index 倒数第几个路径段默认1是最后一段
* @returns {String}
*/
export function getLastPathSegment(path, index = 1) {
if (!path && typeof window !== 'undefined' && window.location) {
path = window.location.pathname;
}
if (!path) return '';
const segments = path.split('/').filter(Boolean);
return segments.length >= index ? segments[segments.length - index] : '';
}

View File

@ -0,0 +1,184 @@
<template>
<div class="app-container">
<!-- 对话框(添加 / 修改) -->
<el-dialog :title="dialogTitle" :visible.sync="dialogVisible" width="45%" v-dialogDrag append-to-body>
<el-form ref="formRef" :model="formData" :rules="formRules" v-loading="formLoading" label-width="100px">
<el-form-item label="汇报主题" prop="reportTopic">
<el-input v-model="formData.reportTopic" placeholder="请输入汇报主题"/>
</el-form-item>
<el-form-item label="汇报时间" prop="reportTime">
<el-date-picker
v-model="formData.reportTime"
type="datetime"
placeholder="选择日期时间">
</el-date-picker>
</el-form-item>
<el-form-item label="汇报给" prop="reportTos">
<el-select v-model="formData.reportTos" multiple placeholder="请选择">
<el-option
v-for="item in reportTo"
:key="item.id"
:label="item.nickname"
:value="item.id">
</el-option>
</el-select>
</el-form-item>
<el-form-item label="汇报内容" prop="reportContent">
<el-input type="textarea" v-model="formData.reportContent" :autosize="{ minRows: 6, maxRows: 10 }"/>
</el-form-item>
<el-form-item label="汇报附件" prop="reportFiles">
<drive-file-upload
:fileSize="30"
:fileType="['doc', 'xls', 'ppt', 'txt', 'pdf','png','jpg','jpeg','gif','docx','xlsx','pptx','wps']"
v-model="formData.filePath"/>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm" :disabled="formLoading"> </el-button>
<el-button @click="dialogVisible = false"> </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import * as ReportApi from '@/views/drivingSchool/workReport/api/index';
import Editor from '@/components/Editor';
import {getReportTo} from '@/views/drivingSchool/workReport/api';
import {formatDate} from "@/utils";
import driveFileUpload from "@/components/FileUpload/index.vue";
export default {
name: "ReportForm",
components: {
driveFileUpload,
Editor,
},
props: {
servicePackageId: {
type: String,
required: true
},
dictType: {
type: String,
required: true
}
},
data() {
return {
//
dialogTitle: "",
//
dialogVisible: false,
// 12
formLoading: false,
//
reportTo: [],
//
formData: {
id: undefined,
reportTopic: undefined,
reportTime: undefined,
reportContent: undefined,
servicePackageId: undefined,
reportTos: [],
},
//
formRules: {
reportTopic: [{required: true, message: '汇报主题不能为空', trigger: 'blur'}],
reportTime: [{required: true, message: '汇报时间不能为空', trigger: 'blur'}],
reportContent: [{required: true, message: '汇报内容不能为空', trigger: 'blur'}],
reportTos: [{required: true, message: '汇报给不能为空', trigger: 'blur'}],
},
};
},
methods: {
/** 打开弹窗 */
async open(id) {
this.dialogVisible = true;
this.reset();
this.getReportTo()
//
if (id) {
this.formLoading = true;
try {
const res = await ReportApi.getReport(id);
this.formData = res.data;
this.dialogTitle = "修改工作汇报";
//
if (this.formData.filePath !== undefined && this.formData.filePath !== null && this.formData.filePath !== "") {
this.formData.filePath = this.formData.filePath.split(",");
}
} finally {
this.formLoading = false;
}
} else {
this.setDefaultData();
this.dialogTitle = "新增工作汇报";
}
},
/** 提交按钮 */
async submitForm() {
//
await this.$refs["formRef"].validate();
this.formLoading = true;
try {
const data = this.formData;
//
if (data.id) {
await ReportApi.updateReport(data);
this.$modal.msgSuccess("修改成功");
this.dialogVisible = false;
this.$emit('success');
return;
}
//
data.reportTime = this.formData.reportTime.getTime();
await ReportApi.createReport(data);
this.$modal.msgSuccess("新增成功");
this.dialogVisible = false;
this.$emit('success');
} finally {
this.formLoading = false;
}
},
/** 表单重置 */
reset() {
this.formData = {
id: undefined,
reportTopic: undefined,
reportTime: undefined,
reportContent: undefined,
};
this.resetForm("formRef");
},
/** 设置默认数据 */
setDefaultData() {
this.formData.reportTime = new Date();
this.formData.servicePackageId = this.servicePackageId;
},
/** 获取汇报对象 */
getReportTo() {
const data = {
dictType: this.dictType
}
getReportTo(data).then(response => {
this.reportTo = response.data;
});
},
/** 格式化时间yyyy-MM-dd HH:mm:ss */
formatDateTime(date) {
if (!date) return null;
const d = new Date(date);
const year = d.getFullYear();
const month = String(d.getMonth() + 1).padStart(2, '0');
const day = String(d.getDate()).padStart(2, '0');
const hours = String(d.getHours()).padStart(2, '0');
const minutes = String(d.getMinutes()).padStart(2, '0');
const seconds = String(d.getSeconds()).padStart(2, '0');
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
}
}
};
</script>

View File

@ -0,0 +1,69 @@
import request from '@/utils/request'
// 创建工作汇报
export function getReportTo(query) {
return request({
url: '/work/report/queryReportTo',
method: 'get',
params: query
})
}
// 创建工作汇报
export function createReport(data) {
return request({
url: '/work/report/create',
method: 'post',
data: data
})
}
// 更新工作汇报
export function updateReport(data) {
return request({
url: '/work/report/update',
method: 'put',
data: data
})
}
// 删除工作汇报
export function deleteReport(id) {
return request({
url: '/work/report/delete?id=' + id,
method: 'delete'
})
}
// 获得工作汇报
export function getReport(id) {
return request({
url: '/work/report/get?id=' + id,
method: 'get'
})
}
// 获得工作汇报分页
export function getReportPage(params) {
return request({
url: '/work/report/page',
method: 'get',
params
})
}
// 获得工作汇报分页
export function workReportView(id) {
return request({
url: '/work/report/workReportView?id=' + id,
method: 'get',
})
}
// 导出工作汇报 Excel
export function exportReportExcel(params) {
return request({
url: '/work/report/export-excel',
method: 'get',
params,
responseType: 'blob'
})
}

View File

@ -0,0 +1,407 @@
<template>
<div class="app-container">
<!-- 搜索工作栏 -->
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="汇报主题" prop="reportTopic">
<el-input v-model="queryParams.reportTopic" placeholder="请输入汇报主题" clearable
@keyup.enter.native="handleQuery"/>
</el-form-item>
<el-form-item label="汇报时间" prop="reportTime">
<el-date-picker v-model="queryParams.reportTime" style="width: 240px" value-format="yyyy-MM-dd HH:mm:ss"
type="daterange"
range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期"
:default-time="['00:00:00', '23:59:59']"/>
</el-form-item>
<el-form-item label="汇报人" prop="userId">
<el-input v-model="queryParams.userName" placeholder="请输入汇报人" clearable
@keyup.enter.native="handleQuery"/>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
<!-- 操作工具栏 -->
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button type="primary" plain icon="el-icon-plus" size="mini" @click="openForm(undefined)">新增
</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport"
:loading="exportLoading">导出
</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
<el-table-column label="汇报主题" align="center" prop="reportTopic"/>
<el-table-column label="汇报时间" align="center" prop="reportTime" width="180">
<template v-slot="scope">
<span>{{ parseTime(scope.row.reportTime) }}</span>
</template>
</el-table-column>
<el-table-column label="汇报内容" align="center" prop="reportContent" show-overflow-tooltip/>
<el-table-column label="汇报人" align="center" prop="userName"/>
<el-table-column label="附件" align="center" width="100">
<template v-slot="scope">
<el-button
v-if="scope.row.filePath"
size="mini"
type="text"
@click="handleViewFiles(scope.row.filePath)"
>
查看附件
</el-button>
<span v-else>无附件</span>
</template>
</el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template v-slot="scope">
<el-button size="mini" type="text" icon="el-icon-edit" @click="workReportView(scope.row.id)">打印
</el-button>
<el-button size="mini" type="text" icon="el-icon-edit" @click="openForm(scope.row.id)">修改
</el-button>
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)">删除
</el-button>
</template>
</el-table-column>
</el-table>
<el-dialog :title="'文件预览(' + currentFileName + ''" :visible.sync="fileDialogVisible" width="70%"
append-to-body>
<div class="preview-container">
<!-- 左侧预览区域 -->
<!-- 音频文件 -->
<audio v-if="isAudioType" class="preview-iframe" controls>
<source :src="currentFileUrl"/>
</audio>
<!-- Office文档/文本/PDF -->
<iframe
v-else-if="!isImageType && currentFileType !== 'txt' && !isAudioType && currentFileType !== 'pdf'"
:src="officePreviewUrl"
frameborder="0"
class="preview-iframe"
></iframe>
<!-- 图片预览 -->
<image-preview
v-else-if="isImageType"
class="preview-iframe"
:src="currentFileUrl"
></image-preview>
<!-- PDF/文本 -->
<iframe
v-else-if="currentFileType === 'txt' || currentFileType === 'pdf'"
:src="currentFileUrl"
frameborder="0"
class="preview-iframe"
></iframe>
<!-- 右侧文件列表 -->
<div class="file-list" v-if="currentFileList.length > 1">
<el-table
:data="currentFileList"
height="100%"
@row-click="handleFileClick"
:row-class-name="getRowClassName">
<el-table-column
prop="fileName"
label="文件列表"
min-width="180">
<template #default="{ row }">
<div class="file-item">
<i :class="getFileIcon(row)"></i>
{{ getFileName(row) }}
</div>
</template>
</el-table-column>
</el-table>
</div>
</div>
</el-dialog>
<!-- 分页组件 -->
<pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
@pagination="getList"/>
<!-- 对话框(添加 / 修改) -->
<ReportForm ref="formRef" :servicePackageId="queryParams.servicePackageId" :dictType="reportToDictType" @success="getList"/>
</div>
</template>
<script>
import * as ReportApi from '@/views/drivingSchool/workReport/api/index';
import ReportForm from './ReportForm.vue';
import print from 'vue-print-nb'
import {workReportView} from "@/views/drivingSchool/workReport/api/index";
import {getLastPathSegment} from "@/utils/ruoyi";
export default {
name: "Report",
directives: {
print
},
components: {
ReportForm,
},
data() {
return {
//
loading: true,
showView: false,
//
exportLoading: false,
//
showSearch: true,
htmText: '',
//
total: 0,
//
list: [],
//
isExpandAll: true,
//
refreshTable: true,
//
currentRow: {},
//
queryParams: {
pageNo: 1,
pageSize: 10,
reportTopic: null,
reportTime: [],
createTime: [],
userId: null,
userName: null,
servicePackageId: this.$route.query.servicePackageId,
dictType: this.$route.query.dictType,
},
// dictDtype
reportToDictType: '',
fileDialogVisible: false,
currentFileList: [],
activeFileTab: 0,
baseUrl: process.env.VUE_APP_BASE_API,
currentFileUrl: '',
currentFileName: '',
currentFileType: '',
officePreviewUrl: '',
};
},
computed: {
isImageType() {
return /\.(jpg|jpeg|png|gif|webp|bmp)$/i.test(this.currentFileUrl);
},
isAudioType() {
const audioExtensions = ['mp3', 'wav', 'ogg', 'aac', 'm4a', 'flac'];
return audioExtensions.some(ext => this.currentFileUrl.endsWith(ext));
}
},
created() {
const servicePackageId = getLastPathSegment(this.$route.path); //
console.log('服务套餐', servicePackageId)
this.queryParams.servicePackageId = servicePackageId;
switch (servicePackageId) {
case 'jiance':
this.queryParams.dictType = 'ins_high_rise';
this.reportToDictType = 'ins_report_role';
break;
case 'jiaxiao':
this.queryParams.dictType = 'drive_school_high_rise';
this.reportToDictType = 'drive_school_report_role';
break;
case 'weixiu':
this.queryParams.dictType = 'repair_high_rise';
this.reportToDictType = 'repair_report_role';
break;
case 'jiuyuan':
this.queryParams.dictType = 'recue_high_rise';
this.reportToDictType = 'rescue_report_role';
break;
}
console.log('服务套餐', this.reportToDictType)
this.getList();
},
methods: {
/** 查询列表 */
async getList() {
try {
this.loading = true;
const res = await ReportApi.getReportPage(this.queryParams);
this.list = res.data.records;
this.total = res.data.total;
} finally {
this.loading = false;
}
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNo = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
/** 添加/修改操作 */
openForm(id) {
this.$refs["formRef"].open(id);
},
workReportView(id) {
this.showView = true
ReportApi.workReportView(id).then(res => {
this.htmText = res.data
})
},
/** 删除按钮操作 */
async handleDelete(row) {
const id = row.id;
await this.$modal.confirm('是否确认删除工作汇报编号为"' + id + '"的数据项?')
try {
await ReportApi.deleteReport(id);
await this.getList();
this.$modal.msgSuccess("删除成功");
} catch {
}
},
/** 导出按钮操作 */
async handleExport() {
await this.$modal.confirm('是否确认导出所有工作汇报数据项?');
try {
this.exportLoading = true;
const data = await ReportApi.exportReportExcel(this.queryParams);
this.$download.excel(data, '工作汇报.xls');
} catch {
} finally {
this.exportLoading = false;
}
},
//
handleViewFiles(filePath) {
if (!filePath) {
this.$message.warning('没有附件');
return;
}
//
this.currentFileList = filePath.split(',').filter(item => item.trim());
this.fileDialogVisible = true;
//
if (this.currentFileList.length > 0) {
this.previewFile(this.currentFileList[0]);
}
},
// URLAPI
getFullFileUrl(filePath) {
if (!filePath) return '';
// URLbase64
if (filePath.startsWith('http') || filePath.startsWith('data:')) {
return filePath;
}
// API
const baseUrl = 'http://122.51.230.86:9000/' || '';
return `${baseUrl.replace(/\/$/, '')}/${filePath.replace(/^\//, '')}`;
},
//
getFileName(filePath) {
return filePath.split('/').pop() || '未命名文件';
},
//
isImage(filePath) {
return /\.(jpg|jpeg|png|gif|webp|bmp)$/i.test(filePath);
},
//
previewFile(filePath) {
this.currentFileUrl = this.getFullFileUrl(filePath);
this.currentFileName = this.getFileName(filePath);
this.currentFileType = this.getFileExtension(filePath);
// OfficeURL
this.officePreviewUrl = 'https://view.officeapps.live.com/op/view.aspx?src=' +
encodeURIComponent(this.currentFileUrl);
},
//
getFileExtension(filePath) {
return filePath.split('.').pop().toLowerCase();
},
//
getFileIcon(filePath) {
return this.isImage(filePath) ? 'el-icon-picture' : 'el-icon-document';
},
//
handleFileClick(row) {
this.previewFile(row);
},
//
getRowClassName({row}) {
return row === this.currentFileUrl ? 'highlight-row' : '';
},
}
};
</script>
<style scoped>
.image-preview {
display: flex;
justify-content: center;
margin: 20px 0;
}
.image-preview img {
max-height: 500px;
max-width: 100%;
border: 1px solid #eee;
}
.preview-container {
display: flex;
height: 70vh;
}
.preview-iframe {
flex: 1;
width: 100%;
height: 100%;
border: none;
}
.file-list {
flex: 0 0 250px;
border-left: 1px solid #ebeef5;
padding-left: 10px;
margin-left: 10px;
}
.file-item {
cursor: pointer;
padding: 8px;
transition: background 0.3s;
}
.file-item:hover {
background: #f5f7fa;
}
.highlight-row {
background-color: #f0f7ff;
}
</style>