123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186 |
- <!DOCTYPE html>
- <html lang="en" >
- <head>
- <meta charset="utf-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <meta http-equiv="X-UA-Compatible" content="IE=edge">
- <meta name="keywords" content="">
- <meta name="description" content="">
- <title text="数据字典"></title>
- <link rel="stylesheet" href="../../../component/pear/css/pear.css">
- <link rel="stylesheet" href="../../../admin/css/other/user.css" />
- </head>
- <body class="pear-container">
- <div class="layui-card">
- <div class="layui-card-body">
- <form class="layui-form">
- <div class="layui-form-item">
- <label class="layui-form-label">字典名称</label>
- <div class="layui-input-inline">
- <input type="text" name="name" placeholder="" class="layui-input">
- </div>
- <label class="layui-form-label">字典编码</label>
- <div class="layui-input-inline">
- <input type="text" name="type" placeholder="" class="layui-input">
- </div>
- <button class="pear-btn pear-btn-md-0 pear-btn-primary" lay-submit lay-filter="query">
- <i class="layui-icon layui-icon-search"></i>
- 查询
- </button>
- <button type="reset" class="pear-btn pear-btn-md-0">
- <i class="layui-icon layui-icon-refresh"></i>
- 重置
- </button>
- </div>
- </form>
- </div>
- </div>
- <div class="layui-card">
- <div class="layui-card-body">
- <table id="table" lay-filter="table"></table>
- </div>
- </div>
- </body>
- <script type="text/html" id="toolbar">
- <button class="pear-btn pear-btn-primary pear-btn-md" lay-event="add">
- <i class="pear-icon pear-icon-add"></i>
- 新增
- </button>
- <button class="pear-btn pear-btn-danger pear-btn-md" lay-event="batchRemove">
- <i class="pear-icon pear-icon-ashbin"></i>
- 删除
- </button>
- </script>
- <script type="text/html" id="bar">
- <a class="cool-line-btn cool-bg-blue" lay-event="edit">编辑</a>
- <div class="cool-line-divider"></div>
- <a class="cool-line-btn cool-bg-blue" lay-event="remove">删除</a>
- </script>
- <script type="text/html" id="enableTpl">
- <input type="checkbox" name="enable" value="{{d.id}}" lay-skin="switch"
- lay-text="启用|禁用" lay-filter="switch" {{ d.enable== 1 ? 'checked' : '' }} />
- </script>
- <script type="text/html" id="createTimeTpl">
- {{layui.util.toDateString(d.createTime, 'yyyy-MM-dd HH:mm:ss')}}
- </script>
- <script type="text/html" id="typeTpl">
- <a href="javascript:;" style="cursor: pointer;color: #409eff;" lay-event="toItem" >{{d.type}}</a>
- </script>
- <script src="../../../component/layui/layui.js"></script>
- <script src="../../../component/pear/pear.js"></script>
- <script>
- layui.use(['request', 'table', 'form', 'popup', 'common'], function () {
- var request = layui.request,
- table = layui.table,
- form = layui.form,
- popup = layui.popup,
- common = layui.common;
- var MODULE_PATH = "/system/dict/v1/";
- request.tableRender({
- url: MODULE_PATH,
- cols: [
- [
- {type: 'checkbox'},
- {title: '字典名称', field: 'name', align: 'center'},
- {title: '字典编码', field: 'type', align: 'center', templet: '#typeTpl'},
- {title: '字典描述', field: 'remark', align: 'center', templet: '#sexTpl'},
- {title: '状态', field: 'enable', align: 'center', templet: '#enableTpl'},
- {title: '创建时间', field: 'createTime', align: 'center', templet: '#createTimeTpl',},
- {title: '操作', toolbar: '#bar', align: 'center'}
- ]
- ]
- });
- table.on('tool(table)', function (obj) {
- if (obj.event === 'toItem') {
- f.item(obj);
- }
- else if (obj.event === 'edit') {
- f.edit(obj);
- }
- else if (obj.event === 'remove') {
- f.remove(obj.data.id)
- }
- });
- table.on('toolbar(table)', function (obj) {
- if (obj.event === 'add') {
- f.save();
- }
- else if (obj.event === 'batchRemove') {
- f.remove(common.checkField(obj,'id'));
- }
- });
- form.on('submit(query)', function (data) {
- refresh(data.field);
- return false;
- });
- form.on('switch(switch)', function (obj) {
- request.http({
- url: MODULE_PATH,
- type: 'put',
- data: {id: obj.value, enable: obj.elem.checked? 1: 0},
- loading: true,
- success: function (result) {
- refresh();
- if (result.success) {
- popup.success(result.msg);
- } else {
- popup.failure(result.msg);
- }
- }
- });
- });
- var f = {
- save: function() {
- layer.open({
- type: 2,
- title: '新增',
- shade: 0.1,
- area: ['500px', '400px'],
- content: ['add.html', 'no']
- });
- },
- item: function(obj) {
- var url = 'view/system/dict/item/main.html?type='+ obj.data.type,
- layId = 'dict_item'+ obj.data.type,
- title = '字典项管理';
- parent.layui.tab.addTabOnlyByElem('content',{id: layId, title: title, url: url, close: true})
- },
- edit: function(obj) {
- layer.open({
- type: 2,
- title: '修改',
- shade: 0.1,
- area: ['500px', '400px'],
- content: ['add.html?id=' + obj.data.id, 'no']
- });
- },
- remove: function(ids) {
- request.http({
- url: MODULE_PATH,
- type: 'delete',
- data: {ids: ids},
- success: function (result) {
- refresh();
- if (result.success) {
- popup.success(result.msg);
- } else {
- popup.failure(result.msg);
- }
- }
- })
- }
- };
- window.refresh = function (param) {
- table.reload('table', {where: param});
- };
- })
- </script>
- </html>
|