Keine Beschreibung

shuJuZiDian.js 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444
  1. var tps = $(".tps");
  2. var id = ""; //当前节点id
  3. var name = ""; //当前节点name
  4. var pid; //当前节点父ID
  5. var pidName; //
  6. var xlName; //添加弹出框内下拉框内节点name
  7. var token = $.cookie("token");
  8. tree();
  9. departmentTree(); //部门名称数据
  10. function tree() {
  11. $.get(
  12. huayi.config.callcenter_url + "Dictionary/GetZTreeList",
  13. {
  14. token: $.cookie("token"),
  15. // "pid": pid
  16. },
  17. function (result) {
  18. result = $.parseJSON(result);
  19. $.fn.zTree.init($("#treeDemo"), setting1, result.data); //实例化树形图
  20. }
  21. );
  22. }
  23. var setting1 = {
  24. data: {
  25. key: {
  26. name: "text",
  27. },
  28. simpleData: {
  29. enable: true,
  30. idKey: "id",
  31. rootPId: 0,
  32. },
  33. },
  34. callback: {
  35. onClick: zTreeOnClick,
  36. },
  37. };
  38. function zTreeOnClick(event, treeId, treeNode) {
  39. id = treeNode.id;
  40. name = treeNode.text;
  41. var pidnode = treeNode.getParentNode();
  42. if (pidnode) {
  43. pidName = pidnode.text;
  44. pid = pidnode.id;
  45. } else {
  46. pidName = "顶级分类";
  47. pid = 0;
  48. }
  49. }
  50. var setting2 = {
  51. data: {
  52. key: {
  53. name: "text",
  54. },
  55. simpleData: {
  56. enable: true,
  57. idKey: "id",
  58. rootPId: 0,
  59. },
  60. },
  61. callback: {
  62. onClick: addTreeClick,
  63. },
  64. };
  65. function addTreeClick(event, treeId, treeNode) {
  66. addPid = treeNode.id;
  67. console.log(addPid);
  68. if (addPid == 38) {
  69. $(".addkey").show();
  70. } else {
  71. $(".addkey").hide();
  72. }
  73. xlName = treeNode.text;
  74. $(".inps1").val(xlName);
  75. }
  76. //删除按钮
  77. $(".del").click(function () {
  78. if (id == "null" || id == "") {
  79. layer.confirm("没有要删除的分类!", {
  80. btn: ["确定"],
  81. });
  82. return;
  83. } else {
  84. $(".delModel").css("display", "block");
  85. $(".delName").html(name);
  86. }
  87. });
  88. //关闭按钮
  89. $(".delBtr").click(function () {
  90. $(".delModel").css("display", "none");
  91. });
  92. //确定删除按钮
  93. $(".sure").click(function () {
  94. $.ajax({
  95. type: "post",
  96. url: huayi.config.callcenter_url + "Dictionary/DelDicValue",
  97. async: true,
  98. dataType: "json",
  99. data: {
  100. ids: id,
  101. token: token,
  102. },
  103. success: function (data) {
  104. if (data.state == "success") {
  105. layer.msg("删除成功!");
  106. tree();
  107. }
  108. },
  109. });
  110. $(".delModel").css("display", "none");
  111. });
  112. //取消删除按钮
  113. $(".return").click(function () {
  114. $(".delModel").css("display", "none");
  115. });
  116. //添加按钮
  117. $(".add").click(function () {
  118. $(".addModel").css("display", "block");
  119. if (name) {
  120. if (name == "关键字") {
  121. $(".addkey").show();
  122. } else {
  123. $(".addkey").hide();
  124. }
  125. tps.html(name);
  126. $(".inps1").val(name);
  127. addPid = id;
  128. } else {
  129. tps.html("顶级分类");
  130. $(".inps1").val("顶级分类");
  131. addPid = 0;
  132. }
  133. treeCont();
  134. });
  135. //添加关闭按钮
  136. $(".addBtr").click(function () {
  137. $(".addModel").css("display", "none");
  138. $(".addTree3").css("display", "none");
  139. });
  140. //添加内容下拉
  141. $(".inps1").click(function () {
  142. $(".xlAdd").css("display", "block");
  143. });
  144. $(".xl_one").click(function () {
  145. if ($(".xlAdd").css("display") == "block") {
  146. $(".xlAdd").css("display", "none");
  147. } else {
  148. $(".xlAdd").css("display", "block");
  149. }
  150. });
  151. $(".addTree").mouseleave(function () {
  152. $(this).css("display", "none");
  153. });
  154. //保存添加按钮
  155. var addPid, addDeptname, addSort;
  156. //添加弹出框内 所属部门下拉框内数据
  157. function treeCont() {
  158. $.get(
  159. huayi.config.callcenter_url + "Dictionary/GetZTreeList",
  160. {
  161. token: $.cookie("token"),
  162. // "pid": pid
  163. },
  164. function (result) {
  165. result = $.parseJSON(result);
  166. $.fn.zTree.init($("#addTreeDemo"), setting2, result.data); //实例化树形图
  167. }
  168. );
  169. }
  170. $(".addCun").click(function () {
  171. console.log(addPid);
  172. if ($(".inps2").val() == "") {
  173. if (addPid.length <= 0) {
  174. layer.confirm("所添加内容不能为空!", {
  175. btn: ["确定"],
  176. });
  177. return;
  178. }
  179. } else {
  180. addDeptname = $(".inps2").val();
  181. $(".addModel").css("display", "none");
  182. $.ajax({
  183. type: "post",
  184. url: huayi.config.callcenter_url + "Dictionary/AddDicValue",
  185. dataType: "json",
  186. async: true,
  187. data: {
  188. pid: addPid, //当前选择节点ID
  189. name: addDeptname, //部门名称
  190. deptid: $("#Dpment").val(), //部门名称id
  191. remark: $("#addRemarks").val(), //备注
  192. token: token,
  193. },
  194. success: function (data) {
  195. // console.log(data)
  196. // console.log(data.state);
  197. if (data.state == "success") {
  198. layer.msg("添加成功!");
  199. tree();
  200. $(".inps1").val("");
  201. $(".inps2").val("");
  202. $(".inps3").val("");
  203. $("#addRemarks").val("");
  204. }
  205. },
  206. });
  207. }
  208. });
  209. //修改按钮
  210. var chanPid, //修改弹出框内 下拉框父节点ID
  211. chanId, //修改弹出框内 下拉框当前节点ID
  212. changeName, //修改弹出框内 下拉框当前节点name
  213. chbcName, //保存的部门名称
  214. chbcSort, //保存的排序号
  215. chbcPid; //保存的所属部门ID
  216. $(".change").click(function () {
  217. if (id == "null" || id == "") {
  218. layer.confirm("没有选择要修改的项!", {
  219. btn: ["确定"],
  220. });
  221. return;
  222. } else {
  223. // if (String(pid) === "38") {
  224. $(".editkey").show();
  225. // } else {
  226. // $(".editkey").hide();
  227. // }
  228. changeAjax(id);
  229. $(".changeModel").css("display", "block");
  230. $(".chtps").html(name);
  231. $(".inps4").val(pidName);
  232. chbcPid = pid;
  233. changeTreeCont();
  234. }
  235. });
  236. //关闭按钮
  237. $(".changeBtr").click(function () {
  238. $(".changeModel").css("display", "none");
  239. $(".addTree3").css("display", "none");
  240. });
  241. $(".inps4").click(function () {
  242. $(".xlChange").css("display", "block");
  243. });
  244. //下拉按钮功能
  245. $(".xl_two").click(function () {
  246. if ($(".xlChange").css("display") == "block") {
  247. $(".xlChange").css("display", "none");
  248. } else {
  249. $(".xlChange").css("display", "block");
  250. }
  251. });
  252. //修改弹出框内 下拉树形图参数配置项
  253. var setting3 = {
  254. data: {
  255. key: {
  256. name: "text",
  257. },
  258. simpleData: {
  259. enable: true,
  260. idKey: "id",
  261. rootPId: 0,
  262. },
  263. },
  264. callback: {
  265. onClick: changeTreeClick,
  266. },
  267. };
  268. function changeTreeClick(event, treeId, treeNode) {
  269. // chanPid = treeNode.pId;
  270. chanId = treeNode.id;
  271. if (chanId == 38) {
  272. $(".editkey").show();
  273. } else {
  274. $(".editkey").hide();
  275. }
  276. changeName = treeNode.text;
  277. $(".inps4").val(changeName);
  278. var pidnode = treeNode.getParentNode();
  279. if (pidnode) {
  280. chanPid = pidnode.id;
  281. } else {
  282. chanPid = 0;
  283. }
  284. chbcPid = chanId;
  285. }
  286. //修改弹出框内 所属部门下拉框内数据
  287. function changeTreeCont() {
  288. $.get(
  289. huayi.config.callcenter_url + "Dictionary/GetZTreeList",
  290. {
  291. token: $.cookie("token"),
  292. // "pid": pid
  293. },
  294. function (result) {
  295. result = $.parseJSON(result);
  296. $.fn.zTree.init($("#changeTreeDemo"), setting3, result.data); //实例化树形图
  297. }
  298. );
  299. }
  300. function changeAjax(id) {
  301. $.ajax({
  302. type: "get",
  303. url: huayi.config.callcenter_url + "Dictionary/GetDicValue",
  304. dataType: "json",
  305. async: true,
  306. data: {
  307. id: id,
  308. token: token,
  309. },
  310. success: function (data) {
  311. var chanCon = data.data;
  312. if (pid == 0) {
  313. $(".inps4").val("顶级分类");
  314. chbcPid = pid;
  315. } else {
  316. $(".inps4").val(pidName);
  317. chbcPid = pid;
  318. }
  319. $(".inps5").val(chanCon.F_Value);
  320. $(".inps3").val(chanCon.F_DeptName);
  321. $("#Dpment").val(chanCon.F_Deptid);
  322. $("#changeRemarks").val(chanCon.F_Remark);
  323. // $('.inps6').val(chanCon.sort);
  324. // chbcSort = chanCon.sort;
  325. chbcName = chanCon.F_Value;
  326. },
  327. });
  328. }
  329. //修改的保存按钮功能
  330. function changeBaoCunAjax(id, chbcPid, chbcName) {
  331. $.ajax({
  332. type: "post",
  333. url: huayi.config.callcenter_url + "Dictionary/AddDicValue",
  334. async: true,
  335. dataType: "json",
  336. data: {
  337. id: id,
  338. pid: chbcPid,
  339. name: chbcName,
  340. deptid: $("#Dpment").val(), //部门名称id
  341. remark: $("#changeRemarks").val(), //备注
  342. token: token,
  343. },
  344. success: function (data) {
  345. if (data.state == "success") {
  346. layer.msg("修改成功!");
  347. tree();
  348. }
  349. },
  350. });
  351. }
  352. $(".changeCun").click(function () {
  353. if ($(".inps4").val() == "" || $(".inps5").val() == "") {
  354. layer.confirm("所修改内容不允许为空!", {
  355. btn: ["确定"],
  356. });
  357. return;
  358. } else {
  359. $(".changeModel").css("display", "none");
  360. console.log(
  361. "部门id" +
  362. id +
  363. "所属部门id" +
  364. chbcPid +
  365. "部门名称" +
  366. chbcName +
  367. "排序" +
  368. chbcSort
  369. );
  370. chbcPid;
  371. chbcName = $(".inps5").val();
  372. // chbcSort = $('.inps6').val();
  373. changeBaoCunAjax(id, chbcPid, chbcName);
  374. }
  375. });
  376. //部门名称数据
  377. function departmentTree() {
  378. $.get(
  379. huayi.config.callcenter_url + "Department/GetDeptList",
  380. {
  381. token: $.cookie("token"),
  382. // "pid": pid
  383. },
  384. function (result) {
  385. result = $.parseJSON(result);
  386. $.fn.zTree.init($("#addTreeDemo3"), setting4, result.data); //实例化树形图
  387. $.fn.zTree.init($("#addTreeDemo6"), setting4, result.data); //实例化树形图
  388. }
  389. );
  390. }
  391. var setting4 = {
  392. data: {
  393. key: {
  394. name: "F_DeptName",
  395. },
  396. simpleData: {
  397. enable: true,
  398. idKey: "F_DeptId",
  399. pIdKey: "F_PartentId",
  400. rootPId: 0,
  401. },
  402. },
  403. callback: {
  404. onClick: zTreeOnClick3,
  405. },
  406. };
  407. function zTreeOnClick3(event, treeId, treeNode) {
  408. // if (treeNode.level >= 2) {
  409. $(".inps3").val(treeNode.F_DeptName);
  410. $("#PID").val(treeNode.F_DeptId);
  411. $("#Dpment").val(treeNode.F_DeptId);
  412. $(".Cleans").show();
  413. // }
  414. }
  415. $(".inps3").focus(function () {
  416. $(".xlAdd3").css("display", "block");
  417. });
  418. $(".xl3").click(function () {
  419. if ($(".xlAdd3").css("display") == "block") {
  420. $(".xlAdd3").css("display", "none");
  421. } else {
  422. $(".xlAdd3").css("display", "block");
  423. }
  424. });
  425. $(".addTree3").mouseleave(function () {
  426. $(this).css("display", "none");
  427. });
  428. //清除
  429. $(".Cleans ").click(function () {
  430. $(".inps3").val("");
  431. $("#PID").val("");
  432. $("#Dpment").val("");
  433. });