提交 28b9c8b6 编写于 作者: Skyeye云's avatar Skyeye云

表单布局支持编辑布局的禁止编辑操作

上级 bfb17fe3
...@@ -26,7 +26,7 @@ layui.config({ ...@@ -26,7 +26,7 @@ layui.config({
limit: getLimit(), limit: getLimit(),
cols: [[ cols: [[
{ title: systemLanguage["com.skyeye.serialNumber"][languageType], type: 'numbers' }, { title: systemLanguage["com.skyeye.serialNumber"][languageType], type: 'numbers' },
{ field: 'numCode', title: '编码', width: 120 }, { field: 'numCode', title: '编码', width: 250 },
{ field: 'name', title: '名称', width: 120 }, { field: 'name', title: '名称', width: 120 },
{ field: 'typeName', title: '分类', width: 120 }, { field: 'typeName', title: '分类', width: 120 },
{ field: 'showType', title: '显示类型', width: 120, templet: function (d) { { field: 'showType', title: '显示类型', width: 120, templet: function (d) {
......
...@@ -56,7 +56,7 @@ layui.config({ ...@@ -56,7 +56,7 @@ layui.config({
str += '<a class="layui-btn layui-btn-xs" lay-event="subApproval">提交审批</a>'; str += '<a class="layui-btn layui-btn-xs" lay-event="subApproval">提交审批</a>';
} }
if (authPermission['edit']) { if (authPermission['edit']) {
str += '<a class="layui-btn layui-btn-xs" lay-event="edit"><language showName="com.skyeye.editBtn"></language></a>'; str += '<a class="layui-btn layui-btn-xs layui-btn-normal" lay-event="edit"><language showName="com.skyeye.editBtn"></language></a>';
} }
if (authPermission['delete']) { if (authPermission['delete']) {
str += '<a class="layui-btn layui-btn-xs layui-btn-danger" lay-event="del">删除</a>'; str += '<a class="layui-btn layui-btn-xs layui-btn-danger" lay-event="del">删除</a>';
...@@ -77,12 +77,7 @@ layui.config({ ...@@ -77,12 +77,7 @@ layui.config({
} }
if (d.state == 'executing') { if (d.state == 'executing') {
if (authPermission['close']) { if (authPermission['close']) {
str += '<a class="layui-btn layui-btn-xs layui-btn-danger" lay-event="close">关闭</a>'; str += '<a class="layui-btn layui-btn-xs layui-btn-normal" lay-event="close">关闭</a>';
}
}
if (d.state == 'executing') {
if (authPermission['close']) {
str += '<a class="layui-btn layui-btn-xs layui-btn-danger" lay-event="close">关闭</a>';
} }
if (authPermission['layAside']) { if (authPermission['layAside']) {
str += '<a class="layui-btn layui-btn-xs layui-btn-danger" lay-event="shelve">搁置</a>'; str += '<a class="layui-btn layui-btn-xs layui-btn-danger" lay-event="shelve">搁置</a>';
......
...@@ -50,9 +50,15 @@ var dsFormUtil = { ...@@ -50,9 +50,15 @@ var dsFormUtil = {
'8': `{{#bean}} '8': `{{#bean}}
<div class="layui-form-item {{width}}" controlType="{{dsFormComponent.numCode}}" contentId="{{id}}"> <div class="layui-form-item {{width}}" controlType="{{dsFormComponent.numCode}}" contentId="{{id}}">
<label class="layui-form-label">{{title}}:</label> <label class="layui-form-label">{{title}}:</label>
<div class="layui-input-block ver-center">{{#each value}}<span class="layui-badge layui-bg-blue skyeye-badge">{{name}}</span>{{/each}}</div> <div class="layui-input-block ver-center">{{#each value}}{{name}}&nbsp;&nbsp;&nbsp;&nbsp;{{/each}}</div>
</div> </div>
{{/bean}}`, // Id转Mation取值转换后的展示 {{/bean}}`, // Id转Mation取值转换后的展示
'8-1': `{{#bean}}
<div class="layui-form-item {{width}}" controlType="{{dsFormComponent.numCode}}" contentId="{{id}}">
<label class="layui-form-label">{{title}}:</label>
<div class="layui-input-block ver-center">{{#each value}}<span class="layui-badge layui-bg-blue skyeye-badge">{{name}}</span>{{/each}}</div>
</div>
{{/bean}}`, // Id转Mation取值转换后的展示(用户组件)
}, },
pageMation: {}, pageMation: {},
...@@ -100,27 +106,44 @@ var dsFormUtil = { ...@@ -100,27 +106,44 @@ var dsFormUtil = {
* @param data * @param data
*/ */
initEditPage: function(showBoxId, pageMation, data) { initEditPage: function(showBoxId, pageMation, data) {
dsFormUtil.initCreatePage(showBoxId, pageMation); dsFormUtil.pageMation = pageMation;
$.each(dsFormUtil.pageMation.dsFormPageContents, function (i, content) { layui.define(["jquery", 'form'], function(exports) {
var attrDefinition = content.attrDefinition; var form = layui.form;
if (!isNull(attrDefinition) && !$.isEmptyObject(attrDefinition)) { $.each(dsFormUtil.pageMation.dsFormPageContents, function (i, dsFormContent) {
// 获取组件中设置值的脚本 var attrDefinition = dsFormContent.attrDefinition;
var dsFormComponent = content.dsFormComponent; dsFormContent["pageType"] = pageMation.type;
var value = dsFormUtil.getValueDataFromBusinessForEdit(content, data); if (!isNull(attrDefinition) && !$.isEmptyObject(attrDefinition)) {
content["value"] = value; var dsFormComponent = dsFormContent.dsFormComponent;
content["pageType"] = 'edit'; if (dsFormContent.isEdit == 0) {
var jsFitValue = dsFormComponent.jsFitValue; // 不可以编辑
if (!isNull(jsFitValue) && jsFitValue.startsWith('layui.define')) { var value = data[attrDefinition.attrKey];
var setValueScript = getDataUseHandlebars('{{#this}}' + dsFormComponent.jsFitValue + '{{/this}}', content); if (dsFormComponent.valueMergType == 'extend') {
$(`#script${content.id}`).remove(); value = data;
$(`div[contentId="${content.id}"]`).after(`<script id="script${content.id}">${setValueScript}</script>`); }
dsFormUtil.loadComponentValueDetails(showBoxId, dsFormContent, value, data);
} else {
dsFormUtil.loadComponent(showBoxId, dsFormContent);
var value = dsFormUtil.getValueDataFromBusinessForEdit(dsFormContent, data);
dsFormContent["value"] = value;
var jsFitValue = dsFormComponent.jsFitValue;
if (!isNull(jsFitValue) && jsFitValue.startsWith('layui.define')) {
var setValueScript = getDataUseHandlebars('{{#this}}' + dsFormComponent.jsFitValue + '{{/this}}', dsFormContent);
$(`#script${dsFormContent.id}`).remove();
$(`div[contentId="${dsFormContent.id}"]`).after(`<script id="script${dsFormContent.id}">${setValueScript}</script>`);
} else {
var setValueScript = getDataUseHandlebars('{{#this}}' + dsFormComponent.jsFitValue + '{{/this}}', dsFormContent);
eval(setValueScript);
}
}
} else { } else {
var setValueScript = getDataUseHandlebars('{{#this}}' + dsFormComponent.jsFitValue + '{{/this}}', content); dsFormUtil.loadComponent(showBoxId, dsFormContent);
eval(setValueScript);
} }
} });
matchingLanguage();
form.render();
dsFormUtil.initEvent(form);
}); });
layui.form.render();
}, },
// 获取业务数据中实际的值 // 获取业务数据中实际的值
...@@ -301,8 +324,6 @@ var dsFormUtil = { ...@@ -301,8 +324,6 @@ var dsFormUtil = {
if (!isNull(content.require)) { if (!isNull(content.require)) {
dsFormUtil.setIsRequired(content); dsFormUtil.setIsRequired(content);
} }
dsFormUtil.setIsEdit(content);
return content; return content;
}, },
...@@ -313,14 +334,6 @@ var dsFormUtil = { ...@@ -313,14 +334,6 @@ var dsFormUtil = {
} }
}, },
// 设置是否可以编辑
setIsEdit: function (content) {
if (content.isEdit == 0) {
$(`div[contentId='${content.id}']`).find('select').attr('disabled', true);
$(`div[contentId='${content.id}']`).find('input').attr('disabled', true);
}
},
/** /**
* 加载组件详情信息 * 加载组件详情信息
* *
...@@ -354,7 +367,12 @@ var dsFormUtil = { ...@@ -354,7 +367,12 @@ var dsFormUtil = {
content.photo = photoValue; content.photo = photoValue;
} }
// 加载html // 加载html
var str = getDataUseHandlebars(dsFormUtil.showType[showType], {bean: content}); var str = '';
if (component.numCode == 'userStaffChoose') {
str = getDataUseHandlebars(dsFormUtil.showType['8-1'], {bean: content});
} else {
str = getDataUseHandlebars(dsFormUtil.showType[showType], {bean: content});
}
$("#" + boxId).append(str); $("#" + boxId).append(str);
if (showType == 5) { // 表格展示 if (showType == 5) { // 表格展示
...@@ -490,13 +508,15 @@ var dsFormUtil = { ...@@ -490,13 +508,15 @@ var dsFormUtil = {
} }
if (!isNull(customAttr.dsFormComponent)) { if (!isNull(customAttr.dsFormComponent)) {
var showType = dsFormUtil.getShowType(attrDefinition);
var numCode = customAttr.dsFormComponent.numCode;
// 团队模板类型的组件,value值单独转换 // 团队模板类型的组件,value值单独转换
if (customAttr.dsFormComponent.numCode == 'teamTemplate') { if (numCode == 'teamTemplate') {
return teamObjectPermissionUtil.getTeamTemplate(value).name; return teamObjectPermissionUtil.getTeamTemplate(value).name;
} }
// 用户组件,value值特殊处理 // Id转Mation取值转换
if (customAttr.dsFormComponent.numCode == 'userStaffChoose') { if (showType == 8) {
var key = attrDefinition.attrKey; var key = attrDefinition.attrKey;
// 例如:将key由relationUserId变为relationUserMation // 例如:将key由relationUserId变为relationUserMation
key = key.replace("Id", "") + "Mation"; key = key.replace("Id", "") + "Mation";
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册