123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174 |
- {include file="common/header"/}
- <style>
- .yourclass {
- display: block;
- }
- .canel {
- display: none;
- }
- </style>
- <div class="LM-container">
- <div class="LM-main">
- <fieldset class="layui-elem-field layui-field-title">
- <legend>会员等级列表</legend>
- <blockquote class="layui-elem-quote">
- <div class="LM-table">
- <div class="layui-form-item">
- <label class="layui-form-label">等级</label>
- <div class="layui-input-inline">
- <input type="number" name="level" id="level" required lay-verify="required" placeholder="请输入等级" autocomplete="off" class="layui-input">
- </div>
- <label class="layui-form-label">优惠比例</label>
- <div class="layui-input-inline">
- <input type="number" name="bili" id="bili" required lay-verify="required" placeholder="请输入优惠比例" autocomplete="off" class="layui-input">
- </div>
- <button type="button" class="layui-btn layui-btn-normal" lay-submit="" lay-filter="add" id="add_level">添加</button>
- </div>
- </div>
- </blockquote>
- </fieldset>
- <table class="layui-table" id="list" lay-filter="list"></table>
- </div>
- </div>
- <script type="text/html" id="barDemo">
- <input type="button" class="layui-btn layui-btn-xs" lay-event="del" value="删除">
- </script>
- {include file="common/footer"/}
- <script>
- let redIndex=0;
- let user_id=0;
- let vip_level=0;
- layui.use(['form', 'table'], function () {
- var $ = layui.jquery,
- form = layui.form,
- table = layui.table;
- var tableIn = table.render({
- elem: '#list',
- url: '{:url("update_level")}',
- method: 'post',
- title: '用户数据表',
- // toolbar: '#toolbar', //开启头部工具栏,并为其绑定左侧模板
- defaultToolbar: ['filter', 'exports', 'print', { //自定义头部工具栏右侧图标。如无需自定义,去除该参数即可
- title: '提示'
- , layEvent: 'LAYTABLE_TIPS'
- , icon: 'layui-icon-tips'
- }],
- cols: [[
- // {checkbox: true, fixed: true},
- {field: 'id', title: 'ID', width: 80, sort: true},
- {field: 'level', title: '等级', width: 200,edit: 'text'},
- {field: 'bili', title: '优惠比例', width: 200,edit: 'text'},
- {title: '操作', width: 150, toolbar: '#barDemo', align: "center"},
- ]],
- limits: [10, 15, 20, 25, 50, 100],
- limit: 15,
- page: true
- });
- //监听单元格编辑
- table.on('edit(list)', function(obj){
- var value = obj.value //得到修改后的值
- ,data = obj.data //得到所在行所有键值
- ,field = obj.field; //得到字段
- // layer.msg('[ID: '+ data.id +'] ' + field + ' 字段更改为:'+ value);
- let da={
- id:data.id,
- field:field,
- value:value
- }
- $.post("{:url('update_user_level')}", da, function (res) {
- if (res.code ==200) {
- layer.msg(res.msg, {time: 1000, icon: 1});
- } else {
- tableIn.reload()
- layer.msg(res.msg, {time: 1000, icon: 2});
- }
- },"json");
- });
- table.on('tool(list)', function (obj) {
- var data = obj.data;
- if (obj.event === 'del') {
- layer.confirm('您确定要删除吗', function (index) {
- loading = layer.load(1, {shade: [0.1, '#fff']});
- $.post("{:url('del_user_level')}", {id: data.id}, function (res) {
- layer.close(loading);
- layer.close(index);
- if (res.code ==200) {
- layer.msg(res.msg, {time: 1000, icon: 1});
- obj.del();
- } else {
- layer.msg(res.msg, {time: 1000, icon: 2});
- }
- },"json");
- });
- }
- });
- form.on('switch(status)', function (data) {
- // 修改状态
- loading = layer.load(1, {shade: [0.1, '#fff']});
- $.post("{:url('fenhao')}", {id: data.value}, function (res) {
- layer.close(loading);
- if (res.code == 200) {
- layer.msg(res.msg, {time: 1000, icon: 1});
- } else {
- layer.msg(res.msg, {time: 1000, icon: 2});
- }
- }, "json");
- });
- $("#add_level").click(function () {
- let data={
- level:$("#level").val(),
- bili:$("#bili").val(),
- }
- if (!data.level){
- layer.msg("请输入等级", {time: 1000, icon: 1});
- return;
- }
- loading = layer.load(1, {shade: [0.1, '#fff']});
- $.post("{:url('add_user_level')}", data, function (res) {
- layer.close(loading);
- if (res.code == 200) {
- layer.msg(res.msg, {time: 1000, icon: 1});
- tableIn.reload()
- } else {
- layer.msg(res.msg, {time: 1000, icon: 2});
- }
- }, "json");
- })
- $('#search').click(function () {
- var $keys = $('#keys').val();
- if (!$keys) {
- return layer.msg('请输入关键词');
- }
- tableIn.reload({page: {page: 1}, where: {keys: $keys}});
- })
- });
- </script>
|