complaintOrder.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  1. app.controller('complaintOrderCtrl', ['$scope', '$filter', '$http', '$stateParams', '$timeout', 'uiGridConstants', 'i18nService', 'toaster', function ($scope, $filter, $http, $stateParams, $timeout, uiGridConstants, i18nService, toaster,) {
  2. i18nService.setCurrentLang("zh-cn");
  3. moment.locale('zh-cn');
  4. $scope.startTimeOpen = false;
  5. $scope.endTimeOpen = false;
  6. $scope.timeChange = function (newDate, oldDate) {
  7. $scope.startTimeOpen = false;
  8. $scope.endTimeOpen = false;
  9. };
  10. $scope.gridOptions = {
  11. data: 'myData',
  12. showGridFooter: true, //是否显示grid footer
  13. // rowHeight: 80,
  14. //-------- 分页属性 ----------------
  15. paginationPageSizes: [10, 20, 50, 100], //每页显示个数可选项
  16. paginationCurrentPage: 1, //当前页码
  17. paginationPageSize: 10, //每页显示个数
  18. totalItems: 0,// 总数量
  19. useExternalPagination: true,//是否使用分页按钮
  20. //过滤
  21. // enableFiltering: true,
  22. columnDefs: [],
  23. //---------------api---------------------
  24. onRegisterApi: function (gridApi) {
  25. $scope.gridApi = gridApi;
  26. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  27. if ($scope.setPagingData) {
  28. $scope.getPagedDataAsync(newPage, pageSize, true);//翻页是强制刷新
  29. }
  30. });
  31. }
  32. };
  33. let stateMap = {
  34. '': '-请选择-',
  35. PENDING: '未处理',
  36. PROCESSING: '正在处理',
  37. PROCESSED: '处理完成',
  38. }
  39. let stateList = []
  40. for (let key in stateMap) {
  41. stateList.push({
  42. value: key,
  43. label: stateMap[key]
  44. })
  45. }
  46. //枚举常量
  47. $scope.enum = {
  48. stateMap: stateMap,
  49. stateList: stateList
  50. };
  51. var searchType = $scope.enum.searchType = [
  52. {value: 'complaintId', label: "按投诉订单查询", desc: '输入用户投诉订单'},
  53. ];
  54. //查询条件
  55. var condition = $scope.condition = {
  56. stateFilter: stateList[0],
  57. searchType: searchType[0],
  58. searchKey: '',
  59. };
  60. //查询条件
  61. $scope.query = {
  62. startTime: moment().format("YYYY-MM-DD"),
  63. endTime: moment().format("YYYY-MM-DD"),
  64. };
  65. //事件
  66. $scope.event = {
  67. statusChange: function (key, item) {
  68. condition[key] = {}
  69. condition[key].value = item.value;
  70. condition[key].label = item.label;
  71. condition[key].desc = item.desc;
  72. },
  73. search: function () {
  74. // 就在当前 厂商|代理商|经销商的域下进行搜索
  75. if (condition.searchKey === "") {
  76. $scope.getPagedDataAsync(1, $scope.gridOptions.paginationPageSize, true);
  77. } else {
  78. $scope.getPagedDataAsync(1, $scope.gridOptions.paginationPageSize);
  79. }
  80. },
  81. };
  82. $scope.getStateText = function (value) {
  83. return stateMap[value]
  84. }
  85. function setColumnDefs() {
  86. $scope.gridOptions.columnDefs = [
  87. {
  88. field: 'complaint_id',
  89. displayName: '投诉订单号',
  90. },
  91. {
  92. field: 'complaint_time',
  93. displayName: '投诉时间',
  94. },
  95. {
  96. field: 'complainted_mchid',
  97. displayName: '用户投诉商户号',
  98. },
  99. {
  100. field: 'complaint_state',
  101. displayName: '投诉状态',
  102. cellTemplate: `<div class="temp-row" ng-class="{
  103. 'text-danger':row.entity.complaint_state=='PENDING',
  104. 'text-warning':row.entity.complaint_state=='PROCESSING',
  105. 'text-success':row.entity.complaint_state=='PROCESSED',
  106. }">{{ grid.appScope.getStateText(row.entity.complaint_state)}}</div>`
  107. },
  108. {
  109. field: 'complaint_detail', displayName: '投诉详情',
  110. cellTemplate: '<div class="temp-row" ng-click="grid.appScope.showInfoDetailInfo(\'投诉详情\',\'complaint_detail\',row.entity)" >{{row.entity.complaint_detail}}</div>'
  111. },
  112. {
  113. field: 'payer_phone',
  114. displayName: '用户联系方式',
  115. },
  116. {
  117. field: 'complaint_order_info', displayName: '订单详情',
  118. cellTemplate: '<div class="temp-row" ng-click="grid.appScope.showInfoDetailInfo(\'投诉详情\',\'complaint_order_info\',row.entity)" >{{row.entity.complaint_order_info}}</div>'
  119. },
  120. {field: 'complaint_full_refunded', displayName: '是否已退款',},
  121. {field: 'incoming_user_response', displayName: '是否有新回复',},
  122. {
  123. field: 'user_complaint_times', displayName: '投诉次数',
  124. cellTemplate: `<div class="temp-row" ng-class="{
  125. 'text-success':row.entity.user_complaint_times<=1,
  126. 'text-danger':row.entity.user_complaint_times>1,
  127. }">{{row.entity.user_complaint_times}}</div>`
  128. },
  129. {
  130. field: 'operation',
  131. displayName: '操作',
  132. enableFiltering: false,
  133. enableSorting: false,
  134. enableHiding: false,//禁止在列选择器中隐藏
  135. enableColumnMenu: false,// 是否显示列头部菜单按钮
  136. minWidth: 100,
  137. cellTemplate: '<div class="grid-button">' +
  138. '<button class="btn btn-sm btn-rounded btn-success" ng-click="grid.appScope.reply(row.entity)">回复用户</button>' +
  139. '<button class="btn btn-sm btn-rounded btn-danger" ng-click="grid.appScope.submitComplaint(row.entity)">提交投诉处理</button>' +
  140. '</div>'
  141. },
  142. ];
  143. var fields = $scope.gridOptions.columnDefs;
  144. for (var index in fields) {
  145. var item = fields[index];
  146. if (item && item['minWidth'] == null) {
  147. item['minWidth'] = 100;
  148. }
  149. }
  150. }
  151. $scope.setPagingData = function (data) {
  152. var pagedData = data.data.dataList;
  153. $scope.myData = pagedData;
  154. $scope.gridOptions.totalItems = data.data.total;
  155. };
  156. $scope.getPagedDataAsync = function (curPage, pageSize, force) {
  157. if ($scope.gridOptionsLoading) {
  158. return;
  159. }
  160. var params = {
  161. pageSize: pageSize,
  162. pageIndex: curPage,
  163. };
  164. var query = $scope.query;
  165. params.startTime = query.startTime
  166. params.endTime = query.endTime
  167. console.log(condition.searchType)
  168. if (condition.searchKey !== "") {
  169. params[condition.searchType.value] = condition.searchKey
  170. }
  171. if (condition.stateFilter.value) {
  172. params.stateFilter = condition.stateFilter.value
  173. }
  174. $scope.gridOptionsLoading = true;
  175. $http.get('/superadmin/getUserComplaintList', {
  176. params: params
  177. }).then(function (data) {
  178. data = data.data
  179. $scope.gridOptionsLoading = false;
  180. $scope.setPagingData(data, curPage, pageSize);
  181. }).catch(function (data) {
  182. toaster.pop("error", "提示", "获取数据列表失败");
  183. });
  184. };
  185. function initDataGrid() {
  186. //首次加载表格
  187. $scope.getPagedDataAsync($scope.gridOptions.paginationCurrentPage, $scope.gridOptions.paginationPageSize);
  188. }
  189. setColumnDefs();
  190. initDataGrid();
  191. $scope.reply = function (entity) {
  192. var url = "/superadmin/replyComplaint";
  193. $.confirm({
  194. content: '<textarea type="text" id="replyRemark" placeholder="输入回复内容" style="width: 320px;height: 100px"/>',
  195. title: "回复用户",
  196. buttons: {
  197. ok: {
  198. btnClass: 'btn-red',
  199. action: function () {
  200. var remark = $('#replyRemark').val()
  201. if (!remark) {
  202. return false
  203. }
  204. $http({
  205. method: 'POST',
  206. url: url,
  207. data: {
  208. complainted_mchid: entity.complainted_mchid,
  209. complaint_id: entity.complaint_id,
  210. remark: remark,
  211. }
  212. }).then(function (response) {
  213. if (response.data.result) {
  214. toaster.pop("success", "提示", "回复成功!");
  215. } else {
  216. toaster.pop("error", "提示", "回复失败!");
  217. }
  218. $scope.getPagedDataAsync($scope.gridOptions.paginationCurrentPage, $scope.gridOptions.paginationPageSize);
  219. }, function (response) {
  220. toaster.pop("error", "提示", "回复失败!");
  221. });
  222. }
  223. },
  224. }
  225. });
  226. };
  227. $scope.submitComplaint = function (entity) {
  228. var url = "/superadmin/submitComplaint";
  229. $.confirm({
  230. content: '确定提交投诉处理?',
  231. buttons: {
  232. ok: {
  233. btnClass: 'btn-red',
  234. action: function () {
  235. $http({
  236. method: 'POST',
  237. url: url,
  238. data: {
  239. complainted_mchid: entity.complainted_mchid,
  240. complaint_id: entity.complaint_id,
  241. }
  242. }).then(function (response) {
  243. if (response.data.result) {
  244. toaster.pop("success", "提示", "提交成功!");
  245. } else {
  246. toaster.pop("error", "提示", "提交失败!");
  247. }
  248. $scope.getPagedDataAsync($scope.gridOptions.paginationCurrentPage, $scope.gridOptions.paginationPageSize);
  249. }, function (response) {
  250. toaster.pop("error", "提示", "提交失败!");
  251. });
  252. }
  253. },
  254. }
  255. });
  256. };
  257. $scope.showInfoDetailInfo = function (title, key, content) {
  258. var detail = content[key]
  259. $scope.infoDetail = {title: title, content: detail};
  260. $(".devManageMain #detailInfoPanel").modal();
  261. };
  262. $scope.closeDetailPanel = function () {
  263. $(".devManageMain #detailInfoPanel").modal("hide");
  264. };
  265. }]);