<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>配件出库</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  <link rel="stylesheet" href="../../layuiadmin/layui/css/layui.css" media="all">
  <link rel="stylesheet" href="../../layuiadmin/style/admin.css" media="all">
      <style type="text/css">
        .table-overlay .layui-table-view,
        .table-overlay .layui-table-header,
        .table-overlay .layui-table-box,
        .table-overlay .layui-table-body{overflow: visible;}
        .table-overlay .layui-table-cell{height: auto; overflow: visible;}
        .layui-form-select dl{max-height: 150px;}
    </style>
</head>
<body>

<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-card-body" pad15>
            <div class="layui-row layui-col-space15">
                <div class="layui-col-md12">

                    <form class="layui-form" action="" lay-filter="component-form-element">
                        <div class="layui-row layui-col-space10" >
                            <div class="layui-col-xs12 layui-col-sm4 layui-col-md4" id="id_div">
                            </div>
                        </div>
                        <button class="layui-btn" id="purchase-order-submit" lay-submit lay-filter="component-form-element" style="display: none">保存</button>
                    </form>

                </div>
            </div>
        </div>
    </div>
</div>

  <script src="../../layuiadmin/layui/layui.js"></script>
  <script>

  layui.link('../../../layuiadmin/style/autocomplete.css');
  layui.config({
    base: '../../../layuiadmin/' //静态资源所在路径
  }).extend({
    index: 'lib/index',
    autocomplete: 'autocomplete'
  }).use(['index', 'utils','form', 'element'], function(){
    var $ = layui.$
    ,admin = layui.admin
    ,element = layui.element
    ,form = layui.form;

    var editdata = JSON.parse(JSON.stringify(parent.layui.table.editdata));
    var html = '';

     admin.req({
        url: '/order/sale_order/msg/?id=' + editdata.id,
        done: function(res){
            for (var i in res.data) {
                 html += '<label class="layui-form-label" style="margin-top:5px;">'+ res.data[i].name +'：</label>\n' +
                '         <div class="layui-input-block" style="margin-top:5px;">\n' +
                '         <input type="text" id="'+ res.data[i].id + ' " name="'+ res.data[i].id + '" value= " '+res.data[i].content+' "  autocomplete="off" class="layui-input">\n' +
                '         </div>'
            }
            $('#id_div').html(html);
            form.render();

        }
    });


    form.render(null, 'component-form-element');
    element.render('breadcrumb', 'breadcrumb');

    form.on('submit(component-form-element)', function(data){
        admin.req({
            url: '/order/sale_order/msg_save/?id='+editdata.id
            ,data: JSON.stringify(data.field)
            ,type: 'post'
            , done: function (res) {
                parent.layui.onSubmitChild();
            }
        });

        return false;
    });

    parent.layui.submitChild = function () {
      $("#purchase-order-submit").click();
    };

  });

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