pdf 上传 代码调整
This commit is contained in:
parent
3bbfae4082
commit
57feb88e6c
@ -1,13 +1,22 @@
|
||||
import request from '@/utils/request';
|
||||
|
||||
/** 创建分组 */
|
||||
/** 创建 */
|
||||
export function postUploadFile(data) {
|
||||
return request({
|
||||
url: `/api/file`,
|
||||
url: `/api/file/basic`,
|
||||
method: 'post',
|
||||
data
|
||||
});
|
||||
}
|
||||
|
||||
// /** 复制一条文件基础信息 */
|
||||
// export function copyUploadFile(id) {
|
||||
// return request({
|
||||
// url: `/api/file/basic/copy/${id}`,
|
||||
// method: 'post'
|
||||
// });
|
||||
// }
|
||||
|
||||
// 查询
|
||||
export function getUploadFile(params) {
|
||||
return request({
|
||||
@ -19,15 +28,27 @@ export function getUploadFile(params) {
|
||||
// 修改
|
||||
export function putUploadFile(data) {
|
||||
return request({
|
||||
url: `/api/file`,
|
||||
url: `/api/file/basic`,
|
||||
method: 'put',
|
||||
data
|
||||
});
|
||||
}
|
||||
// 删除
|
||||
export function deleteUploadFile(data) {
|
||||
export function deleteUploadFile(id) {
|
||||
return request({
|
||||
url: `/api/file`,
|
||||
url: `/api/file/${id}`,
|
||||
method: 'delete'
|
||||
});
|
||||
}
|
||||
|
||||
// 查询文件绑定信息
|
||||
export function getFileBindInfo(fileId, mapId) {
|
||||
return request({
|
||||
url: `/api/file/binding/${fileId}/${mapId}`,
|
||||
method: 'get'
|
||||
});
|
||||
}
|
||||
|
||||
/** */
|
||||
// @GetMapping("")
|
||||
|
||||
|
87
src/views/uploadPdf/bindMap.vue
Normal file
87
src/views/uploadPdf/bindMap.vue
Normal file
@ -0,0 +1,87 @@
|
||||
<template>
|
||||
<el-dialog v-dialogDrag title="绑定地图数据" :visible.sync="dialogVisible" width="30%" :before-close="handleClose" center class="uploadDialog">
|
||||
<data-form ref="dataform" :form="form" :form-model="formModel" :rules="rules" />
|
||||
<span slot="footer" class="dialog-footer">
|
||||
<el-button type="primary" @click="doSave">{{ $t('global.confirm') }}</el-button>
|
||||
<el-button @click="handleClose">{{ $t('global.cancel') }}</el-button>
|
||||
</span>
|
||||
</el-dialog>
|
||||
</template>
|
||||
<script>
|
||||
import { getPublishMapList } from '@/api/jmap/map';
|
||||
import { getFileBindInfo } from '@/api/pdf';
|
||||
export default {
|
||||
name:'BindMap',
|
||||
data() {
|
||||
return {
|
||||
mapList:[],
|
||||
fileId:'',
|
||||
dialogVisible: false,
|
||||
formModel: {
|
||||
mapId:''
|
||||
}
|
||||
};
|
||||
},
|
||||
computed:{
|
||||
form() {
|
||||
const form = {
|
||||
labelWidth: '120px',
|
||||
items: [
|
||||
{ prop: 'mapId', label: '选择线路:', type:'select', options: this.mapList, optionValue:'id', optionLabel:'name' }
|
||||
// change: true, onChange: this.handleMap
|
||||
]
|
||||
};
|
||||
return form;
|
||||
},
|
||||
rules() {
|
||||
const crules = {
|
||||
mapId: [
|
||||
{ required: true, message: ' 地图不能为空', trigger: 'blur'},
|
||||
{ required: true, message: ' 地图不能为空', trigger: 'change'}
|
||||
]
|
||||
};
|
||||
return crules;
|
||||
}
|
||||
|
||||
},
|
||||
created() {
|
||||
const params = {
|
||||
pageSize: 9999,
|
||||
pageNum: 1
|
||||
};
|
||||
getPublishMapList(params).then(res => {
|
||||
this.mapList = res.data.list || [];
|
||||
});
|
||||
},
|
||||
methods:{
|
||||
doShow(data) {
|
||||
this.fileId = data.id;
|
||||
this.dialogVisible = true;
|
||||
},
|
||||
handleClose() {
|
||||
this.formModel = {
|
||||
mapId: ''
|
||||
};
|
||||
this.$refs.dataform.resetForm();
|
||||
this.dialogVisible = false;
|
||||
},
|
||||
doSave() {
|
||||
const self = this;
|
||||
this.$refs.dataform.validateForm(() => {
|
||||
if (self.fileId) {
|
||||
getFileBindInfo(self.fileId, self.formModel.mapId).then((res) => {
|
||||
let data = null;
|
||||
if (res.data) {
|
||||
data = res.data;
|
||||
}
|
||||
this.$refs.bindMapInfo.doShow(data);
|
||||
}).catch(error => {
|
||||
console.log(error);
|
||||
// self.$message.error(`上传PDF失败:${error.message}`);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
@ -1,6 +1,7 @@
|
||||
<template>
|
||||
<el-dialog v-dialogDrag :title="title" :visible.sync="dialogVisible" width="30%" :before-close="handleClose" center class="uploadDialog">
|
||||
<data-form ref="dataform" :form="form" :form-model="formModel" :rules="rules" />
|
||||
<div class="fileError">{{ message }}</div>
|
||||
<span slot="footer" class="dialog-footer">
|
||||
<el-button type="primary" @click="doSave">{{ $t('global.confirm') }}</el-button>
|
||||
<el-button @click="handleClose">{{ $t('global.cancel') }}</el-button>
|
||||
@ -10,8 +11,8 @@
|
||||
|
||||
<script>
|
||||
import { postUploadFile, putUploadFile } from '@/api/pdf';
|
||||
import { getPublishMapDetailById, getPublishMapVersionById } from '@/api/jmap/map';
|
||||
import { dbReadData, dbAddData, dbUpdateData } from '@/utils/indexedDb';
|
||||
// import { getPublishMapDetailById, getPublishMapVersionById } from '@/api/jmap/map';
|
||||
// import { dbReadData, dbAddData, dbUpdateData } from '@/utils/indexedDb';
|
||||
// uploadFile
|
||||
import { meansUrl } from '@/api/upload';
|
||||
|
||||
@ -21,39 +22,30 @@ export default {
|
||||
type: {
|
||||
type: String,
|
||||
required: true
|
||||
},
|
||||
mapList:{
|
||||
type: Array,
|
||||
required: true
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
dialogVisible: false,
|
||||
formModel: {
|
||||
// cityCode: '',
|
||||
mapId: '',
|
||||
deviceTypes: '',
|
||||
deviceIds: [],
|
||||
upload: '',
|
||||
filePath: '',
|
||||
fileType: 'DRAWING'
|
||||
fileType: 'DRAWING',
|
||||
fileName:''
|
||||
},
|
||||
rowData: null,
|
||||
graphDataNew: null,
|
||||
fileList: [],
|
||||
formData: '',
|
||||
id: '',
|
||||
deviceTypeList: [
|
||||
{ label: '区段', value: 'sectionList', code: 'SECTION' },
|
||||
{ label: '道岔', value: 'switchList', code: 'SWITCH' },
|
||||
{ label: '信号机', value: 'signalList', code: 'SIGNAL' },
|
||||
{ label: '车站', value: 'stationList', code: 'STATION' },
|
||||
{ label: '站台', value: 'stationStandList', code: 'STAND' },
|
||||
{ label: '屏蔽门', value: 'psdList', code: 'PSD' },
|
||||
{ label: '列车', value: 'trainList', code: 'TRAIN' }
|
||||
],
|
||||
deviceCodesList: []
|
||||
message:''
|
||||
// deviceTypeList: [
|
||||
// { label: '区段', value: 'sectionList', code: 'SECTION' },
|
||||
// { label: '道岔', value: 'switchList', code: 'SWITCH' },
|
||||
// { label: '信号机', value: 'signalList', code: 'SIGNAL' },
|
||||
// { label: '车站', value: 'stationList', code: 'STATION' },
|
||||
// { label: '站台', value: 'stationStandList', code: 'STAND' },
|
||||
// { label: '屏蔽门', value: 'psdList', code: 'PSD' },
|
||||
// { label: '列车', value: 'trainList', code: 'TRAIN' }
|
||||
// ],
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
@ -64,25 +56,23 @@ export default {
|
||||
const form = {
|
||||
labelWidth: '120px',
|
||||
items: [
|
||||
{ prop: 'mapId', label: '选择线路:', type:'select', options: this.mapList, optionValue:'id', optionLabel:'name', change: true, onChange: this.handleMap },
|
||||
{ prop: 'deviceTypes', label: '选择设备类型:', type:'select', options: this.deviceTypeList, optionValue:'value', optionLabel:'label', change: true, onChange: this.handleDevice },
|
||||
{ prop: 'deviceIds', label: '选择设备:', type:'select', multiple: true, options: this.deviceCodesList, optionValue:'code', optionLabel:'name' },
|
||||
{ prop: 'upload', label: '上传:', type:'uploadPicture', show: this.type == 'ADD', action: this.action, fileList: this.fileList, onChange: this.onChange, onSuccess: this.onSuccess }
|
||||
// { prop: 'mapId', label: '选择线路:', type:'select', options: this.mapList, optionValue:'id', optionLabel:'name', change: true, onChange: this.handleMap },
|
||||
// { prop: 'deviceTypes', label: '选择设备类型:', type:'select', options: this.deviceTypeList, optionValue:'value', optionLabel:'label', change: true, onChange: this.handleDevice },
|
||||
// { prop: 'deviceIds', label: '选择设备:', type:'select', multiple: true, options: this.deviceCodesList, optionValue:'code', optionLabel:'name' },
|
||||
{ prop: 'fileName', label: '文件名:', type:'text', show:true, rightWidth:true, required:true },
|
||||
{ prop: 'upload', label: '上传:', type:'uploadPicture', fileList: this.fileList, show: this.type == 'ADD', action: this.action, onChange: this.onChange, onSuccess: this.onSuccess }
|
||||
]
|
||||
};
|
||||
return form;
|
||||
},
|
||||
rules() {
|
||||
const crules = {
|
||||
mapId: [
|
||||
{ required: true, message: '请选择线路', trigger: 'change' }
|
||||
],
|
||||
deviceTypes: [
|
||||
{ required: true, message: '请选择设备类型', trigger: 'change' }
|
||||
],
|
||||
deviceIds: [
|
||||
{ required: true, message: '请选择设备', trigger: 'change' }
|
||||
fileName: [
|
||||
{ required: true, message: '文件名不能为空', trigger: 'blur'}
|
||||
]
|
||||
// upload: [
|
||||
// { required: true, message: '请上传文件', trigger: 'onChange' }
|
||||
// ]
|
||||
};
|
||||
return crules;
|
||||
},
|
||||
@ -90,7 +80,7 @@ export default {
|
||||
if (this.type === 'ADD') {
|
||||
return '上传PDF';
|
||||
} else {
|
||||
return '更新文章';
|
||||
return '更新PDF';
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -98,88 +88,84 @@ export default {
|
||||
async show(data) {
|
||||
this.dialogVisible = true;
|
||||
if (this.type != 'ADD') {
|
||||
const obj = this.deviceTypeList.find(el => el.code == data.deviceTypes[0]);
|
||||
this.id = data.id;
|
||||
this.rowData = data;
|
||||
this.rowData.deviceTypes = obj ? obj.value : '';
|
||||
this.formModel = {
|
||||
mapId: data.mapId,
|
||||
deviceTypes: obj ? obj.value : '',
|
||||
deviceIds: data.deviceIds,
|
||||
upload: '',
|
||||
fileName:data.fileName,
|
||||
filePath: data.filePath
|
||||
};
|
||||
await this.handleMap(data.mapId);
|
||||
obj && await this.handleDevice(obj.value);
|
||||
} else {
|
||||
this.rowData = {};
|
||||
this.formModel = {
|
||||
mapId: '',
|
||||
deviceTypes: '',
|
||||
deviceIds: [],
|
||||
upload: '',
|
||||
filePath: ''
|
||||
filePath: '',
|
||||
fileName:''
|
||||
};
|
||||
}
|
||||
},
|
||||
async handleMap(mapId) {
|
||||
if (mapId) {
|
||||
if (mapId != this.rowData.mapId) {
|
||||
this.formModel.deviceIds = [];
|
||||
this.formModel.deviceTypes = '';
|
||||
}
|
||||
return new Promise(async (resolve, reject) => {
|
||||
const resp = await getPublishMapVersionById(mapId);
|
||||
const version = resp.data;
|
||||
dbReadData('mapData', mapId, version, async (mapData, version) =>{
|
||||
if (mapData && mapData.version == version) {
|
||||
this.graphDataNew = mapData.graphDataNew;
|
||||
resolve();
|
||||
} else if (mapData) {
|
||||
const res = await getPublishMapDetailById(mapId);
|
||||
this.graphDataNew = res.data.graphDataNew;
|
||||
dbUpdateData('mapData', res.data);
|
||||
resolve();
|
||||
} else {
|
||||
const res = await getPublishMapDetailById(mapId);
|
||||
this.graphDataNew = res.data.graphDataNew;
|
||||
dbAddData('mapData', res.data);
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
});
|
||||
} else {
|
||||
this.formModel.deviceIds = [];
|
||||
this.formModel.mapId = '';
|
||||
this.formModel.deviceTypes = '';
|
||||
}
|
||||
},
|
||||
handleDevice(type) {
|
||||
if (type) {
|
||||
if (type != this.rowData.deviceTypes) {
|
||||
this.formModel.deviceIds = [];
|
||||
}
|
||||
this.deviceCodesList = this.graphDataNew[type].map(el => {
|
||||
return {
|
||||
code: el.code,
|
||||
name: `${el.name}(${el.code})`
|
||||
};
|
||||
});
|
||||
} else {
|
||||
this.formModel.deviceIds = [];
|
||||
}
|
||||
},
|
||||
// async handleMap(mapId) {
|
||||
// if (mapId) {
|
||||
// if (mapId != this.rowData.mapId) {
|
||||
// this.formModel.deviceIds = [];
|
||||
// this.formModel.deviceTypes = '';
|
||||
// }
|
||||
// return new Promise(async (resolve, reject) => {
|
||||
// const resp = await getPublishMapVersionById(mapId);
|
||||
// const version = resp.data;
|
||||
// dbReadData('mapData', mapId, version, async (mapData, version) =>{
|
||||
// if (mapData && mapData.version == version) {
|
||||
// this.graphDataNew = mapData.graphDataNew;
|
||||
// resolve();
|
||||
// } else if (mapData) {
|
||||
// const res = await getPublishMapDetailById(mapId);
|
||||
// this.graphDataNew = res.data.graphDataNew;
|
||||
// dbUpdateData('mapData', res.data);
|
||||
// resolve();
|
||||
// } else {
|
||||
// const res = await getPublishMapDetailById(mapId);
|
||||
// this.graphDataNew = res.data.graphDataNew;
|
||||
// dbAddData('mapData', res.data);
|
||||
// resolve();
|
||||
// }
|
||||
// });
|
||||
// });
|
||||
// } else {
|
||||
// this.formModel.deviceIds = [];
|
||||
// this.formModel.mapId = '';
|
||||
// this.formModel.deviceTypes = '';
|
||||
// }
|
||||
// },
|
||||
// handleDevice(type) {
|
||||
// if (type) {
|
||||
// if (type != this.rowData.deviceTypes) {
|
||||
// this.formModel.deviceIds = [];
|
||||
// }
|
||||
// this.deviceCodesList = this.graphDataNew[type].map(el => {
|
||||
// return {
|
||||
// code: el.code,
|
||||
// name: `${el.name}(${el.code})`
|
||||
// };
|
||||
// });
|
||||
// } else {
|
||||
// this.formModel.deviceIds = [];
|
||||
// }
|
||||
// },
|
||||
// uploadFile(file) {
|
||||
// this.formData.append('file', file.file);
|
||||
// },
|
||||
onSuccess(res, file) {
|
||||
this.formModel.filePath = res.data;
|
||||
this.message = '';
|
||||
},
|
||||
doSave() {
|
||||
const self = this;
|
||||
this.$refs.dataform.validateForm(() => {
|
||||
if (self.type == 'ADD') {
|
||||
if (this.formModel.filePath) {
|
||||
self.create();
|
||||
} else {
|
||||
this.message = '请上传文件';
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
self.update();
|
||||
}
|
||||
@ -187,16 +173,10 @@ export default {
|
||||
},
|
||||
create() {
|
||||
const self = this;
|
||||
const obj = this.deviceTypeList.find(el => el.value == this.formModel.deviceTypes);
|
||||
if (obj) {
|
||||
this.formModel.deviceTypes = [obj.code];
|
||||
}
|
||||
const data = {
|
||||
fileType: 'DRAWING',
|
||||
mapId: this.formModel.mapId,
|
||||
deviceTypes: this.formModel.deviceTypes,
|
||||
deviceIds: this.formModel.deviceIds,
|
||||
filePath: this.formModel.filePath
|
||||
filePath: this.formModel.filePath,
|
||||
fileName:this.formModel.fileName
|
||||
};
|
||||
postUploadFile(data).then((res) => {
|
||||
self.$message.success('上传PDF成功!');
|
||||
@ -204,34 +184,31 @@ export default {
|
||||
self.$emit('reloadTable');
|
||||
}).catch(error => {
|
||||
console.log(error);
|
||||
self.$message.error(`创建文章失败:${error.message}`);
|
||||
self.$message.error(`上传PDF失败:${error.message}`);
|
||||
});
|
||||
},
|
||||
update() {
|
||||
const self = this;
|
||||
const obj = this.deviceTypeList.find(el => el.value == this.formModel.deviceTypes);
|
||||
if (obj) {
|
||||
this.formModel.deviceTypes = [obj.code];
|
||||
}
|
||||
const data = {
|
||||
id: this.id,
|
||||
fileType: 'DRAWING',
|
||||
mapId: this.formModel.mapId,
|
||||
deviceTypes: this.formModel.deviceTypes,
|
||||
deviceIds: this.formModel.deviceIds,
|
||||
fileName:this.formModel.fileName,
|
||||
filePath: this.formModel.filePath
|
||||
};
|
||||
putUploadFile(data).then(() => {
|
||||
self.$message.success('更新文章成功!');
|
||||
self.$message.success('更新PDF成功!');
|
||||
self.handleClose();
|
||||
self.$emit('reloadTable');
|
||||
}).catch(error => {
|
||||
self.$message.error(`更新文章失败:${error.message}`);
|
||||
self.$message.error(`更新PDF失败:${error.message}`);
|
||||
});
|
||||
},
|
||||
handleClose() {
|
||||
this.message = '';
|
||||
this.formModel = {
|
||||
title: ''
|
||||
upload: '',
|
||||
filePath: '',
|
||||
fileName:''
|
||||
};
|
||||
this.$refs.dataform.resetForm();
|
||||
this.dialogVisible = false;
|
||||
@ -248,4 +225,12 @@ export default {
|
||||
}
|
||||
}
|
||||
}
|
||||
.fileError{
|
||||
color: red;
|
||||
font-size: 13px;
|
||||
margin-left: 122px;
|
||||
vertical-align: top;
|
||||
display: inline-block;
|
||||
margin-top: -10px;
|
||||
}
|
||||
</style>
|
||||
|
@ -4,12 +4,11 @@
|
||||
<el-card>
|
||||
<el-form
|
||||
ref="queryForm"
|
||||
:model="formModel"
|
||||
size="small"
|
||||
style="padding: 6px 20px 6px 20px;overflow: hidden;"
|
||||
>
|
||||
<el-form-item label="地图" style="margin-bottom: 0;float: left; width: 300px;">
|
||||
<el-select v-model="formModel.mapId" placeholder="请选择" filterable style="width: 240px;" @change="handleMap">
|
||||
<!-- <el-form-item label="地图" style="margin-bottom: 0;float: left; width: 300px;">
|
||||
<el-select v-model="formModel.mapId" placeholder="请选择" clearable filterable style="width: 240px;" @change="handleMap">
|
||||
<el-option
|
||||
v-for="item in mapList"
|
||||
:key="item.id"
|
||||
@ -17,8 +16,8 @@
|
||||
:value="item.id"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="设备类型" style="margin-bottom: 0;float: left; width:350px;">
|
||||
</el-form-item> -->
|
||||
<!-- <el-form-item label="设备类型" style="margin-bottom: 0;float: left; width:350px;">
|
||||
<el-select v-model="formModel.deviceType" placeholder="请选择" filterable clearable style="width: 240px;" @change="handleDevice">
|
||||
<el-option
|
||||
v-for="item in deviceTypeList"
|
||||
@ -27,8 +26,8 @@
|
||||
:value="item.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="设备id" style="margin-bottom: 0;float: left; width: 300px;">
|
||||
</el-form-item> -->
|
||||
<!-- <el-form-item label="设备id" style="margin-bottom: 0;float: left; width: 300px;">
|
||||
<el-select v-model="formModel.deviceId" placeholder="请选择" filterable clearable style="width: 200px;">
|
||||
<el-option
|
||||
v-for="item in deviceIdList"
|
||||
@ -37,18 +36,18 @@
|
||||
:value="item.code"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-form-item> -->
|
||||
<el-button style="margin-right: 10px; float: right;" type="primary" size="small" @click="createTitle">创建</el-button>
|
||||
<el-button style="margin-right: 10px; float: right;" type="primary" size="small" @click="query">查询</el-button>
|
||||
</el-form>
|
||||
</el-card>
|
||||
<el-table :data="tableData" border style="width: 100%">
|
||||
<el-table-column label="线路">
|
||||
<!-- <el-table-column label="线路">
|
||||
<template slot-scope="scope">
|
||||
<span>{{ getMapName(scope.row.mapId) }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="类型">
|
||||
</el-table-column> -->
|
||||
<!-- <el-table-column label="类型">
|
||||
<template slot-scope="scope">
|
||||
<span>{{ scope.row.deviceTypes }}</span>
|
||||
</template>
|
||||
@ -57,80 +56,80 @@
|
||||
<template slot-scope="scope">
|
||||
<el-tag v-for="(item, index) in scope.row.deviceIds" :key="index" class="deviceIdTag">{{ item }}</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table-column> -->
|
||||
<el-table-column label="pdf名称" prop="fileName" />
|
||||
<el-table-column label="路径" prop="filePath" />
|
||||
<el-table-column label="时间" prop="createTime" />
|
||||
<el-table-column label="操作" width="450">
|
||||
<template slot-scope="scope">
|
||||
<!-- <el-button size="mini" @click="handleEdit(scope.$index, scope.row)">编辑</el-button> -->
|
||||
<el-button size="mini" @click="handleUpdate(scope.$index, scope.row)">更新</el-button>
|
||||
<el-button size="mini" type="primary" @click="handleBind(scope.$index, scope.row)">绑定</el-button>
|
||||
<el-button size="mini" type="success" @click="handleUpdate(scope.$index, scope.row)">更新</el-button>
|
||||
<!-- <el-button size="mini" @click="handlePublish(scope.$index, scope.row)">发布</el-button> -->
|
||||
<el-button size="mini" type="danger" @click="handleDelete(scope.$index, scope.row)">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<Edit ref="edits" type="ADD" :map-list="mapList" @reloadTable="reloadTable" />
|
||||
<Edit ref="edit" type="EDIT" :map-list="mapList" @reloadTable="reloadTable" />
|
||||
<Edit ref="edits" type="ADD" @reloadTable="reloadTable" />
|
||||
<Edit ref="edit" type="EDIT" @reloadTable="reloadTable" />
|
||||
<Bind-Map ref="bindMap" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { getPublishMapDetailById, getPublishMapVersionById } from '@/api/jmap/map';
|
||||
// import { getPublishMapDetailById, getPublishMapVersionById } from '@/api/jmap/map';
|
||||
import { getUploadFile, deleteUploadFile } from '@/api/pdf';
|
||||
import { getPublishMapList } from '@/api/jmap/map';
|
||||
import { dbReadData, dbAddData, dbUpdateData } from '@/utils/indexedDb';
|
||||
// import { dbReadData, dbAddData, dbUpdateData } from '@/utils/indexedDb';
|
||||
import Edit from './edit';
|
||||
import BindMap from './bindMap';
|
||||
|
||||
export default {
|
||||
name: 'CacheControl',
|
||||
components: {
|
||||
Edit
|
||||
Edit,
|
||||
BindMap
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
tableData: [],
|
||||
formModel: {
|
||||
mapId: '',
|
||||
deviceType:'',
|
||||
deviceId:''
|
||||
},
|
||||
mapList: [],
|
||||
graphDataNew:null,
|
||||
deviceIdList:[],
|
||||
deviceTypeList: [
|
||||
{ label: '区段', value: 'sectionList', code: 'SECTION' },
|
||||
{ label: '道岔', value: 'switchList', code: 'SWITCH' },
|
||||
{ label: '信号机', value: 'signalList', code: 'SIGNAL' },
|
||||
{ label: '车站', value: 'stationList', code: 'STATION' },
|
||||
{ label: '站台', value: 'stationStandList', code: 'STAND' },
|
||||
{ label: '屏蔽门', value: 'psdList', code: 'PSD' },
|
||||
{ label: '列车', value: 'trainList', code: 'TRAIN' }
|
||||
]
|
||||
// formModel: {
|
||||
// mapId: '',
|
||||
// deviceType:'',
|
||||
// deviceId:''
|
||||
// },
|
||||
// mapList: [],
|
||||
// graphDataNew:null,
|
||||
deviceIdList:[]
|
||||
// deviceTypeList: [
|
||||
// { label: '区段', value: 'sectionList', code: 'SECTION' },
|
||||
// { label: '道岔', value: 'switchList', code: 'SWITCH' },
|
||||
// { label: '信号机', value: 'signalList', code: 'SIGNAL' },
|
||||
// { label: '车站', value: 'stationList', code: 'STATION' },
|
||||
// { label: '站台', value: 'stationStandList', code: 'STAND' },
|
||||
// { label: '屏蔽门', value: 'psdList', code: 'PSD' },
|
||||
// { label: '列车', value: 'trainList', code: 'TRAIN' }
|
||||
// ]
|
||||
};
|
||||
},
|
||||
created() {
|
||||
const params = {
|
||||
pageSize: 9999,
|
||||
pageNum: 1
|
||||
};
|
||||
getPublishMapList(params).then(res => {
|
||||
// this.mapList = res.data.list.filter(el => !el.project );
|
||||
this.mapList = res.data.list || [];
|
||||
if (this.mapList.length > 0) { this.formModel.mapId = this.mapList[0].id; this.handleMap(this.formModel.mapId); }
|
||||
this.query();
|
||||
});
|
||||
// getPublishMapList(params).then(res => {
|
||||
// // this.mapList = res.data.list.filter(el => !el.project );
|
||||
// this.mapList = res.data.list || [];
|
||||
// // if (this.mapList.length > 0) { this.formModel.mapId = this.mapList[0].id; this.handleMap(this.formModel.mapId); }
|
||||
// });
|
||||
},
|
||||
methods: {
|
||||
query() {
|
||||
this.reloadTable();
|
||||
},
|
||||
getMapName(val) {
|
||||
if (this && this.mapList.length) {
|
||||
const data = this.mapList.find(el => el.id == val);
|
||||
return data.name;
|
||||
}
|
||||
return val;
|
||||
},
|
||||
// getMapName(val) {
|
||||
// if (this && this.mapList.length) {
|
||||
// const data = this.mapList.find(el => el.id == val);
|
||||
// return data.name;
|
||||
// }
|
||||
// return val;
|
||||
// },
|
||||
createTitle() {
|
||||
this.$refs.edits.show();
|
||||
},
|
||||
@ -139,7 +138,7 @@ export default {
|
||||
// this.$router.push({path : '/editor', query: {docId: data.id, draft: 1}});
|
||||
// },
|
||||
// 更新标题
|
||||
handleUpdate(row, data) {
|
||||
handleUpdate(index, data) {
|
||||
this.$refs.edit.show(data);
|
||||
},
|
||||
// // 草稿发布
|
||||
@ -152,14 +151,17 @@ export default {
|
||||
// this.$message.error(`发布失败: ${error.data}`);
|
||||
// });
|
||||
// },
|
||||
handleDelete(row, data) {
|
||||
handleBind(index, data) {
|
||||
this.$refs.bindMap.doShow(data);
|
||||
},
|
||||
handleDelete(index, data) {
|
||||
this.$confirm('是否确认删除?', this.$t('tip.hint'), {
|
||||
confirmButtonText: '确认',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
deleteUploadFile(data.id).then(res => {
|
||||
this.$message.success('删除文章成功!');
|
||||
this.$message.success('删除pdf成功!');
|
||||
this.reloadTable();
|
||||
}).catch(error => {
|
||||
this.$message.error(`删除失败: ${error.data}`);
|
||||
@ -168,59 +170,59 @@ export default {
|
||||
},
|
||||
reloadTable() {
|
||||
this.tableData = [];
|
||||
getUploadFile(this.formModel).then(res => {
|
||||
getUploadFile({}).then(res => {
|
||||
this.tableData = res.data;
|
||||
this.tableData.forEach(each=>{
|
||||
const deviceTypeName = this.deviceTypeList.find(type=>{ return type.code == each.deviceTypes[0]; }) || {label:''};
|
||||
each.deviceTypes = deviceTypeName.label;
|
||||
});
|
||||
// this.tableData.forEach(each=>{
|
||||
// const deviceTypeName = this.deviceTypeList.find(type=>{ return type.code == each.deviceTypes[0]; }) || {label:''};
|
||||
// each.deviceTypes = deviceTypeName.label;
|
||||
// });
|
||||
}).catch(error => {
|
||||
console.log(error);
|
||||
});
|
||||
},
|
||||
handleMap(mapId) {
|
||||
this.deviceIdList = [];
|
||||
this.formModel.deviceId = '';
|
||||
this.formModel.deviceType = '';
|
||||
return new Promise(async (resolve, reject) => {
|
||||
const resp = await getPublishMapVersionById(mapId);
|
||||
const version = resp.data;
|
||||
dbReadData('mapData', mapId, version, async (mapData, version) =>{
|
||||
if (mapData && mapData.version == version) {
|
||||
this.graphDataNew = mapData.graphDataNew;
|
||||
resolve();
|
||||
} else if (mapData) {
|
||||
const res = await getPublishMapDetailById(mapId);
|
||||
this.graphDataNew = res.data.graphDataNew;
|
||||
dbUpdateData('mapData', res.data);
|
||||
resolve();
|
||||
} else {
|
||||
const res = await getPublishMapDetailById(mapId);
|
||||
this.graphDataNew = res.data.graphDataNew;
|
||||
dbAddData('mapData', res.data);
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
handleDevice(type) {
|
||||
if (type) {
|
||||
const data = this.graphDataNew[type];
|
||||
if (data && data.length > 0) {
|
||||
this.deviceIdList = this.graphDataNew[type].map(el => {
|
||||
return {
|
||||
code: el.code,
|
||||
name: `${el.name}(${el.code})`
|
||||
};
|
||||
});
|
||||
} else {
|
||||
this.deviceIdList = [];
|
||||
}
|
||||
} else {
|
||||
this.formModel.deviceId = '';
|
||||
this.deviceIdList = [];
|
||||
}
|
||||
}
|
||||
// handleMap(mapId) {
|
||||
// this.deviceIdList = [];
|
||||
// this.formModel.deviceId = '';
|
||||
// this.formModel.deviceType = '';
|
||||
// return new Promise(async (resolve, reject) => {
|
||||
// const resp = await getPublishMapVersionById(mapId);
|
||||
// const version = resp.data;
|
||||
// dbReadData('mapData', mapId, version, async (mapData, version) =>{
|
||||
// if (mapData && mapData.version == version) {
|
||||
// this.graphDataNew = mapData.graphDataNew;
|
||||
// resolve();
|
||||
// } else if (mapData) {
|
||||
// const res = await getPublishMapDetailById(mapId);
|
||||
// this.graphDataNew = res.data.graphDataNew;
|
||||
// dbUpdateData('mapData', res.data);
|
||||
// resolve();
|
||||
// } else {
|
||||
// const res = await getPublishMapDetailById(mapId);
|
||||
// this.graphDataNew = res.data.graphDataNew;
|
||||
// dbAddData('mapData', res.data);
|
||||
// resolve();
|
||||
// }
|
||||
// });
|
||||
// });
|
||||
// },
|
||||
// handleDevice(type) {
|
||||
// if (type) {
|
||||
// const data = this.graphDataNew[type];
|
||||
// if (data && data.length > 0) {
|
||||
// this.deviceIdList = this.graphDataNew[type].map(el => {
|
||||
// return {
|
||||
// code: el.code,
|
||||
// name: `${el.name}(${el.code})`
|
||||
// };
|
||||
// });
|
||||
// } else {
|
||||
// this.deviceIdList = [];
|
||||
// }
|
||||
// } else {
|
||||
// this.formModel.deviceId = '';
|
||||
// this.deviceIdList = [];
|
||||
// }
|
||||
// }
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
Loading…
Reference in New Issue
Block a user