文档服务地址:http://47.92.0.57:3000/ 周报索引地址:http://47.92.0.57:3000/s/NruNXRYmV

Commit 9bc28a19 by 李梓桢

图片前端对接修改1

parent 17927c2d
...@@ -151,6 +151,8 @@ export default { ...@@ -151,6 +151,8 @@ export default {
isAlert1: false, isAlert1: false,
radio1: '矩形标注', radio1: '矩形标注',
pictureId: 1, pictureId: 1,
relationId: null,
imageUrl: '',
scaleSize: 1, scaleSize: 1,
height_res: 0, height_res: 0,
activeIndex1: 1, activeIndex1: 1,
...@@ -181,18 +183,30 @@ export default { ...@@ -181,18 +183,30 @@ export default {
let routeParams = this.$route.params let routeParams = this.$route.params
console.log("routeParams") console.log("routeParams")
console.log(routeParams) console.log(routeParams)
let imageName = routeParams.file.url
this.relationId = routeParams.relationId
// let src = this.getimageUrl(imageName)
// 获取图片列表并转换格式 // 获取图片列表并转换格式
let imageList = await this.getLabelList() let imageList = await this.getLabelList()
console.log(imageList) console.log(imageList)
this.imageList = imageList.imageList this.imageList = imageList.imageList
// 加载第一张图片
// 这个是原来的代码
// var imgUrl = this.data.length ? this.data[0].imageUrl : 'https://juanmdbucket.oss-cn-beijing.aliyuncs.com/20200627155321.png'
// 这个是现在使用的代码
var imgUrl = 'http://127.0.0.1:9100/api/files/getImage/' + imageName
// 如果不使用后端可以用这个模拟
// var imgUrl = 'https://juanmdbucket.oss-cn-beijing.aliyuncs.com/20200301231737.png'
this.imageUrl = imgUrl
// 把这个函数放在后面是因为formExchange中可能会用到this.imageUrl
console.log('input') console.log('input')
console.log(this.imageList) console.log(this.imageList)
this.formExchange(this.imageList) this.formExchange(this.imageList)
console.log('output') console.log('output')
console.log(this.data) console.log(this.data)
// 加载第一张图片
var imgUrl = this.data.length ? this.data[0].imageUrl : 'https://juanmdbucket.oss-cn-beijing.aliyuncs.com/20200627155321.png'
console.log(this.data.length + ' 图片张数') console.log(this.data.length + ' 图片张数')
var img = new Image() var img = new Image()
img.src = imgUrl img.src = imgUrl
...@@ -722,8 +736,7 @@ export default { ...@@ -722,8 +736,7 @@ export default {
this.data = [] this.data = []
let params = { let params = {
'relationList': [ 'relationList': [
123, this.relationId
11
] ]
} }
var self = this var self = this
...@@ -749,8 +762,9 @@ export default { ...@@ -749,8 +762,9 @@ export default {
alert('请求出错!') alert('请求出错!')
} }
}, },
// 将数据库保存的数据格式转换为前端可以直接使用的格式 // 将数据库保存的数据格式转换为前端可以直接使用的格式,同时如果第一次标注该图片,会生成新数据
formExchange (inputData) { formExchange (inputData) {
if (inputData.length > 0) {
var index = 0 var index = 0
inputData.forEach(element => { inputData.forEach(element => {
let newData = { let newData = {
...@@ -763,6 +777,17 @@ export default { ...@@ -763,6 +777,17 @@ export default {
index++ index++
}) })
this.imageNum = index this.imageNum = index
} else {
let newData = {
relationId: this.relationId,
imageUrl: this.imageUrl,
label: this.getImageName(this.imageUrl),
children: []
}
this.data.push(newData)
//imageNum这个虽然没啥用,但是先放着吧
this.imageNum = 1
}
}, },
// 添加标签前弹窗输入标签名字 // 添加标签前弹窗输入标签名字
......
...@@ -9,44 +9,44 @@ import Mock from 'mockjs' ...@@ -9,44 +9,44 @@ import Mock from 'mockjs'
// }] // }]
// }) // })
Mock.mock('http://localhost:9100/api/image/getImage', { // Mock.mock('http://localhost:9100/api/image/getImage', {
code: 1, // code: 1,
data: { // data: {
'imageList': [{ // 'imageList': [{
'relationId': 123, // 'relationId': 123,
'imageUrl': 'https://juanmdbucket.oss-cn-beijing.aliyuncs.com/20200301231737.png', // 'imageUrl': 'https://juanmdbucket.oss-cn-beijing.aliyuncs.com/20200301231737.png',
'labelList': [] // 'labelList': []
}, { // }, {
'relationId': 11, // 'relationId': 11,
'imageUrl': 'https://juanmdbucket.oss-cn-beijing.aliyuncs.com/20200526170357.jpg', // 'imageUrl': 'https://juanmdbucket.oss-cn-beijing.aliyuncs.com/20200526170357.jpg',
'labelList': [{ // 'labelList': [{
'labelId': 0, // 'labelId': 0,
'labelName': 'label1', // 'labelName': 'label1',
'pointList': [{ // 'pointList': [{
'pointId': 0, // 'pointId': 0,
'X': 500, // 'X': 500,
'Y': 300 // 'Y': 300
}, { // }, {
'pointId': 1, // 'pointId': 1,
'X': 600, // 'X': 600,
'Y': 300 // 'Y': 300
}, { // }, {
'pointId': 2, // 'pointId': 2,
'X': 700, // 'X': 700,
'Y': 350 // 'Y': 350
}, { // }, {
'pointId': 3, // 'pointId': 3,
'X': 600, // 'X': 600,
'Y': 400 // 'Y': 400
}, { // }, {
'pointId': 4, // 'pointId': 4,
'X': 450, // 'X': 450,
'Y': 350 // 'Y': 350
}] // }]
}] // }]
}] // }]
} // }
}) // })
// Mock.mock('http://localhost:9100/api/layer/getLayer', { // Mock.mock('http://localhost:9100/api/layer/getLayer', {
// code: 1, // code: 1,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment