/**
|
* 链接类型的添加
|
* @author wangting
|
* @date 2021-3-16
|
*/
|
layui.define(['layer','element','BaseAction'],function(exports){
|
var webUtil = $webUtil;
|
var Class = function() {
|
this.MODELNAME = "BaseLinkAddAction";
|
this.moduleKey = "BaseLinkAddAction";
|
|
this.getContent = function (id) {
|
var that = this;
|
that.id = id;
|
var html = [
|
'<div class="addOrEdit" id="addOrEdit_', id, ' lay-filter="addOrEdit_', 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 = {
|
url: 'uiDataController/linkAddSave',
|
backPath: configData.compatibility ? path : configData.objectServicePath,
|
method: 'post',
|
uploadFileUrl: 'vciFileUploadController/uploadFile',
|
uploadFileBackPath: configData.compatibility ? path : configData.fileServicePath,
|
direction:false
|
}
|
$.extend(paramVOS, options.paramVOS);
|
options.paramVOS = paramVOS;
|
|
var baseAction = layui['BaseAction'];
|
baseAction.callPreEvent(options, that, function (options) {
|
that.doAdd(options, function () {
|
baseAction.callPostEvent(options, that, options.callback);
|
});
|
});
|
};
|
|
|
this.doAdd = function (options,callback) {
|
var that = this;
|
var paramVOS = $webUtil.paramLow(options.paramVOS);
|
if (!paramVOS['form'] && !paramVOS['context']&& !paramVOS['content']) {
|
$webUtil.showErrorMsg("按钮配置不正确");
|
return false;
|
}
|
if (!paramVOS['linktype']) {
|
$webUtil.showErrorMsg("按钮配置无linktype");
|
return false;
|
}
|
var selectData = options.dataStore;
|
|
var table = layui.table;
|
if (paramVOS.form) {
|
var filter = "addOrEdit_" + options.id;
|
var form = layui.form;
|
var content = ['<form id="', filter, '" lay-filter="', filter, '" class="layui-form" style="margin:15px 30px 50px 0;" ></form>'
|
].join('');
|
var addSaveIndex = layer.open({
|
type: 1,
|
title: paramVOS.title,
|
btn: ['保存', '取消'],
|
//skin: 'layui-layer-lan',
|
content: content,
|
//area: ['1860px', '200px'],
|
maxWidth: $(window).width() - 100,
|
maxHeight: $(window).height() - 100,
|
closeBtn: 1,
|
shade: true,
|
shadeClose: true,
|
resize: true,
|
resizing: function (layero) {
|
form.doResize(filter);
|
},
|
success: function (layero,layerIndex,classP) {
|
$webUtil.get('webUIController/getFormDefineById', {
|
btmType: paramVOS.linktype,
|
id: paramVOS.form
|
}, function (result) {
|
if (result.success) {
|
var formCallback = function () {
|
var initValues = form.getValues(filter,true);
|
if (paramVOS.initvalue) {
|
var urlobj = $webUtil.getUrlParams('?' + paramVOS.initvalue, {}, '#', ';');
|
initValues = urlobj.params;
|
}
|
var treeInitKeyMap = {
|
"f_oid":(paramVOS.foid||paramVOS.f_oid||options.sourceData.oid),
|
"f_btwname":(paramVOS.fbtmname || paramVOS.f_btmname || paramVOS.f_btwname||options.sourceData.btmname),
|
"t_oid":(paramVOS.toid || paramVOS.t_oid),
|
"t_btwname":(paramVOS.tbtmname || paramVOS.t_btmname),
|
"foid":(paramVOS.foid||paramVOS.f_oid||options.sourceData.oid),
|
"fbtwname":(paramVOS.fbtmname || paramVOS.f_btmname || paramVOS.f_btwname||options.sourceData.btmname),
|
"toid":(paramVOS.toid || paramVOS.t_oid),
|
"tbtwname":(paramVOS.tbtmname || paramVOS.t_btmname)
|
}
|
for(var key in treeInitKeyMap){
|
var value = treeInitKeyMap[key];
|
if(value && $webUtil.isNotNull(value)){
|
initValues[key] = $webUtil.replaceFreeMarker(value,selectData,options.sourceData);
|
}
|
}
|
form.setValues(initValues,filter);
|
var baseAction = layui['BaseAction'];
|
if ($('#' + filter + ' .layui-upload-drag').length > 0) {
|
//文件上传
|
baseAction.renderUploadFile('#' + filter + ' .layui-upload-drag',paramVOS)
|
}
|
|
if(paramVOS.uploadattachment &¶mVOS.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)
|
|
}
|
|
form.addItems(filter, result.obj.items, formCallback, {}, {
|
defaultColumnOneRow: result.obj.columnOneRow
|
});
|
} else {
|
$webUtil.showErrorMsg(result.msg||'获取表单失败');
|
}
|
|
}, function (xhr, error) {
|
$webUtil.showErrorMsg("获取表单出现了错误,可能是文件服务没有启动");
|
}, paramVOS.backpath)
|
},
|
yes: function (layero) {
|
if (form.validata(filter)) {
|
if (paramVOS.savebeforeevent) {
|
var urlobj = $webUtil.getUrlParams(paramVOS.savebeforeevent);
|
layui.use(urlobj.jsPath, function () {
|
var pathAction = layui[urlobj.jsPath];
|
var id = 'saveBeforeEvent_' + id;
|
pathAction[urlobj.methodName](paramVOS, id, selectData);
|
})
|
}
|
var formValues = form.getDefaultValues(filter, true,form.linkDefaultKeys);
|
if(formValues.otherValue.releaseFileOids){
|
formValues.otherValue.releaseFileOids=formValues.otherValue.releaseFileOids.split(',');
|
}
|
if (!formValues.defaultValues.linkType) {
|
formValues.defaultValues.linkType = paramVOS.linktype||paramVOS.type;
|
}
|
var datas = {
|
formDefineId: paramVOS.form,
|
preEvent: paramVOS.preevent,
|
afterEvent: paramVOS.afterevent,
|
beforeServerEvent: paramVOS.beforeserverevent,
|
afterServerEvent: paramVOS.afterserverevent,
|
releaseFileOids: formValues.otherValue.releaseFileOids||[],
|
data: formValues.otherValue
|
}
|
$.extend(datas, formValues.defaultValues,formValues.otherValue);
|
$webUtil.manualAjax(paramVOS.method, paramVOS.url, JSON.stringify(datas), function (result) {
|
if (result.success) {
|
$webUtil.showMsgFromResult(result, paramVOS.title + '成功');
|
that.refresh();
|
if (options.callback) {
|
options.callback()
|
}
|
if (paramVOS.saveafterevent) {
|
var urlobj = $webUtil.getUrlParams(paramVOS.saveafterevent);
|
layui.use(urlobj.jsPath, function () {
|
var pathAction = layui[urlobj.jsPath];
|
var id = 'saveBeforeEvent_' + id;
|
pathAction[urlobj.methodName](paramVOS, id, selectData);
|
})
|
}
|
if(callback){
|
callback();
|
}
|
layer.close(addSaveIndex);
|
} else {
|
$webUtil.showErrorMsg(result.msg||paramVOS.title + '失败');
|
}
|
}, function (xhr, error) {
|
$webUtil.showErrorMsg("访问服务器出现了错误,可能服务器没有开启,或者连接失败");
|
}, paramVOS.backpath);
|
}
|
},
|
btn2: function (layero) {
|
layer.close(addSaveIndex)
|
}
|
});
|
} else if (paramVOS.context||paramVOS.content) {
|
layui.use('platform/objectService/VciUIContentViewer', function () {
|
var newTabClass = layui['platform/objectService/VciUIContentViewer'];
|
newTabClass.id = that.id;
|
newTabClass.multiCompent = true;
|
newTabClass.sourceData = {
|
btmType: paramVOS.type,
|
content: paramVOS.context,
|
actionData: {
|
selectData: options.sourceData,
|
isOpen: true,
|
paramVOS: paramVOS
|
}
|
};
|
var filter = "addOrEdit_" + that.id;
|
var content = ['<div id="', filter, '" lay-filter="', filter, '" style="margin:5px;" >',newTabClass.getContent(that.id),'</div>']
|
var addSaveIndex = layer.open({
|
type: 1,
|
title: paramVOS.title,
|
//skin: 'layui-layer-lan',
|
content: content.join(''),
|
shade: true,
|
shadeClose: true,
|
area: [$(window).width() - 100+'px', $(window).height() - 100+'px'],
|
resize: true,
|
resizing: function (layero) {
|
},
|
success: function (layero,layerIndex,classP) {
|
newTabClass.init(that.id, newTabClass.sourceData,function (){
|
//layui['BaseAction'].relocationOpen(classP)
|
})
|
|
},
|
cancel: function (layero) {
|
if (options.callback) {
|
options.callback()
|
}
|
}
|
});
|
});
|
}
|
}
|
|
this.refresh = function () {
|
var that = this;
|
|
};
|
|
this.destory = function () {
|
var that = this;
|
var filter = "addOrEdit_" + that.id;
|
$('#' + filter).remove()
|
};
|
};
|
var cs = new Class();
|
exports(cs.MODELNAME,cs);
|
});
|