| | |
| | | <div class="layui-inline"> |
| | | <label class="layui-form-label layui-form-label-sm">状态</label> |
| | | <div class="layui-input-inline"> |
| | | <select name="status"> |
| | | <select name="state"> |
| | | <option value="">请选择</option> |
| | | <option value="1">待支付</option> |
| | | <option value="2">待使用</option> |
| | | <option value="3">已使用</option> |
| | | <option value="4">售后</option> |
| | | <option value="5">已评价</option> |
| | | <option value="7">已失效</option> |
| | | </select> |
| | | </div> |
| | | </div> |
| | |
| | | |
| | | <script type="text/html" id="orderActivityOption"> |
| | | <!-- <button class="layui-btn layui-btn-normal layui-btn-sm" type="button" shiro:hasPermission="orderActivity:info" lay-event="orderActivity">详情</button>--> |
| | | <button class="layui-btn layui-btn-danger layui-btn-sm" type="button" shiro:hasPermission="orderActivity:info" lay-event="groupDelete">删除</button> |
| | | <button class="layui-btn layui-btn-danger layui-btn-sm" type="button" shiro:hasPermission="orderActivity:info" lay-event="orderActivityDel">删除</button> |
| | | <!-- <button class="layui-btn layui-btn-danger layui-btn-sm" type="button" shiro:hasPermission="orderActivity:returnOrder" lay-event="returnOrder">售后退款</button>--> |
| | | </script> |
| | | <script type="text/html" id="orderStateOption"> |
| | |
| | | 2: {title: '待使用', color: 'orange'}, |
| | | 3: {title: '已使用', color: 'green'}, |
| | | 4: {title: '售后', color: 'red'}, |
| | | 5: {title: '已评价', color: 'black'}, |
| | | 6: {title: '删除', color: 'black'}, |
| | | 7: {title: '已失效', color: 'black'}, |
| | | }[d.state]; |
| | | }} |
| | | <span class="layui-badge febs-bg-{{state.color}}">{{ state.title }}</span> |
| | |
| | | 1: {title: '余额', color: 'blue'}, |
| | | 2: {title: '微信', color: 'green'}, |
| | | 3: {title: '积分', color: 'orange'}, |
| | | 4: {title: '免费', color: 'red'}, |
| | | 0: {title: '免费', color: 'red'}, |
| | | }[d.payType]; |
| | | }} |
| | | <span class="layui-badge febs-bg-{{payType.color}}">{{ payType.title }}</span> |
| | |
| | | table.on('tool(orderActivityTable)', function (obj) { |
| | | var data = obj.data, |
| | | layEvent = obj.event; |
| | | if (layEvent === 'groupDelete') { |
| | | if (layEvent === 'orderActivityDel') { |
| | | febs.modal.confirm('删除', '确认删除?', function () { |
| | | groupDelete(data.id); |
| | | orderActivityDel(data.id); |
| | | }); |
| | | } |
| | | if (layEvent === 'groupInfo') { |
| | |
| | | }); |
| | | } |
| | | }); |
| | | function groupDelete(id) { |
| | | function orderActivityDel(id) { |
| | | febs.get(ctx + 'admin/happyActivity/activityOrderDel/' + id, null, function (data) { |
| | | febs.alert.success(data.message); |
| | | $query.click(); |
| | |
| | | |
| | | // 初始化表格操作栏各个按钮功能 |
| | | table.on('toolbar(orderActivityTable)', function (obj) { |
| | | console.log("触发事件:", obj.event); // 调试信息 |
| | | let event = obj.event; |
| | | let id = obj.config.id; |
| | | let checkStatus = table.checkStatus(id); |
| | | if(event === 'checkOrder'){ |
| | | |
| | | if (event === 'checkOrder') { |
| | | let data = checkStatus.data; |
| | | let ids = []; |
| | | for(let i = 0;i < data.length;i++){ |
| | | if(data[i].state != 2){ |
| | | febs.alert.warn('请选择待使用的订单'); |
| | | return; |
| | | }else{ |
| | | ids.push(data[i].id); |
| | | } |
| | | } |
| | | console.log(ids); |
| | | if(ids == null || ids == ""){ |
| | | |
| | | // 校验 data 是否为空或未定义 |
| | | if (!Array.isArray(data) || data.length === 0) { |
| | | febs.alert.warn('请选择需要核销的订单'); |
| | | return; |
| | | } |
| | | $.ajax({ |
| | | 'url':ctx + 'admin/happyActivity/checkOrder', |
| | | 'type':'post', |
| | | 'dataType':'json', |
| | | 'headers' : {'Content-Type' : 'application/json;charset=utf-8'}, //接口json格式 |
| | | 'traditional': true,//ajax传递数组必须添加属性 |
| | | 'data':ids, |
| | | 'success':function (data) { |
| | | if(data.code==200){ |
| | | febs.alert.success('操作成功'); |
| | | $query.click(); |
| | | }else{ |
| | | febs.alert.warn(data.message); |
| | | } |
| | | }, |
| | | 'error':function () { |
| | | febs.alert.warn('服务器繁忙'); |
| | | |
| | | let ids = []; |
| | | let hasInvalidOrder = false; |
| | | |
| | | // 遍历数据,筛选符合条件的订单 |
| | | for (let i = 0; i < data.length; i++) { |
| | | if (data[i].state !== 2) { |
| | | hasInvalidOrder = true; |
| | | break; // 提前中断循环,避免无意义的继续遍历 |
| | | } else { |
| | | ids.push(data[i].id); |
| | | } |
| | | }) |
| | | } |
| | | |
| | | if (hasInvalidOrder) { |
| | | febs.alert.warn('请选择待使用的订单'); |
| | | return; |
| | | } |
| | | |
| | | if (ids.length === 0) { // 正确判断数组是否为空 |
| | | febs.alert.warn('请选择需要核销的订单'); |
| | | return; |
| | | } |
| | | |
| | | // 封装 AJAX 请求为独立函数 |
| | | function sendCheckOrderRequest(ids, successCallback, errorCallback) { |
| | | $.ajax({ |
| | | url: ctx + 'admin/happyActivity/checkOrder', // 硬编码路径建议提取为配置项 |
| | | type: 'post', |
| | | dataType: 'json', |
| | | headers: { 'Content-Type': 'application/json;charset=utf-8' }, |
| | | traditional: true, |
| | | data: JSON.stringify(ids), // 确保传递的是 JSON 格式 |
| | | success: function (response) { |
| | | if (response.code === 200) { |
| | | successCallback(response); |
| | | } else { |
| | | errorCallback(response.message); |
| | | } |
| | | }, |
| | | error: function (xhr, status, error) { |
| | | errorCallback(`服务器繁忙: ${error}`); // 捕获具体错误信息 |
| | | } |
| | | }); |
| | | } |
| | | |
| | | // 调用封装的请求函数 |
| | | sendCheckOrderRequest(ids, |
| | | function onSuccess(response) { |
| | | febs.alert.success('操作成功'); |
| | | $query.click(); |
| | | }, |
| | | function onError(message) { |
| | | febs.alert.warn(message); |
| | | } |
| | | ); |
| | | } |
| | | }); |
| | | |
| | | |
| | | |
| | | function initorderActivityTable() { |
| | |
| | | toolbar:"#orderActivityToolbar", |
| | | defaultToolbar:[], |
| | | cols: [[ |
| | | {type: 'checkbox'}, |
| | | {type: 'numbers', title: '', width: 80}, |
| | | {title: '操作', toolbar: '#orderActivityOption', minWidth: 200, align: 'center'}, |
| | | {field: 'name', title: '名称', minWidth: 100,align:'center'}, |
| | |
| | | ]] |
| | | }); |
| | | } |
| | | |
| | | form.on('switch(hotStateSwitch)', function (data) { |
| | | if (data.elem.checked) { |
| | | groupState(data.value,1); |
| | | } else { |
| | | groupState(data.value,1); |
| | | } |
| | | }) |
| | | |
| | | form.on('switch(groupStatusSwitch)', function (data) { |
| | | if (data.elem.checked) { |
| | | groupState(data.value,2); |
| | | } else { |
| | | groupState(data.value,2); |
| | | } |
| | | }) |
| | | function groupState(id,type) { |
| | | febs.get(ctx + 'admin/happyActivity/groupState/' + id+'/' + type, null, function (data) { |
| | | febs.alert.success(data.message); |
| | | $query.click(); |
| | | }); |
| | | } |
| | | |
| | | |
| | | |
| | | // 查询按钮 |
| | | $query.on('click', function () { |