When layui is clicked to increase, the value in the form is added to the code in the table row

 1 layui.use(['table','layer'],function(){
 2     var $=layui.$,
 3         table=layui.table,
 4         layer=layui.layer;
 5      function getParam(){
 6          C1=window.location.href.split('?')[1];
 7          id=C1.split('&')[1].split('=')[1];
 8          id=id.lastIndexOf('#')!=-1?id.split('#')[0]:id;
 9          toolSceneId=C1.split('&')[0].split('=')[1];
10      }
11      getParam();
12      var inParaData;
13      $.get('/cd/workPlatform/tool/queryPara?toolId='+id+'&type=0',{},function(response){
14          inParaData=response.data;
15          table.reload('addDemo1',{data:inParaData});
16      },"json")
17     var tableObjIn=table.render({
18         elem:'#inDemo'
19         ,dataF:inParaData,
20         limit:100,
21         cols:[[
22             {
23                 field:'inputName',
24                 title:'参数名',
25                 edit:'text',
26             }, {
27                 field: 'parameterCode',
28                 title: 'parameter English name',
 29                  edit: 'text'
 30              }, {
 31                  field: 'defaultValue',
 32                  title: 'default value',
 33                  edit: 'text'
 34              },
 35              {
 36                  field: 'description' ,
 37                  title: 'Parameter description',
 38                  edit: 'text'
 39              },{
 40                  fixed: 'right',
 41                  width: 178,
 42                  align: 'center',
43                 title: 'Operation',
 44                  toolbar: '#inDemoBar'
 45              }
 46          ]],
 47          id:'addDemo1'
 48      });
 49       $('#addInTableRow').click(function () {
 50           $("#inputOne ").val('');
 51           $("#inputTwo").val('');
 52           $("#inputThree").val('');
 53           $("#inputfour").val( '');
 54           layer.open({
 55               title:'Add input parameters',
 56               type:1,
57              area:['500px'],
58              content:$('#layerIn'),
 59               btn:['Save','Don't save'],
 60               yes:function (index,layero) {
 61                   var cache=table.cache['addDemo1'];
 62                   var t ={};
 63                   var inputName=$('#inputOne').val();
 64                   var parameeterCode=$('#inputTwo').val();
 65                   var reg=/^0-9A-Z$/;
 66                   if(inputName==null||""==inputName){
 67                       layer.msg('Parameter name cannot be empty');
 68                       return;
 69                   }
 70                  t["inputName"] = inputName;
71                  t["parameterCode"] = $('#inputTwo').val();
72                  t["defaultValue"] = $('#inputThree').val();
73                  t["description"] = $('#inputfour').val();
74                  t["inputTypeId"] = 0;
75                  t["toolId"] = id;
76                  t["type"] = 0;
77                  cache.push(t);
78                  layer.closeAll();
79                  table.reload('addDemo1',{data:cache});
80              },
81              btn2:function (index,layero) {
82                  layer.closeAll();
83              }
84          })
85      })
86 })

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325179707&siteId=291194637