<!DOCTYPE html>
<html lang="en">
<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">
</head>
<style type="text/css">
    .LAY-btns .layui-nav {padding-left:0;padding-right:10px;top:-4px;margin: 0 10px;border: 0;background-color: #009688;}
    .LAY-btns .layui-nav .layui-nav-item{line-height: 30px;}
    .LAY-btns .layui-nav .layui-nav-child{top:34px;}
    .LAY-btns .layui-nav .layui-nav-bar{display: none;}
    .LAY-btns .layui-nav .layui-nav-child dd.layui-this a{color:#333;background-color:#fff;}
    .LAY-btns .layui-nav .layui-nav-child dd.layui-this a:hover {background-color: #f2f2f2;color: #000;}
  </style>
<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">
                    <table class="layui-hide" id="datagrid" lay-filter="datagrid-operate"></table>
                    <script type="text/html" id="datagrid-operate-bar">
                      <a class="layui-btn layui-btn-xs" id="view" lay-event="view">查看</a>
                      {{#  if(d.check_status ==0){ }}
                      <a class="layui-btn layui-btn-danger layui-btn-xs" data-permission="purchase.add_purchase_invoice" id="delete" lay-event="delete">删除</a>
                      {{#  } }}
                    </script>
                  </div>
                </div>
            </div>
        </div>
    </div>

    <script src="../../layuiadmin/layui/layui.js?t=1"></script>
    <script>
        var _params = ''
        layui.config({
            base: '../../../layuiadmin/' //静态资源所在路径
        }).extend({
            index: 'lib/index' //主入口模块
        }).use(['index', 'table','laydate', 'form', 'upload', 'utils'], function () {
            var $ = layui.$;
            var table = layui.table
                ,laydate = layui.laydate
                ,form = layui.form;

            var id = layui.view.getParameterByName('id');
            table.render({
              elem: '#datagrid'
              ,url: '/purchase/purchase_invoice/images/?id=' + id
              ,cols: [[
                {field:'image_name', title:'图片', width:500}
                ,{width:150, align:'left', fixed: 'right', toolbar: '#datagrid-operate-bar'}
              ]]
              ,page: true
              ,height: 'full-104'
              ,done:function () {
                    layui.index.removeNoPermButtons();
                }
              });
            //监听工具条
            table.on('tool(datagrid-operate)', function(obj){
              var data = obj.data;
              if(obj.event === 'view'){
                  layer.open({
                  type: 2,
                  title: '查看图片',
                  area: ['90%', '90%'],
                  content: '../..' + data.image_url
                });
              }else if(obj.event === 'delete'){
                  if (data.check_status == 1) {
                      layer.msg('发票已审核，不允许删除');
                      return false;
                  }
                  layer.confirm('确定要删除吗？', function(index){
                      layer.close(index);
                      layui.admin.req({
                         url: '/purchase/purchase_invoice/del_image/?id='+data.id
                         ,done: function(res){
                             table.reload('datagrid',{});
                         }
                      });
                  });
              }
            });

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