|
@@ -2022,7 +2022,7 @@ $(document).ready(() => {
|
|
|
this._initModifyDetail();
|
|
|
this._initLocateRela();
|
|
|
// 草图相关
|
|
|
- this._initImageRela();
|
|
|
+ // this._initImageRela();
|
|
|
this.reBuildImData();
|
|
|
}
|
|
|
_initImTypeSetRela() {
|
|
@@ -2334,6 +2334,7 @@ $(document).ready(() => {
|
|
|
}
|
|
|
_initModifyDetail() {
|
|
|
const self = this;
|
|
|
+ let updateImageData;
|
|
|
// 编辑
|
|
|
$('#edit-detail').click(function () {
|
|
|
$(this).hide();
|
|
@@ -2341,6 +2342,7 @@ $(document).ready(() => {
|
|
|
$('#cancel-detail').show();
|
|
|
$('#detail-show').hide();
|
|
|
$('#detail-edit').show();
|
|
|
+ makeImageItem();
|
|
|
});
|
|
|
// 保存
|
|
|
$('#save-detail').click(() => {
|
|
@@ -2390,14 +2392,21 @@ $(document).ready(() => {
|
|
|
stageIm.loadUpdateDetailData(result);
|
|
|
self.reLoadDetailData();
|
|
|
});
|
|
|
+ if (updateImageData) {
|
|
|
+ postData(window.location.pathname + '/detail/merge-img', updateImageData, function (result) {
|
|
|
+ stageIm.loadUpdateDetailData(result);
|
|
|
+ updateImageData = '';
|
|
|
+ self.reLoadDetailData();
|
|
|
+ });
|
|
|
+ }
|
|
|
});
|
|
|
// 取消
|
|
|
$('#cancel-detail').click(() => {
|
|
|
self.reLoadDetailData();
|
|
|
});
|
|
|
- }
|
|
|
- _initImageRela() {
|
|
|
- const self = this;
|
|
|
+ // }
|
|
|
+ // _initImageRela() {
|
|
|
+ // const self = this;
|
|
|
function setdraggrable(){
|
|
|
$( ".img-item" ).draggable({ containment: "parent" },{stop: function( event, ui ) {
|
|
|
}}).resizable({ containment: "parent" },{ handles: 'n, e, s, w, ne, se, sw, nw' },{ maxWidth: parseFloat($('#imgwidth').val())},{maxHeight: parseFloat($('#imgheight').val())},{
|
|
@@ -2443,7 +2452,24 @@ $(document).ready(() => {
|
|
|
$(this).parent().remove();
|
|
|
};
|
|
|
// 加载草图组成
|
|
|
- $('#edit-img').on('show.bs.modal', function () {
|
|
|
+ // $('#edit-img').on('show.bs.modal', function () {
|
|
|
+ // const data = SpreadJsObj.getSelectObject(self.spread.getActiveSheet());
|
|
|
+ // const items = data.calc_img_org ? JSON.parse(data.calc_img_org) : [];
|
|
|
+ // const html = [];
|
|
|
+ // for (const item of items) {
|
|
|
+ // const itemStyle = 'top:' + item.top + ';' + 'left:' + item.left + ';' + 'width:' + item.width + ';' + 'height:' + item.height + ';';
|
|
|
+ // html.push('<div class="img-item" style="' + itemStyle + '">');
|
|
|
+ // html.push('<div class="img-bar">');
|
|
|
+ // html.push('<a href="javascript: void(0);" class="text-danger" title="删除"><i class="fa fa-remove" style="font-size: 24px"></i></a>');
|
|
|
+ // html.push('</div>');
|
|
|
+ // html.push('<div class="focus" style="width:100%; height:100%"><img src="', item.src, '" id="draggable" style="width:100%; height:100%"></div>');
|
|
|
+ // html.push('</div>');
|
|
|
+ // }
|
|
|
+ // $('.img-view').html(html.join(''));
|
|
|
+ // $('.img-bar').click(removeImageItem);
|
|
|
+ // setdraggrable();
|
|
|
+ // });
|
|
|
+ function makeImageItem () {
|
|
|
const data = SpreadJsObj.getSelectObject(self.spread.getActiveSheet());
|
|
|
const items = data.calc_img_org ? JSON.parse(data.calc_img_org) : [];
|
|
|
const html = [];
|
|
@@ -2459,7 +2485,7 @@ $(document).ready(() => {
|
|
|
$('.img-view').html(html.join(''));
|
|
|
$('.img-bar').click(removeImageItem);
|
|
|
setdraggrable();
|
|
|
- });
|
|
|
+ };
|
|
|
// 上传图片
|
|
|
$('#upload-img').click(function () {
|
|
|
$('#upload-img-file').trigger('click');
|
|
@@ -2540,27 +2566,45 @@ $(document).ready(() => {
|
|
|
}
|
|
|
updateData.img = canvas.toDataURL('image/png');
|
|
|
updateData.imgInfo = itemInfo;
|
|
|
- postData(window.location.pathname + '/detail/merge-img', updateData, function (result) {
|
|
|
- stageIm.loadUpdateDetailData(result);
|
|
|
- data.calc_img = result.calc_img;
|
|
|
- data.calc_img_org = result.calc_img_org;
|
|
|
- const calcImgSrc = data && data.calc_img ? '/' + data.calc_img : '';
|
|
|
- $('#show-calc-img').attr('src', calcImgSrc);
|
|
|
- $('#calc-img').attr('src', calcImgSrc);
|
|
|
- $('#view-calc-img').attr('src', calcImgSrc);
|
|
|
- $('#edit-img').modal('hide');
|
|
|
- });
|
|
|
+
|
|
|
+ updateImageData = updateData;
|
|
|
+ $('#calc-img').attr('src', updateData.img);
|
|
|
+ $('#view-calc-img').attr('src', updateData.img);
|
|
|
+ $('#show-calc-img').attr('src', updateData.img);
|
|
|
+ $('#edit-img').modal('hide');
|
|
|
+ // updateImageData = updateData;
|
|
|
+ // $('#edit-img').modal('hide');
|
|
|
+ // postData(window.location.pathname + '/detail/merge-img', updateData, function (result) {
|
|
|
+ // stageIm.loadUpdateDetailData(result);
|
|
|
+ // data.calc_img = result.calc_img;
|
|
|
+ // data.calc_img_org = result.calc_img_org;
|
|
|
+ // const calcImgSrc = data && data.calc_img ? '/' + data.calc_img : '';
|
|
|
+ // $('#show-calc-img').attr('src', calcImgSrc);
|
|
|
+ // $('#calc-img').attr('src', calcImgSrc);
|
|
|
+ // $('#view-calc-img').attr('src', calcImgSrc);
|
|
|
+ // $('#edit-img').modal('hide');
|
|
|
+ // });
|
|
|
} else if (data.calc_img) {
|
|
|
- postData(window.location.pathname + '/detail/merge-img', {updateType: 'clear', lid: data.lid, pid: data.pid, uuid: data.uuid}, function (result) {
|
|
|
- stageIm.loadUpdateDetailData(result);
|
|
|
- data.calc_img = result.calc_img;
|
|
|
- data.calc_img_org = result.calc_img_org;
|
|
|
- const calcImgSrc = data && data.calc_img ? '/' + data.calc_img : '';
|
|
|
- $('#show-calc-img').attr('src', calcImgSrc);
|
|
|
- $('#calc-img').attr('src', calcImgSrc);
|
|
|
- $('#view-calc-img').attr('src', calcImgSrc);
|
|
|
- $('#edit-img').modal('hide');
|
|
|
- });
|
|
|
+ updateImageData = {updateType: 'clear', lid: data.lid, pid: data.pid, uuid: data.uuid};
|
|
|
+ $('#show-calc-img').attr('src', '');
|
|
|
+ $('#calc-img').attr('src', '');
|
|
|
+ $('#view-calc-img').attr('src', '');
|
|
|
+ $('#edit-img').modal('hide');
|
|
|
+ // postData(window.location.pathname + '/detail/merge-img', {updateType: 'clear', lid: data.lid, pid: data.pid, uuid: data.uuid}, function (result) {
|
|
|
+ // stageIm.loadUpdateDetailData(result);
|
|
|
+ // data.calc_img = result.calc_img;
|
|
|
+ // data.calc_img_org = result.calc_img_org;
|
|
|
+ // const calcImgSrc = data && data.calc_img ? '/' + data.calc_img : '';
|
|
|
+ // $('#show-calc-img').attr('src', calcImgSrc);
|
|
|
+ // $('#calc-img').attr('src', calcImgSrc);
|
|
|
+ // $('#view-calc-img').attr('src', calcImgSrc);
|
|
|
+ // $('#edit-img').modal('hide');
|
|
|
+ // });
|
|
|
+ } else {
|
|
|
+ $('#show-calc-img').attr('src', '');
|
|
|
+ $('#calc-img').attr('src', '');
|
|
|
+ $('#view-calc-img').attr('src', '');
|
|
|
+ $('#edit-img').modal('hide');
|
|
|
}
|
|
|
});
|
|
|
}
|