index.js 20 KB

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