index.js 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556
  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. }
  181. setTimeout(function () {
  182. getMyTipOrder();
  183. }, 3 * 60000);
  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. }
  213. else if (action == "稍后提醒") {
  214. laterTipIdx = 30;
  215. }
  216. setTimeout(function () {
  217. getMyTipOrder();
  218. }, intervalTime);
  219. }
  220. });
  221. }
  222. } else {
  223. for (var item of data) {
  224. if (item.IsReadTag == 1) {
  225. tStr += (item.ctid + " 被打回。")
  226. toOrderState = item.OrderState;
  227. }
  228. else if (item.IsReadTag == 2) {
  229. tStr += (item.ctid + " 申请退款。")
  230. toOrderState = item.OrderState;
  231. } else if (item.IsReadTag == 3) {
  232. tStr += (item.ctid + "设计费被修改。");
  233. toOrderState = item.OrderState;
  234. } else if (item.IsReadTag == 4) {
  235. tStr += (item.ctid + "售后单生成。");
  236. toOrderState = item.OrderState;
  237. }
  238. else if (item.VerifyState != undefined && item.VerifyState == 0) {
  239. tStr += (item.ctid + " 售后责任待审核。")
  240. toOrderState = 10;
  241. isTipedAfterSale = 1;
  242. afterSaleVerifyIdx = intervalAftersale;
  243. }
  244. ids += item.ctid;
  245. ids += ",";
  246. }
  247. if (tStr.length <= 0) return;
  248. tStr += " 请及时查看处理!!";
  249. mini.showMessageBox({
  250. title: "提示",
  251. iconCls: "mini-messagebox-question",
  252. buttons: ["前往处理", "稍后提醒"],
  253. message: tStr,
  254. callback: function (action) {
  255. if (action == "前往处理") {
  256. ids = ids.substring(0, ids.length - 1);
  257. goToHandleOrder(ids, toOrderState);
  258. }
  259. else if (action == "稍后提醒") {
  260. laterTipIdx = 30;
  261. }
  262. setTimeout(function () {
  263. getMyTipOrder();
  264. }, intervalTime);
  265. }
  266. });
  267. }
  268. }
  269. else {
  270. setTimeout(function () {
  271. getMyTipOrder();
  272. }, intervalTime);
  273. }
  274. }, function (data) { }, false);
  275. postAjax("back_supplier_audit", "", function (data) {
  276. if (data.length > 0) {
  277. mini.showMessageBox({
  278. title: "提示",
  279. iconCls: "mini-messagebox-question",
  280. buttons: ["同意撤回订单", "不同意"],
  281. message: "有订单需要撤回处理:" + data[0]["tid"],
  282. callback: function (action) {
  283. if (action == "同意撤回订单") {
  284. mini.showMessageBox({
  285. title: "提示",
  286. iconCls: "mini-messagebox-question",
  287. buttons: ["确认撤回订单", "不同意"],
  288. message: "有订单需要撤回处理:" + data[0]["tid"],
  289. callback: function (action) {
  290. if (action == "确认撤回订单") {
  291. postAjax("upd_supplier_audit", { ctid: data[0]["tid"], returnreason: "1" }, function (data) {
  292. resultShow(data);
  293. });
  294. } else if (action == "不同意") {
  295. postAjax("upd_supplier_audit", { ctid: data[0]["tid"], returnreason: "2" }, function (data) {
  296. resultShow(data);
  297. });
  298. }
  299. }
  300. });
  301. } else if (action == "不同意") {
  302. postAjax("upd_supplier_audit", { ctid: data[0]["tid"], returnreason: "2" }, function (data) {
  303. resultShow(data);
  304. });
  305. }
  306. }
  307. });
  308. }
  309. }, function (data) { }, false);
  310. postAjax("verified_to_order", "", function (data) {
  311. if (data.length > 0) {
  312. mini.showMessageBox({
  313. title: "提示",
  314. iconCls: "mini-messagebox-question",
  315. buttons: ["我知道了"],
  316. message: "您有订单未审核:" + data[0]["tid"],
  317. callback: function (action) {
  318. if (action == "我知道了") {
  319. postAjax("upd_supplier_audit", { ctid: data[0]["tid"], returnreason: "4" }, function (data) {
  320. resultShow(data);
  321. });
  322. }
  323. }
  324. });
  325. }
  326. }, function () { }, false);
  327. postAjax("refund_order_tip", "", function (data) {
  328. if (data.length > 0) {
  329. let content = "";
  330. data.map(item => {
  331. content += item.content + "/n";
  332. })
  333. if (content != "") {
  334. mini.open({
  335. url: "../" + "ECharts/TipRefundList.aspx?",
  336. title: "退款详情", width: 1500, height: 500, style: "border:0px",
  337. showCloseButton: true,
  338. allowResize: true,
  339. onload: function () {
  340. //var iframe = this.getIFrameEl();
  341. //var data = { action: "new" };
  342. //iframe.contentWindow.SetData(data);
  343. },
  344. ondestroy: function (action) {
  345. }
  346. });
  347. }
  348. }
  349. }, function (data) { }, false);
  350. postAjax("change_order_info", "", function (data) {
  351. if (data.length > 0) {
  352. let item = data[0];
  353. mini.showMessageBox({
  354. title: "提示",
  355. iconCls: "mini-messagebox-question",
  356. width: 700,
  357. height: 405,
  358. buttons: ["同意", "不同意", "稍后处理"],
  359. 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>`,
  360. callback: function (action) {
  361. let params = { ctid: item.tid, id: item.ID }
  362. if (action == "同意") {
  363. params.type = 0;
  364. } else if (action == "不同意") {
  365. params.type = 1;
  366. }
  367. params.content = $("#passChangeInpupt").val();
  368. if (action == "同意" || action == "不同意") {
  369. postAjax("change_win_mome", params, function (e) {
  370. resultShow(e);
  371. })
  372. }
  373. }
  374. });
  375. }
  376. }, function (data) { }, false)
  377. }
  378. else {
  379. laterTipIdx--;
  380. afterSaleVerifyIdx--;
  381. if (afterSaleVerifyIdx <= 0) {
  382. isTipedAfterSale = 0;
  383. afterSaleVerifyIdx = 0;
  384. }
  385. setTimeout(function () {
  386. getMyTipOrder();
  387. }, intervalTime);
  388. }
  389. }
  390. function goToHandleOrder(ids, toOrderState) {
  391. postAjax("reset_erp_tiporder", "ids=" + ids, function (data) {
  392. });
  393. if (toOrderState == 0) {
  394. openNewSearchTab("打回订单", "EOrder/ReturnOrder.aspx", "");
  395. }
  396. else if (toOrderState == 10) {
  397. openNewSearchTab("待审核售后", "EAfterSale/WaitingVerify.aspx", "");
  398. }
  399. else if (toOrderState == 8) {
  400. openNewSearchTab("我的设计费", "EDesign/MyDesignBill.aspx", "");
  401. }
  402. else {
  403. openNewSearchTab("我的设计", "EDesign/MyDesignList.aspx", "");
  404. }
  405. }
  406. function openUserCenter() {
  407. var item = new Object();
  408. item.id = "1";
  409. item.text = "个人中心";
  410. item.url = "Center.aspx";
  411. item.iconCls = "";
  412. activeTab(item);
  413. }
  414. function openNewSearchTab(name, page, parms) {
  415. //console.log("parms", parms);
  416. var item = new Object();
  417. item.id = addTabId.toString();
  418. item.text = name;
  419. item.url = getTabUrl(page, parms);
  420. item.iconCls = "";
  421. activeTab(item);
  422. addTabId += 1;
  423. }
  424. function openItemTab(name, parms) {
  425. //console.log("parms", parms);
  426. var m_tabs = mini.get("mainTabs");
  427. var tabLsts = m_tabs.tabs;
  428. for (var i = tabLsts.length - 1; i >= 0; i--) {
  429. if (tabLsts[i].title == name) {
  430. //alert(JSON.stringify(tabLsts[i]));
  431. var tab = m_tabs.getTab(tabLsts[i].name);
  432. tab.url = getTabUrl(tab.url, parms);
  433. m_tabs.activeTab(tab);
  434. m_tabs.reloadTab(tab);
  435. return;
  436. }
  437. }
  438. if (mData != null && mData.length > 0) {
  439. for (var i = 0; i < mData.length; i++) {
  440. for (var j = 0; j < mData[i].children.length; j++) {
  441. if (mData[i].children[j].text == name) {
  442. mData[i].children[j].url = getTabUrl(mData[i].children[j].url, parms);
  443. activeTab(mData[i].children[j]);
  444. return;
  445. }
  446. }
  447. }
  448. }
  449. }
  450. function getTabUrl(url, parms) {
  451. if (url.indexOf("?") != -1) {
  452. var eIdx = url.indexOf("?");
  453. url = url.substr(0, eIdx);
  454. }
  455. return url + "?" + parms;
  456. }
  457. function transRole(r) {
  458. //if (!confirm("确认切换?")) return;
  459. //postAjax("trans_user_role", "r=" + r, function (data) {
  460. // window.location.href = "index.aspx?sys=" + data;
  461. //});
  462. if (r == 1) {
  463. window.open("http://47.114.150.226/quote_price/");
  464. }
  465. else
  466. window.open("https://www.baidu.com");
  467. }
  468. function initNet() {
  469. var il = getCookie("islocal");
  470. if (il != null && il == "1") {
  471. $(".net_span").html("访问内网");
  472. } else {
  473. $(".net_span").html("访问外网");
  474. }
  475. }
  476. function transnet(r) {
  477. var txt = "";
  478. switch (r) {
  479. case 1: txt = "访问内网"; break;
  480. default: txt = "访问外网";
  481. }
  482. if (!confirm("确认切换为[" + txt + "]?")) return;
  483. if (r == 1) {
  484. setCookie("islocal", "1");
  485. $(".net_span").html("访问内网");
  486. }
  487. else {
  488. setCookie("islocal", "0");
  489. $(".net_span").html("访问外网");
  490. }
  491. mini.alert("切换网络成功,已打开的页面需要刷新或重新打开");
  492. }
  493. function goToCheckOrder(ctid) {
  494. var sData = { "tid": ctid };
  495. sData = JSON.stringify(sData);
  496. sData = "sData=" + sData;
  497. console.log(sData);
  498. openNewSearchTab("查货列表", "EAfterSale/CheckOrderList.aspx", sData);
  499. }