From f011b4c62d7f1dfb18ae46d05408c0414b58ba55 Mon Sep 17 00:00:00 2001 From: yujh Date: Mon, 12 Aug 2024 10:18:57 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0table=E5=B1=9E=E6=80=A7?= =?UTF-8?q?=E6=96=B0=E6=89=93=E5=BC=80=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../js/coe.pal.processlevel.create.js | 170 +++++++++++++++++- 1 file changed, 165 insertions(+), 5 deletions(-) diff --git a/com.actionsoft.apps.coe.pal/web/com.actionsoft.apps.coe.pal/js/coe.pal.processlevel.create.js b/com.actionsoft.apps.coe.pal/web/com.actionsoft.apps.coe.pal/js/coe.pal.processlevel.create.js index 69971a83..b22f0f64 100755 --- a/com.actionsoft.apps.coe.pal/web/com.actionsoft.apps.coe.pal/js/coe.pal.processlevel.create.js +++ b/com.actionsoft.apps.coe.pal/web/com.actionsoft.apps.coe.pal/js/coe.pal.processlevel.create.js @@ -888,10 +888,137 @@ function openTextareaDialog(obj, title,id) { } } -// 打开文件属性表格弹框 -function showTableDialog(obj,value,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 = + '' + + '拖拽操作' + + '' + + tableList[0].firstColumn + + '' + + '' + + tableList[0].secondColumn + + '' + + '' + + tableList[0].threeColumn + + '' + + '' + + tableList[0].fourColumn + + '' + + '操作' + + '' + 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 = + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '删除' + +'' + parent.$('#attribute-table-content1').append(str) + } + parent.$('#attribute-add-content1').append('') + 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() { + '' 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 = + ' ' + + '' + + '' + + '' + + '' + + '' + + '删除' + + '' + 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) {