dic.js 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. var treeData = null;
  2. var treeSel = null;
  3. var tree = null;
  4. var importValueList = [{ "text": "中通快递标准模板", "value": "http://cloudprint.cainiao.com/template/standard/301/221" }, { "text": "中通快递标准三联模板", "value": "http://cloudprint.cainiao.com/template/standard/74805/47" }, { "text": "中通快递标准模板(蓝牙版)", "value": "http://cloudprint.cainiao.com/template/standard/285198/2" }, { "text": "中通便携式模板", "value": "http://cloudprint.cainiao.com/template/standard/278404/3" }, { "text": "中通便携式模板(高度200mm)", "value": "http://cloudprint.cainiao.com/template/standard/288345/4" }, { "text": "中通一联单", "value": "http://cloudprint.cainiao.com/template/standard/300336/38" }, { "text": "中通蓝牙一联单", "value": "http://cloudprint.cainiao.com/template/standard/308812/8" }];
  5. $(document).ready(function () {
  6. if (treeData != null) {
  7. tree = mini.get("m_tree");
  8. tree.loadList(treeData, "id", "pid");
  9. if (treeSel != null) {
  10. $_selTreeNode();
  11. }
  12. }
  13. });
  14. function $_selTreeNode() {
  15. if (treeSel == null) true;
  16. tree.expandPath(treeSel);
  17. tree.expandNode(treeSel);
  18. tree.selectNode(treeSel);
  19. //alert(tree.scrollIntoView);
  20. tree.scrollIntoView(tree.getNode(treeSel));
  21. }
  22. function getParentName(pId) {
  23. if (treeData != null && treeData.length > 0) {
  24. for (var i = 0; i < treeData.length; i++) {
  25. if (treeData[i].id == pId) return treeData[i].name;
  26. }
  27. }
  28. return "";
  29. }
  30. function treeNodeSelFn(e, node) {
  31. var id = e.node.id;
  32. $("#hId").val(id);
  33. $("#hName").val(e.node.name);
  34. if (id == "0") {
  35. addFn();
  36. $("#designTable").hide()
  37. } else {
  38. $("#designTable").show()
  39. getDesignInfo()
  40. getAjax("get_dic_item", "class=" + $("#hClass").val() + "&mId=" + id, function (dataList) {
  41. if (dataList.length > 0) {
  42. var data = dataList[0];
  43. mini.get("btnAdd").setEnabled(true);
  44. mini.get("btnDel").setEnabled(true);
  45. $("#hParentId").val(data.ParentID);
  46. var pName = getParentName(data.ParentID);
  47. $("#txtParentName").val(pName);
  48. $("#txtName").val(data.Name);
  49. $("#txtCode").val(data.Code);
  50. if ($("#selShop").is(':visible')) {
  51. mini.get("selPemShop").setValue(data.pemShop);
  52. }
  53. $("#txtSort").val(data.Sort);
  54. $("#chkDel")[0].checked = (data.IsDel == "False" ? false : true);
  55. if ($("#OldOrder").is(':visible')) {
  56. $("#OldOrder")[0].checked = (data.OldOrder == "False" ? false : true);
  57. }
  58. $("#txtMemo").val(data.Memo);
  59. if (data.Url != undefined) $("#txtUrl").val(data.Url);
  60. if (data.Tag != undefined) $("#txtTag").val(data.Tag);
  61. if (data.Icon != undefined) $("#txtIcon").val(data.Icon);
  62. if (data.HostFieldName != undefined) $("#txtHostFieldName").val(data.HostFieldName);
  63. if (data.HostName != undefined) $("#txtHostName").val(data.HostName);
  64. if (data.MaxStock != undefined) $("#txtMaxStock").val(data.MaxStock);
  65. if (data.WarningStock != undefined) $("#txtWarningStock").val(data.WarningStock);
  66. if (data.isOperate != undefined) $("#chkOperate")[0].checked = (data.isOperate == "False" ? false : true);
  67. }
  68. });
  69. }
  70. }
  71. function addFn() {
  72. var id = $("#hId").val();
  73. $("#hParentId").val(id);
  74. var objs = $(".m_tb").find("input");
  75. for (var i = 0; i < objs.length; i++) {
  76. if (objs[i].type == "text") {
  77. objs[i].value = "";
  78. }
  79. else if (objs[i].type = "checkbox") {
  80. objs[i].checked = false;
  81. }
  82. }
  83. var pName = getParentName(id);
  84. $("#txtParentName").val(pName);
  85. $("#txtMemo").val("");
  86. mini.get("btnAdd").setEnabled(false);
  87. mini.get("btnDel").setEnabled(false);
  88. if ($("#selShop").is(':visible')) {
  89. mini.get("selPemShop").setValue("");
  90. }
  91. $("#hId").val("");
  92. }
  93. function saveFn() {
  94. var id = $("#hId").val();
  95. var pArr = new Array();
  96. if (id == "" || id == "0") {
  97. pArr.push("id=0");
  98. pArr.push("pid=" + $("#hParentId").val());
  99. } else {
  100. if ($("#hParentId").val() == "") {
  101. alert("数据错误无法保存");
  102. return;
  103. }
  104. pArr.push("id=" + $("#hId").val());
  105. pArr.push("pid=" + $("#hParentId").val());
  106. }
  107. pArr.push("class=" + $("#hClass").val());
  108. pArr.push("name=" + encodeURIComponent($("#txtName").val()));
  109. pArr.push("code=" + $("#txtCode").val());
  110. if ($("#selShop").is(':visible')) {
  111. pArr.push("selPemShop=" + mini.get("selPemShop").getValue());
  112. }
  113. pArr.push("sort=" + $("#txtSort").val());
  114. pArr.push("del=" + ($("#chkDel")[0].checked ? "1" : "0"));
  115. if ($("#OldOrder").is(':visible')) {
  116. pArr.push("oldOrder=" + ($("#OldOrder")[0].checked ? "1" : "0"));
  117. }
  118. pArr.push("memo=" + encodeURI($("#txtMemo").val()));
  119. if ($("#chkOperate").length > 0) pArr.push("operate=" + ($("#chkOperate")[0].checked ? "1" : "0"));
  120. if ($("#txtUrl").length > 0) pArr.push("url=" + $("#txtUrl").val());
  121. if ($("#txtTag").length > 0) pArr.push("tag=" + $("#txtTag").val());
  122. if ($("#txtIcon").length > 0) pArr.push("icon=" + $("#txtIcon").val());
  123. if ($("#txtHostFieldName").length > 0) pArr.push("hostfield=" + encodeURIComponent($("#txtHostFieldName").val()));
  124. if ($("#txtHostName").length > 0) pArr.push("hostname=" + encodeURIComponent($("#txtHostName").val()));
  125. if ($("#txtMaxStock").length > 0) pArr.push("maxstock=" + $("#txtMaxStock").val());
  126. if ($("#txtWarningStock").length > 0) pArr.push("warningstock=" + $("#txtWarningStock").val());
  127. getAjax("save_dic_item", pArr.join("&"), async function (data) {
  128. if (data != "") {
  129. var sArr = data.split('|');
  130. await saveShopDesign();
  131. setTimeout(() => {
  132. window.location = "DicPage.aspx?t=" + $("#hClass").val() + "&mId=" + sArr[0];
  133. }, 200);
  134. //resultShow(sArr[1], "");
  135. } else {
  136. alert('保存失败!');
  137. }
  138. });
  139. }
  140. function delFn() {
  141. var id = $("#hId").val();
  142. if (id == "") {
  143. alert("找不到要删除的项!");
  144. return false;
  145. }
  146. getAjax("del_dic_item", "class=" + $("#hClass").val() + "&mId=" + id, function (data) {
  147. if (data != "") {
  148. var sArr = data.split('|');
  149. resultShow(sArr[1], "window.location='DicPage.aspx?t=" + $("#hClass").val() + "&mId=" + sArr[0] + "';");
  150. } else {
  151. alert('删除失败!');
  152. }
  153. });
  154. }
  155. function builderFn() {
  156. var id = $("#hId").val();
  157. if (id == "") {
  158. alert("找不到要生成的项!");
  159. return false;
  160. }
  161. getAjax("build_dic_item", "mId=" + id, function (data) {
  162. if (data != "") {
  163. var sArr = data.split('|');
  164. window.location = "DicPage.aspx?t=" + $("#hClass").val() + "&mId=" + sArr[0];
  165. //resultShow(sArr[1], "");
  166. } else {
  167. alert('保存失败!');
  168. }
  169. });
  170. }
  171. function transferFn() {
  172. var id = $("#hId").val();
  173. if (id == "") {
  174. alert("找不到要操作的项!");
  175. return false;
  176. }
  177. var win = mini.get("transfer_win");
  178. win.setTitle("节点转移");
  179. win.show();
  180. }
  181. function saveTransferFn() {
  182. var id = $("#hId").val();
  183. var pId = $("#selTrans").val();
  184. var sort = mini.get("txtTransSort").getValue();
  185. if (sort == "") {
  186. alert("排序不允许为空!");
  187. return;
  188. }
  189. getAjax("transfer_dic_item", "class=" + $("#hClass").val() + "&mId=" + id + "&pId=" + pId + "&sort=" + sort, function (data) {
  190. if (data != "") {
  191. var sArr = data.split('|');
  192. window.location = "DicPage.aspx?t=" + $("#hClass").val() + "&mId=" + sArr[0];
  193. //resultShow(sArr[1], "");
  194. } else {
  195. alert('保存失败!');
  196. }
  197. });
  198. }