main
kgdxpr 2 years ago
parent 26041adc2b
commit 2c5e68ccf6

@ -24,19 +24,16 @@
<div class="layui-card" style="margin-top: 10px;margin-left: 10px;">
<div class="layui-card-body">
<ul class="layui-menu" id="sheetListView">
<li lay-options="{id: 100}" class="layui-menu-item-checked">
<div class="layui-menu-body-title">
<a href="javascript:;">menu item 1</a><i class="layui-icon layui-icon-ok-circle"
style="font-size: 18px; color: #04B543;margin-top: -10px;"></i>
</div>
</li>
</ul>
<script id="sheetListScript" type="text/html">
<script id="sheetListScript" type="text/html">
{{# layui.each(d, function(index, item){ }}
<li lay-options="{id: {{item.sheet_index}}}" class="layui-menu-item-checked">
<li lay-options="{ id: '{{item.sheet_index}}',table_name:'{{item.table_name}}' }" class="{{ index == 0 ? 'layui-menu-item-checked' : '' }}" >
<div class="layui-menu-body-title">
<a href="javascript:;">{{item.sheet_name}}</a><i class="layui-icon layui-icon-ok-circle"
style="font-size: 18px; color: #04B543;margin-top: -10px;"></i>
<a href="javascript:;">{{item.sheet_name}}</a>
{{# if(item.is_check==1){ }}
<i class="layui-icon layui-icon-ok-circle"
style="font-size: 18px; color: #04B543;margin-top: -10px;"></i>
{{# } }}
</div>
</li>
{{# }); }}
@ -50,7 +47,7 @@
<div class="layui-inline" style="margin-top: 15px;margin-bottom: 5px;">
<label class="layui-form-label" style="width: auto;margin-left: 1px;">数据库表名称:</label>
<div class="layui-input-inline">
<input type="text" id="personName" placeholder="请输入数据库表名称" class="layui-input"
<input type="text" id="tableName" placeholder="请输入数据库表名称" class="layui-input"
style="width: 300px;">
</div>
<div class="layui-input-inline">
@ -68,13 +65,13 @@
{{# var fieldsTypeList = [{"id":1,"name":"文本"},{"id":2,"name":"日期"},{"id":3,"name":"数值"},{"id":4,"name":"小数"},]; }}
<select name="fieldsType" class="layui-border fields-select" lay-ignore>
{{# layui.each(fieldsTypeList, function(index, item){ }}
<option value="{{item.id}}" {{item.id === d.login ? 'selected' : '' }}>{{item.name}}</option>
<option value="{{item.id}}" {{item.id === d.data_type_id ? 'selected' : '' }}>{{item.name}}</option>
{{# }); }}
</select>
</script>
<script type="text/html" id="required_switch">
<input type="checkbox" title="是|否" lay-skin="switch" lay-filter="requiredSwitch" {{d.sex == 1 ? "checked" : "" }}>
<input type="checkbox" title="是|否" lay-skin="switch" lay-filter="requiredSwitch" {{d.allow_blank == false ? "checked" : "" }}>
</script>
</div>
@ -83,11 +80,6 @@
</div>
<script src="../../../component/layui/layui.js"></script>
<script>
@ -100,7 +92,9 @@
var errArr = [];
var laytpl = layui.laytpl;
var jobId = "4";
var jobId = GetQueryString("job_id");
var index0TableName = "";
//获取sheet列表
$.ajax({
@ -117,60 +111,69 @@
}
});
tableRender(0);
function tableRender(sheetIndex) {
table.render({
id: 'setField',
elem: '#data-table',
url: '/QingLong/collect/getSheetStruct?job_id=' + jobId + '&sheet_index=' + sheetIndex,
height: 'full-100',
page: false,
even: true,
css: [
'.layui-table-cell{height: 50px; line-height: 40px;}',
'.layui-table-cell select{height: 36px; padding: 0 5px;}'
].join(''),
cols: [[
{ title: '序号', align: 'center', width: "5%", type: 'numbers' },
{ title: '字段名称', field: 'column_name', align: 'center', width: "20%", edit: 'text' },
{ title: '原始名称', field: 'original_name', align: 'center', width: "20%" },
{ title: '字段类型', align: 'center', width: "10%", templet: '#fieldsType_select' },
{ title: '必填', align: 'center', width: "10%", templet: '#required_switch' },
{ title: '数据范围', field: 'options', align: 'center', edit: 'text' }
]],
// skin: 'line',
defaultToolbar: [],
done: function (res, curr, count) {
var options = this;
$("#tableName").val('11111111')
// 获取当前行数据
table.getRowData = function (tableId, elem) {
var index = $(elem).closest('tr').data('index');
return table.cache[tableId][index] || {};
};
var tableViewElem = this.elem.next();
tableViewElem.find('.fields-select').on('change', function () {
var value = this.value;
var data = table.getRowData(options.id, this);
data.login = value;
console.log('选中值: ' + value + '<br>当前行数据:' + JSON.stringify(data));
});
form.on('switch(requiredSwitch)', function (obj) {
var data = table.getRowData(options.id, this);
if (obj.elem.checked) {
data.sex = 1;
} else {
data.sex = 2;
}
console.log('选中值: ' + obj.elem.checked + '<br>当前行数据:' + JSON.stringify(data));
});
}
});
}
table.render({
id: 'setField',
elem: '#data-table',
url: '../../admin/data/table.json',
height: 'full-100',
page: false,
even: true,
css: [
'.layui-table-cell{height: 50px; line-height: 40px;}',
'.layui-table-cell select{height: 36px; padding: 0 5px;}'
].join(''),
cols: [[
{ title: '序号', align: 'center', width: "5%", type: 'numbers' },
{ title: '字段名称', field: 'username', align: 'center', width: "20%", edit: 'text' },
{ title: '原始名称', field: 'realName', align: 'center', width: "20%" },
{ title: '字段类型', align: 'center', width: "10%", templet: '#fieldsType_select' },
{ title: '必填', align: 'center', width: "10%", templet: '#required_switch' },
{ title: '数据范围', field: 'phone', align: 'center', edit: 'text' }
]],
// skin: 'line',
defaultToolbar: [],
done: function (res, curr, count) {
var options = this;
// 获取当前行数据
table.getRowData = function (tableId, elem) {
var index = $(elem).closest('tr').data('index');
return table.cache[tableId][index] || {};
};
var tableViewElem = this.elem.next();
tableViewElem.find('.fields-select').on('change', function () {
var value = this.value;
var data = table.getRowData(options.id, this);
data.login = value;
console.log('选中值: ' + value + '<br>当前行数据:' + JSON.stringify(data));
});
form.on('switch(requiredSwitch)', function (obj) {
var data = table.getRowData(options.id, this);
if (obj.elem.checked) {
data.sex = 1;
} else {
data.sex = 2;
}
console.log('选中值: ' + obj.elem.checked + '<br>当前行数据:' + JSON.stringify(data));
});
}
});
util.on({
save: function () {
@ -206,7 +209,7 @@
});
//菜单的点击事件
dropdown.on('click(sheetList)', function (options) {
dropdown.on('click(sheetListView)', function (options) {
console.log(this, options);
// 显示 - 仅用于演示
@ -214,6 +217,16 @@
});
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>
</body>

@ -325,8 +325,9 @@
window.openExcelCreatePage = function () {
window.location = "./upload_excel.html";
// window.location = "./fields_set.html?job_id=1";
// window.location = "./upload_excel.html";
window.location = "./fields_set.html?job_id=2";
// layer.open({
// type: 2,
// title: '创建任务',

Loading…
Cancel
Save