连续复制
一键复制
一键打包

数据列表

启用、禁用

<!--{if auth("state") and $vo.status eq 1}-->
    <a class="layui-btn layui-btn-sm layui-btn-warm" data-action="{:url('state')}" data-value="id#{$vo.id};status#0">禁 用</a>
<!--{/if}-->

<!--{if auth("state") and $vo.status eq 0}-->
    <a class="layui-btn layui-btn-sm layui-btn-warm" data-action="{:url('state')}" data-value="id#{$vo.id};status#1">激 活</a>
<!--{/if}-->

多选

表头
<th class='list-table-check-td think-checkbox'>
    <label><input data-auto-none data-check-target='.list-check-box' type='checkbox'></label>
</th>
表行
<td class='list-table-check-td think-checkbox'><label><input class="list-check-box" type='checkbox' value='{$vo.id}'></label></td>

排序

表头
<th class='list-table-sort-td'><button class="layui-btn layui-btn-xs" data-reload type="button">刷 新</button></th>
表行
<td class='list-table-sort-td'><label><input class="list-sort-input" data-action-blur="{:request()->url()}" data-loading="false" data-value="id#{$vo.id};action#sort;sort#{value}" value="{$vo.sort}"></label></td>

angluar操作例子

<form method="post" id="answerForm" class='layui-form layui-card'
      autocomplete="off">

    <div class="layui-card-body">
        <div class="layui-row padding-left-30">
            <table class="layui-table" lay-skin="line">
                <thead>
                <tr>
                    <th class='text-left nowrap'>序号</th>
                    <th class='text-left nowrap'>是否正确</th>
                    <th class='text-left nowrap'>答案内容</th>
                    <th>
                        <a class="layui-btn layui-btn-sm layui-btn-primary" ng-click="add()">添加</a>
                    </th>
                </tr>
                <tr ng-repeat="item in list track by $index">
                    <td class="text-left nowrap">
                    <div class="layui-input-inline">
                        <input name="answer" type="number" min="1" max="10" ng-model="item.sort" class="layui-input inline-block" placeholder="请输入序号" value="{{item.sort}}">
                    </div>
                    </td>
                    <td class="text-left nowrap">
                        <div class="layui-input-inline">
                            <label class="think-radio" ng-click="changeCorrect($index,1)">
                                <input type="radio" ng-checked="item.isCorrect==1" value="1" lay-ignore> 正确
                            </label>
                            <label class="think-radio" ng-click="changeCorrect($index,0)">
                                <input type="radio" ng-checked="item.isCorrect==0" value="0" title="错误" lay-ignore> 错误
                            </label>
                        </div>
                    </td>
                    <td class="text-left nowrap">
                        <div class="layui-input-block margin-0">
                            <input name="answer" required ng-model="item.answer" class="layui-input" placeholder="请输入答案"
                                   value="{{item.answer}}">
                        </div>
                    </td>
                    <td>
                        <div class="layui-input-inline">
                            <a class="layui-icon font-s20 color-red layui-icon-close-fill"
                               ng-click="delete($index)"></a>
                        </div>
                    </td>
                </tr>
                </thead>
            </table>
        </div>
    </div>

    <div class="hr-line-dashed"></div>
    <div class="layui-form-item text-center">
        <button class="layui-btn" type='submit' ng-click="save()">保存数据</button>
        <button class="layui-btn layui-btn-danger" type='button' data-confirm="确定要取消编辑吗?" data-close>取消编辑</button>
    </div>
</form>
<script>
    window.form.render();
    require(['angular'], function () {
        var $form = $('#answerForm').vali();
        var $vali = $form.vali().data('validate');
        var app = angular.module('answerForm', []).run(callback);
        angular.bootstrap(document.getElementById(app.name), [app.name]);

        function callback($rootScope) {
            $rootScope.question_id = '{$Think.get.question_id}'
            $rootScope.list = JSON.parse('{:json_encode($list,JSON_NUMERIC_CHECK)}');
            $rootScope.delete = function (index) {
                $rootScope.list.splice(index, 1);
            };
            $rootScope.add = function () {
                $rootScope.list.push({
                    sort:0,
                    isCorrect: 0,
                    answer: '',
                    id: ''
                });
            };
            $rootScope.changeCorrect = function (index, val) {
                $rootScope.list[index].isCorrect = val;
            };
            $rootScope.save = function () {
                console.log($rootScope.list);
                $vali.checkAllInput();
                if ($form.find('.validate-error').size() > 0) return false;
                // 验证是否有一个正确答案
                var isCorrect = false;
                $rootScope.list.map(function (item) {
                    if (item.isCorrect)
                        isCorrect=true;
                })
                if (!isCorrect){
                    $.msg.error('请至少选择一个正确答案');
                    return false;
                }
                $.form.load('{:url("answer")}', {list: angular.toJson($rootScope.list),question_id:$rootScope.question_id}, 'post');
            };
            // 批量设置数值

        }
    });
</script>