黄海 2 years ago
commit 26288f9dc4

@ -4727,17 +4727,31 @@ layui.config({ base: './ayq/modules/' }).define(["layer", 'flow', "laytpl", "ele
}); });
}); });
$("#returnList").on('click', function () {
window.location = "../org/task_list.html";
});
$("#formSave").on('click', function () { $("#formSave").on('click', function () {
if (options.data.length > 0) { if (options.data.length > 0) {
console.log(JSON.stringify(options.data));
window.localStorage.setItem('form_json', JSON.stringify(options.data)); window.localStorage.setItem('form_json', JSON.stringify(options.data));
if (window.localStorage.getItem('job_id') == null) {
layer.open({ layer.open({
type: 2, type: 2,
title: '重命名', title: '保存表单',
shade: 0.1, shade: 0.1,
area: ['450px', '245px'], area: ['450px', '245px'],
content: './save_form.html' content: './save_form.html'
}); });
} else {
layer.open({
type: 2,
title: '修改表单',
shade: 0.1,
area: ['450px', '245px'],
content: './update_form.html?job_id=' + window.localStorage.getItem('job_id')
});
}
} else { } else {
layer.msg("请维护表单内容!", { layer.msg("请维护表单内容!", {
icon: 2, icon: 2,

@ -149,7 +149,7 @@ layui.define(['layer'], function (exports) {
'<div class="layui-layer-title" style="font-weight: bolder;border-bottom: 0;">创建任务</div>\n' + '<div class="layui-layer-title" style="font-weight: bolder;border-bottom: 0;">创建任务</div>\n' +
'<div style="width: 140px;">\n' + '<div style="width: 140px;">\n' +
'<button type="button" class="layui-btn layui-btn-sm" id="formSave">保存</button>\n' + '<button type="button" class="layui-btn layui-btn-sm" id="formSave">保存</button>\n' +
'<button type="button" class="layui-btn layui-btn-primary layui-btn-sm" lay-on="returnList">返回</button>\n' + '<button type="button" class="layui-btn layui-btn-primary layui-btn-sm" id="returnList">返回</button>\n' +
'</div>\n' + '</div>\n' +
'</div>\n' + '</div>\n' +
' <div class="layui-side" style="top: 40px;">\n' + ' <div class="layui-side" style="top: 40px;">\n' +

@ -28,13 +28,48 @@
<script> <script>
layui.config( layui.config(
{ base: './ayq/modules/' }).use(['layer', 'formDesigner'], function () { { base: './ayq/modules/' }).use(['layer', 'formDesigner'], function () {
var formDesigner = layui.formDesigner; var $ = layui.jquery;
var data = []; var data = [];
var jobId = GetQueryString("job_id");
if (jobId != null && jobId != "") {
window.localStorage.setItem('job_id', jobId);
$.ajax({
url: "/QingLong/collect/getJob?job_id=" + jobId,
async: false,
type: 'GET',
dataType: "json",
success: function (res) {
data = JSON.parse(res.form_json);
}
});
} else {
localStorage.removeItem('job_id');
if(window.localStorage.getItem('job_id')==null){
console.log(1111);
}
}
var formDesigner = layui.formDesigner;
var render = formDesigner.render({ var render = formDesigner.render({
data: data, data: data,
elem: '#formdesigner' elem: '#formdesigner'
}); });
}); });
function GetQueryString(name, istop) {
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
var r = window.location.search.substr(1).match(reg);
if (typeof (istop) != "undefined") r = top.location.search.substr(1).match(reg);
if (r != null) return unescape(r[2]);
return null;
}
</script> </script>
</body> </body>

@ -0,0 +1,145 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
<link rel="stylesheet" href="../../../component/pear/css/pear.css" />
<style>
.require-star {
position: absolute;
width: 3px;
height: 14px;
background-color: #ea4335;
top: 12px;
right: 8px;
border-radius: 1.5px;
}
.input-width {
max-width: 470px
}
</style>
</head>
<body>
<form class="layui-form" action="">
<div class="mainBox">
<div class="main-container" style="margin-top: 25px;">
<div class="layui-form-item">
<label class="layui-form-label" style="width: 85px !important;"><span
class="require-star"></span>任务名称</label>
<div class="layui-input-block" style="margin-left: 118px !important;">
<input type="text" id="task_name" lay-verify="taskName" autocomplete="off" placeholder="请输入任务名称"
class="layui-input input-width">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label" style="width: 85px !important;"><span
class="require-star"></span>数据库表名称</label>
<div class="layui-input-block" style="margin-left: 118px !important;">
<input type="text" id="table_name" lay-verify="taskName" autocomplete="off"
placeholder="请输入数据库表名称" class="layui-input input-width">
</div>
</div>
</div>
</div>
<div class="bottom">
<div class="button-container">
<button type="submit" class="pear-btn pear-btn-primary pear-btn-sm" lay-submit="" lay-filter="save">
<i class="layui-icon layui-icon-ok"></i>
提交
</button>
<button type="reset" class="pear-btn pear-btn-sm">
<i class="layui-icon layui-icon-refresh"></i>
重置
</button>
</div>
</div>
</form>
<script src="../../../component/layui/layui.js"></script>
<script src="../../../component/pear/pear.js"></script>
<script>
layui.use(function () {
var form = layui.form;
var $ = layui.jquery;
// 自定义验证
form.verify({
taskName: [/^.{2,32}$/, '名称长度必须为2到32位']
});
var jobId = GetQueryString("job_id");
$.ajax({
url: "/QingLong/collect/getJob?job_id=" + jobId,
async: false,
type: 'GET',
success: function (res) {
$("#task_name").val(res.job_name);
$("#table_name").val(res.form_table_name);
},
error: function (xhr, status, error) {
layer.msg("获取信息异常!", {
icon: 2,
time: 1000
});
}
});
form.on('submit(save)', function (data) {
if (window.localStorage.getItem('form_json') !== undefined) {
$.ajax({
url: '/QingLong/collect/updateFormJob',
type: 'post',
data: {
"job_id": jobId,
"job_name": $("#task_name").val(),
"table_name": $("#table_name").val(),
"json": window.localStorage.getItem('form_json')
},
success: function (result) {
if (result.success) {
layer.msg("修改成功!", {
icon: 1,
time: 1000
}, function () {
parent.layer.close(parent.layer.getFrameIndex(window.name));
parent.window.location = "/QingLong/view/tb/org/task_list.html"
});
} else {
layer.msg(result.message, {
icon: 2,
time: 2000
});
}
}
});
} else {
layer.msg("出现异常,请重新维护表单内容!", {
icon: 2,
time: 2000
});
}
return false;
});
function GetQueryString(name, istop) {
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
var r = window.location.search.substr(1).match(reg);
if (typeof (istop) != "undefined") r = top.location.search.substr(1).match(reg);
if (r != null) return unescape(r[2]);
return null;
}
});
</script>
<script>
</script>
</body>
</html>

@ -243,9 +243,14 @@
} }
window.update = function (obj) { window.update = function (obj) {
if (obj.data.job_type == 1) {
window.location = "../form/designer.html?job_id=" + obj.data.job_id;
} else {
window.location = "./fields_set.html?job_id=" + obj.data.job_id; window.location = "./fields_set.html?job_id=" + obj.data.job_id;
} }
}
window.rename = function (obj) { window.rename = function (obj) {
layer.open({ layer.open({
type: 2, type: 2,

Loading…
Cancel
Save