优化
This commit is contained in:
110
src/views/safety/safetyWeeklyReport/component/add.vue
Normal file
110
src/views/safety/safetyWeeklyReport/component/add.vue
Normal file
@ -0,0 +1,110 @@
|
||||
<template>
|
||||
<div class="system-busWeeklySecurityReport-add">
|
||||
<!-- 添加或修改安全周期对话框 -->
|
||||
<el-dialog v-model="isShowDialog" width="500px" :close-on-click-modal="false" :destroy-on-close="true">
|
||||
<template #header>
|
||||
<div v-drag="['.system-busWeeklySecurityReport-add .el-dialog', '.system-busWeeklySecurityReport-add .el-dialog__header']">添加安全周期</div>
|
||||
</template>
|
||||
<el-form ref="formRef" :model="formData" :rules="rules" label-width="90px">
|
||||
<el-form-item label="周期范围" prop="timeRange">
|
||||
<el-date-picker
|
||||
format="YYYY-MM-DD"
|
||||
value-format="YYYY-MM-DD"
|
||||
v-model="formData.timeRange"
|
||||
type="daterange"
|
||||
range-separator="至"
|
||||
start-placeholder="开始时间"
|
||||
end-placeholder="结束时间"
|
||||
size="large"
|
||||
/>
|
||||
</el-form-item>
|
||||
</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 lang="ts">
|
||||
import { reactive, toRefs, defineComponent, ref, unref, getCurrentInstance } from 'vue';
|
||||
import { ElMessageBox, ElMessage } from 'element-plus';
|
||||
import { addSafetyWeeklyReport } from '@/api/safety/safetyWeeklyReport';
|
||||
// 获取用户 store
|
||||
import { useUserStoreHook } from '@/store/modules/user';
|
||||
const userStore = useUserStoreHook();
|
||||
// 从 store 中获取项目列表和当前选中的项目
|
||||
const currentProject = computed(() => userStore.selectedProject);
|
||||
export default defineComponent({
|
||||
name: 'index',
|
||||
setup(props, { emit }) {
|
||||
const { proxy } = <any>getCurrentInstance();
|
||||
const formRef = ref<HTMLElement | null>(null);
|
||||
const menuRef = ref();
|
||||
const state = reactive({
|
||||
loading: false,
|
||||
isShowDialog: false,
|
||||
formData: {
|
||||
timeRange: [],
|
||||
projectId: currentProject.value?.goId
|
||||
},
|
||||
// 表单校验
|
||||
rules: {
|
||||
timeRange: [{ required: true, message: '时间范围不能为空', trigger: 'blur' }]
|
||||
}
|
||||
});
|
||||
// 打开弹窗
|
||||
const openDialog = () => {
|
||||
resetForm();
|
||||
state.isShowDialog = true;
|
||||
};
|
||||
// 关闭弹窗
|
||||
const closeDialog = () => {
|
||||
state.isShowDialog = false;
|
||||
};
|
||||
// 取消
|
||||
const onCancel = () => {
|
||||
closeDialog();
|
||||
};
|
||||
// 提交
|
||||
const onSubmit = () => {
|
||||
const formWrap = unref(formRef) as any;
|
||||
if (!formWrap) return;
|
||||
formWrap.validate((valid: boolean) => {
|
||||
if (valid) {
|
||||
state.loading = true;
|
||||
let timeRange = state.formData.timeRange.join(',');
|
||||
addSafetyWeeklyReport({ projectId: state.formData.projectId, timeRange })
|
||||
.then(() => {
|
||||
ElMessage.success('添加成功');
|
||||
closeDialog(); // 关闭弹窗
|
||||
emit('busWeeklySecurityReportList');
|
||||
})
|
||||
.finally(() => {
|
||||
state.loading = false;
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
const resetForm = () => {
|
||||
state.formData = {
|
||||
timeRange: [],
|
||||
projectId: currentProject.value?.goId
|
||||
};
|
||||
};
|
||||
return {
|
||||
proxy,
|
||||
openDialog,
|
||||
closeDialog,
|
||||
onCancel,
|
||||
onSubmit,
|
||||
menuRef,
|
||||
formRef,
|
||||
...toRefs(state)
|
||||
};
|
||||
}
|
||||
});
|
||||
</script>
|
||||
<style scoped></style>
|
@ -0,0 +1,186 @@
|
||||
<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 { toRefs, reactive, onMounted, defineComponent, getCurrentInstance } from 'vue';
|
||||
import { setMove } from '@/utils/moveDiv';
|
||||
import { getSafetyWeeklyReport } from '@/api/safety/safetyWeeklyReport';
|
||||
|
||||
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.name;
|
||||
getSafetyWeeklyReport(obj.id).then((res: any) => {
|
||||
console.log(res);
|
||||
if (res.code == 0) {
|
||||
init(res.data);
|
||||
}
|
||||
});
|
||||
};
|
||||
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 baseURL = window['$HOSTSRC'].replace('ws:', 'http:').replace('/ws', '');
|
||||
let url = baseURL + obj.path;
|
||||
new CXO_API.CXEditor('box_app', {
|
||||
document: {
|
||||
fileType: 'docx',
|
||||
key: documentKey,
|
||||
title: '周报',
|
||||
url
|
||||
},
|
||||
documentType: 'word',
|
||||
editorConfig: {
|
||||
mode: 'view',
|
||||
callbackUrl: ''
|
||||
},
|
||||
height: '100%',
|
||||
events: {
|
||||
onDocumentReady: onDocumentReady,
|
||||
onError: onError
|
||||
}
|
||||
});
|
||||
};
|
||||
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">
|
||||
.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>
|
@ -0,0 +1,187 @@
|
||||
<template>
|
||||
<div class="document_detail_eidt1" id="document_detail_eidt1">
|
||||
<div class="move_pop" id="detial_edit1">
|
||||
<!-- <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_edit1"></div>
|
||||
</div>
|
||||
</template>
|
||||
<script lang="ts">
|
||||
import { toRefs, reactive, onMounted, ref, defineComponent, watch, getCurrentInstance } from 'vue';
|
||||
import { setMove } from '@/utils/moveDiv';
|
||||
import { getSafetyWeeklyReport } from '@/api/safety/safetyWeeklyReport';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'index',
|
||||
setup(props, { emit }) {
|
||||
const { proxy } = <any>getCurrentInstance();
|
||||
const state = reactive({
|
||||
title: '',
|
||||
type: 2
|
||||
});
|
||||
onMounted(() => {
|
||||
setMove('detial_edit1', 'document_detail_eidt1');
|
||||
});
|
||||
// 打开弹窗
|
||||
const openDialog = (obj) => {
|
||||
getSafetyWeeklyReport(obj.id).then((res: any) => {
|
||||
if (res.code == 0) {
|
||||
init(res.data);
|
||||
}
|
||||
});
|
||||
};
|
||||
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();
|
||||
window['$HOSTSRC'] = 'ws://58.17.134.85:8920/ws';
|
||||
let baseURL = window['$HOSTSRC'].replace('ws:', 'http:').replace('/ws', '');
|
||||
let url = baseURL + obj.path;
|
||||
new CXO_API.CXEditor('box_app_edit1', {
|
||||
document: {
|
||||
fileType: 'docx',
|
||||
key: documentKey,
|
||||
title: '周报',
|
||||
url
|
||||
},
|
||||
documentType: 'word',
|
||||
editorConfig: {
|
||||
callbackUrl: baseURL + '/zm/api/v1/system/busWeeklySecurityReport/securityReportAdd?path=' + obj.path
|
||||
},
|
||||
events: {
|
||||
onDocumentReady: onDocumentReady,
|
||||
onError: onError
|
||||
}
|
||||
});
|
||||
};
|
||||
const onClose = () => {
|
||||
emit('onClose', false);
|
||||
};
|
||||
const onFull = (type) => {
|
||||
// 全屏
|
||||
let document_detail = document.getElementById('document_detail_eidt1');
|
||||
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">
|
||||
.document_detail_eidt1 {
|
||||
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>
|
BIN
src/views/safety/safetyWeeklyReport/component/icon/full.png
Normal file
BIN
src/views/safety/safetyWeeklyReport/component/icon/full.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.8 KiB |
BIN
src/views/safety/safetyWeeklyReport/component/icon/suo.png
Normal file
BIN
src/views/safety/safetyWeeklyReport/component/icon/suo.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.4 KiB |
58
src/views/safety/safetyWeeklyReport/component/model.ts
Normal file
58
src/views/safety/safetyWeeklyReport/component/model.ts
Normal file
@ -0,0 +1,58 @@
|
||||
export interface BusWeeklySecurityReportTableColumns {
|
||||
id:number; // 主键ID
|
||||
projectId:number; // 项目ID
|
||||
projectName:string; // 项目名称
|
||||
scope:string; // 周期范围
|
||||
scopeEnd:string; // 周期范围结束
|
||||
path:string; // 文件位置
|
||||
createBy:string; // 创建者
|
||||
updateBy:string; // 更新者
|
||||
createdAt:string; // 创建时间
|
||||
}
|
||||
|
||||
|
||||
export interface BusWeeklySecurityReportInfoData {
|
||||
id:number|undefined; // 主键ID
|
||||
projectId:number|undefined; // 项目ID
|
||||
projectName:string|undefined; // 项目名称
|
||||
scope:string|undefined; // 周期范围
|
||||
scopeEnd:string|undefined; // 周期范围结束
|
||||
path:string|undefined; // 文件位置
|
||||
createBy:string|undefined; // 创建者
|
||||
updateBy:string|undefined; // 更新者
|
||||
createdAt:string|undefined; // 创建时间
|
||||
updatedAt:string|undefined; // 更新时间
|
||||
deletedAt:string|undefined; // 删除时间
|
||||
}
|
||||
|
||||
|
||||
export interface BusWeeklySecurityReportTableDataState {
|
||||
ids:any[];
|
||||
tableData: {
|
||||
data: Array<BusWeeklySecurityReportTableColumns>;
|
||||
total: number;
|
||||
loading: boolean;
|
||||
param: {
|
||||
pageNum: number;
|
||||
pageSize: number;
|
||||
id: number|undefined;
|
||||
projectId: number|undefined;
|
||||
projectName: string|undefined;
|
||||
scope: string|undefined;
|
||||
scopeEnd: string|undefined;
|
||||
path: string|undefined;
|
||||
createBy: string|undefined;
|
||||
updateBy: string|undefined;
|
||||
createdAt: string|undefined;
|
||||
dateRange: string[];
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
export interface BusWeeklySecurityReportEditState{
|
||||
loading:boolean;
|
||||
isShowDialog: boolean;
|
||||
formData:BusWeeklySecurityReportInfoData;
|
||||
rules: object;
|
||||
}
|
Reference in New Issue
Block a user