first commit
This commit is contained in:
@ -0,0 +1,135 @@
|
||||
<template>
|
||||
<div class="system-document-container">
|
||||
<el-card shadow="hover">
|
||||
<div class="system-document-search mb15">
|
||||
<el-form :model="param" ref="queryRef" :inline="true" label-width="100px">
|
||||
<el-row>
|
||||
<el-col>
|
||||
<el-button type="success" v-hasPermi="['project:project:remove']" :disabled="multiple" @click="onRecyclingStation(null)"
|
||||
><el-icon><RefreshRight /></el-icon>批量恢复</el-button
|
||||
>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-form>
|
||||
</div>
|
||||
<el-table v-loading="loading" :data="tableData" @selection-change="handleSelectionChange">
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column label="序号" align="center" type="index" min-width="30px" />
|
||||
<el-table-column label="文件名称" align="center" prop="fileName" min-width="100px" />
|
||||
<el-table-column label="文件类型" align="center" prop="fileType" min-width="100px">
|
||||
<template #default="scope">
|
||||
<span>{{ scope.row.fileType == '1' ? '文件' : '文件夹' }}</span>
|
||||
</template> </el-table-column
|
||||
><el-table-column label="文件路径" align="center" min-width="100px">
|
||||
<template #default="scope">
|
||||
<span>{{ scope.row.filePath }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="删除时间" align="center" prop="deletedAt" min-width="100px"> </el-table-column>
|
||||
<el-table-column label="操作" align="center" class-name="small-padding" min-width="100px" fixed="right">
|
||||
<template #default="scope">
|
||||
<el-button type="success" v-hasPermi="['project:project:remove']" link @click="onRecyclingStation(scope.row)"
|
||||
><el-icon><RefreshRight /></el-icon>恢复</el-button
|
||||
>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<!-- <pagination v-show="total > 0" :total="total" v-model:page="param.pageNum" v-model:limit="param.pageSize" @pagination="getDocumentDataList" /> -->
|
||||
</el-card>
|
||||
</div>
|
||||
</template>
|
||||
<script lang="ts">
|
||||
import { toRefs, reactive, ref, defineComponent, getCurrentInstance } from 'vue';
|
||||
import { ElMessageBox, ElMessage, ElLoading } from 'element-plus';
|
||||
import { useUserStoreHook } from '@/store/modules/user';
|
||||
|
||||
// 获取用户 store
|
||||
const userStore = useUserStoreHook();
|
||||
// 从 store 中获取项目列表和当前选中的项目
|
||||
const currentProject = computed(() => userStore.selectedProject);
|
||||
import { documentRecycleBinList, completionDataRecyclingStation } from '@/api/safety/documentSafetyMeeting';
|
||||
export default defineComponent({
|
||||
name: 'index',
|
||||
setup() {
|
||||
const { proxy } = <any>getCurrentInstance();
|
||||
const loading = ref(false);
|
||||
const queryRef = ref();
|
||||
// 非多个禁用
|
||||
const multiple = ref(true);
|
||||
const state = reactive({
|
||||
tableData: [],
|
||||
param: {
|
||||
type: 2,
|
||||
projectId: currentProject.value?.id
|
||||
},
|
||||
total: 0,
|
||||
ids: [] //所选择的文件
|
||||
});
|
||||
// 获取资料删除的列表数据
|
||||
const getDocumentDataList = () => {
|
||||
loading.value = true;
|
||||
documentRecycleBinList(state.param).then((res: any) => {
|
||||
let list = res.rows ?? [];
|
||||
state.tableData = list;
|
||||
console.log('🚀 ~ documentRecycleBinList ~ state.tableData:', state.tableData);
|
||||
|
||||
state.total = res.total;
|
||||
loading.value = false;
|
||||
});
|
||||
};
|
||||
// 多选框选中数据
|
||||
const handleSelectionChange = (selection) => {
|
||||
state.ids = selection.map((item) => item.id);
|
||||
multiple.value = !selection.length;
|
||||
};
|
||||
const onRecyclingStation = (row) => {
|
||||
let ids = [];
|
||||
if (row) {
|
||||
ids = [row.id];
|
||||
} else {
|
||||
// 批量
|
||||
ids = state.ids;
|
||||
}
|
||||
ElMessageBox.confirm('你确定要恢复所选文件或文件夹?', '提示', {
|
||||
confirmButtonText: '确认',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
})
|
||||
.then(() => {
|
||||
const loading = ElLoading.service({
|
||||
lock: true,
|
||||
text: '正在恢复中……',
|
||||
background: 'rgba(0, 0, 0, 0.7)'
|
||||
});
|
||||
completionDataRecyclingStation(ids).then((res) => {
|
||||
loading.close();
|
||||
if (res.code == 200) {
|
||||
getDocumentDataList();
|
||||
ElMessage.success('操作成功');
|
||||
} else {
|
||||
ElMessage.error(res.msg);
|
||||
}
|
||||
});
|
||||
})
|
||||
.catch(() => {});
|
||||
};
|
||||
return {
|
||||
proxy,
|
||||
multiple,
|
||||
loading,
|
||||
onRecyclingStation,
|
||||
handleSelectionChange,
|
||||
getDocumentDataList,
|
||||
...toRefs(state)
|
||||
};
|
||||
}
|
||||
});
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
.colBlock {
|
||||
display: block;
|
||||
}
|
||||
.colNone {
|
||||
display: none;
|
||||
}
|
||||
</style>
|
||||
524
src/views/safety/documentSafetyMeeting/index.vue
Normal file
524
src/views/safety/documentSafetyMeeting/index.vue
Normal file
@ -0,0 +1,524 @@
|
||||
<template>
|
||||
<div class="documentCompletion-data">
|
||||
<el-tabs v-model="activeName" class="p-4" @tab-click="handleClick">
|
||||
<el-tab-pane label="文件夹" name="first">
|
||||
<el-button type="success" :disabled="toolStart" @click="handleFile(3)"
|
||||
><el-icon><Plus /></el-icon>新建文件夹</el-button
|
||||
>
|
||||
<el-button type="primary" :disabled="toolStart" @click="handleFile(2)"
|
||||
><el-icon><Upload /></el-icon>上传文件</el-button
|
||||
>
|
||||
<el-card style="margin-top: 10px">
|
||||
<div class="breadcrumb-img">
|
||||
<el-breadcrumb>
|
||||
<el-breadcrumb-item @click="onBreadcrumb(item)" v-for="(item, i) of breadcrumbList" :key="i">
|
||||
<span title="点击打开文件夹" style="cursor: pointer">{{ item.fileName }}</span>
|
||||
</el-breadcrumb-item>
|
||||
</el-breadcrumb>
|
||||
<div class="tool-All">
|
||||
<div v-if="!toolStart">
|
||||
<el-button type="primary" v-hasPermi="['project:project:remove']" @click="onBatchAll">
|
||||
<el-icon><Menu /></el-icon>批量操作</el-button
|
||||
>
|
||||
</div>
|
||||
<div v-if="toolStart">
|
||||
<el-button type="warning" @click="onBatchAll">
|
||||
<el-icon><Tools /></el-icon>取消操作</el-button
|
||||
>
|
||||
<el-button type="danger" @click="onDeleteAll">
|
||||
<el-icon><Delete /></el-icon>删除</el-button
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</el-card>
|
||||
<el-card style="margin-top: 10px">
|
||||
<div class="file_detail" id="file_detail1">
|
||||
<el-row class="row-bg" v-if="fileList.length">
|
||||
<el-col :span="2" v-for="(item, i) of fileList" :key="i">
|
||||
<div :class="{ file_style: true }">
|
||||
<div @click="onNav(item)" title="点击打开文件" @contextmenu="onContextmenu($event, item, i)">
|
||||
<img src="../../../assets/icons/svg/file1.png" v-if="item.fileType == '2'" alt="" />
|
||||
<img src="../../../assets/icons/svg/file.png" v-else-if="item.fileType == '1'" alt="" />
|
||||
<el-image
|
||||
v-else-if="item.fileType == '3'"
|
||||
style="width: 100%; height: 100%"
|
||||
:src="item.filePath"
|
||||
:zoom-rate="1.2"
|
||||
:max-scale="7"
|
||||
:min-scale="0.2"
|
||||
:initial-index="4"
|
||||
:preview-src-list="[item.filenPathCoding]"
|
||||
fit="cover"
|
||||
/>
|
||||
<img :src="'/icon/' + item.fileType + '.png'" v-else />
|
||||
</div>
|
||||
<span @click="onFileName(item)" title="点击重命名">{{ item.fileName }}</span>
|
||||
<div :class="{ fileActive: toolStart }" v-if="toolStart" @click="onToolAll(item)"></div>
|
||||
<div class="checkbox-box" v-if="toolStart">
|
||||
<el-checkbox v-model="item.checkbox" size="large" />
|
||||
</div>
|
||||
</div>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-empty :image-size="200" description="暂无文件" v-else />
|
||||
<div class="right_box" id="right_box">
|
||||
<div v-for="(item, i) of list" :key="i" @click="item.callback($event)">
|
||||
{{ item.name }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</el-card>
|
||||
</el-tab-pane>
|
||||
<el-tab-pane label="回收站" name="second">
|
||||
<RecyclingStation ref="RecyclingStationRef"></RecyclingStation>
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
</div>
|
||||
</template>
|
||||
<script lang="ts">
|
||||
import { toRefs, reactive, onMounted, ref, defineComponent, computed, getCurrentInstance, toRaw, nextTick, onBeforeUnmount } from 'vue';
|
||||
import { ElMessageBox, ElMessage, ElLoading } from 'element-plus';
|
||||
import {
|
||||
documentCompletionTreeStructure,
|
||||
documentCompletionDelete,
|
||||
documentCompletionAdd,
|
||||
documentCompletionEdit,
|
||||
newFolder,
|
||||
uniFileDownload
|
||||
} from '@/api/safety/documentSafetyMeeting/index';
|
||||
import { useUserStoreHook } from '@/store/modules/user';
|
||||
|
||||
// 获取用户 store
|
||||
const userStore = useUserStoreHook();
|
||||
// 从 store 中获取项目列表和当前选中的项目
|
||||
const currentProject = computed(() => userStore.selectedProject);
|
||||
// 回收站
|
||||
import RecyclingStation from '@/views/safety/documentSafetyMeeting/RecyclingStation/index.vue';
|
||||
export default defineComponent({
|
||||
name: 'index',
|
||||
components: {
|
||||
RecyclingStation
|
||||
},
|
||||
setup() {
|
||||
const { proxy } = <any>getCurrentInstance();
|
||||
const RecyclingStationRef = ref();
|
||||
// 字典选项数据
|
||||
const {} = proxy.useDict();
|
||||
// 文件下载
|
||||
const onExport = (event) => {
|
||||
event.stopPropagation();
|
||||
// 文件下载 state.typeFile: 2、文件夹 1、文件
|
||||
if (state.typeFile == '2') {
|
||||
window.open(state.relativePath, '_black');
|
||||
} else {
|
||||
uniFileDownload({ relativePath: state.relativePath, type: state.typeFile }).then((res) => {
|
||||
if (res.code == 200) {
|
||||
window.open(res.data.Path, '_black');
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
// 文件删除
|
||||
const onDeleteFile = (event) => {
|
||||
event.stopPropagation();
|
||||
setDel([state.delId]);
|
||||
};
|
||||
const state = reactive({
|
||||
fileList: [],
|
||||
activeName: 'first',
|
||||
breadcrumbList: [{ id: 0, fileName: '目录' }], //菜单列表
|
||||
projectId: currentProject.value?.id,
|
||||
parentPid: '0', //父级的id 默认为0
|
||||
fileType: 0, //文件 或压缩文件
|
||||
list: [
|
||||
{ id: 1, name: '文件下载', callback: onExport, auth: 'api/v1/system/documentSafetyMeeting/safetyDataUniFileDownload' },
|
||||
{ id: 2, name: '文件删除', callback: onDeleteFile, auth: 'api/v1/system/documentSafetyMeeting/delete' }
|
||||
],
|
||||
relativePath: '', //文件下载需要相对路径
|
||||
delId: '', //删除需要的id
|
||||
toolStart: false,
|
||||
imageType: ['jpg', 'png', 'jpeg'],
|
||||
wordType: ['docx', 'doc', 'pdf', 'xls', 'xlsx', 'pptx', 'ppt'],
|
||||
typeFile: ''
|
||||
});
|
||||
onMounted(() => {
|
||||
// 全局设置阻止右键点击
|
||||
document.addEventListener('contextmenu', function (event) {
|
||||
event.preventDefault();
|
||||
});
|
||||
let file_detail_box = document.getElementById('file_detail1');
|
||||
// 监听当前元素点击事件 并关闭弹框
|
||||
file_detail_box.addEventListener('click', () => {
|
||||
let box = document.getElementById('right_box');
|
||||
box.style.display = 'none';
|
||||
});
|
||||
// 默认第一级 父级pid为0
|
||||
getdocumentCompletionTreeStructure();
|
||||
// 压缩文件上传
|
||||
|
||||
proxy.mittBus.on('bigUploader.uploadFileSuccess' + 1010, (res: any) => {
|
||||
const { filename, totalSize, url, identifier, fileType } = res;
|
||||
let arr = filename.split('.');
|
||||
let fileType1 = arr[arr.length - 1];
|
||||
if (fileType1 == 'zip' || fileType1 == 'rar') {
|
||||
state.fileType = 1;
|
||||
} else {
|
||||
//除了压缩 其他文件
|
||||
state.fileType = 2;
|
||||
}
|
||||
let obj = {
|
||||
filePath: {
|
||||
url,
|
||||
name: filename,
|
||||
size: totalSize,
|
||||
fileType: '.' + fileType1 //后缀名
|
||||
},
|
||||
file: ''
|
||||
};
|
||||
documentCompletionAdd(obj).then((res: any) => {
|
||||
if (res.code == 200) {
|
||||
ElMessage({
|
||||
type: 'success',
|
||||
message: '上传成功'
|
||||
});
|
||||
getdocumentCompletionTreeStructure(); //获取当前当前文件夹的文件数据
|
||||
} else {
|
||||
ElMessage({
|
||||
type: 'error',
|
||||
message: res.message
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
onBeforeUnmount(() => {
|
||||
// 取消订阅特定事件
|
||||
proxy.mittBus.off('bigUploader.uploadFileSuccess' + 1010);
|
||||
});
|
||||
const getdocumentCompletionTreeStructure = () => {
|
||||
const loading = ElLoading.service({
|
||||
lock: true,
|
||||
text: '正在查询文件……',
|
||||
background: 'rgba(0, 0, 0, 0.7)'
|
||||
});
|
||||
documentCompletionTreeStructure({ projectId: currentProject.value?.id, pid: state.parentPid }).then((res: any) => {
|
||||
loading.close();
|
||||
if (res.code == 200) {
|
||||
state.fileList = res.data || [];
|
||||
if (state.fileList.length) {
|
||||
state.fileList.map((item) => {
|
||||
return {
|
||||
...item,
|
||||
checkbox: false
|
||||
};
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
const handleFile = (type) => {
|
||||
state.fileType = type;
|
||||
if (type == 3) {
|
||||
// 新建文件夹
|
||||
ElMessageBox.prompt('填写文件夹名', '新建文件夹', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消'
|
||||
})
|
||||
.then(({ value }) => {
|
||||
// pid 父级
|
||||
newFolder({ fileName: value, pid: state.parentPid == '0' ? '' : state.parentPid, projectId: state.projectId }).then((res: any) => {
|
||||
if (res.code == 200) {
|
||||
getdocumentCompletionTreeStructure();
|
||||
ElMessage({
|
||||
type: 'success',
|
||||
message: '添加成功'
|
||||
});
|
||||
} else {
|
||||
ElMessage({
|
||||
type: 'error',
|
||||
message: res.data
|
||||
});
|
||||
}
|
||||
});
|
||||
})
|
||||
.catch(() => {});
|
||||
} else {
|
||||
// 竣工图
|
||||
proxy.mittBus.emit('bigUploader.uploadFile', { type: 100, types: 1010, accept: [] });
|
||||
}
|
||||
return;
|
||||
};
|
||||
// 页面跳转
|
||||
const onNav = (item) => {
|
||||
// 通过后缀判断该文件是什么类型
|
||||
// 图片格式 jpg、png、jpeg、
|
||||
// word文档格式:docx、doc、pdf、xls、xlsx、pptx、ppt
|
||||
// 其他全文件夹
|
||||
if (item.fileType == '3') {
|
||||
// 可以预览图片
|
||||
return;
|
||||
} else if (item.fileType == '2') {
|
||||
// 打开文件夹
|
||||
state.parentPid = item.id;
|
||||
state.breadcrumbList.push(item); //路径设置
|
||||
state.fileList = [];
|
||||
// 获取对应文件夹的数据
|
||||
getdocumentCompletionTreeStructure();
|
||||
} else {
|
||||
window.open(item.filenPathCoding, '_black');
|
||||
return;
|
||||
}
|
||||
};
|
||||
const onFileName = (item) => {
|
||||
// 修改文件名称
|
||||
ElMessageBox.prompt('文件名称修改', '重命名', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
inputValue: item.name
|
||||
})
|
||||
.then(({ value }) => {
|
||||
// 确定
|
||||
documentCompletionEdit({ id: item.id, name: value, type: item.type }).then((res: any) => {
|
||||
if (res.code == 200) {
|
||||
item.name = value;
|
||||
getdocumentCompletionTreeStructure();
|
||||
ElMessage({
|
||||
type: 'success',
|
||||
message: '修改成功'
|
||||
});
|
||||
} else {
|
||||
ElMessage({
|
||||
type: 'error',
|
||||
message: res.message
|
||||
});
|
||||
}
|
||||
});
|
||||
})
|
||||
.catch(() => {});
|
||||
};
|
||||
const handleClick = (val) => {
|
||||
if (state.activeName == 'second') {
|
||||
getdocumentCompletionTreeStructure();
|
||||
} else {
|
||||
RecyclingStationRef.value.getDocumentDataList();
|
||||
}
|
||||
};
|
||||
const onBreadcrumb = (item) => {
|
||||
if (item.fileName == '目录') {
|
||||
state.parentPid = '0';
|
||||
state.breadcrumbList = [{ id: 0, fileName: '目录' }]; //菜单列表
|
||||
// 最初目录
|
||||
getdocumentCompletionTreeStructure();
|
||||
} else {
|
||||
let arr = [];
|
||||
let array = state.breadcrumbList;
|
||||
for (let index = 0; index < array.length; index++) {
|
||||
arr.push(array[index]);
|
||||
if (array[index].fileName == item.fileName) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
state.breadcrumbList = arr;
|
||||
// 通过 当前点击的文件进行获取数据
|
||||
// 重复点击不用再次获取
|
||||
if (item.id == state.parentPid) return;
|
||||
state.parentPid = item.id;
|
||||
getdocumentCompletionTreeStructure();
|
||||
}
|
||||
};
|
||||
// 批量操作数据
|
||||
const onBatchAll = () => {
|
||||
state.toolStart = !state.toolStart;
|
||||
};
|
||||
const setDel = (ids) => {
|
||||
let msg = '你确定要删除所选数据?';
|
||||
if (ids.length === 0) {
|
||||
ElMessage.error('请选择要删除的数据。');
|
||||
return;
|
||||
}
|
||||
ElMessageBox.confirm(msg, '温馨提示', {
|
||||
confirmButtonText: '确认',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
})
|
||||
.then(() => {
|
||||
console.log(ids);
|
||||
|
||||
documentCompletionDelete(ids).then((res) => {
|
||||
if (res.code == 200) {
|
||||
let box = document.getElementById('right_box');
|
||||
box.style.display = 'none'; //显示div盒子
|
||||
ElMessage.success('删除成功');
|
||||
getdocumentCompletionTreeStructure();
|
||||
} else {
|
||||
ElMessage.error(res.msg);
|
||||
}
|
||||
});
|
||||
})
|
||||
.catch(() => {});
|
||||
};
|
||||
// 批量删除
|
||||
const onDeleteAll = () => {
|
||||
//获取所有已经选中的数据
|
||||
let selectList = [];
|
||||
if (state.fileList.length) {
|
||||
state.fileList.map((item) => {
|
||||
if (item.checkbox) {
|
||||
selectList.push(item.id);
|
||||
}
|
||||
});
|
||||
if (!selectList.length) {
|
||||
ElMessage.warning('请选择需要删除的文件');
|
||||
return;
|
||||
}
|
||||
setDel(selectList);
|
||||
}
|
||||
};
|
||||
// 批量选择
|
||||
const onToolAll = (row) => {
|
||||
row.checkbox = !row.checkbox;
|
||||
};
|
||||
const onContextmenu = (event, item, i) => {
|
||||
state.typeFile = item.fileType;
|
||||
state.relativePath = item.filenPath;
|
||||
state.delId = item.id;
|
||||
let len = (100 / 12) * (i % 12) + 4 + '%';
|
||||
let box = document.getElementById('right_box');
|
||||
box.style.top = event.clientY - 250 + 'px'; //鼠标点击时给div定位Y轴
|
||||
box.style.left = len; //鼠标点击时给div定位X轴
|
||||
box.style.display = 'block'; //显示div盒子
|
||||
};
|
||||
return {
|
||||
proxy,
|
||||
handleFile,
|
||||
onFileName,
|
||||
onNav,
|
||||
handleClick,
|
||||
RecyclingStationRef,
|
||||
onBreadcrumb,
|
||||
onBatchAll,
|
||||
onDeleteAll,
|
||||
onExport,
|
||||
onDeleteFile,
|
||||
onToolAll,
|
||||
onContextmenu,
|
||||
...toRefs(state)
|
||||
};
|
||||
}
|
||||
});
|
||||
</script>
|
||||
<style lang="scss">
|
||||
.documentCompletion-data {
|
||||
.el-card__body {
|
||||
padding: 10px !important;
|
||||
}
|
||||
|
||||
.breadcrumb-img {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
padding-right: 10px;
|
||||
.tool-All {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
> div {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
}
|
||||
.batch {
|
||||
width: 24px;
|
||||
}
|
||||
}
|
||||
.file_detail {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
height: 66vh;
|
||||
overflow: auto;
|
||||
.right_box {
|
||||
position: absolute;
|
||||
z-index: 999;
|
||||
background-color: rgb(0 0 0 / 56%);
|
||||
width: 120px;
|
||||
height: 100px;
|
||||
top: 0;
|
||||
left: 0;
|
||||
display: none;
|
||||
border-radius: 6px;
|
||||
padding: 14px 4px;
|
||||
> div {
|
||||
font-size: 16px;
|
||||
font-weight: bold;
|
||||
color: #fff;
|
||||
padding: 8px 20px;
|
||||
cursor: pointer;
|
||||
font-family: revert;
|
||||
border-radius: 5px;
|
||||
}
|
||||
> div:hover {
|
||||
background-color: rgb(0 0 0 / 80%);
|
||||
}
|
||||
}
|
||||
.file_style {
|
||||
// height: 100px;
|
||||
width: 90px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
padding: 10px;
|
||||
box-sizing: border-box;
|
||||
animation: 0.5s ease;
|
||||
position: relative;
|
||||
margin-bottom: 10px;
|
||||
> div {
|
||||
width: 100%;
|
||||
// height: 70%;
|
||||
height: 80px;
|
||||
> img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
}
|
||||
.checkbox-box {
|
||||
position: absolute;
|
||||
top: -8px;
|
||||
left: 60px;
|
||||
z-index: 1000;
|
||||
}
|
||||
> span {
|
||||
font-size: 12px;
|
||||
width: 100%;
|
||||
display: block;
|
||||
text-align: center;
|
||||
// display: flex;
|
||||
// align-items: center;
|
||||
// justify-content: center;
|
||||
word-wrap: break-word;
|
||||
}
|
||||
}
|
||||
.file_style:hover {
|
||||
background-color: rgba(189, 189, 189, 0.322);
|
||||
border-radius: 5px;
|
||||
}
|
||||
.fileActive {
|
||||
display: block;
|
||||
top: 0;
|
||||
position: absolute;
|
||||
z-index: 999;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100% !important;
|
||||
border-radius: 5px;
|
||||
background-color: rgba(189, 189, 189, 0.322);
|
||||
}
|
||||
}
|
||||
}
|
||||
.colBlock {
|
||||
display: block;
|
||||
}
|
||||
.colNone {
|
||||
display: none;
|
||||
}
|
||||
</style>
|
||||
137
src/views/safety/knowledgeDocument/component/bookFile.vue
Normal file
137
src/views/safety/knowledgeDocument/component/bookFile.vue
Normal file
@ -0,0 +1,137 @@
|
||||
<template>
|
||||
<div class="book_file">
|
||||
<!-- 添加或修改公司对话框 -->
|
||||
<el-dialog v-model="isShowDialog" width="80vw" custom-class="book_file_loading" :close-on-click-modal="false" :destroy-on-close="true">
|
||||
<template #header>
|
||||
<div>查看资料文件</div>
|
||||
</template>
|
||||
<el-form ref="queryRef" :inline="true" label-width="100px">
|
||||
<el-row>
|
||||
<el-col :span="8" class="colBlock">
|
||||
<el-form-item label="文件名称" prop="fileName">
|
||||
<el-input v-model="formData.fileName" placeholder="请输入文件名称搜索" clearable @keyup.enter.native="getDataFileQuery" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="getDataFileQuery">
|
||||
<el-icon><Search /></el-icon>搜索
|
||||
</el-button>
|
||||
<el-button @click="resetQuery" type="danger">
|
||||
<el-icon><Refresh /></el-icon>清空
|
||||
</el-button>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-form>
|
||||
<div class="content">
|
||||
<div class="left_box" :style="treeList.length ? 'width: 70%' : 'width: 100%'">
|
||||
<el-table v-loading="loading" :data="tableData" border height="63vh" :empty-text="emptyText">
|
||||
<el-table-column label="序号" align="center" type="index" width="80px" />
|
||||
<el-table-column label="文件名称" align="center" prop="fileName" min-width="100px" />
|
||||
<el-table-column label="文件类型" align="center" prop="fileSuffix" width="100px" />
|
||||
|
||||
<el-table-column label="文件路径" align="center" min-width="100px">
|
||||
<template #default="scope">
|
||||
<span>{{ filterfilenPath(scope.row.filePath) }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" align="center" class-name="small-padding" width="250px" fixed="right">
|
||||
<template #default="scope">
|
||||
<el-button type="success" link @click="onExport(scope.row)">
|
||||
<el-icon><Download /></el-icon>下载
|
||||
</el-button>
|
||||
<el-button type="primary" link @click="onBook(scope.row)">
|
||||
<el-icon><View /></el-icon>查看
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<pagination :total="total" v-model:page="formData.pageNum" v-model:limit="formData.pageSize" @pagination="getDataFileQuery" />
|
||||
</div>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { listKnowledgeDocument } from '@/api/safety/knowledgeDocument';
|
||||
import { useUserStoreHook } from '@/store/modules/user';
|
||||
|
||||
const emit = defineEmits(['onExport', 'onExportView', 'onBook']);
|
||||
const stores = useUserStoreHook();
|
||||
const loading = ref(false);
|
||||
const tableData = ref<any[]>([]);
|
||||
const isShowDialog = ref(false);
|
||||
const formData = reactive({
|
||||
fileName: '',
|
||||
projectId: stores.selectedProject.id,
|
||||
pageNum: 1,
|
||||
pageSize: 10
|
||||
});
|
||||
const total = ref(0);
|
||||
const emptyText = ref('暂无数据');
|
||||
const treeList = ref<any[]>([]);
|
||||
|
||||
const openDialog = () => {
|
||||
isShowDialog.value = true;
|
||||
getDataFileQuery();
|
||||
emptyText.value = '请输入文件名称进行搜索!';
|
||||
resetForm();
|
||||
};
|
||||
|
||||
const resetForm = () => {
|
||||
tableData.value = [];
|
||||
formData.fileName = '';
|
||||
treeList.value = [];
|
||||
emptyText.value = '暂无数据';
|
||||
};
|
||||
|
||||
const getDataFileQuery = () => {
|
||||
loading.value = true;
|
||||
emptyText.value = '数据加载中……';
|
||||
listKnowledgeDocument(formData).then((res: any) => {
|
||||
loading.value = false;
|
||||
tableData.value = [];
|
||||
if (res.code == 200 && res.rows?.length) {
|
||||
tableData.value = res.rows;
|
||||
total.value = res.total;
|
||||
} else {
|
||||
emptyText.value = '没有查询到数据,请重新输入搜索';
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const onBook = (row: any) => {
|
||||
emit('onBook', row);
|
||||
};
|
||||
|
||||
const onExport = (row: any) => {
|
||||
emit('onExportView', row);
|
||||
};
|
||||
|
||||
const resetQuery = () => {
|
||||
tableData.value = [];
|
||||
formData.fileName = '';
|
||||
loading.value = false;
|
||||
emptyText.value = '暂无数据';
|
||||
};
|
||||
|
||||
const filterfilenPath = (val: string): string => {
|
||||
return val.replace(/^.*?知识库\//, '知识库/');
|
||||
};
|
||||
|
||||
defineExpose({ openDialog });
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.book_file {
|
||||
.content {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: space-between;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
189
src/views/safety/knowledgeDocument/component/documentsDeails.vue
Normal file
189
src/views/safety/knowledgeDocument/component/documentsDeails.vue
Normal file
@ -0,0 +1,189 @@
|
||||
<template>
|
||||
<div class="document_detail" id="document_detail">
|
||||
<div class="move_pop" id="detial_pop">
|
||||
<!-- <span>{{ title }}</span> -->
|
||||
<div class="box">
|
||||
<img v-if="type == 2" src="../icon/suo.png" @click="onFull(1)" />
|
||||
<img v-else src="../icon/full.png" @click="onFull(2)" />
|
||||
<span class="close" @click="onClose">✖</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="box_app" id="box_app"></div>
|
||||
</div>
|
||||
</template>
|
||||
<script lang="ts">
|
||||
import { setMove } from '@/utils/moveDiv';
|
||||
declare const CXO_API: any;
|
||||
|
||||
export default defineComponent({
|
||||
name: 'index',
|
||||
setup(props, { emit }) {
|
||||
const { proxy } = <any>getCurrentInstance();
|
||||
const state = reactive({
|
||||
title: '',
|
||||
type: 2
|
||||
});
|
||||
onMounted(() => {
|
||||
setMove('detial_pop', 'document_detail');
|
||||
});
|
||||
// 打开弹窗
|
||||
const openDialog = (obj) => {
|
||||
state.title = obj.fileName;
|
||||
init(obj);
|
||||
};
|
||||
const onError = function (event) {
|
||||
//举例,强制保存后,判断文档内容是否保存成功
|
||||
if (event.data) {
|
||||
if (event.data.errorCode == 'forcesave') {
|
||||
var desc = event.data.errorDescription;
|
||||
desc = JSON.parse(desc);
|
||||
if (desc.error == 0) {
|
||||
//保存成功
|
||||
} else {
|
||||
//保存失败或异常
|
||||
}
|
||||
} else if (event.data.errorCode == 'setallcellvalue') {
|
||||
var desc = event.data.errorDescription;
|
||||
desc = JSON.parse(desc);
|
||||
if (desc.error == 0) {
|
||||
//填充成功
|
||||
} else if (desc.error == -1) {
|
||||
//当前文档正处于协同编辑中
|
||||
} else {
|
||||
//填充异常
|
||||
}
|
||||
} else if (event.data.errorCode == 'clearsheet') {
|
||||
var desc = event.data.errorDescription;
|
||||
desc = JSON.parse(desc);
|
||||
if (desc.error == 0) {
|
||||
//清除成功
|
||||
} else if (desc.error == -1) {
|
||||
//当前文档正处于协同编辑中
|
||||
} else {
|
||||
//清除异常
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
const onDocumentReady = function () {
|
||||
// console.log('文档加载完成');
|
||||
};
|
||||
const init = (obj) => {
|
||||
let documentKey = obj.id.toString() + new Date().getTime();
|
||||
let type = obj.fileSuffix;
|
||||
if (obj.fileSuffix.includes('.')) {
|
||||
type = obj.fileSuffix.substring(1);
|
||||
}
|
||||
let documentType = 'word'; // docx doc
|
||||
if (type == 'xlsx' || type == 'xls') {
|
||||
documentType = 'cell'; //电子表格
|
||||
} else if (type == 'ppt' || type == 'pptx') {
|
||||
documentType = 'slide'; //演示文档文件
|
||||
}
|
||||
new CXO_API.CXEditor('box_app', {
|
||||
document: {
|
||||
fileType: type,
|
||||
key: documentKey,
|
||||
title: obj.fileName,
|
||||
url: obj.fileUrl
|
||||
},
|
||||
documentType,
|
||||
editorConfig: {
|
||||
mode: 'view',
|
||||
callbackUrl: ''
|
||||
},
|
||||
height: '100%',
|
||||
events: {
|
||||
onDocumentReady: onDocumentReady,
|
||||
onError: onError
|
||||
},
|
||||
zoom: -1
|
||||
});
|
||||
};
|
||||
const onClose = () => {
|
||||
emit('onClose', false);
|
||||
};
|
||||
const onFull = (type) => {
|
||||
// 全屏
|
||||
let document_detail = document.getElementById('document_detail');
|
||||
state.type = type;
|
||||
if (type == 2) {
|
||||
document_detail.style.width = '100%';
|
||||
document_detail.style.height = '100%';
|
||||
} else {
|
||||
document_detail.style.width = '1200px';
|
||||
document_detail.style.height = '80vh';
|
||||
}
|
||||
};
|
||||
return {
|
||||
proxy,
|
||||
openDialog,
|
||||
onClose,
|
||||
onFull,
|
||||
...toRefs(state)
|
||||
};
|
||||
}
|
||||
});
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
.document_detail {
|
||||
position: fixed;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
z-index: 999999;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
border: 1px solid #9f9f9f;
|
||||
.box_app {
|
||||
// width: 1300px !important;
|
||||
// height: 80vh !important;
|
||||
background-color: #f1f1f1;
|
||||
}
|
||||
.move_pop {
|
||||
width: 100%;
|
||||
// position: absolute;
|
||||
// top: 0;
|
||||
// right: 0%;
|
||||
height: 24px;
|
||||
// background: linear-gradient(#2a5095, #213f7b, #111e48);
|
||||
background-color: #f4f5f6;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
> span {
|
||||
color: #000000;
|
||||
font-weight: bold;
|
||||
font-size: 20px;
|
||||
letter-spacing: 2px;
|
||||
}
|
||||
.box {
|
||||
display: flex;
|
||||
width: 60px;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
right: 10px;
|
||||
// height: 100%;
|
||||
align-items: center;
|
||||
img {
|
||||
width: 22px;
|
||||
margin-top: 6px;
|
||||
cursor: pointer;
|
||||
}
|
||||
.close {
|
||||
position: absolute;
|
||||
right: 2px;
|
||||
/* top: -8px; */
|
||||
color: #8d8d8d;
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
font-size: 20px;
|
||||
//border: 2px solid #0ff;
|
||||
border-radius: 50%;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
203
src/views/safety/knowledgeDocument/component/documentsEdit.vue
Normal file
203
src/views/safety/knowledgeDocument/component/documentsEdit.vue
Normal file
@ -0,0 +1,203 @@
|
||||
<template>
|
||||
<div class="document_detail_eidt" id="document_detail_eidt">
|
||||
<div class="move_pop" id="detial_edit">
|
||||
<!-- <span>{{ title }}</span> -->
|
||||
<div class="box">
|
||||
<img v-if="type == 2" src="../icon/full.png" @click="onFull(1)" />
|
||||
<img v-else src="../icon/suo.png" @click="onFull(2)" />
|
||||
<span class="close" @click="onClose">✖</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="box_app" id="box_app_edit"></div>
|
||||
</div>
|
||||
</template>
|
||||
<script lang="ts">
|
||||
import { toRefs, reactive, onMounted, ref, defineComponent, watch, getCurrentInstance } from 'vue';
|
||||
import { setMove } from '@/utils/moveDiv';
|
||||
import { useUserStoreHook } from '@/store/modules/user';
|
||||
|
||||
// Ensure CXO_API is available globally or import it if it's a module
|
||||
// Example for global usage (e.g., included via script tag in index.html):
|
||||
declare const CXO_API: any;
|
||||
|
||||
export default defineComponent({
|
||||
name: 'index',
|
||||
setup(props, { emit }) {
|
||||
const stores = useUserStoreHook();
|
||||
const { proxy } = <any>getCurrentInstance();
|
||||
const state = reactive({
|
||||
title: '',
|
||||
projectId: stores.selectedProject.id,
|
||||
type: 2,
|
||||
postUrl: ''
|
||||
});
|
||||
onMounted(() => {
|
||||
setMove('detial_edit', 'document_detail_eidt');
|
||||
});
|
||||
// 打开弹窗
|
||||
const openDialog = (obj, url) => {
|
||||
state.postUrl = url;
|
||||
|
||||
state.title = obj.name;
|
||||
init(obj);
|
||||
};
|
||||
const onError = function (event) {
|
||||
console.log('编辑器错误: code ' + event.data.errorCode + ', 描述' + event.data.errorDescription);
|
||||
//举例,强制保存后,判断文档内容是否保存成功
|
||||
if (event.data) {
|
||||
if (event.data.errorCode == 'forcesave') {
|
||||
var desc = event.data.errorDescription;
|
||||
desc = JSON.parse(desc);
|
||||
if (desc.error == 0) {
|
||||
//保存成功
|
||||
} else {
|
||||
//保存失败或异常
|
||||
}
|
||||
} else if (event.data.errorCode == 'setallcellvalue') {
|
||||
var desc = event.data.errorDescription;
|
||||
desc = JSON.parse(desc);
|
||||
if (desc.error == 0) {
|
||||
//填充成功
|
||||
} else if (desc.error == -1) {
|
||||
//当前文档正处于协同编辑中
|
||||
} else {
|
||||
//填充异常
|
||||
}
|
||||
} else if (event.data.errorCode == 'clearsheet') {
|
||||
var desc = event.data.errorDescription;
|
||||
desc = JSON.parse(desc);
|
||||
if (desc.error == 0) {
|
||||
//清除成功
|
||||
} else if (desc.error == -1) {
|
||||
//当前文档正处于协同编辑中
|
||||
} else {
|
||||
//清除异常
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
const onDocumentReady = function () {
|
||||
console.log('文档加载完成');
|
||||
};
|
||||
const init = (obj) => {
|
||||
let documentKey = obj.id.toString() + new Date().getTime();
|
||||
let baseURL = import.meta.env.VITE_APP_BASE_API;
|
||||
let type = obj.fileSuffix;
|
||||
if (obj.fileSuffix.includes('.')) {
|
||||
type = obj.fileSuffix.substring(1);
|
||||
}
|
||||
let documentType = 'word'; // docx doc
|
||||
if (type == 'xlsx' || type == 'xls') {
|
||||
documentType = 'cell'; //电子表格
|
||||
} else if (type == 'ppt' || type == 'pptx') {
|
||||
documentType = 'slide'; //演示文档文件
|
||||
}
|
||||
console.log(baseURL + state.postUrl + '?path=' + obj.filePath + '&id=' + obj.id);
|
||||
new CXO_API.CXEditor('box_app_edit', {
|
||||
document: {
|
||||
fileType: obj.fileSuffix,
|
||||
key: documentKey,
|
||||
title: obj.fileName,
|
||||
url: obj.fileUrl
|
||||
},
|
||||
documentType,
|
||||
token: stores.token,
|
||||
editorConfig: {
|
||||
callbackUrl: baseURL + state.postUrl + obj.id + '?path=' + obj.filePath
|
||||
},
|
||||
events: {
|
||||
onDocumentReady: onDocumentReady,
|
||||
onError: onError
|
||||
}
|
||||
});
|
||||
};
|
||||
const onClose = () => {
|
||||
emit('onClose', false);
|
||||
};
|
||||
const onFull = (type) => {
|
||||
// 全屏
|
||||
let document_detail = document.getElementById('document_detail_eidt');
|
||||
state.type = type;
|
||||
if (type == 2) {
|
||||
// 弹框放大
|
||||
document_detail.style.width = '100%';
|
||||
document_detail.style.height = '100%';
|
||||
} else {
|
||||
// 弹框缩小
|
||||
document_detail.style.width = '1200px';
|
||||
document_detail.style.height = '80vh';
|
||||
}
|
||||
};
|
||||
return {
|
||||
proxy,
|
||||
onFull,
|
||||
openDialog,
|
||||
onClose,
|
||||
...toRefs(state)
|
||||
};
|
||||
}
|
||||
});
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
.document_detail_eidt {
|
||||
position: fixed;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
z-index: 999999;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
border: 1px solid #9f9f9f;
|
||||
.box_app {
|
||||
width: 1200px !important;
|
||||
height: 80vh !important;
|
||||
background-color: #f1f1f1;
|
||||
margin-top: 100px;
|
||||
}
|
||||
.move_pop {
|
||||
width: 100%;
|
||||
// position: absolute;
|
||||
// top: 0;
|
||||
// right: 0%;
|
||||
height: 24px;
|
||||
// background: linear-gradient(#2a5095, #213f7b, #111e48);
|
||||
background-color: #f4f5f6;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
> span {
|
||||
color: #000000;
|
||||
font-weight: bold;
|
||||
font-size: 20px;
|
||||
letter-spacing: 2px;
|
||||
}
|
||||
.box {
|
||||
display: flex;
|
||||
width: 60px;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
right: 10px;
|
||||
// height: 100%;
|
||||
align-items: center;
|
||||
img {
|
||||
width: 22px;
|
||||
margin-top: 6px;
|
||||
cursor: pointer;
|
||||
}
|
||||
.close {
|
||||
position: absolute;
|
||||
right: 2px;
|
||||
/* top: -8px; */
|
||||
color: #8d8d8d;
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
font-size: 20px;
|
||||
//border: 2px solid #0ff;
|
||||
border-radius: 50%;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@ -0,0 +1,148 @@
|
||||
<template>
|
||||
<div class="system-document-container">
|
||||
<el-card shadow="hover">
|
||||
<div class="system-document-search mb-5">
|
||||
<el-form :model="param" ref="queryRef" :inline="true" label-width="100px">
|
||||
<el-row>
|
||||
<el-col :span="2">
|
||||
<el-button type="success" :disabled="multiple" @click="onRecyclingStation(null, true)">
|
||||
<el-icon><RefreshRight /></el-icon>批量恢复
|
||||
</el-button>
|
||||
</el-col>
|
||||
<el-col :span="2">
|
||||
<el-button type="danger" :disabled="multiple" @click="onRecyclingStation(null, false)">
|
||||
<el-icon><DeleteFilled /></el-icon>批量删除
|
||||
</el-button>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-form>
|
||||
</div>
|
||||
<el-table v-loading="loading" :data="tableData" @selection-change="handleSelectionChange">
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column label="序号" align="center" type="index" min-width="30px" />
|
||||
<el-table-column label="文件名称" align="center" prop="fileName" min-width="100px" />
|
||||
<el-table-column label="文件路径" align="center" min-width="100px">
|
||||
<template #default="scope">
|
||||
<span>{{ filterfilenPath(scope.row.filePath) }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="删除时间" align="center" prop="createTime" min-width="100px" />
|
||||
<el-table-column label="操作" align="center" class-name="small-padding" min-width="80px" fixed="right">
|
||||
<template #default="scope">
|
||||
<div>
|
||||
<el-button type="success" link @click="onRecyclingStation(scope.row, true)">
|
||||
<el-icon><RefreshRight /></el-icon>恢复
|
||||
</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<pagination v-show="total > 0" :total="total" v-model:page="param.pageNum" v-model:limit="param.pageSize" @pagination="getDocumentDataList" />
|
||||
</el-card>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { documentDataAllList, templateRecycleBin, dataRecyclingStation } from '@/api/safety/knowledgeDocument';
|
||||
import { useUserStoreHook } from '@/store/modules/user';
|
||||
const userStore = useUserStoreHook();
|
||||
const currentProject = computed(() => userStore.selectedProject);
|
||||
|
||||
const loading = ref(false);
|
||||
const queryRef = ref();
|
||||
const multiple = ref(true);
|
||||
|
||||
const ids = ref<string>('');
|
||||
const tableData = ref<any[]>([]);
|
||||
const param = reactive({
|
||||
type: 2,
|
||||
projectId: currentProject.value?.id,
|
||||
pageNum: 1,
|
||||
pageSize: 10
|
||||
});
|
||||
const total = ref(0);
|
||||
const value = ref('2');
|
||||
|
||||
const getDocumentDataList = () => {
|
||||
loading.value = true;
|
||||
tableData.value = [];
|
||||
value.value = '2';
|
||||
param.projectId = currentProject.value?.id;
|
||||
documentDataAllList(param).then((res: any) => {
|
||||
tableData.value = res.rows ?? [];
|
||||
total.value = res.total;
|
||||
loading.value = false;
|
||||
});
|
||||
};
|
||||
|
||||
const handleSelectionChange = (selection: any[]) => {
|
||||
ids.value = selection.map((item) => item.id).join(',');
|
||||
multiple.value = !selection.length;
|
||||
};
|
||||
|
||||
const onRecyclingStation = (row: any, flag: boolean) => {
|
||||
let type = 2;
|
||||
let selectedIds: string = '';
|
||||
let title = '删除';
|
||||
let msg = '你确定要删除所选文件或文件夹?';
|
||||
|
||||
if (row) {
|
||||
selectedIds = row.id;
|
||||
} else {
|
||||
selectedIds = ids.value;
|
||||
}
|
||||
|
||||
if (flag) {
|
||||
type = 1;
|
||||
title = '恢复';
|
||||
msg = '你确定要恢复所选文件或文件夹?';
|
||||
}
|
||||
ElMessageBox.confirm(msg, '提示', {
|
||||
confirmButtonText: '确认',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
})
|
||||
.then(() => {
|
||||
const loadingInstance = ElLoading.service({
|
||||
lock: true,
|
||||
text: `正在${title}中……`,
|
||||
background: 'rgba(0, 0, 0, 0.7)'
|
||||
});
|
||||
if (flag) {
|
||||
dataRecyclingStation(selectedIds).then((res) => {
|
||||
loadingInstance.close();
|
||||
if (res.code == 200) {
|
||||
getDocumentDataList();
|
||||
ElMessage.success('操作成功');
|
||||
}
|
||||
});
|
||||
} else {
|
||||
templateRecycleBin(selectedIds).then((res) => {
|
||||
loadingInstance.close();
|
||||
if (res.code == 200) {
|
||||
getDocumentDataList();
|
||||
ElMessage.success('操作成功');
|
||||
}
|
||||
});
|
||||
}
|
||||
})
|
||||
.catch(() => {});
|
||||
};
|
||||
|
||||
const filterfilenPath = (val: string): string => {
|
||||
return val.replace(/^.*?知识库\//, '知识库/');
|
||||
};
|
||||
|
||||
defineExpose({
|
||||
getDocumentDataList
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.colBlock {
|
||||
display: block;
|
||||
}
|
||||
.colNone {
|
||||
display: none;
|
||||
}
|
||||
</style>
|
||||
BIN
src/views/safety/knowledgeDocument/icon/full.png
Normal file
BIN
src/views/safety/knowledgeDocument/icon/full.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.8 KiB |
BIN
src/views/safety/knowledgeDocument/icon/suo.png
Normal file
BIN
src/views/safety/knowledgeDocument/icon/suo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.4 KiB |
580
src/views/safety/knowledgeDocument/index.vue
Normal file
580
src/views/safety/knowledgeDocument/index.vue
Normal file
@ -0,0 +1,580 @@
|
||||
<template>
|
||||
<el-tabs v-model="activeName" class="demo-tabs p5" @tab-click="handleCheckMian">
|
||||
<el-tab-pane label="资料" name="first">
|
||||
<div class="profile_engin">
|
||||
<div class="box_info">
|
||||
<div class="tree_left1" id="tree_left1">
|
||||
<div class="file_upload check_select">
|
||||
<div class="box_btn">
|
||||
<file-upload
|
||||
v-model="state.paramsQuery.file"
|
||||
:limit="100"
|
||||
:uploadUrl="uploadUrl"
|
||||
:params="uploadParams"
|
||||
:on-upload-success="uploadFile"
|
||||
:fileType="[]"
|
||||
>
|
||||
<el-button type="primary" style="float: left" :disabled="!state.parentPid">
|
||||
<el-icon size="small"><Plus /></el-icon>上传文件
|
||||
</el-button>
|
||||
</file-upload>
|
||||
</div>
|
||||
<el-button type="primary" :disabled="!state.parentPid" @click="onExport"
|
||||
><el-icon><Download /></el-icon>下载</el-button
|
||||
>
|
||||
<el-button type="primary" @click="onBook"
|
||||
><el-icon><View /></el-icon>查看全项目文件</el-button
|
||||
>
|
||||
</div>
|
||||
<div class="file_upload check_select">
|
||||
<el-input class="input_left" v-model="filterText" size="small" placeholder="请输入文件名称" />
|
||||
</div>
|
||||
<el-tree
|
||||
ref="treeRef"
|
||||
highlight-current
|
||||
:default-expand-all="state.checked"
|
||||
:filter-node-method="filterFolder"
|
||||
:data="state.treeList"
|
||||
node-key="id"
|
||||
accordion
|
||||
:expand-on-click-node="false"
|
||||
@node-click="handleNodeClick"
|
||||
:current-node-key="state.selectedNodeId"
|
||||
>
|
||||
<template #default="{ node, data }">
|
||||
<span class="custom-tree-node">
|
||||
<el-icon color="#f1a81a"><FolderOpened /></el-icon>
|
||||
<span>{{ node.label }}</span>
|
||||
</span>
|
||||
</template>
|
||||
</el-tree>
|
||||
<div class="resize-handle resize-handle-right right"></div>
|
||||
</div>
|
||||
<div class="list_right" id="list_right1">
|
||||
<div>
|
||||
<el-form :model="state.paramsQuery" ref="queryRef" :inline="true" label-width="100px">
|
||||
<el-row>
|
||||
<el-col :span="7" class="colBlock">
|
||||
<el-form-item label="文件名称" prop="fileName">
|
||||
<el-input
|
||||
v-model="state.paramsQuery.fileName"
|
||||
placeholder="请输入文件名称"
|
||||
clearable
|
||||
@keyup.enter.native="getdocumentDataList"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="6" class="m-l10">
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="searchInfo"
|
||||
><el-icon><Search /></el-icon>搜索</el-button
|
||||
>
|
||||
<el-button @click="resetQuery"
|
||||
><el-icon><Refresh /></el-icon>重置</el-button
|
||||
>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-form>
|
||||
</div>
|
||||
<el-table v-loading="state.loading" :data="state.infoList" height="67vh" border>
|
||||
<el-table-column label="序号" align="center" type="index" min-width="50px" />
|
||||
<el-table-column label="文件名称" align="center" prop="fileName"></el-table-column>
|
||||
<el-table-column label="文件类型" align="center" prop="fileSuffix" width="100px" />
|
||||
|
||||
<el-table-column label="上传时间" align="center" prop="createTime"> </el-table-column>
|
||||
<el-table-column label="操作" align="center" width="300">
|
||||
<template #default="scope">
|
||||
<el-button type="primary" link @click="handleView(scope.row)" v-if="acceptType.includes(scope.row.fileSuffix)"
|
||||
><el-icon><View /></el-icon>查看</el-button
|
||||
>
|
||||
<el-button type="primary" v-if="state.wordType.includes(scope.row.fileSuffix)" link @click="updataView(scope.row)"
|
||||
><el-icon><EditPen /></el-icon>修改文件</el-button
|
||||
>
|
||||
<el-button type="primary" link
|
||||
><el-icon><Download /></el-icon>下载</el-button
|
||||
>
|
||||
<el-button type="success" link @click="updateName(scope.row)"
|
||||
><el-icon><EditPen /></el-icon>修改名称</el-button
|
||||
>
|
||||
<el-button type="danger" link @click="handleDelete(scope.row)"
|
||||
><el-icon><DeleteFilled /></el-icon>删除</el-button
|
||||
>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<pagination
|
||||
:total="state.total"
|
||||
v-model:page="state.paramsQuery.pageNum"
|
||||
v-model:limit="state.paramsQuery.pageSize"
|
||||
@pagination="getdocumentDataList"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<documentsDeailsVue ref="documentDetailRef" v-if="state.showDocumentDetail" @onClose="onClose"></documentsDeailsVue>
|
||||
<documentsEdit ref="documentDataEditRef" v-if="state.showdocumentDataEdit" @onClose="onCloseEdit"></documentsEdit>
|
||||
<bookFile ref="bookFileRef" @onExportView="onExportView" @onBook="handleView" @onExport="onExport"></bookFile>
|
||||
<el-dialog title="上传文件" v-model="uploadFileder" width="30%">
|
||||
<file-upload v-model="state.paramsQuery.file"></file-upload>
|
||||
<template #footer>
|
||||
<span>
|
||||
<el-button @click="uploadFileder = false">取消</el-button>
|
||||
<el-button type="primary" @click="subMitUpload">确定</el-button>
|
||||
</span>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
<el-image-viewer
|
||||
ref="imageRef"
|
||||
style="width: 100%; height: 100%"
|
||||
:url-list="[imgUrl]"
|
||||
v-if="imgUrl"
|
||||
show-progress
|
||||
fit="cover"
|
||||
@close="imgUrl = ''"
|
||||
/>
|
||||
</el-tab-pane>
|
||||
<el-tab-pane label="回收站" name="second">
|
||||
<RecyclingStation ref="recylingRef"></RecyclingStation>
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
</template>
|
||||
|
||||
<script setup name="KnowledgeDocument" lang="ts">
|
||||
import {
|
||||
listKnowledgeDocument,
|
||||
delKnowledgeDocument,
|
||||
addKnowledgeDocument,
|
||||
getUniFolderDownloadList,
|
||||
treeStructureData,
|
||||
documentDataEdit
|
||||
} from '@/api/safety/knowledgeDocument';
|
||||
|
||||
import documentsEdit from './component/documentsEdit.vue';
|
||||
import documentsDeailsVue from './component/documentsDeails.vue';
|
||||
import RecyclingStation from './component/recyclingStation.vue';
|
||||
|
||||
import { useUserStoreHook } from '@/store/modules/user';
|
||||
import bookFile from './component/bookFile.vue';
|
||||
const activeName = ref('first');
|
||||
const { proxy } = getCurrentInstance() as any;
|
||||
// 获取用户 store
|
||||
const userStore = useUserStoreHook();
|
||||
// 从 store 中获取项目列表和当前选中的项目
|
||||
const currentProject = computed(() => userStore.selectedProject);
|
||||
const uploadUrl = computed(() => {
|
||||
return `/safety/knowledgeDocument/file`;
|
||||
});
|
||||
const uploadParams = computed(() => {
|
||||
return {
|
||||
pid: state.paramsQuery.folderId,
|
||||
projectId: state.projectId
|
||||
};
|
||||
});
|
||||
|
||||
const imgUrl = ref<string>('');
|
||||
const filterText = ref('');
|
||||
const treeRef = ref();
|
||||
const documentDetailRef = ref();
|
||||
const documentDataEditRef = ref();
|
||||
const uploadFileder = ref(false);
|
||||
const imageRef = ref();
|
||||
const recylingRef = ref();
|
||||
const bookFileRef = ref();
|
||||
const state = reactive({
|
||||
treeList: [] as any,
|
||||
arrayList: [] as any,
|
||||
infoMap: new Map(),
|
||||
infoList: [] as any,
|
||||
|
||||
total: 0,
|
||||
paramsQuery: {
|
||||
folderId: '',
|
||||
fileName: '',
|
||||
pageNum: 1,
|
||||
pageSize: 20,
|
||||
projectId: currentProject.value?.id,
|
||||
file: null,
|
||||
pid: null
|
||||
},
|
||||
loading: false,
|
||||
checked: true,
|
||||
options: [
|
||||
{ id: 1, label: '当前文件夹及以下' },
|
||||
{ id: 2, label: '当前文件夹' }
|
||||
],
|
||||
showDocumentDetail: false,
|
||||
showdocumentDataEdit: false,
|
||||
showUploadFileder: false,
|
||||
parentRow: null,
|
||||
parentPid: null,
|
||||
parentName: '',
|
||||
selectedNodeId: null,
|
||||
projectId: currentProject.value?.id || '',
|
||||
imgType: ['jpg', 'png', 'jpeg', 'gif', 'svg'],
|
||||
wordType: ['pdf', 'doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx'],
|
||||
browserViewableType: ['html', 'htm', 'txt', 'log', 'md', 'json', 'xml', 'css', 'js'],
|
||||
|
||||
draggableCheck: true
|
||||
});
|
||||
|
||||
const acceptType = computed(() => [...state.imgType, ...state.wordType, ...state.browserViewableType]);
|
||||
|
||||
watch(filterText, (val: any) => {
|
||||
treeRef.value!.filter(val);
|
||||
});
|
||||
|
||||
// 上传文件
|
||||
const uploadFile = (files: any[]) => {
|
||||
proxy.$modal.success('上传成功');
|
||||
state.paramsQuery.file = null;
|
||||
getdocumentDataList();
|
||||
// uploadFileder.value = true;
|
||||
};
|
||||
|
||||
// 提交上传文件
|
||||
const subMitUpload = () => {
|
||||
if (!state.paramsQuery.file) {
|
||||
ElMessage.warning('请选择文件!');
|
||||
return;
|
||||
}
|
||||
addKnowledgeDocument(state.paramsQuery, { projectId: state.projectId, pid: state.parentPid }).then((res: any) => {
|
||||
if (res.code == 200) {
|
||||
ElMessage.success('上传成功');
|
||||
uploadFileder.value = false;
|
||||
state.paramsQuery.file = null; //清空文件
|
||||
getdocumentDataList();
|
||||
} else {
|
||||
ElMessage.error(res.message);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const searchInfo = () => {
|
||||
// 搜索
|
||||
getdocumentDataList();
|
||||
};
|
||||
const resetQuery = () => {
|
||||
// 重置
|
||||
state.paramsQuery.fileName = '';
|
||||
getdocumentDataList();
|
||||
};
|
||||
// 获取树形结构文件夹目录
|
||||
const gettreeStructureData = () => {
|
||||
state.parentPid = null;
|
||||
const loading = ElLoading.service({
|
||||
lock: true,
|
||||
text: '正在加载中……',
|
||||
background: 'rgba(0, 0, 0, 0.7)',
|
||||
target: '.tree_left1'
|
||||
});
|
||||
treeStructureData(state.projectId).then((res: any) => {
|
||||
loading.close();
|
||||
if (res.code == 200) {
|
||||
state.selectedNodeId = res.data[0] ? res.data[0].children[0].id : '';
|
||||
state.treeList = res.data;
|
||||
state.paramsQuery.folderId = res.data[0] ? res.data[0].children[0].id : '';
|
||||
getdocumentDataList();
|
||||
// setInfo(res.data);
|
||||
}
|
||||
});
|
||||
};
|
||||
// 处理数据
|
||||
const setInfo = (arr) => {
|
||||
arr.forEach((element) => {
|
||||
state.arrayList.push(element);
|
||||
state.infoMap.set(element.folderId, element.id);
|
||||
if (element.treeStructureDataRes && element.treeStructureDataRes.length) {
|
||||
setInfo(element.treeStructureDataRes);
|
||||
}
|
||||
});
|
||||
};
|
||||
// 选择目录文件
|
||||
const handleNodeClick = (row) => {
|
||||
state.parentRow = row;
|
||||
state.parentPid = row.parentId;
|
||||
console.log('🚀 ~ handleNodeClick ~ state.parentPid:', state.parentPid);
|
||||
state.parentName = row.label;
|
||||
state.paramsQuery.folderId = row.id;
|
||||
getdocumentDataList();
|
||||
if (row.id === state.selectedNodeId) {
|
||||
// 如果当前节点已经选中,则取消选中
|
||||
state.selectedNodeId = null;
|
||||
state.parentPid = null; //关闭父级选择的id
|
||||
state.parentRow = null; //获取父级对象
|
||||
state.parentName = ''; //获取父级对应的名称
|
||||
state.paramsQuery.folderId = ''; //
|
||||
} else {
|
||||
// 否则选中当前节点 重新赋值
|
||||
state.selectedNodeId = row.id;
|
||||
}
|
||||
};
|
||||
// 获取文档列表数据
|
||||
const getdocumentDataList = () => {
|
||||
if (!state.paramsQuery.folderId) {
|
||||
state.infoList = [];
|
||||
state.total = 0;
|
||||
return;
|
||||
}
|
||||
state.loading = true;
|
||||
listKnowledgeDocument(state.paramsQuery).then((res: any) => {
|
||||
state.loading = false;
|
||||
if (res.code == 200) {
|
||||
state.infoList = res.rows;
|
||||
state.total = res.total;
|
||||
}
|
||||
});
|
||||
};
|
||||
// 查询tree树形结构数据
|
||||
const filterFolder = (value: string, data: any) => {
|
||||
if (!value) return true;
|
||||
return data.name.includes(value);
|
||||
};
|
||||
const handleDelete = (row) => {
|
||||
// 删除文档
|
||||
let msg = '你确定要删除所选文件?';
|
||||
delFile(msg, row, () => {
|
||||
getdocumentDataList();
|
||||
});
|
||||
};
|
||||
|
||||
//切换tab
|
||||
const handleCheckMian = (tab, event) => {
|
||||
activeName.value = tab.paneName;
|
||||
|
||||
if (activeName.value === 'first') {
|
||||
gettreeStructureData();
|
||||
} else {
|
||||
// 回收站
|
||||
recylingRef.value.getDocumentDataList();
|
||||
}
|
||||
};
|
||||
|
||||
const onExportView = (row) => {
|
||||
console.log(row);
|
||||
proxy.$download.direct(row.fileUrl, row.originalName);
|
||||
};
|
||||
const updateName = (row) => {
|
||||
// 修改名称
|
||||
editName(row, '请输入文件名称', 1);
|
||||
};
|
||||
const handleView = (row) => {
|
||||
if (state.imgType.includes(row.fileSuffix)) {
|
||||
imgUrl.value = row.fileUrl;
|
||||
return;
|
||||
} else if (state.wordType.includes(row.fileSuffix)) {
|
||||
state.showDocumentDetail = true;
|
||||
nextTick(() => {
|
||||
documentDetailRef.value.openDialog(row);
|
||||
});
|
||||
} else {
|
||||
window.open(row.fileUrl);
|
||||
}
|
||||
};
|
||||
// 关闭在线编辑弹框
|
||||
const onClose = () => {
|
||||
state.showDocumentDetail = false;
|
||||
};
|
||||
// 关闭修改的在线文档弹框
|
||||
const onCloseEdit = () => {
|
||||
state.showdocumentDataEdit = false;
|
||||
};
|
||||
const updataView = (row) => {
|
||||
// 修改文档
|
||||
state.showdocumentDataEdit = true;
|
||||
nextTick(() => {
|
||||
documentDataEditRef.value.openDialog(row, '/safety/knowledgeDocument/changxie/callback/');
|
||||
});
|
||||
};
|
||||
// 删除文件及文件夹
|
||||
const delFile = (msg, data, cb) => {
|
||||
ElMessageBox.confirm(msg, '提示', {
|
||||
confirmButtonText: '确认',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
})
|
||||
.then(() => {
|
||||
delKnowledgeDocument([data.id]).then((res: any) => {
|
||||
if (res.code == 200) {
|
||||
ElMessage.success('删除成功');
|
||||
cb();
|
||||
}
|
||||
});
|
||||
})
|
||||
.catch(() => {});
|
||||
};
|
||||
const editName = (data, title, type) => {
|
||||
ElMessageBox.prompt(title, '温馨提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
inputErrorMessage: title,
|
||||
inputValue: data.fileName
|
||||
})
|
||||
.then(({ value }) => {
|
||||
documentDataEdit({ id: data.id, fileName: value }).then((res: any) => {
|
||||
if (res.code == 200) {
|
||||
ElMessage({
|
||||
type: 'success',
|
||||
message: '修改成功'
|
||||
});
|
||||
// 数据重新刷新
|
||||
if (type == 2) {
|
||||
gettreeStructureData();
|
||||
} else {
|
||||
getdocumentDataList();
|
||||
}
|
||||
} else {
|
||||
ElMessage({
|
||||
type: 'error',
|
||||
message: res.message
|
||||
});
|
||||
}
|
||||
});
|
||||
})
|
||||
.catch(() => {});
|
||||
};
|
||||
const onExport = () => {
|
||||
getUniFolderDownloadList(state.paramsQuery.folderId).then((res: any) => {
|
||||
if (res.code == 200) {
|
||||
console.log(state.paramsQuery.fileName);
|
||||
proxy.$download.downloadFilesAsZip(res.data, { urlKey: 'fileUrl', nameKey: 'originalName', zipName: state.parentName + '.zip' });
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// 查看所有资料
|
||||
const onBook = () => {
|
||||
bookFileRef.value.openDialog();
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
gettreeStructureData();
|
||||
});
|
||||
|
||||
//监听项目id刷新数据
|
||||
const listeningProject = watch(
|
||||
() => currentProject.value?.id,
|
||||
(nid, oid) => {
|
||||
state.projectId = nid;
|
||||
state.paramsQuery.projectId = nid;
|
||||
if (activeName.value === 'first') {
|
||||
gettreeStructureData();
|
||||
} else {
|
||||
// 回收站
|
||||
recylingRef.value.getDocumentDataList();
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
onUnmounted(() => {
|
||||
listeningProject();
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.profile_engin {
|
||||
height: 80vh;
|
||||
.set-tool {
|
||||
display: none;
|
||||
}
|
||||
.el-tree-node__content:hover,
|
||||
.el-tree-node__content:active {
|
||||
.set-tool {
|
||||
display: inline-block;
|
||||
}
|
||||
}
|
||||
.el-tree--highlight-current .el-tree-node.is-current > .el-tree-node__content {
|
||||
background-color: #354e67 !important;
|
||||
color: #fff;
|
||||
}
|
||||
.box_info {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
}
|
||||
.pagination-container {
|
||||
padding: 10px 0 !important;
|
||||
}
|
||||
> div {
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
}
|
||||
.tree_left1 {
|
||||
width: 30%;
|
||||
background-color: #fff;
|
||||
border: 1px solid #dddddd;
|
||||
border-radius: 6px;
|
||||
padding: 6px 0px;
|
||||
position: relative;
|
||||
min-width: 26%;
|
||||
border-right: 6px solid;
|
||||
border-right-color: rgba(204, 230, 255, 0);
|
||||
.resize-handle-right {
|
||||
top: 0;
|
||||
width: 6px;
|
||||
height: 100%;
|
||||
right: -10px;
|
||||
cursor: ew-resize;
|
||||
position: absolute;
|
||||
z-index: 999;
|
||||
}
|
||||
.check_select {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
// justify-content: space-between;
|
||||
padding: 4px;
|
||||
border-bottom: 1px solid #f1f1f1;
|
||||
.box_btn {
|
||||
margin: 0 10px 0 20px;
|
||||
position: relative;
|
||||
> span {
|
||||
padding: 4px 10px;
|
||||
background: #67c23a;
|
||||
color: #fff;
|
||||
border-radius: 2px;
|
||||
}
|
||||
.btn {
|
||||
position: absolute;
|
||||
left: 20%;
|
||||
display: none;
|
||||
top: -2px;
|
||||
width: 220px;
|
||||
.el-button {
|
||||
float: left;
|
||||
}
|
||||
}
|
||||
}
|
||||
.box_btn:hover,
|
||||
.box_btn:active {
|
||||
cursor: pointer;
|
||||
.btn {
|
||||
display: block;
|
||||
}
|
||||
}
|
||||
}
|
||||
.file_upload {
|
||||
margin: 2px 0;
|
||||
}
|
||||
.input_left {
|
||||
padding: 6px;
|
||||
box-sizing: border-box;
|
||||
// border-bottom: 1px solid #cbcbcb;
|
||||
}
|
||||
}
|
||||
.list_right {
|
||||
width: 69.5%;
|
||||
background: white;
|
||||
border: 1px solid #ededed;
|
||||
padding: 10px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.el-tree {
|
||||
height: calc(80vh - 160px);
|
||||
width: 100%;
|
||||
overflow: auto !important;
|
||||
}
|
||||
// .el-tree-node__children {
|
||||
// overflow: visible !important;
|
||||
// }
|
||||
}
|
||||
</style>
|
||||
278
src/views/safety/questionBank/index.vue
Normal file
278
src/views/safety/questionBank/index.vue
Normal file
@ -0,0 +1,278 @@
|
||||
<template>
|
||||
<div class="p-2">
|
||||
<transition :enter-active-class="proxy?.animate.searchAnimate.enter" :leave-active-class="proxy?.animate.searchAnimate.leave">
|
||||
<div v-show="showSearch" class="mb-[10px]">
|
||||
<el-card shadow="hover">
|
||||
<el-form ref="queryFormRef" :model="queryParams" :inline="true">
|
||||
<el-form-item label="题目类别" prop="categoryType">
|
||||
<el-select v-model="queryParams.categoryType" placeholder="请选择题目类别" clearable>
|
||||
<el-option v-for="dict in safety_question_category_type" :key="dict.value" :label="dict.label" :value="dict.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="题目类型" prop="questionType">
|
||||
<el-select v-model="queryParams.questionType" placeholder="请选择题目类型" clearable>
|
||||
<el-option v-for="dict in safety_question_type" :key="dict.value" :label="dict.label" :value="dict.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="题目内容" prop="questionContent">
|
||||
<el-input v-model="queryParams.questionContent" placeholder="请输入题目内容" clearable @keyup.enter="handleQuery" />
|
||||
</el-form-item>
|
||||
<el-form-item label="选项" prop="options">
|
||||
<el-input v-model="queryParams.options" placeholder="请输入选项" clearable @keyup.enter="handleQuery" />
|
||||
</el-form-item>
|
||||
<el-form-item label="正确答案" prop="correctAnswer">
|
||||
<el-input v-model="queryParams.correctAnswer" placeholder="请输入正确答案" clearable @keyup.enter="handleQuery" />
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
|
||||
<el-button icon="Refresh" @click="resetQuery">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-card>
|
||||
</div>
|
||||
</transition>
|
||||
|
||||
<el-card shadow="never">
|
||||
<template #header>
|
||||
<el-row :gutter="10" class="mb8">
|
||||
<el-col :span="1.5">
|
||||
<el-button type="primary" plain icon="Plus" @click="handleAdd" v-hasPermi="['safety:questionBank:add']"> 新增 </el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button type="success" plain icon="Edit" :disabled="single" @click="handleUpdate()" v-hasPermi="['safety:questionBank:edit']"
|
||||
>修改
|
||||
</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete()" v-hasPermi="['safety:questionBank:remove']"
|
||||
>删除
|
||||
</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button type="warning" plain icon="Download" @click="handleExport" v-hasPermi="['safety:questionBank:export']">导出 </el-button>
|
||||
</el-col>
|
||||
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
|
||||
</el-row>
|
||||
</template>
|
||||
|
||||
<el-table v-loading="loading" :data="questionBankList" @selection-change="handleSelectionChange">
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column label="主键id" align="center" prop="id" v-if="true" />
|
||||
<el-table-column label="题目类别" align="center" prop="categoryType">
|
||||
<template #default="scope">
|
||||
<dict-tag :options="safety_question_category_type" :value="scope.row.categoryType" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="题目类型" align="center" prop="questionType">
|
||||
<template #default="scope">
|
||||
<dict-tag :options="safety_question_type" :value="scope.row.questionType" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="题目内容" align="center" prop="questionContent" />
|
||||
<el-table-column label="选项" align="center" prop="options" />
|
||||
<el-table-column label="正确答案" align="center" prop="correctAnswer" />
|
||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||
<template #default="scope">
|
||||
<el-tooltip content="修改" placement="top">
|
||||
<el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['safety:questionBank:edit']"></el-button>
|
||||
</el-tooltip>
|
||||
<el-tooltip content="删除" placement="top">
|
||||
<el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['safety:questionBank:remove']"></el-button>
|
||||
</el-tooltip>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" @pagination="getList" />
|
||||
</el-card>
|
||||
<!-- 添加或修改题库对话框 -->
|
||||
<el-dialog :title="dialog.title" v-model="dialog.visible" width="500px" append-to-body>
|
||||
<el-form ref="questionBankFormRef" :model="form" :rules="rules" label-width="80px">
|
||||
<el-form-item label="题目类别" prop="categoryType">
|
||||
<el-select v-model="form.categoryType" placeholder="请选择题目类别">
|
||||
<el-option v-for="dict in safety_question_category_type" :key="dict.value" :label="dict.label" :value="dict.value"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="题目类型" prop="questionType">
|
||||
<el-select v-model="form.questionType" placeholder="请选择题目类型">
|
||||
<el-option v-for="dict in safety_question_type" :key="dict.value" :label="dict.label" :value="dict.value"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="题目内容" prop="questionContent">
|
||||
<el-input v-model="form.questionContent" placeholder="请输入题目内容" />
|
||||
</el-form-item>
|
||||
<el-form-item label="选项" prop="options">
|
||||
<el-input v-model="form.options" type="textarea" placeholder="请输入内容" />
|
||||
</el-form-item>
|
||||
<el-form-item label="正确答案" prop="correctAnswer">
|
||||
<el-input v-model="form.correctAnswer" placeholder="请输入正确答案" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<el-button :loading="buttonLoading" type="primary" @click="submitForm">确 定</el-button>
|
||||
<el-button @click="cancel">取 消</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup name="QuestionBank" lang="ts">
|
||||
import { addQuestionBank, delQuestionBank, getQuestionBank, listQuestionBank, updateQuestionBank } from '@/api/safety/questionBank';
|
||||
import { QuestionBankForm, QuestionBankQuery, QuestionBankVO } from '@/api/safety/questionBank/types';
|
||||
import { useUserStoreHook } from '@/store/modules/user';
|
||||
|
||||
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
|
||||
const { safety_question_type, safety_question_category_type } = toRefs<any>(proxy?.useDict('safety_question_type', 'safety_question_category_type'));
|
||||
// 获取用户 store
|
||||
const userStore = useUserStoreHook();
|
||||
// 从 store 中获取项目列表和当前选中的项目
|
||||
const currentProject = computed(() => userStore.selectedProject);
|
||||
const questionBankList = ref<QuestionBankVO[]>([]);
|
||||
const buttonLoading = ref(false);
|
||||
const loading = ref(true);
|
||||
const showSearch = ref(true);
|
||||
const ids = ref<Array<string | number>>([]);
|
||||
const single = ref(true);
|
||||
const multiple = ref(true);
|
||||
const total = ref(0);
|
||||
|
||||
const queryFormRef = ref<ElFormInstance>();
|
||||
const questionBankFormRef = ref<ElFormInstance>();
|
||||
|
||||
const dialog = reactive<DialogOption>({
|
||||
visible: false,
|
||||
title: ''
|
||||
});
|
||||
|
||||
const initFormData: QuestionBankForm = {
|
||||
id: undefined,
|
||||
categoryType: undefined,
|
||||
questionType: undefined,
|
||||
questionContent: undefined,
|
||||
options: undefined,
|
||||
correctAnswer: undefined
|
||||
};
|
||||
const data = reactive<PageData<QuestionBankForm, QuestionBankQuery>>({
|
||||
form: { ...initFormData },
|
||||
queryParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
categoryType: undefined,
|
||||
questionType: undefined,
|
||||
questionContent: undefined,
|
||||
options: undefined,
|
||||
correctAnswer: undefined,
|
||||
params: {}
|
||||
},
|
||||
rules: {
|
||||
id: [{ required: true, message: '主键id不能为空', trigger: 'blur' }],
|
||||
categoryType: [{ required: true, message: '题目类别不能为空', trigger: 'change' }],
|
||||
questionType: [{ required: true, message: '题目类型不能为空', trigger: 'change' }],
|
||||
questionContent: [{ required: true, message: '题目内容不能为空', trigger: 'blur' }],
|
||||
options: [{ required: true, message: '选项不能为空', trigger: 'blur' }],
|
||||
correctAnswer: [{ required: true, message: '正确答案不能为空', trigger: 'blur' }]
|
||||
}
|
||||
});
|
||||
|
||||
const { queryParams, form, rules } = toRefs(data);
|
||||
|
||||
/** 查询题库列表 */
|
||||
const getList = async () => {
|
||||
loading.value = true;
|
||||
const res = await listQuestionBank(queryParams.value);
|
||||
questionBankList.value = res.rows;
|
||||
total.value = res.total;
|
||||
loading.value = false;
|
||||
};
|
||||
|
||||
/** 取消按钮 */
|
||||
const cancel = () => {
|
||||
reset();
|
||||
dialog.visible = false;
|
||||
};
|
||||
|
||||
/** 表单重置 */
|
||||
const reset = () => {
|
||||
form.value = { ...initFormData };
|
||||
questionBankFormRef.value?.resetFields();
|
||||
};
|
||||
|
||||
/** 搜索按钮操作 */
|
||||
const handleQuery = () => {
|
||||
queryParams.value.pageNum = 1;
|
||||
getList();
|
||||
};
|
||||
|
||||
/** 重置按钮操作 */
|
||||
const resetQuery = () => {
|
||||
queryFormRef.value?.resetFields();
|
||||
handleQuery();
|
||||
};
|
||||
|
||||
/** 多选框选中数据 */
|
||||
const handleSelectionChange = (selection: QuestionBankVO[]) => {
|
||||
ids.value = selection.map((item) => item.id);
|
||||
single.value = selection.length != 1;
|
||||
multiple.value = !selection.length;
|
||||
};
|
||||
|
||||
/** 新增按钮操作 */
|
||||
const handleAdd = () => {
|
||||
reset();
|
||||
dialog.visible = true;
|
||||
dialog.title = '添加题库';
|
||||
};
|
||||
|
||||
/** 修改按钮操作 */
|
||||
const handleUpdate = async (row?: QuestionBankVO) => {
|
||||
reset();
|
||||
const _id = row?.id || ids.value[0];
|
||||
const res = await getQuestionBank(_id);
|
||||
Object.assign(form.value, res.data);
|
||||
dialog.visible = true;
|
||||
dialog.title = '修改题库';
|
||||
};
|
||||
|
||||
/** 提交按钮 */
|
||||
const submitForm = () => {
|
||||
questionBankFormRef.value?.validate(async (valid: boolean) => {
|
||||
if (valid) {
|
||||
buttonLoading.value = true;
|
||||
if (form.value.id) {
|
||||
await updateQuestionBank(form.value).finally(() => (buttonLoading.value = false));
|
||||
} else {
|
||||
await addQuestionBank(form.value).finally(() => (buttonLoading.value = false));
|
||||
}
|
||||
proxy?.$modal.msgSuccess('操作成功');
|
||||
dialog.visible = false;
|
||||
await getList();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/** 删除按钮操作 */
|
||||
const handleDelete = async (row?: QuestionBankVO) => {
|
||||
const _ids = row?.id || ids.value;
|
||||
await proxy?.$modal.confirm('是否确认删除题库编号为"' + _ids + '"的数据项?').finally(() => (loading.value = false));
|
||||
await delQuestionBank(_ids);
|
||||
proxy?.$modal.msgSuccess('删除成功');
|
||||
await getList();
|
||||
};
|
||||
|
||||
/** 导出按钮操作 */
|
||||
const handleExport = () => {
|
||||
proxy?.download(
|
||||
'safety/questionBank/export',
|
||||
{
|
||||
...queryParams.value
|
||||
},
|
||||
`questionBank_${new Date().getTime()}.xlsx`
|
||||
);
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
getList();
|
||||
});
|
||||
</script>
|
||||
247
src/views/safety/questionUserAnswer/index.vue
Normal file
247
src/views/safety/questionUserAnswer/index.vue
Normal file
@ -0,0 +1,247 @@
|
||||
<template>
|
||||
<div class="p-2">
|
||||
<transition :enter-active-class="proxy?.animate.searchAnimate.enter" :leave-active-class="proxy?.animate.searchAnimate.leave">
|
||||
<div v-show="showSearch" class="mb-[10px]">
|
||||
<el-card shadow="hover">
|
||||
<el-form ref="queryFormRef" :model="queryParams" :inline="true">
|
||||
<el-form-item label="用户姓名" prop="userName">
|
||||
<el-input v-model="queryParams.userName" placeholder="请输入用户姓名" clearable @keyup.enter="handleQuery" />
|
||||
</el-form-item>
|
||||
<el-form-item label="班组" prop="teamId">
|
||||
<el-select v-model="queryParams.teamId" clearable placeholder="全部">
|
||||
<el-option v-for="item in ProjectTeam" :key="item.value" :label="item.label" :value="item.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
|
||||
<el-button icon="Refresh" @click="resetQuery">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-card>
|
||||
</div>
|
||||
</transition>
|
||||
|
||||
<el-card shadow="never">
|
||||
<template #header>
|
||||
<el-row :gutter="10" class="mb8">
|
||||
<el-col :span="1.5">
|
||||
<el-tooltip placement="top" effect="dark">
|
||||
<template #content>
|
||||
注:上传压缩包内的文件夹名称需设置为【姓名-身份证-满分-得分-及格分】, <br />
|
||||
例如:小明-5130112333654X-100-59-60
|
||||
</template>
|
||||
<file-upload
|
||||
:limit="1"
|
||||
v-model:model-value="filePath"
|
||||
isImportInfo
|
||||
:fileType="['zip']"
|
||||
uploadUrl="/safety/questionUserAnswer/upload/zip"
|
||||
:file-size="5000"
|
||||
:data="{ projectId: currentProject.id }"
|
||||
><el-button type="success" plain icon="Upload">上传线下安全考试</el-button></file-upload
|
||||
>
|
||||
</el-tooltip>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button type="primary" plain icon="Download" :disabled="single" @click="handleDownload()">批量下载试卷</el-button>
|
||||
</el-col>
|
||||
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
|
||||
</el-row>
|
||||
</template>
|
||||
|
||||
<el-table v-loading="loading" :data="questionUserAnswerList" @selection-change="handleSelectionChange">
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column label="主键id" align="center" prop="id" v-if="false" />
|
||||
<el-table-column label="姓名" align="center" prop="userName" />
|
||||
<el-table-column label="及格线/总分" align="center" prop="pass" />
|
||||
<el-table-column label="得分" align="center" prop="score" />
|
||||
<el-table-column label="计划时间" align="center" prop="examTime" />
|
||||
<el-table-column label="用时时间" align="center" prop="takeTime" />
|
||||
<el-table-column label="考试时间" align="center" prop="createTime" />
|
||||
<el-table-column label="类型" align="center" prop="examType">
|
||||
<template #default="scope">
|
||||
<dict-tag :options="user_exam_type" :value="scope.row.examType" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||
<template #default="scope">
|
||||
<el-link type="primary" :underline="false" :href="scope.row.fileUrl[0]" target="_blank">
|
||||
<el-button link type="primary" icon="View">预览试卷</el-button>
|
||||
</el-link>
|
||||
|
||||
<el-button link type="primary" icon="Download" @click="downloadOssOne(scope.row)">下载试卷</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" @pagination="getList" />
|
||||
</el-card>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup name="QuestionUserAnswer" lang="ts">
|
||||
import {
|
||||
listQuestionUserAnswer,
|
||||
getQuestionUserAnswer,
|
||||
delQuestionUserAnswer,
|
||||
addQuestionUserAnswer,
|
||||
updateQuestionUserAnswer,
|
||||
uploadQuestionUserAnswer
|
||||
} from '@/api/safety/questionUserAnswer';
|
||||
import { QuestionUserAnswerVO, QuestionUserAnswerQuery, QuestionUserAnswerForm } from '@/api/safety/questionUserAnswer/types';
|
||||
import { downLoadOss } from '@/api/system/oss';
|
||||
import download from '@/plugins/download';
|
||||
|
||||
import { useUserStoreHook } from '@/store/modules/user';
|
||||
import { blobValidate } from '@/utils/ruoyi';
|
||||
import FileSaver from 'file-saver';
|
||||
|
||||
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
|
||||
const { user_exam_type } = toRefs<any>(proxy?.useDict('user_exam_type'));
|
||||
|
||||
// 获取用户 store
|
||||
const userStore = useUserStoreHook();
|
||||
// 从 store 中获取项目列表和当前选中的项目
|
||||
const currentProject = computed(() => userStore.selectedProject);
|
||||
const ProjectTeam = computed(() => proxy?.$cache.local.getJSON('ProjectTeamList') || []);
|
||||
|
||||
const questionUserAnswerList = ref<QuestionUserAnswerVO[]>([]);
|
||||
const buttonLoading = ref(false);
|
||||
const loading = ref(true);
|
||||
const showSearch = ref(true);
|
||||
const ids = ref<Array<string | number>>([]);
|
||||
const single = ref(true);
|
||||
const multiple = ref(true);
|
||||
const total = ref(0);
|
||||
const filePath = ref<string>('');
|
||||
const queryFormRef = ref<ElFormInstance>();
|
||||
const questionUserAnswerFormRef = ref<ElFormInstance>();
|
||||
|
||||
const dialog = reactive<DialogOption>({
|
||||
visible: false,
|
||||
title: ''
|
||||
});
|
||||
|
||||
const initFormData: QuestionUserAnswerForm = {
|
||||
id: undefined,
|
||||
projectId: currentProject.value?.id,
|
||||
userId: undefined,
|
||||
bankId: undefined,
|
||||
answer: undefined,
|
||||
userName: undefined,
|
||||
score: undefined,
|
||||
examTime: undefined,
|
||||
takeTime: undefined,
|
||||
pass: undefined,
|
||||
file: undefined,
|
||||
teamId: undefined
|
||||
};
|
||||
const data = reactive<PageData<QuestionUserAnswerForm, QuestionUserAnswerQuery>>({
|
||||
form: { ...initFormData },
|
||||
queryParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
userId: undefined,
|
||||
examType: undefined,
|
||||
teamId: undefined,
|
||||
projectId: currentProject.value?.id,
|
||||
userName: undefined,
|
||||
params: {}
|
||||
},
|
||||
rules: {
|
||||
id: [{ required: true, message: '主键id不能为空', trigger: 'blur' }],
|
||||
projectId: [{ required: true, message: '项目id不能为空', trigger: 'blur' }],
|
||||
userId: [{ required: true, message: '用户id不能为空', trigger: 'blur' }]
|
||||
}
|
||||
});
|
||||
|
||||
const { queryParams, form, rules } = toRefs(data);
|
||||
|
||||
/** 查询用户试卷存储列表 */
|
||||
const getList = async () => {
|
||||
loading.value = true;
|
||||
const res = await listQuestionUserAnswer(queryParams.value);
|
||||
questionUserAnswerList.value = res.rows;
|
||||
total.value = res.total;
|
||||
loading.value = false;
|
||||
};
|
||||
|
||||
/** 取消按钮 */
|
||||
const cancel = () => {
|
||||
reset();
|
||||
dialog.visible = false;
|
||||
};
|
||||
|
||||
/** 表单重置 */
|
||||
const reset = () => {
|
||||
form.value = { ...initFormData };
|
||||
questionUserAnswerFormRef.value?.resetFields();
|
||||
};
|
||||
|
||||
/** 搜索按钮操作 */
|
||||
const handleQuery = () => {
|
||||
queryParams.value.pageNum = 1;
|
||||
getList();
|
||||
};
|
||||
|
||||
/** 重置按钮操作 */
|
||||
const resetQuery = () => {
|
||||
queryFormRef.value?.resetFields();
|
||||
handleQuery();
|
||||
};
|
||||
|
||||
/** 多选框选中数据 */
|
||||
const handleSelectionChange = (selection: QuestionUserAnswerVO[]) => {
|
||||
ids.value = selection.map((item) => item.id);
|
||||
single.value = selection.length == 0;
|
||||
multiple.value = !selection.length;
|
||||
};
|
||||
|
||||
/** 修改按钮操作 */
|
||||
// const handleUpdate = async (row?: QuestionUserAnswerVO) => {
|
||||
// reset();
|
||||
// const _id = row?.id || ids.value[0];
|
||||
// const res = await getQuestionUserAnswer(_id);
|
||||
// Object.assign(form.value, res.data);
|
||||
// dialog.visible = true;
|
||||
// dialog.title = '修改用户试卷存储';
|
||||
// };
|
||||
|
||||
/** 批量下载按钮操作 */
|
||||
const handleDownload = async () => {
|
||||
const _ids = ids.value;
|
||||
await downLoadOss({ idList: _ids }, '/safety/questionUserAnswer/exportFile', '安全考试.zip');
|
||||
};
|
||||
/** 下载单个按钮操作 */
|
||||
const downloadOssOne = async (row?: QuestionUserAnswerVO) => {
|
||||
await download.oss(row?.file);
|
||||
};
|
||||
|
||||
// const fileWatch = watch(
|
||||
// () => filePath.value,
|
||||
// (nid, oid) => {
|
||||
// uploadQuestionUserAnswer({ file: filePath.value, projectId: currentProject.value?.id }).then((res) => {
|
||||
// console.log(res);
|
||||
// });
|
||||
// }
|
||||
// );
|
||||
|
||||
//监听项目id刷新数据
|
||||
const listeningProject = watch(
|
||||
() => currentProject.value?.id,
|
||||
(nid, oid) => {
|
||||
queryParams.value.projectId = nid;
|
||||
form.value.projectId = nid;
|
||||
getList();
|
||||
}
|
||||
);
|
||||
|
||||
onUnmounted(() => {
|
||||
listeningProject();
|
||||
});
|
||||
|
||||
onMounted(() => {
|
||||
getList();
|
||||
});
|
||||
</script>
|
||||
236
src/views/safety/questionsCategory/index.vue
Normal file
236
src/views/safety/questionsCategory/index.vue
Normal file
@ -0,0 +1,236 @@
|
||||
<template>
|
||||
<div class="p-2">
|
||||
<transition :enter-active-class="proxy?.animate.searchAnimate.enter" :leave-active-class="proxy?.animate.searchAnimate.leave">
|
||||
<div v-show="showSearch" class="mb-[10px]">
|
||||
<el-card shadow="hover">
|
||||
<el-form ref="queryFormRef" :model="queryParams" :inline="true">
|
||||
<el-form-item label="题库类别" prop="categoryName">
|
||||
<el-input v-model="queryParams.categoryName" placeholder="请输入题库类别" clearable @keyup.enter="handleQuery" />
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
|
||||
<el-button icon="Refresh" @click="resetQuery">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-card>
|
||||
</div>
|
||||
</transition>
|
||||
|
||||
<el-card shadow="never">
|
||||
<template #header>
|
||||
<el-row :gutter="10" class="mb8">
|
||||
<el-col :span="1.5">
|
||||
<el-button type="primary" plain icon="Plus" @click="handleAdd" v-hasPermi="['safety:questionsCategory:add']">新增</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button type="success" plain icon="Edit" :disabled="single" @click="handleUpdate()" v-hasPermi="['safety:questionsCategory:edit']"
|
||||
>修改</el-button
|
||||
>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete()" v-hasPermi="['safety:questionsCategory:remove']"
|
||||
>删除</el-button
|
||||
>
|
||||
</el-col>
|
||||
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
|
||||
</el-row>
|
||||
</template>
|
||||
|
||||
<el-table v-loading="loading" :data="questionsCategoryList" @selection-change="handleSelectionChange">
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column label="序号" align="center" type="index" width="100" />
|
||||
<el-table-column label="题库类别" align="center" prop="categoryName" />
|
||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||
<template #default="scope">
|
||||
<el-tooltip content="修改" placement="top">
|
||||
<el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['safety:questionsCategory:edit']"></el-button>
|
||||
</el-tooltip>
|
||||
<el-tooltip content="删除" placement="top">
|
||||
<el-button
|
||||
link
|
||||
type="primary"
|
||||
icon="Delete"
|
||||
@click="handleDelete(scope.row)"
|
||||
v-hasPermi="['safety:questionsCategory:remove']"
|
||||
></el-button>
|
||||
</el-tooltip>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" @pagination="getList" />
|
||||
</el-card>
|
||||
<!-- 添加或修改题库类别对话框 -->
|
||||
<el-dialog :title="dialog.title" v-model="dialog.visible" width="500px" append-to-body>
|
||||
<el-form ref="questionsCategoryFormRef" :model="form" :rules="rules" label-width="80px">
|
||||
<el-form-item label="题库类别" prop="categoryName">
|
||||
<el-input v-model="form.categoryName" placeholder="请输入题库类别" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<el-button :loading="buttonLoading" type="primary" @click="submitForm">确 定</el-button>
|
||||
<el-button @click="cancel">取 消</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup name="QuestionsCategory" lang="ts">
|
||||
import {
|
||||
listQuestionsCategory,
|
||||
getQuestionsCategory,
|
||||
delQuestionsCategory,
|
||||
addQuestionsCategory,
|
||||
updateQuestionsCategory
|
||||
} from '@/api/safety/questionsCategory';
|
||||
import { QuestionsCategoryVO, QuestionsCategoryQuery, QuestionsCategoryForm } from '@/api/safety/questionsCategory/types';
|
||||
import { useUserStoreHook } from '@/store/modules/user';
|
||||
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
|
||||
// 获取用户 store
|
||||
const userStore = useUserStoreHook();
|
||||
// 从 store 中获取项目列表和当前选中的项目
|
||||
const currentProject = computed(() => userStore.selectedProject);
|
||||
const questionsCategoryList = ref<QuestionsCategoryVO[]>([]);
|
||||
const buttonLoading = ref(false);
|
||||
const loading = ref(true);
|
||||
const showSearch = ref(true);
|
||||
const ids = ref<Array<string | number>>([]);
|
||||
const single = ref(true);
|
||||
const multiple = ref(true);
|
||||
const total = ref(0);
|
||||
|
||||
const queryFormRef = ref<ElFormInstance>();
|
||||
const questionsCategoryFormRef = ref<ElFormInstance>();
|
||||
|
||||
const dialog = reactive<DialogOption>({
|
||||
visible: false,
|
||||
title: ''
|
||||
});
|
||||
|
||||
const initFormData: QuestionsCategoryForm = {
|
||||
id: undefined,
|
||||
projectId: currentProject.value?.id,
|
||||
categoryName: undefined
|
||||
};
|
||||
const data = reactive<PageData<QuestionsCategoryForm, QuestionsCategoryQuery>>({
|
||||
form: { ...initFormData },
|
||||
queryParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
projectId: currentProject.value?.id,
|
||||
categoryName: undefined,
|
||||
params: {}
|
||||
},
|
||||
rules: {
|
||||
id: [{ required: true, message: '主键id不能为空', trigger: 'blur' }],
|
||||
projectId: [{ required: true, message: '项目id不能为空', trigger: 'blur' }],
|
||||
categoryName: [{ required: true, message: '题库类别不能为空', trigger: 'blur' }]
|
||||
}
|
||||
});
|
||||
|
||||
const { queryParams, form, rules } = toRefs(data);
|
||||
|
||||
/** 查询题库类别列表 */
|
||||
const getList = async () => {
|
||||
loading.value = true;
|
||||
const res = await listQuestionsCategory(queryParams.value);
|
||||
questionsCategoryList.value = res.rows;
|
||||
total.value = res.total;
|
||||
loading.value = false;
|
||||
};
|
||||
|
||||
/** 取消按钮 */
|
||||
const cancel = () => {
|
||||
reset();
|
||||
dialog.visible = false;
|
||||
};
|
||||
|
||||
/** 表单重置 */
|
||||
const reset = () => {
|
||||
form.value = { ...initFormData };
|
||||
questionsCategoryFormRef.value?.resetFields();
|
||||
};
|
||||
|
||||
/** 搜索按钮操作 */
|
||||
const handleQuery = () => {
|
||||
queryParams.value.pageNum = 1;
|
||||
getList();
|
||||
};
|
||||
|
||||
/** 重置按钮操作 */
|
||||
const resetQuery = () => {
|
||||
queryFormRef.value?.resetFields();
|
||||
handleQuery();
|
||||
};
|
||||
|
||||
/** 多选框选中数据 */
|
||||
const handleSelectionChange = (selection: QuestionsCategoryVO[]) => {
|
||||
ids.value = selection.map((item) => item.id);
|
||||
single.value = selection.length != 1;
|
||||
multiple.value = !selection.length;
|
||||
};
|
||||
|
||||
/** 新增按钮操作 */
|
||||
const handleAdd = () => {
|
||||
reset();
|
||||
dialog.visible = true;
|
||||
dialog.title = '添加题库类别';
|
||||
};
|
||||
|
||||
/** 修改按钮操作 */
|
||||
const handleUpdate = async (row?: QuestionsCategoryVO) => {
|
||||
reset();
|
||||
const _id = row?.id || ids.value[0];
|
||||
const res = await getQuestionsCategory(_id);
|
||||
Object.assign(form.value, res.data);
|
||||
dialog.visible = true;
|
||||
dialog.title = '修改题库类别';
|
||||
};
|
||||
|
||||
/** 提交按钮 */
|
||||
const submitForm = () => {
|
||||
questionsCategoryFormRef.value?.validate(async (valid: boolean) => {
|
||||
if (valid) {
|
||||
buttonLoading.value = true;
|
||||
form.value.projectId = currentProject.value?.id;
|
||||
if (form.value.id) {
|
||||
await updateQuestionsCategory(form.value).finally(() => (buttonLoading.value = false));
|
||||
} else {
|
||||
await addQuestionsCategory(form.value).finally(() => (buttonLoading.value = false));
|
||||
}
|
||||
proxy?.$modal.msgSuccess('操作成功');
|
||||
dialog.visible = false;
|
||||
await getList();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/** 删除按钮操作 */
|
||||
const handleDelete = async (row?: QuestionsCategoryVO) => {
|
||||
const _ids = row?.id || ids.value;
|
||||
await proxy?.$modal.confirm('是否确认删除题库类别编号为"' + _ids + '"的数据项?').finally(() => (loading.value = false));
|
||||
await delQuestionsCategory(_ids);
|
||||
proxy?.$modal.msgSuccess('删除成功');
|
||||
await getList();
|
||||
};
|
||||
|
||||
//监听项目id刷新数据
|
||||
const listeningProject = watch(
|
||||
() => currentProject.value?.id,
|
||||
(nid, oid) => {
|
||||
queryParams.value.projectId = nid;
|
||||
form.value.projectId = nid;
|
||||
getList();
|
||||
}
|
||||
);
|
||||
|
||||
onUnmounted(() => {
|
||||
listeningProject();
|
||||
});
|
||||
|
||||
onMounted(() => {
|
||||
getList();
|
||||
});
|
||||
</script>
|
||||
309
src/views/safety/questionsConfig/index.vue
Normal file
309
src/views/safety/questionsConfig/index.vue
Normal file
@ -0,0 +1,309 @@
|
||||
<template>
|
||||
<div class="p-2">
|
||||
<transition :enter-active-class="proxy?.animate.searchAnimate.enter" :leave-active-class="proxy?.animate.searchAnimate.leave">
|
||||
<div v-show="showSearch" class="mb-[10px]">
|
||||
<el-card shadow="hover">
|
||||
<el-form ref="queryFormRef" :model="queryParams" :inline="true">
|
||||
<el-form-item label="单选题" prop="singleChoice">
|
||||
<el-input v-model="queryParams.singleChoice" placeholder="请输入单选题" clearable @keyup.enter="handleQuery" />
|
||||
</el-form-item>
|
||||
<el-form-item label="单选分数" prop="singleScore">
|
||||
<el-input v-model="queryParams.singleScore" placeholder="请输入单选分数" clearable @keyup.enter="handleQuery" />
|
||||
</el-form-item>
|
||||
<el-form-item label="多选题" prop="multipleChoice">
|
||||
<el-input v-model="queryParams.multipleChoice" placeholder="请输入多选题" clearable @keyup.enter="handleQuery" />
|
||||
</el-form-item>
|
||||
<el-form-item label="多选分数" prop="multipleScore">
|
||||
<el-input v-model="queryParams.multipleScore" placeholder="请输入多选分数" clearable @keyup.enter="handleQuery" />
|
||||
</el-form-item>
|
||||
<el-form-item label="判断题" prop="estimate">
|
||||
<el-input v-model="queryParams.estimate" placeholder="请输入判断题" clearable @keyup.enter="handleQuery" />
|
||||
</el-form-item>
|
||||
<el-form-item label="判断分数" prop="estimateScore">
|
||||
<el-input v-model="queryParams.estimateScore" placeholder="请输入判断分数" clearable @keyup.enter="handleQuery" />
|
||||
</el-form-item>
|
||||
<el-form-item label="满分" prop="fullMark">
|
||||
<el-input v-model="queryParams.fullMark" placeholder="请输入满分" clearable @keyup.enter="handleQuery" />
|
||||
</el-form-item>
|
||||
<el-form-item label="及格线" prop="passScore">
|
||||
<el-input v-model="queryParams.passScore" placeholder="请输入及格线" clearable @keyup.enter="handleQuery" />
|
||||
</el-form-item>
|
||||
<el-form-item label="答题最大时间" prop="answerTime">
|
||||
<el-input v-model="queryParams.answerTime" placeholder="请输入答题最大时间" clearable @keyup.enter="handleQuery" />
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
|
||||
<el-button icon="Refresh" @click="resetQuery">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-card>
|
||||
</div>
|
||||
</transition>
|
||||
|
||||
<el-card shadow="never">
|
||||
<template #header>
|
||||
<el-row :gutter="10" class="mb8">
|
||||
<el-col :span="1.5">
|
||||
<el-button type="primary" plain icon="Plus" @click="handleAdd" v-hasPermi="['safety:questionsConfig:add']"> 新增 </el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button type="success" plain icon="Edit" :disabled="single" @click="handleUpdate()" v-hasPermi="['safety:questionsConfig:edit']"
|
||||
>修改
|
||||
</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete()" v-hasPermi="['safety:questionsConfig:remove']"
|
||||
>删除
|
||||
</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button type="warning" plain icon="Download" @click="handleExport" v-hasPermi="['safety:questionsConfig:export']">导出 </el-button>
|
||||
</el-col>
|
||||
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
|
||||
</el-row>
|
||||
</template>
|
||||
|
||||
<el-table v-loading="loading" :data="questionsConfigList" @selection-change="handleSelectionChange">
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column label="主键id" align="center" prop="id" v-if="true" />
|
||||
<el-table-column label="单选题" align="center" prop="singleChoice" />
|
||||
<el-table-column label="单选分数" align="center" prop="singleScore" />
|
||||
<el-table-column label="多选题" align="center" prop="multipleChoice" />
|
||||
<el-table-column label="多选分数" align="center" prop="multipleScore" />
|
||||
<el-table-column label="判断题" align="center" prop="estimate" />
|
||||
<el-table-column label="判断分数" align="center" prop="estimateScore" />
|
||||
<el-table-column label="满分" align="center" prop="fullMark" />
|
||||
<el-table-column label="及格线" align="center" prop="passScore" />
|
||||
<el-table-column label="答题最大时间" align="center" prop="answerTime" />
|
||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||
<template #default="scope">
|
||||
<el-tooltip content="修改" placement="top">
|
||||
<el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['safety:questionsConfig:edit']"></el-button>
|
||||
</el-tooltip>
|
||||
<el-tooltip content="删除" placement="top">
|
||||
<el-button
|
||||
link
|
||||
type="primary"
|
||||
icon="Delete"
|
||||
@click="handleDelete(scope.row)"
|
||||
v-hasPermi="['safety:questionsConfig:remove']"
|
||||
></el-button>
|
||||
</el-tooltip>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" @pagination="getList" />
|
||||
</el-card>
|
||||
<!-- 添加或修改题库配置对话框 -->
|
||||
<el-dialog :title="dialog.title" v-model="dialog.visible" width="500px" append-to-body>
|
||||
<el-form ref="questionsConfigFormRef" :model="form" :rules="rules" label-width="80px">
|
||||
<el-form-item label="单选题" prop="singleChoice">
|
||||
<el-input v-model="form.singleChoice" placeholder="请输入单选题" />
|
||||
</el-form-item>
|
||||
<el-form-item label="单选分数" prop="singleScore">
|
||||
<el-input v-model="form.singleScore" placeholder="请输入单选分数" />
|
||||
</el-form-item>
|
||||
<el-form-item label="多选题" prop="multipleChoice">
|
||||
<el-input v-model="form.multipleChoice" placeholder="请输入多选题" />
|
||||
</el-form-item>
|
||||
<el-form-item label="多选分数" prop="multipleScore">
|
||||
<el-input v-model="form.multipleScore" placeholder="请输入多选分数" />
|
||||
</el-form-item>
|
||||
<el-form-item label="判断题" prop="estimate">
|
||||
<el-input v-model="form.estimate" placeholder="请输入判断题" />
|
||||
</el-form-item>
|
||||
<el-form-item label="判断分数" prop="estimateScore">
|
||||
<el-input v-model="form.estimateScore" placeholder="请输入判断分数" />
|
||||
</el-form-item>
|
||||
<el-form-item label="满分" prop="fullMark">
|
||||
<el-input v-model="form.fullMark" placeholder="请输入满分" />
|
||||
</el-form-item>
|
||||
<el-form-item label="及格线" prop="passScore">
|
||||
<el-input v-model="form.passScore" placeholder="请输入及格线" />
|
||||
</el-form-item>
|
||||
<el-form-item label="答题最大时间" prop="answerTime">
|
||||
<el-input v-model="form.answerTime" placeholder="请输入答题最大时间" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<el-button :loading="buttonLoading" type="primary" @click="submitForm">确 定</el-button>
|
||||
<el-button @click="cancel">取 消</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup name="QuestionsConfig" lang="ts">
|
||||
import { addQuestionsConfig, delQuestionsConfig, getQuestionsConfig, listQuestionsConfig, updateQuestionsConfig } from '@/api/safety/questionsConfig';
|
||||
import { QuestionsConfigForm, QuestionsConfigQuery, QuestionsConfigVO } from '@/api/safety/questionsConfig/types';
|
||||
import { useUserStoreHook } from '@/store/modules/user';
|
||||
|
||||
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
|
||||
// 获取用户 store
|
||||
const userStore = useUserStoreHook();
|
||||
// 从 store 中获取项目列表和当前选中的项目
|
||||
const currentProject = computed(() => userStore.selectedProject);
|
||||
const questionsConfigList = ref<QuestionsConfigVO[]>([]);
|
||||
const buttonLoading = ref(false);
|
||||
const loading = ref(true);
|
||||
const showSearch = ref(true);
|
||||
const ids = ref<Array<string | number>>([]);
|
||||
const single = ref(true);
|
||||
const multiple = ref(true);
|
||||
const total = ref(0);
|
||||
|
||||
const queryFormRef = ref<ElFormInstance>();
|
||||
const questionsConfigFormRef = ref<ElFormInstance>();
|
||||
|
||||
const dialog = reactive<DialogOption>({
|
||||
visible: false,
|
||||
title: ''
|
||||
});
|
||||
|
||||
const initFormData: QuestionsConfigForm = {
|
||||
id: undefined,
|
||||
projectId: currentProject.value?.id,
|
||||
singleChoice: undefined,
|
||||
singleScore: undefined,
|
||||
multipleChoice: undefined,
|
||||
multipleScore: undefined,
|
||||
estimate: undefined,
|
||||
estimateScore: undefined,
|
||||
fullMark: undefined,
|
||||
passScore: undefined,
|
||||
answerTime: undefined
|
||||
};
|
||||
const data = reactive<PageData<QuestionsConfigForm, QuestionsConfigQuery>>({
|
||||
form: { ...initFormData },
|
||||
queryParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
projectId: currentProject.value?.id,
|
||||
singleChoice: undefined,
|
||||
singleScore: undefined,
|
||||
multipleChoice: undefined,
|
||||
multipleScore: undefined,
|
||||
estimate: undefined,
|
||||
estimateScore: undefined,
|
||||
fullMark: undefined,
|
||||
passScore: undefined,
|
||||
answerTime: undefined,
|
||||
params: {}
|
||||
},
|
||||
rules: {
|
||||
id: [{ required: true, message: '主键id不能为空', trigger: 'blur' }],
|
||||
singleChoice: [{ required: true, message: '单选题不能为空', trigger: 'blur' }],
|
||||
singleScore: [{ required: true, message: '单选分数不能为空', trigger: 'blur' }],
|
||||
multipleChoice: [{ required: true, message: '多选题不能为空', trigger: 'blur' }],
|
||||
multipleScore: [{ required: true, message: '多选分数不能为空', trigger: 'blur' }],
|
||||
estimate: [{ required: true, message: '判断题不能为空', trigger: 'blur' }],
|
||||
estimateScore: [{ required: true, message: '判断分数不能为空', trigger: 'blur' }],
|
||||
fullMark: [{ required: true, message: '满分不能为空', trigger: 'blur' }],
|
||||
passScore: [{ required: true, message: '及格线不能为空', trigger: 'blur' }],
|
||||
answerTime: [{ required: true, message: '答题最大时间不能为空', trigger: 'blur' }]
|
||||
}
|
||||
});
|
||||
|
||||
const { queryParams, form, rules } = toRefs(data);
|
||||
|
||||
/** 查询题库配置列表 */
|
||||
const getList = async () => {
|
||||
loading.value = true;
|
||||
const res = await listQuestionsConfig(queryParams.value);
|
||||
questionsConfigList.value = res.rows;
|
||||
total.value = res.total;
|
||||
loading.value = false;
|
||||
};
|
||||
|
||||
/** 取消按钮 */
|
||||
const cancel = () => {
|
||||
reset();
|
||||
dialog.visible = false;
|
||||
};
|
||||
|
||||
/** 表单重置 */
|
||||
const reset = () => {
|
||||
form.value = { ...initFormData };
|
||||
questionsConfigFormRef.value?.resetFields();
|
||||
};
|
||||
|
||||
/** 搜索按钮操作 */
|
||||
const handleQuery = () => {
|
||||
queryParams.value.pageNum = 1;
|
||||
getList();
|
||||
};
|
||||
|
||||
/** 重置按钮操作 */
|
||||
const resetQuery = () => {
|
||||
queryFormRef.value?.resetFields();
|
||||
handleQuery();
|
||||
};
|
||||
|
||||
/** 多选框选中数据 */
|
||||
const handleSelectionChange = (selection: QuestionsConfigVO[]) => {
|
||||
ids.value = selection.map((item) => item.id);
|
||||
single.value = selection.length != 1;
|
||||
multiple.value = !selection.length;
|
||||
};
|
||||
|
||||
/** 新增按钮操作 */
|
||||
const handleAdd = () => {
|
||||
reset();
|
||||
dialog.visible = true;
|
||||
dialog.title = '添加题库配置';
|
||||
};
|
||||
|
||||
/** 修改按钮操作 */
|
||||
const handleUpdate = async (row?: QuestionsConfigVO) => {
|
||||
reset();
|
||||
const _id = row?.id || ids.value[0];
|
||||
const res = await getQuestionsConfig(_id);
|
||||
Object.assign(form.value, res.data);
|
||||
dialog.visible = true;
|
||||
dialog.title = '修改题库配置';
|
||||
};
|
||||
|
||||
/** 提交按钮 */
|
||||
const submitForm = () => {
|
||||
questionsConfigFormRef.value?.validate(async (valid: boolean) => {
|
||||
if (valid) {
|
||||
buttonLoading.value = true;
|
||||
if (form.value.id) {
|
||||
await updateQuestionsConfig(form.value).finally(() => (buttonLoading.value = false));
|
||||
} else {
|
||||
await addQuestionsConfig(form.value).finally(() => (buttonLoading.value = false));
|
||||
}
|
||||
proxy?.$modal.msgSuccess('操作成功');
|
||||
dialog.visible = false;
|
||||
await getList();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/** 删除按钮操作 */
|
||||
const handleDelete = async (row?: QuestionsConfigVO) => {
|
||||
const _ids = row?.id || ids.value;
|
||||
await proxy?.$modal.confirm('是否确认删除题库配置编号为"' + _ids + '"的数据项?').finally(() => (loading.value = false));
|
||||
await delQuestionsConfig(_ids);
|
||||
proxy?.$modal.msgSuccess('删除成功');
|
||||
await getList();
|
||||
};
|
||||
|
||||
/** 导出按钮操作 */
|
||||
const handleExport = () => {
|
||||
proxy?.download(
|
||||
'safety/questionsConfig/export',
|
||||
{
|
||||
...queryParams.value
|
||||
},
|
||||
`questionsConfig_${new Date().getTime()}.xlsx`
|
||||
);
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
getList();
|
||||
});
|
||||
</script>
|
||||
283
src/views/safety/recognizeRecord/index.vue
Normal file
283
src/views/safety/recognizeRecord/index.vue
Normal file
@ -0,0 +1,283 @@
|
||||
<template>
|
||||
<div class="p-2">
|
||||
<transition :enter-active-class="proxy?.animate.searchAnimate.enter" :leave-active-class="proxy?.animate.searchAnimate.leave">
|
||||
<div v-show="showSearch" class="mb-[10px]">
|
||||
<el-card shadow="hover">
|
||||
<el-form ref="queryFormRef" :model="queryParams" :inline="true">
|
||||
<el-form-item label="类别" prop="recordCategory">
|
||||
<el-select v-model="queryParams.recordCategory" placeholder="请选择类别" clearable>
|
||||
<el-option v-for="dict in recordCategoryType" :key="dict.value" :label="dict.label" :value="dict.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="类型" prop="violationType">
|
||||
<el-select v-model="queryParams.violationType" placeholder="请选择违章类型" clearable>
|
||||
<el-option v-for="dict in violation_level_type" :key="dict.value" :label="dict.label" :value="dict.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="故障描述" prop="description">
|
||||
<el-input v-model="queryParams.description" placeholder="请输入故障描述" clearable @keyup.enter="handleQuery" />
|
||||
</el-form-item>
|
||||
<el-form-item label="创建时间" prop="createTime">
|
||||
<el-date-picker clearable v-model="queryParams.createTime" type="date" value-format="YYYY-MM-DD" placeholder="请选择创建时间" />
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
|
||||
<el-button icon="Refresh" @click="resetQuery">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-card>
|
||||
</div>
|
||||
</transition>
|
||||
|
||||
<el-card shadow="never">
|
||||
<el-table v-loading="loading" :data="recognizeRecordList" @selection-change="handleSelectionChange">
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column label="主键id" align="center" prop="id" v-if="false" />
|
||||
<el-table-column label="设备名称" align="center" prop="deviceName" />
|
||||
<el-table-column label="识别类别" align="center" prop="recordCategory">
|
||||
<template #default="scope">
|
||||
{{ scope.row.recordCategory === '1' ? '无人机识别' : '监控拍摄' }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="违章类型" align="center" prop="violationType">
|
||||
<template #default="scope">
|
||||
<dict-tag :options="violation_level_type" :value="scope.row.violationType" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="图片路径" align="center" prop="picture" width="100">
|
||||
<template #default="scope">
|
||||
<image-preview :src="scope.row.picture" :width="50" :height="50" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="故障描述" align="center" prop="description" />
|
||||
<el-table-column label="创建时间" align="center" prop="createTime" width="180">
|
||||
<template #default="scope">
|
||||
<span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||
<template #default="scope">
|
||||
<el-button link type="danger" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['safety:recognizeRecord:remove']"
|
||||
>删除</el-button
|
||||
>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" @pagination="getList" />
|
||||
</el-card>
|
||||
<!-- 添加或修改识别记录对话框 -->
|
||||
<el-dialog :title="dialog.title" v-model="dialog.visible" width="500px" append-to-body>
|
||||
<el-form ref="recognizeRecordFormRef" :model="form" :rules="rules" label-width="80px">
|
||||
<el-form-item label="项目id" prop="projectId">
|
||||
<el-input v-model="form.projectId" placeholder="请输入项目id" />
|
||||
</el-form-item>
|
||||
<el-form-item label="设备序列号" prop="deviceSerial">
|
||||
<el-input v-model="form.deviceSerial" placeholder="请输入设备序列号" />
|
||||
</el-form-item>
|
||||
<el-form-item label="设备名称" prop="deviceName">
|
||||
<el-input v-model="form.deviceName" placeholder="请输入设备名称" />
|
||||
</el-form-item>
|
||||
<el-form-item label="违章类型" prop="violationType">
|
||||
<el-select v-model="form.violationType" placeholder="请选择违章类型">
|
||||
<el-option v-for="dict in violation_level_type" :key="dict.value" :label="dict.label" :value="dict.value"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="图片路径" prop="picture">
|
||||
<image-upload v-model="form.picture" />
|
||||
</el-form-item>
|
||||
<el-form-item label="违规数量" prop="num">
|
||||
<el-input v-model="form.num" placeholder="请输入违规数量" />
|
||||
</el-form-item>
|
||||
<el-form-item label="故障描述" prop="description">
|
||||
<el-input v-model="form.description" type="textarea" placeholder="请输入内容" />
|
||||
</el-form-item>
|
||||
<el-form-item label="备注" prop="remark">
|
||||
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<el-button :loading="buttonLoading" type="primary" @click="submitForm">确 定</el-button>
|
||||
<el-button @click="cancel">取 消</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup name="RecognizeRecord" lang="ts">
|
||||
import { listRecognizeRecord, getRecognizeRecord, delRecognizeRecord, addRecognizeRecord, updateRecognizeRecord } from '@/api/safety/recognizeRecord';
|
||||
import { RecognizeRecordVO, RecognizeRecordQuery, RecognizeRecordForm } from '@/api/safety/recognizeRecord/types';
|
||||
import { useUserStoreHook } from '@/store/modules/user';
|
||||
|
||||
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
|
||||
const { violation_level_type } = toRefs<any>(proxy?.useDict('violation_level_type'));
|
||||
|
||||
const recognizeRecordList = ref<RecognizeRecordVO[]>([]);
|
||||
const buttonLoading = ref(false);
|
||||
const loading = ref(true);
|
||||
const showSearch = ref(true);
|
||||
const ids = ref<Array<string | number>>([]);
|
||||
const single = ref(true);
|
||||
const multiple = ref(true);
|
||||
const total = ref(0);
|
||||
const recordCategoryType = ref<{ label: string; value: string | number }[]>([
|
||||
{ label: '无人机识别', value: '1' },
|
||||
{ label: '监控拍摄', value: '2' }
|
||||
]);
|
||||
const queryFormRef = ref<ElFormInstance>();
|
||||
const recognizeRecordFormRef = ref<ElFormInstance>();
|
||||
// 获取用户 store
|
||||
const userStore = useUserStoreHook();
|
||||
// 从 store 中获取项目列表和当前选中的项目
|
||||
const currentProject = computed(() => userStore.selectedProject);
|
||||
|
||||
const dialog = reactive<DialogOption>({
|
||||
visible: false,
|
||||
title: ''
|
||||
});
|
||||
|
||||
const initFormData: RecognizeRecordForm = {
|
||||
id: undefined,
|
||||
projectId: undefined,
|
||||
deviceSerial: undefined,
|
||||
deviceName: undefined,
|
||||
recordCategory: undefined,
|
||||
violationType: undefined,
|
||||
picture: undefined,
|
||||
num: undefined,
|
||||
description: undefined,
|
||||
remark: undefined
|
||||
};
|
||||
const data = reactive<PageData<RecognizeRecordForm, RecognizeRecordQuery>>({
|
||||
form: { ...initFormData },
|
||||
queryParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
projectId: undefined,
|
||||
deviceName: undefined,
|
||||
recordCategory: undefined,
|
||||
violationType: undefined,
|
||||
createTime: undefined,
|
||||
params: {}
|
||||
},
|
||||
rules: {
|
||||
id: [{ required: true, message: '主键id不能为空', trigger: 'blur' }],
|
||||
projectId: [{ required: true, message: '项目id不能为空', trigger: 'blur' }]
|
||||
}
|
||||
});
|
||||
|
||||
const { queryParams, form, rules } = toRefs(data);
|
||||
|
||||
/** 查询识别记录列表 */
|
||||
const getList = async () => {
|
||||
loading.value = true;
|
||||
const res = await listRecognizeRecord(queryParams.value);
|
||||
recognizeRecordList.value = res.rows;
|
||||
total.value = res.total;
|
||||
loading.value = false;
|
||||
};
|
||||
|
||||
/** 取消按钮 */
|
||||
const cancel = () => {
|
||||
reset();
|
||||
dialog.visible = false;
|
||||
};
|
||||
|
||||
/** 表单重置 */
|
||||
const reset = () => {
|
||||
form.value = { ...initFormData };
|
||||
recognizeRecordFormRef.value?.resetFields();
|
||||
};
|
||||
|
||||
/** 搜索按钮操作 */
|
||||
const handleQuery = () => {
|
||||
queryParams.value.pageNum = 1;
|
||||
getList();
|
||||
};
|
||||
|
||||
/** 重置按钮操作 */
|
||||
const resetQuery = () => {
|
||||
queryFormRef.value?.resetFields();
|
||||
handleQuery();
|
||||
};
|
||||
|
||||
/** 多选框选中数据 */
|
||||
const handleSelectionChange = (selection: RecognizeRecordVO[]) => {
|
||||
ids.value = selection.map((item) => item.id);
|
||||
single.value = selection.length != 1;
|
||||
multiple.value = !selection.length;
|
||||
};
|
||||
|
||||
/** 新增按钮操作 */
|
||||
const handleAdd = () => {
|
||||
reset();
|
||||
dialog.visible = true;
|
||||
dialog.title = '添加识别记录';
|
||||
};
|
||||
|
||||
/** 修改按钮操作 */
|
||||
const handleUpdate = async (row?: RecognizeRecordVO) => {
|
||||
reset();
|
||||
const _id = row?.id || ids.value[0];
|
||||
const res = await getRecognizeRecord(_id);
|
||||
Object.assign(form.value, res.data);
|
||||
dialog.visible = true;
|
||||
dialog.title = '修改识别记录';
|
||||
};
|
||||
|
||||
/** 提交按钮 */
|
||||
const submitForm = () => {
|
||||
recognizeRecordFormRef.value?.validate(async (valid: boolean) => {
|
||||
if (valid) {
|
||||
buttonLoading.value = true;
|
||||
if (form.value.id) {
|
||||
await updateRecognizeRecord(form.value).finally(() => (buttonLoading.value = false));
|
||||
} else {
|
||||
await addRecognizeRecord(form.value).finally(() => (buttonLoading.value = false));
|
||||
}
|
||||
proxy?.$modal.msgSuccess('操作成功');
|
||||
dialog.visible = false;
|
||||
await getList();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/** 删除按钮操作 */
|
||||
const handleDelete = async (row?: RecognizeRecordVO) => {
|
||||
const _ids = row?.id || ids.value;
|
||||
await proxy?.$modal.confirm('是否确认删除识别记录编号为"' + _ids + '"的数据项?').finally(() => (loading.value = false));
|
||||
await delRecognizeRecord(_ids);
|
||||
proxy?.$modal.msgSuccess('删除成功');
|
||||
await getList();
|
||||
};
|
||||
|
||||
/** 导出按钮操作 */
|
||||
const handleExport = () => {
|
||||
proxy?.download(
|
||||
'safety/recognizeRecord/export',
|
||||
{
|
||||
...queryParams.value
|
||||
},
|
||||
`recognizeRecord_${new Date().getTime()}.xlsx`
|
||||
);
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
getList();
|
||||
});
|
||||
|
||||
//监听项目id刷新数据
|
||||
const listeningProject = watch(
|
||||
() => currentProject.value?.id,
|
||||
(nid, oid) => {
|
||||
queryParams.value.projectId = nid;
|
||||
getList();
|
||||
}
|
||||
);
|
||||
|
||||
onUnmounted(() => {
|
||||
listeningProject();
|
||||
});
|
||||
</script>
|
||||
@ -0,0 +1,243 @@
|
||||
<template>
|
||||
<!-- <el-card v-loading="loading" body-class="printMe"> -->
|
||||
<div class="w75% m-a">
|
||||
<div id="printMe" class="pos-relative">
|
||||
<div class="resultIcon"><img :src="'../../../../../src/assets/icons/svg/' + inspectionType + '.png'" alt="" /></div>
|
||||
<h2 style="text-align: center; margin-top: 5px; font-weight: bold">安全生产监督检查通知书</h2>
|
||||
<el-row>
|
||||
<el-col :span="12" style="text-align: left">填报人:{{ safetyInspectionDetail?.creatorName }}</el-col>
|
||||
<el-col :span="12" style="text-align: right">填报时间:{{ safetyInspectionDetail?.createTime }}</el-col>
|
||||
</el-row>
|
||||
<el-descriptions :column="2" border style="margin-top: 8px" label-width="160px" size="large">
|
||||
<el-descriptions-item label-align="center" label="检查项目" :span="2" class-name="zebra">{{ currentProject?.name }} </el-descriptions-item>
|
||||
<el-descriptions-item label-align="center" label="检查类型" label-class-name="white">
|
||||
<dict-tag :options="safety_inspection_check_type" :value="safetyInspectionDetail?.checkType" />
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label-align="center" label="违章类型" label-class-name="white">
|
||||
<dict-tag :options="safety_inspection_violation_type" :value="safetyInspectionDetail?.violationType" />
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label-align="center" label="检查时间" class-name="zebra">{{ safetyInspectionDetail?.checkTime }} </el-descriptions-item>
|
||||
<el-descriptions-item label-align="center" label="检查人" class-name="zebra">{{ safetyInspectionDetail?.creatorName }} </el-descriptions-item>
|
||||
<el-descriptions-item label-align="center" label="整改人" label-class-name="white"
|
||||
>{{ safetyInspectionDetail?.correctorName }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label-align="center" label="要求整改期限" label-class-name="white">
|
||||
{{ dayjs(safetyInspectionDetail?.rectificationDeadline).format('YYYY 年 MM 月 DD 日') }}
|
||||
</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
<el-descriptions border direction="vertical" size="large">
|
||||
<el-descriptions-item label-align="center" label="巡检结果" class-name="none"></el-descriptions-item>
|
||||
</el-descriptions>
|
||||
<el-descriptions :column="2" border label-width="160px" size="large">
|
||||
<el-descriptions-item label-align="center" label="内容" :span="2" label-class-name="white"
|
||||
>{{ safetyInspectionDetail?.hiddenDanger }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label-align="center" label="检查附件" :span="2" label-class-name="white">
|
||||
<el-space wrap>
|
||||
<div v-for="item in checkFileList" :key="item.ossId">
|
||||
<span v-if="['.png', '.jpg', '.jpeg'].includes(item.fileSuffix)">
|
||||
<image-preview :src="item.url" width="200px" />
|
||||
</span>
|
||||
<span v-else>
|
||||
<el-link :href="`${item.url}`" type="primary" :underline="false" target="_blank">
|
||||
<span> {{ item.originalName }} </span>
|
||||
</el-link>
|
||||
</span>
|
||||
</div>
|
||||
</el-space>
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label-align="center" label="检查状态" :span="2" label-class-name="white">
|
||||
<el-steps style="max-width: 200px" :active="Number(safetyInspectionDetail?.status)" finish-status="finish">
|
||||
<el-step v-for="item in safety_inspection_type" :key="item.value" :title="item.label" />
|
||||
</el-steps>
|
||||
</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
<el-descriptions border direction="vertical" size="large">
|
||||
<el-descriptions-item label-align="center" label="整改情况" class-name="none"></el-descriptions-item>
|
||||
</el-descriptions>
|
||||
<el-descriptions :column="2" border label-width="160px" size="large">
|
||||
<el-descriptions-item label-align="center" label="班组" label-class-name="white"
|
||||
>{{ safetyInspectionDetail?.teamName }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label-align="center" label="整改日期" label-class-name="white"
|
||||
>{{ safetyInspectionDetail?.rectificationTime }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label-align="center" label="整改措施及完成情况" :span="2" label-class-name="white">
|
||||
{{ safetyInspectionDetail?.measure }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label-align="center" label="整改附件" :span="2" label-class-name="white">
|
||||
<el-space wrap>
|
||||
<div v-for="item in rectificationFileList" :key="item.ossId">
|
||||
<span v-if="['.png', '.jpg', '.jpeg'].includes(item.fileSuffix)">
|
||||
<image-preview :src="item.url" width="200px" />
|
||||
</span>
|
||||
<span v-else>
|
||||
<el-link :href="`${item.url}`" :underline="false" target="_blank">
|
||||
<span> {{ item.originalName }} </span>
|
||||
</el-link>
|
||||
</span>
|
||||
</div>
|
||||
</el-space>
|
||||
</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
<el-descriptions border direction="vertical" size="large">
|
||||
<el-descriptions-item label-align="center" label="复查结果" class-name="none"></el-descriptions-item>
|
||||
</el-descriptions>
|
||||
<el-descriptions :column="2" border label-width="160px" size="large">
|
||||
<el-descriptions-item label-align="center" label="复查人" label-class-name="white"
|
||||
>{{ safetyInspectionDetail?.creatorName }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label-align="center" label="复查日期" label-class-name="white"
|
||||
>{{ safetyInspectionDetail?.reviewTime }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label-align="center" label="复查情况" :span="2" label-class-name="white"
|
||||
>{{ safetyInspectionDetail?.review }}
|
||||
</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- </el-card> -->
|
||||
<div class="dialog-footer">
|
||||
<div class="btn-item" @click="handleExport">
|
||||
<img src="../../../../assets/icons/svg/derived.png" />
|
||||
<span>导出</span>
|
||||
</div>
|
||||
<div class="btn-item" v-print="'#printMe'">
|
||||
<img src="../../../../assets/icons/svg/print.png" />
|
||||
<span>打印</span>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { useUserStoreHook } from '@/store/modules/user';
|
||||
import { SafetyInspectionVO } from '@/api/safety/safetyInspection/types';
|
||||
import { getSafetyInspection } from '@/api/safety/safetyInspection';
|
||||
import { downLoadOss, listByIds } from '@/api/system/oss';
|
||||
import { OssVO } from '@/api/system/oss/types';
|
||||
import { dayjs } from 'element-plus';
|
||||
|
||||
interface Props {
|
||||
safetyInspectionId?: string | number;
|
||||
}
|
||||
|
||||
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
|
||||
const { safety_inspection_violation_type, safety_inspection_type, safety_inspection_check_type } = toRefs<any>(
|
||||
proxy?.useDict('safety_inspection_violation_type', 'review_type', 'reply_type', 'safety_inspection_type', 'safety_inspection_check_type')
|
||||
);
|
||||
// 获取用户 store
|
||||
const userStore = useUserStoreHook();
|
||||
// 从 store 中获取项目列表和当前选中的项目
|
||||
const currentProject = computed(() => userStore.selectedProject);
|
||||
const props = defineProps<Props>();
|
||||
const loading = ref<boolean>(false);
|
||||
const safetyInspectionDetail = ref<SafetyInspectionVO>();
|
||||
const checkFileList = ref<OssVO[]>();
|
||||
const rectificationFileList = ref<OssVO[]>();
|
||||
//检查状态图片
|
||||
const inspectionType = computed(() => {
|
||||
let imgName = 'successLogo';
|
||||
if (safetyInspectionDetail.value?.status == '2') imgName = 'rectification';
|
||||
if (safetyInspectionDetail.value?.reviewType == '1') imgName = 'successful';
|
||||
if (safetyInspectionDetail.value?.reviewType == '2') imgName = 'failure';
|
||||
console.log('🚀 ~ inspectionType ~ imgName:', imgName);
|
||||
|
||||
return imgName;
|
||||
});
|
||||
|
||||
const get = async () => {
|
||||
loading.value = true;
|
||||
const res = await getSafetyInspection(props.safetyInspectionId);
|
||||
if (res.data && res.code === 200) {
|
||||
safetyInspectionDetail.value = res.data;
|
||||
if (res.data.checkFile) {
|
||||
const checkFileRes = await listByIds(res.data.checkFile.split(','));
|
||||
checkFileList.value = checkFileRes.data;
|
||||
}
|
||||
if (res.data.rectificationFile) {
|
||||
const rectificationFileRes = await listByIds(res.data.rectificationFile.split(','));
|
||||
rectificationFileList.value = rectificationFileRes.data;
|
||||
}
|
||||
}
|
||||
loading.value = false;
|
||||
};
|
||||
|
||||
const handleExport = async () => {
|
||||
await downLoadOss({ id: safetyInspectionDetail.value.id }, '/safety/safetyInspection/export/word', '安全生产监督检查通知书.zip');
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
console.log('🚀 ~ onMounted ~ props.safetyInspectionId:', props.safetyInspectionId);
|
||||
get();
|
||||
});
|
||||
|
||||
watch(
|
||||
() => props.safetyInspectionId,
|
||||
(newId, oldId) => {
|
||||
if (newId !== oldId) {
|
||||
checkFileList.value = undefined;
|
||||
rectificationFileList.value = undefined;
|
||||
get();
|
||||
}
|
||||
}
|
||||
);
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
#printMe {
|
||||
padding: 15px 20px 20px 20px !important;
|
||||
box-shadow: 0px 0px 12px rgba(0, 0, 0, 0.12);
|
||||
}
|
||||
|
||||
:deep(.white) {
|
||||
background: #fff !important;
|
||||
}
|
||||
|
||||
:deep(.none) {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
:deep(.zebra) {
|
||||
background: #f5f7fa;
|
||||
}
|
||||
|
||||
@page {
|
||||
size: auto;
|
||||
margin: 0mm;
|
||||
}
|
||||
|
||||
.dialog-footer {
|
||||
height: 200px;
|
||||
display: flex;
|
||||
|
||||
flex-direction: column;
|
||||
justify-content: space-between;
|
||||
position: absolute;
|
||||
top: 14%;
|
||||
right: 6%;
|
||||
background: #fff;
|
||||
box-shadow: 0 0 10px #ddd;
|
||||
text-align: center;
|
||||
padding: 20px 10px;
|
||||
|
||||
.btn-item {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
|
||||
.resultIcon {
|
||||
position: absolute;
|
||||
top: 100px;
|
||||
right: 50px;
|
||||
z-index: 10;
|
||||
width: 105px;
|
||||
height: 105px;
|
||||
img {
|
||||
width: 105px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
420
src/views/safety/safetyInspection/index.vue
Normal file
420
src/views/safety/safetyInspection/index.vue
Normal file
@ -0,0 +1,420 @@
|
||||
<template>
|
||||
<div class="p-2">
|
||||
<transition :enter-active-class="proxy?.animate.searchAnimate.enter" :leave-active-class="proxy?.animate.searchAnimate.leave">
|
||||
<div v-show="showSearch" class="mb-[10px]">
|
||||
<el-card shadow="hover">
|
||||
<el-form ref="queryFormRef" :model="queryParams" :inline="true">
|
||||
<el-form-item label="检查类型" prop="checkType">
|
||||
<el-select v-model="queryParams.checkType" placeholder="全部" clearable>
|
||||
<el-option v-for="dict in safety_inspection_check_type" :key="dict.value" :label="dict.label" :value="dict.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="违章类型" prop="violationType">
|
||||
<el-select v-model="queryParams.violationType" placeholder="全部" clearable>
|
||||
<el-option v-for="dict in safety_inspection_violation_type" :key="dict.value" :label="dict.label" :value="dict.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="处理状态" prop="status">
|
||||
<el-select v-model="queryParams.status" placeholder="全部" clearable>
|
||||
<el-option v-for="dict in safety_inspection_type" :key="dict.value" :label="dict.label" :value="dict.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
|
||||
<el-button icon="Refresh" @click="resetQuery">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-card>
|
||||
</div>
|
||||
</transition>
|
||||
|
||||
<el-card shadow="never">
|
||||
<template #header>
|
||||
<el-row :gutter="10" class="mb8">
|
||||
<el-col :span="1.5">
|
||||
<el-button type="primary" plain icon="Plus" @click="handleAdd" v-hasPermi="['safety:safetyInspection:add']"> 新增 </el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete()" v-hasPermi="['safety:safetyInspection:remove']">
|
||||
删除
|
||||
</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button type="warning" plain icon="Download" @click="handleExport" v-hasPermi="['safety:safetyInspection:export']">导出 </el-button>
|
||||
</el-col>
|
||||
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
|
||||
</el-row>
|
||||
</template>
|
||||
|
||||
<el-table v-loading="loading" :data="safetyInspectionList" @selection-change="handleSelectionChange">
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column label="序号" type="index" width="60" align="center" />
|
||||
<el-table-column label="处理状态" align="center" prop="status">
|
||||
<template #default="scope">
|
||||
<dict-tag :options="safety_inspection_type" :value="scope.row.status" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="检查人" align="center" prop="correctorName" />
|
||||
<el-table-column label="检查时间" align="center" prop="rectificationDeadline" width="180">
|
||||
<template #default="scope">
|
||||
<span>{{ parseTime(scope.row.rectificationDeadline, '{y}-{m}-{d}') }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="检查类型" align="center" prop="checkType">
|
||||
<template #default="scope">
|
||||
<dict-tag :options="safety_inspection_check_type" :value="scope.row.checkType" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="违章类型" align="center" prop="violationType">
|
||||
<template #default="scope">
|
||||
<dict-tag :options="safety_inspection_violation_type" :value="scope.row.violationType" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="巡检结果" align="center" prop="inspectionResult">
|
||||
<template #default="scope">
|
||||
<el-tooltip placement="top" effect="dark">
|
||||
<template #content>
|
||||
<div class="max-w-670px">{{ scope.row.inspectionResult }}</div>
|
||||
</template>
|
||||
<el-text truncated>
|
||||
{{ scope.row.inspectionResult }}
|
||||
</el-text>
|
||||
</el-tooltip>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="整改人" align="center" prop="correctorName" />
|
||||
<el-table-column label="复查状态" align="center" prop="reviewType">
|
||||
<template #default="scope">
|
||||
<dict-tag :options="review_type" :value="scope.row.reviewType" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="备注" align="center" prop="remark" />
|
||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="220">
|
||||
<template #default="scope">
|
||||
<el-space>
|
||||
<el-button link type="primary" icon="View" @click="handleShowDialog(scope.row)" v-hasPermi="['safety:safetyInspection:query']">
|
||||
详情
|
||||
</el-button>
|
||||
<!-- <el-button link type="success" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['safety:safetyInspection:edit']">修改 </el-button> -->
|
||||
<el-button link type="danger" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['safety:safetyInspection:remove']">
|
||||
删除
|
||||
</el-button>
|
||||
</el-space>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" @pagination="getList" />
|
||||
</el-card>
|
||||
<!-- 添加或修改安全巡检工单对话框 -->
|
||||
<el-dialog :title="dialog.title" v-model="dialog.visible" append-to-body>
|
||||
<el-form ref="safetyInspectionFormRef" :model="form" :rules="rules" label-width="120px">
|
||||
<el-form-item label="检查类型" prop="checkType">
|
||||
<el-select v-model="form.checkType" placeholder="请选择检查类型">
|
||||
<el-option v-for="dict in safety_inspection_check_type" :key="dict.value" :label="dict.label" :value="dict.value"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="违章类型" prop="violationType">
|
||||
<el-select v-model="form.violationType" placeholder="请选择违章类型">
|
||||
<el-option v-for="dict in safety_inspection_violation_type" :key="dict.value" :label="dict.label" :value="dict.value"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="巡检结果" prop="inspectionResult">
|
||||
<el-input v-model="form.inspectionResult" placeholder="请输入巡检结果" />
|
||||
</el-form-item>
|
||||
<el-form-item label="工单整改单位" prop="rectificationUnit">
|
||||
<el-select v-model="form.rectificationUnit" placeholder="请选择整改单位类型">
|
||||
<el-option v-for="dict in rectification_unit_type" :key="dict.value" :label="dict.label" :value="dict.value"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="整改班组" prop="teamId">
|
||||
<el-select v-model="form.teamId" placeholder="请选择整改班组">
|
||||
<el-option v-for="item in teamOpt" :key="item.value" :label="item.label" :value="item.value" @click="changeForeman(item.value)" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="整改人" prop="correctorId">
|
||||
<el-select v-model="form.correctorId" placeholder="请选择整改人" :disabled="!form.teamId">
|
||||
<el-option v-for="item in foremanOpt" :key="item.value" :label="item.label" :value="item.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="问题隐患" prop="hiddenDanger">
|
||||
<el-input v-model="form.hiddenDanger" type="textarea" placeholder="请输入内容" />
|
||||
</el-form-item>
|
||||
<el-form-item label="整改措施" prop="measure">
|
||||
<el-input v-model="form.measure" type="textarea" placeholder="请输入内容" />
|
||||
</el-form-item>
|
||||
<el-form-item label="要求整改期限" prop="checkTime">
|
||||
<el-date-picker clearable v-model="form.rectificationDeadline" type="date" value-format="YYYY-MM-DD" placeholder="选择要求整改期限" />
|
||||
</el-form-item>
|
||||
<el-form-item label="检查附件" prop="checkFile">
|
||||
<file-upload v-model="form.checkFile" :file-size="20" :file-type="['doc', 'docx', 'pdf', 'png', 'jpg', 'jpeg']" />
|
||||
</el-form-item>
|
||||
<el-form-item label="整改附件" prop="rectificationFile">
|
||||
<file-upload v-model="form.rectificationFile" :file-size="20" :file-type="['doc', 'docx', 'pdf', 'png', 'jpg', 'jpeg']" />
|
||||
</el-form-item>
|
||||
<el-form-item label="备注" prop="remark">
|
||||
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<el-button :loading="buttonLoading" type="primary" @click="submitForm">确 定</el-button>
|
||||
<el-button @click="cancel">取 消</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
<el-dialog title="巡检工单详情" v-model="showDetailDialog" width="60vw">
|
||||
<safety-inspection-detail-dialog :safety-inspection-id="currentSafetyInspectionId" />
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup name="SafetyInspection" lang="ts">
|
||||
import {
|
||||
addSafetyInspection,
|
||||
delSafetyInspection,
|
||||
getSafetyInspection,
|
||||
listSafetyInspection,
|
||||
updateSafetyInspection
|
||||
} from '@/api/safety/safetyInspection';
|
||||
import { SafetyInspectionForm, SafetyInspectionQuery, SafetyInspectionVO } from '@/api/safety/safetyInspection/types';
|
||||
import { useUserStoreHook } from '@/store/modules/user';
|
||||
import SafetyInspectionDetailDialog from '@/views/safety/safetyInspection/component/SafetyInspectionDetailDialog.vue';
|
||||
import { listProjectTeamForeman } from '@/api/project/projectTeam';
|
||||
import { foremanQuery, ProjectTeamForemanResp } from '@/api/project/projectTeam/types';
|
||||
|
||||
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
|
||||
const { rectification_unit_type, safety_inspection_violation_type, review_type, safety_inspection_type, safety_inspection_check_type } = toRefs<any>(
|
||||
proxy?.useDict(
|
||||
'rectification_unit_type',
|
||||
'safety_inspection_violation_type',
|
||||
'review_type',
|
||||
'safety_inspection_type',
|
||||
'safety_inspection_check_type'
|
||||
)
|
||||
);
|
||||
// 获取用户 store
|
||||
const userStore = useUserStoreHook();
|
||||
// 从 store 中获取项目列表和当前选中的项目
|
||||
const currentProject = computed(() => userStore.selectedProject);
|
||||
const safetyInspectionList = ref<SafetyInspectionVO[]>([]);
|
||||
const buttonLoading = ref(false);
|
||||
const loading = ref(true);
|
||||
const showSearch = ref(true);
|
||||
const ids = ref<Array<string | number>>([]);
|
||||
const single = ref(true);
|
||||
const multiple = ref(true);
|
||||
const total = ref(0);
|
||||
|
||||
const queryFormRef = ref<ElFormInstance>();
|
||||
const safetyInspectionFormRef = ref<ElFormInstance>();
|
||||
|
||||
const dialog = reactive<DialogOption>({
|
||||
visible: false,
|
||||
title: ''
|
||||
});
|
||||
|
||||
const initFormData: SafetyInspectionForm = {
|
||||
id: undefined,
|
||||
pid: undefined,
|
||||
projectId: currentProject.value?.id,
|
||||
checkType: undefined,
|
||||
violationType: undefined,
|
||||
inspectionResult: undefined,
|
||||
teamId: undefined,
|
||||
correctorId: undefined,
|
||||
rectificationDeadline: undefined,
|
||||
isReply: undefined,
|
||||
replyDate: undefined,
|
||||
status: undefined,
|
||||
hiddenDanger: undefined,
|
||||
measure: undefined,
|
||||
review: undefined,
|
||||
reviewType: undefined,
|
||||
checkTime: undefined,
|
||||
rectificationTime: undefined,
|
||||
rectificationUnit: undefined,
|
||||
|
||||
reviewTime: undefined,
|
||||
checkFile: undefined,
|
||||
rectificationFile: undefined,
|
||||
remark: undefined
|
||||
};
|
||||
const data = reactive<PageData<SafetyInspectionForm, SafetyInspectionQuery>>({
|
||||
form: { ...initFormData },
|
||||
queryParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
id: undefined,
|
||||
pid: undefined,
|
||||
projectId: currentProject.value?.id,
|
||||
checkType: undefined,
|
||||
violationType: undefined,
|
||||
inspectionResult: undefined,
|
||||
teamId: undefined,
|
||||
correctorId: undefined,
|
||||
isReply: undefined,
|
||||
replyDate: undefined,
|
||||
status: undefined,
|
||||
hiddenDanger: undefined,
|
||||
measure: undefined,
|
||||
review: undefined,
|
||||
reviewType: undefined,
|
||||
checkTime: undefined,
|
||||
rectificationTime: undefined,
|
||||
reviewTime: undefined,
|
||||
remark: undefined,
|
||||
params: {}
|
||||
},
|
||||
rules: {
|
||||
id: [{ required: true, message: '主键ID不能为空', trigger: 'blur' }],
|
||||
projectId: [{ required: true, message: '项目ID不能为空', trigger: 'blur' }],
|
||||
checkType: [{ required: true, message: '检查类型不能为空', trigger: 'blur' }],
|
||||
violationType: [{ required: true, message: '违章类型不能为空', trigger: 'blur' }]
|
||||
}
|
||||
});
|
||||
|
||||
const { queryParams, form, rules } = toRefs(data);
|
||||
|
||||
const teamOpt = ref([]);
|
||||
const foremanOpt = ref([]);
|
||||
const teamList = ref<ProjectTeamForemanResp[]>();
|
||||
/** 查询安全巡检工单列表 */
|
||||
const getList = async () => {
|
||||
loading.value = true;
|
||||
const res = await listSafetyInspection(queryParams.value);
|
||||
safetyInspectionList.value = res.rows;
|
||||
total.value = res.total;
|
||||
// 获取项目班组信息
|
||||
const teamRes = await listProjectTeamForeman(currentProject.value?.id);
|
||||
teamList.value = teamRes.data;
|
||||
teamOpt.value = teamList.value.map((team: ProjectTeamForemanResp) => ({
|
||||
label: team.teamName,
|
||||
value: team.id
|
||||
}));
|
||||
|
||||
loading.value = false;
|
||||
};
|
||||
|
||||
const changeForeman = (value: string | number) => {
|
||||
const team = teamList.value.filter((team) => team.id === value)[0];
|
||||
foremanOpt.value = team.foremanList?.map((foreman: foremanQuery) => ({
|
||||
label: foreman.foremanName,
|
||||
value: foreman.foremanId
|
||||
}));
|
||||
form.value.correctorId = '';
|
||||
};
|
||||
|
||||
/** 展开安全巡检工单详情对话框操作 */
|
||||
const currentSafetyInspectionId = ref<string | number>();
|
||||
const showDetailDialog = ref<boolean>(false);
|
||||
const handleShowDialog = (row?: SafetyInspectionVO) => {
|
||||
currentSafetyInspectionId.value = row.id;
|
||||
|
||||
showDetailDialog.value = true;
|
||||
};
|
||||
|
||||
/** 取消按钮 */
|
||||
const cancel = () => {
|
||||
reset();
|
||||
dialog.visible = false;
|
||||
};
|
||||
|
||||
/** 表单重置 */
|
||||
const reset = () => {
|
||||
form.value = { ...initFormData };
|
||||
safetyInspectionFormRef.value?.resetFields();
|
||||
};
|
||||
|
||||
/** 搜索按钮操作 */
|
||||
const handleQuery = () => {
|
||||
queryParams.value.pageNum = 1;
|
||||
getList();
|
||||
};
|
||||
|
||||
/** 重置按钮操作 */
|
||||
const resetQuery = () => {
|
||||
queryFormRef.value?.resetFields();
|
||||
handleQuery();
|
||||
};
|
||||
|
||||
/** 多选框选中数据 */
|
||||
const handleSelectionChange = (selection: SafetyInspectionVO[]) => {
|
||||
ids.value = selection.map((item) => item.id);
|
||||
single.value = selection.length != 1;
|
||||
multiple.value = !selection.length;
|
||||
};
|
||||
|
||||
/** 新增按钮操作 */
|
||||
const handleAdd = () => {
|
||||
reset();
|
||||
dialog.visible = true;
|
||||
dialog.title = '添加安全巡检工单';
|
||||
};
|
||||
|
||||
/** 修改按钮操作 */
|
||||
const handleUpdate = async (row?: SafetyInspectionVO) => {
|
||||
reset();
|
||||
const _id = row?.id || ids.value[0];
|
||||
const res = await getSafetyInspection(_id);
|
||||
Object.assign(form.value, res.data);
|
||||
dialog.visible = true;
|
||||
dialog.title = '修改安全巡检工单';
|
||||
};
|
||||
|
||||
/** 提交按钮 */
|
||||
const submitForm = () => {
|
||||
safetyInspectionFormRef.value?.validate(async (valid: boolean) => {
|
||||
if (valid) {
|
||||
buttonLoading.value = true;
|
||||
form.value.projectId = currentProject.value?.id;
|
||||
if (form.value.id) {
|
||||
await updateSafetyInspection(form.value).finally(() => (buttonLoading.value = false));
|
||||
} else {
|
||||
await addSafetyInspection(form.value).finally(() => (buttonLoading.value = false));
|
||||
}
|
||||
proxy?.$modal.msgSuccess('操作成功');
|
||||
dialog.visible = false;
|
||||
await getList();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/** 删除按钮操作 */
|
||||
const handleDelete = async (row?: SafetyInspectionVO) => {
|
||||
const _ids = row?.id || ids.value;
|
||||
await proxy?.$modal.confirm('是否确认删除安全巡检工单编号为"' + _ids + '"的数据项?').finally(() => (loading.value = false));
|
||||
await delSafetyInspection(_ids);
|
||||
proxy?.$modal.msgSuccess('删除成功');
|
||||
await getList();
|
||||
};
|
||||
|
||||
/** 导出按钮操作 */
|
||||
const handleExport = () => {
|
||||
proxy?.download(
|
||||
'safety/safetyInspection/export',
|
||||
{
|
||||
...queryParams.value
|
||||
},
|
||||
`safetyInspection_${new Date().getTime()}.xlsx`
|
||||
);
|
||||
};
|
||||
|
||||
//监听项目id刷新数据
|
||||
const listeningProject = watch(
|
||||
() => currentProject.value?.id,
|
||||
(nid, oid) => {
|
||||
queryParams.value.projectId = nid;
|
||||
form.value.projectId = nid;
|
||||
getList();
|
||||
}
|
||||
);
|
||||
|
||||
onUnmounted(() => {
|
||||
listeningProject();
|
||||
});
|
||||
|
||||
onMounted(() => {
|
||||
getList();
|
||||
});
|
||||
</script>
|
||||
103
src/views/safety/safetyLog/component/SafetyLogDetailDialog.vue
Normal file
103
src/views/safety/safetyLog/component/SafetyLogDetailDialog.vue
Normal file
@ -0,0 +1,103 @@
|
||||
<template>
|
||||
<el-card v-loading="loading">
|
||||
<h2 style="text-align: center; margin-top: 5px; font-weight: bold">安全日志</h2>
|
||||
<el-row>
|
||||
<el-col :span="12" style="text-align: left">记录人:{{ safetyLogDetail?.creator?.name }}</el-col>
|
||||
<el-col :span="12" style="text-align: right">记录时间:{{ safetyLogDetail?.createTime }}</el-col>
|
||||
</el-row>
|
||||
<el-descriptions :column="3" border style="margin-top: 8px">
|
||||
<el-descriptions-item label-align="center" width="160px" label="项目名称" :span="3">{{ currentProject?.name }} </el-descriptions-item>
|
||||
<el-descriptions-item label-align="center" label="发生日期">{{ safetyLogDetail?.dateOfOccurrence }} </el-descriptions-item>
|
||||
<el-descriptions-item label-align="center" label="气温">
|
||||
<span>最高:{{ safetyLogDetail?.airTemperatureMax }}(℃)</span>
|
||||
<span>最低:{{ safetyLogDetail?.airTemperatureMin }}(℃)</span>
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label-align="center" label="气候">
|
||||
<dict-tag :value="safetyLogDetail?.weather" :options="weather_type" />
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label-align="center" label="工程施工部位及施工进展情况" :span="3">
|
||||
{{ safetyLogDetail?.progress }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label-align="center" label="当日主要危险性项目作业内容" :span="3">
|
||||
{{ safetyLogDetail?.jobContent }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label-align="center" label="施工项目安全教育与安全交底情况" :span="3">
|
||||
{{ safetyLogDetail?.discloseCondition }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label-align="center" label="施工作业队伍班前施工安全活动情况" :span="3">
|
||||
{{ safetyLogDetail?.activityCondition }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label-align="center" label="现场施工安全巡视与检查情况" :span="3">
|
||||
{{ safetyLogDetail?.examineCondition }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label-align="center" label="季节施工防寒、防暑等措施实施情况" :span="3">
|
||||
{{ safetyLogDetail?.implementCondition }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label-align="center" label="监理通知有关部门安全检查情况" :span="3">
|
||||
{{ safetyLogDetail?.safetyInspectionCondition }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label-align="center" label="停工、加班情况" :span="3">{{ safetyLogDetail?.stoppageOrOvertime }} </el-descriptions-item>
|
||||
<el-descriptions-item label-align="center" label="其他应记录的安全与文明施工事项" :span="3">
|
||||
{{ safetyLogDetail?.otherCondition }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label-align="center" label="附件" :span="3">
|
||||
<el-space direction="vertical">
|
||||
<el-link v-for="item in fileList" :key="item.ossId" :href="`${item.url}`" type="primary" :underline="false" target="_blank">
|
||||
<span> {{ item.originalName }} </span>
|
||||
</el-link>
|
||||
</el-space>
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label-align="center" label="备注" :span="3">{{ safetyLogDetail?.remark }} </el-descriptions-item>
|
||||
</el-descriptions>
|
||||
</el-card>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { SafetyLogVO } from '@/api/safety/safetyLog/types';
|
||||
import { getSafetyLog } from '@/api/safety/safetyLog';
|
||||
import { useUserStoreHook } from '@/store/modules/user';
|
||||
import { listByIds } from '@/api/system/oss';
|
||||
import { OssVO } from '@/api/system/oss/types';
|
||||
|
||||
interface Props {
|
||||
safetyLogId?: string | number;
|
||||
}
|
||||
|
||||
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
|
||||
const { weather_type } = toRefs<any>(proxy?.useDict('weather_type'));
|
||||
|
||||
// 获取用户 store
|
||||
const userStore = useUserStoreHook();
|
||||
// 从 store 中获取项目列表和当前选中的项目
|
||||
const currentProject = computed(() => userStore.selectedProject);
|
||||
const props = defineProps<Props>();
|
||||
const loading = ref<boolean>(false);
|
||||
const safetyLogDetail = ref<SafetyLogVO>();
|
||||
const fileList = ref<Array<OssVO>>([]);
|
||||
const get = async () => {
|
||||
loading.value = true;
|
||||
const res = await getSafetyLog(props.safetyLogId);
|
||||
if (res.data && res.code === 200) {
|
||||
safetyLogDetail.value = res.data;
|
||||
if (res.data.fileId) {
|
||||
const fileRes = await listByIds(res.data.fileId.split(','));
|
||||
fileList.value = fileRes.data;
|
||||
}
|
||||
}
|
||||
loading.value = false;
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
get();
|
||||
});
|
||||
|
||||
watch(
|
||||
() => props.safetyLogId,
|
||||
(newId, oldId) => {
|
||||
if (newId !== oldId) {
|
||||
fileList.value = undefined;
|
||||
get();
|
||||
}
|
||||
}
|
||||
);
|
||||
</script>
|
||||
337
src/views/safety/safetyLog/index.vue
Normal file
337
src/views/safety/safetyLog/index.vue
Normal file
@ -0,0 +1,337 @@
|
||||
<template>
|
||||
<div class="p-2">
|
||||
<transition :enter-active-class="proxy?.animate.searchAnimate.enter" :leave-active-class="proxy?.animate.searchAnimate.leave">
|
||||
<div v-show="showSearch" class="mb-[10px]">
|
||||
<el-card shadow="hover">
|
||||
<el-form ref="queryFormRef" :model="queryParams" :inline="true">
|
||||
<el-form-item label="发生日期" prop="dateOfOccurrence">
|
||||
<el-date-picker clearable v-model="queryParams.dateOfOccurrence" type="date" value-format="YYYY-MM-DD" placeholder="请选择发生日期" />
|
||||
</el-form-item>
|
||||
<el-form-item label="录入人" prop="creatorName">
|
||||
<el-input clearable v-model="queryParams.creatorName" placeholder="请输入录入人" />
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
|
||||
<el-button icon="Refresh" @click="resetQuery">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-card>
|
||||
</div>
|
||||
</transition>
|
||||
|
||||
<el-card shadow="never">
|
||||
<template #header>
|
||||
<el-row :gutter="10" class="mb8">
|
||||
<el-col :span="1.5">
|
||||
<el-button type="primary" plain icon="Plus" @click="handleAdd" v-hasPermi="['safety:safetyLog:add']">新增 </el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete()" v-hasPermi="['safety:safetyLog:remove']">
|
||||
批量删除
|
||||
</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button type="warning" plain icon="Download" @click="handleExport" v-hasPermi="['safety:safetyLog:export']">导出 </el-button>
|
||||
</el-col>
|
||||
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
|
||||
</el-row>
|
||||
</template>
|
||||
|
||||
<el-table v-loading="loading" :data="safetyLogList" @selection-change="handleSelectionChange">
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column label="序号" type="index" width="60" align="center" />
|
||||
<el-table-column label="日志名称" align="center">
|
||||
<template #default="scope">
|
||||
<span>{{ dayjs(scope.row.dateOfOccurrence).format('YYYY 年 MM 月 DD 日') }}安全日志</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="发生日期" align="center" prop="dateOfOccurrence" width="180">
|
||||
<template #default="scope">
|
||||
<span>{{ parseTime(scope.row.dateOfOccurrence, '{y}-{m}-{d}') }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="录入时间" align="center" prop="createTime" />
|
||||
<el-table-column label="录入人" align="center" prop="creatorName" />
|
||||
<el-table-column label="备注" align="center" prop="remark" />
|
||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||
<template #default="scope">
|
||||
<el-space>
|
||||
<el-button link type="primary" icon="View" @click="handleShowDialog(scope.row)" v-hasPermi="['safety:safetyLog:query']">
|
||||
详情
|
||||
</el-button>
|
||||
<!-- <el-button link type="success" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['safety:safetyLog:edit']"> 修改 </el-button> -->
|
||||
<el-button link type="danger" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['safety:safetyLog:remove']"> 删除 </el-button>
|
||||
</el-space>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" @pagination="getList" />
|
||||
</el-card>
|
||||
<!-- 添加或修改安全日志对话框 -->
|
||||
<el-dialog :title="dialog.title" v-model="dialog.visible" width="950px" append-to-body>
|
||||
<el-form ref="safetyLogFormRef" :model="form" :rules="rules" label-width="250px">
|
||||
<el-form-item label="发生日期" prop="dateOfOccurrence">
|
||||
<el-date-picker clearable v-model="form.dateOfOccurrence" type="date" value-format="YYYY-MM-DD" placeholder="请选择发生日期">
|
||||
</el-date-picker>
|
||||
</el-form-item>
|
||||
<el-form-item label="最高气温" prop="airTemperatureMax">
|
||||
<el-input v-model="form.airTemperatureMax" placeholder="请输入最高气温" />
|
||||
</el-form-item>
|
||||
<el-form-item label="最低气温" prop="airTemperatureMin">
|
||||
<el-input v-model="form.airTemperatureMin" placeholder="请输入最低气温" />
|
||||
</el-form-item>
|
||||
<el-form-item label="气候" prop="weather">
|
||||
<el-select v-model="form.weather" placeholder="请选择气候">
|
||||
<el-option v-for="dict in weather_type" :key="dict.value" :label="dict.label" :value="dict.value"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="工程施工部位及施工进展情况" prop="progress">
|
||||
<el-input v-model="form.progress" type="textarea" placeholder="请输入内容" />
|
||||
</el-form-item>
|
||||
<el-form-item label="当日主要危险性项目作业内容">
|
||||
<editor v-model="form.jobContent" :min-height="192" />
|
||||
</el-form-item>
|
||||
<el-form-item label="施工项目安全教育与安全交底情况">
|
||||
<editor v-model="form.discloseCondition" :min-height="192" />
|
||||
</el-form-item>
|
||||
<el-form-item label="施工作业队伍班前施工安全活动情况">
|
||||
<editor v-model="form.activityCondition" :min-height="192" />
|
||||
</el-form-item>
|
||||
<el-form-item label="现场施工安全巡视与检查情况">
|
||||
<editor v-model="form.examineCondition" :min-height="192" />
|
||||
</el-form-item>
|
||||
<el-form-item label="季节施工防寒、防暑等措施实施情况">
|
||||
<editor v-model="form.implementCondition" :min-height="192" />
|
||||
</el-form-item>
|
||||
<el-form-item label="监理通知有关部门安全检查情况">
|
||||
<editor v-model="form.safetyInspectionCondition" :min-height="192" />
|
||||
</el-form-item>
|
||||
<el-form-item label="停工、加班情况">
|
||||
<editor v-model="form.stoppageOrOvertime" :min-height="192" />
|
||||
</el-form-item>
|
||||
<el-form-item label="其他应记录的安全与文明施工事项">
|
||||
<editor v-model="form.otherCondition" :min-height="192" />
|
||||
</el-form-item>
|
||||
<el-form-item label="附件" prop="fileId">
|
||||
<file-upload v-model="form.fileId" />
|
||||
</el-form-item>
|
||||
<el-form-item label="备注" prop="remark">
|
||||
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<el-button :loading="buttonLoading" type="primary" @click="submitForm">确 定</el-button>
|
||||
<el-button @click="cancel">取 消</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
<el-dialog title="安全日志详情" v-model="showDetailDialog">
|
||||
<safety-log-detail-dialog :safety-log-id="currentSafetyLogId" />
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup name="SafetyLog" lang="ts">
|
||||
import { addSafetyLog, delSafetyLog, getSafetyLog, listSafetyLog, updateSafetyLog } from '@/api/safety/safetyLog';
|
||||
import { SafetyLogForm, SafetyLogQuery, SafetyLogVO } from '@/api/safety/safetyLog/types';
|
||||
import { useUserStoreHook } from '@/store/modules/user';
|
||||
import { dayjs } from 'element-plus';
|
||||
|
||||
import SafetyLogDetailDialog from '@/views/safety/safetyLog/component/SafetyLogDetailDialog.vue';
|
||||
|
||||
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
|
||||
const { weather_type } = toRefs<any>(proxy?.useDict('weather_type'));
|
||||
// 获取用户 store
|
||||
const userStore = useUserStoreHook();
|
||||
// 从 store 中获取项目列表和当前选中的项目
|
||||
const currentProject = computed(() => userStore.selectedProject);
|
||||
const safetyLogList = ref<SafetyLogVO[]>([]);
|
||||
const buttonLoading = ref(false);
|
||||
const loading = ref(true);
|
||||
const showSearch = ref(true);
|
||||
const ids = ref<Array<string | number>>([]);
|
||||
const single = ref(true);
|
||||
const multiple = ref(true);
|
||||
const total = ref(0);
|
||||
const queryFormRef = ref<ElFormInstance>();
|
||||
const safetyLogFormRef = ref<ElFormInstance>();
|
||||
|
||||
const dialog = reactive<DialogOption>({
|
||||
visible: false,
|
||||
title: ''
|
||||
});
|
||||
|
||||
const initFormData: SafetyLogForm = {
|
||||
id: undefined,
|
||||
projectId: currentProject.value?.id,
|
||||
dateOfOccurrence: undefined,
|
||||
airTemperatureMax: undefined,
|
||||
airTemperatureMin: undefined,
|
||||
weather: undefined,
|
||||
progress: undefined,
|
||||
jobContent: undefined,
|
||||
discloseCondition: undefined,
|
||||
activityCondition: undefined,
|
||||
examineCondition: undefined,
|
||||
implementCondition: undefined,
|
||||
safetyInspectionCondition: undefined,
|
||||
stoppageOrOvertime: undefined,
|
||||
otherCondition: undefined,
|
||||
fileId: undefined,
|
||||
creatorName: undefined,
|
||||
remark: undefined
|
||||
};
|
||||
const data = reactive<PageData<SafetyLogForm, SafetyLogQuery>>({
|
||||
form: { ...initFormData },
|
||||
queryParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
projectId: currentProject.value?.id,
|
||||
dateOfOccurrence: undefined,
|
||||
airTemperatureMax: undefined,
|
||||
airTemperatureMin: undefined,
|
||||
weather: undefined,
|
||||
progress: undefined,
|
||||
jobContent: undefined,
|
||||
discloseCondition: undefined,
|
||||
activityCondition: undefined,
|
||||
examineCondition: undefined,
|
||||
implementCondition: undefined,
|
||||
safetyInspectionCondition: undefined,
|
||||
stoppageOrOvertime: undefined,
|
||||
otherCondition: undefined,
|
||||
remark: undefined,
|
||||
creatorName: undefined,
|
||||
params: {}
|
||||
},
|
||||
rules: {
|
||||
id: [{ required: true, message: '主键id不能为空', trigger: 'blur' }],
|
||||
projectId: [{ required: true, message: '项目id不能为空', trigger: 'blur' }]
|
||||
}
|
||||
});
|
||||
|
||||
const { queryParams, form, rules } = toRefs(data);
|
||||
|
||||
/** 查询安全日志列表 */
|
||||
const getList = async () => {
|
||||
loading.value = true;
|
||||
const res = await listSafetyLog(queryParams.value);
|
||||
safetyLogList.value = res.rows;
|
||||
total.value = res.total;
|
||||
loading.value = false;
|
||||
};
|
||||
|
||||
/** 取消按钮 */
|
||||
const cancel = () => {
|
||||
reset();
|
||||
dialog.visible = false;
|
||||
};
|
||||
|
||||
/** 表单重置 */
|
||||
const reset = () => {
|
||||
form.value = { ...initFormData };
|
||||
safetyLogFormRef.value?.resetFields();
|
||||
};
|
||||
|
||||
/** 搜索按钮操作 */
|
||||
const handleQuery = () => {
|
||||
queryParams.value.pageNum = 1;
|
||||
getList();
|
||||
};
|
||||
|
||||
/** 重置按钮操作 */
|
||||
const resetQuery = () => {
|
||||
queryFormRef.value?.resetFields();
|
||||
handleQuery();
|
||||
};
|
||||
|
||||
/** 多选框选中数据 */
|
||||
const handleSelectionChange = (selection: SafetyLogVO[]) => {
|
||||
ids.value = selection.map((item) => item.id);
|
||||
single.value = selection.length != 1;
|
||||
multiple.value = !selection.length;
|
||||
};
|
||||
|
||||
/** 展开安全日志详情对话框操作 */
|
||||
const currentSafetyLogId = ref<string | number>();
|
||||
const showDetailDialog = ref<boolean>(false);
|
||||
const handleShowDialog = (row?: SafetyLogVO) => {
|
||||
currentSafetyLogId.value = row.id;
|
||||
showDetailDialog.value = true;
|
||||
};
|
||||
|
||||
/** 新增按钮操作 */
|
||||
const handleAdd = () => {
|
||||
reset();
|
||||
dialog.visible = true;
|
||||
dialog.title = '添加安全日志';
|
||||
};
|
||||
|
||||
/** 修改按钮操作 */
|
||||
const handleUpdate = async (row?: SafetyLogVO) => {
|
||||
reset();
|
||||
const _id = row?.id || ids.value[0];
|
||||
const res = await getSafetyLog(_id);
|
||||
Object.assign(form.value, res.data);
|
||||
dialog.visible = true;
|
||||
dialog.title = '修改安全日志';
|
||||
};
|
||||
|
||||
/** 提交按钮 */
|
||||
const submitForm = () => {
|
||||
safetyLogFormRef.value?.validate(async (valid: boolean) => {
|
||||
if (valid) {
|
||||
buttonLoading.value = true;
|
||||
form.value.projectId = currentProject.value?.id;
|
||||
if (form.value.id) {
|
||||
await updateSafetyLog(form.value).finally(() => (buttonLoading.value = false));
|
||||
} else {
|
||||
await addSafetyLog(form.value).finally(() => (buttonLoading.value = false));
|
||||
}
|
||||
proxy?.$modal.msgSuccess('操作成功');
|
||||
dialog.visible = false;
|
||||
await getList();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/** 删除按钮操作 */
|
||||
const handleDelete = async (row?: SafetyLogVO) => {
|
||||
const _ids = row?.id || ids.value;
|
||||
await proxy?.$modal.confirm('是否确认删除安全日志编号为"' + _ids + '"的数据项?').finally(() => (loading.value = false));
|
||||
await delSafetyLog(_ids);
|
||||
proxy?.$modal.msgSuccess('删除成功');
|
||||
await getList();
|
||||
};
|
||||
|
||||
/** 导出按钮操作 */
|
||||
const handleExport = () => {
|
||||
proxy?.download(
|
||||
'safety/safetyLog/export',
|
||||
{
|
||||
...queryParams.value
|
||||
},
|
||||
`safetyLog_${new Date().getTime()}.xlsx`
|
||||
);
|
||||
};
|
||||
|
||||
//监听项目id刷新数据
|
||||
const listeningProject = watch(
|
||||
() => currentProject.value?.id,
|
||||
(nid, oid) => {
|
||||
queryParams.value.projectId = nid;
|
||||
form.value.projectId = nid;
|
||||
getList();
|
||||
}
|
||||
);
|
||||
|
||||
onUnmounted(() => {
|
||||
listeningProject();
|
||||
});
|
||||
|
||||
onMounted(() => {
|
||||
getList();
|
||||
});
|
||||
</script>
|
||||
284
src/views/safety/safetyWeeklyReport/index.vue
Normal file
284
src/views/safety/safetyWeeklyReport/index.vue
Normal file
@ -0,0 +1,284 @@
|
||||
<template>
|
||||
<div class="p-2">
|
||||
<transition :enter-active-class="proxy?.animate.searchAnimate.enter" :leave-active-class="proxy?.animate.searchAnimate.leave">
|
||||
<div v-show="showSearch" class="mb-[10px]">
|
||||
<el-card shadow="hover">
|
||||
<el-form ref="queryFormRef" :model="queryParams" :inline="true">
|
||||
<el-form-item label="周期范围" prop="scope">
|
||||
<el-date-picker
|
||||
clearable
|
||||
v-model="queryParams.scopeDate"
|
||||
format="YYYY-MM-DD"
|
||||
value-format="YYYY-MM-DD"
|
||||
type="daterange"
|
||||
range-separator="至"
|
||||
start-placeholder="开始时间"
|
||||
end-placeholder="结束时间"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
|
||||
<el-button icon="Refresh" @click="resetQuery">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-card>
|
||||
</div>
|
||||
</transition>
|
||||
|
||||
<el-card shadow="never">
|
||||
<template #header>
|
||||
<el-row :gutter="10" class="mb8">
|
||||
<el-col :span="1.5">
|
||||
<el-button type="primary" plain icon="Plus" @click="handleAdd" v-hasPermi="['safety:safetyWeeklyReport:add']">新增 </el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="danger"
|
||||
plain
|
||||
icon="Delete"
|
||||
:disabled="multiple"
|
||||
@click="handleDelete()"
|
||||
v-hasPermi="['safety:safetyWeeklyReport:remove']"
|
||||
>
|
||||
批量删除
|
||||
</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button type="warning" plain icon="Download" @click="handleExport" v-hasPermi="['safety:safetyWeeklyReport:export']">导出 </el-button>
|
||||
</el-col>
|
||||
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
|
||||
</el-row>
|
||||
</template>
|
||||
|
||||
<el-table v-loading="loading" :data="safetyWeeklyReportList" @selection-change="handleSelectionChange">
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column label="序号" type="index" width="60" align="center" />
|
||||
<el-table-column label="周期" align="center" prop="week" />
|
||||
<el-table-column label="周期范围" align="center" prop="scope" width="260">
|
||||
<template #default="scope">
|
||||
<span>{{ parseTime(scope.row.scope, '{y}-{m}-{d}') }} 至 {{ parseTime(scope.row.scopeEnd, '{y}-{m}-{d}') }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="创建时间" align="center" prop="createTime" />
|
||||
<el-table-column label="备注" align="center" prop="remark" />
|
||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||
<template #default="scope">
|
||||
<el-space>
|
||||
<el-button link type="success" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['safety:safetyWeeklyReport:edit']">
|
||||
修改
|
||||
</el-button>
|
||||
<el-button link type="danger" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['safety:safetyWeeklyReport:remove']">
|
||||
删除
|
||||
</el-button>
|
||||
</el-space>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" @pagination="getList" />
|
||||
</el-card>
|
||||
<!-- 添加或修改安全周报对话框 -->
|
||||
<el-dialog :title="dialog.title" v-model="dialog.visible" width="500px" append-to-body>
|
||||
<el-form ref="safetyWeeklyReportFormRef" :model="form" :rules="rules" label-width="120px">
|
||||
<el-form-item label="周期" prop="week">
|
||||
<el-input v-model="form.week" placeholder="请输入周期" />
|
||||
</el-form-item>
|
||||
<el-form-item label="周期开始范围" prop="scope">
|
||||
<el-date-picker clearable v-model="form.scope" type="date" value-format="YYYY-MM-DD" placeholder="请选择周期范围" />
|
||||
</el-form-item>
|
||||
<el-form-item label="周期范围结束" prop="scopeEnd">
|
||||
<el-date-picker clearable v-model="form.scopeEnd" type="date" value-format="YYYY-MM-DD" placeholder="请选择周期范围结束" />
|
||||
</el-form-item>
|
||||
<el-form-item label="文件位置" prop="path">
|
||||
<div><file-upload v-model="form.path" :file-size="20" :limit="1" :file-type="['doc', 'docx']" /></div>
|
||||
</el-form-item>
|
||||
<el-form-item label="备注" prop="remark">
|
||||
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<el-button :loading="buttonLoading" type="primary" @click="submitForm">确 定</el-button>
|
||||
<el-button @click="cancel">取 消</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup name="SafetyWeeklyReport" lang="ts">
|
||||
import {
|
||||
addSafetyWeeklyReport,
|
||||
delSafetyWeeklyReport,
|
||||
getSafetyWeeklyReport,
|
||||
listSafetyWeeklyReport,
|
||||
updateSafetyWeeklyReport
|
||||
} from '@/api/safety/safetyWeeklyReport';
|
||||
import { SafetyWeeklyReportForm, SafetyWeeklyReportQuery, SafetyWeeklyReportVO } from '@/api/safety/safetyWeeklyReport/types';
|
||||
import { useUserStoreHook } from '@/store/modules/user';
|
||||
|
||||
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
|
||||
|
||||
// 获取用户 store
|
||||
const userStore = useUserStoreHook();
|
||||
// 从 store 中获取项目列表和当前选中的项目
|
||||
const currentProject = computed(() => userStore.selectedProject);
|
||||
const safetyWeeklyReportList = ref<SafetyWeeklyReportVO[]>([]);
|
||||
const buttonLoading = ref(false);
|
||||
const loading = ref(true);
|
||||
const showSearch = ref(true);
|
||||
const ids = ref<Array<string | number>>([]);
|
||||
const single = ref(true);
|
||||
const multiple = ref(true);
|
||||
const total = ref(0);
|
||||
|
||||
const queryFormRef = ref<ElFormInstance>();
|
||||
const safetyWeeklyReportFormRef = ref<ElFormInstance>();
|
||||
|
||||
const dialog = reactive<DialogOption>({
|
||||
visible: false,
|
||||
title: ''
|
||||
});
|
||||
|
||||
const initFormData: SafetyWeeklyReportForm = {
|
||||
id: undefined,
|
||||
projectId: currentProject.value?.id,
|
||||
week: undefined,
|
||||
scope: undefined,
|
||||
scopeEnd: undefined,
|
||||
path: undefined,
|
||||
remark: undefined
|
||||
};
|
||||
const data = reactive<PageData<SafetyWeeklyReportForm, SafetyWeeklyReportQuery>>({
|
||||
form: { ...initFormData },
|
||||
queryParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
id: undefined,
|
||||
projectId: currentProject.value?.id,
|
||||
week: undefined,
|
||||
scopeDate: undefined,
|
||||
remark: undefined,
|
||||
params: {}
|
||||
},
|
||||
rules: {
|
||||
id: [{ required: true, message: '主键id不能为空', trigger: 'blur' }],
|
||||
projectId: [{ required: true, message: '项目id不能为空', trigger: 'blur' }]
|
||||
}
|
||||
});
|
||||
|
||||
const { queryParams, form, rules } = toRefs(data);
|
||||
|
||||
/** 查询安全周报列表 */
|
||||
const getList = async () => {
|
||||
loading.value = true;
|
||||
const res = await listSafetyWeeklyReport(queryParams.value);
|
||||
safetyWeeklyReportList.value = res.rows;
|
||||
total.value = res.total;
|
||||
loading.value = false;
|
||||
};
|
||||
|
||||
/** 取消按钮 */
|
||||
const cancel = () => {
|
||||
reset();
|
||||
dialog.visible = false;
|
||||
};
|
||||
|
||||
/** 表单重置 */
|
||||
const reset = () => {
|
||||
form.value = { ...initFormData };
|
||||
safetyWeeklyReportFormRef.value?.resetFields();
|
||||
};
|
||||
|
||||
/** 搜索按钮操作 */
|
||||
const handleQuery = () => {
|
||||
queryParams.value.pageNum = 1;
|
||||
getList();
|
||||
};
|
||||
|
||||
/** 重置按钮操作 */
|
||||
const resetQuery = () => {
|
||||
queryFormRef.value?.resetFields();
|
||||
handleQuery();
|
||||
};
|
||||
|
||||
/** 多选框选中数据 */
|
||||
const handleSelectionChange = (selection: SafetyWeeklyReportVO[]) => {
|
||||
ids.value = selection.map((item) => item.id);
|
||||
single.value = selection.length != 1;
|
||||
multiple.value = !selection.length;
|
||||
};
|
||||
|
||||
/** 新增按钮操作 */
|
||||
const handleAdd = () => {
|
||||
reset();
|
||||
dialog.visible = true;
|
||||
dialog.title = '添加安全周报';
|
||||
};
|
||||
|
||||
/** 修改按钮操作 */
|
||||
const handleUpdate = async (row?: SafetyWeeklyReportVO) => {
|
||||
reset();
|
||||
const _id = row?.id || ids.value[0];
|
||||
const res = await getSafetyWeeklyReport(_id);
|
||||
Object.assign(form.value, res.data);
|
||||
dialog.visible = true;
|
||||
dialog.title = '修改安全周报';
|
||||
};
|
||||
|
||||
/** 提交按钮 */
|
||||
const submitForm = () => {
|
||||
safetyWeeklyReportFormRef.value?.validate(async (valid: boolean) => {
|
||||
if (valid) {
|
||||
buttonLoading.value = true;
|
||||
form.value.projectId = currentProject.value?.id;
|
||||
if (form.value.id) {
|
||||
await updateSafetyWeeklyReport(form.value).finally(() => (buttonLoading.value = false));
|
||||
} else {
|
||||
await addSafetyWeeklyReport(form.value).finally(() => (buttonLoading.value = false));
|
||||
}
|
||||
proxy?.$modal.msgSuccess('操作成功');
|
||||
dialog.visible = false;
|
||||
await getList();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/** 删除按钮操作 */
|
||||
const handleDelete = async (row?: SafetyWeeklyReportVO) => {
|
||||
const _ids = row?.id || ids.value;
|
||||
await proxy?.$modal.confirm('是否确认删除安全周报编号为"' + _ids + '"的数据项?').finally(() => (loading.value = false));
|
||||
await delSafetyWeeklyReport(_ids);
|
||||
proxy?.$modal.msgSuccess('删除成功');
|
||||
await getList();
|
||||
};
|
||||
|
||||
/** 导出按钮操作 */
|
||||
const handleExport = () => {
|
||||
proxy?.download(
|
||||
'safety/safetyWeeklyReport/export',
|
||||
{
|
||||
...queryParams.value
|
||||
},
|
||||
`safetyWeeklyReport_${new Date().getTime()}.xlsx`
|
||||
);
|
||||
};
|
||||
|
||||
//监听项目id刷新数据
|
||||
const listeningProject = watch(
|
||||
() => currentProject.value?.id,
|
||||
(nid, oid) => {
|
||||
queryParams.value.projectId = nid;
|
||||
form.value.projectId = nid;
|
||||
getList();
|
||||
}
|
||||
);
|
||||
|
||||
onUnmounted(() => {
|
||||
listeningProject();
|
||||
});
|
||||
|
||||
onMounted(() => {
|
||||
getList();
|
||||
});
|
||||
</script>
|
||||
@ -0,0 +1,57 @@
|
||||
<template>
|
||||
<div>
|
||||
<el-descriptions v-loading="loading" :column="2">
|
||||
<el-descriptions-item :span="2" label="宣讲人">{{ teamMeetingDetail?.compereName }}</el-descriptions-item>
|
||||
<el-descriptions-item :span="2" label="参与人">
|
||||
<span :key="item.id" v-for="item in teamMeetingDetail?.participantList">{{ item.name }},</span>
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="班组名称">{{ teamMeetingDetail?.teamName }}</el-descriptions-item>
|
||||
<el-descriptions-item label="施工单位">{{ teamMeetingDetail?.contractorName }}</el-descriptions-item>
|
||||
<el-descriptions-item label="开会时间">{{ dayjs(teamMeetingDetail?.meetingDate).format('YYYY 年 MM 月 DD 日') }}</el-descriptions-item>
|
||||
<el-descriptions-item label="上传时间">{{ teamMeetingDetail?.createTime }}</el-descriptions-item>
|
||||
<el-descriptions-item :span="2" label="班会内容">{{ teamMeetingDetail?.content }}</el-descriptions-item>
|
||||
<el-descriptions-item :span="2" label="班会图片">
|
||||
<el-space wrap>
|
||||
<span :key="item" v-for="item in teamMeetingDetail?.pictureUrlList">
|
||||
<image-preview :src="item" width="200px" />
|
||||
</span>
|
||||
</el-space>
|
||||
</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { getTeamMeeting } from '@/api/safety/teamMeeting';
|
||||
import { TeamMeetingVO } from '@/api/safety/teamMeeting/types';
|
||||
import { dayjs } from 'element-plus';
|
||||
|
||||
interface Props {
|
||||
teamMeetingId?: string | number;
|
||||
}
|
||||
|
||||
const props = defineProps<Props>();
|
||||
const loading = ref<boolean>(false);
|
||||
const teamMeetingDetail = ref<TeamMeetingVO>();
|
||||
const get = async () => {
|
||||
loading.value = true;
|
||||
const res = await getTeamMeeting(props.teamMeetingId);
|
||||
if (res.data && res.code === 200) {
|
||||
teamMeetingDetail.value = res.data;
|
||||
}
|
||||
loading.value = false;
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
get();
|
||||
});
|
||||
|
||||
watch(
|
||||
() => props.teamMeetingId,
|
||||
(newId, oldId) => {
|
||||
if (newId !== oldId) {
|
||||
get();
|
||||
}
|
||||
}
|
||||
);
|
||||
</script>
|
||||
292
src/views/safety/teamMeeting/index.vue
Normal file
292
src/views/safety/teamMeeting/index.vue
Normal file
@ -0,0 +1,292 @@
|
||||
<template>
|
||||
<div class="p-2">
|
||||
<transition :enter-active-class="proxy?.animate.searchAnimate.enter" :leave-active-class="proxy?.animate.searchAnimate.leave">
|
||||
<div v-show="showSearch" class="mb-[10px]">
|
||||
<el-card shadow="hover">
|
||||
<el-form ref="queryFormRef" :model="queryParams" :inline="true">
|
||||
<el-form-item label="开会时间" prop="meetingDate">
|
||||
<el-date-picker clearable v-model="queryParams.meetingDate" type="date" value-format="YYYY-MM-DD" placeholder="请选择开会时间" />
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
|
||||
<el-button icon="Refresh" @click="resetQuery">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-card>
|
||||
</div>
|
||||
</transition>
|
||||
|
||||
<el-card shadow="never">
|
||||
<template #header>
|
||||
<el-row :gutter="10" class="mb8">
|
||||
<!-- <el-col :span="1.5">
|
||||
<el-button type="primary" plain icon="Plus" @click="handleAdd" v-hasPermi="['safety:teamMeeting:add']"> 新增 </el-button>
|
||||
</el-col> -->
|
||||
<el-col :span="1.5">
|
||||
<el-button type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete()" v-hasPermi="['safety:teamMeeting:remove']">
|
||||
删除
|
||||
</el-button>
|
||||
</el-col>
|
||||
<!-- <el-col :span="1.5">
|
||||
<el-button type="warning" plain icon="Download" @click="handleExport" v-hasPermi="['safety:teamMeeting:export']">导出 </el-button>
|
||||
</el-col> -->
|
||||
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
|
||||
</el-row>
|
||||
</template>
|
||||
|
||||
<el-table v-loading="loading" :data="teamMeetingList" @selection-change="handleSelectionChange">
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column label="序号" type="index" width="60" align="center" />
|
||||
<el-table-column label="宣讲人" align="center" prop="compereName" />
|
||||
<el-table-column label="施工单位" align="center" prop="contractorName" />
|
||||
<el-table-column label="班组名称" align="center" prop="teamName" />
|
||||
<el-table-column label="参与人数" align="center">
|
||||
<template #default="scope">
|
||||
<span>{{ scope.row.participantList.length + 1 }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="开会时间" align="center" prop="meetingDate" width="180">
|
||||
<template #default="scope">
|
||||
<span>{{ parseTime(scope.row.meetingDate, '{y}-{m}-{d}') }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="上传时间" align="center" prop="createTime" width="180">
|
||||
<template #default="scope">
|
||||
<span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d} {hh}:{mm}:{ss}') }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="备注" align="center" prop="remark" />
|
||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||
<template #default="scope">
|
||||
<el-space>
|
||||
<el-button link type="primary" icon="View" @click="handleShowDrawer(scope.row)" v-hasPermi="['safety:teamMeeting:query']">
|
||||
详情
|
||||
</el-button>
|
||||
<!-- <el-button link type="success" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['safety:teamMeeting:edit']"> 修改 </el-button> -->
|
||||
<el-button link type="danger" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['safety:teamMeeting:remove']">
|
||||
删除
|
||||
</el-button>
|
||||
</el-space>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" @pagination="getList" />
|
||||
</el-card>
|
||||
<!-- 添加或修改站班会对话框 -->
|
||||
<el-dialog :title="dialog.title" v-model="dialog.visible" width="500px" append-to-body>
|
||||
<el-form ref="teamMeetingFormRef" :model="form" :rules="rules" label-width="80px">
|
||||
<el-form-item label="开会时间" prop="meetingDate">
|
||||
<el-date-picker clearable v-model="form.meetingDate" type="date" value-format="YYYY-MM-DD" placeholder="请选择开会时间" />
|
||||
</el-form-item>
|
||||
<el-form-item label="班会内容">
|
||||
<editor v-model="form.content" :min-height="192" />
|
||||
</el-form-item>
|
||||
<el-form-item label="班会图片" prop="picture">
|
||||
<image-upload v-model="form.pictureList" />
|
||||
</el-form-item>
|
||||
<el-form-item label="备注" prop="remark">
|
||||
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<el-button :loading="buttonLoading" type="primary" @click="submitForm">确 定</el-button>
|
||||
<el-button @click="cancel">取 消</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
<el-dialog title="站班会详情" v-model="showDetailDrawer" width="800px">
|
||||
<TeamMeetingDetailDrawer :team-meeting-id="currentTeamMeetingId" />
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup name="TeamMeeting" lang="ts">
|
||||
console.log(111);
|
||||
|
||||
import { addTeamMeeting, delTeamMeeting, getTeamMeeting, listTeamMeeting, updateTeamMeeting } from '@/api/safety/teamMeeting';
|
||||
import { TeamMeetingForm, TeamMeetingQuery, TeamMeetingVO } from '@/api/safety/teamMeeting/types';
|
||||
import { useUserStoreHook } from '@/store/modules/user';
|
||||
import TeamMeetingDetailDrawer from '@/views/safety/teamMeeting/component/TeamMeetingDetailDrawer.vue';
|
||||
|
||||
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
|
||||
|
||||
// 获取用户 store
|
||||
const userStore = useUserStoreHook();
|
||||
// 从 store 中获取项目列表和当前选中的项目
|
||||
const currentProject = computed(() => userStore.selectedProject);
|
||||
const teamMeetingList = ref<TeamMeetingVO[]>([]);
|
||||
const buttonLoading = ref(false);
|
||||
const loading = ref(true);
|
||||
const showSearch = ref(true);
|
||||
const ids = ref<Array<string | number>>([]);
|
||||
const single = ref(true);
|
||||
const multiple = ref(true);
|
||||
const total = ref(0);
|
||||
|
||||
const queryFormRef = ref<ElFormInstance>();
|
||||
const teamMeetingFormRef = ref<ElFormInstance>();
|
||||
const currentTeamMeetingId = ref<string | number>(0);
|
||||
const dialog = reactive<DialogOption>({
|
||||
visible: false,
|
||||
title: ''
|
||||
});
|
||||
|
||||
const initFormData: TeamMeetingForm = {
|
||||
id: undefined,
|
||||
projectId: currentProject.value?.id,
|
||||
teamId: undefined,
|
||||
contractorId: undefined,
|
||||
meetingDate: undefined,
|
||||
compereId: undefined,
|
||||
participantIdList: undefined,
|
||||
content: undefined,
|
||||
pictureList: undefined,
|
||||
remark: undefined
|
||||
};
|
||||
const data = reactive<PageData<TeamMeetingForm, TeamMeetingQuery>>({
|
||||
form: { ...initFormData },
|
||||
queryParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
projectId: currentProject.value?.id,
|
||||
teamId: undefined,
|
||||
contractorId: undefined,
|
||||
meetingDate: undefined,
|
||||
compereId: undefined,
|
||||
participantIdList: undefined,
|
||||
content: undefined,
|
||||
params: {}
|
||||
},
|
||||
rules: {
|
||||
id: [{ required: true, message: '主键id不能为空', trigger: 'blur' }],
|
||||
projectId: [{ required: true, message: '项目id不能为空', trigger: 'change' }],
|
||||
teamId: [{ required: true, message: '班组id不能为空', trigger: 'change' }],
|
||||
contractorId: [{ required: true, message: '分包公司id不能为空', trigger: 'change' }]
|
||||
}
|
||||
});
|
||||
|
||||
const { queryParams, form, rules } = toRefs(data);
|
||||
|
||||
/** 查询站班会列表 */
|
||||
const getList = async () => {
|
||||
loading.value = true;
|
||||
const res = await listTeamMeeting(queryParams.value);
|
||||
teamMeetingList.value = res.rows;
|
||||
total.value = res.total;
|
||||
loading.value = false;
|
||||
};
|
||||
|
||||
/** 取消按钮 */
|
||||
const cancel = () => {
|
||||
reset();
|
||||
dialog.visible = false;
|
||||
};
|
||||
|
||||
/** 表单重置 */
|
||||
const reset = () => {
|
||||
form.value = { ...initFormData };
|
||||
teamMeetingFormRef.value?.resetFields();
|
||||
};
|
||||
|
||||
/** 搜索按钮操作 */
|
||||
const handleQuery = () => {
|
||||
queryParams.value.pageNum = 1;
|
||||
getList();
|
||||
};
|
||||
|
||||
/** 重置按钮操作 */
|
||||
const resetQuery = () => {
|
||||
queryFormRef.value?.resetFields();
|
||||
handleQuery();
|
||||
};
|
||||
|
||||
/** 多选框选中数据 */
|
||||
const handleSelectionChange = (selection: TeamMeetingVO[]) => {
|
||||
ids.value = selection.map((item) => item.id);
|
||||
single.value = selection.length != 1;
|
||||
multiple.value = !selection.length;
|
||||
};
|
||||
|
||||
/** 新增按钮操作 */
|
||||
const handleAdd = () => {
|
||||
reset();
|
||||
dialog.visible = true;
|
||||
dialog.title = '添加站班会';
|
||||
};
|
||||
|
||||
/** 展开站班会详情抽屉操作 */
|
||||
const showDetailDrawer = ref<boolean>(false);
|
||||
const handleShowDrawer = (row?: TeamMeetingVO) => {
|
||||
currentTeamMeetingId.value = row.id;
|
||||
showDetailDrawer.value = true;
|
||||
};
|
||||
|
||||
/** 修改按钮操作 */
|
||||
const handleUpdate = async (row?: TeamMeetingVO) => {
|
||||
reset();
|
||||
const _id = row?.id || ids.value[0];
|
||||
const res = await getTeamMeeting(_id);
|
||||
Object.assign(form.value, res.data);
|
||||
dialog.visible = true;
|
||||
dialog.title = '修改站班会';
|
||||
};
|
||||
|
||||
/** 提交按钮 */
|
||||
const submitForm = () => {
|
||||
teamMeetingFormRef.value?.validate(async (valid: boolean) => {
|
||||
if (valid) {
|
||||
buttonLoading.value = true;
|
||||
if (form.value.id) {
|
||||
await updateTeamMeeting(form.value).finally(() => (buttonLoading.value = false));
|
||||
} else {
|
||||
await addTeamMeeting(form.value).finally(() => (buttonLoading.value = false));
|
||||
}
|
||||
proxy?.$modal.msgSuccess('操作成功');
|
||||
dialog.visible = false;
|
||||
await getList();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/** 删除按钮操作 */
|
||||
const handleDelete = async (row?: TeamMeetingVO) => {
|
||||
const _ids = row?.id || ids.value;
|
||||
await proxy?.$modal.confirm('是否确认删除站班会编号为"' + _ids + '"的数据项?').finally(() => (loading.value = false));
|
||||
await delTeamMeeting(_ids);
|
||||
proxy?.$modal.msgSuccess('删除成功');
|
||||
await getList();
|
||||
};
|
||||
|
||||
/** 导出按钮操作 */
|
||||
const handleExport = () => {
|
||||
proxy?.download(
|
||||
'safety/teamMeeting/export',
|
||||
{
|
||||
...queryParams.value
|
||||
},
|
||||
`teamMeeting_${new Date().getTime()}.xlsx`
|
||||
);
|
||||
};
|
||||
|
||||
//监听项目id刷新数据
|
||||
const listeningProject = watch(
|
||||
() => currentProject.value?.id,
|
||||
(nid, oid) => {
|
||||
queryParams.value.projectId = nid;
|
||||
form.value.projectId = nid;
|
||||
getList();
|
||||
}
|
||||
);
|
||||
|
||||
onUnmounted(() => {
|
||||
listeningProject();
|
||||
});
|
||||
console.log(11);
|
||||
|
||||
onMounted(() => {
|
||||
console.log(122);
|
||||
getList();
|
||||
});
|
||||
</script>
|
||||
240
src/views/safety/violationLevel/component/add.vue
Normal file
240
src/views/safety/violationLevel/component/add.vue
Normal file
@ -0,0 +1,240 @@
|
||||
<template>
|
||||
<div class="system-busViolationLevel-add">
|
||||
<el-dialog v-model="isShowDialog" width="550px" :close-on-click-modal="false" :destroy-on-close="true">
|
||||
<template #header>
|
||||
<div v-drag="['.system-busViolationLevel-add .el-dialog', '.system-busViolationLevel-add .el-dialog__header']">添加违章等级</div>
|
||||
</template>
|
||||
<el-form ref="formRef" size="large" :model="formData" :rules="rules" label-width="90px">
|
||||
<el-row>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="违章等级" prop="violationLevel">
|
||||
<el-input v-model="formData.violationLevel" placeholder="请输入违章等级" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="颜色" prop="color">
|
||||
<el-color-picker v-model="formData.color" show-alpha />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="24">
|
||||
<el-form-item label="风险等级" prop="riskType">
|
||||
<el-select v-model="formData.riskType" placeholder="请选择风险等级">
|
||||
<el-option v-for="dict in risxList" :key="dict.value" :label="dict.label" :value="dict.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="24" :offset="0" prop="dept">
|
||||
<el-form-item label="部门">
|
||||
<el-cascader
|
||||
:options="postListAll"
|
||||
v-model="formData.dept"
|
||||
clearable
|
||||
filterable
|
||||
:show-all-levels="false"
|
||||
placeholder="请选择部门"
|
||||
:props="{ expandTrigger: 'hover', checkStrictly: true, value: 'id', emitPath: false, multiple: true }"
|
||||
@change="changeDept"
|
||||
>
|
||||
</el-cascader>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="24">
|
||||
<el-form-item label="岗位" prop="postIdList">
|
||||
<el-select v-model="formData.postIdList" placeholder="请选择岗位" multiple :disabled="!formData.dept">
|
||||
<el-option
|
||||
v-for="dict in formData.postWorkList"
|
||||
:key="dict.postId"
|
||||
:label="dict.deptName + '/' + dict.postName"
|
||||
:value="dict.postId"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="24">
|
||||
<el-form-item label="违章类型" prop="violationType">
|
||||
<el-select v-model="formData.violationType" placeholder="请选择违章类型" multiple>
|
||||
<el-option v-for="dict in tourTypeOptions" :key="dict.value" :label="dict.label" :value="dict.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<el-button type="primary" @click="onSubmit">确 定</el-button>
|
||||
<el-button @click="onCancel">取 消</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive, getCurrentInstance } from 'vue';
|
||||
import { ElMessage } from 'element-plus';
|
||||
import { addViolationLevel } from '@/api/safety/violationLevel';
|
||||
import { useUserStoreHook } from '@/store/modules/user';
|
||||
// 获取用户 store
|
||||
const userStore = useUserStoreHook();
|
||||
// 从 store 中获取项目列表和当前选中的项目
|
||||
const currentProject = computed(() => userStore.selectedProject);
|
||||
|
||||
// Props
|
||||
const props = defineProps<{
|
||||
tourTypeOptions: any[];
|
||||
risxList: any[];
|
||||
postListAll: any[];
|
||||
}>();
|
||||
|
||||
const emit = defineEmits(['busViolationLevelList']);
|
||||
const { proxy } = getCurrentInstance()!;
|
||||
|
||||
const formRef = ref<any>(null);
|
||||
const menuRef = ref();
|
||||
|
||||
const isShowDialog = ref(false);
|
||||
const loading = ref(false);
|
||||
|
||||
const formData = reactive({
|
||||
id: undefined,
|
||||
violationLevel: undefined,
|
||||
dept: undefined,
|
||||
color: undefined,
|
||||
violationType: undefined as any,
|
||||
wxOrPc: undefined,
|
||||
createBy: undefined,
|
||||
updateBy: undefined,
|
||||
createdAt: undefined,
|
||||
updatedAt: undefined,
|
||||
deletedAt: undefined,
|
||||
projectId: currentProject.value?.id,
|
||||
riskType: '',
|
||||
postWorkList: [] as any[],
|
||||
postIdList: [] as any[]
|
||||
});
|
||||
|
||||
const rules = {
|
||||
id: [{ required: true, message: '主键ID不能为空', trigger: 'blur' }],
|
||||
violationLevel: [
|
||||
{
|
||||
required: true,
|
||||
validator: (_rule: any, value: string) => /^[A-Z]*$/g.test(value),
|
||||
message: '请输入A-Z的字母',
|
||||
trigger: 'change'
|
||||
}
|
||||
],
|
||||
postIdList: [{ required: true, message: '岗位不能为空', trigger: 'blur' }]
|
||||
};
|
||||
|
||||
// 打开弹窗
|
||||
const openDialog = () => {
|
||||
resetForm();
|
||||
isShowDialog.value = true;
|
||||
};
|
||||
|
||||
// 关闭弹窗
|
||||
const closeDialog = () => {
|
||||
isShowDialog.value = false;
|
||||
};
|
||||
|
||||
// 取消操作
|
||||
const onCancel = () => {
|
||||
closeDialog();
|
||||
};
|
||||
|
||||
// 表单重置
|
||||
const resetForm = () => {
|
||||
Object.assign(formData, {
|
||||
id: undefined,
|
||||
violationLevel: undefined,
|
||||
color: undefined,
|
||||
violationType: undefined,
|
||||
dept: undefined,
|
||||
wxOrPc: undefined,
|
||||
createBy: undefined,
|
||||
updateBy: undefined,
|
||||
createdAt: undefined,
|
||||
updatedAt: undefined,
|
||||
deletedAt: undefined,
|
||||
projectId: currentProject.value?.id,
|
||||
riskType: '',
|
||||
postWorkList: [] as any[],
|
||||
postIdList: []
|
||||
});
|
||||
};
|
||||
|
||||
// 提交操作
|
||||
const onSubmit = () => {
|
||||
if (!formRef.value) return;
|
||||
|
||||
formRef.value.validate((valid: boolean) => {
|
||||
if (valid) {
|
||||
loading.value = true;
|
||||
|
||||
const param = JSON.parse(JSON.stringify(formData));
|
||||
if (param.violationType?.length) {
|
||||
param.violationType = param.violationType.join(',');
|
||||
}
|
||||
|
||||
addViolationLevel(param)
|
||||
.then(() => {
|
||||
ElMessage.success('添加成功');
|
||||
closeDialog();
|
||||
emit('busViolationLevelList');
|
||||
})
|
||||
.finally(() => {
|
||||
loading.value = false;
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const changeDept = (val: any) => {
|
||||
formData.postWorkList = getPostVoListByIds(props.postListAll, val);
|
||||
formData.postIdList = [];
|
||||
console.log(formData.postWorkList, val);
|
||||
};
|
||||
|
||||
function getPostVoListByIds(tree: any[], idList: (string | number)[]): any[] {
|
||||
const idSet = new Set(idList.map(String)); // 用于快速匹配 ID(统一为字符串比较)
|
||||
const result: any[] = [];
|
||||
|
||||
function dfs(nodes: any[]) {
|
||||
for (const node of nodes) {
|
||||
if (idSet.has(String(node.id))) {
|
||||
result.push(...(node.postVoList || []));
|
||||
}
|
||||
|
||||
if (node.children && node.children.length > 0) {
|
||||
dfs(node.children);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dfs(tree);
|
||||
return result;
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
openDialog,
|
||||
closeDialog
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
.system-busViolationLevel-add {
|
||||
.el-col {
|
||||
margin-top: 20px;
|
||||
}
|
||||
.el-select .el-input__wrapper {
|
||||
width: 400px;
|
||||
}
|
||||
.el-select__tags {
|
||||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
flex-wrap: nowrap;
|
||||
overflow: hidden;
|
||||
margin-left: 1px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
261
src/views/safety/violationLevel/component/edit.vue
Normal file
261
src/views/safety/violationLevel/component/edit.vue
Normal file
@ -0,0 +1,261 @@
|
||||
<template>
|
||||
<div class="system-busViolationLevel-edit">
|
||||
<el-dialog v-model="isShowDialog" width="550px" :close-on-click-modal="false" :destroy-on-close="true" custom-class="busViolationLevel_edit">
|
||||
<template #header>
|
||||
<div v-drag="['.system-busViolationLevel-edit .el-dialog', '.system-busViolationLevel-edit .el-dialog__header']">
|
||||
{{ (!formData.id || formData.id == 0 ? '添加' : '修改') + '违章等级' }}
|
||||
</div>
|
||||
</template>
|
||||
<el-form ref="formRef" size="large" :model="formData" :rules="rules" label-width="90px">
|
||||
<el-row>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="违章等级" prop="violationLevel">
|
||||
<el-input v-model="formData.violationLevel" placeholder="请输入违章等级" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="颜色" prop="color">
|
||||
<el-color-picker v-model="formData.color" show-alpha />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="24">
|
||||
<el-form-item label="风险等级" prop="riskType">
|
||||
<el-select v-model="formData.riskType" placeholder="请选择风险等级">
|
||||
<el-option v-for="dict in risxList" :key="dict.value" :label="dict.label" :value="dict.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="24" :offset="0" prop="dept">
|
||||
<el-form-item label="部门">
|
||||
<el-cascader
|
||||
:options="postListAll"
|
||||
v-model="formData.dept"
|
||||
clearable
|
||||
filterable
|
||||
:show-all-levels="false"
|
||||
placeholder="请选择部门"
|
||||
:props="{ expandTrigger: 'hover', checkStrictly: true, value: 'id', emitPath: false, multiple: true }"
|
||||
@change="changeDept"
|
||||
>
|
||||
</el-cascader>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="24">
|
||||
<el-form-item label="岗位" prop="postIdList">
|
||||
<el-select v-model="formData.postIdList" placeholder="请选择岗位" multiple :disabled="!formData.dept">
|
||||
<el-option
|
||||
v-for="dict in formData.postWorkList"
|
||||
:key="dict.postId"
|
||||
:label="dict.deptName + '/' + dict.postName"
|
||||
:value="dict.postId"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="24">
|
||||
<el-form-item label="违章类型" prop="violationType">
|
||||
<el-select v-model="formData.violationType" placeholder="请选择违章类型" multiple>
|
||||
<el-option v-for="dict in tourTypeOptions" :key="dict.value" :label="dict.label" :value="dict.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<el-button type="primary" @click="onSubmit">确 定</el-button>
|
||||
<el-button @click="onCancel">取 消</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive, getCurrentInstance, unref, nextTick } from 'vue';
|
||||
import { ElMessage, ElLoading } from 'element-plus';
|
||||
import { getViolationLevel, addViolationLevel, updateViolationLevel } from '@/api/safety/violationLevel';
|
||||
import { ViolationLevelForm, ViolationLevelVO } from '@/api/safety/violationLevel/types';
|
||||
|
||||
const props = defineProps<{
|
||||
tourTypeOptions: any[];
|
||||
risxList: any[];
|
||||
postListAll: any[];
|
||||
}>();
|
||||
|
||||
const emit = defineEmits(['busViolationLevelList']);
|
||||
|
||||
const { proxy } = getCurrentInstance()!;
|
||||
const formRef = ref<any>(null);
|
||||
const isShowDialog = ref(false);
|
||||
const loading = ref(false);
|
||||
|
||||
const formData = reactive<
|
||||
Partial<ViolationLevelForm> & {
|
||||
risx?: string[] | string;
|
||||
tourType?: string[] | string;
|
||||
postIdList: number[];
|
||||
dept: any;
|
||||
postWorkList: any[];
|
||||
}
|
||||
>({
|
||||
id: undefined,
|
||||
violationLevel: undefined,
|
||||
color: undefined,
|
||||
dept: undefined,
|
||||
postWorkList: [] as any[],
|
||||
|
||||
riskType: undefined,
|
||||
createBy: undefined,
|
||||
updateBy: undefined,
|
||||
risx: '',
|
||||
postIdList: []
|
||||
});
|
||||
|
||||
const rules = {
|
||||
id: [{ required: true, message: '主键ID不能为空', trigger: 'blur' }],
|
||||
violationLevel: [
|
||||
{
|
||||
required: true,
|
||||
validator: (_rule: any, value: string) => /^[A-Z]*$/g.test(value),
|
||||
message: '请输入A-Z的字母',
|
||||
trigger: 'change'
|
||||
}
|
||||
],
|
||||
posts: [{ required: true, message: '岗位不能为空', trigger: 'blur' }]
|
||||
};
|
||||
|
||||
const openDialog = (row?: ViolationLevelVO) => {
|
||||
resetForm();
|
||||
if (row && row.id) {
|
||||
nextTick(() => {
|
||||
const loadingInstance = ElLoading.service({
|
||||
lock: true,
|
||||
text: '正在加载中……',
|
||||
background: 'rgba(0, 0, 0, 0.7)',
|
||||
target: '.busViolationLevel_edit'
|
||||
});
|
||||
getViolationLevel(row.id as string).then((res) => {
|
||||
loadingInstance.close();
|
||||
const data = res.data;
|
||||
data.postIdList = (data.postList || []).map((item: any) => item.postId);
|
||||
data.violationType = data.violationType ? (data.violationType as string).split(',') : [];
|
||||
formData.dept = (data.postList || []).map((item: any) => item.deptId);
|
||||
formData.postWorkList = getPostVoListByIds(props.postListAll, formData.dept);
|
||||
Object.assign(formData, data);
|
||||
});
|
||||
});
|
||||
}
|
||||
isShowDialog.value = true;
|
||||
};
|
||||
|
||||
const closeDialog = () => {
|
||||
isShowDialog.value = false;
|
||||
};
|
||||
|
||||
const onCancel = () => {
|
||||
closeDialog();
|
||||
};
|
||||
|
||||
const onSubmit = () => {
|
||||
const form = unref(formRef);
|
||||
if (!form) return;
|
||||
|
||||
form.validate((valid: boolean) => {
|
||||
if (!valid) return;
|
||||
|
||||
loading.value = true;
|
||||
|
||||
const param = JSON.parse(JSON.stringify(formData));
|
||||
if (Array.isArray(param.violationType)) {
|
||||
param.violationType = param.violationType.join(',');
|
||||
}
|
||||
if (Array.isArray(param.riskType)) {
|
||||
param.riskType = param.riskType.join(',');
|
||||
}
|
||||
|
||||
const action = !param.id || param.id === 0 ? addViolationLevel : updateViolationLevel;
|
||||
const successMsg = !param.id || param.id === 0 ? '添加成功' : '修改成功';
|
||||
|
||||
action(param)
|
||||
.then(() => {
|
||||
ElMessage.success(successMsg);
|
||||
closeDialog();
|
||||
emit('busViolationLevelList');
|
||||
})
|
||||
.finally(() => {
|
||||
loading.value = false;
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
const resetForm = () => {
|
||||
Object.assign(formData, {
|
||||
id: undefined,
|
||||
grade: undefined,
|
||||
color: undefined,
|
||||
tourType: undefined,
|
||||
wxOrPc: undefined,
|
||||
createBy: undefined,
|
||||
updateBy: undefined,
|
||||
createdAt: undefined,
|
||||
updatedAt: undefined,
|
||||
deletedAt: undefined,
|
||||
dept: undefined,
|
||||
postWorkList: [],
|
||||
postIdList: [],
|
||||
|
||||
risx: '',
|
||||
posts: []
|
||||
});
|
||||
};
|
||||
|
||||
const changeDept = (val: any) => {
|
||||
formData.postWorkList = getPostVoListByIds(props.postListAll, val);
|
||||
formData.postIdList = [];
|
||||
console.log(formData.postWorkList, val);
|
||||
};
|
||||
|
||||
function getPostVoListByIds(tree: any[], idList: (string | number)[]): any[] {
|
||||
const idSet = new Set(idList.map(String)); // 用于快速匹配 ID(统一为字符串比较)
|
||||
const result: any[] = [];
|
||||
|
||||
function dfs(nodes: any[]) {
|
||||
for (const node of nodes) {
|
||||
if (idSet.has(String(node.id))) {
|
||||
result.push(...(node.postVoList || []));
|
||||
}
|
||||
|
||||
if (node.children && node.children.length > 0) {
|
||||
dfs(node.children);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dfs(tree);
|
||||
return result;
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
openDialog,
|
||||
closeDialog
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
.system-busViolationLevel-edit {
|
||||
.el-col {
|
||||
margin-top: 20px;
|
||||
}
|
||||
.el-select .el-input__wrapper {
|
||||
width: 400px;
|
||||
}
|
||||
.el-select__tags {
|
||||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
flex-wrap: nowrap;
|
||||
overflow: hidden;
|
||||
margin-left: 1px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
289
src/views/safety/violationLevel/index.vue
Normal file
289
src/views/safety/violationLevel/index.vue
Normal file
@ -0,0 +1,289 @@
|
||||
<template>
|
||||
<div class="system-busViolationLevel-container">
|
||||
<el-card shadow="hover">
|
||||
<div class="system-busViolationLevel-search mb15">
|
||||
<el-form :model="state.tableData.param" ref="queryRef" :inline="true" label-width="100px">
|
||||
<el-row>
|
||||
<el-col :span="8" class="colBlock">
|
||||
<el-form-item label="违章类型" prop="tourType">
|
||||
<el-select v-model="state.tableData.param.violationType" placeholder="请选择违章类型" clearable>
|
||||
<el-option v-for="dict in violation_level_type" :key="dict.value" :label="dict.label" :value="dict.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="8" class="colBlock">
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="busViolationLevelList">
|
||||
<el-icon><Search /></el-icon>搜索
|
||||
</el-button>
|
||||
<el-button @click="resetQuery(queryRef)">
|
||||
<el-icon><Refresh /></el-icon>重置
|
||||
</el-button>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-form>
|
||||
<el-row :gutter="10" class="mb8">
|
||||
<el-col :span="1.5">
|
||||
<el-button type="primary" @click="handleAdd" v-auth="'api/v1/system/busViolationLevel/add'">
|
||||
<el-icon><Plus /></el-icon>新增
|
||||
</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button type="success" :disabled="single" @click="handleUpdate(null)" v-auth="'api/v1/system/busViolationLevel/edit'">
|
||||
<el-icon><Edit /></el-icon>修改
|
||||
</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button type="danger" :disabled="multiple" @click="handleDelete(null)" v-auth="'api/v1/system/busViolationLevel/delete'">
|
||||
<el-icon><Delete /></el-icon>删除
|
||||
</el-button>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</div>
|
||||
<el-table v-loading="loading" :data="state.tableData.data" @selection-change="handleSelectionChange">
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column label="序号" align="center" type="index" :index="indexMethod" width="60" />
|
||||
<el-table-column label="违章等级" align="center" prop="violationLevel" width="100px" />
|
||||
<el-table-column label="颜色" align="center" prop="color" width="100px">
|
||||
<template #default="scope">
|
||||
<div :style="`background: ${scope.row.color};width:15px;height:15px;margin:auto;`"></div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="风险等级" align="center" prop="riskType" width="150px">
|
||||
<template #default="scope">
|
||||
<span>{{ filterRiskLevelType(scope.row.riskType) }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="违章类型" show-overflow-tooltip align="center" prop="violationType" :formatter="tourTypeFormat" min-width="100px" />
|
||||
<el-table-column label="创建时间" align="center" prop="createTime" width="150px">
|
||||
<template #default="scope">
|
||||
<span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" align="center" class-name="small-padding" width="160px" fixed="right">
|
||||
<template #default="scope">
|
||||
<el-button type="success" link @click="handleUpdate(scope.row)" v-auth="'api/v1/system/busViolationLevel/edit'">
|
||||
<el-icon><EditPen /></el-icon>修改
|
||||
</el-button>
|
||||
<el-button type="danger" link @click="handleDelete(scope.row)" v-auth="'api/v1/system/busViolationLevel/delete'">
|
||||
<el-icon><DeleteFilled /></el-icon>删除
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<pagination
|
||||
v-show="state.tableData.total > 0"
|
||||
:total="state.tableData.total"
|
||||
v-model:page="state.tableData.param.pageNum"
|
||||
v-model:limit="state.tableData.param.pageSize"
|
||||
@pagination="busViolationLevelList"
|
||||
/>
|
||||
</el-card>
|
||||
|
||||
<apiV1SystemBusViolationLevelAdd
|
||||
ref="addRef"
|
||||
:tourTypeOptions="violation_level_type"
|
||||
:risxList="risk_level_type"
|
||||
@busViolationLevelList="busViolationLevelList"
|
||||
:postListAll="state.postListAll"
|
||||
/>
|
||||
<apiV1SystemBusViolationLevelEdit
|
||||
ref="editRef"
|
||||
:tourTypeOptions="violation_level_type"
|
||||
:risxList="risk_level_type"
|
||||
:postListAll="state.postListAll"
|
||||
@busViolationLevelList="busViolationLevelList"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive, computed, onMounted, getCurrentInstance, toRaw } from 'vue';
|
||||
import { ElMessageBox, ElMessage, FormInstance } from 'element-plus';
|
||||
import { listViolationLevel, delViolationLevel } from '@/api/safety/violationLevel';
|
||||
import { ViolationLevelForm, ViolationLevelVO } from '@/api/safety/violationLevel/types';
|
||||
import apiV1SystemBusViolationLevelAdd from '@/views/safety/violationLevel/component/add.vue';
|
||||
import apiV1SystemBusViolationLevelEdit from '@/views/safety/violationLevel/component/edit.vue';
|
||||
import { useUserStoreHook } from '@/store/modules/user';
|
||||
import { listPost, listTreeByProject, optionselect } from '@/api/system/post';
|
||||
// 获取用户 store
|
||||
const userStore = useUserStoreHook();
|
||||
// 从 store 中获取项目列表和当前选中的项目
|
||||
const currentProject = computed(() => userStore.selectedProject);
|
||||
const { proxy } = getCurrentInstance()!;
|
||||
|
||||
const loading = ref(false);
|
||||
const queryRef = ref<FormInstance>();
|
||||
const addRef = ref<InstanceType<typeof apiV1SystemBusViolationLevelAdd>>();
|
||||
const editRef = ref<InstanceType<typeof apiV1SystemBusViolationLevelEdit>>();
|
||||
const detailRef = ref<any>();
|
||||
|
||||
const showAll = ref(false);
|
||||
const single = ref(true);
|
||||
const multiple = ref(true);
|
||||
|
||||
const word = computed(() => (showAll.value === false ? '展开搜索' : '收起搜索'));
|
||||
const { violation_level_type, risk_level_type } = toRefs<any>(proxy?.useDict('violation_level_type', 'risk_level_type'));
|
||||
|
||||
const state = reactive<any>({
|
||||
ids: [],
|
||||
tableData: {
|
||||
data: [],
|
||||
total: 0,
|
||||
loading: false,
|
||||
param: {
|
||||
projectId: currentProject.value?.id,
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
tourType: undefined,
|
||||
createdAt: undefined,
|
||||
dateRange: []
|
||||
}
|
||||
},
|
||||
postListAll: []
|
||||
});
|
||||
|
||||
const postList = () => {
|
||||
listTreeByProject(currentProject.value?.id).then((res) => {
|
||||
console.log('🚀 ~ listTreeByProject ~ res:', res);
|
||||
state.postListAll = res.data ?? [];
|
||||
});
|
||||
};
|
||||
|
||||
const initTableData = () => {
|
||||
busViolationLevelList();
|
||||
};
|
||||
|
||||
const resetQuery = (formEl?: FormInstance) => {
|
||||
if (!formEl) return;
|
||||
formEl.resetFields();
|
||||
busViolationLevelList();
|
||||
};
|
||||
|
||||
const busViolationLevelList = () => {
|
||||
loading.value = true;
|
||||
listViolationLevel(state.tableData.param).then((res: any) => {
|
||||
const list = res.rows ?? [];
|
||||
state.tableData.data = list;
|
||||
state.tableData.total = res.total;
|
||||
loading.value = false;
|
||||
});
|
||||
};
|
||||
|
||||
const toggleSearch = () => {
|
||||
showAll.value = !showAll.value;
|
||||
};
|
||||
|
||||
const tourTypeFormat = (row: ViolationLevelVO) => {
|
||||
const type: string[] = [];
|
||||
if (row.violationType.includes(',')) {
|
||||
(row.violationType as string).split(',').forEach((item) => {
|
||||
type.push(proxy.selectDictLabel(violation_level_type.value, item));
|
||||
});
|
||||
} else {
|
||||
type.push(proxy.selectDictLabel(violation_level_type.value, row.violationType as string));
|
||||
}
|
||||
return type.join(',');
|
||||
};
|
||||
|
||||
const handleSelectionChange = (selection: ViolationLevelForm[]) => {
|
||||
state.ids = selection.map((item) => item.id);
|
||||
single.value = selection.length !== 1;
|
||||
multiple.value = selection.length === 0;
|
||||
};
|
||||
|
||||
const handleAdd = () => {
|
||||
addRef.value?.openDialog();
|
||||
};
|
||||
|
||||
const handleUpdate = (row: ViolationLevelVO | null) => {
|
||||
if (!row) {
|
||||
row = state.tableData.data.find((item) => item.id === state.ids[0]) ?? null;
|
||||
}
|
||||
if (row) {
|
||||
editRef.value?.openDialog(toRaw(row));
|
||||
}
|
||||
};
|
||||
|
||||
const handleDelete = (row: ViolationLevelVO | null) => {
|
||||
let msg = '你确定要删除所选数据?';
|
||||
let id: (string | number)[] = [];
|
||||
if (row) {
|
||||
msg = `此操作将永久删除数据,是否继续?`;
|
||||
id = [row.id as string];
|
||||
} else {
|
||||
id = state.ids;
|
||||
}
|
||||
if (id.length === 0) {
|
||||
ElMessage.error('请选择要删除的数据。');
|
||||
return;
|
||||
}
|
||||
ElMessageBox.confirm(msg, '提示', {
|
||||
confirmButtonText: '确认',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
})
|
||||
.then(() => {
|
||||
delViolationLevel(id).then(() => {
|
||||
ElMessage.success('删除成功');
|
||||
busViolationLevelList();
|
||||
});
|
||||
})
|
||||
.catch(() => {});
|
||||
};
|
||||
|
||||
const handleView = (row: ViolationLevelVO) => {
|
||||
detailRef.value?.openDialog(toRaw(row));
|
||||
};
|
||||
|
||||
const indexMethod = (index: number) => {
|
||||
const pageNum = state.tableData.param.pageNum - 1;
|
||||
if (pageNum !== -1 && pageNum !== 0) {
|
||||
return index + 1 + pageNum * state.tableData.param.pageSize;
|
||||
} else {
|
||||
return index + 1;
|
||||
}
|
||||
};
|
||||
|
||||
const filterRiskLevelType = (val: any) => {
|
||||
let label = '';
|
||||
if (val) {
|
||||
if (risk_level_type.value.length) {
|
||||
risk_level_type.value.forEach((item: any) => {
|
||||
if (item.value == val) {
|
||||
label = item.label;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
return label;
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
postList();
|
||||
initTableData();
|
||||
});
|
||||
|
||||
//监听项目id刷新数据
|
||||
const listeningProject = watch(
|
||||
() => currentProject.value?.id,
|
||||
(nid, oid) => {
|
||||
state.tableData.param.projectId = nid;
|
||||
initTableData();
|
||||
}
|
||||
);
|
||||
|
||||
onUnmounted(() => {
|
||||
listeningProject();
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.colBlock {
|
||||
display: block;
|
||||
}
|
||||
.colNone {
|
||||
display: none;
|
||||
}
|
||||
</style>
|
||||
@ -0,0 +1,214 @@
|
||||
<template>
|
||||
<!-- <el-card v-loading="loading" body-class="printMe"> -->
|
||||
<div class="w75% m-a">
|
||||
<div id="printMe" class="pos-relative">
|
||||
<div class="resultIcon"><img :src="'../../../../../src/assets/icons/svg/' + inspectionType + '.png'" alt="" /></div>
|
||||
<!-- <h2 style="text-align: center; margin-top: 5px; font-weight: bold">安全生产监督检查通知书</h2> -->
|
||||
<el-row>
|
||||
<el-col :span="12" style="text-align: left">填报人:{{ safetyInspectionDetail?.createByName }}</el-col>
|
||||
<el-col :span="12" style="text-align: right">填报时间:{{ safetyInspectionDetail?.createTime }}</el-col>
|
||||
</el-row>
|
||||
<el-descriptions :column="2" border style="margin-top: 8px" label-width="160px" size="large">
|
||||
<el-descriptions-item label-align="center" label="检查项目" :span="2" class-name="zebra">{{ currentProject?.name }} </el-descriptions-item>
|
||||
|
||||
<el-descriptions-item label-align="center" label="违章类型" label-class-name="white" width="300px">
|
||||
<dict-tag :options="violation_level_type" :value="safetyInspectionDetail?.violationType" />
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label-align="center" label="违章等级" label-class-name="white">
|
||||
<div class="flex">
|
||||
{{ safetyInspectionDetail?.levelVo.violationLevel }}:<dict-tag
|
||||
:options="risk_level_type"
|
||||
:value="safetyInspectionDetail?.levelVo.riskType"
|
||||
/>
|
||||
</div>
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label-align="center" label="检查时间" class-name="zebra"
|
||||
>{{ safetyInspectionDetail?.violationTime }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label-align="center" label="检查人" class-name="zebra"
|
||||
>{{ safetyInspectionDetail?.createByName }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label-align="center" label="整改人" label-class-name="white"
|
||||
>{{ safetyInspectionDetail?.handlerName }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label-align="center" label="要求整改期限" label-class-name="white">
|
||||
{{ safetyInspectionDetail?.disposeDeadline ? dayjs(safetyInspectionDetail?.disposeDeadline).format('YYYY - MM - DD ') : '' }}
|
||||
</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
<el-descriptions border direction="vertical" size="large">
|
||||
<el-descriptions-item label-align="center" label="巡检结果" class-name="none"></el-descriptions-item>
|
||||
</el-descriptions>
|
||||
<el-descriptions :column="2" border label-width="160px" size="large">
|
||||
<el-descriptions-item label-align="center" label="内容" :span="2" label-class-name="white"
|
||||
>{{ safetyInspectionDetail?.recognizeVo.description }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label-align="center" label="检查附件" :span="2" label-class-name="white">
|
||||
<el-space wrap>
|
||||
<!-- <div v-for="item in checkFileList" :key="item.ossId">
|
||||
<span v-if="['.png', '.jpg', '.jpeg'].includes(item.fileSuffix)">
|
||||
<image-preview :src="item.url" width="200px" />
|
||||
</span>
|
||||
<span v-else>
|
||||
<el-link :href="`${item.url}`" type="primary" :underline="false" target="_blank">
|
||||
<span> {{ item.originalName }} </span>
|
||||
</el-link>
|
||||
</span>
|
||||
</div> -->
|
||||
<span>
|
||||
<image-preview :src="safetyInspectionDetail?.recognizeVo.picture" width="200px" />
|
||||
</span>
|
||||
</el-space>
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label-align="center" label="检查状态" :span="2" label-class-name="white">
|
||||
<el-steps style="max-width: 200px" :active="Number(safetyInspectionDetail?.status)" finish-status="finish">
|
||||
<el-step v-for="item in safety_inspection_type" :key="item.value" :title="item.label" />
|
||||
</el-steps>
|
||||
</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- </el-card> -->
|
||||
<!-- <div class="dialog-footer">
|
||||
<div class="btn-item" @click="handleExport">
|
||||
<img src="../../../../assets/icons/svg/derived.png" />
|
||||
<span>导出</span>
|
||||
</div>
|
||||
<div class="btn-item" v-print="'#printMe'">
|
||||
<img src="../../../../assets/icons/svg/print.png" />
|
||||
<span>打印</span>
|
||||
</div>
|
||||
</div> -->
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { useUserStoreHook } from '@/store/modules/user';
|
||||
import { downLoadOss, listByIds } from '@/api/system/oss';
|
||||
import { OssVO } from '@/api/system/oss/types';
|
||||
import { dayjs } from 'element-plus';
|
||||
import { getViolationRecord } from '@/api/safety/violationRecord';
|
||||
import { ViolationRecordVO } from '@/api/safety/violationRecord/types';
|
||||
|
||||
interface Props {
|
||||
violationRecordId?: string | number;
|
||||
}
|
||||
|
||||
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
|
||||
const { violation_level_type, safety_inspection_type, risk_level_type } = toRefs<any>(
|
||||
proxy?.useDict('violation_level_type', 'review_type', 'reply_type', 'safety_inspection_type', 'risk_level_type')
|
||||
);
|
||||
// 获取用户 store
|
||||
const userStore = useUserStoreHook();
|
||||
// 从 store 中获取项目列表和当前选中的项目
|
||||
const currentProject = computed(() => userStore.selectedProject);
|
||||
const props = defineProps<Props>();
|
||||
const loading = ref<boolean>(false);
|
||||
const safetyInspectionDetail = ref<any>();
|
||||
const checkFileList = ref<OssVO[]>();
|
||||
const rectificationFileList = ref<OssVO[]>();
|
||||
//检查状态图片
|
||||
const inspectionType = computed(() => {
|
||||
let imgName = 'successLogo';
|
||||
if (safetyInspectionDetail.value?.status == '2') imgName = 'rectification';
|
||||
if (safetyInspectionDetail.value?.reviewType == '1') imgName = 'successful';
|
||||
if (safetyInspectionDetail.value?.reviewType == '2') imgName = 'failure';
|
||||
console.log('🚀 ~ inspectionType ~ imgName:', imgName);
|
||||
|
||||
return imgName;
|
||||
});
|
||||
|
||||
const get = async () => {
|
||||
loading.value = true;
|
||||
const res = await getViolationRecord(props.violationRecordId);
|
||||
if (res.data && res.code === 200) {
|
||||
safetyInspectionDetail.value = res.data;
|
||||
if (res.data.checkFile) {
|
||||
const checkFileRes = await listByIds(res.data.checkFile.split(','));
|
||||
checkFileList.value = checkFileRes.data;
|
||||
}
|
||||
if (res.data.rectificationFile) {
|
||||
const rectificationFileRes = await listByIds(res.data.rectificationFile.split(','));
|
||||
rectificationFileList.value = rectificationFileRes.data;
|
||||
}
|
||||
}
|
||||
loading.value = false;
|
||||
};
|
||||
|
||||
const handleExport = async () => {
|
||||
await downLoadOss({ id: safetyInspectionDetail.value.id }, '/safety/safetyInspection/export/word', '安全生产监督检查通知书.zip');
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
console.log('🚀 ~ onMounted ~ props.safetyInspectionId:', props.violationRecordId);
|
||||
get();
|
||||
});
|
||||
|
||||
watch(
|
||||
() => props.violationRecordId,
|
||||
(newId, oldId) => {
|
||||
if (newId !== oldId) {
|
||||
checkFileList.value = undefined;
|
||||
rectificationFileList.value = undefined;
|
||||
get();
|
||||
}
|
||||
}
|
||||
);
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
#printMe {
|
||||
padding: 15px 20px 20px 20px !important;
|
||||
box-shadow: 0px 0px 12px rgba(0, 0, 0, 0.12);
|
||||
}
|
||||
|
||||
:deep(.white) {
|
||||
background: #fff !important;
|
||||
}
|
||||
|
||||
:deep(.none) {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
:deep(.zebra) {
|
||||
background: #f5f7fa;
|
||||
}
|
||||
|
||||
@page {
|
||||
size: auto;
|
||||
margin: 0mm;
|
||||
}
|
||||
|
||||
.dialog-footer {
|
||||
height: 200px;
|
||||
display: flex;
|
||||
|
||||
flex-direction: column;
|
||||
justify-content: space-between;
|
||||
position: absolute;
|
||||
top: 14%;
|
||||
right: 6%;
|
||||
background: #fff;
|
||||
box-shadow: 0 0 10px #ddd;
|
||||
text-align: center;
|
||||
padding: 20px 10px;
|
||||
|
||||
.btn-item {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
|
||||
.resultIcon {
|
||||
position: absolute;
|
||||
top: 100px;
|
||||
right: 50px;
|
||||
z-index: 10;
|
||||
width: 105px;
|
||||
height: 105px;
|
||||
img {
|
||||
width: 105px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
307
src/views/safety/violationRecord/index.vue
Normal file
307
src/views/safety/violationRecord/index.vue
Normal file
@ -0,0 +1,307 @@
|
||||
<template>
|
||||
<div class="p-2">
|
||||
<transition :enter-active-class="proxy?.animate.searchAnimate.enter" :leave-active-class="proxy?.animate.searchAnimate.leave">
|
||||
<div v-show="showSearch" class="mb-[10px]">
|
||||
<el-card shadow="hover">
|
||||
<el-form ref="queryFormRef" :model="queryParams" :inline="true">
|
||||
<el-form-item label="工单号" prop="id">
|
||||
<el-input v-model="queryParams.id" placeholder="请输入工单号" clearable @keyup.enter="handleQuery" />
|
||||
</el-form-item>
|
||||
<el-form-item label="违章时间" prop="violationTime">
|
||||
<el-date-picker clearable v-model="queryParams.violationTime" type="date" value-format="YYYY-MM-DD" placeholder="请选择违章时间" />
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
|
||||
<el-button icon="Refresh" @click="resetQuery">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-card>
|
||||
</div>
|
||||
</transition>
|
||||
|
||||
<el-card shadow="never">
|
||||
<template #header>
|
||||
<el-row :gutter="10" class="mb8">
|
||||
<el-col :span="1.5">
|
||||
<el-button type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete()" v-hasPermi="['safety:violationRecord:remove']"
|
||||
>删除</el-button
|
||||
>
|
||||
</el-col>
|
||||
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
|
||||
</el-row>
|
||||
</template>
|
||||
|
||||
<el-table v-loading="loading" :data="violationRecordList" @selection-change="handleSelectionChange">
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column label="工单号" align="center" prop="id" v-if="true" />
|
||||
<el-table-column label="违章等级" align="center" prop="levelVo" width="180">
|
||||
<template #default="scope">
|
||||
<div class="flex justify-center">
|
||||
{{ scope.row.levelVo.violationLevel }}:<dict-tag :options="risk_level_type" :value="scope.row.levelVo.riskType" />
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="违章类型" align="center" prop="violationType">
|
||||
<template #default="scope">
|
||||
<dict-tag :options="violation_level_type" :value="scope.row.violationType" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="违章时间" align="center" prop="violationTime" width="180">
|
||||
<template #default="scope">
|
||||
<span>{{ parseTime(scope.row.violationTime, '{y}-{m}-{d}') }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="处理人" align="center" prop="handlerName" />
|
||||
<el-table-column label="整改措施" align="center" prop="measure" />
|
||||
<el-table-column label="整改时间" align="center" prop="rectificationTime" width="180">
|
||||
<template #default="scope">
|
||||
<span>{{ parseTime(scope.row.rectificationTime, '{y}-{m}-{d}') }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="复查情况" align="center" prop="review" />
|
||||
<el-table-column label="复查状态" align="center" prop="reviewType">
|
||||
<template #default="scope">
|
||||
{{ scope.row.reviewType ? (scope.row.reviewType == 1 ? '已通过' : '未通过') : '' }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="复查时间" align="center" prop="reviewTime" width="180">
|
||||
<template #default="scope">
|
||||
<span>{{ parseTime(scope.row.reviewTime, '{y}-{m}-{d}') }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<!-- <el-table-column label="处理流程类型(0仅通知 1通知整改复查)" align="center" prop="processType" /> -->
|
||||
<el-table-column label="工单状态" align="center" prop="status">
|
||||
<template #default="scope">
|
||||
<dict-tag :options="safety_inspection_type" :value="scope.row.status" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="备注" align="center" prop="remark" />
|
||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||
<template #default="scope">
|
||||
<el-tooltip content="详情" placement="top">
|
||||
<el-button
|
||||
link
|
||||
type="primary"
|
||||
icon="View"
|
||||
@click="handleShowDialog(scope.row)"
|
||||
v-hasPermi="['safety:violationRecord:view']"
|
||||
></el-button>
|
||||
</el-tooltip>
|
||||
<el-tooltip content="违章处理人" placement="top">
|
||||
<el-button link type="primary" icon="User" @click="handleUpdate(scope.row)" v-hasPermi="['safety:violationRecord:edit']"></el-button>
|
||||
</el-tooltip>
|
||||
<el-tooltip content="删除" placement="top">
|
||||
<el-button link type="danger" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['safety:violationRecord:remove']"></el-button>
|
||||
</el-tooltip>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" @pagination="getList" />
|
||||
</el-card>
|
||||
<!-- 添加或修改违规记录对话框 -->
|
||||
<el-dialog :title="dialog.title" v-model="dialog.visible" width="500px" append-to-body>
|
||||
<el-form ref="violationRecordFormRef" :model="form" :rules="rules" label-width="90px">
|
||||
<el-form-item label="违章处理人" prop="handlerId">
|
||||
<el-input v-model="form.handlerId" placeholder="请输入违章处理人" />
|
||||
</el-form-item>
|
||||
<el-form-item label="处理期限" prop="disposeDeadline">
|
||||
<el-date-picker clearable v-model="form.disposeDeadline" type="datetime" value-format="YYYY-MM-DD HH:mm:ss" placeholder="请选择处理期限">
|
||||
</el-date-picker>
|
||||
</el-form-item>
|
||||
<el-form-item label="备注" prop="remark">
|
||||
<el-input v-model="form.remark" placeholder="请输入备注" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<el-button :loading="buttonLoading" type="primary" @click="submitForm">确 定</el-button>
|
||||
<el-button @click="cancel">取 消</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
<el-dialog title="违规记录详情" v-model="showDetailDialog" width="60vw">
|
||||
<ViolationRecordDetailDialog :violation-record-id="currentViolationRecordId" />
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup name="ViolationRecord" lang="ts">
|
||||
import { listViolationRecord, getViolationRecord, delViolationRecord, addViolationRecord, updateViolationRecord } from '@/api/safety/violationRecord';
|
||||
import { ViolationRecordVO, ViolationRecordQuery, ViolationRecordForm } from '@/api/safety/violationRecord/types';
|
||||
import ViolationRecordDetailDialog from './component/violationRecordDetailDialog.vue';
|
||||
|
||||
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
|
||||
const { violation_level_type, risk_level_type, safety_inspection_type } = toRefs<any>(
|
||||
proxy?.useDict('violation_level_type', 'risk_level_type', 'safety_inspection_type')
|
||||
);
|
||||
|
||||
const violationRecordList = ref<ViolationRecordVO[]>([]);
|
||||
const buttonLoading = ref(false);
|
||||
const loading = ref(true);
|
||||
const showSearch = ref(true);
|
||||
const ids = ref<Array<string | number>>([]);
|
||||
const single = ref(true);
|
||||
const multiple = ref(true);
|
||||
const total = ref(0);
|
||||
const currentViolationRecordId = ref<string | number>(undefined);
|
||||
const showDetailDialog = ref(false);
|
||||
|
||||
const queryFormRef = ref<ElFormInstance>();
|
||||
const violationRecordFormRef = ref<ElFormInstance>();
|
||||
|
||||
const dialog = reactive<DialogOption>({
|
||||
visible: false,
|
||||
title: ''
|
||||
});
|
||||
|
||||
const initFormData: ViolationRecordForm = {
|
||||
id: undefined,
|
||||
projectId: undefined,
|
||||
levelId: undefined,
|
||||
recognizeId: undefined,
|
||||
violationType: undefined,
|
||||
violationTime: undefined,
|
||||
handlerId: undefined,
|
||||
disposeDeadline: undefined,
|
||||
disposeTime: undefined,
|
||||
measure: undefined,
|
||||
rectificationTime: undefined,
|
||||
review: undefined,
|
||||
reviewType: undefined,
|
||||
reviewTime: undefined,
|
||||
processType: undefined,
|
||||
status: undefined,
|
||||
remark: undefined
|
||||
};
|
||||
const data = reactive<PageData<ViolationRecordForm, ViolationRecordQuery>>({
|
||||
form: { ...initFormData },
|
||||
queryParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
id: undefined,
|
||||
projectId: undefined,
|
||||
violationType: undefined,
|
||||
violationTime: undefined,
|
||||
handlerId: undefined,
|
||||
disposeDeadline: undefined,
|
||||
disposeTime: undefined,
|
||||
measure: undefined,
|
||||
rectificationTime: undefined,
|
||||
review: undefined,
|
||||
reviewType: undefined,
|
||||
reviewTime: undefined,
|
||||
processType: undefined,
|
||||
status: undefined,
|
||||
params: {}
|
||||
},
|
||||
rules: {
|
||||
id: [{ required: true, message: '主键id不能为空', trigger: 'blur' }],
|
||||
projectId: [{ required: true, message: '项目id不能为空', trigger: 'blur' }],
|
||||
levelId: [{ required: true, message: '违章等级id不能为空', trigger: 'blur' }],
|
||||
recognizeId: [{ required: true, message: '识别记录id不能为空', trigger: 'blur' }],
|
||||
processType: [{ required: true, message: '处理流程类型(0仅通知 1通知整改复查)不能为空', trigger: 'change' }],
|
||||
status: [{ required: true, message: '工单状态不能为空', trigger: 'change' }]
|
||||
}
|
||||
});
|
||||
|
||||
const { queryParams, form, rules } = toRefs(data);
|
||||
|
||||
/** 查询违规记录列表 */
|
||||
const getList = async () => {
|
||||
loading.value = true;
|
||||
const res = await listViolationRecord(queryParams.value);
|
||||
violationRecordList.value = res.rows;
|
||||
total.value = res.total;
|
||||
loading.value = false;
|
||||
};
|
||||
|
||||
/** 取消按钮 */
|
||||
const cancel = () => {
|
||||
reset();
|
||||
dialog.visible = false;
|
||||
};
|
||||
|
||||
/** 表单重置 */
|
||||
const reset = () => {
|
||||
form.value = { ...initFormData };
|
||||
violationRecordFormRef.value?.resetFields();
|
||||
};
|
||||
|
||||
/** 搜索按钮操作 */
|
||||
const handleQuery = () => {
|
||||
queryParams.value.pageNum = 1;
|
||||
getList();
|
||||
};
|
||||
|
||||
/** 重置按钮操作 */
|
||||
const resetQuery = () => {
|
||||
queryFormRef.value?.resetFields();
|
||||
handleQuery();
|
||||
};
|
||||
|
||||
/** 多选框选中数据 */
|
||||
const handleSelectionChange = (selection: ViolationRecordVO[]) => {
|
||||
ids.value = selection.map((item) => item.id);
|
||||
single.value = selection.length != 1;
|
||||
multiple.value = !selection.length;
|
||||
};
|
||||
|
||||
/** 新增按钮操作 */
|
||||
const handleAdd = () => {
|
||||
reset();
|
||||
dialog.visible = true;
|
||||
dialog.title = '添加违规记录';
|
||||
};
|
||||
|
||||
/** 修改按钮操作 */
|
||||
const handleUpdate = async (row?: ViolationRecordVO) => {
|
||||
reset();
|
||||
form.value.id = row.id;
|
||||
dialog.visible = true;
|
||||
dialog.title = '选择违章处理人';
|
||||
};
|
||||
|
||||
const handleShowDialog = (row?: ViolationRecordVO) => {
|
||||
currentViolationRecordId.value = row.id;
|
||||
showDetailDialog.value = true;
|
||||
};
|
||||
|
||||
/** 提交按钮 */
|
||||
const submitForm = () => {
|
||||
violationRecordFormRef.value?.validate(async (valid: boolean) => {
|
||||
if (valid) {
|
||||
buttonLoading.value = true;
|
||||
await addViolationRecord(form.value).finally(() => (buttonLoading.value = false));
|
||||
proxy?.$modal.msgSuccess('操作成功');
|
||||
dialog.visible = false;
|
||||
await getList();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/** 删除按钮操作 */
|
||||
const handleDelete = async (row?: ViolationRecordVO) => {
|
||||
const _ids = row?.id || ids.value;
|
||||
await proxy?.$modal.confirm('是否确认删除违规记录编号为"' + _ids + '"的数据项?').finally(() => (loading.value = false));
|
||||
await delViolationRecord(_ids);
|
||||
proxy?.$modal.msgSuccess('删除成功');
|
||||
await getList();
|
||||
};
|
||||
|
||||
/** 导出按钮操作 */
|
||||
const handleExport = () => {
|
||||
proxy?.download(
|
||||
'safety/violationRecord/export',
|
||||
{
|
||||
...queryParams.value
|
||||
},
|
||||
`violationRecord_${new Date().getTime()}.xlsx`
|
||||
);
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
getList();
|
||||
});
|
||||
</script>
|
||||
Reference in New Issue
Block a user