增加table属性新打开方式
This commit is contained in:
parent
b0c88e20d3
commit
f011b4c62d
@ -888,10 +888,137 @@ function openTextareaDialog(obj, title,id) {
|
||||
}
|
||||
}
|
||||
|
||||
// 打开文件属性表格弹框
|
||||
|
||||
function showTableDialog(obj,value,id){
|
||||
let tableRef = JSON.parse($(obj).attr('ref'))
|
||||
//先判断是否包含第三列第四列
|
||||
if(tableRef.threeColumn ===""){
|
||||
showTableDialog_open(obj,value,id);
|
||||
}else{
|
||||
showTableDialog_open_new(obj,value,id);
|
||||
}
|
||||
}
|
||||
// 打开文件属性表格弹框 (三列形式)
|
||||
function showTableDialog_open_new(obj,value,id) {
|
||||
let tableRef = JSON.parse($(obj).attr('ref'))
|
||||
let tableName = $(obj).attr('tableTitle')
|
||||
let tableList = []
|
||||
if (JSON.stringify(value) == '{}') {
|
||||
tableList = [
|
||||
{ id: 'table_head' ,firstColumn: tableRef.firstColumn, secondColumn: tableRef.secondColumn,threeColumn:tableRef.threeColumn,fourColumn:tableRef.fourColumn}
|
||||
]
|
||||
} else {
|
||||
tableList = value.table
|
||||
tableList[0] = { id: 'table_head' ,firstColumn: tableRef.firstColumn, secondColumn: tableRef.secondColumn,threeColumn:tableRef.threeColumn,fourColumn:tableRef.fourColumn}
|
||||
}
|
||||
parent.operateList = tableList
|
||||
var thead =
|
||||
'<tr id="' + tableList[0].id + '" class="nodrop nodrag">'
|
||||
+ '<td style="width: 80px;" class="dialogTableHead">拖拽操作</td>'
|
||||
+ '<td style="width: 100px;" class="dialogTableHead">'
|
||||
+ tableList[0].firstColumn
|
||||
+ '</td>'
|
||||
+ '<td style="width: 270px;" class="dialogTableHead">'
|
||||
+ tableList[0].secondColumn
|
||||
+ '</td>'
|
||||
+ '<td style="width: 100px;" class="dialogTableHead">'
|
||||
+ tableList[0].threeColumn
|
||||
+ '</td>'
|
||||
+ '<td style="width: 270px;" class="dialogTableHead">'
|
||||
+ tableList[0].fourColumn
|
||||
+ '</td>'
|
||||
+ '<td style="width: 80px;" class="dialogTableHead">操作</td>'
|
||||
+ '</tr>'
|
||||
if (parent.isParentShow) {
|
||||
parent.$('#attribute-table-content1').empty()
|
||||
parent.$('#attribute-add-content1').empty()
|
||||
parent.$('#attribute-table-content1').append(thead)
|
||||
for ( let i = 1; i < tableList.length; i++) {
|
||||
let str =
|
||||
'<tr id="' + tableList[i].id + '">'
|
||||
+ '<td style="width: 80px;text-align: center;"><i class="awsui-iconfont"></i></td>'
|
||||
+ '<td style="width: 100px;">'
|
||||
+ '<textarea type="textarea" rows="5" class="dialog_table_input_css" value="' + tableList[i].firstColumn + '">' + tableList[i].firstColumn + '</textarea>'
|
||||
+ '</td>'
|
||||
+ '<td style="width: 270px;">'
|
||||
+ '<textarea type="textarea" rows="5" class="dialog_table_input_css" value="' + tableList[i].secondColumn + '">' + tableList[i].secondColumn + '</textarea>'
|
||||
+ '</td>'
|
||||
+ '<td style="width: 100px;">'
|
||||
+ '<textarea type="textarea" rows="5" class="dialog_table_input_css" value="' + tableList[i].threeColumn + '">' + tableList[i].threeColumn + '</textarea>'
|
||||
+ '</td>'
|
||||
+ '<td style="width: 270px;">'
|
||||
+ '<textarea type="textarea" rows="5" class="dialog_table_input_css" value="' + tableList[i].fourColumn + '">' + tableList[i].fourColumn + '</textarea>'
|
||||
+ '</td>'
|
||||
+ '<td style="width: 80px;text-align: center;" class="dialogTableDelete" onclick="removeTr(this)">删除</td>'
|
||||
+'</tr>'
|
||||
parent.$('#attribute-table-content1').append(str)
|
||||
}
|
||||
parent.$('#attribute-add-content1').append('<button onclick="addTr_new()">新增</button>')
|
||||
parent.$("#attribute-table-window1").dialog({
|
||||
draggable: true,
|
||||
title: tableName,
|
||||
buttons : [{
|
||||
text : '确定',
|
||||
cls : "blue",
|
||||
handler : function() {
|
||||
// let name = parent.$("#attribute-title-content1").val()
|
||||
// $("#" + id).val(name)
|
||||
let inputs = parent.$('#attribute-table-content1').find('textarea')
|
||||
for (let i = 1; i < parent.operateList.length; i++) {
|
||||
parent.operateList[i].firstColumn = inputs[4*(i-1)].value
|
||||
parent.operateList[i].secondColumn = inputs[4*(i-1) + 1].value
|
||||
parent.operateList[i].threeColumn = inputs[4*(i-1) + 2].value
|
||||
parent.operateList[i].fourColumn = inputs[4*(i-1) + 3].value
|
||||
}
|
||||
let value = {
|
||||
name: tableName,
|
||||
table: parent.operateList
|
||||
}
|
||||
if(value.table.some(item => item.name == '') || value.table.some(item => item.desc == '')) { // 表格存在空值
|
||||
$.simpleAlert("表格内容不能存在空值",'warning')
|
||||
} else {
|
||||
saveDialogTableValue(value,id,obj)
|
||||
}
|
||||
parent.$("#attribute-table-window1").dialog("close");
|
||||
}
|
||||
}, {
|
||||
text : '取消',
|
||||
handler : function() {
|
||||
parent.$("#attribute-table-window1").dialog("close");
|
||||
}
|
||||
}]
|
||||
});
|
||||
} else {
|
||||
|
||||
}
|
||||
parent.$("#table").tableDnD({
|
||||
//滚动的速度
|
||||
scrollAmount:10,
|
||||
onDragClass:'highlight',
|
||||
//当拖动排序完成后
|
||||
onDrop: function(table,row) {
|
||||
//获取id为table的元素
|
||||
var table = parent.document.getElementById("table");
|
||||
//获取table元素所包含的tr元素集合
|
||||
var tr = table.getElementsByTagName("tr");
|
||||
//遍历所有的tr
|
||||
for (var i = 0; i < tr.length; i++) {
|
||||
//获取拖动排序结束后新表格中,row id的结果
|
||||
var rowid = tr[i].getAttribute("id");
|
||||
//console.log("排序完成后表格的第 " + (i+1) + " 行id为 : " + rowid);
|
||||
}
|
||||
//console.log( $('#table').tableDnDSerialize());
|
||||
},
|
||||
onDragStart:function(table,row){
|
||||
//console.log(row.id);
|
||||
},
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
// 打开文件属性表格弹框 (两列形式)
|
||||
function showTableDialog_open(obj,value,id) {
|
||||
let tableRef = JSON.parse($(obj).attr('ref'))
|
||||
let tableName = $(obj).attr('tableTitle')
|
||||
let tableList = []
|
||||
@ -1006,9 +1133,6 @@ function addTr() {
|
||||
+ '</tr>'
|
||||
operateList.push({ id: newTrId ,name: '',desc: ''})
|
||||
$('#attribute-table-content1').append(defaultStr)
|
||||
|
||||
|
||||
|
||||
parent.$("#table").tableDnD({
|
||||
//滚动的速度
|
||||
scrollAmount:10,
|
||||
@ -1031,7 +1155,43 @@ function addTr() {
|
||||
console.log(row.id);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
function addTr_new() {
|
||||
let newTrId = Date.now().toString(36)
|
||||
let defaultStr =
|
||||
' <tr id="'+ newTrId + '">'
|
||||
+ '<td style="width: 80px;text-align: center"><i class="awsui-iconfont"></i></td>'
|
||||
+ '<td style="width: 100px;"><textarea type="textarea" rows="5" class="dialog_table_input_css" value=""></textarea></td>'
|
||||
+ '<td style="width: 270px;"><textarea type="textarea" rows="5" class="dialog_table_input_css" value=""></textarea></td>'
|
||||
+ '<td style="width: 100px;"><textarea type="textarea" rows="5" class="dialog_table_input_css" value=""></textarea></td>'
|
||||
+ '<td style="width: 270px;"><textarea type="textarea" rows="5" class="dialog_table_input_css" value=""></textarea></td>'
|
||||
+ '<td style="width: 80px;text-align: center" class="dialogTableDelete" onclick="removeTr(this)">删除</td>'
|
||||
+ '</tr>'
|
||||
operateList.push({ id: newTrId ,firstColumn: '',secondColumn: '',threeColumn:'',fourColumn:''})
|
||||
$('#attribute-table-content1').append(defaultStr)
|
||||
parent.$("#table").tableDnD({
|
||||
//滚动的速度
|
||||
scrollAmount:10,
|
||||
onDragClass:'highlight',
|
||||
//当拖动排序完成后
|
||||
onDrop: function(table,row) {
|
||||
//获取id为table的元素
|
||||
var table = parent.document.getElementById("table");
|
||||
//获取table元素所包含的tr元素集合
|
||||
var tr = table.getElementsByTagName("tr");
|
||||
//遍历所有的tr
|
||||
for (var i = 0; i < tr.length; i++) {
|
||||
//获取拖动排序结束后新表格中,row id的结果
|
||||
var rowid = tr[i].getAttribute("id");
|
||||
//console.log("排序完成后表格的第 " + (i+1) + " 行id为 : " + rowid);
|
||||
}
|
||||
//console.log( $('#table').tableDnDSerialize());
|
||||
},
|
||||
onDragStart:function(table,row){
|
||||
console.log(row.id);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
function removeTr(obj) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user