#include("/view/include/list.html")
#@layout()

#define main()
	#include("filter.html")
	<script type="text/html" id="toolbar">
        <div class="layui-btn-container">
            <button class="layui-btn layui-btn-sm" lay-event="form" url="add.html"> 添加 </button>
            <button class="layui-btn layui-btn-sm layui-btn-danger" lay-event="ajax_select" url="delete"> 删除选择 </button>
        </div>
    </script>
	<script type="text/html" id="tool">
        <a class="layui-btn layui-btn-xs " lay-event="form" url="edit.html">编辑</a>
        <a class="layui-btn layui-btn-xs layui-btn-danger" lay-event="ajax" url="delete">删除</a>
    </script>
		<script type="text/html" id="tpl_db_type">
        	{{= dict_db_type(d.dbType) }}
    	</script>
		<script type="text/html" id="tpl_field_type">
        	{{= dict_field_type(d.type) }}
    	</script>
		<script type="text/html" id="tpl_nullable">
        	{{= dict_boolean(d.nullable) }}
    	</script>
		<script type="text/html" id="tpl_model">
        	{{#(SHARP)  if(d.model){ }}
    			{{ d.model.title }}
  			{{#(SHARP)  } }} 
    	</script>
		<script type="text/html" id="tpl_len">
        	{{#(SHARP) if(d.len > 0){ }}
    			{{ d.len }}
  			{{#(SHARP)  } }} 
			{{#(SHARP)  if(d.scale > 0){ }}
    			,{{ d.scale }}
  			{{#(SHARP)  } }} 
    	</script>

#end

#define script()
<script>
    layui.use(['curd'], function () {
        var $ = layui.jquery,
            curd = layui.curd,
            layuimini = layui.layuimini;

        var listTable = curd.init({
            elem: '#listTable',
            url: '#(CONTEXT)#(_module)/#(_controller)/lists',
            cols: [[
                {type: "checkbox", width: 50, fixed: "left"},
                {field: 'modelId', minWidth: 120, title: '所属模型', templet: '#tpl_model'},
                {field: 'code', minWidth: 150, title: '字段代码'},
                {field: 'title', minWidth: 150, title: '字段名称'},
                {field: 'dbType', minWidth: 100, title: '数据类型', templet: '#tpl_db_type'},
                {field: 'type', minWidth: 100, title: '字段类型', templet: '#tpl_field_type'},
                {field: 'len', minWidth: 100, title: '长度', templet: '#tpl_len'},
                {field: 'nullable', minWidth: 100, title: '空值',templet:"#tpl_nullable"},
                {field: 'defaults', minWidth: 100, title: '默认值'},
                {title: '操作', width: 150, templet: '#tool', fixed: "right", align: "center"}
            ]]
        });
    });       
</script>
#end