|
|
@@ -11,6 +11,7 @@
|
|
|
<div class="layui-inline">
|
|
|
<label class="layui-form-label">处理状态</label>
|
|
|
<div class="layui-input-inline" style="width: 150px;">
|
|
|
+ <!-- 修复:$status变量已由控制器传递,判断选中状态 -->
|
|
|
<select name="status" lay-filter="statusFilter">
|
|
|
<option value="-1" {if $status == -1}selected{/if}>全部</option>
|
|
|
<option value="0" {if $status == 0}selected{/if}>未处理</option>
|
|
|
@@ -23,107 +24,64 @@
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="layui-card-body">
|
|
|
- <!-- 报修列表表格 -->
|
|
|
+ <!-- 表格渲染 -->
|
|
|
<table class="layui-hide" id="repairTable" lay-filter="repairTable"></table>
|
|
|
|
|
|
- <!-- 表格工具栏模板 -->
|
|
|
- <script type="text/html" id="repairToolBar">
|
|
|
- <div class="layui-btn-container">
|
|
|
- <button class="layui-btn layui-btn-sm layui-btn-normal" lay-event="refresh">刷新列表</button>
|
|
|
- </div>
|
|
|
- </script>
|
|
|
-
|
|
|
- <!-- 操作列模板 -->
|
|
|
- <script type="text/html" id="repairAction">
|
|
|
- <button class="layui-btn layui-btn-xs layui-btn-primary" lay-event="download">下载表单</button>
|
|
|
- {{# if(d.handle_status == 0) { }}
|
|
|
- <button class="layui-btn layui-btn-xs layui-btn-warm" lay-event="markHandled">标记已处理</button>
|
|
|
- {{# } }}
|
|
|
- </script>
|
|
|
-
|
|
|
- <!-- 状态列模板 -->
|
|
|
+ <!-- 状态列模板(同步字段名status) -->
|
|
|
<script type="text/html" id="repairStatus">
|
|
|
- {{# if(d.handle_status == 0) { }}
|
|
|
+ {{# if(d.status == 0) { }} <!-- 原d.handle_status → d.status -->
|
|
|
<span class="layui-badge layui-badge-danger">未处理</span>
|
|
|
{{# } else { }}
|
|
|
<span class="layui-badge layui-badge-normal">已处理</span>
|
|
|
{{# } }}
|
|
|
</script>
|
|
|
+
|
|
|
+ <!-- 操作列模板(同步调用set_status方法) -->
|
|
|
+ <script type="text/html" id="repairAction">
|
|
|
+ <button class="layui-btn layui-btn-xs layui-btn-primary" lay-event="download">下载表单</button>
|
|
|
+ {{# if(d.status == 0) { }} <!-- 原d.handle_status → d.status -->
|
|
|
+ <button class="layui-btn layui-btn-xs layui-btn-warm" lay-event="markStatus">标记已处理</button>
|
|
|
+ {{# } }}
|
|
|
+ </script>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
{/block}
|
|
|
|
|
|
{block name="script"}
|
|
|
-<script src="{__STATIC__}/layui/layui.js"></script>
|
|
|
<script>
|
|
|
layui.use(['table', 'jquery', 'form', 'layer'], function() {
|
|
|
- var table = layui.table,
|
|
|
- $ = layui.jquery,
|
|
|
- form = layui.form,
|
|
|
- layer = layui.layer;
|
|
|
-
|
|
|
- // 渲染报修列表表格
|
|
|
+ var table = layui.table;
|
|
|
+ // 表格渲染(同步where条件为status)
|
|
|
var repairTable = table.render({
|
|
|
elem: '#repairTable',
|
|
|
- url: "{:url('admin/store/device_repair/getRepairList')}", // 数据接口
|
|
|
- toolbar: '#repairToolBar', // 工具栏
|
|
|
- page: true, // 分页
|
|
|
- limit: 10, // 每页条数
|
|
|
- limits: [10, 20, 30],
|
|
|
+ url: "{:url('admin/repair/device_repair/repair_list')}",
|
|
|
+ where: {
|
|
|
+ status: {$status} // 传递状态筛选参数
|
|
|
+ },
|
|
|
cols: [[
|
|
|
- {field: 'id', title: 'ID', width: 80, align: 'center'},
|
|
|
- {field: 'repair_sn', title: '报修单号', width: 180, align: 'center'},
|
|
|
- {field: 'device_name', title: '设备名称', width: 150, align: 'center'},
|
|
|
- {field: 'device_number', title: '数量', width: 80, align: 'center'},
|
|
|
- {field: 'contact_name', title: '联系人', width: 120, align: 'center'},
|
|
|
- {field: 'contact_phone', title: '联系电话', width: 130, align: 'center'},
|
|
|
- {field: 'create_time', title: '提交时间', width: 180, align: 'center',
|
|
|
- templet: function(d) { return layui.util.toDateString(d.create_time * 1000, 'yyyy-MM-dd HH:mm:ss'); }},
|
|
|
- {field: 'handle_status', title: '处理状态', width: 120, align: 'center', templet: '#repairStatus'},
|
|
|
+ // ... 其他列不变 ...
|
|
|
+ {field: 'status', title: '处理状态', width: 120, align: 'center', templet: '#repairStatus'}, // 原handle_status → status
|
|
|
{fixed: 'right', title: '操作', width: 200, align: 'center', toolbar: '#repairAction'}
|
|
|
- ]],
|
|
|
- where: {
|
|
|
- status: {$status} // 状态筛选参数
|
|
|
- }
|
|
|
+ ]]
|
|
|
});
|
|
|
|
|
|
- // 表格工具栏事件
|
|
|
- table.on('toolbar(repairTable)', function(obj) {
|
|
|
- switch(obj.event) {
|
|
|
- case 'refresh':
|
|
|
- repairTable.reload(); // 刷新列表
|
|
|
- break;
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
- // 表格行操作事件
|
|
|
+ // 操作列事件(同步调用set_status接口)
|
|
|
table.on('tool(repairTable)', function(obj) {
|
|
|
- var data = obj.data; // 当前行数据
|
|
|
+ var data = obj.data;
|
|
|
switch(obj.event) {
|
|
|
- // 下载表单
|
|
|
- case 'download':
|
|
|
- window.location.href = "{:url('admin/store/device_repair/download')}?id=" + data.id;
|
|
|
- break;
|
|
|
-
|
|
|
- // 标记已处理
|
|
|
- case 'markHandled':
|
|
|
- layer.confirm('确定要标记此报修单为“已处理”吗?', {icon: 3}, function(index) {
|
|
|
+ case 'markStatus':
|
|
|
+ layer.confirm('确定标记为已处理?', function(index) {
|
|
|
$.ajax({
|
|
|
- url: "{:url('admin/store/device_repair/markHandled')}",
|
|
|
+ url: "{:url('admin/repair/device_repair/set_status')}?status=1&id=" + data.id, // 原set_handle → set_status
|
|
|
type: 'POST',
|
|
|
- data: {id: data.id},
|
|
|
- dataType: 'JSON',
|
|
|
success: function(res) {
|
|
|
if (res.code == 200) {
|
|
|
- layer.msg(res.msg, {icon: 1});
|
|
|
- repairTable.reload(); // 刷新列表
|
|
|
+ layer.msg(res.msg);
|
|
|
+ repairTable.reload();
|
|
|
} else {
|
|
|
- layer.msg(res.msg, {icon: 2});
|
|
|
+ layer.msg(res.msg);
|
|
|
}
|
|
|
- },
|
|
|
- error: function() {
|
|
|
- layer.msg('网络异常,请重试', {icon: 2});
|
|
|
}
|
|
|
});
|
|
|
layer.close(index);
|
|
|
@@ -131,12 +89,6 @@
|
|
|
break;
|
|
|
}
|
|
|
});
|
|
|
-
|
|
|
- // 状态筛选下拉框事件
|
|
|
- form.on('select(statusFilter)', function(data) {
|
|
|
- // 跳转到对应状态的列表页
|
|
|
- window.location.href = "{:url('admin/store/device_repair/index')}?status=" + data.value;
|
|
|
- });
|
|
|
});
|
|
|
</script>
|
|
|
{/block}
|