pdf 上传 代码调整

This commit is contained in:
joylink_cuiweidong 2021-05-17 17:20:26 +08:00
parent 3bbfae4082
commit 57feb88e6c
4 changed files with 320 additions and 225 deletions

View File

@ -1,13 +1,22 @@
import request from '@/utils/request'; import request from '@/utils/request';
/** 创建分组 */ /** 创建 */
export function postUploadFile(data) { export function postUploadFile(data) {
return request({ return request({
url: `/api/file`, url: `/api/file/basic`,
method: 'post', method: 'post',
data data
}); });
} }
// /** 复制一条文件基础信息 */
// export function copyUploadFile(id) {
// return request({
// url: `/api/file/basic/copy/${id}`,
// method: 'post'
// });
// }
// 查询 // 查询
export function getUploadFile(params) { export function getUploadFile(params) {
return request({ return request({
@ -19,15 +28,27 @@ export function getUploadFile(params) {
// 修改 // 修改
export function putUploadFile(data) { export function putUploadFile(data) {
return request({ return request({
url: `/api/file`, url: `/api/file/basic`,
method: 'put', method: 'put',
data data
}); });
} }
// 删除 // 删除
export function deleteUploadFile(data) { export function deleteUploadFile(id) {
return request({ return request({
url: `/api/file`, url: `/api/file/${id}`,
method: 'delete' method: 'delete'
}); });
} }
// 查询文件绑定信息
export function getFileBindInfo(fileId, mapId) {
return request({
url: `/api/file/binding/${fileId}/${mapId}`,
method: 'get'
});
}
/** */
// @GetMapping("")

View 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>

View File

@ -1,6 +1,7 @@
<template> <template>
<el-dialog v-dialogDrag :title="title" :visible.sync="dialogVisible" width="30%" :before-close="handleClose" center class="uploadDialog"> <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" /> <data-form ref="dataform" :form="form" :form-model="formModel" :rules="rules" />
<div class="fileError">{{ message }}</div>
<span slot="footer" class="dialog-footer"> <span slot="footer" class="dialog-footer">
<el-button type="primary" @click="doSave">{{ $t('global.confirm') }}</el-button> <el-button type="primary" @click="doSave">{{ $t('global.confirm') }}</el-button>
<el-button @click="handleClose">{{ $t('global.cancel') }}</el-button> <el-button @click="handleClose">{{ $t('global.cancel') }}</el-button>
@ -10,8 +11,8 @@
<script> <script>
import { postUploadFile, putUploadFile } from '@/api/pdf'; import { postUploadFile, putUploadFile } from '@/api/pdf';
import { getPublishMapDetailById, getPublishMapVersionById } from '@/api/jmap/map'; // import { getPublishMapDetailById, getPublishMapVersionById } from '@/api/jmap/map';
import { dbReadData, dbAddData, dbUpdateData } from '@/utils/indexedDb'; // import { dbReadData, dbAddData, dbUpdateData } from '@/utils/indexedDb';
// uploadFile // uploadFile
import { meansUrl } from '@/api/upload'; import { meansUrl } from '@/api/upload';
@ -21,39 +22,30 @@ export default {
type: { type: {
type: String, type: String,
required: true required: true
},
mapList:{
type: Array,
required: true
} }
}, },
data() { data() {
return { return {
dialogVisible: false, dialogVisible: false,
formModel: { formModel: {
// cityCode: '',
mapId: '',
deviceTypes: '',
deviceIds: [],
upload: '', upload: '',
filePath: '', filePath: '',
fileType: 'DRAWING' fileType: 'DRAWING',
fileName:''
}, },
rowData: null,
graphDataNew: null,
fileList: [], fileList: [],
formData: '', formData: '',
id: '', id: '',
deviceTypeList: [ message:''
{ label: '区段', value: 'sectionList', code: 'SECTION' }, // deviceTypeList: [
{ label: '道岔', value: 'switchList', code: 'SWITCH' }, // { label: '', value: 'sectionList', code: 'SECTION' },
{ label: '信号机', value: 'signalList', code: 'SIGNAL' }, // { label: '', value: 'switchList', code: 'SWITCH' },
{ label: '车站', value: 'stationList', code: 'STATION' }, // { label: '', value: 'signalList', code: 'SIGNAL' },
{ label: '站台', value: 'stationStandList', code: 'STAND' }, // { label: '', value: 'stationList', code: 'STATION' },
{ label: '屏蔽门', value: 'psdList', code: 'PSD' }, // { label: '', value: 'stationStandList', code: 'STAND' },
{ label: '列车', value: 'trainList', code: 'TRAIN' } // { label: '', value: 'psdList', code: 'PSD' },
], // { label: '', value: 'trainList', code: 'TRAIN' }
deviceCodesList: [] // ],
}; };
}, },
computed: { computed: {
@ -64,25 +56,23 @@ export default {
const form = { const form = {
labelWidth: '120px', labelWidth: '120px',
items: [ items: [
{ prop: 'mapId', label: '选择线路:', type:'select', options: this.mapList, optionValue:'id', optionLabel:'name', change: true, onChange: this.handleMap }, // { 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: '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: '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: '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; return form;
}, },
rules() { rules() {
const crules = { const crules = {
mapId: [ fileName: [
{ required: true, message: '请选择线路', trigger: 'change' } { required: true, message: '文件名不能为空', trigger: 'blur'}
],
deviceTypes: [
{ required: true, message: '请选择设备类型', trigger: 'change' }
],
deviceIds: [
{ required: true, message: '请选择设备', trigger: 'change' }
] ]
// upload: [
// { required: true, message: '', trigger: 'onChange' }
// ]
}; };
return crules; return crules;
}, },
@ -90,7 +80,7 @@ export default {
if (this.type === 'ADD') { if (this.type === 'ADD') {
return '上传PDF'; return '上传PDF';
} else { } else {
return '更新文章'; return '更新PDF';
} }
} }
}, },
@ -98,88 +88,84 @@ export default {
async show(data) { async show(data) {
this.dialogVisible = true; this.dialogVisible = true;
if (this.type != 'ADD') { if (this.type != 'ADD') {
const obj = this.deviceTypeList.find(el => el.code == data.deviceTypes[0]);
this.id = data.id; this.id = data.id;
this.rowData = data;
this.rowData.deviceTypes = obj ? obj.value : '';
this.formModel = { this.formModel = {
mapId: data.mapId,
deviceTypes: obj ? obj.value : '',
deviceIds: data.deviceIds,
upload: '', upload: '',
fileName:data.fileName,
filePath: data.filePath filePath: data.filePath
}; };
await this.handleMap(data.mapId);
obj && await this.handleDevice(obj.value);
} else { } else {
this.rowData = {};
this.formModel = { this.formModel = {
mapId: '',
deviceTypes: '',
deviceIds: [],
upload: '', upload: '',
filePath: '' filePath: '',
fileName:''
}; };
} }
}, },
async handleMap(mapId) { // async handleMap(mapId) {
if (mapId) { // if (mapId) {
if (mapId != this.rowData.mapId) { // if (mapId != this.rowData.mapId) {
this.formModel.deviceIds = []; // this.formModel.deviceIds = [];
this.formModel.deviceTypes = ''; // this.formModel.deviceTypes = '';
} // }
return new Promise(async (resolve, reject) => { // return new Promise(async (resolve, reject) => {
const resp = await getPublishMapVersionById(mapId); // const resp = await getPublishMapVersionById(mapId);
const version = resp.data; // const version = resp.data;
dbReadData('mapData', mapId, version, async (mapData, version) =>{ // dbReadData('mapData', mapId, version, async (mapData, version) =>{
if (mapData && mapData.version == version) { // if (mapData && mapData.version == version) {
this.graphDataNew = mapData.graphDataNew; // this.graphDataNew = mapData.graphDataNew;
resolve(); // resolve();
} else if (mapData) { // } else if (mapData) {
const res = await getPublishMapDetailById(mapId); // const res = await getPublishMapDetailById(mapId);
this.graphDataNew = res.data.graphDataNew; // this.graphDataNew = res.data.graphDataNew;
dbUpdateData('mapData', res.data); // dbUpdateData('mapData', res.data);
resolve(); // resolve();
} else { // } else {
const res = await getPublishMapDetailById(mapId); // const res = await getPublishMapDetailById(mapId);
this.graphDataNew = res.data.graphDataNew; // this.graphDataNew = res.data.graphDataNew;
dbAddData('mapData', res.data); // dbAddData('mapData', res.data);
resolve(); // resolve();
} // }
}); // });
}); // });
} else { // } else {
this.formModel.deviceIds = []; // this.formModel.deviceIds = [];
this.formModel.mapId = ''; // this.formModel.mapId = '';
this.formModel.deviceTypes = ''; // this.formModel.deviceTypes = '';
} // }
}, // },
handleDevice(type) { // handleDevice(type) {
if (type) { // if (type) {
if (type != this.rowData.deviceTypes) { // if (type != this.rowData.deviceTypes) {
this.formModel.deviceIds = []; // this.formModel.deviceIds = [];
} // }
this.deviceCodesList = this.graphDataNew[type].map(el => { // this.deviceCodesList = this.graphDataNew[type].map(el => {
return { // return {
code: el.code, // code: el.code,
name: `${el.name}(${el.code})` // name: `${el.name}(${el.code})`
}; // };
}); // });
} else { // } else {
this.formModel.deviceIds = []; // this.formModel.deviceIds = [];
} // }
}, // },
// uploadFile(file) { // uploadFile(file) {
// this.formData.append('file', file.file); // this.formData.append('file', file.file);
// }, // },
onSuccess(res, file) { onSuccess(res, file) {
this.formModel.filePath = res.data; this.formModel.filePath = res.data;
this.message = '';
}, },
doSave() { doSave() {
const self = this; const self = this;
this.$refs.dataform.validateForm(() => { this.$refs.dataform.validateForm(() => {
if (self.type == 'ADD') { if (self.type == 'ADD') {
if (this.formModel.filePath) {
self.create(); self.create();
} else {
this.message = '请上传文件';
return false;
}
} else { } else {
self.update(); self.update();
} }
@ -187,16 +173,10 @@ export default {
}, },
create() { create() {
const self = this; const self = this;
const obj = this.deviceTypeList.find(el => el.value == this.formModel.deviceTypes);
if (obj) {
this.formModel.deviceTypes = [obj.code];
}
const data = { const data = {
fileType: 'DRAWING', fileType: 'DRAWING',
mapId: this.formModel.mapId, filePath: this.formModel.filePath,
deviceTypes: this.formModel.deviceTypes, fileName:this.formModel.fileName
deviceIds: this.formModel.deviceIds,
filePath: this.formModel.filePath
}; };
postUploadFile(data).then((res) => { postUploadFile(data).then((res) => {
self.$message.success('上传PDF成功!'); self.$message.success('上传PDF成功!');
@ -204,34 +184,31 @@ export default {
self.$emit('reloadTable'); self.$emit('reloadTable');
}).catch(error => { }).catch(error => {
console.log(error); console.log(error);
self.$message.error(`创建文章失败:${error.message}`); self.$message.error(`上传PDF失败:${error.message}`);
}); });
}, },
update() { update() {
const self = this; const self = this;
const obj = this.deviceTypeList.find(el => el.value == this.formModel.deviceTypes);
if (obj) {
this.formModel.deviceTypes = [obj.code];
}
const data = { const data = {
id: this.id, id: this.id,
fileType: 'DRAWING', fileType: 'DRAWING',
mapId: this.formModel.mapId, fileName:this.formModel.fileName,
deviceTypes: this.formModel.deviceTypes,
deviceIds: this.formModel.deviceIds,
filePath: this.formModel.filePath filePath: this.formModel.filePath
}; };
putUploadFile(data).then(() => { putUploadFile(data).then(() => {
self.$message.success('更新文章成功!'); self.$message.success('更新PDF成功!');
self.handleClose(); self.handleClose();
self.$emit('reloadTable'); self.$emit('reloadTable');
}).catch(error => { }).catch(error => {
self.$message.error(`更新文章失败:${error.message}`); self.$message.error(`更新PDF失败:${error.message}`);
}); });
}, },
handleClose() { handleClose() {
this.message = '';
this.formModel = { this.formModel = {
title: '' upload: '',
filePath: '',
fileName:''
}; };
this.$refs.dataform.resetForm(); this.$refs.dataform.resetForm();
this.dialogVisible = false; 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> </style>

View File

@ -4,12 +4,11 @@
<el-card> <el-card>
<el-form <el-form
ref="queryForm" ref="queryForm"
:model="formModel"
size="small" size="small"
style="padding: 6px 20px 6px 20px;overflow: hidden;" style="padding: 6px 20px 6px 20px;overflow: hidden;"
> >
<el-form-item label="地图" style="margin-bottom: 0;float: left; width: 300px;"> <!-- <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-select v-model="formModel.mapId" placeholder="请选择" clearable filterable style="width: 240px;" @change="handleMap">
<el-option <el-option
v-for="item in mapList" v-for="item in mapList"
:key="item.id" :key="item.id"
@ -17,8 +16,8 @@
:value="item.id" :value="item.id"
/> />
</el-select> </el-select>
</el-form-item> </el-form-item> -->
<el-form-item label="设备类型" style="margin-bottom: 0;float: left; width:350px;"> <!-- <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-select v-model="formModel.deviceType" placeholder="请选择" filterable clearable style="width: 240px;" @change="handleDevice">
<el-option <el-option
v-for="item in deviceTypeList" v-for="item in deviceTypeList"
@ -27,8 +26,8 @@
:value="item.value" :value="item.value"
/> />
</el-select> </el-select>
</el-form-item> </el-form-item> -->
<el-form-item label="设备id" style="margin-bottom: 0;float: left; width: 300px;"> <!-- <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-select v-model="formModel.deviceId" placeholder="请选择" filterable clearable style="width: 200px;">
<el-option <el-option
v-for="item in deviceIdList" v-for="item in deviceIdList"
@ -37,18 +36,18 @@
:value="item.code" :value="item.code"
/> />
</el-select> </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="createTitle">创建</el-button>
<el-button style="margin-right: 10px; float: right;" type="primary" size="small" @click="query">查询</el-button> <el-button style="margin-right: 10px; float: right;" type="primary" size="small" @click="query">查询</el-button>
</el-form> </el-form>
</el-card> </el-card>
<el-table :data="tableData" border style="width: 100%"> <el-table :data="tableData" border style="width: 100%">
<el-table-column label="线路"> <!-- <el-table-column label="线路">
<template slot-scope="scope"> <template slot-scope="scope">
<span>{{ getMapName(scope.row.mapId) }}</span> <span>{{ getMapName(scope.row.mapId) }}</span>
</template> </template>
</el-table-column> </el-table-column> -->
<el-table-column label="类型"> <!-- <el-table-column label="类型">
<template slot-scope="scope"> <template slot-scope="scope">
<span>{{ scope.row.deviceTypes }}</span> <span>{{ scope.row.deviceTypes }}</span>
</template> </template>
@ -57,80 +56,80 @@
<template slot-scope="scope"> <template slot-scope="scope">
<el-tag v-for="(item, index) in scope.row.deviceIds" :key="index" class="deviceIdTag">{{ item }}</el-tag> <el-tag v-for="(item, index) in scope.row.deviceIds" :key="index" class="deviceIdTag">{{ item }}</el-tag>
</template> </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="filePath" />
<el-table-column label="时间" prop="createTime" /> <el-table-column label="时间" prop="createTime" />
<el-table-column label="操作" width="450"> <el-table-column label="操作" width="450">
<template slot-scope="scope"> <template slot-scope="scope">
<!-- <el-button size="mini" @click="handleEdit(scope.$index, scope.row)">编辑</el-button> --> <!-- <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" @click="handlePublish(scope.$index, scope.row)">发布</el-button> -->
<el-button size="mini" type="danger" @click="handleDelete(scope.$index, scope.row)">删除</el-button> <el-button size="mini" type="danger" @click="handleDelete(scope.$index, scope.row)">删除</el-button>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
<Edit ref="edits" type="ADD" :map-list="mapList" @reloadTable="reloadTable" /> <Edit ref="edits" type="ADD" @reloadTable="reloadTable" />
<Edit ref="edit" type="EDIT" :map-list="mapList" @reloadTable="reloadTable" /> <Edit ref="edit" type="EDIT" @reloadTable="reloadTable" />
<Bind-Map ref="bindMap" />
</div> </div>
</template> </template>
<script> <script>
import { getPublishMapDetailById, getPublishMapVersionById } from '@/api/jmap/map'; // import { getPublishMapDetailById, getPublishMapVersionById } from '@/api/jmap/map';
import { getUploadFile, deleteUploadFile } from '@/api/pdf'; 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 Edit from './edit';
import BindMap from './bindMap';
export default { export default {
name: 'CacheControl', name: 'CacheControl',
components: { components: {
Edit Edit,
BindMap
}, },
data() { data() {
return { return {
tableData: [], tableData: [],
formModel: { // formModel: {
mapId: '', // mapId: '',
deviceType:'', // deviceType:'',
deviceId:'' // deviceId:''
}, // },
mapList: [], // mapList: [],
graphDataNew:null, // graphDataNew:null,
deviceIdList:[], deviceIdList:[]
deviceTypeList: [ // deviceTypeList: [
{ label: '区段', value: 'sectionList', code: 'SECTION' }, // { label: '', value: 'sectionList', code: 'SECTION' },
{ label: '道岔', value: 'switchList', code: 'SWITCH' }, // { label: '', value: 'switchList', code: 'SWITCH' },
{ label: '信号机', value: 'signalList', code: 'SIGNAL' }, // { label: '', value: 'signalList', code: 'SIGNAL' },
{ label: '车站', value: 'stationList', code: 'STATION' }, // { label: '', value: 'stationList', code: 'STATION' },
{ label: '站台', value: 'stationStandList', code: 'STAND' }, // { label: '', value: 'stationStandList', code: 'STAND' },
{ label: '屏蔽门', value: 'psdList', code: 'PSD' }, // { label: '', value: 'psdList', code: 'PSD' },
{ label: '列车', value: 'trainList', code: 'TRAIN' } // { label: '', value: 'trainList', code: 'TRAIN' }
] // ]
}; };
}, },
created() { 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(); 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: { methods: {
query() { query() {
this.reloadTable(); this.reloadTable();
}, },
getMapName(val) { // getMapName(val) {
if (this && this.mapList.length) { // if (this && this.mapList.length) {
const data = this.mapList.find(el => el.id == val); // const data = this.mapList.find(el => el.id == val);
return data.name; // return data.name;
} // }
return val; // return val;
}, // },
createTitle() { createTitle() {
this.$refs.edits.show(); this.$refs.edits.show();
}, },
@ -139,7 +138,7 @@ export default {
// this.$router.push({path : '/editor', query: {docId: data.id, draft: 1}}); // this.$router.push({path : '/editor', query: {docId: data.id, draft: 1}});
// }, // },
// //
handleUpdate(row, data) { handleUpdate(index, data) {
this.$refs.edit.show(data); this.$refs.edit.show(data);
}, },
// // 稿 // // 稿
@ -152,14 +151,17 @@ export default {
// this.$message.error(`: ${error.data}`); // 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'), { this.$confirm('是否确认删除?', this.$t('tip.hint'), {
confirmButtonText: '确认', confirmButtonText: '确认',
cancelButtonText: '取消', cancelButtonText: '取消',
type: 'warning' type: 'warning'
}).then(() => { }).then(() => {
deleteUploadFile(data.id).then(res => { deleteUploadFile(data.id).then(res => {
this.$message.success('删除文章成功!'); this.$message.success('删除pdf成功!');
this.reloadTable(); this.reloadTable();
}).catch(error => { }).catch(error => {
this.$message.error(`删除失败: ${error.data}`); this.$message.error(`删除失败: ${error.data}`);
@ -168,59 +170,59 @@ export default {
}, },
reloadTable() { reloadTable() {
this.tableData = []; this.tableData = [];
getUploadFile(this.formModel).then(res => { getUploadFile({}).then(res => {
this.tableData = res.data; this.tableData = res.data;
this.tableData.forEach(each=>{ // this.tableData.forEach(each=>{
const deviceTypeName = this.deviceTypeList.find(type=>{ return type.code == each.deviceTypes[0]; }) || {label:''}; // const deviceTypeName = this.deviceTypeList.find(type=>{ return type.code == each.deviceTypes[0]; }) || {label:''};
each.deviceTypes = deviceTypeName.label; // each.deviceTypes = deviceTypeName.label;
}); // });
}).catch(error => { }).catch(error => {
console.log(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> </script>