/**
|
* 按钮处理 弹窗展示内容
|
* @author wangting
|
* @date 2021-3-16
|
*/
|
layui.define(['layer','element','BaseAction'],function(exports){
|
var webUtil = $webUtil;
|
var Class = function() {
|
this.MODELNAME = "BaseViewAction";
|
this.moduleKey = "BaseViewAction";
|
|
this.getContent = function (id) {
|
var that = this;
|
that.id = id;
|
var html = [
|
'<div class="addOrEdit" id="View_', id, ' lay-filter="View_', id, '" style="display:block; text-align: center"></div>'
|
].join("");
|
return html;
|
};
|
|
this.doAction = function (options) {
|
var that = this;
|
webUtil.copyConfig(that, that.moduleKey);
|
that.id = options.id;
|
var paramVOS={
|
getDataUrl:'uiDataController/dataFormQuery',
|
getDataBackPath: configData.compatibility ? path : configData.objectServicePath,
|
getDataMethod:'post',
|
url:'uiDataController/editSave',
|
backPath:configData.compatibility ? path : configData.objectServicePath,
|
method:'put',
|
uploadFileUrl:'vciFileUploadController/uploadFile',
|
uploadFileBackPath: configData.compatibility ? path : configData.fileServicePath
|
}
|
$.extend(paramVOS,options.paramVOS);
|
options.paramVOS=paramVOS;
|
|
var baseAction = layui['BaseAction'];
|
baseAction.callPreEvent(options, that, function (options) {
|
that.doView(options, function () {
|
baseAction.callPostEvent(options, that, options.callback);
|
});
|
});
|
};
|
|
this.doView=function (options){
|
var that = this;
|
var paramVOS=$webUtil.paramLow(options.paramVOS);
|
if (!paramVOS['form'] && !paramVOS['context']&& !paramVOS['content']) {
|
$webUtil.showErrorMsg("按钮配置不正确");
|
return false;
|
}
|
var id=options.id;
|
var selectData=options.dataStore;
|
if(selectData.length<1){
|
$webUtil.showErrorMsg("请选择一条需要查看的数据");
|
return false;
|
}
|
if(!paramVOS.multi && selectData.length > 1){
|
$webUtil.showErrorMsg("仅能选择一条数据来查看");
|
return false;
|
}
|
var table = layui.table;
|
if (paramVOS.form) {
|
var filter = "View_" + id;
|
var form = layui.form;
|
var content = ['<form id="', filter, '" lay-filter="', filter, '" class="layui-form" style="margin:15px 30px 15px 0;" ></form>'
|
].join('');
|
var addSaveIndex = layer.open({
|
type: 1,
|
title: paramVOS.title,
|
//skin: 'layui-layer-lan',
|
content: content,
|
//area: ['1860px', '200px'],
|
maxWidth: $(window).width() - 100,
|
maxHeight: $(window).height() - 100,
|
shade: true,
|
shadeClose: true,
|
resize: true,
|
resizing: function (layero) {
|
form.doResize(filter);
|
},
|
success: function (layero,layerIndex,classP) {
|
$webUtil.get('webUIController/getFormDefineById', {
|
btmType: paramVOS.type,
|
id: paramVOS.form
|
}, function (result) {
|
if (result.success) {
|
var formCallback = function () {
|
var baseAction = layui['BaseAction'];
|
if ($('#' + filter + ' .layui-upload-drag').length > 0) {
|
baseAction.renderUploadFile('#' + filter + ' .layui-upload-drag', paramVOS)
|
}
|
if (paramVOS.uploadattachment && paramVOS.uploadattachment == 'true') {
|
//显示上传附件
|
baseAction.renderUploadAttach(filter, paramVOS)
|
}
|
if ($('#' + filter + ' .webeditor').length > 0) {
|
//编辑器
|
var editId='editor_'+$('#' + filter + ' .webeditor').attr('name')
|
baseAction.renderEditor(editId,'',paramVOS,function (){
|
baseAction.relocationOpen(classP)
|
});
|
}
|
baseAction.relocationOpen(classP)
|
|
|
//获取选中的数据
|
var sourceDataMap = {};
|
layui.each(options.sourceData, function (i, item) {
|
if(item.constructor === Object) return;
|
sourceDataMap['sourceDataMap["' + i + '"]'] = item;
|
})
|
$webUtil.ajax(paramVOS.getdatamethod, paramVOS.getdataurl, $.extend({
|
btmname: paramVOS.type,
|
formDefineId: paramVOS.form,
|
oid: selectData[0].oid
|
}, sourceDataMap),
|
function (result) {
|
if (result.success) {
|
form.setValues(result.obj.data, filter);
|
//文件
|
if (result.obj.filePathFieldMap) {
|
var filepath = layui.$('#' + filter + ' .uploadDemoView input.uploadFileOid').attr('name');
|
layui.$('#' + filter + ' .uploadDemoView').removeClass('layui-hide').find('img').attr('src', paramVOS.uploadfilebackpath + 'vciFileDownloadController/downloadByFileOid?fileOid=' + result.obj.filePathFieldMap[filepath].oid + '&' + TOKEN_KEY + '=' + $webUtil.getToken());
|
layui.$('#' + filter + ' .uploadDemoView input.uploadFileOid').val(result.obj.filePathFieldMap[filepath].filePath);
|
}
|
//附件
|
if (result.obj.attachmentFileVOs && result.obj.attachmentFileVOs.length > 0) {
|
var val = [];
|
layui.each(result.obj.attachmentFileVOs, function (i, attachmentFile) {
|
val.push(attachmentFile.oid)
|
})
|
$('#' + filter + ' [name="releaseFileOids"]').val(val.join(','))
|
}
|
if ($('#' + filter + ' .webeditor').length > 0) {
|
//编辑器
|
var initV=result.obj.data[$('#' + filter + ' .webeditor').attr('name')];
|
editor.html(initV);
|
$('#' + filter + ' .webeditor').val(initV);
|
}
|
|
}
|
}, function (xhr, error) {
|
$webUtil.showErrorMsg("获取数据出现了错误,可能是文件服务没有启动");
|
}, paramVOS.getdatabackpath)
|
|
}
|
|
form.addItems(filter, result.obj.items, formCallback, {}, {
|
defaultColumnOneRow: result.obj.columnOneRow
|
});
|
} else {
|
$webUtil.showErrorMsg(result.msg||'获取表单失败');
|
}
|
|
}, function (xhr, error) {
|
$webUtil.showErrorMsg("获取表单出现了错误,可能是文件服务没有启动");
|
}, paramVOS.backpath)
|
}
|
});
|
} else if (paramVOS.context||paramVOS.content) {
|
layui.use('platform/objectService/VciUIContentViewer', function () {
|
var newTabClass = layui['platform/objectService/VciUIContentViewer'];
|
newTabClass.id = id;
|
newTabClass.multiCompent = true;
|
newTabClass.sourceData = {
|
btmType: paramVOS.type,
|
content: paramVOS.context,
|
dataOid:options.dataStore[0].oid,
|
actionData: {
|
selectData: options.sourceData,
|
dataStore:options.dataStore,
|
isOpen: true,
|
isShowBtns:false,
|
paramVOS: paramVOS
|
}
|
};
|
|
var filter = "View_" + id;
|
var content = ['<div id="', filter, '" lay-filter="', filter, '" style="margin:5px;" >',newTabClass.getContent(id),'</div>']
|
var addSaveIndex = layer.open({
|
type: 1,
|
title: paramVOS.title,
|
//skin: 'layui-layer-lan',
|
content: content.join(''),
|
area: [$(window).width() - 100+'px', $(window).height() - 100+'px'],
|
shade: true,
|
shadeClose: true,
|
resize: true,
|
resizing: function (layero) {
|
},
|
success: function (layero,layerIndex,classP) {
|
newTabClass.init(id, newTabClass.sourceData,function (){
|
//layui['BaseAction'].relocationOpen(classP)
|
})
|
}
|
});
|
});
|
}
|
}
|
|
this.refresh = function () {
|
var that = this;
|
|
};
|
|
this.destory = function () {
|
var that = this;
|
var filter = "View_" + that.id;
|
$('#' + filter).remove()
|
};
|
};
|
var cs = new Class();
|
exports(cs.MODELNAME,cs);
|
});
|