diff --git a/resources/assets/component.min.js b/resources/assets/component.min.js index d06933c..bca2700 100644 --- a/resources/assets/component.min.js +++ b/resources/assets/component.min.js @@ -1 +1 @@ -window._component={trash:'\n \n \n',move:'\n \n',write:'\n \n \n',close:'',check:'\n \n',check_circle:'\n \n \n',caret_right:'\n \n',caret_right_circle:'\n \n',sub_loading:'\n \n \n \n ',node:'\n \n',request:function(e){e=Object.assign({url:"",method:"GET",header:{},data:{},callback:null,error_callback:null,timeout:3e4},e);let t=new XMLHttpRequest;"GET"===e.method&&(e.url=_component.parseParams(e.url,e.data)),t.open(e.method,e.url,!0),t.timeout=e.timeout;let i="";if(document.querySelector('meta[name="csrf-token"]')&&(i=document.querySelector('meta[name="csrf-token"]').getAttribute("content")),t.setRequestHeader("X-CSRF-TOKEN",i),e.header)for(let i in e.header)e.header.hasOwnProperty(i)&&t.setRequestHeader(i,e.header[i]);"GET"===e.method?(t.setRequestHeader("Content-type","application/text;charset=UTF-8"),t.responseType="text",t.send(null)):(e.data instanceof FormData?t.setRequestHeader("X-Requested-With","XMLHttpRequest"):(t.setRequestHeader("Content-Type","application/json;charset=UTF-8"),e.data=JSON.stringify(e.data)),t.responseType="json",t.send(e.data)),t.onload=function(){this.status>=200&&this.status<300||"function"==typeof e.error_callback&&e.error_callback()},t.onreadystatechange=function(){if(t.readyState===t.DONE&&200===t.status){let i=t.response;"function"==typeof e.callback&&e.callback(i)}},t.onerror=function(t){console.error(t),"function"==typeof e.error_callback&&e.error_callback(t)}},parseParams(e,t){let i=[];return 0===Object.keys(t).length||(Object.keys(t).forEach((e=>t[e]&&i.push(`${e}=${t[e]}`))),-1===e.search(/\?/)?e+=`?${i.join("&")}`:e+=`&${i.join("&")}`),e},loading:function(e,t=!1){t?e.innerHTML="":e.insertAdjacentHTML("afterbegin",'
\n
\n
\n
\n
\n
\n
\n
')},_alert_documents:[],alert:function(e,t=1,i=null,s=null){let a,n,l=document.createElement("div");l.insertAdjacentHTML("afterbegin",`${e}`),l.className="dlp-alert",this._alert_documents.forEach((e=>{e.style.top=parseInt(e.style.top)-60+"px"})),this._alert_documents.push(l),s?s.append(l):document.getElementsByTagName("BODY")[0].appendChild(l),s?(a=(s.offsetWidth-320)/2,n=s.offsetHeight/2-15,l.style.position="absolute"):(a=(window.innerWidth-320)/2,n=window.innerHeight/2-15,l.style.position="fixed"),l.style.top=n+"px",l.style.left=a+"px",setTimeout((()=>{let e=this._alert_documents.shift();e.parentNode.removeChild(e),"function"==typeof i&&i()}),1e3*t)},contextmenu:function(e,t,i={}){i=Object.assign({W:"70px"},i);let s=document.createElement("ul");s.className="dlp dlp-contextmenu",t.forEach((e=>{let t=document.createElement("li");t.className="dlp dlp-text",t.insertAdjacentHTML("afterbegin",e.title),t.style.width=i.W,"function"==typeof e.func&&(t.addEventListener("click",(()=>{s.remove(),setTimeout((()=>{e.func()}),100)})),s.append(t))})),s.style.top=e.pageY-3+"px",s.style.left=e.pageX-3+"px",s.addEventListener("contextmenu",(e=>{e.preventDefault()})),s.addEventListener("mouseleave",(()=>{s.remove()})),document.getElementsByTagName("BODY")[0].appendChild(s)},dimensional(e,t,i=0,s=[]){if(Array.isArray(t)){for(let a in t){if(!t.hasOwnProperty(a))continue;let n=s.slice(0);n.push(t[a].key),_component.dimensional(e,t[a],i,n)}return}let a=s.slice(0);a.pop(),t.parentNodes=a,Array.isArray(e[i])?e[i].push(t):e[i]=[t],t.hasOwnProperty("nodes")&&Array.isArray(t.nodes)&&0!==t.nodes.length&&(i++,_component.dimensional(e,t.nodes,i,s))}},window.ComponentDot=class{MODE={insert:"insert",delete:"delete"};constructor(e,t,i,s=0,a={}){if(!Array.isArray(i))return void console.error("Dot param selected must be array!");if(Array.isArray(t)||"object"!=typeof t)return void console.error("Dot param select must be object such as {key:val,key2:val2,...} !");this.select=t,this.name=e,this.limit=s,this.DOM=document.getElementById(e),this.DOM.addEventListener("contextmenu",(e=>{e.preventDefault()})),this.menu=Object.assign({mode:!1,placeholder:"未选择",height:"150px"},a),this.selected_data=i,this.select_data=[],this.insert_data=[],this.delete_data=[],setTimeout((()=>{let e=[];this.CONTENT_DOM.childNodes.forEach((t=>{let s=parseInt(t.getAttribute("data-id"));-1!==i.indexOf(s)&&e.push(t)})),e.forEach((e=>e.click())),!0===this.menu.mode&&(this.DOM.querySelector(".menu-list").style.display="none")})),!1===this.menu.mode?this.make(i,t):(this.menu_placeholder=this.menu.placeholder,this.menuMake(i,t));let n=this.DOM.querySelector(".dot-search");n.addEventListener("input",(()=>{setTimeout((()=>{this.search(n,this.menu.mode)}),500)}))}make(e,t){let i="";for(let e in t)t.hasOwnProperty(e)&&(i+=`
${t[e]}
`);let s=`
${i}
\n`;this.DOM.insertAdjacentHTML("afterbegin",s),this.SELECTED_DOM=document.querySelector(`#${this.name} .dot-selected`),this.CONTENT_DOM=document.querySelector(`#${this.name} .dot-select`),this.selectInputDOM=document.querySelector(`input[name='${this.name}[select]']`),this.insertInputDOM=document.querySelector(`input[name='${this.name}[insert]']`),this.deleteInputDOM=document.querySelector(`input[name='${this.name}[delete]']`);for(let e of this.CONTENT_DOM.getElementsByClassName("dlp-label"))e.addEventListener("click",this.tagSelect.bind(this,e),!1)}menuMake(e,t){let i=document.createElement("div");i.className="dlp-dot-menu";let s=document.createElement("div");s.className="dlp-input dlp-dot-menu-select",s.insertAdjacentHTML("afterbegin",`
${this.menu_placeholder}
`);let a=document.createElement("div");a.className="menu-list";let n=document.createElement("div");n.className="search-box";let l=document.createElement("input");l.className="dlp dlp-input dot-search",l.setAttribute("placeholder","搜索");let d=document.createElement("div");d.className="list dlp-scroll",d.style.maxHeight=this.menu.height;let r=_component.check;r=r.replace('width="16" height="16"','width="12" height="12"'),this.id_line_hash=[];let o=0;for(let e in t){if(!t.hasOwnProperty(e))continue;this.id_line_hash[e]=o,o++;let i=document.createElement("div");i.className="option",i.setAttribute("data-id",e),i.insertAdjacentHTML("afterbegin",`
${t[e]}
`),i.addEventListener("click",(()=>{if(e=parseInt(e),-1!==this.select_data.indexOf(e))return this.tagCal(e,this.MODE.delete),i.classList.remove("option-active"),i.lastChild instanceof HTMLElement&&(i.lastChild.innerHTML=""),this.menuSelect(t),void(0===this.select_data.length&&(this.SELECTED_DOM.textContent=this.menu_placeholder));this.limit>0&&this.select_data.length>=this.limit&&d.childNodes[this.id_line_hash[this.select_data[0].toString()]].click(),i.classList.add("option-active"),this.tagCal(e,this.MODE.insert),i.lastChild instanceof HTMLElement&&i.lastChild.insertAdjacentHTML("afterbegin",r),this.menuSelect(t)}),!1),d.append(i)}i.append(s),n.append(l),a.append(n),a.append(d),i.append(a),i.addEventListener("click",(()=>{a.style.display="flex"})),i.addEventListener("mouseleave",(()=>{a.style.display="none",this.DOM.querySelector(".dot-search").value="";for(let e of this.CONTENT_DOM.childNodes)e.style.display="flex"})),this.DOM.append(i),this.DOM.insertAdjacentHTML("beforeend",``),this.SELECTED_DOM=document.querySelector(`#${this.name} .dlp-dot-menu-select`).firstElementChild,this.CONTENT_DOM=document.querySelector(`#${this.name} .list`),this.selectInputDOM=document.querySelector(`input[name='${this.name}[select]']`),this.insertInputDOM=document.querySelector(`input[name='${this.name}[insert]']`),this.deleteInputDOM=document.querySelector(`input[name='${this.name}[delete]']`)}menuSelect(e){if(1===this.limit)return void(this.SELECTED_DOM.innerHTML=`

${e[this.select_data[0]]}

`);let t="";for(let i of this.select_data)t+=`${e[i]}`;this.SELECTED_DOM.innerHTML=t}tagSelect(e){this.limit>0&&this.select_data.length>=this.limit&&this.SELECTED_DOM.firstChild instanceof HTMLElement&&this.SELECTED_DOM.firstChild.click();let t=e.cloneNode(!0);t.addEventListener("click",this.tagCancel.bind(this,t),!1),this.SELECTED_DOM.appendChild(t),e.remove(),this.tagCal(parseInt(e.getAttribute("data-id")),this.MODE.insert),this.SELECTED_DOM.scrollTop=this.SELECTED_DOM.scrollHeight}tagCancel(e){let t=e.cloneNode(!0);t.addEventListener("click",this.tagSelect.bind(this,t),!1),this.CONTENT_DOM.appendChild(t),e.remove(),this.tagCal(parseInt(e.getAttribute("data-id")),this.MODE.delete)}tagCal(e,t){let i=this.select_data.indexOf(e);t===this.MODE.insert?(-1===i&&(this.select_data.push(e),this.selectInputDOM.value=JSON.stringify(this.select_data)),-1===this.selected_data.indexOf(e)&&-1===this.insert_data.indexOf(e)&&(this.insert_data.push(e),this.insertInputDOM.value=JSON.stringify(this.insert_data)),i=this.delete_data.indexOf(e),-1!==i&&(this.delete_data.splice(i,1),this.deleteInputDOM.value=JSON.stringify(this.delete_data))):(-1!==i&&(this.select_data.splice(i,1),this.selectInputDOM.value=JSON.stringify(this.select_data)),-1!==this.selected_data.indexOf(e)&&-1===this.delete_data.indexOf(e)&&(this.delete_data.push(e),this.deleteInputDOM.value=JSON.stringify(this.delete_data)),i=this.insert_data.indexOf(e),-1!==i&&(this.insert_data.splice(i,1),this.insertInputDOM.value=JSON.stringify(this.insert_data)))}search(e,t){if(t){if(""===e.value){for(let e of this.CONTENT_DOM.childNodes)e.style.display="flex";return}for(let t in this.select){if(!this.select.hasOwnProperty(t))continue;let i=this.select[t],s=this.id_line_hash[t];-1!==i.indexOf(e.value)||-1!==e.value.indexOf(i)?this.CONTENT_DOM.childNodes[s].style.display="flex":this.CONTENT_DOM.childNodes[s].style.display="none"}return}if(""===e.value){if(this.SELECT_COVER_DOM instanceof HTMLElement){let e=[];this.SELECT_COVER_DOM.childNodes.forEach((t=>{e.push(t)})),this.CONTENT_DOM.append(...e),this.SELECT_COVER_DOM.remove(),this.SELECT_COVER_DOM=null}return}if(this.SELECT_COVER_DOM instanceof HTMLElement){let e=[];this.SELECT_COVER_DOM.childNodes.forEach((t=>{e.push(t)})),this.CONTENT_DOM.append(...e)}else this.SELECT_COVER_DOM=document.createElement("div"),this.SELECT_COVER_DOM.className="dot-select dlp-scroll dot-select-cover",this.CONTENT_DOM.parentNode.appendChild(this.SELECT_COVER_DOM);let i=[];for(let t of this.CONTENT_DOM.childNodes)-1!==t.className.indexOf("dlp-label")&&(-1===t.innerText.indexOf(e.value)&&-1===e.value.indexOf(t.innerText)||i.push(t));this.SELECT_COVER_DOM.append(...i)}},window.ComponentCascadeDot=class{MODE={insert:"insert",delete:"delete"};constructor(e,t,i,s=0){if(!Array.isArray(i)||!Array.isArray(t))return void console.error("CascadeDot param selected and select must be array!");this.name=e,this.limit=s,this.DOM=document.getElementById(e),this.selected_data=i,this.select_data=[],this.insert_data=[],this.delete_data=[],this.make().makeSelect(t),setTimeout((()=>{this.selected_label_dom.forEach((e=>{e.click()}))})),this.selectInputDOM.value=JSON.stringify(this.select_data);let a=document.querySelector(`#${this.name} .dot-search`);a.addEventListener("input",(()=>{setTimeout((()=>{this.search(a)}),500)}))}make(){let e=`
\n`;return this.DOM.insertAdjacentHTML("afterbegin",e),this.DOM.addEventListener("contextmenu",(e=>{e.preventDefault()})),this.SELECTED_DOM=document.querySelector(`#${this.name} .dot-selected`),this.CONTENT_DOM=document.querySelector(`#${this.name} .dot-select`),this.selectInputDOM=document.querySelector(`input[name='${this.name}[select]']`),this.insertInputDOM=document.querySelector(`input[name='${this.name}[insert]']`),this.deleteInputDOM=document.querySelector(`input[name='${this.name}[delete]']`),this}makeSelect(e){this.dimensional_data=[],this.selected_label_dom=[],_component.dimensional(this.dimensional_data,e);let t=this;for(let e in this.dimensional_data){if(!this.dimensional_data.hasOwnProperty(e))continue;e=parseInt(e);let i=this.dimensional_data[e],s=document.createElement("div");s.className="dot-cascade-stack dlp-scroll",i.forEach(((i,a)=>{Array.isArray(i.nodes)&&0!==i.nodes.length?i.nodes=i.nodes.map((e=>e.key)):(i.nodes=null,i.checked=!1);let n=document.createElement("div");n.className="dlp dlp-text dlp-label",n.insertAdjacentHTML("afterbegin",`${i.val}`),n.setAttribute("data-id",i.key),n.setAttribute("data-k",a),n.addEventListener("click",this.select.bind(this,n,e)),null!==i.nodes?(n.querySelector("i.left").insertAdjacentHTML("afterbegin",`${_component.caret_right}`),n.addEventListener("contextmenu",(i=>{i.target instanceof HTMLElement&&i.target.click(),i.preventDefault();let s=parseInt(n.getAttribute("data-k"));_component.contextmenu(i,[{title:"全选",func:()=>{t.checkAll(e+1,this.dimensional_data[e][s].nodes,!0),i.target instanceof HTMLElement&&i.target.click()}},{title:"取消",func:()=>{t.checkAll(e+1,this.dimensional_data[e][s].nodes,!1)}}])}))):n.addEventListener("contextmenu",(e=>{e.preventDefault()})),s.append(n);let l=this.selected_data.indexOf(parseInt(i.key));!1===i.checked||-1===l?-1!==l&&this.selected_label_dom.push(n):this.selected_data.splice(l,1)})),this.CONTENT_DOM.append(s)}return this.STACKS=this.CONTENT_DOM.childNodes,this}select(e,t){let i=parseInt(e.getAttribute("data-id")),s=parseInt(e.getAttribute("data-k")),a=this.dimensional_data[t][s],n=this.STACKS[t].childNodes,l=a.parentNodes[a.parentNodes.length-1];if(!0===a.checked){a.checked=!1,this.tagCal(i,this.MODE.delete),null===a.nodes&&(e.querySelector("i.right").innerHTML="");for(let e of this.SELECTED_DOM.childNodes)if(parseInt(e.getAttribute("data-id"))===i){e.remove();break}}else this.dimensional_data[t].forEach(((e,t)=>{-1!==e.parentNodes.indexOf(l)?n[t].classList.remove("dlp-label-silence"):n[t].classList.add("dlp-label-silence")})),!1===a.checked?(this.limit>0&&this.select_data.length>=this.limit&&this.SELECTED_DOM.firstChild instanceof HTMLElement&&this.SELECTED_DOM.firstChild.click(),a.checked=!0,this.tagCal(i,this.MODE.insert),e.classList.remove("dlp-label-silence"),e.querySelector("i.right").insertAdjacentHTML("afterbegin",_component.check),this.selectToChildren(t+1,a.nodes),this.selectToSelected(e,t),this.SELECTED_DOM.scrollTop=this.SELECTED_DOM.scrollHeight):(e.classList.remove("dlp-label-silence"),this.selectToChildren(t+1,a.nodes));if(Array.isArray(a.parentNodes)&&a.parentNodes.length>0){let e=a.parentNodes.slice(0);this.selectToParent(e,a.checked)}}selectToSelected(e,t){let i=document.createElement("div");i.className="dlp dlp-text dlp-label",i.setAttribute("data-id",e.getAttribute("data-id")),i.setAttribute("stack",t),i.insertAdjacentHTML("afterbegin",`${e.querySelector("span").textContent}`),i.addEventListener("click",(()=>{this.select(e,t)})),this.SELECTED_DOM.append(i)}selectToParent(e,t){let i=e.length-1,s=e.pop(),a=e[i-1],n=this.STACKS[i].childNodes,l=null;this.dimensional_data[i].forEach(((e,d)=>{let r=n[d],o=e.parentNodes;if(!0!==t&&void 0!==t||(o.length>0&&o[i-1]!==a||0===o.length&&parseInt(r.getAttribute("data-id"))!==s?r.classList.add("dlp-label-silence"):(r.classList.remove("dlp-label-silence"),parseInt(r.getAttribute("data-id"))===s&&null===l&&(l=d))),!0===t&&s===e.key&&!0!==e.mark&&(e.mark=!0,r.querySelector(".right").insertAdjacentHTML("afterbegin",_component.check_circle)),!1===t&&s===e.key){let t=this.dimensional_data[i][d].nodes,s=!0;for(let e of this.dimensional_data[i+1])if(-1!==t.indexOf(e.key)&&(!0===e.checked||!0===e.mark)){s=!1;break}s&&(e.mark=!1,r.querySelector("i.right").innerHTML="")}})),null!==l&&this.STACKS[i].scrollTo(0,27*l),e.length>0&&this.selectToParent(e,t)}selectToChildren(e,t){if(e>this.dimensional_data.length-1)return;let i=this.STACKS[e].childNodes,s=[],a=null;this.dimensional_data[e].forEach(((e,n)=>{let l=i[n];if(null!==t)if(-1!==t.indexOf(parseInt(l.getAttribute("data-id")))){l.classList.remove("dlp-label-silence");let t=e.nodes;Array.isArray(t)&&t.forEach((e=>{-1===s.indexOf(t)&&s.push(e)})),null===a&&(a=n)}else l.classList.add("dlp-label-silence");else l.classList.add("dlp-label-silence")})),null!==a&&this.STACKS[e].scrollTo(0,27*a),this.selectToChildren(e+1,s)}tagCal(e,t){if(t!==this.MODE.insert){if(t===this.MODE.delete){let t=this.select_data.indexOf(e);-1!==t&&(this.select_data.splice(t,1),this.selectInputDOM.value=JSON.stringify(this.select_data)),-1!==this.selected_data.indexOf(e)&&-1===this.delete_data.indexOf(e)&&(this.delete_data.push(e),this.deleteInputDOM.value=JSON.stringify(this.delete_data)),t=this.insert_data.indexOf(e),-1!==t&&(this.insert_data.splice(t,1),this.insertInputDOM.value=JSON.stringify(this.insert_data))}}else{-1===this.select_data.indexOf(e)&&(this.select_data.push(e),this.selectInputDOM.value=JSON.stringify(this.select_data)),-1===this.selected_data.indexOf(e)&&-1===this.insert_data.indexOf(e)&&(this.insert_data.push(e),this.insertInputDOM.value=JSON.stringify(this.insert_data));let t=this.delete_data.indexOf(e);-1!==t&&(this.delete_data.splice(t,1),this.deleteInputDOM.value=JSON.stringify(this.delete_data))}}search(e){if(""!==e.value){if(!(this.SELECT_COVER_DOM instanceof HTMLElement)){this.COVER_STACK_HASH_DOM=[],this.SELECT_COVER_DOM=document.createElement("div"),this.SELECT_COVER_DOM.className="dot-select-cover dlp-scroll dot-select-cascade";for(let e=1;e<=this.dimensional_data.length;e++){let e=document.createElement("div");e.className="dot-cascade-stack dlp-scroll",this.SELECT_COVER_DOM.append(e)}this.CONTENT_DOM.parentNode.append(this.SELECT_COVER_DOM)}this.dimensional_data.forEach(((t,i)=>{this.searchPushTag(e,t,i)}))}else this.SELECT_COVER_DOM instanceof HTMLElement&&(this.SELECT_COVER_DOM.remove(),this.SELECT_COVER_DOM=null,this.COVER_STACK_HASH_DOM=[])}searchCoverClick(e,t,i){if(null===t.nodes)i instanceof HTMLElement&&i.click();else{let i=e+1;Array.isArray(this.dimensional_data[i])&&this.searchPushTag(t.nodes,this.dimensional_data[i],i)}}searchPushTag(e,t,i){t.forEach(((t,s)=>{if(Array.isArray(e)){if(-1===e.indexOf(t.key))return}else if(-1===t.val.indexOf(e.value)&&-1===e.value.indexOf(t.val))return;if(Array.isArray(this.COVER_STACK_HASH_DOM[i])&&-1!==this.COVER_STACK_HASH_DOM[i].indexOf(t.key))return;let a=document.createElement("div");a.className="dlp dlp-text dlp-label",a.insertAdjacentHTML("afterbegin",''),a.textContent=t.val,a.insertAdjacentHTML("beforeend",''),null!==t.nodes&&a.querySelector("i.left").insertAdjacentHTML("afterbegin",_component.caret_right),a.addEventListener("click",(()=>this.searchCoverClick(i,t,this.STACKS[i].childNodes[s]))),this.SELECT_COVER_DOM.childNodes[i].prepend(a),Array.isArray(this.COVER_STACK_HASH_DOM[i])?this.COVER_STACK_HASH_DOM[i].push(t.key):this.COVER_STACK_HASH_DOM[i]=[t.key]}))}checkAll(e,t,i){if(e>this.dimensional_data.length-1)return;if(!Array.isArray(t)||t.length<=0)return;let s=this.STACKS[e].childNodes,a=[],n=null;s.forEach(((s,l)=>{if(-1!==t.indexOf(parseInt(s.getAttribute("data-id")))){let t=this.dimensional_data[e][l].checked;!0===i?!1===t&&s.click():!1===i&&!0===t&&s.click();let d=this.dimensional_data[e][l].nodes;Array.isArray(d)&&d.forEach((e=>{-1===a.indexOf(d)&&a.push(e)})),null===n&&(n=l)}})),null!==n&&this.STACKS[e].scrollTo(0,27*n),this.checkAll(e+1,a,i)}},window.ComponentLine=class{constructor(e,t,i,s={}){this.DOM=document.getElementById(e),this.NAME=e,this.DOM.addEventListener("contextmenu",(e=>{e.preventDefault()})),this.format_settings={},this.COLUMNS=t,this.DATA=i,this.OPTIONS=Object.assign({sortable:!0,delete:!0,insert:!0},s);let a=this.makeHeadFoot();this.DATA_INPUT=document.createElement("input"),this.DATA_INPUT.setAttribute("name",e),this.DATA_INPUT.setAttribute("type","hidden"),this.DATA_INPUT.value="[]",this.DOM.appendChild(this.DATA_INPUT),this.makeBody(),this.makeFoot(a),this.datepicker(),this.OPTIONS.sortable&&this.sortable()}makeHeadFoot(){let e='',t=document.createElement("tr");t.className="dlp-tr";let i=this.COLUMNS;this.INSERT_ROW_MENUE_DATA={};for(let s in i){if(!i.hasOwnProperty(s))continue;let a=i[s];if("hidden"===a.type)continue;let n=a.style?`style="${a.style}"`:"";switch(e+=`${a.name}`,a.insert_type?a.insert_type:a.type){case"input":t.insertAdjacentHTML("beforeend",``);break;case"select":let e=document.createElement("td");e.style=a.style,e.append(this.menuMake(s,[],a.options,a.options_limit,a.name,!0)),t.append(e);break;case"datetime":let i;switch(a.format){case 1:i="YYYY-MM-DD";break;case 2:i="YYYY";break;default:i="YYYY-MM-DD HH:mm:ss"}this.format_settings[s]=i,n=a.style?`${a.style}`:"",t.insertAdjacentHTML("beforeend",``);break;case"hidden":t.insertAdjacentHTML("beforeend",``);break;default:this.COLUMNS[s].insert_type="input",t.insertAdjacentHTML("beforeend",``)}}return e+='',t.insertAdjacentHTML("beforeend",'
'),this.DOM.insertAdjacentHTML("afterbegin",`${e}
`),this.TABLE_DOM=this.DOM.getElementsByTagName("table")[0],t}makeBody(){let e=[],t=document.createElement("tbody"),i=this.COLUMNS;!1!==Array.isArray(this.DATA)&&(this.DATA.forEach(((s,a)=>{let n=document.createElement("tr");n.className="dlp-tr",n.setAttribute("sortable-item","sortable-item");let l={};for(let e in i){if(!i.hasOwnProperty(e))continue;let t=i[e];s[e]||(this.DATA[a][e]="",l[e]="");let d=document.createElement("td"),r=this.DATA[a][e];"select"===t.type&&(/^[0-9]+$/.test(r)?r=[parseInt(r)]:!1===Array.isArray(r)&&(r=[])),this.makeTd(d,e,t,r),l[e]=r,n.appendChild(d)}let d=document.createElement("td");d.insertAdjacentHTML("afterbegin","
"),this.operateButton(d),n.appendChild(d),t.appendChild(n),e.push(l)})),this.DATA=e,this.DATA_INPUT.value=JSON.stringify(e),t.setAttribute("sortable-list","sortable-list"),t.className="dlp-tbody dlp-scroll",this.TBODY_DOM=t,this.TABLE_DOM.appendChild(t))}makeFoot(e){let t=document.createElement("tfoot");if(t.className="dlp-tfoot",!this.OPTIONS.insert)return t.insertAdjacentHTML("afterbegin",""),void this.TABLE_DOM.appendChild(t);t.append(e),this.TABLE_DOM.appendChild(t);let i=document.createElement("i");i.className="dlp text-white",i.style.cursor="pointer",i.insertAdjacentHTML("afterbegin",_component.write),i.addEventListener("click",(()=>{let e=this.DOM.getElementsByTagName("tfoot")[0],t={},i=document.createElement("tr");i.className="dlp-tr",i.setAttribute("sortable-item","sortable-item");for(let s in this.COLUMNS){if(!this.COLUMNS.hasOwnProperty(s))continue;let a,n=this.COLUMNS[s].insert_type?this.COLUMNS[s].insert_type:this.COLUMNS[s].type,l=document.createElement("td");a="input"===n||"datetime"===n?e.querySelector(`input[data-column="${s}"]`).value:"select"===n?this.INSERT_ROW_MENUE_DATA[s]:"",t[s]=a,this.makeTd(l,s,this.COLUMNS[s],a),i.appendChild(l)}let s=document.createElement("td");s.insertAdjacentHTML("afterbegin","
"),this.operateButton(s),i.appendChild(s),this.TBODY_DOM.appendChild(i),this.DATA.push(t),this.DATA_INPUT.value=JSON.stringify(this.DATA),this.TBODY_DOM.scrollTop=this.TBODY_DOM.scrollHeight,this.datepicker()}),!1),this.TABLE_DOM.querySelector(".insert_handel div").appendChild(i)}makeTd(e,t,i,s){let a,n=this.DATA,l=this.DATA_INPUT;switch(i.type){case"text":default:e.insertAdjacentHTML("afterbegin",`

${s}

`);break;case"input":a=document.createElement("input"),a.className="dlp dlp-input",a.setAttribute("data-column",t),a.value=s,a.addEventListener("input",(()=>{let e=this.searchChildrenDomIndex(a.parentNode.parentNode),t=a.getAttribute("data-column");n[e]&&(n[e][t]=a.value,l.value=JSON.stringify(n))}),!1),e.appendChild(a);break;case"datetime":let d;switch(a=document.createElement("input"),a.setAttribute("class",`dlp dlp-input datetime-${t}`),a.setAttribute("data-column",t),a.value=s,i.format){case 1:d="YYYY-MM-DD";break;case 2:d="YYYY";break;default:d="YYYY-MM-DD HH:mm:ss"}this.format_settings[t]=d,a.addEventListener("blur",(()=>{let e=this.searchChildrenDomIndex(a.parentNode.parentNode),t=a.getAttribute("data-column");n[e]&&(n[e][t]=a.value,l.value=JSON.stringify(n))}),!1),e.appendChild(a),e.style.position="relative";break;case"select":e.append(this.menuMake(t,s,i.options,i.options_limit,i.name))}i.style&&(e.style=i.style)}operateButton(e){if(this.OPTIONS.sortable){let t=document.createElement("i");t.className="dlp text-white",t.setAttribute("style","cursor: pointer;"),t.setAttribute("sortable-handle","sortable-handle"),t.insertAdjacentHTML("afterbegin",_component.move),e.firstElementChild.appendChild(t)}if(this.OPTIONS.delete){let t=document.createElement("i");t.className="dlp text-white",t.setAttribute("style","cursor: pointer;"),t.insertAdjacentHTML("afterbegin",_component.trash),t.addEventListener("click",(()=>{let e=t.parentNode.parentNode.parentNode,i=e.parentNode,s=this.searchChildrenDomIndex(e);this.DATA.splice(s,1),i.removeChild(e),this.DATA_INPUT.value=JSON.stringify(this.DATA)}),!1),e.firstElementChild.appendChild(t)}e.className="operate-column"}menuMake(e,t,i,s,a,n=!1){let l=document.createElement("div");l.className="dlp-dot-menu",n&&(this.INSERT_ROW_MENUE_DATA[e]=[]);let d=document.createElement("div");d.className="dlp-input dlp-dot-menu-select",d.insertAdjacentHTML("afterbegin",`
${a}
`);let r=document.createElement("div");r.className="menu-list";let o=document.createElement("div");o.className="search-box";let c=document.createElement("input");c.className="dlp dlp-input dot-search",c.setAttribute("placeholder","搜索"),c.addEventListener("input",(()=>{setTimeout((()=>{if(""!==c.value)for(let e of h.childNodes){let t=e.firstElementChild.innerText;-1!==t.indexOf(c.value)||-1!==c.value.indexOf(t)?e.style.display="flex":e.style.display="none"}else for(let e of h.childNodes)e.style.display="flex"}),300)}));let h=document.createElement("div");h.className="list dlp-scroll";let p=_component.check;p=p.replace('width="16" height="16"','width="12" height="12"');for(let r in i){if(!i.hasOwnProperty(r))continue;let o=document.createElement("div");o.className="option",o.setAttribute("data-id",r),o.insertAdjacentHTML("afterbegin",`
${i[r]}
`),o.addEventListener("click",(()=>{let t;if(r=parseInt(r),n)t=this.INSERT_ROW_MENUE_DATA[e];else{let i=this.searchChildrenDomIndex(l.parentNode.parentNode);t=this.DATA[i][e]}let c=t.indexOf(r);if(-1!==c)return t.splice(c,1),o.classList.remove("option-active"),o.lastChild instanceof HTMLElement&&(o.lastChild.innerHTML=""),m(i,t,s),0===t.length&&(d.firstElementChild.textContent=a),void(!1===n&&(this.DATA_INPUT.value=JSON.stringify(this.DATA)));if(s>0&&t.length>=s)for(let e of h.childNodes)t.hasOwnProperty("0")&&e.getAttribute("data-id")===t[0].toString()&&e.click();o.classList.add("option-active"),t.push(r),o.lastChild instanceof HTMLElement&&o.lastChild.insertAdjacentHTML("afterbegin",p),m(i,t,s),!1===n&&(this.DATA_INPUT.value=JSON.stringify(this.DATA))}),!1),s>0&&t.length>=s&&t.slice(0,s),-1!==t.indexOf(parseInt(r))&&(o.classList.add("option-active"),o.lastChild instanceof HTMLElement&&o.lastChild.insertAdjacentHTML("afterbegin",p),m(i,t,s)),h.append(o)}function m(e,t,i){if(1===i)return void(d.firstElementChild.innerHTML=`

${e[t[0]]}

`);let s="";for(let i of t)s+=`${e[i]}`;d.firstElementChild.innerHTML=s}return l.append(d),o.append(c),r.append(o),r.append(h),l.append(r),l.addEventListener("click",(()=>{r.style.display="flex"})),l.addEventListener("mouseleave",(()=>{r.style.display="none",this.DOM.querySelector(".dot-search").value=""})),l}sortable(){let e=this;new ComponentSortable(this.TBODY_DOM,(function(t){let i=[];t.forEach((function(t){i.push(e.DATA[t])})),e.DATA=i,e.DATA_INPUT.value=JSON.stringify(e.DATA)}))}datepicker(){"undefined"!=typeof jQuery&&setTimeout((()=>{for(let e in this.format_settings){let t=this.format_settings[e];$(`#${this.NAME} input.datetime-${e}`).datetimepicker({format:t,locale:"zh-CN"})}}))}searchChildrenDomIndex(e){let t=0;for(;null!=(e=e.previousSibling);)t++;return t}},window.ComponentPlane=class{constructor(e,t={},i={}){document.querySelector("#dlp-plane")instanceof HTMLElement||(this.URL=e,this.XHR=Object.assign({url:e,method:"POST",listener:null,event:"click",callback:null},t),this.OPTIONS=Object.assign({w:.8,h:.8,top:"30px",left:"auto"},i),this.makeModal(),this.makeContent())}makeModal(){let e,t;e=-1!==this.OPTIONS.w.toString().indexOf(".")?window.innerWidth*this.OPTIONS.w+"px":this.OPTIONS.w,t=-1!==this.OPTIONS.h.toString().indexOf(".")?window.innerHeight*this.OPTIONS.h+"px":this.OPTIONS.h;let i=`
`;document.body.insertAdjacentHTML("beforeEnd",i),this.DOM=document.getElementById("dlp-plane");let s=document.createElement("i");s.insertAdjacentHTML("afterbegin",_component.close),s.addEventListener("click",(()=>{this.DOM instanceof HTMLElement&&this.DOM.remove(),document.getElementById("kvFileinputModal")instanceof HTMLElement&&document.getElementById("kvFileinputModal").remove()}),!1),this.DOM.querySelector(".plane-header").append(s),this.MODEL_BODY_DOM=this.DOM.querySelector(".plane-body"),window.addEventListener("popstate",(()=>{this.DOM.remove()}),!1)}makeContent(){_component.loading(this.MODEL_BODY_DOM);let e=this;_component.request({url:this.URL,method:"GET",callback:function(t){_component.loading(e.MODEL_BODY_DOM,!0);let i=document.createRange().createContextualFragment(t);e.MODEL_BODY_DOM.appendChild(i);let s=e.XHR.listener;if("function"==typeof s){let t=s(e.MODEL_BODY_DOM);t instanceof HTMLElement&&t.addEventListener(e.XHR.event,e.submitEvent.bind(e,t),!1)}}})}submitEvent(e){e.setAttribute("disabled","disabled"),e.innerText="提交中...";let t=this.MODEL_BODY_DOM.getElementsByTagName("form")[0],i=new FormData(t);for(const e of i.entries()){let t=e[0],s=e[1];/\[.*\]/.test(t)&&/^\[.*\]$/.test(s)&&"string"==typeof s&&(s=JSON.parse(s),Array.isArray(s)&&s.length>0?s.forEach((e=>{i.append(`${t}[]`,e)})):i.append(`${t}`,""))}_component.request({url:this.XHR.url,method:this.XHR.method,data:i,callback:t=>{"function"!=typeof this.XHR.callback?t&&(0===t.code?window.location.reload():_component.alert(t.message,3,(function(){e.removeAttribute("disabled"),e.innerText="提交"}))):this.XHR.callback(t)}})}},window.ComponentSortable=class{constructor(e,t=null){this.list="string"==typeof e?document.querySelector(e):e,this.options={animationSpeed:200,animationEasing:"ease-out"},this.callback=t,this.animation=!1,this.dragStart=this.dragStart.bind(this),this.dragMove=this.dragMove.bind(this),this.dragEnd=this.dragEnd.bind(this),this.list.addEventListener("touchstart",this.dragStart,!1),this.list.addEventListener("mousedown",this.dragStart,!1)}reset(){this.items=Array.from(this.list.children),this.items[this.items.length-1].offsetTop>this.list.offsetHeight?this.listHeight=this.list.scrollHeight:this.listHeight=this.items[this.items.length-1].offsetTop}dragStart(e){if(this.reset(),this.animation)return;if(this.items.length<2)return;this.handle=null;let t=e.target;for(;t&&(t.hasAttribute("sortable-handle")&&(this.handle=t),t.hasAttribute("sortable-item")&&(this.item=t),!t.hasAttribute("sortable-list"));)t=t.parentElement;if(!this.handle)return;this.list.style.position="relative",this.item.classList.add("is-dragging"),this.itemHeight=this.items[1].offsetTop,this.startTouchY=this.getDragY(e),this.startTop=this.item.offsetTop;const i=this.items.map((e=>e.offsetTop));this.items.forEach(((e,t)=>{e.style.position="absolute",e.style.top="0",e.style.left="0",e.style.transform=`translateY(${i[t]}px)`,e.style.zIndex=e===this.item?"2":"1"})),this.positions=this.items.map(((e,t)=>t)),this.position=Math.round(this.startTop/this.listHeight*this.items.length),this.touch="touchstart"===e.type,window.addEventListener(this.touch?"touchmove":"mousemove",this.dragMove),window.addEventListener(this.touch?"touchend":"mouseup",this.dragEnd,!1)}dragMove(e){if(this.animation)return;if(this.items.length<2)return;const t=this.startTop+this.getDragY(e)-this.startTouchY,i=Math.round(t/this.listHeight*this.items.length);this.item.style.transform=`translateY(${t}px)`,this.positions.forEach((e=>{e!==this.position&&e===i&&(this.swapElements(this.positions,this.position,e),this.position=e)})),this.items.forEach(((e,t)=>{e!==this.item&&(e.style.transform=`translateY(${this.positions.indexOf(t)*this.itemHeight}px)`,e.style.transition=`transform ${this.options.animationSpeed}ms ${this.options.animationEasing}`)})),e.preventDefault()}dragEnd(){this.animation=!0,this.items.length<2||(this.item.style.transition=`all ${this.options.animationSpeed}ms ${this.options.animationEasing}`,this.item.style.transform=`translateY(${this.position*this.itemHeight}px)`,this.item.classList.remove("is-dragging"),"function"==typeof this.callback&&this.callback(this.positions),setTimeout((()=>{this.list.style.position="",this.items.forEach((e=>{e.style.top="",e.style.left="",e.style.right="",e.style.position="",e.style.transform="",e.style.transition="",e.style.zIndex=""})),this.positions.map((e=>{this.items[e]&&this.list.appendChild(this.items[e])})),this.animation=!1}),this.options.animationSpeed),window.removeEventListener(this.touch?"touchmove":"mousemove",this.dragMove),window.removeEventListener(this.touch?"touchend":"mouseup",this.dragEnd,!1))}swapElements(e,t,i){let s=e[t];e[t]=e[i],e[i]=s}getDragY(e){return e.touches?(e.touches[0]||e.changedTouches[0]).pageY:e.pageY}},window.ComponentCascadeLine=class{constructor(e,t,i,s){if(!Array.isArray(t))return void console.error("CascadeLine param select must be array!");this.name=e,this.OPTIONS=Object.assign({movable:!0,exchange:!0,detail:!0,insert:!0,update:!0,delete:!0,root:!0},s),this.DOM=document.getElementById(e),this.URL=i,this.make().makeSelect(t),this.OPTIONS.insert&&this.makeHeader();let a=document.querySelector(`#${this.name} .dot-search`);if(a.addEventListener("input",(()=>{setTimeout((()=>{this.search(a)}),700)})),this.OPTIONS.movable)for(let e of this.DOM.querySelectorAll("i.right"))this.nodeMigrate(e)}make(){return this.DOM.insertAdjacentHTML("afterbegin",'
'),this.DOM.addEventListener("contextmenu",(e=>{e.preventDefault()})),this.HEADER_DOM=document.querySelector(`#${this.name} .dot-top`),this.CONTENT_DOM=document.querySelector(`#${this.name} .dot-select`),this.SEARCH_BOX=document.querySelector(`#${this.name} .search-box`),this}makeHeader(){let e=document.createElement("div");e.className="dlp-btn",e.addEventListener("click",(()=>{this.panel("新增根节点");let e=this;_component.request({url:this.URL+"/create",method:"GET",data:{},callback:function(t){e.panelContent(t,{key:0},e.URL,"POST",(t=>{if(void 0===t.data.key)return _component.alert("返回数据结构缺少key",3,null,e.DOM);if(void 0===t.data.val)return _component.alert("返回数据结构缺少val",3,null,e.DOM);let i=parseInt(t.data.key),s=t.data.val,a=e.dimensional_data[0].push({expand:!1,key:i,val:s,nodes:null,parentNodes:[]})-1,n=e.STACKS[0];n.append(e.insertLabelDom(e.dimensional_data[0][a],a,0)),e.STACKS[0].scrollTo(0,27*a),n.lastChild.click(),e.PLANE_DOM.remove()}))}})})),e.insertAdjacentHTML("afterbegin",_component.node),this.HEADER_DOM.append(e)}makeSelect(e){this.dimensional_data=[],_component.dimensional(this.dimensional_data,e);for(let e in this.dimensional_data){if(!this.dimensional_data.hasOwnProperty(e))continue;e=parseInt(e);let t=this.dimensional_data[e],i=document.createElement("div");i.className="dot-cascade-stack dlp-scroll",t.forEach(((t,s)=>{t.stack=e,Array.isArray(t.nodes)&&0!==t.nodes.length?(t.nodes=t.nodes.map((e=>e.key)),t.expand=!1):t.nodes=null;let a=this.insertLabelDom(t,s,e);null!==t.nodes&&a.insertAdjacentHTML("afterbegin",`${_component.caret_right}`),i.append(a)})),this.CONTENT_DOM.append(i)}this.STACKS=this.CONTENT_DOM.childNodes}insertLabelDom(e,t,i){let s=document.createElement("div");return s.className="dlp dlp-text dlp-label",s.insertAdjacentHTML("afterbegin",`${e.val}`),s.setAttribute("data-id",e.key.toString()),s.setAttribute("data-k",t.toString()),s.setAttribute("data-stack",i.toString()),s.setAttribute("drag-zone","true"),s.addEventListener("click",this.select.bind(this,s,i)),s.addEventListener("contextmenu",(t=>{t.preventDefault(),t.target instanceof HTMLElement&&t.target.click();let a=[];this.OPTIONS.detail&&a.push({title:"详情",func:()=>{this.nodeDetail(s,e)}}),this.OPTIONS.insert&&a.push({title:"新增",func:()=>{this.nodeInsert(s,e,i)}}),this.OPTIONS.update&&a.push({title:"修改",func:()=>{this.nodeUpdate(s,e)}}),this.OPTIONS.delete&&a.push({title:"删除",func:()=>{this.nodeDelete(s,e,i)}}),this.OPTIONS.root&&a.push({title:_component.node,func:()=>{let e=parseInt(s.getAttribute("data-stack")),t=parseInt(s.getAttribute("data-k")),i=this.dimensional_data[e][t];this.dialog(`${i.val} 迁移到根节点`,90);let a=document.createElement("div");a.className="dlp dlp-text dlp-label",a.insertAdjacentHTML("afterbegin",`${i.val}${_component.check_circle}`),this.PLANE_BODY.insertAdjacentHTML("afterbegin",`
${_component.node}
`),this.PLANE_BODY.insertAdjacentHTML("beforeend",'
');let n=this;a.addEventListener("click",(()=>{if(0===i.stack)return n.PLANE_DOM.remove();n.submit_block||(n.submit_block=!0,a.querySelector(".right").innerHTML=_component.sub_loading,_component.request({url:this.URL,method:"GET",data:{event:"root",node_key:i.key,node_val:i.val},callback:function(e){if(n.submit_block=!1,0!==(e=JSON.parse(e)).code)return _component.alert(e.message,3,null,n.DOM);n.nodeRootExec(s,i),n.PLANE_DOM.remove()},error_callback:function(){n.submit_block=!1}}))})),this.PLANE_BODY.append(a)}}),_component.contextmenu(t,a)})),this.OPTIONS.movable&&s.insertAdjacentHTML("beforeend",`${_component.move}`),s}select(e,t){let i=parseInt(e.getAttribute("data-k")),s=this.dimensional_data[t][i],a=this.STACKS[t].childNodes,n=s.parentNodes[s.parentNodes.length-1];if(this.dimensional_data[t].forEach(((e,t)=>{let i=a[t];-1!==e.parentNodes.indexOf(n)?i.classList.remove("dlp-label-silence"):i.classList.add("dlp-label-silence"),this.expand(e,a[t],!1)})),this.expand(s,e,!0),e.classList.remove("dlp-label-silence"),this.selectToChildren(t+1,s.nodes),Array.isArray(s.parentNodes)&&s.parentNodes.length>0){let e=s.parentNodes.slice(0);this.selectToParent(e)}}selectToParent(e){let t=e.length-1,i=e.pop(),s=e[t-1],a=this.STACKS[t].childNodes,n=null;this.dimensional_data[t].forEach(((e,l)=>{let d=a[l],r=e.parentNodes;r.length>0&&r[t-1]!==s||0===r.length&&parseInt(d.getAttribute("data-id"))!==i?(d.classList.add("dlp-label-silence"),this.expand(e,d,!1)):(d.classList.remove("dlp-label-silence"),parseInt(d.getAttribute("data-id"))===i?(null===n&&(n=l),this.expand(e,d,!0)):this.expand(e,d,!1))})),null!==n&&this.STACKS[t].scrollTo(0,27*n),e.length>0&&this.selectToParent(e)}selectToChildren(e,t){if(e>this.dimensional_data.length-1)return;let i=this.STACKS[e].childNodes,s=[],a=null;this.dimensional_data[e].forEach(((n,l)=>{let d=i[l];if(null!==t)if(-1!==t.indexOf(parseInt(d.getAttribute("data-id")))){d.classList.remove("dlp-label-silence");let t=this.dimensional_data[e][l].nodes;Array.isArray(t)&&t.forEach((e=>{-1===s.indexOf(t)&&s.push(e)})),null===a&&(a=l),this.expand(n,d,!0)}else d.classList.add("dlp-label-silence"),this.expand(n,d,!1);else d.classList.add("dlp-label-silence")})),null!==a&&this.STACKS[e].scrollTo(0,27*a),this.selectToChildren(e+1,s)}expand(e,t,i=!0){if(e.expand===i)return;e.expand=i;let s=t.querySelector("i.left");s instanceof HTMLElement&&(s.innerHTML=i?_component.caret_right_circle:_component.caret_right)}panel(e){this.DOM.childNodes[0].insertAdjacentHTML("beforeend",'
');let t=this.DOM.childNodes[0].lastChild,i=t.querySelector(".plane-header");this.PLANE_DOM=t;let s=document.createElement("div");s.className="header-content",s.insertAdjacentHTML("afterbegin",_component.node+` ${e}`),i.append(s);let a=document.createElement("i");a.insertAdjacentHTML("afterbegin",_component.close),a.addEventListener("click",(()=>{t.remove()}),!1),i.append(a),this.PLANE_BODY=t.querySelector(".plane-body"),_component.loading(this.PLANE_BODY)}panelContent(e,t,i,s,a){_component.loading(this.PLANE_BODY,!0);let n=document.createRange().createContextualFragment(e);this.PLANE_BODY.appendChild(n);let l=document.createElement("div");if(l.insertAdjacentHTML("afterbegin",_component.check),l.addEventListener("click",this.submitEvent.bind(this,l,t,i,s,a)),l.className="dlp-submit-btn",!(this.PLANE_DOM instanceof HTMLElement))return;let d=this.PLANE_DOM.querySelector(".plane-header"),r=d.querySelector("i");d.insertBefore(l,r)}submitEvent(e,t,i,s,a){if(this.submit_block)return;this.submit_block=!0,e.innerHTML=_component.sub_loading;let n=this.DOM.getElementsByTagName("form")[0],l=new FormData(n);l.set("key",t.key),l.set("val",t.val),l.set("_method",s);let d=this;_component.request({url:i,method:"POST",data:l,callback:function(t){if(d.submit_block=!1,e.innerHTML=_component.check,0!==t.code)return _component.alert(t.message,3,null,d.DOM);a(t)},error_callback:function(){d.submit_block=!1}})}nodeDetail(e,t){this.panel(`${t.val} 详情`);let i=this;_component.request({url:this.URL+"/"+t.key,method:"GET",data:{},callback:function(e){_component.loading(i.PLANE_BODY,!0);let t=document.createRange().createContextualFragment(e);i.PLANE_BODY.appendChild(t)}})}nodeInsert(e,t,i){this.panel(`${t.val} 新增`);let s=this,a=parseInt(i)+1;_component.request({url:this.URL+"/create",method:"GET",data:{id:t.key},callback:function(i){s.panelContent(i,t,s.URL,"POST",(i=>{if(0!==i.code)return _component.alert(i.message,3,null,s.DOM);if(void 0===i.data.key)return _component.alert("返回数据结构缺少key",3,null,s.DOM);if(void 0===i.data.val)return _component.alert("返回数据结构缺少val",3,null,s.DOM);let n=parseInt(i.data.key),l=i.data.val,d=t.parentNodes.slice(0);if(d.push(t.key),Array.isArray(s.dimensional_data[a]))if(Array.isArray(t.nodes)&&0!==t.nodes.length){let e=t.nodes[t.nodes.length-1],i=s.STACKS[a].childNodes,r=0;for(let t in s.dimensional_data[a])if(s.dimensional_data[a].hasOwnProperty(t)&&(t=parseInt(t),r=t+1,s.dimensional_data[a][t].key===e)){s.dimensional_data[a].splice(r,0,{expand:!1,key:n,val:l,nodes:null,parentNodes:d});let e=i[t];e.parentNode.insertBefore(s.insertLabelDom(s.dimensional_data[a][r],r,a),e.nextSibling);break}s.dimensional_data[a].forEach(((e,t)=>{t>r&&i[t].setAttribute("data-k",t)})),s.STACKS[a].scrollTo(0,27*r)}else{let t=s.dimensional_data[a].push({expand:!1,key:n,val:l,nodes:null,parentNodes:d})-1;s.STACKS[a].append(s.insertLabelDom(s.dimensional_data[a][t],t,a)),e.insertAdjacentHTML("afterbegin",`${_component.caret_right_circle}`),s.STACKS[a].scrollTo(0,27*t)}else{s.dimensional_data[a]=[{expand:!1,key:n,val:l,nodes:null,parentNodes:d}];let t=document.createElement("div");t.className="dot-cascade-stack dlp-scroll",t.append(s.insertLabelDom(s.dimensional_data[a][0],0,a)),s.CONTENT_DOM.append(t),e.insertAdjacentHTML("afterbegin",`${_component.caret_right_circle}`)}Array.isArray(t.nodes)||(t.nodes=[]),t.nodes.push(n),s.PLANE_DOM.remove()}))}})}nodeUpdate(e,t){this.panel(`${t.val} 修改`);let i=this;_component.request({url:this.URL+"/"+t.key+"/edit",method:"GET",data:{val:t.val},callback:function(s){i.panelContent(s,t,i.URL+"/"+t.key,"PUT",(s=>{if(0!==s.code)return _component.alert(s.message,3,null,i.DOM);if(void 0===s.data.val)return _component.alert("返回数据结构缺少val",3,null,i.DOM);let a=s.data.val;t.val=a,e.querySelector("span").textContent=a,i.PLANE_DOM.remove()}))}})}dialog(e,t=50){let i=`
`;this.DOM.childNodes[0].insertAdjacentHTML("beforeend",i);let s=this.DOM.childNodes[0].lastChild,a=s.querySelector(".plane-header"),n=document.createElement("div");n.className="header-content",n.insertAdjacentHTML("afterbegin",_component.node+`${e}`),a.append(n);let l=document.createElement("i");l.insertAdjacentHTML("afterbegin",_component.close),l.addEventListener("click",(()=>{s.remove()}),!1),a.append(l),this.PLANE_DOM=s,this.PLANE_BODY=s.querySelector(".plane-body")}nodeDelete(e,t,i){let s=this,a=`${t.val} 删除`;this.dialog(a);let n=document.createElement("div");n.className="dlp dlp-text dlp-label",n.addEventListener("click",(()=>{s.submit_block||(s.submit_block=!0,n.querySelector(".right").innerHTML=_component.sub_loading,_component.request({url:this.URL+"/"+t.key,method:"DELETE",data:{},callback:function(e){if(s.submit_block=!1,0!==e.code)return _component.alert(e.message,3,null,s.DOM);s.nodeDeleteExec(t,i),s.PLANE_DOM.remove()},function(){s.submit_block=!1}}))})),n.insertAdjacentHTML("afterbegin",`${t.val}${_component.trash}`),this.PLANE_BODY.append(n)}nodeDeleteExec(e,t){let i,s=e.parentNodes.length-1;if(s>=0){let t=e.parentNodes.pop();for(let i in this.dimensional_data[s]){if(!this.dimensional_data[s].hasOwnProperty(i))continue;i=parseInt(i);let a=this.dimensional_data[s][i];if(a.key===t&&(a.nodes.forEach(((t,i)=>{t===e.key&&a.nodes.splice(i,1)})),0===a.nodes.length)){let e=this.STACKS[s].childNodes[i].querySelector("i.left");e&&e.remove()}}}for(let i=t+1;i0?(this.STACKS[t].remove(),this.dimensional_data.splice(t,1)):this.dimensional_data=[[]])}search(e){if(Array.isArray(this.search_result)&&this.search_result.length>0&&this.lastPickRemove(),this.search_result=[],this.search_result_panel instanceof HTMLElement&&this.search_result_panel.remove(),""===e.value)return;if(this.dimensional_data.forEach(((t,i)=>{t.forEach(((t,s)=>{-1===t.val.indexOf(e.value)&&-1===e.value.indexOf(t.val)||this.search_result.push({stack:i,index:s})}))})),0===this.search_result.length)return;let t=document.createElement("div");t.className="dot-search-result-panel";let i=document.createElement("span");i.className="dlp-btn",i.textContent="◀",i.addEventListener("click",this.searchPick.bind(this,!1));let s=document.createElement("span");s.className="dlp-btn",s.textContent="▶",s.addEventListener("click",this.searchPick.bind(this,!0));let a=document.createElement("span");a.className="search-result-number dlp-text",a.textContent="1",this.SEARCH_PICK=a,this.search_result_pick=1,t.append(i),t.append(a),t.insertAdjacentHTML("beforeend",` / ${this.search_result.length.toString()}`),t.append(s),this.search_result_panel=t,this.SEARCH_BOX.append(t),this.pickUp()}searchPick(e=!0){this.lastPickRemove(),e?(this.search_result_pick++,this.search_result_pick>this.search_result.length&&(this.search_result_pick=1)):(this.search_result_pick--,this.search_result_pick<1&&(this.search_result_pick=this.search_result.length)),this.SEARCH_PICK.textContent=this.search_result_pick.toString(),this.pickUp()}lastPickRemove(){let e=this.search_result[this.search_result_pick-1];this.STACKS[e.stack].childNodes[e.index].classList.remove("dlp-label-active")}pickUp(){let e=this.search_result[this.search_result_pick-1],t=this.STACKS[e.stack].childNodes[e.index];t instanceof HTMLElement&&(t.classList.add("dlp-label-active"),this.STACKS[e.stack].scrollTo(0,27*e.index),t.click())}nodeMigrate(e){let t=e.parentNode,i=this,s=null;function a(e){e.preventDefault();let a=e.target;for(;null!==a&&a!==t&&(a instanceof HTMLElement||"svg"===a.tagName)&&"true"!==a.getAttribute("drag-area")&&"BODY"!==a.tagName;){if("true"===a.getAttribute("drag-zone")){if("dragover"===e.type)if(s=a,s.classList.contains("dlp-label-silence")&&s.click(),i.OPTIONS.exchange)s.style.setProperty("background","#bb8f2c");else{let e=parseInt(s.getAttribute("data-stack")),a=parseInt(s.getAttribute("data-k")),n=i.dimensional_data[e][a].parentNodes;Array.isArray(n)&&-1===n.indexOf(parseInt(t.getAttribute("data-id")))&&s.style.setProperty("background","#bb8f2c")}else"dragleave"===e.type&&s instanceof HTMLElement&&(s.style.removeProperty("background"),s=null);break}a=a.parentNode}}function n(){t.removeAttribute("draggable"),t.style.removeProperty("border"),t.removeEventListener("dragend",n),document.removeEventListener("dragover",a),document.removeEventListener("dragleave",a),s instanceof HTMLElement&&i.nodeMigrateConfirm(t,s)}e.addEventListener("mousedown",(()=>{t.click(),t.setAttribute("draggable","true"),t.style.setProperty("border","1px dashed #3c2d2d"),document.addEventListener("dragover",a),document.addEventListener("dragleave",a),t.addEventListener("dragend",n)})),e.addEventListener("mouseup",(()=>{e.parentNode.style.removeProperty("border"),document.removeEventListener("dragover",a),document.removeEventListener("dragleave",a),t.removeEventListener("dragend",n),s instanceof HTMLElement&&(s.style.removeProperty("background"),s=null)}))}nodeMigrateConfirm(e,t){let i,s=parseInt(t.getAttribute("data-stack")),a=parseInt(t.getAttribute("data-k")),n=this.dimensional_data[s][a];s=parseInt(e.getAttribute("data-stack")),a=parseInt(e.getAttribute("data-k"));let l=this.dimensional_data[s][a],d="迁移";if(-1!==n.parentNodes.indexOf(l.key)?(i="exchange",d="迁移.交换"):i="migrate",!this.OPTIONS.exchange&&"exchange"===i)return;t.style.removeProperty("background"),this.dialog(`${l.val} ${d}`,90);let r=document.createElement("div"),o=this;r.className="dlp dlp-text dlp-label",r.insertAdjacentHTML("afterbegin",`${l.val}${_component.check_circle}`),this.PLANE_BODY.insertAdjacentHTML("afterbegin",`
${n.val}
`),"exchange"===i?this.PLANE_BODY.insertAdjacentHTML("beforeend",'
'):this.PLANE_BODY.insertAdjacentHTML("beforeend",'
'),r.addEventListener("click",(()=>{o.submit_block||(o.submit_block=!0,r.querySelector(".right").innerHTML=_component.sub_loading,_component.request({url:this.URL,method:"GET",data:{event:i,node_key:l.key,node_val:l.val,aim_node_key:n.key,aim_node_val:n.val},callback:function(s){if(o.submit_block=!1,0!==(s=JSON.parse(s)).code)return _component.alert(s.message,3,null,o.DOM);"exchange"===i&&o.nodeExchangeExec(e,l,t,n),"migrate"===i&&o.nodeMigrateExec(e,l,t,n),o.PLANE_DOM.remove()},error_callback:function(){o.submit_block=!1}}))})),this.PLANE_BODY.append(r)}nodeRootExec(e,t){let i=t.parentNodes.slice().pop(),s=t.stack-1;t.parentNodes=[];let a=0-t.stack,n=parseInt(e.getAttribute("data-k"));this.dimensional_data[t.stack].splice(n,1),this.dimensional_data[0].push(t),null!==t.nodes&&this.resetChildrenDimensional(t,t.stack+1,a),t.stack=0,this.dimensional_data=this.dimensional_data.filter((e=>e.length>0)),this.CONTENT_DOM.innerHTML="";for(let e in this.dimensional_data){if(!this.dimensional_data.hasOwnProperty(e))continue;e=parseInt(e);let a=this.dimensional_data[e],n=document.createElement("div");n.className="dot-cascade-stack dlp-scroll",a.forEach(((a,l)=>{parseInt(e)===s&&a.key===i&&a.nodes.splice(a.nodes.indexOf(t.key),1),Array.isArray(a.nodes)&&0!==a.nodes.length?a.expand=!1:a.nodes=null;let d=this.insertLabelDom(a,l,e);null!==a.nodes&&d.insertAdjacentHTML("afterbegin",`${_component.caret_right}`),n.append(d)})),this.CONTENT_DOM.append(n)}this.STACKS=this.CONTENT_DOM.childNodes;for(let e of this.DOM.querySelectorAll("i.right"))this.nodeMigrate(e)}nodeMigrateExec(e,t,i,s){let a,n=t.parentNodes.slice().pop(),l=t.stack-1,d=s.parentNodes.slice(0);d.push(s.key),t.parentNodes=d,null!==s.nodes&&(a=s.nodes.slice(0).pop());let r=s.stack+1,o=r-t.stack,c=parseInt(e.getAttribute("data-k"));if(this.dimensional_data[t.stack].splice(c,1),Array.isArray(this.dimensional_data[r])||(this.dimensional_data[r]=[]),a){let e=0;for(let t in this.dimensional_data[s.stack+1])if(this.dimensional_data[s.stack+1].hasOwnProperty(t)&&this.dimensional_data[s.stack+1][t].key===a){e=t;break}e++,this.dimensional_data[s.stack+1].splice(e,0,t)}else this.dimensional_data[r].push(t);this.resetChildrenDimensional(t,t.stack+1,o),this.dimensional_data=this.dimensional_data.filter((e=>e.length>0)),t.stack=r,Array.isArray(s.nodes)||(s.nodes=[]),s.nodes.push(t.key),this.CONTENT_DOM.innerHTML="";for(let e in this.dimensional_data){if(!this.dimensional_data.hasOwnProperty(e))continue;e=parseInt(e);let i=this.dimensional_data[e],s=document.createElement("div");s.className="dot-cascade-stack dlp-scroll",i.forEach(((i,a)=>{parseInt(e)===l&&i.key===n&&i.nodes.splice(i.nodes.indexOf(t.key),1),Array.isArray(i.nodes)&&0!==i.nodes.length?i.expand=!1:i.nodes=null;let d=this.insertLabelDom(i,a,e);null!==i.nodes&&d.insertAdjacentHTML("afterbegin",`${_component.caret_right}`),s.append(d)})),this.CONTENT_DOM.append(s)}this.STACKS=this.CONTENT_DOM.childNodes;for(let e of this.DOM.querySelectorAll("i.right"))this.nodeMigrate(e)}nodeExchangeExec(e,t,i,s){let a=t.key,n=t.val;t.key=s.key,t.val=s.val;let l=t.nodes.indexOf(s.key);-1!==l&&t.nodes.splice(l,1,a);let d=t.parentNodes.slice(0).pop();if(void 0!==d)for(let e in this.dimensional_data[t.stack-1]){if(!this.dimensional_data[t.stack-1].hasOwnProperty(e))continue;let i=this.dimensional_data[t.stack-1][e];if(i.key===d){i.nodes.splice(i.nodes.indexOf(a),1,s.key);break}}s.key=a,s.val=n;let r=s.parentNodes.slice(0).pop();for(let e in this.dimensional_data[s.stack-1]){if(!this.dimensional_data[s.stack-1].hasOwnProperty(e))continue;let i=this.dimensional_data[s.stack-1][e];if(i.key===r){i.nodes.splice(i.nodes.indexOf(t.key),1,s.key);break}}this.resetChildrenParent(t),e.querySelector("span").textContent=t.val,e.setAttribute("data-id",t.key),i.querySelector("span").textContent=s.val,i.setAttribute("data-id",s.key)}resetChildrenParent(e){let t=e.stack,i=e.nodes,s=e.parentNodes.slice(0);s.push(e.key),t++,this.dimensional_data[t].forEach((e=>{-1!==i.indexOf(e.key)&&(e.parentNodes=s,Array.isArray(e.nodes)&&e.nodes.length>0&&this.resetChildrenParent(e))}))}resetChildrenDimensional(e,t,i){let s=e.nodes,a=e.parentNodes.slice(0);if(a.push(e.key),!Array.isArray(this.dimensional_data[t]))return;let n=[];this.dimensional_data[t].forEach(((e,l)=>{Array.isArray(s)&&-1!==s.indexOf(e.key)&&(n.push(l),e.parentNodes=a,e.stack=t+i,Array.isArray(this.dimensional_data[e.stack])||(this.dimensional_data[e.stack]=[]),this.dimensional_data[e.stack].push(e),this.resetChildrenDimensional(e,t+1,i))})),n.reverse(),n.forEach((e=>{this.dimensional_data[t].splice(e,1)}))}}; \ No newline at end of file +window._component={trash:'\n \n \n',move:'\n \n',write:'\n \n \n',close:'',check:'\n \n',check_circle:'\n \n \n',caret_right:'\n \n',caret_right_circle:'\n \n',sub_loading:'\n \n \n \n ',node:'\n \n',request:function(e){e=Object.assign({url:"",method:"GET",header:{},data:{},callback:null,error_callback:null,timeout:3e4},e);let t=new XMLHttpRequest;"GET"===e.method&&(e.url=_component.parseParams(e.url,e.data)),t.open(e.method,e.url,!0),t.timeout=e.timeout;let i="";if(document.querySelector('meta[name="csrf-token"]')&&(i=document.querySelector('meta[name="csrf-token"]').getAttribute("content")),t.setRequestHeader("X-CSRF-TOKEN",i),e.header)for(let i in e.header)e.header.hasOwnProperty(i)&&t.setRequestHeader(i,e.header[i]);"GET"===e.method?(t.setRequestHeader("Content-type","application/text;charset=UTF-8"),t.responseType="text",t.send(null)):(e.data instanceof FormData?t.setRequestHeader("X-Requested-With","XMLHttpRequest"):(t.setRequestHeader("Content-Type","application/json;charset=UTF-8"),e.data=JSON.stringify(e.data)),t.responseType="json",t.send(e.data)),t.onload=function(){this.status>=200&&this.status<300||"function"==typeof e.error_callback&&e.error_callback()},t.onreadystatechange=function(){if(t.readyState===t.DONE&&200===t.status){let i=t.response;"function"==typeof e.callback&&e.callback(i)}},t.onerror=function(t){console.error(t),"function"==typeof e.error_callback&&e.error_callback(t)}},parseParams(e,t){let i=[];return 0===Object.keys(t).length||(Object.keys(t).forEach((e=>t[e]&&i.push(`${e}=${t[e]}`))),-1===e.search(/\?/)?e+=`?${i.join("&")}`:e+=`&${i.join("&")}`),e},loading:function(e,t=!1){t?e.innerHTML="":e.insertAdjacentHTML("afterbegin",'
\n
\n
\n
\n
\n
\n
\n
')},_alert_documents:[],alert:function(e,t=1,i=null,s=null){let a,n,l=document.createElement("div");l.insertAdjacentHTML("afterbegin",`${e}`),l.className="dlp-alert",this._alert_documents.forEach((e=>{e.style.top=parseInt(e.style.top)-60+"px"})),this._alert_documents.push(l),s?s.append(l):document.getElementsByTagName("BODY")[0].appendChild(l),s?(a=(s.offsetWidth-320)/2,n=s.offsetHeight/2-15,l.style.position="absolute"):(a=(window.innerWidth-320)/2,n=window.innerHeight/2-15,l.style.position="fixed"),l.style.top=n+"px",l.style.left=a+"px",setTimeout((()=>{let e=this._alert_documents.shift();e.parentNode.removeChild(e),"function"==typeof i&&i()}),1e3*t)},contextmenu:function(e,t,i={}){i=Object.assign({W:"70px"},i);let s=document.createElement("ul");s.className="dlp dlp-contextmenu",t.forEach((e=>{let t=document.createElement("li");t.className="dlp dlp-text",t.insertAdjacentHTML("afterbegin",e.title),t.style.width=i.W,"function"==typeof e.func&&(t.addEventListener("click",(()=>{s.remove(),setTimeout((()=>{e.func()}),100)})),s.append(t))})),s.style.top=e.pageY-3+"px",s.style.left=e.pageX-3+"px",s.addEventListener("contextmenu",(e=>{e.preventDefault()})),s.addEventListener("mouseleave",(()=>{s.remove()})),document.getElementsByTagName("BODY")[0].appendChild(s)},dimensional(e,t,i=0,s=[]){if(Array.isArray(t)){for(let a in t){if(!t.hasOwnProperty(a))continue;let n=s.slice(0);n.push(t[a].key),_component.dimensional(e,t[a],i,n)}return}let a=s.slice(0);a.pop(),t.parentNodes=a,Array.isArray(e[i])?e[i].push(t):e[i]=[t],t.hasOwnProperty("nodes")&&Array.isArray(t.nodes)&&0!==t.nodes.length&&(i++,_component.dimensional(e,t.nodes,i,s))}},window.ComponentDot=class{MODE={insert:"insert",delete:"delete"};constructor(e,t,i,s=0,a={}){if(!Array.isArray(i))return void console.error("Dot param selected must be array!");if(Array.isArray(t)||"object"!=typeof t)return void console.error("Dot param select must be object such as {key:val,key2:val2,...} !");this.select=t,this.name=e,this.limit=s,this.DOM=document.getElementById(e),this.DOM.addEventListener("contextmenu",(e=>{e.preventDefault()})),this.menu=Object.assign({mode:!1,placeholder:"未选择",height:"150px"},a),i=i.filter((e=>void 0!==t[e])),this.selected_data=i,this.select_data=[],this.insert_data=[],this.delete_data=[],setTimeout((()=>{let e=[];this.CONTENT_DOM.childNodes.forEach((t=>{let s=parseInt(t.getAttribute("data-id"));-1!==i.indexOf(s)&&e.push(t)})),e.forEach((e=>e.click())),!0===this.menu.mode&&(this.DOM.querySelector(".menu-list").style.display="none")})),!1===this.menu.mode?this.make(i,t):(this.menu_placeholder=this.menu.placeholder,this.menuMake(i,t));let n=this.DOM.querySelector(".dot-search");n.addEventListener("input",(()=>{setTimeout((()=>{this.search(n,this.menu.mode)}),500)}))}make(e,t){let i="";for(let e in t)t.hasOwnProperty(e)&&(i+=`
${t[e]}
`);let s=`
${i}
\n`;this.DOM.insertAdjacentHTML("afterbegin",s),this.SELECTED_DOM=document.querySelector(`#${this.name} .dot-selected`),this.CONTENT_DOM=document.querySelector(`#${this.name} .dot-select`),this.selectInputDOM=document.querySelector(`input[name='${this.name}[select]']`),this.insertInputDOM=document.querySelector(`input[name='${this.name}[insert]']`),this.deleteInputDOM=document.querySelector(`input[name='${this.name}[delete]']`);for(let e of this.CONTENT_DOM.getElementsByClassName("dlp-label"))e.addEventListener("click",this.tagSelect.bind(this,e),!1)}menuMake(e,t){let i=document.createElement("div");i.className="dlp-dot-menu";let s=document.createElement("div");s.className="dlp-input dlp-dot-menu-select",s.insertAdjacentHTML("afterbegin",`
${this.menu_placeholder}
`);let a=document.createElement("div");a.className="menu-list";let n=document.createElement("div");n.className="search-box";let l=document.createElement("input");l.className="dlp dlp-input dot-search",l.setAttribute("placeholder","搜索");let d=document.createElement("div");d.className="list dlp-scroll",d.style.maxHeight=this.menu.height;let r=_component.check;r=r.replace('width="16" height="16"','width="12" height="12"'),this.id_line_hash=[];let o=0;for(let e in t){if(!t.hasOwnProperty(e))continue;this.id_line_hash[e]=o,o++;let i=document.createElement("div");i.className="option",i.setAttribute("data-id",e),i.insertAdjacentHTML("afterbegin",`
${t[e]}
`),i.addEventListener("click",(()=>{if(e=parseInt(e),-1!==this.select_data.indexOf(e))return this.tagCal(e,this.MODE.delete),i.classList.remove("option-active"),i.lastChild instanceof HTMLElement&&(i.lastChild.innerHTML=""),this.menuSelect(t),void(0===this.select_data.length&&(this.SELECTED_DOM.textContent=this.menu_placeholder));this.limit>0&&this.select_data.length>=this.limit&&d.childNodes[this.id_line_hash[this.select_data[0].toString()]].click(),i.classList.add("option-active"),this.tagCal(e,this.MODE.insert),i.lastChild instanceof HTMLElement&&i.lastChild.insertAdjacentHTML("afterbegin",r),this.menuSelect(t)}),!1),d.append(i)}i.append(s),n.append(l),a.append(n),a.append(d),i.append(a),i.addEventListener("click",(()=>{a.style.display="flex"})),i.addEventListener("mouseleave",(()=>{a.style.display="none",this.DOM.querySelector(".dot-search").value="";for(let e of this.CONTENT_DOM.childNodes)e.style.display="flex"})),this.DOM.append(i),this.DOM.insertAdjacentHTML("beforeend",``),this.SELECTED_DOM=document.querySelector(`#${this.name} .dlp-dot-menu-select`).firstElementChild,this.CONTENT_DOM=document.querySelector(`#${this.name} .list`),this.selectInputDOM=document.querySelector(`input[name='${this.name}[select]']`),this.insertInputDOM=document.querySelector(`input[name='${this.name}[insert]']`),this.deleteInputDOM=document.querySelector(`input[name='${this.name}[delete]']`)}menuSelect(e){if(1===this.limit)return void(this.SELECTED_DOM.innerHTML=`

${e[this.select_data[0]]}

`);let t="";for(let i of this.select_data)t+=`${e[i]}`;this.SELECTED_DOM.innerHTML=t}tagSelect(e){this.limit>0&&this.select_data.length>=this.limit&&this.SELECTED_DOM.firstChild instanceof HTMLElement&&this.SELECTED_DOM.firstChild.click();let t=e.cloneNode(!0);t.addEventListener("click",this.tagCancel.bind(this,t),!1),this.SELECTED_DOM.appendChild(t),e.remove(),this.tagCal(parseInt(e.getAttribute("data-id")),this.MODE.insert),this.SELECTED_DOM.scrollTop=this.SELECTED_DOM.scrollHeight}tagCancel(e){let t=e.cloneNode(!0);t.addEventListener("click",this.tagSelect.bind(this,t),!1),this.CONTENT_DOM.appendChild(t),e.remove(),this.tagCal(parseInt(e.getAttribute("data-id")),this.MODE.delete)}tagCal(e,t){let i=this.select_data.indexOf(e);t===this.MODE.insert?(-1===i&&(this.select_data.push(e),this.selectInputDOM.value=JSON.stringify(this.select_data)),-1===this.selected_data.indexOf(e)&&-1===this.insert_data.indexOf(e)&&(this.insert_data.push(e),this.insertInputDOM.value=JSON.stringify(this.insert_data)),i=this.delete_data.indexOf(e),-1!==i&&(this.delete_data.splice(i,1),this.deleteInputDOM.value=JSON.stringify(this.delete_data))):(-1!==i&&(this.select_data.splice(i,1),this.selectInputDOM.value=JSON.stringify(this.select_data)),-1!==this.selected_data.indexOf(e)&&-1===this.delete_data.indexOf(e)&&(this.delete_data.push(e),this.deleteInputDOM.value=JSON.stringify(this.delete_data)),i=this.insert_data.indexOf(e),-1!==i&&(this.insert_data.splice(i,1),this.insertInputDOM.value=JSON.stringify(this.insert_data)))}search(e,t){if(t){if(""===e.value){for(let e of this.CONTENT_DOM.childNodes)e.style.display="flex";return}for(let t in this.select){if(!this.select.hasOwnProperty(t))continue;let i=this.select[t],s=this.id_line_hash[t];-1!==i.indexOf(e.value)||-1!==e.value.indexOf(i)?this.CONTENT_DOM.childNodes[s].style.display="flex":this.CONTENT_DOM.childNodes[s].style.display="none"}return}if(""===e.value){if(this.SELECT_COVER_DOM instanceof HTMLElement){let e=[];this.SELECT_COVER_DOM.childNodes.forEach((t=>{e.push(t)})),this.CONTENT_DOM.append(...e),this.SELECT_COVER_DOM.remove(),this.SELECT_COVER_DOM=null}return}if(this.SELECT_COVER_DOM instanceof HTMLElement){let e=[];this.SELECT_COVER_DOM.childNodes.forEach((t=>{e.push(t)})),this.CONTENT_DOM.append(...e)}else this.SELECT_COVER_DOM=document.createElement("div"),this.SELECT_COVER_DOM.className="dot-select dlp-scroll dot-select-cover",this.CONTENT_DOM.parentNode.appendChild(this.SELECT_COVER_DOM);let i=[];for(let t of this.CONTENT_DOM.childNodes)-1!==t.className.indexOf("dlp-label")&&(-1===t.innerText.indexOf(e.value)&&-1===e.value.indexOf(t.innerText)||i.push(t));this.SELECT_COVER_DOM.append(...i)}},window.ComponentCascadeDot=class{MODE={insert:"insert",delete:"delete"};constructor(e,t,i,s=0){if(!Array.isArray(i)||!Array.isArray(t))return void console.error("CascadeDot param selected and select must be array!");i=i.filter((e=>void 0!==t[e])),this.name=e,this.limit=s,this.DOM=document.getElementById(e),this.selected_data=i,this.select_data=[],this.insert_data=[],this.delete_data=[],this.make().makeSelect(t),setTimeout((()=>{this.selected_label_dom.forEach((e=>{e.click()}))})),this.selectInputDOM.value=JSON.stringify(this.select_data);let a=document.querySelector(`#${this.name} .dot-search`);a.addEventListener("input",(()=>{setTimeout((()=>{this.search(a)}),500)}))}make(){let e=`
\n`;return this.DOM.insertAdjacentHTML("afterbegin",e),this.DOM.addEventListener("contextmenu",(e=>{e.preventDefault()})),this.SELECTED_DOM=document.querySelector(`#${this.name} .dot-selected`),this.CONTENT_DOM=document.querySelector(`#${this.name} .dot-select`),this.selectInputDOM=document.querySelector(`input[name='${this.name}[select]']`),this.insertInputDOM=document.querySelector(`input[name='${this.name}[insert]']`),this.deleteInputDOM=document.querySelector(`input[name='${this.name}[delete]']`),this}makeSelect(e){this.dimensional_data=[],this.selected_label_dom=[],_component.dimensional(this.dimensional_data,e);let t=this;for(let e in this.dimensional_data){if(!this.dimensional_data.hasOwnProperty(e))continue;e=parseInt(e);let i=this.dimensional_data[e],s=document.createElement("div");s.className="dot-cascade-stack dlp-scroll",i.forEach(((i,a)=>{Array.isArray(i.nodes)&&0!==i.nodes.length?i.nodes=i.nodes.map((e=>e.key)):(i.nodes=null,i.checked=!1);let n=document.createElement("div");n.className="dlp dlp-text dlp-label",n.insertAdjacentHTML("afterbegin",`${i.val}`),n.setAttribute("data-id",i.key),n.setAttribute("data-k",a),n.addEventListener("click",this.select.bind(this,n,e)),null!==i.nodes?(n.querySelector("i.left").insertAdjacentHTML("afterbegin",`${_component.caret_right}`),n.addEventListener("contextmenu",(i=>{i.target instanceof HTMLElement&&i.target.click(),i.preventDefault();let s=parseInt(n.getAttribute("data-k"));_component.contextmenu(i,[{title:"全选",func:()=>{t.checkAll(e+1,this.dimensional_data[e][s].nodes,!0),i.target instanceof HTMLElement&&i.target.click()}},{title:"取消",func:()=>{t.checkAll(e+1,this.dimensional_data[e][s].nodes,!1)}}])}))):n.addEventListener("contextmenu",(e=>{e.preventDefault()})),s.append(n);let l=this.selected_data.indexOf(parseInt(i.key));!1===i.checked||-1===l?-1!==l&&this.selected_label_dom.push(n):this.selected_data.splice(l,1)})),this.CONTENT_DOM.append(s)}return this.STACKS=this.CONTENT_DOM.childNodes,this}select(e,t){let i=parseInt(e.getAttribute("data-id")),s=parseInt(e.getAttribute("data-k")),a=this.dimensional_data[t][s],n=this.STACKS[t].childNodes,l=a.parentNodes[a.parentNodes.length-1];if(!0===a.checked){a.checked=!1,this.tagCal(i,this.MODE.delete),null===a.nodes&&(e.querySelector("i.right").innerHTML="");for(let e of this.SELECTED_DOM.childNodes)if(parseInt(e.getAttribute("data-id"))===i){e.remove();break}}else this.dimensional_data[t].forEach(((e,t)=>{-1!==e.parentNodes.indexOf(l)?n[t].classList.remove("dlp-label-silence"):n[t].classList.add("dlp-label-silence")})),!1===a.checked?(this.limit>0&&this.select_data.length>=this.limit&&this.SELECTED_DOM.firstChild instanceof HTMLElement&&this.SELECTED_DOM.firstChild.click(),a.checked=!0,this.tagCal(i,this.MODE.insert),e.classList.remove("dlp-label-silence"),e.querySelector("i.right").insertAdjacentHTML("afterbegin",_component.check),this.selectToChildren(t+1,a.nodes),this.selectToSelected(e,t),this.SELECTED_DOM.scrollTop=this.SELECTED_DOM.scrollHeight):(e.classList.remove("dlp-label-silence"),this.selectToChildren(t+1,a.nodes));if(Array.isArray(a.parentNodes)&&a.parentNodes.length>0){let e=a.parentNodes.slice(0);this.selectToParent(e,a.checked)}}selectToSelected(e,t){let i=document.createElement("div");i.className="dlp dlp-text dlp-label",i.setAttribute("data-id",e.getAttribute("data-id")),i.setAttribute("stack",t),i.insertAdjacentHTML("afterbegin",`${e.querySelector("span").textContent}`),i.addEventListener("click",(()=>{this.select(e,t)})),this.SELECTED_DOM.append(i)}selectToParent(e,t){let i=e.length-1,s=e.pop(),a=e[i-1],n=this.STACKS[i].childNodes,l=null;this.dimensional_data[i].forEach(((e,d)=>{let r=n[d],o=e.parentNodes;if(!0!==t&&void 0!==t||(o.length>0&&o[i-1]!==a||0===o.length&&parseInt(r.getAttribute("data-id"))!==s?r.classList.add("dlp-label-silence"):(r.classList.remove("dlp-label-silence"),parseInt(r.getAttribute("data-id"))===s&&null===l&&(l=d))),!0===t&&s===e.key&&!0!==e.mark&&(e.mark=!0,r.querySelector(".right").insertAdjacentHTML("afterbegin",_component.check_circle)),!1===t&&s===e.key){let t=this.dimensional_data[i][d].nodes,s=!0;for(let e of this.dimensional_data[i+1])if(-1!==t.indexOf(e.key)&&(!0===e.checked||!0===e.mark)){s=!1;break}s&&(e.mark=!1,r.querySelector("i.right").innerHTML="")}})),null!==l&&this.STACKS[i].scrollTo(0,27*l),e.length>0&&this.selectToParent(e,t)}selectToChildren(e,t){if(e>this.dimensional_data.length-1)return;let i=this.STACKS[e].childNodes,s=[],a=null;this.dimensional_data[e].forEach(((e,n)=>{let l=i[n];if(null!==t)if(-1!==t.indexOf(parseInt(l.getAttribute("data-id")))){l.classList.remove("dlp-label-silence");let t=e.nodes;Array.isArray(t)&&t.forEach((e=>{-1===s.indexOf(t)&&s.push(e)})),null===a&&(a=n)}else l.classList.add("dlp-label-silence");else l.classList.add("dlp-label-silence")})),null!==a&&this.STACKS[e].scrollTo(0,27*a),this.selectToChildren(e+1,s)}tagCal(e,t){if(t!==this.MODE.insert){if(t===this.MODE.delete){let t=this.select_data.indexOf(e);-1!==t&&(this.select_data.splice(t,1),this.selectInputDOM.value=JSON.stringify(this.select_data)),-1!==this.selected_data.indexOf(e)&&-1===this.delete_data.indexOf(e)&&(this.delete_data.push(e),this.deleteInputDOM.value=JSON.stringify(this.delete_data)),t=this.insert_data.indexOf(e),-1!==t&&(this.insert_data.splice(t,1),this.insertInputDOM.value=JSON.stringify(this.insert_data))}}else{-1===this.select_data.indexOf(e)&&(this.select_data.push(e),this.selectInputDOM.value=JSON.stringify(this.select_data)),-1===this.selected_data.indexOf(e)&&-1===this.insert_data.indexOf(e)&&(this.insert_data.push(e),this.insertInputDOM.value=JSON.stringify(this.insert_data));let t=this.delete_data.indexOf(e);-1!==t&&(this.delete_data.splice(t,1),this.deleteInputDOM.value=JSON.stringify(this.delete_data))}}search(e){if(""!==e.value){if(!(this.SELECT_COVER_DOM instanceof HTMLElement)){this.COVER_STACK_HASH_DOM=[],this.SELECT_COVER_DOM=document.createElement("div"),this.SELECT_COVER_DOM.className="dot-select-cover dlp-scroll dot-select-cascade";for(let e=1;e<=this.dimensional_data.length;e++){let e=document.createElement("div");e.className="dot-cascade-stack dlp-scroll",this.SELECT_COVER_DOM.append(e)}this.CONTENT_DOM.parentNode.append(this.SELECT_COVER_DOM)}this.dimensional_data.forEach(((t,i)=>{this.searchPushTag(e,t,i)}))}else this.SELECT_COVER_DOM instanceof HTMLElement&&(this.SELECT_COVER_DOM.remove(),this.SELECT_COVER_DOM=null,this.COVER_STACK_HASH_DOM=[])}searchCoverClick(e,t,i){if(null===t.nodes)i instanceof HTMLElement&&i.click();else{let i=e+1;Array.isArray(this.dimensional_data[i])&&this.searchPushTag(t.nodes,this.dimensional_data[i],i)}}searchPushTag(e,t,i){t.forEach(((t,s)=>{if(Array.isArray(e)){if(-1===e.indexOf(t.key))return}else if(-1===t.val.indexOf(e.value)&&-1===e.value.indexOf(t.val))return;if(Array.isArray(this.COVER_STACK_HASH_DOM[i])&&-1!==this.COVER_STACK_HASH_DOM[i].indexOf(t.key))return;let a=document.createElement("div");a.className="dlp dlp-text dlp-label",a.insertAdjacentHTML("afterbegin",''),a.textContent=t.val,a.insertAdjacentHTML("beforeend",''),null!==t.nodes&&a.querySelector("i.left").insertAdjacentHTML("afterbegin",_component.caret_right),a.addEventListener("click",(()=>this.searchCoverClick(i,t,this.STACKS[i].childNodes[s]))),this.SELECT_COVER_DOM.childNodes[i].prepend(a),Array.isArray(this.COVER_STACK_HASH_DOM[i])?this.COVER_STACK_HASH_DOM[i].push(t.key):this.COVER_STACK_HASH_DOM[i]=[t.key]}))}checkAll(e,t,i){if(e>this.dimensional_data.length-1)return;if(!Array.isArray(t)||t.length<=0)return;let s=this.STACKS[e].childNodes,a=[],n=null;s.forEach(((s,l)=>{if(-1!==t.indexOf(parseInt(s.getAttribute("data-id")))){let t=this.dimensional_data[e][l].checked;!0===i?!1===t&&s.click():!1===i&&!0===t&&s.click();let d=this.dimensional_data[e][l].nodes;Array.isArray(d)&&d.forEach((e=>{-1===a.indexOf(d)&&a.push(e)})),null===n&&(n=l)}})),null!==n&&this.STACKS[e].scrollTo(0,27*n),this.checkAll(e+1,a,i)}},window.ComponentLine=class{constructor(e,t,i,s={}){this.DOM=document.getElementById(e),this.NAME=e,this.DOM.addEventListener("contextmenu",(e=>{e.preventDefault()})),this.format_settings={},this.COLUMNS=t,this.DATA=i,this.OPTIONS=Object.assign({sortable:!0,delete:!0,insert:!0},s);let a=this.makeHeadFoot();this.DATA_INPUT=document.createElement("input"),this.DATA_INPUT.setAttribute("name",e),this.DATA_INPUT.setAttribute("type","hidden"),this.DATA_INPUT.value="[]",this.DOM.appendChild(this.DATA_INPUT),this.makeBody(),this.makeFoot(a),this.datepicker(),this.OPTIONS.sortable&&this.sortable()}makeHeadFoot(){let e='',t=document.createElement("tr");t.className="dlp-tr";let i=this.COLUMNS;this.INSERT_ROW_MENUE_DATA={};for(let s in i){if(!i.hasOwnProperty(s))continue;let a=i[s];if("hidden"===a.type)continue;let n=a.style?`style="${a.style}"`:"";switch(e+=`${a.name}`,a.insert_type?a.insert_type:a.type){case"input":t.insertAdjacentHTML("beforeend",``);break;case"select":let e=document.createElement("td");e.style=a.style,e.append(this.menuMake(s,[],a.options,a.options_limit,a.name,!0)),t.append(e);break;case"datetime":let i;switch(a.format){case 1:i="YYYY-MM-DD";break;case 2:i="YYYY";break;default:i="YYYY-MM-DD HH:mm:ss"}this.format_settings[s]=i,n=a.style?`${a.style}`:"",t.insertAdjacentHTML("beforeend",``);break;case"hidden":t.insertAdjacentHTML("beforeend",``);break;default:this.COLUMNS[s].insert_type="input",t.insertAdjacentHTML("beforeend",``)}}return e+='',t.insertAdjacentHTML("beforeend",'
'),this.DOM.insertAdjacentHTML("afterbegin",`${e}
`),this.TABLE_DOM=this.DOM.getElementsByTagName("table")[0],t}makeBody(){let e=[],t=document.createElement("tbody"),i=this.COLUMNS;!1!==Array.isArray(this.DATA)&&(this.DATA.forEach(((s,a)=>{let n=document.createElement("tr");n.className="dlp-tr",n.setAttribute("sortable-item","sortable-item");let l={};for(let e in i){if(!i.hasOwnProperty(e))continue;let t=i[e];s[e]||(this.DATA[a][e]="",l[e]="");let d=document.createElement("td"),r=this.DATA[a][e];"select"===t.type&&(/^[0-9]+$/.test(r)?r=[parseInt(r)]:!1===Array.isArray(r)&&(r=[])),this.makeTd(d,e,t,r),l[e]=r,n.appendChild(d)}let d=document.createElement("td");d.insertAdjacentHTML("afterbegin","
"),this.operateButton(d),n.appendChild(d),t.appendChild(n),e.push(l)})),this.DATA=e,this.DATA_INPUT.value=JSON.stringify(e),t.setAttribute("sortable-list","sortable-list"),t.className="dlp-tbody dlp-scroll",this.TBODY_DOM=t,this.TABLE_DOM.appendChild(t))}makeFoot(e){let t=document.createElement("tfoot");if(t.className="dlp-tfoot",!this.OPTIONS.insert)return t.insertAdjacentHTML("afterbegin",""),void this.TABLE_DOM.appendChild(t);t.append(e),this.TABLE_DOM.appendChild(t);let i=document.createElement("i");i.className="dlp text-white",i.style.cursor="pointer",i.insertAdjacentHTML("afterbegin",_component.write),i.addEventListener("click",(()=>{let e=this.DOM.getElementsByTagName("tfoot")[0],t={},i=document.createElement("tr");i.className="dlp-tr",i.setAttribute("sortable-item","sortable-item");for(let s in this.COLUMNS){if(!this.COLUMNS.hasOwnProperty(s))continue;let a,n=this.COLUMNS[s].insert_type?this.COLUMNS[s].insert_type:this.COLUMNS[s].type,l=document.createElement("td");a="input"===n||"datetime"===n?e.querySelector(`input[data-column="${s}"]`).value:"select"===n?this.INSERT_ROW_MENUE_DATA[s]:"",t[s]=a,this.makeTd(l,s,this.COLUMNS[s],a),i.appendChild(l)}let s=document.createElement("td");s.insertAdjacentHTML("afterbegin","
"),this.operateButton(s),i.appendChild(s),this.TBODY_DOM.appendChild(i),this.DATA.push(t),this.DATA_INPUT.value=JSON.stringify(this.DATA),this.TBODY_DOM.scrollTop=this.TBODY_DOM.scrollHeight,this.datepicker()}),!1),this.TABLE_DOM.querySelector(".insert_handel div").appendChild(i)}makeTd(e,t,i,s){let a,n=this.DATA,l=this.DATA_INPUT;switch(i.type){case"text":default:e.insertAdjacentHTML("afterbegin",`

${s}

`);break;case"input":a=document.createElement("input"),a.className="dlp dlp-input",a.setAttribute("data-column",t),a.value=s,a.addEventListener("input",(()=>{let e=this.searchChildrenDomIndex(a.parentNode.parentNode),t=a.getAttribute("data-column");n[e]&&(n[e][t]=a.value,l.value=JSON.stringify(n))}),!1),e.appendChild(a);break;case"datetime":let d;switch(a=document.createElement("input"),a.setAttribute("class",`dlp dlp-input datetime-${t}`),a.setAttribute("data-column",t),a.value=s,i.format){case 1:d="YYYY-MM-DD";break;case 2:d="YYYY";break;default:d="YYYY-MM-DD HH:mm:ss"}this.format_settings[t]=d,a.addEventListener("blur",(()=>{let e=this.searchChildrenDomIndex(a.parentNode.parentNode),t=a.getAttribute("data-column");n[e]&&(n[e][t]=a.value,l.value=JSON.stringify(n))}),!1),e.appendChild(a),e.style.position="relative";break;case"select":e.append(this.menuMake(t,s,i.options,i.options_limit,i.name))}i.style&&(e.style=i.style)}operateButton(e){if(this.OPTIONS.sortable){let t=document.createElement("i");t.className="dlp text-white",t.setAttribute("style","cursor: pointer;"),t.setAttribute("sortable-handle","sortable-handle"),t.insertAdjacentHTML("afterbegin",_component.move),e.firstElementChild.appendChild(t)}if(this.OPTIONS.delete){let t=document.createElement("i");t.className="dlp text-white",t.setAttribute("style","cursor: pointer;"),t.insertAdjacentHTML("afterbegin",_component.trash),t.addEventListener("click",(()=>{let e=t.parentNode.parentNode.parentNode,i=e.parentNode,s=this.searchChildrenDomIndex(e);this.DATA.splice(s,1),i.removeChild(e),this.DATA_INPUT.value=JSON.stringify(this.DATA)}),!1),e.firstElementChild.appendChild(t)}e.className="operate-column"}menuMake(e,t,i,s,a,n=!1){let l=document.createElement("div");l.className="dlp-dot-menu",n&&(this.INSERT_ROW_MENUE_DATA[e]=[]);let d=document.createElement("div");d.className="dlp-input dlp-dot-menu-select",d.insertAdjacentHTML("afterbegin",`
${a}
`);let r=document.createElement("div");r.className="menu-list";let o=document.createElement("div");o.className="search-box";let c=document.createElement("input");c.className="dlp dlp-input dot-search",c.setAttribute("placeholder","搜索"),c.addEventListener("input",(()=>{setTimeout((()=>{if(""!==c.value)for(let e of h.childNodes){let t=e.firstElementChild.innerText;-1!==t.indexOf(c.value)||-1!==c.value.indexOf(t)?e.style.display="flex":e.style.display="none"}else for(let e of h.childNodes)e.style.display="flex"}),300)}));let h=document.createElement("div");h.className="list dlp-scroll";let p=_component.check;p=p.replace('width="16" height="16"','width="12" height="12"');for(let r in i){if(!i.hasOwnProperty(r))continue;let o=document.createElement("div");o.className="option",o.setAttribute("data-id",r),o.insertAdjacentHTML("afterbegin",`
${i[r]}
`),o.addEventListener("click",(()=>{let t;if(r=parseInt(r),n)t=this.INSERT_ROW_MENUE_DATA[e];else{let i=this.searchChildrenDomIndex(l.parentNode.parentNode);t=this.DATA[i][e]}let c=t.indexOf(r);if(-1!==c)return t.splice(c,1),o.classList.remove("option-active"),o.lastChild instanceof HTMLElement&&(o.lastChild.innerHTML=""),m(i,t,s),0===t.length&&(d.firstElementChild.textContent=a),void(!1===n&&(this.DATA_INPUT.value=JSON.stringify(this.DATA)));if(s>0&&t.length>=s)for(let e of h.childNodes)t.hasOwnProperty("0")&&e.getAttribute("data-id")===t[0].toString()&&e.click();o.classList.add("option-active"),t.push(r),o.lastChild instanceof HTMLElement&&o.lastChild.insertAdjacentHTML("afterbegin",p),m(i,t,s),!1===n&&(this.DATA_INPUT.value=JSON.stringify(this.DATA))}),!1),s>0&&t.length>=s&&t.slice(0,s),-1!==t.indexOf(parseInt(r))&&(o.classList.add("option-active"),o.lastChild instanceof HTMLElement&&o.lastChild.insertAdjacentHTML("afterbegin",p),m(i,t,s)),h.append(o)}function m(e,t,i){if(1===i)return void(d.firstElementChild.innerHTML=`

${e[t[0]]}

`);let s="";for(let i of t)s+=`${e[i]}`;d.firstElementChild.innerHTML=s}return l.append(d),o.append(c),r.append(o),r.append(h),l.append(r),l.addEventListener("click",(()=>{r.style.display="flex"})),l.addEventListener("mouseleave",(()=>{r.style.display="none",this.DOM.querySelector(".dot-search").value=""})),l}sortable(){let e=this;new ComponentSortable(this.TBODY_DOM,(function(t){let i=[];t.forEach((function(t){i.push(e.DATA[t])})),e.DATA=i,e.DATA_INPUT.value=JSON.stringify(e.DATA)}))}datepicker(){"undefined"!=typeof jQuery&&setTimeout((()=>{for(let e in this.format_settings){let t=this.format_settings[e];$(`#${this.NAME} input.datetime-${e}`).datetimepicker({format:t,locale:"zh-CN"})}}))}searchChildrenDomIndex(e){let t=0;for(;null!=(e=e.previousSibling);)t++;return t}},window.ComponentPlane=class{constructor(e,t={},i={}){document.querySelector("#dlp-plane")instanceof HTMLElement||(this.URL=e,this.XHR=Object.assign({url:e,method:"POST",listener:null,event:"click",callback:null},t),this.OPTIONS=Object.assign({w:.8,h:.8,top:"30px",left:"auto"},i),this.makeModal(),this.makeContent())}makeModal(){let e,t;e=-1!==this.OPTIONS.w.toString().indexOf(".")?window.innerWidth*this.OPTIONS.w+"px":this.OPTIONS.w,t=-1!==this.OPTIONS.h.toString().indexOf(".")?window.innerHeight*this.OPTIONS.h+"px":this.OPTIONS.h;let i=`
`;document.body.insertAdjacentHTML("beforeEnd",i),this.DOM=document.getElementById("dlp-plane");let s=document.createElement("i");s.insertAdjacentHTML("afterbegin",_component.close),s.addEventListener("click",(()=>{this.DOM instanceof HTMLElement&&this.DOM.remove(),document.getElementById("kvFileinputModal")instanceof HTMLElement&&document.getElementById("kvFileinputModal").remove()}),!1),this.DOM.querySelector(".plane-header").append(s),this.MODEL_BODY_DOM=this.DOM.querySelector(".plane-body"),window.addEventListener("popstate",(()=>{this.DOM.remove()}),!1)}makeContent(){_component.loading(this.MODEL_BODY_DOM);let e=this;_component.request({url:this.URL,method:"GET",callback:function(t){_component.loading(e.MODEL_BODY_DOM,!0);let i=document.createRange().createContextualFragment(t);e.MODEL_BODY_DOM.appendChild(i);let s=e.XHR.listener;if("function"==typeof s){let t=s(e.MODEL_BODY_DOM);t instanceof HTMLElement&&t.addEventListener(e.XHR.event,e.submitEvent.bind(e,t),!1)}}})}submitEvent(e){e.setAttribute("disabled","disabled"),e.innerText="提交中...";let t=this.MODEL_BODY_DOM.getElementsByTagName("form")[0],i=new FormData(t);for(const e of i.entries()){let t=e[0],s=e[1];/\[.*\]/.test(t)&&/^\[.*\]$/.test(s)&&"string"==typeof s&&(s=JSON.parse(s),Array.isArray(s)&&s.length>0?s.forEach((e=>{i.append(`${t}[]`,e)})):i.append(`${t}`,""))}_component.request({url:this.XHR.url,method:this.XHR.method,data:i,callback:t=>{"function"!=typeof this.XHR.callback?t&&(0===t.code?window.location.reload():_component.alert(t.message,3,(function(){e.removeAttribute("disabled"),e.innerText="提交"}))):this.XHR.callback(t)}})}},window.ComponentSortable=class{constructor(e,t=null){this.list="string"==typeof e?document.querySelector(e):e,this.options={animationSpeed:200,animationEasing:"ease-out"},this.callback=t,this.animation=!1,this.dragStart=this.dragStart.bind(this),this.dragMove=this.dragMove.bind(this),this.dragEnd=this.dragEnd.bind(this),this.list.addEventListener("touchstart",this.dragStart,!1),this.list.addEventListener("mousedown",this.dragStart,!1)}reset(){this.items=Array.from(this.list.children),this.items[this.items.length-1].offsetTop>this.list.offsetHeight?this.listHeight=this.list.scrollHeight:this.listHeight=this.items[this.items.length-1].offsetTop}dragStart(e){if(this.reset(),this.animation)return;if(this.items.length<2)return;this.handle=null;let t=e.target;for(;t&&(t.hasAttribute("sortable-handle")&&(this.handle=t),t.hasAttribute("sortable-item")&&(this.item=t),!t.hasAttribute("sortable-list"));)t=t.parentElement;if(!this.handle)return;this.list.style.position="relative",this.item.classList.add("is-dragging"),this.itemHeight=this.items[1].offsetTop,this.startTouchY=this.getDragY(e),this.startTop=this.item.offsetTop;const i=this.items.map((e=>e.offsetTop));this.items.forEach(((e,t)=>{e.style.position="absolute",e.style.top="0",e.style.left="0",e.style.transform=`translateY(${i[t]}px)`,e.style.zIndex=e===this.item?"2":"1"})),this.positions=this.items.map(((e,t)=>t)),this.position=Math.round(this.startTop/this.listHeight*this.items.length),this.touch="touchstart"===e.type,window.addEventListener(this.touch?"touchmove":"mousemove",this.dragMove),window.addEventListener(this.touch?"touchend":"mouseup",this.dragEnd,!1)}dragMove(e){if(this.animation)return;if(this.items.length<2)return;const t=this.startTop+this.getDragY(e)-this.startTouchY,i=Math.round(t/this.listHeight*this.items.length);this.item.style.transform=`translateY(${t}px)`,this.positions.forEach((e=>{e!==this.position&&e===i&&(this.swapElements(this.positions,this.position,e),this.position=e)})),this.items.forEach(((e,t)=>{e!==this.item&&(e.style.transform=`translateY(${this.positions.indexOf(t)*this.itemHeight}px)`,e.style.transition=`transform ${this.options.animationSpeed}ms ${this.options.animationEasing}`)})),e.preventDefault()}dragEnd(){this.animation=!0,this.items.length<2||(this.item.style.transition=`all ${this.options.animationSpeed}ms ${this.options.animationEasing}`,this.item.style.transform=`translateY(${this.position*this.itemHeight}px)`,this.item.classList.remove("is-dragging"),"function"==typeof this.callback&&this.callback(this.positions),setTimeout((()=>{this.list.style.position="",this.items.forEach((e=>{e.style.top="",e.style.left="",e.style.right="",e.style.position="",e.style.transform="",e.style.transition="",e.style.zIndex=""})),this.positions.map((e=>{this.items[e]&&this.list.appendChild(this.items[e])})),this.animation=!1}),this.options.animationSpeed),window.removeEventListener(this.touch?"touchmove":"mousemove",this.dragMove),window.removeEventListener(this.touch?"touchend":"mouseup",this.dragEnd,!1))}swapElements(e,t,i){let s=e[t];e[t]=e[i],e[i]=s}getDragY(e){return e.touches?(e.touches[0]||e.changedTouches[0]).pageY:e.pageY}},window.ComponentCascadeLine=class{constructor(e,t,i,s){if(!Array.isArray(t))return void console.error("CascadeLine param select must be array!");this.name=e,this.OPTIONS=Object.assign({movable:!0,exchange:!0,detail:!0,insert:!0,update:!0,delete:!0,root:!0},s),this.DOM=document.getElementById(e),this.URL=i,this.make().makeSelect(t),this.OPTIONS.insert&&this.makeHeader();let a=document.querySelector(`#${this.name} .dot-search`);if(a.addEventListener("input",(()=>{setTimeout((()=>{this.search(a)}),700)})),this.OPTIONS.movable)for(let e of this.DOM.querySelectorAll("i.right"))this.nodeMigrate(e)}make(){return this.DOM.insertAdjacentHTML("afterbegin",'
'),this.DOM.addEventListener("contextmenu",(e=>{e.preventDefault()})),this.HEADER_DOM=document.querySelector(`#${this.name} .dot-top`),this.CONTENT_DOM=document.querySelector(`#${this.name} .dot-select`),this.SEARCH_BOX=document.querySelector(`#${this.name} .search-box`),this}makeHeader(){let e=document.createElement("div");e.className="dlp-btn",e.addEventListener("click",(()=>{this.panel("新增根节点");let e=this;_component.request({url:this.URL+"/create",method:"GET",data:{},callback:function(t){e.panelContent(t,{key:0},e.URL,"POST",(t=>{if(void 0===t.data.key)return _component.alert("返回数据结构缺少key",3,null,e.DOM);if(void 0===t.data.val)return _component.alert("返回数据结构缺少val",3,null,e.DOM);let i=parseInt(t.data.key),s=t.data.val,a=e.dimensional_data[0].push({expand:!1,key:i,val:s,nodes:null,parentNodes:[]})-1,n=e.STACKS[0];n.append(e.insertLabelDom(e.dimensional_data[0][a],a,0)),e.STACKS[0].scrollTo(0,27*a),n.lastChild.click(),e.PLANE_DOM.remove()}))}})})),e.insertAdjacentHTML("afterbegin",_component.node),this.HEADER_DOM.append(e)}makeSelect(e){this.dimensional_data=[],_component.dimensional(this.dimensional_data,e);for(let e in this.dimensional_data){if(!this.dimensional_data.hasOwnProperty(e))continue;e=parseInt(e);let t=this.dimensional_data[e],i=document.createElement("div");i.className="dot-cascade-stack dlp-scroll",t.forEach(((t,s)=>{t.stack=e,Array.isArray(t.nodes)&&0!==t.nodes.length?(t.nodes=t.nodes.map((e=>e.key)),t.expand=!1):t.nodes=null;let a=this.insertLabelDom(t,s,e);null!==t.nodes&&a.insertAdjacentHTML("afterbegin",`${_component.caret_right}`),i.append(a)})),this.CONTENT_DOM.append(i)}this.STACKS=this.CONTENT_DOM.childNodes}insertLabelDom(e,t,i){let s=document.createElement("div");return s.className="dlp dlp-text dlp-label",s.insertAdjacentHTML("afterbegin",`${e.val}`),s.setAttribute("data-id",e.key.toString()),s.setAttribute("data-k",t.toString()),s.setAttribute("data-stack",i.toString()),s.setAttribute("drag-zone","true"),s.addEventListener("click",this.select.bind(this,s,i)),s.addEventListener("contextmenu",(t=>{t.preventDefault(),t.target instanceof HTMLElement&&t.target.click();let a=[];this.OPTIONS.detail&&a.push({title:"详情",func:()=>{this.nodeDetail(s,e)}}),this.OPTIONS.insert&&a.push({title:"新增",func:()=>{this.nodeInsert(s,e,i)}}),this.OPTIONS.update&&a.push({title:"修改",func:()=>{this.nodeUpdate(s,e)}}),this.OPTIONS.delete&&a.push({title:"删除",func:()=>{this.nodeDelete(s,e,i)}}),this.OPTIONS.root&&a.push({title:_component.node,func:()=>{let e=parseInt(s.getAttribute("data-stack")),t=parseInt(s.getAttribute("data-k")),i=this.dimensional_data[e][t];this.dialog(`${i.val} 迁移到根节点`,90);let a=document.createElement("div");a.className="dlp dlp-text dlp-label",a.insertAdjacentHTML("afterbegin",`${i.val}${_component.check_circle}`),this.PLANE_BODY.insertAdjacentHTML("afterbegin",`
${_component.node}
`),this.PLANE_BODY.insertAdjacentHTML("beforeend",'
');let n=this;a.addEventListener("click",(()=>{if(0===i.stack)return n.PLANE_DOM.remove();n.submit_block||(n.submit_block=!0,a.querySelector(".right").innerHTML=_component.sub_loading,_component.request({url:this.URL,method:"GET",data:{event:"root",node_key:i.key,node_val:i.val},callback:function(e){if(n.submit_block=!1,0!==(e=JSON.parse(e)).code)return _component.alert(e.message,3,null,n.DOM);n.nodeRootExec(s,i),n.PLANE_DOM.remove()},error_callback:function(){n.submit_block=!1}}))})),this.PLANE_BODY.append(a)}}),_component.contextmenu(t,a)})),this.OPTIONS.movable&&s.insertAdjacentHTML("beforeend",`${_component.move}`),s}select(e,t){let i=parseInt(e.getAttribute("data-k")),s=this.dimensional_data[t][i],a=this.STACKS[t].childNodes,n=s.parentNodes[s.parentNodes.length-1];if(this.dimensional_data[t].forEach(((e,t)=>{let i=a[t];-1!==e.parentNodes.indexOf(n)?i.classList.remove("dlp-label-silence"):i.classList.add("dlp-label-silence"),this.expand(e,a[t],!1)})),this.expand(s,e,!0),e.classList.remove("dlp-label-silence"),this.selectToChildren(t+1,s.nodes),Array.isArray(s.parentNodes)&&s.parentNodes.length>0){let e=s.parentNodes.slice(0);this.selectToParent(e)}}selectToParent(e){let t=e.length-1,i=e.pop(),s=e[t-1],a=this.STACKS[t].childNodes,n=null;this.dimensional_data[t].forEach(((e,l)=>{let d=a[l],r=e.parentNodes;r.length>0&&r[t-1]!==s||0===r.length&&parseInt(d.getAttribute("data-id"))!==i?(d.classList.add("dlp-label-silence"),this.expand(e,d,!1)):(d.classList.remove("dlp-label-silence"),parseInt(d.getAttribute("data-id"))===i?(null===n&&(n=l),this.expand(e,d,!0)):this.expand(e,d,!1))})),null!==n&&this.STACKS[t].scrollTo(0,27*n),e.length>0&&this.selectToParent(e)}selectToChildren(e,t){if(e>this.dimensional_data.length-1)return;let i=this.STACKS[e].childNodes,s=[],a=null;this.dimensional_data[e].forEach(((n,l)=>{let d=i[l];if(null!==t)if(-1!==t.indexOf(parseInt(d.getAttribute("data-id")))){d.classList.remove("dlp-label-silence");let t=this.dimensional_data[e][l].nodes;Array.isArray(t)&&t.forEach((e=>{-1===s.indexOf(t)&&s.push(e)})),null===a&&(a=l),this.expand(n,d,!0)}else d.classList.add("dlp-label-silence"),this.expand(n,d,!1);else d.classList.add("dlp-label-silence")})),null!==a&&this.STACKS[e].scrollTo(0,27*a),this.selectToChildren(e+1,s)}expand(e,t,i=!0){if(e.expand===i)return;e.expand=i;let s=t.querySelector("i.left");s instanceof HTMLElement&&(s.innerHTML=i?_component.caret_right_circle:_component.caret_right)}panel(e){this.DOM.childNodes[0].insertAdjacentHTML("beforeend",'
');let t=this.DOM.childNodes[0].lastChild,i=t.querySelector(".plane-header");this.PLANE_DOM=t;let s=document.createElement("div");s.className="header-content",s.insertAdjacentHTML("afterbegin",_component.node+` ${e}`),i.append(s);let a=document.createElement("i");a.insertAdjacentHTML("afterbegin",_component.close),a.addEventListener("click",(()=>{t.remove()}),!1),i.append(a),this.PLANE_BODY=t.querySelector(".plane-body"),_component.loading(this.PLANE_BODY)}panelContent(e,t,i,s,a){_component.loading(this.PLANE_BODY,!0);let n=document.createRange().createContextualFragment(e);this.PLANE_BODY.appendChild(n);let l=document.createElement("div");if(l.insertAdjacentHTML("afterbegin",_component.check),l.addEventListener("click",this.submitEvent.bind(this,l,t,i,s,a)),l.className="dlp-submit-btn",!(this.PLANE_DOM instanceof HTMLElement))return;let d=this.PLANE_DOM.querySelector(".plane-header"),r=d.querySelector("i");d.insertBefore(l,r)}submitEvent(e,t,i,s,a){if(this.submit_block)return;this.submit_block=!0,e.innerHTML=_component.sub_loading;let n=this.DOM.getElementsByTagName("form")[0],l=new FormData(n);l.set("key",t.key),l.set("val",t.val),l.set("_method",s);let d=this;_component.request({url:i,method:"POST",data:l,callback:function(t){if(d.submit_block=!1,e.innerHTML=_component.check,0!==t.code)return _component.alert(t.message,3,null,d.DOM);a(t)},error_callback:function(){d.submit_block=!1}})}nodeDetail(e,t){this.panel(`${t.val} 详情`);let i=this;_component.request({url:this.URL+"/"+t.key,method:"GET",data:{},callback:function(e){_component.loading(i.PLANE_BODY,!0);let t=document.createRange().createContextualFragment(e);i.PLANE_BODY.appendChild(t)}})}nodeInsert(e,t,i){this.panel(`${t.val} 新增`);let s=this,a=parseInt(i)+1;_component.request({url:this.URL+"/create",method:"GET",data:{id:t.key},callback:function(i){s.panelContent(i,t,s.URL,"POST",(i=>{if(0!==i.code)return _component.alert(i.message,3,null,s.DOM);if(void 0===i.data.key)return _component.alert("返回数据结构缺少key",3,null,s.DOM);if(void 0===i.data.val)return _component.alert("返回数据结构缺少val",3,null,s.DOM);let n=parseInt(i.data.key),l=i.data.val,d=t.parentNodes.slice(0);if(d.push(t.key),Array.isArray(s.dimensional_data[a]))if(Array.isArray(t.nodes)&&0!==t.nodes.length){let e=t.nodes[t.nodes.length-1],i=s.STACKS[a].childNodes,r=0;for(let t in s.dimensional_data[a])if(s.dimensional_data[a].hasOwnProperty(t)&&(t=parseInt(t),r=t+1,s.dimensional_data[a][t].key===e)){s.dimensional_data[a].splice(r,0,{expand:!1,key:n,val:l,nodes:null,parentNodes:d});let e=i[t];e.parentNode.insertBefore(s.insertLabelDom(s.dimensional_data[a][r],r,a),e.nextSibling);break}s.dimensional_data[a].forEach(((e,t)=>{t>r&&i[t].setAttribute("data-k",t)})),s.STACKS[a].scrollTo(0,27*r)}else{let t=s.dimensional_data[a].push({expand:!1,key:n,val:l,nodes:null,parentNodes:d})-1;s.STACKS[a].append(s.insertLabelDom(s.dimensional_data[a][t],t,a)),e.insertAdjacentHTML("afterbegin",`${_component.caret_right_circle}`),s.STACKS[a].scrollTo(0,27*t)}else{s.dimensional_data[a]=[{expand:!1,key:n,val:l,nodes:null,parentNodes:d}];let t=document.createElement("div");t.className="dot-cascade-stack dlp-scroll",t.append(s.insertLabelDom(s.dimensional_data[a][0],0,a)),s.CONTENT_DOM.append(t),e.insertAdjacentHTML("afterbegin",`${_component.caret_right_circle}`)}Array.isArray(t.nodes)||(t.nodes=[]),t.nodes.push(n),s.PLANE_DOM.remove()}))}})}nodeUpdate(e,t){this.panel(`${t.val} 修改`);let i=this;_component.request({url:this.URL+"/"+t.key+"/edit",method:"GET",data:{val:t.val},callback:function(s){i.panelContent(s,t,i.URL+"/"+t.key,"PUT",(s=>{if(0!==s.code)return _component.alert(s.message,3,null,i.DOM);if(void 0===s.data.val)return _component.alert("返回数据结构缺少val",3,null,i.DOM);let a=s.data.val;t.val=a,e.querySelector("span").textContent=a,i.PLANE_DOM.remove()}))}})}dialog(e,t=50){let i=`
`;this.DOM.childNodes[0].insertAdjacentHTML("beforeend",i);let s=this.DOM.childNodes[0].lastChild,a=s.querySelector(".plane-header"),n=document.createElement("div");n.className="header-content",n.insertAdjacentHTML("afterbegin",_component.node+`${e}`),a.append(n);let l=document.createElement("i");l.insertAdjacentHTML("afterbegin",_component.close),l.addEventListener("click",(()=>{s.remove()}),!1),a.append(l),this.PLANE_DOM=s,this.PLANE_BODY=s.querySelector(".plane-body")}nodeDelete(e,t,i){let s=this,a=`${t.val} 删除`;this.dialog(a);let n=document.createElement("div");n.className="dlp dlp-text dlp-label",n.addEventListener("click",(()=>{s.submit_block||(s.submit_block=!0,n.querySelector(".right").innerHTML=_component.sub_loading,_component.request({url:this.URL+"/"+t.key,method:"DELETE",data:{},callback:function(e){if(s.submit_block=!1,0!==e.code)return _component.alert(e.message,3,null,s.DOM);s.nodeDeleteExec(t,i),s.PLANE_DOM.remove()},function(){s.submit_block=!1}}))})),n.insertAdjacentHTML("afterbegin",`${t.val}${_component.trash}`),this.PLANE_BODY.append(n)}nodeDeleteExec(e,t){let i,s=e.parentNodes.length-1;if(s>=0){let t=e.parentNodes.pop();for(let i in this.dimensional_data[s]){if(!this.dimensional_data[s].hasOwnProperty(i))continue;i=parseInt(i);let a=this.dimensional_data[s][i];if(a.key===t&&(a.nodes.forEach(((t,i)=>{t===e.key&&a.nodes.splice(i,1)})),0===a.nodes.length)){let e=this.STACKS[s].childNodes[i].querySelector("i.left");e&&e.remove()}}}for(let i=t+1;i0?(this.STACKS[t].remove(),this.dimensional_data.splice(t,1)):this.dimensional_data=[[]])}search(e){if(Array.isArray(this.search_result)&&this.search_result.length>0&&this.lastPickRemove(),this.search_result=[],this.search_result_panel instanceof HTMLElement&&this.search_result_panel.remove(),""===e.value)return;if(this.dimensional_data.forEach(((t,i)=>{t.forEach(((t,s)=>{-1===t.val.indexOf(e.value)&&-1===e.value.indexOf(t.val)||this.search_result.push({stack:i,index:s})}))})),0===this.search_result.length)return;let t=document.createElement("div");t.className="dot-search-result-panel";let i=document.createElement("span");i.className="dlp-btn",i.textContent="◀",i.addEventListener("click",this.searchPick.bind(this,!1));let s=document.createElement("span");s.className="dlp-btn",s.textContent="▶",s.addEventListener("click",this.searchPick.bind(this,!0));let a=document.createElement("span");a.className="search-result-number dlp-text",a.textContent="1",this.SEARCH_PICK=a,this.search_result_pick=1,t.append(i),t.append(a),t.insertAdjacentHTML("beforeend",` / ${this.search_result.length.toString()}`),t.append(s),this.search_result_panel=t,this.SEARCH_BOX.append(t),this.pickUp()}searchPick(e=!0){this.lastPickRemove(),e?(this.search_result_pick++,this.search_result_pick>this.search_result.length&&(this.search_result_pick=1)):(this.search_result_pick--,this.search_result_pick<1&&(this.search_result_pick=this.search_result.length)),this.SEARCH_PICK.textContent=this.search_result_pick.toString(),this.pickUp()}lastPickRemove(){let e=this.search_result[this.search_result_pick-1];this.STACKS[e.stack].childNodes[e.index].classList.remove("dlp-label-active")}pickUp(){let e=this.search_result[this.search_result_pick-1],t=this.STACKS[e.stack].childNodes[e.index];t instanceof HTMLElement&&(t.classList.add("dlp-label-active"),this.STACKS[e.stack].scrollTo(0,27*e.index),t.click())}nodeMigrate(e){let t=e.parentNode,i=this,s=null;function a(e){e.preventDefault();let a=e.target;for(;null!==a&&a!==t&&(a instanceof HTMLElement||"svg"===a.tagName)&&"true"!==a.getAttribute("drag-area")&&"BODY"!==a.tagName;){if("true"===a.getAttribute("drag-zone")){if("dragover"===e.type)if(s=a,s.classList.contains("dlp-label-silence")&&s.click(),i.OPTIONS.exchange)s.style.setProperty("background","#bb8f2c");else{let e=parseInt(s.getAttribute("data-stack")),a=parseInt(s.getAttribute("data-k")),n=i.dimensional_data[e][a].parentNodes;Array.isArray(n)&&-1===n.indexOf(parseInt(t.getAttribute("data-id")))&&s.style.setProperty("background","#bb8f2c")}else"dragleave"===e.type&&s instanceof HTMLElement&&(s.style.removeProperty("background"),s=null);break}a=a.parentNode}}function n(){t.removeAttribute("draggable"),t.style.removeProperty("border"),t.removeEventListener("dragend",n),document.removeEventListener("dragover",a),document.removeEventListener("dragleave",a),s instanceof HTMLElement&&i.nodeMigrateConfirm(t,s)}e.addEventListener("mousedown",(()=>{t.click(),t.setAttribute("draggable","true"),t.style.setProperty("border","1px dashed #3c2d2d"),document.addEventListener("dragover",a),document.addEventListener("dragleave",a),t.addEventListener("dragend",n)})),e.addEventListener("mouseup",(()=>{e.parentNode.style.removeProperty("border"),document.removeEventListener("dragover",a),document.removeEventListener("dragleave",a),t.removeEventListener("dragend",n),s instanceof HTMLElement&&(s.style.removeProperty("background"),s=null)}))}nodeMigrateConfirm(e,t){let i,s=parseInt(t.getAttribute("data-stack")),a=parseInt(t.getAttribute("data-k")),n=this.dimensional_data[s][a];s=parseInt(e.getAttribute("data-stack")),a=parseInt(e.getAttribute("data-k"));let l=this.dimensional_data[s][a],d="迁移";if(-1!==n.parentNodes.indexOf(l.key)?(i="exchange",d="迁移.交换"):i="migrate",!this.OPTIONS.exchange&&"exchange"===i)return;t.style.removeProperty("background"),this.dialog(`${l.val} ${d}`,90);let r=document.createElement("div"),o=this;r.className="dlp dlp-text dlp-label",r.insertAdjacentHTML("afterbegin",`${l.val}${_component.check_circle}`),this.PLANE_BODY.insertAdjacentHTML("afterbegin",`
${n.val}
`),"exchange"===i?this.PLANE_BODY.insertAdjacentHTML("beforeend",'
'):this.PLANE_BODY.insertAdjacentHTML("beforeend",'
'),r.addEventListener("click",(()=>{o.submit_block||(o.submit_block=!0,r.querySelector(".right").innerHTML=_component.sub_loading,_component.request({url:this.URL,method:"GET",data:{event:i,node_key:l.key,node_val:l.val,aim_node_key:n.key,aim_node_val:n.val},callback:function(s){if(o.submit_block=!1,0!==(s=JSON.parse(s)).code)return _component.alert(s.message,3,null,o.DOM);"exchange"===i&&o.nodeExchangeExec(e,l,t,n),"migrate"===i&&o.nodeMigrateExec(e,l,t,n),o.PLANE_DOM.remove()},error_callback:function(){o.submit_block=!1}}))})),this.PLANE_BODY.append(r)}nodeRootExec(e,t){let i=t.parentNodes.slice().pop(),s=t.stack-1;t.parentNodes=[];let a=0-t.stack,n=parseInt(e.getAttribute("data-k"));this.dimensional_data[t.stack].splice(n,1),this.dimensional_data[0].push(t),null!==t.nodes&&this.resetChildrenDimensional(t,t.stack+1,a),t.stack=0,this.dimensional_data=this.dimensional_data.filter((e=>e.length>0)),this.CONTENT_DOM.innerHTML="";for(let e in this.dimensional_data){if(!this.dimensional_data.hasOwnProperty(e))continue;e=parseInt(e);let a=this.dimensional_data[e],n=document.createElement("div");n.className="dot-cascade-stack dlp-scroll",a.forEach(((a,l)=>{parseInt(e)===s&&a.key===i&&a.nodes.splice(a.nodes.indexOf(t.key),1),Array.isArray(a.nodes)&&0!==a.nodes.length?a.expand=!1:a.nodes=null;let d=this.insertLabelDom(a,l,e);null!==a.nodes&&d.insertAdjacentHTML("afterbegin",`${_component.caret_right}`),n.append(d)})),this.CONTENT_DOM.append(n)}this.STACKS=this.CONTENT_DOM.childNodes;for(let e of this.DOM.querySelectorAll("i.right"))this.nodeMigrate(e)}nodeMigrateExec(e,t,i,s){let a,n=t.parentNodes.slice().pop(),l=t.stack-1,d=s.parentNodes.slice(0);d.push(s.key),t.parentNodes=d,null!==s.nodes&&(a=s.nodes.slice(0).pop());let r=s.stack+1,o=r-t.stack,c=parseInt(e.getAttribute("data-k"));if(this.dimensional_data[t.stack].splice(c,1),Array.isArray(this.dimensional_data[r])||(this.dimensional_data[r]=[]),a){let e=0;for(let t in this.dimensional_data[s.stack+1])if(this.dimensional_data[s.stack+1].hasOwnProperty(t)&&this.dimensional_data[s.stack+1][t].key===a){e=t;break}e++,this.dimensional_data[s.stack+1].splice(e,0,t)}else this.dimensional_data[r].push(t);this.resetChildrenDimensional(t,t.stack+1,o),this.dimensional_data=this.dimensional_data.filter((e=>e.length>0)),t.stack=r,Array.isArray(s.nodes)||(s.nodes=[]),s.nodes.push(t.key),this.CONTENT_DOM.innerHTML="";for(let e in this.dimensional_data){if(!this.dimensional_data.hasOwnProperty(e))continue;e=parseInt(e);let i=this.dimensional_data[e],s=document.createElement("div");s.className="dot-cascade-stack dlp-scroll",i.forEach(((i,a)=>{parseInt(e)===l&&i.key===n&&i.nodes.splice(i.nodes.indexOf(t.key),1),Array.isArray(i.nodes)&&0!==i.nodes.length?i.expand=!1:i.nodes=null;let d=this.insertLabelDom(i,a,e);null!==i.nodes&&d.insertAdjacentHTML("afterbegin",`${_component.caret_right}`),s.append(d)})),this.CONTENT_DOM.append(s)}this.STACKS=this.CONTENT_DOM.childNodes;for(let e of this.DOM.querySelectorAll("i.right"))this.nodeMigrate(e)}nodeExchangeExec(e,t,i,s){let a=t.key,n=t.val;t.key=s.key,t.val=s.val;let l=t.nodes.indexOf(s.key);-1!==l&&t.nodes.splice(l,1,a);let d=t.parentNodes.slice(0).pop();if(void 0!==d)for(let e in this.dimensional_data[t.stack-1]){if(!this.dimensional_data[t.stack-1].hasOwnProperty(e))continue;let i=this.dimensional_data[t.stack-1][e];if(i.key===d){i.nodes.splice(i.nodes.indexOf(a),1,s.key);break}}s.key=a,s.val=n;let r=s.parentNodes.slice(0).pop();for(let e in this.dimensional_data[s.stack-1]){if(!this.dimensional_data[s.stack-1].hasOwnProperty(e))continue;let i=this.dimensional_data[s.stack-1][e];if(i.key===r){i.nodes.splice(i.nodes.indexOf(t.key),1,s.key);break}}this.resetChildrenParent(t),e.querySelector("span").textContent=t.val,e.setAttribute("data-id",t.key),i.querySelector("span").textContent=s.val,i.setAttribute("data-id",s.key)}resetChildrenParent(e){let t=e.stack,i=e.nodes,s=e.parentNodes.slice(0);s.push(e.key),t++,this.dimensional_data[t].forEach((e=>{-1!==i.indexOf(e.key)&&(e.parentNodes=s,Array.isArray(e.nodes)&&e.nodes.length>0&&this.resetChildrenParent(e))}))}resetChildrenDimensional(e,t,i){let s=e.nodes,a=e.parentNodes.slice(0);if(a.push(e.key),!Array.isArray(this.dimensional_data[t]))return;let n=[];this.dimensional_data[t].forEach(((e,l)=>{Array.isArray(s)&&-1!==s.indexOf(e.key)&&(n.push(l),e.parentNodes=a,e.stack=t+i,Array.isArray(this.dimensional_data[e.stack])||(this.dimensional_data[e.stack]=[]),this.dimensional_data[e.stack].push(e),this.resetChildrenDimensional(e,t+1,i))})),n.reverse(),n.forEach((e=>{this.dimensional_data[t].splice(e,1)}))}}; \ No newline at end of file diff --git a/src/DLPServiceProvider.php b/src/DLPServiceProvider.php index 28c51f5..48704f2 100644 --- a/src/DLPServiceProvider.php +++ b/src/DLPServiceProvider.php @@ -29,8 +29,8 @@ public function boot(DLP $extension) } Admin::booting(function () { - Admin::css('vendor/dlp/component.min.css?v4.2'); - Admin::headerJs('vendor/dlp/component.min.js?v4.2'); + Admin::css('vendor/dlp/component.min.css?v4.3'); + Admin::headerJs('vendor/dlp/component.min.js?v4.3'); Form::extend('Dot', Dot::class); Form::extend('CascadeDot', CascadeDot::class); Form::extend('Linear', Linear::class);