提交 2cda4a11 编写于 作者: doc_wei's avatar doc_wei

数据信息修改为属性的字段

上级 77f6dd7a
......@@ -37,11 +37,16 @@ layui.config({
cols: [[
{ title: systemLanguage["com.skyeye.serialNumber"][languageType], type: 'numbers' },
{ field: 'attrKey', title: '属性', align: 'left', width: 150 },
{ field: 'name', title: '名称', align: 'left', width: 120 },
{ field: 'name', title: '名称', align: 'left', width: 120, templet: function (d) {
if (!isNull(d.attrDefinitionCustom)) {
return d.attrDefinitionCustom.name;
}
return d.name;
}},
{ field: 'attrType', title: '类型', align: 'left', width: 120 },
{ field: 'componentName', title: '关联组件', align: 'left', width: 140, templet: function (d) {
if (!isNull(d.dsFormComponent)) {
return d.dsFormComponent.name;
if (!isNull(d.attrDefinitionCustom) && !isNull(d.attrDefinitionCustom.dsFormComponent)) {
return d.attrDefinitionCustom.dsFormComponent.name;
}
return '';
}},
......
......@@ -10,6 +10,33 @@ layui.config({
var $ = layui.$,
form = layui.form,
textool = layui.textool;
var selOption = getFileContent('tpl/template/select-option.tpl');
// 不同的数据来源对应不同的html
var dataTypeObject = {
"1": `<div class="layui-form-item layui-col-xs12">
<label class="layui-form-label">默认数据<i class="red">*</i></label>
<div class="layui-input-block">
<textarea id="defaultData" name="defaultData" win-verify="required" class="layui-textarea"></textarea>
<div class="layui-form-mid layui-word-aux">数据样式为:[{"id":"1","name":"男",...},{"id":"2","name":"女",...}]</div>
</div>
</div>`,
"2": `<div class="layui-form-item layui-col-xs12">
<label class="layui-form-label">枚举数据<i class="red">*</i></label>
<div class="layui-input-block">
<select id="objectId" name="objectId" lay-search="" win-verify="required" lay-filter="objectId"></select>
</div>
</div>`,
"3": `<div class="layui-form-item layui-col-xs12">
<label class="layui-form-label">数据字典<i class="red">*</i></label>
<div class="layui-input-block">
<select id="objectId" name="objectId" lay-search="" win-verify="required" lay-filter="objectId"></select>
</div>
</div>`
};
// 表单控件集合
var componentList = [];
var className = GetUrlParam('className');
var attrKey = GetUrlParam('attrKey');
......@@ -23,11 +50,23 @@ layui.config({
eleTree: layui.eleTree,
elem: 'componentId',
url: reqBasePath + "queryAllDsFormComponentList",
defaultId: json.bean.componentId
defaultId: json.bean.componentId,
ajaxCallback: function (data) {
$.each(data.rows, function (i, item) {
if (!isNull(item.children)) {
componentList = componentList.concat(item.children);
}
});
var value = dataType == 1 ? json.bean.defaultData : json.bean.objectId;
loadLinkData(json.bean.componentId, json.bean.dataType, value);
},
clickCallback: function (chooseId) {
loadLinkData(chooseId, '', '');
}
});
// 如果不是入参属性,则不能设置特定的一些值
if (!json.bean.attrDefinition.whetherInputParams) {
if (!json.bean.whetherInputParams) {
$('.inputParams').hide();
}
......@@ -46,6 +85,38 @@ layui.config({
remark: $("#remark").val(),
id: id
};
var dsFormComponent = getInPoingArr(componentList, 'id', params.componentId);
if (!isNull(dsFormComponent) && dsFormComponent.linkedData == 1) {
params.dataType = $("#dataType").val();
if (params.dataType == 1) {
// 自定义
var defaultDataStr = $("#defaultData").val();
if (isNull(defaultDataStr)) {
winui.window.msg("请填写Json串!", {icon: 2, time: 2000});
return false;
} else {
if (isJSON(defaultDataStr)) {
var defaultKey = getOutKey(defaultDataStr);//取出json串的键
// 获取数据展示模板
var tplContentVal = strMatchAllByTwo(dsFormComponent.htmlDataFrom, '{{', '}}');//取出数据模板中用{{}}包裹的词
removeByValue(tplContentVal, "#each this");
removeByValue(tplContentVal, "/each");
if (subset(tplContentVal, defaultKey)) {
params.defaultData = defaultDataStr;
} else {
winui.window.msg('json串内容有误,请重新填写!', {icon: 2, time: 2000});
return false;
}
} else {
winui.window.msg('json串格式不正确,请重新填写!', {icon: 2, time: 2000});
return false;
}
}
} else {
params.objectId = $("#objectId").val();
}
}
AjaxPostUtil.request({url: reqBasePath + "saveAttrDefinitionCustom", params: params, type: 'json', method: "POST", callback: function (json) {
parent.layer.close(index);
parent.refreshCode = '0';
......@@ -55,7 +126,65 @@ layui.config({
});
}});
function loadLinkData(componentId, dataType, value) {
var dsFormComponent = getInPoingArr(componentList, 'id', componentId);
if (!isNull(dsFormComponent) && dsFormComponent.linkedData == 1) {
// 允许关联数据
$("#linkDataBox").removeClass("layui-hide");
// 数据来源类型
skyeyeClassEnumUtil.showEnumDataListByClassName("attrKeyDataType", 'select', "dataType", dataType, form);
form.on('select(dataType)', function(data) {
loadDataMation($('#dataType').val(), '');
});
loadDataMation(dataType, value);
} else {
$("#linkDataBox").addClass("layui-hide");
}
}
function loadDataMation(dataType, value) {
$("#dataTypeObjectBox").html(dataTypeObject[dataType]);
if (dataType == 1) {
// 自定义
$("#defaultData").val(value);
} else if (dataType == 2) {
// 枚举
initEnumData();
$("#objectId").val(value);
} else if (dataType == 3) {
// 数据字典
initDictData();
$("#objectId").val(value);
}
form.render('select');
}
/**
* 加载枚举类可选列表
*/
function initEnumData() {
var arr = [];
$.each(skyeyeClassEnum, function (key, value) {
arr.push({
id: key,
name: value.name
})
});
$("#objectId").html(getDataUseHandlebars(selOption, {rows: arr}));
form.render('select');
}
/**
* 加载数据字典可选列表
*/
function initDictData() {
AjaxPostUtil.request({url: reqBasePath + "queryDictTypeListByEnabled", params: {enabled: 1}, type: 'json', method: 'GET', callback: function (json) {
$("#objectId").html(getDataUseHandlebars(selOption, json));
}, async: false});
}
$("body").on("click", "#cancle", function() {
parent.layer.close(index);
});
});
\ No newline at end of file
......@@ -16,7 +16,7 @@
<table id="messageTable" lay-filter="messageTable"></table>
<script type="text/html" id="tableBar">
<a class="layui-btn layui-btn-xs layui-btn-normal" lay-event="edit"><language showName="com.skyeye.editBtn"></language></a>
{{# if(!isNull(d.attrDefinitionCustomId)) { }}
{{# if(!isNull(d.attrDefinitionCustom)) { }}
<a class="layui-btn layui-btn-xs layui-btn-danger" lay-event="restore">还原</a>
{{# } }}
</script>
......
......@@ -37,6 +37,19 @@
<input type="text" id="componentId" name="componentId" placeholder="请选择组件" class="layui-input" readonly="readonly" componentId=""/>
</div>
</div>
<div class="layui-hide" id="linkDataBox">
<div class="layui-form-item layui-col-xs12">
<label class="layui-form-label">数据来源<i class="red">*</i></label>
<div class="layui-input-block">
<select id="dataType" name="dataType" lay-search="" lay-filter="dataType">
</select>
</div>
</div>
<div id="dataTypeObjectBox">
</div>
</div>
<div class="layui-form-item layui-col-xs6">
<label class="layui-form-label">最小长度</label>
<div class="layui-input-block">
......
......@@ -119,10 +119,11 @@ layui.config({
template: $("#leftAttrBoxItem").html(),
ajaxSendLoadBefore: function (hdb, json) {
$.each(json.rows, function (i, item) {
if (isNull(item.dsFormComponent)) {
if (isNull(item.attrDefinitionCustom) || isNull(item.attrDefinitionCustom.dsFormComponent)) {
item.class = "no-choose";
item.showTitle = noComponentTitle;
} else {
item.name = item.attrDefinitionCustom.name;
var temp = getInPoingArr(contentList, 'attrKey', item.attrKey);
if (!isNull(temp)) {
item.class = "no-choose";
......
......@@ -15,40 +15,20 @@ layui.config({
}
var selOption = getFileContent('tpl/template/select-option.tpl');
// 不同的数据来源对应不同的html
var dataTypeObject = {
"1": `<div class="layui-form-item layui-col-xs12">
<label class="layui-form-label">默认数据<i class="red">*</i></label>
<div class="layui-input-block">
<textarea id="defaultData" name="defaultData" win-verify="required" class="layui-textarea"></textarea>
<div class="layui-form-mid layui-word-aux">数据样式为:[{"id":"1","name":"男",...},{"id":"2","name":"女",...}]</div>
</div>
</div>`,
"2": `<div class="layui-form-item layui-col-xs12">
<label class="layui-form-label">枚举数据<i class="red">*</i></label>
<div class="layui-input-block">
<select id="objectId" name="objectId" lay-search="" win-verify="required" lay-filter="objectId"></select>
</div>
</div>`,
"3": `<div class="layui-form-item layui-col-xs12">
<label class="layui-form-label">数据字典<i class="red">*</i></label>
<div class="layui-input-block">
<select id="objectId" name="objectId" lay-search="" win-verify="required" lay-filter="objectId"></select>
</div>
</div>`
};
$("#showForm").html(getDataUseHandlebars($("#controlItemEdit").html(), {bean: data}));
// 属性信息
var attrs = [];
$.each(parent.attrList, function (i, item) {
// 获取已经绑定组件的属性并且适用于当前组件的属性
if (!isNull(item.dsFormComponent) && data.dsFormComponent.id == item.dsFormComponent.id) {
attrs.push({
id: item.attrKey,
name: item.name
})
if (!isNull(item.attrDefinitionCustom)) {
var dsFormComponent = item.attrDefinitionCustom.dsFormComponent;
if (!isNull(dsFormComponent) && data.dsFormComponent.id == dsFormComponent.id) {
attrs.push({
id: item.attrKey,
name: item.attrDefinitionCustom.name
})
}
}
});
$("#attrKey").html(getDataUseHandlebars(selOption, {rows: attrs}));
......@@ -72,16 +52,6 @@ layui.config({
$("#" + item).removeClass("layui-hide");
});
if (data.dsFormComponent.linkedData == 1) {
// 允许关联数据
$("#linkDataBox").removeClass("layui-hide");
// 数据来源类型
skyeyeClassEnumUtil.showEnumDataListByClassName("pageComponentDataType", 'select', "dataType", data.dataType, form);
form.on('select(dataType)', function(data) {
loadDataMation($('#dataType').val());
});
loadDataMation(data.dataType)
}
$("#width").val(data.width);
// 属性的限制条件
......@@ -119,36 +89,6 @@ layui.config({
newParams.attrDefinition = getInPoingArr(parent.attrList, 'attrKey', $("#attrKey").val());
}
if (newParams.dsFormComponent.linkedData == 1) {
newParams.dataType = $("#dataType").val();
if (newParams.dataType == 1) {
// 自定义
var defaultDataStr = $("#defaultData").val();
if (isNull(defaultDataStr)) {
winui.window.msg("请填写Json串!", {icon: 2, time: 2000});
return false;
} else {
if (isJSON(defaultDataStr)) {
var defaultKey = getOutKey(defaultDataStr);//取出json串的键
// 获取数据展示模板
var tplContentVal = strMatchAllByTwo(data.dsFormComponent.htmlDataFrom, '{{', '}}');//取出数据模板中用{{}}包裹的词
removeByValue(tplContentVal, "#each this");
removeByValue(tplContentVal, "/each");
if (subset(tplContentVal, defaultKey)) {
newParams.defaultData = defaultDataStr;
} else {
winui.window.msg('json串内容有误,请重新填写!', {icon: 2, time: 2000});
return false;
}
} else {
winui.window.msg('json串格式不正确,请重新填写!', {icon: 2, time: 2000});
return false;
}
}
} else {
newParams.objectId = $("#objectId").val();
}
}
parent.contentList = parent.contentList.map(t => {
return t.id === data.id ? newParams : t;
});
......@@ -156,42 +96,4 @@ layui.config({
$(".mask-req-str").remove();
}
function loadDataMation(value) {
$("#dataTypeObjectBox").html(dataTypeObject[value]);
if (value == 1) {
// 自定义
} else if (value == 2) {
// 枚举
initEnumData();
} else if (value == 3) {
// 数据字典
initDictData();
}
}
/**
* 加载枚举类可选列表
*/
function initEnumData() {
var arr = [];
$.each(skyeyeClassEnum, function (key, value) {
arr.push({
id: key,
name: value.name
})
});
$("#objectId").html(getDataUseHandlebars(selOption, {rows: arr}));
form.render('select');
}
/**
* 加载数据字典可选列表
*/
function initDictData() {
AjaxPostUtil.request({url: reqBasePath + "queryDictTypeListByEnabled", params: {enabled: 1}, type: 'json', method: 'GET', callback: function (json) {
$("#objectId").html(getDataUseHandlebars(selOption, json));
form.render('select');
}});
}
});
\ No newline at end of file
......@@ -55,7 +55,7 @@
<script type="text/html" id="leftAttrBoxItem">
{{#each rows}}
<div class="btntext attr-mation {{class}}" attrKey="{{attrKey}}" componentId="{{dsFormComponent.id}}" title="{{showTitle}}">
<div class="btntext attr-mation {{class}}" attrKey="{{attrKey}}" componentId="{{attrDefinitionCustom.dsFormComponent.id}}" title="{{showTitle}}">
<label class="col-sm-12 {{class}}">
<i class="fa fa-arrows fa-fw {{iLabelClass}}"></i>{{name}}
</label>
......
......@@ -59,22 +59,6 @@
</select>
</div>
</div>
<div class="layui-hide" id="linkDataBox">
<div class="layui-form-item layui-col-xs12">
<span class="hr-title">数据信息</span><hr>
</div>
<div class="layui-form-item layui-col-xs12">
<label class="layui-form-label">数据来源<i class="red">*</i></label>
<div class="layui-input-block">
<select id="dataType" name="dataType" lay-search="" lay-filter="dataType">
</select>
</div>
</div>
<div id="dataTypeObjectBox">
</div>
</div>
<div class="layui-form-item layui-col-xs12">
<div class="layui-input-block">
<button class="winui-btn" lay-submit lay-filter="formAddBean"><language showName="com.skyeye.save"></language></button>
......
......@@ -915,7 +915,9 @@ var treeSelectUtil = {
url: '',
idKey: 'id',
nameKey: 'name',
defaultId: ''
defaultId: '',
ajaxCallback: null,
clickCallback: null
},
init: function (_config) {
......@@ -943,6 +945,9 @@ var treeSelectUtil = {
$(`#${treeSelectUtil.config.elem}`).val(html);
$(`#${treeSelectUtil.config.elem}`).attr(`${treeSelectUtil.config.elem}`, treeSelectUtil.config.defaultId);
}
if (typeof treeSelectUtil.config.ajaxCallback == "function") {
treeSelectUtil.config.ajaxCallback(res);
}
}
});
......@@ -958,6 +963,9 @@ var treeSelectUtil = {
}
$(`#${treeSelectUtil.config.elem}`).val(d.data.currentData[treeSelectUtil.config.nameKey]);
$(`#${treeSelectUtil.config.elem}`).attr(`${treeSelectUtil.config.elem}`, d.data.currentData[treeSelectUtil.config.idKey]);
if (typeof treeSelectUtil.config.clickCallback == "function") {
treeSelectUtil.config.clickCallback(d.data.currentData[treeSelectUtil.config.idKey]);
}
$(".ele5").hide();
})
$(document).on("click",function() {
......
......@@ -148,7 +148,11 @@ var dsFormUtil = {
content = dsFormUtil.getContentLinkedData(content);
}
if (!isNull(content.attrDefinition)) {
content.title = content.attrDefinition.name;
if (!isNull(content.attrDefinition.attrDefinitionCustom)) {
content.title = content.attrDefinition.attrDefinitionCustom.name;
} else {
content.title = content.attrDefinition.name;
}
}
var jsonStr = {bean: content};
......
......@@ -35,7 +35,7 @@
"disCussionAuthEnum": {"name": "讨论帖权限", "className": "skyeye-pro#com.skyeye.discussion.classenum.DisCussionAuthEnum"},
"dsFormPageType": {"name": "表单布局类型", "className": "skyeye-pro#com.skyeye.dsform.classenum.DsFormPageType"},
"pageComponentDataType": {"name": "表单布局里面的组件关联的数据类型", "className": "skyeye-pro#com.skyeye.dsform.classenum.PageComponentDataType"},
"attrKeyDataType": {"name": "表单布局里面的组件关联的数据类型", "className": "skyeye-pro#com.skyeye.attr.classenum.AttrKeyDataType"},
"componentAttr": {"name": "组件关联的属性", "className": "skyeye-pro#com.skyeye.dsform.classenum.ComponentAttr"},
"buttonColorType": {"name": "操作按钮颜色", "className": "skyeye-pro#com.skyeye.attr.classenum.ButtonColorType"},
"eventType": {"name": "操作按钮事件类型", "className": "skyeye-pro#com.skyeye.operate.classenum.EventType"},
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册