| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159 |
- <div class="layui-fluid">
- <div class="layui-row layui-col-space15">
- <div class="layui-col-md12">
- <div class="layui-form layui-form-pane" lay-filter="{$lay_table}">
- <div class="layui-card">
- <div class="layui-card-header">活动信息</div>
- <div class="layui-card-body" pad15>
- <input type="hidden" name="id" value="{:array_get($info,'id')}">
- <div class="layui-form-item">
- <label class="layui-form-label"><span style="color:#f90c05;">*</span>标题</label>
- <div class="layui-input-block">
- <input type="text" name="title" value="{:array_get($info,'title')}"
- lay-verify="required"
- placeholder="请输入标题" autocomplete="off"
- class="layui-input">
- </div>
- </div>
- <div class="layui-form-item">
- <label class="layui-form-label"><span style="color:#f90c05;">*</span>状态</label>
- <div class="layui-input-block">
- {volist name="status_list" id="v"}
- <input type="radio" name="status" value="{$key}" title="{$v}"
- {eq name=":array_get($info,'status',1)" value="$key" }checked{/eq}>
- {/volist}
- </div>
- </div>
- <div class="layui-form-item">
- <label class="layui-form-label"><span style="color:#f90c05;">*</span>时间</label>
- <div class="layui-input-block">
- <input type="text" name="start_time" id="start_time"
- value="{:array_get($info,'start_time')}" lay-verify="required"
- placeholder="请选择..." autocomplete="off" class="layui-input">
- </div>
- </div>
- </div>
- <div class="layui-card-header">座位设置</div>
- <div class="layui-card-body" pad15>
- <div>
- <button class="layui-btn layuiadmin-btn" id="add-table" type="button">添加</button>
- </div>
- <form id="form">
- <table class="layui-table">
- <colgroup>
- <col width="400">
- <col width="100">
- <col width="100">
- </colgroup>
- <thead>
- <tr>
- <th>排数</th>
- <th>人数</th>
- <th>操作</th>
- </tr>
- </thead>
- <tbody id="tb">
- </tbody>
- </table>
- </form>
- </div>
- </div>
- <div class="layui-form-item">
- <div class="layui-input-block">
- <input type="button" lay-submit lay-filter="{$lay_btn}" value="确认提交" class="layui-btn">
- </div>
- </div>
- </div>
- </div>
- </div>
- </div>
- <script>
- layui.use(['index', 'form', 'layedit', 'upload', 'laydate'], function () {
- const $ = layui.$;
- const admin = layui.admin;
- const laydate = layui.laydate;
- const form = layui.form;
- form.render();
- laydate.render({
- elem: '#start_time',
- type: 'datetime'
- });
- form.on('submit({$lay_btn})', function (obj) {
- const index = parent.layer.getFrameIndex(window.name);
- admin.req({
- url: "{:url('seat/editSeat')}",
- type: 'post',
- data: obj.field,
- done: function (res) {
- layer.msg("提交成功", {
- icon: 1
- });
- parent.layui.table.reload('lay-seat-index-table'); //重载表格
- parent.layer.close(index);
- }
- });
- });
- let data = {$seat_list};
- function createTable() {
- let html = "";
- data.forEach((v, k) => {
- html += `<tr>
- <td>第${k + 1}排</td>
- <td>
- <input placeholder="人数"
- name="seat_list[]"
- lay-verify="required"
- value="${v}"
- type="number"
- class="layui-input"/>
- </td>
- <td>
- <button class="layui-btn layui-btn-danger layuiadmin-btn delete-table" type="button" data-index="${k}">删除</button>
- </td>
- </tr>`;
- });
- $('#tb').html(html);
- }
- createTable();
- $('#add-table').click(function () {
- data = getFormData();
- data.push("");
- createTable();
- });
- $("#tb").on('click', '.delete-table', function () {
- let index = $(this).data('index');
- if (data.length <= 1) {
- return false;
- }
- data = getFormData();
- data.splice(index, 1);
- createTable();
- });
- function getFormData() {
- let arr = $('#form').serializeArray();
- if (arr.length === 0) {
- return arr;
- }
- let res = [];
- arr.map((v, k) => {
- res.push(v.value);
- })
- return res;
- }
- });
- </script>
|