<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head th:replace="/common/template :: header(~{::title},~{::link},~{::style})">
    <link rel="stylesheet" th:href="@{/css/generate.code.css}">
</head>
<body>
    生产凭证
    <div class="layui-form timo-compile" style="padding-top: 0px;">
       <!-- <div class="layui-tab layui-tab-card">
            <ul class="layui-tab-title">
                <li class="layui-this">手工录入</li>
&lt;!&ndash;                <li>查验录入</li>&ndash;&gt;
            </ul>
            <div class="layui-tab-content" style="height: 100%;">
                <div class="layui-tab-item layui-show">
                    <form th:action="@{/bss/vatInvoice/add}">
                    <fieldset id="basic" class="layui-elem-field layui-form">
                        <legend class="code-legend">基本信息</legend>
                        <div class="layui-field-box">
                            <div class="layui-form-item">
                                <div class="layui-inline">
                                    <label class="layui-form-label required">发票类型</label>
                                    <div class="layui-input-inline">
                                        <select id="invoiceType" name="invoiceType" lay-filter="invoiceType">
                                            <option value="0">增值税普通发票</option>
                                            <option value="1">增值税专用发票</option>
                                        </select>
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <label class="layui-form-label required">发票代码</label>
                                    <div class="layui-input-inline">
                                        <input type="text" id="invoiceCode" name="invoiceCode" autocomplete="off" class="layui-input">
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <label class="layui-form-label required">发票号码</label>
                                    <div class="layui-input-inline">
                                        <input type="text" id="invoiceNo" name="invoiceNo" autocomplete="off" class="layui-input">
                                    </div>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <div class="layui-inline">
                                    <label class="layui-form-label required">校验码</label>
                                    <div class="layui-input-inline">
                                        <input type="text" id="checkCode" name="checkCode" autocomplete="off" class="layui-input">
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <label class="layui-form-label required">发票日期</label>
                                    <div class="layui-input-inline">
                                        <input type="text" name="invoiceDate" class="layui-input test-item" id="laydate" placeholder="yyyy-MM-dd" lay-key="1">
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <label class="layui-form-label">备注</label>
                                    <div class="layui-input-inline">
                                        <input type="text" id="remark" name="remark" autocomplete="off" class="layui-input">
                                    </div>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <div class="layui-inline">
                                    <label class="layui-form-label required">不含税金额</label>
                                    <div class="layui-input-inline">
                                        <input type="text" id="invoiceMoney" name="invoiceMoney" autocomplete="off" class="layui-input">
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <label class="layui-form-label required">税额</label>
                                    <div class="layui-input-inline">
                                        <input type="text" id="taxAmount" name="taxAmount" autocomplete="off" class="layui-input">
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <label class="layui-form-label required">价税合计</label>
                                    <div class="layui-input-inline">
                                        <input type="text" id="totalAmount" name="totalAmount" autocomplete="off" class="layui-input">
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <label class="layui-form-label required">价税合计(大写)</label>
                                    <div class="layui-input-inline">
                                        <input type="text" id="totalAmountCn" name="totalAmountCn" autocomplete="off" class="layui-input">
                                    </div>
                                    <input type="hidden" id="salerTaxInfoId" name="salerTaxInfoId" />
                                    <input type="hidden" id="buyTaxInfoId" name="buyTaxInfoId" />
                                </div>
                            </div>
                            <div class="layui-inline">
                                <div class="layui-form-item">
                                    <label class="layui-form-label">发票图片</label>
                                    <div class="layui-input-inline">
                                            <button type="button" class="layui-btn" id="vatInvoiceImg" name="invoiceImg" up-field="path" up-url="/bss/vatInvoice/upload/image">
                                            <i class="layui-icon"></i>上传图片
                                        </button>
                                    </div>
                                    <div class="upload-show"></div>
                                </div>
                            </div>
                        </div>
                    </fieldset>
                    <div class="panel">
                        <div class="panel-header">
                            <div class="title">货物信息</div>
                            <div class="control">
                                <button class="col-add field-add layui-btn layui-btn-primary layui-btn-xs">
                                    <i class="fa fa-plus-circle"></i>添加
                                </button>
                                <button class="col-del field-del layui-btn layui-btn-primary layui-btn-xs">
                                    <i class="fa fa-minus-circle"></i>删除
                                </button>
                            </div>
                            <div class="entity"><span class="bindTableEntity"></span>(<span class="bindTablePrefix"></span><span class="bindTableName"></span>)</div>
                        </div>
                        <div class="panel-body panel-body-entity">
                            <table class="layui-table">
                                <thead>
                                <tr>
                                    <th width="20">#</th>
                                    <th width="100">货物名称</th>
                                    <th width="100">规格型号</th>
                                    <th width="100">单位</th>
                                    <th width="100">数量</th>
                                    <th width="100">单价</th>
                                    <th width="100">金额</th>
                                    <th width="100">税率</th>
                                    <th width="100">税额</th>
                                </tr>
                                </thead>
                                <tbody id="entity">
                                <tr>
                                    <td class="entity-number" th:text="1"></td>
                                    <td class="entity-name"><input type="text" name="name"/></td>
                                    <td class="entity-specification"><input type="text" name="specification"/></td>
                                    <td class="entity-unit"><input type="text" name="unit"/></td>
                                    <td class="entity-num"><input type="text" name="num"/></td>
                                    <td class="entity-unitPrice"><input type="text" name="unitPrice"/></td>
                                    <td class="entity-detailAmount"><input type="text" name="detailAmount"/></td>
                                    <td class="entity-taxRate"><input type="text" name="taxRate"/></td>
                                    <td class="entity-taxAmount"><input type="text" name="goodTaxAmount"/></td>
                                </tr>
                                </tbody>
                            </table>
                        </div>
                        <div class="layui-form-item timo-finally">
                            <button class="layui-btn ajax-submit" ><i class="fa fa-check-circle"></i> 保存</button>
                            <button class="layui-btn btn-secondary close-popup"><i class="fa fa-times-circle"></i> 关闭</button>
                        </div>
                    </div>
                    </form>
                </div>
                &lt;!&ndash;<div class="layui-tab-item">
                    <form th:action="@{/bss/vatInvoice/check}">
                        <div class="layui-form-item">
                            <label class="layui-form-label required">发票代码</label>
                            <div class="layui-input-inline">
                                <input class="layui-input" type="text" name="invoiceCode" placeholder="请输入发票代码" />
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label required">发票号码</label>
                            <div class="layui-input-inline">
                                <input class="layui-input" type="text" name="invoiceNo" placeholder="请输入发票号码" />
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label required">开票时间</label>
                            <div class="layui-input-inline">
                                <input type="text" class="layui-input" name="invoiceDate" placeholder="yyyy-MM-dd">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">开具金额(不含税)</label>
                            <div class="layui-input-inline">
                                <input class="layui-input" type="text" name="invoiceMoney" placeholder="请输入开具金额(不含税)" />
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label required">校验码</label>
                            <div class="layui-input-inline">
                                <input class="layui-input" type="text" name="checkCode" placeholder="请输入校验码" />
                            </div>
                        </div>
                        <div class="layui-form-item timo-finally">
                            <button class="layui-btn ajax-submit"><i class="fa fa-check-circle"></i> 保存</button>
                            <button class="layui-btn btn-secondary close-popup"><i class="fa fa-times-circle"></i> 关闭</button>
                        </div>
                    </form>
                </div>&ndash;&gt;
            </div>
        </div>-->
    </div>

    <script th:replace="/common/template :: script"></script>
    <script type="text/javascript" th:src="@{/js/plugins/jquery-3.3.1.min.js}"></script>
    <!--<script type="text/javascript" th:src="@{/lib/zTree_v3/js/jquery.ztree.core.min.js}"></script>-->
    <!--<script type="text/javascript" th:src="@{/js/timoTree.js}"></script>-->
    <script type="text/javascript">
        // 树形菜单
//        $.fn.selectTree({
//            rootTree: '顶级菜单'
//        });

      // 验证下拉选择器
//        layui.config({
//            base: '[[@{/lib/formSelects-v4/}]]'
//        }).extend({
//            formSelects: 'formSelects-v4.min'
//        });

        var entity = $("#entity");
        var field = null;
        // 选中字段
        entity.on("click", ".entity-number", function () {
            if(field !== null){
                $(field).css("background-color", "#FFFFFF");
                $(field).css("color", "#666666");
            }
            if(field !== this){
                $(this).css("background-color", "#5FB878");
                $(this).css("color", "#FFFFFF");
                field = this;
            }else{
                field = null;
            }
        });

        // 添加行
        $(".col-add").on("click", function (e) {
            e.preventDefault();
            var element = entity.children("tr:last-child").clone();
            element.find("input").val("");
            if(field == null){
                entity.append(element);
            }else {
                $(field).parent().after(element);
            }
            element.children(".entity-number").click();
            resetNumber();
        });

        // 删除行
        $(".col-del").on("click", function (e) {
            e.preventDefault();
            if(field != null){
                if (entity.children("tr").length == 1) {
                    return;
                }
                $(field).parent().remove();
                entity.children("tr:last-child").children(".entity-number").click();
                resetNumber();
            }
        });

        // 重置字段编号
        var resetNumber = function(){
            entity.children().each(function (key, val) {
                $(val).children(".entity-number").text(key + 1);
            });
        };
    </script>
    <!--<script type="text/javascript" th:src="@{/js/generate.code.js}"></script>-->
    <!--<script type="text/javascript" th:src="@{/js/build.js}"></script>-->
</body>
</html>