index.js 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550
  1. var selTabName = "";
  2. var addTabId = 100;
  3. var laterTipIdx = 0; //定时取提示的计时器
  4. var intervalTime = 50 * 1000; //间隔时间
  5. var afterSaleVerifyIdx = 0; //售后责任人剩余12 6小时 提醒
  6. var intervalAftersale = 360;
  7. var isTipedAfterSale = 0; //是否提示过售后审核
  8. let messageBoxId = null;
  9. function activeTab(item) {
  10. var tabs = mini.get("mainTabs");
  11. var tab = tabs.getTab(item.id);
  12. if (!tab) {
  13. tab = { name: item.id, title: item.text, url: item.url, iconCls: item.iconCls, showCloseButton: true };
  14. tab = tabs.addTab(tab);
  15. }
  16. tabs.activeTab(tab);
  17. bindMenuEvent(tab._id);
  18. //tabs.on("activechanged", function (d) {
  19. // alert('refresh');
  20. //});
  21. }
  22. function bindMenuEvent(tid) {
  23. var cell = document.getElementById("mini-1$" + tid);
  24. if (cell != undefined && cell != null) {
  25. cell.setAttribute("tn", cell.innerText);
  26. $(cell).bind("contextmenu", function (e) {
  27. selTabName = cell.getAttribute("tn");
  28. var menu = mini.get("contextMenu");
  29. menu.showAtPos(e.pageX, e.pageY);
  30. return false;
  31. });
  32. }
  33. }
  34. function closeOtherFn() {
  35. var tabs = mini.get("mainTabs").tabs;
  36. for (var i = tabs.length - 1; i >= 0; i--) {
  37. if (tabs[i].title != selTabName) {
  38. mini.get("mainTabs").removeTab(i);
  39. }
  40. }
  41. }
  42. function closeAllFn() {
  43. var tabs = mini.get("mainTabs");
  44. tabs.removeAll();
  45. }
  46. function edit_pwd() {
  47. $("#txtNewPwd").val("");
  48. mini.get("pwd_win_index").show();
  49. }
  50. function savePwdFn() {
  51. var tbxOldPwd = $("#tbxOldPwd").val();
  52. var tbxNewPwd = $("#tbxNewPwd").val();
  53. var tbxRNewPwd = $("#tbxRNewPwd").val();
  54. if (tbxOldPwd == "") {
  55. mini.alert("请输入原密码!");
  56. return false;
  57. }
  58. if (tbxNewPwd == "") {
  59. mini.alert("请输入新密码!");
  60. return false;
  61. }
  62. if (tbxRNewPwd != tbxNewPwd) {
  63. mini.alert("新密码与确认密码不一致!");
  64. return false;
  65. }
  66. var pwdRegex = new RegExp('(?=.*[0-9])(?=.*[a-zA-Z])(?=.*[^a-zA-Z0-9]).{6,20}');
  67. if (!pwdRegex.test(tbxNewPwd)) {
  68. mini.alert("您的密码复杂度太低(必须包含字母、数字、特殊字符),密码长度大于6位!");
  69. return false;
  70. }
  71. var data = "tbxOldPwd=" + tbxOldPwd + "&tbxNewPwd=" + tbxNewPwd;
  72. getAjax("update_employee_pwd2", data, function (data) {
  73. resultShow(data, "mini.get('pwd_win_index').hide();");
  74. });
  75. }
  76. var mData = null;
  77. $(function () {
  78. //menu
  79. var menu = new Menu("#mainMenu", {
  80. itemclick: function (item) {
  81. if (item.children != null && item.children.length < 1) {
  82. activeTab(item);
  83. }
  84. }
  85. });
  86. $(".sidebar").mCustomScrollbar({ autoHideScrollbar: true });
  87. new MenuTip(menu);
  88. if (mData != null && mData.length > 0) {
  89. var data = mini.decode(mData);
  90. menu.loadData(data);
  91. }
  92. //$.ajax({
  93. // url: "data/menu.txt",
  94. // success: function (text) {
  95. // var data = mini.decode(text);
  96. // menu.loadData(data);
  97. // }
  98. //})
  99. //toggle
  100. $("#toggle, .sidebar-toggle").click(function () {
  101. $('body').toggleClass('compact');
  102. mini.layout();
  103. });
  104. //dropdown
  105. $(".user-toggle").click(function (event) {
  106. $(this).parent().addClass("open");
  107. return false;
  108. });
  109. $(document).click(function (event) {
  110. $(".dropdown").removeClass("open");
  111. });
  112. bindMenuEvent("1");
  113. initNet();
  114. timeForShowTip();
  115. });
  116. function timeForShowTip() {
  117. setTimeout(function () {
  118. getMyTipOrder();
  119. //checkIsAccLogin();
  120. }, 30 * 1000);
  121. }
  122. function checkIsAccLogin() {
  123. postAjax("isAccLogin", "", function (data) {
  124. console.log("isAccLogin", data);
  125. if (data == 0) {
  126. var options = {
  127. title: "警告",
  128. message: "账号在其它地方登入或已过期!!",
  129. buttons: ["ok"],
  130. iconCls: "mini-messagebox-question",
  131. showCloseButton: false,
  132. callback: function (action) {
  133. if (action == "ok") {
  134. window.location = "Login.aspx";
  135. }
  136. }
  137. }
  138. mini.showMessageBox(options);
  139. //mini.alert("账号在其它地方登入或已过期!!", "警告", function (action) {
  140. // if (action == "ok") {
  141. // window.location = "Login.aspx";
  142. // }
  143. //});
  144. return;
  145. }
  146. else {
  147. setTimeout(function () {
  148. checkIsAccLogin();
  149. }, intervalTime)
  150. }
  151. }, null, false);
  152. }
  153. function getMyTipOrder() {
  154. if (laterTipIdx <= 0) {
  155. afterSaleVerifyIdx--;
  156. if (afterSaleVerifyIdx <= 0) {
  157. isTipedAfterSale = 0;
  158. afterSaleVerifyIdx = 0;
  159. }
  160. if (mini.get(messageBoxId)) {
  161. setTimeout(function () {
  162. getMyTipOrder();
  163. }, intervalTime);
  164. return;
  165. }
  166. //tip-content提示
  167. postAjax("get_erp_my_tiporder", "af=" + isTipedAfterSale, function (data) {
  168. var toOrderState = 0;
  169. if (data.length > 0) {
  170. var tStr = "";
  171. var ids = "";
  172. var userCode = $("#userPostCode").val();
  173. if (userCode == "Supplier") {
  174. if (data[0]["VerifyState"] == undefined) {
  175. /*for (var item of data) {
  176. ids += item.ctid;
  177. ids += ",";
  178. }*/
  179. ids = data[0]["ctid"];
  180. messageBoxId = mini.showMessageBox({
  181. title: "提示",
  182. iconCls: "mini-messagebox-question",
  183. buttons: ["前往处理"],
  184. message: "有查货订单需要处理:" + ids,
  185. callback: function (action) {
  186. if (action == "前往处理") {
  187. goToCheckOrder(ids);
  188. }
  189. }
  190. });
  191. } else {
  192. for (var item of data) {
  193. if (item.VerifyState != undefined && (item.VerifyState == 0 || item.VerifyState == 3)) {
  194. tStr += (item.ctid + " 售后责任待审核。")
  195. toOrderState = 10;
  196. isTipedAfterSale = 1;
  197. afterSaleVerifyIdx = intervalAftersale;
  198. }
  199. else if (item.IsReadTag == 1) {
  200. tStr += (item.ctid + " 被打回。")
  201. toOrderState = item.OrderState;
  202. }
  203. ids += item.ctid;
  204. ids += ",";
  205. }
  206. if (tStr.length <= 0) return;
  207. tStr += " 请及时查看处理!!";
  208. messageBoxId = mini.showMessageBox({
  209. title: "提示",
  210. iconCls: "mini-messagebox-question",
  211. buttons: ["前往处理", "稍后提醒"],
  212. message: tStr,
  213. callback: function (action) {
  214. if (action == "前往处理") {
  215. ids = ids.substring(0, ids.length - 1);
  216. goToHandleOrder(ids, toOrderState);
  217. }
  218. else if (action == "稍后提醒") {
  219. laterTipIdx = 30;
  220. }
  221. }
  222. });
  223. }
  224. } else {
  225. for (var item of data) {
  226. if (item.IsReadTag == 1) {
  227. tStr += (item.ctid + " 被打回。")
  228. toOrderState = item.OrderState;
  229. }
  230. else if (item.IsReadTag == 2) {
  231. tStr += (item.ctid + " 申请退款。")
  232. toOrderState = item.OrderState;
  233. } else if (item.IsReadTag == 3) {
  234. tStr += (item.ctid + "设计费被修改。");
  235. toOrderState = item.OrderState;
  236. } else if (item.IsReadTag == 4) {
  237. tStr += (item.ctid + "售后单生成。");
  238. toOrderState = item.OrderState;
  239. }
  240. else if (item.VerifyState != undefined && item.VerifyState == 0) {
  241. tStr += (item.ctid + " 售后责任待审核。")
  242. toOrderState = 10;
  243. isTipedAfterSale = 1;
  244. afterSaleVerifyIdx = intervalAftersale;
  245. }
  246. ids += item.ctid;
  247. ids += ",";
  248. }
  249. if (tStr.length <= 0) return;
  250. tStr += " 请及时查看处理!!";
  251. messageBoxId = mini.showMessageBox({
  252. title: "提示",
  253. iconCls: "mini-messagebox-question",
  254. buttons: ["前往处理", "稍后提醒"],
  255. message: tStr,
  256. callback: function (action) {
  257. if (action == "前往处理") {
  258. ids = ids.substring(0, ids.length - 1);
  259. goToHandleOrder(ids, toOrderState);
  260. }
  261. else if (action == "稍后提醒") {
  262. laterTipIdx = 30;
  263. }
  264. }
  265. });
  266. }
  267. }
  268. }, function (data) { }, false);
  269. //线下单审核订单
  270. postAjax("verified_to_order", "", function (data) {
  271. if (data.length > 0) {
  272. messageBoxId = mini.showMessageBox({
  273. title: "提示",
  274. iconCls: "mini-messagebox-question",
  275. buttons: ["我知道了"],
  276. message: "您有订单未审核:" + data[0]["tid"],
  277. callback: function (action) {
  278. if (action == "我知道了") {
  279. postAjax("upd_supplier_audit", { ctid: data[0]["tid"], returnreason: "4" }, function (data) {
  280. resultShow(data);
  281. });
  282. }
  283. }
  284. });
  285. }
  286. }, function () { }, false);
  287. //退款提示
  288. postAjax("refund_order_tip", "", function (data) {
  289. if (data.length > 0) {
  290. let content = "";
  291. data.map(item => {
  292. content += item.content + "/n";
  293. })
  294. if (content != "") {
  295. mini.open({
  296. url: "../" + "ECharts/TipRefundList.aspx?",
  297. title: "退款详情", width: 1500, height: 500, style: "border:0px",
  298. showCloseButton: true,
  299. allowResize: true,
  300. onload: function () {
  301. //var iframe = this.getIFrameEl();
  302. //var data = { action: "new" };
  303. //iframe.contentWindow.SetData(data);
  304. },
  305. ondestroy: function (action) {
  306. }
  307. });
  308. }
  309. }
  310. }, function (data) { }, false);
  311. //共创修改备注
  312. postAjax("change_order_info", "", function (data) {
  313. if (data.length > 0) {
  314. let item = data[0];
  315. messageBoxId = mini.showMessageBox({
  316. title: "提示",
  317. iconCls: "mini-messagebox-question",
  318. width: 700,
  319. height: 405,
  320. buttons: ["同意", "不同意", "稍后处理"],
  321. html: `<div style="display:flex;font-size:16px;flex-direction: column;font-weight: 600;justify-content: center;"><span style="padding:5px 0">订单编号为:${item?.tid} 申请改价</span><span style="padding:5px 0">修改内容:${item?.content}</span><span style="color: #fb0606;padding:5px 0">同意后内容将替换订单备注</span><span style="display:flex;align-items: center; text-align: center;padding:5px 0">修改内容:<textarea id="passChangeInpupt" style="width:400px;height:100px" >${item?.seller_memo}</textarea></span></div>`,
  322. callback: function (action) {
  323. let params = { ctid: item.tid, id: item.ID }
  324. if (action == "同意") {
  325. params.type = 0;
  326. } else if (action == "不同意") {
  327. params.type = 1;
  328. }
  329. params.content = $("#passChangeInpupt").val();
  330. if (action == "同意" || action == "不同意") {
  331. postAjax("change_win_mome", params, function (e) {
  332. resultShow(e);
  333. })
  334. }
  335. }
  336. });
  337. }
  338. }, function (data) { }, false)
  339. //messageTip提示不需要操作类提示
  340. postAjax("size_order_tip", "", function (data) {
  341. if (data.length > 0) {
  342. let content = "";
  343. data.map(item => {
  344. content += item.content;
  345. })
  346. if (content != "") {
  347. messageBoxId = mini.showMessageBox({
  348. title: "提示",
  349. iconCls: "mini-messagebox-question",
  350. buttons: ["我知道了"],
  351. message: content,
  352. callback: function (action) {
  353. }
  354. });
  355. }
  356. }
  357. }, function (data) { }, false);
  358. //messageTip提示不需要操作类提示
  359. postAjax("getApplyBackCount", "", function (data) {
  360. if (data.data == 0 || data.data.length == 0) {
  361. return;
  362. }
  363. messageBoxId = mini.showMessageBox({
  364. title: "提示",
  365. iconCls: "mini-messagebox-question",
  366. buttons: ["我知道了"],
  367. message: "订单申请打回,请及时处理。\n\r" + "订单号:" + data.data,
  368. callback: function (action) {
  369. }
  370. });
  371. }, function (data) { }, false);
  372. }
  373. else {
  374. laterTipIdx--;
  375. afterSaleVerifyIdx--;
  376. if (afterSaleVerifyIdx <= 0) {
  377. isTipedAfterSale = 0;
  378. afterSaleVerifyIdx = 0;
  379. }
  380. }
  381. setTimeout(function () {
  382. getMyTipOrder();
  383. }, intervalTime);
  384. }
  385. function goToHandleOrder(ids, toOrderState) {
  386. postAjax("reset_erp_tiporder", "ids=" + ids, function (data) {
  387. });
  388. if (toOrderState == 0) {
  389. openNewSearchTab("打回订单", "EOrder/ReturnOrder.aspx", "");
  390. }
  391. else if (toOrderState == 10) {
  392. openNewSearchTab("待审核售后", "EAfterSale/WaitingVerify.aspx", "");
  393. }
  394. else if (toOrderState == 8) {
  395. openNewSearchTab("我的设计费", "EDesign/MyDesignBill.aspx", "");
  396. }
  397. else {
  398. openNewSearchTab("我的设计", "EDesign/MyDesignList.aspx", "");
  399. }
  400. }
  401. function openUserCenter() {
  402. var item = new Object();
  403. item.id = "1";
  404. item.text = "个人中心";
  405. item.url = "Center.aspx";
  406. item.iconCls = "";
  407. activeTab(item);
  408. }
  409. function openNewSearchTab(name, page, parms) {
  410. //console.log("parms", parms);
  411. var item = new Object();
  412. item.id = addTabId.toString();
  413. item.text = name;
  414. item.url = getTabUrl(page, parms);
  415. item.iconCls = "";
  416. activeTab(item);
  417. addTabId += 1;
  418. }
  419. function openItemTab(name, parms) {
  420. //console.log("parms", parms);
  421. var m_tabs = mini.get("mainTabs");
  422. var tabLsts = m_tabs.tabs;
  423. for (var i = tabLsts.length - 1; i >= 0; i--) {
  424. if (tabLsts[i].title == name) {
  425. //alert(JSON.stringify(tabLsts[i]));
  426. var tab = m_tabs.getTab(tabLsts[i].name);
  427. tab.url = getTabUrl(tab.url, parms);
  428. m_tabs.activeTab(tab);
  429. m_tabs.reloadTab(tab);
  430. return;
  431. }
  432. }
  433. if (mData != null && mData.length > 0) {
  434. for (var i = 0; i < mData.length; i++) {
  435. for (var j = 0; j < mData[i].children.length; j++) {
  436. if (mData[i].children[j].text == name) {
  437. mData[i].children[j].url = getTabUrl(mData[i].children[j].url, parms);
  438. activeTab(mData[i].children[j]);
  439. return;
  440. }
  441. }
  442. }
  443. }
  444. }
  445. function getTabUrl(url, parms) {
  446. if (url.indexOf("?") != -1) {
  447. var eIdx = url.indexOf("?");
  448. url = url.substr(0, eIdx);
  449. }
  450. return url + "?" + parms;
  451. }
  452. function transRole(r) {
  453. //if (!confirm("确认切换?")) return;
  454. //postAjax("trans_user_role", "r=" + r, function (data) {
  455. // window.location.href = "index.aspx?sys=" + data;
  456. //});
  457. if (r == 1) {
  458. window.open("http://47.114.150.226/quote_price/");
  459. }
  460. else
  461. window.open("https://www.baidu.com");
  462. }
  463. function initNet() {
  464. var il = getCookie("islocal");
  465. if (il != null && il == "1") {
  466. $(".net_span").html("访问内网");
  467. } else {
  468. $(".net_span").html("访问外网");
  469. }
  470. }
  471. function transnet(r) {
  472. var txt = "";
  473. switch (r) {
  474. case 1: txt = "访问内网"; break;
  475. default: txt = "访问外网";
  476. }
  477. if (!confirm("确认切换为[" + txt + "]?")) return;
  478. if (r == 1) {
  479. setCookie("islocal", "1");
  480. $(".net_span").html("访问内网");
  481. }
  482. else {
  483. setCookie("islocal", "0");
  484. $(".net_span").html("访问外网");
  485. }
  486. mini.alert("切换网络成功,已打开的页面需要刷新或重新打开");
  487. }
  488. function goToCheckOrder(ctid) {
  489. var sData = { "tid": ctid };
  490. sData = JSON.stringify(sData);
  491. sData = "sData=" + sData;
  492. console.log(sData);
  493. openNewSearchTab("查货列表", "EAfterSale/CheckOrderList.aspx", sData);
  494. }