MRP计算html实现

MRP一:

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <style>
        body{
            background-color: white;
        }
        tr{height: 80px;}
        td{width: 30px;}
        h1{
    color: #333;
    font-family: Helvetica;
    margin:0;
    padding:0;
    font-size: 10rem;
    letter-spacing: -0.3rem;/*缩小字距*/
    display:flex;
    justify-content:center;/*水平*/
}

table{display:flex;
    justify-content:center;/*水平*/}


    .box:hover{/*.box:hover划过事件*/
        display:flex;
            width: 500px;
            height: 100px;



            background-color: blue;
            background-image: url(images/order-completed.gif) ;
        }


        

    </style>


<div> 第一部分  </div>


<input  id="o" type="button" value="填写完成">
<table  id="t1" border=1px;  style="border-color: rgb(85, 230, 193); ">
        
    <tr> 
        
        <th contenteditable="true">&nbsp;最终需求期&nbsp;</th>
        <th contenteditable="true"> &nbsp;名称 &nbsp;</th>
        <th contenteditable="true"> &nbsp;提前期 &nbsp;</th>
        <th contenteditable="true"> &nbsp;等级 &nbsp;</th>
        <th contenteditable="true"> &nbsp;数量&nbsp;</th>
        <th contenteditable="true"> &nbsp;父级 &nbsp;</th>
        
    
    </tr>
    <tr> 
        <th contenteditable="true"> 8</th>
        <th contenteditable="true">A</th>
        <th contenteditable="true"> 4</th>
        <th contenteditable="true">1</th>
        <th contenteditable="true"> 100</th>
        <th contenteditable="true"> null</th>
    </tr>
    <tr> 
        <th contenteditable="true"></th>
        <th contenteditable="true"> B</th>
        <th contenteditable="true"> 3</th>
        <th contenteditable="true"> 2</th>
        <th contenteditable="true"> 100</th>
        <th contenteditable="true"> A</th>
    </tr>
    <tr> 
        <th contenteditable="true"></th>
        <th contenteditable="true">C</th>
        <th contenteditable="true"> 2</th>
        <th contenteditable="true"> 2</th>
        <th contenteditable="true"> 200</th>
        <th contenteditable="true"> A</th>
    </tr>
    <tr> 
        <th contenteditable="true"></th>
        <th contenteditable="true">D</th>
        <th contenteditable="true">1</th>
        <th contenteditable="true">2</th>
        <th contenteditable="true"> 200</th>
        <th contenteditable="true"> C</th>
    </tr>
    <tr> 
        <th contenteditable="true"></th>
        <th contenteditable="true"> E</th>
        <th contenteditable="true"> 1</th>
        <th contenteditable="true"> 2</th>
        <th contenteditable="true"> 400</th>
        <th contenteditable="true">C</th>
    </tr>
    </table>

<h1>MRP的填写与保存</h1>
<div id="test" style="height: 1000px;"></div>

<div style="font-size: 0.5em;">不考虑损耗时 输入产品需要的数量,时期 工艺信息  得出产品生产信息
所在层数 父级/直接的生产个数</div>

<div id="ha">
<table>
    <tr>
    <td>1</td>
    <td>2</td>
    <td >
        <div ></div>
        <div class="box" style="height: 50px;width: 50px;">

        <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
        viewBox="0 0 50 50" style="enable-background:new 0 0 50 50;" xml:space="preserve">
       <style type="text/css">
       .st0{fill:none;stroke:#000000;stroke-width:2;stroke-linecap:round;stroke-miterlimit:10;}
       .st1{fill:none;stroke:#000000;stroke-width:2;stroke-miterlimit:10;}
       </style>
    <path class="st0" d="M7,47V3h36v44H7z"/>
    <path class="st1" d="M17,26h-4 M37,26H20 M37,32H20 M17,32h-4 M37,38H20 M17,38h-4"/>
    </svg>
    
    </div></div>
</td>
    <td >4</td>
    <td>5</td>
</tr>
</table>
</div>



<script>
     let n;
   // var n=8;//初始条件
    //var m=100;
    console.log("");
    //创建产品类  
   function createproduct(pname,plt, prank, pnum,pfa){      
  var product= new Object;      // 创建一个对象变量
  product.name=pname;
  product.lt=plt;
  product.rank=prank;/*等级 */
  product.num=pnum;/*需求量*/
  product.fa=pfa;/*父级*/



  
  product.maoxuqiulie=0;
  product.fdl=0;

  
  
              //  定义age属性
  product.teach = function()
  {
      if(this.rank==1)
      {product.maoxuqiulie=n;
      }
      else{
          product.maoxuqiulie=product.fa.fdl;
         
      }
      product.fdl=product.maoxuqiulie-product.lt;
      
  };
  return product;             // 返回nTeacher对象
 }








</script>















    <script>
       






/*点击事件*/
let box = document.getElementById("ha");
       
        box.onclick =function(){
            console.log(120);
            alert("提交成功");
            
        }




/*填写完成----点击事件*/
let o = document.getElementById("o");
       
        o.onclick =function(){
        //let n=9;/*总周期赋值*/
        n=9;
        let aplt=4;
         let aprank=1;
         let apnum=100;

         let bplt=3;
         let bprank=2;
         let bpnum=100;

         let cplt=2;
         let cprank=2;
         let cpnum=200;

         let dplt=1;
         let dprank=2;
         let dpnum=200;

         let eplt=1;
         let eprank=2;
         let epnum=400;




            var tb=document.getElementById("t1");    //获取table对像
        var rows = tb.rows;
        for (var i = 0; i < rows.length; i++) {    //--循环所有的行
        var cells = rows[i].cells;  // cells 集合返回表格中所有 <td> 或 <th> 元素。
            for (var j = 0; j < cells.length; j++) {   //--循环所有的列,从第一列取数据,因为一般第一列都是标识,数据毫无意义。
           
           
            
                if(i==1&j==0){ n = cells[j].innerHTML;console.log(n);}
            if(i==1&j==2){ aplt = cells[j].innerHTML;console.log(n);}
            if(i==1&j==3){ aprank = cells[j].innerHTML;console.log(n);}
            if(i==1&j==4){ apnum = cells[j].innerHTML;console.log(n);}

            if(i==2&j==2){ bplt = cells[j].innerHTML;console.log(n);}
            if(i==2&j==3){ bprank = cells[j].innerHTML;console.log(n);}
            if(i==2&j==4){ bpnum = cells[j].innerHTML;console.log(n);}

            if(i==3&j==2){ cplt = cells[j].innerHTML;console.log(n);}
            if(i==3&j==3){ cprank = cells[j].innerHTML;console.log(n);}
            if(i==3&j==4){ cpnum = cells[j].innerHTML;console.log(n);}

            if(i==4&j==2){ dplt = cells[j].innerHTML;console.log(n);}
            if(i==4&j==3){ dprank = cells[j].innerHTML;console.log(n);}
            if(i==4&j==4){ dpnum = cells[j].innerHTML;console.log(n);}

            if(i==5&j==2){ eplt = cells[j].innerHTML;console.log(n);}
            if(i==5&j==3){ eprank = cells[j].innerHTML;console.log(n);}
            if(i==5&j==4){ epnum = cells[j].innerHTML;console.log(n);}



              }
         }

         var zong=[];
                            //pname,plt, prank, pnum,pfa

         var A = createproduct("A",aplt, aprank, apnum,null);
         var B = createproduct("B",bplt, bprank, bpnum,A);
         var C = createproduct("C",cplt, cprank, cpnum,A);
         var D = createproduct("D",dplt, dprank, dpnum,C);
         var E = createproduct("E",eplt, eprank, epnum,C);
         A.teach();//对A初始话
         var zong=[A,B,C,D,E];



























            console.log(120);
     
            for(i=1;i<5;i++){
                zong[i].teach();
            }
            
            /*alert("A在"+A.maoxuqiulie+"期,毛需求为"+A.num)
            alert("A在"+A.fdl+"期,订货需求为"+A.num)
            alert("B在"+B.maoxuqiulie+"期,毛需求为"+B.num)
            alert("B在"+B.fdl+"期,订货需求为"+B.num)
            alert("C在"+C.maoxuqiulie+"期,毛需求为"+C.num)
            alert("C在"+C.fdl+"期,订货需求为"+C.num)
            alert("D在"+D.maoxuqiulie+"期,毛需求为"+D.num)
            alert("D在"+D.fdl+"期,订货需求为"+D.num)
            alert("E在"+E.maoxuqiulie+"期,毛需求为"+E.num)
            alert("E在"+E.fdl+"期,订货需求为"+E.num)*/
            
         var s= "<table  id='familyTable' border=1px; style= 'border-color: rgb(85, 230, 193);'>";
         
            s=s+"<tr> <th>产品编码</th><th>计划阶段</th>"+
            "<th>&nbsp; 1 &nbsp;</th><th> &nbsp;2 &nbsp;</th><th> &nbsp;3 &nbsp;</th><th> &nbsp;4 &nbsp;"+
            "</th><th> &nbsp;5 &nbsp;</th><th> &nbsp;6 &nbsp;</th><th> &nbsp;7 &nbsp;</th>"+
            "<th> &nbsp;8 &nbsp;</th> <th> &nbsp;9 &nbsp;</th><th> &nbsp;10 &nbsp;</th>"+
            "<th> &nbsp;11 &nbsp;</th><th> &nbsp;12 &nbsp;</th>"+
            "</tr>"+"<tr>";



for(j=0;j<5;j++){
         s=s+"<th>"+zong[j].name+"</th>"+"<th> 毛需求</th>";

            for(i=1;i<=12;i++)
           {
               if(i==zong[j].maoxuqiulie){
                s=s+"<td class='aaaa'>"+zong[j].num+"</td>";
                   }
               else{
                s=s+"<td class='aaaa'>"+"</td>";
            }
           }


          s=s+"</tr>";
          s=s+"<tr>"+"<th>"+zong[j].name+"</th>"+"<th> 订货需求</th>";
            for(i=1;i<=12;i++)
           {
               if(i==zong[j].fdl){
                s=s+"<td class='aaaa'>"+zong[j].num+"</td>";
                   }
               else{
                s=s+"<td class='aaaa'>"+"</td>";
            }
           }
          s=s+"</tr>";
        }


          s=s+"</table>";
            document.getElementById("test").innerHTML =s ;

            

            

            var tb=document.getElementById("familyTable");    //获取table对像
        var rows = tb.rows;
        for (var i = 1; i < rows.length; i++) {    //--循环所有的行
        var cells = rows[i].cells;  // cells 集合返回表格中所有 <td> 或 <th> 元素。
            for (var j = 1; j < cells.length; j++) {   //--循环所有的列,从第一列取数据,因为一般第一列都是标识,数据毫无意义。
            //var value = cells[j].childNodes[0].value;//取有input框的数据
            var value = cells[j].innerHTML;//取没有input框的数据
            console.log(value);
              }
}








    

        }
    </script>
</body>
</html>

MRP二:

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <style>
        body{
            background-color: white;
        }
        tr{height: 80px;}
        h1{
    color: #333;
    font-family: Helvetica;
    margin:0;
    padding:0;
    font-size: 10rem;
    letter-spacing: -0.3rem;/*缩小字距*/
    display:flex;
    justify-content:center;/*水平*/
}

table{display:flex;
    justify-content:center;/*水平*/}


    .box:hover{/*.box:hover划过事件*/
        display:flex;
            width: 500px;
            height: 100px;



            background-color: blue;
            background-image: url(images/order-completed.gif) ;
        }


        

    </style>


<div> 第一部分  </div>
<h1>MRP的填写与保存</h1>
    <table  id="familyTable" border=1px;  style="border-color: rgb(85, 230, 193); ">
        
    <tr> 
        <th>低位码</th>
        <th>提前期(LT)</th>
        <th>产品编码</th>
        <th>计划阶段</th>
        <th>&nbsp; 1 &nbsp;</th>
        <th> &nbsp;2 &nbsp;</th>
        <th> &nbsp;3 &nbsp;</th>
        <th> &nbsp;4 &nbsp;</th>
        <th> &nbsp;5 &nbsp;</th>
        <th> &nbsp;6 &nbsp;</th>
        <th> &nbsp;7 &nbsp;</th>
        <th> &nbsp;8 &nbsp;</th>
        <th> &nbsp;9 &nbsp;</th>
        <th> &nbsp;10 &nbsp;</th>
        <th> &nbsp;11 &nbsp;</th>
        <th> &nbsp;12 &nbsp;</th>
    
    </tr>

    <tr>
        <td rowspan="1" contenteditable="true">1</td>
        <td rowspan="1" contenteditable="true">4</td>
        <td rowspan="1">A</td><!--contenteditable="true"html5属性-->
        <td contenteditable="true">相关需求A</td>
        <th contenteditable="true"></th>
        <th contenteditable="true"></th>
        <th contenteditable="true"></th>
        <th contenteditable="true"></th>
        <th contenteditable="true"></th>
        <th contenteditable="true"></th>
        <th contenteditable="true"></th>
        <th contenteditable="true"></th>
        <th contenteditable="true"></th>
        <th contenteditable="true"></th>
        <th contenteditable="true"></th>
        <th contenteditable="true"></th>

    </tr>
        
   

















    <tr>
        <td rowspan="1" contenteditable="true">1</td>
        <td rowspan="1" contenteditable="true">6</td>
        <td rowspan="1">A</td><!--contenteditable="true"html5属性-->
        <td contenteditable="true">相关需求B</td>
        <th contenteditable="true"></th>
        <th contenteditable="true"></th>
        <th contenteditable="true"></th>
        <th contenteditable="true"></th>
        <th contenteditable="true"></th>
        <th contenteditable="true"></th>
        <th contenteditable="true"></th>
        <th contenteditable="true"></th>
        <th contenteditable="true"></th>
        <th contenteditable="true"></th>
        <th contenteditable="true"></th>
        <th contenteditable="true"></th>

    </tr>
    <tr>
        <td rowspan="1" contenteditable="true">1</td>
        <td rowspan="1" contenteditable="true">0</td>
        <td rowspan="1">A</td><!--contenteditable="true"html5属性-->
        <td contenteditable="true">独立需求</td>
        <th contenteditable="true"></th>
        <th contenteditable="true"></th>
        <th contenteditable="true"></th>
        <th contenteditable="true"></th>
        <th contenteditable="true"></th>
        <th contenteditable="true"></th>
        <th contenteditable="true"></th>
        <th contenteditable="true"></th>
        <th contenteditable="true"></th>
        <th contenteditable="true"></th>
        <th contenteditable="true"></th>
        <th contenteditable="true"></th>

    </tr>
        
   












    </table>


<div style="font-size: 0.5em;">不考虑损耗时 输入产品需要的数量,时期 工艺信息  得出产品生产信息
所在层数 父级</div>

<div id="ha">
<table>
    <tr>
    <td>1</td>
    <td>2</td>
    <td >
        <div ></div>
        <div class="box" style="height: 50px;width: 50px;">

        <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
        viewBox="0 0 50 50" style="enable-background:new 0 0 50 50;" xml:space="preserve">
       <style type="text/css">
       .st0{fill:none;stroke:#000000;stroke-width:2;stroke-linecap:round;stroke-miterlimit:10;}
       .st1{fill:none;stroke:#000000;stroke-width:2;stroke-miterlimit:10;}
       </style>
    <path class="st0" d="M7,47V3h36v44H7z"/>
    <path class="st1" d="M17,26h-4 M37,26H20 M37,32H20 M17,32h-4 M37,38H20 M17,38h-4"/>
    </svg>
    
    </div></div>
</td>
    <td >4</td>
    <td>5</td>
</tr>
</table>
</div>
<div id="test" style="height: 1000px;"></div>



    <script>
        /*
        var tb=document.getElementById("familyTable");    //获取table对像
        var rows = tb.rows;
        for (var i = 1; i < rows.length; i++) {    //--循环所有的行
        var cells = rows[i].cells;  // cells 集合返回表格中所有 <td> 或 <th> 元素。
            for (var j = 1; j < cells.length; j++) {   //--循环所有的列,从第一列取数据,因为一般第一列都是标识,数据毫无意义。
            //var value = cells[j].childNodes[0].value;//取有input框的数据
            var value = cells[j].innerHTML;//取没有input框的数据
            console.log(value);
              }
        }   */






/*点击事件*/
let box = document.getElementById("ha");
       
        box.onclick =function(){
            console.log(120);
            alert("提交成功");
            let a=[];
            let b=new Array(12);
            let c=[];
            let n,m,atq,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12;
            let     btq,b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12;

            var tb=document.getElementById("familyTable");    //获取table对像
        var rows = tb.rows;
        for (var i = 0; i < rows.length; i++) {    //--循环所有的行
        var cells = rows[i].cells;  // cells 集合返回表格中所有 <td> 或 <th> 元素。
            for (var j = 0; j < cells.length; j++) {   //--循环所有的列,从第一列取数据,因为一般第一列都是标识,数据毫无意义。
           
           
            
            
            if(i==1&j==1){ atq = cells[j].innerHTML;console.log(atq);}
            if(i==2&j==1){ btq = cells[j].innerHTML;console.log(btq);}
            
            if(i==1&j<12){a[j-atq] = cells[j+4].innerHTML;console.log(a);}
            if(i==2&j<12){b[j-btq] = cells[j+4].innerHTML;console.log(b);}
            if(i==3&j<12){c[j] = cells[j+4].innerHTML;console.log(b);}
           


              }
         }
         
         var s= "<table  id='familyTable' border=1px; style= 'border-color: rgb(85, 230, 193);'>";
         
         /*s=s+"<tr> <th>产品编码</th><th>计划阶段</th>"+
         "<th>&nbsp; 1 &nbsp;</th><th> &nbsp;2 &nbsp;</th><th> &nbsp;3 &nbsp;</th><th> &nbsp;4 &nbsp;"+
         "</th><th> &nbsp;5 &nbsp;</th><th> &nbsp;6 &nbsp;</th><th> &nbsp;7 &nbsp;</th>"+
         "<th> &nbsp;8 &nbsp;</th> <th> &nbsp;9 &nbsp;</th><th> &nbsp;10 &nbsp;</th>"+
         "<th> &nbsp;11 &nbsp;</th><th> &nbsp;12 &nbsp;</th>"+
         "</tr>"+"<tr>";*/
            for(j=0;j<12;j++){
                if(a[j]==undefined&&b[j]==undefined&&c[j]==undefined)
          {   s=s+"<th>undefined</th>";
            }
          else{
          if(a[j]==undefined){a[j]=0;};if(b[j]==undefined){b[j]=0;};if(c[j]==undefined){c[j]=0;}
            let d=Number(a[j])+Number(b[j])+Number(c[j]);
            if(d==0){d="---"};
              s=s+"<th>"+d+"</th>";
              }
         document.getElementById("test").innerHTML =s ;

        }
         


        }

    </script>
</body>
</html>

MRP 三:

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <style>
        body{
            background-color: white;
        }
        tr{height: 80px;}
        td{width: 30px;}
        h1{
    color: #333;
    font-family: Helvetica;
    margin:0;
    padding:0;
    font-size: 10rem;
    letter-spacing: -0.3rem;/*缩小字距*/
    display:flex;
    justify-content:center;/*水平*/
}

table{display:flex;
    justify-content:center;/*水平*/}


    .box:hover{/*.box:hover划过事件*/
        display:flex;
            width: 500px;
            height: 100px;



            background-color: blue;
            background-image: url(images/order-completed.gif) ;
        }


        

    </style>


<div> 第一部分  </div>


<input  id="o" type="button" value="填写完成">
<table  id="t1" border=1px;  style="border-color: rgb(85, 230, 193); ">
        
    <tr> 
        
        <th contenteditable="true">&nbsp;最终需求期&nbsp;</th>
        
        <th contenteditable="true"> &nbsp;名称 &nbsp;</th>
        <th contenteditable="true"> &nbsp;提前期 &nbsp;</th>
        <th contenteditable="true"> &nbsp;等级 &nbsp;</th>
        <th contenteditable="true"> &nbsp;数量&nbsp;</th>
        <th contenteditable="true"> &nbsp;父级 &nbsp;</th>
        <th contenteditable="true">&nbsp;库存&nbsp;</th>
    
    </tr>
    <tr> 
        <th contenteditable="true"> 8</th>
        
        <th contenteditable="true">A</th>
        <th contenteditable="true"> 4</th>
        <th contenteditable="true">1</th>
        <th contenteditable="true"> 100</th>
        <th contenteditable="true"> null</th>
        <th contenteditable="true">0</th>
    </tr>
    <tr> 
        <th contenteditable="true"></th>
        
        <th contenteditable="true"> B</th>
        <th contenteditable="true"> 3</th>
        <th contenteditable="true"> 2</th>
        <th contenteditable="true"> 100</th>
        <th contenteditable="true"> A</th>
        <th contenteditable="true">120</th>
    </tr>
    <tr> 
        <th contenteditable="true"></th>
        
        <th contenteditable="true">C</th>
        <th contenteditable="true"> 2</th>
        <th contenteditable="true"> 2</th>
        <th contenteditable="true"> 200</th>
        <th contenteditable="true"> A</th>
        <th contenteditable="true">60</th>
    </tr>
    <tr> 
        <th contenteditable="true"></th>
        
        <th contenteditable="true">D</th>
        <th contenteditable="true">1</th>
        <th contenteditable="true">2</th>
        <th contenteditable="true"> 200</th>
        <th contenteditable="true"> C</th>
        <th contenteditable="true">70</th>
    </tr>
    <tr> 
        <th contenteditable="true"></th>
        
        <th contenteditable="true"> E</th>
        <th contenteditable="true"> 1</th>
        <th contenteditable="true"> 2</th>
        <th contenteditable="true"> 400</th>
        <th contenteditable="true">C</th>
        <th contenteditable="true">&nbsp;库存&nbsp;</th>
    </tr>
    </table>

<h1>MRP的填写与保存</h1>
<div id="test" style="height: 1000px;"></div>

<div style="font-size: 0.5em;">不考虑损耗时 输入产品需要的数量,时期 工艺信息  得出产品生产信息
所在层数 父级/直接的生产个数</div>

<div id="ha">
<table>
    <tr>
    <td>1</td>
    <td>2</td>
    <td >
        <div ></div>
        <div class="box" style="height: 50px;width: 50px;">

        <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
        viewBox="0 0 50 50" style="enable-background:new 0 0 50 50;" xml:space="preserve">
       <style type="text/css">
       .st0{fill:none;stroke:#000000;stroke-width:2;stroke-linecap:round;stroke-miterlimit:10;}
       .st1{fill:none;stroke:#000000;stroke-width:2;stroke-miterlimit:10;}
       </style>
    <path class="st0" d="M7,47V3h36v44H7z"/>
    <path class="st1" d="M17,26h-4 M37,26H20 M37,32H20 M17,32h-4 M37,38H20 M17,38h-4"/>
    </svg>
    
    </div></div>
</td>
    <td >4</td>
    <td>5</td>
</tr>
</table>
</div>



<script>
     let n;
   // var n=8;//初始条件
    //var m=100;
    console.log("");
    //创建产品类  
   function createproduct(pname,plt, prank, pnum,pfa,pcun){      
  var product= new Object;      // 创建一个对象变量
  product.name=pname;
  product.lt=plt;
  product.rank=prank;/*等级 好像定义了父级等级没用了*/
  product.num=pnum;/*需求量*/
  product.fa=pfa;/*父级*/
  product.cun=pcun;/*存量*/


  
  product.maoxuqiulie=0;
  product.fdl=0;

  
  
              //  定义age属性
  product.teach = function()
  {
      if(this.rank==1)
      {product.maoxuqiulie=n;
      }
      else{
          product.maoxuqiulie=product.fa.fdl;
         
      }
      product.fdl=product.maoxuqiulie-product.lt;
       
  };
  return product;             // 返回nTeacher对象
 }








</script>















    <script>
       






/*点击事件*/
let box = document.getElementById("ha");
       
        box.onclick =function(){
            console.log(120);
            alert("提交成功");
            
        }




/*填写完成----点击事件*/
let o = document.getElementById("o");
       
        o.onclick =function(){
        //let n=9;/*总周期赋值*/
        n=9;
        let aplt=4;
         let aprank=1;
         let apnum=100;

         let bplt=3;
         let bprank=2;
         let bpnum=100;

         let cplt=2;
         let cprank=2;
         let cpnum=200;

         let dplt=1;
         let dprank=2;
         let dpnum=200;

         let eplt=1;
         let eprank=2;
         let epnum=400;




            var tb=document.getElementById("t1");    //获取table对像
        var rows = tb.rows;
        for (var i = 0; i < rows.length; i++) {    //--循环所有的行
        var cells = rows[i].cells;  // cells 集合返回表格中所有 <td> 或 <th> 元素。
            for (var j = 0; j < cells.length; j++) {   //--循环所有的列,从第一列取数据,因为一般第一列都是标识,数据毫无意义。
           
           
            
            if(i==1&j==0){ n = cells[j].innerHTML;console.log(n);}
            if(i==1&j==2){ aplt = cells[j].innerHTML;console.log(n);}
            if(i==1&j==3){ aprank = cells[j].innerHTML;console.log(n);}
            if(i==1&j==4){ apnum = cells[j].innerHTML;console.log(n);}
            if(i==1&j==6){ acun = cells[j].innerHTML;console.log(n);}

            if(i==2&j==2){ bplt = cells[j].innerHTML;console.log(n);}
            if(i==2&j==3){ bprank = cells[j].innerHTML;console.log(n);}
            if(i==2&j==4){ bpnum = cells[j].innerHTML;console.log(n);}
            if(i==2&j==6){ bcun = cells[j].innerHTML;console.log(n);}

            if(i==3&j==2){ cplt = cells[j].innerHTML;console.log(n);}
            if(i==3&j==3){ cprank = cells[j].innerHTML;console.log(n);}
            if(i==3&j==4){ cpnum = cells[j].innerHTML;console.log(n);}
            if(i==3&j==6){ ccun = cells[j].innerHTML;console.log(n);}

            if(i==4&j==2){ dplt = cells[j].innerHTML;console.log(n);}
            if(i==4&j==3){ dprank = cells[j].innerHTML;console.log(n);}
            if(i==4&j==4){ dpnum = cells[j].innerHTML;console.log(n);}
            if(i==4&j==6){ dcun = cells[j].innerHTML;console.log(n);}

            if(i==5&j==2){ eplt = cells[j].innerHTML;console.log(n);}
            if(i==5&j==3){ eprank = cells[j].innerHTML;console.log(n);}
            if(i==5&j==4){ epnum = cells[j].innerHTML;console.log(n);}



              }
         }

         var zong=[];
                            //pname,plt, prank, pnum,pfa

         var A = createproduct("A",aplt, aprank, apnum,null,acun);
         var B = createproduct("B",bplt, bprank, bpnum,A,bcun);
         var C = createproduct("C",cplt, cprank, cpnum,A,ccun);
         var D = createproduct("D",dplt, dprank, dpnum,C,dcun);
         
         A.teach();//对A初始话
         var zong=[A,B,C,D];



























            console.log(120);
     
            for(i=1;i<4;i++){
                zong[i].teach();
            }
            
            /*alert("A在"+A.maoxuqiulie+"期,毛需求为"+A.num)
            alert("A在"+A.fdl+"期,订货需求为"+A.num)
            alert("B在"+B.maoxuqiulie+"期,毛需求为"+B.num)
            alert("B在"+B.fdl+"期,订货需求为"+B.num)
            alert("C在"+C.maoxuqiulie+"期,毛需求为"+C.num)
            alert("C在"+C.fdl+"期,订货需求为"+C.num)
            alert("D在"+D.maoxuqiulie+"期,毛需求为"+D.num)
            alert("D在"+D.fdl+"期,订货需求为"+D.num)
            alert("E在"+E.maoxuqiulie+"期,毛需求为"+E.num)
            alert("E在"+E.fdl+"期,订货需求为"+E.num)*/
            
         var s= "<table  id='familyTable' border=1px; style= 'border-color: rgb(85, 230, 193);'>";
         
            s=s+"<tr> <th>产品编码</th><th>计划阶段</th>"+
            "<th>&nbsp; 1 &nbsp;</th><th> &nbsp;2 &nbsp;</th><th> &nbsp;3 &nbsp;</th><th> &nbsp;4 &nbsp;"+
            "</th><th> &nbsp;5 &nbsp;</th><th> &nbsp;6 &nbsp;</th><th> &nbsp;7 &nbsp;</th>"+
            "<th> &nbsp;8 &nbsp;</th> <th> &nbsp;9 &nbsp;</th><th> &nbsp;10 &nbsp;</th>"+
            "<th> &nbsp;11 &nbsp;</th><th> &nbsp;12 &nbsp;</th>"+
            "</tr>"+"<tr>";



for(j=0;j<4;j++){
         s=s+"<th>"+zong[j].name+"</th>"+"<th> 毛需求</th>";

            for(i=1;i<=12;i++)
           {
               if(i==zong[j].maoxuqiulie){
                s=s+"<td class='aaaa'>"+zong[j].num+"</td>";
                   }
               else{
                s=s+"<td class='aaaa'>"+"</td>";
            }
           }


          s=s+"</tr>";
          s=s+"<tr>"+"<th>"+zong[j].name+"</th>"+"<th> 订货需求</th>";
            for(i=1;i<=12;i++)
           {
               if(i==zong[j].fdl){
                let d=Number(zong[j].num)-Number(zong[j].cun);
                if(d<0){d=0;}
                s=s+"<td class='aaaa'>"+d+"</td>";
                   }
               else{
                s=s+"<td class='aaaa'>"+"</td>";
            }
           }
          s=s+"</tr>";
        }


          s=s+"</table>";
            document.getElementById("test").innerHTML =s ;

            

            

            var tb=document.getElementById("familyTable");    //获取table对像
        var rows = tb.rows;
        for (var i = 1; i < rows.length; i++) {    //--循环所有的行
        var cells = rows[i].cells;  // cells 集合返回表格中所有 <td> 或 <th> 元素。
            for (var j = 1; j < cells.length; j++) {   //--循环所有的列,从第一列取数据,因为一般第一列都是标识,数据毫无意义。
            //var value = cells[j].childNodes[0].value;//取有input框的数据
            var value = cells[j].innerHTML;//取没有input框的数据
            console.log(value);
              }
}








    

        }
    </script>
</body>
</html>

关键路径和最早晚开始时间

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <style>
        body{
            background-color: white;
        }
        tr{height: 80px;}
        td{width: 30px;}
        h1{
    color: #333;
    font-family: Helvetica;
    margin:0;
    padding:0;
    font-size: 10rem;
    letter-spacing: -0.3rem;/*缩小字距*/
    display:flex;
    justify-content:center;/*水平*/
}

table{display:flex;
    justify-content:center;/*水平*/}


    .box:hover{/*.box:hover划过事件*/
        display:flex;
            width: 500px;
            height: 100px;



            background-color: blue;
            background-image: url(images/order-completed.gif) ;
        }


        

    </style>


<div> 第一部分  </div>


<input  id="o" type="button" value="填写完成">
<table  id="t1" border=1px;  style="border-color: rgb(85, 230, 193); ">
        
    <tr> 
        
        <th contenteditable="true">&nbsp;编号&nbsp;</th>
        <th contenteditable="true"> &nbsp;名称 &nbsp;</th>
        <th contenteditable="true"> &nbsp;提前期 &nbsp;</th>
        <th contenteditable="true"> &nbsp;等级 &nbsp;</th>
        <th contenteditable="true"> &nbsp;数量&nbsp;</th>
        <th contenteditable="true"> &nbsp;父级 &nbsp;</th>
        
        
    
    </tr>
    <tr> 
        <th contenteditable="true"> 0</th>
        <th contenteditable="true">A</th>
        <th contenteditable="true"> 4</th>
        <th contenteditable="true">1</th>
        <th contenteditable="true"> 100</th>
        <th contenteditable="true"> null</th>
        
    </tr>
    <tr> 
        <th contenteditable="true">1</th>
        <th contenteditable="true"> B</th>
        <th contenteditable="true"> 3</th>
        <th contenteditable="true"> 2</th>
        <th contenteditable="true"> 100</th>
        <th contenteditable="true"> A</th>
    </tr>
    <tr> 
        <th contenteditable="true">2</th>
        <th contenteditable="true">C</th>
        <th contenteditable="true"> 2</th>
        <th contenteditable="true"> 2</th>
        <th contenteditable="true"> 200</th>
        <th contenteditable="true"> A</th>
    </tr>
    <tr> 
        <th contenteditable="true">3</th>
        <th contenteditable="true">D</th>
        <th contenteditable="true">1</th>
        <th contenteditable="true">3</th>
        <th contenteditable="true"> 200</th>
        <th contenteditable="true"> C</th>
    </tr>
    <tr> 
        <th contenteditable="true">4</th>
        <th contenteditable="true"> E</th>
        <th contenteditable="true"> 1</th>
        <th contenteditable="true"> 3</th>
        <th contenteditable="true"> 400</th>
        <th contenteditable="true">C</th>
    </tr>
    </table>

<h1>MRP的填写与保存</h1>
<div id="test" style="height: 1000px;"></div>

<div style="font-size: 0.5em;"></div>

<div id="ha">
<table>
    <tr>
    <td>1</td>
    <td>2</td>
    <td >
        <div ></div>
        <div class="box" style="height: 50px;width: 50px;">

        <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
        viewBox="0 0 50 50" style="enable-background:new 0 0 50 50;" xml:space="preserve">
       <style type="text/css">
       .st0{fill:none;stroke:#000000;stroke-width:2;stroke-linecap:round;stroke-miterlimit:10;}
       .st1{fill:none;stroke:#000000;stroke-width:2;stroke-miterlimit:10;}
       </style>
    <path class="st0" d="M7,47V3h36v44H7z"/>
    <path class="st1" d="M17,26h-4 M37,26H20 M37,32H20 M17,32h-4 M37,38H20 M17,38h-4"/>
    </svg>
    
    </div></div>
</td>
    <td >4</td>
    <td>5</td>
</tr>
</table>
</div>



<script>
     let n;
    console.log("");
    //创建产品类  
   function createproduct(pname,plt, prank, pnum,pfa){      
  var product= new Object;      // 创建一个对象变量
  product.name=pname;
  product.lt=plt;
  product.rank=prank;/*等级*/
  product.num=pnum;/*需求量*/
  product.fa=pfa;/*父级*/
  product.zuizao=100;


  /*暂存结果*/
  product.maoxuqiulie=product.lt;//路径总长度
  product.fdl=product.name;//工作路径
  product.yezi= 0;
  product.zuiwan=0;
  
  return product; // 返回对象
 }








</script>















    <script>
       






/*点击事件*/
let box = document.getElementById("ha");
       
        box.onclick =function(){
            console.log(120);
            alert("提交成功");
            
        }




/*填写完成----点击事件*/
let o = document.getElementById("o");
       
        o.onclick =function(){
        //let n=9;/*总周期赋值*/
        n=9;
        gaunjian=0;
        let aplt=4;
         let aprank=1;
         let apnum=100;

         let bplt=3;
         let bprank=2;
         let bpnum=100;

         let cplt=2;
         let cprank=2;
         let cpnum=200;

         let dplt=1;
         let dprank=2;
         let dpnum=200;

         let eplt=1;
         let eprank=2;
         let epnum=400;




            var tb=document.getElementById("t1");    //获取table对像
        var rows = tb.rows;
        for (var i = 0; i < rows.length; i++) {    //--循环所有的行
        var cells = rows[i].cells;  // cells 集合返回表格中所有 <td> 或 <th> 元素。
            for (var j = 0; j < cells.length; j++) {   //--循环所有的列,从第一列取数据,因为一般第一列都是标识,数据毫无意义。
           
           
            
                if(i==1&j==0){ n = cells[j].innerHTML;console.log(n);}
            if(i==1&j==2){ aplt = cells[j].innerHTML;console.log(n);}
            if(i==1&j==3){ aprank = cells[j].innerHTML;console.log(n);}
            if(i==1&j==4){ apnum = cells[j].innerHTML;console.log(n);}

            if(i==2&j==2){ bplt = cells[j].innerHTML;console.log(n);}
            if(i==2&j==3){ bprank = cells[j].innerHTML;console.log(n);}
            if(i==2&j==4){ bpnum = cells[j].innerHTML;console.log(n);}

            if(i==3&j==2){ cplt = cells[j].innerHTML;console.log(n);}
            if(i==3&j==3){ cprank = cells[j].innerHTML;console.log(n);}
            if(i==3&j==4){ cpnum = cells[j].innerHTML;console.log(n);}

            if(i==4&j==2){ dplt = cells[j].innerHTML;console.log(n);}
            if(i==4&j==3){ dprank = cells[j].innerHTML;console.log(n);}
            if(i==4&j==4){ dpnum = cells[j].innerHTML;console.log(n);}

            if(i==5&j==2){ eplt = cells[j].innerHTML;console.log(n);}
            if(i==5&j==3){ eprank = cells[j].innerHTML;console.log(n);}
            if(i==5&j==4){ epnum = cells[j].innerHTML;console.log(n);}



              }
         }

         var zong=[];
                            //pname,plt, prank, pnum,pfa

         var A = createproduct("A",aplt, aprank, apnum,null);
         var B = createproduct("B",bplt, bprank, bpnum,A);
         var C = createproduct("C",cplt, cprank, cpnum,A);
         var D = createproduct("D",dplt, dprank, dpnum,C);
         var E = createproduct("E",eplt, eprank, epnum,C);
         
         var zong=[A,B,C,D,E];
         for(i=0;i<5;i++){ //对所有节点判断是否为叶子节点
            if(zong[i].fa!=null){zong[i].fa.yezi=1;}
             }
             for(i=0;i<5;i++){ console.log(zong[i].name+zong[i].yezi);}

         let now;
         for(i=0;i<5;i++){
             now=zong[i];
             
            for(;now.fa!=null;){

                now=now.fa;
                zong[i].maoxuqiulie=Number(zong[i].maoxuqiulie)+Number(now.lt);/*总时间*/
                zong[i].fdl=zong[i].fdl+"-->"+now.name;
            }
           
            if(zong[i].yezi==0){//是叶子节点
            //alert("总时间"+zong[i].name+zong[i].maoxuqiulie);
            //alert("总路线"+zong[i].name+zong[i].fdl);
            gaunjian=Math.max(Number(zong[i].maoxuqiulie),gaunjian)
           
                }
         }










         //求最短时间
         for(i=0;i<5;i++){ 

           if(zong[i].yezi==1){
                    
                    for(j=0;j<5;j++){ 
                        if(zong[j].fa==zong[i]){//zong[j]为子节点
                        if(zong[i].fa!=null){

                        let h=    Number(zong[j].dl)+Number(zong[i].dl)
                        console.log(h);
                        if(!isNaN(h)){
                        zong[i].fa.zuizao=Math.min(Number(zong[i].fa.zuizao),h);
                        console.log(Math.min(Number(zong[i].fa.zuizao),h));}
                                            }
                                               }
                                    }
                }    

            if(zong[i].yezi==0){

                zong[i].zuizao=0;
                zong[i].fa.zuizao=Math.min(Number(zong[i].fa.zuizao),Number(zong[i].lt))
                console.log("fajoja;aj;ahffp;ahfpah");
                
                }
               

               
        }
        for(i=0;i<5;i++){ /* alert("最早开始时间"+zong[i].name+zong[i].zuizao);*/}





       //最晚时间
       console.log("gaunjian"+gaunjian);
       for(i=0;i<5;i++){ 
        zong[i].zuiwan=Number(gaunjian)-Number(zong[i].maoxuqiulie);
        console.log("zuiwan"+zong[i].name+zong[i].zuiwan);
       }


       //输出关键路径
       for(i=0;i<5;i++){ 
       if(Number(zong[i].maoxuqiulie)==Number(gaunjian)){
                alert("关键路径:"+zong[i].fdl)
            }
       }












            console.log(120);
     
            
            
            /*alert("A在"+A.maoxuqiulie+"期,毛需求为"+A.num)
            alert("A在"+A.fdl+"期,订货需求为"+A.num)
            alert("B在"+B.maoxuqiulie+"期,毛需求为"+B.num)
            alert("B在"+B.fdl+"期,订货需求为"+B.num)
            alert("C在"+C.maoxuqiulie+"期,毛需求为"+C.num)
            alert("C在"+C.fdl+"期,订货需求为"+C.num)
            alert("D在"+D.maoxuqiulie+"期,毛需求为"+D.num)
            alert("D在"+D.fdl+"期,订货需求为"+D.num)
            alert("E在"+E.maoxuqiulie+"期,毛需求为"+E.num)
            alert("E在"+E.fdl+"期,订货需求为"+E.num)*/
            
         var s= "<table  id='familyTable' border=1px; style= 'border-color: rgb(85, 230, 193);'>";
         
            s=s+"<tr> <th>产品编码</th><th>生产路径</th>"+
            "<th>&nbsp; 最早开始时间 &nbsp;</th><th> &nbsp;最晚开始时间 &nbsp;</th>"+
            "</tr>"+"<tr>";



for(j=0;j<5;j++){
         s=s+"<th>"+zong[j].name+"</th>"+"<th>" +zong[j].fdl+"</th>"
         +"<th>" +zong[j].zuizao+"</th>"+"<th>" +zong[j].zuiwan+"</th>";
          s=s+"</tr>";
        }
          s=s+"</table>";
            document.getElementById("test").innerHTML =s ;

            

            

            var tb=document.getElementById("familyTable");    //获取table对像
        var rows = tb.rows;
        for (var i = 1; i < rows.length; i++) {    //--循环所有的行
        var cells = rows[i].cells;  // cells 集合返回表格中所有 <td> 或 <th> 元素。
            for (var j = 1; j < cells.length; j++) {   //--循环所有的列,从第一列取数据,因为一般第一列都是标识,数据毫无意义。
            //var value = cells[j].childNodes[0].value;//取有input框的数据
            var value = cells[j].innerHTML;//取没有input框的数据
            console.log(value);
              }
}








    

        }
    </script>
</body>
</html>
  • 1
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值