Showing
7 changed files
with
636 additions
and
1 deletions
@@ -5,6 +5,7 @@ import com.yohobuy.platform.model.common.ApiResponse; | @@ -5,6 +5,7 @@ import com.yohobuy.platform.model.common.ApiResponse; | ||
5 | import com.yohobuy.platform.model.common.PageResponseVO; | 5 | import com.yohobuy.platform.model.common.PageResponseVO; |
6 | import com.yohobuy.platform.model.grass.request.GrassUserManageReq; | 6 | import com.yohobuy.platform.model.grass.request.GrassUserManageReq; |
7 | import com.yohobuy.platform.model.grass.response.GrassUserRespBo; | 7 | import com.yohobuy.platform.model.grass.response.GrassUserRespBo; |
8 | +import com.yohobuy.platform.model.grass.response.GrassVirtualUserRespBo; | ||
8 | import org.springframework.beans.factory.annotation.Autowired; | 9 | import org.springframework.beans.factory.annotation.Autowired; |
9 | import org.springframework.stereotype.Controller; | 10 | import org.springframework.stereotype.Controller; |
10 | import org.springframework.web.bind.annotation.RequestBody; | 11 | import org.springframework.web.bind.annotation.RequestBody; |
@@ -41,5 +42,30 @@ public class GrassUserManageController { | @@ -41,5 +42,30 @@ public class GrassUserManageController { | ||
41 | return new ApiResponse.ApiResponseBuilder().build(); | 42 | return new ApiResponse.ApiResponseBuilder().build(); |
42 | } | 43 | } |
43 | 44 | ||
45 | + /** | ||
46 | + * 马甲用户列表 | ||
47 | + * @param req | ||
48 | + * @return | ||
49 | + */ | ||
50 | + @RequestMapping("/grassVirtualList") | ||
51 | + @ResponseBody | ||
52 | + public ApiResponse grassVirtualList(@RequestBody GrassUserManageReq req){ | ||
53 | + PageResponseVO<GrassVirtualUserRespBo> result = userService.grassVirtualList(req); | ||
54 | + return new ApiResponse.ApiResponseBuilder().data(result).build(); | ||
55 | + } | ||
56 | + | ||
57 | + | ||
58 | + /** | ||
59 | + * 修改马甲用户信息 | ||
60 | + * @param req | ||
61 | + * @return | ||
62 | + */ | ||
63 | + @RequestMapping("/updateVirtualUser") | ||
64 | + @ResponseBody | ||
65 | + public ApiResponse updateVirtualUser(@RequestBody GrassUserManageReq req){ | ||
66 | + userService.updateVirtualUser(req); | ||
67 | + return new ApiResponse.ApiResponseBuilder().build(); | ||
68 | + } | ||
69 | + | ||
44 | 70 | ||
45 | } | 71 | } |
@@ -32,4 +32,6 @@ public interface IGrassArticleService { | @@ -32,4 +32,6 @@ public interface IGrassArticleService { | ||
32 | 32 | ||
33 | ArticleDetailRspBo getArticleById(GrassArticleReq req) throws PlatformException; | 33 | ArticleDetailRspBo getArticleById(GrassArticleReq req) throws PlatformException; |
34 | 34 | ||
35 | + | ||
36 | + List<Integer> getUidByNickName(String nickName); | ||
35 | } | 37 | } |
@@ -4,6 +4,7 @@ import com.yohobuy.platform.model.common.PageResponseVO; | @@ -4,6 +4,7 @@ import com.yohobuy.platform.model.common.PageResponseVO; | ||
4 | import com.yohobuy.platform.model.grass.request.GrassTopicReq; | 4 | import com.yohobuy.platform.model.grass.request.GrassTopicReq; |
5 | import com.yohobuy.platform.model.grass.request.GrassUserManageReq; | 5 | import com.yohobuy.platform.model.grass.request.GrassUserManageReq; |
6 | import com.yohobuy.platform.model.grass.response.GrassUserRespBo; | 6 | import com.yohobuy.platform.model.grass.response.GrassUserRespBo; |
7 | +import com.yohobuy.platform.model.grass.response.GrassVirtualUserRespBo; | ||
7 | import com.yohobuy.platform.model.grass.response.TopicRespBo; | 8 | import com.yohobuy.platform.model.grass.response.TopicRespBo; |
8 | 9 | ||
9 | import java.util.List; | 10 | import java.util.List; |
@@ -17,4 +18,8 @@ public interface IGrassUserService { | @@ -17,4 +18,8 @@ public interface IGrassUserService { | ||
17 | 18 | ||
18 | 19 | ||
19 | void changeGrassUserStatus(GrassUserManageReq req); | 20 | void changeGrassUserStatus(GrassUserManageReq req); |
21 | + | ||
22 | + PageResponseVO<GrassVirtualUserRespBo> grassVirtualList(GrassUserManageReq req); | ||
23 | + | ||
24 | + void updateVirtualUser(GrassUserManageReq req); | ||
20 | } | 25 | } |
@@ -332,7 +332,7 @@ public class GrassArticleServiceImpl implements IGrassArticleService{ | @@ -332,7 +332,7 @@ public class GrassArticleServiceImpl implements IGrassArticleService{ | ||
332 | return rsp; | 332 | return rsp; |
333 | } | 333 | } |
334 | 334 | ||
335 | - private List<Integer> getUidByNickName(String nickName){ | 335 | + public List<Integer> getUidByNickName(String nickName){ |
336 | String url = uicUrl + "/UserInfoRest/getUserInfoByNickName"; | 336 | String url = uicUrl + "/UserInfoRest/getUserInfoByNickName"; |
337 | BaseReqBO<String> uicReq = new BaseReqBO<>(); | 337 | BaseReqBO<String> uicReq = new BaseReqBO<>(); |
338 | uicReq.setParam(nickName); | 338 | uicReq.setParam(nickName); |
1 | package com.yohobuy.platform.grass.service.impl; | 1 | package com.yohobuy.platform.grass.service.impl; |
2 | 2 | ||
3 | import com.yoho.core.rest.client.ServiceCaller; | 3 | import com.yoho.core.rest.client.ServiceCaller; |
4 | +import com.yoho.quartz.utils.DateUtils; | ||
5 | +import com.yoho.service.model.request.UserBaseReqBO; | ||
6 | +import com.yoho.service.model.response.CommonRspBO; | ||
4 | import com.yoho.service.model.social.request.BaseReqBO; | 7 | import com.yoho.service.model.social.request.BaseReqBO; |
5 | import com.yoho.service.model.social.request.UicUserReqBO; | 8 | import com.yoho.service.model.social.request.UicUserReqBO; |
6 | import com.yoho.service.model.social.response.UserInfoRspBO; | 9 | import com.yoho.service.model.social.response.UserInfoRspBO; |
@@ -8,12 +11,16 @@ import com.yoho.service.model.social.response.UserLoginInfoRspBO; | @@ -8,12 +11,16 @@ import com.yoho.service.model.social.response.UserLoginInfoRspBO; | ||
8 | import com.yohobuy.platform.common.util.DateUtil; | 11 | import com.yohobuy.platform.common.util.DateUtil; |
9 | import com.yohobuy.platform.dal.grass.IGrassArticleDao; | 12 | import com.yohobuy.platform.dal.grass.IGrassArticleDao; |
10 | import com.yohobuy.platform.dal.grass.IGrassUserAchieveDAO; | 13 | import com.yohobuy.platform.dal.grass.IGrassUserAchieveDAO; |
14 | +import com.yohobuy.platform.dal.grass.IGrassVirtualUserDao; | ||
11 | import com.yohobuy.platform.dal.grass.model.GrassArticle; | 15 | import com.yohobuy.platform.dal.grass.model.GrassArticle; |
12 | import com.yohobuy.platform.dal.grass.model.GrassUserAchieve; | 16 | import com.yohobuy.platform.dal.grass.model.GrassUserAchieve; |
17 | +import com.yohobuy.platform.dal.grass.model.GrassVirtualUser; | ||
18 | +import com.yohobuy.platform.grass.service.IGrassArticleService; | ||
13 | import com.yohobuy.platform.grass.service.IGrassUserService; | 19 | import com.yohobuy.platform.grass.service.IGrassUserService; |
14 | import com.yohobuy.platform.model.common.PageResponseVO; | 20 | import com.yohobuy.platform.model.common.PageResponseVO; |
15 | import com.yohobuy.platform.model.grass.request.GrassUserManageReq; | 21 | import com.yohobuy.platform.model.grass.request.GrassUserManageReq; |
16 | import com.yohobuy.platform.model.grass.response.GrassUserRespBo; | 22 | import com.yohobuy.platform.model.grass.response.GrassUserRespBo; |
23 | +import com.yohobuy.platform.model.grass.response.GrassVirtualUserRespBo; | ||
17 | import org.apache.commons.collections.CollectionUtils; | 24 | import org.apache.commons.collections.CollectionUtils; |
18 | import org.apache.commons.lang.StringUtils; | 25 | import org.apache.commons.lang.StringUtils; |
19 | import org.apache.commons.lang3.StringEscapeUtils; | 26 | import org.apache.commons.lang3.StringEscapeUtils; |
@@ -45,6 +52,12 @@ public class GrassUserServiceImpl implements IGrassUserService{ | @@ -45,6 +52,12 @@ public class GrassUserServiceImpl implements IGrassUserService{ | ||
45 | private IGrassArticleDao articleDao; | 52 | private IGrassArticleDao articleDao; |
46 | 53 | ||
47 | @Autowired | 54 | @Autowired |
55 | + private IGrassVirtualUserDao virtualUserDao; | ||
56 | + | ||
57 | + @Autowired | ||
58 | + IGrassArticleService grassArticleService; | ||
59 | + | ||
60 | + @Autowired | ||
48 | private ServiceCaller serviceCaller; | 61 | private ServiceCaller serviceCaller; |
49 | 62 | ||
50 | @Value("${uic.service.url:http://uic.yohoops.org/uic}") | 63 | @Value("${uic.service.url:http://uic.yohoops.org/uic}") |
@@ -104,6 +117,123 @@ public class GrassUserServiceImpl implements IGrassUserService{ | @@ -104,6 +117,123 @@ public class GrassUserServiceImpl implements IGrassUserService{ | ||
104 | } | 117 | } |
105 | 118 | ||
106 | /** | 119 | /** |
120 | + * 马甲用户列表 | ||
121 | + * @param req | ||
122 | + * @return | ||
123 | + */ | ||
124 | + @Override | ||
125 | + public PageResponseVO<GrassVirtualUserRespBo> grassVirtualList(GrassUserManageReq req) { | ||
126 | + logger.info("enter grassVirtualList req={}", req); | ||
127 | + PageResponseVO responseVO = new PageResponseVO(); | ||
128 | + responseVO.setList(new ArrayList()); | ||
129 | + responseVO.setTotal(0); | ||
130 | + responseVO.setPage(req.getPage()); | ||
131 | + responseVO.setSize(req.getSize()); | ||
132 | + | ||
133 | + List<Integer> uids = new ArrayList<>(); | ||
134 | + if(StringUtils.isNotEmpty(req.getNickName())){//昵称,先去uic查 | ||
135 | + uids = grassArticleService.getUidByNickName(req.getNickName()); | ||
136 | + if(CollectionUtils.isEmpty(uids)){ | ||
137 | + logger.info("grassVirtualList result is null, nickName not found, req={}", req); | ||
138 | + return responseVO; | ||
139 | + } | ||
140 | + } | ||
141 | + | ||
142 | + if(req.getUid() != null){ | ||
143 | + uids.add(req.getUid()); | ||
144 | + } | ||
145 | + | ||
146 | + Map<String,Object> params = new HashMap<>(); | ||
147 | + params.put("status",req.getStatus() == null || req.getStatus() == 8 ? null : req.getStatus()); | ||
148 | + params.put("nickName",req.getNickName()); | ||
149 | + params.put("uids",uids); | ||
150 | + params.put("startTime",req.getStartTime()); | ||
151 | + params.put("endTime",req.getEndTime()); | ||
152 | + | ||
153 | + int total = virtualUserDao.countByCondition(params); | ||
154 | + responseVO.setTotal(total); | ||
155 | + if(total == 0){ | ||
156 | + logger.info("grassVirtualList total is 0, req={}", req); | ||
157 | + return responseVO; | ||
158 | + } | ||
159 | + | ||
160 | + List<GrassVirtualUser> list = virtualUserDao.selectByPage(params, req.getStart(), req.getSize()); | ||
161 | + List<GrassVirtualUserRespBo> data = buildVirtualInfo(list); | ||
162 | + responseVO.setList(data); | ||
163 | + logger.info("grassVirtualList success! req={}, total = {}",req, total); | ||
164 | + return responseVO; | ||
165 | + } | ||
166 | + | ||
167 | + /** | ||
168 | + * 修改马甲用户信息 | ||
169 | + * @param req | ||
170 | + */ | ||
171 | + @Override | ||
172 | + public void updateVirtualUser(GrassUserManageReq req) { | ||
173 | + logger.info("enter updateVirtualUser req={}", req); | ||
174 | + Integer type = req.getType() == null ? 0 : req.getType() ; | ||
175 | + if(type == 1){//修改状态 | ||
176 | + virtualUserDao.changeStatusByUid(req.getUid(), req.getStatus()); | ||
177 | + return; | ||
178 | + | ||
179 | + } | ||
180 | + //修改基本信息(头像,签名等) | ||
181 | + String url = uicUrl + "/UserInfoRest/updateUserBase"; | ||
182 | + UserBaseReqBO uicReq = new UserBaseReqBO(); | ||
183 | + uicReq.setUid(req.getUid()); | ||
184 | + uicReq.setNick_name(req.getNickName()); | ||
185 | + uicReq.setHeadIco(req.getHeadIcon()); | ||
186 | + logger.info("updateVirtualUser call uic.modifyUserBase url ={}, uicReq={}", url, uicReq); | ||
187 | + //调uic 的接口(修改头像等) | ||
188 | + serviceCaller.post("uic.modifyUserBase", url, uicReq, CommonRspBO.class, null).get(); | ||
189 | + // | ||
190 | + GrassUserAchieve grassUserAchieve = userAchieveDAO.selectByUid(req.getUid()); | ||
191 | + if(grassUserAchieve == null){ | ||
192 | + grassUserAchieve = new GrassUserAchieve(); | ||
193 | + grassUserAchieve.setUid(req.getUid()); | ||
194 | + grassUserAchieve.setSignature(req.getSignature()); | ||
195 | + grassUserAchieve.setCreateTime((int) (System.currentTimeMillis() /1000)); | ||
196 | + userAchieveDAO.insertSelective(grassUserAchieve); | ||
197 | + logger.info("updateVirtualUser create userAchieve success! req={} ", req); | ||
198 | + }else{ | ||
199 | + grassUserAchieve.setSignature(Optional.ofNullable(req.getSignature()).orElse("")); | ||
200 | + grassUserAchieve.setUpdateTime((int) (System.currentTimeMillis() /1000)); | ||
201 | + userAchieveDAO.updateSelective(grassUserAchieve); | ||
202 | + logger.info("updateVirtualUser update userAchieve success! req={} ", req); | ||
203 | + } | ||
204 | + } | ||
205 | + | ||
206 | + //马甲用户的详细信息 | ||
207 | + private List<GrassVirtualUserRespBo> buildVirtualInfo(List<GrassVirtualUser> list) { | ||
208 | + List<GrassVirtualUserRespBo> result = new ArrayList<>(); | ||
209 | + if(CollectionUtils.isEmpty(list)){ | ||
210 | + return result; | ||
211 | + } | ||
212 | + //查询用户的头像等基本信息 | ||
213 | + //用户的基本信息(昵称 头像等) | ||
214 | + List<Integer> uids = list.stream().map(GrassVirtualUser::getUid).collect(Collectors.toList()); | ||
215 | + Map<Integer,UserInfoRspBO> userInfoMap = getUsersInfo(uids); | ||
216 | + | ||
217 | + //获取签名信息 | ||
218 | + List<GrassUserAchieve> userAchieves = userAchieveDAO.selectByUids(uids); | ||
219 | + Map<Integer,String > userAchieveMap = userAchieves.stream().collect(Collectors.toMap(GrassUserAchieve::getUid, obj -> obj.getSignature() == null ? "" : obj.getSignature())); | ||
220 | + | ||
221 | + //组装信息 | ||
222 | + for(GrassVirtualUser user : list){ | ||
223 | + GrassVirtualUserRespBo bo = new GrassVirtualUserRespBo(); | ||
224 | + bo.setUid(user.getUid()); | ||
225 | + UserInfoRspBO userInfoRspBO = userInfoMap.get(user.getUid()); | ||
226 | + bo.setNickName(userInfoRspBO == null ? "" : userInfoRspBO.getNickName()); | ||
227 | + bo.setHeadIcon(userInfoRspBO == null ? "" : buildHeadIcon(userInfoRspBO.getHeadIco())); | ||
228 | + bo.setSignature(userAchieveMap.get(user.getUid()) == null ? "" : userAchieveMap.get(user.getUid())); | ||
229 | + bo.setCreateTimeStr(DateUtil.getDateFormatFromInt(user.getCreateTime(), "yyyy-MM-dd HH:mm:ss")); | ||
230 | + bo.setStatus(user.getStatus()); | ||
231 | + result.add(bo); | ||
232 | + } | ||
233 | + return result; | ||
234 | + } | ||
235 | + | ||
236 | + /** | ||
107 | * 根据昵称查询 | 237 | * 根据昵称查询 |
108 | * 先去查询uic --精确查询 | 238 | * 先去查询uic --精确查询 |
109 | * @param req | 239 | * @param req |
1 | +<!DOCTYPE html> | ||
2 | +<div id="tt" class="easyui-layout" fit="true" style="overflow-y: scroll"> | ||
3 | + <form name="topicForm" id="topicForm" method="post"> | ||
4 | + <div style="margin-top: 20px;margin-left: 30px"> | ||
5 | + <table border="0" style="width:95%;margin-top:5px;line-height:30px;" id="tab"> | ||
6 | + | ||
7 | + <tr style="height: 60px"> | ||
8 | + | ||
9 | + <td> | ||
10 | + <span style="color:red">*</span><label>UID</label> <br> | ||
11 | + <input id="uid" name="uid" class="easyui-textbox" style="width: 380px;" readonly='readonly'/> | ||
12 | + </td> | ||
13 | + </tr> | ||
14 | + | ||
15 | + <tr style="height: 60px"> | ||
16 | + | ||
17 | + <td> | ||
18 | + <span style="color:red">*</span><label>马甲昵称</label> <br> | ||
19 | + <input id="nickName" name="nickName" class="easyui-textbox" style="width: 380px;"/> | ||
20 | + </td> | ||
21 | + </tr> | ||
22 | + | ||
23 | + <tr style="height: 60px"> | ||
24 | + <td> | ||
25 | + <span style="color:red">*</span><label>头像</label> <br> | ||
26 | + | ||
27 | + <div id="imageUpload"> | ||
28 | + </div> | ||
29 | + <!-- <span style=" margin-left: 10px; color: red"> 图片宽高(186x170)</span>--> | ||
30 | + </td> | ||
31 | + </tr> | ||
32 | + <tr style="height: 60px"> | ||
33 | + | ||
34 | + <td> | ||
35 | + <span style="color:red">*</span><label>马甲简介</label> <br> | ||
36 | + <textarea id="signature" name="signature" style="width: 380px;" rows="6" placeholder="" | ||
37 | + required="true" maxlength="500"></textarea> | ||
38 | + </td> | ||
39 | + </tr> | ||
40 | + | ||
41 | + | ||
42 | + </table> | ||
43 | + </div> | ||
44 | + </form> | ||
45 | + | ||
46 | +</div> | ||
47 | + | ||
48 | + | ||
49 | +<script> | ||
50 | + | ||
51 | + | ||
52 | + $(function () { | ||
53 | + $("#nickName").textbox({ | ||
54 | + required: true, | ||
55 | + missingMessage: "昵称不能为空", | ||
56 | + prompt: "请输入昵称" | ||
57 | + }); | ||
58 | + | ||
59 | + | ||
60 | + $("#imageUpload").imageUpload({ | ||
61 | + width: 171, | ||
62 | + height: 120, | ||
63 | + realInputName: "headIcon", | ||
64 | + url: serverContextPath + '/fileupload/uploadFile', | ||
65 | + queryParams: { | ||
66 | + bucket: "activity" | ||
67 | + }, | ||
68 | + onBeforeSubmit: function () { | ||
69 | + $.messager.progress({ | ||
70 | + title: "正在执行", | ||
71 | + msg: "正在执行,请稍后...", | ||
72 | + interval: 500, | ||
73 | + text: "" | ||
74 | + }); | ||
75 | + }, | ||
76 | + filterFileName: function (data) { | ||
77 | + debugger; | ||
78 | + if (!data || data.code != 200) { | ||
79 | + $.messager.progress("close"); | ||
80 | + $.messager.alert("错误", data.message); | ||
81 | + return ""; | ||
82 | + } | ||
83 | + return data.data.url; | ||
84 | + }, | ||
85 | + onLoadSuccess: function (data) { | ||
86 | + $.messager.progress("close"); | ||
87 | + //$("#imageUpload").hide(); | ||
88 | + //$("#fileName").val(data.data.fileName); | ||
89 | + //$("#videoSize").val(data.data.fileSize); //如果有大小校验 | ||
90 | + /*$("#callBackDiv").html("<div id='videoUploadDiv' class='image-upload' style='position: relative;top:19px;width: 120px; height: 150px;'><img id='imageShow' src='"+data.data.url+"?vframe/jpg/offset/0' width='120' height='150'/></div>" | ||
91 | + +"<span style='position: relative;top: -40px;left: 30px;'>"+data.data.fileName+"</span><span style='position: relative;left: 50px;top: -40px;'>"+data.data.fileSize+"M</span>").show(); | ||
92 | + */ | ||
93 | + return false; | ||
94 | + } | ||
95 | + }); | ||
96 | + | ||
97 | + //加载数据 | ||
98 | + var data = paramObject.mkData; | ||
99 | + $("#uid").textbox("setValue", data.uid); | ||
100 | + $("#nickName").textbox("setValue", data.nickName); | ||
101 | + $("#signature").html(data.signature); | ||
102 | + //图片 | ||
103 | + $("#imageUpload").imageUpload('setValue', data.headIcon); | ||
104 | + | ||
105 | + }); | ||
106 | + | ||
107 | + | ||
108 | +</script> | ||
109 | + | ||
110 | +</html> | ||
111 | + |
1 | +<!DOCTYPE html> | ||
2 | +<html> | ||
3 | +<head> | ||
4 | + <meta charset="UTF-8"/> | ||
5 | + <title>Yoho!Buy运营平台</title> | ||
6 | + <script src="/pfcms/js/include.js"></script> | ||
7 | + <script src="/pfcms/js/ajaxfileupload.js"></script> | ||
8 | + <style> | ||
9 | + .btn-long { | ||
10 | + width: 120px; | ||
11 | + height: 37px; | ||
12 | + line-height: 37px; | ||
13 | + font-size: 15px; | ||
14 | + color: white; | ||
15 | + border-radius: 5px; | ||
16 | + display: inline-block; | ||
17 | + cursor: pointer; | ||
18 | + text-align: center; | ||
19 | + } | ||
20 | + | ||
21 | + .btn-long:hover { | ||
22 | + opacity: 0.9; | ||
23 | + } | ||
24 | + | ||
25 | + </style> | ||
26 | +</head> | ||
27 | +<body class="easyui-layout"> | ||
28 | +<div region="north" style="height: 200px;"> | ||
29 | + <script> | ||
30 | + document.write(addHead('种草社区管理', '马甲管理')); | ||
31 | + </script> | ||
32 | + | ||
33 | + <div style="margin-left: 20px;margin-top: 10px"> | ||
34 | + | ||
35 | + | ||
36 | + <input class="easyui-combobox" id="statusParam"> | ||
37 | + </input> | ||
38 | + | ||
39 | + <input class="easyui-textbox" id="nickNameParam" style="width: 140px"> | ||
40 | + | ||
41 | + </input> | ||
42 | + | ||
43 | + | ||
44 | + <input class="easyui-textbox" id="uidParam" style="width: 140px"> | ||
45 | + | ||
46 | + </input> | ||
47 | + | ||
48 | + <input id="startTimeStr" name="startTimeStr" class="easyui-datetimebox" data-options="prompt:'开始时间'"/> | ||
49 | + | ||
50 | + ~ | ||
51 | + <input id="endTimeStr" name="endTimeStr" class="easyui-datetimebox" data-options="prompt:'结束时间'"/> | ||
52 | + </input> | ||
53 | + | ||
54 | + <a id="searchBtn" class="btn-info">查询</a> | ||
55 | + <!--<a id="addActivityBtn" class="btn-success">新增</a>--> | ||
56 | + <a id="allBtn" class="btn-info">全部</a> | ||
57 | + | ||
58 | + </div> | ||
59 | + | ||
60 | +</div> | ||
61 | + | ||
62 | +<div region="center" id="labelList" style="margin-left: 20px"> | ||
63 | + <table id="labelListTable"></table> | ||
64 | +</div> | ||
65 | + | ||
66 | +</body> | ||
67 | + | ||
68 | +<script> | ||
69 | + | ||
70 | + $(function () { | ||
71 | + //用于页面刷新后的数据行定位 | ||
72 | + var index = ""; | ||
73 | + $("#allBtn").linkbutton({ | ||
74 | + iconCls: "icon-search", | ||
75 | + onClick: function () { | ||
76 | + $("#labelListTable").datagrid("load", {}); | ||
77 | + } | ||
78 | + }); | ||
79 | + | ||
80 | + $("#nickNameParam").textbox({ | ||
81 | + required: false, | ||
82 | + prompt: "昵称" | ||
83 | + }); | ||
84 | + $("#uidParam").textbox({ | ||
85 | + required: false, | ||
86 | + prompt: "UID" | ||
87 | + }); | ||
88 | + | ||
89 | + $("#statusParam").combobox({ | ||
90 | + valueField: "value", | ||
91 | + textField: "text", | ||
92 | + required: false, | ||
93 | + prompt: "请选择状态", | ||
94 | + data: [{text: "请选择状态", value: ""}, {text: "全部", value: "8"},{text: "正常", value: "1"}, {text: "停用", value: "0"}] | ||
95 | + }); | ||
96 | + | ||
97 | + $("#searchBtn").linkbutton({ | ||
98 | + iconCls: "icon-search", | ||
99 | + onClick: function () { | ||
100 | + var startTime = ""; | ||
101 | + var endTime = ""; | ||
102 | + if ($("#startTimeStr").datetimebox('getValue') != '') { | ||
103 | + startTime = parseInt(new Date($("#startTimeStr").datetimebox('getValue')).getTime() / 1000); | ||
104 | + } | ||
105 | + if ($("#endTimeStr").datetimebox('getValue') != '') { | ||
106 | + endTime = parseInt(new Date($("#endTimeStr").datetimebox('getValue')).getTime() / 1000); | ||
107 | + } | ||
108 | + $("#labelListTable").datagrid("load", { | ||
109 | + uid: $("#uidParam").textbox("getValue"), | ||
110 | + nickName:$("#nickNameParam").textbox("getValue"), | ||
111 | + status: $("#statusParam").combobox("getValue"), | ||
112 | + startTime: startTime, | ||
113 | + endTime: endTime | ||
114 | + }); | ||
115 | + } | ||
116 | + }); | ||
117 | + | ||
118 | + | ||
119 | + | ||
120 | + | ||
121 | + // 检索按钮 | ||
122 | + $("#labelListTable").myDatagrid({ | ||
123 | + fit: true, | ||
124 | + fitColumns: true, | ||
125 | + striped: true, | ||
126 | + /*queryParams: { | ||
127 | + rewardName: $("#rewardName1").textbox("getValue"), | ||
128 | + status: $("#rewardstatus1").combobox("getValue"), | ||
129 | + type: $("#rewardtype1").combobox("getValue") | ||
130 | + },*/ | ||
131 | + url: serverContextPath + "/grassUserManage/grassVirtualList", | ||
132 | + method: 'POST', | ||
133 | + loadFilter: function (data) { | ||
134 | + var tmp = defaultLoadFilter(data); | ||
135 | + tmp.rows = tmp.list; | ||
136 | + return tmp; | ||
137 | + }, | ||
138 | + columns: [[ | ||
139 | + { | ||
140 | + title: "马甲UID", | ||
141 | + field: "uid", | ||
142 | + width: 15, | ||
143 | + align: "uid" | ||
144 | + }, | ||
145 | + | ||
146 | + { | ||
147 | + title: "昵称", | ||
148 | + field: "nickName", | ||
149 | + width: 30, | ||
150 | + align: "left" | ||
151 | + }, | ||
152 | + { | ||
153 | + title: "头像", | ||
154 | + field: "headIcon", | ||
155 | + width: 20, | ||
156 | + align: "left", | ||
157 | + formatter: function (value, rowData, rowIndex) { | ||
158 | + if(value == null || value==""){ | ||
159 | + return ""; | ||
160 | + } | ||
161 | + return '<div><img style="width: 100px;height: 100px" src="'+value+'"/></div>'; | ||
162 | + } | ||
163 | + }, { | ||
164 | + title: "马甲简介", | ||
165 | + field: "signature", | ||
166 | + width: 35, | ||
167 | + align: "left" | ||
168 | + | ||
169 | + }, | ||
170 | + { | ||
171 | + title: "创建时间", | ||
172 | + field: "createTimeStr", | ||
173 | + width: 25, | ||
174 | + align: "left" | ||
175 | + }, { | ||
176 | + title: "状态", | ||
177 | + field: "status", | ||
178 | + width: 25, | ||
179 | + align: "left", | ||
180 | + formatter: function (value, rowData, rowIndex) { | ||
181 | + if (value == 1) { | ||
182 | + return "正常"; | ||
183 | + } else { | ||
184 | + return "停用"; | ||
185 | + } | ||
186 | + } | ||
187 | + | ||
188 | + }, | ||
189 | + { | ||
190 | + title: "操作", | ||
191 | + field: "ddg", | ||
192 | + width: 40, | ||
193 | + align: "center", | ||
194 | + formatter: function (value, rowData, rowIndex) { | ||
195 | + //停用 启用 修改 | ||
196 | + var str = "<a role='changeStatus' style='margin-left:10px;background-color: #ffa951' changedStatus='1' dataId='" + rowData.id + "' index='" + rowIndex + "'>启用</a>"; | ||
197 | + if(rowData.status == 1){ | ||
198 | + str = "<a role='changeStatus' style='margin-left:10px;background-color: #ffa951' changedStatus='0' dataId='" + rowData.id + "' index='" + rowIndex + "'>停用</a>"; | ||
199 | + } | ||
200 | + str += "<a role='edit' dataId='" + rowData.id + "' style='margin-left:10px;background-color: #31b0d5' index='" + rowIndex + "'>编辑</a>"; | ||
201 | + return str ; | ||
202 | + } | ||
203 | + } | ||
204 | + | ||
205 | + ]], | ||
206 | + cache: false, | ||
207 | + pagination: true, | ||
208 | + pageSize: 10, | ||
209 | + pageList: [10], | ||
210 | + idField: "id", | ||
211 | + singleSelect: true, | ||
212 | + onLoadSuccess: function (data) { | ||
213 | + | ||
214 | + if (index != "") { | ||
215 | + $(this).datagrid("scrollTo", index); | ||
216 | + index = ""; | ||
217 | + } | ||
218 | + | ||
219 | + // 编辑 | ||
220 | + $(this).datagrid("getPanel").find("a[role='edit']").linkbutton({ | ||
221 | + iconCls: "icon-edit", | ||
222 | + onClick: function () { | ||
223 | + | ||
224 | + index = $(this).attr("index"); | ||
225 | + var row = $("#labelListTable").datagrid('getData').rows[index]; | ||
226 | + getEditDialog(row); | ||
227 | + } | ||
228 | + }); | ||
229 | + | ||
230 | + // 上架下架 | ||
231 | + $(this).datagrid("getPanel").find("a[role='changeStatus']").linkbutton({ | ||
232 | + iconCls: "icon-edit", | ||
233 | + onClick: function () { | ||
234 | + var index = $(this).attr("index"); | ||
235 | + var row = $("#labelListTable").datagrid('getData').rows[index]; | ||
236 | + row.status = $(this).attr("changedStatus"); | ||
237 | + changeStatus(row); | ||
238 | + } | ||
239 | + }); | ||
240 | + | ||
241 | + } | ||
242 | + }); | ||
243 | + | ||
244 | + | ||
245 | + // 启用 停用 | ||
246 | + function changeStatus(data) { | ||
247 | + var param = { | ||
248 | + uid: data.uid, | ||
249 | + status: data.status, | ||
250 | + type: 1 | ||
251 | + }; | ||
252 | + | ||
253 | + $.post(serverContextPath + "/grassUserManage/updateVirtualUser", param, function (data) { | ||
254 | + if (data.code == 200) { | ||
255 | + //刷新table | ||
256 | + $("#labelListTable").datagrid("reload"); | ||
257 | + $.messager.show({ | ||
258 | + title: "提示", | ||
259 | + msg: "更新成功!", | ||
260 | + height: 120 | ||
261 | + }); | ||
262 | + | ||
263 | + | ||
264 | + } else {// | ||
265 | + $.messager.alert("失败", "更新失败,请稍后再试!", "error"); | ||
266 | + } | ||
267 | + | ||
268 | + }, "json"); | ||
269 | + | ||
270 | + | ||
271 | + } | ||
272 | + | ||
273 | + | ||
274 | + // 编辑分组 | ||
275 | + function getEditDialog(data) { | ||
276 | + var labelList = $("<div id='labelList'>").appendTo($(document.body)); | ||
277 | + var title = "修改马甲资料"; | ||
278 | + var textVar = data == null ? "保存" : "保存"; | ||
279 | + var msgVar = "确定修改吗"; | ||
280 | + | ||
281 | + window.self.paramObject.mkData = data; | ||
282 | + $(labelList).myDialog({ | ||
283 | + title: title, | ||
284 | + width: "70%", | ||
285 | + height: "80%", | ||
286 | + resizable: false, | ||
287 | + buttons: [{ | ||
288 | + id: "saveBtn", | ||
289 | + text: textVar, | ||
290 | + iconCls: "icon-save", | ||
291 | + handler: function () { | ||
292 | + | ||
293 | + $("#topicForm").form("submit", { | ||
294 | + url: serverContextPath + "/grassUserManage/updateVirtualUser", | ||
295 | + onSubmit: function (param) { | ||
296 | + if (data != null) { | ||
297 | + param.id = data.id; | ||
298 | + } | ||
299 | + | ||
300 | + //1)表单基本检查 | ||
301 | + if (!$("#topicForm").form("validate")) { | ||
302 | + return false; | ||
303 | + } | ||
304 | + | ||
305 | + //2)是否上传了图片 | ||
306 | + var imageCount = 0; | ||
307 | + $("input[name='headIcon']").each(function (j, item) { | ||
308 | + var url = item.value; | ||
309 | + if (url != '') { | ||
310 | + imageCount++; | ||
311 | + } | ||
312 | + }); | ||
313 | + if (imageCount == 0) { | ||
314 | + $.messager.alert("保存失败", "至少要选择一张图片", "error"); | ||
315 | + return false; | ||
316 | + | ||
317 | + } | ||
318 | + | ||
319 | + $.messager.progress({ | ||
320 | + title: "正在执行", | ||
321 | + msg: "正在执行,请稍后..." | ||
322 | + }); | ||
323 | + return true; | ||
324 | + }, | ||
325 | + success: function (data) { | ||
326 | + $.messager.progress("close"); | ||
327 | + data = JSON.parse(data); | ||
328 | + if (data.code == 200) { | ||
329 | + $(labelList).dialog("close"); | ||
330 | + $("#labelListTable").datagrid("reload"); | ||
331 | + $.messager.show({ | ||
332 | + title: "提示", | ||
333 | + msg: title + "成功!", | ||
334 | + height: 120 | ||
335 | + }); | ||
336 | + } else { | ||
337 | + $.messager.alert("失败", "操作失败", "error"); | ||
338 | + } | ||
339 | + } | ||
340 | + }); | ||
341 | + } | ||
342 | + }, { | ||
343 | + text: "关闭", | ||
344 | + iconCls: "icon-cancel", | ||
345 | + handler: function () { | ||
346 | + $.messager.confirm("确认", "确认关闭吗?", function (flag) { | ||
347 | + if (flag) { | ||
348 | + $(labelList).dialog("close"); | ||
349 | + } | ||
350 | + }); | ||
351 | + } | ||
352 | + }], | ||
353 | + modal: true, | ||
354 | + href: contextPath + "/html/grass/userManage/virtualEdit.html", | ||
355 | + }); | ||
356 | + } | ||
357 | + | ||
358 | + }); | ||
359 | + | ||
360 | +</script> | ||
361 | +</html> |
-
Please register or login to post a comment