|
@@ -234,14 +234,24 @@ const sceneView = {
|
|
|
html += `<option value="${pageData.sceneData[i].id}" ${id && id == pageData.sceneData[i].id ? 'selected': ''}>
|
|
|
${pageData.sceneData[i].sceneName}</option>`
|
|
|
if (id && id == pageData.sceneData[i].id && img) {
|
|
|
- _this.renderImgView(pageData.sceneData[i].imgs, function(imgJson) {
|
|
|
- let imgUrl = imgJson.sceneImg
|
|
|
- if (!imgJson.sceneImg.startsWith('http')) {
|
|
|
- imgUrl = pageData.path() + imgJson.sceneImg
|
|
|
- }
|
|
|
- $('#sceneImg').attr('src', imgUrl)
|
|
|
- _this.getSceneByIdApi()
|
|
|
- })
|
|
|
+ let imgJson = {};
|
|
|
+ if(pageData.sceneData[i].imgs.length>0){
|
|
|
+ imgJson = pageData.sceneData[i].imgs[0]
|
|
|
+ }
|
|
|
+ console.log(imgJson);
|
|
|
+ if(imgJson!=null){
|
|
|
+ _this.renderImgView(pageData.sceneData[i].imgs, function(imgJson) {
|
|
|
+ if(imgJson!=undefined){
|
|
|
+ let imgUrl = imgJson.sceneImg
|
|
|
+ if (!imgJson.sceneImg.startsWith('http')) {
|
|
|
+ imgUrl = pageData.path() + imgJson.sceneImg
|
|
|
+ }
|
|
|
+ $('#sceneImg').attr('src', imgUrl)
|
|
|
+ _this.getSceneByIdApi()
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
$('#sceneList').empty().append(html)
|
|
@@ -253,7 +263,7 @@ const sceneView = {
|
|
|
},
|
|
|
renderImgView: function(arr, callback) {
|
|
|
const img = pageData.getParam('img')
|
|
|
- let html = '<option value="">请选择</option>'
|
|
|
+ let html = ''//'<option value="">请选择</option>'
|
|
|
let data;
|
|
|
for (var j = 0; j < arr.length; j++) {
|
|
|
if (img && img == arr[j].id) {
|
|
@@ -685,29 +695,37 @@ const sceneWindow = {
|
|
|
const tree = layui.tree
|
|
|
const table = layui.table
|
|
|
let imgarr = []
|
|
|
+ let hasimg = true
|
|
|
$('input[name="imgPath"][data-type="0"]').each(function(i, item) {
|
|
|
if (!$(item).hasClass('layui-hide')) {
|
|
|
if (!$(item).val()) {
|
|
|
- layer.msg('模型图地址不能为空!', {
|
|
|
- icon: 2
|
|
|
- })
|
|
|
- return
|
|
|
+ hasimg = false
|
|
|
}
|
|
|
imgarr.push($(item).val())
|
|
|
}
|
|
|
})
|
|
|
+ if(!hasimg){
|
|
|
+ layer.msg('模型图地址不能为空!', {
|
|
|
+ icon: 2
|
|
|
+ })
|
|
|
+ return
|
|
|
+ }
|
|
|
let formData = new FormData();
|
|
|
+ let hasimg2 = true
|
|
|
$('input[name="imgPath"][data-type="1"]').each(function(i, item) {
|
|
|
if (!$(item).hasClass('layui-hide')) {
|
|
|
if (!$(item).val()) {
|
|
|
- layer.msg('模型图地址不能为空!', {
|
|
|
- icon: 2
|
|
|
- })
|
|
|
- return
|
|
|
+ hasimg2 = false
|
|
|
}
|
|
|
formData.append('file', $(item)[0].files[0])
|
|
|
}
|
|
|
})
|
|
|
+ if(!hasimg2){
|
|
|
+ layer.msg('模型图地址不能为空!', {
|
|
|
+ icon: 2
|
|
|
+ })
|
|
|
+ return
|
|
|
+ }
|
|
|
formData.append('monitors', JSON.stringify(layui.xmSelect.get('#monitorSelect', true).getValue('value')))
|
|
|
formData.append('ids', JSON.stringify(this.treeData(tree.getChecked('deviceTree'))))
|
|
|
formData.append('imgs', JSON.stringify(imgarr))
|