center.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372
  1. var isOnDuty = null;
  2. var postCode = null;
  3. var userId = null;
  4. var curDateType = 1;
  5. var noticeData = null;
  6. window.onload = function () {
  7. postAjax("get_user_info", "", function (data) {
  8. $("#userIcon").attr("src", data[0]["Picture"] != "" ? data[0]["Picture"] : "images/userCenter/user.png");
  9. $("#userName").text(data[0]["Name"]);
  10. $("#depName").text(data[0]["OrgName"]);
  11. $("#postName").text(data[0]["PostName"]);
  12. isOnDuty = data[0]["OnDuty"];
  13. isBeOnDuty = data[0]["BeOnDuty"];
  14. postCode = data[0]["PostCode"];
  15. userId = data[0]["ID"];
  16. userPostCode = postCode;
  17. $("#id_customer1").show();
  18. $("#id_all1").hide();
  19. mini.get()
  20. //设计
  21. if (postCode == "Designer" || postCode == "Designerhd" || postCode == "DesignerMr" || postCode == "wxDesigner" || postCode == "wxDesignerMr") {
  22. $("#dutyState").text(isOnDuty == 1 ? (isBeOnDuty == 1 ? "(值班)接单中" : "(上班)接单中") : "未到岗");
  23. $("#dutyState").css("color", isOnDuty == 1 ? "green" : "red");
  24. mini.get("btnOnduty").setEnabled(isOnDuty != 1);
  25. mini.get("cmbSearchDate").setValue(1);
  26. //$("#userOnduty").css('visibility', 'visible');
  27. //$("#id_design1").css('visibility', 'visible');
  28. //$("#id_design2").css('visibility', 'visible');
  29. $("#id_all1").show();
  30. $("#id_all2").show();
  31. $("#userOnduty").show();
  32. $("#id_design1").show();
  33. $("#id_design2").show();
  34. $("#id_design3").show();
  35. $("#id_design4").show();
  36. getDesignerDataList(1);
  37. $("#dataDesignCount").show();
  38. $("#dataBackCount").show();
  39. getCenterDataList(0)
  40. }
  41. //客服
  42. if (postCode == "CustomerService" || postCode == "Director") {
  43. $("#id_all1").show();
  44. $("#id_all2").show();
  45. mini.get("cmbSearchDate").setValue(1);
  46. $("#id_customer1").show();
  47. $("#id_customer2").show();
  48. $("#id_customer3").show();
  49. getCustomerDataList(1);
  50. $("#dataDesignCount").show();
  51. $("#dataOrderCount").show();
  52. $("#dataSendCount").show();
  53. $("#dataBackCount").show();
  54. $("#dataRefundCount").show();
  55. getCenterDataList(0)
  56. }
  57. //售后
  58. if (postCode == "AfterSale" || postCode == "AfterSaleMaster") {
  59. $("#dataSendCount").show();
  60. $("#dataRefundCount").show();
  61. $("#dataCheckCount").show();
  62. getCenterDataList(2)
  63. }
  64. //下单部
  65. if (postCode == "Place" || postCode == "PlaceMr") {
  66. $("#dataOrderCount").show();
  67. $("#dataSendCount").show();
  68. getCenterDataList(1)
  69. }
  70. //车间
  71. if (postCode == "Supplier") {
  72. $("#dataCheckCount").show();
  73. getCenterDataList(5)
  74. }
  75. });
  76. postAjax("get_center_data", "", function (data) {
  77. if (data && data.length > 0) {
  78. let info = data[0];
  79. $("#designCountText").text(`(${info.designCount || 0})`)
  80. $("#orderCountText").text(`(${info.orderCount || 0})`)
  81. $("#sendCountText").text(`(${info.sendCount || 0})`)
  82. $("#backCountText").text(`(${info.backCount || 0})`)
  83. $("#refundCountText").text(`(${info.refundCount || 0})`)
  84. $("#checkCountText").text(`(${info.checkCount || 0})`)
  85. }
  86. })
  87. if (noticeData != null && noticeData.length > 0) {
  88. //console.log("noticedata", noticeData);
  89. var wt = this.document.body.clientWidth;
  90. var ht = this.document.body.clientHeight;
  91. mini.open({
  92. url: "../" + "ENotice/Notice_win.aspx?",
  93. title: "公告栏", width: wt - 100, height: ht - 200, style: "border:0px",
  94. showCloseButton: false,
  95. allowResize: true,
  96. onload: function () {
  97. //var iframe = this.getIFrameEl();
  98. //var data = { action: "new" };
  99. //iframe.contentWindow.SetData(data);
  100. },
  101. ondestroy: function (action) {
  102. }
  103. });
  104. //openWin("订单详情", "EOrder/Order_Detail.aspx?ctid=" + ctid + "&tid=" + tid + "", 1000, 500);
  105. //var ahtml = "";
  106. //var ids = "";
  107. //for (var item of noticeData) {
  108. // ids += item.ID;
  109. // ids += ",";
  110. // ahtml += ("<div style=\"font-size:20px;color:#000000; margin-top:15px;line-height:25px; \">标题:" + item.Title + "</div>")
  111. // ahtml += ("<div style=\"font-size:10px;color:lightgray; margin-top:5px;line-height:15px; \">来自:" + item.senderName + " " + formatCommonDate(item.CreatedTime) + "</div>")
  112. // ahtml += ("<div style=\"font-size:14px;color:#3C3C3C; margin-top:5px;line-height:25px;overflow:hidden;word-break:break-all; \">内容:" + item.Con + "</div>")
  113. //}
  114. //ahtml += ("<a style=\"width:100px;height:30px;text-align:center;line-height:30px;margin-left:400px;margin-top:20px;\" class=\"mini-button mini-button-primary\" iconcls=\"icon-ok\" onclick=\"clickToRead('" + ids + "')\">已读通知</a>");
  115. //$("#notice_con").html(ahtml);
  116. //mini.get("notice_win").show();
  117. }
  118. };
  119. //function clickToRead(ids) {
  120. // postAjax("set_erp_readnotice", "ids=" + ids, function (data) {
  121. // mini.get("notice_win").hide();
  122. // });
  123. //}
  124. function getCenterDataList(order_type) {
  125. let data_grid = mini.get("data_grid");
  126. let title = "";
  127. switch (order_type) {
  128. case 0:
  129. title = "设计超时";
  130. break;
  131. case 1:
  132. title = "下单超时";
  133. break;
  134. case 2:
  135. title = "发货超时";
  136. break;
  137. case 3:
  138. title = "打回订单";
  139. break;
  140. case 4:
  141. title = "退款订单";
  142. break;
  143. case 5:
  144. title = "查货超时";
  145. break;
  146. default:
  147. break;
  148. }
  149. $("#center_data_layout .mini-panel-title").text(title);
  150. data_grid.load({ order_type });
  151. }
  152. function userOnDuty() {
  153. mini.showMessageBox({
  154. title: "请选择是“上班”还是“值班”",
  155. iconCls: "mini-messagebox-question",
  156. buttons: ["上班", "值班", "晚班", "取消"],
  157. message: "选择:上班,值班,晚班,取消。",
  158. callback: function (action) {
  159. if (action == "上班" || action == "值班" || action == "晚班") {
  160. postAjax("upd_user_onduty", "duty=" + action, function (data) {
  161. $("#dutyState").text("(" + action + ")接单中");
  162. $("#dutyState").css("color", "green");
  163. mini.get("btnOnduty").setEnabled(false);
  164. });
  165. }
  166. }
  167. });
  168. }
  169. function userOffDuty() {
  170. postAjax("upd_user_offduty", "", function (data) {
  171. $("#dutyState").text("未到岗");
  172. $("#dutyState").css("color", "red");
  173. mini.get("btnOnduty").setEnabled(true);
  174. });
  175. }
  176. function dispatchDTRenderer(e) {
  177. var record = e.record;
  178. var html = "<div>" + formatCommonDate(record.WaitDesignTime) + "</div>";
  179. return html;
  180. }
  181. function overtimeDTRenderer(e) {
  182. var record = e.record;
  183. var html = "<div>接单:" + formatCommonDate(record.WaitDesignTime) + "</div>";
  184. html += "<div>超时:" + formatCommonDate(record.WaitDesignTime) + "</div>";
  185. return html;
  186. }
  187. function isAutoDispatchRenderer(e) {
  188. var record = e.record;
  189. var html = "<div>" + record.IsAutoDispatch ? "是" : "否" + "</div>";
  190. return html;
  191. }
  192. function getDesignerDataList(dateType) {
  193. if (dateType == 3) {
  194. postAjax("get_total_data", "", function (data) {
  195. $("#_totalCount").text(data[0]["orderCount"]);
  196. $("#_totalAmount").text(data[0]["orderAmount"]);
  197. $("#_refundCount").text(data[0]["refundCount"]);
  198. $("#_refundAmount").text(data[0]["refundAmount"]);
  199. $("#_unBeginAmount").text(data[0]["orderBeginAmount"]);
  200. $("#_unBeginCount").text(data[0]["orderBeginCount"]);
  201. $("#_unFinishAmount").text(data[0]["orderFinishAmount"]);
  202. $("#_unFinishCount").text(data[0]["orderFinishCount"]);
  203. var per = Math.floor(parseInt(data[0]["refundCount"]) / parseInt(data[0]["orderCount"]) * 100);
  204. if (parseInt(data[0]["orderCount"]) == 0) {
  205. per = 0;
  206. }
  207. $("#_refundCountPer").text(per + "%");
  208. });
  209. } else {
  210. postAjax("get_date_area_total_data", "timetype=" + dateType, function (data) {
  211. var strData = data.data;
  212. var dataList = strData.split(",");
  213. $("#_unBeginCount").text(dataList[2]);
  214. $("#_unBeginAmount").text(dataList[3]);
  215. $("#_unFinishCount").text(dataList[4]);
  216. $("#_unFinishAmount").text(dataList[5]);
  217. $("#_totalCount").text(dataList[0]);
  218. $("#_totalAmount").text(dataList[1]);
  219. $("#_refundCount").text(dataList[6]);
  220. $("#_refundAmount").text(dataList[7]);
  221. var per = Math.floor(parseInt(dataList[6]) / (parseInt(dataList[0])) * 100);
  222. if (parseInt(dataList[0]) == 0) {
  223. per = 0;
  224. }
  225. $("#_refundCountPer").text("率:" + per + "%");
  226. });
  227. }
  228. var timearr = [];
  229. if (dateType == 0) {
  230. var day = getCurDate();
  231. timearr.push(day);
  232. timearr.push(day);
  233. }
  234. else if (dateType == 1) {
  235. timearr = getWeekStartAndEnd();
  236. }
  237. else if (dateType == 2) {
  238. timearr = getMonthStartAndEnd();
  239. }
  240. wait_grid = mini.get("wait_grid");
  241. wait_grid.load({
  242. paraFields: "ctid, WaitDesignTime,payment,IsAutoDispatch",
  243. paraOrder: "WaitDesignTime asc",
  244. paraWhere: "OrderState = 3 and DesignUserId = " + userId + " and WaitDesignTime >= '" + timearr[0] + "' and WaitDesignTime <= '" + timearr[1] + "'",
  245. paraPageSize: 1000
  246. });
  247. design_grid = mini.get("design_grid");
  248. design_grid.load({
  249. paraFields: "ctid, WaitDesignTime,payment,IsAutoDispatch",
  250. paraOrder: "WaitDesignTime asc",
  251. paraWhere: "OrderState = 4 and DesignUserId = " + userId + " and WaitDesignTime >= '" + timearr[0] + "' and WaitDesignTime <= '" + timearr[1] + "'",
  252. paraPageSize: 1000
  253. });
  254. unusual_grid = mini.get("unusual_grid");
  255. unusual_grid.load({
  256. paraFields: "ctid, WaitDesignTime,UnusualTime,payment,IsAutoDispatch",
  257. paraOrder: "WaitDesignTime asc",
  258. paraWhere: "OvertimeUserId = " + userId + " and WaitDesignTime >= '" + timearr[0] + "' and WaitDesignTime <= '" + timearr[1] + "'",
  259. paraPageSize: 1000
  260. });
  261. //wait_grid = mini.get("wait_grid");
  262. //wait_grid.load({ date_type: dateType });
  263. order_grid = mini.get("order_grid");
  264. order_grid.load({ date_type: dateType });
  265. amount_grid = mini.get("amount_grid");
  266. amount_grid.load({ date_type: dateType });
  267. refundOrder_grid = mini.get("refundOrder_grid");
  268. refundOrder_grid.load({ date_type: dateType });
  269. refundAmount_grid = mini.get("refundAmount_grid");
  270. refundAmount_grid.load({ date_type: dateType });
  271. }
  272. function getCustomerDataList(dateType) {
  273. if (dateType == 3) {
  274. postAjax("get_total_data", "", function (data) {
  275. $("#_totalCount").text(data[0]["orderCount"]);
  276. $("#_totalAmount").text(data[0]["orderAmount"]);
  277. $("#_afterCount").text(data[0]["afterCount"]);
  278. $("#_afterAmount").text(data[0]["afterAmount"]);
  279. $("#_refundCount").text(data[0]["refundCount"]);
  280. $("#_refundAmount").text(data[0]["refundAmount"]);
  281. var per = Math.floor(parseInt(data[0]["refundCount"]) / parseInt(data[0]["orderCount"]) * 100);
  282. if (parseInt(data[0]["orderCount"]) == 0) {
  283. per = 0;
  284. }
  285. $("#_refundCountPer").text(per + "%");
  286. });
  287. } else {
  288. postAjax("get_date_area_total_data", "timetype=" + dateType, function (data) {
  289. var strData = data.data;
  290. var dataList = strData.split(",");
  291. $("#_afterCount").text(dataList[2]);
  292. $("#_afterAmount").text(dataList[3]);
  293. $("#_totalCount").text(dataList[0]);
  294. $("#_totalAmount").text(dataList[1]);
  295. $("#_refundCount").text(dataList[4]);
  296. $("#_refundAmount").text(dataList[5]);
  297. var per = Math.floor(parseInt(dataList[4]) / (parseInt(dataList[0])) * 100);
  298. if (parseInt(dataList[0]) == 0) {
  299. per = 0;
  300. }
  301. $("#_refundCountPer").text("率:" + per + "%");
  302. });
  303. }
  304. }
  305. function changeDateAreaFn() {
  306. curDateType = mini.get("cmbSearchDate").getValue();
  307. if (postCode == "Designer" || postCode == "DesignerMr") {
  308. getDesignerDataList(curDateType);
  309. }
  310. else {
  311. getCustomerDataList(curDateType);
  312. }
  313. }
  314. function openItemTab(name, parms) {
  315. if (parent != null) parent.openItemTab(name, parms);
  316. }
  317. function openOrderTab(parms) {
  318. if (parent != null) parent.openItemTab("订单列表", parms);
  319. }
  320. function openMyOrderTab(name, parms) {
  321. if (parent != null) parent.openItemTab("我的订单", parms);
  322. }
  323. function clickToMyDesignList(state) {
  324. if (parent != null) parent.openItemTab("我的设计", state);
  325. }
  326. function clickToMyRefund(tType) {
  327. if (tType == 1) {
  328. var timetype = "time=" + curDateType;
  329. if (parent != null) parent.openItemTab("退款确认", timetype);
  330. }
  331. else {
  332. if (parent != null) parent.openItemTab("退款确认", "");
  333. }
  334. }