From 45faaf27722588e92050e2e3eace9b3704377048 Mon Sep 17 00:00:00 2001 From: ZZJ <zzjdsg2300@163.com> Date: 星期六, 02 四月 2022 18:44:30 +0800 Subject: [PATCH] 首页接口 --- vue.config.js | 10 src/views/equipmentManagement/equipmentDetail/components/UnbindBox.vue | 2 src/views/index/components/rightForm.vue | 37 src/views/hashrate/CameraManage/index.vue | 50 src/views/productDetail/components/ConfirmOrder.vue | 94 src/views/index/components/productLeft.vue | 15 src/components/giantTree/zTree/ztree_v3/jquery.ztree.all.js | 3036 ++++++++++++++++------ src/views/product/components/ProductContent.vue | 60 src/views/index/index.vue | 266 - src/components/Connect.vue | 3 src/views/index/components/rightTabs.vue | 1 src/views/productDetail/components/OffpayInstruct.vue | 165 + src/views/hashrate/index.vue | 13 src/views/hashrate/AlgManage/index.vue | 242 - src/Pool/TreeData.ts | 30 src/views/index/components/commendContent.vue | 32 src/components/Price.vue | 71 src/api/login.js | 23 src/views/productDetail/index.vue | 5 src/api/clusterManage.ts | 8 src/views/index/components/banner.vue | 44 src/components/IndexHeader.vue | 27 src/views/productDetail/components/PayCard.vue | 10 src/views/index/components/rightColumn.vue | 41 src/views/search/components/giantTree/zTree/ztree_v3/jquery.ztree.all.js | 3032 ++++++++++++++++------ src/views/index/components/rightRrid.vue | 31 src/api/product.ts | 45 src/api/area.ts | 8 /dev/null | 58 src/api/algorithm.ts | 7 src/views/register/components/ResetPassword.vue | 14 src/views/manageCenter/index.vue | 10 src/scripts/httpRequest.ts | 9 src/views/product/components/productCard.vue | 2 test.html | 8 src/views/connectUs/components/consult.vue | 66 src/views/connectUs/index.vue | 10 src/views/hashrate/AlgManage/components/AlgCard.vue | 45 src/views/productDetail/components/UploadBox.vue | 349 ++ src/App.vue | 12 src/api/device.js | 36 41 files changed, 5,734 insertions(+), 2,293 deletions(-) diff --git a/src/App.vue b/src/App.vue index 76561ce..27261e1 100644 --- a/src/App.vue +++ b/src/App.vue @@ -152,6 +152,18 @@ } } +.limitRow2 { + word-wrap: break-word; + // 鍙瓒呰繃瀹藉害灏辨崲琛岋紝涓嶈涓枃杩樻槸鑻辨枃 + word-break: break-all; + // 璁╂枃鏈彧鑳藉睍绀轰袱琛� + display: -webkit-box; + -webkit-box-orient: vertical; + -webkit-line-clamp: 2; + overflow: hidden; + text-overflow: ellipsis; +} + .gutter { background-color: rgb(233, 235, 238); padding: 1px; diff --git a/src/Pool/TreeData.ts b/src/Pool/TreeData.ts index 27be295..49b9c0e 100644 --- a/src/Pool/TreeData.ts +++ b/src/Pool/TreeData.ts @@ -11,6 +11,8 @@ getCameraBaseImage } from '@/api/area' +import {getClusterDevList} from '@/api/clusterManage' + export default class TreeDataPool { public openeds: Array<boolean> public activeTreeData: Array<object> @@ -63,6 +65,8 @@ public cameraNameForBaseImage: string public gb28181CameraBaseImage: string public baseImageLoading: boolean + public clusterId: string + public devId: string constructor() { this.openeds = [true, true, false] @@ -102,6 +106,23 @@ this.cameraNameForBaseImage = "" this.gb28181CameraBaseImage = "" this.baseImageLoading = false + + this.clusterId = "" + this.devId = "" + + this.getId() + } + + async getId(){ + + //鍏堟嬁闆嗙兢id鎴栬澶噄d + const res:any = await getClusterDevList() + if(res.data.clusterList.length > 0) { + this.clusterId = res.data.clusterList[0].cluster_id + } + else { + this.devId = res.data.devList[0].devId + } } setVideoArr(index: number, value: object, vue: any): void { @@ -338,17 +359,22 @@ async fetchLocalTree() { let params: any = { + parentId:"", searchType: this.searchCamType, - cameraName: this.searchInput + cameraName: this.searchInput, + clusterId:this.clusterId, + devId:this.devId //isPlatform: 1 } if (this.searchFrom == 'cluster') { params.isPlatform = 1 } + + const rsp: any = await getLocalCameraTree(params) if (rsp && rsp.success) { - this.treeData = rsp.data ? rsp.data : [] + this.treeData = rsp.data.treeMenu ? rsp.data.treeMenu : [] if (this.treeData && this.treeData.length > 0) { this.sortTreeData(this.treeData) } diff --git a/src/api/algorithm.ts b/src/api/algorithm.ts index 84370ef..30930f1 100644 --- a/src/api/algorithm.ts +++ b/src/api/algorithm.ts @@ -115,4 +115,11 @@ url: '/saas/api-s/sdk/unInstall', method: 'post', data +}) + +// 璁惧鍗歌浇鍏ㄩ儴绠楁硶 +export const unInstallAll = (data) => request({ + url: '/saas/api-s/sdk/downloadOrUpgradeAll', + method: 'post', + data }) \ No newline at end of file diff --git a/src/api/area.ts b/src/api/area.ts index 17f5043..5395da4 100644 --- a/src/api/area.ts +++ b/src/api/area.ts @@ -1,11 +1,11 @@ import request from "@/scripts/httpRequest"; import qs from "qs"; -export const getLocalCameraTree = (query: any) => { +export const getLocalCameraTree = (data: any) => { return request({ - url: "/data/api-v/area/localmenu", - method: "get", - params: query + url: "/saas/api-s/area/localmenu", + method: "post", + data: data }); }; diff --git a/src/api/clusterManage.ts b/src/api/clusterManage.ts index 690d640..cadb61d 100644 --- a/src/api/clusterManage.ts +++ b/src/api/clusterManage.ts @@ -127,4 +127,12 @@ method: "post", data }) +} + +//鑾峰彇闆嗙兢鍒楄〃 +export const getClusterDevList = () => { + return request({ + url: "/saas/api-s/area/getClusterDevList", + method: "get", + }) } \ No newline at end of file diff --git a/src/api/device.js b/src/api/device.js index b3eeb9a..fe9fa13 100644 --- a/src/api/device.js +++ b/src/api/device.js @@ -7,7 +7,7 @@ */ export const addDevice = (params) => { return request({ - url: "/data/api-d/device/addDevice", + url: "/sass/api-d/device/addDevice", method: "post", data: params, }); @@ -25,7 +25,7 @@ */ export const findDevList = (params) => { return request({ - url: "/data/api-d/device/findDeviceList", + url: "/saas/api-d/device/findDeviceListByUser", method: "post", data: params, }); @@ -37,7 +37,7 @@ */ export const findDevListByUser = () => { return request({ - url: "/data/api-d/device/getAllDeviceMenu", + url: "/saas/api-d/device/getAllDeviceMenu", method: "get", }); }; @@ -49,7 +49,7 @@ */ export const unbind = (params) => { return request({ - url: "/data/api-d/device/unbind", + url: "/sass/api-d/device/unbind", method: "post", data: params, }); @@ -58,7 +58,7 @@ // 鏄剧ず璁惧璇︽儏 export const findDevDetail = (data) => { return request({ - url: "/data/api-d/device/show", + url: "/sass/api-d/device/show", method: "post", data, }); @@ -67,7 +67,7 @@ //鍥炲~閲嶅惎鏃ユ湡 export const getRestartTask = (data) => { return request({ - url: "/data/api-d/device/getRestartTask", + url: "/sass/api-d/device/getRestartTask", method: "post", data, }); @@ -76,7 +76,7 @@ // 璁剧疆閲嶅惎鏃ユ湡 export const setRestartTask = (data) => { return request({ - url: "/data/api-d/device/setRestartTask", + url: "/sass/api-d/device/setRestartTask", method: "post", data, }); @@ -85,7 +85,7 @@ // 璁剧疆閲嶅惎鏃ユ湡 export const restart = (data) => { return request({ - url: "/data/api-d/device/restart", + url: "/sass/api-d/device/restart", method: "post", data, }); @@ -94,7 +94,7 @@ // 妫�鏌ユ渶鏂扮増鏈� export const checkVersion = (data) => { return request({ - url: "/data/api-d/device/checkVersion", + url: "/sass/api-d/device/checkVersion", method: "post", data, }); @@ -103,7 +103,7 @@ // 鏇存柊鏈�鏂扮増鏈� export const updateVersion = (data) => { return request({ - url: "/data/api-d/device/updateVersion", + url: "/sass/api-d/device/updateVersion", method: "post", data, }); @@ -112,7 +112,7 @@ // 鑾峰彇搴旂敤 export const findAllApp = (data) => { return request({ - url: "/data/api-d/device/findAllApp", + url: "/sass/api-d/device/findAllApp", method: "post", data, }); @@ -121,7 +121,7 @@ // 鑾峰彇绠楁硶 export const findAllSdk = (data) => { return request({ - url: "/data/api-d/device/findAllSdk", + url: "/sass/api-d/device/findAllSdk", method: "post", data, }); @@ -130,7 +130,7 @@ // 鑾峰彇璁惧鎬ц兘 export const showSystemStates = (data) => { return request({ - url: "/data/api-d/device/showSystemStates", + url: "/sass/api-d/device/showSystemStates", method: "post", data, }); @@ -139,7 +139,7 @@ // 鑾峰彇绠楁硶璧勬簮 export const showProcesses = (data) => { return request({ - url: "/data/api-d/device/showProcesses", + url: "/sass/api-d/device/showProcesses", method: "post", data, }); @@ -148,7 +148,7 @@ // 鍗歌浇绠楁硶 export const unInstallSdk = (data) => { return request({ - url: "/data/api-d/device/unInstallSdk", + url: "/sass/api-d/device/unInstallSdk", method: "post", data, }); @@ -157,7 +157,7 @@ // 鍗歌浇搴旂敤 export const unInstallApp = (data) => { return request({ - url: "/data/api-d/device/unInstallApp", + url: "/sass/api-d/device/unInstallApp", method: "post", data, }); @@ -166,7 +166,7 @@ // 鍗囩骇绠楁硶搴旂敤 export const installAppSdk = (data) => { return request({ - url: "/data/api-d/device/installAppSdk", + url: "/sass/api-d/device/installAppSdk", method: "post", data, }); @@ -175,7 +175,7 @@ // 鑾峰彇鏃堕棿 export const clockInfo = (data) => { return request({ - url: "/data/api-d/device/clockInfo", + url: "/sass/api-d/device/clockInfo", method: "post", data, }); diff --git a/src/api/login.js b/src/api/login.js index 819ac5a..de0f94f 100644 --- a/src/api/login.js +++ b/src/api/login.js @@ -1,11 +1,11 @@ -import request from "./index"; +import request from "@/scripts/httpRequest"; import qs from "qs"; // 鐧诲綍 export const tologin = (query) => { // let query = 'username=' + user.loginName + '&password=' + user.password return request({ - url: "/saas/api-u/user/login", + url: "/cloud/api-u/user/login", method: "post", data: qs.stringify(query), }); @@ -15,17 +15,17 @@ export const logout = () => { // let token = sessionStorage.getItem('loginedInfo') && JSON.parse(sessionStorage.getItem('loginedInfo')).access_token return request({ - url: "/saas/api-u/user/logout", + url: "/cloud/api-u/user/logout", method: "post", }); }; // 鑾峰彇楠岃瘉鐮� -export const getVerifyCode = (query) => { +export const getVerifyCode = (data) => { return request({ - url: "/saas/api-u/user/makeVerifyCode", - method: "get", - params: query, + url: "/saas/api-i/saasIndex/sendVerifyCode", + method: "post", + data, }); }; @@ -125,3 +125,12 @@ data: qs.stringify(query), }); }; + +//鑱旂郴鎴戜滑 +export const saveConnectUs = (data) => { + return request({ + url: "/saas/api-i/saasIndex/saveConnectUs", + method: "post", + data, + }); +}; diff --git a/src/api/login.ts b/src/api/login.ts deleted file mode 100644 index 2473dce..0000000 --- a/src/api/login.ts +++ /dev/null @@ -1,51 +0,0 @@ -import request from "@/scripts/httpRequest"; -import qs from "qs"; - -// 鐧诲綍 -export const tologin = (query: any) => { - // let query = 'username=' + user.loginName + '&password=' + user.password - return request({ - url: '/data/api-u/sys/login', - method: 'post', - data: qs.stringify(query) - }) -}; - -// 閫�鍑� -export const logout = (query: any) => { - let token = sessionStorage.getItem('loginedInfo') && JSON.parse(sessionStorage.getItem('loginedInfo')).access_token - return request({ - url: "/data/api-u/sys/logout", - method: "get" - }); -}; - -// 鑾峰彇鐢ㄦ埛淇℃伅 -export const getLoginUserData = () => { - let token = sessionStorage.getItem('loginedInfo') && JSON.parse(sessionStorage.getItem('loginedInfo')).access_token - return request({ - url: "/data/api-u/users/current", - method: "get", - headers: { - 'Content-Type': 'application/x-www-form-urlencoded', - 'Authorization': token || '' - } - }); -}; - -//淇敼瀵嗙爜 -export const updatePwd = (query: any) => { - return request({ - url: '/data/api-u/users/updatePwd', - method: 'post', - data: qs.stringify(query) - }) -}; - -//鑾峰彇椤圭洰鍚嶇О -export const getServerName = (query: any) => { - return request({ - url: "/data/api-v/info/getServerName", - method: "get" - }); -}; \ No newline at end of file diff --git a/src/api/product.ts b/src/api/product.ts index 2c49eef..f4c1e9e 100644 --- a/src/api/product.ts +++ b/src/api/product.ts @@ -1,4 +1,4 @@ -import request from "./index" +import request from "@/scripts/httpRequest"; import qs from "qs"; // 鏌ヨ浜у搧涓績鍒楄〃 @@ -41,11 +41,10 @@ // 鑾峰彇鏍囩瀛楀吀 // param:type -export const findDicByType = (params: any) => { +export const findDicByType = () => { return request({ - url: "/data/api-s/dic/findDicByType", + url: "/saas/api-s/saasProduct/getProductType?scope=", method: "get", - params: params }); }; @@ -80,7 +79,7 @@ */ export const findAllCenterProduct = (params: any) => { return request({ - url: "/data/api-s/product/findAllCenterProduct", + url: "/saas/api-s/saasProduct/findAllCenterProduct", method: "post", data: params }) @@ -120,7 +119,7 @@ */ export const getReleaseProduct = (params: any) => { return request({ - url: "/data/api-s/product/getAllProductMenu", + url: "/saas/api-s/saasProduct/getAllProductMenu", method: "get", params: params }) @@ -261,3 +260,37 @@ params: params }) } + +//鑾峰彇杞挱鍥� +export const getIndexPics = () => { + return request({ + url: `/saas/api-i/saasIndex/getIndexPics`, + method: 'get', + }) +} + +//鑾峰彇浜у搧璇︽儏 +export const selectProductById = (data: any) => { + return request({ + url: `/saas/api-s/saasProduct/selectProductById`, + method: 'post', + data, + }) +} + +//鑾峰彇鎺ㄨ崘绠楁硶 +export const getIndexModelRecommend = (data: any) => { + return request({ + url: `/saas/api-i/saasIndex/getIndexModelRecommend`, + method: 'post', + data, + }) +} + +//鑾峰彇棣栭〉妯″潡 +export const getModelList = () => { + return request({ + url: `/saas/api-i/saasIndex/getModelList`, + method: 'get', + }) +} \ No newline at end of file diff --git a/src/components/Connect.vue b/src/components/Connect.vue index 276babb..f4914e4 100644 --- a/src/components/Connect.vue +++ b/src/components/Connect.vue @@ -130,12 +130,14 @@ margin-top: 6px; margin-left: 34px; color: #0065ff; + font-size: 12px; } .des { margin-top: 6px; margin-left: 34px; color: #666666; + font-size: 12px; } } @@ -153,6 +155,7 @@ border-radius: 22px; text-align: center; line-height: 20px; + font-size: 14px; cursor: pointer; &:hover { diff --git a/src/components/IndexHeader.vue b/src/components/IndexHeader.vue index 9c631c6..645b30c 100644 --- a/src/components/IndexHeader.vue +++ b/src/components/IndexHeader.vue @@ -3,14 +3,20 @@ <div class="header" :class="{ showBox: isShow, disOpacity: !opacity }"> <!-- 鍙充晶 --> <div class="left"> - <img class="logo" src="/images/index/LOGO.png" alt="" /> - <div class="title">宸ヤ笟鐗╄仈缃戝钩鍙�</div> + <router-link to="/"> + <img class="logo" src="/images/index/LOGO.png" alt="" /> + </router-link> + <router-link to="/"> + <div class="title">宸ヤ笟鐗╄仈缃戝钩鍙�</div> + </router-link> <div class="label"><router-link to="/">棣栭〉</router-link></div> <div class="label">浜戞湇鍔�</div> <div class="label"> <router-link to="/manageCenter">绠$悊涓績</router-link> </div> - <div class="label">搴旂敤鍟嗗煄</div> + <div class="label"> + <router-link to="/product">搴旂敤鍟嗗煄</router-link> + </div> </div> <!-- 宸︿晶 --> @@ -224,10 +230,12 @@ .logo { margin: 0 7px 0 20px; + cursor: pointer; } .title { margin-right: 10px; + cursor: pointer; } .label { @@ -334,8 +342,8 @@ &.showBox .right .el-input { position: absolute; z-index: 4; - top: 0; - right: 158px; + top: -7px; + right: 88px; width: 300px; background-color: #fff; ::v-deep input { @@ -355,7 +363,8 @@ box-sizing: border-box; position: absolute; top: 62px; - right: 158px; + right: 88px; + // right: -158px; padding: 12px 20px 8px 20px; width: 300px; background-color: #fff; @@ -463,8 +472,12 @@ .logOut { margin-top: 20px; font-size: 16px; - color: #0065ff; + color: #3d3d3d; cursor: pointer; + + &:hover { + color: #0065ff; + } } } </style> \ No newline at end of file diff --git a/src/components/Price.vue b/src/components/Price.vue index d11da29..9d641b5 100644 --- a/src/components/Price.vue +++ b/src/components/Price.vue @@ -1,9 +1,10 @@ <template> - <div class="Price"> - 锟�<span class="newPrice">{{ priceNew1 }}</span - >.00/骞� - <span class="oldPrice">锟{ priceOld1 }}.00/骞�</span> + <div class="Price" v-if="priceNew"> + 锟�<span class="newPrice">{{ priceN1 }}</span + >{{ priceN2 }}/骞� + <span class="iconSave" v-if="showIcon">鐪�</span> + <span class="oldPrice">锟{ priceO1 }}{{ priceO2 }}/骞�</span> </div> </template> @@ -11,23 +12,35 @@ export default { props: { priceNew: {}, - priceOld: {}, + showIcon: { + default: false, + }, }, - computed: { - priceNew1() { - if (this.priceNew) { - return this.priceNew; - } else { - return 0; - } - }, - priceOld1() { - if (this.priceOld) { - return this.priceOld; - } else { - return this.priceNew1 * 2; - } - }, + data() { + return { + priceN1: "", + priceN2: "", + priceO1: "", + priceO2: "", + }; + }, + created() { + const priceO = (this.priceNew * 1.2 + "").split("."); + const priceN = (this.priceNew + "").split("."); + if (priceN.length > 1) { + this.priceN1 = priceN[0]; + this.priceN2 = "." + priceN[1]; + } else { + this.priceN1 = priceN[0]; + this.priceN2 = ".00"; + } + if (priceO.length > 1) { + this.priceO1 = priceO[0]; + this.priceO2 = "." + priceO[1]; + } else { + this.priceO1 = priceO[0]; + this.priceO2 = ".00"; + } }, }; </script> @@ -37,6 +50,12 @@ margin: 0 20px 0 20px; font-size: 14px; text-align: left; + + display: -webkit-box; + -webkit-box-orient: vertical; + -webkit-line-clamp: 1; + overflow: hidden; + text-overflow: ellipsis; .newPrice { font-size: 30px; @@ -50,5 +69,17 @@ color: #999999; text-decoration: line-through; } + + .iconSave { + display: inline-block; + width: 18px; + height: 18px; + font-size: 12px; + color: #fff; + line-height: 18px; + text-align: center; + background: #ff6000; + border-radius: 2px; + } } </style> \ No newline at end of file diff --git a/src/components/giantTree/zTree/ztree_v3/jquery.ztree.all.js b/src/components/giantTree/zTree/ztree_v3/jquery.ztree.all.js index dee4cce..df95111 100644 --- a/src/components/giantTree/zTree/ztree_v3/jquery.ztree.all.js +++ b/src/components/giantTree/zTree/ztree_v3/jquery.ztree.all.js @@ -11,8 +11,10 @@ * Date: 2020-11-21 */ -(function ($) { - var settings = {}, roots = {}, caches = {}, +(function($) { + var settings = {}, + roots = {}, + caches = {}, //default consts of core _consts = { className: { @@ -20,7 +22,7 @@ LEVEL: "level", ICO_LOADING: "ico_loading", SWITCH: "switch", - NAME: 'node_name' + NAME: "node_name", }, event: { NODECREATED: "ztree_nodeCreated", @@ -31,14 +33,14 @@ ASYNC_ERROR: "ztree_async_error", REMOVE: "ztree_remove", SELECTED: "ztree_selected", - UNSELECTED: "ztree_unselected" + UNSELECTED: "ztree_unselected", }, id: { A: "_a", ICON: "_ico", SPAN: "_span", SWITCH: "_switch", - UL: "_ul" + UL: "_ul", }, line: { ROOT: "root", @@ -46,16 +48,16 @@ CENTER: "center", BOTTOM: "bottom", NOLINE: "noline", - LINE: "line" + LINE: "line", }, folder: { OPEN: "open", CLOSE: "close", - DOCU: "docu" + DOCU: "docu", }, node: { - CURSELECTED: "curSelectedNode" - } + CURSELECTED: "curSelectedNode", + }, }, //default setting of core _setting = { @@ -73,7 +75,7 @@ showIcon: true, showLine: true, showTitle: true, - txtSelectedEnable: false + txtSelectedEnable: false, }, data: { key: { @@ -82,7 +84,7 @@ name: "name", title: "", url: "url", - icon: "icon" + icon: "icon", }, render: { name: null, @@ -92,12 +94,12 @@ enable: false, idKey: "id", pIdKey: "pId", - rootPId: null + rootPId: null, }, keep: { parent: false, - leaf: false - } + leaf: false, + }, }, async: { enable: false, @@ -109,7 +111,7 @@ url: "", autoParam: [], otherParam: [], - dataFilter: null + dataFilter: null, }, callback: { beforeAsync: null, @@ -132,12 +134,12 @@ onMouseUp: null, onExpand: null, onCollapse: null, - onRemove: null - } + onRemove: null, + }, }, //default root of core //zTree use root to save full data - _initRoot = function (setting) { + _initRoot = function(setting) { var r = data.getRoot(setting); if (!r) { r = {}; @@ -149,10 +151,10 @@ r.noSelection = true; r.createdNodes = []; r.zId = 0; - r._ver = (new Date()).getTime(); + r._ver = new Date().getTime(); }, //default cache of core - _initCache = function (setting) { + _initCache = function(setting) { var c = data.getCache(setting); if (!c) { c = {}; @@ -162,45 +164,69 @@ c.doms = []; }, //default bindEvent of core - _bindEvent = function (setting) { + _bindEvent = function(setting) { var o = setting.treeObj, c = consts.event; - o.bind(c.NODECREATED, function (event, treeId, node) { + o.bind(c.NODECREATED, function(event, treeId, node) { tools.apply(setting.callback.onNodeCreated, [event, treeId, node]); }); - o.bind(c.CLICK, function (event, srcEvent, treeId, node, clickFlag) { - tools.apply(setting.callback.onClick, [srcEvent, treeId, node, clickFlag]); + o.bind(c.CLICK, function(event, srcEvent, treeId, node, clickFlag) { + tools.apply(setting.callback.onClick, [ + srcEvent, + treeId, + node, + clickFlag, + ]); }); - o.bind(c.EXPAND, function (event, treeId, node) { + o.bind(c.EXPAND, function(event, treeId, node) { tools.apply(setting.callback.onExpand, [event, treeId, node]); }); - o.bind(c.COLLAPSE, function (event, treeId, node) { + o.bind(c.COLLAPSE, function(event, treeId, node) { tools.apply(setting.callback.onCollapse, [event, treeId, node]); }); - o.bind(c.ASYNC_SUCCESS, function (event, treeId, node, msg) { - tools.apply(setting.callback.onAsyncSuccess, [event, treeId, node, msg]); + o.bind(c.ASYNC_SUCCESS, function(event, treeId, node, msg) { + tools.apply(setting.callback.onAsyncSuccess, [ + event, + treeId, + node, + msg, + ]); }); - o.bind(c.ASYNC_ERROR, function (event, treeId, node, XMLHttpRequest, textStatus, errorThrown) { - tools.apply(setting.callback.onAsyncError, [event, treeId, node, XMLHttpRequest, textStatus, errorThrown]); + o.bind(c.ASYNC_ERROR, function( + event, + treeId, + node, + XMLHttpRequest, + textStatus, + errorThrown + ) { + tools.apply(setting.callback.onAsyncError, [ + event, + treeId, + node, + XMLHttpRequest, + textStatus, + errorThrown, + ]); }); - o.bind(c.REMOVE, function (event, treeId, treeNode) { + o.bind(c.REMOVE, function(event, treeId, treeNode) { tools.apply(setting.callback.onRemove, [event, treeId, treeNode]); }); - o.bind(c.SELECTED, function (event, treeId, node) { + o.bind(c.SELECTED, function(event, treeId, node) { tools.apply(setting.callback.onSelected, [treeId, node]); }); - o.bind(c.UNSELECTED, function (event, treeId, node) { + o.bind(c.UNSELECTED, function(event, treeId, node) { tools.apply(setting.callback.onUnSelected, [treeId, node]); }); }, - _unbindEvent = function (setting) { + _unbindEvent = function(setting) { var o = setting.treeObj, c = consts.event; o.unbind(c.NODECREATED) @@ -214,12 +240,15 @@ .unbind(c.UNSELECTED); }, //default event proxy of core - _eventProxy = function (event) { + _eventProxy = function(event) { var target = event.target, setting = data.getSetting(event.data.treeId), - tId = "", node = null, - nodeEventType = "", treeEventType = "", - nodeEventCallback = null, treeEventCallback = null, + tId = "", + node = null, + nodeEventType = "", + treeEventType = "", + nodeEventCallback = null, + treeEventCallback = null, tmp = null; if (tools.eqs(event.type, "mousedown")) { @@ -229,11 +258,16 @@ } else if (tools.eqs(event.type, "contextmenu")) { treeEventType = "contextmenu"; } else if (tools.eqs(event.type, "click")) { - if (tools.eqs(target.tagName, "span") && target.getAttribute("treeNode" + consts.id.SWITCH) !== null) { + if ( + tools.eqs(target.tagName, "span") && + target.getAttribute("treeNode" + consts.id.SWITCH) !== null + ) { tId = tools.getNodeMainDom(target).id; nodeEventType = "switchNode"; } else { - tmp = tools.getMDom(setting, target, [{ tagName: "a", attrName: "treeNode" + consts.id.A }]); + tmp = tools.getMDom(setting, target, [ + { tagName: "a", attrName: "treeNode" + consts.id.A }, + ]); if (tmp) { tId = tools.getNodeMainDom(tmp).id; nodeEventType = "clickNode"; @@ -241,14 +275,18 @@ } } else if (tools.eqs(event.type, "dblclick")) { treeEventType = "dblclick"; - tmp = tools.getMDom(setting, target, [{ tagName: "a", attrName: "treeNode" + consts.id.A }]); + tmp = tools.getMDom(setting, target, [ + { tagName: "a", attrName: "treeNode" + consts.id.A }, + ]); if (tmp) { tId = tools.getNodeMainDom(tmp).id; nodeEventType = "switchNode"; } } if (treeEventType.length > 0 && tId.length == 0) { - tmp = tools.getMDom(setting, target, [{ tagName: "a", attrName: "treeNode" + consts.id.A }]); + tmp = tools.getMDom(setting, target, [ + { tagName: "a", attrName: "treeNode" + consts.id.A }, + ]); if (tmp) { tId = tools.getNodeMainDom(tmp).id; } @@ -261,8 +299,15 @@ var isParent = data.nodeIsParent(setting, node); if (!isParent) { nodeEventType = ""; - } else if (tools.eqs(event.type, "click") - || (tools.eqs(event.type, "dblclick") && tools.apply(setting.view.dblClickExpand, [setting.treeId, node], setting.view.dblClickExpand))) { + } else if ( + tools.eqs(event.type, "click") || + (tools.eqs(event.type, "dblclick") && + tools.apply( + setting.view.dblClickExpand, + [setting.treeId, node], + setting.view.dblClickExpand + )) + ) { nodeEventCallback = handler.onSwitchNode; } else { nodeEventType = ""; @@ -294,43 +339,51 @@ nodeEventType: nodeEventType, nodeEventCallback: nodeEventCallback, treeEventType: treeEventType, - treeEventCallback: treeEventCallback + treeEventCallback: treeEventCallback, }; - return proxyResult + return proxyResult; }, //default init node of core - _initNode = function (setting, level, n, parentNode, isFirstNode, isLastNode, openFlag) { + _initNode = function( + setting, + level, + n, + parentNode, + isFirstNode, + isLastNode, + openFlag + ) { if (!n) return; var r = data.getRoot(setting), children = data.nodeChildren(setting, n); n.level = level; - n.tId = setting.treeId + "_" + (++r.zId); + n.tId = setting.treeId + "_" + ++r.zId; n.parentTId = parentNode ? parentNode.tId : null; - n.open = (typeof n.open == "string") ? tools.eqs(n.open, "true") : !!n.open; + n.open = typeof n.open == "string" ? tools.eqs(n.open, "true") : !!n.open; var isParent = data.nodeIsParent(setting, n); if (tools.isArray(children)) { data.nodeIsParent(setting, n, true); n.zAsync = true; } else { isParent = data.nodeIsParent(setting, n, isParent); - n.open = (isParent && !setting.async.enable) ? n.open : false; + n.open = isParent && !setting.async.enable ? n.open : false; n.zAsync = !isParent; } n.isFirstNode = isFirstNode; n.isLastNode = isLastNode; - n.getParentNode = function () { + n.getParentNode = function() { return data.getNodeCache(setting, n.parentTId); }; - n.getPreNode = function () { + n.getPreNode = function() { return data.getPreNode(setting, n); }; - n.getNextNode = function () { + n.getNextNode = function() { return data.getNextNode(setting, n); }; - n.getIndex = function () { + n.getIndex = function() { return data.getNodeIndex(setting, n); }; - n.getPath = function () { + n.getPath = function() { return data.getNodePath(setting, n); }; n.isAjaxing = false; @@ -347,52 +400,53 @@ afterA: [], innerBeforeA: [], innerAfterA: [], - zTreeTools: [] + zTreeTools: [], }, //method of operate data data = { - addNodeCache: function (setting, node) { + addNodeCache: function(setting, node) { data.getCache(setting).nodes[data.getNodeCacheId(node.tId)] = node; }, - getNodeCacheId: function (tId) { + getNodeCacheId: function(tId) { return tId.substring(tId.lastIndexOf("_") + 1); }, - addAfterA: function (afterA) { + addAfterA: function(afterA) { _init.afterA.push(afterA); }, - addBeforeA: function (beforeA) { + addBeforeA: function(beforeA) { _init.beforeA.push(beforeA); }, - addInnerAfterA: function (innerAfterA) { + addInnerAfterA: function(innerAfterA) { _init.innerAfterA.push(innerAfterA); }, - addInnerBeforeA: function (innerBeforeA) { + addInnerBeforeA: function(innerBeforeA) { _init.innerBeforeA.push(innerBeforeA); }, - addInitBind: function (bindEvent) { + addInitBind: function(bindEvent) { _init.bind.push(bindEvent); }, - addInitUnBind: function (unbindEvent) { + addInitUnBind: function(unbindEvent) { _init.unbind.push(unbindEvent); }, - addInitCache: function (initCache) { + addInitCache: function(initCache) { _init.caches.push(initCache); }, - addInitNode: function (initNode) { + addInitNode: function(initNode) { _init.nodes.push(initNode); }, - addInitProxy: function (initProxy, isFirst) { + addInitProxy: function(initProxy, isFirst) { if (!!isFirst) { _init.proxys.splice(0, 0, initProxy); } else { _init.proxys.push(initProxy); } }, - addInitRoot: function (initRoot) { + addInitRoot: function(initRoot) { _init.roots.push(initRoot); }, - addNodesData: function (setting, parentNode, index, nodes) { - var children = data.nodeChildren(setting, parentNode), params; + addNodesData: function(setting, parentNode, index, nodes) { + var children = data.nodeChildren(setting, parentNode), + params; if (!children) { children = data.nodeChildren(setting, parentNode, []); index = -1; @@ -416,53 +470,55 @@ children.splice.apply(children, params); } }, - addSelectedNode: function (setting, node) { + addSelectedNode: function(setting, node) { var root = data.getRoot(setting); if (!data.isSelectedNode(setting, node)) { root.curSelectedList.push(node); } }, - addCreatedNode: function (setting, node) { + addCreatedNode: function(setting, node) { if (!!setting.callback.onNodeCreated || !!setting.view.addDiyDom) { var root = data.getRoot(setting); root.createdNodes.push(node); } }, - addZTreeTools: function (zTreeTools) { + addZTreeTools: function(zTreeTools) { _init.zTreeTools.push(zTreeTools); }, - exSetting: function (s) { + exSetting: function(s) { $.extend(true, _setting, s); }, - fixPIdKeyValue: function (setting, node) { + fixPIdKeyValue: function(setting, node) { if (setting.data.simpleData.enable) { - node[setting.data.simpleData.pIdKey] = node.parentTId ? node.getParentNode()[setting.data.simpleData.idKey] : setting.data.simpleData.rootPId; + node[setting.data.simpleData.pIdKey] = node.parentTId + ? node.getParentNode()[setting.data.simpleData.idKey] + : setting.data.simpleData.rootPId; } }, - getAfterA: function (setting, node, array) { + getAfterA: function(setting, node, array) { for (var i = 0, j = _init.afterA.length; i < j; i++) { _init.afterA[i].apply(this, arguments); } }, - getBeforeA: function (setting, node, array) { + getBeforeA: function(setting, node, array) { for (var i = 0, j = _init.beforeA.length; i < j; i++) { _init.beforeA[i].apply(this, arguments); } }, - getInnerAfterA: function (setting, node, array) { + getInnerAfterA: function(setting, node, array) { for (var i = 0, j = _init.innerAfterA.length; i < j; i++) { _init.innerAfterA[i].apply(this, arguments); } }, - getInnerBeforeA: function (setting, node, array) { + getInnerBeforeA: function(setting, node, array) { for (var i = 0, j = _init.innerBeforeA.length; i < j; i++) { _init.innerBeforeA[i].apply(this, arguments); } }, - getCache: function (setting) { + getCache: function(setting) { return caches[setting.treeId]; }, - getNodeIndex: function (setting, node) { + getNodeIndex: function(setting, node) { if (!node) return null; var p = node.parentTId ? node.getParentNode() : data.getRoot(setting), children = data.nodeChildren(setting, p); @@ -473,18 +529,18 @@ } return -1; }, - getNextNode: function (setting, node) { + getNextNode: function(setting, node) { if (!node) return null; var p = node.parentTId ? node.getParentNode() : data.getRoot(setting), children = data.nodeChildren(setting, p); for (var i = 0, l = children.length - 1; i <= l; i++) { if (children[i] === node) { - return (i == l ? null : children[i + 1]); + return i == l ? null : children[i + 1]; } } return null; }, - getNodeByParam: function (setting, nodes, key, value) { + getNodeByParam: function(setting, nodes, key, value) { if (!nodes || !key) return null; for (var i = 0, l = nodes.length; i < l; i++) { var node = nodes[i]; @@ -497,12 +553,12 @@ } return null; }, - getNodeCache: function (setting, tId) { + getNodeCache: function(setting, tId) { if (!tId) return null; var n = caches[setting.treeId].nodes[data.getNodeCacheId(tId)]; return n ? n : null; }, - getNodePath: function (setting, node) { + getNodePath: function(setting, node) { if (!node) return null; var path; @@ -518,10 +574,10 @@ return path; }, - getNodes: function (setting) { + getNodes: function(setting) { return data.nodeChildren(setting, data.getRoot(setting)); }, - getNodesByParam: function (setting, nodes, key, value) { + getNodesByParam: function(setting, nodes, key, value) { if (!nodes || !key) return []; var result = []; for (var i = 0, l = nodes.length; i < l; i++) { @@ -530,26 +586,39 @@ result.push(node); } var children = data.nodeChildren(setting, node); - result = result.concat(data.getNodesByParam(setting, children, key, value)); + result = result.concat( + data.getNodesByParam(setting, children, key, value) + ); } return result; }, - getNodesByParamFuzzy: function (setting, nodes, key, value) { + getNodesByParamFuzzy: function(setting, nodes, key, value) { if (!nodes || !key) return []; var result = []; value = value.toLowerCase(); for (var i = 0, l = nodes.length; i < l; i++) { var node = nodes[i]; - if (typeof node[key] == "string" && nodes[i][key].toLowerCase().indexOf(value) > -1) { + if ( + typeof node[key] == "string" && + nodes[i][key].toLowerCase().indexOf(value) > -1 + ) { result.push(node); } var children = data.nodeChildren(setting, node); - result = result.concat(data.getNodesByParamFuzzy(setting, children, key, value)); + result = result.concat( + data.getNodesByParamFuzzy(setting, children, key, value) + ); } return result; }, - getNodesByFilter: function (setting, nodes, filter, isSingle, invokeParam) { - if (!nodes) return (isSingle ? null : []); + getNodesByFilter: function( + setting, + nodes, + filter, + isSingle, + invokeParam + ) { + if (!nodes) return isSingle ? null : []; var result = isSingle ? null : []; for (var i = 0, l = nodes.length; i < l; i++) { var node = nodes[i]; @@ -560,7 +629,13 @@ result.push(node); } var children = data.nodeChildren(setting, node); - var tmpResult = data.getNodesByFilter(setting, children, filter, isSingle, invokeParam); + var tmpResult = data.getNodesByFilter( + setting, + children, + filter, + isSingle, + invokeParam + ); if (isSingle && !!tmpResult) { return tmpResult; } @@ -568,72 +643,72 @@ } return result; }, - getPreNode: function (setting, node) { + getPreNode: function(setting, node) { if (!node) return null; var p = node.parentTId ? node.getParentNode() : data.getRoot(setting), children = data.nodeChildren(setting, p); for (var i = 0, l = children.length; i < l; i++) { if (children[i] === node) { - return (i == 0 ? null : children[i - 1]); + return i == 0 ? null : children[i - 1]; } } return null; }, - getRoot: function (setting) { + getRoot: function(setting) { return setting ? roots[setting.treeId] : null; }, - getRoots: function () { + getRoots: function() { return roots; }, - getSetting: function (treeId) { + getSetting: function(treeId) { return settings[treeId]; }, - getSettings: function () { + getSettings: function() { return settings; }, - getZTreeTools: function (treeId) { + getZTreeTools: function(treeId) { var r = this.getRoot(this.getSetting(treeId)); return r ? r.treeTools : null; }, - initCache: function (setting) { + initCache: function(setting) { for (var i = 0, j = _init.caches.length; i < j; i++) { _init.caches[i].apply(this, arguments); } }, - initNode: function (setting, level, node, parentNode, preNode, nextNode) { + initNode: function(setting, level, node, parentNode, preNode, nextNode) { for (var i = 0, j = _init.nodes.length; i < j; i++) { _init.nodes[i].apply(this, arguments); } }, - initRoot: function (setting) { + initRoot: function(setting) { for (var i = 0, j = _init.roots.length; i < j; i++) { _init.roots[i].apply(this, arguments); } }, - isSelectedNode: function (setting, node) { + isSelectedNode: function(setting, node) { var root = data.getRoot(setting); for (var i = 0, j = root.curSelectedList.length; i < j; i++) { if (node === root.curSelectedList[i]) return true; } return false; }, - nodeChildren: function (setting, node, newChildren) { + nodeChildren: function(setting, node, newChildren) { if (!node) { return null; } var key = setting.data.key.children; - if (typeof newChildren !== 'undefined') { + if (typeof newChildren !== "undefined") { node[key] = newChildren; } return node[key]; }, - nodeIsParent: function (setting, node, newIsParent) { + nodeIsParent: function(setting, node, newIsParent) { if (!node) { return false; } var key = setting.data.key.isParent; - if (typeof newIsParent !== 'undefined') { + if (typeof newIsParent !== "undefined") { if (typeof newIsParent === "string") { newIsParent = tools.eqs(newIsParent, "true"); } @@ -650,28 +725,35 @@ node[key] = true; } + if (node.type == "4") { + node[key] = false; + } + return node[key]; }, - nodeName: function (setting, node, newName) { + nodeName: function(setting, node, newName) { var key = setting.data.key.name; - if (typeof newName !== 'undefined') { + if (typeof newName !== "undefined") { node[key] = newName; } var rawName = "" + node[key]; - if (typeof setting.data.render.name === 'function') { + if (typeof setting.data.render.name === "function") { return setting.data.render.name.call(this, rawName, node); } return rawName; }, - nodeTitle: function (setting, node) { - var t = setting.data.key.title === "" ? setting.data.key.name : setting.data.key.title; + nodeTitle: function(setting, node) { + var t = + setting.data.key.title === "" + ? setting.data.key.name + : setting.data.key.title; var rawTitle = "" + node[t]; - if (typeof setting.data.render.title === 'function') { + if (typeof setting.data.render.title === "function") { return setting.data.render.title.call(this, rawTitle, node); } return rawTitle; }, - removeNodeCache: function (setting, node) { + removeNodeCache: function(setting, node) { var children = data.nodeChildren(setting, node); if (children) { for (var i = 0, l = children.length; i < l; i++) { @@ -680,29 +762,35 @@ } data.getCache(setting).nodes[data.getNodeCacheId(node.tId)] = null; }, - removeSelectedNode: function (setting, node) { + removeSelectedNode: function(setting, node) { var root = data.getRoot(setting); for (var i = 0, j = root.curSelectedList.length; i < j; i++) { - if (node === root.curSelectedList[i] || !data.getNodeCache(setting, root.curSelectedList[i].tId)) { + if ( + node === root.curSelectedList[i] || + !data.getNodeCache(setting, root.curSelectedList[i].tId) + ) { root.curSelectedList.splice(i, 1); - setting.treeObj.trigger(consts.event.UNSELECTED, [setting.treeId, node]); + setting.treeObj.trigger(consts.event.UNSELECTED, [ + setting.treeId, + node, + ]); i--; j--; } } }, - setCache: function (setting, cache) { + setCache: function(setting, cache) { caches[setting.treeId] = cache; }, - setRoot: function (setting, root) { + setRoot: function(setting, root) { roots[setting.treeId] = root; }, - setZTreeTools: function (setting, zTreeTools) { + setZTreeTools: function(setting, zTreeTools) { for (var i = 0, j = _init.zTreeTools.length; i < j; i++) { _init.zTreeTools[i].apply(this, arguments); } }, - transformToArrayFormat: function (setting, nodes) { + transformToArrayFormat: function(setting, nodes) { if (!nodes) return []; var r = []; if (tools.isArray(nodes)) { @@ -723,8 +811,9 @@ } } }, - transformTozTreeFormat: function (setting, sNodes) { - var i, l, + transformTozTreeFormat: function(setting, sNodes) { + var i, + l, key = setting.data.simpleData.idKey, parentKey = setting.data.simpleData.pIdKey; if (!key || key == "" || !sNodes) return []; @@ -751,51 +840,51 @@ } else { return [sNodes]; } - } + }, }, //method of event proxy event = { - bindEvent: function (setting) { + bindEvent: function(setting) { for (var i = 0, j = _init.bind.length; i < j; i++) { _init.bind[i].apply(this, arguments); } }, - unbindEvent: function (setting) { + unbindEvent: function(setting) { for (var i = 0, j = _init.unbind.length; i < j; i++) { _init.unbind[i].apply(this, arguments); } }, - bindTree: function (setting) { + bindTree: function(setting) { var eventParam = { - treeId: setting.treeId - }, + treeId: setting.treeId, + }, o = setting.treeObj; if (!setting.view.txtSelectedEnable) { // for can't select text - o.bind('selectstart', handler.onSelectStart).css({ - "-moz-user-select": "-moz-none" + o.bind("selectstart", handler.onSelectStart).css({ + "-moz-user-select": "-moz-none", }); } - o.bind('click', eventParam, event.proxy); - o.bind('dblclick', eventParam, event.proxy); - o.bind('mouseover', eventParam, event.proxy); - o.bind('mouseout', eventParam, event.proxy); - o.bind('mousedown', eventParam, event.proxy); - o.bind('mouseup', eventParam, event.proxy); - o.bind('contextmenu', eventParam, event.proxy); + o.bind("click", eventParam, event.proxy); + o.bind("dblclick", eventParam, event.proxy); + o.bind("mouseover", eventParam, event.proxy); + o.bind("mouseout", eventParam, event.proxy); + o.bind("mousedown", eventParam, event.proxy); + o.bind("mouseup", eventParam, event.proxy); + o.bind("contextmenu", eventParam, event.proxy); }, - unbindTree: function (setting) { + unbindTree: function(setting) { var o = setting.treeObj; - o.unbind('selectstart', handler.onSelectStart) - .unbind('click', event.proxy) - .unbind('dblclick', event.proxy) - .unbind('mouseover', event.proxy) - .unbind('mouseout', event.proxy) - .unbind('mousedown', event.proxy) - .unbind('mouseup', event.proxy) - .unbind('contextmenu', event.proxy); + o.unbind("selectstart", handler.onSelectStart) + .unbind("click", event.proxy) + .unbind("dblclick", event.proxy) + .unbind("mouseover", event.proxy) + .unbind("mouseout", event.proxy) + .unbind("mousedown", event.proxy) + .unbind("mouseup", event.proxy) + .unbind("contextmenu", event.proxy); }, - doProxy: function (e) { + doProxy: function(e) { var results = []; for (var i = 0, j = _init.proxys.length; i < j; i++) { var proxyResult = _init.proxys[i].apply(this, arguments); @@ -806,120 +895,217 @@ } return results; }, - proxy: function (e) { + proxy: function(e) { var setting = data.getSetting(e.data.treeId); if (!tools.uCanDo(setting, e)) return true; var results = event.doProxy(e), - r = true, x = false; + r = true, + x = false; for (var i = 0, l = results.length; i < l; i++) { var proxyResult = results[i]; if (proxyResult.nodeEventCallback) { x = true; - r = proxyResult.nodeEventCallback.apply(proxyResult, [e, proxyResult.node]) && r; + r = + proxyResult.nodeEventCallback.apply(proxyResult, [ + e, + proxyResult.node, + ]) && r; } if (proxyResult.treeEventCallback) { x = true; - r = proxyResult.treeEventCallback.apply(proxyResult, [e, proxyResult.node]) && r; + r = + proxyResult.treeEventCallback.apply(proxyResult, [ + e, + proxyResult.node, + ]) && r; } } return r; - } + }, }, //method of event handler handler = { - onSwitchNode: function (event, node) { + onSwitchNode: function(event, node) { var setting = data.getSetting(event.data.treeId); if (node.open) { - if (tools.apply(setting.callback.beforeCollapse, [setting.treeId, node], true) == false) return true; + if ( + tools.apply( + setting.callback.beforeCollapse, + [setting.treeId, node], + true + ) == false + ) + return true; data.getRoot(setting).expandTriggerFlag = true; view.switchNode(setting, node); } else { - if (tools.apply(setting.callback.beforeExpand, [setting.treeId, node], true) == false) return true; + if ( + tools.apply( + setting.callback.beforeExpand, + [setting.treeId, node], + true + ) == false + ) + return true; data.getRoot(setting).expandTriggerFlag = true; view.switchNode(setting, node); } return true; }, - onClickNode: function (event, node) { + onClickNode: function(event, node) { // debugger var setting = data.getSetting(event.data.treeId), - clickFlag = ((setting.view.autoCancelSelected && (event.ctrlKey || event.metaKey)) && data.isSelectedNode(setting, node)) ? 0 : (setting.view.autoCancelSelected && (event.ctrlKey || event.metaKey) && setting.view.selectedMulti) ? 2 : 1; - if (tools.apply(setting.callback.beforeClick, [setting.treeId, node, clickFlag], true) == false) return true; + clickFlag = + setting.view.autoCancelSelected && + (event.ctrlKey || event.metaKey) && + data.isSelectedNode(setting, node) + ? 0 + : setting.view.autoCancelSelected && + (event.ctrlKey || event.metaKey) && + setting.view.selectedMulti + ? 2 + : 1; + if ( + tools.apply( + setting.callback.beforeClick, + [setting.treeId, node, clickFlag], + true + ) == false + ) + return true; if (clickFlag === 0) { view.cancelPreSelectedNode(setting, node); } else { view.selectNode(setting, node, clickFlag === 2); } - setting.treeObj.trigger(consts.event.CLICK, [event, setting.treeId, node, clickFlag]); + setting.treeObj.trigger(consts.event.CLICK, [ + event, + setting.treeId, + node, + clickFlag, + ]); return true; }, - onZTreeMousedown: function (event, node) { + onZTreeMousedown: function(event, node) { var setting = data.getSetting(event.data.treeId); - if (tools.apply(setting.callback.beforeMouseDown, [setting.treeId, node], true)) { - tools.apply(setting.callback.onMouseDown, [event, setting.treeId, node]); + if ( + tools.apply( + setting.callback.beforeMouseDown, + [setting.treeId, node], + true + ) + ) { + tools.apply(setting.callback.onMouseDown, [ + event, + setting.treeId, + node, + ]); } return true; }, - onZTreeMouseup: function (event, node) { + onZTreeMouseup: function(event, node) { var setting = data.getSetting(event.data.treeId); - if (tools.apply(setting.callback.beforeMouseUp, [setting.treeId, node], true)) { - tools.apply(setting.callback.onMouseUp, [event, setting.treeId, node]); + if ( + tools.apply( + setting.callback.beforeMouseUp, + [setting.treeId, node], + true + ) + ) { + tools.apply(setting.callback.onMouseUp, [ + event, + setting.treeId, + node, + ]); } return true; }, - onZTreeDblclick: function (event, node) { + onZTreeDblclick: function(event, node) { var setting = data.getSetting(event.data.treeId); - if (tools.apply(setting.callback.beforeDblClick, [setting.treeId, node], true)) { - tools.apply(setting.callback.onDblClick, [event, setting.treeId, node]); + if ( + tools.apply( + setting.callback.beforeDblClick, + [setting.treeId, node], + true + ) + ) { + tools.apply(setting.callback.onDblClick, [ + event, + setting.treeId, + node, + ]); } return true; }, - onZTreeContextmenu: function (event, node) { + onZTreeContextmenu: function(event, node) { var setting = data.getSetting(event.data.treeId); - if (tools.apply(setting.callback.beforeRightClick, [setting.treeId, node], true)) { - tools.apply(setting.callback.onRightClick, [event, setting.treeId, node]); + if ( + tools.apply( + setting.callback.beforeRightClick, + [setting.treeId, node], + true + ) + ) { + tools.apply(setting.callback.onRightClick, [ + event, + setting.treeId, + node, + ]); } - return (typeof setting.callback.onRightClick) != "function"; + return typeof setting.callback.onRightClick != "function"; }, - onSelectStart: function (e) { + onSelectStart: function(e) { var n = e.originalEvent.srcElement.nodeName.toLowerCase(); - return (n === "input" || n === "textarea"); - } + return n === "input" || n === "textarea"; + }, }, //method of tools for zTree tools = { - apply: function (fun, param, defaultValue) { - if ((typeof fun) == "function") { + apply: function(fun, param, defaultValue) { + if (typeof fun == "function") { return fun.apply(zt, param ? param : []); } return defaultValue; }, - canAsync: function (setting, node) { + canAsync: function(setting, node) { var children = data.nodeChildren(setting, node); var isParent = data.nodeIsParent(setting, node); - return (setting.async.enable && node && isParent && !(node.zAsync || (children && children.length > 0))); + return ( + setting.async.enable && + node && + isParent && + !(node.zAsync || (children && children.length > 0)) + ); }, - clone: function (obj) { + clone: function(obj) { if (obj === null) return null; var o = tools.isArray(obj) ? [] : {}; for (var i in obj) { - o[i] = (obj[i] instanceof Date) ? new Date(obj[i].getTime()) : (typeof obj[i] === "object" ? tools.clone(obj[i]) : obj[i]); + o[i] = + obj[i] instanceof Date + ? new Date(obj[i].getTime()) + : typeof obj[i] === "object" + ? tools.clone(obj[i]) + : obj[i]; } return o; }, - eqs: function (str1, str2) { + eqs: function(str1, str2) { return str1.toLowerCase() === str2.toLowerCase(); }, - isArray: function (arr) { + isArray: function(arr) { return Object.prototype.toString.apply(arr) === "[object Array]"; }, - isElement: function (o) { - return ( - typeof HTMLElement === "object" ? o instanceof HTMLElement : //DOM2 - o && typeof o === "object" && o !== null && o.nodeType === 1 && typeof o.nodeName === "string" - ); + isElement: function(o) { + return typeof HTMLElement === "object" + ? o instanceof HTMLElement //DOM2 + : o && + typeof o === "object" && + o !== null && + o.nodeType === 1 && + typeof o.nodeName === "string"; }, - $: function (node, exp, setting) { + $: function(node, exp, setting) { if (!!exp && typeof exp != "string") { setting = exp; exp = ""; @@ -930,11 +1116,14 @@ return $("#" + node.tId + exp, setting ? setting.treeObj : null); } }, - getMDom: function (setting, curDom, targetExpr) { + getMDom: function(setting, curDom, targetExpr) { if (!curDom) return null; while (curDom && curDom.id !== setting.treeId) { for (var i = 0, l = targetExpr.length; curDom.tagName && i < l; i++) { - if (tools.eqs(curDom.tagName, targetExpr[i].tagName) && curDom.getAttribute(targetExpr[i].attrName) !== null) { + if ( + tools.eqs(curDom.tagName, targetExpr[i].tagName) && + curDom.getAttribute(targetExpr[i].attrName) !== null + ) { return curDom; } } @@ -942,19 +1131,27 @@ } return null; }, - getNodeMainDom: function (target) { - return ($(target).parent("li").get(0) || $(target).parentsUntil("li").parent().get(0)); + getNodeMainDom: function(target) { + return ( + $(target) + .parent("li") + .get(0) || + $(target) + .parentsUntil("li") + .parent() + .get(0) + ); }, - isChildOrSelf: function (dom, parentId) { - return ($(dom).closest("#" + parentId).length > 0); + isChildOrSelf: function(dom, parentId) { + return $(dom).closest("#" + parentId).length > 0; }, - uCanDo: function (setting, e) { + uCanDo: function(setting, e) { return true; - } + }, }, //method of operate ztree dom view = { - addNodes: function (setting, parentNode, index, newNodes, isSilent) { + addNodes: function(setting, parentNode, index, newNodes, isSilent) { var isParent = data.nodeIsParent(setting, parentNode); if (setting.data.keep.leaf && parentNode && !isParent) { return; @@ -971,16 +1168,30 @@ target_ulObj = $$(parentNode, consts.id.UL, setting); if (!parentNode.open) { - view.replaceSwitchClass(parentNode, target_switchObj, consts.folder.CLOSE); - view.replaceIcoClass(parentNode, target_icoObj, consts.folder.CLOSE); + view.replaceSwitchClass( + parentNode, + target_switchObj, + consts.folder.CLOSE + ); + view.replaceIcoClass( + parentNode, + target_icoObj, + consts.folder.CLOSE + ); parentNode.open = false; target_ulObj.css({ - "display": "none" + display: "none", }); } data.addNodesData(setting, parentNode, index, newNodes); - view.createNodes(setting, parentNode.level + 1, newNodes, parentNode, index); + view.createNodes( + setting, + parentNode.level + 1, + newNodes, + parentNode, + index + ); if (!isSilent) { view.expandCollapseParentNode(setting, parentNode, true); } @@ -989,13 +1200,22 @@ view.createNodes(setting, 0, newNodes, null, index); } }, - appendNodes: function (setting, level, nodes, parentNode, index, initFlag, openFlag) { + appendNodes: function( + setting, + level, + nodes, + parentNode, + index, + initFlag, + openFlag + ) { if (!nodes) return []; var html = []; - var tmpPNode = (parentNode) ? parentNode : data.getRoot(setting), + var tmpPNode = parentNode ? parentNode : data.getRoot(setting), tmpPChild = data.nodeChildren(setting, tmpPNode), - isFirstNode, isLastNode; + isFirstNode, + isLastNode; if (!tmpPChild || index >= tmpPChild.length - nodes.length) { index = -1; @@ -1004,9 +1224,18 @@ for (var i = 0, l = nodes.length; i < l; i++) { var node = nodes[i]; if (initFlag) { - isFirstNode = ((index === 0 || tmpPChild.length == nodes.length) && (i == 0)); - isLastNode = (index < 0 && i == (nodes.length - 1)); - data.initNode(setting, level, node, parentNode, isFirstNode, isLastNode, openFlag); + isFirstNode = + (index === 0 || tmpPChild.length == nodes.length) && i == 0; + isLastNode = index < 0 && i == nodes.length - 1; + data.initNode( + setting, + level, + node, + parentNode, + isFirstNode, + isLastNode, + openFlag + ); data.addNodeCache(setting, node); } var isParent = data.nodeIsParent(setting, node); @@ -1015,7 +1244,15 @@ var children = data.nodeChildren(setting, node); if (children && children.length > 0) { //make child html first, because checkType - childHtml = view.appendNodes(setting, level + 1, children, node, -1, initFlag, openFlag && node.open); + childHtml = view.appendNodes( + setting, + level + 1, + children, + node, + -1, + initFlag, + openFlag && node.open + ); } if (openFlag) { view.makeDOMNodeMainBefore(html, setting, node); @@ -1028,7 +1265,7 @@ view.makeDOMNodeNameAfter(html, setting, node); data.getAfterA(setting, node, html); if (isParent && node.open) { - view.makeUlHtml(setting, node, html, childHtml.join('')); + view.makeUlHtml(setting, node, html, childHtml.join("")); } view.makeDOMNodeMainAfter(html, setting, node); data.addCreatedNode(setting, node); @@ -1036,7 +1273,7 @@ } return html; }, - appendParentULDom: function (setting, node) { + appendParentULDom: function(setting, node) { var html = [], nObj = $$(node, setting); if (!nObj.get(0) && !!node.parentTId) { @@ -1048,11 +1285,19 @@ ulObj.remove(); } var children = data.nodeChildren(setting, node), - childHtml = view.appendNodes(setting, node.level + 1, children, node, -1, false, true); - view.makeUlHtml(setting, node, html, childHtml.join('')); - nObj.append(html.join('')); + childHtml = view.appendNodes( + setting, + node.level + 1, + children, + node, + -1, + false, + true + ); + view.makeUlHtml(setting, node, html, childHtml.join("")); + nObj.append(html.join("")); }, - asyncNode: function (setting, node, isSilent, callback) { + asyncNode: function(setting, node, isSilent, callback) { var i, l; var isParent = data.nodeIsParent(setting, node); if (node && !isParent) { @@ -1060,27 +1305,45 @@ return false; } else if (node && node.isAjaxing) { return false; - } else if (tools.apply(setting.callback.beforeAsync, [setting.treeId, node], true) == false) { + } else if ( + tools.apply( + setting.callback.beforeAsync, + [setting.treeId, node], + true + ) == false + ) { tools.apply(callback); return false; } if (node) { node.isAjaxing = true; var icoObj = $$(node, consts.id.ICON, setting); - icoObj.attr({ "style": "", "class": consts.className.BUTTON + " " + consts.className.ICO_LOADING }); + icoObj.attr({ + style: "", + class: consts.className.BUTTON + " " + consts.className.ICO_LOADING, + }); } var tmpParam = {}; - var autoParam = tools.apply(setting.async.autoParam, [setting.treeId, node], setting.async.autoParam); + var autoParam = tools.apply( + setting.async.autoParam, + [setting.treeId, node], + setting.async.autoParam + ); for (i = 0, l = autoParam.length; node && i < l; i++) { - var pKey = autoParam[i].split("="), spKey = pKey; + var pKey = autoParam[i].split("="), + spKey = pKey; if (pKey.length > 1) { spKey = pKey[1]; pKey = pKey[0]; } tmpParam[spKey] = node[pKey]; } - var otherParam = tools.apply(setting.async.otherParam, [setting.treeId, node], setting.async.otherParam); + var otherParam = tools.apply( + setting.async.otherParam, + [setting.treeId, node], + setting.async.otherParam + ); if (tools.isArray(otherParam)) { for (i = 0, l = otherParam.length; i < l; i += 2) { tmpParam[otherParam[i]] = otherParam[i + 1]; @@ -1096,12 +1359,19 @@ contentType: setting.async.contentType, cache: false, type: setting.async.type, - url: tools.apply(setting.async.url, [setting.treeId, node], setting.async.url), - data: setting.async.contentType.indexOf('application/json') > -1 ? JSON.stringify(tmpParam) : tmpParam, + url: tools.apply( + setting.async.url, + [setting.treeId, node], + setting.async.url + ), + data: + setting.async.contentType.indexOf("application/json") > -1 + ? JSON.stringify(tmpParam) + : tmpParam, dataType: setting.async.dataType, headers: setting.async.headers, xhrFields: setting.async.xhrFields, - success: function (msg) { + success: function(msg) { if (_tmpV != data.getRoot(setting)._ver) { return; } @@ -1124,28 +1394,49 @@ } view.setNodeLineIcos(setting, node); if (newNodes && newNodes !== "") { - newNodes = tools.apply(setting.async.dataFilter, [setting.treeId, node, newNodes], newNodes); - view.addNodes(setting, node, -1, !!newNodes ? tools.clone(newNodes) : [], !!isSilent); + newNodes = tools.apply( + setting.async.dataFilter, + [setting.treeId, node, newNodes], + newNodes + ); + view.addNodes( + setting, + node, + -1, + !!newNodes ? tools.clone(newNodes) : [], + !!isSilent + ); } else { view.addNodes(setting, node, -1, [], !!isSilent); } - setting.treeObj.trigger(consts.event.ASYNC_SUCCESS, [setting.treeId, node, msg]); + setting.treeObj.trigger(consts.event.ASYNC_SUCCESS, [ + setting.treeId, + node, + msg, + ]); tools.apply(callback); }, - error: function (XMLHttpRequest, textStatus, errorThrown) { + error: function(XMLHttpRequest, textStatus, errorThrown) { if (_tmpV != data.getRoot(setting)._ver) { return; } if (node) node.isAjaxing = null; view.setNodeLineIcos(setting, node); - setting.treeObj.trigger(consts.event.ASYNC_ERROR, [setting.treeId, node, XMLHttpRequest, textStatus, errorThrown]); - } + setting.treeObj.trigger(consts.event.ASYNC_ERROR, [ + setting.treeId, + node, + XMLHttpRequest, + textStatus, + errorThrown, + ]); + }, }); return true; }, - cancelPreSelectedNode: function (setting, node, excludeNode) { + cancelPreSelectedNode: function(setting, node, excludeNode) { var list = data.getRoot(setting).curSelectedList, - i, n; + i, + n; for (i = list.length - 1; i >= 0; i--) { n = list[i]; if (node === n || (!node && (!excludeNode || excludeNode !== n))) { @@ -1155,30 +1446,48 @@ break; } else { list.splice(i, 1); - setting.treeObj.trigger(consts.event.UNSELECTED, [setting.treeId, n]); + setting.treeObj.trigger(consts.event.UNSELECTED, [ + setting.treeId, + n, + ]); } } } }, - createNodeCallback: function (setting) { + createNodeCallback: function(setting) { if (!!setting.callback.onNodeCreated || !!setting.view.addDiyDom) { var root = data.getRoot(setting); while (root.createdNodes.length > 0) { var node = root.createdNodes.shift(); tools.apply(setting.view.addDiyDom, [setting.treeId, node]); if (!!setting.callback.onNodeCreated) { - setting.treeObj.trigger(consts.event.NODECREATED, [setting.treeId, node]); + setting.treeObj.trigger(consts.event.NODECREATED, [ + setting.treeId, + node, + ]); } } } }, - createNodes: function (setting, level, nodes, parentNode, index) { + createNodes: function(setting, level, nodes, parentNode, index) { if (!nodes || nodes.length == 0) return; var root = data.getRoot(setting), - openFlag = !parentNode || parentNode.open || !!$$(data.nodeChildren(setting, parentNode)[0], setting).get(0); + openFlag = + !parentNode || + parentNode.open || + !!$$(data.nodeChildren(setting, parentNode)[0], setting).get(0); root.createdNodes = []; - var zTreeHtml = view.appendNodes(setting, level, nodes, parentNode, index, true, openFlag), - parentObj, nextObj; + var zTreeHtml = view.appendNodes( + setting, + level, + nodes, + parentNode, + index, + true, + openFlag + ), + parentObj, + nextObj; if (!parentNode) { parentObj = setting.treeObj; @@ -1195,15 +1504,15 @@ nextObj = parentObj.children()[index]; } if (index >= 0 && nextObj) { - $(nextObj).before(zTreeHtml.join('')); + $(nextObj).before(zTreeHtml.join("")); } else { - parentObj.append(zTreeHtml.join('')); + parentObj.append(zTreeHtml.join("")); } } view.createNodeCallback(setting); }, - destroy: function (setting) { + destroy: function(setting) { if (!setting) return; data.initCache(setting); data.initRoot(setting); @@ -1212,7 +1521,13 @@ setting.treeObj.empty(); delete settings[setting.treeId]; }, - expandCollapseNode: function (setting, node, expandFlag, animateFlag, callback) { + expandCollapseNode: function( + setting, + node, + expandFlag, + animateFlag, + callback + ) { var root = data.getRoot(setting); var tmpCb, _callback; if (!node) { @@ -1223,18 +1538,31 @@ var isParent = data.nodeIsParent(setting, node); if (root.expandTriggerFlag) { _callback = callback; - tmpCb = function () { + tmpCb = function() { if (_callback) _callback(); if (node.open) { - setting.treeObj.trigger(consts.event.EXPAND, [setting.treeId, node]); + setting.treeObj.trigger(consts.event.EXPAND, [ + setting.treeId, + node, + ]); } else { - setting.treeObj.trigger(consts.event.COLLAPSE, [setting.treeId, node]); + setting.treeObj.trigger(consts.event.COLLAPSE, [ + setting.treeId, + node, + ]); } }; callback = tmpCb; root.expandTriggerFlag = false; } - if (!node.open && isParent && ((!$$(node, consts.id.UL, setting).get(0)) || (children && children.length > 0 && !$$(children[0], setting).get(0)))) { + if ( + !node.open && + isParent && + (!$$(node, consts.id.UL, setting).get(0) || + (children && + children.length > 0 && + !$$(children[0], setting).get(0))) + ) { view.appendParentULDom(setting, node); view.createNodeCallback(setting); } @@ -1269,7 +1597,11 @@ } else { view.replaceSwitchClass(node, switchObj, consts.folder.CLOSE); view.replaceIcoClass(node, icoObj, consts.folder.CLOSE); - if (animateFlag == false || setting.view.expandSpeed == "" || !(children && children.length > 0)) { + if ( + animateFlag == false || + setting.view.expandSpeed == "" || + !(children && children.length > 0) + ) { ulObj.hide(); tools.apply(callback, []); } else { @@ -1280,33 +1612,71 @@ tools.apply(callback, []); } }, - expandCollapseParentNode: function (setting, node, expandFlag, animateFlag, callback) { + expandCollapseParentNode: function( + setting, + node, + expandFlag, + animateFlag, + callback + ) { if (!node) return; if (!node.parentTId) { - view.expandCollapseNode(setting, node, expandFlag, animateFlag, callback); + view.expandCollapseNode( + setting, + node, + expandFlag, + animateFlag, + callback + ); return; } else { view.expandCollapseNode(setting, node, expandFlag, animateFlag); } if (node.parentTId) { - view.expandCollapseParentNode(setting, node.getParentNode(), expandFlag, animateFlag, callback); + view.expandCollapseParentNode( + setting, + node.getParentNode(), + expandFlag, + animateFlag, + callback + ); } }, - expandCollapseSonNode: function (setting, node, expandFlag, animateFlag, callback) { + expandCollapseSonNode: function( + setting, + node, + expandFlag, + animateFlag, + callback + ) { var root = data.getRoot(setting), - treeNodes = (node) ? data.nodeChildren(setting, node) : data.nodeChildren(setting, root), - selfAnimateSign = (node) ? false : animateFlag, + treeNodes = node + ? data.nodeChildren(setting, node) + : data.nodeChildren(setting, root), + selfAnimateSign = node ? false : animateFlag, expandTriggerFlag = data.getRoot(setting).expandTriggerFlag; data.getRoot(setting).expandTriggerFlag = false; if (treeNodes) { for (var i = 0, l = treeNodes.length; i < l; i++) { - if (treeNodes[i]) view.expandCollapseSonNode(setting, treeNodes[i], expandFlag, selfAnimateSign); + if (treeNodes[i]) + view.expandCollapseSonNode( + setting, + treeNodes[i], + expandFlag, + selfAnimateSign + ); } } data.getRoot(setting).expandTriggerFlag = expandTriggerFlag; - view.expandCollapseNode(setting, node, expandFlag, animateFlag, callback); + view.expandCollapseNode( + setting, + node, + expandFlag, + animateFlag, + callback + ); }, - isSelectedNode: function (setting, node) { + isSelectedNode: function(setting, node) { if (!node) { return false; } @@ -1319,28 +1689,63 @@ } return false; }, - makeDOMNodeIcon: function (html, setting, node) { + makeDOMNodeIcon: function(html, setting, node) { var nameStr = data.nodeName(setting, node), - name = setting.view.nameIsHTML ? nameStr : nameStr.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>'); - html.push("<span id='", node.tId, consts.id.ICON, - "' title='' treeNode", consts.id.ICON, " class='", view.makeNodeIcoClass(setting, node), - "' style='", view.makeNodeIcoStyle(setting, node), "'></span><span id='", node.tId, consts.id.SPAN, - "' class='", view.makeNodeNameClass(node), - "'>", name, "</span>"); + name = setting.view.nameIsHTML + ? nameStr + : nameStr + .replace(/&/g, "&") + .replace(/</g, "<") + .replace(/>/g, ">"); + html.push( + "<span id='", + node.tId, + consts.id.ICON, + "' title='' treeNode", + consts.id.ICON, + " class='", + view.makeNodeIcoClass(setting, node), + "' style='", + view.makeNodeIcoStyle(setting, node), + "'></span><span id='", + node.tId, + consts.id.SPAN, + "' class='", + view.makeNodeNameClass(node), + "'>", + name, + "</span>" + ); }, - makeDOMNodeLine: function (html, setting, node) { - html.push("<span id='", node.tId, consts.id.SWITCH, "' title='' class='", view.makeNodeLineClass(setting, node), "' treeNode", consts.id.SWITCH, "></span>"); + makeDOMNodeLine: function(html, setting, node) { + html.push( + "<span id='", + node.tId, + consts.id.SWITCH, + "' title='' class='", + view.makeNodeLineClass(setting, node), + "' treeNode", + consts.id.SWITCH, + "></span>" + ); }, - makeDOMNodeMainAfter: function (html, setting, node) { + makeDOMNodeMainAfter: function(html, setting, node) { html.push("</li>"); }, - makeDOMNodeMainBefore: function (html, setting, node) { - html.push("<li id='", node.tId, "' class='", consts.className.LEVEL, node.level, "' tabindex='0' hidefocus='true' treenode>"); + makeDOMNodeMainBefore: function(html, setting, node) { + html.push( + "<li id='", + node.tId, + "' class='", + consts.className.LEVEL, + node.level, + "' tabindex='0' hidefocus='true' treenode>" + ); }, - makeDOMNodeNameAfter: function (html, setting, node) { + makeDOMNodeNameAfter: function(html, setting, node) { html.push("</a>"); }, - makeDOMNodeNameBefore: function (html, setting, node) { + makeDOMNodeNameBefore: function(html, setting, node) { var title = data.nodeTitle(setting, node), url = view.makeNodeUrl(setting, node), fontcss = view.makeNodeFontCss(setting, node), @@ -1349,26 +1754,62 @@ for (var f in fontcss) { fontStyle.push(f, ":", fontcss[f], ";"); } - html.push("<a id='", node.tId, consts.id.A, "' class='", consts.className.LEVEL, node.level, - nodeClasses.add ? ' ' + nodeClasses.add.join(' ') : '', - "' treeNode", consts.id.A, - node.click ? " onclick=\"" + node.click + "\"" : "", - ((url != null && url.length > 0) ? " href='" + url + "'" : ""), " target='", view.makeNodeTarget(node), "' style='", fontStyle.join(''), - "'"); - if (tools.apply(setting.view.showTitle, [setting.treeId, node], setting.view.showTitle) && title) { - html.push("title='", title.replace(/'/g, "'").replace(/</g, '<').replace(/>/g, '>'), "'"); + html.push( + "<a id='", + node.tId, + consts.id.A, + "' class='", + consts.className.LEVEL, + node.level, + nodeClasses.add ? " " + nodeClasses.add.join(" ") : "", + "' treeNode", + consts.id.A, + node.click ? ' onclick="' + node.click + '"' : "", + url != null && url.length > 0 ? " href='" + url + "'" : "", + " target='", + view.makeNodeTarget(node), + "' style='", + fontStyle.join(""), + "'" + ); + if ( + tools.apply( + setting.view.showTitle, + [setting.treeId, node], + setting.view.showTitle + ) && + title + ) { + html.push( + "title='", + title + .replace(/'/g, "'") + .replace(/</g, "<") + .replace(/>/g, ">"), + "'" + ); } html.push(">"); }, - makeNodeFontCss: function (setting, node) { - var fontCss = tools.apply(setting.view.fontCss, [setting.treeId, node], setting.view.fontCss); - return (fontCss && ((typeof fontCss) != "function")) ? fontCss : {}; + makeNodeFontCss: function(setting, node) { + var fontCss = tools.apply( + setting.view.fontCss, + [setting.treeId, node], + setting.view.fontCss + ); + return fontCss && typeof fontCss != "function" ? fontCss : {}; }, - makeNodeClasses: function (setting, node) { - var classes = tools.apply(setting.view.nodeClasses, [setting.treeId, node], setting.view.nodeClasses); - return (classes && (typeof classes !== "function")) ? classes : { add: [], remove: [] }; + makeNodeClasses: function(setting, node) { + var classes = tools.apply( + setting.view.nodeClasses, + [setting.treeId, node], + setting.view.nodeClasses + ); + return classes && typeof classes !== "function" + ? classes + : { add: [], remove: [] }; }, - makeNodeIcoClass: function (setting, node) { + makeNodeIcoClass: function(setting, node) { var icoCss = ["ico"]; if (!node.isAjaxing) { var isParent = data.nodeIsParent(setting, node); @@ -1377,42 +1818,50 @@ icoCss.push(node.open ? consts.folder.OPEN : consts.folder.CLOSE); } else { // 瀹氬埗瀛愯妭鐐瑰浘鏍� - let fontClass = "" - if (node.type === '4' && !node.isAI) { - fontClass = "iconjiankongshexiangji" + let fontClass = ""; + if (node.type === "4" && !node.isAI) { + fontClass = "iconjiankongshexiangji"; } else if (node.isAI) { - fontClass = "iconfenxishexiangji" + fontClass = "iconfenxishexiangji"; } if (node.isRunning) { - fontClass = fontClass + " running" + fontClass = fontClass + " running"; } - return "iconfont " + fontClass + return "iconfont " + fontClass; } } - return consts.className.BUTTON + " " + icoCss.join('_'); + return consts.className.BUTTON + " " + icoCss.join("_"); }, - makeNodeNameClass: function (node) { + makeNodeNameClass: function(node) { let icoCss = ""; if (node.isRunning) { icoCss = " running"; } return consts.className.NAME + icoCss; }, - makeNodeIcoStyle: function (setting, node) { + makeNodeIcoStyle: function(setting, node) { var icoStyle = []; if (!node.isAjaxing) { var isParent = data.nodeIsParent(setting, node); - var icon = (isParent && node.iconOpen && node.iconClose) ? (node.open ? node.iconOpen : node.iconClose) : node[setting.data.key.icon]; + var icon = + isParent && node.iconOpen && node.iconClose + ? node.open + ? node.iconOpen + : node.iconClose + : node[setting.data.key.icon]; if (icon) icoStyle.push("background:url(", icon, ") 0 0 no-repeat;"); - if (setting.view.showIcon == false || !tools.apply(setting.view.showIcon, [setting.treeId, node], true)) { + if ( + setting.view.showIcon == false || + !tools.apply(setting.view.showIcon, [setting.treeId, node], true) + ) { icoStyle.push("display:none;"); } } - return icoStyle.join(''); + return icoStyle.join(""); }, - makeNodeLineClass: function (setting, node) { + makeNodeLineClass: function(setting, node) { var lineClass = []; if (setting.view.showLine) { if (node.level == 0 && node.isFirstNode && node.isLastNode) { @@ -1432,27 +1881,49 @@ } else { lineClass.push(consts.folder.DOCU); } - return view.makeNodeLineClassEx(node) + lineClass.join('_'); + return view.makeNodeLineClassEx(node) + lineClass.join("_"); }, - makeNodeLineClassEx: function (node) { - return consts.className.BUTTON + " " + consts.className.LEVEL + node.level + " " + consts.className.SWITCH + " "; + makeNodeLineClassEx: function(node) { + return ( + consts.className.BUTTON + + " " + + consts.className.LEVEL + + node.level + + " " + + consts.className.SWITCH + + " " + ); }, - makeNodeTarget: function (node) { - return (node.target || "_blank"); + makeNodeTarget: function(node) { + return node.target || "_blank"; }, - makeNodeUrl: function (setting, node) { + makeNodeUrl: function(setting, node) { var urlKey = setting.data.key.url; return node[urlKey] ? node[urlKey] : null; }, - makeUlHtml: function (setting, node, html, content) { - html.push("<ul id='", node.tId, consts.id.UL, "' class='", consts.className.LEVEL, node.level, " ", view.makeUlLineClass(setting, node), "' style='display:", (node.open ? "block" : "none"), "'>"); + makeUlHtml: function(setting, node, html, content) { + html.push( + "<ul id='", + node.tId, + consts.id.UL, + "' class='", + consts.className.LEVEL, + node.level, + " ", + view.makeUlLineClass(setting, node), + "' style='display:", + node.open ? "block" : "none", + "'>" + ); html.push(content); html.push("</ul>"); }, - makeUlLineClass: function (setting, node) { - return ((setting.view.showLine && !node.isLastNode) ? consts.line.LINE : ""); + makeUlLineClass: function(setting, node) { + return setting.view.showLine && !node.isLastNode + ? consts.line.LINE + : ""; }, - removeChildNodes: function (setting, node) { + removeChildNodes: function(setting, node) { if (!node) return; var nodes = data.nodeChildren(setting, node); if (!nodes) return; @@ -1475,27 +1946,34 @@ $$(node, consts.id.UL, setting).empty(); } }, - scrollIntoView: function (setting, dom) { + scrollIntoView: function(setting, dom) { if (!dom) { return; } // support IE 7 / 8 - if (typeof Element === 'undefined' || typeof HTMLElement === 'undefined') { + if ( + typeof Element === "undefined" || + typeof HTMLElement === "undefined" + ) { var contRect = setting.treeObj.get(0).getBoundingClientRect(), findMeRect = dom.getBoundingClientRect(); - if (findMeRect.top < contRect.top || findMeRect.bottom > contRect.bottom - || findMeRect.right > contRect.right || findMeRect.left < contRect.left) { + if ( + findMeRect.top < contRect.top || + findMeRect.bottom > contRect.bottom || + findMeRect.right > contRect.right || + findMeRect.left < contRect.left + ) { dom.scrollIntoView(); } return; } // CC-BY jocki84@googlemail.com, https://gist.github.com/jocki84/6ffafd003387179a988e if (!Element.prototype.scrollIntoViewIfNeeded) { - Element.prototype.scrollIntoViewIfNeeded = function (centerIfNeeded) { + Element.prototype.scrollIntoViewIfNeeded = function(centerIfNeeded) { "use strict"; function makeRange(start, length) { - return { "start": start, "length": length, "end": start + length }; + return { start: start, length: length, end: start + length }; } function coverRange(inner, outer) { @@ -1513,11 +1991,11 @@ function makePoint(x, y) { return { - "x": x, - "y": y, - "translate": function translate(dX, dY) { + x: x, + y: y, + translate: function translate(dX, dY) { return makePoint(x + dX, y + dY); - } + }, }; } @@ -1536,7 +2014,10 @@ while (elem instanceof HTMLElement) { // Apply desired scroll amount. - origin = absolute(elem, makePoint(elem.clientLeft, elem.clientTop)); + origin = absolute( + elem, + makePoint(elem.clientLeft, elem.clientTop) + ); elem.scrollLeft = coverRange( makeRange(target.x - origin.x, extent.x), makeRange(elem.scrollLeft, elem.clientWidth) @@ -1554,28 +2035,28 @@ } dom.scrollIntoViewIfNeeded(); }, - setFirstNode: function (setting, parentNode) { + setFirstNode: function(setting, parentNode) { var children = data.nodeChildren(setting, parentNode); if (children.length > 0) { children[0].isFirstNode = true; } }, - setLastNode: function (setting, parentNode) { + setLastNode: function(setting, parentNode) { var children = data.nodeChildren(setting, parentNode); if (children.length > 0) { children[children.length - 1].isLastNode = true; } }, - removeNode: function (setting, node) { + removeNode: function(setting, node) { var root = data.getRoot(setting), - parentNode = (node.parentTId) ? node.getParentNode() : root; + parentNode = node.parentTId ? node.getParentNode() : root; node.isFirstNode = false; node.isLastNode = false; - node.getPreNode = function () { + node.getPreNode = function() { return null; }; - node.getNextNode = function () { + node.getNextNode = function() { return null; }; @@ -1597,7 +2078,9 @@ view.setFirstNode(setting, parentNode); view.setLastNode(setting, parentNode); - var tmp_ulObj, tmp_switchObj, tmp_icoObj, + var tmp_ulObj, + tmp_switchObj, + tmp_icoObj, childLength = children.length; //repair nodes old parent @@ -1609,10 +2092,13 @@ tmp_ulObj = $$(parentNode, consts.id.UL, setting); tmp_switchObj = $$(parentNode, consts.id.SWITCH, setting); tmp_icoObj = $$(parentNode, consts.id.ICON, setting); - view.replaceSwitchClass(parentNode, tmp_switchObj, consts.folder.DOCU); + view.replaceSwitchClass( + parentNode, + tmp_switchObj, + consts.folder.DOCU + ); view.replaceIcoClass(parentNode, tmp_icoObj, consts.folder.DOCU); tmp_ulObj.css("display", "none"); - } else if (setting.view.showLine && childLength > 0) { //old parentNode has child nodes var newLast = children[childLength - 1]; @@ -1624,9 +2110,21 @@ //node was root, and ztree has only one root after move node view.replaceSwitchClass(newLast, tmp_switchObj, consts.line.ROOT); } else { - var tmp_first_switchObj = $$(children[0], consts.id.SWITCH, setting); - view.replaceSwitchClass(children[0], tmp_first_switchObj, consts.line.ROOTS); - view.replaceSwitchClass(newLast, tmp_switchObj, consts.line.BOTTOM); + var tmp_first_switchObj = $$( + children[0], + consts.id.SWITCH, + setting + ); + view.replaceSwitchClass( + children[0], + tmp_first_switchObj, + consts.line.ROOTS + ); + view.replaceSwitchClass( + newLast, + tmp_switchObj, + consts.line.BOTTOM + ); } } else { view.replaceSwitchClass(newLast, tmp_switchObj, consts.line.BOTTOM); @@ -1634,7 +2132,7 @@ tmp_ulObj.removeClass(consts.line.LINE); } }, - replaceIcoClass: function (node, obj, newName) { + replaceIcoClass: function(node, obj, newName) { if (!obj || node.isAjaxing) return; var tmpName = obj.attr("class"); if (tmpName == undefined) return; @@ -1648,7 +2146,7 @@ } obj.attr("class", tmpList.join("_")); }, - replaceSwitchClass: function (node, obj, newName) { + replaceSwitchClass: function(node, obj, newName) { if (!obj) return; var tmpName = obj.attr("class"); if (tmpName == undefined) return; @@ -1674,7 +2172,7 @@ obj.attr("disabled", "disabled"); } }, - selectNode: function (setting, node, addFlag) { + selectNode: function(setting, node, addFlag) { // debugger if (!addFlag) { view.cancelPreSelectedNode(setting, null, node); @@ -1683,24 +2181,24 @@ data.addSelectedNode(setting, node); setting.treeObj.trigger(consts.event.SELECTED, [setting.treeId, node]); }, - setNodeFontCss: function (setting, treeNode) { + setNodeFontCss: function(setting, treeNode) { var aObj = $$(treeNode, consts.id.A, setting), fontCss = view.makeNodeFontCss(setting, treeNode); if (fontCss) { aObj.css(fontCss); } }, - setNodeClasses: function (setting, treeNode) { + setNodeClasses: function(setting, treeNode) { var aObj = $$(treeNode, consts.id.A, setting), classes = view.makeNodeClasses(setting, treeNode); - if ('add' in classes && classes.add.length) { - aObj.addClass(classes.add.join(' ')); + if ("add" in classes && classes.add.length) { + aObj.addClass(classes.add.join(" ")); } - if ('remove' in classes && classes.remove.length) { - aObj.removeClass(classes.remove.join(' ')); + if ("remove" in classes && classes.remove.length) { + aObj.removeClass(classes.remove.join(" ")); } }, - setNodeLineIcos: function (setting, node) { + setNodeLineIcos: function(setting, node) { if (!node) return; var switchObj = $$(node, consts.id.SWITCH, setting), ulObj = $$(node, consts.id.UL, setting), @@ -1722,7 +2220,7 @@ icoObj.attr("class", view.makeNodeIcoClass(setting, node)); // icoObj.attr("class", view.makeNodeNameClass(setting, node)); }, - setNodeName: function (setting, node) { + setNodeName: function(setting, node) { var title = data.nodeTitle(setting, node), nObj = $$(node, consts.id.SPAN, setting); nObj.empty(); @@ -1731,16 +2229,22 @@ } else { nObj.text(data.nodeName(setting, node)); } - if (tools.apply(setting.view.showTitle, [setting.treeId, node], setting.view.showTitle)) { + if ( + tools.apply( + setting.view.showTitle, + [setting.treeId, node], + setting.view.showTitle + ) + ) { var aObj = $$(node, consts.id.A, setting); aObj.attr("title", !title ? "" : title); } }, - setNodeTarget: function (setting, node) { + setNodeTarget: function(setting, node) { var aObj = $$(node, consts.id.A, setting); aObj.attr("target", view.makeNodeTarget(node)); }, - setNodeUrl: function (setting, node) { + setNodeUrl: function(setting, node) { var aObj = $$(node, consts.id.A, setting), url = view.makeNodeUrl(setting, node); if (url == null || url.length == 0) { @@ -1749,7 +2253,7 @@ aObj.attr("href", url); } }, - switchNode: function (setting, node) { + switchNode: function(setting, node) { if (node.open || !tools.canAsync(setting, node)) { view.expandCollapseNode(setting, node, !node.open); } else if (setting.async.enable) { @@ -1760,7 +2264,7 @@ } else if (node) { view.expandCollapseNode(setting, node, !node.open); } - } + }, }; // zTree defind $.fn.zTree = { @@ -1769,13 +2273,13 @@ tools: tools, view: view, event: event, - data: data + data: data, }, - getZTreeObj: function (treeId) { + getZTreeObj: function(treeId) { var o = data.getZTreeTools(treeId); return o ? o : null; }, - destroy: function (treeId) { + destroy: function(treeId) { if (!!treeId && treeId.length > 0) { view.destroy(data.getSetting(treeId)); } else { @@ -1784,7 +2288,7 @@ } } }, - init: function (obj, zSetting, zNodes) { + init: function(obj, zSetting, zNodes) { var setting = tools.clone(_setting); $.extend(true, setting, zSetting); setting.treeId = obj.attr("id"); @@ -1797,9 +2301,15 @@ } data.initRoot(setting); var root = data.getRoot(setting); - zNodes = zNodes ? tools.clone(tools.isArray(zNodes) ? zNodes : [zNodes]) : []; + zNodes = zNodes + ? tools.clone(tools.isArray(zNodes) ? zNodes : [zNodes]) + : []; if (setting.data.simpleData.enable) { - data.nodeChildren(setting, root, data.transformTozTreeFormat(setting, zNodes)); + data.nodeChildren( + setting, + root, + data.transformTozTreeFormat(setting, zNodes) + ); } else { data.nodeChildren(setting, root, zNodes); } @@ -1812,7 +2322,7 @@ var zTreeTools = { setting: setting, - addNodes: function (parentNode, index, newNodes, isSilent) { + addNodes: function(parentNode, index, newNodes, isSilent) { if (!parentNode) parentNode = null; var isParent = data.nodeIsParent(setting, parentNode); if (parentNode && !isParent && setting.data.keep.leaf) return null; @@ -1827,11 +2337,18 @@ } if (!newNodes) return null; - - var xNewNodes = tools.clone(tools.isArray(newNodes) ? newNodes : [newNodes]); + var xNewNodes = tools.clone( + tools.isArray(newNodes) ? newNodes : [newNodes] + ); function addCallback() { - view.addNodes(setting, parentNode, index, xNewNodes, (isSilent == true)); + view.addNodes( + setting, + parentNode, + index, + xNewNodes, + isSilent == true + ); } if (tools.canAsync(setting, parentNode)) { @@ -1841,31 +2358,52 @@ } return xNewNodes; }, - cancelSelectedNode: function (node) { + cancelSelectedNode: function(node) { view.cancelPreSelectedNode(setting, node); }, - destroy: function () { + destroy: function() { view.destroy(setting); }, - expandAll: function (expandFlag) { + expandAll: function(expandFlag) { expandFlag = !!expandFlag; view.expandCollapseSonNode(setting, null, expandFlag, true); return expandFlag; }, - expandNode: function (node, expandFlag, sonSign, focus, callbackFlag) { + expandNode: function(node, expandFlag, sonSign, focus, callbackFlag) { if (!node || !data.nodeIsParent(setting, node)) return null; if (expandFlag !== true && expandFlag !== false) { expandFlag = !node.open; } callbackFlag = !!callbackFlag; - if (callbackFlag && expandFlag && (tools.apply(setting.callback.beforeExpand, [setting.treeId, node], true) == false)) { + if ( + callbackFlag && + expandFlag && + tools.apply( + setting.callback.beforeExpand, + [setting.treeId, node], + true + ) == false + ) { return null; - } else if (callbackFlag && !expandFlag && (tools.apply(setting.callback.beforeCollapse, [setting.treeId, node], true) == false)) { + } else if ( + callbackFlag && + !expandFlag && + tools.apply( + setting.callback.beforeCollapse, + [setting.treeId, node], + true + ) == false + ) { return null; } if (expandFlag && node.parentTId) { - view.expandCollapseParentNode(setting, node.getParentNode(), expandFlag, false); + view.expandCollapseParentNode( + setting, + node.getParentNode(), + expandFlag, + false + ); } if (expandFlag === node.open && !sonSign) { return null; @@ -1873,7 +2411,13 @@ data.getRoot(setting).expandTriggerFlag = callbackFlag; if (!tools.canAsync(setting, node) && sonSign) { - view.expandCollapseSonNode(setting, node, expandFlag, true, showNodeFocus); + view.expandCollapseSonNode( + setting, + node, + expandFlag, + true, + showNodeFocus + ); } else { node.open = !expandFlag; view.switchNode(this.setting, node); @@ -1888,61 +2432,104 @@ } } }, - getNodes: function () { + getNodes: function() { return data.getNodes(setting); }, - getNodeByParam: function (key, value, parentNode) { + getNodeByParam: function(key, value, parentNode) { if (!key) return null; - return data.getNodeByParam(setting, parentNode ? data.nodeChildren(setting, parentNode) : data.getNodes(setting), key, value); + return data.getNodeByParam( + setting, + parentNode + ? data.nodeChildren(setting, parentNode) + : data.getNodes(setting), + key, + value + ); }, - getNodeByTId: function (tId) { + getNodeByTId: function(tId) { return data.getNodeCache(setting, tId); }, - getNodesByParam: function (key, value, parentNode) { + getNodesByParam: function(key, value, parentNode) { if (!key) return null; - return data.getNodesByParam(setting, parentNode ? data.nodeChildren(setting, parentNode) : data.getNodes(setting), key, value); + return data.getNodesByParam( + setting, + parentNode + ? data.nodeChildren(setting, parentNode) + : data.getNodes(setting), + key, + value + ); }, - getNodesByParamFuzzy: function (key, value, parentNode) { + getNodesByParamFuzzy: function(key, value, parentNode) { if (!key) return null; - return data.getNodesByParamFuzzy(setting, parentNode ? data.nodeChildren(setting, parentNode) : data.getNodes(setting), key, value); + return data.getNodesByParamFuzzy( + setting, + parentNode + ? data.nodeChildren(setting, parentNode) + : data.getNodes(setting), + key, + value + ); }, - getNodesByFilter: function (filter, isSingle, parentNode, invokeParam) { + getNodesByFilter: function(filter, isSingle, parentNode, invokeParam) { isSingle = !!isSingle; - if (!filter || (typeof filter != "function")) return (isSingle ? null : []); - return data.getNodesByFilter(setting, parentNode ? data.nodeChildren(setting, parentNode) : data.getNodes(setting), filter, isSingle, invokeParam); + if (!filter || typeof filter != "function") + return isSingle ? null : []; + return data.getNodesByFilter( + setting, + parentNode + ? data.nodeChildren(setting, parentNode) + : data.getNodes(setting), + filter, + isSingle, + invokeParam + ); }, - getNodeIndex: function (node) { + getNodeIndex: function(node) { if (!node) return null; - var parentNode = (node.parentTId) ? node.getParentNode() : data.getRoot(setting); + var parentNode = node.parentTId + ? node.getParentNode() + : data.getRoot(setting); var children = data.nodeChildren(setting, parentNode); for (var i = 0, l = children.length; i < l; i++) { if (children[i] == node) return i; } return -1; }, - getSelectedNodes: function () { - var r = [], list = data.getRoot(setting).curSelectedList; + getSelectedNodes: function() { + var r = [], + list = data.getRoot(setting).curSelectedList; for (var i = 0, l = list.length; i < l; i++) { r.push(list[i]); } return r; }, - isSelectedNode: function (node) { + isSelectedNode: function(node) { return data.isSelectedNode(setting, node); }, - reAsyncChildNodesPromise: function (parentNode, reloadType, isSilent) { - var promise = new Promise(function (resolve, reject) { + reAsyncChildNodesPromise: function(parentNode, reloadType, isSilent) { + var promise = new Promise(function(resolve, reject) { try { - zTreeTools.reAsyncChildNodes(parentNode, reloadType, isSilent, function () { - resolve(parentNode); - }); + zTreeTools.reAsyncChildNodes( + parentNode, + reloadType, + isSilent, + function() { + resolve(parentNode); + } + ); } catch (e) { reject(e); } }); return promise; }, - reAsyncChildNodes: function (parentNode, reloadType, isSilent, callback) { + reAsyncChildNodes: function( + parentNode, + reloadType, + isSilent, + callback + ) { if (!this.setting.async.enable) return; var isRoot = !parentNode; if (isRoot) { @@ -1962,43 +2549,72 @@ ulObj.empty(); } } - view.asyncNode(this.setting, isRoot ? null : parentNode, !!isSilent, callback); + view.asyncNode( + this.setting, + isRoot ? null : parentNode, + !!isSilent, + callback + ); }, - refresh: function () { + refresh: function() { this.setting.treeObj.empty(); var root = data.getRoot(setting), nodes = data.nodeChildren(setting, root); data.initRoot(setting); data.nodeChildren(setting, root, nodes); data.initCache(setting); - view.createNodes(setting, 0, data.nodeChildren(setting, root), null, -1); + view.createNodes( + setting, + 0, + data.nodeChildren(setting, root), + null, + -1 + ); }, - removeChildNodes: function (node) { + removeChildNodes: function(node) { if (!node) return null; var nodes = data.nodeChildren(setting, node); view.removeChildNodes(setting, node); return nodes ? nodes : null; }, - removeNode: function (node, callbackFlag) { + removeNode: function(node, callbackFlag) { if (!node) return; callbackFlag = !!callbackFlag; - if (callbackFlag && tools.apply(setting.callback.beforeRemove, [setting.treeId, node], true) == false) return; + if ( + callbackFlag && + tools.apply( + setting.callback.beforeRemove, + [setting.treeId, node], + true + ) == false + ) + return; view.removeNode(setting, node); if (callbackFlag) { - this.setting.treeObj.trigger(consts.event.REMOVE, [setting.treeId, node]); + this.setting.treeObj.trigger(consts.event.REMOVE, [ + setting.treeId, + node, + ]); } }, - selectNode: function (node, addFlag, isSilent) { + selectNode: function(node, addFlag, isSilent) { if (!node) return; if (tools.uCanDo(setting)) { addFlag = setting.view.selectedMulti && addFlag; if (node.parentTId) { - view.expandCollapseParentNode(setting, node.getParentNode(), true, false, showNodeFocus); + view.expandCollapseParentNode( + setting, + node.getParentNode(), + true, + false, + showNodeFocus + ); } else if (!isSilent) { try { - $$(node, setting).focus().blur(); - } catch (e) { - } + $$(node, setting) + .focus() + .blur(); + } catch (e) {} } view.selectNode(setting, node, addFlag); } @@ -2011,13 +2627,13 @@ view.scrollIntoView(setting, a); } }, - transformTozTreeNodes: function (simpleNodes) { + transformTozTreeNodes: function(simpleNodes) { return data.transformTozTreeFormat(setting, simpleNodes); }, - transformToArray: function (nodes) { + transformToArray: function(nodes) { return data.transformToArrayFormat(setting, nodes); }, - updateNode: function (node, checkTypeFlag) { + updateNode: function(node, checkTypeFlag) { if (!node) return; var nObj = $$(node, setting); if (nObj.get(0) && tools.uCanDo(setting)) { @@ -2028,18 +2644,22 @@ view.setNodeFontCss(setting, node); view.setNodeClasses(setting, node); } - } + }, }; root.treeTools = zTreeTools; data.setZTreeTools(setting, zTreeTools); var children = data.nodeChildren(setting, root); if (children && children.length > 0) { view.createNodes(setting, 0, children, null, -1); - } else if (setting.async.enable && setting.async.url && setting.async.url !== '') { + } else if ( + setting.async.enable && + setting.async.url && + setting.async.url !== "" + ) { view.asyncNode(setting); } return zTreeTools; - } + }, }; var zt = $.fn.zTree, @@ -2059,31 +2679,31 @@ * Date: 2020-11-21 */ -(function ($) { +(function($) { //default consts of excheck var _consts = { - event: { - CHECK: "ztree_check" + event: { + CHECK: "ztree_check", + }, + id: { + CHECK: "_check", + }, + checkbox: { + STYLE: "checkbox", + DEFAULT: "chk", + DISABLED: "disable", + FALSE: "false", + TRUE: "true", + FULL: "full", + PART: "part", + FOCUS: "focus", + }, + radio: { + STYLE: "radio", + TYPE_ALL: "all", + TYPE_LEVEL: "level", + }, }, - id: { - CHECK: "_check" - }, - checkbox: { - STYLE: "checkbox", - DEFAULT: "chk", - DISABLED: "disable", - FALSE: "false", - TRUE: "true", - FULL: "full", - PART: "part", - FOCUS: "focus" - }, - radio: { - STYLE: "radio", - TYPE_ALL: "all", - TYPE_LEVEL: "level" - } - }, //default setting of excheck _setting = { check: { @@ -2094,62 +2714,76 @@ chkDisabledInherit: false, radioType: _consts.radio.TYPE_LEVEL, chkboxType: { - "Y": "ps", - "N": "ps" - } + Y: "ps", + N: "ps", + }, }, data: { key: { - checked: "checked" - } + checked: "checked", + }, }, callback: { beforeCheck: null, - onCheck: null - } + onCheck: null, + }, }, //default root of excheck - _initRoot = function (setting) { + _initRoot = function(setting) { var r = data.getRoot(setting); r.radioCheckedList = []; }, //default cache of excheck - _initCache = function (treeId) { - }, + _initCache = function(treeId) {}, //default bind event of excheck - _bindEvent = function (setting) { + _bindEvent = function(setting) { var o = setting.treeObj, c = consts.event; - o.bind(c.CHECK, function (event, srcEvent, treeId, node) { + o.bind(c.CHECK, function(event, srcEvent, treeId, node) { event.srcEvent = srcEvent; tools.apply(setting.callback.onCheck, [event, treeId, node]); }); }, - _unbindEvent = function (setting) { + _unbindEvent = function(setting) { var o = setting.treeObj, c = consts.event; o.unbind(c.CHECK); }, //default event proxy of excheck - _eventProxy = function (e) { + _eventProxy = function(e) { var target = e.target, setting = data.getSetting(e.data.treeId), - tId = "", node = null, - nodeEventType = "", treeEventType = "", - nodeEventCallback = null, treeEventCallback = null; + tId = "", + node = null, + nodeEventType = "", + treeEventType = "", + nodeEventCallback = null, + treeEventCallback = null; if (tools.eqs(e.type, "mouseover")) { - if (setting.check.enable && tools.eqs(target.tagName, "span") && target.getAttribute("treeNode" + consts.id.CHECK) !== null) { + if ( + setting.check.enable && + tools.eqs(target.tagName, "span") && + target.getAttribute("treeNode" + consts.id.CHECK) !== null + ) { tId = tools.getNodeMainDom(target).id; nodeEventType = "mouseoverCheck"; } } else if (tools.eqs(e.type, "mouseout")) { - if (setting.check.enable && tools.eqs(target.tagName, "span") && target.getAttribute("treeNode" + consts.id.CHECK) !== null) { + if ( + setting.check.enable && + tools.eqs(target.tagName, "span") && + target.getAttribute("treeNode" + consts.id.CHECK) !== null + ) { tId = tools.getNodeMainDom(target).id; nodeEventType = "mouseoutCheck"; } } else if (tools.eqs(e.type, "click")) { - if (setting.check.enable && tools.eqs(target.tagName, "span") && target.getAttribute("treeNode" + consts.id.CHECK) !== null) { + if ( + setting.check.enable && + tools.eqs(target.tagName, "span") && + target.getAttribute("treeNode" + consts.id.CHECK) !== null + ) { tId = tools.getNodeMainDom(target).id; nodeEventType = "checkNode"; } @@ -2174,42 +2808,78 @@ nodeEventType: nodeEventType, nodeEventCallback: nodeEventCallback, treeEventType: treeEventType, - treeEventCallback: treeEventCallback + treeEventCallback: treeEventCallback, }; - return proxyResult + return proxyResult; }, //default init node of excheck - _initNode = function (setting, level, n, parentNode, isFirstNode, isLastNode, openFlag) { + _initNode = function( + setting, + level, + n, + parentNode, + isFirstNode, + isLastNode, + openFlag + ) { if (!n) return; var checked = data.nodeChecked(setting, n); n.checkedOld = checked; - if (typeof n.nocheck == "string") n.nocheck = tools.eqs(n.nocheck, "true"); - n.nocheck = !!n.nocheck || (setting.check.nocheckInherit && parentNode && !!parentNode.nocheck); - if (typeof n.chkDisabled == "string") n.chkDisabled = tools.eqs(n.chkDisabled, "true"); - n.chkDisabled = !!n.chkDisabled || (setting.check.chkDisabledInherit && parentNode && !!parentNode.chkDisabled); - if (typeof n.halfCheck == "string") n.halfCheck = tools.eqs(n.halfCheck, "true"); + if (typeof n.nocheck == "string") + n.nocheck = tools.eqs(n.nocheck, "true"); + n.nocheck = + !!n.nocheck || + (setting.check.nocheckInherit && parentNode && !!parentNode.nocheck); + if (typeof n.chkDisabled == "string") + n.chkDisabled = tools.eqs(n.chkDisabled, "true"); + n.chkDisabled = + !!n.chkDisabled || + (setting.check.chkDisabledInherit && + parentNode && + !!parentNode.chkDisabled); + if (typeof n.halfCheck == "string") + n.halfCheck = tools.eqs(n.halfCheck, "true"); n.halfCheck = !!n.halfCheck; n.check_Child_State = -1; n.check_Focus = false; - n.getCheckStatus = function () { + n.getCheckStatus = function() { return data.getCheckStatus(setting, n); }; - if (setting.check.chkStyle == consts.radio.STYLE && setting.check.radioType == consts.radio.TYPE_ALL && checked) { + if ( + setting.check.chkStyle == consts.radio.STYLE && + setting.check.radioType == consts.radio.TYPE_ALL && + checked + ) { var r = data.getRoot(setting); r.radioCheckedList.push(n); } }, //add dom for check - _beforeA = function (setting, node, html) { + _beforeA = function(setting, node, html) { if (setting.check.enable) { data.makeChkFlag(setting, node); - html.push("<span ID='", node.tId, consts.id.CHECK, "' class='", view.makeChkClass(setting, node), "' treeNode", consts.id.CHECK, (node.nocheck === true ? " style='display:none;'" : ""), "></span>"); + html.push( + "<span ID='", + node.tId, + consts.id.CHECK, + "' class='", + view.makeChkClass(setting, node), + "' treeNode", + consts.id.CHECK, + node.nocheck === true ? " style='display:none;'" : "", + "></span>" + ); } }, //update zTreeObj, add method of check - _zTreeTools = function (setting, zTreeTools) { - zTreeTools.checkNode = function (node, checked, checkTypeFlag, callbackFlag) { + _zTreeTools = function(setting, zTreeTools) { + zTreeTools.checkNode = function( + node, + checked, + checkTypeFlag, + callbackFlag + ) { var nodeChecked = data.nodeChecked(setting, node); if (node.chkDisabled === true) return; if (checked !== true && checked !== false) { @@ -2219,60 +2889,98 @@ if (nodeChecked === checked && !checkTypeFlag) { return; - } else if (callbackFlag && tools.apply(this.setting.callback.beforeCheck, [this.setting.treeId, node], true) == false) { + } else if ( + callbackFlag && + tools.apply( + this.setting.callback.beforeCheck, + [this.setting.treeId, node], + true + ) == false + ) { return; } - if (tools.uCanDo(this.setting) && this.setting.check.enable && node.nocheck !== true) { + if ( + tools.uCanDo(this.setting) && + this.setting.check.enable && + node.nocheck !== true + ) { data.nodeChecked(setting, node, checked); var checkObj = $$(node, consts.id.CHECK, this.setting); - if (checkTypeFlag || this.setting.check.chkStyle === consts.radio.STYLE) view.checkNodeRelation(this.setting, node); + if ( + checkTypeFlag || + this.setting.check.chkStyle === consts.radio.STYLE + ) + view.checkNodeRelation(this.setting, node); view.setChkClass(this.setting, checkObj, node); view.repairParentChkClassWithSelf(this.setting, node); if (callbackFlag) { - this.setting.treeObj.trigger(consts.event.CHECK, [null, this.setting.treeId, node]); + this.setting.treeObj.trigger(consts.event.CHECK, [ + null, + this.setting.treeId, + node, + ]); } } - } + }; - zTreeTools.checkAllNodes = function (checked) { + zTreeTools.checkAllNodes = function(checked) { view.repairAllChk(this.setting, !!checked); - } + }; - zTreeTools.getCheckedNodes = function (checked) { - checked = (checked !== false); + zTreeTools.getCheckedNodes = function(checked) { + checked = checked !== false; var children = data.nodeChildren(setting, data.getRoot(this.setting)); return data.getTreeCheckedNodes(this.setting, children, checked); - } + }; - zTreeTools.getChangeCheckedNodes = function () { + zTreeTools.getChangeCheckedNodes = function() { var children = data.nodeChildren(setting, data.getRoot(this.setting)); return data.getTreeChangeCheckedNodes(this.setting, children); - } + }; - zTreeTools.setChkDisabled = function (node, disabled, inheritParent, inheritChildren) { + zTreeTools.setChkDisabled = function( + node, + disabled, + inheritParent, + inheritChildren + ) { disabled = !!disabled; inheritParent = !!inheritParent; inheritChildren = !!inheritChildren; - view.repairSonChkDisabled(this.setting, node, disabled, inheritChildren); - view.repairParentChkDisabled(this.setting, node.getParentNode(), disabled, inheritParent); - } + view.repairSonChkDisabled( + this.setting, + node, + disabled, + inheritChildren + ); + view.repairParentChkDisabled( + this.setting, + node.getParentNode(), + disabled, + inheritParent + ); + }; var _updateNode = zTreeTools.updateNode; - zTreeTools.updateNode = function (node, checkTypeFlag) { + zTreeTools.updateNode = function(node, checkTypeFlag) { if (_updateNode) _updateNode.apply(zTreeTools, arguments); if (!node || !this.setting.check.enable) return; var nObj = $$(node, this.setting); if (nObj.get(0) && tools.uCanDo(this.setting)) { var checkObj = $$(node, consts.id.CHECK, this.setting); - if (checkTypeFlag == true || this.setting.check.chkStyle === consts.radio.STYLE) view.checkNodeRelation(this.setting, node); + if ( + checkTypeFlag == true || + this.setting.check.chkStyle === consts.radio.STYLE + ) + view.checkNodeRelation(this.setting, node); view.setChkClass(this.setting, checkObj, node); view.repairParentChkClassWithSelf(this.setting, node); } - } + }; }, //method of operate data _data = { - getRadioCheckedList: function (setting) { + getRadioCheckedList: function(setting) { var checkedList = data.getRoot(setting).radioCheckedList; for (var i = 0, j = checkedList.length; i < j; i++) { if (!data.getNodeCache(setting, checkedList[i].tId)) { @@ -2283,24 +2991,38 @@ } return checkedList; }, - getCheckStatus: function (setting, node) { - if (!setting.check.enable || node.nocheck || node.chkDisabled) return null; + getCheckStatus: function(setting, node) { + if (!setting.check.enable || node.nocheck || node.chkDisabled) + return null; var checked = data.nodeChecked(setting, node), r = { checked: checked, - half: node.halfCheck ? node.halfCheck : (setting.check.chkStyle == consts.radio.STYLE ? (node.check_Child_State === 2) : (checked ? (node.check_Child_State > -1 && node.check_Child_State < 2) : (node.check_Child_State > 0))) + half: node.halfCheck + ? node.halfCheck + : setting.check.chkStyle == consts.radio.STYLE + ? node.check_Child_State === 2 + : checked + ? node.check_Child_State > -1 && node.check_Child_State < 2 + : node.check_Child_State > 0, }; return r; }, - getTreeCheckedNodes: function (setting, nodes, checked, results) { + getTreeCheckedNodes: function(setting, nodes, checked, results) { if (!nodes) return []; - var onlyOne = (checked && setting.check.chkStyle == consts.radio.STYLE && setting.check.radioType == consts.radio.TYPE_ALL); + var onlyOne = + checked && + setting.check.chkStyle == consts.radio.STYLE && + setting.check.radioType == consts.radio.TYPE_ALL; results = !results ? [] : results; for (var i = 0, l = nodes.length; i < l; i++) { var node = nodes[i]; var children = data.nodeChildren(setting, node); var nodeChecked = data.nodeChecked(setting, node); - if (node.nocheck !== true && node.chkDisabled !== true && nodeChecked == checked) { + if ( + node.nocheck !== true && + node.chkDisabled !== true && + nodeChecked == checked + ) { results.push(node); if (onlyOne) { break; @@ -2313,21 +3035,25 @@ } return results; }, - getTreeChangeCheckedNodes: function (setting, nodes, results) { + getTreeChangeCheckedNodes: function(setting, nodes, results) { if (!nodes) return []; results = !results ? [] : results; for (var i = 0, l = nodes.length; i < l; i++) { var node = nodes[i]; var children = data.nodeChildren(setting, node); var nodeChecked = data.nodeChecked(setting, node); - if (node.nocheck !== true && node.chkDisabled !== true && nodeChecked != node.checkedOld) { + if ( + node.nocheck !== true && + node.chkDisabled !== true && + nodeChecked != node.checkedOld + ) { results.push(node); } data.getTreeChangeCheckedNodes(setting, children, results); } return results; }, - makeChkFlag: function (setting, node) { + makeChkFlag: function(setting, node) { if (!node) return; var chkFlag = -1; var children = data.nodeChildren(setting, node); @@ -2358,14 +3084,23 @@ } else if (cNode.halfCheck === true) { tmp = 1; } else if (nodeChecked) { - tmp = (cNode.check_Child_State === -1 || cNode.check_Child_State === 2) ? 2 : 1; + tmp = + cNode.check_Child_State === -1 || + cNode.check_Child_State === 2 + ? 2 + : 1; } else { - tmp = (cNode.check_Child_State > 0) ? 1 : 0; + tmp = cNode.check_Child_State > 0 ? 1 : 0; } if (tmp === 1) { chkFlag = 1; break; - } else if (tmp === 2 && chkFlag > -1 && i > 0 && tmp !== chkFlag) { + } else if ( + tmp === 2 && + chkFlag > -1 && + i > 0 && + tmp !== chkFlag + ) { chkFlag = 1; break; } else if (chkFlag === 2 && tmp > -1 && tmp < 2) { @@ -2378,26 +3113,37 @@ } } node.check_Child_State = chkFlag; - } + }, }, //method of event proxy _event = {}, //method of event handler _handler = { - onCheckNode: function (event, node) { + onCheckNode: function(event, node) { if (node.chkDisabled === true) return false; var setting = data.getSetting(event.data.treeId); - if (tools.apply(setting.callback.beforeCheck, [setting.treeId, node], true) == false) return true; + if ( + tools.apply( + setting.callback.beforeCheck, + [setting.treeId, node], + true + ) == false + ) + return true; var nodeChecked = data.nodeChecked(setting, node); data.nodeChecked(setting, node, !nodeChecked); view.checkNodeRelation(setting, node); var checkObj = $$(node, consts.id.CHECK, setting); view.setChkClass(setting, checkObj, node); view.repairParentChkClassWithSelf(setting, node); - setting.treeObj.trigger(consts.event.CHECK, [event, setting.treeId, node]); + setting.treeObj.trigger(consts.event.CHECK, [ + event, + setting.treeId, + node, + ]); return true; }, - onMouseoverCheck: function (event, node) { + onMouseoverCheck: function(event, node) { if (node.chkDisabled === true) return false; var setting = data.getSetting(event.data.treeId), checkObj = $$(node, consts.id.CHECK, setting); @@ -2405,21 +3151,23 @@ view.setChkClass(setting, checkObj, node); return true; }, - onMouseoutCheck: function (event, node) { + onMouseoutCheck: function(event, node) { if (node.chkDisabled === true) return false; var setting = data.getSetting(event.data.treeId), checkObj = $$(node, consts.id.CHECK, setting); node.check_Focus = false; view.setChkClass(setting, checkObj, node); return true; - } + }, }, //method of tools for zTree _tools = {}, //method of operate ztree dom _view = { - checkNodeRelation: function (setting, node) { - var pNode, i, l, + checkNodeRelation: function(setting, node) { + var pNode, + i, + l, r = consts.radio; var nodeChecked = data.nodeChecked(setting, node); if (setting.check.chkStyle == r.STYLE) { @@ -2433,7 +3181,11 @@ data.nodeChecked(setting, pNode, false); checkedList.splice(i, 1); - view.setChkClass(setting, $$(pNode, consts.id.CHECK, setting), pNode); + view.setChkClass( + setting, + $$(pNode, consts.id.CHECK, setting), + pNode + ); if (pNode.parentTId != node.parentTId) { view.repairParentChkClassWithSelf(setting, pNode); } @@ -2441,14 +3193,20 @@ } checkedList.push(node); } else { - var parentNode = (node.parentTId) ? node.getParentNode() : data.getRoot(setting); + var parentNode = node.parentTId + ? node.getParentNode() + : data.getRoot(setting); var children = data.nodeChildren(setting, parentNode); for (i = 0, l = children.length; i < l; i++) { pNode = children[i]; var pNodeChecked = data.nodeChecked(setting, pNode); if (pNodeChecked && pNode != node) { data.nodeChecked(setting, pNode, false); - view.setChkClass(setting, $$(pNode, consts.id.CHECK, setting), pNode); + view.setChkClass( + setting, + $$(pNode, consts.id.CHECK, setting), + pNode + ); } } } @@ -2460,13 +3218,22 @@ } } } - } else { var children = data.nodeChildren(setting, node); - if (nodeChecked && (!children || children.length == 0 || setting.check.chkboxType.Y.indexOf("s") > -1)) { + if ( + nodeChecked && + (!children || + children.length == 0 || + setting.check.chkboxType.Y.indexOf("s") > -1) + ) { view.setSonNodeCheckBox(setting, node, true); } - if (!nodeChecked && (!children || children.length == 0 || setting.check.chkboxType.N.indexOf("s") > -1)) { + if ( + !nodeChecked && + (!children || + children.length == 0 || + setting.check.chkboxType.N.indexOf("s") > -1) + ) { view.setSonNodeCheckBox(setting, node, false); } if (nodeChecked && setting.check.chkboxType.Y.indexOf("p") > -1) { @@ -2477,8 +3244,9 @@ } } }, - makeChkClass: function (setting, node) { - var c = consts.checkbox, r = consts.radio, + makeChkClass: function(setting, node) { + var c = consts.checkbox, + r = consts.radio, fullStyle = ""; var nodeChecked = data.nodeChecked(setting, node); if (node.chkDisabled === true) { @@ -2486,16 +3254,33 @@ } else if (node.halfCheck) { fullStyle = c.PART; } else if (setting.check.chkStyle == r.STYLE) { - fullStyle = (node.check_Child_State < 1) ? c.FULL : c.PART; + fullStyle = node.check_Child_State < 1 ? c.FULL : c.PART; } else { - fullStyle = nodeChecked ? ((node.check_Child_State === 2 || node.check_Child_State === -1) ? c.FULL : c.PART) : ((node.check_Child_State < 1) ? c.FULL : c.PART); + fullStyle = nodeChecked + ? node.check_Child_State === 2 || node.check_Child_State === -1 + ? c.FULL + : c.PART + : node.check_Child_State < 1 + ? c.FULL + : c.PART; } - var chkName = setting.check.chkStyle + "_" + (nodeChecked ? c.TRUE : c.FALSE) + "_" + fullStyle; - chkName = (node.check_Focus && node.chkDisabled !== true) ? chkName + "_" + c.FOCUS : chkName; + var chkName = + setting.check.chkStyle + + "_" + + (nodeChecked ? c.TRUE : c.FALSE) + + "_" + + fullStyle; + chkName = + node.check_Focus && node.chkDisabled !== true + ? chkName + "_" + c.FOCUS + : chkName; return consts.className.BUTTON + " " + c.DEFAULT + " " + chkName; }, - repairAllChk: function (setting, checked) { - if (setting.check.enable && setting.check.chkStyle === consts.checkbox.STYLE) { + repairAllChk: function(setting, checked) { + if ( + setting.check.enable && + setting.check.chkStyle === consts.checkbox.STYLE + ) { var root = data.getRoot(setting); var children = data.nodeChildren(setting, root); for (var i = 0, l = children.length; i < l; i++) { @@ -2507,7 +3292,7 @@ } } }, - repairChkClass: function (setting, node) { + repairChkClass: function(setting, node) { if (!node) return; data.makeChkFlag(setting, node); if (node.nocheck !== true) { @@ -2515,13 +3300,13 @@ view.setChkClass(setting, checkObj, node); } }, - repairParentChkClass: function (setting, node) { + repairParentChkClass: function(setting, node) { if (!node || !node.parentTId) return; var pNode = node.getParentNode(); view.repairChkClass(setting, pNode); view.repairParentChkClass(setting, pNode); }, - repairParentChkClassWithSelf: function (setting, node) { + repairParentChkClassWithSelf: function(setting, node) { if (!node) return; var children = data.nodeChildren(setting, node); if (children && children.length > 0) { @@ -2530,7 +3315,7 @@ view.repairParentChkClass(setting, node); } }, - repairSonChkDisabled: function (setting, node, chkDisabled, inherit) { + repairSonChkDisabled: function(setting, node, chkDisabled, inherit) { if (!node) return; if (node.chkDisabled != chkDisabled) { node.chkDisabled = chkDisabled; @@ -2544,24 +3329,29 @@ } } }, - repairParentChkDisabled: function (setting, node, chkDisabled, inherit) { + repairParentChkDisabled: function(setting, node, chkDisabled, inherit) { if (!node) return; if (node.chkDisabled != chkDisabled && inherit) { node.chkDisabled = chkDisabled; } view.repairChkClass(setting, node); - view.repairParentChkDisabled(setting, node.getParentNode(), chkDisabled, inherit); + view.repairParentChkDisabled( + setting, + node.getParentNode(), + chkDisabled, + inherit + ); }, - setChkClass: function (setting, obj, node) { + setChkClass: function(setting, obj, node) { if (!obj) return; if (node.nocheck === true) { obj.hide(); } else { obj.show(); } - obj.attr('class', view.makeChkClass(setting, node)); + obj.attr("class", view.makeChkClass(setting, node)); }, - setParentNodeCheckBox: function (setting, node, value, srcNode) { + setParentNodeCheckBox: function(setting, node, value, srcNode) { var checkObj = $$(node, consts.id.CHECK, setting); if (!srcNode) srcNode = node; data.makeChkFlag(setting, node); @@ -2569,7 +3359,11 @@ data.nodeChecked(setting, node, value); view.setChkClass(setting, checkObj, node); if (setting.check.autoCheckTrigger && node != srcNode) { - setting.treeObj.trigger(consts.event.CHECK, [null, setting.treeId, node]); + setting.treeObj.trigger(consts.event.CHECK, [ + null, + setting.treeId, + node, + ]); } } if (node.parentTId) { @@ -2579,19 +3373,29 @@ for (var i = 0, l = pNodes.length; i < l; i++) { var pNode = pNodes[i]; var nodeChecked = data.nodeChecked(setting, pNode); - if ((pNode.nocheck !== true && pNode.chkDisabled !== true && nodeChecked) - || ((pNode.nocheck === true || pNode.chkDisabled === true) && pNode.check_Child_State > 0)) { + if ( + (pNode.nocheck !== true && + pNode.chkDisabled !== true && + nodeChecked) || + ((pNode.nocheck === true || pNode.chkDisabled === true) && + pNode.check_Child_State > 0) + ) { pSign = false; break; } } } if (pSign) { - view.setParentNodeCheckBox(setting, node.getParentNode(), value, srcNode); + view.setParentNodeCheckBox( + setting, + node.getParentNode(), + value, + srcNode + ); } } }, - setSonNodeCheckBox: function (setting, node, value, srcNode) { + setSonNodeCheckBox: function(setting, node, value, srcNode) { if (!node) return; var checkObj = $$(node, consts.id.CHECK, setting); if (!srcNode) srcNode = node; @@ -2612,24 +3416,33 @@ } if (node.nocheck !== true && node.chkDisabled !== true) { data.nodeChecked(setting, node, value); - if (!hasDisable) node.check_Child_State = (children && children.length > 0) ? (value ? 2 : 0) : -1; + if (!hasDisable) + node.check_Child_State = + children && children.length > 0 ? (value ? 2 : 0) : -1; } else { node.check_Child_State = -1; } view.setChkClass(setting, checkObj, node); - if (setting.check.autoCheckTrigger && node != srcNode && node.nocheck !== true && node.chkDisabled !== true) { - setting.treeObj.trigger(consts.event.CHECK, [null, setting.treeId, node]); + if ( + setting.check.autoCheckTrigger && + node != srcNode && + node.nocheck !== true && + node.chkDisabled !== true + ) { + setting.treeObj.trigger(consts.event.CHECK, [ + null, + setting.treeId, + node, + ]); } } - - } + }, }, - _z = { tools: _tools, view: _view, event: _event, - data: _data + data: _data, }; $.extend(true, $.fn.zTree.consts, _consts); $.extend(true, $.fn.zTree._z, _z); @@ -2642,12 +3455,12 @@ event = zt._z.event, $$ = tools.$; - data.nodeChecked = function (setting, node, newChecked) { + data.nodeChecked = function(setting, node, newChecked) { if (!node) { return false; } var key = setting.data.key.checked; - if (typeof newChecked !== 'undefined') { + if (typeof newChecked !== "undefined") { if (typeof newChecked === "string") { newChecked = tools.eqs(newChecked, "true"); } @@ -2672,22 +3485,30 @@ data.addZTreeTools(_zTreeTools); var _createNodes = view.createNodes; - view.createNodes = function (setting, level, nodes, parentNode, index) { + view.createNodes = function(setting, level, nodes, parentNode, index) { if (_createNodes) _createNodes.apply(view, arguments); if (!nodes) return; view.repairParentChkClassWithSelf(setting, parentNode); - } + }; var _removeNode = view.removeNode; - view.removeNode = function (setting, node) { + view.removeNode = function(setting, node) { var parentNode = node.getParentNode(); if (_removeNode) _removeNode.apply(view, arguments); if (!node || !parentNode) return; view.repairChkClass(setting, parentNode); view.repairParentChkClass(setting, parentNode); - } + }; var _appendNodes = view.appendNodes; - view.appendNodes = function (setting, level, nodes, parentNode, index, initFlag, openFlag) { + view.appendNodes = function( + setting, + level, + nodes, + parentNode, + index, + initFlag, + openFlag + ) { var html = ""; if (_appendNodes) { html = _appendNodes.apply(view, arguments); @@ -2696,7 +3517,7 @@ data.makeChkFlag(setting, parentNode); } return html; - } + }; })(jQuery); /* * JQuery zTree exedit @@ -2711,31 +3532,31 @@ * Date: 2020-11-21 */ -(function ($) { +(function($) { //default consts of exedit var _consts = { - event: { - DRAG: "ztree_drag", - DROP: "ztree_drop", - RENAME: "ztree_rename", - DRAGMOVE: "ztree_dragmove" + event: { + DRAG: "ztree_drag", + DROP: "ztree_drop", + RENAME: "ztree_rename", + DRAGMOVE: "ztree_dragmove", + }, + id: { + EDIT: "_edit", + INPUT: "_input", + REMOVE: "_remove", + }, + move: { + TYPE_INNER: "inner", + TYPE_PREV: "prev", + TYPE_NEXT: "next", + }, + node: { + CURSELECTED_EDIT: "curSelectedNode_Edit", + TMPTARGET_TREE: "tmpTargetzTree", + TMPTARGET_NODE: "tmpTargetNode", + }, }, - id: { - EDIT: "_edit", - INPUT: "_input", - REMOVE: "_remove" - }, - move: { - TYPE_INNER: "inner", - TYPE_PREV: "prev", - TYPE_NEXT: "next" - }, - node: { - CURSELECTED_EDIT: "curSelectedNode_Edit", - TMPTARGET_TREE: "tmpTargetzTree", - TMPTARGET_NODE: "tmpTargetNode" - } - }, //default setting of exedit _setting = { edit: { @@ -2756,12 +3577,12 @@ borderMax: 10, borderMin: -5, maxShowNodeNum: 5, - autoOpenTime: 500 - } + autoOpenTime: 500, + }, }, view: { addHoverDom: null, - removeHoverDom: null + removeHoverDom: null, }, callback: { beforeDrag: null, @@ -2772,12 +3593,13 @@ onDrag: null, onDragMove: null, onDrop: null, - onRename: null - } + onRename: null, + }, }, //default root of exedit - _initRoot = function (setting) { - var r = data.getRoot(setting), rs = data.getRoots(); + _initRoot = function(setting) { + var r = data.getRoot(setting), + rs = data.getRoots(); r.curEditNode = null; r.curEditInput = null; r.curHoverNode = null; @@ -2787,29 +3609,48 @@ rs.showHoverDom = true; }, //default cache of exedit - _initCache = function (treeId) { - }, + _initCache = function(treeId) {}, //default bind event of exedit - _bindEvent = function (setting) { + _bindEvent = function(setting) { var o = setting.treeObj; var c = consts.event; - o.bind(c.RENAME, function (event, treeId, treeNode, isCancel) { - tools.apply(setting.callback.onRename, [event, treeId, treeNode, isCancel]); + o.bind(c.RENAME, function(event, treeId, treeNode, isCancel) { + tools.apply(setting.callback.onRename, [ + event, + treeId, + treeNode, + isCancel, + ]); }); - o.bind(c.DRAG, function (event, srcEvent, treeId, treeNodes) { + o.bind(c.DRAG, function(event, srcEvent, treeId, treeNodes) { tools.apply(setting.callback.onDrag, [srcEvent, treeId, treeNodes]); }); - o.bind(c.DRAGMOVE, function (event, srcEvent, treeId, treeNodes) { + o.bind(c.DRAGMOVE, function(event, srcEvent, treeId, treeNodes) { tools.apply(setting.callback.onDragMove, [srcEvent, treeId, treeNodes]); }); - o.bind(c.DROP, function (event, srcEvent, treeId, treeNodes, targetNode, moveType, isCopy) { - tools.apply(setting.callback.onDrop, [srcEvent, treeId, treeNodes, targetNode, moveType, isCopy]); + o.bind(c.DROP, function( + event, + srcEvent, + treeId, + treeNodes, + targetNode, + moveType, + isCopy + ) { + tools.apply(setting.callback.onDrop, [ + srcEvent, + treeId, + treeNodes, + targetNode, + moveType, + isCopy, + ]); }); }, - _unbindEvent = function (setting) { + _unbindEvent = function(setting) { var o = setting.treeObj; var c = consts.event; o.unbind(c.RENAME); @@ -2818,29 +3659,38 @@ o.unbind(c.DROP); }, //default event proxy of exedit - _eventProxy = function (e) { + _eventProxy = function(e) { var target = e.target, setting = data.getSetting(e.data.treeId), relatedTarget = e.relatedTarget, - tId = "", node = null, - nodeEventType = "", treeEventType = "", - nodeEventCallback = null, treeEventCallback = null, + tId = "", + node = null, + nodeEventType = "", + treeEventType = "", + nodeEventCallback = null, + treeEventCallback = null, tmp = null; if (tools.eqs(e.type, "mouseover")) { - tmp = tools.getMDom(setting, target, [{ tagName: "a", attrName: "treeNode" + consts.id.A }]); + tmp = tools.getMDom(setting, target, [ + { tagName: "a", attrName: "treeNode" + consts.id.A }, + ]); if (tmp) { tId = tools.getNodeMainDom(tmp).id; nodeEventType = "hoverOverNode"; } } else if (tools.eqs(e.type, "mouseout")) { - tmp = tools.getMDom(setting, relatedTarget, [{ tagName: "a", attrName: "treeNode" + consts.id.A }]); + tmp = tools.getMDom(setting, relatedTarget, [ + { tagName: "a", attrName: "treeNode" + consts.id.A }, + ]); if (!tmp) { tId = "remove"; nodeEventType = "hoverOutNode"; } } else if (tools.eqs(e.type, "mousedown")) { - tmp = tools.getMDom(setting, target, [{ tagName: "a", attrName: "treeNode" + consts.id.A }]); + tmp = tools.getMDom(setting, target, [ + { tagName: "a", attrName: "treeNode" + consts.id.A }, + ]); if (tmp) { tId = tools.getNodeMainDom(tmp).id; nodeEventType = "mousedownNode"; @@ -2866,27 +3716,41 @@ nodeEventType: nodeEventType, nodeEventCallback: nodeEventCallback, treeEventType: treeEventType, - treeEventCallback: treeEventCallback + treeEventCallback: treeEventCallback, }; - return proxyResult + return proxyResult; }, //default init node of exedit - _initNode = function (setting, level, n, parentNode, isFirstNode, isLastNode, openFlag) { + _initNode = function( + setting, + level, + n, + parentNode, + isFirstNode, + isLastNode, + openFlag + ) { if (!n) return; n.isHover = false; n.editNameFlag = false; }, //update zTreeObj, add method of edit - _zTreeTools = function (setting, zTreeTools) { - zTreeTools.cancelEditName = function (newName) { + _zTreeTools = function(setting, zTreeTools) { + zTreeTools.cancelEditName = function(newName) { var root = data.getRoot(this.setting); if (!root.curEditNode) return; view.cancelCurEditNode(this.setting, newName ? newName : null, true); - } - zTreeTools.copyNode = function (targetNode, node, moveType, isSilent) { + }; + zTreeTools.copyNode = function(targetNode, node, moveType, isSilent) { if (!node) return null; var isParent = data.nodeIsParent(setting, targetNode); - if (targetNode && !isParent && this.setting.data.keep.leaf && moveType === consts.move.TYPE_INNER) return null; + if ( + targetNode && + !isParent && + this.setting.data.keep.leaf && + moveType === consts.move.TYPE_INNER + ) + return null; var _this = this, newNode = tools.clone(node); if (!targetNode) { @@ -2904,22 +3768,55 @@ copyCallback(); } } else { - view.addNodes(this.setting, targetNode.parentNode, -1, [newNode], isSilent); - view.moveNode(this.setting, targetNode, newNode, moveType, false, isSilent); + view.addNodes( + this.setting, + targetNode.parentNode, + -1, + [newNode], + isSilent + ); + view.moveNode( + this.setting, + targetNode, + newNode, + moveType, + false, + isSilent + ); } return newNode; - } - zTreeTools.editName = function (node) { - if (!node || !node.tId || node !== data.getNodeCache(this.setting, node.tId)) return; - if (node.parentTId) view.expandCollapseParentNode(this.setting, node.getParentNode(), true); - view.editNode(this.setting, node) - } - zTreeTools.moveNode = function (targetNode, node, moveType, isSilent) { + }; + zTreeTools.editName = function(node) { + if ( + !node || + !node.tId || + node !== data.getNodeCache(this.setting, node.tId) + ) + return; + if (node.parentTId) + view.expandCollapseParentNode( + this.setting, + node.getParentNode(), + true + ); + view.editNode(this.setting, node); + }; + zTreeTools.moveNode = function(targetNode, node, moveType, isSilent) { if (!node) return node; var isParent = data.nodeIsParent(setting, targetNode); - if (targetNode && !isParent && this.setting.data.keep.leaf && moveType === consts.move.TYPE_INNER) { + if ( + targetNode && + !isParent && + this.setting.data.keep.leaf && + moveType === consts.move.TYPE_INNER + ) { return null; - } else if (targetNode && ((node.parentTId == targetNode.tId && moveType == consts.move.TYPE_INNER) || $$(node, this.setting).find("#" + targetNode.tId).length > 0)) { + } else if ( + targetNode && + ((node.parentTId == targetNode.tId && + moveType == consts.move.TYPE_INNER) || + $$(node, this.setting).find("#" + targetNode.tId).length > 0) + ) { return null; } else if (!targetNode) { targetNode = null; @@ -2927,38 +3824,48 @@ var _this = this; function moveCallback() { - view.moveNode(_this.setting, targetNode, node, moveType, false, isSilent); + view.moveNode( + _this.setting, + targetNode, + node, + moveType, + false, + isSilent + ); } - if (tools.canAsync(this.setting, targetNode) && moveType === consts.move.TYPE_INNER) { + if ( + tools.canAsync(this.setting, targetNode) && + moveType === consts.move.TYPE_INNER + ) { view.asyncNode(this.setting, targetNode, isSilent, moveCallback); } else { moveCallback(); } return node; - } - zTreeTools.setEditable = function (editable) { + }; + zTreeTools.setEditable = function(editable) { this.setting.edit.enable = editable; return this.refresh(); - } + }; }, //method of operate data _data = { - setSonNodeLevel: function (setting, parentNode, node) { + setSonNodeLevel: function(setting, parentNode, node) { if (!node) return; var children = data.nodeChildren(setting, node); - node.level = (parentNode) ? parentNode.level + 1 : 0; + node.level = parentNode ? parentNode.level + 1 : 0; if (!children) return; for (var i = 0, l = children.length; i < l; i++) { if (children[i]) data.setSonNodeLevel(setting, node, children[i]); } - } + }, }, //method of event proxy _event = {}, //method of event handler _handler = { - onHoverOverNode: function (event, node) { + onHoverOverNode: function(event, node) { var setting = data.getSetting(event.data.treeId), root = data.getRoot(setting); if (root.curHoverNode != node) { @@ -2967,20 +3874,30 @@ root.curHoverNode = node; view.addHoverDom(setting, node); }, - onHoverOutNode: function (event, node) { + onHoverOutNode: function(event, node) { var setting = data.getSetting(event.data.treeId), root = data.getRoot(setting); - if (root.curHoverNode && !data.isSelectedNode(setting, root.curHoverNode)) { + if ( + root.curHoverNode && + !data.isSelectedNode(setting, root.curHoverNode) + ) { view.removeTreeDom(setting, root.curHoverNode); root.curHoverNode = null; } }, - onMousedownNode: function (eventMouseDown, _node) { - var i, l, + onMousedownNode: function(eventMouseDown, _node) { + var i, + l, setting = data.getSetting(eventMouseDown.data.treeId), - root = data.getRoot(setting), roots = data.getRoots(); + root = data.getRoot(setting), + roots = data.getRoots(); //right click can't drag & drop - if (eventMouseDown.button == 2 || !setting.edit.enable || (!setting.edit.drag.isCopy && !setting.edit.drag.isMove)) return true; + if ( + eventMouseDown.button == 2 || + !setting.edit.enable || + (!setting.edit.drag.isCopy && !setting.edit.drag.isMove) + ) + return true; //input of edit node name can't drag & drop var target = eventMouseDown.target, @@ -2990,7 +3907,11 @@ nodes = [_node]; } else { for (i = 0, l = _nodes.length; i < l; i++) { - if (_nodes[i].editNameFlag && tools.eqs(target.tagName, "input") && target.getAttribute("treeNode" + consts.id.INPUT) !== null) { + if ( + _nodes[i].editNameFlag && + tools.eqs(target.tagName, "input") && + target.getAttribute("treeNode" + consts.id.INPUT) !== null + ) { return true; } nodes.push(_nodes[i]); @@ -3005,18 +3926,22 @@ view.cancelCurEditNode(setting); var doc = $(setting.treeObj.get(0).ownerDocument), - body = $(setting.treeObj.get(0).ownerDocument.body), curNode, tmpArrow, tmpTarget, + body = $(setting.treeObj.get(0).ownerDocument.body), + curNode, + tmpArrow, + tmpTarget, isOtherTree = false, targetSetting = setting, sourceSetting = setting, - preNode, nextNode, + preNode, + nextNode, preTmpTargetNodeId = null, preTmpMoveType = null, tmpTargetNodeId = null, moveType = consts.move.TYPE_INNER, mouseDownX = eventMouseDown.clientX, mouseDownY = eventMouseDown.clientY, - startTime = (new Date()).getTime(); + startTime = new Date().getTime(); if (tools.uCanDo(setting)) { doc.bind("mousemove", _docMouseMove); @@ -3024,15 +3949,25 @@ function _docMouseMove(event) { //avoid start drag after click node - if (root.dragFlag == 0 && Math.abs(mouseDownX - event.clientX) < setting.edit.drag.minMoveSize - && Math.abs(mouseDownY - event.clientY) < setting.edit.drag.minMoveSize) { + if ( + root.dragFlag == 0 && + Math.abs(mouseDownX - event.clientX) < + setting.edit.drag.minMoveSize && + Math.abs(mouseDownY - event.clientY) < setting.edit.drag.minMoveSize + ) { return true; } var i, l, tmpNode, tmpDom, tmpNodes; body.css("cursor", "pointer"); if (root.dragFlag == 0) { - if (tools.apply(setting.callback.beforeDrag, [setting.treeId, nodes], true) == false) { + if ( + tools.apply( + setting.callback.beforeDrag, + [setting.treeId, nodes], + true + ) == false + ) { _docMouseUp(event); return true; } @@ -3055,13 +3990,16 @@ tools.showIfameMask(setting, true); //sort - var isOrder = true, lastIndex = -1; + var isOrder = true, + lastIndex = -1; if (nodes.length > 1) { - var pNodes = nodes[0].parentTId ? data.nodeChildren(setting, nodes[0].getParentNode()) : data.getNodes(setting); + var pNodes = nodes[0].parentTId + ? data.nodeChildren(setting, nodes[0].getParentNode()) + : data.getNodes(setting); tmpNodes = []; for (i = 0, l = pNodes.length; i < l; i++) { if (root.dragNodeShowBefore[pNodes[i].tId] !== undefined) { - if (isOrder && lastIndex > -1 && (lastIndex + 1) !== i) { + if (isOrder && lastIndex > -1 && lastIndex + 1 !== i) { isOrder = false; } tmpNodes.push(pNodes[i]); @@ -3093,10 +4031,15 @@ tmpDom = $$("<li id='" + tmpNode.tId + "_tmp'></li>", setting); tmpDom.append($$(tmpNode, consts.id.A, setting).clone()); tmpDom.css("padding", "0"); - tmpDom.children("#" + tmpNode.tId + consts.id.A).removeClass(consts.node.CURSELECTED); + tmpDom + .children("#" + tmpNode.tId + consts.id.A) + .removeClass(consts.node.CURSELECTED); curNode.append(tmpDom); if (i == setting.edit.drag.maxShowNodeNum - 1) { - tmpDom = $$("<li id='" + tmpNode.tId + "_moretmp'><a> ... </a></li>", setting); + tmpDom = $$( + "<li id='" + tmpNode.tId + "_moretmp'><a> ... </a></li>", + setting + ); curNode.append(tmpDom); } } @@ -3108,17 +4051,36 @@ tmpArrow.attr("id", "zTreeMove_arrow_tmp"); tmpArrow.appendTo(body); - setting.treeObj.trigger(consts.event.DRAG, [event, setting.treeId, nodes]); + setting.treeObj.trigger(consts.event.DRAG, [ + event, + setting.treeId, + nodes, + ]); } if (root.dragFlag == 1) { - if (tmpTarget && tmpArrow.attr("id") == event.target.id && tmpTargetNodeId && (event.clientX + doc.scrollLeft() + 2) > ($("#" + tmpTargetNodeId + consts.id.A, tmpTarget).offset().left)) { + if ( + tmpTarget && + tmpArrow.attr("id") == event.target.id && + tmpTargetNodeId && + event.clientX + doc.scrollLeft() + 2 > + $("#" + tmpTargetNodeId + consts.id.A, tmpTarget).offset().left + ) { var xT = $("#" + tmpTargetNodeId + consts.id.A, tmpTarget); - event.target = (xT.length > 0) ? xT.get(0) : event.target; + event.target = xT.length > 0 ? xT.get(0) : event.target; } else if (tmpTarget) { tmpTarget.removeClass(consts.node.TMPTARGET_TREE); - if (tmpTargetNodeId) $("#" + tmpTargetNodeId + consts.id.A, tmpTarget).removeClass(consts.node.TMPTARGET_NODE + "_" + consts.move.TYPE_PREV) - .removeClass(consts.node.TMPTARGET_NODE + "_" + _consts.move.TYPE_NEXT).removeClass(consts.node.TMPTARGET_NODE + "_" + _consts.move.TYPE_INNER); + if (tmpTargetNodeId) + $("#" + tmpTargetNodeId + consts.id.A, tmpTarget) + .removeClass( + consts.node.TMPTARGET_NODE + "_" + consts.move.TYPE_PREV + ) + .removeClass( + consts.node.TMPTARGET_NODE + "_" + _consts.move.TYPE_NEXT + ) + .removeClass( + consts.node.TMPTARGET_NODE + "_" + _consts.move.TYPE_INNER + ); } tmpTarget = null; tmpTargetNodeId = null; @@ -3128,8 +4090,13 @@ targetSetting = setting; var settings = data.getSettings(); for (var s in settings) { - if (settings[s].treeId && settings[s].edit.enable && settings[s].treeId != setting.treeId - && (event.target.id == settings[s].treeId || $(event.target).parents("#" + settings[s].treeId).length > 0)) { + if ( + settings[s].treeId && + settings[s].edit.enable && + settings[s].treeId != setting.treeId && + (event.target.id == settings[s].treeId || + $(event.target).parents("#" + settings[s].treeId).length > 0) + ) { isOtherTree = true; targetSetting = settings[s]; } @@ -3140,24 +4107,62 @@ treeOffset = targetSetting.treeObj.offset(), scrollHeight = targetSetting.treeObj.get(0).scrollHeight, scrollWidth = targetSetting.treeObj.get(0).scrollWidth, - dTop = (event.clientY + docScrollTop - treeOffset.top), - dBottom = (targetSetting.treeObj.height() + treeOffset.top - event.clientY - docScrollTop), - dLeft = (event.clientX + docScrollLeft - treeOffset.left), - dRight = (targetSetting.treeObj.width() + treeOffset.left - event.clientX - docScrollLeft), - isTop = (dTop < setting.edit.drag.borderMax && dTop > setting.edit.drag.borderMin), - isBottom = (dBottom < setting.edit.drag.borderMax && dBottom > setting.edit.drag.borderMin), - isLeft = (dLeft < setting.edit.drag.borderMax && dLeft > setting.edit.drag.borderMin), - isRight = (dRight < setting.edit.drag.borderMax && dRight > setting.edit.drag.borderMin), - isTreeInner = dTop > setting.edit.drag.borderMin && dBottom > setting.edit.drag.borderMin && dLeft > setting.edit.drag.borderMin && dRight > setting.edit.drag.borderMin, - isTreeTop = (isTop && targetSetting.treeObj.scrollTop() <= 0), - isTreeBottom = (isBottom && (targetSetting.treeObj.scrollTop() + targetSetting.treeObj.height() + 10) >= scrollHeight), - isTreeLeft = (isLeft && targetSetting.treeObj.scrollLeft() <= 0), - isTreeRight = (isRight && (targetSetting.treeObj.scrollLeft() + targetSetting.treeObj.width() + 10) >= scrollWidth); + dTop = event.clientY + docScrollTop - treeOffset.top, + dBottom = + targetSetting.treeObj.height() + + treeOffset.top - + event.clientY - + docScrollTop, + dLeft = event.clientX + docScrollLeft - treeOffset.left, + dRight = + targetSetting.treeObj.width() + + treeOffset.left - + event.clientX - + docScrollLeft, + isTop = + dTop < setting.edit.drag.borderMax && + dTop > setting.edit.drag.borderMin, + isBottom = + dBottom < setting.edit.drag.borderMax && + dBottom > setting.edit.drag.borderMin, + isLeft = + dLeft < setting.edit.drag.borderMax && + dLeft > setting.edit.drag.borderMin, + isRight = + dRight < setting.edit.drag.borderMax && + dRight > setting.edit.drag.borderMin, + isTreeInner = + dTop > setting.edit.drag.borderMin && + dBottom > setting.edit.drag.borderMin && + dLeft > setting.edit.drag.borderMin && + dRight > setting.edit.drag.borderMin, + isTreeTop = isTop && targetSetting.treeObj.scrollTop() <= 0, + isTreeBottom = + isBottom && + targetSetting.treeObj.scrollTop() + + targetSetting.treeObj.height() + + 10 >= + scrollHeight, + isTreeLeft = isLeft && targetSetting.treeObj.scrollLeft() <= 0, + isTreeRight = + isRight && + targetSetting.treeObj.scrollLeft() + + targetSetting.treeObj.width() + + 10 >= + scrollWidth; - if (event.target && tools.isChildOrSelf(event.target, targetSetting.treeId)) { + if ( + event.target && + tools.isChildOrSelf(event.target, targetSetting.treeId) + ) { //get node <li> dom var targetObj = event.target; - while (targetObj && targetObj.tagName && !tools.eqs(targetObj.tagName, "li") && targetObj.id != targetSetting.treeId) { + while ( + targetObj && + targetObj.tagName && + !tools.eqs(targetObj.tagName, "li") && + targetObj.id != targetSetting.treeId + ) { targetObj = targetObj.parentNode; } @@ -3168,12 +4173,18 @@ if (targetObj.id === tmpNode.tId) { canMove = false; break; - } else if ($$(tmpNode, setting).find("#" + targetObj.id).length > 0) { + } else if ( + $$(tmpNode, setting).find("#" + targetObj.id).length > 0 + ) { canMove = false; break; } } - if (canMove && event.target && tools.isChildOrSelf(event.target, targetObj.id + consts.id.A)) { + if ( + canMove && + event.target && + tools.isChildOrSelf(event.target, targetObj.id + consts.id.A) + ) { tmpTarget = $(targetObj); tmpTargetNodeId = targetObj.id; } @@ -3181,76 +4192,168 @@ //the mouse must be in zTree tmpNode = nodes[0]; - if (isTreeInner && tools.isChildOrSelf(event.target, targetSetting.treeId)) { + if ( + isTreeInner && + tools.isChildOrSelf(event.target, targetSetting.treeId) + ) { //judge mouse move in root of ztree - if (!tmpTarget && (event.target.id == targetSetting.treeId || isTreeTop || isTreeBottom || isTreeLeft || isTreeRight) && (isOtherTree || (!isOtherTree && tmpNode.parentTId))) { + if ( + !tmpTarget && + (event.target.id == targetSetting.treeId || + isTreeTop || + isTreeBottom || + isTreeLeft || + isTreeRight) && + (isOtherTree || (!isOtherTree && tmpNode.parentTId)) + ) { tmpTarget = targetSetting.treeObj; } //auto scroll top if (isTop) { - targetSetting.treeObj.scrollTop(targetSetting.treeObj.scrollTop() - 10); + targetSetting.treeObj.scrollTop( + targetSetting.treeObj.scrollTop() - 10 + ); } else if (isBottom) { - targetSetting.treeObj.scrollTop(targetSetting.treeObj.scrollTop() + 10); + targetSetting.treeObj.scrollTop( + targetSetting.treeObj.scrollTop() + 10 + ); } if (isLeft) { - targetSetting.treeObj.scrollLeft(targetSetting.treeObj.scrollLeft() - 10); + targetSetting.treeObj.scrollLeft( + targetSetting.treeObj.scrollLeft() - 10 + ); } else if (isRight) { - targetSetting.treeObj.scrollLeft(targetSetting.treeObj.scrollLeft() + 10); + targetSetting.treeObj.scrollLeft( + targetSetting.treeObj.scrollLeft() + 10 + ); } //auto scroll left - if (tmpTarget && tmpTarget != targetSetting.treeObj && tmpTarget.offset().left < targetSetting.treeObj.offset().left) { - targetSetting.treeObj.scrollLeft(targetSetting.treeObj.scrollLeft() + tmpTarget.offset().left - targetSetting.treeObj.offset().left); + if ( + tmpTarget && + tmpTarget != targetSetting.treeObj && + tmpTarget.offset().left < targetSetting.treeObj.offset().left + ) { + targetSetting.treeObj.scrollLeft( + targetSetting.treeObj.scrollLeft() + + tmpTarget.offset().left - + targetSetting.treeObj.offset().left + ); } } curNode.css({ - "top": (event.clientY + docScrollTop + 3) + "px", - "left": (event.clientX + docScrollLeft + 3) + "px" + top: event.clientY + docScrollTop + 3 + "px", + left: event.clientX + docScrollLeft + 3 + "px", }); var dX = 0; var dY = 0; if (tmpTarget && tmpTarget.attr("id") != targetSetting.treeId) { - var tmpTargetNode = tmpTargetNodeId == null ? null : data.getNodeCache(targetSetting, tmpTargetNodeId), - isCopy = ((event.ctrlKey || event.metaKey) && setting.edit.drag.isMove && setting.edit.drag.isCopy) || (!setting.edit.drag.isMove && setting.edit.drag.isCopy), + var tmpTargetNode = + tmpTargetNodeId == null + ? null + : data.getNodeCache(targetSetting, tmpTargetNodeId), + isCopy = + ((event.ctrlKey || event.metaKey) && + setting.edit.drag.isMove && + setting.edit.drag.isCopy) || + (!setting.edit.drag.isMove && setting.edit.drag.isCopy), isPrev = !!(preNode && tmpTargetNodeId === preNode.tId), isNext = !!(nextNode && tmpTargetNodeId === nextNode.tId), - isInner = (tmpNode.parentTId && tmpNode.parentTId == tmpTargetNodeId), - canPrev = (isCopy || !isNext) && tools.apply(targetSetting.edit.drag.prev, [targetSetting.treeId, nodes, tmpTargetNode], !!targetSetting.edit.drag.prev), - canNext = (isCopy || !isPrev) && tools.apply(targetSetting.edit.drag.next, [targetSetting.treeId, nodes, tmpTargetNode], !!targetSetting.edit.drag.next), - canInner = (isCopy || !isInner) && !(targetSetting.data.keep.leaf && !data.nodeIsParent(setting, tmpTargetNode)) && tools.apply(targetSetting.edit.drag.inner, [targetSetting.treeId, nodes, tmpTargetNode], !!targetSetting.edit.drag.inner); + isInner = + tmpNode.parentTId && tmpNode.parentTId == tmpTargetNodeId, + canPrev = + (isCopy || !isNext) && + tools.apply( + targetSetting.edit.drag.prev, + [targetSetting.treeId, nodes, tmpTargetNode], + !!targetSetting.edit.drag.prev + ), + canNext = + (isCopy || !isPrev) && + tools.apply( + targetSetting.edit.drag.next, + [targetSetting.treeId, nodes, tmpTargetNode], + !!targetSetting.edit.drag.next + ), + canInner = + (isCopy || !isInner) && + !( + targetSetting.data.keep.leaf && + !data.nodeIsParent(setting, tmpTargetNode) + ) && + tools.apply( + targetSetting.edit.drag.inner, + [targetSetting.treeId, nodes, tmpTargetNode], + !!targetSetting.edit.drag.inner + ); function clearMove() { tmpTarget = null; tmpTargetNodeId = ""; moveType = consts.move.TYPE_INNER; tmpArrow.css({ - "display": "none" + display: "none", }); if (window.zTreeMoveTimer) { clearTimeout(window.zTreeMoveTimer); - window.zTreeMoveTargetNodeTId = null + window.zTreeMoveTargetNodeTId = null; } } if (!canPrev && !canNext && !canInner) { clearMove(); } else { - var tmpTargetA = $("#" + tmpTargetNodeId + consts.id.A, tmpTarget), - tmpNextA = tmpTargetNode.isLastNode ? null : $("#" + tmpTargetNode.getNextNode().tId + consts.id.A, tmpTarget.next()), + var tmpTargetA = $( + "#" + tmpTargetNodeId + consts.id.A, + tmpTarget + ), + tmpNextA = tmpTargetNode.isLastNode + ? null + : $( + "#" + tmpTargetNode.getNextNode().tId + consts.id.A, + tmpTarget.next() + ), tmpTop = tmpTargetA.offset().top, tmpLeft = tmpTargetA.offset().left, - prevPercent = canPrev ? (canInner ? 0.25 : (canNext ? 0.5 : 1)) : -1, - nextPercent = canNext ? (canInner ? 0.75 : (canPrev ? 0.5 : 0)) : -1, - dY_percent = (event.clientY + docScrollTop - tmpTop) / tmpTargetA.height(); + prevPercent = canPrev + ? canInner + ? 0.25 + : canNext + ? 0.5 + : 1 + : -1, + nextPercent = canNext + ? canInner + ? 0.75 + : canPrev + ? 0.5 + : 0 + : -1, + dY_percent = + (event.clientY + docScrollTop - tmpTop) / + tmpTargetA.height(); - if ((prevPercent == 1 || dY_percent <= prevPercent && dY_percent >= -.2) && canPrev) { + if ( + (prevPercent == 1 || + (dY_percent <= prevPercent && dY_percent >= -0.2)) && + canPrev + ) { dX = 1 - tmpArrow.width(); dY = tmpTop - tmpArrow.height() / 2; moveType = consts.move.TYPE_PREV; - } else if ((nextPercent == 0 || dY_percent >= nextPercent && dY_percent <= 1.2) && canNext) { + } else if ( + (nextPercent == 0 || + (dY_percent >= nextPercent && dY_percent <= 1.2)) && + canNext + ) { dX = 1 - tmpArrow.width(); - dY = (tmpNextA == null || (data.nodeIsParent(setting, tmpTargetNode) && tmpTargetNode.open)) ? (tmpTop + tmpTargetA.height() - tmpArrow.height() / 2) : (tmpNextA.offset().top - tmpArrow.height() / 2); + dY = + tmpNextA == null || + (data.nodeIsParent(setting, tmpTargetNode) && + tmpTargetNode.open) + ? tmpTop + tmpTargetA.height() - tmpArrow.height() / 2 + : tmpNextA.offset().top - tmpArrow.height() / 2; moveType = consts.move.TYPE_NEXT; } else if (canInner) { dX = 5 - tmpArrow.width(); @@ -3262,31 +4365,59 @@ if (tmpTarget) { tmpArrow.css({ - "display": "block", - "top": dY + "px", - "left": (tmpLeft + dX) + "px" + display: "block", + top: dY + "px", + left: tmpLeft + dX + "px", }); - tmpTargetA.addClass(consts.node.TMPTARGET_NODE + "_" + moveType); + tmpTargetA.addClass( + consts.node.TMPTARGET_NODE + "_" + moveType + ); - if (preTmpTargetNodeId != tmpTargetNodeId || preTmpMoveType != moveType) { - startTime = (new Date()).getTime(); + if ( + preTmpTargetNodeId != tmpTargetNodeId || + preTmpMoveType != moveType + ) { + startTime = new Date().getTime(); } - if (tmpTargetNode && data.nodeIsParent(setting, tmpTargetNode) && moveType == consts.move.TYPE_INNER) { + if ( + tmpTargetNode && + data.nodeIsParent(setting, tmpTargetNode) && + moveType == consts.move.TYPE_INNER + ) { var startTimer = true; - if (window.zTreeMoveTimer && window.zTreeMoveTargetNodeTId !== tmpTargetNode.tId) { + if ( + window.zTreeMoveTimer && + window.zTreeMoveTargetNodeTId !== tmpTargetNode.tId + ) { clearTimeout(window.zTreeMoveTimer); window.zTreeMoveTargetNodeTId = null; - } else if (window.zTreeMoveTimer && window.zTreeMoveTargetNodeTId === tmpTargetNode.tId) { + } else if ( + window.zTreeMoveTimer && + window.zTreeMoveTargetNodeTId === tmpTargetNode.tId + ) { startTimer = false; } if (startTimer) { - window.zTreeMoveTimer = setTimeout(function () { + window.zTreeMoveTimer = setTimeout(function() { if (moveType != consts.move.TYPE_INNER) return; - if (tmpTargetNode && data.nodeIsParent(setting, tmpTargetNode) && !tmpTargetNode.open && (new Date()).getTime() - startTime > targetSetting.edit.drag.autoOpenTime - && tools.apply(targetSetting.callback.beforeDragOpen, [targetSetting.treeId, tmpTargetNode], true)) { + if ( + tmpTargetNode && + data.nodeIsParent(setting, tmpTargetNode) && + !tmpTargetNode.open && + new Date().getTime() - startTime > + targetSetting.edit.drag.autoOpenTime && + tools.apply( + targetSetting.callback.beforeDragOpen, + [targetSetting.treeId, tmpTargetNode], + true + ) + ) { view.switchNode(targetSetting, tmpTargetNode); if (targetSetting.edit.drag.autoExpandTrigger) { - targetSetting.treeObj.trigger(consts.event.EXPAND, [targetSetting.treeId, tmpTargetNode]); + targetSetting.treeObj.trigger(consts.event.EXPAND, [ + targetSetting.treeId, + tmpTargetNode, + ]); } } }, targetSetting.edit.drag.autoOpenTime + 50); @@ -3297,13 +4428,20 @@ } } else { moveType = consts.move.TYPE_INNER; - if (tmpTarget && tools.apply(targetSetting.edit.drag.inner, [targetSetting.treeId, nodes, null], !!targetSetting.edit.drag.inner)) { + if ( + tmpTarget && + tools.apply( + targetSetting.edit.drag.inner, + [targetSetting.treeId, nodes, null], + !!targetSetting.edit.drag.inner + ) + ) { tmpTarget.addClass(consts.node.TMPTARGET_TREE); } else { tmpTarget = null; } tmpArrow.css({ - "display": "none" + display: "none", }); if (window.zTreeMoveTimer) { clearTimeout(window.zTreeMoveTimer); @@ -3313,7 +4451,11 @@ preTmpTargetNodeId = tmpTargetNodeId; preTmpMoveType = moveType; - setting.treeObj.trigger(consts.event.DRAGMOVE, [event, setting.treeId, nodes]); + setting.treeObj.trigger(consts.event.DRAGMOVE, [ + event, + setting.treeId, + nodes, + ]); } return false; } @@ -3333,8 +4475,17 @@ body.css("cursor", ""); if (tmpTarget) { tmpTarget.removeClass(consts.node.TMPTARGET_TREE); - if (tmpTargetNodeId) $("#" + tmpTargetNodeId + consts.id.A, tmpTarget).removeClass(consts.node.TMPTARGET_NODE + "_" + consts.move.TYPE_PREV) - .removeClass(consts.node.TMPTARGET_NODE + "_" + _consts.move.TYPE_NEXT).removeClass(consts.node.TMPTARGET_NODE + "_" + _consts.move.TYPE_INNER); + if (tmpTargetNodeId) + $("#" + tmpTargetNodeId + consts.id.A, tmpTarget) + .removeClass( + consts.node.TMPTARGET_NODE + "_" + consts.move.TYPE_PREV + ) + .removeClass( + consts.node.TMPTARGET_NODE + "_" + _consts.move.TYPE_NEXT + ) + .removeClass( + consts.node.TMPTARGET_NODE + "_" + _consts.move.TYPE_INNER + ); } tools.showIfameMask(setting, false); @@ -3345,7 +4496,11 @@ var i, l, tmpNode; for (i = 0, l = nodes.length; i < l; i++) { tmpNode = nodes[i]; - if (data.nodeIsParent(setting, tmpNode) && root.dragNodeShowBefore[tmpNode.tId] && !tmpNode.open) { + if ( + data.nodeIsParent(setting, tmpNode) && + root.dragNodeShowBefore[tmpNode.tId] && + !tmpNode.open + ) { view.expandCollapseNode(setting, tmpNode, !tmpNode.open); delete root.dragNodeShowBefore[tmpNode.tId]; } @@ -3354,13 +4509,33 @@ if (curNode) curNode.remove(); if (tmpArrow) tmpArrow.remove(); - var isCopy = ((event.ctrlKey || event.metaKey) && setting.edit.drag.isMove && setting.edit.drag.isCopy) || (!setting.edit.drag.isMove && setting.edit.drag.isCopy); - if (!isCopy && tmpTarget && tmpTargetNodeId && nodes[0].parentTId && tmpTargetNodeId == nodes[0].parentTId && moveType == consts.move.TYPE_INNER) { + var isCopy = + ((event.ctrlKey || event.metaKey) && + setting.edit.drag.isMove && + setting.edit.drag.isCopy) || + (!setting.edit.drag.isMove && setting.edit.drag.isCopy); + if ( + !isCopy && + tmpTarget && + tmpTargetNodeId && + nodes[0].parentTId && + tmpTargetNodeId == nodes[0].parentTId && + moveType == consts.move.TYPE_INNER + ) { tmpTarget = null; } if (tmpTarget) { - var dragTargetNode = tmpTargetNodeId == null ? null : data.getNodeCache(targetSetting, tmpTargetNodeId); - if (tools.apply(setting.callback.beforeDrop, [targetSetting.treeId, nodes, dragTargetNode, moveType, isCopy], true) == false) { + var dragTargetNode = + tmpTargetNodeId == null + ? null + : data.getNodeCache(targetSetting, tmpTargetNodeId); + if ( + tools.apply( + setting.callback.beforeDrop, + [targetSetting.treeId, nodes, dragTargetNode, moveType, isCopy], + true + ) == false + ) { view.selectNodes(sourceSetting, nodes); return; } @@ -3376,21 +4551,47 @@ if (moveType == consts.move.TYPE_INNER) { view.addNodes(targetSetting, dragTargetNode, -1, newNodes); } else { - view.addNodes(targetSetting, dragTargetNode.getParentNode(), moveType == consts.move.TYPE_PREV ? dragTargetNode.getIndex() : dragTargetNode.getIndex() + 1, newNodes); + view.addNodes( + targetSetting, + dragTargetNode.getParentNode(), + moveType == consts.move.TYPE_PREV + ? dragTargetNode.getIndex() + : dragTargetNode.getIndex() + 1, + newNodes + ); } } else { if (isCopy && moveType == consts.move.TYPE_INNER) { view.addNodes(targetSetting, dragTargetNode, -1, newNodes); } else if (isCopy) { - view.addNodes(targetSetting, dragTargetNode.getParentNode(), moveType == consts.move.TYPE_PREV ? dragTargetNode.getIndex() : dragTargetNode.getIndex() + 1, newNodes); + view.addNodes( + targetSetting, + dragTargetNode.getParentNode(), + moveType == consts.move.TYPE_PREV + ? dragTargetNode.getIndex() + : dragTargetNode.getIndex() + 1, + newNodes + ); } else { if (moveType != consts.move.TYPE_NEXT) { for (i = 0, l = newNodes.length; i < l; i++) { - view.moveNode(targetSetting, dragTargetNode, newNodes[i], moveType, false); + view.moveNode( + targetSetting, + dragTargetNode, + newNodes[i], + moveType, + false + ); } } else { for (i = -1, l = newNodes.length - 1; i < l; l--) { - view.moveNode(targetSetting, dragTargetNode, newNodes[l], moveType, false); + view.moveNode( + targetSetting, + dragTargetNode, + newNodes[l], + moveType, + false + ); } } } @@ -3400,18 +4601,39 @@ var a = $$(newNodes[0], setting).get(0); view.scrollIntoView(setting, a); - setting.treeObj.trigger(consts.event.DROP, [event, targetSetting.treeId, newNodes, dragTargetNode, moveType, isCopy]); + setting.treeObj.trigger(consts.event.DROP, [ + event, + targetSetting.treeId, + newNodes, + dragTargetNode, + moveType, + isCopy, + ]); } - if (moveType == consts.move.TYPE_INNER && tools.canAsync(targetSetting, dragTargetNode)) { - view.asyncNode(targetSetting, dragTargetNode, false, dropCallback); + if ( + moveType == consts.move.TYPE_INNER && + tools.canAsync(targetSetting, dragTargetNode) + ) { + view.asyncNode( + targetSetting, + dragTargetNode, + false, + dropCallback + ); } else { dropCallback(); } - } else { view.selectNodes(sourceSetting, nodes); - setting.treeObj.trigger(consts.event.DROP, [event, setting.treeId, nodes, null, null, null]); + setting.treeObj.trigger(consts.event.DROP, [ + event, + setting.treeId, + nodes, + null, + null, + null, + ]); } } @@ -3428,41 +4650,43 @@ // eventMouseDown.preventDefault(); // } return true; - } + }, }, //method of tools for zTree _tools = { - getAbs: function (obj) { + getAbs: function(obj) { var oRect = obj.getBoundingClientRect(), - scrollTop = document.body.scrollTop + document.documentElement.scrollTop, - scrollLeft = document.body.scrollLeft + document.documentElement.scrollLeft; + scrollTop = + document.body.scrollTop + document.documentElement.scrollTop, + scrollLeft = + document.body.scrollLeft + document.documentElement.scrollLeft; return [oRect.left + scrollLeft, oRect.top + scrollTop]; }, - inputFocus: function (inputObj) { + inputFocus: function(inputObj) { if (inputObj.get(0)) { inputObj.focus(); tools.setCursorPosition(inputObj.get(0), inputObj.val().length); } }, - inputSelect: function (inputObj) { + inputSelect: function(inputObj) { if (inputObj.get(0)) { inputObj.focus(); inputObj.select(); } }, - setCursorPosition: function (obj, pos) { + setCursorPosition: function(obj, pos) { if (obj.setSelectionRange) { obj.focus(); obj.setSelectionRange(pos, pos); } else if (obj.createTextRange) { var range = obj.createTextRange(); range.collapse(true); - range.moveEnd('character', pos); - range.moveStart('character', pos); + range.moveEnd("character", pos); + range.moveStart("character", pos); range.select(); } }, - showIfameMask: function (setting, showSign) { + showIfameMask: function(setting, showSign) { var root = data.getRoot(setting); //clear full mask while (root.dragMaskList.length > 0) { @@ -3475,59 +4699,133 @@ for (var i = 0, l = iframeList.length; i < l; i++) { var obj = iframeList.get(i), r = tools.getAbs(obj), - dragMask = $$("<div id='zTreeMask_" + i + "' class='zTreeMask' style='top:" + r[1] + "px; left:" + r[0] + "px; width:" + obj.offsetWidth + "px; height:" + obj.offsetHeight + "px;'></div>", setting); + dragMask = $$( + "<div id='zTreeMask_" + + i + + "' class='zTreeMask' style='top:" + + r[1] + + "px; left:" + + r[0] + + "px; width:" + + obj.offsetWidth + + "px; height:" + + obj.offsetHeight + + "px;'></div>", + setting + ); dragMask.appendTo($$("body", setting)); root.dragMaskList.push(dragMask); } } - } + }, }, //method of operate ztree dom _view = { - addEditBtn: function (setting, node) { + addEditBtn: function(setting, node) { if (node.editNameFlag || $$(node, consts.id.EDIT, setting).length > 0) { return; } - if (!tools.apply(setting.edit.showRenameBtn, [setting.treeId, node], setting.edit.showRenameBtn)) { + if ( + !tools.apply( + setting.edit.showRenameBtn, + [setting.treeId, node], + setting.edit.showRenameBtn + ) + ) { return; } var aObj = $$(node, consts.id.A, setting), - editStr = "<span class='" + consts.className.BUTTON + " edit' id='" + node.tId + consts.id.EDIT + "' title='" + tools.apply(setting.edit.renameTitle, [setting.treeId, node], setting.edit.renameTitle) + "' treeNode" + consts.id.EDIT + " style='display:none;'></span>"; + editStr = + "<span class='" + + consts.className.BUTTON + + " edit' id='" + + node.tId + + consts.id.EDIT + + "' title='" + + tools.apply( + setting.edit.renameTitle, + [setting.treeId, node], + setting.edit.renameTitle + ) + + "' treeNode" + + consts.id.EDIT + + " style='display:none;'></span>"; aObj.append(editStr); - $$(node, consts.id.EDIT, setting).bind('click', - function () { - if (!tools.uCanDo(setting) || tools.apply(setting.callback.beforeEditName, [setting.treeId, node], true) == false) return false; + $$(node, consts.id.EDIT, setting) + .bind("click", function() { + if ( + !tools.uCanDo(setting) || + tools.apply( + setting.callback.beforeEditName, + [setting.treeId, node], + true + ) == false + ) + return false; view.editNode(setting, node); return false; - } - ).show(); + }) + .show(); }, - addRemoveBtn: function (setting, node) { - if (node.editNameFlag || $$(node, consts.id.REMOVE, setting).length > 0) { + addRemoveBtn: function(setting, node) { + if ( + node.editNameFlag || + $$(node, consts.id.REMOVE, setting).length > 0 + ) { return; } - if (!tools.apply(setting.edit.showRemoveBtn, [setting.treeId, node], setting.edit.showRemoveBtn)) { + if ( + !tools.apply( + setting.edit.showRemoveBtn, + [setting.treeId, node], + setting.edit.showRemoveBtn + ) + ) { return; } var aObj = $$(node, consts.id.A, setting), - removeStr = "<span class='" + consts.className.BUTTON + " remove' id='" + node.tId + consts.id.REMOVE + "' title='" + tools.apply(setting.edit.removeTitle, [setting.treeId, node], setting.edit.removeTitle) + "' treeNode" + consts.id.REMOVE + " style='display:none;'></span>"; + removeStr = + "<span class='" + + consts.className.BUTTON + + " remove' id='" + + node.tId + + consts.id.REMOVE + + "' title='" + + tools.apply( + setting.edit.removeTitle, + [setting.treeId, node], + setting.edit.removeTitle + ) + + "' treeNode" + + consts.id.REMOVE + + " style='display:none;'></span>"; aObj.append(removeStr); - $$(node, consts.id.REMOVE, setting).bind('click', - function () { - if (!tools.uCanDo(setting) || tools.apply(setting.callback.beforeRemove, [setting.treeId, node], true) == false) return false; + $$(node, consts.id.REMOVE, setting) + .bind("click", function() { + if ( + !tools.uCanDo(setting) || + tools.apply( + setting.callback.beforeRemove, + [setting.treeId, node], + true + ) == false + ) + return false; view.removeNode(setting, node); - setting.treeObj.trigger(consts.event.REMOVE, [setting.treeId, node]); + setting.treeObj.trigger(consts.event.REMOVE, [ + setting.treeId, + node, + ]); return false; - } - ).bind('mousedown', - function (eventMouseDown) { + }) + .bind("mousedown", function(eventMouseDown) { return true; - } - ).show(); + }) + .show(); }, - addHoverDom: function (setting, node) { + addHoverDom: function(setting, node) { if (data.getRoots().showHoverDom) { node.isHover = true; if (setting.edit.enable) { @@ -3537,14 +4835,24 @@ tools.apply(setting.view.addHoverDom, [setting.treeId, node]); } }, - cancelCurEditNode: function (setting, forceName, isCancel) { + cancelCurEditNode: function(setting, forceName, isCancel) { var root = data.getRoot(setting), node = root.curEditNode; if (node) { var inputObj = root.curEditInput, - newName = forceName ? forceName : (isCancel ? data.nodeName(setting, node) : inputObj.val()); - if (tools.apply(setting.callback.beforeRename, [setting.treeId, node, newName, isCancel], true) === false) { + newName = forceName + ? forceName + : isCancel + ? data.nodeName(setting, node) + : inputObj.val(); + if ( + tools.apply( + setting.callback.beforeRename, + [setting.treeId, node, newName, isCancel], + true + ) === false + ) { return false; } data.nodeName(setting, node, newName); @@ -3556,16 +4864,24 @@ root.curEditNode = null; root.curEditInput = null; view.selectNode(setting, node, false); - setting.treeObj.trigger(consts.event.RENAME, [setting.treeId, node, isCancel]); + setting.treeObj.trigger(consts.event.RENAME, [ + setting.treeId, + node, + isCancel, + ]); } root.noSelection = true; return true; }, - editNode: function (setting, node) { + editNode: function(setting, node) { var root = data.getRoot(setting); view.editNodeBlur = false; - if (data.isSelectedNode(setting, node) && root.curEditNode == node && node.editNameFlag) { - setTimeout(function () { + if ( + data.isSelectedNode(setting, node) && + root.curEditNode == node && + node.editNameFlag + ) { + setTimeout(function() { tools.inputFocus(root.curEditInput); }, 0); return; @@ -3574,7 +4890,14 @@ view.removeTreeDom(setting, node); view.cancelCurEditNode(setting); view.selectNode(setting, node, false); - $$(node, consts.id.SPAN, setting).html("<input type=text class='rename' id='" + node.tId + consts.id.INPUT + "' treeNode" + consts.id.INPUT + " >"); + $$(node, consts.id.SPAN, setting).html( + "<input type=text class='rename' id='" + + node.tId + + consts.id.INPUT + + "' treeNode" + + consts.id.INPUT + + " >" + ); var inputObj = $$(node, consts.id.INPUT, setting); inputObj.attr("value", data.nodeName(setting, node)); if (setting.edit.editNameSelectAll) { @@ -3583,39 +4906,61 @@ tools.inputFocus(inputObj); } - inputObj.bind('blur', function (event) { - if (!view.editNodeBlur) { - view.cancelCurEditNode(setting); - } - }).bind('keydown', function (event) { - if (event.keyCode == "13") { - view.editNodeBlur = true; - view.cancelCurEditNode(setting); - } else if (event.keyCode == "27") { - view.cancelCurEditNode(setting, null, true); - } - }).bind('click', function (event) { - return false; - }).bind('dblclick', function (event) { - return false; - }); + inputObj + .bind("blur", function(event) { + if (!view.editNodeBlur) { + view.cancelCurEditNode(setting); + } + }) + .bind("keydown", function(event) { + if (event.keyCode == "13") { + view.editNodeBlur = true; + view.cancelCurEditNode(setting); + } else if (event.keyCode == "27") { + view.cancelCurEditNode(setting, null, true); + } + }) + .bind("click", function(event) { + return false; + }) + .bind("dblclick", function(event) { + return false; + }); $$(node, consts.id.A, setting).addClass(consts.node.CURSELECTED_EDIT); root.curEditInput = inputObj; root.noSelection = false; root.curEditNode = node; }, - moveNode: function (setting, targetNode, node, moveType, animateFlag, isSilent) { + moveNode: function( + setting, + targetNode, + node, + moveType, + animateFlag, + isSilent + ) { var root = data.getRoot(setting); if (targetNode == node) return; - if (setting.data.keep.leaf && targetNode && !data.nodeIsParent(setting, targetNode) && moveType == consts.move.TYPE_INNER) return; - var oldParentNode = (node.parentTId ? node.getParentNode() : root), - targetNodeIsRoot = (targetNode === null || targetNode == root); + if ( + setting.data.keep.leaf && + targetNode && + !data.nodeIsParent(setting, targetNode) && + moveType == consts.move.TYPE_INNER + ) + return; + var oldParentNode = node.parentTId ? node.getParentNode() : root, + targetNodeIsRoot = targetNode === null || targetNode == root; if (targetNodeIsRoot && targetNode === null) targetNode = root; if (targetNodeIsRoot) moveType = consts.move.TYPE_INNER; - var targetParentNode = (targetNode.parentTId ? targetNode.getParentNode() : root); + var targetParentNode = targetNode.parentTId + ? targetNode.getParentNode() + : root; - if (moveType != consts.move.TYPE_PREV && moveType != consts.move.TYPE_NEXT) { + if ( + moveType != consts.move.TYPE_PREV && + moveType != consts.move.TYPE_NEXT + ) { moveType = consts.move.TYPE_INNER; } @@ -3642,20 +4987,27 @@ if (!isSilent && moveType == consts.move.TYPE_INNER) { view.expandCollapseNode(setting, targetNode, true, false); } else if (!isSilent) { - view.expandCollapseNode(setting, targetNode.getParentNode(), true, false); + view.expandCollapseNode( + setting, + targetNode.getParentNode(), + true, + false + ); } targetObj = $$(targetNode, setting); target_ulObj = $$(targetNode, consts.id.UL, setting); if (!!targetObj.get(0) && !target_ulObj.get(0)) { var ulstr = []; - view.makeUlHtml(setting, targetNode, ulstr, ''); - targetObj.append(ulstr.join('')); + view.makeUlHtml(setting, targetNode, ulstr, ""); + targetObj.append(ulstr.join("")); } target_ulObj = $$(targetNode, consts.id.UL, setting); } var nodeDom = $$(node, setting); if (!nodeDom.get(0)) { - nodeDom = view.appendNodes(setting, node.level, [node], null, -1, false, true).join(''); + nodeDom = view + .appendNodes(setting, node.level, [node], null, -1, false, true) + .join(""); } else if (!targetObj.get(0)) { nodeDom.remove(); } @@ -3668,7 +5020,8 @@ } //repair the data after move - var i, l, + var i, + l, tmpSrcIndex = -1, tmpTargetIndex = 0, oldNeighbor = null, @@ -3700,7 +5053,8 @@ } if (moveType != consts.move.TYPE_INNER) { for (i = 0, l = targetParentChildren.length; i < l; i++) { - if (targetParentChildren[i].tId == targetNode.tId) tmpTargetIndex = i; + if (targetParentChildren[i].tId == targetNode.tId) + tmpTargetIndex = i; } } if (moveType == consts.move.TYPE_INNER) { @@ -3713,15 +5067,17 @@ } targetChildren.splice(targetChildren.length, 0, node); node.isLastNode = true; - node.isFirstNode = (targetChildren.length == 1); - } else if (targetNode.isFirstNode && moveType == consts.move.TYPE_PREV) { + node.isFirstNode = targetChildren.length == 1; + } else if ( + targetNode.isFirstNode && + moveType == consts.move.TYPE_PREV + ) { targetParentChildren.splice(tmpTargetIndex, 0, node); newNeighbor = targetNode; newNeighbor.isFirstNode = false; node.parentTId = targetNode.parentTId; node.isFirstNode = true; node.isLastNode = false; - } else if (targetNode.isLastNode && moveType == consts.move.TYPE_NEXT) { targetParentChildren.splice(tmpTargetIndex + 1, 0, node); newNeighbor = targetNode; @@ -3729,7 +5085,6 @@ node.parentTId = targetNode.parentTId; node.isFirstNode = false; node.isLastNode = true; - } else { if (moveType == consts.move.TYPE_PREV) { targetParentChildren.splice(tmpTargetIndex, 0, node); @@ -3755,10 +5110,13 @@ var tmp_ulObj = $$(oldParentNode, consts.id.UL, setting), tmp_switchObj = $$(oldParentNode, consts.id.SWITCH, setting), tmp_icoObj = $$(oldParentNode, consts.id.ICON, setting); - view.replaceSwitchClass(oldParentNode, tmp_switchObj, consts.folder.DOCU); + view.replaceSwitchClass( + oldParentNode, + tmp_switchObj, + consts.folder.DOCU + ); view.replaceIcoClass(oldParentNode, tmp_icoObj, consts.folder.DOCU); tmp_ulObj.css("display", "none"); - } else if (oldNeighbor) { //old neigbor node view.setNodeLineIcos(setting, oldNeighbor); @@ -3779,22 +5137,31 @@ //expand parents after move if (!isSilent) { - view.expandCollapseParentNode(setting, node.getParentNode(), true, animateFlag); + view.expandCollapseParentNode( + setting, + node.getParentNode(), + true, + animateFlag + ); } }, - removeEditBtn: function (setting, node) { - $$(node, consts.id.EDIT, setting).unbind().remove(); + removeEditBtn: function(setting, node) { + $$(node, consts.id.EDIT, setting) + .unbind() + .remove(); }, - removeRemoveBtn: function (setting, node) { - $$(node, consts.id.REMOVE, setting).unbind().remove(); + removeRemoveBtn: function(setting, node) { + $$(node, consts.id.REMOVE, setting) + .unbind() + .remove(); }, - removeTreeDom: function (setting, node) { + removeTreeDom: function(setting, node) { node.isHover = false; view.removeEditBtn(setting, node); view.removeRemoveBtn(setting, node); tools.apply(setting.view.removeHoverDom, [setting.treeId, node]); }, - repairNodeLevelClass: function (setting, node, oldLevel) { + repairNodeLevelClass: function(setting, node, oldLevel) { if (oldLevel === node.level) return; var liObj = $$(node, setting), aObj = $$(node, consts.id.A, setting), @@ -3808,18 +5175,17 @@ ulObj.removeClass(oldClass); ulObj.addClass(newClass); }, - selectNodes: function (setting, nodes) { + selectNodes: function(setting, nodes) { for (var i = 0, l = nodes.length; i < l; i++) { view.selectNode(setting, nodes[i], i > 0); } - } + }, }, - _z = { tools: _tools, view: _view, event: _event, - data: _data + data: _data, }; $.extend(true, $.fn.zTree.consts, _consts); $.extend(true, $.fn.zTree._z, _z); @@ -3842,7 +5208,7 @@ data.addZTreeTools(_zTreeTools); var _cancelPreSelectedNode = view.cancelPreSelectedNode; - view.cancelPreSelectedNode = function (setting, node) { + view.cancelPreSelectedNode = function(setting, node) { var list = data.getRoot(setting).curSelectedList; for (var i = 0, j = list.length; i < j; i++) { if (!node || node === list[i]) { @@ -3851,10 +5217,10 @@ } } if (_cancelPreSelectedNode) _cancelPreSelectedNode.apply(view, arguments); - } + }; var _createNodes = view.createNodes; - view.createNodes = function (setting, level, nodes, parentNode, index) { + view.createNodes = function(setting, level, nodes, parentNode, index) { if (_createNodes) { _createNodes.apply(view, arguments); } @@ -3862,43 +5228,55 @@ if (view.repairParentChkClassWithSelf) { view.repairParentChkClassWithSelf(setting, parentNode); } - } + }; var _makeNodeUrl = view.makeNodeUrl; - view.makeNodeUrl = function (setting, node) { - return setting.edit.enable ? null : (_makeNodeUrl.apply(view, arguments)); - } + view.makeNodeUrl = function(setting, node) { + return setting.edit.enable ? null : _makeNodeUrl.apply(view, arguments); + }; var _removeNode = view.removeNode; - view.removeNode = function (setting, node) { + view.removeNode = function(setting, node) { var root = data.getRoot(setting); if (root.curEditNode === node) root.curEditNode = null; if (_removeNode) { _removeNode.apply(view, arguments); } - } + }; var _selectNode = view.selectNode; - view.selectNode = function (setting, node, addFlag) { + view.selectNode = function(setting, node, addFlag) { var root = data.getRoot(setting); - if (data.isSelectedNode(setting, node) && root.curEditNode == node && node.editNameFlag) { + if ( + data.isSelectedNode(setting, node) && + root.curEditNode == node && + node.editNameFlag + ) { return false; } if (_selectNode) _selectNode.apply(view, arguments); view.addHoverDom(setting, node); return true; - } + }; var _uCanDo = tools.uCanDo; - tools.uCanDo = function (setting, e) { + tools.uCanDo = function(setting, e) { var root = data.getRoot(setting); - if (e && (tools.eqs(e.type, "mouseover") || tools.eqs(e.type, "mouseout") || tools.eqs(e.type, "mousedown") || tools.eqs(e.type, "mouseup"))) { + if ( + e && + (tools.eqs(e.type, "mouseover") || + tools.eqs(e.type, "mouseout") || + tools.eqs(e.type, "mousedown") || + tools.eqs(e.type, "mouseup")) + ) { return true; } if (root.curEditNode) { view.editNodeBlur = false; root.curEditInput.focus(); } - return (!root.curEditNode) && (_uCanDo ? _uCanDo.apply(view, arguments) : true); - } -})(jQuery); \ No newline at end of file + return ( + !root.curEditNode && (_uCanDo ? _uCanDo.apply(view, arguments) : true) + ); + }; +})(jQuery); diff --git a/src/scripts/httpRequest.ts b/src/scripts/httpRequest.ts index 5fac11d..194dfe6 100644 --- a/src/scripts/httpRequest.ts +++ b/src/scripts/httpRequest.ts @@ -2,7 +2,7 @@ import axios from 'axios' import qs from 'qs' import { Notification } from 'element-ui' -// import router from '@/router' + import router from '@/router' const Axios = axios.create({ responseType: 'json', @@ -99,10 +99,9 @@ case 401: errJson.status = error.response.status errJson.message = '鏈巿鏉冿紝璇烽噸鏂扮櫥褰�(401)' - window.parent.postMessage({ - msg: "logout" - }, '*') - // console.log("鏍囧織浣嶏細",AuthData.isLoginout) + router.push({ + path: '/login' + }) // if (!AuthData.isLoginout) { // Notification({ // title:"", diff --git a/src/views/connectUs/components/consult.vue b/src/views/connectUs/components/consult.vue index ffc06a4..ecf226d 100644 --- a/src/views/connectUs/components/consult.vue +++ b/src/views/connectUs/components/consult.vue @@ -17,8 +17,8 @@ label-position="left" label-width="100px" > - <el-form-item prop="name" label="鎮ㄧ殑濮撳悕"> - <el-input v-model="formData.name"></el-input> + <el-form-item prop="username" label="鎮ㄧ殑濮撳悕"> + <el-input v-model="formData.username"></el-input> </el-form-item> <el-form-item prop="phoneNum" label="鎮ㄧ殑鎵嬫満鍙�"> @@ -41,37 +41,49 @@ > </el-form-item> - <el-form-item prop="mail" label="鎮ㄧ殑閭"> - <el-input v-model="formData.mail"> </el-input> + <el-form-item prop="email" label="鎮ㄧ殑閭"> + <el-input v-model="formData.email"> </el-input> </el-form-item> <el-form-item label="鎮ㄧ殑鍏徃"> <el-input v-model="formData.company"> </el-input> </el-form-item> - <el-form-item prop="detail" label="鎮ㄦ兂浜嗚В浠�涔�"> - <el-input v-model="formData.detail" type="textarea" :rows="4"> + <el-form-item prop="contents" label="鎯充簡瑙d粈涔�"> + <el-input v-model="formData.contents" type="textarea" :rows="4"> </el-input> </el-form-item> - <div class="button">鎻愪氦</div> + <div class="button" @click="submit">鎻愪氦</div> </el-form> </div> </div> </template> <script> -import { getVerifyCode } from "@/api/login"; +import { getVerifyCode, saveConnectUs } from "@/api/login"; export default { data() { return { formData: { - name: "", + username: "", phoneNum: "", verifyCode: "", - mail: "", + email: "", company: "", - detail: "", + contents: "", }, - rules: {}, + rules: { + username: [{ required: true, message: "璇疯緭鍏ュ鍚�", trigger: "blur" }], + phoneNum: [ + { required: true, message: "璇疯緭鍏ユ墜鏈哄彿", trigger: "blur" }, + ], + verifyCode: [ + { required: true, message: "璇疯緭鍏ラ獙璇佺爜", trigger: "blur" }, + ], + email: [{ required: true, message: "璇疯緭鍏ラ偖绠�", trigger: "blur" }], + contents: [ + { required: true, message: "璇疯緭鍏ユ偍鎯充簡瑙d粈涔�", trigger: "blur" }, + ], + }, codeDisabled: false, countdown: 60, codeMsg: "鑾峰彇楠岃瘉鐮�", @@ -95,18 +107,32 @@ }, //鑾峰彇楠岃瘉鐮� getCode() { + let loginName = JSON.parse(sessionStorage.getItem("userInfo")).username; this.codeDisabled = true; this.getValidStr(); this.timer = setInterval(this.getValidStr, 1000); - getVerifyCode({ phoneNum: this.formData.phoneNum, type: 1 }) - .then(() => { - this.gotCode = true; - }) - .catch((err) => { - if (err.data) { - console.log(err); + getVerifyCode({ + phoneNum: this.formData.phoneNum, + username: loginName, + }).then(() => { + this.gotCode = true; + }); + }, + + submit() { + this.$refs["userForm"].validate(async (valid) => { + if (valid) { + const res = await saveConnectUs(this.formData); + if (res.success) { + this.$notify({ + type: "success", + message: "鎻愪氦鎴愬姛!", + }); } - }); + } else { + return false; + } + }); }, }, }; diff --git a/src/views/connectUs/index.vue b/src/views/connectUs/index.vue index 2b60e9e..72a0ffb 100644 --- a/src/views/connectUs/index.vue +++ b/src/views/connectUs/index.vue @@ -8,7 +8,7 @@ class="navItem" :key="index" :class="{ active: activeNav == index }" - @click="activeNav = index" + @click="jump(index)" > {{ item }} </div> @@ -31,6 +31,14 @@ components: { consult, }, + methods: { + jump(index) { + this.activeNav = index; + if (index == 0) { + this.$router.push("/"); + } + }, + }, }; </script> diff --git a/src/views/equipmentManagement/equipmentDetail/components/UnbindBox.vue b/src/views/equipmentManagement/equipmentDetail/components/UnbindBox.vue index 9cee935..ea90873 100644 --- a/src/views/equipmentManagement/equipmentDetail/components/UnbindBox.vue +++ b/src/views/equipmentManagement/equipmentDetail/components/UnbindBox.vue @@ -141,7 +141,7 @@ position: absolute; top: 10px; right: 10px; - font-size: 12px; + font-size: 1px; color: 187, 187, 187; cursor: pointer; } diff --git a/src/views/hashrate/AlgManage/components/AlgCard.vue b/src/views/hashrate/AlgManage/components/AlgCard.vue index 42892ad..41370cf 100644 --- a/src/views/hashrate/AlgManage/components/AlgCard.vue +++ b/src/views/hashrate/AlgManage/components/AlgCard.vue @@ -1,17 +1,17 @@ <template> <div class="AlgCard"> - <img :src="alg.img" alt="" /> - <div class="name">{{ alg.name }}</div> - <div class="dot" v-if="alg.hasNewVersion"></div> + <img :src="alg.iconBlob" alt="" /> + <div class="name">{{ alg.sdk_name }}</div> + <div class="dot" v-if="alg.isUpgrade"></div> <!-- 鎮仠閬僵灞� --> <div class="version"> <!-- 鏈夋柊鐗堟湰 --> - <div class="isOld" v-if="alg.hasNewVersion"> + <div class="isOld" v-if="alg.isUpgrade"> <div class="row">褰撳墠鐗堟湰: {{ alg.version }}</div> - <div class="row">鏈�鏂扮増鏈�: {{ alg.newVersion }}</div> + <div class="row">鏈�鏂扮増鏈�: {{ alg.remoteVersion }}</div> <div class="btns"> - <div class="button update">鍗囩骇</div> + <div class="button update" @click="update">鍗囩骇</div> <div class="button delete">鍗歌浇</div> </div> </div> @@ -20,7 +20,7 @@ <div class="row">褰撳墠涓烘渶鏂扮増鏈�</div> <div class="row">{{ alg.version }}</div> <div class="btns"> - <div class="button delete">鍗歌浇</div> + <div class="button delete" @click="unInstall">鍗歌浇</div> </div> </div> </div> @@ -28,9 +28,40 @@ </template> <script> +import { downloadOrUpgrade, unInstall } from "@/api/algorithm"; export default { props: { alg: {}, + devId: {}, + }, + methods: { + async update() { + const res = await downloadOrUpgrade({ + nodeId: this.devId, + path: this.alg.id, + userId: JSON.parse(sessionStorage.getItem("userInfo")).id, + }); + if (res && res.success) { + this.$notify({ + type: "success", + message: "鎿嶄綔鎴愬姛,璇风◢鍚�", + }); + } + }, + async unInstall() { + const res = await unInstall({ + nodeId: this.devId, + sdkId: this.alg.id, + userId: JSON.parse(sessionStorage.getItem("userInfo")).id, + }); + if (res && res.success) { + this.$emit("unInstall"); + this.$notify({ + type: "success", + message: "鍗歌浇鎴愬姛", + }); + } + }, }, }; </script> diff --git a/src/views/hashrate/AlgManage/index.vue b/src/views/hashrate/AlgManage/index.vue index 784f699..c09b0d0 100644 --- a/src/views/hashrate/AlgManage/index.vue +++ b/src/views/hashrate/AlgManage/index.vue @@ -6,7 +6,7 @@ <!-- 鏀惰垂绠楁硶鍒楄〃 --> <div class="label">鏀惰垂绠楁硶</div> - <div class="payList"> + <div class="payList scroll"> <div class="algCard" v-for="(item, index) in payAlg" :key="index"> <img :src="item.logoUrl" alt="" draggable="false" /> <div class="name">{{ item.productName }}</div> @@ -15,7 +15,7 @@ </div> <!-- 鍏嶈垂绠楁硶鍒楄〃 --> - <div class="label"> + <div class="label freeLabel"> 鍏嶈垂绠楁硶 <span class="des">浠庢澶勬嫋鎷界畻娉曞浘鏍囧畨瑁呭埌璁惧</span> </div> <div class="freeList"> @@ -40,30 +40,35 @@ <!-- 鍙充晶绠楁硶绠$悊 --> <div class="rightList"> <div class="title">绠楁硶绠$悊</div> - <div class="button update">鍏ㄩ儴鏇存柊</div> + <div class="button update" @click="updateAll">鍏ㄩ儴鏇存柊</div> <!-- 璁惧 --> <div class="equipment" v-for="(item, index) in equipmentArr" :key="index"> - <div class="name">{{ item.name }}</div> + <div class="name">{{ item.devName }}</div> <!-- 绠楁硶鍒楄〃 --> <div class="algList"> <!-- 绠楁硶card --> <Card - v-for="(alg, index) in item.algs" + v-for="(alg, index) in item.sdkList" :key="index" :alg="alg" + :devId="item.devId" + @unInstall="item.sdkList.splice(index, 1)" ></Card> <!-- 鎷栨嫿瀛樻斁box --> <div class="dropBox" v-if="dragAlg" @dragover="dragover($event)" - @drop="drop(item.algs)" + @drop="drop(item.sdkList, item.devId)" > 璇锋嫋鍔ㄥ埌姝ゅ </div> <!-- 绌虹畻娉曟儏鍐� --> - <div class="empty" v-if="item.algs.length === 0 && !dragAlg"> + <div + class="empty" + v-if="item.sdkList && item.sdkList.length === 0 && !dragAlg" + > <img src="/images/hashrate/绠楁硶绠$悊绌洪〉闈�.png" alt="" /> <div class="des"> 鏆傛湭瀹夎绠楁硶锛屼粠宸︿晶绠楁硶涓績鎷栧埌绠楁硶鍒版澶勶紝鍗冲彲瀹夎 @@ -98,13 +103,14 @@ <script> import Card from "./components/AlgCard"; + import { getAllCenterProduct, getSdkConfigInfo, saveSdkConfig, findAllSdk, downloadOrUpgrade, - unInstall, + unInstallAll, } from "@/api/algorithm"; export default { components: { @@ -121,148 +127,7 @@ setting: false, payAlg: [], freeAlg: [], - equipmentArr: [ - { - name: "璁惧1", - algs: [ - { - img: "/images/index/1浠板崸妫�娴�.png", - name: "浠板崸妫�娴�", - version: "v1.0.0", - newVersion: "v1.0.0", - hasNewVersion: false, - }, - { - img: "/images/index/11婊炵暀.png", - name: "婊炵暀", - version: "v1.0.0", - newVersion: "v1.0.0", - hasNewVersion: false, - }, - { - img: "/images/index/15鎴村彛缃�.png", - name: "鎴村彛缃�", - version: "v1.0.0", - newVersion: "v1.0.2", - hasNewVersion: true, - }, - { - img: "/images/index/1浠板崸妫�娴�.png", - name: "浠板崸妫�娴�", - version: "v1.0.0", - newVersion: "v1.0.0", - hasNewVersion: false, - }, - { - img: "/images/index/11婊炵暀.png", - name: "婊炵暀", - version: "v1.0.0", - newVersion: "v1.0.0", - hasNewVersion: false, - }, - { - img: "/images/index/15鎴村彛缃�.png", - name: "鎴村彛缃�", - version: "v1.0.0", - newVersion: "v1.0.2", - hasNewVersion: true, - }, - { - img: "/images/index/1浠板崸妫�娴�.png", - name: "浠板崸妫�娴�", - version: "v1.0.0", - newVersion: "v1.0.0", - hasNewVersion: false, - }, - { - img: "/images/index/11婊炵暀.png", - name: "婊炵暀", - version: "v1.0.0", - newVersion: "v1.0.0", - hasNewVersion: false, - }, - { - img: "/images/index/15鎴村彛缃�.png", - name: "鎴村彛缃�", - version: "v1.0.0", - newVersion: "v1.0.2", - hasNewVersion: true, - }, - { - img: "/images/index/1浠板崸妫�娴�.png", - name: "浠板崸妫�娴�", - version: "v1.0.0", - newVersion: "v1.0.0", - hasNewVersion: false, - }, - { - img: "/images/index/11婊炵暀.png", - name: "婊炵暀", - version: "v1.0.0", - newVersion: "v1.0.0", - hasNewVersion: false, - }, - { - img: "/images/index/15鎴村彛缃�.png", - name: "鎴村彛缃�", - version: "v1.0.0", - newVersion: "v1.0.2", - hasNewVersion: true, - }, - { - img: "/images/index/1浠板崸妫�娴�.png", - name: "浠板崸妫�娴�", - version: "v1.0.0", - newVersion: "v1.0.0", - hasNewVersion: false, - }, - { - img: "/images/index/11婊炵暀.png", - name: "婊炵暀", - version: "v1.0.0", - newVersion: "v1.0.0", - hasNewVersion: false, - }, - { - img: "/images/index/15鎴村彛缃�.png", - name: "鎴村彛缃�", - version: "v1.0.0", - newVersion: "v1.0.2", - hasNewVersion: true, - }, - ], - }, - { - name: "璁惧2", - algs: [ - { - img: "/images/index/1浠板崸妫�娴�.png", - name: "浠板崸妫�娴�", - version: "v1.0.0", - newVersion: "v1.0.0", - hasNewVersion: false, - }, - { - img: "/images/index/11婊炵暀.png", - name: "婊炵暀", - version: "v1.0.0", - newVersion: "v1.0.0", - hasNewVersion: false, - }, - { - img: "/images/index/15鎴村彛缃�.png", - name: "鎴村彛缃�", - version: "v1.0.0", - newVersion: "v1.0.2", - hasNewVersion: true, - }, - ], - }, - { - name: "璁惧3", - algs: [], - }, - ], + equipmentArr: [], dragAlg: null, }; }, @@ -275,7 +140,7 @@ variable: "sdkManageConfig", }); if (res && res.success) { - if (res.data.value === "") { + if (!res.data.value || res.data.value == "off") { this.showSettingBox = true; } else { this.setting = res.data.value === "on" ? true : false; @@ -287,16 +152,18 @@ async getProduct() { const res = await getAllCenterProduct({ page: 1, - size: 100000, + size: 1000000, inputText: "", - archType: "", - gpuType: "", + productType: 3, publishStatus: 1, - productLabelId: "d0aabaee-8edd-492d-8f43-6b0e0bb6e2dd", }); if (res && res.success) { res.data.list.forEach((item) => { + if (item.productName == "瓒翠紡") { + console.log(item); + } + item.logoUrl = "/httpImage/" + item.logoUrl; if (item.priceBase === 0) { this.freeAlg.push(item); @@ -310,6 +177,9 @@ //鑾峰彇鍙充晶璁惧鍒楄〃 async getEquipment() { const res = await findAllSdk(); + if (res && res.success) { + this.equipmentArr = res.data; + } }, //鎷栨嫿寮�濮� dragStart(alg) { @@ -320,14 +190,24 @@ dragover(e) { e.preventDefault(); }, - drop(algArr) { + async drop(algArr, devId) { algArr.push({ - img: this.dragAlg.img, - name: this.dragAlg.name, - version: "v1.0.0", - newVersion: "v1.0.0", - hasNewVersion: false, + iconBlob: this.dragAlg.logoUrl, + sdk_name: this.dragAlg.productName, }); + + const res = await downloadOrUpgrade({ + nodeId: devId, + path: this.dragAlg.productBaseId, + userId: JSON.parse(sessionStorage.getItem("userInfo")).id, + }); + if (res && res.success) { + this.$notify({ + type: "success", + message: "鎿嶄綔鎴愬姛,璇风◢鍚�", + }); + } + this.dragAlg = null; }, async closeSettingBox() { @@ -345,7 +225,35 @@ this.$notify.success({ message: "閰嶇疆鎴愬姛", }); - this.showSettingBox = false; + if (this.setting) { + this.showSettingBox = false; + } + } + }, + async updateAll() { + let devArr = []; + this.equipmentArr.forEach((dev) => { + let devObj = {}; + let sdkIds = []; + devObj.devId = dev.devId; + dev.sdkList.forEach((sdk) => { + if (sdk.isUpgrade) { + sdkIds.push(sdk.id); + } + }); + devObj.sdkIds = sdkIds; + devArr.push(devObj); + }); + + const res = await unInstallAll({ + userId: JSON.parse(sessionStorage.getItem("userInfo")).id, + devSdkIds: devArr, + }); + if (res && res.success) { + this.$notify({ + type: "success", + message: "鎿嶄綔鎴愬姛", + }); } }, }, @@ -401,8 +309,14 @@ } } + .freeLabel { + margin-top: 20px; + } + .payList, .freeList { + max-height: 320px; + overflow: auto; display: flex; flex-wrap: wrap; @@ -410,7 +324,7 @@ box-sizing: border-box; margin-right: 10px; margin-bottom: 16px; - width: 95px; + width: 90px; height: 144px; border: 1px solid #e9ebee; border-radius: 5px; @@ -621,7 +535,7 @@ .mask { position: absolute; - top: 0; + top: 62px; left: 0; right: 0; bottom: 0; diff --git a/src/views/hashrate/CameraManage/index.vue b/src/views/hashrate/CameraManage/index.vue index 61cc152..c8ab02e 100644 --- a/src/views/hashrate/CameraManage/index.vue +++ b/src/views/hashrate/CameraManage/index.vue @@ -2,7 +2,7 @@ <div class="CameraManage"> <div class="cluster"> <div class="title">闆嗙兢閫夋嫨</div> - <el-select v-model="cluster" placeholder="璇烽�夋嫨"> + <el-select v-model="cluster" placeholder="璇烽�夋嫨" @change="selectCluster"> <el-option v-for="item in clusterArr" :key="item.value" @@ -51,6 +51,8 @@ import CameraRules from "./CameraRules"; import VideoRuleData from "@/Pool/VideoRuleData"; +import { getClusterDevList } from "@/api/clusterManage"; + import bus from "@/plugin/bus"; export default { components: { @@ -62,16 +64,7 @@ data() { return { activeTab: "淇℃伅缁存姢", - clusterArr: [ - { - value: 0, - label: "闆嗙兢涓�", - }, - { - value: 1, - label: "闆嗙兢浜�", - }, - ], + clusterArr: [], cluster: "", intervalTimer: null, leftWith: 0, @@ -130,6 +123,7 @@ }, }, created() { + this.getCluster(); this.PollData.statistics(); this.TreeDataPool.readonly = false; @@ -194,6 +188,40 @@ } } }, + async getCluster() { + const res = await getClusterDevList(); + console.log(res); + if (res && res.success) { + res.data.clusterList.forEach((item) => { + this.clusterArr.push({ + label: item.cluster_name, + value: "0$$" + item.cluster_id, + }); + }); + + res.data.devList.forEach((item) => { + this.clusterArr.push({ + label: item.devName, + value: "1$$" + item.devId, + }); + }); + + this.cluster = this.clusterArr[0].value; + } + }, + selectCluster(val) { + const arr = val.split("$$"); + console.log(arr); + if (arr[0] == "0") { + this.TreeDataPool.clusterId = arr[1]; + this.TreeDataPool.devId = ""; + } + if (arr[0] == "1") { + this.TreeDataPool.devId = arr[1]; + this.TreeDataPool.clusterId = ""; + } + this.TreeDataPool.fetchTreeData(); + }, }, }; </script> diff --git a/src/views/hashrate/index.vue b/src/views/hashrate/index.vue index 1ffc56a..c516729 100644 --- a/src/views/hashrate/index.vue +++ b/src/views/hashrate/index.vue @@ -12,6 +12,7 @@ import Banner from "@/views/hashrate/components/Banner"; import Flow from "@/views/hashrate/components/Flow"; import Footer from "@/components/Footer"; + export default { components: { IndexHeader, @@ -23,11 +24,13 @@ </script> <style lang="scss" scoped> -.hashrate { - .IndexHeader { - ::v-deep .header { - position: absolute; - } +.IndexHeader { + ::v-deep .header { + position: fixed; + z-index: 2; + top: 0; + right: 0; + left: 0; } } </style> \ No newline at end of file diff --git a/src/views/index/components/banner.vue b/src/views/index/components/banner.vue index b42ef3a..6641f50 100644 --- a/src/views/index/components/banner.vue +++ b/src/views/index/components/banner.vue @@ -7,14 +7,19 @@ arrow="never" ref="banner" > - <el-carousel-item v-for="item in 4" :key="item"> - <div class="banner_content"> - <div class="banner_text"> - <div class="banner_title_en">SmartAI</div> - <div class="banner_title_zh">浜哄伐鏅鸿兘鎿嶄綔绯荤粺</div> - <div class="banner_des">涓鸿涓氬鎴烽噺韬墦閫犵殑浼佷笟绾I鎿嶄綔绯荤粺</div> - </div> + <el-carousel-item v-for="(item, index) in bannerList" :key="index"> + <div + class="banner_content" + :style="{ + // backgroundImage: 'url(' + baseImg + ')', + backgroundImage: 'url(' + (item.pic ? item.pic : baseImg) + ')', + backgroundSize: '100% 100%', + backgroundRepeat: 'no-repeat', + }" + > + <div class="banner_text" v-html="item.name"></div> </div> + <div class="link"></div> </el-carousel-item> </el-carousel> </div> @@ -23,6 +28,14 @@ <script> export default { name: "Banner", + props: { + bannerList: {}, + }, + data() { + return { + baseImg: "/images/index/banner.png", + }; + }, methods: { toggleBanner(i) { this.$refs["banner"].setActiveItem(i); @@ -41,29 +54,12 @@ top: -62px; .banner_content { height: 100%; - background-image: url("/images/index/banner.png"); padding: 183px 0 0 0; .banner_text { margin: 0 auto; width: 1280px; color: #fff; - - .banner_title_en { - font-size: 24px; - line-height: 60px; - } - - .banner_title_zh { - font-size: 36px; - font-weight: 700; - line-height: 48px; - } - - .banner_des { - font-size: 14px; - line-height: 60px; - } } } diff --git a/src/views/index/components/commendContent.vue b/src/views/index/components/commendContent.vue index d90e824..3c3b324 100644 --- a/src/views/index/components/commendContent.vue +++ b/src/views/index/components/commendContent.vue @@ -1,24 +1,24 @@ <template> <div class="commendContent"> - <div class="refresh"><span class="icon iconfont"></span>鎹竴鎵�</div> + <div class="refresh" @click="refresh"> + <span class="icon iconfont"></span>鎹竴鎵� + </div> <div class="commendTabsItem" v-for="(item, index) in commendData" :key="index" > - <div class="icon"> - <img :src="item.img" alt="" /> - </div> - <div class="title">{{ item.title }}</div> - <div class="des">{{ item.des }}</div> - <price :priceNew="item.priceNew" :priceOld="item.priceOld"></price> + <img :src="'http:/' + item.logoUrl" alt="" /> + <div class="title">{{ item.productName }}</div> + <div class="des limitoRow2">{{ item.description }}</div> + <price :priceNew="item.priceBase"></price> <div class="button">绔嬪嵆璐拱</div> </div> </div> </template> <script> -import price from "./price.vue"; +import price from "@/components/Price.vue"; export default { props: { @@ -28,6 +28,11 @@ }, components: { price, + }, + methods: { + refresh() { + this.$emit("refresh"); + }, }, }; </script> @@ -40,6 +45,9 @@ margin: 0 auto; .commendTabsItem { + position: relative; + max-width: 302px; + height: 332px; flex: 1; padding-top: 20px; text-align: center; @@ -50,7 +58,8 @@ margin-right: 0; } - .icon img { + img { + height: 96px; width: 96px; } @@ -62,13 +71,16 @@ } .des { + height: 38px; margin: 0 20px 20px 20px; color: #666666; font-size: 14px; } .button { - margin-top: 25px; + position: absolute; + bottom: 0; + right: 0; width: 100%; height: 40px; box-shadow: 0px 2px 8px rgba(0, 43, 106, 0.12); diff --git a/src/views/index/components/price.vue b/src/views/index/components/price.vue deleted file mode 100644 index fc1a77c..0000000 --- a/src/views/index/components/price.vue +++ /dev/null @@ -1,58 +0,0 @@ - -<template> - <div class="price"> - 锟�<span class="newPrice">{{ priceNew1 }}</span - >.{{ priceNew2 }}/骞� - <span class="oldPrice">锟{ priceOld }}/骞�</span> - </div> -</template> - -<script> -export default { - props: { - priceNew: {}, - priceOld: {}, - }, - computed: { - priceNew1() { - let prcie = ""; - if (typeof this.priceNew == Number) { - prcie = `${this.priceNew}`.split(".")[0]; - } else { - prcie = this.priceNew.split(".")[0]; - } - return prcie; - }, - priceNew2() { - let prcie = ""; - if (typeof this.priceNew == Number) { - prcie = `${this.priceNew}`.split(".")[1]; - } else { - prcie = this.priceNew.split(".")[1]; - } - return prcie; - }, - }, -}; -</script> - -<style lang="scss" scoped> -.price { - margin: 0 20px 0 20px; - font-size: 14px; - text-align: left; - - .newPrice { - font-size: 30px; - color: rgb(255, 96, 0); - font-weight: 700; - } - - .oldPrice { - margin-left: 10px; - font-size: 14px; - color: #999999; - text-decoration: line-through; - } -} -</style> \ No newline at end of file diff --git a/src/views/index/components/productLeft.vue b/src/views/index/components/productLeft.vue index 9897cce..e69b73d 100644 --- a/src/views/index/components/productLeft.vue +++ b/src/views/index/components/productLeft.vue @@ -1,14 +1,21 @@ <template> - <div class="productLeft" :style="{ background: ` url(${data.img})` }"> + <div + class="productLeft" + :style="{ + background: ` url(${data.pic})`, + backgroundSize: '100% 100%', + backgroundRepeat: 'no-repeat', + }" + > <div class="inner"> <div class="title"> - {{ data.title }} + {{ data.name }} </div> <div class="des"> - {{ data.des }} + {{ data.desc }} </div> <div class="button"> - <router-link :to="data.router">鏌ョ湅鍏ㄩ儴</router-link> + <router-link to="/product">鏌ョ湅鍏ㄩ儴</router-link> </div> </div> </div> diff --git a/src/views/index/components/rightColumn.vue b/src/views/index/components/rightColumn.vue index f656cb2..8bd0397 100644 --- a/src/views/index/components/rightColumn.vue +++ b/src/views/index/components/rightColumn.vue @@ -1,26 +1,26 @@ <template> <div class="rightColumn"> - <div class="columnItem" v-for="(item, index) in data.product" :key="index"> + <div class="columnItem" v-for="(item, index) in product" :key="index"> <div class="title"> - <img :src="item.icon" alt="" /> - {{ item.title }} + <img :src="'/httpImage/' + item.logoUrl" alt="" /> + {{ item.modelName }} </div> - <div class="des"> - {{ item.des }} + <div class="des limitRow2"> + {{ item.summary }} </div> - <ul class="list"> - <li v-for="(v, i) in item.menu" :key="i"> - <span class="icon iconfont"></span>{{ v }} + <ul class="list scroll"> + <li> + <span class="icon iconfont"></span>{{ item.description }} </li> </ul> - <price :priceNew="item.priceNew" :priceOld="item.priceOld"></price> + <price :priceNew="item.priceBase"></price> <div class="button">绔嬪嵆璐拱</div> </div> </div> </template> <script> -import price from "@/views/index/components/price"; +import price from "@/components/Price.vue"; export default { props: { @@ -30,6 +30,18 @@ }, components: { price, + }, + data() { + return { + product: [], + }; + }, + created() { + if (this.data.product.length > 3) { + this.product = this.data.product.slice(0, 3); + } else { + this.product = this.data.product; + } }, }; </script> @@ -70,13 +82,16 @@ } .des { + height: 38px; font-size: 14px; color: #999; } .list { - margin-top: 33px; - height: 150px; + margin-top: 10px; + margin-bottom: 10px; + height: 170px; + overflow-y: auto; li { font-size: 14px; color: #666666; @@ -91,7 +106,7 @@ } } - .price { + .Price { margin-bottom: 10px; margin-left: 0; } diff --git a/src/views/index/components/rightForm.vue b/src/views/index/components/rightForm.vue index a2755e4..ae78fe6 100644 --- a/src/views/index/components/rightForm.vue +++ b/src/views/index/components/rightForm.vue @@ -47,10 +47,12 @@ </div> <div class="price"> - <price :priceOld="priceOld" :priceNew="priceNew"></price> + <price + :priceOld="priceOld" + :priceNew="priceNew" + :showIcon="true" + ></price> </div> - - <div class="iconSave">鐪�</div> <div class="button">绔嬪嵆璐拱</div> <div class="info"> @@ -64,7 +66,7 @@ </template> <script> -import price from "@/views/index/components/price"; +import price from "@/components/Price.vue"; export default { props: { @@ -162,6 +164,17 @@ width: 44px; background-color: #fff; } + + ::v-deep + .el-input-number__increase:hover:not(.is-disabled) + ~ .el-input + .el-input__inner:not(.is-disabled), + ::v-deep + .el-input-number__decrease:hover:not(.is-disabled) + ~ .el-input + .el-input__inner:not(.is-disabled) { + border-color: #0065ff; + } } } @@ -224,7 +237,6 @@ .button { margin-top: 25px; - width: 449px; height: 40px; border: 1px solid #ff6a00; font-size: 14px; @@ -244,6 +256,7 @@ #ffba4a 100% ); color: #fff; + border-color: #fff; } } @@ -262,20 +275,6 @@ text-decoration: underline; cursor: pointer; } - } - - .iconSave { - position: absolute; - top: 218px; - left: 150px; - width: 18px; - height: 18px; - font-size: 12px; - color: #fff; - line-height: 18px; - text-align: center; - background: #ff6000; - border-radius: 2px; } } } diff --git a/src/views/index/components/rightRrid.vue b/src/views/index/components/rightRrid.vue index 948068e..d1f064b 100644 --- a/src/views/index/components/rightRrid.vue +++ b/src/views/index/components/rightRrid.vue @@ -1,21 +1,21 @@ <template> <div class="rightRrid"> - <div class="gridItem" v-for="(item, index) in data.product" :key="index"> + <div class="gridItem" v-for="(item, index) in product" :key="index"> <div class="title"> - <img :src="item.icon" alt="" /> - {{ item.title }} + <img :src="'/httpImage/' + item.logoUrl" alt="" /> + {{ item.modelName }} </div> - <div class="des"> - {{ item.des }} + <div class="des limitRow2"> + {{ item.description }} </div> - <price :priceNew="item.priceNew" :priceOld="item.priceOld"></price> + <price :priceNew="item.priceBase"></price> <div class="button">绔嬪嵆璐拱</div> </div> </div> </template> <script> -import price from "@/views/index/components/price"; +import price from "@/components/Price.vue"; export default { props: { @@ -25,6 +25,18 @@ }, components: { price, + }, + data() { + return { + product: [], + }; + }, + created() { + if (this.data.product.length > 6) { + this.product = this.data.product.slice(0, 6); + } else { + this.product = this.data.product; + } }, }; </script> @@ -72,12 +84,13 @@ .des { margin-bottom: 10px; + height: 35px; font-size: 14px; color: #666666; } - .price { - margin-bottom: 10px; + .Price { + margin-bottom: 16px; margin-left: 0; } diff --git a/src/views/index/components/rightTabs.vue b/src/views/index/components/rightTabs.vue index b372f7c..24364d5 100644 --- a/src/views/index/components/rightTabs.vue +++ b/src/views/index/components/rightTabs.vue @@ -230,6 +230,7 @@ &:hover { color: #fff; + border-color: #fff; background: linear-gradient( 90.78deg, #ffba4a 0%, diff --git a/src/views/index/index.vue b/src/views/index/index.vue index 179814f..2c7a273 100644 --- a/src/views/index/index.vue +++ b/src/views/index/index.vue @@ -3,12 +3,21 @@ <!-- 琛ㄥご --> <IndexHeader></IndexHeader> <!-- 杞挱鍥� --> - <Banner ref="Banner"></Banner> + <Banner ref="Banner" :bannerList="bannerList"></Banner> + + <div class="bannerLink" @click="jump"></div> <!-- 杞挱鍥炬帶鍒跺櫒 --> <ul class="bannerControl"> - <li v-for="i in 4" :key="i" @click="toggleBanner(i)"> - <button class="inner" :class="{ active: activeBanner == i }"></button> + <li + v-for="(item, index) in bannerList" + :key="index" + @click="toggleBanner(index + 1)" + > + <button + class="inner" + :class="{ active: activeBanner == index + 1 }" + ></button> </li> </ul> @@ -27,8 +36,8 @@ <div class="tabs"> <div class="tabItem" - :class="{ active: activeCommend === 0 }" - @click="activeCommend = 0" + :class="{ active: activeCommend === 3 }" + @click="selecTab(3)" > <img src="/images/index/绠楁硶.png" alt="" /> <div class="label">绠楁硶</div> @@ -36,8 +45,8 @@ <div class="tabItem" - :class="{ active: activeCommend === 1 }" - @click="activeCommend = 1" + :class="{ active: activeCommend === 4 }" + @click="selecTab(4)" > <img src="/images/index/搴旂敤.png" alt="" /> <div class="label">搴旂敤</div> @@ -46,7 +55,10 @@ </div> <!-- tab鍐呭 --> <div class="commendTabsContent"> - <commendContent :commendData="commendData"></commendContent> + <commendContent + :commendData="commendData" + @refresh="getRecommend" + ></commendContent> </div> <!-- 鐑棬浜у搧 --> @@ -56,16 +68,28 @@ class="productItem" v-for="(item, index) in productData" :key="index" - :class="{ short: item.type == 1 || item.type == 2 }" + :class="{ short: item.typeId == 4 || item.typeId == 1 }" > <productLeft :data="item"></productLeft> - <rightRrid v-if="item.type == 0" :data="item"></rightRrid> - <rightColumn v-if="item.type == 1" :data="item"></rightColumn> - <rightForm v-if="item.type == 2" :data="item"></rightForm> - <rightTabs v-if="item.type == 3" :data="item"></rightTabs> + <rightRrid v-if="item.typeId == 3" :data="item"></rightRrid> + <rightColumn v-if="item.typeId == 4" :data="item"></rightColumn> + <rightForm v-if="item.typeId == 1" :data="item"></rightForm> + <rightTabs v-if="item.typeId == 2" :data="item"></rightTabs> + </div> + + <div + class="productItem" + v-for="(item, index) in productData1" + :key="index" + :class="{ short: item.typeId == 4 || item.typeId == 1 }" + > + <productLeft :data="item"></productLeft> + <rightForm v-if="item.typeId == 1" :data="item"></rightForm> + <rightTabs v-if="item.typeId == 2" :data="item"></rightTabs> </div> </div> - <Connect></Connect> + + <Connect v-if="showConnect"></Connect> <!-- 椤靛熬 --> <Footer></Footer> @@ -86,6 +110,12 @@ import Connect from "@/components/Connect"; import Footer from "@/components/Footer"; +import { + getIndexPics, + getIndexModelRecommend, + getModelList, +} from "@/api/product"; + export default { name: "Index", components: { @@ -102,7 +132,15 @@ Connect, Footer, }, - + created() { + this.getBanner(); + this.getRecommend(); + this.getModule(); + window.addEventListener("scroll", this.scrollListener); + }, + destroyed() { + window.removeEventListener("scroll", this.scrollListener); + }, data() { return { commendCardData: [ @@ -126,140 +164,16 @@ }, ], //鎺ㄨ崘鍗$墖鏁版嵁 activeBanner: 1, //閫変腑鐨刡anner - activeCommend: 0, //閫変腑鐨勬帹鑽恡abs - commendData: [ - { - img: "/images/index/15鎴村彛缃�.png", - title: "鎴村彛缃�", - des: "瀵圭伀杞﹂┚椹惰埍鐨勭洃鎺ц棰戣繘琛屾娴嬶紝褰撻┚椹朵汉鍛樺嚭鐜拌洞浼忕幇璞℃椂锛屽皢缁撴灉璁板綍涓嬫潵", - priceNew: "540.00", - priceOld: "900.00", - }, - { - img: "/images/index/1浠板崸妫�娴�.png", - title: "浠板崸妫�娴�", - des: "瀵圭伀杞﹂┚椹惰埍鐨勭洃鎺ц棰戣繘琛屾娴嬶紝褰撻┚椹朵汉鍛樺嚭鐜拌洞浼忕幇璞℃椂锛屽皢缁撴灉璁板綍涓嬫潵", - priceNew: "540.00", - priceOld: "900.00", - }, - { - img: "/images/index/11婊炵暀.png", - title: "婊炵暀", - des: "瀵圭伀杞﹂┚椹惰埍鐨勭洃鎺ц棰戣繘琛屾娴嬶紝褰撻┚椹朵汉鍛樺嚭鐜拌洞浼忕幇璞℃椂锛屽皢缁撴灉璁板綍涓嬫潵", - priceNew: "540.00", - priceOld: "900.00", - }, - { - img: "/images/index/34璺屽��.png", - title: "璺屽��", - des: "瀵圭伀杞﹂┚椹惰埍鐨勭洃鎺ц棰戣繘琛屾娴嬶紝褰撻┚椹朵汉鍛樺嚭鐜拌洞浼忕幇璞℃椂锛屽皢缁撴灉璁板綍涓嬫潵", - priceNew: "540.00", - priceOld: "900.00", - }, - ], //鎺ㄨ崘tab鐨勬暟鎹� - productData: [ - { - router: "/product", - type: 0, - img: "/images/index/AI鐖嗘.png", - title: "AI鐖嗘", - des: "绮惧績鎸戦�夌殑鐑棬绠楁硶鍙婂簲鐢紝鎬绘湁涓�娆鹃�傚悎浣�", - product: [ - { - icon: "/images/index/20鐫″矖.png", - title: "鐫″矖", - des: "瀵圭伀杞﹂┚椹惰埍鐨勭洃鎺ц棰戣繘琛屾娴嬶紝褰撻┚椹朵汉鍛樺嚭鐜拌洞浼忕幇璞℃椂锛屽皢缁撴灉璁板綍涓嬫潵", - priceNew: "540.00", - priceOld: "900.00", - }, - { - icon: "/images/index/13婊炵暀.png", - title: "婊炵暀", - des: "瀵圭伀杞﹂┚椹惰埍鐨勭洃鎺ц棰戣繘琛屾娴嬶紝褰撻┚椹朵汉鍛樺嚭鐜拌洞浼忕幇璞℃椂锛屽皢缁撴灉璁板綍涓嬫潵", - priceNew: "540.00", - priceOld: "900.00", - }, - { - icon: "/images/index/1浠板崸妫�娴�.png", - title: "浠板崸妫�娴�", - des: "瀵圭伀杞﹂┚椹惰埍鐨勭洃鎺ц棰戣繘琛屾娴嬶紝褰撻┚椹朵汉鍛樺嚭鐜拌洞浼忕幇璞℃椂锛屽皢缁撴灉璁板綍涓嬫潵", - priceNew: "540.00", - priceOld: "900.00", - }, - { - icon: "/images/index/34璺屽��.png", - title: "璺屽��", - des: "瀵圭伀杞﹂┚椹惰埍鐨勭洃鎺ц棰戣繘琛屾娴嬶紝褰撻┚椹朵汉鍛樺嚭鐜拌洞浼忕幇璞℃椂锛屽皢缁撴灉璁板綍涓嬫潵", - priceNew: "540.00", - priceOld: "900.00", - }, - { - icon: "/images/index/15鎴村彛缃�.png", - title: "鎴村彛缃�", - des: "瀵圭伀杞﹂┚椹惰埍鐨勭洃鎺ц棰戣繘琛屾娴嬶紝褰撻┚椹朵汉鍛樺嚭鐜拌洞浼忕幇璞℃椂锛屽皢缁撴灉璁板綍涓嬫潵", - priceNew: "540.00", - priceOld: "900.00", - }, - { - icon: "/images/index/28鐜╂墜鏈�.png", - title: "鐜╂墜鏈�", - des: "瀵圭伀杞﹂┚椹惰埍鐨勭洃鎺ц棰戣繘琛屾娴嬶紝褰撻┚椹朵汉鍛樺嚭鐜拌洞浼忕幇璞℃椂锛屽皢缁撴灉璁板綍涓嬫潵", - priceNew: "540.00", - priceOld: "900.00", - }, - ], - }, - + activeCommend: 3, //閫変腑鐨勬帹鑽恡abs + commendData: [], //鎺ㄨ崘tab鐨勬暟鎹� + productData: [], + productData1: [ { router: "/", - type: 1, - img: "/images/index/绠$悊涓績.png", - title: "绠$悊涓績", - des: "鎬т环姣旇秴楂樼殑绠$悊涓績锛屽垰闇�浜у搧涓�閿喘榻愶紝涓嶄粎鐪侀挶杩樼渷蹇�", - product: [ - { - icon: "/images/index/姣斿搴撶鐞�.png", - title: "姣斿搴撶鐞�", - des: "瀵规墍鏈夎仈缃戠殑璁惧杩涜鍏ㄦ柟浣嶇鐞�", - menu: [ - "鏀寔璁惧鐨勫熀鏈俊鎭�佺‖浠朵俊鎭�佽祫婧愭儏鍐点�佸畨瑁呯殑绠楁硶/搴旂敤绛夊姛鑳界洃绠�", - "鏀寔瀵硅澶囪繘琛岄噸鍚�佺郴缁熸竻鐞嗙瓑鎿嶄綔", - ], - priceNew: "540.00", - priceOld: "900.00", - }, - { - icon: "/images/index/鏁版嵁鎺ㄩ��.png", - title: "鏁版嵁鎺ㄩ��", - des: "瀵规墍鏈夎仈缃戠殑璁惧杩涜鍏ㄦ柟浣嶇鐞�", - menu: [ - "鏀寔璁惧鐨勫熀鏈俊鎭�佺‖浠朵俊鎭�佽祫婧愭儏鍐点�佸畨瑁呯殑绠楁硶/搴旂敤绛夊姛鑳界洃绠�", - "鏀寔瀵硅澶囪繘琛岄噸鍚�佺郴缁熸竻鐞嗙瓑鎿嶄綔", - "鏀寔瀵硅澶囪繘琛岄噸鍚�佺郴缁熸竻鐞嗙瓑鎿嶄綔", - ], - priceNew: "540.00", - priceOld: "900.00", - }, - { - icon: "/images/index/缁熻鏌ヨ.png", - title: "缁熻鏌ヨ", - des: "瀵规墍鏈夎仈缃戠殑璁惧杩涜鍏ㄦ柟浣嶇鐞�", - menu: [ - "鏀寔璁惧鐨勫熀鏈俊鎭�佺‖浠朵俊鎭�佽祫婧愭儏鍐点�佸畨瑁呯殑绠楁硶/搴旂敤绛夊姛鑳界洃绠�", - "鏀寔瀵硅澶囪繘琛岄噸鍚�佺郴缁熸竻鐞嗙瓑鎿嶄綔", - ], - priceNew: "540.00", - priceOld: "900.00", - }, - ], - }, - - { - router: "/", - type: 2, - img: "/images/index/浜戞湇鍔�.png", - title: "浜戞湇鍔�", - des: "涓�閿喘涔帮紝寮�鍚疉I搴旂敤涔嬫梾", + typeId: 1, + pic: "/images/index/浜戞湇鍔�.png", + name: "浜戞湇鍔�", + desc: "涓�閿喘涔帮紝寮�鍚疉I搴旂敤涔嬫梾", product: { title: "AI-0", menu: [ @@ -296,10 +210,10 @@ { router: "/", - type: 3, - img: "/images/index/杈圭紭璁$畻璁惧.png", - title: "杈圭紭璁$畻璁惧", - des: "涓�绉嶉儴缃插湪杩戝満渚х殑楂樺彲鐢ㄧ殑杞‖涓�浣撲骇鍝侊紝鎻愬崌搴旂敤绋嬪簭鐨勫揩閫熷搷搴旇兘鍔涖�佽妭鐪佸甫瀹芥祦閲忔垚鏈�", + typeId: 2, + pic: "/images/index/杈圭紭璁$畻璁惧.png", + name: "杈圭紭璁$畻璁惧", + desc: "涓�绉嶉儴缃插湪杩戝満渚х殑楂樺彲鐢ㄧ殑杞‖涓�浣撲骇鍝侊紝鎻愬崌搴旂敤绋嬪簭鐨勫揩閫熷搷搴旇兘鍔涖�佽妭鐪佸甫瀹芥祦閲忔垚鏈�", product: [ { name: "杈圭紭璁$畻璁惧1", @@ -450,6 +364,8 @@ ], // 鐑棬浜у搧鏁版嵁 timer: null, //鍚戜笂鍥炴粴鍔ㄧ敾 ConnectTimer: null, // 鎺у埗寮瑰眰鐨勫畾鏃跺櫒 + bannerList: [], + showConnect: false, //鏄剧ず鑱旂郴鎴戜滑涓庡洖鍒伴《閮� }; }, methods: { @@ -457,6 +373,46 @@ toggleBanner(i) { this.activeBanner = i; this.$refs["Banner"].toggleBanner(i); + }, + //鑾峰彇杞挱鍥� + async getBanner() { + const res = await getIndexPics(); + if (res.success) { + this.bannerList = res.data.lists; + } + }, + //杞挱鍥捐烦杞繛鎺� + jump() { + window.open(this.bannerList[this.activeBanner - 1].url); + }, + //鑾峰彇鎺ㄨ崘鍒楄〃 + async getRecommend() { + const res = await getIndexModelRecommend({ typeId: this.activeCommend }); + this.commendData = res.data.productList; + }, + // 鑾峰彇浜у搧鍒楄〃 + async getModule() { + const res = await getModelList(); + if (res && res.success) { + this.productData = res.data.modelList; + } + }, + //閫夋嫨鎺ㄨ崘tab + selecTab(id) { + this.activeCommend = id; + this.getRecommend(); + }, + //娣诲姞婊氬姩鐩戝惉 + scrollListener() { + //椤甸潰婊戝姩瑙﹀彂浜嬩欢 (婊氬姩鏉$Щ鍔ㄥ垯璋冪敤鏄惁鏄剧ず杩斿洖椤堕儴鎸夐挳浜嬩欢) + + if (document.documentElement.scrollTop < 1100) { + this.showConnect = false; + } else { + this.showConnect = true; + } + + //妫�鏌ユ粴鍔ㄦ潯鏄惁鍦ㄩ《閮紝鎺у埗杩斿洖椤堕儴鎸夐挳鐨勯殣钘忓拰鏄剧ず }, }, }; @@ -505,6 +461,14 @@ } } + .bannerLink { + top: 60px; + position: absolute; + width: 100%; + height: 410px; + cursor: pointer; + } + .overCard { position: absolute; top: 394px; diff --git a/src/views/manageCenter/index.vue b/src/views/manageCenter/index.vue index 8b5b91a..88843ea 100644 --- a/src/views/manageCenter/index.vue +++ b/src/views/manageCenter/index.vue @@ -19,11 +19,10 @@ class="productItem" v-for="(item, index) in productList" :key="index" + @click="jump(item.path)" > - <router-link :to="item.path"> - <img :src="item.icon" alt="" /> - <div class="name">{{ item.name }}</div> - </router-link> + <img :src="item.icon" alt="" /> + <div class="name">{{ item.name }}</div> </div> </div> </div> @@ -852,6 +851,9 @@ let myChart = echarts.init(pieDom); myChart.setOption(this.pieOption); }, + jump(path) { + this.$router.push(path); + }, refrash() {}, handleSizeChange() {}, }, diff --git a/src/views/product/components/ProductContent.vue b/src/views/product/components/ProductContent.vue index 193763d..cbf0428 100644 --- a/src/views/product/components/ProductContent.vue +++ b/src/views/product/components/ProductContent.vue @@ -13,9 +13,9 @@ size="mini" v-for="(item, index) in types" :key="index + 't'" - :class="productLabelId == item.id ? 'selected' : ''" + :class="productLabelId == item.productType ? 'selected' : ''" class="type-label" - @click="selectType(item.id)" + @click="selectType(item.productType)" >{{ item.name }}</el-button > </div> @@ -59,7 +59,7 @@ :data="item" v-for="(item, index) in dataList" :key="index" - :labels="getLabel(item.productLabelId)" + :labels="getLabel(item.productType)" > </productCard> </div> @@ -76,15 +76,7 @@ </template> <script> -import { - findAllCenterProduct, - findDicByType, - // getReleaseProduct, -} from "@/api/product"; -// import { activeByCode, showDetail } from "../api/code"; -// import { findDevListByUser } from "../api/device"; -// import { addShopcartProd, resumeOrder } from "../api/shopcart"; -// import request from "../api/index"; +import { findAllCenterProduct, findDicByType } from "@/api/product"; import productCard from "@/views/product/components/productCard"; export default { mounted() { @@ -106,7 +98,7 @@ { id: "bitmain", name: "bitmain" }, ], targetPlatformId: "all", - productLabelId: "", + productLabelId: 0, elvChip: "all", size: 12, publishStatus: 1, @@ -121,27 +113,14 @@ }, methods: { getDic() { - findDicByType() - .then((res) => { - let dics = res.data.dics.filter( - (item) => item.type === "PRODUCTLABEL" - ); - this.types = dics; - this.types.unshift({ - id: "", - name: "鍏ㄩ儴", - }); - this.labelDics = res.data.dics; - }) - .catch((err) => { - console.log(err); - this.$notify({ - type: "error", - message: "鏍囩鑾峰彇澶辫触", - duration: 2500, - offset: 57, - }); + findDicByType().then((res) => { + this.types = res.data.list; + this.types.unshift({ + productType: 0, + name: "鍏ㄩ儴", }); + this.labelDics = res.data.list; + }); }, selectType(id) { this.productLabelId = id; @@ -156,7 +135,6 @@ this.getProductList(); }, getProductList(v) { - console.log("--------------"); let param = { page: v === 1 ? 1 : this.page, size: this.size, @@ -164,7 +142,7 @@ archType: this.targetPlatformId == "all" ? "" : this.targetPlatformId, gpuType: this.elvChip == "all" ? "" : this.elvChip, publishStatus: this.publishStatus, - productLabelId: this.productLabelId, + productType: this.productLabelId, }; findAllCenterProduct(param) .then((res) => { @@ -189,14 +167,12 @@ }); }); }, - getLabel(ids) { + getLabel(id) { let arr = []; - ids.forEach((id) => { - let obj = this.labelDics.filter((item) => item.id == id); - if (obj.length > 0) { - arr.push(obj[0].name); - } - }); + let obj = this.labelDics.filter((item) => item.productType == id); + if (obj.length > 0) { + arr.push(obj[0].name); + } return arr; }, refresh(page) { diff --git a/src/views/product/components/productCard.vue b/src/views/product/components/productCard.vue index 9f2a1aa..8a4aa2f 100644 --- a/src/views/product/components/productCard.vue +++ b/src/views/product/components/productCard.vue @@ -40,7 +40,7 @@ this.$router.push({ path: "/productDetail", query: { - name: this.data.productName, + id: this.data.id, }, }); }, diff --git a/src/views/productDetail/components/ConfirmOrder.vue b/src/views/productDetail/components/ConfirmOrder.vue index 9378241..33045aa 100644 --- a/src/views/productDetail/components/ConfirmOrder.vue +++ b/src/views/productDetail/components/ConfirmOrder.vue @@ -182,15 +182,40 @@ </div> </div> </el-dialog> + + <div class="offerpay" v-if="showOffpayInstruct || showUploadBox"> + <OffpayInstruct + v-if="showOffpayInstruct" + @close="showOffpayInstruct = false" + :offerData="{ username: username, sum: sum, orderId: orderId }" + @confirm="confirmOrder" + ></OffpayInstruct> + <UploadBox + :orderId="orderId" + @close="showUploadBox = false" + @back="back" + v-if="showUploadBox" + > + </UploadBox> + </div> + + <div class="mask" v-if="showOffpayInstruct || showUploadBox"></div> </div> </template> <script> import { getOrderById } from "@/api/product"; import { resumePay } from "@/api/order"; +import OffpayInstruct from "@/views/productDetail/components/OffpayInstruct"; +import UploadBox from "@/views/productDetail/components/UploadBox"; + export default { props: { orderId: {}, + }, + components: { + OffpayInstruct, + UploadBox, }, data() { return { @@ -202,6 +227,8 @@ username: "", offPayInstruVisible: false, onlinePayVisible: false, + showOffpayInstruct: false, + showUploadBox: false, }; }, computed: { @@ -232,13 +259,20 @@ this.payWay = payway; }, forPay() { + if (!this.policyChecked) { + this.$notify({ + type: "error", + message: "璇风‘璁ょ敤鎴锋潯娆�", + }); + return; + } let orderId = this.orderId; let payMethod = this.payWay; let _this = this; if (this.orderInfo.orderMoney == 0) { resumePay({ orderId, payMethod: 5 }).then((res) => { if (res.success) { - this.$router.replace("/Layout/ManageOrder"); + // this.$router.replace("/Layout/ManageOrder"); } }); return; @@ -255,7 +289,7 @@ resumePay({ orderId, payMethod: 1 }) .then((res) => { if (res.success) { - this.offPayInstruVisible = true; + this.showOffpayInstruct = true; } }) .catch((e) => { @@ -278,6 +312,14 @@ }, close() { this.$emit("close"); + }, + confirmOrder() { + this.showOffpayInstruct = false; + this.showUploadBox = true; + }, + back() { + this.showOffpayInstruct = true; + this.showUploadBox = false; }, }, }; @@ -399,6 +441,54 @@ } } } + + .btns { + position: absolute; + right: 20px; + bottom: 20px; + display: flex; + justify-content: end; + text-align: center; + line-height: 40px; + + .confirm { + margin-left: 10px; + width: 104px; + height: 40px; + background: #0065ff; + color: #fff; + } + + .cancel { + width: 104px; + height: 40px; + border: 1px solid #0065ff; + color: #0065ff; + } + } + + .offerpay { + position: fixed; + top: 50%; + left: 50%; + margin-top: -331px; + margin-left: -223px; + width: 446px; + height: 662px; + background: #ffffff; + z-index: 2; + } + + .mask { + position: fixed; + top: 0; + left: 0; + right: 0; + bottom: 0; + background: #000000; + opacity: 0.2; + z-index: 1; + } } </style> diff --git a/src/views/productDetail/components/OffpayInstruct.vue b/src/views/productDetail/components/OffpayInstruct.vue new file mode 100644 index 0000000..8584905 --- /dev/null +++ b/src/views/productDetail/components/OffpayInstruct.vue @@ -0,0 +1,165 @@ +<template> + <div class="OffpayInstruct"> + <div class="title">绾夸笅姹囨璇存槑</div> + <div class="close iconfont" @click="close"></div> + <el-tooltip placement="left"> + <div slot="content"> + 璇存槑锛�<br /> + 路鐐瑰嚮鍏抽棴鎸夐挳锛屽叧闂淇℃伅寮圭獥锛屽湪纭<br />璁㈠崟椤甸潰鍙互閫夋嫨鍏朵粬浠樻鏂瑰紡缁х画浠樻锛�<br /> + 路濡傛灉涓嶉�夋嫨鍏朵粬浠樻鏂瑰紡锛屽叧闂‘璁よ鍗�<br />椤甸潰锛屽湪鎴戠殑璁㈠崟涓彲浠ョ湅鍒版璁㈠崟鐘舵�佷负<br />鈥滄湭浠樻鈥濓紝鏀粯鏂瑰紡涓衡�滄眹娆锯�濓紱<br /> + 路濡傛灉閲嶆柊閫夋嫨浜嗘敮浠樺疂锛屽垯璁㈠崟涓殑鏀粯<br />鏂瑰紡鏇存柊涓烘敮浠樺疂銆� + </div> + <div class="tip iconfont"></div> + </el-tooltip> + <div class="content"> + <p>璇峰皢娆鹃」姹囧叆浠ヤ笅閾惰璐︽埛</p> + <div class="info"> + <div class="itfoRow"> + <div class="label">寮�鎴烽摱琛岋細</div> + <div class="data">鍖椾含閾惰澶槼瀹敮琛�</div> + </div> + <div class="itfoRow"> + <div class="label">璐︽埛锛�</div> + <div class="data">2000 0031 2025 0000 9136 746</div> + </div> + <div class="itfoRow"> + <div class="label">寮�鎴疯琛屽彿锛�</div> + <div class="data">3131 0000 1792</div> + </div> + <div class="itfoRow"> + <div class="label">娆鹃」锛�</div> + <div class="data">鍖椾含閾惰澶槼瀹敮琛�</div> + </div> + </div> + <div class="userInfo">鎮ㄧ殑鐧诲綍鐢ㄦ埛鍚嶏細{{ offerData.username }}</div> + <div class="userInfo">鎮ㄧ殑璁㈠崟鍙凤細{{ offerData.orderId }}</div> + + <div class="des"> + <div class="label">娉ㄦ剰浜嬮」锛�</div> + <div>1.璇峰湪杞处鏄姟蹇呮彁渚涚敤鎴峰悕鍜岃鍗曠紪鍙凤紱</div> + <div> + 2.杞处鍚庯紝璇峰姟蹇呯偣鍑烩�滀笂浼犲嚟璇佲�濇寜閽彁浜よ浆璐︿俊鎭紝浠ヤ究璐㈠姟纭锛岃储鍔$‘ + 璁ゆ椂闂翠负鎻愪氦鍚庨1~3涓伐浣滄棩锛� + </div> + <div>3.鎮ㄥ彲浠ュ湪鈥滄垜鐨勮鍗曗�濈偣鍑汇�愭彁浜や粯娆惧嚟璇併�戯紝鏌ョ湅鏈〉涓殑鍐呭</div> + </div> + </div> + <div class="btns"> + <div class="button cancel" @click="close">鍙栨秷</div> + <div class="button confirm" @click="confirm">涓婁紶鍑瘉</div> + </div> + </div> +</template> + +<script> +export default { + props: { + offerData: {}, + }, + methods: { + close() { + this.$emit("close"); + }, + confirm() { + this.$emit("confirm"); + }, + }, +}; +</script> + +<style lang="scss" scoped > +.OffpayInstruct { + .title { + box-sizing: border-box; + padding: 20px; + height: 64px; + border-bottom: 1px solid #e9ebee; + font-size: 18px; + font-weight: 700; + } + + .close { + position: absolute; + top: 20px; + right: 20px; + font-size: 16px; + color: #666; + cursor: pointer; + } + + .tip { + position: absolute; + top: 20px; + right: 40px; + font-size: 16px; + color: #dbdbdb; + cursor: pointer; + } + + .content { + box-sizing: border-box; + padding: 30px 20px 20px 20px; + font-size: 14px; + + p { + font-size: 16px; + margin-bottom: 16px; + } + + .info { + box-sizing: border-box; + margin-bottom: 16px; + padding: 20px 20px 4px 20px; + background: #f3f3f3; + + .itfoRow { + display: flex; + margin-bottom: 16px; + + .label { + width: 108px; + color: #666666; + } + } + } + + .userInfo { + margin-top: 8px; + } + + .des { + margin-top: 30px; + padding: 30px 0; + color: #ff4a32; + line-height: 20px; + border-top: 1px solid #e9ebee; + border-bottom: 1px solid #e9ebee; + } + } + + .btns { + position: absolute; + right: 20px; + bottom: 20px; + display: flex; + justify-content: end; + text-align: center; + line-height: 40px; + + .confirm { + margin-left: 10px; + width: 112px; + height: 40px; + background: #0065ff; + color: #fff; + } + + .cancel { + width: 80px; + height: 40px; + border: 1px solid #0065ff; + color: #0065ff; + } + } +} +</style> \ No newline at end of file diff --git a/src/views/productDetail/components/PayCard.vue b/src/views/productDetail/components/PayCard.vue index 2569d6d..62b90e0 100644 --- a/src/views/productDetail/components/PayCard.vue +++ b/src/views/productDetail/components/PayCard.vue @@ -143,16 +143,6 @@ > <div class="label">鎺堟潈鏁伴噺</div> <el-input-number - v-model="cartItem.chCount" - @change="handleChangeCh" - :disabled="!data.hasChUnitPrice" - size="small" - :min="1" - :max="16" - label="鎻忚堪鏂囧瓧" - ></el-input-number> - <span class="desText">鏈�澶ф敮鎸�16璺�</span> - <el-input-number v-model="cartItem.authCount" @change="handleChangeAuth" :disabled="!data.hasAuthPrice" diff --git a/src/views/productDetail/components/UploadBox.vue b/src/views/productDetail/components/UploadBox.vue new file mode 100644 index 0000000..ffa5aa2 --- /dev/null +++ b/src/views/productDetail/components/UploadBox.vue @@ -0,0 +1,349 @@ +<template> + <div class="UploadBox"> + <div class="title">绾夸笅姹囨璇存槑</div> + <div class="close iconfont" @click="close"></div> + <div class="content"> + <el-form + :model="certificateForm" + ref="certificateForm" + label-width="118px" + > + <div + v-for="(item, index) in certificateForm.list" + :key="index" + class="form-area" + > + <div class="text-right" v-if="index != 0"> + <div class="devide-dash"></div> + <el-button class="btn-remove" @click="removeItem(index)" + >鍒犻櫎姝や粯娆句俊鎭�</el-button + > + </div> + <el-form-item + label="浠樻鍗曚綅/濮撳悕" + :prop="`list[${index}].payUser`" + :rules="[ + { + required: true, + message: '璇疯緭鍏ヤ粯娆惧崟浣�/濮撳悕', + trigger: 'blur', + }, + ]" + > + <el-input class="h32" v-model="item.payUser"></el-input> + </el-form-item> + <el-form-item + label="浠樻璐﹀彿" + :prop="`list[${index}].payAccount`" + :rules="[ + { required: true, message: '璇疯緭鍏ヤ粯娆捐处鍙�', trigger: 'blur' }, + ]" + > + <el-input class="h32" v-model="item.payAccount"></el-input> + </el-form-item> + <el-form-item + label="浠樻閲戦(鍏�)" + :prop="`list[${index}].payMoney`" + :rules="[ + { required: true, message: '璇疯緭鍏ヤ粯娆鹃噾棰�', trigger: 'blur' }, + { + type: 'number', + min: 0, + message: '璇疯緭鍏ュぇ浜庨浂鐨勬暟瀛�', + trigger: 'blur', + }, + ]" + > + <el-input class="h32" v-model.number="item.payMoney"> + <!-- <template slot="append">鍏�</template> --> + </el-input> + </el-form-item> + <el-form-item label="澶囨敞" prop="reserved"> + <el-input type="textarea" v-model="item.reserved"></el-input> + </el-form-item> + <el-form-item label="浠樻鍑瘉" prop="pic"> + <el-upload + class="upload-demo" + drag + action="https://jsonplaceholder.typicode.com/posts/" + :http-request="(param) => definedUpload(param, index)" + :show-file-list="false" + > + <el-image + class="preview" + v-if="item.appendix" + :src="`/httpImage/${item.appendix}`" + fit="contain" + ></el-image> + <div class="el-upload__text"> + <i class="el-icon-plus"></i> + <span class="words"> + <em>鐐瑰嚮涓婁紶</em> + </span> + </div> + </el-upload> + <i + class="el-icon-error remove" + v-if="item.appendix" + @click="item.appendix = ''" + ></i> + </el-form-item> + <!-- <div class="text-left" v-if="index!=0"> + <el-button + icon="el-icon-remove" + type="text" + style="color:#f90;" + @click="removeItem(index)" + >绉婚櫎</el-button> + </div>--> + </div> + <el-button class="btn-add" @click="addPayInfo">娣诲姞浠樻淇℃伅</el-button> + </el-form> + + <div class="btns"> + <div class="button cancel" @click="back">鍙栨秷</div> + <div class="button confirm" @click="saveCertificate">涓婁紶鍑瘉</div> + </div> + </div> + </div> +</template> + +<script> +import { saveOrderCertificate } from "@/api/order"; +import request from "@/scripts/httpRequest"; + +export default { + props: { + offerId: {}, + }, + mounted() { + this.certificateForm.orderId = this.offerId; + }, + data() { + return { + certificateForm: { + orderId: "", + list: [ + { + id: "", + payUser: "", + payAccount: "", + payMoney: "", + reserved: "", + appendix: "", + }, + ], + }, + certificateRule: { + payUser: [ + { required: true, message: "璇疯緭鍏ヤ粯娆惧崟浣�/濮撳悕", trigger: "blur" }, + ], + payAccount: [ + { required: true, message: "璇疯緭鍏ヤ粯娆捐处鍙�", trigger: "blur" }, + ], + payMoney: [ + { required: true, message: "璇疯緭鍏ヤ粯娆鹃噾棰�", trigger: "blur" }, + ], + }, + }; + }, + methods: { + close() { + this.$emit("close"); + }, + back() { + this.$emit("back"); + }, + removeItem(index) { + this.certificateForm.list.splice(index, 1); + }, + definedUpload(param, index) { + let _this = this; + const fd = new FormData(); + fd.append("file", param.file); + request({ + method: "post", + url: `/data/api-s/file/upload`, + data: fd, + }) + .then((res) => { + _this.certificateForm.list[index].appendix = res.data.picUrl; + }) + .catch((err) => { + this.$notify({ + type: "error", + message: "涓婁紶澶辫触", + duration: 2500, + offset: 57, + }); + }); + }, + saveCertificate() { + this.$refs["certificateForm"].validate((valid) => { + if (valid) { + //鏍¢獙鎴愬姛鎻愪氦鍑瘉 + saveOrderCertificate(this.certificateForm) + .then((res) => { + if (res.success) { + this.$notify({ + type: "success", + message: "淇濆瓨鎴愬姛", + duration: 2500, + offset: 57, + }); + this.certificateSubmitVisible = false; + this.close(); + } + }) + .catch((e) => { + this.$notify({ + type: "error", + message: "淇濆瓨澶辫触,璇风◢鍚庨噸璇�", + duration: 2500, + offset: 57, + }); + }); + } else { + return false; + } + }); + }, + addPayInfo(e) { + this.certificateForm.list.push(this.newPayInfo()); + }, + newPayInfo() { + return { + id: "", + payUser: "", + payAccount: "", + payMoney: "", + reserved: "", + appendix: "", + }; + }, + }, +}; +</script> + +<style lang="scss" scoped > +.UploadBox { + .title { + box-sizing: border-box; + padding: 20px; + height: 64px; + border-bottom: 1px solid #e9ebee; + font-size: 18px; + font-weight: 700; + } + + .close { + position: absolute; + top: 20px; + right: 20px; + font-size: 16px; + color: #666; + cursor: pointer; + } + + .tip { + position: absolute; + top: 20px; + right: 40px; + font-size: 16px; + color: #dbdbdb; + cursor: pointer; + } + + .content { + box-sizing: border-box; + padding: 30px 20px 20px 20px; + font-size: 14px; + } + + .btns { + position: absolute; + right: 20px; + bottom: 20px; + display: flex; + justify-content: end; + text-align: center; + line-height: 40px; + + .confirm { + margin-left: 10px; + width: 112px; + height: 40px; + background: #0065ff; + color: #fff; + } + + .cancel { + width: 80px; + height: 40px; + border: 1px solid #0065ff; + color: #0065ff; + } + } + + .h32 { + height: 32px; + line-height: 32px; + + ::v-deep input { + height: 32px; + } + + .el-icon-arrow-up { + line-height: 32px; + } + + ::v-deep .el-icon-arrow-up { + height: 32px; + } + } + + .btn-add { + margin-left: 120px; + width: 88px; + height: 24px; + border-radius: 3px; + background: #0064ff; + color: #fff; + padding: 3px 8px; + font-size: 12px; + } +} +</style> + +<style lang="scss"> +.el-upload-dragger { + width: 120px; + height: 120px; + border: 1px dashed #c0c5cc !important; + border-radius: 3px; + background: #e9ebee; + .el-upload__text { + margin-top: 35px; + display: flex; + flex-direction: column; + i { + font-size: 28px; + margin-bottom: 10px; + } + .words { + margin: 0 auto; + width: 84px; + height: 34px; + font-size: 12px; + font-family: PingFangSC-Regular, PingFang SC; + font-weight: 400; + color: #888888; + line-height: 17px; + } + + em { + color: #999; + } + } +} +</style> \ No newline at end of file diff --git a/src/views/productDetail/index.vue b/src/views/productDetail/index.vue index 29d8c2f..3706282 100644 --- a/src/views/productDetail/index.vue +++ b/src/views/productDetail/index.vue @@ -51,11 +51,12 @@ let param = { page: 1, size: 1, - inputText: this.$route.query.name, + inputText: "", + id: this.$route.query.id, archType: "", gpuType: "", publishStatus: 1, - productLabelId: "", + productType: 0, }; findAllCenterProduct(param) .then((res) => { diff --git a/src/views/register/components/ResetPassword.vue b/src/views/register/components/ResetPassword.vue index 372ef35..ffcab2b 100644 --- a/src/views/register/components/ResetPassword.vue +++ b/src/views/register/components/ResetPassword.vue @@ -90,7 +90,7 @@ </template> <script> -import { getVerifyCode } from "@/api/login"; +import { getVerifyCode, forgetPwd } from "@/api/login"; import { isPhone, validPassword } from "@/scripts/validate"; // 姝e垯鏂囦欢 export default { @@ -181,7 +181,17 @@ } }); }, - submit() { + async submit() { + const res = await forgetPwd({ + phoneNum: this.formData.phoneNum, + newPwd: this.formData.password, + }); + if (res && res.success) { + this.$notify({ + type: "success", + message: "閲嶇疆鎴愬姛", + }); + } this.isReseted = true; }, }, diff --git a/src/views/search/components/giantTree/zTree/ztree_v3/jquery.ztree.all.js b/src/views/search/components/giantTree/zTree/ztree_v3/jquery.ztree.all.js index dee4cce..a5e1ff8 100644 --- a/src/views/search/components/giantTree/zTree/ztree_v3/jquery.ztree.all.js +++ b/src/views/search/components/giantTree/zTree/ztree_v3/jquery.ztree.all.js @@ -11,8 +11,10 @@ * Date: 2020-11-21 */ -(function ($) { - var settings = {}, roots = {}, caches = {}, +(function($) { + var settings = {}, + roots = {}, + caches = {}, //default consts of core _consts = { className: { @@ -20,7 +22,7 @@ LEVEL: "level", ICO_LOADING: "ico_loading", SWITCH: "switch", - NAME: 'node_name' + NAME: "node_name", }, event: { NODECREATED: "ztree_nodeCreated", @@ -31,14 +33,14 @@ ASYNC_ERROR: "ztree_async_error", REMOVE: "ztree_remove", SELECTED: "ztree_selected", - UNSELECTED: "ztree_unselected" + UNSELECTED: "ztree_unselected", }, id: { A: "_a", ICON: "_ico", SPAN: "_span", SWITCH: "_switch", - UL: "_ul" + UL: "_ul", }, line: { ROOT: "root", @@ -46,16 +48,16 @@ CENTER: "center", BOTTOM: "bottom", NOLINE: "noline", - LINE: "line" + LINE: "line", }, folder: { OPEN: "open", CLOSE: "close", - DOCU: "docu" + DOCU: "docu", }, node: { - CURSELECTED: "curSelectedNode" - } + CURSELECTED: "curSelectedNode", + }, }, //default setting of core _setting = { @@ -73,7 +75,7 @@ showIcon: true, showLine: true, showTitle: true, - txtSelectedEnable: false + txtSelectedEnable: false, }, data: { key: { @@ -82,7 +84,7 @@ name: "name", title: "", url: "url", - icon: "icon" + icon: "icon", }, render: { name: null, @@ -92,12 +94,12 @@ enable: false, idKey: "id", pIdKey: "pId", - rootPId: null + rootPId: null, }, keep: { parent: false, - leaf: false - } + leaf: false, + }, }, async: { enable: false, @@ -109,7 +111,7 @@ url: "", autoParam: [], otherParam: [], - dataFilter: null + dataFilter: null, }, callback: { beforeAsync: null, @@ -132,12 +134,12 @@ onMouseUp: null, onExpand: null, onCollapse: null, - onRemove: null - } + onRemove: null, + }, }, //default root of core //zTree use root to save full data - _initRoot = function (setting) { + _initRoot = function(setting) { var r = data.getRoot(setting); if (!r) { r = {}; @@ -149,10 +151,10 @@ r.noSelection = true; r.createdNodes = []; r.zId = 0; - r._ver = (new Date()).getTime(); + r._ver = new Date().getTime(); }, //default cache of core - _initCache = function (setting) { + _initCache = function(setting) { var c = data.getCache(setting); if (!c) { c = {}; @@ -162,45 +164,69 @@ c.doms = []; }, //default bindEvent of core - _bindEvent = function (setting) { + _bindEvent = function(setting) { var o = setting.treeObj, c = consts.event; - o.bind(c.NODECREATED, function (event, treeId, node) { + o.bind(c.NODECREATED, function(event, treeId, node) { tools.apply(setting.callback.onNodeCreated, [event, treeId, node]); }); - o.bind(c.CLICK, function (event, srcEvent, treeId, node, clickFlag) { - tools.apply(setting.callback.onClick, [srcEvent, treeId, node, clickFlag]); + o.bind(c.CLICK, function(event, srcEvent, treeId, node, clickFlag) { + tools.apply(setting.callback.onClick, [ + srcEvent, + treeId, + node, + clickFlag, + ]); }); - o.bind(c.EXPAND, function (event, treeId, node) { + o.bind(c.EXPAND, function(event, treeId, node) { tools.apply(setting.callback.onExpand, [event, treeId, node]); }); - o.bind(c.COLLAPSE, function (event, treeId, node) { + o.bind(c.COLLAPSE, function(event, treeId, node) { tools.apply(setting.callback.onCollapse, [event, treeId, node]); }); - o.bind(c.ASYNC_SUCCESS, function (event, treeId, node, msg) { - tools.apply(setting.callback.onAsyncSuccess, [event, treeId, node, msg]); + o.bind(c.ASYNC_SUCCESS, function(event, treeId, node, msg) { + tools.apply(setting.callback.onAsyncSuccess, [ + event, + treeId, + node, + msg, + ]); }); - o.bind(c.ASYNC_ERROR, function (event, treeId, node, XMLHttpRequest, textStatus, errorThrown) { - tools.apply(setting.callback.onAsyncError, [event, treeId, node, XMLHttpRequest, textStatus, errorThrown]); + o.bind(c.ASYNC_ERROR, function( + event, + treeId, + node, + XMLHttpRequest, + textStatus, + errorThrown + ) { + tools.apply(setting.callback.onAsyncError, [ + event, + treeId, + node, + XMLHttpRequest, + textStatus, + errorThrown, + ]); }); - o.bind(c.REMOVE, function (event, treeId, treeNode) { + o.bind(c.REMOVE, function(event, treeId, treeNode) { tools.apply(setting.callback.onRemove, [event, treeId, treeNode]); }); - o.bind(c.SELECTED, function (event, treeId, node) { + o.bind(c.SELECTED, function(event, treeId, node) { tools.apply(setting.callback.onSelected, [treeId, node]); }); - o.bind(c.UNSELECTED, function (event, treeId, node) { + o.bind(c.UNSELECTED, function(event, treeId, node) { tools.apply(setting.callback.onUnSelected, [treeId, node]); }); }, - _unbindEvent = function (setting) { + _unbindEvent = function(setting) { var o = setting.treeObj, c = consts.event; o.unbind(c.NODECREATED) @@ -214,12 +240,15 @@ .unbind(c.UNSELECTED); }, //default event proxy of core - _eventProxy = function (event) { + _eventProxy = function(event) { var target = event.target, setting = data.getSetting(event.data.treeId), - tId = "", node = null, - nodeEventType = "", treeEventType = "", - nodeEventCallback = null, treeEventCallback = null, + tId = "", + node = null, + nodeEventType = "", + treeEventType = "", + nodeEventCallback = null, + treeEventCallback = null, tmp = null; if (tools.eqs(event.type, "mousedown")) { @@ -229,11 +258,16 @@ } else if (tools.eqs(event.type, "contextmenu")) { treeEventType = "contextmenu"; } else if (tools.eqs(event.type, "click")) { - if (tools.eqs(target.tagName, "span") && target.getAttribute("treeNode" + consts.id.SWITCH) !== null) { + if ( + tools.eqs(target.tagName, "span") && + target.getAttribute("treeNode" + consts.id.SWITCH) !== null + ) { tId = tools.getNodeMainDom(target).id; nodeEventType = "switchNode"; } else { - tmp = tools.getMDom(setting, target, [{ tagName: "a", attrName: "treeNode" + consts.id.A }]); + tmp = tools.getMDom(setting, target, [ + { tagName: "a", attrName: "treeNode" + consts.id.A }, + ]); if (tmp) { tId = tools.getNodeMainDom(tmp).id; nodeEventType = "clickNode"; @@ -241,14 +275,18 @@ } } else if (tools.eqs(event.type, "dblclick")) { treeEventType = "dblclick"; - tmp = tools.getMDom(setting, target, [{ tagName: "a", attrName: "treeNode" + consts.id.A }]); + tmp = tools.getMDom(setting, target, [ + { tagName: "a", attrName: "treeNode" + consts.id.A }, + ]); if (tmp) { tId = tools.getNodeMainDom(tmp).id; nodeEventType = "switchNode"; } } if (treeEventType.length > 0 && tId.length == 0) { - tmp = tools.getMDom(setting, target, [{ tagName: "a", attrName: "treeNode" + consts.id.A }]); + tmp = tools.getMDom(setting, target, [ + { tagName: "a", attrName: "treeNode" + consts.id.A }, + ]); if (tmp) { tId = tools.getNodeMainDom(tmp).id; } @@ -261,8 +299,15 @@ var isParent = data.nodeIsParent(setting, node); if (!isParent) { nodeEventType = ""; - } else if (tools.eqs(event.type, "click") - || (tools.eqs(event.type, "dblclick") && tools.apply(setting.view.dblClickExpand, [setting.treeId, node], setting.view.dblClickExpand))) { + } else if ( + tools.eqs(event.type, "click") || + (tools.eqs(event.type, "dblclick") && + tools.apply( + setting.view.dblClickExpand, + [setting.treeId, node], + setting.view.dblClickExpand + )) + ) { nodeEventCallback = handler.onSwitchNode; } else { nodeEventType = ""; @@ -294,43 +339,51 @@ nodeEventType: nodeEventType, nodeEventCallback: nodeEventCallback, treeEventType: treeEventType, - treeEventCallback: treeEventCallback + treeEventCallback: treeEventCallback, }; - return proxyResult + return proxyResult; }, //default init node of core - _initNode = function (setting, level, n, parentNode, isFirstNode, isLastNode, openFlag) { + _initNode = function( + setting, + level, + n, + parentNode, + isFirstNode, + isLastNode, + openFlag + ) { if (!n) return; var r = data.getRoot(setting), children = data.nodeChildren(setting, n); n.level = level; - n.tId = setting.treeId + "_" + (++r.zId); + n.tId = setting.treeId + "_" + ++r.zId; n.parentTId = parentNode ? parentNode.tId : null; - n.open = (typeof n.open == "string") ? tools.eqs(n.open, "true") : !!n.open; + n.open = typeof n.open == "string" ? tools.eqs(n.open, "true") : !!n.open; var isParent = data.nodeIsParent(setting, n); if (tools.isArray(children)) { data.nodeIsParent(setting, n, true); n.zAsync = true; } else { isParent = data.nodeIsParent(setting, n, isParent); - n.open = (isParent && !setting.async.enable) ? n.open : false; + n.open = isParent && !setting.async.enable ? n.open : false; n.zAsync = !isParent; } n.isFirstNode = isFirstNode; n.isLastNode = isLastNode; - n.getParentNode = function () { + n.getParentNode = function() { return data.getNodeCache(setting, n.parentTId); }; - n.getPreNode = function () { + n.getPreNode = function() { return data.getPreNode(setting, n); }; - n.getNextNode = function () { + n.getNextNode = function() { return data.getNextNode(setting, n); }; - n.getIndex = function () { + n.getIndex = function() { return data.getNodeIndex(setting, n); }; - n.getPath = function () { + n.getPath = function() { return data.getNodePath(setting, n); }; n.isAjaxing = false; @@ -347,52 +400,53 @@ afterA: [], innerBeforeA: [], innerAfterA: [], - zTreeTools: [] + zTreeTools: [], }, //method of operate data data = { - addNodeCache: function (setting, node) { + addNodeCache: function(setting, node) { data.getCache(setting).nodes[data.getNodeCacheId(node.tId)] = node; }, - getNodeCacheId: function (tId) { + getNodeCacheId: function(tId) { return tId.substring(tId.lastIndexOf("_") + 1); }, - addAfterA: function (afterA) { + addAfterA: function(afterA) { _init.afterA.push(afterA); }, - addBeforeA: function (beforeA) { + addBeforeA: function(beforeA) { _init.beforeA.push(beforeA); }, - addInnerAfterA: function (innerAfterA) { + addInnerAfterA: function(innerAfterA) { _init.innerAfterA.push(innerAfterA); }, - addInnerBeforeA: function (innerBeforeA) { + addInnerBeforeA: function(innerBeforeA) { _init.innerBeforeA.push(innerBeforeA); }, - addInitBind: function (bindEvent) { + addInitBind: function(bindEvent) { _init.bind.push(bindEvent); }, - addInitUnBind: function (unbindEvent) { + addInitUnBind: function(unbindEvent) { _init.unbind.push(unbindEvent); }, - addInitCache: function (initCache) { + addInitCache: function(initCache) { _init.caches.push(initCache); }, - addInitNode: function (initNode) { + addInitNode: function(initNode) { _init.nodes.push(initNode); }, - addInitProxy: function (initProxy, isFirst) { + addInitProxy: function(initProxy, isFirst) { if (!!isFirst) { _init.proxys.splice(0, 0, initProxy); } else { _init.proxys.push(initProxy); } }, - addInitRoot: function (initRoot) { + addInitRoot: function(initRoot) { _init.roots.push(initRoot); }, - addNodesData: function (setting, parentNode, index, nodes) { - var children = data.nodeChildren(setting, parentNode), params; + addNodesData: function(setting, parentNode, index, nodes) { + var children = data.nodeChildren(setting, parentNode), + params; if (!children) { children = data.nodeChildren(setting, parentNode, []); index = -1; @@ -416,53 +470,55 @@ children.splice.apply(children, params); } }, - addSelectedNode: function (setting, node) { + addSelectedNode: function(setting, node) { var root = data.getRoot(setting); if (!data.isSelectedNode(setting, node)) { root.curSelectedList.push(node); } }, - addCreatedNode: function (setting, node) { + addCreatedNode: function(setting, node) { if (!!setting.callback.onNodeCreated || !!setting.view.addDiyDom) { var root = data.getRoot(setting); root.createdNodes.push(node); } }, - addZTreeTools: function (zTreeTools) { + addZTreeTools: function(zTreeTools) { _init.zTreeTools.push(zTreeTools); }, - exSetting: function (s) { + exSetting: function(s) { $.extend(true, _setting, s); }, - fixPIdKeyValue: function (setting, node) { + fixPIdKeyValue: function(setting, node) { if (setting.data.simpleData.enable) { - node[setting.data.simpleData.pIdKey] = node.parentTId ? node.getParentNode()[setting.data.simpleData.idKey] : setting.data.simpleData.rootPId; + node[setting.data.simpleData.pIdKey] = node.parentTId + ? node.getParentNode()[setting.data.simpleData.idKey] + : setting.data.simpleData.rootPId; } }, - getAfterA: function (setting, node, array) { + getAfterA: function(setting, node, array) { for (var i = 0, j = _init.afterA.length; i < j; i++) { _init.afterA[i].apply(this, arguments); } }, - getBeforeA: function (setting, node, array) { + getBeforeA: function(setting, node, array) { for (var i = 0, j = _init.beforeA.length; i < j; i++) { _init.beforeA[i].apply(this, arguments); } }, - getInnerAfterA: function (setting, node, array) { + getInnerAfterA: function(setting, node, array) { for (var i = 0, j = _init.innerAfterA.length; i < j; i++) { _init.innerAfterA[i].apply(this, arguments); } }, - getInnerBeforeA: function (setting, node, array) { + getInnerBeforeA: function(setting, node, array) { for (var i = 0, j = _init.innerBeforeA.length; i < j; i++) { _init.innerBeforeA[i].apply(this, arguments); } }, - getCache: function (setting) { + getCache: function(setting) { return caches[setting.treeId]; }, - getNodeIndex: function (setting, node) { + getNodeIndex: function(setting, node) { if (!node) return null; var p = node.parentTId ? node.getParentNode() : data.getRoot(setting), children = data.nodeChildren(setting, p); @@ -473,18 +529,18 @@ } return -1; }, - getNextNode: function (setting, node) { + getNextNode: function(setting, node) { if (!node) return null; var p = node.parentTId ? node.getParentNode() : data.getRoot(setting), children = data.nodeChildren(setting, p); for (var i = 0, l = children.length - 1; i <= l; i++) { if (children[i] === node) { - return (i == l ? null : children[i + 1]); + return i == l ? null : children[i + 1]; } } return null; }, - getNodeByParam: function (setting, nodes, key, value) { + getNodeByParam: function(setting, nodes, key, value) { if (!nodes || !key) return null; for (var i = 0, l = nodes.length; i < l; i++) { var node = nodes[i]; @@ -497,12 +553,12 @@ } return null; }, - getNodeCache: function (setting, tId) { + getNodeCache: function(setting, tId) { if (!tId) return null; var n = caches[setting.treeId].nodes[data.getNodeCacheId(tId)]; return n ? n : null; }, - getNodePath: function (setting, node) { + getNodePath: function(setting, node) { if (!node) return null; var path; @@ -518,10 +574,10 @@ return path; }, - getNodes: function (setting) { + getNodes: function(setting) { return data.nodeChildren(setting, data.getRoot(setting)); }, - getNodesByParam: function (setting, nodes, key, value) { + getNodesByParam: function(setting, nodes, key, value) { if (!nodes || !key) return []; var result = []; for (var i = 0, l = nodes.length; i < l; i++) { @@ -530,26 +586,39 @@ result.push(node); } var children = data.nodeChildren(setting, node); - result = result.concat(data.getNodesByParam(setting, children, key, value)); + result = result.concat( + data.getNodesByParam(setting, children, key, value) + ); } return result; }, - getNodesByParamFuzzy: function (setting, nodes, key, value) { + getNodesByParamFuzzy: function(setting, nodes, key, value) { if (!nodes || !key) return []; var result = []; value = value.toLowerCase(); for (var i = 0, l = nodes.length; i < l; i++) { var node = nodes[i]; - if (typeof node[key] == "string" && nodes[i][key].toLowerCase().indexOf(value) > -1) { + if ( + typeof node[key] == "string" && + nodes[i][key].toLowerCase().indexOf(value) > -1 + ) { result.push(node); } var children = data.nodeChildren(setting, node); - result = result.concat(data.getNodesByParamFuzzy(setting, children, key, value)); + result = result.concat( + data.getNodesByParamFuzzy(setting, children, key, value) + ); } return result; }, - getNodesByFilter: function (setting, nodes, filter, isSingle, invokeParam) { - if (!nodes) return (isSingle ? null : []); + getNodesByFilter: function( + setting, + nodes, + filter, + isSingle, + invokeParam + ) { + if (!nodes) return isSingle ? null : []; var result = isSingle ? null : []; for (var i = 0, l = nodes.length; i < l; i++) { var node = nodes[i]; @@ -560,7 +629,13 @@ result.push(node); } var children = data.nodeChildren(setting, node); - var tmpResult = data.getNodesByFilter(setting, children, filter, isSingle, invokeParam); + var tmpResult = data.getNodesByFilter( + setting, + children, + filter, + isSingle, + invokeParam + ); if (isSingle && !!tmpResult) { return tmpResult; } @@ -568,72 +643,72 @@ } return result; }, - getPreNode: function (setting, node) { + getPreNode: function(setting, node) { if (!node) return null; var p = node.parentTId ? node.getParentNode() : data.getRoot(setting), children = data.nodeChildren(setting, p); for (var i = 0, l = children.length; i < l; i++) { if (children[i] === node) { - return (i == 0 ? null : children[i - 1]); + return i == 0 ? null : children[i - 1]; } } return null; }, - getRoot: function (setting) { + getRoot: function(setting) { return setting ? roots[setting.treeId] : null; }, - getRoots: function () { + getRoots: function() { return roots; }, - getSetting: function (treeId) { + getSetting: function(treeId) { return settings[treeId]; }, - getSettings: function () { + getSettings: function() { return settings; }, - getZTreeTools: function (treeId) { + getZTreeTools: function(treeId) { var r = this.getRoot(this.getSetting(treeId)); return r ? r.treeTools : null; }, - initCache: function (setting) { + initCache: function(setting) { for (var i = 0, j = _init.caches.length; i < j; i++) { _init.caches[i].apply(this, arguments); } }, - initNode: function (setting, level, node, parentNode, preNode, nextNode) { + initNode: function(setting, level, node, parentNode, preNode, nextNode) { for (var i = 0, j = _init.nodes.length; i < j; i++) { _init.nodes[i].apply(this, arguments); } }, - initRoot: function (setting) { + initRoot: function(setting) { for (var i = 0, j = _init.roots.length; i < j; i++) { _init.roots[i].apply(this, arguments); } }, - isSelectedNode: function (setting, node) { + isSelectedNode: function(setting, node) { var root = data.getRoot(setting); for (var i = 0, j = root.curSelectedList.length; i < j; i++) { if (node === root.curSelectedList[i]) return true; } return false; }, - nodeChildren: function (setting, node, newChildren) { + nodeChildren: function(setting, node, newChildren) { if (!node) { return null; } var key = setting.data.key.children; - if (typeof newChildren !== 'undefined') { + if (typeof newChildren !== "undefined") { node[key] = newChildren; } return node[key]; }, - nodeIsParent: function (setting, node, newIsParent) { + nodeIsParent: function(setting, node, newIsParent) { if (!node) { return false; } var key = setting.data.key.isParent; - if (typeof newIsParent !== 'undefined') { + if (typeof newIsParent !== "undefined") { if (typeof newIsParent === "string") { newIsParent = tools.eqs(newIsParent, "true"); } @@ -652,26 +727,29 @@ return node[key]; }, - nodeName: function (setting, node, newName) { + nodeName: function(setting, node, newName) { var key = setting.data.key.name; - if (typeof newName !== 'undefined') { + if (typeof newName !== "undefined") { node[key] = newName; } var rawName = "" + node[key]; - if (typeof setting.data.render.name === 'function') { + if (typeof setting.data.render.name === "function") { return setting.data.render.name.call(this, rawName, node); } return rawName; }, - nodeTitle: function (setting, node) { - var t = setting.data.key.title === "" ? setting.data.key.name : setting.data.key.title; + nodeTitle: function(setting, node) { + var t = + setting.data.key.title === "" + ? setting.data.key.name + : setting.data.key.title; var rawTitle = "" + node[t]; - if (typeof setting.data.render.title === 'function') { + if (typeof setting.data.render.title === "function") { return setting.data.render.title.call(this, rawTitle, node); } return rawTitle; }, - removeNodeCache: function (setting, node) { + removeNodeCache: function(setting, node) { var children = data.nodeChildren(setting, node); if (children) { for (var i = 0, l = children.length; i < l; i++) { @@ -680,29 +758,35 @@ } data.getCache(setting).nodes[data.getNodeCacheId(node.tId)] = null; }, - removeSelectedNode: function (setting, node) { + removeSelectedNode: function(setting, node) { var root = data.getRoot(setting); for (var i = 0, j = root.curSelectedList.length; i < j; i++) { - if (node === root.curSelectedList[i] || !data.getNodeCache(setting, root.curSelectedList[i].tId)) { + if ( + node === root.curSelectedList[i] || + !data.getNodeCache(setting, root.curSelectedList[i].tId) + ) { root.curSelectedList.splice(i, 1); - setting.treeObj.trigger(consts.event.UNSELECTED, [setting.treeId, node]); + setting.treeObj.trigger(consts.event.UNSELECTED, [ + setting.treeId, + node, + ]); i--; j--; } } }, - setCache: function (setting, cache) { + setCache: function(setting, cache) { caches[setting.treeId] = cache; }, - setRoot: function (setting, root) { + setRoot: function(setting, root) { roots[setting.treeId] = root; }, - setZTreeTools: function (setting, zTreeTools) { + setZTreeTools: function(setting, zTreeTools) { for (var i = 0, j = _init.zTreeTools.length; i < j; i++) { _init.zTreeTools[i].apply(this, arguments); } }, - transformToArrayFormat: function (setting, nodes) { + transformToArrayFormat: function(setting, nodes) { if (!nodes) return []; var r = []; if (tools.isArray(nodes)) { @@ -723,8 +807,9 @@ } } }, - transformTozTreeFormat: function (setting, sNodes) { - var i, l, + transformTozTreeFormat: function(setting, sNodes) { + var i, + l, key = setting.data.simpleData.idKey, parentKey = setting.data.simpleData.pIdKey; if (!key || key == "" || !sNodes) return []; @@ -751,51 +836,51 @@ } else { return [sNodes]; } - } + }, }, //method of event proxy event = { - bindEvent: function (setting) { + bindEvent: function(setting) { for (var i = 0, j = _init.bind.length; i < j; i++) { _init.bind[i].apply(this, arguments); } }, - unbindEvent: function (setting) { + unbindEvent: function(setting) { for (var i = 0, j = _init.unbind.length; i < j; i++) { _init.unbind[i].apply(this, arguments); } }, - bindTree: function (setting) { + bindTree: function(setting) { var eventParam = { - treeId: setting.treeId - }, + treeId: setting.treeId, + }, o = setting.treeObj; if (!setting.view.txtSelectedEnable) { // for can't select text - o.bind('selectstart', handler.onSelectStart).css({ - "-moz-user-select": "-moz-none" + o.bind("selectstart", handler.onSelectStart).css({ + "-moz-user-select": "-moz-none", }); } - o.bind('click', eventParam, event.proxy); - o.bind('dblclick', eventParam, event.proxy); - o.bind('mouseover', eventParam, event.proxy); - o.bind('mouseout', eventParam, event.proxy); - o.bind('mousedown', eventParam, event.proxy); - o.bind('mouseup', eventParam, event.proxy); - o.bind('contextmenu', eventParam, event.proxy); + o.bind("click", eventParam, event.proxy); + o.bind("dblclick", eventParam, event.proxy); + o.bind("mouseover", eventParam, event.proxy); + o.bind("mouseout", eventParam, event.proxy); + o.bind("mousedown", eventParam, event.proxy); + o.bind("mouseup", eventParam, event.proxy); + o.bind("contextmenu", eventParam, event.proxy); }, - unbindTree: function (setting) { + unbindTree: function(setting) { var o = setting.treeObj; - o.unbind('selectstart', handler.onSelectStart) - .unbind('click', event.proxy) - .unbind('dblclick', event.proxy) - .unbind('mouseover', event.proxy) - .unbind('mouseout', event.proxy) - .unbind('mousedown', event.proxy) - .unbind('mouseup', event.proxy) - .unbind('contextmenu', event.proxy); + o.unbind("selectstart", handler.onSelectStart) + .unbind("click", event.proxy) + .unbind("dblclick", event.proxy) + .unbind("mouseover", event.proxy) + .unbind("mouseout", event.proxy) + .unbind("mousedown", event.proxy) + .unbind("mouseup", event.proxy) + .unbind("contextmenu", event.proxy); }, - doProxy: function (e) { + doProxy: function(e) { var results = []; for (var i = 0, j = _init.proxys.length; i < j; i++) { var proxyResult = _init.proxys[i].apply(this, arguments); @@ -806,120 +891,217 @@ } return results; }, - proxy: function (e) { + proxy: function(e) { var setting = data.getSetting(e.data.treeId); if (!tools.uCanDo(setting, e)) return true; var results = event.doProxy(e), - r = true, x = false; + r = true, + x = false; for (var i = 0, l = results.length; i < l; i++) { var proxyResult = results[i]; if (proxyResult.nodeEventCallback) { x = true; - r = proxyResult.nodeEventCallback.apply(proxyResult, [e, proxyResult.node]) && r; + r = + proxyResult.nodeEventCallback.apply(proxyResult, [ + e, + proxyResult.node, + ]) && r; } if (proxyResult.treeEventCallback) { x = true; - r = proxyResult.treeEventCallback.apply(proxyResult, [e, proxyResult.node]) && r; + r = + proxyResult.treeEventCallback.apply(proxyResult, [ + e, + proxyResult.node, + ]) && r; } } return r; - } + }, }, //method of event handler handler = { - onSwitchNode: function (event, node) { + onSwitchNode: function(event, node) { var setting = data.getSetting(event.data.treeId); if (node.open) { - if (tools.apply(setting.callback.beforeCollapse, [setting.treeId, node], true) == false) return true; + if ( + tools.apply( + setting.callback.beforeCollapse, + [setting.treeId, node], + true + ) == false + ) + return true; data.getRoot(setting).expandTriggerFlag = true; view.switchNode(setting, node); } else { - if (tools.apply(setting.callback.beforeExpand, [setting.treeId, node], true) == false) return true; + if ( + tools.apply( + setting.callback.beforeExpand, + [setting.treeId, node], + true + ) == false + ) + return true; data.getRoot(setting).expandTriggerFlag = true; view.switchNode(setting, node); } return true; }, - onClickNode: function (event, node) { + onClickNode: function(event, node) { // debugger var setting = data.getSetting(event.data.treeId), - clickFlag = ((setting.view.autoCancelSelected && (event.ctrlKey || event.metaKey)) && data.isSelectedNode(setting, node)) ? 0 : (setting.view.autoCancelSelected && (event.ctrlKey || event.metaKey) && setting.view.selectedMulti) ? 2 : 1; - if (tools.apply(setting.callback.beforeClick, [setting.treeId, node, clickFlag], true) == false) return true; + clickFlag = + setting.view.autoCancelSelected && + (event.ctrlKey || event.metaKey) && + data.isSelectedNode(setting, node) + ? 0 + : setting.view.autoCancelSelected && + (event.ctrlKey || event.metaKey) && + setting.view.selectedMulti + ? 2 + : 1; + if ( + tools.apply( + setting.callback.beforeClick, + [setting.treeId, node, clickFlag], + true + ) == false + ) + return true; if (clickFlag === 0) { view.cancelPreSelectedNode(setting, node); } else { view.selectNode(setting, node, clickFlag === 2); } - setting.treeObj.trigger(consts.event.CLICK, [event, setting.treeId, node, clickFlag]); + setting.treeObj.trigger(consts.event.CLICK, [ + event, + setting.treeId, + node, + clickFlag, + ]); return true; }, - onZTreeMousedown: function (event, node) { + onZTreeMousedown: function(event, node) { var setting = data.getSetting(event.data.treeId); - if (tools.apply(setting.callback.beforeMouseDown, [setting.treeId, node], true)) { - tools.apply(setting.callback.onMouseDown, [event, setting.treeId, node]); + if ( + tools.apply( + setting.callback.beforeMouseDown, + [setting.treeId, node], + true + ) + ) { + tools.apply(setting.callback.onMouseDown, [ + event, + setting.treeId, + node, + ]); } return true; }, - onZTreeMouseup: function (event, node) { + onZTreeMouseup: function(event, node) { var setting = data.getSetting(event.data.treeId); - if (tools.apply(setting.callback.beforeMouseUp, [setting.treeId, node], true)) { - tools.apply(setting.callback.onMouseUp, [event, setting.treeId, node]); + if ( + tools.apply( + setting.callback.beforeMouseUp, + [setting.treeId, node], + true + ) + ) { + tools.apply(setting.callback.onMouseUp, [ + event, + setting.treeId, + node, + ]); } return true; }, - onZTreeDblclick: function (event, node) { + onZTreeDblclick: function(event, node) { var setting = data.getSetting(event.data.treeId); - if (tools.apply(setting.callback.beforeDblClick, [setting.treeId, node], true)) { - tools.apply(setting.callback.onDblClick, [event, setting.treeId, node]); + if ( + tools.apply( + setting.callback.beforeDblClick, + [setting.treeId, node], + true + ) + ) { + tools.apply(setting.callback.onDblClick, [ + event, + setting.treeId, + node, + ]); } return true; }, - onZTreeContextmenu: function (event, node) { + onZTreeContextmenu: function(event, node) { var setting = data.getSetting(event.data.treeId); - if (tools.apply(setting.callback.beforeRightClick, [setting.treeId, node], true)) { - tools.apply(setting.callback.onRightClick, [event, setting.treeId, node]); + if ( + tools.apply( + setting.callback.beforeRightClick, + [setting.treeId, node], + true + ) + ) { + tools.apply(setting.callback.onRightClick, [ + event, + setting.treeId, + node, + ]); } - return (typeof setting.callback.onRightClick) != "function"; + return typeof setting.callback.onRightClick != "function"; }, - onSelectStart: function (e) { + onSelectStart: function(e) { var n = e.originalEvent.srcElement.nodeName.toLowerCase(); - return (n === "input" || n === "textarea"); - } + return n === "input" || n === "textarea"; + }, }, //method of tools for zTree tools = { - apply: function (fun, param, defaultValue) { - if ((typeof fun) == "function") { + apply: function(fun, param, defaultValue) { + if (typeof fun == "function") { return fun.apply(zt, param ? param : []); } return defaultValue; }, - canAsync: function (setting, node) { + canAsync: function(setting, node) { var children = data.nodeChildren(setting, node); var isParent = data.nodeIsParent(setting, node); - return (setting.async.enable && node && isParent && !(node.zAsync || (children && children.length > 0))); + return ( + setting.async.enable && + node && + isParent && + !(node.zAsync || (children && children.length > 0)) + ); }, - clone: function (obj) { + clone: function(obj) { if (obj === null) return null; var o = tools.isArray(obj) ? [] : {}; for (var i in obj) { - o[i] = (obj[i] instanceof Date) ? new Date(obj[i].getTime()) : (typeof obj[i] === "object" ? tools.clone(obj[i]) : obj[i]); + o[i] = + obj[i] instanceof Date + ? new Date(obj[i].getTime()) + : typeof obj[i] === "object" + ? tools.clone(obj[i]) + : obj[i]; } return o; }, - eqs: function (str1, str2) { + eqs: function(str1, str2) { return str1.toLowerCase() === str2.toLowerCase(); }, - isArray: function (arr) { + isArray: function(arr) { return Object.prototype.toString.apply(arr) === "[object Array]"; }, - isElement: function (o) { - return ( - typeof HTMLElement === "object" ? o instanceof HTMLElement : //DOM2 - o && typeof o === "object" && o !== null && o.nodeType === 1 && typeof o.nodeName === "string" - ); + isElement: function(o) { + return typeof HTMLElement === "object" + ? o instanceof HTMLElement //DOM2 + : o && + typeof o === "object" && + o !== null && + o.nodeType === 1 && + typeof o.nodeName === "string"; }, - $: function (node, exp, setting) { + $: function(node, exp, setting) { if (!!exp && typeof exp != "string") { setting = exp; exp = ""; @@ -930,11 +1112,14 @@ return $("#" + node.tId + exp, setting ? setting.treeObj : null); } }, - getMDom: function (setting, curDom, targetExpr) { + getMDom: function(setting, curDom, targetExpr) { if (!curDom) return null; while (curDom && curDom.id !== setting.treeId) { for (var i = 0, l = targetExpr.length; curDom.tagName && i < l; i++) { - if (tools.eqs(curDom.tagName, targetExpr[i].tagName) && curDom.getAttribute(targetExpr[i].attrName) !== null) { + if ( + tools.eqs(curDom.tagName, targetExpr[i].tagName) && + curDom.getAttribute(targetExpr[i].attrName) !== null + ) { return curDom; } } @@ -942,19 +1127,27 @@ } return null; }, - getNodeMainDom: function (target) { - return ($(target).parent("li").get(0) || $(target).parentsUntil("li").parent().get(0)); + getNodeMainDom: function(target) { + return ( + $(target) + .parent("li") + .get(0) || + $(target) + .parentsUntil("li") + .parent() + .get(0) + ); }, - isChildOrSelf: function (dom, parentId) { - return ($(dom).closest("#" + parentId).length > 0); + isChildOrSelf: function(dom, parentId) { + return $(dom).closest("#" + parentId).length > 0; }, - uCanDo: function (setting, e) { + uCanDo: function(setting, e) { return true; - } + }, }, //method of operate ztree dom view = { - addNodes: function (setting, parentNode, index, newNodes, isSilent) { + addNodes: function(setting, parentNode, index, newNodes, isSilent) { var isParent = data.nodeIsParent(setting, parentNode); if (setting.data.keep.leaf && parentNode && !isParent) { return; @@ -971,16 +1164,30 @@ target_ulObj = $$(parentNode, consts.id.UL, setting); if (!parentNode.open) { - view.replaceSwitchClass(parentNode, target_switchObj, consts.folder.CLOSE); - view.replaceIcoClass(parentNode, target_icoObj, consts.folder.CLOSE); + view.replaceSwitchClass( + parentNode, + target_switchObj, + consts.folder.CLOSE + ); + view.replaceIcoClass( + parentNode, + target_icoObj, + consts.folder.CLOSE + ); parentNode.open = false; target_ulObj.css({ - "display": "none" + display: "none", }); } data.addNodesData(setting, parentNode, index, newNodes); - view.createNodes(setting, parentNode.level + 1, newNodes, parentNode, index); + view.createNodes( + setting, + parentNode.level + 1, + newNodes, + parentNode, + index + ); if (!isSilent) { view.expandCollapseParentNode(setting, parentNode, true); } @@ -989,13 +1196,22 @@ view.createNodes(setting, 0, newNodes, null, index); } }, - appendNodes: function (setting, level, nodes, parentNode, index, initFlag, openFlag) { + appendNodes: function( + setting, + level, + nodes, + parentNode, + index, + initFlag, + openFlag + ) { if (!nodes) return []; var html = []; - var tmpPNode = (parentNode) ? parentNode : data.getRoot(setting), + var tmpPNode = parentNode ? parentNode : data.getRoot(setting), tmpPChild = data.nodeChildren(setting, tmpPNode), - isFirstNode, isLastNode; + isFirstNode, + isLastNode; if (!tmpPChild || index >= tmpPChild.length - nodes.length) { index = -1; @@ -1004,9 +1220,18 @@ for (var i = 0, l = nodes.length; i < l; i++) { var node = nodes[i]; if (initFlag) { - isFirstNode = ((index === 0 || tmpPChild.length == nodes.length) && (i == 0)); - isLastNode = (index < 0 && i == (nodes.length - 1)); - data.initNode(setting, level, node, parentNode, isFirstNode, isLastNode, openFlag); + isFirstNode = + (index === 0 || tmpPChild.length == nodes.length) && i == 0; + isLastNode = index < 0 && i == nodes.length - 1; + data.initNode( + setting, + level, + node, + parentNode, + isFirstNode, + isLastNode, + openFlag + ); data.addNodeCache(setting, node); } var isParent = data.nodeIsParent(setting, node); @@ -1015,7 +1240,15 @@ var children = data.nodeChildren(setting, node); if (children && children.length > 0) { //make child html first, because checkType - childHtml = view.appendNodes(setting, level + 1, children, node, -1, initFlag, openFlag && node.open); + childHtml = view.appendNodes( + setting, + level + 1, + children, + node, + -1, + initFlag, + openFlag && node.open + ); } if (openFlag) { view.makeDOMNodeMainBefore(html, setting, node); @@ -1028,7 +1261,7 @@ view.makeDOMNodeNameAfter(html, setting, node); data.getAfterA(setting, node, html); if (isParent && node.open) { - view.makeUlHtml(setting, node, html, childHtml.join('')); + view.makeUlHtml(setting, node, html, childHtml.join("")); } view.makeDOMNodeMainAfter(html, setting, node); data.addCreatedNode(setting, node); @@ -1036,7 +1269,7 @@ } return html; }, - appendParentULDom: function (setting, node) { + appendParentULDom: function(setting, node) { var html = [], nObj = $$(node, setting); if (!nObj.get(0) && !!node.parentTId) { @@ -1048,11 +1281,19 @@ ulObj.remove(); } var children = data.nodeChildren(setting, node), - childHtml = view.appendNodes(setting, node.level + 1, children, node, -1, false, true); - view.makeUlHtml(setting, node, html, childHtml.join('')); - nObj.append(html.join('')); + childHtml = view.appendNodes( + setting, + node.level + 1, + children, + node, + -1, + false, + true + ); + view.makeUlHtml(setting, node, html, childHtml.join("")); + nObj.append(html.join("")); }, - asyncNode: function (setting, node, isSilent, callback) { + asyncNode: function(setting, node, isSilent, callback) { var i, l; var isParent = data.nodeIsParent(setting, node); if (node && !isParent) { @@ -1060,27 +1301,45 @@ return false; } else if (node && node.isAjaxing) { return false; - } else if (tools.apply(setting.callback.beforeAsync, [setting.treeId, node], true) == false) { + } else if ( + tools.apply( + setting.callback.beforeAsync, + [setting.treeId, node], + true + ) == false + ) { tools.apply(callback); return false; } if (node) { node.isAjaxing = true; var icoObj = $$(node, consts.id.ICON, setting); - icoObj.attr({ "style": "", "class": consts.className.BUTTON + " " + consts.className.ICO_LOADING }); + icoObj.attr({ + style: "", + class: consts.className.BUTTON + " " + consts.className.ICO_LOADING, + }); } var tmpParam = {}; - var autoParam = tools.apply(setting.async.autoParam, [setting.treeId, node], setting.async.autoParam); + var autoParam = tools.apply( + setting.async.autoParam, + [setting.treeId, node], + setting.async.autoParam + ); for (i = 0, l = autoParam.length; node && i < l; i++) { - var pKey = autoParam[i].split("="), spKey = pKey; + var pKey = autoParam[i].split("="), + spKey = pKey; if (pKey.length > 1) { spKey = pKey[1]; pKey = pKey[0]; } tmpParam[spKey] = node[pKey]; } - var otherParam = tools.apply(setting.async.otherParam, [setting.treeId, node], setting.async.otherParam); + var otherParam = tools.apply( + setting.async.otherParam, + [setting.treeId, node], + setting.async.otherParam + ); if (tools.isArray(otherParam)) { for (i = 0, l = otherParam.length; i < l; i += 2) { tmpParam[otherParam[i]] = otherParam[i + 1]; @@ -1096,12 +1355,19 @@ contentType: setting.async.contentType, cache: false, type: setting.async.type, - url: tools.apply(setting.async.url, [setting.treeId, node], setting.async.url), - data: setting.async.contentType.indexOf('application/json') > -1 ? JSON.stringify(tmpParam) : tmpParam, + url: tools.apply( + setting.async.url, + [setting.treeId, node], + setting.async.url + ), + data: + setting.async.contentType.indexOf("application/json") > -1 + ? JSON.stringify(tmpParam) + : tmpParam, dataType: setting.async.dataType, headers: setting.async.headers, xhrFields: setting.async.xhrFields, - success: function (msg) { + success: function(msg) { if (_tmpV != data.getRoot(setting)._ver) { return; } @@ -1124,28 +1390,49 @@ } view.setNodeLineIcos(setting, node); if (newNodes && newNodes !== "") { - newNodes = tools.apply(setting.async.dataFilter, [setting.treeId, node, newNodes], newNodes); - view.addNodes(setting, node, -1, !!newNodes ? tools.clone(newNodes) : [], !!isSilent); + newNodes = tools.apply( + setting.async.dataFilter, + [setting.treeId, node, newNodes], + newNodes + ); + view.addNodes( + setting, + node, + -1, + !!newNodes ? tools.clone(newNodes) : [], + !!isSilent + ); } else { view.addNodes(setting, node, -1, [], !!isSilent); } - setting.treeObj.trigger(consts.event.ASYNC_SUCCESS, [setting.treeId, node, msg]); + setting.treeObj.trigger(consts.event.ASYNC_SUCCESS, [ + setting.treeId, + node, + msg, + ]); tools.apply(callback); }, - error: function (XMLHttpRequest, textStatus, errorThrown) { + error: function(XMLHttpRequest, textStatus, errorThrown) { if (_tmpV != data.getRoot(setting)._ver) { return; } if (node) node.isAjaxing = null; view.setNodeLineIcos(setting, node); - setting.treeObj.trigger(consts.event.ASYNC_ERROR, [setting.treeId, node, XMLHttpRequest, textStatus, errorThrown]); - } + setting.treeObj.trigger(consts.event.ASYNC_ERROR, [ + setting.treeId, + node, + XMLHttpRequest, + textStatus, + errorThrown, + ]); + }, }); return true; }, - cancelPreSelectedNode: function (setting, node, excludeNode) { + cancelPreSelectedNode: function(setting, node, excludeNode) { var list = data.getRoot(setting).curSelectedList, - i, n; + i, + n; for (i = list.length - 1; i >= 0; i--) { n = list[i]; if (node === n || (!node && (!excludeNode || excludeNode !== n))) { @@ -1155,30 +1442,48 @@ break; } else { list.splice(i, 1); - setting.treeObj.trigger(consts.event.UNSELECTED, [setting.treeId, n]); + setting.treeObj.trigger(consts.event.UNSELECTED, [ + setting.treeId, + n, + ]); } } } }, - createNodeCallback: function (setting) { + createNodeCallback: function(setting) { if (!!setting.callback.onNodeCreated || !!setting.view.addDiyDom) { var root = data.getRoot(setting); while (root.createdNodes.length > 0) { var node = root.createdNodes.shift(); tools.apply(setting.view.addDiyDom, [setting.treeId, node]); if (!!setting.callback.onNodeCreated) { - setting.treeObj.trigger(consts.event.NODECREATED, [setting.treeId, node]); + setting.treeObj.trigger(consts.event.NODECREATED, [ + setting.treeId, + node, + ]); } } } }, - createNodes: function (setting, level, nodes, parentNode, index) { + createNodes: function(setting, level, nodes, parentNode, index) { if (!nodes || nodes.length == 0) return; var root = data.getRoot(setting), - openFlag = !parentNode || parentNode.open || !!$$(data.nodeChildren(setting, parentNode)[0], setting).get(0); + openFlag = + !parentNode || + parentNode.open || + !!$$(data.nodeChildren(setting, parentNode)[0], setting).get(0); root.createdNodes = []; - var zTreeHtml = view.appendNodes(setting, level, nodes, parentNode, index, true, openFlag), - parentObj, nextObj; + var zTreeHtml = view.appendNodes( + setting, + level, + nodes, + parentNode, + index, + true, + openFlag + ), + parentObj, + nextObj; if (!parentNode) { parentObj = setting.treeObj; @@ -1195,15 +1500,15 @@ nextObj = parentObj.children()[index]; } if (index >= 0 && nextObj) { - $(nextObj).before(zTreeHtml.join('')); + $(nextObj).before(zTreeHtml.join("")); } else { - parentObj.append(zTreeHtml.join('')); + parentObj.append(zTreeHtml.join("")); } } view.createNodeCallback(setting); }, - destroy: function (setting) { + destroy: function(setting) { if (!setting) return; data.initCache(setting); data.initRoot(setting); @@ -1212,7 +1517,13 @@ setting.treeObj.empty(); delete settings[setting.treeId]; }, - expandCollapseNode: function (setting, node, expandFlag, animateFlag, callback) { + expandCollapseNode: function( + setting, + node, + expandFlag, + animateFlag, + callback + ) { var root = data.getRoot(setting); var tmpCb, _callback; if (!node) { @@ -1223,18 +1534,31 @@ var isParent = data.nodeIsParent(setting, node); if (root.expandTriggerFlag) { _callback = callback; - tmpCb = function () { + tmpCb = function() { if (_callback) _callback(); if (node.open) { - setting.treeObj.trigger(consts.event.EXPAND, [setting.treeId, node]); + setting.treeObj.trigger(consts.event.EXPAND, [ + setting.treeId, + node, + ]); } else { - setting.treeObj.trigger(consts.event.COLLAPSE, [setting.treeId, node]); + setting.treeObj.trigger(consts.event.COLLAPSE, [ + setting.treeId, + node, + ]); } }; callback = tmpCb; root.expandTriggerFlag = false; } - if (!node.open && isParent && ((!$$(node, consts.id.UL, setting).get(0)) || (children && children.length > 0 && !$$(children[0], setting).get(0)))) { + if ( + !node.open && + isParent && + (!$$(node, consts.id.UL, setting).get(0) || + (children && + children.length > 0 && + !$$(children[0], setting).get(0))) + ) { view.appendParentULDom(setting, node); view.createNodeCallback(setting); } @@ -1269,7 +1593,11 @@ } else { view.replaceSwitchClass(node, switchObj, consts.folder.CLOSE); view.replaceIcoClass(node, icoObj, consts.folder.CLOSE); - if (animateFlag == false || setting.view.expandSpeed == "" || !(children && children.length > 0)) { + if ( + animateFlag == false || + setting.view.expandSpeed == "" || + !(children && children.length > 0) + ) { ulObj.hide(); tools.apply(callback, []); } else { @@ -1280,33 +1608,71 @@ tools.apply(callback, []); } }, - expandCollapseParentNode: function (setting, node, expandFlag, animateFlag, callback) { + expandCollapseParentNode: function( + setting, + node, + expandFlag, + animateFlag, + callback + ) { if (!node) return; if (!node.parentTId) { - view.expandCollapseNode(setting, node, expandFlag, animateFlag, callback); + view.expandCollapseNode( + setting, + node, + expandFlag, + animateFlag, + callback + ); return; } else { view.expandCollapseNode(setting, node, expandFlag, animateFlag); } if (node.parentTId) { - view.expandCollapseParentNode(setting, node.getParentNode(), expandFlag, animateFlag, callback); + view.expandCollapseParentNode( + setting, + node.getParentNode(), + expandFlag, + animateFlag, + callback + ); } }, - expandCollapseSonNode: function (setting, node, expandFlag, animateFlag, callback) { + expandCollapseSonNode: function( + setting, + node, + expandFlag, + animateFlag, + callback + ) { var root = data.getRoot(setting), - treeNodes = (node) ? data.nodeChildren(setting, node) : data.nodeChildren(setting, root), - selfAnimateSign = (node) ? false : animateFlag, + treeNodes = node + ? data.nodeChildren(setting, node) + : data.nodeChildren(setting, root), + selfAnimateSign = node ? false : animateFlag, expandTriggerFlag = data.getRoot(setting).expandTriggerFlag; data.getRoot(setting).expandTriggerFlag = false; if (treeNodes) { for (var i = 0, l = treeNodes.length; i < l; i++) { - if (treeNodes[i]) view.expandCollapseSonNode(setting, treeNodes[i], expandFlag, selfAnimateSign); + if (treeNodes[i]) + view.expandCollapseSonNode( + setting, + treeNodes[i], + expandFlag, + selfAnimateSign + ); } } data.getRoot(setting).expandTriggerFlag = expandTriggerFlag; - view.expandCollapseNode(setting, node, expandFlag, animateFlag, callback); + view.expandCollapseNode( + setting, + node, + expandFlag, + animateFlag, + callback + ); }, - isSelectedNode: function (setting, node) { + isSelectedNode: function(setting, node) { if (!node) { return false; } @@ -1319,28 +1685,63 @@ } return false; }, - makeDOMNodeIcon: function (html, setting, node) { + makeDOMNodeIcon: function(html, setting, node) { var nameStr = data.nodeName(setting, node), - name = setting.view.nameIsHTML ? nameStr : nameStr.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>'); - html.push("<span id='", node.tId, consts.id.ICON, - "' title='' treeNode", consts.id.ICON, " class='", view.makeNodeIcoClass(setting, node), - "' style='", view.makeNodeIcoStyle(setting, node), "'></span><span id='", node.tId, consts.id.SPAN, - "' class='", view.makeNodeNameClass(node), - "'>", name, "</span>"); + name = setting.view.nameIsHTML + ? nameStr + : nameStr + .replace(/&/g, "&") + .replace(/</g, "<") + .replace(/>/g, ">"); + html.push( + "<span id='", + node.tId, + consts.id.ICON, + "' title='' treeNode", + consts.id.ICON, + " class='", + view.makeNodeIcoClass(setting, node), + "' style='", + view.makeNodeIcoStyle(setting, node), + "'></span><span id='", + node.tId, + consts.id.SPAN, + "' class='", + view.makeNodeNameClass(node), + "'>", + name, + "</span>" + ); }, - makeDOMNodeLine: function (html, setting, node) { - html.push("<span id='", node.tId, consts.id.SWITCH, "' title='' class='", view.makeNodeLineClass(setting, node), "' treeNode", consts.id.SWITCH, "></span>"); + makeDOMNodeLine: function(html, setting, node) { + html.push( + "<span id='", + node.tId, + consts.id.SWITCH, + "' title='' class='", + view.makeNodeLineClass(setting, node), + "' treeNode", + consts.id.SWITCH, + "></span>" + ); }, - makeDOMNodeMainAfter: function (html, setting, node) { + makeDOMNodeMainAfter: function(html, setting, node) { html.push("</li>"); }, - makeDOMNodeMainBefore: function (html, setting, node) { - html.push("<li id='", node.tId, "' class='", consts.className.LEVEL, node.level, "' tabindex='0' hidefocus='true' treenode>"); + makeDOMNodeMainBefore: function(html, setting, node) { + html.push( + "<li id='", + node.tId, + "' class='", + consts.className.LEVEL, + node.level, + "' tabindex='0' hidefocus='true' treenode>" + ); }, - makeDOMNodeNameAfter: function (html, setting, node) { + makeDOMNodeNameAfter: function(html, setting, node) { html.push("</a>"); }, - makeDOMNodeNameBefore: function (html, setting, node) { + makeDOMNodeNameBefore: function(html, setting, node) { var title = data.nodeTitle(setting, node), url = view.makeNodeUrl(setting, node), fontcss = view.makeNodeFontCss(setting, node), @@ -1349,26 +1750,62 @@ for (var f in fontcss) { fontStyle.push(f, ":", fontcss[f], ";"); } - html.push("<a id='", node.tId, consts.id.A, "' class='", consts.className.LEVEL, node.level, - nodeClasses.add ? ' ' + nodeClasses.add.join(' ') : '', - "' treeNode", consts.id.A, - node.click ? " onclick=\"" + node.click + "\"" : "", - ((url != null && url.length > 0) ? " href='" + url + "'" : ""), " target='", view.makeNodeTarget(node), "' style='", fontStyle.join(''), - "'"); - if (tools.apply(setting.view.showTitle, [setting.treeId, node], setting.view.showTitle) && title) { - html.push("title='", title.replace(/'/g, "'").replace(/</g, '<').replace(/>/g, '>'), "'"); + html.push( + "<a id='", + node.tId, + consts.id.A, + "' class='", + consts.className.LEVEL, + node.level, + nodeClasses.add ? " " + nodeClasses.add.join(" ") : "", + "' treeNode", + consts.id.A, + node.click ? ' onclick="' + node.click + '"' : "", + url != null && url.length > 0 ? " href='" + url + "'" : "", + " target='", + view.makeNodeTarget(node), + "' style='", + fontStyle.join(""), + "'" + ); + if ( + tools.apply( + setting.view.showTitle, + [setting.treeId, node], + setting.view.showTitle + ) && + title + ) { + html.push( + "title='", + title + .replace(/'/g, "'") + .replace(/</g, "<") + .replace(/>/g, ">"), + "'" + ); } html.push(">"); }, - makeNodeFontCss: function (setting, node) { - var fontCss = tools.apply(setting.view.fontCss, [setting.treeId, node], setting.view.fontCss); - return (fontCss && ((typeof fontCss) != "function")) ? fontCss : {}; + makeNodeFontCss: function(setting, node) { + var fontCss = tools.apply( + setting.view.fontCss, + [setting.treeId, node], + setting.view.fontCss + ); + return fontCss && typeof fontCss != "function" ? fontCss : {}; }, - makeNodeClasses: function (setting, node) { - var classes = tools.apply(setting.view.nodeClasses, [setting.treeId, node], setting.view.nodeClasses); - return (classes && (typeof classes !== "function")) ? classes : { add: [], remove: [] }; + makeNodeClasses: function(setting, node) { + var classes = tools.apply( + setting.view.nodeClasses, + [setting.treeId, node], + setting.view.nodeClasses + ); + return classes && typeof classes !== "function" + ? classes + : { add: [], remove: [] }; }, - makeNodeIcoClass: function (setting, node) { + makeNodeIcoClass: function(setting, node) { var icoCss = ["ico"]; if (!node.isAjaxing) { var isParent = data.nodeIsParent(setting, node); @@ -1377,42 +1814,50 @@ icoCss.push(node.open ? consts.folder.OPEN : consts.folder.CLOSE); } else { // 瀹氬埗瀛愯妭鐐瑰浘鏍� - let fontClass = "" - if (node.type === '4' && !node.isAI) { - fontClass = "iconjiankongshexiangji" + let fontClass = ""; + if (node.type === "4" && !node.isAI) { + fontClass = "iconjiankongshexiangji"; } else if (node.isAI) { - fontClass = "iconfenxishexiangji" + fontClass = "iconfenxishexiangji"; } if (node.isRunning) { - fontClass = fontClass + " running" + fontClass = fontClass + " running"; } - return "iconfont " + fontClass + return "iconfont " + fontClass; } } - return consts.className.BUTTON + " " + icoCss.join('_'); + return consts.className.BUTTON + " " + icoCss.join("_"); }, - makeNodeNameClass: function (node) { + makeNodeNameClass: function(node) { let icoCss = ""; if (node.isRunning) { icoCss = " running"; } return consts.className.NAME + icoCss; }, - makeNodeIcoStyle: function (setting, node) { + makeNodeIcoStyle: function(setting, node) { var icoStyle = []; if (!node.isAjaxing) { var isParent = data.nodeIsParent(setting, node); - var icon = (isParent && node.iconOpen && node.iconClose) ? (node.open ? node.iconOpen : node.iconClose) : node[setting.data.key.icon]; + var icon = + isParent && node.iconOpen && node.iconClose + ? node.open + ? node.iconOpen + : node.iconClose + : node[setting.data.key.icon]; if (icon) icoStyle.push("background:url(", icon, ") 0 0 no-repeat;"); - if (setting.view.showIcon == false || !tools.apply(setting.view.showIcon, [setting.treeId, node], true)) { + if ( + setting.view.showIcon == false || + !tools.apply(setting.view.showIcon, [setting.treeId, node], true) + ) { icoStyle.push("display:none;"); } } - return icoStyle.join(''); + return icoStyle.join(""); }, - makeNodeLineClass: function (setting, node) { + makeNodeLineClass: function(setting, node) { var lineClass = []; if (setting.view.showLine) { if (node.level == 0 && node.isFirstNode && node.isLastNode) { @@ -1432,27 +1877,49 @@ } else { lineClass.push(consts.folder.DOCU); } - return view.makeNodeLineClassEx(node) + lineClass.join('_'); + return view.makeNodeLineClassEx(node) + lineClass.join("_"); }, - makeNodeLineClassEx: function (node) { - return consts.className.BUTTON + " " + consts.className.LEVEL + node.level + " " + consts.className.SWITCH + " "; + makeNodeLineClassEx: function(node) { + return ( + consts.className.BUTTON + + " " + + consts.className.LEVEL + + node.level + + " " + + consts.className.SWITCH + + " " + ); }, - makeNodeTarget: function (node) { - return (node.target || "_blank"); + makeNodeTarget: function(node) { + return node.target || "_blank"; }, - makeNodeUrl: function (setting, node) { + makeNodeUrl: function(setting, node) { var urlKey = setting.data.key.url; return node[urlKey] ? node[urlKey] : null; }, - makeUlHtml: function (setting, node, html, content) { - html.push("<ul id='", node.tId, consts.id.UL, "' class='", consts.className.LEVEL, node.level, " ", view.makeUlLineClass(setting, node), "' style='display:", (node.open ? "block" : "none"), "'>"); + makeUlHtml: function(setting, node, html, content) { + html.push( + "<ul id='", + node.tId, + consts.id.UL, + "' class='", + consts.className.LEVEL, + node.level, + " ", + view.makeUlLineClass(setting, node), + "' style='display:", + node.open ? "block" : "none", + "'>" + ); html.push(content); html.push("</ul>"); }, - makeUlLineClass: function (setting, node) { - return ((setting.view.showLine && !node.isLastNode) ? consts.line.LINE : ""); + makeUlLineClass: function(setting, node) { + return setting.view.showLine && !node.isLastNode + ? consts.line.LINE + : ""; }, - removeChildNodes: function (setting, node) { + removeChildNodes: function(setting, node) { if (!node) return; var nodes = data.nodeChildren(setting, node); if (!nodes) return; @@ -1475,27 +1942,34 @@ $$(node, consts.id.UL, setting).empty(); } }, - scrollIntoView: function (setting, dom) { + scrollIntoView: function(setting, dom) { if (!dom) { return; } // support IE 7 / 8 - if (typeof Element === 'undefined' || typeof HTMLElement === 'undefined') { + if ( + typeof Element === "undefined" || + typeof HTMLElement === "undefined" + ) { var contRect = setting.treeObj.get(0).getBoundingClientRect(), findMeRect = dom.getBoundingClientRect(); - if (findMeRect.top < contRect.top || findMeRect.bottom > contRect.bottom - || findMeRect.right > contRect.right || findMeRect.left < contRect.left) { + if ( + findMeRect.top < contRect.top || + findMeRect.bottom > contRect.bottom || + findMeRect.right > contRect.right || + findMeRect.left < contRect.left + ) { dom.scrollIntoView(); } return; } // CC-BY jocki84@googlemail.com, https://gist.github.com/jocki84/6ffafd003387179a988e if (!Element.prototype.scrollIntoViewIfNeeded) { - Element.prototype.scrollIntoViewIfNeeded = function (centerIfNeeded) { + Element.prototype.scrollIntoViewIfNeeded = function(centerIfNeeded) { "use strict"; function makeRange(start, length) { - return { "start": start, "length": length, "end": start + length }; + return { start: start, length: length, end: start + length }; } function coverRange(inner, outer) { @@ -1513,11 +1987,11 @@ function makePoint(x, y) { return { - "x": x, - "y": y, - "translate": function translate(dX, dY) { + x: x, + y: y, + translate: function translate(dX, dY) { return makePoint(x + dX, y + dY); - } + }, }; } @@ -1536,7 +2010,10 @@ while (elem instanceof HTMLElement) { // Apply desired scroll amount. - origin = absolute(elem, makePoint(elem.clientLeft, elem.clientTop)); + origin = absolute( + elem, + makePoint(elem.clientLeft, elem.clientTop) + ); elem.scrollLeft = coverRange( makeRange(target.x - origin.x, extent.x), makeRange(elem.scrollLeft, elem.clientWidth) @@ -1554,28 +2031,28 @@ } dom.scrollIntoViewIfNeeded(); }, - setFirstNode: function (setting, parentNode) { + setFirstNode: function(setting, parentNode) { var children = data.nodeChildren(setting, parentNode); if (children.length > 0) { children[0].isFirstNode = true; } }, - setLastNode: function (setting, parentNode) { + setLastNode: function(setting, parentNode) { var children = data.nodeChildren(setting, parentNode); if (children.length > 0) { children[children.length - 1].isLastNode = true; } }, - removeNode: function (setting, node) { + removeNode: function(setting, node) { var root = data.getRoot(setting), - parentNode = (node.parentTId) ? node.getParentNode() : root; + parentNode = node.parentTId ? node.getParentNode() : root; node.isFirstNode = false; node.isLastNode = false; - node.getPreNode = function () { + node.getPreNode = function() { return null; }; - node.getNextNode = function () { + node.getNextNode = function() { return null; }; @@ -1597,7 +2074,9 @@ view.setFirstNode(setting, parentNode); view.setLastNode(setting, parentNode); - var tmp_ulObj, tmp_switchObj, tmp_icoObj, + var tmp_ulObj, + tmp_switchObj, + tmp_icoObj, childLength = children.length; //repair nodes old parent @@ -1609,10 +2088,13 @@ tmp_ulObj = $$(parentNode, consts.id.UL, setting); tmp_switchObj = $$(parentNode, consts.id.SWITCH, setting); tmp_icoObj = $$(parentNode, consts.id.ICON, setting); - view.replaceSwitchClass(parentNode, tmp_switchObj, consts.folder.DOCU); + view.replaceSwitchClass( + parentNode, + tmp_switchObj, + consts.folder.DOCU + ); view.replaceIcoClass(parentNode, tmp_icoObj, consts.folder.DOCU); tmp_ulObj.css("display", "none"); - } else if (setting.view.showLine && childLength > 0) { //old parentNode has child nodes var newLast = children[childLength - 1]; @@ -1624,9 +2106,21 @@ //node was root, and ztree has only one root after move node view.replaceSwitchClass(newLast, tmp_switchObj, consts.line.ROOT); } else { - var tmp_first_switchObj = $$(children[0], consts.id.SWITCH, setting); - view.replaceSwitchClass(children[0], tmp_first_switchObj, consts.line.ROOTS); - view.replaceSwitchClass(newLast, tmp_switchObj, consts.line.BOTTOM); + var tmp_first_switchObj = $$( + children[0], + consts.id.SWITCH, + setting + ); + view.replaceSwitchClass( + children[0], + tmp_first_switchObj, + consts.line.ROOTS + ); + view.replaceSwitchClass( + newLast, + tmp_switchObj, + consts.line.BOTTOM + ); } } else { view.replaceSwitchClass(newLast, tmp_switchObj, consts.line.BOTTOM); @@ -1634,7 +2128,7 @@ tmp_ulObj.removeClass(consts.line.LINE); } }, - replaceIcoClass: function (node, obj, newName) { + replaceIcoClass: function(node, obj, newName) { if (!obj || node.isAjaxing) return; var tmpName = obj.attr("class"); if (tmpName == undefined) return; @@ -1648,7 +2142,7 @@ } obj.attr("class", tmpList.join("_")); }, - replaceSwitchClass: function (node, obj, newName) { + replaceSwitchClass: function(node, obj, newName) { if (!obj) return; var tmpName = obj.attr("class"); if (tmpName == undefined) return; @@ -1674,7 +2168,7 @@ obj.attr("disabled", "disabled"); } }, - selectNode: function (setting, node, addFlag) { + selectNode: function(setting, node, addFlag) { // debugger if (!addFlag) { view.cancelPreSelectedNode(setting, null, node); @@ -1683,24 +2177,24 @@ data.addSelectedNode(setting, node); setting.treeObj.trigger(consts.event.SELECTED, [setting.treeId, node]); }, - setNodeFontCss: function (setting, treeNode) { + setNodeFontCss: function(setting, treeNode) { var aObj = $$(treeNode, consts.id.A, setting), fontCss = view.makeNodeFontCss(setting, treeNode); if (fontCss) { aObj.css(fontCss); } }, - setNodeClasses: function (setting, treeNode) { + setNodeClasses: function(setting, treeNode) { var aObj = $$(treeNode, consts.id.A, setting), classes = view.makeNodeClasses(setting, treeNode); - if ('add' in classes && classes.add.length) { - aObj.addClass(classes.add.join(' ')); + if ("add" in classes && classes.add.length) { + aObj.addClass(classes.add.join(" ")); } - if ('remove' in classes && classes.remove.length) { - aObj.removeClass(classes.remove.join(' ')); + if ("remove" in classes && classes.remove.length) { + aObj.removeClass(classes.remove.join(" ")); } }, - setNodeLineIcos: function (setting, node) { + setNodeLineIcos: function(setting, node) { if (!node) return; var switchObj = $$(node, consts.id.SWITCH, setting), ulObj = $$(node, consts.id.UL, setting), @@ -1722,7 +2216,7 @@ icoObj.attr("class", view.makeNodeIcoClass(setting, node)); // icoObj.attr("class", view.makeNodeNameClass(setting, node)); }, - setNodeName: function (setting, node) { + setNodeName: function(setting, node) { var title = data.nodeTitle(setting, node), nObj = $$(node, consts.id.SPAN, setting); nObj.empty(); @@ -1731,16 +2225,22 @@ } else { nObj.text(data.nodeName(setting, node)); } - if (tools.apply(setting.view.showTitle, [setting.treeId, node], setting.view.showTitle)) { + if ( + tools.apply( + setting.view.showTitle, + [setting.treeId, node], + setting.view.showTitle + ) + ) { var aObj = $$(node, consts.id.A, setting); aObj.attr("title", !title ? "" : title); } }, - setNodeTarget: function (setting, node) { + setNodeTarget: function(setting, node) { var aObj = $$(node, consts.id.A, setting); aObj.attr("target", view.makeNodeTarget(node)); }, - setNodeUrl: function (setting, node) { + setNodeUrl: function(setting, node) { var aObj = $$(node, consts.id.A, setting), url = view.makeNodeUrl(setting, node); if (url == null || url.length == 0) { @@ -1749,7 +2249,7 @@ aObj.attr("href", url); } }, - switchNode: function (setting, node) { + switchNode: function(setting, node) { if (node.open || !tools.canAsync(setting, node)) { view.expandCollapseNode(setting, node, !node.open); } else if (setting.async.enable) { @@ -1760,7 +2260,7 @@ } else if (node) { view.expandCollapseNode(setting, node, !node.open); } - } + }, }; // zTree defind $.fn.zTree = { @@ -1769,13 +2269,13 @@ tools: tools, view: view, event: event, - data: data + data: data, }, - getZTreeObj: function (treeId) { + getZTreeObj: function(treeId) { var o = data.getZTreeTools(treeId); return o ? o : null; }, - destroy: function (treeId) { + destroy: function(treeId) { if (!!treeId && treeId.length > 0) { view.destroy(data.getSetting(treeId)); } else { @@ -1784,7 +2284,7 @@ } } }, - init: function (obj, zSetting, zNodes) { + init: function(obj, zSetting, zNodes) { var setting = tools.clone(_setting); $.extend(true, setting, zSetting); setting.treeId = obj.attr("id"); @@ -1797,9 +2297,15 @@ } data.initRoot(setting); var root = data.getRoot(setting); - zNodes = zNodes ? tools.clone(tools.isArray(zNodes) ? zNodes : [zNodes]) : []; + zNodes = zNodes + ? tools.clone(tools.isArray(zNodes) ? zNodes : [zNodes]) + : []; if (setting.data.simpleData.enable) { - data.nodeChildren(setting, root, data.transformTozTreeFormat(setting, zNodes)); + data.nodeChildren( + setting, + root, + data.transformTozTreeFormat(setting, zNodes) + ); } else { data.nodeChildren(setting, root, zNodes); } @@ -1812,7 +2318,7 @@ var zTreeTools = { setting: setting, - addNodes: function (parentNode, index, newNodes, isSilent) { + addNodes: function(parentNode, index, newNodes, isSilent) { if (!parentNode) parentNode = null; var isParent = data.nodeIsParent(setting, parentNode); if (parentNode && !isParent && setting.data.keep.leaf) return null; @@ -1827,11 +2333,18 @@ } if (!newNodes) return null; - - var xNewNodes = tools.clone(tools.isArray(newNodes) ? newNodes : [newNodes]); + var xNewNodes = tools.clone( + tools.isArray(newNodes) ? newNodes : [newNodes] + ); function addCallback() { - view.addNodes(setting, parentNode, index, xNewNodes, (isSilent == true)); + view.addNodes( + setting, + parentNode, + index, + xNewNodes, + isSilent == true + ); } if (tools.canAsync(setting, parentNode)) { @@ -1841,31 +2354,52 @@ } return xNewNodes; }, - cancelSelectedNode: function (node) { + cancelSelectedNode: function(node) { view.cancelPreSelectedNode(setting, node); }, - destroy: function () { + destroy: function() { view.destroy(setting); }, - expandAll: function (expandFlag) { + expandAll: function(expandFlag) { expandFlag = !!expandFlag; view.expandCollapseSonNode(setting, null, expandFlag, true); return expandFlag; }, - expandNode: function (node, expandFlag, sonSign, focus, callbackFlag) { + expandNode: function(node, expandFlag, sonSign, focus, callbackFlag) { if (!node || !data.nodeIsParent(setting, node)) return null; if (expandFlag !== true && expandFlag !== false) { expandFlag = !node.open; } callbackFlag = !!callbackFlag; - if (callbackFlag && expandFlag && (tools.apply(setting.callback.beforeExpand, [setting.treeId, node], true) == false)) { + if ( + callbackFlag && + expandFlag && + tools.apply( + setting.callback.beforeExpand, + [setting.treeId, node], + true + ) == false + ) { return null; - } else if (callbackFlag && !expandFlag && (tools.apply(setting.callback.beforeCollapse, [setting.treeId, node], true) == false)) { + } else if ( + callbackFlag && + !expandFlag && + tools.apply( + setting.callback.beforeCollapse, + [setting.treeId, node], + true + ) == false + ) { return null; } if (expandFlag && node.parentTId) { - view.expandCollapseParentNode(setting, node.getParentNode(), expandFlag, false); + view.expandCollapseParentNode( + setting, + node.getParentNode(), + expandFlag, + false + ); } if (expandFlag === node.open && !sonSign) { return null; @@ -1873,7 +2407,13 @@ data.getRoot(setting).expandTriggerFlag = callbackFlag; if (!tools.canAsync(setting, node) && sonSign) { - view.expandCollapseSonNode(setting, node, expandFlag, true, showNodeFocus); + view.expandCollapseSonNode( + setting, + node, + expandFlag, + true, + showNodeFocus + ); } else { node.open = !expandFlag; view.switchNode(this.setting, node); @@ -1888,61 +2428,104 @@ } } }, - getNodes: function () { + getNodes: function() { return data.getNodes(setting); }, - getNodeByParam: function (key, value, parentNode) { + getNodeByParam: function(key, value, parentNode) { if (!key) return null; - return data.getNodeByParam(setting, parentNode ? data.nodeChildren(setting, parentNode) : data.getNodes(setting), key, value); + return data.getNodeByParam( + setting, + parentNode + ? data.nodeChildren(setting, parentNode) + : data.getNodes(setting), + key, + value + ); }, - getNodeByTId: function (tId) { + getNodeByTId: function(tId) { return data.getNodeCache(setting, tId); }, - getNodesByParam: function (key, value, parentNode) { + getNodesByParam: function(key, value, parentNode) { if (!key) return null; - return data.getNodesByParam(setting, parentNode ? data.nodeChildren(setting, parentNode) : data.getNodes(setting), key, value); + return data.getNodesByParam( + setting, + parentNode + ? data.nodeChildren(setting, parentNode) + : data.getNodes(setting), + key, + value + ); }, - getNodesByParamFuzzy: function (key, value, parentNode) { + getNodesByParamFuzzy: function(key, value, parentNode) { if (!key) return null; - return data.getNodesByParamFuzzy(setting, parentNode ? data.nodeChildren(setting, parentNode) : data.getNodes(setting), key, value); + return data.getNodesByParamFuzzy( + setting, + parentNode + ? data.nodeChildren(setting, parentNode) + : data.getNodes(setting), + key, + value + ); }, - getNodesByFilter: function (filter, isSingle, parentNode, invokeParam) { + getNodesByFilter: function(filter, isSingle, parentNode, invokeParam) { isSingle = !!isSingle; - if (!filter || (typeof filter != "function")) return (isSingle ? null : []); - return data.getNodesByFilter(setting, parentNode ? data.nodeChildren(setting, parentNode) : data.getNodes(setting), filter, isSingle, invokeParam); + if (!filter || typeof filter != "function") + return isSingle ? null : []; + return data.getNodesByFilter( + setting, + parentNode + ? data.nodeChildren(setting, parentNode) + : data.getNodes(setting), + filter, + isSingle, + invokeParam + ); }, - getNodeIndex: function (node) { + getNodeIndex: function(node) { if (!node) return null; - var parentNode = (node.parentTId) ? node.getParentNode() : data.getRoot(setting); + var parentNode = node.parentTId + ? node.getParentNode() + : data.getRoot(setting); var children = data.nodeChildren(setting, parentNode); for (var i = 0, l = children.length; i < l; i++) { if (children[i] == node) return i; } return -1; }, - getSelectedNodes: function () { - var r = [], list = data.getRoot(setting).curSelectedList; + getSelectedNodes: function() { + var r = [], + list = data.getRoot(setting).curSelectedList; for (var i = 0, l = list.length; i < l; i++) { r.push(list[i]); } return r; }, - isSelectedNode: function (node) { + isSelectedNode: function(node) { return data.isSelectedNode(setting, node); }, - reAsyncChildNodesPromise: function (parentNode, reloadType, isSilent) { - var promise = new Promise(function (resolve, reject) { + reAsyncChildNodesPromise: function(parentNode, reloadType, isSilent) { + var promise = new Promise(function(resolve, reject) { try { - zTreeTools.reAsyncChildNodes(parentNode, reloadType, isSilent, function () { - resolve(parentNode); - }); + zTreeTools.reAsyncChildNodes( + parentNode, + reloadType, + isSilent, + function() { + resolve(parentNode); + } + ); } catch (e) { reject(e); } }); return promise; }, - reAsyncChildNodes: function (parentNode, reloadType, isSilent, callback) { + reAsyncChildNodes: function( + parentNode, + reloadType, + isSilent, + callback + ) { if (!this.setting.async.enable) return; var isRoot = !parentNode; if (isRoot) { @@ -1962,43 +2545,72 @@ ulObj.empty(); } } - view.asyncNode(this.setting, isRoot ? null : parentNode, !!isSilent, callback); + view.asyncNode( + this.setting, + isRoot ? null : parentNode, + !!isSilent, + callback + ); }, - refresh: function () { + refresh: function() { this.setting.treeObj.empty(); var root = data.getRoot(setting), nodes = data.nodeChildren(setting, root); data.initRoot(setting); data.nodeChildren(setting, root, nodes); data.initCache(setting); - view.createNodes(setting, 0, data.nodeChildren(setting, root), null, -1); + view.createNodes( + setting, + 0, + data.nodeChildren(setting, root), + null, + -1 + ); }, - removeChildNodes: function (node) { + removeChildNodes: function(node) { if (!node) return null; var nodes = data.nodeChildren(setting, node); view.removeChildNodes(setting, node); return nodes ? nodes : null; }, - removeNode: function (node, callbackFlag) { + removeNode: function(node, callbackFlag) { if (!node) return; callbackFlag = !!callbackFlag; - if (callbackFlag && tools.apply(setting.callback.beforeRemove, [setting.treeId, node], true) == false) return; + if ( + callbackFlag && + tools.apply( + setting.callback.beforeRemove, + [setting.treeId, node], + true + ) == false + ) + return; view.removeNode(setting, node); if (callbackFlag) { - this.setting.treeObj.trigger(consts.event.REMOVE, [setting.treeId, node]); + this.setting.treeObj.trigger(consts.event.REMOVE, [ + setting.treeId, + node, + ]); } }, - selectNode: function (node, addFlag, isSilent) { + selectNode: function(node, addFlag, isSilent) { if (!node) return; if (tools.uCanDo(setting)) { addFlag = setting.view.selectedMulti && addFlag; if (node.parentTId) { - view.expandCollapseParentNode(setting, node.getParentNode(), true, false, showNodeFocus); + view.expandCollapseParentNode( + setting, + node.getParentNode(), + true, + false, + showNodeFocus + ); } else if (!isSilent) { try { - $$(node, setting).focus().blur(); - } catch (e) { - } + $$(node, setting) + .focus() + .blur(); + } catch (e) {} } view.selectNode(setting, node, addFlag); } @@ -2011,13 +2623,13 @@ view.scrollIntoView(setting, a); } }, - transformTozTreeNodes: function (simpleNodes) { + transformTozTreeNodes: function(simpleNodes) { return data.transformTozTreeFormat(setting, simpleNodes); }, - transformToArray: function (nodes) { + transformToArray: function(nodes) { return data.transformToArrayFormat(setting, nodes); }, - updateNode: function (node, checkTypeFlag) { + updateNode: function(node, checkTypeFlag) { if (!node) return; var nObj = $$(node, setting); if (nObj.get(0) && tools.uCanDo(setting)) { @@ -2028,18 +2640,22 @@ view.setNodeFontCss(setting, node); view.setNodeClasses(setting, node); } - } + }, }; root.treeTools = zTreeTools; data.setZTreeTools(setting, zTreeTools); var children = data.nodeChildren(setting, root); if (children && children.length > 0) { view.createNodes(setting, 0, children, null, -1); - } else if (setting.async.enable && setting.async.url && setting.async.url !== '') { + } else if ( + setting.async.enable && + setting.async.url && + setting.async.url !== "" + ) { view.asyncNode(setting); } return zTreeTools; - } + }, }; var zt = $.fn.zTree, @@ -2059,31 +2675,31 @@ * Date: 2020-11-21 */ -(function ($) { +(function($) { //default consts of excheck var _consts = { - event: { - CHECK: "ztree_check" + event: { + CHECK: "ztree_check", + }, + id: { + CHECK: "_check", + }, + checkbox: { + STYLE: "checkbox", + DEFAULT: "chk", + DISABLED: "disable", + FALSE: "false", + TRUE: "true", + FULL: "full", + PART: "part", + FOCUS: "focus", + }, + radio: { + STYLE: "radio", + TYPE_ALL: "all", + TYPE_LEVEL: "level", + }, }, - id: { - CHECK: "_check" - }, - checkbox: { - STYLE: "checkbox", - DEFAULT: "chk", - DISABLED: "disable", - FALSE: "false", - TRUE: "true", - FULL: "full", - PART: "part", - FOCUS: "focus" - }, - radio: { - STYLE: "radio", - TYPE_ALL: "all", - TYPE_LEVEL: "level" - } - }, //default setting of excheck _setting = { check: { @@ -2094,62 +2710,76 @@ chkDisabledInherit: false, radioType: _consts.radio.TYPE_LEVEL, chkboxType: { - "Y": "ps", - "N": "ps" - } + Y: "ps", + N: "ps", + }, }, data: { key: { - checked: "checked" - } + checked: "checked", + }, }, callback: { beforeCheck: null, - onCheck: null - } + onCheck: null, + }, }, //default root of excheck - _initRoot = function (setting) { + _initRoot = function(setting) { var r = data.getRoot(setting); r.radioCheckedList = []; }, //default cache of excheck - _initCache = function (treeId) { - }, + _initCache = function(treeId) {}, //default bind event of excheck - _bindEvent = function (setting) { + _bindEvent = function(setting) { var o = setting.treeObj, c = consts.event; - o.bind(c.CHECK, function (event, srcEvent, treeId, node) { + o.bind(c.CHECK, function(event, srcEvent, treeId, node) { event.srcEvent = srcEvent; tools.apply(setting.callback.onCheck, [event, treeId, node]); }); }, - _unbindEvent = function (setting) { + _unbindEvent = function(setting) { var o = setting.treeObj, c = consts.event; o.unbind(c.CHECK); }, //default event proxy of excheck - _eventProxy = function (e) { + _eventProxy = function(e) { var target = e.target, setting = data.getSetting(e.data.treeId), - tId = "", node = null, - nodeEventType = "", treeEventType = "", - nodeEventCallback = null, treeEventCallback = null; + tId = "", + node = null, + nodeEventType = "", + treeEventType = "", + nodeEventCallback = null, + treeEventCallback = null; if (tools.eqs(e.type, "mouseover")) { - if (setting.check.enable && tools.eqs(target.tagName, "span") && target.getAttribute("treeNode" + consts.id.CHECK) !== null) { + if ( + setting.check.enable && + tools.eqs(target.tagName, "span") && + target.getAttribute("treeNode" + consts.id.CHECK) !== null + ) { tId = tools.getNodeMainDom(target).id; nodeEventType = "mouseoverCheck"; } } else if (tools.eqs(e.type, "mouseout")) { - if (setting.check.enable && tools.eqs(target.tagName, "span") && target.getAttribute("treeNode" + consts.id.CHECK) !== null) { + if ( + setting.check.enable && + tools.eqs(target.tagName, "span") && + target.getAttribute("treeNode" + consts.id.CHECK) !== null + ) { tId = tools.getNodeMainDom(target).id; nodeEventType = "mouseoutCheck"; } } else if (tools.eqs(e.type, "click")) { - if (setting.check.enable && tools.eqs(target.tagName, "span") && target.getAttribute("treeNode" + consts.id.CHECK) !== null) { + if ( + setting.check.enable && + tools.eqs(target.tagName, "span") && + target.getAttribute("treeNode" + consts.id.CHECK) !== null + ) { tId = tools.getNodeMainDom(target).id; nodeEventType = "checkNode"; } @@ -2174,42 +2804,78 @@ nodeEventType: nodeEventType, nodeEventCallback: nodeEventCallback, treeEventType: treeEventType, - treeEventCallback: treeEventCallback + treeEventCallback: treeEventCallback, }; - return proxyResult + return proxyResult; }, //default init node of excheck - _initNode = function (setting, level, n, parentNode, isFirstNode, isLastNode, openFlag) { + _initNode = function( + setting, + level, + n, + parentNode, + isFirstNode, + isLastNode, + openFlag + ) { if (!n) return; var checked = data.nodeChecked(setting, n); n.checkedOld = checked; - if (typeof n.nocheck == "string") n.nocheck = tools.eqs(n.nocheck, "true"); - n.nocheck = !!n.nocheck || (setting.check.nocheckInherit && parentNode && !!parentNode.nocheck); - if (typeof n.chkDisabled == "string") n.chkDisabled = tools.eqs(n.chkDisabled, "true"); - n.chkDisabled = !!n.chkDisabled || (setting.check.chkDisabledInherit && parentNode && !!parentNode.chkDisabled); - if (typeof n.halfCheck == "string") n.halfCheck = tools.eqs(n.halfCheck, "true"); + if (typeof n.nocheck == "string") + n.nocheck = tools.eqs(n.nocheck, "true"); + n.nocheck = + !!n.nocheck || + (setting.check.nocheckInherit && parentNode && !!parentNode.nocheck); + if (typeof n.chkDisabled == "string") + n.chkDisabled = tools.eqs(n.chkDisabled, "true"); + n.chkDisabled = + !!n.chkDisabled || + (setting.check.chkDisabledInherit && + parentNode && + !!parentNode.chkDisabled); + if (typeof n.halfCheck == "string") + n.halfCheck = tools.eqs(n.halfCheck, "true"); n.halfCheck = !!n.halfCheck; n.check_Child_State = -1; n.check_Focus = false; - n.getCheckStatus = function () { + n.getCheckStatus = function() { return data.getCheckStatus(setting, n); }; - if (setting.check.chkStyle == consts.radio.STYLE && setting.check.radioType == consts.radio.TYPE_ALL && checked) { + if ( + setting.check.chkStyle == consts.radio.STYLE && + setting.check.radioType == consts.radio.TYPE_ALL && + checked + ) { var r = data.getRoot(setting); r.radioCheckedList.push(n); } }, //add dom for check - _beforeA = function (setting, node, html) { + _beforeA = function(setting, node, html) { if (setting.check.enable) { data.makeChkFlag(setting, node); - html.push("<span ID='", node.tId, consts.id.CHECK, "' class='", view.makeChkClass(setting, node), "' treeNode", consts.id.CHECK, (node.nocheck === true ? " style='display:none;'" : ""), "></span>"); + html.push( + "<span ID='", + node.tId, + consts.id.CHECK, + "' class='", + view.makeChkClass(setting, node), + "' treeNode", + consts.id.CHECK, + node.nocheck === true ? " style='display:none;'" : "", + "></span>" + ); } }, //update zTreeObj, add method of check - _zTreeTools = function (setting, zTreeTools) { - zTreeTools.checkNode = function (node, checked, checkTypeFlag, callbackFlag) { + _zTreeTools = function(setting, zTreeTools) { + zTreeTools.checkNode = function( + node, + checked, + checkTypeFlag, + callbackFlag + ) { var nodeChecked = data.nodeChecked(setting, node); if (node.chkDisabled === true) return; if (checked !== true && checked !== false) { @@ -2219,60 +2885,98 @@ if (nodeChecked === checked && !checkTypeFlag) { return; - } else if (callbackFlag && tools.apply(this.setting.callback.beforeCheck, [this.setting.treeId, node], true) == false) { + } else if ( + callbackFlag && + tools.apply( + this.setting.callback.beforeCheck, + [this.setting.treeId, node], + true + ) == false + ) { return; } - if (tools.uCanDo(this.setting) && this.setting.check.enable && node.nocheck !== true) { + if ( + tools.uCanDo(this.setting) && + this.setting.check.enable && + node.nocheck !== true + ) { data.nodeChecked(setting, node, checked); var checkObj = $$(node, consts.id.CHECK, this.setting); - if (checkTypeFlag || this.setting.check.chkStyle === consts.radio.STYLE) view.checkNodeRelation(this.setting, node); + if ( + checkTypeFlag || + this.setting.check.chkStyle === consts.radio.STYLE + ) + view.checkNodeRelation(this.setting, node); view.setChkClass(this.setting, checkObj, node); view.repairParentChkClassWithSelf(this.setting, node); if (callbackFlag) { - this.setting.treeObj.trigger(consts.event.CHECK, [null, this.setting.treeId, node]); + this.setting.treeObj.trigger(consts.event.CHECK, [ + null, + this.setting.treeId, + node, + ]); } } - } + }; - zTreeTools.checkAllNodes = function (checked) { + zTreeTools.checkAllNodes = function(checked) { view.repairAllChk(this.setting, !!checked); - } + }; - zTreeTools.getCheckedNodes = function (checked) { - checked = (checked !== false); + zTreeTools.getCheckedNodes = function(checked) { + checked = checked !== false; var children = data.nodeChildren(setting, data.getRoot(this.setting)); return data.getTreeCheckedNodes(this.setting, children, checked); - } + }; - zTreeTools.getChangeCheckedNodes = function () { + zTreeTools.getChangeCheckedNodes = function() { var children = data.nodeChildren(setting, data.getRoot(this.setting)); return data.getTreeChangeCheckedNodes(this.setting, children); - } + }; - zTreeTools.setChkDisabled = function (node, disabled, inheritParent, inheritChildren) { + zTreeTools.setChkDisabled = function( + node, + disabled, + inheritParent, + inheritChildren + ) { disabled = !!disabled; inheritParent = !!inheritParent; inheritChildren = !!inheritChildren; - view.repairSonChkDisabled(this.setting, node, disabled, inheritChildren); - view.repairParentChkDisabled(this.setting, node.getParentNode(), disabled, inheritParent); - } + view.repairSonChkDisabled( + this.setting, + node, + disabled, + inheritChildren + ); + view.repairParentChkDisabled( + this.setting, + node.getParentNode(), + disabled, + inheritParent + ); + }; var _updateNode = zTreeTools.updateNode; - zTreeTools.updateNode = function (node, checkTypeFlag) { + zTreeTools.updateNode = function(node, checkTypeFlag) { if (_updateNode) _updateNode.apply(zTreeTools, arguments); if (!node || !this.setting.check.enable) return; var nObj = $$(node, this.setting); if (nObj.get(0) && tools.uCanDo(this.setting)) { var checkObj = $$(node, consts.id.CHECK, this.setting); - if (checkTypeFlag == true || this.setting.check.chkStyle === consts.radio.STYLE) view.checkNodeRelation(this.setting, node); + if ( + checkTypeFlag == true || + this.setting.check.chkStyle === consts.radio.STYLE + ) + view.checkNodeRelation(this.setting, node); view.setChkClass(this.setting, checkObj, node); view.repairParentChkClassWithSelf(this.setting, node); } - } + }; }, //method of operate data _data = { - getRadioCheckedList: function (setting) { + getRadioCheckedList: function(setting) { var checkedList = data.getRoot(setting).radioCheckedList; for (var i = 0, j = checkedList.length; i < j; i++) { if (!data.getNodeCache(setting, checkedList[i].tId)) { @@ -2283,24 +2987,38 @@ } return checkedList; }, - getCheckStatus: function (setting, node) { - if (!setting.check.enable || node.nocheck || node.chkDisabled) return null; + getCheckStatus: function(setting, node) { + if (!setting.check.enable || node.nocheck || node.chkDisabled) + return null; var checked = data.nodeChecked(setting, node), r = { checked: checked, - half: node.halfCheck ? node.halfCheck : (setting.check.chkStyle == consts.radio.STYLE ? (node.check_Child_State === 2) : (checked ? (node.check_Child_State > -1 && node.check_Child_State < 2) : (node.check_Child_State > 0))) + half: node.halfCheck + ? node.halfCheck + : setting.check.chkStyle == consts.radio.STYLE + ? node.check_Child_State === 2 + : checked + ? node.check_Child_State > -1 && node.check_Child_State < 2 + : node.check_Child_State > 0, }; return r; }, - getTreeCheckedNodes: function (setting, nodes, checked, results) { + getTreeCheckedNodes: function(setting, nodes, checked, results) { if (!nodes) return []; - var onlyOne = (checked && setting.check.chkStyle == consts.radio.STYLE && setting.check.radioType == consts.radio.TYPE_ALL); + var onlyOne = + checked && + setting.check.chkStyle == consts.radio.STYLE && + setting.check.radioType == consts.radio.TYPE_ALL; results = !results ? [] : results; for (var i = 0, l = nodes.length; i < l; i++) { var node = nodes[i]; var children = data.nodeChildren(setting, node); var nodeChecked = data.nodeChecked(setting, node); - if (node.nocheck !== true && node.chkDisabled !== true && nodeChecked == checked) { + if ( + node.nocheck !== true && + node.chkDisabled !== true && + nodeChecked == checked + ) { results.push(node); if (onlyOne) { break; @@ -2313,21 +3031,25 @@ } return results; }, - getTreeChangeCheckedNodes: function (setting, nodes, results) { + getTreeChangeCheckedNodes: function(setting, nodes, results) { if (!nodes) return []; results = !results ? [] : results; for (var i = 0, l = nodes.length; i < l; i++) { var node = nodes[i]; var children = data.nodeChildren(setting, node); var nodeChecked = data.nodeChecked(setting, node); - if (node.nocheck !== true && node.chkDisabled !== true && nodeChecked != node.checkedOld) { + if ( + node.nocheck !== true && + node.chkDisabled !== true && + nodeChecked != node.checkedOld + ) { results.push(node); } data.getTreeChangeCheckedNodes(setting, children, results); } return results; }, - makeChkFlag: function (setting, node) { + makeChkFlag: function(setting, node) { if (!node) return; var chkFlag = -1; var children = data.nodeChildren(setting, node); @@ -2358,14 +3080,23 @@ } else if (cNode.halfCheck === true) { tmp = 1; } else if (nodeChecked) { - tmp = (cNode.check_Child_State === -1 || cNode.check_Child_State === 2) ? 2 : 1; + tmp = + cNode.check_Child_State === -1 || + cNode.check_Child_State === 2 + ? 2 + : 1; } else { - tmp = (cNode.check_Child_State > 0) ? 1 : 0; + tmp = cNode.check_Child_State > 0 ? 1 : 0; } if (tmp === 1) { chkFlag = 1; break; - } else if (tmp === 2 && chkFlag > -1 && i > 0 && tmp !== chkFlag) { + } else if ( + tmp === 2 && + chkFlag > -1 && + i > 0 && + tmp !== chkFlag + ) { chkFlag = 1; break; } else if (chkFlag === 2 && tmp > -1 && tmp < 2) { @@ -2378,26 +3109,37 @@ } } node.check_Child_State = chkFlag; - } + }, }, //method of event proxy _event = {}, //method of event handler _handler = { - onCheckNode: function (event, node) { + onCheckNode: function(event, node) { if (node.chkDisabled === true) return false; var setting = data.getSetting(event.data.treeId); - if (tools.apply(setting.callback.beforeCheck, [setting.treeId, node], true) == false) return true; + if ( + tools.apply( + setting.callback.beforeCheck, + [setting.treeId, node], + true + ) == false + ) + return true; var nodeChecked = data.nodeChecked(setting, node); data.nodeChecked(setting, node, !nodeChecked); view.checkNodeRelation(setting, node); var checkObj = $$(node, consts.id.CHECK, setting); view.setChkClass(setting, checkObj, node); view.repairParentChkClassWithSelf(setting, node); - setting.treeObj.trigger(consts.event.CHECK, [event, setting.treeId, node]); + setting.treeObj.trigger(consts.event.CHECK, [ + event, + setting.treeId, + node, + ]); return true; }, - onMouseoverCheck: function (event, node) { + onMouseoverCheck: function(event, node) { if (node.chkDisabled === true) return false; var setting = data.getSetting(event.data.treeId), checkObj = $$(node, consts.id.CHECK, setting); @@ -2405,21 +3147,23 @@ view.setChkClass(setting, checkObj, node); return true; }, - onMouseoutCheck: function (event, node) { + onMouseoutCheck: function(event, node) { if (node.chkDisabled === true) return false; var setting = data.getSetting(event.data.treeId), checkObj = $$(node, consts.id.CHECK, setting); node.check_Focus = false; view.setChkClass(setting, checkObj, node); return true; - } + }, }, //method of tools for zTree _tools = {}, //method of operate ztree dom _view = { - checkNodeRelation: function (setting, node) { - var pNode, i, l, + checkNodeRelation: function(setting, node) { + var pNode, + i, + l, r = consts.radio; var nodeChecked = data.nodeChecked(setting, node); if (setting.check.chkStyle == r.STYLE) { @@ -2433,7 +3177,11 @@ data.nodeChecked(setting, pNode, false); checkedList.splice(i, 1); - view.setChkClass(setting, $$(pNode, consts.id.CHECK, setting), pNode); + view.setChkClass( + setting, + $$(pNode, consts.id.CHECK, setting), + pNode + ); if (pNode.parentTId != node.parentTId) { view.repairParentChkClassWithSelf(setting, pNode); } @@ -2441,14 +3189,20 @@ } checkedList.push(node); } else { - var parentNode = (node.parentTId) ? node.getParentNode() : data.getRoot(setting); + var parentNode = node.parentTId + ? node.getParentNode() + : data.getRoot(setting); var children = data.nodeChildren(setting, parentNode); for (i = 0, l = children.length; i < l; i++) { pNode = children[i]; var pNodeChecked = data.nodeChecked(setting, pNode); if (pNodeChecked && pNode != node) { data.nodeChecked(setting, pNode, false); - view.setChkClass(setting, $$(pNode, consts.id.CHECK, setting), pNode); + view.setChkClass( + setting, + $$(pNode, consts.id.CHECK, setting), + pNode + ); } } } @@ -2460,13 +3214,22 @@ } } } - } else { var children = data.nodeChildren(setting, node); - if (nodeChecked && (!children || children.length == 0 || setting.check.chkboxType.Y.indexOf("s") > -1)) { + if ( + nodeChecked && + (!children || + children.length == 0 || + setting.check.chkboxType.Y.indexOf("s") > -1) + ) { view.setSonNodeCheckBox(setting, node, true); } - if (!nodeChecked && (!children || children.length == 0 || setting.check.chkboxType.N.indexOf("s") > -1)) { + if ( + !nodeChecked && + (!children || + children.length == 0 || + setting.check.chkboxType.N.indexOf("s") > -1) + ) { view.setSonNodeCheckBox(setting, node, false); } if (nodeChecked && setting.check.chkboxType.Y.indexOf("p") > -1) { @@ -2477,8 +3240,9 @@ } } }, - makeChkClass: function (setting, node) { - var c = consts.checkbox, r = consts.radio, + makeChkClass: function(setting, node) { + var c = consts.checkbox, + r = consts.radio, fullStyle = ""; var nodeChecked = data.nodeChecked(setting, node); if (node.chkDisabled === true) { @@ -2486,16 +3250,33 @@ } else if (node.halfCheck) { fullStyle = c.PART; } else if (setting.check.chkStyle == r.STYLE) { - fullStyle = (node.check_Child_State < 1) ? c.FULL : c.PART; + fullStyle = node.check_Child_State < 1 ? c.FULL : c.PART; } else { - fullStyle = nodeChecked ? ((node.check_Child_State === 2 || node.check_Child_State === -1) ? c.FULL : c.PART) : ((node.check_Child_State < 1) ? c.FULL : c.PART); + fullStyle = nodeChecked + ? node.check_Child_State === 2 || node.check_Child_State === -1 + ? c.FULL + : c.PART + : node.check_Child_State < 1 + ? c.FULL + : c.PART; } - var chkName = setting.check.chkStyle + "_" + (nodeChecked ? c.TRUE : c.FALSE) + "_" + fullStyle; - chkName = (node.check_Focus && node.chkDisabled !== true) ? chkName + "_" + c.FOCUS : chkName; + var chkName = + setting.check.chkStyle + + "_" + + (nodeChecked ? c.TRUE : c.FALSE) + + "_" + + fullStyle; + chkName = + node.check_Focus && node.chkDisabled !== true + ? chkName + "_" + c.FOCUS + : chkName; return consts.className.BUTTON + " " + c.DEFAULT + " " + chkName; }, - repairAllChk: function (setting, checked) { - if (setting.check.enable && setting.check.chkStyle === consts.checkbox.STYLE) { + repairAllChk: function(setting, checked) { + if ( + setting.check.enable && + setting.check.chkStyle === consts.checkbox.STYLE + ) { var root = data.getRoot(setting); var children = data.nodeChildren(setting, root); for (var i = 0, l = children.length; i < l; i++) { @@ -2507,7 +3288,7 @@ } } }, - repairChkClass: function (setting, node) { + repairChkClass: function(setting, node) { if (!node) return; data.makeChkFlag(setting, node); if (node.nocheck !== true) { @@ -2515,13 +3296,13 @@ view.setChkClass(setting, checkObj, node); } }, - repairParentChkClass: function (setting, node) { + repairParentChkClass: function(setting, node) { if (!node || !node.parentTId) return; var pNode = node.getParentNode(); view.repairChkClass(setting, pNode); view.repairParentChkClass(setting, pNode); }, - repairParentChkClassWithSelf: function (setting, node) { + repairParentChkClassWithSelf: function(setting, node) { if (!node) return; var children = data.nodeChildren(setting, node); if (children && children.length > 0) { @@ -2530,7 +3311,7 @@ view.repairParentChkClass(setting, node); } }, - repairSonChkDisabled: function (setting, node, chkDisabled, inherit) { + repairSonChkDisabled: function(setting, node, chkDisabled, inherit) { if (!node) return; if (node.chkDisabled != chkDisabled) { node.chkDisabled = chkDisabled; @@ -2544,24 +3325,29 @@ } } }, - repairParentChkDisabled: function (setting, node, chkDisabled, inherit) { + repairParentChkDisabled: function(setting, node, chkDisabled, inherit) { if (!node) return; if (node.chkDisabled != chkDisabled && inherit) { node.chkDisabled = chkDisabled; } view.repairChkClass(setting, node); - view.repairParentChkDisabled(setting, node.getParentNode(), chkDisabled, inherit); + view.repairParentChkDisabled( + setting, + node.getParentNode(), + chkDisabled, + inherit + ); }, - setChkClass: function (setting, obj, node) { + setChkClass: function(setting, obj, node) { if (!obj) return; if (node.nocheck === true) { obj.hide(); } else { obj.show(); } - obj.attr('class', view.makeChkClass(setting, node)); + obj.attr("class", view.makeChkClass(setting, node)); }, - setParentNodeCheckBox: function (setting, node, value, srcNode) { + setParentNodeCheckBox: function(setting, node, value, srcNode) { var checkObj = $$(node, consts.id.CHECK, setting); if (!srcNode) srcNode = node; data.makeChkFlag(setting, node); @@ -2569,7 +3355,11 @@ data.nodeChecked(setting, node, value); view.setChkClass(setting, checkObj, node); if (setting.check.autoCheckTrigger && node != srcNode) { - setting.treeObj.trigger(consts.event.CHECK, [null, setting.treeId, node]); + setting.treeObj.trigger(consts.event.CHECK, [ + null, + setting.treeId, + node, + ]); } } if (node.parentTId) { @@ -2579,19 +3369,29 @@ for (var i = 0, l = pNodes.length; i < l; i++) { var pNode = pNodes[i]; var nodeChecked = data.nodeChecked(setting, pNode); - if ((pNode.nocheck !== true && pNode.chkDisabled !== true && nodeChecked) - || ((pNode.nocheck === true || pNode.chkDisabled === true) && pNode.check_Child_State > 0)) { + if ( + (pNode.nocheck !== true && + pNode.chkDisabled !== true && + nodeChecked) || + ((pNode.nocheck === true || pNode.chkDisabled === true) && + pNode.check_Child_State > 0) + ) { pSign = false; break; } } } if (pSign) { - view.setParentNodeCheckBox(setting, node.getParentNode(), value, srcNode); + view.setParentNodeCheckBox( + setting, + node.getParentNode(), + value, + srcNode + ); } } }, - setSonNodeCheckBox: function (setting, node, value, srcNode) { + setSonNodeCheckBox: function(setting, node, value, srcNode) { if (!node) return; var checkObj = $$(node, consts.id.CHECK, setting); if (!srcNode) srcNode = node; @@ -2612,24 +3412,33 @@ } if (node.nocheck !== true && node.chkDisabled !== true) { data.nodeChecked(setting, node, value); - if (!hasDisable) node.check_Child_State = (children && children.length > 0) ? (value ? 2 : 0) : -1; + if (!hasDisable) + node.check_Child_State = + children && children.length > 0 ? (value ? 2 : 0) : -1; } else { node.check_Child_State = -1; } view.setChkClass(setting, checkObj, node); - if (setting.check.autoCheckTrigger && node != srcNode && node.nocheck !== true && node.chkDisabled !== true) { - setting.treeObj.trigger(consts.event.CHECK, [null, setting.treeId, node]); + if ( + setting.check.autoCheckTrigger && + node != srcNode && + node.nocheck !== true && + node.chkDisabled !== true + ) { + setting.treeObj.trigger(consts.event.CHECK, [ + null, + setting.treeId, + node, + ]); } } - - } + }, }, - _z = { tools: _tools, view: _view, event: _event, - data: _data + data: _data, }; $.extend(true, $.fn.zTree.consts, _consts); $.extend(true, $.fn.zTree._z, _z); @@ -2642,12 +3451,12 @@ event = zt._z.event, $$ = tools.$; - data.nodeChecked = function (setting, node, newChecked) { + data.nodeChecked = function(setting, node, newChecked) { if (!node) { return false; } var key = setting.data.key.checked; - if (typeof newChecked !== 'undefined') { + if (typeof newChecked !== "undefined") { if (typeof newChecked === "string") { newChecked = tools.eqs(newChecked, "true"); } @@ -2672,22 +3481,30 @@ data.addZTreeTools(_zTreeTools); var _createNodes = view.createNodes; - view.createNodes = function (setting, level, nodes, parentNode, index) { + view.createNodes = function(setting, level, nodes, parentNode, index) { if (_createNodes) _createNodes.apply(view, arguments); if (!nodes) return; view.repairParentChkClassWithSelf(setting, parentNode); - } + }; var _removeNode = view.removeNode; - view.removeNode = function (setting, node) { + view.removeNode = function(setting, node) { var parentNode = node.getParentNode(); if (_removeNode) _removeNode.apply(view, arguments); if (!node || !parentNode) return; view.repairChkClass(setting, parentNode); view.repairParentChkClass(setting, parentNode); - } + }; var _appendNodes = view.appendNodes; - view.appendNodes = function (setting, level, nodes, parentNode, index, initFlag, openFlag) { + view.appendNodes = function( + setting, + level, + nodes, + parentNode, + index, + initFlag, + openFlag + ) { var html = ""; if (_appendNodes) { html = _appendNodes.apply(view, arguments); @@ -2696,7 +3513,7 @@ data.makeChkFlag(setting, parentNode); } return html; - } + }; })(jQuery); /* * JQuery zTree exedit @@ -2711,31 +3528,31 @@ * Date: 2020-11-21 */ -(function ($) { +(function($) { //default consts of exedit var _consts = { - event: { - DRAG: "ztree_drag", - DROP: "ztree_drop", - RENAME: "ztree_rename", - DRAGMOVE: "ztree_dragmove" + event: { + DRAG: "ztree_drag", + DROP: "ztree_drop", + RENAME: "ztree_rename", + DRAGMOVE: "ztree_dragmove", + }, + id: { + EDIT: "_edit", + INPUT: "_input", + REMOVE: "_remove", + }, + move: { + TYPE_INNER: "inner", + TYPE_PREV: "prev", + TYPE_NEXT: "next", + }, + node: { + CURSELECTED_EDIT: "curSelectedNode_Edit", + TMPTARGET_TREE: "tmpTargetzTree", + TMPTARGET_NODE: "tmpTargetNode", + }, }, - id: { - EDIT: "_edit", - INPUT: "_input", - REMOVE: "_remove" - }, - move: { - TYPE_INNER: "inner", - TYPE_PREV: "prev", - TYPE_NEXT: "next" - }, - node: { - CURSELECTED_EDIT: "curSelectedNode_Edit", - TMPTARGET_TREE: "tmpTargetzTree", - TMPTARGET_NODE: "tmpTargetNode" - } - }, //default setting of exedit _setting = { edit: { @@ -2756,12 +3573,12 @@ borderMax: 10, borderMin: -5, maxShowNodeNum: 5, - autoOpenTime: 500 - } + autoOpenTime: 500, + }, }, view: { addHoverDom: null, - removeHoverDom: null + removeHoverDom: null, }, callback: { beforeDrag: null, @@ -2772,12 +3589,13 @@ onDrag: null, onDragMove: null, onDrop: null, - onRename: null - } + onRename: null, + }, }, //default root of exedit - _initRoot = function (setting) { - var r = data.getRoot(setting), rs = data.getRoots(); + _initRoot = function(setting) { + var r = data.getRoot(setting), + rs = data.getRoots(); r.curEditNode = null; r.curEditInput = null; r.curHoverNode = null; @@ -2787,29 +3605,48 @@ rs.showHoverDom = true; }, //default cache of exedit - _initCache = function (treeId) { - }, + _initCache = function(treeId) {}, //default bind event of exedit - _bindEvent = function (setting) { + _bindEvent = function(setting) { var o = setting.treeObj; var c = consts.event; - o.bind(c.RENAME, function (event, treeId, treeNode, isCancel) { - tools.apply(setting.callback.onRename, [event, treeId, treeNode, isCancel]); + o.bind(c.RENAME, function(event, treeId, treeNode, isCancel) { + tools.apply(setting.callback.onRename, [ + event, + treeId, + treeNode, + isCancel, + ]); }); - o.bind(c.DRAG, function (event, srcEvent, treeId, treeNodes) { + o.bind(c.DRAG, function(event, srcEvent, treeId, treeNodes) { tools.apply(setting.callback.onDrag, [srcEvent, treeId, treeNodes]); }); - o.bind(c.DRAGMOVE, function (event, srcEvent, treeId, treeNodes) { + o.bind(c.DRAGMOVE, function(event, srcEvent, treeId, treeNodes) { tools.apply(setting.callback.onDragMove, [srcEvent, treeId, treeNodes]); }); - o.bind(c.DROP, function (event, srcEvent, treeId, treeNodes, targetNode, moveType, isCopy) { - tools.apply(setting.callback.onDrop, [srcEvent, treeId, treeNodes, targetNode, moveType, isCopy]); + o.bind(c.DROP, function( + event, + srcEvent, + treeId, + treeNodes, + targetNode, + moveType, + isCopy + ) { + tools.apply(setting.callback.onDrop, [ + srcEvent, + treeId, + treeNodes, + targetNode, + moveType, + isCopy, + ]); }); }, - _unbindEvent = function (setting) { + _unbindEvent = function(setting) { var o = setting.treeObj; var c = consts.event; o.unbind(c.RENAME); @@ -2818,29 +3655,38 @@ o.unbind(c.DROP); }, //default event proxy of exedit - _eventProxy = function (e) { + _eventProxy = function(e) { var target = e.target, setting = data.getSetting(e.data.treeId), relatedTarget = e.relatedTarget, - tId = "", node = null, - nodeEventType = "", treeEventType = "", - nodeEventCallback = null, treeEventCallback = null, + tId = "", + node = null, + nodeEventType = "", + treeEventType = "", + nodeEventCallback = null, + treeEventCallback = null, tmp = null; if (tools.eqs(e.type, "mouseover")) { - tmp = tools.getMDom(setting, target, [{ tagName: "a", attrName: "treeNode" + consts.id.A }]); + tmp = tools.getMDom(setting, target, [ + { tagName: "a", attrName: "treeNode" + consts.id.A }, + ]); if (tmp) { tId = tools.getNodeMainDom(tmp).id; nodeEventType = "hoverOverNode"; } } else if (tools.eqs(e.type, "mouseout")) { - tmp = tools.getMDom(setting, relatedTarget, [{ tagName: "a", attrName: "treeNode" + consts.id.A }]); + tmp = tools.getMDom(setting, relatedTarget, [ + { tagName: "a", attrName: "treeNode" + consts.id.A }, + ]); if (!tmp) { tId = "remove"; nodeEventType = "hoverOutNode"; } } else if (tools.eqs(e.type, "mousedown")) { - tmp = tools.getMDom(setting, target, [{ tagName: "a", attrName: "treeNode" + consts.id.A }]); + tmp = tools.getMDom(setting, target, [ + { tagName: "a", attrName: "treeNode" + consts.id.A }, + ]); if (tmp) { tId = tools.getNodeMainDom(tmp).id; nodeEventType = "mousedownNode"; @@ -2866,27 +3712,41 @@ nodeEventType: nodeEventType, nodeEventCallback: nodeEventCallback, treeEventType: treeEventType, - treeEventCallback: treeEventCallback + treeEventCallback: treeEventCallback, }; - return proxyResult + return proxyResult; }, //default init node of exedit - _initNode = function (setting, level, n, parentNode, isFirstNode, isLastNode, openFlag) { + _initNode = function( + setting, + level, + n, + parentNode, + isFirstNode, + isLastNode, + openFlag + ) { if (!n) return; n.isHover = false; n.editNameFlag = false; }, //update zTreeObj, add method of edit - _zTreeTools = function (setting, zTreeTools) { - zTreeTools.cancelEditName = function (newName) { + _zTreeTools = function(setting, zTreeTools) { + zTreeTools.cancelEditName = function(newName) { var root = data.getRoot(this.setting); if (!root.curEditNode) return; view.cancelCurEditNode(this.setting, newName ? newName : null, true); - } - zTreeTools.copyNode = function (targetNode, node, moveType, isSilent) { + }; + zTreeTools.copyNode = function(targetNode, node, moveType, isSilent) { if (!node) return null; var isParent = data.nodeIsParent(setting, targetNode); - if (targetNode && !isParent && this.setting.data.keep.leaf && moveType === consts.move.TYPE_INNER) return null; + if ( + targetNode && + !isParent && + this.setting.data.keep.leaf && + moveType === consts.move.TYPE_INNER + ) + return null; var _this = this, newNode = tools.clone(node); if (!targetNode) { @@ -2904,22 +3764,55 @@ copyCallback(); } } else { - view.addNodes(this.setting, targetNode.parentNode, -1, [newNode], isSilent); - view.moveNode(this.setting, targetNode, newNode, moveType, false, isSilent); + view.addNodes( + this.setting, + targetNode.parentNode, + -1, + [newNode], + isSilent + ); + view.moveNode( + this.setting, + targetNode, + newNode, + moveType, + false, + isSilent + ); } return newNode; - } - zTreeTools.editName = function (node) { - if (!node || !node.tId || node !== data.getNodeCache(this.setting, node.tId)) return; - if (node.parentTId) view.expandCollapseParentNode(this.setting, node.getParentNode(), true); - view.editNode(this.setting, node) - } - zTreeTools.moveNode = function (targetNode, node, moveType, isSilent) { + }; + zTreeTools.editName = function(node) { + if ( + !node || + !node.tId || + node !== data.getNodeCache(this.setting, node.tId) + ) + return; + if (node.parentTId) + view.expandCollapseParentNode( + this.setting, + node.getParentNode(), + true + ); + view.editNode(this.setting, node); + }; + zTreeTools.moveNode = function(targetNode, node, moveType, isSilent) { if (!node) return node; var isParent = data.nodeIsParent(setting, targetNode); - if (targetNode && !isParent && this.setting.data.keep.leaf && moveType === consts.move.TYPE_INNER) { + if ( + targetNode && + !isParent && + this.setting.data.keep.leaf && + moveType === consts.move.TYPE_INNER + ) { return null; - } else if (targetNode && ((node.parentTId == targetNode.tId && moveType == consts.move.TYPE_INNER) || $$(node, this.setting).find("#" + targetNode.tId).length > 0)) { + } else if ( + targetNode && + ((node.parentTId == targetNode.tId && + moveType == consts.move.TYPE_INNER) || + $$(node, this.setting).find("#" + targetNode.tId).length > 0) + ) { return null; } else if (!targetNode) { targetNode = null; @@ -2927,38 +3820,48 @@ var _this = this; function moveCallback() { - view.moveNode(_this.setting, targetNode, node, moveType, false, isSilent); + view.moveNode( + _this.setting, + targetNode, + node, + moveType, + false, + isSilent + ); } - if (tools.canAsync(this.setting, targetNode) && moveType === consts.move.TYPE_INNER) { + if ( + tools.canAsync(this.setting, targetNode) && + moveType === consts.move.TYPE_INNER + ) { view.asyncNode(this.setting, targetNode, isSilent, moveCallback); } else { moveCallback(); } return node; - } - zTreeTools.setEditable = function (editable) { + }; + zTreeTools.setEditable = function(editable) { this.setting.edit.enable = editable; return this.refresh(); - } + }; }, //method of operate data _data = { - setSonNodeLevel: function (setting, parentNode, node) { + setSonNodeLevel: function(setting, parentNode, node) { if (!node) return; var children = data.nodeChildren(setting, node); - node.level = (parentNode) ? parentNode.level + 1 : 0; + node.level = parentNode ? parentNode.level + 1 : 0; if (!children) return; for (var i = 0, l = children.length; i < l; i++) { if (children[i]) data.setSonNodeLevel(setting, node, children[i]); } - } + }, }, //method of event proxy _event = {}, //method of event handler _handler = { - onHoverOverNode: function (event, node) { + onHoverOverNode: function(event, node) { var setting = data.getSetting(event.data.treeId), root = data.getRoot(setting); if (root.curHoverNode != node) { @@ -2967,20 +3870,30 @@ root.curHoverNode = node; view.addHoverDom(setting, node); }, - onHoverOutNode: function (event, node) { + onHoverOutNode: function(event, node) { var setting = data.getSetting(event.data.treeId), root = data.getRoot(setting); - if (root.curHoverNode && !data.isSelectedNode(setting, root.curHoverNode)) { + if ( + root.curHoverNode && + !data.isSelectedNode(setting, root.curHoverNode) + ) { view.removeTreeDom(setting, root.curHoverNode); root.curHoverNode = null; } }, - onMousedownNode: function (eventMouseDown, _node) { - var i, l, + onMousedownNode: function(eventMouseDown, _node) { + var i, + l, setting = data.getSetting(eventMouseDown.data.treeId), - root = data.getRoot(setting), roots = data.getRoots(); + root = data.getRoot(setting), + roots = data.getRoots(); //right click can't drag & drop - if (eventMouseDown.button == 2 || !setting.edit.enable || (!setting.edit.drag.isCopy && !setting.edit.drag.isMove)) return true; + if ( + eventMouseDown.button == 2 || + !setting.edit.enable || + (!setting.edit.drag.isCopy && !setting.edit.drag.isMove) + ) + return true; //input of edit node name can't drag & drop var target = eventMouseDown.target, @@ -2990,7 +3903,11 @@ nodes = [_node]; } else { for (i = 0, l = _nodes.length; i < l; i++) { - if (_nodes[i].editNameFlag && tools.eqs(target.tagName, "input") && target.getAttribute("treeNode" + consts.id.INPUT) !== null) { + if ( + _nodes[i].editNameFlag && + tools.eqs(target.tagName, "input") && + target.getAttribute("treeNode" + consts.id.INPUT) !== null + ) { return true; } nodes.push(_nodes[i]); @@ -3005,18 +3922,22 @@ view.cancelCurEditNode(setting); var doc = $(setting.treeObj.get(0).ownerDocument), - body = $(setting.treeObj.get(0).ownerDocument.body), curNode, tmpArrow, tmpTarget, + body = $(setting.treeObj.get(0).ownerDocument.body), + curNode, + tmpArrow, + tmpTarget, isOtherTree = false, targetSetting = setting, sourceSetting = setting, - preNode, nextNode, + preNode, + nextNode, preTmpTargetNodeId = null, preTmpMoveType = null, tmpTargetNodeId = null, moveType = consts.move.TYPE_INNER, mouseDownX = eventMouseDown.clientX, mouseDownY = eventMouseDown.clientY, - startTime = (new Date()).getTime(); + startTime = new Date().getTime(); if (tools.uCanDo(setting)) { doc.bind("mousemove", _docMouseMove); @@ -3024,15 +3945,25 @@ function _docMouseMove(event) { //avoid start drag after click node - if (root.dragFlag == 0 && Math.abs(mouseDownX - event.clientX) < setting.edit.drag.minMoveSize - && Math.abs(mouseDownY - event.clientY) < setting.edit.drag.minMoveSize) { + if ( + root.dragFlag == 0 && + Math.abs(mouseDownX - event.clientX) < + setting.edit.drag.minMoveSize && + Math.abs(mouseDownY - event.clientY) < setting.edit.drag.minMoveSize + ) { return true; } var i, l, tmpNode, tmpDom, tmpNodes; body.css("cursor", "pointer"); if (root.dragFlag == 0) { - if (tools.apply(setting.callback.beforeDrag, [setting.treeId, nodes], true) == false) { + if ( + tools.apply( + setting.callback.beforeDrag, + [setting.treeId, nodes], + true + ) == false + ) { _docMouseUp(event); return true; } @@ -3055,13 +3986,16 @@ tools.showIfameMask(setting, true); //sort - var isOrder = true, lastIndex = -1; + var isOrder = true, + lastIndex = -1; if (nodes.length > 1) { - var pNodes = nodes[0].parentTId ? data.nodeChildren(setting, nodes[0].getParentNode()) : data.getNodes(setting); + var pNodes = nodes[0].parentTId + ? data.nodeChildren(setting, nodes[0].getParentNode()) + : data.getNodes(setting); tmpNodes = []; for (i = 0, l = pNodes.length; i < l; i++) { if (root.dragNodeShowBefore[pNodes[i].tId] !== undefined) { - if (isOrder && lastIndex > -1 && (lastIndex + 1) !== i) { + if (isOrder && lastIndex > -1 && lastIndex + 1 !== i) { isOrder = false; } tmpNodes.push(pNodes[i]); @@ -3093,10 +4027,15 @@ tmpDom = $$("<li id='" + tmpNode.tId + "_tmp'></li>", setting); tmpDom.append($$(tmpNode, consts.id.A, setting).clone()); tmpDom.css("padding", "0"); - tmpDom.children("#" + tmpNode.tId + consts.id.A).removeClass(consts.node.CURSELECTED); + tmpDom + .children("#" + tmpNode.tId + consts.id.A) + .removeClass(consts.node.CURSELECTED); curNode.append(tmpDom); if (i == setting.edit.drag.maxShowNodeNum - 1) { - tmpDom = $$("<li id='" + tmpNode.tId + "_moretmp'><a> ... </a></li>", setting); + tmpDom = $$( + "<li id='" + tmpNode.tId + "_moretmp'><a> ... </a></li>", + setting + ); curNode.append(tmpDom); } } @@ -3108,17 +4047,36 @@ tmpArrow.attr("id", "zTreeMove_arrow_tmp"); tmpArrow.appendTo(body); - setting.treeObj.trigger(consts.event.DRAG, [event, setting.treeId, nodes]); + setting.treeObj.trigger(consts.event.DRAG, [ + event, + setting.treeId, + nodes, + ]); } if (root.dragFlag == 1) { - if (tmpTarget && tmpArrow.attr("id") == event.target.id && tmpTargetNodeId && (event.clientX + doc.scrollLeft() + 2) > ($("#" + tmpTargetNodeId + consts.id.A, tmpTarget).offset().left)) { + if ( + tmpTarget && + tmpArrow.attr("id") == event.target.id && + tmpTargetNodeId && + event.clientX + doc.scrollLeft() + 2 > + $("#" + tmpTargetNodeId + consts.id.A, tmpTarget).offset().left + ) { var xT = $("#" + tmpTargetNodeId + consts.id.A, tmpTarget); - event.target = (xT.length > 0) ? xT.get(0) : event.target; + event.target = xT.length > 0 ? xT.get(0) : event.target; } else if (tmpTarget) { tmpTarget.removeClass(consts.node.TMPTARGET_TREE); - if (tmpTargetNodeId) $("#" + tmpTargetNodeId + consts.id.A, tmpTarget).removeClass(consts.node.TMPTARGET_NODE + "_" + consts.move.TYPE_PREV) - .removeClass(consts.node.TMPTARGET_NODE + "_" + _consts.move.TYPE_NEXT).removeClass(consts.node.TMPTARGET_NODE + "_" + _consts.move.TYPE_INNER); + if (tmpTargetNodeId) + $("#" + tmpTargetNodeId + consts.id.A, tmpTarget) + .removeClass( + consts.node.TMPTARGET_NODE + "_" + consts.move.TYPE_PREV + ) + .removeClass( + consts.node.TMPTARGET_NODE + "_" + _consts.move.TYPE_NEXT + ) + .removeClass( + consts.node.TMPTARGET_NODE + "_" + _consts.move.TYPE_INNER + ); } tmpTarget = null; tmpTargetNodeId = null; @@ -3128,8 +4086,13 @@ targetSetting = setting; var settings = data.getSettings(); for (var s in settings) { - if (settings[s].treeId && settings[s].edit.enable && settings[s].treeId != setting.treeId - && (event.target.id == settings[s].treeId || $(event.target).parents("#" + settings[s].treeId).length > 0)) { + if ( + settings[s].treeId && + settings[s].edit.enable && + settings[s].treeId != setting.treeId && + (event.target.id == settings[s].treeId || + $(event.target).parents("#" + settings[s].treeId).length > 0) + ) { isOtherTree = true; targetSetting = settings[s]; } @@ -3140,24 +4103,62 @@ treeOffset = targetSetting.treeObj.offset(), scrollHeight = targetSetting.treeObj.get(0).scrollHeight, scrollWidth = targetSetting.treeObj.get(0).scrollWidth, - dTop = (event.clientY + docScrollTop - treeOffset.top), - dBottom = (targetSetting.treeObj.height() + treeOffset.top - event.clientY - docScrollTop), - dLeft = (event.clientX + docScrollLeft - treeOffset.left), - dRight = (targetSetting.treeObj.width() + treeOffset.left - event.clientX - docScrollLeft), - isTop = (dTop < setting.edit.drag.borderMax && dTop > setting.edit.drag.borderMin), - isBottom = (dBottom < setting.edit.drag.borderMax && dBottom > setting.edit.drag.borderMin), - isLeft = (dLeft < setting.edit.drag.borderMax && dLeft > setting.edit.drag.borderMin), - isRight = (dRight < setting.edit.drag.borderMax && dRight > setting.edit.drag.borderMin), - isTreeInner = dTop > setting.edit.drag.borderMin && dBottom > setting.edit.drag.borderMin && dLeft > setting.edit.drag.borderMin && dRight > setting.edit.drag.borderMin, - isTreeTop = (isTop && targetSetting.treeObj.scrollTop() <= 0), - isTreeBottom = (isBottom && (targetSetting.treeObj.scrollTop() + targetSetting.treeObj.height() + 10) >= scrollHeight), - isTreeLeft = (isLeft && targetSetting.treeObj.scrollLeft() <= 0), - isTreeRight = (isRight && (targetSetting.treeObj.scrollLeft() + targetSetting.treeObj.width() + 10) >= scrollWidth); + dTop = event.clientY + docScrollTop - treeOffset.top, + dBottom = + targetSetting.treeObj.height() + + treeOffset.top - + event.clientY - + docScrollTop, + dLeft = event.clientX + docScrollLeft - treeOffset.left, + dRight = + targetSetting.treeObj.width() + + treeOffset.left - + event.clientX - + docScrollLeft, + isTop = + dTop < setting.edit.drag.borderMax && + dTop > setting.edit.drag.borderMin, + isBottom = + dBottom < setting.edit.drag.borderMax && + dBottom > setting.edit.drag.borderMin, + isLeft = + dLeft < setting.edit.drag.borderMax && + dLeft > setting.edit.drag.borderMin, + isRight = + dRight < setting.edit.drag.borderMax && + dRight > setting.edit.drag.borderMin, + isTreeInner = + dTop > setting.edit.drag.borderMin && + dBottom > setting.edit.drag.borderMin && + dLeft > setting.edit.drag.borderMin && + dRight > setting.edit.drag.borderMin, + isTreeTop = isTop && targetSetting.treeObj.scrollTop() <= 0, + isTreeBottom = + isBottom && + targetSetting.treeObj.scrollTop() + + targetSetting.treeObj.height() + + 10 >= + scrollHeight, + isTreeLeft = isLeft && targetSetting.treeObj.scrollLeft() <= 0, + isTreeRight = + isRight && + targetSetting.treeObj.scrollLeft() + + targetSetting.treeObj.width() + + 10 >= + scrollWidth; - if (event.target && tools.isChildOrSelf(event.target, targetSetting.treeId)) { + if ( + event.target && + tools.isChildOrSelf(event.target, targetSetting.treeId) + ) { //get node <li> dom var targetObj = event.target; - while (targetObj && targetObj.tagName && !tools.eqs(targetObj.tagName, "li") && targetObj.id != targetSetting.treeId) { + while ( + targetObj && + targetObj.tagName && + !tools.eqs(targetObj.tagName, "li") && + targetObj.id != targetSetting.treeId + ) { targetObj = targetObj.parentNode; } @@ -3168,12 +4169,18 @@ if (targetObj.id === tmpNode.tId) { canMove = false; break; - } else if ($$(tmpNode, setting).find("#" + targetObj.id).length > 0) { + } else if ( + $$(tmpNode, setting).find("#" + targetObj.id).length > 0 + ) { canMove = false; break; } } - if (canMove && event.target && tools.isChildOrSelf(event.target, targetObj.id + consts.id.A)) { + if ( + canMove && + event.target && + tools.isChildOrSelf(event.target, targetObj.id + consts.id.A) + ) { tmpTarget = $(targetObj); tmpTargetNodeId = targetObj.id; } @@ -3181,76 +4188,168 @@ //the mouse must be in zTree tmpNode = nodes[0]; - if (isTreeInner && tools.isChildOrSelf(event.target, targetSetting.treeId)) { + if ( + isTreeInner && + tools.isChildOrSelf(event.target, targetSetting.treeId) + ) { //judge mouse move in root of ztree - if (!tmpTarget && (event.target.id == targetSetting.treeId || isTreeTop || isTreeBottom || isTreeLeft || isTreeRight) && (isOtherTree || (!isOtherTree && tmpNode.parentTId))) { + if ( + !tmpTarget && + (event.target.id == targetSetting.treeId || + isTreeTop || + isTreeBottom || + isTreeLeft || + isTreeRight) && + (isOtherTree || (!isOtherTree && tmpNode.parentTId)) + ) { tmpTarget = targetSetting.treeObj; } //auto scroll top if (isTop) { - targetSetting.treeObj.scrollTop(targetSetting.treeObj.scrollTop() - 10); + targetSetting.treeObj.scrollTop( + targetSetting.treeObj.scrollTop() - 10 + ); } else if (isBottom) { - targetSetting.treeObj.scrollTop(targetSetting.treeObj.scrollTop() + 10); + targetSetting.treeObj.scrollTop( + targetSetting.treeObj.scrollTop() + 10 + ); } if (isLeft) { - targetSetting.treeObj.scrollLeft(targetSetting.treeObj.scrollLeft() - 10); + targetSetting.treeObj.scrollLeft( + targetSetting.treeObj.scrollLeft() - 10 + ); } else if (isRight) { - targetSetting.treeObj.scrollLeft(targetSetting.treeObj.scrollLeft() + 10); + targetSetting.treeObj.scrollLeft( + targetSetting.treeObj.scrollLeft() + 10 + ); } //auto scroll left - if (tmpTarget && tmpTarget != targetSetting.treeObj && tmpTarget.offset().left < targetSetting.treeObj.offset().left) { - targetSetting.treeObj.scrollLeft(targetSetting.treeObj.scrollLeft() + tmpTarget.offset().left - targetSetting.treeObj.offset().left); + if ( + tmpTarget && + tmpTarget != targetSetting.treeObj && + tmpTarget.offset().left < targetSetting.treeObj.offset().left + ) { + targetSetting.treeObj.scrollLeft( + targetSetting.treeObj.scrollLeft() + + tmpTarget.offset().left - + targetSetting.treeObj.offset().left + ); } } curNode.css({ - "top": (event.clientY + docScrollTop + 3) + "px", - "left": (event.clientX + docScrollLeft + 3) + "px" + top: event.clientY + docScrollTop + 3 + "px", + left: event.clientX + docScrollLeft + 3 + "px", }); var dX = 0; var dY = 0; if (tmpTarget && tmpTarget.attr("id") != targetSetting.treeId) { - var tmpTargetNode = tmpTargetNodeId == null ? null : data.getNodeCache(targetSetting, tmpTargetNodeId), - isCopy = ((event.ctrlKey || event.metaKey) && setting.edit.drag.isMove && setting.edit.drag.isCopy) || (!setting.edit.drag.isMove && setting.edit.drag.isCopy), + var tmpTargetNode = + tmpTargetNodeId == null + ? null + : data.getNodeCache(targetSetting, tmpTargetNodeId), + isCopy = + ((event.ctrlKey || event.metaKey) && + setting.edit.drag.isMove && + setting.edit.drag.isCopy) || + (!setting.edit.drag.isMove && setting.edit.drag.isCopy), isPrev = !!(preNode && tmpTargetNodeId === preNode.tId), isNext = !!(nextNode && tmpTargetNodeId === nextNode.tId), - isInner = (tmpNode.parentTId && tmpNode.parentTId == tmpTargetNodeId), - canPrev = (isCopy || !isNext) && tools.apply(targetSetting.edit.drag.prev, [targetSetting.treeId, nodes, tmpTargetNode], !!targetSetting.edit.drag.prev), - canNext = (isCopy || !isPrev) && tools.apply(targetSetting.edit.drag.next, [targetSetting.treeId, nodes, tmpTargetNode], !!targetSetting.edit.drag.next), - canInner = (isCopy || !isInner) && !(targetSetting.data.keep.leaf && !data.nodeIsParent(setting, tmpTargetNode)) && tools.apply(targetSetting.edit.drag.inner, [targetSetting.treeId, nodes, tmpTargetNode], !!targetSetting.edit.drag.inner); + isInner = + tmpNode.parentTId && tmpNode.parentTId == tmpTargetNodeId, + canPrev = + (isCopy || !isNext) && + tools.apply( + targetSetting.edit.drag.prev, + [targetSetting.treeId, nodes, tmpTargetNode], + !!targetSetting.edit.drag.prev + ), + canNext = + (isCopy || !isPrev) && + tools.apply( + targetSetting.edit.drag.next, + [targetSetting.treeId, nodes, tmpTargetNode], + !!targetSetting.edit.drag.next + ), + canInner = + (isCopy || !isInner) && + !( + targetSetting.data.keep.leaf && + !data.nodeIsParent(setting, tmpTargetNode) + ) && + tools.apply( + targetSetting.edit.drag.inner, + [targetSetting.treeId, nodes, tmpTargetNode], + !!targetSetting.edit.drag.inner + ); function clearMove() { tmpTarget = null; tmpTargetNodeId = ""; moveType = consts.move.TYPE_INNER; tmpArrow.css({ - "display": "none" + display: "none", }); if (window.zTreeMoveTimer) { clearTimeout(window.zTreeMoveTimer); - window.zTreeMoveTargetNodeTId = null + window.zTreeMoveTargetNodeTId = null; } } if (!canPrev && !canNext && !canInner) { clearMove(); } else { - var tmpTargetA = $("#" + tmpTargetNodeId + consts.id.A, tmpTarget), - tmpNextA = tmpTargetNode.isLastNode ? null : $("#" + tmpTargetNode.getNextNode().tId + consts.id.A, tmpTarget.next()), + var tmpTargetA = $( + "#" + tmpTargetNodeId + consts.id.A, + tmpTarget + ), + tmpNextA = tmpTargetNode.isLastNode + ? null + : $( + "#" + tmpTargetNode.getNextNode().tId + consts.id.A, + tmpTarget.next() + ), tmpTop = tmpTargetA.offset().top, tmpLeft = tmpTargetA.offset().left, - prevPercent = canPrev ? (canInner ? 0.25 : (canNext ? 0.5 : 1)) : -1, - nextPercent = canNext ? (canInner ? 0.75 : (canPrev ? 0.5 : 0)) : -1, - dY_percent = (event.clientY + docScrollTop - tmpTop) / tmpTargetA.height(); + prevPercent = canPrev + ? canInner + ? 0.25 + : canNext + ? 0.5 + : 1 + : -1, + nextPercent = canNext + ? canInner + ? 0.75 + : canPrev + ? 0.5 + : 0 + : -1, + dY_percent = + (event.clientY + docScrollTop - tmpTop) / + tmpTargetA.height(); - if ((prevPercent == 1 || dY_percent <= prevPercent && dY_percent >= -.2) && canPrev) { + if ( + (prevPercent == 1 || + (dY_percent <= prevPercent && dY_percent >= -0.2)) && + canPrev + ) { dX = 1 - tmpArrow.width(); dY = tmpTop - tmpArrow.height() / 2; moveType = consts.move.TYPE_PREV; - } else if ((nextPercent == 0 || dY_percent >= nextPercent && dY_percent <= 1.2) && canNext) { + } else if ( + (nextPercent == 0 || + (dY_percent >= nextPercent && dY_percent <= 1.2)) && + canNext + ) { dX = 1 - tmpArrow.width(); - dY = (tmpNextA == null || (data.nodeIsParent(setting, tmpTargetNode) && tmpTargetNode.open)) ? (tmpTop + tmpTargetA.height() - tmpArrow.height() / 2) : (tmpNextA.offset().top - tmpArrow.height() / 2); + dY = + tmpNextA == null || + (data.nodeIsParent(setting, tmpTargetNode) && + tmpTargetNode.open) + ? tmpTop + tmpTargetA.height() - tmpArrow.height() / 2 + : tmpNextA.offset().top - tmpArrow.height() / 2; moveType = consts.move.TYPE_NEXT; } else if (canInner) { dX = 5 - tmpArrow.width(); @@ -3262,31 +4361,59 @@ if (tmpTarget) { tmpArrow.css({ - "display": "block", - "top": dY + "px", - "left": (tmpLeft + dX) + "px" + display: "block", + top: dY + "px", + left: tmpLeft + dX + "px", }); - tmpTargetA.addClass(consts.node.TMPTARGET_NODE + "_" + moveType); + tmpTargetA.addClass( + consts.node.TMPTARGET_NODE + "_" + moveType + ); - if (preTmpTargetNodeId != tmpTargetNodeId || preTmpMoveType != moveType) { - startTime = (new Date()).getTime(); + if ( + preTmpTargetNodeId != tmpTargetNodeId || + preTmpMoveType != moveType + ) { + startTime = new Date().getTime(); } - if (tmpTargetNode && data.nodeIsParent(setting, tmpTargetNode) && moveType == consts.move.TYPE_INNER) { + if ( + tmpTargetNode && + data.nodeIsParent(setting, tmpTargetNode) && + moveType == consts.move.TYPE_INNER + ) { var startTimer = true; - if (window.zTreeMoveTimer && window.zTreeMoveTargetNodeTId !== tmpTargetNode.tId) { + if ( + window.zTreeMoveTimer && + window.zTreeMoveTargetNodeTId !== tmpTargetNode.tId + ) { clearTimeout(window.zTreeMoveTimer); window.zTreeMoveTargetNodeTId = null; - } else if (window.zTreeMoveTimer && window.zTreeMoveTargetNodeTId === tmpTargetNode.tId) { + } else if ( + window.zTreeMoveTimer && + window.zTreeMoveTargetNodeTId === tmpTargetNode.tId + ) { startTimer = false; } if (startTimer) { - window.zTreeMoveTimer = setTimeout(function () { + window.zTreeMoveTimer = setTimeout(function() { if (moveType != consts.move.TYPE_INNER) return; - if (tmpTargetNode && data.nodeIsParent(setting, tmpTargetNode) && !tmpTargetNode.open && (new Date()).getTime() - startTime > targetSetting.edit.drag.autoOpenTime - && tools.apply(targetSetting.callback.beforeDragOpen, [targetSetting.treeId, tmpTargetNode], true)) { + if ( + tmpTargetNode && + data.nodeIsParent(setting, tmpTargetNode) && + !tmpTargetNode.open && + new Date().getTime() - startTime > + targetSetting.edit.drag.autoOpenTime && + tools.apply( + targetSetting.callback.beforeDragOpen, + [targetSetting.treeId, tmpTargetNode], + true + ) + ) { view.switchNode(targetSetting, tmpTargetNode); if (targetSetting.edit.drag.autoExpandTrigger) { - targetSetting.treeObj.trigger(consts.event.EXPAND, [targetSetting.treeId, tmpTargetNode]); + targetSetting.treeObj.trigger(consts.event.EXPAND, [ + targetSetting.treeId, + tmpTargetNode, + ]); } } }, targetSetting.edit.drag.autoOpenTime + 50); @@ -3297,13 +4424,20 @@ } } else { moveType = consts.move.TYPE_INNER; - if (tmpTarget && tools.apply(targetSetting.edit.drag.inner, [targetSetting.treeId, nodes, null], !!targetSetting.edit.drag.inner)) { + if ( + tmpTarget && + tools.apply( + targetSetting.edit.drag.inner, + [targetSetting.treeId, nodes, null], + !!targetSetting.edit.drag.inner + ) + ) { tmpTarget.addClass(consts.node.TMPTARGET_TREE); } else { tmpTarget = null; } tmpArrow.css({ - "display": "none" + display: "none", }); if (window.zTreeMoveTimer) { clearTimeout(window.zTreeMoveTimer); @@ -3313,7 +4447,11 @@ preTmpTargetNodeId = tmpTargetNodeId; preTmpMoveType = moveType; - setting.treeObj.trigger(consts.event.DRAGMOVE, [event, setting.treeId, nodes]); + setting.treeObj.trigger(consts.event.DRAGMOVE, [ + event, + setting.treeId, + nodes, + ]); } return false; } @@ -3333,8 +4471,17 @@ body.css("cursor", ""); if (tmpTarget) { tmpTarget.removeClass(consts.node.TMPTARGET_TREE); - if (tmpTargetNodeId) $("#" + tmpTargetNodeId + consts.id.A, tmpTarget).removeClass(consts.node.TMPTARGET_NODE + "_" + consts.move.TYPE_PREV) - .removeClass(consts.node.TMPTARGET_NODE + "_" + _consts.move.TYPE_NEXT).removeClass(consts.node.TMPTARGET_NODE + "_" + _consts.move.TYPE_INNER); + if (tmpTargetNodeId) + $("#" + tmpTargetNodeId + consts.id.A, tmpTarget) + .removeClass( + consts.node.TMPTARGET_NODE + "_" + consts.move.TYPE_PREV + ) + .removeClass( + consts.node.TMPTARGET_NODE + "_" + _consts.move.TYPE_NEXT + ) + .removeClass( + consts.node.TMPTARGET_NODE + "_" + _consts.move.TYPE_INNER + ); } tools.showIfameMask(setting, false); @@ -3345,7 +4492,11 @@ var i, l, tmpNode; for (i = 0, l = nodes.length; i < l; i++) { tmpNode = nodes[i]; - if (data.nodeIsParent(setting, tmpNode) && root.dragNodeShowBefore[tmpNode.tId] && !tmpNode.open) { + if ( + data.nodeIsParent(setting, tmpNode) && + root.dragNodeShowBefore[tmpNode.tId] && + !tmpNode.open + ) { view.expandCollapseNode(setting, tmpNode, !tmpNode.open); delete root.dragNodeShowBefore[tmpNode.tId]; } @@ -3354,13 +4505,33 @@ if (curNode) curNode.remove(); if (tmpArrow) tmpArrow.remove(); - var isCopy = ((event.ctrlKey || event.metaKey) && setting.edit.drag.isMove && setting.edit.drag.isCopy) || (!setting.edit.drag.isMove && setting.edit.drag.isCopy); - if (!isCopy && tmpTarget && tmpTargetNodeId && nodes[0].parentTId && tmpTargetNodeId == nodes[0].parentTId && moveType == consts.move.TYPE_INNER) { + var isCopy = + ((event.ctrlKey || event.metaKey) && + setting.edit.drag.isMove && + setting.edit.drag.isCopy) || + (!setting.edit.drag.isMove && setting.edit.drag.isCopy); + if ( + !isCopy && + tmpTarget && + tmpTargetNodeId && + nodes[0].parentTId && + tmpTargetNodeId == nodes[0].parentTId && + moveType == consts.move.TYPE_INNER + ) { tmpTarget = null; } if (tmpTarget) { - var dragTargetNode = tmpTargetNodeId == null ? null : data.getNodeCache(targetSetting, tmpTargetNodeId); - if (tools.apply(setting.callback.beforeDrop, [targetSetting.treeId, nodes, dragTargetNode, moveType, isCopy], true) == false) { + var dragTargetNode = + tmpTargetNodeId == null + ? null + : data.getNodeCache(targetSetting, tmpTargetNodeId); + if ( + tools.apply( + setting.callback.beforeDrop, + [targetSetting.treeId, nodes, dragTargetNode, moveType, isCopy], + true + ) == false + ) { view.selectNodes(sourceSetting, nodes); return; } @@ -3376,21 +4547,47 @@ if (moveType == consts.move.TYPE_INNER) { view.addNodes(targetSetting, dragTargetNode, -1, newNodes); } else { - view.addNodes(targetSetting, dragTargetNode.getParentNode(), moveType == consts.move.TYPE_PREV ? dragTargetNode.getIndex() : dragTargetNode.getIndex() + 1, newNodes); + view.addNodes( + targetSetting, + dragTargetNode.getParentNode(), + moveType == consts.move.TYPE_PREV + ? dragTargetNode.getIndex() + : dragTargetNode.getIndex() + 1, + newNodes + ); } } else { if (isCopy && moveType == consts.move.TYPE_INNER) { view.addNodes(targetSetting, dragTargetNode, -1, newNodes); } else if (isCopy) { - view.addNodes(targetSetting, dragTargetNode.getParentNode(), moveType == consts.move.TYPE_PREV ? dragTargetNode.getIndex() : dragTargetNode.getIndex() + 1, newNodes); + view.addNodes( + targetSetting, + dragTargetNode.getParentNode(), + moveType == consts.move.TYPE_PREV + ? dragTargetNode.getIndex() + : dragTargetNode.getIndex() + 1, + newNodes + ); } else { if (moveType != consts.move.TYPE_NEXT) { for (i = 0, l = newNodes.length; i < l; i++) { - view.moveNode(targetSetting, dragTargetNode, newNodes[i], moveType, false); + view.moveNode( + targetSetting, + dragTargetNode, + newNodes[i], + moveType, + false + ); } } else { for (i = -1, l = newNodes.length - 1; i < l; l--) { - view.moveNode(targetSetting, dragTargetNode, newNodes[l], moveType, false); + view.moveNode( + targetSetting, + dragTargetNode, + newNodes[l], + moveType, + false + ); } } } @@ -3400,18 +4597,39 @@ var a = $$(newNodes[0], setting).get(0); view.scrollIntoView(setting, a); - setting.treeObj.trigger(consts.event.DROP, [event, targetSetting.treeId, newNodes, dragTargetNode, moveType, isCopy]); + setting.treeObj.trigger(consts.event.DROP, [ + event, + targetSetting.treeId, + newNodes, + dragTargetNode, + moveType, + isCopy, + ]); } - if (moveType == consts.move.TYPE_INNER && tools.canAsync(targetSetting, dragTargetNode)) { - view.asyncNode(targetSetting, dragTargetNode, false, dropCallback); + if ( + moveType == consts.move.TYPE_INNER && + tools.canAsync(targetSetting, dragTargetNode) + ) { + view.asyncNode( + targetSetting, + dragTargetNode, + false, + dropCallback + ); } else { dropCallback(); } - } else { view.selectNodes(sourceSetting, nodes); - setting.treeObj.trigger(consts.event.DROP, [event, setting.treeId, nodes, null, null, null]); + setting.treeObj.trigger(consts.event.DROP, [ + event, + setting.treeId, + nodes, + null, + null, + null, + ]); } } @@ -3428,41 +4646,43 @@ // eventMouseDown.preventDefault(); // } return true; - } + }, }, //method of tools for zTree _tools = { - getAbs: function (obj) { + getAbs: function(obj) { var oRect = obj.getBoundingClientRect(), - scrollTop = document.body.scrollTop + document.documentElement.scrollTop, - scrollLeft = document.body.scrollLeft + document.documentElement.scrollLeft; + scrollTop = + document.body.scrollTop + document.documentElement.scrollTop, + scrollLeft = + document.body.scrollLeft + document.documentElement.scrollLeft; return [oRect.left + scrollLeft, oRect.top + scrollTop]; }, - inputFocus: function (inputObj) { + inputFocus: function(inputObj) { if (inputObj.get(0)) { inputObj.focus(); tools.setCursorPosition(inputObj.get(0), inputObj.val().length); } }, - inputSelect: function (inputObj) { + inputSelect: function(inputObj) { if (inputObj.get(0)) { inputObj.focus(); inputObj.select(); } }, - setCursorPosition: function (obj, pos) { + setCursorPosition: function(obj, pos) { if (obj.setSelectionRange) { obj.focus(); obj.setSelectionRange(pos, pos); } else if (obj.createTextRange) { var range = obj.createTextRange(); range.collapse(true); - range.moveEnd('character', pos); - range.moveStart('character', pos); + range.moveEnd("character", pos); + range.moveStart("character", pos); range.select(); } }, - showIfameMask: function (setting, showSign) { + showIfameMask: function(setting, showSign) { var root = data.getRoot(setting); //clear full mask while (root.dragMaskList.length > 0) { @@ -3475,59 +4695,133 @@ for (var i = 0, l = iframeList.length; i < l; i++) { var obj = iframeList.get(i), r = tools.getAbs(obj), - dragMask = $$("<div id='zTreeMask_" + i + "' class='zTreeMask' style='top:" + r[1] + "px; left:" + r[0] + "px; width:" + obj.offsetWidth + "px; height:" + obj.offsetHeight + "px;'></div>", setting); + dragMask = $$( + "<div id='zTreeMask_" + + i + + "' class='zTreeMask' style='top:" + + r[1] + + "px; left:" + + r[0] + + "px; width:" + + obj.offsetWidth + + "px; height:" + + obj.offsetHeight + + "px;'></div>", + setting + ); dragMask.appendTo($$("body", setting)); root.dragMaskList.push(dragMask); } } - } + }, }, //method of operate ztree dom _view = { - addEditBtn: function (setting, node) { + addEditBtn: function(setting, node) { if (node.editNameFlag || $$(node, consts.id.EDIT, setting).length > 0) { return; } - if (!tools.apply(setting.edit.showRenameBtn, [setting.treeId, node], setting.edit.showRenameBtn)) { + if ( + !tools.apply( + setting.edit.showRenameBtn, + [setting.treeId, node], + setting.edit.showRenameBtn + ) + ) { return; } var aObj = $$(node, consts.id.A, setting), - editStr = "<span class='" + consts.className.BUTTON + " edit' id='" + node.tId + consts.id.EDIT + "' title='" + tools.apply(setting.edit.renameTitle, [setting.treeId, node], setting.edit.renameTitle) + "' treeNode" + consts.id.EDIT + " style='display:none;'></span>"; + editStr = + "<span class='" + + consts.className.BUTTON + + " edit' id='" + + node.tId + + consts.id.EDIT + + "' title='" + + tools.apply( + setting.edit.renameTitle, + [setting.treeId, node], + setting.edit.renameTitle + ) + + "' treeNode" + + consts.id.EDIT + + " style='display:none;'></span>"; aObj.append(editStr); - $$(node, consts.id.EDIT, setting).bind('click', - function () { - if (!tools.uCanDo(setting) || tools.apply(setting.callback.beforeEditName, [setting.treeId, node], true) == false) return false; + $$(node, consts.id.EDIT, setting) + .bind("click", function() { + if ( + !tools.uCanDo(setting) || + tools.apply( + setting.callback.beforeEditName, + [setting.treeId, node], + true + ) == false + ) + return false; view.editNode(setting, node); return false; - } - ).show(); + }) + .show(); }, - addRemoveBtn: function (setting, node) { - if (node.editNameFlag || $$(node, consts.id.REMOVE, setting).length > 0) { + addRemoveBtn: function(setting, node) { + if ( + node.editNameFlag || + $$(node, consts.id.REMOVE, setting).length > 0 + ) { return; } - if (!tools.apply(setting.edit.showRemoveBtn, [setting.treeId, node], setting.edit.showRemoveBtn)) { + if ( + !tools.apply( + setting.edit.showRemoveBtn, + [setting.treeId, node], + setting.edit.showRemoveBtn + ) + ) { return; } var aObj = $$(node, consts.id.A, setting), - removeStr = "<span class='" + consts.className.BUTTON + " remove' id='" + node.tId + consts.id.REMOVE + "' title='" + tools.apply(setting.edit.removeTitle, [setting.treeId, node], setting.edit.removeTitle) + "' treeNode" + consts.id.REMOVE + " style='display:none;'></span>"; + removeStr = + "<span class='" + + consts.className.BUTTON + + " remove' id='" + + node.tId + + consts.id.REMOVE + + "' title='" + + tools.apply( + setting.edit.removeTitle, + [setting.treeId, node], + setting.edit.removeTitle + ) + + "' treeNode" + + consts.id.REMOVE + + " style='display:none;'></span>"; aObj.append(removeStr); - $$(node, consts.id.REMOVE, setting).bind('click', - function () { - if (!tools.uCanDo(setting) || tools.apply(setting.callback.beforeRemove, [setting.treeId, node], true) == false) return false; + $$(node, consts.id.REMOVE, setting) + .bind("click", function() { + if ( + !tools.uCanDo(setting) || + tools.apply( + setting.callback.beforeRemove, + [setting.treeId, node], + true + ) == false + ) + return false; view.removeNode(setting, node); - setting.treeObj.trigger(consts.event.REMOVE, [setting.treeId, node]); + setting.treeObj.trigger(consts.event.REMOVE, [ + setting.treeId, + node, + ]); return false; - } - ).bind('mousedown', - function (eventMouseDown) { + }) + .bind("mousedown", function(eventMouseDown) { return true; - } - ).show(); + }) + .show(); }, - addHoverDom: function (setting, node) { + addHoverDom: function(setting, node) { if (data.getRoots().showHoverDom) { node.isHover = true; if (setting.edit.enable) { @@ -3537,14 +4831,24 @@ tools.apply(setting.view.addHoverDom, [setting.treeId, node]); } }, - cancelCurEditNode: function (setting, forceName, isCancel) { + cancelCurEditNode: function(setting, forceName, isCancel) { var root = data.getRoot(setting), node = root.curEditNode; if (node) { var inputObj = root.curEditInput, - newName = forceName ? forceName : (isCancel ? data.nodeName(setting, node) : inputObj.val()); - if (tools.apply(setting.callback.beforeRename, [setting.treeId, node, newName, isCancel], true) === false) { + newName = forceName + ? forceName + : isCancel + ? data.nodeName(setting, node) + : inputObj.val(); + if ( + tools.apply( + setting.callback.beforeRename, + [setting.treeId, node, newName, isCancel], + true + ) === false + ) { return false; } data.nodeName(setting, node, newName); @@ -3556,16 +4860,24 @@ root.curEditNode = null; root.curEditInput = null; view.selectNode(setting, node, false); - setting.treeObj.trigger(consts.event.RENAME, [setting.treeId, node, isCancel]); + setting.treeObj.trigger(consts.event.RENAME, [ + setting.treeId, + node, + isCancel, + ]); } root.noSelection = true; return true; }, - editNode: function (setting, node) { + editNode: function(setting, node) { var root = data.getRoot(setting); view.editNodeBlur = false; - if (data.isSelectedNode(setting, node) && root.curEditNode == node && node.editNameFlag) { - setTimeout(function () { + if ( + data.isSelectedNode(setting, node) && + root.curEditNode == node && + node.editNameFlag + ) { + setTimeout(function() { tools.inputFocus(root.curEditInput); }, 0); return; @@ -3574,7 +4886,14 @@ view.removeTreeDom(setting, node); view.cancelCurEditNode(setting); view.selectNode(setting, node, false); - $$(node, consts.id.SPAN, setting).html("<input type=text class='rename' id='" + node.tId + consts.id.INPUT + "' treeNode" + consts.id.INPUT + " >"); + $$(node, consts.id.SPAN, setting).html( + "<input type=text class='rename' id='" + + node.tId + + consts.id.INPUT + + "' treeNode" + + consts.id.INPUT + + " >" + ); var inputObj = $$(node, consts.id.INPUT, setting); inputObj.attr("value", data.nodeName(setting, node)); if (setting.edit.editNameSelectAll) { @@ -3583,39 +4902,61 @@ tools.inputFocus(inputObj); } - inputObj.bind('blur', function (event) { - if (!view.editNodeBlur) { - view.cancelCurEditNode(setting); - } - }).bind('keydown', function (event) { - if (event.keyCode == "13") { - view.editNodeBlur = true; - view.cancelCurEditNode(setting); - } else if (event.keyCode == "27") { - view.cancelCurEditNode(setting, null, true); - } - }).bind('click', function (event) { - return false; - }).bind('dblclick', function (event) { - return false; - }); + inputObj + .bind("blur", function(event) { + if (!view.editNodeBlur) { + view.cancelCurEditNode(setting); + } + }) + .bind("keydown", function(event) { + if (event.keyCode == "13") { + view.editNodeBlur = true; + view.cancelCurEditNode(setting); + } else if (event.keyCode == "27") { + view.cancelCurEditNode(setting, null, true); + } + }) + .bind("click", function(event) { + return false; + }) + .bind("dblclick", function(event) { + return false; + }); $$(node, consts.id.A, setting).addClass(consts.node.CURSELECTED_EDIT); root.curEditInput = inputObj; root.noSelection = false; root.curEditNode = node; }, - moveNode: function (setting, targetNode, node, moveType, animateFlag, isSilent) { + moveNode: function( + setting, + targetNode, + node, + moveType, + animateFlag, + isSilent + ) { var root = data.getRoot(setting); if (targetNode == node) return; - if (setting.data.keep.leaf && targetNode && !data.nodeIsParent(setting, targetNode) && moveType == consts.move.TYPE_INNER) return; - var oldParentNode = (node.parentTId ? node.getParentNode() : root), - targetNodeIsRoot = (targetNode === null || targetNode == root); + if ( + setting.data.keep.leaf && + targetNode && + !data.nodeIsParent(setting, targetNode) && + moveType == consts.move.TYPE_INNER + ) + return; + var oldParentNode = node.parentTId ? node.getParentNode() : root, + targetNodeIsRoot = targetNode === null || targetNode == root; if (targetNodeIsRoot && targetNode === null) targetNode = root; if (targetNodeIsRoot) moveType = consts.move.TYPE_INNER; - var targetParentNode = (targetNode.parentTId ? targetNode.getParentNode() : root); + var targetParentNode = targetNode.parentTId + ? targetNode.getParentNode() + : root; - if (moveType != consts.move.TYPE_PREV && moveType != consts.move.TYPE_NEXT) { + if ( + moveType != consts.move.TYPE_PREV && + moveType != consts.move.TYPE_NEXT + ) { moveType = consts.move.TYPE_INNER; } @@ -3642,20 +4983,27 @@ if (!isSilent && moveType == consts.move.TYPE_INNER) { view.expandCollapseNode(setting, targetNode, true, false); } else if (!isSilent) { - view.expandCollapseNode(setting, targetNode.getParentNode(), true, false); + view.expandCollapseNode( + setting, + targetNode.getParentNode(), + true, + false + ); } targetObj = $$(targetNode, setting); target_ulObj = $$(targetNode, consts.id.UL, setting); if (!!targetObj.get(0) && !target_ulObj.get(0)) { var ulstr = []; - view.makeUlHtml(setting, targetNode, ulstr, ''); - targetObj.append(ulstr.join('')); + view.makeUlHtml(setting, targetNode, ulstr, ""); + targetObj.append(ulstr.join("")); } target_ulObj = $$(targetNode, consts.id.UL, setting); } var nodeDom = $$(node, setting); if (!nodeDom.get(0)) { - nodeDom = view.appendNodes(setting, node.level, [node], null, -1, false, true).join(''); + nodeDom = view + .appendNodes(setting, node.level, [node], null, -1, false, true) + .join(""); } else if (!targetObj.get(0)) { nodeDom.remove(); } @@ -3668,7 +5016,8 @@ } //repair the data after move - var i, l, + var i, + l, tmpSrcIndex = -1, tmpTargetIndex = 0, oldNeighbor = null, @@ -3700,7 +5049,8 @@ } if (moveType != consts.move.TYPE_INNER) { for (i = 0, l = targetParentChildren.length; i < l; i++) { - if (targetParentChildren[i].tId == targetNode.tId) tmpTargetIndex = i; + if (targetParentChildren[i].tId == targetNode.tId) + tmpTargetIndex = i; } } if (moveType == consts.move.TYPE_INNER) { @@ -3713,15 +5063,17 @@ } targetChildren.splice(targetChildren.length, 0, node); node.isLastNode = true; - node.isFirstNode = (targetChildren.length == 1); - } else if (targetNode.isFirstNode && moveType == consts.move.TYPE_PREV) { + node.isFirstNode = targetChildren.length == 1; + } else if ( + targetNode.isFirstNode && + moveType == consts.move.TYPE_PREV + ) { targetParentChildren.splice(tmpTargetIndex, 0, node); newNeighbor = targetNode; newNeighbor.isFirstNode = false; node.parentTId = targetNode.parentTId; node.isFirstNode = true; node.isLastNode = false; - } else if (targetNode.isLastNode && moveType == consts.move.TYPE_NEXT) { targetParentChildren.splice(tmpTargetIndex + 1, 0, node); newNeighbor = targetNode; @@ -3729,7 +5081,6 @@ node.parentTId = targetNode.parentTId; node.isFirstNode = false; node.isLastNode = true; - } else { if (moveType == consts.move.TYPE_PREV) { targetParentChildren.splice(tmpTargetIndex, 0, node); @@ -3755,10 +5106,13 @@ var tmp_ulObj = $$(oldParentNode, consts.id.UL, setting), tmp_switchObj = $$(oldParentNode, consts.id.SWITCH, setting), tmp_icoObj = $$(oldParentNode, consts.id.ICON, setting); - view.replaceSwitchClass(oldParentNode, tmp_switchObj, consts.folder.DOCU); + view.replaceSwitchClass( + oldParentNode, + tmp_switchObj, + consts.folder.DOCU + ); view.replaceIcoClass(oldParentNode, tmp_icoObj, consts.folder.DOCU); tmp_ulObj.css("display", "none"); - } else if (oldNeighbor) { //old neigbor node view.setNodeLineIcos(setting, oldNeighbor); @@ -3779,22 +5133,31 @@ //expand parents after move if (!isSilent) { - view.expandCollapseParentNode(setting, node.getParentNode(), true, animateFlag); + view.expandCollapseParentNode( + setting, + node.getParentNode(), + true, + animateFlag + ); } }, - removeEditBtn: function (setting, node) { - $$(node, consts.id.EDIT, setting).unbind().remove(); + removeEditBtn: function(setting, node) { + $$(node, consts.id.EDIT, setting) + .unbind() + .remove(); }, - removeRemoveBtn: function (setting, node) { - $$(node, consts.id.REMOVE, setting).unbind().remove(); + removeRemoveBtn: function(setting, node) { + $$(node, consts.id.REMOVE, setting) + .unbind() + .remove(); }, - removeTreeDom: function (setting, node) { + removeTreeDom: function(setting, node) { node.isHover = false; view.removeEditBtn(setting, node); view.removeRemoveBtn(setting, node); tools.apply(setting.view.removeHoverDom, [setting.treeId, node]); }, - repairNodeLevelClass: function (setting, node, oldLevel) { + repairNodeLevelClass: function(setting, node, oldLevel) { if (oldLevel === node.level) return; var liObj = $$(node, setting), aObj = $$(node, consts.id.A, setting), @@ -3808,18 +5171,17 @@ ulObj.removeClass(oldClass); ulObj.addClass(newClass); }, - selectNodes: function (setting, nodes) { + selectNodes: function(setting, nodes) { for (var i = 0, l = nodes.length; i < l; i++) { view.selectNode(setting, nodes[i], i > 0); } - } + }, }, - _z = { tools: _tools, view: _view, event: _event, - data: _data + data: _data, }; $.extend(true, $.fn.zTree.consts, _consts); $.extend(true, $.fn.zTree._z, _z); @@ -3842,7 +5204,7 @@ data.addZTreeTools(_zTreeTools); var _cancelPreSelectedNode = view.cancelPreSelectedNode; - view.cancelPreSelectedNode = function (setting, node) { + view.cancelPreSelectedNode = function(setting, node) { var list = data.getRoot(setting).curSelectedList; for (var i = 0, j = list.length; i < j; i++) { if (!node || node === list[i]) { @@ -3851,10 +5213,10 @@ } } if (_cancelPreSelectedNode) _cancelPreSelectedNode.apply(view, arguments); - } + }; var _createNodes = view.createNodes; - view.createNodes = function (setting, level, nodes, parentNode, index) { + view.createNodes = function(setting, level, nodes, parentNode, index) { if (_createNodes) { _createNodes.apply(view, arguments); } @@ -3862,43 +5224,55 @@ if (view.repairParentChkClassWithSelf) { view.repairParentChkClassWithSelf(setting, parentNode); } - } + }; var _makeNodeUrl = view.makeNodeUrl; - view.makeNodeUrl = function (setting, node) { - return setting.edit.enable ? null : (_makeNodeUrl.apply(view, arguments)); - } + view.makeNodeUrl = function(setting, node) { + return setting.edit.enable ? null : _makeNodeUrl.apply(view, arguments); + }; var _removeNode = view.removeNode; - view.removeNode = function (setting, node) { + view.removeNode = function(setting, node) { var root = data.getRoot(setting); if (root.curEditNode === node) root.curEditNode = null; if (_removeNode) { _removeNode.apply(view, arguments); } - } + }; var _selectNode = view.selectNode; - view.selectNode = function (setting, node, addFlag) { + view.selectNode = function(setting, node, addFlag) { var root = data.getRoot(setting); - if (data.isSelectedNode(setting, node) && root.curEditNode == node && node.editNameFlag) { + if ( + data.isSelectedNode(setting, node) && + root.curEditNode == node && + node.editNameFlag + ) { return false; } if (_selectNode) _selectNode.apply(view, arguments); view.addHoverDom(setting, node); return true; - } + }; var _uCanDo = tools.uCanDo; - tools.uCanDo = function (setting, e) { + tools.uCanDo = function(setting, e) { var root = data.getRoot(setting); - if (e && (tools.eqs(e.type, "mouseover") || tools.eqs(e.type, "mouseout") || tools.eqs(e.type, "mousedown") || tools.eqs(e.type, "mouseup"))) { + if ( + e && + (tools.eqs(e.type, "mouseover") || + tools.eqs(e.type, "mouseout") || + tools.eqs(e.type, "mousedown") || + tools.eqs(e.type, "mouseup")) + ) { return true; } if (root.curEditNode) { view.editNodeBlur = false; root.curEditInput.focus(); } - return (!root.curEditNode) && (_uCanDo ? _uCanDo.apply(view, arguments) : true); - } -})(jQuery); \ No newline at end of file + return ( + !root.curEditNode && (_uCanDo ? _uCanDo.apply(view, arguments) : true) + ); + }; +})(jQuery); diff --git a/test.html b/test.html index 0140930..af46fa6 100644 --- a/test.html +++ b/test.html @@ -37,7 +37,13 @@ </div> <script> - + let obj = { + a:{ + b:{ + c:'c' + } + } + } </script> </body> </html> \ No newline at end of file diff --git a/vue.config.js b/vue.config.js index 53c46cf..3027214 100644 --- a/vue.config.js +++ b/vue.config.js @@ -33,17 +33,17 @@ changeOrigin: true, }, "/api": { - target: "http://192.168.20.10:7004", - // target: "http://192.168.20.117:7080", + // target: "http://192.168.20.10:7004", + target: "http://192.168.20.174:7070", // secure: false, changeOrigin: true, }, + "/httpImage": { //target: "http://bsic.asuscomm.com:7003", // target: "http://222.128.87.51:7003", - // target: "http://192.168.20.10:7009", - target: "http://192.168.20.117:7080", - + target: "http://192.168.20.10:7009", + // target: "http://192.168.20.117:7080", // target: "http://192.168.20.189:7009", // target: "http://192.168.20.117:7080", -- Gitblit v1.8.0