| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189 | @extends('admin/layout')@section('content')    <body class="gray-bg">    <div class="wrapper wrapper-content animated fadeInRight">        <div class="row">            <div class="col-sm-12">                <div class="ibox float-e-margins">                    <div class="ibox-title"></div>                    <div class="ibox-content">                        <form class="row" id="searchForm">                            <div class="col-md-4">                                <div class="input-group">                                   <span class="input-group-btn">                                       <button type="button" class="btn btn-md btn-primary"                                               style="margin-left: 10px" onclick="units.edit(0)"> <span                                               class="glyphicon glyphicon-plus"></span> 添加</button>                                       <button type="button" class="btn btn-md btn-danger" onclick="units.delete()"                                               style="margin-left: 10px"><span                                               class="glyphicon glyphicon-remove"></span> 删除</button>                                   </span>                                </div>                            </div>                            {{--<div class="col-md-6 pull-right">--}}                            {{--<div class="input-group">--}}                            {{--<input type="text" placeholder="请输入名称" class="input-md form-control"--}}                            {{--name="keyword"--}}                            {{--id="keyword">--}}                            {{--<span class="input-group-btn">--}}                            {{--<button type="button" class="btn btn-md btn-primary"--}}                            {{--onclick="units.search()"> 搜索</button>--}}                            {{--<button type="reset" class="btn btn-md btn-primary" style="margin-left: 10px"--}}                            {{--name="resetBtn"> 重置</button> </span>--}}                            {{--</div>--}}                            {{--</div>--}}                        </form>                        <hr>                        <div class="table-responsive">                            <table id="table" class="table table-condensed" data-mobile-responsive="true"></table>                        </div>                    </div>                </div>            </div>        </div>    </div>    </body>@endsection@section('footer')    <script>        var units = {            search: function () {                tips.selectPage();            },            getIdsBySelections: function () {                var selections = $("#table").bootstrapTable('getSelections');                var ids = [];                $.each(selections, function (inx, val) {                    ids.push(val.id);                });                return ids;            },            edit: function (id) {                var title = '添加';                if (id > 0) {                    title = '编辑';                }                layer.open({                    type: 2,                    content: ['/admin/invoices/' + id],                    area: ['100%', '100%'],                    title: title                });            },            delete: function () {                var ids = units.getIdsBySelections();                if (ids.length === 0) {                    layer.alert('请先选择您所要操作的对象', {icon: 0});                    return;                }                layer.confirm('您确定要删除吗?', {icon: 3, title: '删除信息'}, function (index, layero) {                    layer.close(index);                    tips.ajax({                        url: '/admin/invoices',                        type: 'delete',                        data: {ids: ids},                        tableRefresh: '#table'                    });                });            },            upload: function (id, photo) {                var str = '<div class="ibox-content" id="importLayer">' +                    '<form class="form-horizontal">' +                    '<div class="form-group">' +                    '<label class="col-sm-3 control-label">请选择图片:</label>' +                    '<div class="col-sm-6">' +                    '<input type="file" id="excel_file" class="form-control">' +                    '<input type="hidden" id="excel_path">' +                    '</div>' +                    '<div class="col-sm-2"><button class="btn btn-info" type="button" onclick="units.fileUpload()">上传</button></div>' +                    '</div>' +                    '<div class="form-group">' +                    '<div class="col-sm-6 col-sm-offset-3">' +                    '<img ';                if (photo.length > 10) {                    str += 'src="' + photo + '"';                }                str += ' style="height:150px" id="img">' +                    '</div>' +                    '</div>' +                    '</form>' +                    '</div>';                layer.open({                    type: 1,                    content: str,                    area: ['60%', '50%'],                    btn: ['确定', '取消'],                    title: '拍照上传',                    yes: function (index, layero) {                        var config = {                            url: '/admin/invoices/' + id + '/photo',                            type: 'put',                            data: {photo: $("#img").attr('src')},                            success:function (result) {                                layer.msg(result.message, {icon: 6, time: 1500}, function () {                                    tips.tableRefresh('#table');                                    layer.close(index);                                });                            }                        };                        tips.ajax(config);                    }                });            },            fileUpload: function () {                var config = {                    url: '/admin/tool/upload'                };                config.success = function (result) {                    $("#img").attr('src', result.data.file_url);                    layer.msg(result.message, {icon: 6, time: 1500});                };                tips.fileUpload($("#excel_file")[0], config);            }        };        var config = {};        config.url = '/admin/invoices';        config.columns = [ //字段            {checkbox: true},            {                title: '序号', align: 'center', formatter: function (value, item, index) {                    return index + 1;                }            },            {title: '金额', field: 'amount', align: 'center'},            {title: '抬头', field: 'title', align: 'center'},            {title: '税号', field: 'tax_no', align: 'center'},            {title: '创建时间', field: 'created_at', align: 'center'},            {                title: '操作', field: 'id', align: 'center',                formatter: function (value, row) {                    return (                        '<button onclick="units.edit(' + value + ')" class="btn btn-xs"><span class="glyphicon glyphicon-edit"></span>编辑</button> ' +                        '<button onclick="units.upload(' + value + ',\'' + row.photo + '\')" class="btn btn-xs"><span class="glyphicon glyphicon-edit"></span>上传</button> '                    );                }            }        ];        tips.bootstrapTable(config);    </script>@endsection
 |