yujian
2020-05-17 63da7625fdca6a7de96d6afd1e76ebb70a0516b8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8" />
        <meta http-equiv="X-UA-Compatible" content="chrome=1"/>
        <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no"/>
        <title>今日推荐</title>
        <link rel="stylesheet" type="text/css" href="../../../../css/doui.min.css"/>
        <script src="../../../../js/doui.min.js" type="text/javascript" charset="utf-8"></script>
        <script src="../../../../js/requestHost.js" type="text/javascript" charset="utf-8"></script>
        <script type="text/javascript">
            doui.importLoad({
                importArray: [
                    // 雷打不动
                    getHostPath() + "js/jquery.min.js",
                    getHostPath() + "js/vue.min.js",
                    // 字体图标
                    getHostPath() + "fontAdmin/iconfont.css",
                    getHostPath() + "font/iconfont.css",
                    // dom模板
                    getHostPath() + "css/admin-all.css",
                    getHostPath() + "js/admin-creat.js",
                ],
            });
        </script>
    </head>
    <body class="fontPC">
        <div class="winSizeBox">
            
            <!-- =============================================================== 搜索筛选(顶部) -->
            <div id="thisHeader" style="width:7.5rem;"></div>
            
            <!-- =============================================================== 表格 -->
            <div id="thisTable" class="admin-main-overHeader"></div>
            
        </div>
    </body>
</html>
 
 
<script type="text/javascript">
    
    // ==================================================================================== 页面数据
    doui.onReady({
        success: function ()
        {
            // ----------------------------------------------------- 顶部
            // 生成顶部筛选项dom
            adminDom.header.creat({ el: "#thisHeader" });
            // 输入搜索
            adminDom.header.input({ placeholder: "标题 / 内容", });
            // 筛选项
            adminDom.header.screen({
                show: true,
                list: [
                    {
                        title: "推送状态", 
                        muchCheck: false, // 是否可以多选
                        child: [
                            { key: [1], value: "已推送", check: false },
                            { key: [0], value: "未推送", check: false },
                        ],
                        input: { type: "number", num: 0 },
                    }
                ],
            });
            
            
            // ----------------------------------------------------- 表格
            // 表格dom创建
            adminDom.table.creat({
                el: "#thisTable",
                // 搜索触发
                touchSearch: function (optC) 
                {
                    doui.showLoading({ content: "加载列表" });
                    doui.request({
                        type: "jsonp",
                        url: gethttp() + "/admin/new/api/v1/pushgoods/query",
                        data: {
                            pageIndex: optC.table.page, // 页码
                            pageSize: optC.table.pageSize, // 每页数量
                            key: optC.input[0].result, // 搜索关键字
                            state: optC.screen[0].result[0], // 只看哪种用户
                        },
                        success: function (res)
                        {
                            doui.hideLoading();
                            if (res.code != 0) { doui.showToast({ content: res.msg }); }
                            else 
                            {
                                // 申明 表格内容数据
                                var mo_tr = []; // tr组
                                for (var i = 0, mo = res.data.result_list; i < mo.length; i++)
                                {
                                    // 当前行
                                    var thatTr = {
                                        check: false,
                                        td: [
                                            { title: "ID", key: mo[i].id, value: mo[i].id },
                                            { title: "标题", key: mo[i].title, value: mo[i].title },
                                            { title: "内容", key: mo[i].content, value: mo[i].content },
                                            { title: "状态", key: mo[i].isPush, value: mo[i].isPush },
                                            { title: "预设时间", key: mo[i].controlTime_str, value: mo[i].controlTime_str, "class": "font13 font-gray" },
                                            { title: "推送时间", key: mo[i].pushTime, value: mo[i].pushTime, "class": "font13 font-gray" },
                                            { title: "安卓推送版本", key: mo[i].listAndroid, value: "(未返回)", "class": "font-gray" },
                                            { title: "IOS推送版本", key: mo[i].listIOS, value: "(未返回)", "class": "font-gray" },
                                            { title: "推送用户", key: mo[i].uid, value: mo[i].uid },
                                        ],
                                    };
                                    // 状态分析
                                    if (thatTr.td[3].key == 1) { thatTr.td[3].value = "已推送"; thatTr.td[3]["class"] = "font-green"; }
                                    else if (thatTr.td[3].key == 0) { thatTr.td[3].value = "未推送"; thatTr.td[3]["class"] = "font-orange"; }
                                    else if (thatTr.td[3].key == 2) { thatTr.td[3].value = "推送失败"; thatTr.td[3]["class"] = "font-red"; }
                                    
                                    // 版本分析
                                    if (thatTr.td[6].key) { thatTr.td[6].value = thatTr.td[6].key.join("—"); thatTr.td[6]["class"] = ""; }
                                    if (thatTr.td[7].key) { thatTr.td[7].value = thatTr.td[7].key.join("—"); thatTr.td[7]["class"] = ""; }
                                    
                                    // 用户分析
                                    if (!thatTr.td[8].key || thatTr.td[8].key == 0 || thatTr.td[8].key == "") { 
                                        thatTr.td[8].value = "不限"; thatTr.td[8]["class"]="font-gray"; 
                                    }
                                    
                                    // 将当前行放入tr组
                                    mo_tr.push(thatTr);
                                }
                                // 更新表格的数据
                                adminDom.table.opt({ pageMax: res.data.pe.totalPage }); // 最大页码
                                adminDom.table.tbody({ tr: mo_tr }); // 内容数据
                            }
                        }
                    });
                },
            });
            // 表格设置
            adminDom.table.opt({ pageSize: 20, });
            // 表格头排
            adminDom.table.thead({
                th: [
                    { title: "ID", width: "0.4rem", orderUp: "", orderDown: "" },
                    { title: "标题", width: "0.8rem", orderUp: "", orderDown: "" },
                    { title: "内容", width: "0.8rem", orderUp: "", orderDown: "" },
                    { title: "状态", width: "0.4rem", orderUp: "", orderDown: "" },
                    { title: "预设时间", width: "0.6rem", orderUp: "", orderDown: "" },
                    { title: "推送时间", width: "0.6rem", orderUp: "", orderDown: "" },
                    { title: "安卓推送版本", width: "0.6rem", orderUp: "", orderDown: "" },
                    { title: "IOS推送版本", width: "0.6rem", orderUp: "", orderDown: "" },
                    { title: "推送用户", width: "0.6rem", orderUp: "", orderDown: "" },
                ]
            });
            // 工具栏
            adminDom.table.tools({
                show: true,
                list: [
                    { "title": "新建", "name": "add", "icon": "fi fi-plus" }, 
                    { "title": "删除", "name": "del", "icon": "fi fi-trash" },
                    { "title": "修改", "name": "edit", "icon": "fi fi-edit-box" }, 
                    { "title": "推送", "name": "work", "icon": "admin adminhuaban" }, 
                ],
                touch: function (back)
                {
                    // 新建
                    if (back.toolName == "add")
                    {
                        // 直接跳转到编辑页
                        doui.pageToUrl({
                            type: "replace",
                            url: "today_evaluate.html",
                            data: { 
                                type: "new",
                            },
                        });
                    }
                    
                    // 删除
                    else if (back.toolName == "del")
                    {
                        // 获取所选行的ID
                        var zu_id = new Array();
                        for (var i = 0, mo = back.list; i < mo.length; i++) { zu_id.push(mo[i][0].key); }
                        // 发起请求
                        doui.showLoading({ content: "正在删除" });
                        doui.request({
                            type: "jsonp",
                            url: gethttp() + "/admin/new/api/v1/pushgoods/delete",
                            data: { idArray: zu_id, },
                            success: function (res) 
                            {
                                doui.hideLoading();
                                if (res.code != 0) { doui.showToast({ content: res.msg }); }
                                else { doui.showToast({ content: "删除成功" }); vm_table.search(); }
                            }
                        });
                    }
                    
                    // 修改
                    else if (back.toolName == "edit")
                    {
                        if (back.list.length > 1) { doui.showToast({ content: "一次只能操作一个" }); return false; }
                        var item = back.list[0]; // 获取第一个选择的行
                        
                        // 跳转到编辑页
                        doui.pageToUrl({
                            type: "replace",
                            url: "today_evaluate.html",
                            data: { 
                                type: "updata", 
                                id: item[0].key,
                            },
                        });
                    }
                    
                    // 推送
                    else if (back.toolName == "work")
                    {
                        // 获取所选行的ID
                        var zu_id = new Array();
                        for (var i = 0, mo = back.list; i < mo.length; i++) { zu_id.push(mo[i][0].key); }
                        // 发起请求
                        doui.showLoading({ content: "正在推送" });
                        doui.request({
                            type: "jsonp",
                            url: gethttp() + "/admin/new/api/v1/pushgoods/push",
                            data: { idArray: zu_id, },
                            success: function (res) 
                            {
                                doui.hideLoading();
                                if (res.code != 0) { doui.showToast({ content: res.msg }); }
                                else { doui.showToast({ content: "推送成功" }); vm_table.search(); }
                            }
                        });
                    }
                    
                }
            });
            
            
            // ----------------------------------------------------- 初始行为
            // 模拟搜索点击
            vm_table.search();
        }
    });
    
</script>