designAfterOrgStatistics.zml 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365
  1. ${Scripts.src("/zinc/chart/highcharts.js")}
  2. ${Scripts.src("/zinc/chart/exporting.js")}
  3. ${Scripts.src("/zinc/chart/highcharts-zh_CN.js")}
  4. <script>
  5. var dataMap = new Z.HashMap();
  6. var dataList = [];
  7. var orgMap = new Z.HashMap();
  8. var finalizeEndMap = new Z.HashMap();
  9. var finalizeSum =0;
  10. var allOrgCountMap=new Z.HashMap();
  11. var allCount=0;
  12. //倒叙方法 [].reverse();
  13. function getObject(json)
  14. {
  15. json = json.replace(/\r/g, '');
  16. json = json.replace(/\n/g, '<br/>');
  17. json = json.replace(/\t/g, '&nbsp;&nbsp;&nbsp;&nbsp;');
  18. var reg = /(\u0000)|(\u0001)|(\u0002)|(\u0003)|(\u0004)|(\u0005)|(\u0006)|(\u0007)|(\u000b)|(\u000e)|(\u000f)|(\u0010)|(\u0011)|(\u0012)|(\u0013)|(\u0014)|(\u0015)|(\u0016)|(\u0017)|(\u0018)|(\u0019)|(\u001a)|(\u001b)|(\u001c)|(\u001d)|(\u001e)|(\u001f)/g;
  19. //var reg = //g;
  20. return Z.J.toObject(json.replace(reg, ""));
  21. }
  22. function initData()
  23. {//数据初始化
  24. <#for item : orgAfterMap.values()>
  25. dataMap.put('${item.getAfterBlamer()}', getObject('${item}'));
  26. dataList.push(dataMap.get('${item.getAfterBlamer()}'));
  27. </#for>
  28. <#for item : finalizeMap.keySet()>
  29. finalizeEndMap.put('${item}','${finalizeMap.get(item)}');
  30. </#for>
  31. <#for item : allDesignOrderCountMap.keySet()>
  32. allOrgCountMap.put('${item}','${allDesignOrderCountMap.get(item)}');
  33. </#for>
  34. <#for item : orgList>
  35. orgMap.put('${item.getOrgId()}', getObject('${item}'));
  36. </#for>
  37. };
  38. function getOrgName(orgId)
  39. {//获取售后原因
  40. return orgMap.get(''+orgId) ? orgMap.get(''+orgId).orgName : ''+orgId;
  41. }
  42. function doBuildCharts()
  43. {//构建图表
  44. var allCount = 0;
  45. var chartDatas = [];
  46. try
  47. {
  48. Z.each(dataList, function(orgData, i){
  49. allCount += orgData.afterCount ? orgData.afterCount : 0;
  50. });
  51. Z.each(dataList, function(orgData, i){
  52. var ratio = 0;
  53. if (allCount > 0)
  54. {
  55. ratio = ((orgData.afterCount ? orgData.afterCount : 0) / allCount)*100;
  56. }
  57. var name = getOrgName(orgData.afterBlamer);
  58. chartDatas.push({name: name, y:ratio.toFixed(2)*1})
  59. //chartDatas.push({name:"1232331", y:200})
  60. });
  61. }
  62. catch(e)
  63. {console.error(e)}
  64. console.log(chartDatas);
  65. console.log(allCount);
  66. Highcharts.chart('container',
  67. {
  68. chart: {plotBackgroundColor: null,plotBorderWidth: null,plotShadow: false,type: 'pie'},
  69. title: {text: '售后组织总统计(总售后单量:'+allCount+')'},
  70. tooltip: {pointFormat: '{series.name}: <b>{point.percentage:.2f}%</b>'},
  71. plotOptions:
  72. {
  73. pie:
  74. {
  75. allowPointSelect: true,
  76. cursor: 'pointer',
  77. dataLabels:
  78. {
  79. enabled: true,
  80. format: '<b>{point.name}</b>: {point.percentage:.2f} %',
  81. style: { color: (Highcharts.theme && Highcharts.theme.contrastTextColor) || 'black'}
  82. }
  83. }
  84. },
  85. series:
  86. [{
  87. name: '百分比',
  88. colorByPoint: true,
  89. data:chartDatas
  90. }]
  91. });
  92. }
  93. function doBuildChartTable()
  94. {//构建表格统计
  95. var allCount = 0;
  96. var allLostAmount = 0;
  97. var allOrderAmount = 0;
  98. var allOrgOrdAmount = 0;
  99. Z.each(dataList, function(orgData, i){
  100. var oName = getOrgName(orgData.afterBlamer);
  101. allCount += orgData.afterCount ? orgData.afterCount : 0;
  102. allLostAmount += orgData.lostAmount ? orgData.lostAmount : 0;
  103. allOrderAmount += orgData.totalOrderAmount ? Z.Amounts.toYuanMustRadix(orgData.totalOrderAmount)*1 : 0;
  104. allOrgOrdAmount += allOrgCountMap.get(oName)==null ? 0:Z.Amounts.toYuanMustRadix(allOrgCountMap.get(oName))*1;
  105. });
  106. var chartTableHtml = '';
  107. chartTableHtml += '<table class="z-table z-bordered-line z-pd10 z-bg-white z-text-left">';
  108. chartTableHtml += ' <tr class="z-bg-gray">';
  109. chartTableHtml += ' <td width="100">售后组织</td>';
  110. chartTableHtml += ' <td width="80">总定稿量</td>';
  111. chartTableHtml += ' <td width="95">总定稿金额</td>';
  112. chartTableHtml += ' <td width="80">售后单量</td>';
  113. //chartTableHtml += ' <td width="110">售后单量占比</td>';
  114. chartTableHtml += ' <td width="95">售后单损失金额</td>';
  115. chartTableHtml += ' <td width="95">售后单金额</td>';
  116. chartTableHtml += ' <td width="95">售后&总定稿金额占比</td>';
  117. chartTableHtml += ' <td width="95">售后&总定稿量占比</td>';
  118. //chartTableHtml += ' <td width="*">售后损失&订单金额占比</td>';
  119. chartTableHtml += ' </tr>';
  120. Z.each(dataList, function(orgData, i){
  121. var orgName = getOrgName(orgData.afterBlamer);
  122. var afterCount = orgData.afterCount ? orgData.afterCount : 0;
  123. var totalOrderAmount = orgData.totalOrderAmount ? Z.Amounts.toYuanMustRadix(orgData.totalOrderAmount)*1 : 0;
  124. var lostAmount = orgData.lostAmount ? orgData.lostAmount : 0;
  125. var finalizeCount = finalizeEndMap.get(orgName) == null ? 0 : finalizeEndMap.get(orgName);
  126. var allOrgCount=allOrgCountMap.get(orgName) == null ? 0 : Z.Amounts.toYuanMustRadix(allOrgCountMap.get(orgName))*1;
  127. finalizeSum += parseInt(finalizeCount);
  128. chartTableHtml += ' <tr class="z-h40" bgcolor="'+(i%2 != 0 ? '#f3fdfc' : '#ffffff')+'">';
  129. chartTableHtml += ' <td><a href="javascript:doShowDetailList(\''+orgData.afterBlamer+'\')" class="z-text-ellipsis z-pointer" style="max-width:120px" title="'+orgName+'">'+orgName+'</a></td>';
  130. chartTableHtml += ' <td>'+finalizeCount+'</td>';
  131. chartTableHtml += ' <td>'+allOrgCount+'</td>';
  132. chartTableHtml += ' <td>'+afterCount+'</td>';
  133. //chartTableHtml += ' <td>'+(allCount == 0 ? 0 : (afterCount/allCount)*100).toFixed(2)+'%</td>';
  134. chartTableHtml += ' <td>'+lostAmount.toFixed(2)+'</td>';
  135. chartTableHtml += ' <td>'+totalOrderAmount.toFixed(2)+'</td>';
  136. chartTableHtml += ' <td>'+(allOrgCount == 0 ? 100 : (totalOrderAmount/allOrgCount)*100).toFixed(2)+'%</td>';
  137. chartTableHtml += ' <td>'+(finalizeCount == 0 ? 100 : (afterCount/finalizeCount)*100).toFixed(2)+'%</td>';
  138. //chartTableHtml += ' <td>'+(totalOrderAmount == 0 ? 100 : (lostAmount/totalOrderAmount)*100).toFixed(2)+'%</td>';
  139. chartTableHtml += ' </tr>';
  140. });
  141. chartTableHtml += ' <tr class="z-bold">';
  142. chartTableHtml += ' <td>总计</td>';
  143. chartTableHtml += ' <td>'+finalizeSum+'</td>';
  144. chartTableHtml += ' <td>'+allOrgOrdAmount.toFixed(2)+'</td>';
  145. chartTableHtml += ' <td>'+allCount+'</td>';
  146. //chartTableHtml += ' <td>100%</td>';
  147. chartTableHtml += ' <td>'+allLostAmount.toFixed(2)+'</td>';
  148. chartTableHtml += ' <td>'+allOrderAmount.toFixed(2)+'</td>';
  149. chartTableHtml += ' <td>'+(allOrgOrdAmount == 0 ? 100 : (allOrderAmount/allOrgOrdAmount)*100).toFixed(2)+'%</td>';
  150. chartTableHtml += ' <td>'+(finalizeSum == 0 ? 100 : (allCount/finalizeSum)*100).toFixed(2)+'%</td>';
  151. //chartTableHtml += ' <td>'+(allOrderAmount == 0 ? 0 : (allLostAmount/allOrderAmount)*100).toFixed(2)+'%</td>';
  152. chartTableHtml += ' </tr>';
  153. chartTableHtml += ' </table>';
  154. Z("#chartTable_panal").htmlc(chartTableHtml)
  155. }
  156. Z.onload(function()
  157. {
  158. //初始化数据
  159. initData();
  160. //构建图表
  161. doBuildCharts();
  162. //构建表格统计
  163. doBuildChartTable();
  164. });
  165. function getAfterStatusHtml(status)
  166. {//获取售后状态
  167. <#for item : AfterConstants.getStatusList()>
  168. if (''+status == ''+'${item.value()}')
  169. {
  170. var status${item_index} = "${AfterConstants.statusHtml(item.value())}";
  171. return status${item_index};
  172. }
  173. </#for>
  174. return '';
  175. }
  176. function doShowDetailList(orgId)
  177. {//显示详情列表
  178. var afterModule = dataMap.get(''+orgId);
  179. var detailList = afterModule.afterDetail ? afterModule.afterDetail : [];
  180. if (detailList .length == 0)
  181. return;
  182. detailList.sort(function (a, b){
  183. a.afterCount = Z.V.isInteger(a.afterCount) ? a.afterCount : 0;
  184. b.afterCount = Z.V.isInteger(b.afterCount) ? b.afterCount : 0;
  185. a.lostAmount = Z.V.isFloat(a.lostAmount) ? a.lostAmount : 0;
  186. b.lostAmount = Z.V.isFloat(b.lostAmount) ? b.lostAmount : 0;
  187. var result1 = a.afterCount - b.afterCount;
  188. var result2 = a.lostAmount - b.lostAmount;
  189. return result2 != 0 ? result2 : result1;
  190. });
  191. detailList.sort();
  192. detailList.reverse();
  193. var detailHtml = '';
  194. var commNorecod = '';
  195. commNorecod += '<tr valign="middle" class="z-h40 z-text-center z-bg-white">';
  196. commNorecod += ' <td colspan="20">暂无数据信息</td>';
  197. commNorecod += '</tr>';
  198. var commThead = ''
  199. commThead += '<tr class="z-h40 z-text-center z-bg-gray">';
  200. commThead += ' <td width="90">售后单号</td>';
  201. commThead += ' <td width="90">设计单号</td>';
  202. commThead += ' <td width="90">处理状态</td>';
  203. commThead += ' <td width="100">损失金额</td>';
  204. commThead += ' <td width="100">设计师</td>';
  205. commThead += ' <td width="100">店铺</td>';
  206. commThead += ' <td width="100">旺旺号</td>';
  207. commThead += ' <td width="*">产品</td>';
  208. commThead += ' <td width="90">订单金额</td>';
  209. commThead += ' <td width="90">售后创建时间</td>';
  210. commThead += ' <td width="90">联系人</td>';
  211. commThead += ' <td width="100">联系电话</td>';
  212. commThead += '</tr>';
  213. detailHtml += '<div class="z-overflow-y-auto" style="max-height:750px">';
  214. detailHtml += '<table class="z-table z-bordered z-bg-white z-text-center">';
  215. detailHtml += commThead;
  216. if (detailList.length > 0)
  217. {
  218. Z.each(detailList, function(item, i)
  219. {
  220. detailHtml += '<tr align="center" class="z-h40 z-pointer" bgcolor="'+(i%2 != 0 ? '#f3fdfc' : '#ffffff')+'"> ';
  221. detailHtml += ' <td>'+item.designAfsId+'</td>';
  222. detailHtml += ' <td>'+item.designId+'</td>';
  223. detailHtml += ' <td>'+getAfterStatusHtml(item.afterStatus)+'</td>';
  224. detailHtml += ' <td>'+(item.lossAmount ? item.lossAmount : 0).toFixed(2)+'</td>';
  225. detailHtml += ' <td>'+item.designer+'</td>';
  226. detailHtml += ' <td>'+(item.shopNick ? item.shopNick : '')+'</td>';
  227. detailHtml += ' <td>'+(item.buyerNick ? item.buyerNick : '')+'</td>';
  228. detailHtml += ' <td>'+(item.orderText ? item.orderText : '')+'</td>';
  229. detailHtml += ' <td>'+parseFloat((item.amount ? Z.Amounts.toYuanMustRadix(''+item.amount) : 0)).toFixed(2)+'</td>';
  230. detailHtml += ' <td>'+(item.afterFinishTime ? item.afterCreateTime : '')+'</td>';
  231. detailHtml += ' <td>'+(item.userContact ? item.userContact : '')+'</td>';
  232. detailHtml += ' <td>'+(item.userMobile ? item.userMobile : '')+'</td>';
  233. detailHtml += '</tr>';
  234. });
  235. detailHtml += '<tr valign="middle" class="z-h40 z-text-right z-bg-white">';
  236. detailHtml += ' <td colspan="15">共&nbsp;<span class="z-text-red">'+detailList.length+'</span>&nbsp;条数据&nbsp;&nbsp;</td>';
  237. detailHtml += '</tr>';
  238. }
  239. else
  240. detailHtml += commNorecod;
  241. detailHtml += ' </table>';
  242. detailHtml += '</div>'
  243. detailHtml += '</table>';
  244. detailHtml += '</div>';
  245. var title ='<span class="zi-text-red zi-bold">['+getOrgName(afterModule.afterBlamer)+']</span>售后订单详情统';
  246. if (Z("#detailHtml").length == 0)
  247. Z.dialog({id:'detailDialog',title: '<span id="detailDialogTile"><span>', text: '<div id="detailHtml"></div>', width:1300, height:780, shadow:true})
  248. Z("#detailDialogTile").htmlc(title);
  249. Z("#detailHtml").htmlc(detailHtml);
  250. }
  251. </script>
  252. ${zhiqim_manager_breadcrumb("售后统计")}
  253. ${zhiqim_manager_content()}
  254. <#-- 导航栏 -->
  255. <div class="z-tabnav-main z-blue z-mg-b20">
  256. <nav>
  257. <ul>
  258. <li onclick="Z.Location.href('personalAfterStatistics.htm');">个人售后统计</li>
  259. <#if ZmrPathRule.check(request, "/designAfterStatistics.htm")><li onclick="Z.L.href('designAfterStatistics.htm')">售后订单统计</li></#if>
  260. <#if ZmrPathRule.check(request, "/designAfterCreateStatistics.htm")><li onclick="Z.L.href('designAfterCreateStatistics.htm')">售后创建统计</li></#if>
  261. <#if ZmrPathRule.check(request, "/designAfterReasonStatistics.htm")><li onclick="Z.L.href('designAfterReasonStatistics.htm')">售后原因统计</li></#if>
  262. <li class="z-active">售后组织统计</li>
  263. </ul>
  264. </nav>
  265. </div>
  266. <#-- 查询条件 -->
  267. ${zhiqim_manager_title("查询条件")}
  268. <form name="theForm" action="/designAfterOrgStatistics.htm">
  269. <table class="z-table z-bordered z-pd6">
  270. <tr class="z-h40 z-bg-white">
  271. <td>查询日期:
  272. <select name="year" class="z-select" data-role="z-select" data-class="z-blue">
  273. <#for yyyy : 2018..DateTimes.getCurrentYear()>
  274. <option value="${yyyy}" <#if year==yyyy>selected</#if>>${yyyy}</option>
  275. </#for>
  276. </select>
  277. <select name="month" class="z-select" data-role="z-select" data-class="z-blue">
  278. <#for mm : 1..12>
  279. <option value="${mm}" <#if month==mm>selected</#if>>${mm}</option>
  280. </#for>
  281. </select>
  282. <button type="button" class="z-mg-l10 z-button ${zmr_color_class}" onclick="Z.loading({shadow: true});this.form.submit();">查询</button>
  283. </td>
  284. </tr>
  285. </table>
  286. </form>
  287. <br>
  288. <#-- 分页列表-->
  289. <table class="z-table z-bordered z-pd6 z-bg-white">
  290. <tr>
  291. <td width="40%"><div id="container" class="z-bg-white" style="min-width:400px;height:600px"></div></td>
  292. <td width="*" valign="top">
  293. <div id="chartTable_panal" class="z-overflow-y-auto" style="max-height:750px">
  294. <table class="z-table z-bordered-line z-pd10 z-bg-white z-text-left">
  295. <tr class="z-bg-gray">
  296. <td width="100">售后组织</td>
  297. <td width="80">总定稿量</td>
  298. <td width="95">总定稿金额</td>
  299. <td width="80">售后单量</td>
  300. <!--<td width="110">售后单量占比</td> -->
  301. <td width="95">售后单损失金额</td>
  302. <td width="95">售后单金额</td>
  303. <td width="95">售后&总定稿金额占比</td>
  304. <td width="95">售后&总定稿量占比</td>
  305. <!--<td width="*">售后损失&订单金额占比</td>-->
  306. </tr>
  307. <tr class="z-bold">
  308. <td>总计</td>
  309. <td>0</td>
  310. <td>0</td>
  311. <td>0</td>
  312. <td>0</td>
  313. <td>0</td>
  314. </tr>
  315. </table>
  316. </div>
  317. </td>
  318. </tr>
  319. </table>
  320. ${zhiqim_manager_content_end()}