| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444 |
- var tps = $(".tps");
- var id = ""; //当前节点id
- var name = ""; //当前节点name
- var pid; //当前节点父ID
- var pidName; //
- var xlName; //添加弹出框内下拉框内节点name
- var token = $.cookie("token");
- tree();
- departmentTree(); //部门名称数据
- function tree() {
- $.get(
- huayi.config.callcenter_url + "Dictionary/GetZTreeList",
- {
- token: $.cookie("token"),
- // "pid": pid
- },
- function (result) {
- result = $.parseJSON(result);
- $.fn.zTree.init($("#treeDemo"), setting1, result.data); //实例化树形图
- }
- );
- }
- var setting1 = {
- data: {
- key: {
- name: "text",
- },
- simpleData: {
- enable: true,
- idKey: "id",
- rootPId: 0,
- },
- },
- callback: {
- onClick: zTreeOnClick,
- },
- };
- function zTreeOnClick(event, treeId, treeNode) {
- id = treeNode.id;
- name = treeNode.text;
- var pidnode = treeNode.getParentNode();
- if (pidnode) {
- pidName = pidnode.text;
- pid = pidnode.id;
- } else {
- pidName = "顶级分类";
- pid = 0;
- }
- }
- var setting2 = {
- data: {
- key: {
- name: "text",
- },
- simpleData: {
- enable: true,
- idKey: "id",
- rootPId: 0,
- },
- },
- callback: {
- onClick: addTreeClick,
- },
- };
- function addTreeClick(event, treeId, treeNode) {
- addPid = treeNode.id;
- console.log(addPid);
- if (addPid == 38) {
- $(".addkey").show();
- } else {
- $(".addkey").hide();
- }
- xlName = treeNode.text;
- $(".inps1").val(xlName);
- }
- //删除按钮
- $(".del").click(function () {
- if (id == "null" || id == "") {
- layer.confirm("没有要删除的分类!", {
- btn: ["确定"],
- });
- return;
- } else {
- $(".delModel").css("display", "block");
- $(".delName").html(name);
- }
- });
- //关闭按钮
- $(".delBtr").click(function () {
- $(".delModel").css("display", "none");
- });
- //确定删除按钮
- $(".sure").click(function () {
- $.ajax({
- type: "post",
- url: huayi.config.callcenter_url + "Dictionary/DelDicValue",
- async: true,
- dataType: "json",
- data: {
- ids: id,
- token: token,
- },
- success: function (data) {
- if (data.state == "success") {
- layer.msg("删除成功!");
- tree();
- }
- },
- });
- $(".delModel").css("display", "none");
- });
- //取消删除按钮
- $(".return").click(function () {
- $(".delModel").css("display", "none");
- });
- //添加按钮
- $(".add").click(function () {
- $(".addModel").css("display", "block");
- if (name) {
- if (name == "关键字") {
- $(".addkey").show();
- } else {
- $(".addkey").hide();
- }
- tps.html(name);
- $(".inps1").val(name);
- addPid = id;
- } else {
- tps.html("顶级分类");
- $(".inps1").val("顶级分类");
- addPid = 0;
- }
- treeCont();
- });
- //添加关闭按钮
- $(".addBtr").click(function () {
- $(".addModel").css("display", "none");
- $(".addTree3").css("display", "none");
- });
- //添加内容下拉
- $(".inps1").click(function () {
- $(".xlAdd").css("display", "block");
- });
- $(".xl_one").click(function () {
- if ($(".xlAdd").css("display") == "block") {
- $(".xlAdd").css("display", "none");
- } else {
- $(".xlAdd").css("display", "block");
- }
- });
- $(".addTree").mouseleave(function () {
- $(this).css("display", "none");
- });
- //保存添加按钮
- var addPid, addDeptname, addSort;
- //添加弹出框内 所属部门下拉框内数据
- function treeCont() {
- $.get(
- huayi.config.callcenter_url + "Dictionary/GetZTreeList",
- {
- token: $.cookie("token"),
- // "pid": pid
- },
- function (result) {
- result = $.parseJSON(result);
- $.fn.zTree.init($("#addTreeDemo"), setting2, result.data); //实例化树形图
- }
- );
- }
- $(".addCun").click(function () {
- console.log(addPid);
- if ($(".inps2").val() == "") {
- if (addPid.length <= 0) {
- layer.confirm("所添加内容不能为空!", {
- btn: ["确定"],
- });
- return;
- }
- } else {
- addDeptname = $(".inps2").val();
- $(".addModel").css("display", "none");
- $.ajax({
- type: "post",
- url: huayi.config.callcenter_url + "Dictionary/AddDicValue",
- dataType: "json",
- async: true,
- data: {
- pid: addPid, //当前选择节点ID
- name: addDeptname, //部门名称
- deptid: $("#Dpment").val(), //部门名称id
- remark: $("#addRemarks").val(), //备注
- token: token,
- },
- success: function (data) {
- // console.log(data)
- // console.log(data.state);
- if (data.state == "success") {
- layer.msg("添加成功!");
- tree();
- $(".inps1").val("");
- $(".inps2").val("");
- $(".inps3").val("");
- $("#addRemarks").val("");
- }
- },
- });
- }
- });
- //修改按钮
- var chanPid, //修改弹出框内 下拉框父节点ID
- chanId, //修改弹出框内 下拉框当前节点ID
- changeName, //修改弹出框内 下拉框当前节点name
- chbcName, //保存的部门名称
- chbcSort, //保存的排序号
- chbcPid; //保存的所属部门ID
- $(".change").click(function () {
- if (id == "null" || id == "") {
- layer.confirm("没有选择要修改的项!", {
- btn: ["确定"],
- });
- return;
- } else {
- // if (String(pid) === "38") {
- $(".editkey").show();
- // } else {
- // $(".editkey").hide();
- // }
- changeAjax(id);
- $(".changeModel").css("display", "block");
- $(".chtps").html(name);
- $(".inps4").val(pidName);
- chbcPid = pid;
- changeTreeCont();
- }
- });
- //关闭按钮
- $(".changeBtr").click(function () {
- $(".changeModel").css("display", "none");
- $(".addTree3").css("display", "none");
- });
- $(".inps4").click(function () {
- $(".xlChange").css("display", "block");
- });
- //下拉按钮功能
- $(".xl_two").click(function () {
- if ($(".xlChange").css("display") == "block") {
- $(".xlChange").css("display", "none");
- } else {
- $(".xlChange").css("display", "block");
- }
- });
- //修改弹出框内 下拉树形图参数配置项
- var setting3 = {
- data: {
- key: {
- name: "text",
- },
- simpleData: {
- enable: true,
- idKey: "id",
- rootPId: 0,
- },
- },
- callback: {
- onClick: changeTreeClick,
- },
- };
- function changeTreeClick(event, treeId, treeNode) {
- // chanPid = treeNode.pId;
- chanId = treeNode.id;
- if (chanId == 38) {
- $(".editkey").show();
- } else {
- $(".editkey").hide();
- }
- changeName = treeNode.text;
- $(".inps4").val(changeName);
- var pidnode = treeNode.getParentNode();
- if (pidnode) {
- chanPid = pidnode.id;
- } else {
- chanPid = 0;
- }
- chbcPid = chanId;
- }
- //修改弹出框内 所属部门下拉框内数据
- function changeTreeCont() {
- $.get(
- huayi.config.callcenter_url + "Dictionary/GetZTreeList",
- {
- token: $.cookie("token"),
- // "pid": pid
- },
- function (result) {
- result = $.parseJSON(result);
- $.fn.zTree.init($("#changeTreeDemo"), setting3, result.data); //实例化树形图
- }
- );
- }
- function changeAjax(id) {
- $.ajax({
- type: "get",
- url: huayi.config.callcenter_url + "Dictionary/GetDicValue",
- dataType: "json",
- async: true,
- data: {
- id: id,
- token: token,
- },
- success: function (data) {
- var chanCon = data.data;
- if (pid == 0) {
- $(".inps4").val("顶级分类");
- chbcPid = pid;
- } else {
- $(".inps4").val(pidName);
- chbcPid = pid;
- }
- $(".inps5").val(chanCon.F_Value);
- $(".inps3").val(chanCon.F_DeptName);
- $("#Dpment").val(chanCon.F_Deptid);
- $("#changeRemarks").val(chanCon.F_Remark);
- // $('.inps6').val(chanCon.sort);
- // chbcSort = chanCon.sort;
- chbcName = chanCon.F_Value;
- },
- });
- }
- //修改的保存按钮功能
- function changeBaoCunAjax(id, chbcPid, chbcName) {
- $.ajax({
- type: "post",
- url: huayi.config.callcenter_url + "Dictionary/AddDicValue",
- async: true,
- dataType: "json",
- data: {
- id: id,
- pid: chbcPid,
- name: chbcName,
- deptid: $("#Dpment").val(), //部门名称id
- remark: $("#changeRemarks").val(), //备注
- token: token,
- },
- success: function (data) {
- if (data.state == "success") {
- layer.msg("修改成功!");
- tree();
- }
- },
- });
- }
- $(".changeCun").click(function () {
- if ($(".inps4").val() == "" || $(".inps5").val() == "") {
- layer.confirm("所修改内容不允许为空!", {
- btn: ["确定"],
- });
- return;
- } else {
- $(".changeModel").css("display", "none");
- console.log(
- "部门id" +
- id +
- "所属部门id" +
- chbcPid +
- "部门名称" +
- chbcName +
- "排序" +
- chbcSort
- );
- chbcPid;
- chbcName = $(".inps5").val();
- // chbcSort = $('.inps6').val();
- changeBaoCunAjax(id, chbcPid, chbcName);
- }
- });
- //部门名称数据
- function departmentTree() {
- $.get(
- huayi.config.callcenter_url + "Department/GetDeptList",
- {
- token: $.cookie("token"),
- // "pid": pid
- },
- function (result) {
- result = $.parseJSON(result);
- $.fn.zTree.init($("#addTreeDemo3"), setting4, result.data); //实例化树形图
- $.fn.zTree.init($("#addTreeDemo6"), setting4, result.data); //实例化树形图
- }
- );
- }
- var setting4 = {
- data: {
- key: {
- name: "F_DeptName",
- },
- simpleData: {
- enable: true,
- idKey: "F_DeptId",
- pIdKey: "F_PartentId",
- rootPId: 0,
- },
- },
- callback: {
- onClick: zTreeOnClick3,
- },
- };
- function zTreeOnClick3(event, treeId, treeNode) {
- // if (treeNode.level >= 2) {
- $(".inps3").val(treeNode.F_DeptName);
- $("#PID").val(treeNode.F_DeptId);
- $("#Dpment").val(treeNode.F_DeptId);
- $(".Cleans").show();
- // }
- }
- $(".inps3").focus(function () {
- $(".xlAdd3").css("display", "block");
- });
- $(".xl3").click(function () {
- if ($(".xlAdd3").css("display") == "block") {
- $(".xlAdd3").css("display", "none");
- } else {
- $(".xlAdd3").css("display", "block");
- }
- });
- $(".addTree3").mouseleave(function () {
- $(this).css("display", "none");
- });
- //清除
- $(".Cleans ").click(function () {
- $(".inps3").val("");
- $("#PID").val("");
- $("#Dpment").val("");
- });
|