From 50d74d230a1d3cdcf38f077270aef4d25dfba652 Mon Sep 17 00:00:00 2001 From: xiamaofa <951755725@qq.com> Date: Thu, 11 Apr 2024 15:32:40 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=92=E4=BB=B6=E6=BA=90=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 3 +- build.gradle | 122 + encrypt.xml | 13 + plugin.xml | 26 + .../shsytzfsds/ServerTable/ServerTable.java | 42 + .../ServerTable/ServerTableSheet.java | 43 + .../shsytzfsds/ServerTable/TableDataPane.java | 94 + .../ServerTable/TableDataPaneSheet.java | 90 + .../DatasetComponent.java | 37 + .../biPlublicServerTable/DatasetProvider.java | 18 + .../data/feishu/DBConfig.java | 26 + .../FeishuDatasetDatasourceGenerator.java | 28 + .../data/feishu/FeishuRowIterator.java | 91 + .../generator/DatasetGenerator.java | 37 + .../generator/DatasetPageGenerator.java | 49 + .../sheet/DatasetComponent.java | 37 + .../sheet/DatasetProvider.java | 18 + .../sheet/feishu/DBConfig.java | 26 + .../FeishuDatasetDatasourceGenerator.java | 34 + .../sheet/feishu/FeishuRowIterator.java | 100 + .../sheet/generator/DatasetGenerator.java | 37 + .../sheet/generator/DatasetPageGenerator.java | 49 + .../plugin/shsytzfsds/constants/Result.java | 9 + .../ControllerRegisterProvider.java | 20 + .../shsytzfsds/controller/ControllerSelf.java | 255 + .../plugin/shsytzfsds/db/bean/DBEntity.java | 73 + .../db/controller/DBController.java | 153 + .../eco/plugin/shsytzfsds/db/dao/DBDao.java | 66 + .../univalsalServerTable/DataModel.java | 144 + .../univalsalServerTable/DataModelSheet.java | 169 + .../univalsalServerTable/TableData.java | 58 + .../univalsalServerTable/TableDataBean.java | 63 + .../TableDataBeanSheet.java | 63 + .../univalsalServerTable/TableDataSheet.java | 58 + .../UniversalServerTableData.java | 69 + .../UniversalServerTableDataSheet.java | 67 + .../plugin/shsytzfsds/utils/DataSetUtils.java | 89 + .../eco/plugin/shsytzfsds/utils/FRUtils.java | 378 + .../plugin/shsytzfsds/utils/FeiShuUtils.java | 290 + .../plugin/shsytzfsds/utils/HttpUtils.java | 260 + .../shsytzfsds/utils/ResponseUtils.java | 108 + .../eco/plugin/shsytzfsds/utils/Utils.java | 385 + .../WebResourceProvider.java | 35 + .../com/eco/plugin/shsytzfsds/css/wink.css | 16 + .../com/eco/plugin/shsytzfsds/html/dwb.html | 290 + .../com/eco/plugin/shsytzfsds/html/sheet.html | 356 + .../eco/plugin/shsytzfsds/js/bi/feishu.png | Bin 0 -> 1467 bytes .../eco/plugin/shsytzfsds/js/bi/publicds.css | 5 + .../eco/plugin/shsytzfsds/js/bi/publicds.js | 34 + .../shsytzfsds/js/jquery/jquery-2.1.3.min.js | 4 + .../shsytzfsds/js/jquery/jquery.tool.js | 1484 +++ .../plugin/shsytzfsds/js/layui/css/layui.css | 1 + .../shsytzfsds/js/layui/css/modules/code.css | 1 + .../css/modules/laydate/default/laydate.css | 1 + .../css/modules/layer/default/icon-ext.png | Bin 0 -> 5911 bytes .../layui/css/modules/layer/default/icon.png | Bin 0 -> 11493 bytes .../layui/css/modules/layer/default/layer.css | 1 + .../css/modules/layer/default/loading-0.gif | Bin 0 -> 5793 bytes .../css/modules/layer/default/loading-1.gif | Bin 0 -> 701 bytes .../css/modules/layer/default/loading-2.gif | Bin 0 -> 1787 bytes .../shsytzfsds/js/layui/font/iconfont.eot | Bin 0 -> 46684 bytes .../shsytzfsds/js/layui/font/iconfont.svg | 554 + .../shsytzfsds/js/layui/font/iconfont.ttf | Bin 0 -> 46508 bytes .../shsytzfsds/js/layui/font/iconfont.woff | Bin 0 -> 30628 bytes .../shsytzfsds/js/layui/font/iconfont.woff2 | Bin 0 -> 25964 bytes .../eco/plugin/shsytzfsds/js/layui/layui.js | 10543 ++++++++++++++++ .../com/eco/plugin/shsytzfsds/js/ui.js | 1789 +++ .../shsytzfsds/js/univalsalServerTable.js | 382 + .../js/univalsalServerTableSheet.js | 493 + 69 files changed, 19785 insertions(+), 1 deletion(-) create mode 100644 build.gradle create mode 100644 encrypt.xml create mode 100644 plugin.xml create mode 100644 src/main/java/com/eco/plugin/shsytzfsds/ServerTable/ServerTable.java create mode 100644 src/main/java/com/eco/plugin/shsytzfsds/ServerTable/ServerTableSheet.java create mode 100644 src/main/java/com/eco/plugin/shsytzfsds/ServerTable/TableDataPane.java create mode 100644 src/main/java/com/eco/plugin/shsytzfsds/ServerTable/TableDataPaneSheet.java create mode 100644 src/main/java/com/eco/plugin/shsytzfsds/biPlublicServerTable/DatasetComponent.java create mode 100644 src/main/java/com/eco/plugin/shsytzfsds/biPlublicServerTable/DatasetProvider.java create mode 100644 src/main/java/com/eco/plugin/shsytzfsds/biPlublicServerTable/data/feishu/DBConfig.java create mode 100644 src/main/java/com/eco/plugin/shsytzfsds/biPlublicServerTable/data/feishu/FeishuDatasetDatasourceGenerator.java create mode 100644 src/main/java/com/eco/plugin/shsytzfsds/biPlublicServerTable/data/feishu/FeishuRowIterator.java create mode 100644 src/main/java/com/eco/plugin/shsytzfsds/biPlublicServerTable/generator/DatasetGenerator.java create mode 100644 src/main/java/com/eco/plugin/shsytzfsds/biPlublicServerTable/generator/DatasetPageGenerator.java create mode 100644 src/main/java/com/eco/plugin/shsytzfsds/biPlublicServerTable/sheet/DatasetComponent.java create mode 100644 src/main/java/com/eco/plugin/shsytzfsds/biPlublicServerTable/sheet/DatasetProvider.java create mode 100644 src/main/java/com/eco/plugin/shsytzfsds/biPlublicServerTable/sheet/feishu/DBConfig.java create mode 100644 src/main/java/com/eco/plugin/shsytzfsds/biPlublicServerTable/sheet/feishu/FeishuDatasetDatasourceGenerator.java create mode 100644 src/main/java/com/eco/plugin/shsytzfsds/biPlublicServerTable/sheet/feishu/FeishuRowIterator.java create mode 100644 src/main/java/com/eco/plugin/shsytzfsds/biPlublicServerTable/sheet/generator/DatasetGenerator.java create mode 100644 src/main/java/com/eco/plugin/shsytzfsds/biPlublicServerTable/sheet/generator/DatasetPageGenerator.java create mode 100644 src/main/java/com/eco/plugin/shsytzfsds/constants/Result.java create mode 100644 src/main/java/com/eco/plugin/shsytzfsds/controller/ControllerRegisterProvider.java create mode 100644 src/main/java/com/eco/plugin/shsytzfsds/controller/ControllerSelf.java create mode 100644 src/main/java/com/eco/plugin/shsytzfsds/db/bean/DBEntity.java create mode 100644 src/main/java/com/eco/plugin/shsytzfsds/db/controller/DBController.java create mode 100644 src/main/java/com/eco/plugin/shsytzfsds/db/dao/DBDao.java create mode 100644 src/main/java/com/eco/plugin/shsytzfsds/univalsalServerTable/DataModel.java create mode 100644 src/main/java/com/eco/plugin/shsytzfsds/univalsalServerTable/DataModelSheet.java create mode 100644 src/main/java/com/eco/plugin/shsytzfsds/univalsalServerTable/TableData.java create mode 100644 src/main/java/com/eco/plugin/shsytzfsds/univalsalServerTable/TableDataBean.java create mode 100644 src/main/java/com/eco/plugin/shsytzfsds/univalsalServerTable/TableDataBeanSheet.java create mode 100644 src/main/java/com/eco/plugin/shsytzfsds/univalsalServerTable/TableDataSheet.java create mode 100644 src/main/java/com/eco/plugin/shsytzfsds/univalsalServerTable/UniversalServerTableData.java create mode 100644 src/main/java/com/eco/plugin/shsytzfsds/univalsalServerTable/UniversalServerTableDataSheet.java create mode 100644 src/main/java/com/eco/plugin/shsytzfsds/utils/DataSetUtils.java create mode 100644 src/main/java/com/eco/plugin/shsytzfsds/utils/FRUtils.java create mode 100644 src/main/java/com/eco/plugin/shsytzfsds/utils/FeiShuUtils.java create mode 100644 src/main/java/com/eco/plugin/shsytzfsds/utils/HttpUtils.java create mode 100644 src/main/java/com/eco/plugin/shsytzfsds/utils/ResponseUtils.java create mode 100644 src/main/java/com/eco/plugin/shsytzfsds/utils/Utils.java create mode 100644 src/main/java/com/eco/plugin/shsytzfsds/webresourceProvider/WebResourceProvider.java create mode 100644 src/main/resources/com/eco/plugin/shsytzfsds/css/wink.css create mode 100644 src/main/resources/com/eco/plugin/shsytzfsds/html/dwb.html create mode 100644 src/main/resources/com/eco/plugin/shsytzfsds/html/sheet.html create mode 100644 src/main/resources/com/eco/plugin/shsytzfsds/js/bi/feishu.png create mode 100644 src/main/resources/com/eco/plugin/shsytzfsds/js/bi/publicds.css create mode 100644 src/main/resources/com/eco/plugin/shsytzfsds/js/bi/publicds.js create mode 100644 src/main/resources/com/eco/plugin/shsytzfsds/js/jquery/jquery-2.1.3.min.js create mode 100644 src/main/resources/com/eco/plugin/shsytzfsds/js/jquery/jquery.tool.js create mode 100644 src/main/resources/com/eco/plugin/shsytzfsds/js/layui/css/layui.css create mode 100644 src/main/resources/com/eco/plugin/shsytzfsds/js/layui/css/modules/code.css create mode 100644 src/main/resources/com/eco/plugin/shsytzfsds/js/layui/css/modules/laydate/default/laydate.css create mode 100644 src/main/resources/com/eco/plugin/shsytzfsds/js/layui/css/modules/layer/default/icon-ext.png create mode 100644 src/main/resources/com/eco/plugin/shsytzfsds/js/layui/css/modules/layer/default/icon.png create mode 100644 src/main/resources/com/eco/plugin/shsytzfsds/js/layui/css/modules/layer/default/layer.css create mode 100644 src/main/resources/com/eco/plugin/shsytzfsds/js/layui/css/modules/layer/default/loading-0.gif create mode 100644 src/main/resources/com/eco/plugin/shsytzfsds/js/layui/css/modules/layer/default/loading-1.gif create mode 100644 src/main/resources/com/eco/plugin/shsytzfsds/js/layui/css/modules/layer/default/loading-2.gif create mode 100644 src/main/resources/com/eco/plugin/shsytzfsds/js/layui/font/iconfont.eot create mode 100644 src/main/resources/com/eco/plugin/shsytzfsds/js/layui/font/iconfont.svg create mode 100644 src/main/resources/com/eco/plugin/shsytzfsds/js/layui/font/iconfont.ttf create mode 100644 src/main/resources/com/eco/plugin/shsytzfsds/js/layui/font/iconfont.woff create mode 100644 src/main/resources/com/eco/plugin/shsytzfsds/js/layui/font/iconfont.woff2 create mode 100644 src/main/resources/com/eco/plugin/shsytzfsds/js/layui/layui.js create mode 100644 src/main/resources/com/eco/plugin/shsytzfsds/js/ui.js create mode 100644 src/main/resources/com/eco/plugin/shsytzfsds/js/univalsalServerTable.js create mode 100644 src/main/resources/com/eco/plugin/shsytzfsds/js/univalsalServerTableSheet.js diff --git a/README.md b/README.md index 199b753..a2b7648 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,3 @@ -# shopself-fsds +# JSD-13470 +JSD-13470 \ No newline at end of file diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..89632b2 --- /dev/null +++ b/build.gradle @@ -0,0 +1,122 @@ + +apply plugin: 'java' + + +ext { + /** + * 项目中依赖的jar的路径 + * 1.如果依赖的jar需要打包到zip中,放置在lib根目录下 + * 2.如果依赖的jar仅仅是编译时需要,防止在lib下子目录下即可 + */ + libPath = "$projectDir/../webroot/WEB-INF/lib" + + /** + * 是否对插件的class进行加密保护,防止反编译 + */ + guard = true + + def pluginInfo = getPluginInfo() + pluginPre = "fine-plugin" + pluginName = pluginInfo.id + pluginVersion = pluginInfo.version + + outputPath = "$projectDir/../webroot/WEB-INF/plugins/plugin-" + pluginName + "-1.0/classes" +} + +group = 'com.fr.plugin' +version = '10.0' +sourceCompatibility = '8' + +sourceSets { + main { + java.outputDir = file(outputPath) + output.resourcesDir = file(outputPath) + } +} + +ant.importBuild("encrypt.xml") +//定义ant变量 +ant.projectDir = projectDir +ant.references["compile.classpath"] = ant.path { + fileset(dir: libPath, includes: '**/*.jar') + fileset(dir: ".",includes:"**/*.jar" ) +} + +classes.dependsOn('clean') + +task copyFiles(type: Copy,dependsOn: 'classes'){ + from outputPath + into "$projectDir/classes" +} + +task preJar(type:Copy,dependsOn: guard ? 'compile_encrypt_javas' : 'compile_plain_javas'){ + from "$projectDir/classes" + into "$projectDir/transform-classes" + include "**/*.*" +} +jar.dependsOn("preJar") + +task makeJar(type: Jar,dependsOn: preJar){ + from fileTree(dir: "$projectDir/transform-classes") + baseName pluginPre + appendix pluginName + version pluginVersion + destinationDir = file("$buildDir/libs") + + doLast(){ + delete file("$projectDir/classes") + delete file("$projectDir/transform-classes") + } +} + +task copyFile(type: Copy,dependsOn: ["makeJar"]){ + from "$buildDir/libs" + from("$projectDir/lib") { + include "*.jar" + } + from "$projectDir/plugin.xml" + into file("$buildDir/temp/plugin") +} + +task zip(type:Zip,dependsOn:["copyFile"]){ + from "$buildDir/temp/plugin" + destinationDir file("$buildDir/install") + baseName pluginPre + appendix pluginName + version pluginVersion +} + +//控制build时包含哪些文件,排除哪些文件 +processResources { +// exclude everything +// 用*.css没效果 +// exclude '**/*.css' +// except this file +// include 'xx.xml' +} + +/*读取plugin.xml中的version*/ +def getPluginInfo(){ + def xmlFile = file("plugin.xml") + if (!xmlFile.exists()) { + return ["id":"none", "version":"1.0.0"] + } + def plugin = new XmlParser().parse(xmlFile) + def version = plugin.version[0].text() + def id = plugin.id[0].text() + return ["id":id,"version":version] +} + +repositories { + mavenLocal() + maven { + url = uri('http://mvn.finedevelop.com/repository/maven-public/') + } +} + +dependencies { + //使用本地jar + implementation fileTree(dir: 'lib', include: ['**/*.jar']) + implementation fileTree(dir: libPath, include: ['**/*.jar']) +} + diff --git a/encrypt.xml b/encrypt.xml new file mode 100644 index 0000000..1401cd1 --- /dev/null +++ b/encrypt.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/plugin.xml b/plugin.xml new file mode 100644 index 0000000..af17d86 --- /dev/null +++ b/plugin.xml @@ -0,0 +1,26 @@ + + com.eco.plugin.shsytzfsds + + yes + 1.0.6 + 10.0 + 2018-07-31 + wink + + + com.eco.plugin.shsytzfsds + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/java/com/eco/plugin/shsytzfsds/ServerTable/ServerTable.java b/src/main/java/com/eco/plugin/shsytzfsds/ServerTable/ServerTable.java new file mode 100644 index 0000000..6779d89 --- /dev/null +++ b/src/main/java/com/eco/plugin/shsytzfsds/ServerTable/ServerTable.java @@ -0,0 +1,42 @@ +//package com.eco.plugin.shsytzfsds.ServerTable; +// +//import com.fr.base.TableData; +//import com.fr.design.data.tabledata.tabledatapane.AbstractTableDataPane; +//import com.fr.design.fun.impl.AbstractServerTableDataDefineProvider; +// +///** +// * @author 秃破天际 +// * @version 10.0 +// * Created by 秃破天际 on 2021-03-29 +// **/ +//public class ServerTable extends AbstractServerTableDataDefineProvider { +// @Override +// public Class classForTableData() { +// return com.eco.plugin.shsytzfsds.univalsalServerTable.TableData.class; +// } +// +// @Override +// public Class classForInitTableData() { +// return com.eco.plugin.shsytzfsds.univalsalServerTable.TableData.class; +// } +// +// @Override +// public Class appearanceForTableData() { +// return TableDataPane.class; +// } +// +// @Override +// public String nameForTableData() { +// return "飞书多维表格"; +// } +// +// @Override +// public String prefixForTableData() { +// return "飞书多维表格"; +// } +// +// @Override +// public String iconPathForTableData() { +// return "com/eco/plugin/shsytzfsds/js/bi/feishu.png"; +// } +//} diff --git a/src/main/java/com/eco/plugin/shsytzfsds/ServerTable/ServerTableSheet.java b/src/main/java/com/eco/plugin/shsytzfsds/ServerTable/ServerTableSheet.java new file mode 100644 index 0000000..99af6d7 --- /dev/null +++ b/src/main/java/com/eco/plugin/shsytzfsds/ServerTable/ServerTableSheet.java @@ -0,0 +1,43 @@ +//package com.eco.plugin.shsytzfsds.ServerTable; +// +//import com.eco.plugin.shsytzfsds.univalsalServerTable.TableDataSheet; +//import com.fr.base.TableData; +//import com.fr.design.data.tabledata.tabledatapane.AbstractTableDataPane; +//import com.fr.design.fun.impl.AbstractServerTableDataDefineProvider; +// +///** +// * @author 秃破天际 +// * @version 10.0 +// * Created by 秃破天际 on 2021-03-29 +// **/ +//public class ServerTableSheet extends AbstractServerTableDataDefineProvider { +// @Override +// public Class classForTableData() { +// return TableDataSheet.class; +// } +// +// @Override +// public Class classForInitTableData() { +// return TableDataSheet.class; +// } +// +// @Override +// public Class appearanceForTableData() { +// return TableDataPaneSheet.class; +// } +// +// @Override +// public String nameForTableData() { +// return "飞书电子表格"; +// } +// +// @Override +// public String prefixForTableData() { +// return "飞书电子表格"; +// } +// +// @Override +// public String iconPathForTableData() { +// return "com/eco/plugin/shsytzfsds/js/bi/feishu.png"; +// } +//} diff --git a/src/main/java/com/eco/plugin/shsytzfsds/ServerTable/TableDataPane.java b/src/main/java/com/eco/plugin/shsytzfsds/ServerTable/TableDataPane.java new file mode 100644 index 0000000..6174f66 --- /dev/null +++ b/src/main/java/com/eco/plugin/shsytzfsds/ServerTable/TableDataPane.java @@ -0,0 +1,94 @@ +//package com.eco.plugin.shsytzfsds.ServerTable; +// +//import com.eco.plugin.shsytzfsds.univalsalServerTable.TableData; +//import com.fr.base.BaseUtils; +//import com.fr.base.Parameter; +//import com.fr.design.data.datapane.preview.PreviewTablePane; +//import com.fr.design.data.tabledata.tabledatapane.AbstractTableDataPane; +//import com.fr.design.gui.ibutton.UIButton; +//import com.fr.design.gui.icontainer.UIScrollPane; +//import com.fr.design.gui.ilable.UILabel; +//import com.fr.design.gui.itableeditorpane.ParameterTableModel; +//import com.fr.design.gui.itableeditorpane.UITableEditorPane; +//import com.fr.design.gui.itableeditorpane.UITableModelAdapter; +//import com.fr.design.gui.itextarea.UITextArea; +//import com.fr.design.layout.TableLayout; +//import com.fr.design.layout.TableLayoutHelper; +//import com.fr.script.Calculator; +//import com.fr.stable.ParameterProvider; +// +//import javax.swing.*; +//import java.awt.*; +//import java.awt.event.ActionEvent; +//import java.awt.event.ActionListener; +// +///** +// * @author 秃破天际 +// * @version 10.0 +// * Created by 秃破天际 on 2021-03-29 +// **/ +//public class TableDataPane extends AbstractTableDataPane { +// +// private UITextArea config; +// private UITableEditorPane parameterTableEditorPane; +// +// public TableDataPane(){ +// config = new UITextArea(); +// setLayout(new BorderLayout()); +// +// UIButton preview = new UIButton(BaseUtils.readIcon("/com/fr/design/images/m_file/preview.png")); +// preview.addActionListener(new ActionListener() { +// @Override +// public void actionPerformed(ActionEvent e) { +// SwingUtilities.invokeLater(new Runnable() { +// @Override +// public void run() { +// PreviewTablePane.previewTableData(TableDataPane.this.updateBean()); +// } +// }); +// } +// }); +// +// add(TableLayoutHelper.createTableLayoutPane( +// new Component[][] {{ +// new UILabel("配置"),preview +// }}, +// new double[] { TableLayout.PREFERRED }, +// new double[] { TableLayout.FILL,TableLayout.PREFERRED } +// ),BorderLayout.NORTH); +// +// UIScrollPane loadArea = new UIScrollPane(config); +// add(loadArea, BorderLayout.CENTER); +// +// UITableModelAdapter model = new ParameterTableModel(); +// parameterTableEditorPane = new UITableEditorPane(model); +// +// add(parameterTableEditorPane,BorderLayout.SOUTH); +// } +// +// @Override +// public void populateBean(TableData data) { +// if (data == null) { +// return; +// } +// Calculator c = Calculator.createCalculator(); +// ParameterProvider[] parameters = data.getParameters(c); +// parameterTableEditorPane.populate(parameters); +// config.setText( data.getConfig() ); +// } +// +// @Override +// public TableData updateBean() { +// TableData data = new TableData(); +// data.setConfig( config.getText() ); +// java.util.List parameterProviderList = parameterTableEditorPane.update(); +// Parameter[] parameters = parameterProviderList.toArray(new Parameter[parameterProviderList.size()]); +// data.setParameters(parameters); +// return data; +// } +// +// @Override +// protected String title4PopupWindow() { +// return "飞书多维表格"; +// } +//} diff --git a/src/main/java/com/eco/plugin/shsytzfsds/ServerTable/TableDataPaneSheet.java b/src/main/java/com/eco/plugin/shsytzfsds/ServerTable/TableDataPaneSheet.java new file mode 100644 index 0000000..54d792e --- /dev/null +++ b/src/main/java/com/eco/plugin/shsytzfsds/ServerTable/TableDataPaneSheet.java @@ -0,0 +1,90 @@ +//package com.eco.plugin.shsytzfsds.ServerTable; +// +//import com.eco.plugin.shsytzfsds.univalsalServerTable.TableDataSheet; +//import com.fr.base.BaseUtils; +//import com.fr.base.Parameter; +//import com.fr.design.data.datapane.preview.PreviewTablePane; +//import com.fr.design.data.tabledata.tabledatapane.AbstractTableDataPane; +//import com.fr.design.gui.ibutton.UIButton; +//import com.fr.design.gui.icontainer.UIScrollPane; +//import com.fr.design.gui.ilable.UILabel; +//import com.fr.design.gui.itableeditorpane.ParameterTableModel; +//import com.fr.design.gui.itableeditorpane.UITableEditorPane; +//import com.fr.design.gui.itableeditorpane.UITableModelAdapter; +//import com.fr.design.gui.itextarea.UITextArea; +//import com.fr.design.layout.TableLayout; +//import com.fr.design.layout.TableLayoutHelper; +//import com.fr.script.Calculator; +//import com.fr.stable.ParameterProvider; +// +//import javax.swing.*; +//import java.awt.*; +//import java.awt.event.ActionEvent; +//import java.awt.event.ActionListener; +// +// +//public class TableDataPaneSheet extends AbstractTableDataPane { +// +// private UITextArea config; +// private UITableEditorPane parameterTableEditorPane; +// +// public TableDataPaneSheet(){ +// config = new UITextArea(); +// setLayout(new BorderLayout()); +// +// UIButton preview = new UIButton(BaseUtils.readIcon("/com/fr/design/images/m_file/preview.png")); +// preview.addActionListener(new ActionListener() { +// @Override +// public void actionPerformed(ActionEvent e) { +// SwingUtilities.invokeLater(new Runnable() { +// @Override +// public void run() { +// PreviewTablePane.previewTableData(TableDataPaneSheet.this.updateBean()); +// } +// }); +// } +// }); +// +// add(TableLayoutHelper.createTableLayoutPane( +// new Component[][] {{ +// new UILabel("配置"),preview +// }}, +// new double[] { TableLayout.PREFERRED }, +// new double[] { TableLayout.FILL,TableLayout.PREFERRED } +// ),BorderLayout.NORTH); +// +// UIScrollPane loadArea = new UIScrollPane(config); +// add(loadArea, BorderLayout.CENTER); +// +// UITableModelAdapter model = new ParameterTableModel(); +// parameterTableEditorPane = new UITableEditorPane(model); +// +// add(parameterTableEditorPane,BorderLayout.SOUTH); +// } +// +// @Override +// public void populateBean(TableDataSheet data) { +// if (data == null) { +// return; +// } +// Calculator c = Calculator.createCalculator(); +// ParameterProvider[] parameters = data.getParameters(c); +// parameterTableEditorPane.populate(parameters); +// config.setText( data.getConfig() ); +// } +// +// @Override +// public TableDataSheet updateBean() { +// TableDataSheet data = new TableDataSheet(); +// data.setConfig( config.getText() ); +// java.util.List parameterProviderList = parameterTableEditorPane.update(); +// Parameter[] parameters = parameterProviderList.toArray(new Parameter[parameterProviderList.size()]); +// data.setParameters(parameters); +// return data; +// } +// +// @Override +// protected String title4PopupWindow() { +// return "飞书电子表格"; +// } +//} diff --git a/src/main/java/com/eco/plugin/shsytzfsds/biPlublicServerTable/DatasetComponent.java b/src/main/java/com/eco/plugin/shsytzfsds/biPlublicServerTable/DatasetComponent.java new file mode 100644 index 0000000..46766d9 --- /dev/null +++ b/src/main/java/com/eco/plugin/shsytzfsds/biPlublicServerTable/DatasetComponent.java @@ -0,0 +1,37 @@ +package com.eco.plugin.shsytzfsds.biPlublicServerTable; + +import com.fr.web.struct.AssembleComponent; +import com.fr.web.struct.Atom; +import com.fr.web.struct.Registry; +import com.fr.web.struct.category.ScriptPath; +import com.fr.web.struct.category.StylePath; + +/** + * @author Heng.J + * @version 6.0 + * Created by Heng.J on 2023/5/30 + */ +public class DatasetComponent extends AssembleComponent { + + public static final DatasetComponent KEY = new DatasetComponent(); + + @Override + public Atom[] refer() { + return new Atom[]{}; + } + + @Override + public ScriptPath script() { + return ScriptPath.build("com/eco/plugin/shsytzfsds/js/bi/publicds.js"); + } + + @Override + public StylePath style() { + return StylePath.build("com/eco/plugin/shsytzfsds/js/bi/publicds.css"); + } + + @Override + public Atom[] children() { + return Registry.getChildren(DatasetComponent.class); + } +} diff --git a/src/main/java/com/eco/plugin/shsytzfsds/biPlublicServerTable/DatasetProvider.java b/src/main/java/com/eco/plugin/shsytzfsds/biPlublicServerTable/DatasetProvider.java new file mode 100644 index 0000000..d72d0a1 --- /dev/null +++ b/src/main/java/com/eco/plugin/shsytzfsds/biPlublicServerTable/DatasetProvider.java @@ -0,0 +1,18 @@ +package com.eco.plugin.shsytzfsds.biPlublicServerTable; + +import com.eco.plugin.shsytzfsds.biPlublicServerTable.generator.DatasetGenerator; +import com.finebi.provider.api.dataset.datasource.AbstractCustomDatasetProvider; +import com.finebi.provider.api.dataset.datasource.CustomDatasetGenerator; + +/** + * @author wink + * @version 6.0 + * Created by wink on 2023/5/30 + */ +public class DatasetProvider extends AbstractCustomDatasetProvider { + + @Override + public CustomDatasetGenerator getGenerator() { + return new DatasetGenerator(); + } +} diff --git a/src/main/java/com/eco/plugin/shsytzfsds/biPlublicServerTable/data/feishu/DBConfig.java b/src/main/java/com/eco/plugin/shsytzfsds/biPlublicServerTable/data/feishu/DBConfig.java new file mode 100644 index 0000000..18f43a7 --- /dev/null +++ b/src/main/java/com/eco/plugin/shsytzfsds/biPlublicServerTable/data/feishu/DBConfig.java @@ -0,0 +1,26 @@ +package com.eco.plugin.shsytzfsds.biPlublicServerTable.data.feishu; + +import java.util.HashMap; +import java.util.Map; + +/** + * 用户自定义数据链接 + * + * @author Heng.J + * @version 6.0 + * Created by Heng.J on 2023/6/14 + */ +public class DBConfig { + + public static final String URL = "jdbc:mysql://localhost:3306/swift_data1?serverTimezone=Asia/Shanghai&useSSL=false"; + public static final String USER = "root"; + public static final String PASSWORD = "123456"; + + public static final Map> PARAMETER_MAP = new HashMap<>(); + + static { + PARAMETER_MAP.put("driver", String.class); + PARAMETER_MAP.put("appId", String.class); + } + +} diff --git a/src/main/java/com/eco/plugin/shsytzfsds/biPlublicServerTable/data/feishu/FeishuDatasetDatasourceGenerator.java b/src/main/java/com/eco/plugin/shsytzfsds/biPlublicServerTable/data/feishu/FeishuDatasetDatasourceGenerator.java new file mode 100644 index 0000000..e2ffcb0 --- /dev/null +++ b/src/main/java/com/eco/plugin/shsytzfsds/biPlublicServerTable/data/feishu/FeishuDatasetDatasourceGenerator.java @@ -0,0 +1,28 @@ +package com.eco.plugin.shsytzfsds.biPlublicServerTable.data.feishu; + +import com.eco.plugin.shsytzfsds.utils.DataSetUtils; +import com.finebi.cbb.api.model.RowIterator; +import com.finebi.provider.api.dataset.datasource.AbstractDefaultDatasourceGenerator; +import com.finebi.provider.api.dataset.datasource.CustomDatasetContext; +import com.fr.data.core.db.ColumnInformation; + +import java.util.Collections; +import java.util.Map; + +public class FeishuDatasetDatasourceGenerator extends AbstractDefaultDatasourceGenerator { + + @Override + public RowIterator getRowIterator(String jsonContext, CustomDatasetContext datasetContext, ColumnInformation[] columnInfos) { + return new FeishuRowIterator(jsonContext, Collections.singletonList(datasetContext), null); + } + + @Override + public Map> getParameters(String jsonContext, CustomDatasetContext datasetContext) { + return DBConfig.PARAMETER_MAP; + } + + @Override + public ColumnInformation[] createColumnInfos(String jsonContext, CustomDatasetContext datasetContext) { + return DataSetUtils.getHeader(jsonContext); + } +} diff --git a/src/main/java/com/eco/plugin/shsytzfsds/biPlublicServerTable/data/feishu/FeishuRowIterator.java b/src/main/java/com/eco/plugin/shsytzfsds/biPlublicServerTable/data/feishu/FeishuRowIterator.java new file mode 100644 index 0000000..6011dc4 --- /dev/null +++ b/src/main/java/com/eco/plugin/shsytzfsds/biPlublicServerTable/data/feishu/FeishuRowIterator.java @@ -0,0 +1,91 @@ +package com.eco.plugin.shsytzfsds.biPlublicServerTable.data.feishu; + +import com.eco.plugin.shsytzfsds.db.bean.DBEntity; +import com.eco.plugin.shsytzfsds.db.controller.DBController; +import com.eco.plugin.shsytzfsds.utils.FeiShuUtils; +import com.eco.plugin.shsytzfsds.utils.Utils; +import com.finebi.base.concurrent.ExecutorServiceFactory; +import com.finebi.cbb.api.model.RowIterator; +import com.finebi.provider.api.dataset.datasource.CustomDatasetContext; +import com.fr.data.core.db.ColumnInformation; +import com.fr.json.JSONArray; +import com.fr.json.JSONObject; + +import java.util.ArrayList; +import java.util.List; + + +public class FeishuRowIterator implements RowIterator { + + private static int count = 0; + private String jsonContexts = ""; + private static List result = new ArrayList<>(); + + public FeishuRowIterator(String jsonContexts, List datasetContexts, String sql) { + count =0; + result = new ArrayList<>(); + this.jsonContexts = jsonContexts; + JSONObject param = new JSONObject(jsonContexts); + String id = param.getString("appid"); + DBEntity feishuApp = DBController.getById(id); + String appid = feishuApp.getAppid(); + String secret = feishuApp.getSecret(); + String url = param.getString("url"); + String token = FeiShuUtils.getTenantToken(appid,secret); + JSONArray header =FeiShuUtils.getTableFields(url,token); + JSONArray dataArray = FeiShuUtils.getTableData(url,token,""); + addRowDatas(header,dataArray); + } + + private void init() { + + } + + @Override + public void open() { + + } + + @Override + public boolean hasNext() { + return count < result.size(); + } + + @Override + public Object[] next() { + int current = count; + count++; + return result.get(current); + } + + @Override + public void close() { + } + + @Override + public void cancel() { + + } + + /** + * 添加行数据 + * @param jsonArray + */ + private void addRowDatas(JSONArray header,JSONArray jsonArray) { + if(jsonArray == null || jsonArray.size() <= 0){ + return ; + } + + for(int i =0;i< jsonArray.size();i++){ + JSONObject fields = jsonArray.getJSONObject(i).getJSONObject("fields"); + Object[] rowDatas = new Object[header.length()]; + + for (int j = 0; j < header.length(); j++) { + String value = fields.getString(header.getString(j)); + rowDatas[j] = Utils.isNullStr(value) ? "" :value; + } + + result.add(rowDatas); + } + } +} diff --git a/src/main/java/com/eco/plugin/shsytzfsds/biPlublicServerTable/generator/DatasetGenerator.java b/src/main/java/com/eco/plugin/shsytzfsds/biPlublicServerTable/generator/DatasetGenerator.java new file mode 100644 index 0000000..165f984 --- /dev/null +++ b/src/main/java/com/eco/plugin/shsytzfsds/biPlublicServerTable/generator/DatasetGenerator.java @@ -0,0 +1,37 @@ +package com.eco.plugin.shsytzfsds.biPlublicServerTable.generator; + +import com.eco.plugin.shsytzfsds.biPlublicServerTable.data.feishu.FeishuDatasetDatasourceGenerator; +import com.finebi.provider.api.dataset.datasource.AbstractCustomDatasetGenerator; +import com.finebi.provider.api.dataset.datasource.CustomDatasetDatasourceGenerator; +import org.jetbrains.annotations.NotNull; + +/** + * @author wink + * @version 6.0 + * Created by wink on 2023/5/30 + */ +public class DatasetGenerator extends AbstractCustomDatasetGenerator { + + @Override + public @NotNull String getName() { + return "飞书多维表格"; + } + + /** + * 前端页面相关接口 + * @return + */ + @Override + public @NotNull DatasetPageGenerator getPageGenerator() { + return new DatasetPageGenerator(); + } + + /** + * 后端数据相关接口 + * @return + */ + @Override + public @NotNull CustomDatasetDatasourceGenerator getDatasourceGenerator() { + return new FeishuDatasetDatasourceGenerator(); + } +} diff --git a/src/main/java/com/eco/plugin/shsytzfsds/biPlublicServerTable/generator/DatasetPageGenerator.java b/src/main/java/com/eco/plugin/shsytzfsds/biPlublicServerTable/generator/DatasetPageGenerator.java new file mode 100644 index 0000000..722a9da --- /dev/null +++ b/src/main/java/com/eco/plugin/shsytzfsds/biPlublicServerTable/generator/DatasetPageGenerator.java @@ -0,0 +1,49 @@ +package com.eco.plugin.shsytzfsds.biPlublicServerTable.generator; + +import com.eco.plugin.shsytzfsds.biPlublicServerTable.DatasetComponent; +import com.finebi.provider.api.dataset.datasource.CustomDatasetContext; +import com.finebi.provider.api.dataset.datasource.CustomDatasetPageGenerator; +import com.fr.web.struct.AssembleComponent; + +/** + * @author wink + * @version 6.0 + * Created by wink on 2023/5/30 + * 前端接口 + */ +public class DatasetPageGenerator implements CustomDatasetPageGenerator { + + /** + * 图标 + * @param datasetContext + * @return + */ + @Override + public String getIcon(CustomDatasetContext datasetContext) { + return "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACkAAAAkCAYAAAAU/hMoAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAVQSURBVFhH7Zd/SF5VGMdlRARRM9dqrCCk/rEw0tH+SDebGw2KUVKSBBGNEfujNUvWP1mNigrbP80/yh+zltooJraUqe8gcOU2bTRW8/XHdGqjLZ02UzdnnnO/Pc8599z33rv7vt53GDHYA1/ur/M+z+c8z3nOvW8KrgO7AblYdv1DSliwLAv7p87j8aFOrBvuwtrhzqSUN9KFsvEhCIu8kS8tobyHtQUyKRWosOYp0CBuirYhJRohtdjHEOppJUVQPjGiACWEnrwdIYwlhGRHsdlbiEyPIbX3BwpOkBw8CMotgkvppomRbulpQ++VaQWZrIVYk1wWLpVQ+nV2Evf2EygHDwLzyExGg24Y/llnkSetnYeypBuHnQ/NXcb9p9s1RChYoxa0TI86oGEtaUgTYHjuEtJP/6gCK4AwsDQmf6iLfHBV/kNIXXoN2j83hRV9XPqQjUSlX2KvTbcZf/HMA7nQYNOZep3q8V2XL+LWXgJIouzvXRiAlLHJ+uU3D+SlKxINR/RADcMguhuD0PkeP//m73MaUoG61il3tweQnp1qReZ3EZTsOownXmlEZkE9MjbtxaqifSh8oxmffHkCfSN/OfHZPJAXpgRWFVuob2dQvW54aKJtg53x2JI/o7Etx6xTs03xke7fXN2A1KerkZpTgWW5n+PO3CrckVupjqxlOZXq/sr1VegbmrAj+CDHpyxkb5cKtOaQ3shN+jm3ftPPdNlm5TxWn+lwZdEG7D6IlK5m3LZ1rwJQUGsqHCgDyPf4Gau2OaombswDOUHrWUPqY1mjxLywQfQQj2lwfsagAj2zU2rTjgG2YUlHE5YW7nFg0tbEMsZgBjSNztNyPkPRjhb1hmO/xryQM5YCNMoqlthWITA5o39gUE12/cb3Pxwb1Nk0gM/WOHAG1C0nmwS5fG0lugfGVRx3hISQrOztFjZ9MI/oCJVfdSStVTU6oPykOSnw4MBPSOloxtKCPQqCs+SH8yvtsQq8/E7EToBJhzYP5MVpLyQDmvPVJcAXEYl/5m1Q15qJGa9jgdrBEdz+TDWtL90cDGrO3QqTRbaEkFkEmf06SV1bqvwv7qL39+9257vKbq5/iY7ioYI6BaDhYiBuQJYzCTpufveQ7U9XyN2oCSH9UtCkR0sE3t8nMTZpYAWEEKhqOIl78qnEFDTeGvSLx92VV6GyGM+SgjQZ5XMGzn1T4NMmiSMnJ/DUqweczJkODoJyizPJ44rLOuwsBpsHcnKGQKi8friY+BmVXa1VnVVeAo9sm8MDL5zC3Ru+dfZCU+4gOJZ5nll0UL1EFhHSSK9TBnQ3F++tGVvO4b6Cw1ieR5t3HEieCD9LL+xA+2/zqlkS2dWQJqB9TFaq0UhZrwlkbP4D6c8dxYqNjVi+7itSHVZubKB7nXh46wQqW3WzJUb0QfI+qbLDwXzBkxFnV0u/Ys218s2ToPOP9tNmxX/OnG6Ob75MSgcyKPi1SPuy1zL55iM3G+8GvKeabSc0pKBJPblTzzQo4LWIIc3WlbND4sAx94tAf8QsZB5I/sHgeQsv7dYZZedGOqg+V+Wzr71Z91/re6wt5RJnRjVUok+/IPNAmm2AXtFoPW6h8GMNq4JfBRYv27H7vCafL5OInKDNnr5skoUz5oVkcbepdzPNmGiP9gq8XS+R/5ZQQd2A7u1KTYK7mia1vlRi59cWjvfbzaF86gSw7zAldpsH0phx4cDSHf6w6D7Lfy8Edn8vUVproaRGkgRK6wTKmwQaj1noPWupb1DzWyXyYPypRWUDh7VAyHjmBLUVdM+txbKkIP8vuwG5OAb8C5svkz2EkBopAAAAAElFTkSuQmCC"; + } + + /** + * 配置页面根节点dom元素 + * @param datasetContext + * @return + */ + @Override + public String getEditPageHTML(CustomDatasetContext datasetContext) { + return ""; + } + + /** + * 注册组件 + * @param datasetContext + * @return + */ + @Override + public AssembleComponent getComponent(CustomDatasetContext datasetContext) { + return DatasetComponent.KEY; + } +} diff --git a/src/main/java/com/eco/plugin/shsytzfsds/biPlublicServerTable/sheet/DatasetComponent.java b/src/main/java/com/eco/plugin/shsytzfsds/biPlublicServerTable/sheet/DatasetComponent.java new file mode 100644 index 0000000..a2d9ca6 --- /dev/null +++ b/src/main/java/com/eco/plugin/shsytzfsds/biPlublicServerTable/sheet/DatasetComponent.java @@ -0,0 +1,37 @@ +package com.eco.plugin.shsytzfsds.biPlublicServerTable.sheet; + +import com.fr.web.struct.AssembleComponent; +import com.fr.web.struct.Atom; +import com.fr.web.struct.Registry; +import com.fr.web.struct.category.ScriptPath; +import com.fr.web.struct.category.StylePath; + +/** + * @author Heng.J + * @version 6.0 + * Created by Heng.J on 2023/5/30 + */ +public class DatasetComponent extends AssembleComponent { + + public static final DatasetComponent KEY = new DatasetComponent(); + + @Override + public Atom[] refer() { + return new Atom[]{}; + } + + @Override + public ScriptPath script() { + return ScriptPath.build("com/eco/plugin/shsytzfsds/js/bi/publicds.js"); + } + + @Override + public StylePath style() { + return StylePath.build("com/eco/plugin/shsytzfsds/js/bi/publicds.css"); + } + + @Override + public Atom[] children() { + return Registry.getChildren(DatasetComponent.class); + } +} diff --git a/src/main/java/com/eco/plugin/shsytzfsds/biPlublicServerTable/sheet/DatasetProvider.java b/src/main/java/com/eco/plugin/shsytzfsds/biPlublicServerTable/sheet/DatasetProvider.java new file mode 100644 index 0000000..5348d83 --- /dev/null +++ b/src/main/java/com/eco/plugin/shsytzfsds/biPlublicServerTable/sheet/DatasetProvider.java @@ -0,0 +1,18 @@ +package com.eco.plugin.shsytzfsds.biPlublicServerTable.sheet; + +import com.eco.plugin.shsytzfsds.biPlublicServerTable.sheet.generator.DatasetGenerator; +import com.finebi.provider.api.dataset.datasource.AbstractCustomDatasetProvider; +import com.finebi.provider.api.dataset.datasource.CustomDatasetGenerator; + +/** + * @author wink + * @version 6.0 + * Created by wink on 2023/5/30 + */ +public class DatasetProvider extends AbstractCustomDatasetProvider { + + @Override + public CustomDatasetGenerator getGenerator() { + return new DatasetGenerator(); + } +} diff --git a/src/main/java/com/eco/plugin/shsytzfsds/biPlublicServerTable/sheet/feishu/DBConfig.java b/src/main/java/com/eco/plugin/shsytzfsds/biPlublicServerTable/sheet/feishu/DBConfig.java new file mode 100644 index 0000000..987b2ec --- /dev/null +++ b/src/main/java/com/eco/plugin/shsytzfsds/biPlublicServerTable/sheet/feishu/DBConfig.java @@ -0,0 +1,26 @@ +package com.eco.plugin.shsytzfsds.biPlublicServerTable.sheet.feishu; + +import java.util.HashMap; +import java.util.Map; + +/** + * 用户自定义数据链接 + * + * @author Heng.J + * @version 6.0 + * Created by Heng.J on 2023/6/14 + */ +public class DBConfig { + + public static final String URL = "jdbc:mysql://localhost:3306/swift_data1?serverTimezone=Asia/Shanghai&useSSL=false"; + public static final String USER = "root"; + public static final String PASSWORD = "123456"; + + public static final Map> PARAMETER_MAP = new HashMap<>(); + + static { + PARAMETER_MAP.put("driver", String.class); + PARAMETER_MAP.put("appId", String.class); + } + +} diff --git a/src/main/java/com/eco/plugin/shsytzfsds/biPlublicServerTable/sheet/feishu/FeishuDatasetDatasourceGenerator.java b/src/main/java/com/eco/plugin/shsytzfsds/biPlublicServerTable/sheet/feishu/FeishuDatasetDatasourceGenerator.java new file mode 100644 index 0000000..6c48a39 --- /dev/null +++ b/src/main/java/com/eco/plugin/shsytzfsds/biPlublicServerTable/sheet/feishu/FeishuDatasetDatasourceGenerator.java @@ -0,0 +1,34 @@ +package com.eco.plugin.shsytzfsds.biPlublicServerTable.sheet.feishu; + +import com.eco.plugin.shsytzfsds.db.bean.DBEntity; +import com.eco.plugin.shsytzfsds.db.controller.DBController; +import com.eco.plugin.shsytzfsds.utils.DataSetUtils; +import com.eco.plugin.shsytzfsds.utils.FeiShuUtils; +import com.finebi.cbb.api.model.RowIterator; +import com.finebi.provider.api.dataset.datasource.AbstractDefaultDatasourceGenerator; +import com.finebi.provider.api.dataset.datasource.CustomDatasetContext; +import com.fr.data.core.db.ColumnInformation; +import com.fr.json.JSONArray; +import com.fr.json.JSONObject; + +import java.util.Collections; +import java.util.Map; + +public class FeishuDatasetDatasourceGenerator extends AbstractDefaultDatasourceGenerator { + + @Override + public RowIterator getRowIterator(String jsonContext, CustomDatasetContext datasetContext, ColumnInformation[] columnInfos) { + return new FeishuRowIterator(jsonContext, Collections.singletonList(datasetContext), null); + } + + @Override + public Map> getParameters(String jsonContext, CustomDatasetContext datasetContext) { + return DBConfig.PARAMETER_MAP; + } + + @Override + public ColumnInformation[] createColumnInfos(String jsonContext, CustomDatasetContext datasetContext) { + + return DataSetUtils.getSheetHeader(jsonContext); + } +} diff --git a/src/main/java/com/eco/plugin/shsytzfsds/biPlublicServerTable/sheet/feishu/FeishuRowIterator.java b/src/main/java/com/eco/plugin/shsytzfsds/biPlublicServerTable/sheet/feishu/FeishuRowIterator.java new file mode 100644 index 0000000..84a2a13 --- /dev/null +++ b/src/main/java/com/eco/plugin/shsytzfsds/biPlublicServerTable/sheet/feishu/FeishuRowIterator.java @@ -0,0 +1,100 @@ +package com.eco.plugin.shsytzfsds.biPlublicServerTable.sheet.feishu; + +import com.eco.plugin.shsytzfsds.db.bean.DBEntity; +import com.eco.plugin.shsytzfsds.db.controller.DBController; +import com.eco.plugin.shsytzfsds.utils.FeiShuUtils; +import com.eco.plugin.shsytzfsds.utils.Utils; +import com.finebi.cbb.api.model.RowIterator; +import com.finebi.provider.api.dataset.datasource.CustomDatasetContext; +import com.fr.json.JSONArray; +import com.fr.json.JSONObject; + +import java.util.ArrayList; +import java.util.List; + + +public class FeishuRowIterator implements RowIterator { + + private static int count = 0; + private String jsonContexts = ""; + private static List result = new ArrayList<>(); + + public FeishuRowIterator(String jsonContexts, List datasetContexts, String sql) { + count =0; + result = new ArrayList<>(); + this.jsonContexts = jsonContexts; + JSONObject param = new JSONObject(jsonContexts); + String id = param.getString("appid"); + String url = param.getString("url"); + String rowSelect = param.getString("rowSelect"); + int headrow = param.getInt("header"); + String colSelect = param.getString("colSelect"); + + int rowsize = rowSelect.equals("custom") ? param.getInt("rowdata"):0; + String columnSize = colSelect.equals("colcustom") ? param.getString("coldata"):""; + + DBEntity feishuApp = DBController.getById(id); + String appid = feishuApp.getAppid(); + String secret = feishuApp.getSecret(); + String token = FeiShuUtils.getTenantToken(appid,secret); + JSONArray jsonArray =FeiShuUtils.getSheetData(url,token,rowsize,columnSize,headrow,5000,0); + addRowDatas(jsonArray,headrow); + } + + private void init() { + + } + + @Override + public void open() { + + } + + @Override + public boolean hasNext() { + return count < result.size(); + } + + @Override + public Object[] next() { + int current = count; + count++; + return result.get(current); + } + + @Override + public void close() { + } + + @Override + public void cancel() { + + } + + /** + * 添加行数据 + * @param jsonArray + */ + private void addRowDatas(JSONArray jsonArray,int headerrow) { + if(jsonArray == null || jsonArray.size() <= 0){ + return ; + } + + for(int i =0;i< jsonArray.size();i++){ + if(i == 0){ + continue; + } + + JSONArray values = jsonArray.getJSONArray(i); + Object[] rowDatas = new Object[values.length()]; + + for (int j = 0; j < values.length(); j++) { + rowDatas[j] =values.getString(j); + } + + result.add(rowDatas); + } + + + } +} diff --git a/src/main/java/com/eco/plugin/shsytzfsds/biPlublicServerTable/sheet/generator/DatasetGenerator.java b/src/main/java/com/eco/plugin/shsytzfsds/biPlublicServerTable/sheet/generator/DatasetGenerator.java new file mode 100644 index 0000000..b18697e --- /dev/null +++ b/src/main/java/com/eco/plugin/shsytzfsds/biPlublicServerTable/sheet/generator/DatasetGenerator.java @@ -0,0 +1,37 @@ +package com.eco.plugin.shsytzfsds.biPlublicServerTable.sheet.generator; + +import com.eco.plugin.shsytzfsds.biPlublicServerTable.sheet.feishu.FeishuDatasetDatasourceGenerator; +import com.finebi.provider.api.dataset.datasource.AbstractCustomDatasetGenerator; +import com.finebi.provider.api.dataset.datasource.CustomDatasetDatasourceGenerator; +import org.jetbrains.annotations.NotNull; + +/** + * @author wink + * @version 6.0 + * Created by wink on 2023/5/30 + */ +public class DatasetGenerator extends AbstractCustomDatasetGenerator { + + @Override + public @NotNull String getName() { + return "飞书电子表格"; + } + + /** + * 前端页面相关接口 + * @return + */ + @Override + public @NotNull DatasetPageGenerator getPageGenerator() { + return new DatasetPageGenerator(); + } + + /** + * 后端数据相关接口 + * @return + */ + @Override + public @NotNull CustomDatasetDatasourceGenerator getDatasourceGenerator() { + return new FeishuDatasetDatasourceGenerator(); + } +} diff --git a/src/main/java/com/eco/plugin/shsytzfsds/biPlublicServerTable/sheet/generator/DatasetPageGenerator.java b/src/main/java/com/eco/plugin/shsytzfsds/biPlublicServerTable/sheet/generator/DatasetPageGenerator.java new file mode 100644 index 0000000..dfe3564 --- /dev/null +++ b/src/main/java/com/eco/plugin/shsytzfsds/biPlublicServerTable/sheet/generator/DatasetPageGenerator.java @@ -0,0 +1,49 @@ +package com.eco.plugin.shsytzfsds.biPlublicServerTable.sheet.generator; + +import com.eco.plugin.shsytzfsds.biPlublicServerTable.sheet.DatasetComponent; +import com.finebi.provider.api.dataset.datasource.CustomDatasetContext; +import com.finebi.provider.api.dataset.datasource.CustomDatasetPageGenerator; +import com.fr.web.struct.AssembleComponent; + +/** + * @author wink + * @version 6.0 + * Created by wink on 2023/5/30 + * 前端接口 + */ +public class DatasetPageGenerator implements CustomDatasetPageGenerator { + + /** + * 图标 + * @param datasetContext + * @return + */ + @Override + public String getIcon(CustomDatasetContext datasetContext) { + return "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACkAAAAkCAYAAAAU/hMoAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAVQSURBVFhH7Zd/SF5VGMdlRARRM9dqrCCk/rEw0tH+SDebGw2KUVKSBBGNEfujNUvWP1mNigrbP80/yh+zltooJraUqe8gcOU2bTRW8/XHdGqjLZ02UzdnnnO/Pc8599z33rv7vt53GDHYA1/ur/M+z+c8z3nOvW8KrgO7AblYdv1DSliwLAv7p87j8aFOrBvuwtrhzqSUN9KFsvEhCIu8kS8tobyHtQUyKRWosOYp0CBuirYhJRohtdjHEOppJUVQPjGiACWEnrwdIYwlhGRHsdlbiEyPIbX3BwpOkBw8CMotgkvppomRbulpQ++VaQWZrIVYk1wWLpVQ+nV2Evf2EygHDwLzyExGg24Y/llnkSetnYeypBuHnQ/NXcb9p9s1RChYoxa0TI86oGEtaUgTYHjuEtJP/6gCK4AwsDQmf6iLfHBV/kNIXXoN2j83hRV9XPqQjUSlX2KvTbcZf/HMA7nQYNOZep3q8V2XL+LWXgJIouzvXRiAlLHJ+uU3D+SlKxINR/RADcMguhuD0PkeP//m73MaUoG61il3tweQnp1qReZ3EZTsOownXmlEZkE9MjbtxaqifSh8oxmffHkCfSN/OfHZPJAXpgRWFVuob2dQvW54aKJtg53x2JI/o7Etx6xTs03xke7fXN2A1KerkZpTgWW5n+PO3CrckVupjqxlOZXq/sr1VegbmrAj+CDHpyxkb5cKtOaQ3shN+jm3ftPPdNlm5TxWn+lwZdEG7D6IlK5m3LZ1rwJQUGsqHCgDyPf4Gau2OaombswDOUHrWUPqY1mjxLywQfQQj2lwfsagAj2zU2rTjgG2YUlHE5YW7nFg0tbEMsZgBjSNztNyPkPRjhb1hmO/xryQM5YCNMoqlthWITA5o39gUE12/cb3Pxwb1Nk0gM/WOHAG1C0nmwS5fG0lugfGVRx3hISQrOztFjZ9MI/oCJVfdSStVTU6oPykOSnw4MBPSOloxtKCPQqCs+SH8yvtsQq8/E7EToBJhzYP5MVpLyQDmvPVJcAXEYl/5m1Q15qJGa9jgdrBEdz+TDWtL90cDGrO3QqTRbaEkFkEmf06SV1bqvwv7qL39+9257vKbq5/iY7ioYI6BaDhYiBuQJYzCTpufveQ7U9XyN2oCSH9UtCkR0sE3t8nMTZpYAWEEKhqOIl78qnEFDTeGvSLx92VV6GyGM+SgjQZ5XMGzn1T4NMmiSMnJ/DUqweczJkODoJyizPJ44rLOuwsBpsHcnKGQKi8friY+BmVXa1VnVVeAo9sm8MDL5zC3Ru+dfZCU+4gOJZ5nll0UL1EFhHSSK9TBnQ3F++tGVvO4b6Cw1ieR5t3HEieCD9LL+xA+2/zqlkS2dWQJqB9TFaq0UhZrwlkbP4D6c8dxYqNjVi+7itSHVZubKB7nXh46wQqW3WzJUb0QfI+qbLDwXzBkxFnV0u/Ys218s2ToPOP9tNmxX/OnG6Ob75MSgcyKPi1SPuy1zL55iM3G+8GvKeabSc0pKBJPblTzzQo4LWIIc3WlbND4sAx94tAf8QsZB5I/sHgeQsv7dYZZedGOqg+V+Wzr71Z91/re6wt5RJnRjVUok+/IPNAmm2AXtFoPW6h8GMNq4JfBRYv27H7vCafL5OInKDNnr5skoUz5oVkcbepdzPNmGiP9gq8XS+R/5ZQQd2A7u1KTYK7mia1vlRi59cWjvfbzaF86gSw7zAldpsH0phx4cDSHf6w6D7Lfy8Edn8vUVproaRGkgRK6wTKmwQaj1noPWupb1DzWyXyYPypRWUDh7VAyHjmBLUVdM+txbKkIP8vuwG5OAb8C5svkz2EkBopAAAAAElFTkSuQmCC"; + } + + /** + * 配置页面根节点dom元素 + * @param datasetContext + * @return + */ + @Override + public String getEditPageHTML(CustomDatasetContext datasetContext) { + return ""; + } + + /** + * 注册组件 + * @param datasetContext + * @return + */ + @Override + public AssembleComponent getComponent(CustomDatasetContext datasetContext) { + return DatasetComponent.KEY; + } +} diff --git a/src/main/java/com/eco/plugin/shsytzfsds/constants/Result.java b/src/main/java/com/eco/plugin/shsytzfsds/constants/Result.java new file mode 100644 index 0000000..38466e9 --- /dev/null +++ b/src/main/java/com/eco/plugin/shsytzfsds/constants/Result.java @@ -0,0 +1,9 @@ +package com.eco.plugin.shsytzfsds.constants; + +public class Result { + public static String paramNotNull= "必填参数不能为空"; + + public static String needLogin= "请先登录"; + + public static String validateFail = "鉴权失败"; +} diff --git a/src/main/java/com/eco/plugin/shsytzfsds/controller/ControllerRegisterProvider.java b/src/main/java/com/eco/plugin/shsytzfsds/controller/ControllerRegisterProvider.java new file mode 100644 index 0000000..d1697fe --- /dev/null +++ b/src/main/java/com/eco/plugin/shsytzfsds/controller/ControllerRegisterProvider.java @@ -0,0 +1,20 @@ +package com.eco.plugin.shsytzfsds.controller; + +import com.fr.decision.fun.impl.AbstractControllerRegisterProvider; +import com.fr.plugin.context.PluginContexts; +import com.fr.stable.fun.Authorize; + +@Authorize(callSignKey = "com.eco.plugin.shsytzfsds") +public class ControllerRegisterProvider extends AbstractControllerRegisterProvider { + @Override + public Class[] getControllers() { + + if(!PluginContexts.currentContext().isAvailable()) { + return new Class[]{}; + } + + return new Class[]{ + ControllerSelf.class + }; + } +} diff --git a/src/main/java/com/eco/plugin/shsytzfsds/controller/ControllerSelf.java b/src/main/java/com/eco/plugin/shsytzfsds/controller/ControllerSelf.java new file mode 100644 index 0000000..8e4bdfd --- /dev/null +++ b/src/main/java/com/eco/plugin/shsytzfsds/controller/ControllerSelf.java @@ -0,0 +1,255 @@ +package com.eco.plugin.shsytzfsds.controller; + +import com.eco.plugin.shsytzfsds.constants.Result; +import com.eco.plugin.shsytzfsds.db.bean.DBEntity; +import com.eco.plugin.shsytzfsds.db.controller.DBController; +import com.eco.plugin.shsytzfsds.utils.FRUtils; +import com.eco.plugin.shsytzfsds.utils.FeiShuUtils; +import com.eco.plugin.shsytzfsds.utils.ResponseUtils; +import com.eco.plugin.shsytzfsds.utils.Utils; +import com.finebi.web.action.v5.conf.FineExportAction; +import com.fr.decision.webservice.annotation.LoginStatusChecker; +import com.fr.json.JSONArray; +import com.fr.json.JSONObject; +import com.fr.plugin.transform.FunctionRecorder; +import com.fr.third.springframework.stereotype.Controller; +import com.fr.third.springframework.web.bind.annotation.GetMapping; +import com.fr.third.springframework.web.bind.annotation.PostMapping; +import com.fr.third.springframework.web.bind.annotation.ResponseBody; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; + +@Controller +@LoginStatusChecker(required = false) +@FunctionRecorder +public class ControllerSelf { + + @GetMapping(value = "/fsds/getAllPage") + @ResponseBody + public void getAllPage(HttpServletRequest req,HttpServletResponse res){ + try { + validateLogin(req,res); + } catch (Exception e) { + e.printStackTrace(); + return; + } + + List all = DBController.getAllPage(); + JSONArray allJson = JSONArray.create(all); + ResponseUtils.successResponse(res,allJson.toString()); + } + + @GetMapping(value = "/fsds/getAll") + @ResponseBody + public void getAll(HttpServletRequest req,HttpServletResponse res){ + try { + validateLogin(req,res); + } catch (Exception e) { + e.printStackTrace(); + return; + } + + List all = DBController.getAll(); + JSONArray allJson = JSONArray.create(all); + ResponseUtils.successResponse(res,allJson.toString()); + } + + @GetMapping(value = "/fsds/getById") + @ResponseBody + public void getById(HttpServletRequest req,HttpServletResponse res){ + try { + validateLogin(req,res); + } catch (Exception e) { + e.printStackTrace(); + return; + } + String id = req.getParameter("id"); + DBEntity dbEntity = DBController.getById(id); + JSONObject entityJson = JSONObject.mapFrom(dbEntity); + ResponseUtils.successResponse(res,entityJson.toString()); + } + + @PostMapping(value = "/fsds/add") + @ResponseBody + public void add(HttpServletRequest req,HttpServletResponse res){ + try { + validateLogin(req,res); + } catch (Exception e) { + e.printStackTrace(); + return; + } + + JSONObject param = Utils.getRequestBody(req); + DBEntity entity = param.mapTo(DBEntity.class); + + entity.setId(entity.getAppid()); + boolean result = DBController.single(entity,null); + + if(result){ + ResponseUtils.successResponse(res,"添加成功"); + }else{ + ResponseUtils.failedResponse(res,"添加失败"); + } + } + + @PostMapping(value = "/fsds/update") + @ResponseBody + public void update(HttpServletRequest req,HttpServletResponse res){ + try { + validateLogin(req,res); + } catch (Exception e) { + e.printStackTrace(); + return; + } + + JSONObject param = Utils.getRequestBody(req); + DBEntity entity = param.mapTo(DBEntity.class); + + boolean result = DBController.single(entity,null); + + if(result){ + ResponseUtils.successResponse(res,"修改成功"); + }else{ + ResponseUtils.failedResponse(res,"修改失败"); + } + } + + @PostMapping(value = "/fsds/delete") + @ResponseBody + public void delete(HttpServletRequest req,HttpServletResponse res){ + try { + validateLogin(req,res); + } catch (Exception e) { + e.printStackTrace(); + return; + } + + JSONObject param = Utils.getRequestBody(req); + String ids = param.getString("id"); + String[] idarray = ids.split(","); + boolean result = false; + + for (int i = 0; i < idarray.length; i++) { + String id = idarray[i]; + DBEntity entity = new DBEntity(); + entity.setId(id); + result = DBController.single(null,entity); + } + + if(result){ + ResponseUtils.successResponse(res,"删除成功"); + }else{ + ResponseUtils.failedResponse(res,"删除失败"); + } + } + + @PostMapping(value = "/fsds/getDWB") + @ResponseBody + public void getDWB(HttpServletRequest req,HttpServletResponse res){ + try { + validateLogin(req,res); + } catch (Exception e) { + e.printStackTrace(); + return; + } + JSONObject param = Utils.getRequestBody(req); + JSONObject result = new JSONObject(); + String id = param.getString("appid"); + String url = param.getString("url"); + DBEntity feishuApp = DBController.getById(id); + String appid = feishuApp.getAppid(); + String secret = feishuApp.getSecret(); + String token = FeiShuUtils.getTenantToken(appid,secret); + JSONArray array =FeiShuUtils.getTableFields(url,token); + + result.put("header",array); + + JSONArray dataArray = FeiShuUtils.getTableData(url,token,""); + result.put("data",dataArray); + + ResponseUtils.successResponse(res,result.toString()); + } + + @PostMapping(value = "/fsds/getSheet") + @ResponseBody + public void getSheet(HttpServletRequest req,HttpServletResponse res){ + try { + validateLogin(req,res); + } catch (Exception e) { + e.printStackTrace(); + return; + } + JSONObject param = Utils.getRequestBody(req); + String id = param.getString("appid"); + String url = param.getString("url"); + String rowSelect = param.getString("rowSelect"); + int headrow = param.getInt("headrow"); + String colSelect = param.getString("colSelect"); + + int rowsize = rowSelect.equals("custom") ? param.getInt("rowdata"):0; + String columnSize = colSelect.equals("colcustom") ? param.getString("coldata"):""; + + DBEntity feishuApp = DBController.getById(id); + String appid = feishuApp.getAppid(); + String secret = feishuApp.getSecret(); + String token = FeiShuUtils.getTenantToken(appid,secret); + JSONArray jsonArray =FeiShuUtils.getSheetData(url,token,rowsize,columnSize,headrow,5000,0); + + JSONArray dataHeader = new JSONArray(); + JSONArray datas = new JSONArray(); + JSONObject data = new JSONObject(); + for(int i =0;i< jsonArray.size();i++){ + JSONArray values = jsonArray.getJSONArray(i); + List rowDatas = new ArrayList(); + data = new JSONObject(); + + for (int j = 0; j < values.length(); j++) { + + if(i == 0){ + JSONObject header = new JSONObject(); + String str =headrow > 0 ? values.getString(j) : String.valueOf(j); + str = Utils.replaceNullStr(str,String.valueOf(j)); + header.put("field",str); + header.put("title",str); + dataHeader.add(header); + } + + + String field =dataHeader.getJSONObject(j).getString("field"); + String value = values.getString(j); + data.put(field,Utils.isNullStr(value) ? "" : value); + } + + if(i ==0 && headrow > 0){ + continue; + } + + datas.add(data); + } + + JSONObject result = new JSONObject(); + result.put("header",dataHeader); + result.put("data",datas); + + ResponseUtils.successResponse(res,result.toString()); + } + + /** + * 判断是否登陆 + * @param req + * @param res + * @throws Exception + */ + private void validateLogin(HttpServletRequest req,HttpServletResponse res) throws Exception { + boolean isLogin = FRUtils.isLogin(req); + + if(!isLogin){ + ResponseUtils.failedResponse(res, Result.needLogin); + throw new Exception("needLogin"); + } + } +} diff --git a/src/main/java/com/eco/plugin/shsytzfsds/db/bean/DBEntity.java b/src/main/java/com/eco/plugin/shsytzfsds/db/bean/DBEntity.java new file mode 100644 index 0000000..ca0e593 --- /dev/null +++ b/src/main/java/com/eco/plugin/shsytzfsds/db/bean/DBEntity.java @@ -0,0 +1,73 @@ +package com.eco.plugin.shsytzfsds.db.bean; + +import com.fr.stable.db.entity.BaseEntity; +import com.fr.stable.db.entity.TableAssociation; +import com.fr.third.javax.persistence.Column; +import com.fr.third.javax.persistence.Entity; +import com.fr.third.javax.persistence.Table; + +/** + * @author wink + * @version 10.0 + * Created by wink on 2021-07-29 + **/ +@Entity +@Table(name = "plugin_entity_fs") +@TableAssociation(associated = true) +public class DBEntity extends BaseEntity { + + @Column(name = "appname") + private String appname = null; + + @Column(name = "appid") + private String appid = null; + + @Column(name = "secret") + private String secret = null; + + @Column(name = "enable") + private Boolean enable = null; + + @Column(name = "describtion") + private String describtion = null; + + public String getAppname() { + return appname; + } + + public void setAppname(String appname) { + this.appname = appname; + } + + public String getAppid() { + return appid; + } + + public void setAppid(String appid) { + this.appid = appid; + } + + public String getSecret() { + return secret; + } + + public void setSecret(String secret) { + this.secret = secret; + } + + public Boolean getEnable() { + return enable; + } + + public void setEnable(Boolean enable) { + this.enable = enable; + } + + public String getDescribtion() { + return describtion; + } + + public void setDescribtion(String describtion) { + this.describtion = describtion; + } +} diff --git a/src/main/java/com/eco/plugin/shsytzfsds/db/controller/DBController.java b/src/main/java/com/eco/plugin/shsytzfsds/db/controller/DBController.java new file mode 100644 index 0000000..a17f8c5 --- /dev/null +++ b/src/main/java/com/eco/plugin/shsytzfsds/db/controller/DBController.java @@ -0,0 +1,153 @@ +package com.eco.plugin.shsytzfsds.db.controller; + +import com.eco.plugin.shsytzfsds.db.bean.DBEntity; +import com.eco.plugin.shsytzfsds.db.dao.DBDao; +import com.eco.plugin.shsytzfsds.utils.FRUtils; +import com.fr.db.fun.impl.AbstractDBAccessProvider; +import com.fr.plugin.transform.FunctionRecorder; +import com.fr.record.analyzer.EnableMetrics; +import com.fr.stable.db.accessor.DBAccessor; +import com.fr.stable.db.action.DBAction; +import com.fr.stable.db.dao.DAOContext; +import com.fr.stable.db.dao.DAOProvider; + +import java.util.ArrayList; +import java.util.List; + +/** + * @author wink + * @version 10.0 + * Created by wink on 2021-07-29 + **/ +@EnableMetrics +@FunctionRecorder +public class DBController extends AbstractDBAccessProvider { + + private static DBAccessor accessor; + + public static DBAccessor getAccessor() { + return accessor; + } + + @Override + public DAOProvider[] registerDAO() { + return new DAOProvider[]{ + DBDao.DAO + }; + } + + @Override + public void onDBAvailable(DBAccessor accessor) { + DBController.accessor = accessor; + } + + /** + * 单个操作 + * @param addOrUpdate + * @param delete + * @return + */ + public static boolean single(DBEntity addOrUpdate,DBEntity delete){ + //新增或者删除 + if(addOrUpdate != null ){ + try{ + accessor.runDMLAction(new DBAction() { + @Override + public Boolean run(DAOContext context) throws Exception { + DBEntity ae =context.getDAO(DBDao.class).getById(addOrUpdate.getId()); + if(ae != null ){ + context.getDAO(DBDao.class).update(addOrUpdate); + }else{ + context.getDAO(DBDao.class).add(addOrUpdate); + } + return true; + } + }); + }catch(Throwable e){ + FRUtils.FRLogError("single addOrUpdate exception ->"+e.getMessage() + addOrUpdate.toString()); + } + } + + if(delete != null ){ + try{ + accessor.runDMLAction(new DBAction() { + @Override + public Boolean run(DAOContext context) throws Exception { + context.getDAO(DBDao.class).remove(delete.getId()); + return true; + } + }); + }catch(Throwable e){ + FRUtils.FRLogError("single delete exception ->"+e.getMessage() + delete.toString()); + } + } + + return true; + } + + /** + * 根据id获取信息 + * @param id + * @return + */ + public static DBEntity getById(final String id){ + try{ + return accessor.runQueryAction(new DBAction() { + @Override + public DBEntity run(DAOContext context) throws Exception { + DBEntity result = context.getDAO(DBDao.class).getById(id); + + return result == null ? new DBEntity() : result; + } + }); + }catch(Throwable e){ + FRUtils.FRLogError("exception getByUsername:"+e.getMessage()); + } + + return new DBEntity(); + } + + /** + * 获取全部信息 + * @param + * @return + */ + public static List getAll(){ + try{ + return accessor.runQueryAction(new DBAction>() { + @Override + public List run(DAOContext context) throws Exception { + List result = context.getDAO(DBDao.class).getAll(); + + return result == null ? new ArrayList<>() : result; + } + }); + }catch(Throwable e){ + FRUtils.FRLogError("exception getById:"+e.getMessage()); + } + + return new ArrayList<>(); + } + + /** + * 获取全部信息 + * @param + * @return + */ + public static List getAllPage(){ + try{ + return accessor.runQueryAction(new DBAction>() { + @Override + public List run(DAOContext context) throws Exception { + List result = context.getDAO(DBDao.class).getAllPage(); + + return result == null ? new ArrayList<>() : result; + } + }); + }catch(Throwable e){ + FRUtils.FRLogError("exception getById:"+e.getMessage()); + } + + return new ArrayList<>(); + } +} diff --git a/src/main/java/com/eco/plugin/shsytzfsds/db/dao/DBDao.java b/src/main/java/com/eco/plugin/shsytzfsds/db/dao/DBDao.java new file mode 100644 index 0000000..592d2bd --- /dev/null +++ b/src/main/java/com/eco/plugin/shsytzfsds/db/dao/DBDao.java @@ -0,0 +1,66 @@ +package com.eco.plugin.shsytzfsds.db.dao; + +import com.eco.plugin.shsytzfsds.db.bean.DBEntity; +import com.fr.stable.db.dao.BaseDAO; +import com.fr.stable.db.dao.DAOProvider; +import com.fr.stable.db.session.DAOSession; +import com.fr.stable.query.QueryFactory; +import com.fr.stable.query.condition.QueryCondition; +import com.fr.stable.query.restriction.RestrictionFactory; + +import java.util.List; + +/** + * @author wink + * @version 10.0 + * Created by wink on 2021-12-03 + **/ +public class DBDao extends BaseDAO { + + public DBDao(DAOSession session) { + super(session); + } + + @Override + protected Class getEntityClass() { + return DBEntity.class; + } + + public final static DAOProvider DAO = new DAOProvider() { + @Override + public Class getEntityClass() { + return DBEntity.class; + } + + @Override + public Class getDAOClass() { + return DBDao.class; + } + }; + + public void add(DBEntity entity) throws Exception { + getSession().persist(entity); + } + + public void remove(String id) throws Exception { + getSession().remove(QueryFactory.create() + .addRestriction(RestrictionFactory.eq("id", id)), + this.getEntityClass()); + } + + public void update(DBEntity entity) throws Exception { + getSession().merge(entity); + } + + public List getAll()throws Exception{ + QueryCondition condition = QueryFactory.create() + .addRestriction(RestrictionFactory.like("appname", "")); + return find(condition); + } + + public List getAllPage()throws Exception{ + QueryCondition condition = QueryFactory.create() + .addRestriction(RestrictionFactory.like("appname", "")); + return find(condition); + } +} diff --git a/src/main/java/com/eco/plugin/shsytzfsds/univalsalServerTable/DataModel.java b/src/main/java/com/eco/plugin/shsytzfsds/univalsalServerTable/DataModel.java new file mode 100644 index 0000000..ed07657 --- /dev/null +++ b/src/main/java/com/eco/plugin/shsytzfsds/univalsalServerTable/DataModel.java @@ -0,0 +1,144 @@ +package com.eco.plugin.shsytzfsds.univalsalServerTable; + + +import com.eco.plugin.shsytzfsds.db.bean.DBEntity; +import com.eco.plugin.shsytzfsds.db.controller.DBController; +import com.eco.plugin.shsytzfsds.utils.FRUtils; +import com.eco.plugin.shsytzfsds.utils.FeiShuUtils; +import com.fr.data.AbstractDataModel; +import com.fr.general.data.TableDataException; +import com.fr.json.JSONArray; +import com.fr.json.JSONObject; +import com.fr.script.Calculator; +import com.fr.stable.ParameterProvider; + +import java.util.ArrayList; +import java.util.List; + +/** + * @author 秃破天际 + * @version 10.0 + * Created by 秃破天际 on 2021-03-29 + **/ +public class DataModel extends AbstractDataModel { + + private String config; + private ParameterProvider[] parameters; + + //表头 + private static String[] dataHeader = {}; + + //表数据 + private List> datas = new ArrayList<>(); + + public DataModel(Calculator calculator, ParameterProvider[] parameters, String config){ + this.parameters = parameters; + this.config = config; + try { + queryData(); + } catch (Exception e) { + e.printStackTrace(); + FRUtils.FRLogInfo("获取数据异常:"+e.getMessage()); + } + } + + @Override + public int getColumnCount() throws TableDataException { + return dataHeader.length; + } + + @Override + public String getColumnName(int colIdx) throws TableDataException { + return dataHeader[colIdx]; + } + + @Override + public int getRowCount() throws TableDataException { + if (this.datas == null) { + return 0; + } + + if (datas == null) { + return 0; + } + int count = datas.size(); + return count; + } + + @Override + public Object getValueAt(int rowIdx, int colIdx) throws TableDataException { + if (this.datas == null) { + return ""; + } + + if ((datas == null) || (datas.size() <= rowIdx)) { + return ""; + } + List rowValues = datas.get(rowIdx); + if ((rowValues == null) || (rowValues.size() <= colIdx)) { + return ""; + } + return rowValues.get(colIdx); + } + + @Override + public void release() throws Exception { + parameters = null; + config = null; + } + + //----------------------------------------------------------------------------以下为获取数据的的逻辑 + /** + * 查询数据 + */ + private void queryData() throws Exception { + String feishuid = ""; + String url = ""; + for (ParameterProvider pv : this.parameters){ + if(pv.getName().equals("appid")){ + feishuid = String.valueOf(pv.getValue()); + } + + if(pv.getName().equals("url")){ + url = String.valueOf(pv.getValue()); + } + } + + DBEntity feishuApp = DBController.getById(feishuid); + String appid = feishuApp.getAppid(); + String secret = feishuApp.getSecret(); + String token = FeiShuUtils.getTenantToken(appid,secret); + JSONArray array =FeiShuUtils.getTableFields(url,token); + dataHeader = new String[array.length()]; + for (int i = 0; i < array.length(); i++) { + dataHeader[i] = array.getString(i); + } + + JSONArray dataArray = FeiShuUtils.getTableData(url,token,""); + addRowDatas(dataArray); + } + + + /** + * 添加行数据 + * @param jsonArray + */ + private void addRowDatas(JSONArray jsonArray) { + if(jsonArray == null || jsonArray.size() <= 0){ + return ; + } + + for(int i =0;i< jsonArray.size();i++){ + JSONObject fields = jsonArray.getJSONObject(i).getJSONObject("fields"); + List rowDatas = new ArrayList(); + + for(String header : dataHeader){ + rowDatas.add(fields.getString(header)); + } + + datas.add(rowDatas); + } + + + } +} diff --git a/src/main/java/com/eco/plugin/shsytzfsds/univalsalServerTable/DataModelSheet.java b/src/main/java/com/eco/plugin/shsytzfsds/univalsalServerTable/DataModelSheet.java new file mode 100644 index 0000000..16c342a --- /dev/null +++ b/src/main/java/com/eco/plugin/shsytzfsds/univalsalServerTable/DataModelSheet.java @@ -0,0 +1,169 @@ +package com.eco.plugin.shsytzfsds.univalsalServerTable; + + +import com.eco.plugin.shsytzfsds.db.bean.DBEntity; +import com.eco.plugin.shsytzfsds.db.controller.DBController; +import com.eco.plugin.shsytzfsds.utils.FRUtils; +import com.eco.plugin.shsytzfsds.utils.FeiShuUtils; +import com.eco.plugin.shsytzfsds.utils.Utils; +import com.fr.data.AbstractDataModel; +import com.fr.general.data.TableDataException; +import com.fr.json.JSONArray; +import com.fr.script.Calculator; +import com.fr.stable.ParameterProvider; + +import java.util.ArrayList; +import java.util.List; + + +public class DataModelSheet extends AbstractDataModel { + + private String config; + private ParameterProvider[] parameters; + + //表头 + private static String[] dataHeader = new String[0]; + + //表数据 + private List> datas = new ArrayList<>(); + + public DataModelSheet(Calculator calculator, ParameterProvider[] parameters, String config){ + this.parameters = parameters; + this.config = config; + try { + queryData(); + } catch (Exception e) { + e.printStackTrace(); + FRUtils.FRLogInfo("获取数据异常:"+e.getMessage()); + } + } + + @Override + public int getColumnCount() throws TableDataException { + return dataHeader.length; + } + + @Override + public String getColumnName(int colIdx) throws TableDataException { + return dataHeader[colIdx]; + } + + @Override + public int getRowCount() throws TableDataException { + if (this.datas == null) { + return 0; + } + + if (datas == null) { + return 0; + } + int count = datas.size(); + return count; + } + + @Override + public Object getValueAt(int rowIdx, int colIdx) throws TableDataException { + if (this.datas == null) { + return ""; + } + + if ((datas == null) || (datas.size() <= rowIdx)) { + return ""; + } + List rowValues = datas.get(rowIdx); + if ((rowValues == null) || (rowValues.size() <= colIdx)) { + return ""; + } + return rowValues.get(colIdx); + } + + @Override + public void release() throws Exception { + parameters = null; + config = null; + } + + //----------------------------------------------------------------------------以下为获取数据的的逻辑 + /** + * 查询数据 + */ + private void queryData() throws Exception { + String feishuid = ""; + String url = ""; + int headrow = 0; + int rowsize = 0; + String columnSize = ""; + for (ParameterProvider pv : this.parameters){ + if(pv.getName().equals("appid")){ + feishuid = String.valueOf(pv.getValue()); + } + + if(pv.getName().equals("url")){ + url = String.valueOf(pv.getValue()); + } + + if(pv.getName().equals("headrow")){ + String value =String.valueOf(pv.getValue()); + if(Utils.isNullStr(value)){ + value = "0"; + } + headrow = Integer.valueOf(value); + if(headrow < 0){ + headrow = 0; + } + } + + if(pv.getName().equals("rowsize")){ + rowsize = Integer.valueOf(String.valueOf(pv.getValue())); + } + + if(pv.getName().equals("columnSize")){ + columnSize = String.valueOf(pv.getValue()); + } + + } + + DBEntity feishuApp = DBController.getById(feishuid); + String appid = feishuApp.getAppid(); + String secret = feishuApp.getSecret(); + String token = FeiShuUtils.getTenantToken(appid,secret); + JSONArray array =FeiShuUtils.getSheetData(url,token,rowsize,columnSize,headrow,5000,0); + addRowDatas(array,headrow); + } + + + /** + * 添加行数据 + * @param jsonArray + */ + private void addRowDatas(JSONArray jsonArray,int headerrow) { + if(jsonArray == null || jsonArray.size() <= 0){ + return ; + } + + for(int i =0;i< jsonArray.size();i++){ + JSONArray values = jsonArray.getJSONArray(i); + List rowDatas = new ArrayList(); + + for (int j = 0; j < values.length(); j++) { + + if(i == 0){ + if(j == 0){ + dataHeader = new String[values.length()]; + } + + dataHeader[j] = headerrow > 0 ? values.getString(j) : String.valueOf(j); + } + + rowDatas.add(values.getString(j)); + } + + if(i ==0 && headerrow > 0){ + continue; + } + datas.add(rowDatas); + } + + + } +} diff --git a/src/main/java/com/eco/plugin/shsytzfsds/univalsalServerTable/TableData.java b/src/main/java/com/eco/plugin/shsytzfsds/univalsalServerTable/TableData.java new file mode 100644 index 0000000..74ff852 --- /dev/null +++ b/src/main/java/com/eco/plugin/shsytzfsds/univalsalServerTable/TableData.java @@ -0,0 +1,58 @@ +package com.eco.plugin.shsytzfsds.univalsalServerTable; + +import com.fr.config.holder.Conf; +import com.fr.config.holder.factory.Holders; +import com.fr.data.AbstractParameterTableData; +import com.fr.general.xml.GeneralXMLTools; +import com.fr.script.Calculator; +import com.fr.stable.EncodeConstants; +import com.fr.stable.StringUtils; +import com.fr.stable.xml.XMLPrintWriter; +import com.fr.stable.xml.XMLableReader; + +public class TableData extends AbstractParameterTableData { + /** + * 自定义一些配置 + */ + private Conf config = Holders.simple(StringUtils.EMPTY); + + public String getConfig() { + return config.get(); + } + + public void setConfig( String config) { + this.config.set(config); + } + + @Override + public DataModel createDataModel(Calculator calculator) { + return new DataModel( calculator, + Calculator.processParameters(calculator,super.getParameters(calculator)), + getConfig() ); + } + + @Override + public void readXML(XMLableReader reader) { + super.readXML(reader); + if (reader.isChildNode()){ + if ("Attributes".equals(reader.getTagName())) { + try{ + String conf = new String(GeneralXMLTools.readByteArray(reader), EncodeConstants.ENCODING_UTF_8); + setConfig(conf); + }catch(Exception e){ + setConfig(StringUtils.EMPTY); + } + } + } + } + + @Override + public void writeXML(XMLPrintWriter writer) { + super.writeXML(writer); + writer.startTAG("Attributes"); + try{ + GeneralXMLTools.writeByteArray(writer, getConfig().getBytes(EncodeConstants.ENCODING_UTF_8)); + }catch(Exception e){} + writer.end(); + } +} diff --git a/src/main/java/com/eco/plugin/shsytzfsds/univalsalServerTable/TableDataBean.java b/src/main/java/com/eco/plugin/shsytzfsds/univalsalServerTable/TableDataBean.java new file mode 100644 index 0000000..24a8deb --- /dev/null +++ b/src/main/java/com/eco/plugin/shsytzfsds/univalsalServerTable/TableDataBean.java @@ -0,0 +1,63 @@ +package com.eco.plugin.shsytzfsds.univalsalServerTable; + +import com.fr.decision.webservice.bean.BaseBean; +import com.fr.decision.webservice.bean.dataset.ParameterBean; +import com.fr.stable.StringUtils; + +import java.util.ArrayList; +import java.util.List; + +/** + * @author wink + * @version 10.0 + * Created by wink on 2022-11-07 + **/ +public class TableDataBean extends BaseBean { + private List parameters = new ArrayList(); + private String config; + + public List getParameters() { + return parameters; + } + + public void setParameters(List parameters) { + this.parameters = parameters; + } + + public String getConfig() { + return config; + } + + public void setConfig(String config) { + this.config = config; + } + + @Override + public boolean equals(Object o){ + return o instanceof TableDataBean + && StringUtils.equals(((TableDataBean)o).config, config) + && isSameParameter(((TableDataBean)o).parameters); + } + + private boolean isSameParameter(List parameters){ + if( null == parameters && null != this.parameters ){ + return false; + } + if( null != parameters && null == this.parameters ){ + return false; + } + if( parameters.size() != this.parameters.size() ){ + return false; + } + for( int i=0,len= parameters.size();i parameters = new ArrayList(); + private String config; + + public List getParameters() { + return parameters; + } + + public void setParameters(List parameters) { + this.parameters = parameters; + } + + public String getConfig() { + return config; + } + + public void setConfig(String config) { + this.config = config; + } + + @Override + public boolean equals(Object o){ + return o instanceof TableDataBeanSheet + && StringUtils.equals(((TableDataBeanSheet)o).config, config) + && isSameParameter(((TableDataBeanSheet)o).parameters); + } + + private boolean isSameParameter(List parameters){ + if( null == parameters && null != this.parameters ){ + return false; + } + if( null != parameters && null == this.parameters ){ + return false; + } + if( parameters.size() != this.parameters.size() ){ + return false; + } + for( int i=0,len= parameters.size();i config = Holders.simple(StringUtils.EMPTY); + + public String getConfig() { + return config.get(); + } + + public void setConfig( String config) { + this.config.set(config); + } + + @Override + public DataModelSheet createDataModel(Calculator calculator) { + return new DataModelSheet( calculator, + Calculator.processParameters(calculator,super.getParameters(calculator)), + getConfig() ); + } + + @Override + public void readXML(XMLableReader reader) { + super.readXML(reader); + if (reader.isChildNode()){ + if ("Attributes".equals(reader.getTagName())) { + try{ + String conf = new String(GeneralXMLTools.readByteArray(reader), EncodeConstants.ENCODING_UTF_8); + setConfig(conf); + }catch(Exception e){ + setConfig(StringUtils.EMPTY); + } + } + } + } + + @Override + public void writeXML(XMLPrintWriter writer) { + super.writeXML(writer); + writer.startTAG("Attributes"); + try{ + GeneralXMLTools.writeByteArray(writer, getConfig().getBytes(EncodeConstants.ENCODING_UTF_8)); + }catch(Exception e){} + writer.end(); + } +} diff --git a/src/main/java/com/eco/plugin/shsytzfsds/univalsalServerTable/UniversalServerTableData.java b/src/main/java/com/eco/plugin/shsytzfsds/univalsalServerTable/UniversalServerTableData.java new file mode 100644 index 0000000..d1cd573 --- /dev/null +++ b/src/main/java/com/eco/plugin/shsytzfsds/univalsalServerTable/UniversalServerTableData.java @@ -0,0 +1,69 @@ +package com.eco.plugin.shsytzfsds.univalsalServerTable; + +import com.fr.base.Parameter; +import com.fr.decision.fun.impl.AbstractUniversalServerTableDataProvider; +import com.fr.decision.webservice.bean.dataset.ParameterBean; +import com.fr.json.JSONObject; +import com.fr.plugin.transform.FunctionRecorder; +import com.fr.script.Calculator; +import com.fr.stable.ParameterProvider; +import com.fr.web.struct.Atom; +import com.fr.web.struct.Component; +import com.fr.web.struct.browser.RequestClient; +import com.fr.web.struct.category.ParserType; +import com.fr.web.struct.category.ScriptPath; + +import java.util.ArrayList; +import java.util.List; + +@FunctionRecorder +public class UniversalServerTableData extends AbstractUniversalServerTableDataProvider { + @Override + public Class classForTableData() { + return TableData.class; + } + + @Override + public String nameForTableData() { + return "飞书多维表数据集"; + } + + @Override + public JSONObject serialize(TableData data) { + TableDataBean bean = new TableDataBean(); + bean.setConfig(data.getConfig()); + List parameterBeans = new ArrayList(); + ParameterProvider[] parameters = data.getParameters(Calculator.createCalculator()); + for (ParameterProvider parameter : parameters) { + parameterBeans.add(new ParameterBean(parameter.getValue().getClass().getSimpleName(), + parameter.getName(), + parameter.valueToString())); + } + bean.setParameters(parameterBeans); + return JSONObject.mapFrom(bean); + } + + @Override + public TableData deserialize(TableData data, JSONObject config) { + TableDataBean bean = config.mapTo(TableDataBean.class); + TableData dataSet = new TableData(); + dataSet.setConfig(bean.getConfig()); + List params = bean.getParameters(); + Parameter[] parameters = new Parameter[params.size()]; + for (int i = 0; i < parameters.length; ++i) { + parameters[i] = params.get(i).createParameter(); + } + dataSet.setParameters(parameters); + return dataSet; + } + + @Override + public Atom client() { + return new Component() { + @Override + public ScriptPath script(RequestClient client) { + return ScriptPath.build("com/eco/plugin/shsytzfsds/js/univalsalServerTable.js", ParserType.DYNAMIC); + } + }; + } +} diff --git a/src/main/java/com/eco/plugin/shsytzfsds/univalsalServerTable/UniversalServerTableDataSheet.java b/src/main/java/com/eco/plugin/shsytzfsds/univalsalServerTable/UniversalServerTableDataSheet.java new file mode 100644 index 0000000..f75733b --- /dev/null +++ b/src/main/java/com/eco/plugin/shsytzfsds/univalsalServerTable/UniversalServerTableDataSheet.java @@ -0,0 +1,67 @@ +package com.eco.plugin.shsytzfsds.univalsalServerTable; + +import com.fr.base.Parameter; +import com.fr.decision.fun.impl.AbstractUniversalServerTableDataProvider; +import com.fr.decision.webservice.bean.dataset.ParameterBean; +import com.fr.json.JSONObject; +import com.fr.script.Calculator; +import com.fr.stable.ParameterProvider; +import com.fr.web.struct.Atom; +import com.fr.web.struct.Component; +import com.fr.web.struct.browser.RequestClient; +import com.fr.web.struct.category.ParserType; +import com.fr.web.struct.category.ScriptPath; + +import java.util.ArrayList; +import java.util.List; + +public class UniversalServerTableDataSheet extends AbstractUniversalServerTableDataProvider { + @Override + public Class classForTableData() { + return TableDataSheet.class; + } + + @Override + public String nameForTableData() { + return "飞书表格单sheet数据集"; + } + + @Override + public JSONObject serialize(TableDataSheet data) { + TableDataBeanSheet bean = new TableDataBeanSheet(); + bean.setConfig(data.getConfig()); + List parameterBeans = new ArrayList(); + ParameterProvider[] parameters = data.getParameters(Calculator.createCalculator()); + for (ParameterProvider parameter : parameters) { + parameterBeans.add(new ParameterBean(parameter.getValue().getClass().getSimpleName(), + parameter.getName(), + parameter.valueToString())); + } + bean.setParameters(parameterBeans); + return JSONObject.mapFrom(bean); + } + + @Override + public TableDataSheet deserialize(TableDataSheet data, JSONObject config) { + TableDataBeanSheet bean = config.mapTo(TableDataBeanSheet.class); + TableDataSheet dataSet = new TableDataSheet(); + dataSet.setConfig(bean.getConfig()); + List params = bean.getParameters(); + Parameter[] parameters = new Parameter[params.size()]; + for (int i = 0; i < parameters.length; ++i) { + parameters[i] = params.get(i).createParameter(); + } + dataSet.setParameters(parameters); + return dataSet; + } + + @Override + public Atom client() { + return new Component() { + @Override + public ScriptPath script(RequestClient client) { + return ScriptPath.build("com/eco/plugin/shsytzfsds/js/univalsalServerTableSheet.js", ParserType.DYNAMIC); + } + }; + } +} diff --git a/src/main/java/com/eco/plugin/shsytzfsds/utils/DataSetUtils.java b/src/main/java/com/eco/plugin/shsytzfsds/utils/DataSetUtils.java new file mode 100644 index 0000000..34275c4 --- /dev/null +++ b/src/main/java/com/eco/plugin/shsytzfsds/utils/DataSetUtils.java @@ -0,0 +1,89 @@ +package com.eco.plugin.shsytzfsds.utils; + +import com.eco.plugin.shsytzfsds.db.bean.DBEntity; +import com.eco.plugin.shsytzfsds.db.controller.DBController; +import com.fr.data.core.db.ColumnInformation; +import com.fr.json.JSONArray; +import com.fr.json.JSONObject; +import scala.annotation.meta.field; + +import java.sql.Types; +import java.util.ArrayList; +import java.util.List; + +/** + * 数据集工具类 + */ +public class DataSetUtils { + + + /** + * 获取数据集请求头 + * @param paramStr + * @return + */ + public static ColumnInformation[] getHeader(String paramStr){ + + JSONObject param = new JSONObject(paramStr); + String appid = param.getString("appid"); + String url = param.getString("url"); + + DBEntity feishuApp = DBController.getById(appid); + String secret = feishuApp.getSecret(); + + String token = FeiShuUtils.getTenantToken(appid,secret); + JSONArray array =FeiShuUtils.getTableFields(url,token); + + ColumnInformation[] columnInformations = new ColumnInformation[array.length()]; + + for (int i = 0; i < array.length(); i++) { + ColumnInformation columnInformation = new ColumnInformation(array.getString(i), Types.VARCHAR,"VARCHAR",255,0); + columnInformations[i] =columnInformation; + } + + return columnInformations; + } + + /** + * 获取电子表格头 + * @param paramStr + * @return + */ + public static ColumnInformation[] getSheetHeader(String paramStr){ + JSONObject param = new JSONObject(paramStr); + String id = param.getString("appid"); + String url = param.getString("url"); + int headrow = param.getInt("headrow"); + String colSelect = param.getString("colSelect"); + + int rowsize = headrow+1; + String columnSize = colSelect.equals("colcustom") ? param.getString("coldata"):""; + + DBEntity feishuApp = DBController.getById(id); + String appid = feishuApp.getAppid(); + String secret = feishuApp.getSecret(); + String token = FeiShuUtils.getTenantToken(appid,secret); + JSONArray jsonArray =FeiShuUtils.getSheetData(url,token,rowsize,columnSize,headrow,10,0); + ColumnInformation[] columnInformations = null; + for(int i =0;i< jsonArray.size();i++){ + JSONArray values = jsonArray.getJSONArray(i); + + for (int j = 0; j < values.length(); j++) { + + if(i == 0){ + if(j == 0){ + columnInformations = new ColumnInformation[values.length()]; + } + String field =headrow > 0 ? values.getString(j) : String.valueOf(j); + field = Utils.replaceNullStr(field,String.valueOf(j)); + ColumnInformation columnInformation = new ColumnInformation(field, Types.VARCHAR,"VARCHAR",255,0); + columnInformations[j] =columnInformation; + } + } + + break; + } + + return columnInformations; + } +} diff --git a/src/main/java/com/eco/plugin/shsytzfsds/utils/FRUtils.java b/src/main/java/com/eco/plugin/shsytzfsds/utils/FRUtils.java new file mode 100644 index 0000000..e4f0496 --- /dev/null +++ b/src/main/java/com/eco/plugin/shsytzfsds/utils/FRUtils.java @@ -0,0 +1,378 @@ +package com.eco.plugin.shsytzfsds.utils; + +import com.fr.base.ServerConfig; +import com.fr.base.TableData; +import com.fr.base.TemplateUtils; +import com.fr.decision.authority.AuthorityContext; +import com.fr.decision.authority.base.constant.type.operation.ManualOperationType; +import com.fr.decision.authority.data.User; +import com.fr.decision.base.util.UUIDUtil; +import com.fr.decision.privilege.TransmissionTool; +import com.fr.decision.privilege.encrpt.PasswordValidator; +import com.fr.decision.webservice.bean.authentication.OriginUrlResponseBean; +import com.fr.decision.webservice.interceptor.handler.ReportTemplateRequestChecker; +import com.fr.decision.webservice.login.LogInOutResultInfo; +import com.fr.decision.webservice.utils.DecisionServiceConstants; +import com.fr.decision.webservice.utils.DecisionStatusService; +import com.fr.decision.webservice.utils.UserSourceFactory; +import com.fr.decision.webservice.v10.login.LoginService; +import com.fr.decision.webservice.v10.login.event.LogInOutEvent; +import com.fr.decision.webservice.v10.user.UserService; +import com.fr.event.EventDispatcher; +import com.fr.file.TableDataConfig; +import com.fr.general.data.DataModel; +import com.fr.json.JSONObject; +import com.fr.log.FineLoggerFactory; +import com.fr.script.Calculator; +import com.fr.stable.StringUtils; +import com.fr.stable.query.QueryFactory; +import com.fr.stable.query.restriction.RestrictionFactory; +import com.fr.third.springframework.web.method.HandlerMethod; +import com.fr.web.controller.ReportRequestService; +import com.fr.web.utils.WebUtils; + +import javax.servlet.http.Cookie; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; +import java.io.IOException; +import java.util.List; + +public class FRUtils { + /** + * 判断用户是否存在 + * @param userName + * @return + */ + public static boolean isUserExist(String userName){ + if (StringUtils.isEmpty(userName)) { + return false; + } else { + try { + List userList = AuthorityContext.getInstance().getUserController().find(QueryFactory.create().addRestriction(RestrictionFactory.eq("userName", userName))); + return userList != null && !userList.isEmpty(); + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e.getMessage()); + return false; + } + } + } + + /** + * 判断是否登录FR + * @param req + * @return + */ + public static boolean isLogin(HttpServletRequest req){ + return LoginService.getInstance().isLogged(req); + } + + /** + * 帆软登录 + * @param httpServletRequest + * @param httpServletResponse + * @param userName + * @param url + */ + public static void login(HttpServletRequest httpServletRequest,HttpServletResponse httpServletResponse,String userName,String url){ + FineLoggerFactory.getLogger().debug("FRLOG:用户名:"+userName+";跳转链接:"+url); + + //判断用户名是否为空 + if(!Utils.isNullStr(userName)){ + if(isUserExist(userName)){ + try { + LoginService.getInstance().login(httpServletRequest, httpServletResponse, userName); + + EventDispatcher.fire(LogInOutEvent.LOGIN,new LogInOutResultInfo(httpServletRequest,httpServletResponse,userName,true)); + FineLoggerFactory.getLogger().debug("FRLOG:登陆成功!"); + + if(!Utils.isNullStr(url)){ + httpServletResponse.sendRedirect(url); + } + } catch (Exception e) { + ResponseUtils.failedResponse(httpServletResponse,"登录异常,请联系管理员!"); + FineLoggerFactory.getLogger().debug("FRLOGException:"+e.getMessage()); + } + }else{ + ResponseUtils.failedResponse(httpServletResponse,"用户:"+userName+"在帆软系统中不存在!"); + } + }else{ + ResponseUtils.failedResponse(httpServletResponse,"用户名不能为空!"); + } + } + + /** + * 帆软登录 + * @param httpServletRequest + * @param httpServletResponse + * @param token + * @param url + */ + public static void loginByToken(HttpServletRequest httpServletRequest,HttpServletResponse httpServletResponse,String token,String url){ + + FineLoggerFactory.getLogger().debug("FRLOG:token:"+token+";跳转链接:"+url); + + //判断用户名是否为空 + if(!Utils.isNullStr(token)){ + writeToken2Cookie(httpServletResponse,token,-1); + + HttpSession session = httpServletRequest.getSession(true); + + httpServletRequest.setAttribute(DecisionServiceConstants.FINE_AUTH_TOKEN_NAME,token); + + session.setAttribute(DecisionServiceConstants.FINE_AUTH_TOKEN_NAME, token); + + if(!Utils.isNullStr(url)){ + try { + httpServletResponse.sendRedirect(url); + } catch (IOException e) { + ResponseUtils.failedResponse(httpServletResponse,"跳转异常!"); + } + } + }else{ + ResponseUtils.failedResponse(httpServletResponse,"token不能为空!"); + } + } + + /** + * 产品原始登录方法 + * @param req + * @param res + * @param username + * @return + */ + public static JSONObject originLogin(HttpServletRequest req,HttpServletResponse res,String username){ +// String password = param.getString("password"); +// password = decryptFRPsd(password); + + FRUtils.FRLogInfo("originLogin:"+username); + + if(isUserExist(username)){ + try { + String token = LoginService.getInstance().login(req, res, username); + JSONObject result = new JSONObject(); + result.put("username",username); + result.put("validity",-1); + result.put("accessToken",token); + result.put("username",username); + result.put("url","/webroot/decision"); + JSONObject originUrlResponse = new JSONObject(); + originUrlResponse.put("originUrl","/webroot/decision"); + originUrlResponse.put("method","GET"); + originUrlResponse.put("parameters",new JSONObject()); + result.put("originUrlResponse",originUrlResponse); + return new JSONObject().put("data",result); + } catch (Exception e) { + ResponseUtils.failedResponse(res,"登录异常,请联系管理员!"); + } + }else{ + ResponseUtils.failedResponse(res,"用户:"+username+"在帆软系统中不存在!"); + } + + return new JSONObject(); + } + + /** + * 获取token + * @param httpServletRequest + * @param httpServletResponse + * @param username + * @return + */ + public static String getToken(HttpServletRequest httpServletRequest,HttpServletResponse httpServletResponse,String username){ + String token = ""; + try { + token = LoginService.getInstance().login(httpServletRequest, httpServletResponse, username); + } catch (Exception e) { + FineLoggerFactory.getLogger().debug("FRLOG:获取token失败"+e.getMessage()); + } + + return token; + } + + private static void writeToken2Cookie(HttpServletResponse req, String token, int num) { + try { + if (StringUtils.isNotEmpty(token)) { + Cookie cookie = new Cookie("fine_auth_token", token); + long maxAge = num == -2 ? 1209600000L : (long)num; + cookie.setMaxAge((int)maxAge); + cookie.setPath(ServerConfig.getInstance().getCookiePath()); + req.addCookie(cookie); + Cookie rememberCookie = new Cookie("fine_remember_login", String.valueOf(num == -2 ? -2 : -1)); + rememberCookie.setMaxAge((int)maxAge); + rememberCookie.setPath(ServerConfig.getInstance().getCookiePath()); + req.addCookie(rememberCookie); + } else { + FineLoggerFactory.getLogger().error("empty token cannot save."); + } + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } + + } + + /** + * 后台登出 + * @param httpServletRequest + * @param httpServletResponse + */ + public static void logoutByToken(HttpServletRequest httpServletRequest,HttpServletResponse httpServletResponse,String token) + { + httpServletRequest.setAttribute("fine_auth_token",token); + logout(httpServletRequest,httpServletResponse); + } + + /** + * + * @param httpServletRequest + * @param httpServletResponse + */ + public static void logout(HttpServletRequest httpServletRequest,HttpServletResponse httpServletResponse) + { + if(!isLogin(httpServletRequest)){ + return ; + } + + try { + LoginService.getInstance().logout(httpServletRequest,httpServletResponse); + } catch (Exception e) { + ResponseUtils.failedResponse(httpServletResponse,"登出异常,请联系管理员!"); + FineLoggerFactory.getLogger().debug("FRLOGException:"+e.getMessage()); + } + } + + /** + * 打印FR日志 + * @param message + */ + public static void FRLogInfo(String message){ + FineLoggerFactory.getLogger().info("FRLOG:"+message); + } + + /** + * 打印FR日志-debug + * @param message + */ + public static void FRLogDebug(String message){ + FineLoggerFactory.getLogger().debug("FRLOG:"+message); + } + + /** + * 打印FR日志-error + * @param message + */ + public static void FRLogError(String message){ + FineLoggerFactory.getLogger().error("FRLOG:"+message); + } + + + /** + * 根据用户名获取用户信息 + * @param userName + * @return + */ + public static User getFRUserByUserName(String userName){ + try { + return UserService.getInstance().getUserByUserName(userName); + } catch (Exception e) { + FRLogInfo("获取用户信息异常:"+e.getMessage()); + } + + return null; + } + + /** + * 解密FR密码 + * @param password + * @return + */ + public static String decryptFRPsd(String password){ + FRLogInfo("解密密码:"+password); + return TransmissionTool.decrypt(password); + } + + /** + * 根据明文密码生成数据库中的密码,用户密码校验用 + * @return + */ + public static String getDBPsd(String username,String password){ + PasswordValidator pv = UserSourceFactory.getInstance().getUserSource(ManualOperationType.KEY).getPasswordValidator(); + String uuid = UUIDUtil.generate(); + + return pv.encode(username, password, uuid); + } + + /** + * 获取带参数的访问链接 + * @return + */ + public static String getAllUrl(HttpServletRequest httpServletRequest){ + return WebUtils.getOriginalURL(httpServletRequest); + } + + /** + * 根据originKey获取源链接 + * @param req + * @return + * @throws Exception + */ + public static String getOriginUrl(HttpServletRequest req) throws Exception { + String origin = req.getParameter("origin"); + if (StringUtils.isNotEmpty(origin)) { + OriginUrlResponseBean originUrlResponseBean = (OriginUrlResponseBean) DecisionStatusService.originUrlStatusService().get(origin); + DecisionStatusService.originUrlStatusService().delete(origin); + if (originUrlResponseBean != null) { + return originUrlResponseBean.getOriginUrl(); + } + } + + return new OriginUrlResponseBean(TemplateUtils.render("${fineServletURL}")).getOriginUrl(); + } + + /** + * 判断是否开启模板认证 + * @param + * @return + * @throws Exception + */ + public static boolean isTempAuth(HttpServletRequest req,HttpServletResponse res) throws Exception { + ReportTemplateRequestChecker checker = new ReportTemplateRequestChecker(); + HandlerMethod hm = new HandlerMethod(new ReportRequestService(),ReportRequestService.class.getMethod("preview", HttpServletRequest.class, HttpServletResponse.class, String.class)); + return checker.checkRequest(req,res,hm); + } + + /** + * 获取数据集数据 + * @param serverDataSetName + * @return + */ + public static DataModel getTableData(String serverDataSetName){ + TableData userdebug = TableDataConfig.getInstance().getTableData(serverDataSetName); + DataModel userdebugDM = userdebug.createDataModel(Calculator.createCalculator()); +// userdebugDM.getRowCount(); +// userdebugDM.getColumnIndex(); +// userdebugDM.getValueAt() + return userdebugDM; + } + + public static String getIndex(HttpServletRequest req){ + String url = req.getScheme()+"://"+req.getServerName()+":"+String.valueOf(req.getServerPort())+req.getRequestURI(); + return url; + } + + /** + * 获取帆软域名 + * @param req + * @return + */ + public static String getFRDomain(HttpServletRequest req){ + String domain = req.getScheme()+"://"+req.getServerName(); + int port = req.getServerPort(); + + if(port != 80){ + domain += ":"+String.valueOf(req.getServerPort()); + } + + return domain; + } +} diff --git a/src/main/java/com/eco/plugin/shsytzfsds/utils/FeiShuUtils.java b/src/main/java/com/eco/plugin/shsytzfsds/utils/FeiShuUtils.java new file mode 100644 index 0000000..36ff521 --- /dev/null +++ b/src/main/java/com/eco/plugin/shsytzfsds/utils/FeiShuUtils.java @@ -0,0 +1,290 @@ +package com.eco.plugin.shsytzfsds.utils; + +import com.fr.json.JSONArray; +import com.fr.json.JSONObject; + +import java.util.HashMap; +import java.util.Locale; +import java.util.Map; + +/** + * 飞书工具类 + */ +public class FeiShuUtils { + private static final String tenant_token_url = "https://open.feishu.cn/open-apis/auth/v3/tenant_access_token/internal"; + private static final String sheet_data_url = "https://open.feishu.cn/open-apis/sheets/v2/spreadsheets/:spreadsheetToken/values/:range"; + //根据sheettoken获取sheet信息地址 + private static final String sheet_sheet_url = "https://open.feishu.cn/open-apis/sheets/v2/spreadsheets/:spreadsheetToken/metainfo"; + private static final String table_data_url = "https://open.feishu.cn/open-apis/bitable/v1/apps/:app_token/tables/:table_id/records"; + private static final String table_fields_url = "https://open.feishu.cn/open-apis/bitable/v1/apps/:app_token/tables/:table_id/fields"; + + /** + * 获取自建应用token + * @param appid + * @param appSecret + * @return + */ + public static String getTenantToken(String appid,String appSecret){ + JSONObject param = new JSONObject(); + param.put("app_id",appid); + param.put("app_secret",appSecret); + + String result = HttpUtils.HttpPostJson(tenant_token_url,param.toString(),null); + + return new JSONObject(result).getString("tenant_access_token"); + } + + /** + * 获取单sheet数据 + * @param url + * @param token + * @param rowsize 行号,为0时获取全部数据源 + * @param column 列号 + * @param headRow 标题行 获取数据时排除此行 + * @param pagecount 每页数量,此处为行数 + * @param curentrow 当前行数 + * @return + */ + public static JSONArray getSheetData(String url,String token,int rowsize,String column,int headRow,int pagecount,int curentrow){ + JSONArray array = new JSONArray(); + JSONObject sheetParam = getSheetParam(url,token); + String sheetToken = sheetParam.getString("sheetToken"); + String sheetId = sheetParam.getString("sheetId"); + String rowCount = sheetParam.getString("rowCount"); + String columnCount = sheetParam.getString("columnCount"); + + //最大行为0时获取全部数据 + if(rowsize <= 0){ + rowsize = Integer.valueOf(rowCount); + } + + //列名为空时获取全部数据 + if(Utils.isNullStr(column)){ + column = numberToLetter(Integer.valueOf(columnCount)); + } + + if(curentrow <= headRow){ + curentrow = headRow == 0 ? 1 : headRow; + } + + int startrow = curentrow; + + curentrow +=pagecount; + + if(curentrow > rowsize){ + curentrow = rowsize; + } + + String range = sheetId+"!A"+startrow+":"+column+curentrow; + + String requestUrl =sheet_data_url.replaceAll(":spreadsheetToken",sheetToken).replaceAll(":range",range); + Map header = new HashMap<>(); + header.put("Authorization","Bearer "+token); + header.put("Content-Type","application/json; charset=utf-8"); + + String result = HttpUtils.httpGet(requestUrl,null,header); + array.addAll(new JSONObject(result).getJSONObject("data").getJSONObject("valueRange").getJSONArray("values")); + + if(curentrow < rowsize){ + JSONArray childrenArray = getSheetData(url,token,rowsize,column,headRow,pagecount,curentrow+1); + array.addAll(childrenArray); + } + + return array; + } + + /** + * 根据url获取sheet参数 + * @param url + * @return + */ + private static JSONObject getSheetParam(String url,String token) { + String[] urls = url.split("\\?"); + String[] urlParam = urls[0].split("/"); + String sheetToken =urlParam[urlParam.length-1]; + String sheetId = ""; + + JSONArray sheetArray = getSheetArray(sheetToken,token); + + if(urls.length > 1){ + String paramstr = urls[1]; + String[] params = paramstr.split("&"); + + for (String param : params){ + String[] kv = param.split("="); + if(kv[0].equals("sheet")){ + sheetId = kv[1]; + break; + } + } + }else{ + sheetId = sheetArray.getJSONObject(0).getString("sheetId"); + } + + JSONObject result = new JSONObject(); + result.put("sheetToken",sheetToken); + result.put("sheetId",sheetId); + + + for (int i = 0; i < sheetArray.length(); i++) { + JSONObject sheet = sheetArray.getJSONObject(i); + String sheetIdE = sheet.getString("sheetId"); + if(sheetIdE.equals(sheetId)){ + result.put("rowCount",sheet.getString("rowCount")); + result.put("columnCount",sheet.getString("columnCount")); + } + } + + return result; + } + + private static JSONArray getSheetArray(String sheetToken,String token){ + String url = sheet_sheet_url.replaceAll(":spreadsheetToken",sheetToken); + + Map header = new HashMap<>(); + header.put("Authorization","Bearer "+token); + header.put("Content-Type","application/json; charset=utf-8"); + + String result = HttpUtils.httpGet(url,null,header); + + return new JSONObject(result).getJSONObject("data").getJSONArray("sheets"); + } + + /** + * 获取多维表数据 + * @param url + * @param token + * @param pageToken + * @return + */ + public static JSONArray getTableData(String url,String token,String pageToken){ + JSONArray array = new JSONArray(); + JSONObject sheetParam = getTableParam(url); + String app_token = sheetParam.getString("app_token"); + String table_id = sheetParam.getString("table_id"); + + String requestUrl =table_data_url.replaceAll(":app_token",app_token).replaceAll(":table_id",table_id)+"?page_token="+pageToken+"&page_size="+500; + Map header = new HashMap<>(); + header.put("Authorization","Bearer "+token); + + String result = HttpUtils.httpGet(requestUrl,null,header); + JSONObject data = new JSONObject(result).getJSONObject("data"); + pageToken = data.getString("page_token"); + array.addAll(data.getJSONArray("items")); + boolean hasMore = data.getBoolean("has_more"); + + if(hasMore){ + array.addAll(getTableData(url,token,pageToken)); + } + + return array; + } + + /** + * 获取多维表字段 + * @param url + * @param token + * @return + */ + public static JSONArray getTableFields(String url,String token){ + JSONObject sheetParam = getTableParam(url); + String app_token = sheetParam.getString("app_token"); + String table_id = sheetParam.getString("table_id"); + + String requestUrl =table_fields_url.replaceAll(":app_token",app_token).replaceAll(":table_id",table_id); + Map header = new HashMap<>(); + header.put("Authorization","Bearer "+token); + + String result = HttpUtils.httpGet(requestUrl,null,header); + JSONObject data = new JSONObject(result).getJSONObject("data"); + JSONArray fileds =data.getJSONArray("items"); + + JSONArray resultArray = new JSONArray(); + + for (int i = 0; i < fileds.length(); i++) { + JSONObject filed = fileds.getJSONObject(i); + resultArray.add(filed.getString("field_name")); + } + + return resultArray; + } + + /** + * 解析多维表参数 + * @param url + * @return + */ + private static JSONObject getTableParam(String url) { + String[] urls = url.split("\\?"); + String[] urlParam = urls[0].split("/"); + String app_token =urlParam[urlParam.length-1]; + String paramstr = urls[1]; + String[] params = paramstr.split("&"); + String sheetId = ""; + + for (String param : params){ + String[] kv = param.split("="); + if(kv[0].equals("table")){ + sheetId = kv[1]; + break; + } + } + + JSONObject result = new JSONObject(); + result.put("app_token",app_token); + result.put("table_id",sheetId); + + return result; + } + + public static void main(String[] args) { +// String token =getTenantToken("cli_a4756c7b3939d00b","4CFoMmAe03YU0kY3ZCsLgfRMnB48Vwxa"); + + //14730 客户飞书参数 + String token =getTenantToken("cli_a52dc2cb0039900c","ugnGbddZTyeTP08ILvR2uhMGsqxVn2Jk"); + String url = "https://w808buw46o.feishu.cn/base/XSKlbxuXda5VGxs54pmcMpnZnWC?table=tblSfSJcbBFzE182&view=vewA9JsnjJ"; +// String url = "https://ka04381dfr9.feishu.cn/sheets/RrnVs4bBkhOIYftOH4tc4xiDnUd?sheet=9fc5e2"; +////// String url = "https://ka04381dfr9.feishu.cn/sheets/RrnVs4bBkhOIYftOH4tc4xiDnUd"; +// int rowsize = 6; +// int headRow = 1; +// String column = "C"; +// int pageCount = 1; +// int currentRow = 0; +//// +// JSONArray jsonArray = getSheetData(url,token,rowsize,column,headRow,pageCount,currentRow); + + //多维表 +// String url = "https://ka04381dfr9.feishu.cn/base/X50lbouzeaI2H4sZazCcVM1lnJg?table=tblznO8etpFgDCcT&view=vewNfD7zhV"; + //异数据源多维表 +// String url = "https://ka04381dfr9.feishu.cn/base/Nte9biFa2afxnfsu4SdcXSM9nte?table=tblhXY5sLnZrq3yr&view=vewsaUn2WV"; + + //审批多维表 +// String url = "https://ka04381dfr9.feishu.cn/base/X50lbouzeaI2H4sZazCcVM1lnJg?table=tbllWZFrVSmYHfQ4&view=vewqQwbR9O"; + + + JSONArray tableFields = getTableFields(url,token); + JSONArray jsonArray = getTableData(url,token,""); + System.out.println(); + } + + public static String numberToLetter(int num){ + if(num <= 0){ + return null; + } + + String letter = ""; + num--; + + do{ + if(letter.length()>0){ + num--; + } + + letter = ((char)(num%26+(int)'A'))+letter; + + num = (int)((num-num%26)/26); + }while (num>0); + + return letter; + } +} diff --git a/src/main/java/com/eco/plugin/shsytzfsds/utils/HttpUtils.java b/src/main/java/com/eco/plugin/shsytzfsds/utils/HttpUtils.java new file mode 100644 index 0000000..4b8d8bb --- /dev/null +++ b/src/main/java/com/eco/plugin/shsytzfsds/utils/HttpUtils.java @@ -0,0 +1,260 @@ +package com.eco.plugin.shsytzfsds.utils; + +import com.fr.log.FineLoggerFactory; +import com.fr.third.org.apache.http.HttpEntity; +import com.fr.third.org.apache.http.HttpResponse; +import com.fr.third.org.apache.http.HttpStatus; +import com.fr.third.org.apache.http.NameValuePair; +import com.fr.third.org.apache.http.client.CookieStore; +import com.fr.third.org.apache.http.client.entity.UrlEncodedFormEntity; +import com.fr.third.org.apache.http.client.methods.HttpGet; +import com.fr.third.org.apache.http.client.methods.HttpPost; +import com.fr.third.org.apache.http.conn.ssl.NoopHostnameVerifier; +import com.fr.third.org.apache.http.entity.StringEntity; +import com.fr.third.org.apache.http.impl.client.BasicCookieStore; +import com.fr.third.org.apache.http.impl.client.CloseableHttpClient; +import com.fr.third.org.apache.http.impl.client.HttpClients; +import com.fr.third.org.apache.http.impl.cookie.BasicClientCookie; +import com.fr.third.org.apache.http.message.BasicNameValuePair; +import com.fr.third.org.apache.http.ssl.SSLContexts; +import com.fr.third.org.apache.http.ssl.TrustStrategy; +import com.fr.third.org.apache.http.util.EntityUtils; + +import javax.net.ssl.SSLContext; +import javax.servlet.http.Cookie; +import java.io.UnsupportedEncodingException; +import java.security.cert.CertificateException; +import java.security.cert.X509Certificate; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Set; + +public class HttpUtils { + + /** + * httpGet请求 + * @param url + * @return + */ + public static String httpGet(String url,Cookie[] cookies,Map header){ + FineLoggerFactory.getLogger().info("FRLOG:HttpUtils.get--url:"+url); + + //创建httpClient + CloseableHttpClient httpclient = createHttpClient(cookies); + + HttpGet getMethod = new HttpGet(url); + + if(header != null && header.size() > 0){ + Set keySet = header.keySet(); + + for(String key : keySet){ + getMethod.setHeader(key,header.get(key)); + } + } + + try { + HttpResponse response = httpclient.execute(getMethod); + int status =response.getStatusLine().getStatusCode(); + HttpEntity entity = response.getEntity(); + String returnResult = EntityUtils.toString(entity, "utf-8"); + + FineLoggerFactory.getLogger().info("FRLOG:HttpUtils.get--status:"+status +";returnResult:"+returnResult); + + httpclient.close(); + + if (status == HttpStatus.SC_OK) { + return returnResult; + } + } catch (Exception e) { + FineLoggerFactory.getLogger().info("FRLOG:HttpUtils.get--exception:"+e.getMessage()); + } + + try { + httpclient.close(); + } catch (Exception e) { + FineLoggerFactory.getLogger().info("FRLOG:http关闭异常:"+e.getMessage()); + } + + return ""; + } + + /** + * HttpPost请求 + * @param postMethod + * @return + */ + private static String HttpPost(HttpPost postMethod){ + CloseableHttpClient httpclient = createHttpClient(null); + + try { + HttpResponse response = httpclient.execute(postMethod); + int status = response.getStatusLine().getStatusCode(); + HttpEntity entity = response.getEntity(); + String returnResult = EntityUtils.toString(entity, "utf-8"); + FineLoggerFactory.getLogger().info("FRLOG:HttpPost:status:"+status+"returnResult:"+returnResult); + httpclient.close(); + + if (status == HttpStatus.SC_OK) { + return returnResult; + } + } catch (Exception e) { + FineLoggerFactory.getLogger().info("FRLOG:HttpPost:exception:"+e.getMessage()); + } + + try { + httpclient.close(); + } catch (Exception e) { + FineLoggerFactory.getLogger().info("FRLOG:http关闭异常:"+e.getMessage()); + } + + return ""; + } + + public static String HttpPostXML(String url, String xmlParam){ + FineLoggerFactory.getLogger().info("FRLOG:HttpPostXML:url:"+url); + + HttpPost postMethod = new HttpPost(url); + + postMethod.setHeader("Content-type", "text/html"); + HttpEntity entity = null; + try { + entity = new StringEntity(xmlParam,"utf-8"); + } catch (Exception e) { + FineLoggerFactory.getLogger().info("FRLOG:HttpPostXML:参数异常:"+e.getMessage()); + return ""; + } + + postMethod.setEntity(entity); + + return HttpPost(postMethod); + } + + public static String HttpPostText(String url, String xmlParam){ + FineLoggerFactory.getLogger().info("FRLOG:HttpPostText:url:"+url); + + HttpPost postMethod = new HttpPost(url); + + postMethod.setHeader("Content-type", "text/plain"); + HttpEntity entity = null; + try { + entity = new StringEntity(xmlParam,"utf-8"); + } catch (Exception e) { + FineLoggerFactory.getLogger().info("FRLOG:HttpPostText:参数异常:"+e.getMessage()); + return ""; + } + + postMethod.setEntity(entity); + + return HttpPost(postMethod); + } + + public static String HttpPostJson(String url, String param,Map header){ + FineLoggerFactory.getLogger().info("FRLOG:HttpPostJSON:url:"+url); + + HttpPost postMethod = new HttpPost(url); + + postMethod.setHeader("Content-Type","application/json"); + + if(header != null && header.size() > 0){ + Set keySet = header.keySet(); + + for(String key : keySet){ + postMethod.setHeader(key,header.get(key)); + } + } + + if(!Utils.isNullStr(param)){ + HttpEntity entity = null; + try { + entity = new StringEntity(param,"utf-8"); + } catch (Exception e) { + FineLoggerFactory.getLogger().info("FRLOG:HttpPostJSON:参数异常:"+e.getMessage()); + return ""; + } + + postMethod.setEntity(entity); + } + + return HttpPost(postMethod); + } + + public static String HttpPostForm(String url, Map header,Map param){ + FineLoggerFactory.getLogger().info("FRLOG:HttpForm:url:"+url); + + HttpPost postMethod = new HttpPost(url); + + if(header != null && header.size() > 0){ + Set keySet = header.keySet(); + + for(String key : keySet){ + postMethod.setHeader(key,header.get(key)); + } + } + + if(param != null && param.size() > 0){ + List params = new ArrayList(param.size()); + + for(Map.Entry map : param.entrySet()){ + params.add(new BasicNameValuePair(map.getKey(), map.getValue())); + } + + try { + postMethod.setEntity(new UrlEncodedFormEntity(params, "UTF-8")); + } catch (UnsupportedEncodingException e) { + FineLoggerFactory.getLogger().info("FRLOG:HttpForm:异常:"+e.getMessage()); + return ""; + } + } + + return HttpPost(postMethod); + } + + private static CloseableHttpClient createHttpClient(Cookie[] cookies){ + + SSLContext sslContext = null; + try { + sslContext = SSLContexts.custom().loadTrustMaterial(null, new TrustStrategy() { + @Override + public boolean isTrusted(X509Certificate[] x509Certificates, String s) throws CertificateException { + return true; + } + }).build(); + } catch (Exception e) { + FRUtils.FRLogDebug("exception:"+e.getMessage()); + } + + CloseableHttpClient httpclient = null; + + if(cookies != null && cookies.length > 0){ + CookieStore cookieStore = cookieToCookieStore(cookies); + + httpclient = HttpClients.custom().setSslcontext(sslContext). + setSSLHostnameVerifier(new NoopHostnameVerifier()).setDefaultCookieStore(cookieStore).build(); + } + else{ + httpclient = HttpClients.custom().setSslcontext(sslContext). + setSSLHostnameVerifier(new NoopHostnameVerifier()).build(); + } + + return httpclient; + } + + /** + * cookies转cookieStore + * @param cookies + * @return + */ + public static CookieStore cookieToCookieStore(Cookie[] cookies){ + CookieStore cookieStore = new BasicCookieStore(); + + if(cookies != null && cookies.length>0){ + for(Cookie cookie : cookies){ + BasicClientCookie cookie1 = new BasicClientCookie(cookie.getName(), cookie.getValue()); + cookieStore.addCookie(cookie1); + } + } + + return cookieStore; + } +} diff --git a/src/main/java/com/eco/plugin/shsytzfsds/utils/ResponseUtils.java b/src/main/java/com/eco/plugin/shsytzfsds/utils/ResponseUtils.java new file mode 100644 index 0000000..94962c4 --- /dev/null +++ b/src/main/java/com/eco/plugin/shsytzfsds/utils/ResponseUtils.java @@ -0,0 +1,108 @@ +package com.eco.plugin.shsytzfsds.utils; + +import com.fr.json.JSONObject; +import com.fr.log.FineLoggerFactory; +import com.fr.web.utils.WebUtils; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.PrintWriter; + +public class ResponseUtils { + private static final int SUCCESS = 200; + private static final int FAILED = -1; + + public static void successResponse(HttpServletResponse res, String body) { + response(res, body, SUCCESS); + } + + public static void failedResponse(HttpServletResponse res, String body) { + response(res, body, FAILED); + } + + private static void response(HttpServletResponse res, String body, int code) { + JSONObject object = new JSONObject(); + PrintWriter pw; + try { + object.put("code", code); + object.put("data", body); + pw = WebUtils.createPrintWriter(res); + } catch (Exception e) { + FineLoggerFactory.getLogger().debug(e.getMessage()); + return; + } + res.setContentType("application/json;charset=utf-8"); + String result = object.toString(); + pw.println(result); + pw.flush(); + pw.close(); + } + + public static void response(HttpServletResponse res,JSONObject json){ + PrintWriter pw; + try { + pw = WebUtils.createPrintWriter(res); + } catch (Exception e) { + FineLoggerFactory.getLogger().debug(e.getMessage()); + return; + } + res.setContentType("application/json;charset=utf-8"); + String result = json.toString(); + pw.println(result); + pw.flush(); + pw.close(); + } + + public static void responseText(HttpServletResponse res,String text){ + PrintWriter pw; + try { + pw = WebUtils.createPrintWriter(res); + } catch (Exception e) { + FineLoggerFactory.getLogger().debug(e.getMessage()); + return; + } + res.setContentType("text/html;charset=utf-8"); + pw.println(text); + pw.flush(); + pw.close(); + } + + public static void responseXml(HttpServletResponse res,String xml){ + PrintWriter pw; + try { + pw = WebUtils.createPrintWriter(res); + } catch (Exception e) { + FineLoggerFactory.getLogger().debug(e.getMessage()); + return; + } + res.setContentType("text/xml;charset=utf-8"); + pw.println(xml); + pw.flush(); + pw.close(); + } + + public static void setCSRFHeader(HttpServletResponse httpServletResponse){ + httpServletResponse.setHeader("Access-Control-Allow-Origin", "*"); + httpServletResponse.setHeader("Access-Control-Allow-Methods", "POST,GET,OPTIONS,DELETE,HEAD,PUT,PATCH"); + httpServletResponse.setHeader("Access-Control-Max-Age", "36000"); + httpServletResponse.setHeader("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept,Authorization,authorization"); + } + + public static void responseJsonp(HttpServletRequest req, HttpServletResponse res, JSONObject json){ + PrintWriter pw; + try { + pw = WebUtils.createPrintWriter(res); + } catch (Exception e) { + FineLoggerFactory.getLogger().debug(e.getMessage()); + return; + } + res.setContentType("text/javascript;charset=utf-8;charset=utf-8"); + String result = json.toString(); + + String jsonp=req.getParameter("callback"); + + pw.println(jsonp+"("+result+")"); + pw.flush(); + pw.close(); + } +} diff --git a/src/main/java/com/eco/plugin/shsytzfsds/utils/Utils.java b/src/main/java/com/eco/plugin/shsytzfsds/utils/Utils.java new file mode 100644 index 0000000..3fcc7f7 --- /dev/null +++ b/src/main/java/com/eco/plugin/shsytzfsds/utils/Utils.java @@ -0,0 +1,385 @@ +package com.eco.plugin.shsytzfsds.utils; + +import com.fr.base.TemplateUtils; +import com.fr.data.NetworkHelper; +import com.fr.decision.webservice.v10.user.UserService; +import com.fr.io.utils.ResourceIOUtils; +import com.fr.json.JSONObject; +import com.fr.stable.CodeUtils; +import com.fr.stable.StringUtils; +import com.fr.third.org.apache.commons.codec.digest.DigestUtils; +import com.fr.web.utils.WebUtils; + +import javax.servlet.http.Cookie; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.BufferedReader; +import java.io.InputStream; +import java.net.InetAddress; +import java.net.URLEncoder; +import java.net.UnknownHostException; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +public class Utils { + + public static byte[] getByteHeader(byte[] bytes){ + byte[] newByte = new byte[3]; + for(int i=0;i parameterMap){ + if(parameterMap == null){ + parameterMap = new HashMap(); + } + + try { + String macPage = TemplateUtils.renderTemplate(path, parameterMap); + WebUtils.printAsString(res, macPage); + }catch (Exception e){ + FRUtils.FRLogError("跳转页面异常"); + } + + } + + /** + * 判断是否是管理员 + * @param username + * @return + */ + public static boolean isAdmin(String username) throws Exception{ + return UserService.getInstance().isAdmin(UserService.getInstance().getUserByUserName(username).getId()); + } + + /** + * 去掉浏览器中的参数 + * @param url + * @param param + * @return + */ + public static String removeParam(String url,String param){ + if(!url.contains("?")){ + return url; + } + String[] urls = url.split("\\?"); + String queryStr = urls[1]; + String[] params = queryStr.split("&"); + url = urls[0]; + for(int i=0;i list, String split){ + String result = ""; + + if(list == null || list.size() <= 0){ + return result; + } + + for(String str : list){ + result+=","+str; + } + + result = result.substring(1); + + return result; + } + + /** + * array 转化为指定字符分割的字符串 + * @param list + * @param list + * @return + */ + public static String arrayToStr(String[] list, String split){ + String result = ""; + + if(list == null ||list.length <= 0){ + return result; + } + + for(int i=0;i + + + + 飞书多维表格 + + + + + + + +
+
+
+ 数据集名称: + +
+
+ + +
+
+
+
+
+
+ 飞书应用 +
+
+ +
+
+
+
+ 多维表url +
+
+ +
+
+
+
+
+
+ +
+
+
+
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/src/main/resources/com/eco/plugin/shsytzfsds/html/sheet.html b/src/main/resources/com/eco/plugin/shsytzfsds/html/sheet.html new file mode 100644 index 0000000..bc922dd --- /dev/null +++ b/src/main/resources/com/eco/plugin/shsytzfsds/html/sheet.html @@ -0,0 +1,356 @@ + + + + + 飞书多维表格 + + + + + + + +
+
+
+ 数据集名称: + +
+
+ + +
+
+
+
+
+
+ 飞书应用 +
+
+ +
+
+
+
+ 表格url +
+
+ +
+
+
+
+ 设置表头 +
+
+ 第 行 +
+
+
+
+ 选取行数据 +
+
+ 默认(第2行~全部行) +
+
+
+
+ 自定义 + +
+
+
+
+ 选取列数据 +
+
+ 默认(第A列~最后有数据列) +
+
+
+
+ 自定义 + +
+
+
+
+
+
+ +
+
+
+
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/src/main/resources/com/eco/plugin/shsytzfsds/js/bi/feishu.png b/src/main/resources/com/eco/plugin/shsytzfsds/js/bi/feishu.png new file mode 100644 index 0000000000000000000000000000000000000000..651a2898a9971e229c7ece6df518a95c19047d7b GIT binary patch literal 1467 zcmV;s1w{IZP)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D1yD&uK~z{r?U#Q@ zUR4;!Wkdu~GuLXYAf*1WFw)WfNH?1s4T@1xk^~Wr5&NSxOV&SGjfx7}Kg~bNAG4O) zC?>X)sqY|g(J#wjm`NA+^}Y5b9|qMNmF5q5vg?p1d6)j3tC*N3q#kh)j_7f-v4+8VZOh$ul82(vj zkteO4hq9y_hn)}2UB>;V+ciWeSfduSOpiLCVJ&G$6JU7m64Foqr~)g1Ft9Wxf2fOm za8>?8NL_jj+CMji6@6U#kc~v8Ut+IKw;6x&%mca5VAGj;o$B#jmoMVhUIIv>?C)I| zfRwSx`sFtd^h7m zUTH*TK|L}y?Zv91eJFgR8J~Q40(~QYIq}&%kQb%|Rux;QZ)Z@wZg^;-ZG)Zh*pfe^ zu`S1}Q?pI+k?!AI-GJ1mtC5;hfn~X$u+Uj;v)lmFoV=^;PH_ny@4IAjhXH zWN()WwC0fB$W8h=w|>*lblGO*JXW9SaAna3>^_K;u4de}b*}sdqUV_Bobys$y^5RYkae#W2zJ+o74(~beQVM#|5mKN@DVA9saGR9yA zG>y*Fay~=Rju!QXW533{kTaG7G|DQL*j6DhIir7IP)&CI#`ixQ8`Rk}fX~)Aa0b*Z zCz}Mhd~GGV2gX$#cZ7tHtnBR;HhnOU=m?cxbtJ7-H9DaDq&X?@;J{Bv>1f8%f;|d? zv*d^KEA6ogy!=kYPJl^=HV@>*X)h!Ln)B5qz!wpTf97pa*P4kLuVaDQ!4cg4Of{`9 z-5d;R&fN-=MYe>HSp=E=I!Rqys{AkRqWAajcIUgwZmxfcj^d$$It8HNVjylnmNN-D zZhrTW?N3+8-KYs6{Zi1RM@t0W-zPCPXUILG7o5KSyoWk83zIFCOQ|=%*mU*68bWpuS77@}&uTuteHy7`%8C%ZbzJkM8 zo=2N^97vuBKT9v{K>Kg=s#y}*)sQBjeN0xW(MVaZ31n>k1L@Bl#fpuMSibHnQXN)q zY@mCcczEjsDqD54B}Vi?@;<4u!@+#PlM!cEOTS{xweroAp!1LR(`Lng&YW(JZ@x@Q z2Qn!5wMhH2*E0F$BR3oG2E3=5Z6`FOph-QsQ_nOg;I)V$&DNE(L*l?O_lrP(#4KbU zNdCd#c?&P?)){5zMmnfISLL&>y;=8P>wBy%a?this[a+this.length]:this[a]:d.call(this)},pushStack:function(a){var b=n.merge(this.constructor(),a);return b.prevObject=this,b.context=this.context,b},each:function(a,b){return n.each(this,a,b)},map:function(a){return this.pushStack(n.map(this,function(b,c){return a.call(b,c,b)}))},slice:function(){return this.pushStack(d.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(a){var b=this.length,c=+a+(0>a?b:0);return this.pushStack(c>=0&&b>c?[this[c]]:[])},end:function(){return this.prevObject||this.constructor(null)},push:f,sort:c.sort,splice:c.splice},n.extend=n.fn.extend=function(){var a,b,c,d,e,f,g=arguments[0]||{},h=1,i=arguments.length,j=!1;for("boolean"==typeof g&&(j=g,g=arguments[h]||{},h++),"object"==typeof g||n.isFunction(g)||(g={}),h===i&&(g=this,h--);i>h;h++)if(null!=(a=arguments[h]))for(b in a)c=g[b],d=a[b],g!==d&&(j&&d&&(n.isPlainObject(d)||(e=n.isArray(d)))?(e?(e=!1,f=c&&n.isArray(c)?c:[]):f=c&&n.isPlainObject(c)?c:{},g[b]=n.extend(j,f,d)):void 0!==d&&(g[b]=d));return g},n.extend({expando:"jQuery"+(m+Math.random()).replace(/\D/g,""),isReady:!0,error:function(a){throw new Error(a)},noop:function(){},isFunction:function(a){return"function"===n.type(a)},isArray:Array.isArray,isWindow:function(a){return null!=a&&a===a.window},isNumeric:function(a){return!n.isArray(a)&&a-parseFloat(a)+1>=0},isPlainObject:function(a){return"object"!==n.type(a)||a.nodeType||n.isWindow(a)?!1:a.constructor&&!j.call(a.constructor.prototype,"isPrototypeOf")?!1:!0},isEmptyObject:function(a){var b;for(b in a)return!1;return!0},type:function(a){return null==a?a+"":"object"==typeof a||"function"==typeof a?h[i.call(a)]||"object":typeof a},globalEval:function(a){var b,c=eval;a=n.trim(a),a&&(1===a.indexOf("use strict")?(b=l.createElement("script"),b.text=a,l.head.appendChild(b).parentNode.removeChild(b)):c(a))},camelCase:function(a){return a.replace(p,"ms-").replace(q,r)},nodeName:function(a,b){return a.nodeName&&a.nodeName.toLowerCase()===b.toLowerCase()},each:function(a,b,c){var d,e=0,f=a.length,g=s(a);if(c){if(g){for(;f>e;e++)if(d=b.apply(a[e],c),d===!1)break}else for(e in a)if(d=b.apply(a[e],c),d===!1)break}else if(g){for(;f>e;e++)if(d=b.call(a[e],e,a[e]),d===!1)break}else for(e in a)if(d=b.call(a[e],e,a[e]),d===!1)break;return a},trim:function(a){return null==a?"":(a+"").replace(o,"")},makeArray:function(a,b){var c=b||[];return null!=a&&(s(Object(a))?n.merge(c,"string"==typeof a?[a]:a):f.call(c,a)),c},inArray:function(a,b,c){return null==b?-1:g.call(b,a,c)},merge:function(a,b){for(var c=+b.length,d=0,e=a.length;c>d;d++)a[e++]=b[d];return a.length=e,a},grep:function(a,b,c){for(var d,e=[],f=0,g=a.length,h=!c;g>f;f++)d=!b(a[f],f),d!==h&&e.push(a[f]);return e},map:function(a,b,c){var d,f=0,g=a.length,h=s(a),i=[];if(h)for(;g>f;f++)d=b(a[f],f,c),null!=d&&i.push(d);else for(f in a)d=b(a[f],f,c),null!=d&&i.push(d);return e.apply([],i)},guid:1,proxy:function(a,b){var c,e,f;return"string"==typeof b&&(c=a[b],b=a,a=c),n.isFunction(a)?(e=d.call(arguments,2),f=function(){return a.apply(b||this,e.concat(d.call(arguments)))},f.guid=a.guid=a.guid||n.guid++,f):void 0},now:Date.now,support:k}),n.each("Boolean Number String Function Array Date RegExp Object Error".split(" "),function(a,b){h["[object "+b+"]"]=b.toLowerCase()});function s(a){var b=a.length,c=n.type(a);return"function"===c||n.isWindow(a)?!1:1===a.nodeType&&b?!0:"array"===c||0===b||"number"==typeof b&&b>0&&b-1 in a}var t=function(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u="sizzle"+1*new Date,v=a.document,w=0,x=0,y=hb(),z=hb(),A=hb(),B=function(a,b){return a===b&&(l=!0),0},C=1<<31,D={}.hasOwnProperty,E=[],F=E.pop,G=E.push,H=E.push,I=E.slice,J=function(a,b){for(var c=0,d=a.length;d>c;c++)if(a[c]===b)return c;return-1},K="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",L="[\\x20\\t\\r\\n\\f]",M="(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",N=M.replace("w","w#"),O="\\["+L+"*("+M+")(?:"+L+"*([*^$|!~]?=)"+L+"*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|("+N+"))|)"+L+"*\\]",P=":("+M+")(?:\\((('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|((?:\\\\.|[^\\\\()[\\]]|"+O+")*)|.*)\\)|)",Q=new RegExp(L+"+","g"),R=new RegExp("^"+L+"+|((?:^|[^\\\\])(?:\\\\.)*)"+L+"+$","g"),S=new RegExp("^"+L+"*,"+L+"*"),T=new RegExp("^"+L+"*([>+~]|"+L+")"+L+"*"),U=new RegExp("="+L+"*([^\\]'\"]*?)"+L+"*\\]","g"),V=new RegExp(P),W=new RegExp("^"+N+"$"),X={ID:new RegExp("^#("+M+")"),CLASS:new RegExp("^\\.("+M+")"),TAG:new RegExp("^("+M.replace("w","w*")+")"),ATTR:new RegExp("^"+O),PSEUDO:new RegExp("^"+P),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+L+"*(even|odd|(([+-]|)(\\d*)n|)"+L+"*(?:([+-]|)"+L+"*(\\d+)|))"+L+"*\\)|)","i"),bool:new RegExp("^(?:"+K+")$","i"),needsContext:new RegExp("^"+L+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+L+"*((?:-\\d)?\\d*)"+L+"*\\)|)(?=[^-]|$)","i")},Y=/^(?:input|select|textarea|button)$/i,Z=/^h\d$/i,$=/^[^{]+\{\s*\[native \w/,_=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,ab=/[+~]/,bb=/'|\\/g,cb=new RegExp("\\\\([\\da-f]{1,6}"+L+"?|("+L+")|.)","ig"),db=function(a,b,c){var d="0x"+b-65536;return d!==d||c?b:0>d?String.fromCharCode(d+65536):String.fromCharCode(d>>10|55296,1023&d|56320)},eb=function(){m()};try{H.apply(E=I.call(v.childNodes),v.childNodes),E[v.childNodes.length].nodeType}catch(fb){H={apply:E.length?function(a,b){G.apply(a,I.call(b))}:function(a,b){var c=a.length,d=0;while(a[c++]=b[d++]);a.length=c-1}}}function gb(a,b,d,e){var f,h,j,k,l,o,r,s,w,x;if((b?b.ownerDocument||b:v)!==n&&m(b),b=b||n,d=d||[],k=b.nodeType,"string"!=typeof a||!a||1!==k&&9!==k&&11!==k)return d;if(!e&&p){if(11!==k&&(f=_.exec(a)))if(j=f[1]){if(9===k){if(h=b.getElementById(j),!h||!h.parentNode)return d;if(h.id===j)return d.push(h),d}else if(b.ownerDocument&&(h=b.ownerDocument.getElementById(j))&&t(b,h)&&h.id===j)return d.push(h),d}else{if(f[2])return H.apply(d,b.getElementsByTagName(a)),d;if((j=f[3])&&c.getElementsByClassName)return H.apply(d,b.getElementsByClassName(j)),d}if(c.qsa&&(!q||!q.test(a))){if(s=r=u,w=b,x=1!==k&&a,1===k&&"object"!==b.nodeName.toLowerCase()){o=g(a),(r=b.getAttribute("id"))?s=r.replace(bb,"\\$&"):b.setAttribute("id",s),s="[id='"+s+"'] ",l=o.length;while(l--)o[l]=s+rb(o[l]);w=ab.test(a)&&pb(b.parentNode)||b,x=o.join(",")}if(x)try{return H.apply(d,w.querySelectorAll(x)),d}catch(y){}finally{r||b.removeAttribute("id")}}}return i(a.replace(R,"$1"),b,d,e)}function hb(){var a=[];function b(c,e){return a.push(c+" ")>d.cacheLength&&delete b[a.shift()],b[c+" "]=e}return b}function ib(a){return a[u]=!0,a}function jb(a){var b=n.createElement("div");try{return!!a(b)}catch(c){return!1}finally{b.parentNode&&b.parentNode.removeChild(b),b=null}}function kb(a,b){var c=a.split("|"),e=a.length;while(e--)d.attrHandle[c[e]]=b}function lb(a,b){var c=b&&a,d=c&&1===a.nodeType&&1===b.nodeType&&(~b.sourceIndex||C)-(~a.sourceIndex||C);if(d)return d;if(c)while(c=c.nextSibling)if(c===b)return-1;return a?1:-1}function mb(a){return function(b){var c=b.nodeName.toLowerCase();return"input"===c&&b.type===a}}function nb(a){return function(b){var c=b.nodeName.toLowerCase();return("input"===c||"button"===c)&&b.type===a}}function ob(a){return ib(function(b){return b=+b,ib(function(c,d){var e,f=a([],c.length,b),g=f.length;while(g--)c[e=f[g]]&&(c[e]=!(d[e]=c[e]))})})}function pb(a){return a&&"undefined"!=typeof a.getElementsByTagName&&a}c=gb.support={},f=gb.isXML=function(a){var b=a&&(a.ownerDocument||a).documentElement;return b?"HTML"!==b.nodeName:!1},m=gb.setDocument=function(a){var b,e,g=a?a.ownerDocument||a:v;return g!==n&&9===g.nodeType&&g.documentElement?(n=g,o=g.documentElement,e=g.defaultView,e&&e!==e.top&&(e.addEventListener?e.addEventListener("unload",eb,!1):e.attachEvent&&e.attachEvent("onunload",eb)),p=!f(g),c.attributes=jb(function(a){return a.className="i",!a.getAttribute("className")}),c.getElementsByTagName=jb(function(a){return a.appendChild(g.createComment("")),!a.getElementsByTagName("*").length}),c.getElementsByClassName=$.test(g.getElementsByClassName),c.getById=jb(function(a){return o.appendChild(a).id=u,!g.getElementsByName||!g.getElementsByName(u).length}),c.getById?(d.find.ID=function(a,b){if("undefined"!=typeof b.getElementById&&p){var c=b.getElementById(a);return c&&c.parentNode?[c]:[]}},d.filter.ID=function(a){var b=a.replace(cb,db);return function(a){return a.getAttribute("id")===b}}):(delete d.find.ID,d.filter.ID=function(a){var b=a.replace(cb,db);return function(a){var c="undefined"!=typeof a.getAttributeNode&&a.getAttributeNode("id");return c&&c.value===b}}),d.find.TAG=c.getElementsByTagName?function(a,b){return"undefined"!=typeof b.getElementsByTagName?b.getElementsByTagName(a):c.qsa?b.querySelectorAll(a):void 0}:function(a,b){var c,d=[],e=0,f=b.getElementsByTagName(a);if("*"===a){while(c=f[e++])1===c.nodeType&&d.push(c);return d}return f},d.find.CLASS=c.getElementsByClassName&&function(a,b){return p?b.getElementsByClassName(a):void 0},r=[],q=[],(c.qsa=$.test(g.querySelectorAll))&&(jb(function(a){o.appendChild(a).innerHTML="",a.querySelectorAll("[msallowcapture^='']").length&&q.push("[*^$]="+L+"*(?:''|\"\")"),a.querySelectorAll("[selected]").length||q.push("\\["+L+"*(?:value|"+K+")"),a.querySelectorAll("[id~="+u+"-]").length||q.push("~="),a.querySelectorAll(":checked").length||q.push(":checked"),a.querySelectorAll("a#"+u+"+*").length||q.push(".#.+[+~]")}),jb(function(a){var b=g.createElement("input");b.setAttribute("type","hidden"),a.appendChild(b).setAttribute("name","D"),a.querySelectorAll("[name=d]").length&&q.push("name"+L+"*[*^$|!~]?="),a.querySelectorAll(":enabled").length||q.push(":enabled",":disabled"),a.querySelectorAll("*,:x"),q.push(",.*:")})),(c.matchesSelector=$.test(s=o.matches||o.webkitMatchesSelector||o.mozMatchesSelector||o.oMatchesSelector||o.msMatchesSelector))&&jb(function(a){c.disconnectedMatch=s.call(a,"div"),s.call(a,"[s!='']:x"),r.push("!=",P)}),q=q.length&&new RegExp(q.join("|")),r=r.length&&new RegExp(r.join("|")),b=$.test(o.compareDocumentPosition),t=b||$.test(o.contains)?function(a,b){var c=9===a.nodeType?a.documentElement:a,d=b&&b.parentNode;return a===d||!(!d||1!==d.nodeType||!(c.contains?c.contains(d):a.compareDocumentPosition&&16&a.compareDocumentPosition(d)))}:function(a,b){if(b)while(b=b.parentNode)if(b===a)return!0;return!1},B=b?function(a,b){if(a===b)return l=!0,0;var d=!a.compareDocumentPosition-!b.compareDocumentPosition;return d?d:(d=(a.ownerDocument||a)===(b.ownerDocument||b)?a.compareDocumentPosition(b):1,1&d||!c.sortDetached&&b.compareDocumentPosition(a)===d?a===g||a.ownerDocument===v&&t(v,a)?-1:b===g||b.ownerDocument===v&&t(v,b)?1:k?J(k,a)-J(k,b):0:4&d?-1:1)}:function(a,b){if(a===b)return l=!0,0;var c,d=0,e=a.parentNode,f=b.parentNode,h=[a],i=[b];if(!e||!f)return a===g?-1:b===g?1:e?-1:f?1:k?J(k,a)-J(k,b):0;if(e===f)return lb(a,b);c=a;while(c=c.parentNode)h.unshift(c);c=b;while(c=c.parentNode)i.unshift(c);while(h[d]===i[d])d++;return d?lb(h[d],i[d]):h[d]===v?-1:i[d]===v?1:0},g):n},gb.matches=function(a,b){return gb(a,null,null,b)},gb.matchesSelector=function(a,b){if((a.ownerDocument||a)!==n&&m(a),b=b.replace(U,"='$1']"),!(!c.matchesSelector||!p||r&&r.test(b)||q&&q.test(b)))try{var d=s.call(a,b);if(d||c.disconnectedMatch||a.document&&11!==a.document.nodeType)return d}catch(e){}return gb(b,n,null,[a]).length>0},gb.contains=function(a,b){return(a.ownerDocument||a)!==n&&m(a),t(a,b)},gb.attr=function(a,b){(a.ownerDocument||a)!==n&&m(a);var e=d.attrHandle[b.toLowerCase()],f=e&&D.call(d.attrHandle,b.toLowerCase())?e(a,b,!p):void 0;return void 0!==f?f:c.attributes||!p?a.getAttribute(b):(f=a.getAttributeNode(b))&&f.specified?f.value:null},gb.error=function(a){throw new Error("Syntax error, unrecognized expression: "+a)},gb.uniqueSort=function(a){var b,d=[],e=0,f=0;if(l=!c.detectDuplicates,k=!c.sortStable&&a.slice(0),a.sort(B),l){while(b=a[f++])b===a[f]&&(e=d.push(f));while(e--)a.splice(d[e],1)}return k=null,a},e=gb.getText=function(a){var b,c="",d=0,f=a.nodeType;if(f){if(1===f||9===f||11===f){if("string"==typeof a.textContent)return a.textContent;for(a=a.firstChild;a;a=a.nextSibling)c+=e(a)}else if(3===f||4===f)return a.nodeValue}else while(b=a[d++])c+=e(b);return c},d=gb.selectors={cacheLength:50,createPseudo:ib,match:X,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(a){return a[1]=a[1].replace(cb,db),a[3]=(a[3]||a[4]||a[5]||"").replace(cb,db),"~="===a[2]&&(a[3]=" "+a[3]+" "),a.slice(0,4)},CHILD:function(a){return a[1]=a[1].toLowerCase(),"nth"===a[1].slice(0,3)?(a[3]||gb.error(a[0]),a[4]=+(a[4]?a[5]+(a[6]||1):2*("even"===a[3]||"odd"===a[3])),a[5]=+(a[7]+a[8]||"odd"===a[3])):a[3]&&gb.error(a[0]),a},PSEUDO:function(a){var b,c=!a[6]&&a[2];return X.CHILD.test(a[0])?null:(a[3]?a[2]=a[4]||a[5]||"":c&&V.test(c)&&(b=g(c,!0))&&(b=c.indexOf(")",c.length-b)-c.length)&&(a[0]=a[0].slice(0,b),a[2]=c.slice(0,b)),a.slice(0,3))}},filter:{TAG:function(a){var b=a.replace(cb,db).toLowerCase();return"*"===a?function(){return!0}:function(a){return a.nodeName&&a.nodeName.toLowerCase()===b}},CLASS:function(a){var b=y[a+" "];return b||(b=new RegExp("(^|"+L+")"+a+"("+L+"|$)"))&&y(a,function(a){return b.test("string"==typeof a.className&&a.className||"undefined"!=typeof a.getAttribute&&a.getAttribute("class")||"")})},ATTR:function(a,b,c){return function(d){var e=gb.attr(d,a);return null==e?"!="===b:b?(e+="","="===b?e===c:"!="===b?e!==c:"^="===b?c&&0===e.indexOf(c):"*="===b?c&&e.indexOf(c)>-1:"$="===b?c&&e.slice(-c.length)===c:"~="===b?(" "+e.replace(Q," ")+" ").indexOf(c)>-1:"|="===b?e===c||e.slice(0,c.length+1)===c+"-":!1):!0}},CHILD:function(a,b,c,d,e){var f="nth"!==a.slice(0,3),g="last"!==a.slice(-4),h="of-type"===b;return 1===d&&0===e?function(a){return!!a.parentNode}:function(b,c,i){var j,k,l,m,n,o,p=f!==g?"nextSibling":"previousSibling",q=b.parentNode,r=h&&b.nodeName.toLowerCase(),s=!i&&!h;if(q){if(f){while(p){l=b;while(l=l[p])if(h?l.nodeName.toLowerCase()===r:1===l.nodeType)return!1;o=p="only"===a&&!o&&"nextSibling"}return!0}if(o=[g?q.firstChild:q.lastChild],g&&s){k=q[u]||(q[u]={}),j=k[a]||[],n=j[0]===w&&j[1],m=j[0]===w&&j[2],l=n&&q.childNodes[n];while(l=++n&&l&&l[p]||(m=n=0)||o.pop())if(1===l.nodeType&&++m&&l===b){k[a]=[w,n,m];break}}else if(s&&(j=(b[u]||(b[u]={}))[a])&&j[0]===w)m=j[1];else while(l=++n&&l&&l[p]||(m=n=0)||o.pop())if((h?l.nodeName.toLowerCase()===r:1===l.nodeType)&&++m&&(s&&((l[u]||(l[u]={}))[a]=[w,m]),l===b))break;return m-=e,m===d||m%d===0&&m/d>=0}}},PSEUDO:function(a,b){var c,e=d.pseudos[a]||d.setFilters[a.toLowerCase()]||gb.error("unsupported pseudo: "+a);return e[u]?e(b):e.length>1?(c=[a,a,"",b],d.setFilters.hasOwnProperty(a.toLowerCase())?ib(function(a,c){var d,f=e(a,b),g=f.length;while(g--)d=J(a,f[g]),a[d]=!(c[d]=f[g])}):function(a){return e(a,0,c)}):e}},pseudos:{not:ib(function(a){var b=[],c=[],d=h(a.replace(R,"$1"));return d[u]?ib(function(a,b,c,e){var f,g=d(a,null,e,[]),h=a.length;while(h--)(f=g[h])&&(a[h]=!(b[h]=f))}):function(a,e,f){return b[0]=a,d(b,null,f,c),b[0]=null,!c.pop()}}),has:ib(function(a){return function(b){return gb(a,b).length>0}}),contains:ib(function(a){return a=a.replace(cb,db),function(b){return(b.textContent||b.innerText||e(b)).indexOf(a)>-1}}),lang:ib(function(a){return W.test(a||"")||gb.error("unsupported lang: "+a),a=a.replace(cb,db).toLowerCase(),function(b){var c;do if(c=p?b.lang:b.getAttribute("xml:lang")||b.getAttribute("lang"))return c=c.toLowerCase(),c===a||0===c.indexOf(a+"-");while((b=b.parentNode)&&1===b.nodeType);return!1}}),target:function(b){var c=a.location&&a.location.hash;return c&&c.slice(1)===b.id},root:function(a){return a===o},focus:function(a){return a===n.activeElement&&(!n.hasFocus||n.hasFocus())&&!!(a.type||a.href||~a.tabIndex)},enabled:function(a){return a.disabled===!1},disabled:function(a){return a.disabled===!0},checked:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&!!a.checked||"option"===b&&!!a.selected},selected:function(a){return a.parentNode&&a.parentNode.selectedIndex,a.selected===!0},empty:function(a){for(a=a.firstChild;a;a=a.nextSibling)if(a.nodeType<6)return!1;return!0},parent:function(a){return!d.pseudos.empty(a)},header:function(a){return Z.test(a.nodeName)},input:function(a){return Y.test(a.nodeName)},button:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&"button"===a.type||"button"===b},text:function(a){var b;return"input"===a.nodeName.toLowerCase()&&"text"===a.type&&(null==(b=a.getAttribute("type"))||"text"===b.toLowerCase())},first:ob(function(){return[0]}),last:ob(function(a,b){return[b-1]}),eq:ob(function(a,b,c){return[0>c?c+b:c]}),even:ob(function(a,b){for(var c=0;b>c;c+=2)a.push(c);return a}),odd:ob(function(a,b){for(var c=1;b>c;c+=2)a.push(c);return a}),lt:ob(function(a,b,c){for(var d=0>c?c+b:c;--d>=0;)a.push(d);return a}),gt:ob(function(a,b,c){for(var d=0>c?c+b:c;++db;b++)d+=a[b].value;return d}function sb(a,b,c){var d=b.dir,e=c&&"parentNode"===d,f=x++;return b.first?function(b,c,f){while(b=b[d])if(1===b.nodeType||e)return a(b,c,f)}:function(b,c,g){var h,i,j=[w,f];if(g){while(b=b[d])if((1===b.nodeType||e)&&a(b,c,g))return!0}else while(b=b[d])if(1===b.nodeType||e){if(i=b[u]||(b[u]={}),(h=i[d])&&h[0]===w&&h[1]===f)return j[2]=h[2];if(i[d]=j,j[2]=a(b,c,g))return!0}}}function tb(a){return a.length>1?function(b,c,d){var e=a.length;while(e--)if(!a[e](b,c,d))return!1;return!0}:a[0]}function ub(a,b,c){for(var d=0,e=b.length;e>d;d++)gb(a,b[d],c);return c}function vb(a,b,c,d,e){for(var f,g=[],h=0,i=a.length,j=null!=b;i>h;h++)(f=a[h])&&(!c||c(f,d,e))&&(g.push(f),j&&b.push(h));return g}function wb(a,b,c,d,e,f){return d&&!d[u]&&(d=wb(d)),e&&!e[u]&&(e=wb(e,f)),ib(function(f,g,h,i){var j,k,l,m=[],n=[],o=g.length,p=f||ub(b||"*",h.nodeType?[h]:h,[]),q=!a||!f&&b?p:vb(p,m,a,h,i),r=c?e||(f?a:o||d)?[]:g:q;if(c&&c(q,r,h,i),d){j=vb(r,n),d(j,[],h,i),k=j.length;while(k--)(l=j[k])&&(r[n[k]]=!(q[n[k]]=l))}if(f){if(e||a){if(e){j=[],k=r.length;while(k--)(l=r[k])&&j.push(q[k]=l);e(null,r=[],j,i)}k=r.length;while(k--)(l=r[k])&&(j=e?J(f,l):m[k])>-1&&(f[j]=!(g[j]=l))}}else r=vb(r===g?r.splice(o,r.length):r),e?e(null,g,r,i):H.apply(g,r)})}function xb(a){for(var b,c,e,f=a.length,g=d.relative[a[0].type],h=g||d.relative[" "],i=g?1:0,k=sb(function(a){return a===b},h,!0),l=sb(function(a){return J(b,a)>-1},h,!0),m=[function(a,c,d){var e=!g&&(d||c!==j)||((b=c).nodeType?k(a,c,d):l(a,c,d));return b=null,e}];f>i;i++)if(c=d.relative[a[i].type])m=[sb(tb(m),c)];else{if(c=d.filter[a[i].type].apply(null,a[i].matches),c[u]){for(e=++i;f>e;e++)if(d.relative[a[e].type])break;return wb(i>1&&tb(m),i>1&&rb(a.slice(0,i-1).concat({value:" "===a[i-2].type?"*":""})).replace(R,"$1"),c,e>i&&xb(a.slice(i,e)),f>e&&xb(a=a.slice(e)),f>e&&rb(a))}m.push(c)}return tb(m)}function yb(a,b){var c=b.length>0,e=a.length>0,f=function(f,g,h,i,k){var l,m,o,p=0,q="0",r=f&&[],s=[],t=j,u=f||e&&d.find.TAG("*",k),v=w+=null==t?1:Math.random()||.1,x=u.length;for(k&&(j=g!==n&&g);q!==x&&null!=(l=u[q]);q++){if(e&&l){m=0;while(o=a[m++])if(o(l,g,h)){i.push(l);break}k&&(w=v)}c&&((l=!o&&l)&&p--,f&&r.push(l))}if(p+=q,c&&q!==p){m=0;while(o=b[m++])o(r,s,g,h);if(f){if(p>0)while(q--)r[q]||s[q]||(s[q]=F.call(i));s=vb(s)}H.apply(i,s),k&&!f&&s.length>0&&p+b.length>1&&gb.uniqueSort(i)}return k&&(w=v,j=t),r};return c?ib(f):f}return h=gb.compile=function(a,b){var c,d=[],e=[],f=A[a+" "];if(!f){b||(b=g(a)),c=b.length;while(c--)f=xb(b[c]),f[u]?d.push(f):e.push(f);f=A(a,yb(e,d)),f.selector=a}return f},i=gb.select=function(a,b,e,f){var i,j,k,l,m,n="function"==typeof a&&a,o=!f&&g(a=n.selector||a);if(e=e||[],1===o.length){if(j=o[0]=o[0].slice(0),j.length>2&&"ID"===(k=j[0]).type&&c.getById&&9===b.nodeType&&p&&d.relative[j[1].type]){if(b=(d.find.ID(k.matches[0].replace(cb,db),b)||[])[0],!b)return e;n&&(b=b.parentNode),a=a.slice(j.shift().value.length)}i=X.needsContext.test(a)?0:j.length;while(i--){if(k=j[i],d.relative[l=k.type])break;if((m=d.find[l])&&(f=m(k.matches[0].replace(cb,db),ab.test(j[0].type)&&pb(b.parentNode)||b))){if(j.splice(i,1),a=f.length&&rb(j),!a)return H.apply(e,f),e;break}}}return(n||h(a,o))(f,b,!p,e,ab.test(a)&&pb(b.parentNode)||b),e},c.sortStable=u.split("").sort(B).join("")===u,c.detectDuplicates=!!l,m(),c.sortDetached=jb(function(a){return 1&a.compareDocumentPosition(n.createElement("div"))}),jb(function(a){return a.innerHTML="","#"===a.firstChild.getAttribute("href")})||kb("type|href|height|width",function(a,b,c){return c?void 0:a.getAttribute(b,"type"===b.toLowerCase()?1:2)}),c.attributes&&jb(function(a){return a.innerHTML="",a.firstChild.setAttribute("value",""),""===a.firstChild.getAttribute("value")})||kb("value",function(a,b,c){return c||"input"!==a.nodeName.toLowerCase()?void 0:a.defaultValue}),jb(function(a){return null==a.getAttribute("disabled")})||kb(K,function(a,b,c){var d;return c?void 0:a[b]===!0?b.toLowerCase():(d=a.getAttributeNode(b))&&d.specified?d.value:null}),gb}(a);n.find=t,n.expr=t.selectors,n.expr[":"]=n.expr.pseudos,n.unique=t.uniqueSort,n.text=t.getText,n.isXMLDoc=t.isXML,n.contains=t.contains;var u=n.expr.match.needsContext,v=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,w=/^.[^:#\[\.,]*$/;function x(a,b,c){if(n.isFunction(b))return n.grep(a,function(a,d){return!!b.call(a,d,a)!==c});if(b.nodeType)return n.grep(a,function(a){return a===b!==c});if("string"==typeof b){if(w.test(b))return n.filter(b,a,c);b=n.filter(b,a)}return n.grep(a,function(a){return g.call(b,a)>=0!==c})}n.filter=function(a,b,c){var d=b[0];return c&&(a=":not("+a+")"),1===b.length&&1===d.nodeType?n.find.matchesSelector(d,a)?[d]:[]:n.find.matches(a,n.grep(b,function(a){return 1===a.nodeType}))},n.fn.extend({find:function(a){var b,c=this.length,d=[],e=this;if("string"!=typeof a)return this.pushStack(n(a).filter(function(){for(b=0;c>b;b++)if(n.contains(e[b],this))return!0}));for(b=0;c>b;b++)n.find(a,e[b],d);return d=this.pushStack(c>1?n.unique(d):d),d.selector=this.selector?this.selector+" "+a:a,d},filter:function(a){return this.pushStack(x(this,a||[],!1))},not:function(a){return this.pushStack(x(this,a||[],!0))},is:function(a){return!!x(this,"string"==typeof a&&u.test(a)?n(a):a||[],!1).length}});var y,z=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,A=n.fn.init=function(a,b){var c,d;if(!a)return this;if("string"==typeof a){if(c="<"===a[0]&&">"===a[a.length-1]&&a.length>=3?[null,a,null]:z.exec(a),!c||!c[1]&&b)return!b||b.jquery?(b||y).find(a):this.constructor(b).find(a);if(c[1]){if(b=b instanceof n?b[0]:b,n.merge(this,n.parseHTML(c[1],b&&b.nodeType?b.ownerDocument||b:l,!0)),v.test(c[1])&&n.isPlainObject(b))for(c in b)n.isFunction(this[c])?this[c](b[c]):this.attr(c,b[c]);return this}return d=l.getElementById(c[2]),d&&d.parentNode&&(this.length=1,this[0]=d),this.context=l,this.selector=a,this}return a.nodeType?(this.context=this[0]=a,this.length=1,this):n.isFunction(a)?"undefined"!=typeof y.ready?y.ready(a):a(n):(void 0!==a.selector&&(this.selector=a.selector,this.context=a.context),n.makeArray(a,this))};A.prototype=n.fn,y=n(l);var B=/^(?:parents|prev(?:Until|All))/,C={children:!0,contents:!0,next:!0,prev:!0};n.extend({dir:function(a,b,c){var d=[],e=void 0!==c;while((a=a[b])&&9!==a.nodeType)if(1===a.nodeType){if(e&&n(a).is(c))break;d.push(a)}return d},sibling:function(a,b){for(var c=[];a;a=a.nextSibling)1===a.nodeType&&a!==b&&c.push(a);return c}}),n.fn.extend({has:function(a){var b=n(a,this),c=b.length;return this.filter(function(){for(var a=0;c>a;a++)if(n.contains(this,b[a]))return!0})},closest:function(a,b){for(var c,d=0,e=this.length,f=[],g=u.test(a)||"string"!=typeof a?n(a,b||this.context):0;e>d;d++)for(c=this[d];c&&c!==b;c=c.parentNode)if(c.nodeType<11&&(g?g.index(c)>-1:1===c.nodeType&&n.find.matchesSelector(c,a))){f.push(c);break}return this.pushStack(f.length>1?n.unique(f):f)},index:function(a){return a?"string"==typeof a?g.call(n(a),this[0]):g.call(this,a.jquery?a[0]:a):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(a,b){return this.pushStack(n.unique(n.merge(this.get(),n(a,b))))},addBack:function(a){return this.add(null==a?this.prevObject:this.prevObject.filter(a))}});function D(a,b){while((a=a[b])&&1!==a.nodeType);return a}n.each({parent:function(a){var b=a.parentNode;return b&&11!==b.nodeType?b:null},parents:function(a){return n.dir(a,"parentNode")},parentsUntil:function(a,b,c){return n.dir(a,"parentNode",c)},next:function(a){return D(a,"nextSibling")},prev:function(a){return D(a,"previousSibling")},nextAll:function(a){return n.dir(a,"nextSibling")},prevAll:function(a){return n.dir(a,"previousSibling")},nextUntil:function(a,b,c){return n.dir(a,"nextSibling",c)},prevUntil:function(a,b,c){return n.dir(a,"previousSibling",c)},siblings:function(a){return n.sibling((a.parentNode||{}).firstChild,a)},children:function(a){return n.sibling(a.firstChild)},contents:function(a){return a.contentDocument||n.merge([],a.childNodes)}},function(a,b){n.fn[a]=function(c,d){var e=n.map(this,b,c);return"Until"!==a.slice(-5)&&(d=c),d&&"string"==typeof d&&(e=n.filter(d,e)),this.length>1&&(C[a]||n.unique(e),B.test(a)&&e.reverse()),this.pushStack(e)}});var E=/\S+/g,F={};function G(a){var b=F[a]={};return n.each(a.match(E)||[],function(a,c){b[c]=!0}),b}n.Callbacks=function(a){a="string"==typeof a?F[a]||G(a):n.extend({},a);var b,c,d,e,f,g,h=[],i=!a.once&&[],j=function(l){for(b=a.memory&&l,c=!0,g=e||0,e=0,f=h.length,d=!0;h&&f>g;g++)if(h[g].apply(l[0],l[1])===!1&&a.stopOnFalse){b=!1;break}d=!1,h&&(i?i.length&&j(i.shift()):b?h=[]:k.disable())},k={add:function(){if(h){var c=h.length;!function g(b){n.each(b,function(b,c){var d=n.type(c);"function"===d?a.unique&&k.has(c)||h.push(c):c&&c.length&&"string"!==d&&g(c)})}(arguments),d?f=h.length:b&&(e=c,j(b))}return this},remove:function(){return h&&n.each(arguments,function(a,b){var c;while((c=n.inArray(b,h,c))>-1)h.splice(c,1),d&&(f>=c&&f--,g>=c&&g--)}),this},has:function(a){return a?n.inArray(a,h)>-1:!(!h||!h.length)},empty:function(){return h=[],f=0,this},disable:function(){return h=i=b=void 0,this},disabled:function(){return!h},lock:function(){return i=void 0,b||k.disable(),this},locked:function(){return!i},fireWith:function(a,b){return!h||c&&!i||(b=b||[],b=[a,b.slice?b.slice():b],d?i.push(b):j(b)),this},fire:function(){return k.fireWith(this,arguments),this},fired:function(){return!!c}};return k},n.extend({Deferred:function(a){var b=[["resolve","done",n.Callbacks("once memory"),"resolved"],["reject","fail",n.Callbacks("once memory"),"rejected"],["notify","progress",n.Callbacks("memory")]],c="pending",d={state:function(){return c},always:function(){return e.done(arguments).fail(arguments),this},then:function(){var a=arguments;return n.Deferred(function(c){n.each(b,function(b,f){var g=n.isFunction(a[b])&&a[b];e[f[1]](function(){var a=g&&g.apply(this,arguments);a&&n.isFunction(a.promise)?a.promise().done(c.resolve).fail(c.reject).progress(c.notify):c[f[0]+"With"](this===d?c.promise():this,g?[a]:arguments)})}),a=null}).promise()},promise:function(a){return null!=a?n.extend(a,d):d}},e={};return d.pipe=d.then,n.each(b,function(a,f){var g=f[2],h=f[3];d[f[1]]=g.add,h&&g.add(function(){c=h},b[1^a][2].disable,b[2][2].lock),e[f[0]]=function(){return e[f[0]+"With"](this===e?d:this,arguments),this},e[f[0]+"With"]=g.fireWith}),d.promise(e),a&&a.call(e,e),e},when:function(a){var b=0,c=d.call(arguments),e=c.length,f=1!==e||a&&n.isFunction(a.promise)?e:0,g=1===f?a:n.Deferred(),h=function(a,b,c){return function(e){b[a]=this,c[a]=arguments.length>1?d.call(arguments):e,c===i?g.notifyWith(b,c):--f||g.resolveWith(b,c)}},i,j,k;if(e>1)for(i=new Array(e),j=new Array(e),k=new Array(e);e>b;b++)c[b]&&n.isFunction(c[b].promise)?c[b].promise().done(h(b,k,c)).fail(g.reject).progress(h(b,j,i)):--f;return f||g.resolveWith(k,c),g.promise()}});var H;n.fn.ready=function(a){return n.ready.promise().done(a),this},n.extend({isReady:!1,readyWait:1,holdReady:function(a){a?n.readyWait++:n.ready(!0)},ready:function(a){(a===!0?--n.readyWait:n.isReady)||(n.isReady=!0,a!==!0&&--n.readyWait>0||(H.resolveWith(l,[n]),n.fn.triggerHandler&&(n(l).triggerHandler("ready"),n(l).off("ready"))))}});function I(){l.removeEventListener("DOMContentLoaded",I,!1),a.removeEventListener("load",I,!1),n.ready()}n.ready.promise=function(b){return H||(H=n.Deferred(),"complete"===l.readyState?setTimeout(n.ready):(l.addEventListener("DOMContentLoaded",I,!1),a.addEventListener("load",I,!1))),H.promise(b)},n.ready.promise();var J=n.access=function(a,b,c,d,e,f,g){var h=0,i=a.length,j=null==c;if("object"===n.type(c)){e=!0;for(h in c)n.access(a,b,h,c[h],!0,f,g)}else if(void 0!==d&&(e=!0,n.isFunction(d)||(g=!0),j&&(g?(b.call(a,d),b=null):(j=b,b=function(a,b,c){return j.call(n(a),c)})),b))for(;i>h;h++)b(a[h],c,g?d:d.call(a[h],h,b(a[h],c)));return e?a:j?b.call(a):i?b(a[0],c):f};n.acceptData=function(a){return 1===a.nodeType||9===a.nodeType||!+a.nodeType};function K(){Object.defineProperty(this.cache={},0,{get:function(){return{}}}),this.expando=n.expando+K.uid++}K.uid=1,K.accepts=n.acceptData,K.prototype={key:function(a){if(!K.accepts(a))return 0;var b={},c=a[this.expando];if(!c){c=K.uid++;try{b[this.expando]={value:c},Object.defineProperties(a,b)}catch(d){b[this.expando]=c,n.extend(a,b)}}return this.cache[c]||(this.cache[c]={}),c},set:function(a,b,c){var d,e=this.key(a),f=this.cache[e];if("string"==typeof b)f[b]=c;else if(n.isEmptyObject(f))n.extend(this.cache[e],b);else for(d in b)f[d]=b[d];return f},get:function(a,b){var c=this.cache[this.key(a)];return void 0===b?c:c[b]},access:function(a,b,c){var d;return void 0===b||b&&"string"==typeof b&&void 0===c?(d=this.get(a,b),void 0!==d?d:this.get(a,n.camelCase(b))):(this.set(a,b,c),void 0!==c?c:b)},remove:function(a,b){var c,d,e,f=this.key(a),g=this.cache[f];if(void 0===b)this.cache[f]={};else{n.isArray(b)?d=b.concat(b.map(n.camelCase)):(e=n.camelCase(b),b in g?d=[b,e]:(d=e,d=d in g?[d]:d.match(E)||[])),c=d.length;while(c--)delete g[d[c]]}},hasData:function(a){return!n.isEmptyObject(this.cache[a[this.expando]]||{})},discard:function(a){a[this.expando]&&delete this.cache[a[this.expando]]}};var L=new K,M=new K,N=/^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,O=/([A-Z])/g;function P(a,b,c){var d;if(void 0===c&&1===a.nodeType)if(d="data-"+b.replace(O,"-$1").toLowerCase(),c=a.getAttribute(d),"string"==typeof c){try{c="true"===c?!0:"false"===c?!1:"null"===c?null:+c+""===c?+c:N.test(c)?n.parseJSON(c):c}catch(e){}M.set(a,b,c)}else c=void 0;return c}n.extend({hasData:function(a){return M.hasData(a)||L.hasData(a)},data:function(a,b,c){return M.access(a,b,c) +},removeData:function(a,b){M.remove(a,b)},_data:function(a,b,c){return L.access(a,b,c)},_removeData:function(a,b){L.remove(a,b)}}),n.fn.extend({data:function(a,b){var c,d,e,f=this[0],g=f&&f.attributes;if(void 0===a){if(this.length&&(e=M.get(f),1===f.nodeType&&!L.get(f,"hasDataAttrs"))){c=g.length;while(c--)g[c]&&(d=g[c].name,0===d.indexOf("data-")&&(d=n.camelCase(d.slice(5)),P(f,d,e[d])));L.set(f,"hasDataAttrs",!0)}return e}return"object"==typeof a?this.each(function(){M.set(this,a)}):J(this,function(b){var c,d=n.camelCase(a);if(f&&void 0===b){if(c=M.get(f,a),void 0!==c)return c;if(c=M.get(f,d),void 0!==c)return c;if(c=P(f,d,void 0),void 0!==c)return c}else this.each(function(){var c=M.get(this,d);M.set(this,d,b),-1!==a.indexOf("-")&&void 0!==c&&M.set(this,a,b)})},null,b,arguments.length>1,null,!0)},removeData:function(a){return this.each(function(){M.remove(this,a)})}}),n.extend({queue:function(a,b,c){var d;return a?(b=(b||"fx")+"queue",d=L.get(a,b),c&&(!d||n.isArray(c)?d=L.access(a,b,n.makeArray(c)):d.push(c)),d||[]):void 0},dequeue:function(a,b){b=b||"fx";var c=n.queue(a,b),d=c.length,e=c.shift(),f=n._queueHooks(a,b),g=function(){n.dequeue(a,b)};"inprogress"===e&&(e=c.shift(),d--),e&&("fx"===b&&c.unshift("inprogress"),delete f.stop,e.call(a,g,f)),!d&&f&&f.empty.fire()},_queueHooks:function(a,b){var c=b+"queueHooks";return L.get(a,c)||L.access(a,c,{empty:n.Callbacks("once memory").add(function(){L.remove(a,[b+"queue",c])})})}}),n.fn.extend({queue:function(a,b){var c=2;return"string"!=typeof a&&(b=a,a="fx",c--),arguments.lengthx",k.noCloneChecked=!!b.cloneNode(!0).lastChild.defaultValue}();var U="undefined";k.focusinBubbles="onfocusin"in a;var V=/^key/,W=/^(?:mouse|pointer|contextmenu)|click/,X=/^(?:focusinfocus|focusoutblur)$/,Y=/^([^.]*)(?:\.(.+)|)$/;function Z(){return!0}function $(){return!1}function _(){try{return l.activeElement}catch(a){}}n.event={global:{},add:function(a,b,c,d,e){var f,g,h,i,j,k,l,m,o,p,q,r=L.get(a);if(r){c.handler&&(f=c,c=f.handler,e=f.selector),c.guid||(c.guid=n.guid++),(i=r.events)||(i=r.events={}),(g=r.handle)||(g=r.handle=function(b){return typeof n!==U&&n.event.triggered!==b.type?n.event.dispatch.apply(a,arguments):void 0}),b=(b||"").match(E)||[""],j=b.length;while(j--)h=Y.exec(b[j])||[],o=q=h[1],p=(h[2]||"").split(".").sort(),o&&(l=n.event.special[o]||{},o=(e?l.delegateType:l.bindType)||o,l=n.event.special[o]||{},k=n.extend({type:o,origType:q,data:d,handler:c,guid:c.guid,selector:e,needsContext:e&&n.expr.match.needsContext.test(e),namespace:p.join(".")},f),(m=i[o])||(m=i[o]=[],m.delegateCount=0,l.setup&&l.setup.call(a,d,p,g)!==!1||a.addEventListener&&a.addEventListener(o,g,!1)),l.add&&(l.add.call(a,k),k.handler.guid||(k.handler.guid=c.guid)),e?m.splice(m.delegateCount++,0,k):m.push(k),n.event.global[o]=!0)}},remove:function(a,b,c,d,e){var f,g,h,i,j,k,l,m,o,p,q,r=L.hasData(a)&&L.get(a);if(r&&(i=r.events)){b=(b||"").match(E)||[""],j=b.length;while(j--)if(h=Y.exec(b[j])||[],o=q=h[1],p=(h[2]||"").split(".").sort(),o){l=n.event.special[o]||{},o=(d?l.delegateType:l.bindType)||o,m=i[o]||[],h=h[2]&&new RegExp("(^|\\.)"+p.join("\\.(?:.*\\.|)")+"(\\.|$)"),g=f=m.length;while(f--)k=m[f],!e&&q!==k.origType||c&&c.guid!==k.guid||h&&!h.test(k.namespace)||d&&d!==k.selector&&("**"!==d||!k.selector)||(m.splice(f,1),k.selector&&m.delegateCount--,l.remove&&l.remove.call(a,k));g&&!m.length&&(l.teardown&&l.teardown.call(a,p,r.handle)!==!1||n.removeEvent(a,o,r.handle),delete i[o])}else for(o in i)n.event.remove(a,o+b[j],c,d,!0);n.isEmptyObject(i)&&(delete r.handle,L.remove(a,"events"))}},trigger:function(b,c,d,e){var f,g,h,i,k,m,o,p=[d||l],q=j.call(b,"type")?b.type:b,r=j.call(b,"namespace")?b.namespace.split("."):[];if(g=h=d=d||l,3!==d.nodeType&&8!==d.nodeType&&!X.test(q+n.event.triggered)&&(q.indexOf(".")>=0&&(r=q.split("."),q=r.shift(),r.sort()),k=q.indexOf(":")<0&&"on"+q,b=b[n.expando]?b:new n.Event(q,"object"==typeof b&&b),b.isTrigger=e?2:3,b.namespace=r.join("."),b.namespace_re=b.namespace?new RegExp("(^|\\.)"+r.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,b.result=void 0,b.target||(b.target=d),c=null==c?[b]:n.makeArray(c,[b]),o=n.event.special[q]||{},e||!o.trigger||o.trigger.apply(d,c)!==!1)){if(!e&&!o.noBubble&&!n.isWindow(d)){for(i=o.delegateType||q,X.test(i+q)||(g=g.parentNode);g;g=g.parentNode)p.push(g),h=g;h===(d.ownerDocument||l)&&p.push(h.defaultView||h.parentWindow||a)}f=0;while((g=p[f++])&&!b.isPropagationStopped())b.type=f>1?i:o.bindType||q,m=(L.get(g,"events")||{})[b.type]&&L.get(g,"handle"),m&&m.apply(g,c),m=k&&g[k],m&&m.apply&&n.acceptData(g)&&(b.result=m.apply(g,c),b.result===!1&&b.preventDefault());return b.type=q,e||b.isDefaultPrevented()||o._default&&o._default.apply(p.pop(),c)!==!1||!n.acceptData(d)||k&&n.isFunction(d[q])&&!n.isWindow(d)&&(h=d[k],h&&(d[k]=null),n.event.triggered=q,d[q](),n.event.triggered=void 0,h&&(d[k]=h)),b.result}},dispatch:function(a){a=n.event.fix(a);var b,c,e,f,g,h=[],i=d.call(arguments),j=(L.get(this,"events")||{})[a.type]||[],k=n.event.special[a.type]||{};if(i[0]=a,a.delegateTarget=this,!k.preDispatch||k.preDispatch.call(this,a)!==!1){h=n.event.handlers.call(this,a,j),b=0;while((f=h[b++])&&!a.isPropagationStopped()){a.currentTarget=f.elem,c=0;while((g=f.handlers[c++])&&!a.isImmediatePropagationStopped())(!a.namespace_re||a.namespace_re.test(g.namespace))&&(a.handleObj=g,a.data=g.data,e=((n.event.special[g.origType]||{}).handle||g.handler).apply(f.elem,i),void 0!==e&&(a.result=e)===!1&&(a.preventDefault(),a.stopPropagation()))}return k.postDispatch&&k.postDispatch.call(this,a),a.result}},handlers:function(a,b){var c,d,e,f,g=[],h=b.delegateCount,i=a.target;if(h&&i.nodeType&&(!a.button||"click"!==a.type))for(;i!==this;i=i.parentNode||this)if(i.disabled!==!0||"click"!==a.type){for(d=[],c=0;h>c;c++)f=b[c],e=f.selector+" ",void 0===d[e]&&(d[e]=f.needsContext?n(e,this).index(i)>=0:n.find(e,this,null,[i]).length),d[e]&&d.push(f);d.length&&g.push({elem:i,handlers:d})}return h]*)\/>/gi,bb=/<([\w:]+)/,cb=/<|&#?\w+;/,db=/<(?:script|style|link)/i,eb=/checked\s*(?:[^=]|=\s*.checked.)/i,fb=/^$|\/(?:java|ecma)script/i,gb=/^true\/(.*)/,hb=/^\s*\s*$/g,ib={option:[1,""],thead:[1,"","
"],col:[2,"","
"],tr:[2,"","
"],td:[3,"","
"],_default:[0,"",""]};ib.optgroup=ib.option,ib.tbody=ib.tfoot=ib.colgroup=ib.caption=ib.thead,ib.th=ib.td;function jb(a,b){return n.nodeName(a,"table")&&n.nodeName(11!==b.nodeType?b:b.firstChild,"tr")?a.getElementsByTagName("tbody")[0]||a.appendChild(a.ownerDocument.createElement("tbody")):a}function kb(a){return a.type=(null!==a.getAttribute("type"))+"/"+a.type,a}function lb(a){var b=gb.exec(a.type);return b?a.type=b[1]:a.removeAttribute("type"),a}function mb(a,b){for(var c=0,d=a.length;d>c;c++)L.set(a[c],"globalEval",!b||L.get(b[c],"globalEval"))}function nb(a,b){var c,d,e,f,g,h,i,j;if(1===b.nodeType){if(L.hasData(a)&&(f=L.access(a),g=L.set(b,f),j=f.events)){delete g.handle,g.events={};for(e in j)for(c=0,d=j[e].length;d>c;c++)n.event.add(b,e,j[e][c])}M.hasData(a)&&(h=M.access(a),i=n.extend({},h),M.set(b,i))}}function ob(a,b){var c=a.getElementsByTagName?a.getElementsByTagName(b||"*"):a.querySelectorAll?a.querySelectorAll(b||"*"):[];return void 0===b||b&&n.nodeName(a,b)?n.merge([a],c):c}function pb(a,b){var c=b.nodeName.toLowerCase();"input"===c&&T.test(a.type)?b.checked=a.checked:("input"===c||"textarea"===c)&&(b.defaultValue=a.defaultValue)}n.extend({clone:function(a,b,c){var d,e,f,g,h=a.cloneNode(!0),i=n.contains(a.ownerDocument,a);if(!(k.noCloneChecked||1!==a.nodeType&&11!==a.nodeType||n.isXMLDoc(a)))for(g=ob(h),f=ob(a),d=0,e=f.length;e>d;d++)pb(f[d],g[d]);if(b)if(c)for(f=f||ob(a),g=g||ob(h),d=0,e=f.length;e>d;d++)nb(f[d],g[d]);else nb(a,h);return g=ob(h,"script"),g.length>0&&mb(g,!i&&ob(a,"script")),h},buildFragment:function(a,b,c,d){for(var e,f,g,h,i,j,k=b.createDocumentFragment(),l=[],m=0,o=a.length;o>m;m++)if(e=a[m],e||0===e)if("object"===n.type(e))n.merge(l,e.nodeType?[e]:e);else if(cb.test(e)){f=f||k.appendChild(b.createElement("div")),g=(bb.exec(e)||["",""])[1].toLowerCase(),h=ib[g]||ib._default,f.innerHTML=h[1]+e.replace(ab,"<$1>")+h[2],j=h[0];while(j--)f=f.lastChild;n.merge(l,f.childNodes),f=k.firstChild,f.textContent=""}else l.push(b.createTextNode(e));k.textContent="",m=0;while(e=l[m++])if((!d||-1===n.inArray(e,d))&&(i=n.contains(e.ownerDocument,e),f=ob(k.appendChild(e),"script"),i&&mb(f),c)){j=0;while(e=f[j++])fb.test(e.type||"")&&c.push(e)}return k},cleanData:function(a){for(var b,c,d,e,f=n.event.special,g=0;void 0!==(c=a[g]);g++){if(n.acceptData(c)&&(e=c[L.expando],e&&(b=L.cache[e]))){if(b.events)for(d in b.events)f[d]?n.event.remove(c,d):n.removeEvent(c,d,b.handle);L.cache[e]&&delete L.cache[e]}delete M.cache[c[M.expando]]}}}),n.fn.extend({text:function(a){return J(this,function(a){return void 0===a?n.text(this):this.empty().each(function(){(1===this.nodeType||11===this.nodeType||9===this.nodeType)&&(this.textContent=a)})},null,a,arguments.length)},append:function(){return this.domManip(arguments,function(a){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var b=jb(this,a);b.appendChild(a)}})},prepend:function(){return this.domManip(arguments,function(a){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var b=jb(this,a);b.insertBefore(a,b.firstChild)}})},before:function(){return this.domManip(arguments,function(a){this.parentNode&&this.parentNode.insertBefore(a,this)})},after:function(){return this.domManip(arguments,function(a){this.parentNode&&this.parentNode.insertBefore(a,this.nextSibling)})},remove:function(a,b){for(var c,d=a?n.filter(a,this):this,e=0;null!=(c=d[e]);e++)b||1!==c.nodeType||n.cleanData(ob(c)),c.parentNode&&(b&&n.contains(c.ownerDocument,c)&&mb(ob(c,"script")),c.parentNode.removeChild(c));return this},empty:function(){for(var a,b=0;null!=(a=this[b]);b++)1===a.nodeType&&(n.cleanData(ob(a,!1)),a.textContent="");return this},clone:function(a,b){return a=null==a?!1:a,b=null==b?a:b,this.map(function(){return n.clone(this,a,b)})},html:function(a){return J(this,function(a){var b=this[0]||{},c=0,d=this.length;if(void 0===a&&1===b.nodeType)return b.innerHTML;if("string"==typeof a&&!db.test(a)&&!ib[(bb.exec(a)||["",""])[1].toLowerCase()]){a=a.replace(ab,"<$1>");try{for(;d>c;c++)b=this[c]||{},1===b.nodeType&&(n.cleanData(ob(b,!1)),b.innerHTML=a);b=0}catch(e){}}b&&this.empty().append(a)},null,a,arguments.length)},replaceWith:function(){var a=arguments[0];return this.domManip(arguments,function(b){a=this.parentNode,n.cleanData(ob(this)),a&&a.replaceChild(b,this)}),a&&(a.length||a.nodeType)?this:this.remove()},detach:function(a){return this.remove(a,!0)},domManip:function(a,b){a=e.apply([],a);var c,d,f,g,h,i,j=0,l=this.length,m=this,o=l-1,p=a[0],q=n.isFunction(p);if(q||l>1&&"string"==typeof p&&!k.checkClone&&eb.test(p))return this.each(function(c){var d=m.eq(c);q&&(a[0]=p.call(this,c,d.html())),d.domManip(a,b)});if(l&&(c=n.buildFragment(a,this[0].ownerDocument,!1,this),d=c.firstChild,1===c.childNodes.length&&(c=d),d)){for(f=n.map(ob(c,"script"),kb),g=f.length;l>j;j++)h=c,j!==o&&(h=n.clone(h,!0,!0),g&&n.merge(f,ob(h,"script"))),b.call(this[j],h,j);if(g)for(i=f[f.length-1].ownerDocument,n.map(f,lb),j=0;g>j;j++)h=f[j],fb.test(h.type||"")&&!L.access(h,"globalEval")&&n.contains(i,h)&&(h.src?n._evalUrl&&n._evalUrl(h.src):n.globalEval(h.textContent.replace(hb,"")))}return this}}),n.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(a,b){n.fn[a]=function(a){for(var c,d=[],e=n(a),g=e.length-1,h=0;g>=h;h++)c=h===g?this:this.clone(!0),n(e[h])[b](c),f.apply(d,c.get());return this.pushStack(d)}});var qb,rb={};function sb(b,c){var d,e=n(c.createElement(b)).appendTo(c.body),f=a.getDefaultComputedStyle&&(d=a.getDefaultComputedStyle(e[0]))?d.display:n.css(e[0],"display");return e.detach(),f}function tb(a){var b=l,c=rb[a];return c||(c=sb(a,b),"none"!==c&&c||(qb=(qb||n("'; + break; + case 3: + delete a.title, + delete a.closeBtn, + -1 === a.icon && a.icon, + m.closeAll("loading"); + break; + case 4: + s || (a.content = [a.content, "body"]), + a.follow = a.content[1], + a.content = a.content[0] + '', + delete a.title, + a.tips = "object" == typeof a.tips ? a.tips : [a.tips, !0], + a.tipsMore || m.closeAll("tips") + } + n.vessel(s, function (e, t, i) { + r.append(e[0]), + s ? 2 == a.type || 4 == a.type ? h("body").append(e[1]) : l.parents("." + d[0])[0] || (l.data("display", l.css("display")).show().addClass("layui-layer-wrap").wrap(e[1]), h("#" + d[0] + o).find("." + d[5]).before(t)) : r.append(e[1]), + h("#" + d.MOVE)[0] || r.append(c.moveElem = i), + n.layero = h("#" + d[0] + o), + n.shadeo = h("#" + d.SHADE + o), + a.scrollbar || d.html.css("overflow", "hidden").attr("layer-full", o) + }).auto(o), + n.shadeo.css({ + "background-color": a.shade[1] || "#000", + opacity: a.shade[0] || a.shade + }), + 2 == a.type && 6 == m.ie && n.layero.find("iframe").attr("src", l[0]), + 4 == a.type ? n.tips() : (n.offset(), parseInt(c.getStyle(document.getElementById(d.MOVE), "z-index")) || (n.layero.css("visibility", "hidden"), m.ready(function () { + n.offset(), + n.layero.css("visibility", "visible") + }))), + a.fixed && f.on("resize", function () { + n.offset(), + (/^\d+%$/.test(a.area[0]) || /^\d+%$/.test(a.area[1])) && n.auto(o), + 4 == a.type && n.tips() + }), + a.time <= 0 || setTimeout(function () { + m.close(n.index) + }, a.time), + n.move().callback(), + d.anim[a.anim] && (e = "layer-anim " + d.anim[a.anim], n.layero.addClass(e).one("webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend", function () { + h(this).removeClass(e) + })), + a.isOutAnim && n.layero.data("isOutAnim", !0) + } + }, t.pt.auto = function (e) { + var t = this.config, + i = h("#" + d[0] + e), + n = ("" === t.area[0] && 0 < t.maxWidth && (m.ie && m.ie < 8 && t.btn && i.width(i.innerWidth()), i.outerWidth() > t.maxWidth && i.width(t.maxWidth)), [i.innerWidth(), i.innerHeight()]), + a = i.find(d[1]).outerHeight() || 0, + o = i.find("." + d[6]).outerHeight() || 0, + e = function (e) { + (e = i.find(e)).height(n[1] - a - o - 2 * (0 | parseFloat(e.css("padding-top")))) + }; + return 2 === t.type ? e("iframe") : "" === t.area[1] ? 0 < t.maxHeight && i.outerHeight() > t.maxHeight ? (n[1] = t.maxHeight, e("." + d[5])) : t.fixed && n[1] >= f.height() && (n[1] = f.height(), e("." + d[5])) : e("." + d[5]), + this + }, t.pt.offset = function () { + var e = this, + t = e.config, + i = e.layero, + n = [i.outerWidth(), i.outerHeight()], + a = "object" == typeof t.offset; + e.offsetTop = (f.height() - n[1]) / 2, + e.offsetLeft = (f.width() - n[0]) / 2, + a ? (e.offsetTop = t.offset[0], e.offsetLeft = t.offset[1] || e.offsetLeft) : "auto" !== t.offset && ("t" === t.offset ? e.offsetTop = 0 : "r" === t.offset ? e.offsetLeft = f.width() - n[0] : "b" === t.offset ? e.offsetTop = f.height() - n[1] : "l" === t.offset ? e.offsetLeft = 0 : "lt" === t.offset ? (e.offsetTop = 0, e.offsetLeft = 0) : "lb" === t.offset ? (e.offsetTop = f.height() - n[1], e.offsetLeft = 0) : "rt" === t.offset ? (e.offsetTop = 0, e.offsetLeft = f.width() - n[0]) : "rb" === t.offset ? (e.offsetTop = f.height() - n[1], e.offsetLeft = f.width() - n[0]) : e.offsetTop = t.offset), + t.fixed || (e.offsetTop = /%$/.test(e.offsetTop) ? f.height() * parseFloat(e.offsetTop) / 100 : parseFloat(e.offsetTop), e.offsetLeft = /%$/.test(e.offsetLeft) ? f.width() * parseFloat(e.offsetLeft) / 100 : parseFloat(e.offsetLeft), e.offsetTop += f.scrollTop(), e.offsetLeft += f.scrollLeft()), + i.attr("minLeft") && (e.offsetTop = f.height() - (i.find(d[1]).outerHeight() || 0), e.offsetLeft = i.css("left")), + i.css({ + top: e.offsetTop, + left: e.offsetLeft + }) + }, t.pt.tips = function () { + var e = this.config, + t = this.layero, + i = [t.outerWidth(), t.outerHeight()], + n = h(e.follow), + a = { + width: (n = n[0] ? n : h("body")).outerWidth(), + height: n.outerHeight(), + top: n.offset().top, + left: n.offset().left + }, + o = t.find(".layui-layer-TipsG"), + n = e.tips[0]; + e.tips[1] || o.remove(), + a.autoLeft = function () { + 0 < a.left + i[0] - f.width() ? (a.tipLeft = a.left + a.width - i[0], o.css({ + right: 12, + left: "auto" + })) : a.tipLeft = a.left + }, + a.where = [function () { + a.autoLeft(), + a.tipTop = a.top - i[1] - 10, + o.removeClass("layui-layer-TipsB").addClass("layui-layer-TipsT").css("border-right-color", e.tips[1]) + }, function () { + a.tipLeft = a.left + a.width + 10, + a.tipTop = a.top, + o.removeClass("layui-layer-TipsL").addClass("layui-layer-TipsR").css("border-bottom-color", e.tips[1]) + }, function () { + a.autoLeft(), + a.tipTop = a.top + a.height + 10, + o.removeClass("layui-layer-TipsT").addClass("layui-layer-TipsB").css("border-right-color", e.tips[1]) + }, function () { + a.tipLeft = a.left - i[0] - 10, + a.tipTop = a.top, + o.removeClass("layui-layer-TipsR").addClass("layui-layer-TipsL").css("border-bottom-color", e.tips[1]) + } + ], + a.where[n - 1](), + 1 === n ? a.top - (f.scrollTop() + i[1] + 16) < 0 && a.where[2]() : 2 === n ? 0 < f.width() - (a.left + a.width + i[0] + 16) || a.where[3]() : 3 === n ? 0 < a.top - f.scrollTop() + a.height + i[1] + 16 - f.height() && a.where[0]() : 4 === n && 0 < i[0] + 16 - a.left && a.where[1](), + t.find("." + d[5]).css({ + "background-color": e.tips[1], + "padding-right": e.closeBtn ? "30px" : "" + }), + t.css({ + left: a.tipLeft - (e.fixed ? f.scrollLeft() : 0), + top: a.tipTop - (e.fixed ? f.scrollTop() : 0) + }) + }, t.pt.move = function () { + var o = this, + s = o.config, + e = h(document), + r = o.layero, + t = r.find(s.move), + i = r.find(".layui-layer-resize"), + l = {}; + return s.move && t.css("cursor", "move"), + t.on("mousedown", function (e) { + e.preventDefault(), + s.move && (l.moveStart = !0, l.offset = [e.clientX - parseFloat(r.css("left")), e.clientY - parseFloat(r.css("top"))], c.moveElem.css("cursor", "move").show()) + }), + i.on("mousedown", function (e) { + e.preventDefault(), + l.resizeStart = !0, + l.offset = [e.clientX, e.clientY], + l.area = [r.outerWidth(), r.outerHeight()], + c.moveElem.css("cursor", "se-resize").show() + }), + e.on("mousemove", function (e) { + var t, + i, + n, + a; + l.moveStart && (n = e.clientX - l.offset[0], a = e.clientY - l.offset[1], t = "fixed" === r.css("position"), e.preventDefault(), l.stX = t ? 0 : f.scrollLeft(), l.stY = t ? 0 : f.scrollTop(), s.moveOut || (t = f.width() - r.outerWidth() + l.stX, i = f.height() - r.outerHeight() + l.stY, t < (n = n < l.stX ? l.stX : n) && (n = t), i < (a = a < l.stY ? l.stY : a) && (a = i)), r.css({ + left: n, + top: a + })), + s.resize && l.resizeStart && (n = e.clientX - l.offset[0], a = e.clientY - l.offset[1], e.preventDefault(), m.style(o.index, { + width: l.area[0] + n, + height: l.area[1] + a + }), l.isResize = !0, s.resizing && s.resizing(r)) + }).on("mouseup", function (e) { + l.moveStart && (delete l.moveStart, c.moveElem.hide(), s.moveEnd && s.moveEnd(r)), + l.resizeStart && (delete l.resizeStart, c.moveElem.hide()) + }), + o + }, t.pt.callback = function () { + var t = this, + i = t.layero, + n = t.config; + t.openLayer(), + n.success && (2 == n.type ? i.find("iframe").on("load", function () { + n.success(i, t.index, t) + }) : n.success(i, t.index, t)), + 6 == m.ie && t.IE6(i), + i.find("." + d[6]).children("a").on("click", function () { + var e = h(this).index(); + 0 === e ? n.yes ? n.yes(t.index, i) : n.btn1 ? n.btn1(t.index, i) : m.close(t.index) : !1 !== (n["btn" + (e + 1)] && n["btn" + (e + 1)](t.index, i)) && m.close(t.index) + }), + i.find("." + d[7]).on("click", function () { + !1 !== (n.cancel && n.cancel(t.index, i)) && m.close(t.index) + }), + n.shadeClose && t.shadeo.on("click", function () { + m.close(t.index) + }), + i.find(".layui-layer-min").on("click", function () { + !1 !== (n.min && n.min(i, t.index)) && m.min(t.index, n) + }), + i.find(".layui-layer-max").on("click", function () { + h(this).hasClass("layui-layer-maxmin") ? (m.restore(t.index), n.restore && n.restore(i, t.index)) : (m.full(t.index, n), setTimeout(function () { + n.full && n.full(i, t.index) + }, 100)) + }), + n.end && (c.end[t.index] = n.end) + }, c.reselect = function () { + h.each(h("select"), function (e, t) { + var i = h(this); + i.parents("." + d[0])[0] || 1 == i.attr("layer") && h("." + d[0]).length < 1 && i.removeAttr("layer").show() + }) + }, t.pt.IE6 = function (e) { + h("select").each(function (e, t) { + var i = h(this); + i.parents("." + d[0])[0] || "none" !== i.css("display") && i.attr({ + layer: "1" + }).hide() + }) + }, t.pt.openLayer = function () { + m.zIndex = this.config.zIndex, + m.setTop = function (e) { + return m.zIndex = parseInt(e[0].style.zIndex), + e.on("mousedown", function () { + m.zIndex++, + e.css("z-index", m.zIndex + 1) + }), + m.zIndex + } + }, c.record = function (e) { + var t = [e.width(), e.height(), e.position().top, e.position().left + parseFloat(e.css("margin-left"))]; + e.find(".layui-layer-max").addClass("layui-layer-maxmin"), + e.attr({ + area: t + }) + }, c.rescollbar = function (e) { + d.html.attr("layer-full") == e && (d.html[0].style.removeProperty ? d.html[0].style.removeProperty("overflow") : d.html[0].style.removeAttribute("overflow"), d.html.removeAttr("layer-full")) + }, (p.layer = m).getChildFrame = function (e, t) { + return t = t || h("." + d[4]).attr("times"), + h("#" + d[0] + t).find("iframe").contents().find(e) + }, m.getFrameIndex = function (e) { + return h("#" + e).parents("." + d[4]).attr("times") + }, m.iframeAuto = function (e) { + var t, + i, + n; + e && (t = m.getChildFrame("html", e).outerHeight(), i = (e = h("#" + d[0] + e)).find(d[1]).outerHeight() || 0, n = e.find("." + d[6]).outerHeight() || 0, e.css({ + height: t + i + n + }), e.find("iframe").css({ + height: t + })) + }, m.iframeSrc = function (e, t) { + h("#" + d[0] + e).find("iframe").attr("src", t) + }, m.style = function (e, t, i) { + var e = h("#" + d[0] + e), + n = e.find(".layui-layer-content"), + a = e.attr("type"), + o = e.find(d[1]).outerHeight() || 0, + s = e.find("." + d[6]).outerHeight() || 0; + e.attr("minLeft"); + a !== c.type[3] && a !== c.type[4] && (i || (parseFloat(t.width) <= 260 && (t.width = 260), parseFloat(t.height) - o - s <= 64 && (t.height = 64 + o + s)), e.css(t), s = e.find("." + d[6]).outerHeight() || 0, a === c.type[2] ? e.find("iframe").css({ + height: parseFloat(t.height) - o - s + }) : n.css({ + height: parseFloat(t.height) - o - s - parseFloat(n.css("padding-top")) - parseFloat(n.css("padding-bottom")) + })) + }, m.min = function (e, t) { + t = t || {}; + var i = h("#" + d[0] + e), + n = h("#" + d.SHADE + e), + a = i.find(d[1]).outerHeight() || 0, + o = i.attr("minLeft") || 181 * c.minIndex + "px", + s = i.css("position"), + r = { + width: 180, + height: a, + position: "fixed", + overflow: "hidden" + }; + c.record(i), + c.minLeft[0] && (o = c.minLeft[0], c.minLeft.shift()), + t.minStack && (r.left = o, r.top = f.height() - a, i.attr("minLeft") || c.minIndex++, i.attr("minLeft", o)), + i.attr("position", s), + m.style(e, r, !0), + i.find(".layui-layer-min").hide(), + "page" === i.attr("type") && i.find(d[4]).hide(), + c.rescollbar(e), + n.hide() + }, m.restore = function (e) { + var t = h("#" + d[0] + e), + i = h("#" + d.SHADE + e), + n = t.attr("area").split(","); + t.attr("type"); + m.style(e, { + width: parseFloat(n[0]), + height: parseFloat(n[1]), + top: parseFloat(n[2]), + left: parseFloat(n[3]), + position: t.attr("position"), + overflow: "visible" + }, !0), + t.find(".layui-layer-max").removeClass("layui-layer-maxmin"), + t.find(".layui-layer-min").show(), + "page" === t.attr("type") && t.find(d[4]).show(), + c.rescollbar(e), + i.show() + }, m.full = function (t) { + var i = h("#" + d[0] + t); + c.record(i), + d.html.attr("layer-full") || d.html.css("overflow", "hidden").attr("layer-full", t), + clearTimeout(void 0), + setTimeout(function () { + var e = "fixed" === i.css("position"); + m.style(t, { + top: e ? 0 : f.scrollTop(), + left: e ? 0 : f.scrollLeft(), + width: f.width(), + height: f.height() + }, !0), + i.find(".layui-layer-min").hide() + }, 100) + }, m.title = function (e, t) { + h("#" + d[0] + (t || m.index)).find(d[1]).html(e) + }, m.close = function (a, o) { + var s, + e, + r = h("#" + d[0] + a), + l = r.attr("type"); + r[0] && (s = "layui-layer-wrap", e = function () { + if (l === c.type[1] && "object" === r.attr("conType")) { + r.children(":not(." + d[5] + ")").remove(); + for (var e = r.find("." + s), t = 0; t < 2; t++) + e.unwrap(); + e.css("display", e.data("display")).removeClass(s) + } else { + if (l === c.type[2]) + try { + var i = h("#" + d[4] + a)[0]; + i.contentWindow.document.write(""), + i.contentWindow.close(), + r.find("." + d[5])[0].removeChild(i) + } catch (n) {} + r[0].innerHTML = "", + r.remove() + } + "function" == typeof c.end[a] && c.end[a](), + delete c.end[a], + "function" == typeof o && o() + }, r.data("isOutAnim") && r.addClass("layer-anim layer-anim-close"), h("#layui-layer-moves, #" + d.SHADE + a).remove(), 6 == m.ie && c.reselect(), c.rescollbar(a), r.attr("minLeft") && (c.minIndex--, c.minLeft.push(r.attr("minLeft"))), m.ie && m.ie < 10 || !r.data("isOutAnim") ? e() : setTimeout(function () { + e() + }, 200)) + }, m.closeAll = function (n, a) { + "function" == typeof n && (a = n, n = null); + var o = h("." + d[0]); + h.each(o, function (e) { + var t = h(this), + i = n ? t.attr("type") === n : 1; + i && m.close(t.attr("times"), e === o.length - 1 ? a : null) + }), + 0 === o.length && "function" == typeof a && a() + }, m.cache || {}), + g = function (e) { + return i.skin ? " " + i.skin + " " + i.skin + "-" + e : "" + }; + m.prompt = function (i, n) { + var e = ""; + "function" == typeof(i = i || {}) && (n = i), + i.area && (e = 'style="width: ' + (t = i.area)[0] + "; height: " + t[1] + ';"', delete i.area); + var a, + t = 2 == i.formType ? '" : '', + o = i.success; + return delete i.success, + m.open(h.extend({ + type: 1, + btn: ["确定", "取消"], + content: t, + skin: "layui-layer-prompt" + g("prompt"), + maxWidth: f.width(), + success: function (e) { + (a = e.find(".layui-layer-input")).val(i.value || "").focus(), + "function" == typeof o && o(e) + }, + resize: !1, + yes: function (e) { + var t = a.val(); + "" === t ? a.focus() : t.length > (i.maxlength || 500) ? m.tips("最多输入" + (i.maxlength || 500) + "个字数", a, { + tips: 1 + }) : n && n(t, e, a) + } + }, i)) + }, + m.tab = function (n) { + var a = (n = n || {}).tab || {}, + o = "layui-this", + s = n.success; + return delete n.success, + m.open(h.extend({ + type: 1, + skin: "layui-layer-tab" + g("tab"), + resize: !1, + title: function () { + var e = a.length, + t = 1, + i = ""; + if (0 < e) + for (i = '' + a[0].title + ""; t < e; t++) + i += "" + a[t].title + ""; + return i + } + (), + content: '
    ' + function () { + var e = a.length, + t = 1, + i = ""; + if (0 < e) + for (i = '
  • ' + (a[0].content || "no content") + "
  • "; t < e; t++) + i += '
  • ' + (a[t].content || "no content") + "
  • "; + return i + } + () + "
", + success: function (e) { + var t = e.find(".layui-layer-title").children(), + i = e.find(".layui-layer-tabmain").children(); + t.on("mousedown", function (e) { + e.stopPropagation ? e.stopPropagation() : e.cancelBubble = !0; + var e = h(this), + t = e.index(); + e.addClass(o).siblings().removeClass(o), + i.eq(t).show().siblings().hide(), + "function" == typeof n.change && n.change(t) + }), + "function" == typeof s && s(e) + } + }, n)) + }, + m.photos = function (i, e, n) { + var a = {}; + if ((i = i || {}).photos) { + var t = !("string" == typeof i.photos || i.photos instanceof h), + o = t ? i.photos : {}, + s = o.data || [], + r = o.start || 0, + l = (a.imgIndex = 1 + (0 | r), i.img = i.img || "img", i.success); + if (delete i.success, t) { + if (0 === s.length) + return m.msg("没有图片") + } else { + var f = h(i.photos), + c = function () { + s = [], + f.find(i.img).each(function (e) { + var t = h(this); + t.attr("layer-index", e), + s.push({ + alt: t.attr("alt"), + pid: t.attr("layer-pid"), + src: t.attr("layer-src") || t.attr("src"), + thumb: t.attr("src") + }) + }) + }; + if (c(), 0 === s.length) + return; + if (e || f.on("click", i.img, function () { + c(); + var e = h(this).attr("layer-index"); + m.photos(h.extend(i, { + photos: { + start: e, + data: s, + tab: i.tab + }, + full: i.full + }), !0) + }), !e) + return + } + a.imgprev = function (e) { + a.imgIndex--, + a.imgIndex < 1 && (a.imgIndex = s.length), + a.tabimg(e) + }, + a.imgnext = function (e, t) { + a.imgIndex++, + a.imgIndex > s.length && (a.imgIndex = 1, t) || a.tabimg(e) + }, + a.keyup = function (e) { + var t; + a.end || (t = e.keyCode, e.preventDefault(), 37 === t ? a.imgprev(!0) : 39 === t ? a.imgnext(!0) : 27 === t && m.close(a.index)) + }, + a.tabimg = function (e) { + if (!(s.length <= 1)) + return o.start = a.imgIndex - 1, m.close(a.index), m.photos(i, !0, e) + }, + a.event = function () { + a.bigimg.find(".layui-layer-imgprev").on("click", function (e) { + e.preventDefault(), + a.imgprev(!0) + }), + a.bigimg.find(".layui-layer-imgnext").on("click", function (e) { + e.preventDefault(), + a.imgnext(!0) + }), + h(document).on("keyup", a.keyup) + }, + a.loadi = m.load(1, { + shade: !("shade" in i) && .9, + scrollbar: !1 + }); + var t = s[r].src, + d = function (e) { + var t; + m.close(a.loadi), + n && (i.anim = -1), + a.index = m.open(h.extend({ + type: 1, + id: "layui-layer-photos", + area: (e = [e.width, e.height], t = [h(p).width() - 100, h(p).height() - 100], !i.full && (e[0] > t[0] || e[1] > t[1]) && ((t = [e[0] / t[0], e[1] / t[1]])[1] < t[0] ? (e[0] = e[0] / t[0], e[1] = e[1] / t[0]) : t[0] < t[1] && (e[0] = e[0] / t[1], e[1] = e[1] / t[1])), [e[0] + "px", e[1] + "px"]), + title: !1, + shade: .9, + shadeClose: !0, + closeBtn: !1, + move: ".layui-layer-phimg img", + moveType: 1, + scrollbar: !1, + moveOut: !0, + anim: 5, + isOutAnim: !1, + skin: "layui-layer-photos" + g("photos"), + content: '
' + (s[r].alt || ' + (1 < s.length ? '
' + (s[r].alt || "") + "" + a.imgIndex + " / " + s.length + "
" : "") + "
", + success: function (e, t) { + a.bigimg = e.find(".layui-layer-phimg"), + a.imgsee = e.find(".layui-layer-imgbar"), + a.event(e), + i.tab && i.tab(s[r], e), + "function" == typeof l && l(e) + }, + end: function () { + a.end = !0, + h(document).off("keyup", a.keyup) + } + }, i)) + }, + u = function () { + m.close(a.loadi), + m.msg("当前图片地址异常
是否继续查看下一张?", { + time: 3e4, + btn: ["下一张", "不看了"], + yes: function () { + 1 < s.length && a.imgnext(!0, !0) + } + }) + }, + y = new Image; + (y.src = t, y.complete) ? d(y) : (y.onload = function () { + y.onload = null, + d(y) + }, y.onerror = function (e) { + y.onerror = null, + u(e) + }) + } + }, + c.run = function (e) { + f = (h = e)(p), + d.html = h("html"), + m.open = function (e) { + return new t(e).index + } + }, + p.layui && layui.define ? (m.ready(), layui.define("jquery", function (e) { + m.path = layui.cache.dir, + c.run(layui.$), + e("layer", p.layer = m) + })) : "function" == typeof define && define.amd ? define(["jquery"], function () { + return c.run(p.jQuery), + m + }) : (m.ready(), c.run(p.jQuery)) +} +(window); +layui.define("jquery", function (e) { + "use strict"; + var u = layui.$, + a = layui.hint(), + o = { + fixbar: function (t) { + var e, + i, + n = "layui-fixbar", + o = "layui-fixbar-top", + a = u(document), + r = u("body"), + l = ((t = u.extend({ + showHeight: 200 + }, t)).bar1 = !0 === t.bar1 ? "" : t.bar1, t.bar2 = !0 === t.bar2 ? "" : t.bar2, t.bgcolor = t.bgcolor ? "background-color:" + t.bgcolor : "", [t.bar1, t.bar2, ""]), + l = u(['
    ', t.bar1 ? '
  • ' + l[0] + "
  • " : "", t.bar2 ? '
  • ' + l[1] + "
  • " : "", '
  • ' + l[2] + "
  • ", "
"].join("")), + c = l.find("." + o), + g = function () { + a.scrollTop() >= t.showHeight ? e || (c.show(), e = 1) : e && (c.hide(), e = 0) + }; + u("." + n)[0] || ("object" == typeof t.css && l.css(t.css), r.append(l), g(), l.find("li").on("click", function () { + var e = u(this).attr("lay-type"); + "top" === e && u("html,body").animate({ + scrollTop: 0 + }, 200), + t.click && t.click.call(this, e) + }), a.on("scroll", function () { + clearTimeout(i), + i = setTimeout(function () { + g() + }, 100) + })) + }, + countdown: function (e, t, i) { + var n = this, + o = "function" == typeof t, + a = new Date(e).getTime(), + r = new Date(!t || o ? (new Date).getTime() : t).getTime(), + a = a - r, + l = [Math.floor(a / 864e5), Math.floor(a / 36e5) % 24, Math.floor(a / 6e4) % 60, Math.floor(a / 1e3) % 60], + o = (o && (i = t), setTimeout(function () { + n.countdown(e, r + 1e3, i) + }, 1e3)); + return i && i(0 < a ? l : [0, 0, 0, 0], t, o), + a <= 0 && clearTimeout(o), + o + }, + timeAgo: function (e, t) { + var i = this, + n = [[], []], + o = (new Date).getTime() - new Date(e).getTime(); + return 26784e5 < o ? (o = new Date(e), n[0][0] = i.digit(o.getFullYear(), 4), n[0][1] = i.digit(o.getMonth() + 1), n[0][2] = i.digit(o.getDate()), t || (n[1][0] = i.digit(o.getHours()), n[1][1] = i.digit(o.getMinutes()), n[1][2] = i.digit(o.getSeconds())), n[0].join("-") + " " + n[1].join(":")) : 864e5 <= o ? (o / 1e3 / 60 / 60 / 24 | 0) + "\u5929\u524d" : 36e5 <= o ? (o / 1e3 / 60 / 60 | 0) + "\u5c0f\u65f6\u524d" : 18e4 <= o ? (o / 1e3 / 60 | 0) + "\u5206\u949f\u524d" : o < 0 ? "\u672a\u6765" : "\u521a\u521a" + }, + digit: function (e, t) { + var i = ""; + t = t || 2; + for (var n = (e = String(e)).length; n < t; n++) + i += "0"; + return e < Math.pow(10, t) ? i + (0 | e) : e + }, + toDateString: function (e, t) { + if (null === e || "" === e) + return ""; + var i = this, + n = new Date(function () { + if (e) + return !isNaN(e) && "string" == typeof e ? parseInt(e) : e + } + () || new Date), + o = [i.digit(n.getFullYear(), 4), i.digit(n.getMonth() + 1), i.digit(n.getDate())], + i = [i.digit(n.getHours()), i.digit(n.getMinutes()), i.digit(n.getSeconds())]; + return n.getDate() ? (t = t || "yyyy-MM-dd HH:mm:ss").replace(/yyyy/g, o[0]).replace(/MM/g, o[1]).replace(/dd/g, o[2]).replace(/HH/g, i[0]).replace(/mm/g, i[1]).replace(/ss/g, i[2]) : (a.error('Invalid Msec for "util.toDateString(Msec)"'), "") + }, + escape: function (e) { + return e === undefined || null === e ? "" : /[<"'>]|&(?=#[a-zA-Z0-9]+)/g.test(e += "") ? e.replace(/&(?!#?[a-zA-Z0-9]+;)/g, "&").replace(//g, ">").replace(/'/g, "'").replace(/"/g, """) : e + }, + unescape: function (e) { + return e !== undefined && null !== e || (e = ""), + (e += "").replace(/\&/g, "&").replace(/\</g, "<").replace(/\>/g, ">").replace(/\'/g, "'").replace(/\"/g, '"') + }, + toVisibleArea: function (e) { + var t, + i, + n, + o, + a, + r, + l, + c; + (e = u.extend({ + margin: 160, + duration: 200, + type: "y" + }, e)).scrollElem[0] && e.thisElem[0] && (t = e.scrollElem, l = e.thisElem, n = (a = "y" === e.type) ? "top" : "left", o = t[i = a ? "scrollTop" : "scrollLeft"](), a = t[a ? "height" : "width"](), r = t.offset()[n], c = {}, ((l = l.offset()[n] - r) > a - e.margin || l < e.margin) && (c[i] = l - a / 2 + o, t.animate(c, e.duration))) + }, + event: function (i, n, e) { + var t = u("body"); + return e = e || "click", + n = o.event[i] = u.extend(!0, o.event[i], n) || {}, + o.event.UTIL_EVENT_CALLBACK = o.event.UTIL_EVENT_CALLBACK || {}, + t.off(e, "*[" + i + "]", o.event.UTIL_EVENT_CALLBACK[i]), + o.event.UTIL_EVENT_CALLBACK[i] = function () { + var e = u(this), + t = e.attr(i); + "function" == typeof n[t] && n[t].call(this, e) + }, + t.on(e, "*[" + i + "]", o.event.UTIL_EVENT_CALLBACK[i]), + n + } + }; + o.on = o.event, + e("util", o) +}); +layui.define(["jquery", "laytpl", "lay"], function (e) { + "use strict"; + var n, + i, + t, + s = layui.$, + m = layui.laytpl, + a = layui.hint(), + l = layui.device().mobile ? "click" : "mousedown", + o = "dropdown", + r = "layui_" + o + "_index", + c = { + config: {}, + index: layui[o] ? layui[o].index + 1e4 : 0, + set: function (e) { + var i = this; + return i.config = s.extend({}, i.config, e), + i + }, + on: function (e, i) { + return layui.onevent.call(this, o, e, i) + } + }, + p = function () { + var i = this, + e = i.config, + t = e.id; + return p.that[t] = i, { + config: e, + reload: function (e) { + i.reload.call(i, e) + } + } + }, + u = "layui-menu-item-up", + d = "layui-menu-item-down", + y = "layui-menu-body-title", + f = "layui-menu-item-group", + g = "layui-menu-item-parent", + h = "layui-menu-item-checked", + v = "layui-menu-item-checked2", + w = "layui-menu-body-panel", + C = "layui-menu-body-panel-left", + V = "." + f + ">." + y, + k = function (e) { + var i = this; + i.index = ++c.index, + i.config = s.extend({}, i.config, c.config, e), + i.init() + }; + k.prototype.config = { + trigger: "click", + content: "", + className: "", + style: "", + show: !1, + isAllowSpread: !0, + isSpreadItem: !0, + data: [], + delay: 300 + }, + k.prototype.reload = function (e) { + var i = this; + i.config = s.extend({}, i.config, e), + i.init(!0) + }, + k.prototype.init = function (e) { + var i = this, + t = i.config, + n = t.elem = s(t.elem); + return 1 < n.length ? (layui.each(n, function () { + c.render(s.extend({}, t, { + elem: this + })) + }), i) : !e && n[0] && n.data(r) ? (n = p.getThis(n.data(r))) ? n.reload(t) : void 0 : (t.id = "id" in t ? t.id : i.index, t.show && i.render(e), void i.events()) + }, + k.prototype.render = function (e) { + var n = this, + u = n.config, + i = s("body"), + d = function (r, e) { + return layui.each(e, function (e, i) { + var t, + n = i.child && 0 < i.child.length, + a = ("isSpreadItem" in i ? i : u).isSpreadItem, + l = i.templet ? m(i.templet).render(i) : u.templet ? m(u.templet).render(i) : i.title, + o = (n && (i.type = i.type || "parent"), i.type ? { + group: "group", + parent: "parent", + "-": "-" + } + [i.type] || "parent" : ""); + ("-" === o || i.title || i.id || n) && ((l = s(["", (t = "href" in i ? '' + l + "" : l, n ? '
' + t + ("parent" === o ? '' : "group" === o && u.isAllowSpread ? '' : "") + "
" : '
' + t + "
"), ""].join(""))).data("item", i), n && (a = s('
'), t = s("
    "), "parent" === o ? (a.append(d(t, i.child)), l.append(a)) : l.append(d(t, i.child))), r.append(l)) + }), + r + }, + t = ['
    ', "
    "].join(""); + !(e = "contextmenu" !== u.trigger && !lay.isTopElem(u.elem[0]) ? e : !0) && u.elem.data(r + "_opened") || (n.elemView = s(t), n.elemView.append(u.content || (e = s('
      '), 0 < u.data.length ? d(e, u.data) : e.html('
    • no menu
    • '), e)), u.className && n.elemView.addClass(u.className), u.style && n.elemView.attr("style", u.style), c.thisId = u.id, n.remove(), i.append(n.elemView), u.elem.data(r + "_opened", !0), n.position(), (p.prevElem = n.elemView).data("prevElem", u.elem), n.elemView.find(".layui-menu").on(l, function (e) { + layui.stope(e) + }), n.elemView.find(".layui-menu li").on("click", function (e) { + var i = s(this), + t = i.data("item") || {}; + t.child && 0 < t.child.length || "-" === t.type || (n.remove(), "function" == typeof u.click && u.click(t, i)) + }), n.elemView.find(V).on("click", function (e) { + var i = s(this).parent(); + "group" === (i.data("item") || {}).type && u.isAllowSpread && p.spread(i) + }), "mouseenter" === u.trigger && n.elemView.on("mouseenter", function () { + clearTimeout(p.timer) + }).on("mouseleave", function () { + n.delayRemove() + })) + }, + k.prototype.position = function (e) { + var i = this.config; + lay.position(i.elem[0], this.elemView[0], { + position: i.position, + e: this.e, + clickType: "contextmenu" === i.trigger ? "right" : null, + align: i.align || null + }) + }, + k.prototype.remove = function () { + this.config; + var e = p.prevElem; + e && (e.data("prevElem") && e.data("prevElem").data(r + "_opened", !1), e.remove()) + }, + k.prototype.delayRemove = function () { + var e = this, + i = e.config; + clearTimeout(p.timer), + p.timer = setTimeout(function () { + e.remove() + }, i.delay) + }, + k.prototype.events = function () { + var i = this, + t = i.config; + "hover" === t.trigger && (t.trigger = "mouseenter"), + i.prevElem && i.prevElem.off(t.trigger, i.prevElemCallback), + i.prevElem = t.elem, + i.prevElemCallback = function (e) { + clearTimeout(p.timer), + i.e = e, + i.render(), + e.preventDefault(), + "function" == typeof t.ready && t.ready(i.elemView, t.elem, i.e.target) + }, + t.elem.on(t.trigger, i.prevElemCallback), + "mouseenter" === t.trigger && t.elem.on("mouseleave", function () { + i.delayRemove() + }) + }, + p.that = {}, + p.getThis = function (e) { + var i = p.that[e]; + return i || a.error(e ? o + " instance with ID '" + e + "' not found" : "ID argument required"), + i + }, + p.spread = function (e) { + var i = e.children("." + y).find(".layui-icon"); + e.hasClass(u) ? (e.removeClass(u).addClass(d), i.removeClass("layui-icon-down").addClass("layui-icon-up")) : (e.removeClass(d).addClass(u), i.removeClass("layui-icon-up").addClass("layui-icon-down")) + }, + n = s(window), + i = s(document), + n.on("resize", function () { + if (c.thisId) { + var e = p.getThis(c.thisId); + if (e) { + if (!e.elemView[0] || !s(".layui-dropdown")[0]) + return !1; + "contextmenu" === e.config.trigger ? e.remove() : e.position() + } + } + }), + i.on(l, function (e) { + var i, + t; + !c.thisId || (i = p.getThis(c.thisId)) && (t = i.config, !lay.isTopElem(t.elem[0]) && "contextmenu" !== t.trigger && (e.target === t.elem[0] || t.elem.find(e.target)[0] || e.target === i.elemView[0] || i.elemView && i.elemView.find(e.target)[0]) || i.remove()) + }), + t = ".layui-menu:not(.layui-dropdown-menu) li", + i.on("click", t, function (e) { + var i = s(this), + t = i.parents(".layui-menu").eq(0), + n = i.hasClass(f) || i.hasClass(g), + a = t.attr("lay-filter") || t.attr("id"), + l = lay.options(this); + i.hasClass("layui-menu-item-divider") || n || (t.find("." + h).removeClass(h), t.find("." + v).removeClass(v), i.addClass(h), i.parents("." + g).addClass(v), layui.event.call(this, o, "click(" + a + ")", l)) + }), + i.on("click", t + V, function (e) { + var i = s(this).parents("." + f + ":eq(0)"), + t = lay.options(i[0]); + "isAllowSpread" in t && !t.isAllowSpread || p.spread(i) + }), + t = ".layui-menu ." + g, + i.on("mouseenter", t, function (e) { + var i, + t = s(this).find("." + w); + t[0] && ((i = t[0].getBoundingClientRect()).right > n.width() && (t.addClass(C), (i = t[0].getBoundingClientRect()).left < 0 && t.removeClass(C)), i.bottom > n.height() && t.eq(0).css("margin-top", - (i.bottom - n.height() + 5))) + }).on("mouseleave", t, function (e) { + var i = s(this).children("." + w); + i.removeClass(C), + i.css("margin-top", 0) + }), + c.reload = function (e, i) { + e = p.getThis(e); + return e ? (e.reload(i), p.call(e)) : this + }, + c.render = function (e) { + e = new k(e); + return p.call(e) + }, + e(o, c) +}); +layui.define("jquery", function (e) { + "use strict"; + var h = layui.$, + t = { + config: {}, + index: layui.slider ? layui.slider.index + 1e4 : 0, + set: function (e) { + var i = this; + return i.config = h.extend({}, i.config, e), + i + }, + on: function (e, i) { + return layui.onevent.call(this, a, e, i) + } + }, + a = "slider", + c = "layui-disabled", + y = "layui-slider-bar", + g = "layui-slider-wrap", + b = "layui-slider-wrap-btn", + x = "layui-slider-tips", + T = "layui-slider-input-txt", + w = "layui-slider-hover", + i = function (e) { + var i = this; + i.index = ++t.index, + i.config = h.extend({}, i.config, t.config, e), + i.render() + }; + i.prototype.config = { + type: "default", + min: 0, + max: 100, + value: 0, + step: 1, + showstep: !1, + tips: !0, + input: !1, + range: !1, + height: 200, + disabled: !1, + theme: "#009688" + }, + i.prototype.render = function () { + var a, + n = this, + l = n.config, + e = (l.step < 1 && (l.step = 1), l.max < l.min && (l.max = l.min + l.step), l.range ? (l.value = "object" == typeof l.value ? l.value : [l.min, l.value], i = Math.min(l.value[0], l.value[1]), s = Math.max(l.value[0], l.value[1]), l.value[0] = i > l.min ? i : l.min, l.value[1] = s > l.min ? s : l.min, l.value[0] = l.value[0] > l.max ? l.max : l.value[0], l.value[1] = l.value[1] > l.max ? l.max : l.value[1], i = Math.floor((l.value[0] - l.min) / (l.max - l.min) * 100), t = (s = Math.floor((l.value[1] - l.min) / (l.max - l.min) * 100)) - i + "%", i += "%", s += "%") : ("object" == typeof l.value && (l.value = Math.min.apply(null, l.value)), l.value < l.min && (l.value = l.min), l.value > l.max && (l.value = l.max), t = Math.floor((l.value - l.min) / (l.max - l.min) * 100) + "%"), l.disabled ? "#c2c2c2" : l.theme), + i = '
      ' + (l.tips ? '
      ' : "") + '
      ' + (l.range ? '
      ' : "") + "
      ", + t = h(l.elem), + s = t.next(".layui-slider"); + if (s[0] && s.remove(), n.elemTemp = h(i), l.range ? (n.elemTemp.find("." + g).eq(0).data("value", l.value[0]), n.elemTemp.find("." + g).eq(1).data("value", l.value[1])) : n.elemTemp.find("." + g).data("value", l.value), t.html(n.elemTemp), "vertical" === l.type && n.elemTemp.height(l.height + "px"), l.showstep) { + for (var o = (l.max - l.min) / l.step, r = "", u = 1; u < 1 + o; u++) { + var d = 100 * u / o; + d < 100 && (r += '
      ') + } + n.elemTemp.append(r) + } + l.input && !l.range && (e = h('
      '), t.css("position", "relative"), t.append(e), t.find("." + T).children("input").val(l.value), "vertical" === l.type ? e.css({ + left: 0, + top: -48 + }) : n.elemTemp.css("margin-right", e.outerWidth() + 15)), + l.disabled ? (n.elemTemp.addClass(c), n.elemTemp.find("." + b).addClass(c)) : n.slide(), + n.elemTemp.find("." + b).on("mouseover", function () { + var e = "vertical" === l.type ? l.height : n.elemTemp[0].offsetWidth, + i = n.elemTemp.find("." + g), + t = ("vertical" === l.type ? e - h(this).parent()[0].offsetTop - i.height() : h(this).parent()[0].offsetLeft) / e * 100, + i = h(this).parent().data("value"), + e = l.setTips ? l.setTips(i) : i; + n.elemTemp.find("." + x).html(e), + clearTimeout(a), + a = setTimeout(function () { + "vertical" === l.type ? n.elemTemp.find("." + x).css({ + bottom: t + "%", + "margin-bottom": "20px", + display: "inline-block" + }) : n.elemTemp.find("." + x).css({ + left: t + "%", + display: "inline-block" + }) + }, 300) + }).on("mouseout", function () { + clearTimeout(a), + n.elemTemp.find("." + x).css("display", "none") + }) + }, + i.prototype.slide = function (e, i, t) { + var o = this.config, + r = this.elemTemp, + u = function () { + return "vertical" === o.type ? o.height : r[0].offsetWidth + }, + d = r.find("." + g), + s = r.next(".layui-slider-input"), + c = s.children("." + T).children("input").val(), + m = 100 / ((o.max - o.min) / Math.ceil(o.step)), + v = function (e, i) { + e = 100 < (e = 100 < Math.ceil(e) * m ? Math.ceil(e) * m : Math.round(e) * m) ? 100 : e, + d.eq(i).css("vertical" === o.type ? "bottom" : "left", e + "%"); + var t, + a = p(d[0].offsetLeft), + n = o.range ? p(d[1].offsetLeft) : 0, + l = ("vertical" === o.type ? (r.find("." + x).css({ + bottom: e + "%", + "margin-bottom": "20px" + }), a = p(u() - d[0].offsetTop - d.height()), n = o.range ? p(u() - d[1].offsetTop - d.height()) : 0) : r.find("." + x).css("left", e + "%"), a = 100 < a ? 100 : a, n = 100 < n ? 100 : n, Math.min(a, n)), + a = Math.abs(a - n), + n = ("vertical" === o.type ? r.find("." + y).css({ + height: a + "%", + bottom: l + "%" + }) : r.find("." + y).css({ + width: a + "%", + left: l + "%" + }), o.min + Math.round((o.max - o.min) * e / 100)); + c = n, + s.children("." + T).children("input").val(c), + d.eq(i).data("value", n), + r.find("." + x).html(o.setTips ? o.setTips(n) : n), + o.range && (t = [d.eq(0).data("value"), d.eq(1).data("value")])[0] > t[1] && t.reverse(), + o.change && o.change(o.range ? t : n) + }, + p = function (e) { + var i = e / u() * 100 / m, + t = Math.round(i) * m; + return t = e == u() ? Math.ceil(i) * m : t + }, + f = h(['
      u() ? u() : i) / u() * 100 / m; + v(i, l), + s.addClass(w), + r.find("." + x).show(), + e.preventDefault() + }, + i = function () { + s.removeClass(w), + r.find("." + x).hide() + }, + t = function () { + i && i(), + f.remove() + }, + h("#LAY-slider-moving")[0] || h("body").append(f), + f.on("mousemove", e), + f.on("mouseup", t).on("mouseleave", t) + }) + }), + r.on("click", function (e) { + var i = h("." + b), + t = h(this); + !i.is(event.target) && 0 === i.has(event.target).length && i.length && (t = (i = (i = (i = "vertical" === o.type ? u() - e.clientY + t.offset().top - h(window).scrollTop() : e.clientX - t.offset().left - h(window).scrollLeft()) < 0 ? 0 : i) > u() ? u() : i) / u() * 100 / m, i = o.range ? "vertical" === o.type ? Math.abs(i - parseInt(h(d[0]).css("bottom"))) > Math.abs(i - parseInt(h(d[1]).css("bottom"))) ? 1 : 0 : Math.abs(i - d[0].offsetLeft) > Math.abs(i - d[1].offsetLeft) ? 1 : 0 : 0, v(t, i), e.preventDefault()) + }), + s.children(".layui-slider-input-btn").children("i").each(function (i) { + h(this).on("click", function () { + c = s.children("." + T).children("input").val(); + var e = ((c = 1 == i ? c - o.step < o.min ? o.min : Number(c) - o.step : Number(c) + o.step > o.max ? o.max : Number(c) + o.step) - o.min) / (o.max - o.min) * 100 / m; + v(e, 0) + }) + }); + var a = function () { + var e = this.value, + e = (e = (e = (e = isNaN(e) ? 0 : e) < o.min ? o.min : e) > o.max ? o.max : e, ((this.value = e) - o.min) / (o.max - o.min) * 100 / m); + v(e, 0) + }; + s.children("." + T).children("input").on("keydown", function (e) { + 13 === e.keyCode && (e.preventDefault(), a.call(this)) + }).on("change", a) + }, + i.prototype.events = function () { + this.config + }, + t.render = function (e) { + e = new i(e); + return function () { + var t = this, + a = t.config; + return { + setValue: function (e, i) { + return a.value = e, + t.slide("set", e, i || 0) + }, + config: a + } + } + .call(e) + }, + e(a, t) +}); +layui.define(["jquery", "lay"], function (e) { + "use strict"; + var k = layui.jquery, + n = layui.lay, + r = layui.device().mobile ? "click" : "mousedown", + l = { + config: {}, + index: layui.colorpicker ? layui.colorpicker.index + 1e4 : 0, + set: function (e) { + var i = this; + return i.config = k.extend({}, i.config, e), + i + }, + on: function (e, i) { + return layui.onevent.call(this, "colorpicker", e, i) + } + }, + t = "layui-colorpicker", + c = ".layui-colorpicker-main", + y = "layui-icon-down", + x = "layui-icon-close", + P = "layui-colorpicker-trigger-span", + C = "layui-colorpicker-trigger-i", + B = "layui-colorpicker-side-slider", + w = "layui-colorpicker-basis", + D = "layui-colorpicker-alpha-bgcolor", + j = "layui-colorpicker-alpha-slider", + E = "layui-colorpicker-basis-cursor", + F = "layui-colorpicker-main-input", + H = function (e) { + var i = { + h: 0, + s: 0, + b: 0 + }, + o = Math.min(e.r, e.g, e.b), + r = Math.max(e.r, e.g, e.b), + n = r - o; + return i.b = r, + i.s = 0 != r ? 255 * n / r : 0, + 0 != i.s ? e.r == r ? i.h = (e.g - e.b) / n : e.g == r ? i.h = 2 + (e.b - e.r) / n : i.h = 4 + (e.r - e.g) / n : i.h = -1, + r == o && (i.h = 0), + i.h *= 60, + i.h < 0 && (i.h += 360), + i.s *= 100 / 255, + i.b *= 100 / 255, + i + }, + M = function (e) { + var i, + o = {}, + r = e.h, + n = 255 * e.s / 100, + e = 255 * e.b / 100; + return 0 == n ? o.r = o.g = o.b = e : (e = r % 60 * ((i = e) - (n = (255 - n) * e / 255)) / 60, (r = 360 == r ? 0 : r) < 60 ? (o.r = i, o.b = n, o.g = n + e) : r < 120 ? (o.g = i, o.b = n, o.r = i - e) : r < 180 ? (o.g = i, o.r = n, o.b = n + e) : r < 240 ? (o.b = i, o.r = n, o.g = i - e) : r < 300 ? (o.b = i, o.g = n, o.r = n + e) : r < 360 ? (o.r = i, o.g = n, o.b = i - e) : (o.r = 0, o.g = 0, o.b = 0)), { + r: Math.round(o.r), + g: Math.round(o.g), + b: Math.round(o.b) + } + }, + f = function (e) { + var e = M(e), + o = [e.r.toString(16), e.g.toString(16), e.b.toString(16)]; + return k.each(o, function (e, i) { + 1 == i.length && (o[e] = "0" + i) + }), + o.join("") + }, + Y = function (e) { + e = e.match(/[0-9]{1,3}/g) || []; + return { + r: e[0], + g: e[1], + b: e[2] + } + }, + I = k(window), + a = k(document), + s = function (e) { + this.index = ++l.index, + this.config = k.extend({}, this.config, l.config, e), + this.render() + }; + s.prototype.config = { + color: "", + size: null, + alpha: !1, + format: "hex", + predefine: !1, + colors: ["#009688", "#5FB878", "#1E9FFF", "#FF5722", "#FFB800", "#01AAED", "#999", "#c00", "#ff8c00", "#ffd700", "#90ee90", "#00ced1", "#1e90ff", "#c71585", "rgb(0, 186, 189)", "rgb(255, 120, 0)", "rgb(250, 212, 0)", "#393D49", "rgba(0,0,0,.5)", "rgba(255, 69, 0, 0.68)", "rgba(144, 240, 144, 0.5)", "rgba(31, 147, 255, 0.73)"] + }, + s.prototype.render = function () { + var e = this, + i = e.config, + o = k(i.elem); + if (1 < o.length) + return layui.each(o, function () { + l.render(k.extend({}, i, { + elem: this + })) + }), e; + k.extend(i, n.options(o[0])); + var o = k(['
      ', "", '', '', "", "", "
      "].join("")), + r = i.elem = k(i.elem); + i.size && o.addClass("layui-colorpicker-" + i.size), + r.addClass("layui-inline").html(e.elemColorBox = o), + e.color = e.elemColorBox.find("." + P)[0].style.background, + e.events() + }, + s.prototype.renderPicker = function () { + var o, + e = this, + i = e.config, + r = e.elemColorBox[0], + i = e.elemPicker = k(['
      ', '
      ', '
      ', '
      ', '
      ', '
      ', "
      ", '
      ', '
      ', "
      ", "
      ", '
      ', '
      ', '
      ', "
      ", "
      ", i.predefine ? (o = ['
      '], layui.each(i.colors, function (e, i) { + o.push(['
      ', '
      ', "
      "].join("")) + }), o.push("
      "), o.join("")) : "", '
      ', '
      ', '', "
      ", '
      ', '', '', "", "
      "].join("")); + e.elemColorBox.find("." + P)[0]; + k(c)[0] && k(c).data("index") == e.index ? e.removePicker(s.thisElemInd) : (e.removePicker(s.thisElemInd), k("body").append(i)), + s.thisElemInd = e.index, + s.thisColor = r.style.background, + e.position(), + e.pickerEvents() + }, + s.prototype.removePicker = function (e) { + this.config; + return k("#layui-colorpicker" + (e || this.index)).remove(), + this + }, + s.prototype.position = function () { + var e = this, + i = e.config; + return n.position(e.bindElem || e.elemColorBox[0], e.elemPicker[0], { + position: i.position, + align: "center" + }), + e + }, + s.prototype.val = function () { + var e, + i = this, + o = (i.config, i.elemColorBox.find("." + P)), + r = i.elemPicker.find("." + F), + n = o[0].style.backgroundColor; + n ? (e = H(Y(n)), o = o.attr("lay-type"), i.select(e.h, e.s, e.b), "torgb" === o && r.find("input").val(n), "rgba" === o && (e = Y(n), 3 == (n.match(/[0-9]{1,3}/g) || []).length ? (r.find("input").val("rgba(" + e.r + ", " + e.g + ", " + e.b + ", 1)"), i.elemPicker.find("." + j).css("left", 280)) : (r.find("input").val(n), o = 280 * n.slice(n.lastIndexOf(",") + 1, n.length - 1), i.elemPicker.find("." + j).css("left", o)), i.elemPicker.find("." + D)[0].style.background = "linear-gradient(to right, rgba(" + e.r + ", " + e.g + ", " + e.b + ", 0), rgb(" + e.r + ", " + e.g + ", " + e.b + "))")) : (i.select(0, 100, 100), r.find("input").val(""), i.elemPicker.find("." + D)[0].style.background = "", i.elemPicker.find("." + j).css("left", 280)) + }, + s.prototype.side = function () { + var n = this, + l = n.config, + t = n.elemColorBox.find("." + P), + c = t.attr("lay-type"), + a = n.elemPicker.find(".layui-colorpicker-side"), + e = n.elemPicker.find("." + B), + s = n.elemPicker.find("." + w), + r = n.elemPicker.find("." + E), + d = n.elemPicker.find("." + D), + f = n.elemPicker.find("." + j), + u = e[0].offsetTop / 180 * 360, + p = 100 - (r[0].offsetTop + 3) / 180 * 100, + g = (r[0].offsetLeft + 3) / 260 * 100, + h = Math.round(f[0].offsetLeft / 280 * 100) / 100, + v = n.elemColorBox.find("." + C), + i = n.elemPicker.find(".layui-colorpicker-pre").children("div"), + b = function (e, i, o, r) { + n.select(e, i, o); + e = M({ + h: e, + s: i, + b: o + }); + v.addClass(y).removeClass(x), + t[0].style.background = "rgb(" + e.r + ", " + e.g + ", " + e.b + ")", + "torgb" === c && n.elemPicker.find("." + F).find("input").val("rgb(" + e.r + ", " + e.g + ", " + e.b + ")"), + "rgba" === c && (f.css("left", 280 * r), n.elemPicker.find("." + F).find("input").val("rgba(" + e.r + ", " + e.g + ", " + e.b + ", " + r + ")"), t[0].style.background = "rgba(" + e.r + ", " + e.g + ", " + e.b + ", " + r + ")", d[0].style.background = "linear-gradient(to right, rgba(" + e.r + ", " + e.g + ", " + e.b + ", 0), rgb(" + e.r + ", " + e.g + ", " + e.b + "))"), + l.change && l.change(n.elemPicker.find("." + F).find("input").val()) + }, + o = k(['
      '].join("")), + m = function (e) { + k("#LAY-colorpicker-moving")[0] || k("body").append(o), + o.on("mousemove", e), + o.on("mouseup", function () { + o.remove() + }).on("mouseleave", function () { + o.remove() + }) + }; + e.on("mousedown", function (e) { + var r = this.offsetTop, + n = e.clientY; + m(function (e) { + var i = r + (e.clientY - n), + o = a[0].offsetHeight, + o = (i = o < (i = i < 0 ? 0 : i) ? o : i) / 180 * 360; + b(u = o, g, p, h), + e.preventDefault() + }), + e.preventDefault() + }), + a.on("click", function (e) { + var i = e.clientY - k(this).offset().top, + i = (i = (i = i < 0 ? 0 : i) > this.offsetHeight ? this.offsetHeight : i) / 180 * 360; + b(u = i, g, p, h), + e.preventDefault() + }), + r.on("mousedown", function (e) { + var l = this.offsetTop, + t = this.offsetLeft, + c = e.clientY, + a = e.clientX; + layui.stope(e), + m(function (e) { + var i = l + (e.clientY - c), + o = t + (e.clientX - a), + r = s[0].offsetHeight - 3, + n = s[0].offsetWidth - 3, + n = ((o = n < (o = o < -3 ? -3 : o) ? n : o) + 3) / 260 * 100, + o = 100 - ((i = r < (i = i < -3 ? -3 : i) ? r : i) + 3) / 180 * 100; + b(u, g = n, p = o, h), + e.preventDefault() + }), + e.preventDefault() + }), + s.on("mousedown", function (e) { + var i = e.clientY - k(this).offset().top - 3 + I.scrollTop(), + o = e.clientX - k(this).offset().left - 3 + I.scrollLeft(), + o = ((i = i < -3 ? -3 : i) > this.offsetHeight - 3 && (i = this.offsetHeight - 3), ((o = (o = o < -3 ? -3 : o) > this.offsetWidth - 3 ? this.offsetWidth - 3 : o) + 3) / 260 * 100), + i = 100 - (i + 3) / 180 * 100; + b(u, g = o, p = i, h), + layui.stope(e), + e.preventDefault(), + r.trigger(e, "mousedown") + }), + f.on("mousedown", function (e) { + var r = this.offsetLeft, + n = e.clientX; + m(function (e) { + var i = r + (e.clientX - n), + o = d[0].offsetWidth, + o = (o < (i = i < 0 ? 0 : i) && (i = o), Math.round(i / 280 * 100) / 100); + b(u, g, p, h = o), + e.preventDefault() + }), + e.preventDefault() + }), + d.on("click", function (e) { + var i = e.clientX - k(this).offset().left, + i = ((i = i < 0 ? 0 : i) > this.offsetWidth && (i = this.offsetWidth), Math.round(i / 280 * 100) / 100); + b(u, g, p, h = i), + e.preventDefault() + }), + i.each(function () { + k(this).on("click", function () { + k(this).parent(".layui-colorpicker-pre").addClass("selected").siblings().removeClass("selected"); + var e = this.style.backgroundColor, + i = H(Y(e)), + o = e.slice(e.lastIndexOf(",") + 1, e.length - 1); + u = i.h, + g = i.s, + p = i.b, + 3 == (e.match(/[0-9]{1,3}/g) || []).length && (o = 1), + h = o, + b(i.h, i.s, i.b, o) + }) + }) + }, + s.prototype.select = function (e, i, o, r) { + var n = this, + l = (n.config, f({ + h: e, + s: 100, + b: 100 + })), + t = f({ + h: e, + s: i, + b: o + }), + e = e / 360 * 180, + o = 180 - o / 100 * 180 - 3, + i = i / 100 * 260 - 3; + n.elemPicker.find("." + B).css("top", e), + n.elemPicker.find("." + w)[0].style.background = "#" + l, + n.elemPicker.find("." + E).css({ + top: o, + left: i + }), + "change" !== r && n.elemPicker.find("." + F).find("input").val("#" + t) + }, + s.prototype.pickerEvents = function () { + var c = this, + a = c.config, + s = c.elemColorBox.find("." + P), + d = c.elemPicker.find("." + F + " input"), + o = { + clear: function (e) { + s[0].style.background = "", + c.elemColorBox.find("." + C).removeClass(y).addClass(x), + c.color = "", + a.done && a.done(""), + c.removePicker() + }, + confirm: function (e, i) { + var o, + r, + n = d.val(), + l = n, + t = {}; + if (-1 < n.indexOf(",") ? (t = H(Y(n)), c.select(t.h, t.s, t.b), s[0].style.background = l = "#" + f(t), 3 < (n.match(/[0-9]{1,3}/g) || []).length && "rgba" === s.attr("lay-type") && (o = 280 * n.slice(n.lastIndexOf(",") + 1, n.length - 1), c.elemPicker.find("." + j).css("left", o), l = s[0].style.background = n)) : (3 == (o = -1 < (o = n).indexOf("#") ? o.substring(1) : o).length && (o = (r = o.split(""))[0] + r[0] + r[1] + r[1] + r[2] + r[2]), r = { + r: (o = parseInt(o, 16)) >> 16, + g: (65280 & o) >> 8, + b: 255 & o + }, t = H(r), s[0].style.background = l = "#" + f(t), c.elemColorBox.find("." + C).removeClass(x).addClass(y)), "change" === i) + return c.select(t.h, t.s, t.b, i), void(a.change && a.change(l)); + c.color = n, + a.done && a.done(n), + c.removePicker() + } + }; + c.elemPicker.on("click", "*[colorpicker-events]", function () { + var e = k(this), + i = e.attr("colorpicker-events"); + o[i] && o[i].call(this, e) + }), + d.on("keyup", function (e) { + var i = k(this); + o.confirm.call(this, i, 13 === e.keyCode ? null : "change") + }) + }, + s.prototype.events = function () { + var i = this, + e = i.config, + o = i.elemColorBox.find("." + P); + i.elemColorBox.on("click", function () { + i.renderPicker(), + k(c)[0] && (i.val(), i.side()) + }), + e.elem[0] && !i.elemColorBox[0].eventHandler && (a.on(r, function (e) { + k(e.target).hasClass(t) || k(e.target).parents("." + t)[0] || k(e.target).hasClass(c.replace(/\./g, "")) || k(e.target).parents(c)[0] || i.elemPicker && (i.color ? (e = H(Y(i.color)), i.select(e.h, e.s, e.b)) : i.elemColorBox.find("." + C).removeClass(y).addClass(x), o[0].style.background = i.color || "", i.removePicker()) + }), I.on("resize", function () { + if (!i.elemPicker || !k(c)[0]) + return !1; + i.position() + }), i.elemColorBox[0].eventHandler = !0) + }, + l.render = function (e) { + e = new s(e); + return function () { + return { + config: this.config + } + } + .call(e) + }, + e("colorpicker", l) +}); +layui.define("jquery", function (t) { + "use strict"; + var u = layui.$, + d = (layui.hint(), layui.device()), + c = "element", + r = "layui-this", + y = "layui-show", + i = function () { + this.config = {} + }, + h = (i.prototype.set = function (t) { + return u.extend(!0, this.config, t), + this + }, i.prototype.on = function (t, i) { + return layui.onevent.call(this, c, t, i) + }, i.prototype.tabAdd = function (t, i) { + var a, + t = u(".layui-tab[lay-filter=" + t + "]"), + e = t.children(".layui-tab-title"), + l = e.children(".layui-tab-bar"), + t = t.children(".layui-tab-content"), + n = "" + (i.title || "unnaming") + ""; + return l[0] ? l.before(n) : e.append(n), + t.append('
      ' + (i.content || "") + "
      "), + C.hideTabMore(!0), + C.tabAuto(), + this + }, i.prototype.tabDelete = function (t, i) { + t = u(".layui-tab[lay-filter=" + t + "]").children(".layui-tab-title").find('>li[lay-id="' + i + '"]'); + return C.tabDelete(null, t), + this + }, i.prototype.tabChange = function (t, i) { + t = u(".layui-tab[lay-filter=" + t + "]").children(".layui-tab-title").find('>li[lay-id="' + i + '"]'); + return C.tabClick.call(t[0], null, null, t), + this + }, i.prototype.tab = function (a) { + a = a || {}, + e.on("click", a.headerElem, function (t) { + var i = u(this).index(); + C.tabClick.call(this, t, i, null, a) + }) + }, i.prototype.progress = function (t, i) { + var a = "layui-progress", + t = u("." + a + "[lay-filter=" + t + "]").find("." + a + "-bar"), + a = t.find("." + a + "-text"); + return t.css("width", i).attr("lay-percent", i), + a.text(i), + this + }, ".layui-nav"), + f = "layui-nav-item", + l = "layui-nav-bar", + p = "layui-nav-tree", + b = "layui-nav-child", + v = "layui-nav-more", + m = "layui-anim layui-anim-upbit", + C = { + tabClick: function (t, i, a, e) { + e = e || {}; + var a = a || u(this), + i = i || a.parent().children("li").index(a), + l = e.headerElem ? a.parent() : a.parents(".layui-tab").eq(0), + e = e.bodyElem ? u(e.bodyElem) : l.children(".layui-tab-content").children(".layui-tab-item"), + n = a.find("a"), + n = "javascript:;" !== n.attr("href") && "_blank" === n.attr("target"), + s = "string" == typeof a.attr("lay-unselect"), + o = l.attr("lay-filter"); + n || s || (a.addClass(r).siblings().removeClass(r), e.eq(i).addClass(y).siblings().removeClass(y)), + layui.event.call(this, c, "tab(" + o + ")", { + elem: l, + index: i + }) + }, + tabDelete: function (t, i) { + var i = i || u(this).parent(), + a = i.index(), + e = i.parents(".layui-tab").eq(0), + l = e.children(".layui-tab-content").children(".layui-tab-item"), + n = e.attr("lay-filter"); + i.hasClass(r) && (i.next()[0] && i.next().is("li") ? C.tabClick.call(i.next()[0], null, a + 1) : i.prev()[0] && i.prev().is("li") && C.tabClick.call(i.prev()[0], null, a - 1)), + i.remove(), + l.eq(a).remove(), + setTimeout(function () { + C.tabAuto() + }, 50), + layui.event.call(this, c, "tabDelete(" + n + ")", { + elem: e, + index: a + }) + }, + tabAuto: function () { + var e = "layui-tab-bar", + l = "layui-tab-close", + n = this; + u(".layui-tab").each(function () { + var t = u(this), + i = t.children(".layui-tab-title"), + a = (t.children(".layui-tab-content").children(".layui-tab-item"), 'lay-stope="tabmore"'), + a = u(''); + n === window && 8 != d.ie && C.hideTabMore(!0), + t.attr("lay-allowClose") && i.find("li").each(function () { + var t, + i = u(this); + i.find("." + l)[0] || ((t = u('')).on("click", C.tabDelete), i.append(t)) + }), + "string" != typeof t.attr("lay-unauto") && (i.prop("scrollWidth") > i.outerWidth() + 1 ? i.find("." + e)[0] || (i.append(a), t.attr("overflow", ""), a.on("click", function (t) { + i[this.title ? "removeClass" : "addClass"]("layui-tab-more"), + this.title = this.title ? "" : "\u6536\u7f29" + })) : (i.find("." + e).remove(), t.removeAttr("overflow"))) + }) + }, + hideTabMore: function (t) { + var i = u(".layui-tab-title"); + !0 !== t && "tabmore" === u(t.target).attr("lay-stope") || (i.removeClass("layui-tab-more"), i.find(".layui-tab-bar").attr("title", "")) + }, + clickThis: function () { + var t = u(this), + i = t.parents(h), + a = i.attr("lay-filter"), + e = t.parent(), + l = t.siblings("." + b), + n = "string" == typeof e.attr("lay-unselect"); + "javascript:;" !== t.attr("href") && "_blank" === t.attr("target") || n || l[0] || (i.find("." + r).removeClass(r), e.addClass(r)), + i.hasClass(p) && (l.removeClass(m), l[0] && (e["none" === l.css("display") ? "addClass" : "removeClass"](f + "ed"), "all" === i.attr("lay-shrink") && e.siblings().removeClass(f + "ed"))), + layui.event.call(this, c, "nav(" + a + ")", t) + }, + collapse: function () { + var t = u(this), + i = t.find(".layui-colla-icon"), + a = t.siblings(".layui-colla-content"), + e = t.parents(".layui-collapse").eq(0), + l = e.attr("lay-filter"), + n = "none" === a.css("display"); + "string" == typeof e.attr("lay-accordion") && ((e = e.children(".layui-colla-item").children("." + y)).siblings(".layui-colla-title").children(".layui-colla-icon").html(""), e.removeClass(y)), + a[n ? "addClass" : "removeClass"](y), + i.html(n ? "" : ""), + layui.event.call(this, c, "collapse(" + l + ")", { + title: t, + content: a, + show: n + }) + } + }, + a = (i.prototype.render = i.prototype.init = function (t, i) { + var a = i ? '[lay-filter="' + i + '"]' : "", + i = { + tab: function () { + C.tabAuto.call({}) + }, + nav: function () { + var s = {}, + o = {}, + c = {}, + r = "layui-nav-title"; + u(h + a).each(function (t) { + var i = u(this), + a = u(''), + e = i.find("." + f); + i.find("." + l)[0] || (i.append(a), (i.hasClass(p) ? e.find("dd,>." + r) : e).on("mouseenter", function () { + !function (t, i, a) { + var e, + l = u(this), + n = l.find("." + b); + i.hasClass(p) ? n[0] || (e = l.children("." + r), t.css({ + top: l.offset().top - i.offset().top, + height: (e[0] ? e : l).outerHeight(), + opacity: 1 + })) : (n.addClass(m), n.hasClass("layui-nav-child-c") && n.css({ + left: - (n.outerWidth() - l.width()) / 2 + }), n[0] ? t.css({ + left: t.position().left + t.width() / 2, + width: 0, + opacity: 0 + }) : t.css({ + left: l.position().left + parseFloat(l.css("marginLeft")), + top: l.position().top + l.height() - t.height() + }), s[a] = setTimeout(function () { + t.css({ + width: n[0] ? 0 : l.width(), + opacity: n[0] ? 0 : 1 + }) + }, d.ie && d.ie < 10 ? 0 : 200), clearTimeout(c[a]), "block" === n.css("display") && clearTimeout(o[a]), o[a] = setTimeout(function () { + n.addClass(y), + l.find("." + v).addClass(v + "d") + }, 300)) + } + .call(this, a, i, t) + }).on("mouseleave", function () { + i.hasClass(p) ? a.css({ + height: 0, + opacity: 0 + }) : (clearTimeout(o[t]), o[t] = setTimeout(function () { + i.find("." + b).removeClass(y), + i.find("." + v).removeClass(v + "d") + }, 300)) + }), i.on("mouseleave", function () { + clearTimeout(s[t]), + c[t] = setTimeout(function () { + i.hasClass(p) || a.css({ + width: 0, + left: a.position().left + a.width() / 2, + opacity: 0 + }) + }, 200) + })), + e.find("a").each(function () { + var t = u(this); + t.parent(); + t.siblings("." + b)[0] && !t.children("." + v)[0] && t.append(''), + t.off("click", C.clickThis).on("click", C.clickThis) + }) + }) + }, + breadcrumb: function () { + u(".layui-breadcrumb" + a).each(function () { + var t = u(this), + i = "lay-separator", + a = t.attr(i) || "/", + e = t.find("a"); + e.next("span[" + i + "]")[0] || (e.each(function (t) { + t !== e.length - 1 && u(this).after("" + a + "") + }), t.css("visibility", "visible")) + }) + }, + progress: function () { + var e = "layui-progress"; + u("." + e + a).each(function () { + var t = u(this), + i = t.find(".layui-progress-bar"), + a = i.attr("lay-percent"); + i.css("width", /^.+\/.+$/.test(a) ? 100 * new Function("return " + a)() + "%" : a), + t.attr("lay-showPercent") && setTimeout(function () { + i.html('' + a + "") + }, 350) + }) + }, + collapse: function () { + u(".layui-collapse" + a).each(function () { + u(this).find(".layui-colla-item").each(function () { + var t = u(this), + i = t.find(".layui-colla-title"), + t = "none" === t.find(".layui-colla-content").css("display"); + i.find(".layui-colla-icon").remove(), + i.append('' + (t ? "" : "") + ""), + i.off("click", C.collapse).on("click", C.collapse) + }) + }) + } + }; + return i[t] ? i[t]() : layui.each(i, function (t, i) { + i() + }) + }, new i), + e = u(document); + u(function () { + a.render() + }); + e.on("click", ".layui-tab-title li", C.tabClick), + e.on("click", C.hideTabMore), + u(window).on("resize", C.tabAuto), + t(c, a) +}); +layui.define("layer", function (e) { + "use strict"; + var v = layui.$, + t = layui.layer, + r = layui.hint(), + y = layui.device(), + i = { + config: {}, + set: function (e) { + var t = this; + return t.config = v.extend({}, t.config, e), + t + }, + on: function (e, t) { + return layui.onevent.call(this, n, e, t) + } + }, + n = "upload", + o = "layui-upload-file", + a = "layui-upload-form", + F = "layui-upload-iframe", + b = "layui-upload-choose", + x = function (e) { + var t = this; + t.config = v.extend({}, t.config, i.config, e), + t.render() + }; + x.prototype.config = { + accept: "images", + exts: "", + auto: !0, + bindAction: "", + url: "", + force: "", + field: "file", + acceptMime: "", + method: "post", + data: {}, + drag: !0, + size: 0, + number: 0, + multiple: !1 + }, + x.prototype.render = function (e) { + var t = this; + (e = t.config).elem = v(e.elem), + e.bindAction = v(e.bindAction), + t.file(), + t.events() + }, + x.prototype.file = function () { + var e = this, + t = e.config, + i = e.elemFile = v(['"].join("")), + n = t.elem.next(); + (n.hasClass(o) || n.hasClass(a)) && n.remove(), + y.ie && y.ie < 10 && t.elem.wrap('
      '), + e.isFile() ? (e.elemFile = t.elem, t.field = t.elem[0].name) : t.elem.after(i), + y.ie && y.ie < 10 && e.initIE() + }, + x.prototype.initIE = function () { + var i, + e = this.config, + t = v(''), + n = v(['
      ', "
      "].join("")); + v("#" + F)[0] || v("body").append(t), + e.elem.next().hasClass(a) || (this.elemFile.wrap(n), e.elem.next("." + a).append((i = [], layui.each(e.data, function (e, t) { + t = "function" == typeof t ? t() : t, + i.push('') + }), i.join("")))) + }, + x.prototype.msg = function (e) { + return t.msg(e, { + icon: 2, + shift: 6 + }) + }, + x.prototype.isFile = function () { + var e = this.config.elem[0]; + if (e) + return "input" === e.tagName.toLocaleLowerCase() && "file" === e.type + }, + x.prototype.preview = function (n) { + window.FileReader && layui.each(this.chooseFiles, function (e, t) { + var i = new FileReader; + i.readAsDataURL(t), + i.onload = function () { + n && n(e, t, this.result) + } + }) + }, + x.prototype.upload = function (i, e) { + var n, + o, + t, + a, + l = this, + r = l.config, + u = l.elemFile[0], + c = function () { + var t = 0, + o = 0, + e = i || l.files || l.chooseFiles || u.files, + a = function () { + r.multiple && t + o === l.fileLength && "function" == typeof r.allDone && r.allDone({ + total: l.fileLength, + successful: t, + failed: o + }) + }; + layui.each(e, function (i, e) { + var n = new FormData, + e = (n.append(r.field, e), layui.each(r.data, function (e, t) { + t = "function" == typeof t ? t() : t, + n.append(e, t) + }), { + url: r.url, + type: "post", + data: n, + contentType: !1, + processData: !1, + dataType: "json", + headers: r.headers || {}, + success: function (e) { + t++, + f(i, e), + a() + }, + error: function (e) { + o++, + l.msg("Request URL is abnormal: " + (e.statusText || "error")), + p(i), + a() + } + }); + "function" == typeof r.progress && (e.xhr = function () { + var e = v.ajaxSettings.xhr(); + return e.upload.addEventListener("progress", function (e) { + var t; + e.lengthComputable && (t = Math.floor(e.loaded / e.total * 100), r.progress(t, (r.item || r.elem)[0], e, i)) + }), + e + }), + v.ajax(e) + }) + }, + s = function () { + var n = v("#" + F); + l.elemFile.parent().submit(), + clearInterval(x.timer), + x.timer = setInterval(function () { + var e, + t = n.contents().find("body"); + try { + e = t.text() + } catch (i) { + l.msg("Cross-domain requests are not supported"), + clearInterval(x.timer), + p() + } + e && (clearInterval(x.timer), t.html(""), f(0, e)) + }, 30) + }, + f = function (e, t) { + if (l.elemFile.next("." + b).remove(), u.value = "", "json" === r.force && "object" != typeof t) + try { + t = JSON.parse(t) + } catch (i) { + return t = {}, + l.msg("Please return JSON data format") + } + "function" == typeof r.done && r.done(t, e || 0, function (e) { + l.upload(e) + }) + }, + p = function (e) { + r.auto && (u.value = ""), + "function" == typeof r.error && r.error(e || 0, function (e) { + l.upload(e) + }) + }, + d = r.exts, + m = (o = [], layui.each(i || l.chooseFiles, function (e, t) { + o.push(t.name) + }), o), + h = { + preview: function (e) { + l.preview(e) + }, + upload: function (e, t) { + var i = {}; + i[e] = t, + l.upload(i) + }, + pushFile: function () { + return l.files = l.files || {}, + layui.each(l.chooseFiles, function (e, t) { + l.files[e] = t + }), + l.files + }, + resetFile: function (e, t, i) { + t = new File([t], i); + l.files = l.files || {}, + l.files[e] = t + } + }, + g = { + file: "\u6587\u4ef6", + images: "\u56fe\u7247", + video: "\u89c6\u9891", + audio: "\u97f3\u9891" + } + [r.accept] || "\u6587\u4ef6", + m = 0 === m.length ? u.value.match(/[^\/\\]+\..+/g) || [] || "" : m; + if (0 !== m.length) { + switch (r.accept) { + case "file": + layui.each(m, function (e, t) { + if (d && !RegExp(".\\.(" + d + ")$", "i").test(escape(t))) + return n = !0 + }); + break; + case "video": + layui.each(m, function (e, t) { + if (!RegExp(".\\.(" + (d || "avi|mp4|wma|rmvb|rm|flash|3gp|flv") + ")$", "i").test(escape(t))) + return n = !0 + }); + break; + case "audio": + layui.each(m, function (e, t) { + if (!RegExp(".\\.(" + (d || "mp3|wav|mid") + ")$", "i").test(escape(t))) + return n = !0 + }); + break; + default: + layui.each(m, function (e, t) { + if (!RegExp(".\\.(" + (d || "jpg|png|gif|bmp|jpeg") + ")$", "i").test(escape(t))) + return n = !0 + }) + } + if (n) + return l.msg("\u9009\u62e9\u7684" + g + "\u4e2d\u5305\u542b\u4e0d\u652f\u6301\u7684\u683c\u5f0f"), u.value = ""; + if ("choose" !== e && !r.auto || (r.choose && r.choose(h), "choose" !== e)) { + if (l.fileLength = (t = 0, g = i || l.files || l.chooseFiles || u.files, layui.each(g, function () { + t++ + }), t), r.number && l.fileLength > r.number) + return l.msg("\u540c\u65f6\u6700\u591a\u53ea\u80fd\u4e0a\u4f20: " + r.number + " \u4e2a\u6587\u4ef6
      \u60a8\u5f53\u524d\u5df2\u7ecf\u9009\u62e9\u4e86: " + l.fileLength + " \u4e2a\u6587\u4ef6"); + if (0 < r.size && !(y.ie && y.ie < 10)) + if (layui.each(l.chooseFiles, function (e, t) { + t.size > 1024 * r.size && (t = 1 <= (t = r.size / 1024) ? t.toFixed(2) + "MB" : r.size + "KB", u.value = "", a = t) + }), a) + return l.msg("\u6587\u4ef6\u5927\u5c0f\u4e0d\u80fd\u8d85\u8fc7 " + a); + if (!r.before || !1 !== r.before(h)) + y.ie ? (9 < y.ie ? c : s)() : c() + } + } + }, + x.prototype.reload = function (e) { + delete (e = e || {}).elem, + delete e.bindAction; + (e = this.config = v.extend({}, this.config, i.config, e)).elem.next().attr({ + name: e.name, + accept: e.acceptMime, + multiple: e.multiple + }) + }, + x.prototype.events = function () { + var n = this, + o = n.config, + a = function (e) { + n.chooseFiles = {}, + layui.each(e, function (e, t) { + var i = (new Date).getTime(); + n.chooseFiles[i + "-" + e] = t + }) + }, + l = function (e, t) { + var i = n.elemFile, + e = (o.item || o.elem, 1 < e.length ? e.length + "\u4e2a\u6587\u4ef6" : (e[0] || {}).name || i[0].value.match(/[^\/\\]+\..+/g) || [] || ""); + i.next().hasClass(b) && i.next().remove(), + n.upload(null, "choose"), + n.isFile() || o.choose || i.after('' + e + "") + }; + o.elem.off("upload.start").on("upload.start", function () { + var e = v(this), + t = e.attr("lay-data"); + if (t) + try { + t = new Function("return " + t)(), + n.config = v.extend({}, o, t) + } catch (i) { + r.error("Upload element property lay-data configuration item has a syntax error: " + t) + } + n.config.item = e, + n.elemFile[0].click() + }), + y.ie && y.ie < 10 || o.elem.off("upload.over").on("upload.over", function () { + v(this).attr("lay-over", "") + }).off("upload.leave").on("upload.leave", function () { + v(this).removeAttr("lay-over") + }).off("upload.drop").on("upload.drop", function (e, t) { + var i = v(this), + t = t.originalEvent.dataTransfer.files || []; + i.removeAttr("lay-over"), + a(t), + o.auto ? n.upload() : l(t) + }), + n.elemFile.off("upload.change").on("upload.change", function () { + var e = this.files || []; + a(e), + o.auto ? n.upload() : l(e) + }), + o.bindAction.off("upload.action").on("upload.action", function () { + n.upload() + }), + o.elem.data("haveEvents") || (n.elemFile.on("change", function () { + v(this).trigger("upload.change") + }), o.elem.on("click", function () { + n.isFile() || v(this).trigger("upload.start") + }), o.drag && o.elem.on("dragover", function (e) { + e.preventDefault(), + v(this).trigger("upload.over") + }).on("dragleave", function (e) { + v(this).trigger("upload.leave") + }).on("drop", function (e) { + e.preventDefault(), + v(this).trigger("upload.drop", e) + }), o.bindAction.on("click", function () { + v(this).trigger("upload.action") + }), o.elem.data("haveEvents", !0)) + }, + i.render = function (e) { + e = new x(e); + return function () { + var t = this; + return { + upload: function (e) { + t.upload.call(t, e) + }, + reload: function (e) { + t.reload.call(t, e) + }, + config: t.config + } + } + .call(e) + }, + e(n, i) +}); +layui.define(["layer", "util"], function (e) { + "use strict"; + var C = layui.$, + h = layui.layer, + d = layui.util, + l = layui.hint(), + w = (layui.device(), "form"), + o = ".layui-form", + T = "layui-this", + $ = "layui-hide", + E = "layui-disabled", + t = function () { + this.config = { + verify: { + required: [/[\S]+/, "\u5fc5\u586b\u9879\u4e0d\u80fd\u4e3a\u7a7a"], + phone: [/^1\d{10}$/, "\u8bf7\u8f93\u5165\u6b63\u786e\u7684\u624b\u673a\u53f7"], + email: [/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/, "\u90ae\u7bb1\u683c\u5f0f\u4e0d\u6b63\u786e"], + url: [/^(#|(http(s?)):\/\/|\/\/)[^\s]+\.[^\s]+$/, "\u94fe\u63a5\u683c\u5f0f\u4e0d\u6b63\u786e"], + number: function (e) { + if (!e || isNaN(e)) + return "\u53ea\u80fd\u586b\u5199\u6570\u5b57" + }, + date: [/^(\d{4})[-\/](\d{1}|0\d{1}|1[0-2])([-\/](\d{1}|0\d{1}|[1-2][0-9]|3[0-1]))*$/, "\u65e5\u671f\u683c\u5f0f\u4e0d\u6b63\u786e"], + identity: [/(^\d{15}$)|(^\d{17}(x|X|\d)$)/, "\u8bf7\u8f93\u5165\u6b63\u786e\u7684\u8eab\u4efd\u8bc1\u53f7"] + }, + autocomplete: null + } + }, + i = (t.prototype.set = function (e) { + return C.extend(!0, this.config, e), + this + }, t.prototype.verify = function (e) { + return C.extend(!0, this.config.verify, e), + this + }, t.prototype.getFormElem = function (e) { + return C(o + (e ? '[lay-filter="' + e + '"]' : "")) + }, t.prototype.on = function (e, t) { + return layui.onevent.call(this, w, e, t) + }, t.prototype.val = function (e, i) { + return this.getFormElem(e).each(function (e, t) { + var a = C(this); + layui.each(i, function (e, t) { + var i, + e = a.find('[name="' + e + '"]'); + e[0] && ("checkbox" === (i = e[0].type) ? e[0].checked = t : "radio" === i ? e.each(function () { + this.value == t && (this.checked = !0) + }) : e.val(t)) + }) + }), + r.render(null, e), + this.getValue(e) + }, t.prototype.getValue = function (e, t) { + t = t || this.getFormElem(e); + var a = {}, + n = {}, + e = t.find("input,select,textarea"); + return layui.each(e, function (e, t) { + var i; + C(this); + t.name = (t.name || "").replace(/^\s*|\s*&/, ""), + t.name && (/^.*\[\]$/.test(t.name) && (i = t.name.match(/^(.*)\[\]$/g)[0], a[i] = 0 | a[i], i = t.name.replace(/^(.*)\[\]$/, "$1[" + a[i]++ + "]")), /^checkbox|radio$/.test(t.type) && !t.checked || (n[i || t.name] = t.value)) + }), + n + }, t.prototype.render = function (e, t) { + var i = this.config, + a = C(o + (t ? '[lay-filter="' + t + '"]' : "")), + n = { + input: function (e) { + e = e || a.find("input,textarea"); + i.autocomplete && e.attr("autocomplete", i.autocomplete) + }, + select: function (e) { + var p, + c = "\u8bf7\u9009\u62e9", + m = "layui-form-select", + g = "layui-select-title", + k = "layui-select-none", + x = "", + e = e || a.find("select"), + b = function (e, t) { + C(e.target).parent().hasClass(g) && !t || (C("." + m).removeClass(m + "ed " + m + "up"), p && x && p.val(x)), + p = null + }, + u = function (a, e, t) { + var s, + r, + i, + n, + o, + l, + c = C(this), + u = a.find("." + g), + d = u.find("input"), + f = a.find("dl"), + h = f.children("dd"), + y = f.children("dt"), + v = this.selectedIndex; + e || (r = c.attr("lay-search"), i = function () { + var e = a.offset().top + a.outerHeight() + 5 - q.scrollTop(), + t = f.outerHeight(); + v = c[0].selectedIndex, + a.addClass(m + "ed"), + h.removeClass($), + y.removeClass($), + s = null, + h.eq(v).addClass(T).siblings().removeClass(T), + e + t > q.height() && t <= e && a.addClass(m + "up"), + o() + }, n = function (e) { + a.removeClass(m + "ed " + m + "up"), + d.blur(), + s = null, + e || l(d.val(), function (e) { + var t = c[0].selectedIndex; + e && (x = C(c[0].options[t]).html(), 0 === t && x === d.attr("placeholder") && (x = ""), d.val(x || "")) + }) + }, o = function () { + var e, + t, + i = f.children("dd." + T); + i[0] && (e = i.position().top, t = f.height(), i = i.height(), t < e && f.scrollTop(e + f.scrollTop() - t + i - 5), e < 0 && f.scrollTop(e + f.scrollTop() - 5)) + }, u.on("click", function (e) { + a.hasClass(m + "ed") ? n() : (b(e, !0), i()), + f.find("." + k).remove() + }), u.find(".layui-edge").on("click", function () { + d.focus() + }), d.on("keyup", function (e) { + 9 === e.keyCode && i() + }).on("keydown", function (l) { + var e = l.keyCode, + r = (9 === e && n(), function (a, n) { + l.preventDefault(); + var e = function () { + var e = f.children("dd." + T); + if (f.children("dd." + $)[0] && "next" === a) { + var t = f.children("dd:not(." + $ + ",." + E + ")"), + i = t.eq(0).index(); + if (0 <= i && i < e.index() && !t.hasClass(T)) + return t.eq(0).prev()[0] ? t.eq(0).prev() : f.children(":last") + } + return n && n[0] ? n : s && s[0] ? s : e + } + (), + t = e[a](), + i = e[a]("dd:not(." + $ + ")"); + return t[0] ? (s = e[a](), i[0] && !i.hasClass(E) || !s[0] ? (i.addClass(T).siblings().removeClass(T), void o()) : r(a, s)) : s = null + }); + 38 === e && r("prev"), + 40 === e && r("next"), + 13 === e && (l.preventDefault(), f.children("dd." + T).trigger("click")) + }), l = function (a, e, n) { + var l = 0, + t = (layui.each(h, function () { + var e = C(this), + t = e.text(), + i = ("cs" !== r && (t = t.toLowerCase(), a = a.toLowerCase()), -1 === t.indexOf(a)); + ("" === a || "blur" === n ? a !== t : i) && l++, + "keyup" === n && e[i ? "addClass" : "removeClass"]($) + }), "keyup" === n && layui.each(y, function () { + var e = C(this), + t = e.nextUntil("dt").filter("dd"); + e[t.length == t.filter("." + $).length ? "addClass" : "removeClass"]($) + }), l === h.length); + return e(t), + t + }, t && d.on("keyup", function (e) { + var t = this.value, + e = e.keyCode; + if (9 === e || 13 === e || 37 === e || 38 === e || 39 === e || 40 === e) + return !1; + l(t, function (e) { + e ? f.find("." + k)[0] || f.append('

      \u65e0\u5339\u914d\u9879

      ') : f.find("." + k).remove() + }, "keyup"), + "" === t && f.find("." + k).remove(), + o() + }).on("blur", function (e) { + var t = c[0].selectedIndex; + p = d, + x = C(c[0].options[t]).html(), + 0 === t && x === d.attr("placeholder") && (x = ""), + setTimeout(function () { + l(d.val(), function (e) { + x || d.val("") + }, "blur") + }, 200) + }), h.on("click", function () { + var e = C(this), + t = e.attr("lay-value"), + i = c.attr("lay-filter"); + return e.hasClass(E) || (e.hasClass("layui-select-tips") ? d.val("") : (d.val(e.text()), e.addClass(T)), e.siblings().removeClass(T), c.val(t).removeClass("layui-form-danger"), layui.event.call(this, w, "select(" + i + ")", { + elem: c[0], + value: t, + othis: a + }), n(!0)), + !1 + }), a.find("dl>dt").on("click", function (e) { + return !1 + }), C(document).off("click", b).on("click", b)) + }; + e.each(function (e, t) { + var i = C(this), + a = i.next("." + m), + n = this.disabled, + l = t.value, + r = C(t.options[t.selectedIndex]), + t = t.options[0]; + if ("string" == typeof i.attr("lay-ignore")) + return i.show(); + var s, + o = "string" == typeof i.attr("lay-search"), + t = t && !t.value && t.innerHTML || c, + r = C(['
      ', '
      ', '', '
      ', '
      ', (t = i.find("*"), s = [], layui.each(t, function (e, t) { + 0 !== e || t.value ? "optgroup" === t.tagName.toLowerCase() ? s.push("
      " + t.label + "
      ") : s.push('
      ' + C.trim(t.innerHTML) + "
      ") : s.push('
      ' + C.trim(t.innerHTML || c) + "
      ") + }), 0 === s.length && s.push('
      \u6ca1\u6709\u9009\u9879
      '), s.join("") + "
      "), "
      "].join("")); + a[0] && a.remove(), + i.after(r), + u.call(this, r, n, o) + }) + }, + checkbox: function (e) { + var o = { + checkbox: ["layui-form-checkbox", "layui-form-checked", "checkbox"], + _switch: ["layui-form-switch", "layui-form-onswitch", "switch"] + }, + e = e || a.find("input[type=checkbox]"); + e.each(function (e, t) { + var i = C(this), + a = i.attr("lay-skin"), + n = (i.attr("lay-text") || "").split("|"), + l = this.disabled, + r = o[a = "switch" === a ? "_" + a : a] || o.checkbox; + if ("string" == typeof i.attr("lay-ignore")) + return i.show(); + var s = i.next("." + r[0]), + t = C(['
      ", (l = { + checkbox: [t.title.replace(/\s/g, "") ? "" + t.title + "" : "", ''].join(""), + _switch: "" + ((t.checked ? n[0] : n[1]) || "") + "" + })[a] || l.checkbox, "
      "].join("")); + s[0] && s.remove(), + i.after(t), + function (i, a) { + var n = C(this); + i.on("click", function () { + var e = n.attr("lay-filter"), + t = (n.attr("lay-text") || "").split("|"); + n[0].disabled || (n[0].checked ? (n[0].checked = !1, i.removeClass(a[1]).find("em").text(t[1])) : (n[0].checked = !0, i.addClass(a[1]).find("em").text(t[0])), layui.event.call(n[0], w, a[2] + "(" + e + ")", { + elem: n[0], + value: n[0].value, + othis: i + })) + }) + } + .call(this, t, r) + }) + }, + radio: function (e) { + var r = "layui-form-radio", + s = ["", ""], + e = e || a.find("input[type=radio]"); + e.each(function (e, t) { + var i = C(this), + a = i.next("." + r), + n = this.disabled; + if ("string" == typeof i.attr("lay-ignore")) + return i.show(); + a[0] && a.remove(); + n = C(['
      ', '' + s[t.checked ? 0 : 1] + "", "
      " + (a = t.title || "", a = "string" == typeof i.next().attr("lay-radio") ? i.next().html() : a) + "
      ", "
      "].join("")); + i.after(n), + function (a) { + var n = C(this), + l = "layui-anim-scaleSpring"; + a.on("click", function () { + var e = n[0].name, + t = n.parents(o), + i = n.attr("lay-filter"), + e = t.find("input[name=" + e.replace(/(\.|#|\[|\])/g, "\\$1") + "]"); + n[0].disabled || (layui.each(e, function () { + var e = C(this).next("." + r); + this.checked = !1, + e.removeClass(r + "ed"), + e.find(".layui-icon").removeClass(l).html(s[1]) + }), n[0].checked = !0, a.addClass(r + "ed"), a.find(".layui-icon").addClass(l).html(s[0]), layui.event.call(n[0], w, "radio(" + i + ")", { + elem: n[0], + value: n[0].value, + othis: a + })) + }) + } + .call(this, n) + }) + } + }; + return "object" === layui.type(e) ? e.each(function (e, t) { + var i = C(t); + i.closest(o).length && ("SELECT" === t.tagName ? n.select(i) : "INPUT" === t.tagName && ("checkbox" === (t = t.type) || "radio" === t ? n[t](i) : n.input(i))) + }) : e ? n[e] ? n[e]() : l.error('\u4e0d\u652f\u6301\u7684 "' + e + '" \u8868\u5355\u6e32\u67d3') : layui.each(n, function (e, t) { + t() + }), + this + }, t.prototype.validate = function (e) { + var u = null, + d = r.config.verify, + f = "layui-form-danger"; + return !(e = C(e))[0] || (e.attr("lay-verify") !== undefined || !1 !== this.validate(e.find("*[lay-verify]"))) && (layui.each(e, function (e, r) { + var s = C(this), + t = (s.attr("lay-verify") || "").split("|"), + o = s.attr("lay-verType"), + c = s.val(); + if (s.removeClass(f), layui.each(t, function (e, t) { + var i = "", + a = d[t]; + if (a) { + var n = "function" == typeof a ? i = a(c, r) : !a[0].test(c), + l = "select" === r.tagName.toLowerCase() || /^checkbox|radio$/.test(r.type), + i = i || a[1]; + if ("required" === t && (i = s.attr("lay-reqText") || i), n) + return "tips" === o ? h.tips(i, "string" != typeof s.attr("lay-ignore") && l ? s.next() : s, { + tips: 1 + }) + : "alert" === o ? h.alert(i, { + title: "\u63d0\u793a", + shadeClose: !0 + }) : /\bstring|number\b/.test(typeof i) && h.msg(i, { + icon: 5, + shift: 6 + }), setTimeout(function () { + (l ? s.next().find("input") : r).focus() + }, 7), s.addClass(f), u = !0 + } + }), u)return u + }), !u) + }, t.prototype.submit = function (e, t) { + var i = C(this), + e = "string" == typeof e ? e : i.attr("lay-filter"), + a = this.getFormElem ? this.getFormElem(e) : i.parents(o).eq(0), + n = a.find("*[lay-verify]"); + if (!r.validate(n)) + return !1; + n = r.getValue(null, a), + a = { + elem: this.getFormElem ? window.event && window.event.target : this, + form: (this.getFormElem ? a : i.parents("form"))[0], + field: n + }; + return "function" == typeof t && t(a), + layui.event.call(this, w, "submit(" + e + ")", a) + }), + r = new t, + t = C(document), + q = C(window); + C(function () { + r.render() + }), + t.on("reset", o, function () { + var e = C(this).attr("lay-filter"); + setTimeout(function () { + r.render(null, e) + }, 50) + }), + t.on("submit", o, i).on("click", "*[lay-submit]", i), + e(w, r) +}); +layui.define(["laytpl", "laypage", "form", "util"], function (e) { + "use strict"; + var m = layui.$, + v = layui.laytpl, + c = layui.laypage, + g = layui.layer, + y = layui.form, + b = layui.util, + f = layui.hint(), + h = layui.device(), + x = { + config: { + checkName: "LAY_CHECKED", + indexName: "LAY_TABLE_INDEX", + disabledName: "LAY_DISABLED" + }, + cache: {}, + index: layui.table ? layui.table.index + 1e4 : 0, + set: function (e) { + var t = this; + return t.config = m.extend({}, t.config, e), + t + }, + on: function (e, t) { + return layui.onevent.call(this, C, e, t) + } + }, + p = function () { + var a = this, + e = a.config, + i = e.id || e.index; + return i && (p.that[i] = a, p.config[i] = e), { + config: e, + reload: function (e, t) { + a.reload.call(a, e, t) + }, + reloadData: function (e, t) { + x.reloadData(i, e, t) + }, + setColsWidth: function () { + a.setColsWidth.call(a) + }, + resize: function () { + a.resize.call(a) + } + } + }, + l = function (e) { + var t = p.config[e]; + return t || f.error(e ? "The table instance with ID '" + e + "' not found" : "ID argument required"), + t || null + }, + k = function (e) { + var t = this.config || {}, + a = (e = e || {}).item3, + i = e.content, + t = (("escape" in a ? a : t).escape && (i = b.escape(i)), e.text && a.exportTemplet || a.templet || a.toolbar); + return t && (i = "function" == typeof t ? t.call(a, e.tplData, e.obj) : v(m(t).html() || String(i)).render(m.extend({ + LAY_COL: a + }, e.tplData))), + e.text ? m("
      " + i + "
      ").text() : i + }, + C = "table", + w = "layui-hide", + r = "layui-hide-v", + d = "layui-none", + s = "layui-table-view", + u = ".layui-table-header", + T = ".layui-table-body", + L = ".layui-table-pageview", + N = ".layui-table-sort", + D = "layui-table-edit", + A = "layui-table-hover", + E = "layui-table-col-special", + _ = "LAY_TABLE_MOVE_DICT", + t = function (e) { + return ['', "", "{{# layui.each(d.data.cols, function(i1, item1){ }}", "", "{{# layui.each(item1, function(i2, item2){ }}", '{{# if(item2.fixed && item2.fixed !== "right"){ left = true; } }}', '{{# if(item2.fixed === "right"){ right = true; } }}', (e = e || {}).fixed && "right" !== e.fixed ? '{{# if(item2.fixed && item2.fixed !== "right"){ }}' : "right" === e.fixed ? '{{# if(item2.fixed === "right"){ }}' : "", "{{# var isSort = !(item2.colGroup) && item2.sort; }}", '", e.fixed ? "{{# }; }}" : "", "{{# }); }}", "", "{{# }); }}", "", "
      ', '
      ', '{{# if(item2.type === "checkbox"){ }}', '', "{{# } else { }}", '{{-item2.title||""}}', "{{# if(isSort){ }}", '', "{{# } }}", "{{# } }}", "
      ", "
      "].join("") + }, + a = ['', "", "
      "].join(""), + j = [, "{{# if(d.data.toolbar){ }}", '
      ', '
      ', '
      ', "
      ", "{{# } }}", '
      ', "{{# if(d.data.loading){ }}", '
      ', '', "
      ", "{{# } }}", "{{# var left, right; }}", '
      ', t(), "
      ", '
      ', a, "
      ", "{{# if(left){ }}", '
      ', '
      ', t({ + fixed: !0 + }), "
      ", '
      ', a, "
      ", "
      ", "{{# }; }}", "{{# if(right){ }}", '
      ', '
      ', t({ + fixed: "right" + }), '
      ', "
      ", '
      ', a, "
      ", "
      ", "{{# }; }}", "
      ", "{{# if(d.data.totalRow){ }}", '
      ', '', '', "
      ", "
      ", "{{# } }}", '
      ', '
      ', "
      ", ""].join(""), + R = m(window), + S = m(document), + i = function (e) { + this.index = ++x.index, + this.config = m.extend({}, this.config, x.config, e), + this.render() + }, + F = (i.prototype.config = { + limit: 10, + loading: !0, + escape: !0, + cellMinWidth: 60, + editTrigger: "click", + defaultToolbar: ["filter", "exports", "print"], + autoSort: !0, + text: { + none: "\u65e0\u6570\u636e" + } + }, i.prototype.render = function (e) { + var t = this, + a = t.config; + if (a.elem = m(a.elem), a.where = a.where || {}, a.id = a.id || a.elem.attr("id") || t.index, a.request = m.extend({ + pageName: "page", + limitName: "limit" + }, a.request), a.response = m.extend({ + statusName: "code", + statusCode: 0, + msgName: "msg", + dataName: "data", + totalRowName: "totalRow", + countName: "count" + }, a.response), "object" == typeof a.page && (a.limit = a.page.limit || a.limit, a.limits = a.page.limits || a.limits, t.page = a.page.curr = a.page.curr || 1, delete a.page.elem, delete a.page.jump), !a.elem[0]) + return t; + if ("reloadData" === e) + return t.pullData(t.page, { + type: "reloadData" + }); + a.height && /^full-\d+$/.test(a.height) && (t.fullHeightGap = a.height.split("-")[1], a.height = R.height() - t.fullHeightGap), + t.setInit(); + var i, + l, + e = a.elem, + n = e.next("." + s), + o = t.elem = m("
      "); + o.addClass((i = [s, s + "-" + t.index, "layui-form", "layui-border-box"], a.className && i.push(a.className), i.join(" "))).attr({ + "lay-filter": "LAY-TABLE-FORM-DF-" + t.index, + "lay-id": a.id, + style: (i = [], a.width && i.push("width:" + a.width + "px;"), a.height && i.push("height:" + a.height + "px;"), i.join("")) + }).html(v(j).render({ + data: a, + index: t.index + })), + a.index = t.index, + t.key = a.id || a.index, + n[0] && n.remove(), + e.after(o), + t.layTool = o.find(".layui-table-tool"), + t.layBox = o.find(".layui-table-box"), + t.layHeader = o.find(u), + t.layMain = o.find(".layui-table-main"), + t.layBody = o.find(T), + t.layFixed = o.find(".layui-table-fixed"), + t.layFixLeft = o.find(".layui-table-fixed-l"), + t.layFixRight = o.find(".layui-table-fixed-r"), + t.layTotal = o.find(".layui-table-total"), + t.layPage = o.find(".layui-table-page"), + t.renderToolbar(), + t.renderPagebar(), + t.fullSize(), + 1 < a.cols.length && (i = t.layFixed.find(u).find("th"), l = t.layHeader.first(), layui.each(i, function (e, t) { + (t = m(t)).height(l.find('th[data-key="' + t.attr("data-key") + '"]').height() + "px") + })), + t.pullData(t.page), + t.events() + }, i.prototype.initOpts = function (e) { + this.config; + e.checkbox && (e.type = "checkbox"), + e.space && (e.type = "space"), + e.type || (e.type = "normal"), + "normal" !== e.type && (e.unresize = !0, e.width = e.width || { + checkbox: 50, + radio: 50, + space: 30, + numbers: 60 + } + [e.type]) + }, i.prototype.setInit = function (e) { + var l, + a, + c = this, + r = c.config; + if (r.clientWidth = r.width || (l = function (e) { + var t, + a = (e = e || r.elem.parent()).width(); + try { + t = "none" === e.css("display") + } catch (i) {} + return !e[0] || a && !t ? a : l(e.parent()) + })(), "width" === e) + return r.clientWidth; + r.css && -1 === r.css.indexOf(s) && (a = r.css.split("}"), layui.each(a, function (e, t) { + t && (a[e] = "." + s + "-" + c.index + " " + t) + }), r.css = a.join("}")); + var d = function (a, e, i, l) { + var n, + o; + l ? (l.key = a + "-" + i, l.hide = l.hide || !1, l.colspan = l.colspan || 1, l.rowspan = l.rowspan || 1, c.initOpts(l), (n = a + (parseInt(l.rowspan) || 1)) < r.cols.length ? (l.colGroup = !0, o = 0, layui.each(r.cols[n], function (e, t) { + t.HAS_PARENT || 1 <= o && o == (l.colspan || 1) || (t.HAS_PARENT = !0, t.parentKey = a + "-" + i, o += parseInt(1 < t.colspan ? t.colspan : 1), d(n, r.cols[n], e, t)) + })) : l.colGroup = !1) : e.splice(i, 1) + }; + layui.each(r.cols, function (a, i) { + if (a) + return !0; + layui.each(i, function (e, t) { + d(a, i, e, t) + }) + }) + }, i.prototype.renderToolbar = function () { + var e = this.config, + t = ['
      ', '
      ', '
      '].join(""), + a = this.layTool.find(".layui-table-tool-temp"), + i = ("default" === e.toolbar ? a.html(t) : "string" == typeof e.toolbar && (t = m(e.toolbar).html() || "") && a.html(v(t).render(e)), { + filter: { + title: "\u7b5b\u9009\u5217", + layEvent: "LAYTABLE_COLS", + icon: "layui-icon-cols" + }, + exports: { + title: "\u5bfc\u51fa", + layEvent: "LAYTABLE_EXPORT", + icon: "layui-icon-export" + }, + print: { + title: "\u6253\u5370", + layEvent: "LAYTABLE_PRINT", + icon: "layui-icon-print" + } + }), + l = []; + "object" == typeof e.defaultToolbar && layui.each(e.defaultToolbar, function (e, t) { + t = "string" == typeof t ? i[t] : t; + t && l.push('
      ') + }), + this.layTool.find(".layui-table-tool-self").html(l.join("")) + }, i.prototype.renderPagebar = function () { + var e, + t = this.config, + a = this.layPagebar = m('
      '); + t.pagebar && ((e = m(t.pagebar).html() || "") && a.append(v(e).render(t)), this.layPage.append(a)) + }, i.prototype.setParentCol = function (e, t) { + var a = this.config, + i = this.layHeader.find('th[data-key="' + a.index + "-" + t + '"]'), + l = parseInt(i.attr("colspan")) || 0; + i[0] && (t = t.split("-"), t = a.cols[t[0]][t[1]], e ? l-- : l++, i.attr("colspan", l), i[l < 1 ? "addClass" : "removeClass"](w), t.colspan = l, t.hide = l < 1, (a = i.data("parentkey")) && this.setParentCol(e, a)) + }, i.prototype.setColsPatch = function () { + var a = this, + e = a.config; + layui.each(e.cols, function (e, t) { + layui.each(t, function (e, t) { + t.hide && a.setParentCol(t.hide, t.parentKey) + }) + }) + }, i.prototype.setColsWidth = function () { + var t, + a, + i = this, + o = i.config, + l = 0, + c = 0, + r = 0, + d = 0, + s = i.setInit("width"), + e = (i.eachCols(function (e, t) { + t.hide || l++ + }), s = s - ("line" === o.skin || "nob" === o.skin ? 2 : l + 1) - i.getScrollWidth(i.layMain[0]) - 1, function (n) { + layui.each(o.cols, function (e, l) { + layui.each(l, function (e, t) { + var a = 0, + i = t.minWidth || o.cellMinWidth; + t ? t.colGroup || t.hide || (n ? r && r < i && (c--, a = i) : (a = t.width || 0, /\d+%$/.test(a) ? (a = Math.floor(parseFloat(a) / 100 * s)) < i && (a = i) : a || (t.width = a = 0, c++)), t.hide && (a = 0), d += a) : l.splice(e, 1) + }) + }), + d < s && c && (r = (s - d) / c) + }), + n = (e(), e(!0), i.autoColNums = c, i.eachCols(function (e, t) { + var a = t.minWidth || o.cellMinWidth; + t.colGroup || t.hide || (0 === t.width ? i.getCssRule(o.index + "-" + t.key, function (e) { + e.style.width = Math.floor(a <= r ? r : a) + "px" + }) : /\d+%$/.test(t.width) && i.getCssRule(o.index + "-" + t.key, function (e) { + e.style.width = Math.floor(parseFloat(t.width) / 100 * s) + "px" + })) + }), i.layMain.width() - i.getScrollWidth(i.layMain[0]) - i.layMain.children("table").outerWidth()); + i.autoColNums && -l <= n && n <= l && (e = (a = (t = function (e) { + return !(e = e || i.layHeader.eq(0).find("thead th:last-child")).data("field") && e.prev()[0] ? t(e.prev()) : e + })()).data("key"), i.getCssRule(e, function (e) { + var t = e.style.width || a.outerWidth(); + e.style.width = parseFloat(t) + n + "px", + 0 < i.layMain.height() - i.layMain.prop("clientHeight") && (e.style.width = parseFloat(e.style.width) - 1 + "px") + })), + i.loading(!0) + }, i.prototype.resize = function () { + this.fullSize(), + this.setColsWidth(), + this.scrollPatch() + }, i.prototype.reload = function (e, t, a) { + var i = this; + e = e || {}, + delete i.haveInit, + layui.each(e, function (e, t) { + "array" === layui.type(t) && delete i.config[e] + }), + i.config = m.extend(t, {}, i.config, e), + i.render(a) + }, i.prototype.errorView = function (e) { + var t = this, + a = t.layMain.find("." + d), + e = m('
      ' + (e || "Error") + "
      "); + a[0] && (t.layNone.remove(), a.remove()), + t.layFixed.addClass(w), + t.layMain.find("tbody").html(""), + t.layMain.append(t.layNone = e), + t.layTotal.addClass(r), + t.layPage.find(L).addClass(r), + x.cache[t.key] = [], + t.syncCheckAll() + }, i.prototype.page = 1, i.prototype.pullData = function (t, a) { + var e, + i = this, + l = i.config, + n = l.request, + o = l.response, + c = function () { + "object" == typeof l.initSort && i.sort(l.initSort.field, l.initSort.type) + }; + a = a || {}, + "function" == typeof l.before && l.before(l), + i.startTime = (new Date).getTime(), + l.url ? ((e = {})[n.pageName] = t, e[n.limitName] = l.limit, n = m.extend(e, l.where), l.contentType && 0 == l.contentType.indexOf("application/json") && (n = JSON.stringify(n)), i.loading(), m.ajax({ + type: l.method || "get", + url: l.url, + contentType: l.contentType, + data: n, + dataType: l.dataType || "json", + jsonpCallback: l.jsonpCallback, + headers: l.headers || {}, + success: function (e) { + (e = "function" == typeof l.parseData ? l.parseData(e) || e : e)[o.statusName] != o.statusCode ? (i.renderForm(), i.errorView(e[o.msgName] || '\u8fd4\u56de\u7684\u6570\u636e\u4e0d\u7b26\u5408\u89c4\u8303\uff0c\u6b63\u786e\u7684\u6210\u529f\u72b6\u6001\u7801\u5e94\u4e3a\uff1a"' + o.statusName + '": ' + o.statusCode)) : (i.renderData({ + res: e, + curr: t, + count: e[o.countName], + type: a.type + }), c(), l.time = (new Date).getTime() - i.startTime + " ms"), + i.setColsWidth(), + "function" == typeof l.done && l.done(e, t, e[o.countName]) + }, + error: function (e, t) { + i.errorView("\u8bf7\u6c42\u5f02\u5e38\uff0c\u9519\u8bef\u63d0\u793a\uff1a" + t), + i.renderForm(), + i.setColsWidth(), + "function" == typeof l.error && l.error(e, t) + } + })) : "array" === layui.type(l.data) && (e = t * l.limit - l.limit, (n = {})[o.dataName] = l.data.concat().splice(e, l.limit), n[o.countName] = l.data.length, "object" == typeof l.totalRow && (n[o.totalRowName] = m.extend({}, l.totalRow)), i.renderData({ + res: n, + curr: t, + count: n[o.countName], + type: a.type + }), c(), i.setColsWidth(), "function" == typeof l.done && l.done(n, t, n[o.countName])) + }, i.prototype.eachCols = function (e) { + return x.eachCols(null, e, this.config.cols), + this + }, i.prototype.col = function (e) { + try { + return e = e.split("-"), + this.config.cols[e[1]][e[2]] + } catch (t) { + return f.error(t), {} + } + }, i.prototype.renderData = function (e) { + var u = this, + y = u.config, + t = e.res, + l = e.curr, + a = e.count, + n = e.sort, + i = t[y.response.dataName] || [], + t = t[y.response.totalRowName], + h = [], + f = [], + p = [], + o = function () { + var s; + if (y.HAS_SET_COLS_PATCH || u.setColsPatch(), y.HAS_SET_COLS_PATCH = !0, !n && u.sortKey) + return u.sort(u.sortKey.field, u.sortKey.sort, !0); + layui.each(i, function (o, c) { + var a = [], + i = [], + r = [], + d = o + y.limit * (l - 1) + 1; + "array" === layui.type(c) && 0 === c.length || (n || (c[x.config.indexName] = o), u.eachCols(function (e, l) { + var e = l.field || e, + t = y.index + "-" + l.key, + n = c[e]; + n !== undefined && null !== n || (n = ""), + l.colGroup || (t = ['', '
      " + function () { + var e, + t = m.extend(!0, { + LAY_INDEX: d, + LAY_COL: l + }, c), + a = x.config.checkName, + i = x.config.disabledName; + switch (l.type) { + case "checkbox": + return '"; + case "radio": + return t[a] && (s = o), + ''; + case "numbers": + return d + } + return l.toolbar ? v(m(l.toolbar).html() || "").render(t) : k.call(u, { + item3: l, + content: n, + tplData: t + }) + } + (), "
      "].join(""), a.push(t), l.fixed && "right" !== l.fixed && i.push(t), "right" === l.fixed && r.push(t)) + }), h.push('' + a.join("") + ""), f.push('' + i.join("") + ""), p.push('' + r.join("") + "")) + }), + "fixed" === y.scrollPos && "reloadData" === e.type || u.layBody.scrollTop(0), + "reset" === y.scrollPos && u.layBody.scrollLeft(0), + u.layMain.find("." + d).remove(), + u.layMain.find("tbody").html(h.join("")), + u.layFixLeft.find("tbody").html(f.join("")), + u.layFixRight.find("tbody").html(p.join("")), + u.renderForm(), + "number" == typeof s && u.setThisRowChecked(s), + u.syncCheckAll(), + u.fullSize(), + u.haveInit ? u.scrollPatch() : setTimeout(function () { + u.scrollPatch() + }, 50), + u.haveInit = !0, + g.close(u.tipsIndex) + }; + return x.cache[u.key] = i, + u.layTotal[0 == i.length ? "addClass" : "removeClass"](r), + u.layPage[y.page || y.pagebar ? "removeClass" : "addClass"](w), + u.layPage.find(L)[!y.page || 0 == a || 0 === i.length && 1 == l ? "addClass" : "removeClass"](r), + 0 === i.length ? (u.renderForm(), u.errorView(y.text.none)) : (u.layFixLeft.removeClass(w), n ? o() : (o(), u.renderTotal(i, t), u.layTotal && u.layTotal.removeClass(w), void(y.page && (y.page = m.extend({ + elem: "layui-table-page" + y.index, + count: a, + limit: y.limit, + limits: y.limits || [10, 20, 30, 40, 50, 60, 70, 80, 90], + groups: 3, + layout: ["prev", "page", "next", "skip", "count", "limit"], + prev: '', + next: '', + jump: function (e, t) { + t || (u.page = e.curr, y.limit = e.limit, u.pullData(e.curr)) + } + }, y.page), y.page.count = a, c.render(y.page))))) + }, i.prototype.renderTotal = function (e, o) { + var c, + r = this, + d = r.config, + s = {}; + d.totalRow && (layui.each(e, function (e, i) { + "array" === layui.type(i) && 0 === i.length || r.eachCols(function (e, t) { + var e = t.field || e, + a = i[e]; + t.totalRow && (s[e] = (s[e] || 0) + (parseFloat(a) || 0)) + }) + }), r.dataTotal = {}, c = [], r.eachCols(function (e, t) { + var a, + e = t.field || e, + i = o && o[t.field], + l = (a = t.totalRowText || "", n = "totalRowDecimals" in t ? t.totalRowDecimals : 2, n = parseFloat(s[e]).toFixed(n), (l = { + LAY_COL: t + })[e] = n, n = t.totalRow && k.call(r, { + item3: t, + content: n, + tplData: l + }) || a, i || n), + n = ['', '
      " + ("string" == typeof(a = t.totalRow || d.totalRow) ? v(a).render(m.extend({ + TOTAL_NUMS: i || s[e], + LAY_COL: t + }, t)) : l), "
      "].join(""); + t.field && (r.dataTotal[e] = l), + c.push(n) + }), r.layTotal.find("tbody").html("" + c.join("") + "")) + }, i.prototype.getColElem = function (e, t) { + var a = this.config; + return e.eq(0).find(".laytable-cell-" + a.index + "-" + t + ":eq(0)") + }, i.prototype.renderForm = function (e) { + this.config; + var t = this.elem.attr("lay-filter"); + y.render(e, t) + }, i.prototype.setThisRowChecked = function (e) { + this.config; + var t = "layui-table-click"; + this.layBody.find('tr[data-index="' + e + '"]').addClass(t).siblings("tr").removeClass(t) + }, i.prototype.sort = function (l, e, t, a) { + var i, + n = this, + o = {}, + c = n.config, + r = c.elem.attr("lay-filter"), + d = x.cache[n.key]; + "string" == typeof l && (s = l, n.layHeader.find("th").each(function (e, t) { + var a = m(this), + i = a.data("field"); + if (i === l) + return l = a, s = i, !1 + })); + try { + var s = s || l.data("field"), + u = l.data("key"); + if (n.sortKey && !t && s === n.sortKey.field && e === n.sortKey.sort) + return; + var y = n.layHeader.find("th .laytable-cell-" + u).find(N); + n.layHeader.find("th").find(N).removeAttr("lay-sort"), + y.attr("lay-sort", e || null), + n.layFixed.find("th") + } catch (h) { + f.error("Table modules: sort field '" + s + "' not matched") + } + n.sortKey = { + field: s, + sort: e + }, + c.autoSort && ("asc" === e ? i = layui.sort(d, s) : "desc" === e ? i = layui.sort(d, s, !0) : (i = layui.sort(d, x.config.indexName), delete n.sortKey, delete c.initSort)), + o[c.response.dataName] = i || d, + n.renderData({ + res: o, + curr: n.page, + count: n.count, + sort: !0 + }), + a && (c.initSort = { + field: s, + type: e + }, layui.event.call(l, C, "sort(" + r + ")", c.initSort)) + }, i.prototype.loading = function (e) { + var t = this; + t.config.loading && (e ? (t.layInit && t.layInit.remove(), delete t.layInit, t.layBox.find(".layui-table-init").remove()) : (t.layInit = m(['
      ', '', "
      "].join("")), t.layBox.append(t.layInit))) + }, i.prototype.setCheckData = function (e, t) { + var a = this.config, + i = x.cache[this.key]; + i[e] && "array" !== layui.type(i[e]) && (i[e][a.checkName] = t) + }, i.prototype.syncCheckAll = function () { + var e = this, + i = e.config, + t = e.layHeader.find('input[name="layTableCheckbox"]'), + a = function (a) { + return e.eachCols(function (e, t) { + "checkbox" === t.type && (t[i.checkName] = a) + }), + a + }; + t[0] && (x.checkStatus(e.key).isAll ? (t[0].checked || (t.prop("checked", !0), e.renderForm("checkbox")), a(!0)) : (t[0].checked && (t.prop("checked", !1), e.renderForm("checkbox")), a(!1))) + }, i.prototype.getCssRule = function (a, i) { + var e = this.elem.find("style")[0], + e = e.sheet || e.styleSheet || {}, + e = e.cssRules || e.rules; + layui.each(e, function (e, t) { + if (t.selectorText === ".laytable-cell-" + a) + return i(t), !0 + }) + }, i.prototype.fullSize = function () { + var e = this, + t = e.config, + a = t.height; + e.fullHeightGap && (a = R.height() - e.fullHeightGap, e.elem.css("height", a = a < 135 ? 135 : a)), + a && (a = parseFloat(a) - (e.layHeader.outerHeight() || 38), t.toolbar && (a -= e.layTool.outerHeight() || 50), t.totalRow && (a -= e.layTotal.outerHeight() || 40), (t.page || t.pagebar) && (a -= e.layPage.outerHeight() || 43), e.layMain.outerHeight(a)) + }, i.prototype.getScrollWidth = function (e) { + var t = 0; + return e ? t = e.offsetWidth - e.clientWidth : ((e = document.createElement("div")).style.width = "100px", e.style.height = "100px", e.style.overflowY = "scroll", document.body.appendChild(e), t = e.offsetWidth - e.clientWidth, document.body.removeChild(e)), + t + }, i.prototype.scrollPatch = function () { + var e = this, + t = e.layMain.children("table"), + a = e.layMain.width() - e.layMain.prop("clientWidth"), + i = e.layMain.height() - e.layMain.prop("clientHeight"), + l = (e.getScrollWidth(e.layMain[0]), t.outerWidth() - e.layMain.width()), + n = function (e) { + var t; + a && i ? (e = e.eq(0)).find(".layui-table-patch")[0] || ((t = m('
      ')).find("div").css({ + width: a + }), e.find("tr").append(t)) : e.find(".layui-table-patch").remove() + }; + n(e.layHeader), + n(e.layTotal); + n = e.layMain.height() - i; + e.layFixed.find(T).css("height", t.height() >= n ? n : "auto"), + e.layFixRight[0 < l ? "removeClass" : "addClass"](w), + e.layFixRight.css("right", a - 1) + }, i.prototype.events = function () { + var s = this, + r = s.config, + d = r.elem.attr("lay-filter"), + e = s.layHeader.find("th"), + u = ".layui-table-cell", + i = m("body"), + l = {}, + n = (s.layTool.on("click", "*[lay-event]", function (e) { + var a, + i = m(this), + t = i.attr("lay-event"), + l = function (e) { + var t = m(e.list), + a = m('
        '); + a.html(t), + r.height && a.css("max-height", r.height - (s.layTool.outerHeight() || 50)), + i.find(".layui-table-tool-panel")[0] || i.append(a), + s.renderForm(), + a.on("click", function (e) { + layui.stope(e) + }), + e.done && e.done(a, t) + }; + switch (layui.stope(e), S.trigger("table.tool.panel.remove"), g.close(s.tipsIndex), t) { + case "LAYTABLE_COLS": + l({ + list: (a = [], s.eachCols(function (e, t) { + t.field && "normal" == t.type && a.push('
      • ') + }), a.join("")), + done: function () { + y.on("checkbox(LAY_TABLE_TOOL_COLS)", function (e) { + var e = m(e.elem), + i = this.checked, + l = e.data("key"), + n = e.data("parentkey"); + layui.each(r.cols, function (a, e) { + layui.each(e, function (e, t) { + a + "-" + e === l && (e = t.hide, t.hide = !i, s.elem.find('*[data-key="' + r.index + "-" + l + '"]')[i ? "removeClass" : "addClass"](w), e != t.hide && s.setParentCol(!i, n), s.resize()) + }) + }) + }) + } + }); + break; + case "LAYTABLE_EXPORT": + h.ie ? g.tips("\u5bfc\u51fa\u529f\u80fd\u4e0d\u652f\u6301 IE\uff0c\u8bf7\u7528 Chrome \u7b49\u9ad8\u7ea7\u6d4f\u89c8\u5668\u5bfc\u51fa", this, { + tips: 3 + }) : l({ + list: ['
      • \u5bfc\u51fa csv \u683c\u5f0f\u6587\u4ef6
      • ', '
      • \u5bfc\u51fa xls \u683c\u5f0f\u6587\u4ef6
      • '].join(""), + done: function (e, t) { + t.on("click", function () { + var e = m(this).data("type"); + x.exportFile.call(s, r.id, null, e) + }) + } + }); + break; + case "LAYTABLE_PRINT": + var n = window.open("about:blank", "_blank"), + o = [""].join(""), + c = m(s.layHeader.html()); + c.append(s.layMain.find("table").html()), + c.append(s.layTotal.find("table").html()), + c.find("th.layui-table-patch").remove(), + c.find("thead>tr>th." + E).filter(function (e, t) { + return !m(t).children(".laytable-cell-group").length + }).remove(), + c.find("tbody>tr>td." + E).remove(), + n.document.write(o + c.prop("outerHTML")), + n.document.close(), + n.print(), + n.close() + } + layui.event.call(this, C, "toolbar(" + d + ")", m.extend({ + event: t, + config: r + }, {})) + }), s.layPagebar.on("click", "*[lay-event]", function (e) { + var t = m(this).attr("lay-event"); + layui.event.call(this, C, "pagebar(" + d + ")", m.extend({ + event: t, + config: r + }, {})) + }), e.on("mousemove", function (e) { + var t = m(this), + a = t.offset().left, + e = e.clientX - a; + t.data("unresize") || p.eventMoveElem || (l.allowResize = t.width() - e <= 10, i.css("cursor", l.allowResize ? "col-resize" : "")) + }).on("mouseleave", function () { + m(this); + p.eventMoveElem || i.css("cursor", "") + }).on("mousedown", function (e) { + var t, + a = m(this); + l.allowResize && (t = a.data("key"), e.preventDefault(), l.offset = [e.clientX, e.clientY], s.getCssRule(t, function (e) { + var t = e.style.width || a.outerWidth(); + l.rule = e, + l.ruleWidth = parseFloat(t), + l.minWidth = a.data("minwidth") || r.cellMinWidth + }), a.data(_, l), p.eventMoveElem = a) + }), p.docEvent || S.on("mousemove", function (e) { + var t; + p.eventMoveElem && (t = p.eventMoveElem.data(_) || {}, p.eventMoveElem.data("resizing", 1), e.preventDefault(), t.rule && ((e = t.ruleWidth + e.clientX - t.offset[0]) < t.minWidth && (e = t.minWidth), t.rule.style.width = e + "px", g.close(s.tipsIndex))) + }).on("mouseup", function (e) { + p.eventMoveElem && (l = {}, i.css("cursor", ""), s.scrollPatch(), p.eventMoveElem.removeData(_), delete p.eventMoveElem) + }), p.docEvent = !0, e.on("click", function (e) { + var t = m(this), + a = t.find(N), + i = a.attr("lay-sort"); + if (!a[0] || 1 === t.data("resizing")) + return t.removeData("resizing"); + s.sort(t, "asc" === i ? "desc" : "desc" === i ? null : "asc", null, !0) + }).find(N + " .layui-edge ").on("click", function (e) { + var t = m(this), + a = t.index(), + t = t.parents("th").eq(0).data("field"); + layui.stope(e), + 0 === a ? s.sort(t, "asc", null, !0) : s.sort(t, "desc", null, !0) + }), s.commonMember = function (e) { + var t = m(this).parents("tr").eq(0).data("index"), + r = s.layBody.find('tr[data-index="' + t + '"]'), + d = (d = x.cache[s.key] || [])[t] || {}; + return m.extend({ + tr: r, + data: x.clearCacheKey(d), + del: function () { + x.cache[s.key][t] = [], + r.remove(), + s.scrollPatch() + }, + update: function (e, c) { + e = e || {}, + layui.each(e, function (i, l) { + var n = r.children('td[data-field="' + i + '"]'), + o = n.children(u); + i in d && (d[i] = l), + s.eachCols(function (e, t) { + var a; + t.field == i ? (o.html(k.call(s, { + item3: t, + content: l, + tplData: d + })), n.data("content", l)) : c && (t.templet || t.toolbar) && (e = r.children('td[data-field="' + (t.field || e) + '"]'), a = d[t.field], e.children(u).html(k.call(s, { + item3: t, + content: a, + tplData: d + })), e.data("content", a)) + }) + }), + s.renderForm() + } + }, e) + }), + t = (s.elem.on("click", 'input[name="layTableCheckbox"]+', function () { + var e = m(this).prev(), + t = s.layBody.find('input[name="layTableCheckbox"]'), + a = e.parents("tr").eq(0).data("index"), + i = e[0].checked, + l = "layTableAllChoose" === e.attr("lay-filter"); + e[0].disabled || (l ? (t.each(function (e, t) { + t.checked = i, + s.setCheckData(e, i) + }), s.syncCheckAll(), s.renderForm("checkbox")) : (s.setCheckData(a, i), s.syncCheckAll()), layui.event.call(e[0], C, "checkbox(" + d + ")", n.call(e[0], { + checked: i, + type: l ? "all" : "one" + }))) + }), s.elem.on("click", 'input[lay-type="layTableRadio"]+', function () { + var e = m(this).prev(), + t = e[0].checked, + a = x.cache[s.key], + i = e.parents("tr").eq(0).data("index"); + layui.each(a, function (e, t) { + i === e ? t[r.checkName] = !0 : delete t[r.checkName] + }), + s.setThisRowChecked(i), + layui.event.call(this, C, "radio(" + d + ")", n.call(this, { + checked: t + })) + }), s.layBody.on("mouseenter", "tr", function () { + var e = m(this), + t = e.index(); + e.data("off") || s.layBody.find("tr:eq(" + t + ")").addClass(A) + }).on("mouseleave", "tr", function () { + var e = m(this), + t = e.index(); + e.data("off") || s.layBody.find("tr:eq(" + t + ")").removeClass(A) + }).on("click", "tr", function () { + t.call(this, "row") + }).on("dblclick", "tr", function () { + t.call(this, "rowDouble") + }), function (e) { + var t = m(this); + t.data("off") || layui.event.call(this, C, e + "(" + d + ")", n.call(t.children("td")[0])) + }), + o = (s.layBody.on("change", "." + D, function () { + var e = m(this), + t = this.value, + a = e.parent().data("field"), + e = e.parents("tr").eq(0).data("index"); + x.cache[s.key][e][a] = t, + layui.event.call(this, C, "edit(" + d + ")", n.call(this, { + value: t, + field: a + })) + }).on("blur", "." + D, function () { + var e, + t = m(this), + a = t.parent(), + i = a.data("key"), + l = t.closest("tr").data("index"), + l = x.cache[s.key][l]; + t.siblings(u).html((e = t[0].value, k.call(s, { + item3: s.col(i), + content: e, + tplData: l + }))), + a.data("content", t[0].value), + t.remove() + }), s.layBody.on(r.editTrigger, "td", function (e) { + var t, + a, + i, + l, + n = m(this); + n.data("off") || (t = n.data("field"), l = n.data("key"), l = s.col(l), a = n.closest("tr").data("index"), a = x.cache[s.key][a], i = n.children(u), (l = "function" == typeof l.edit ? l.edit(a) : l.edit) && ((l = m("textarea" === l ? '' : ''))[0].value = n.data("content") || a[t] || i.text(), n.find("." + D)[0] || n.append(l), l.focus(), layui.stope(e))) + }).on("mouseenter", "td", function () { + a.call(this) + }).on("mouseleave", "td", function () { + a.call(this, "hide") + }), "layui-table-grid-down"), + a = function (e) { + var t = m(this), + a = t.children(u); + t.data("off") || (e ? t.find(".layui-table-grid-down").remove() : !(a.prop("scrollWidth") > a.outerWidth() || 0 < a.find("br").length) || r.lineStyle || a.find("." + o)[0] || t.append('
        ')) + }, + c = (s.layBody.on("click", "." + o, function (e) { + var t = m(this).parent().children(u); + s.tipsIndex = g.tips(['
        ', t.html(), "
        ", ''].join(""), t[0], { + tips: [3, ""], + time: -1, + anim: -1, + maxWidth: h.ios || h.android ? 300 : s.elem.width() / 2, + isOutAnim: !1, + skin: "layui-table-tips", + success: function (e, t) { + e.find(".layui-table-tips-c").on("click", function () { + g.close(t) + }) + } + }), + layui.stope(e) + }), function (e) { + var t = m(this), + a = t.parents("tr").eq(0).data("index"); + layui.event.call(this, C, (e || "tool") + "(" + d + ")", n.call(this, { + event: t.attr("lay-event") + })), + s.setThisRowChecked(a) + }); + s.layBody.on("click", "*[lay-event]", function (e) { + c.call(this), + layui.stope(e) + }).on("dblclick", "*[lay-event]", function (e) { + c.call(this, "toolDouble"), + layui.stope(e) + }), + s.layMain.on("scroll", function () { + var e = m(this), + t = e.scrollLeft(), + e = e.scrollTop(); + s.layHeader.scrollLeft(t), + s.layTotal.scrollLeft(t), + s.layFixed.find(T).scrollTop(e), + g.close(s.tipsIndex) + }), + R.on("resize", function () { + s.resize() + }) + }, S.on("click", function () { + S.trigger("table.remove.tool.panel") + }), S.on("table.remove.tool.panel", function () { + m(".layui-table-tool-panel").remove() + }), x.init = function (a, i) { + i = i || {}; + var e = m(a ? 'table[lay-filter="' + a + '"]' : ".layui-table[lay-data]"), + c = "Table element property lay-data configuration item has a syntax error: "; + return e.each(function () { + var e = m(this), + t = e.attr("lay-data"); + try { + t = new Function("return " + t)() + } catch (l) { + f.error(c + t, "error") + } + var n = [], + o = m.extend({ + elem: this, + cols: [], + data: [], + skin: e.attr("lay-skin"), + size: e.attr("lay-size"), + even: "string" == typeof e.attr("lay-even") + }, x.config, i, t); + a && e.hide(), + e.find("thead>tr").each(function (i) { + o.cols[i] = [], + m(this).children().each(function (e) { + var t = m(this), + a = t.attr("lay-data"); + try { + a = new Function("return " + a)() + } catch (l) { + return f.error(c + a) + } + t = m.extend({ + title: t.text(), + colspan: t.attr("colspan") || 1, + rowspan: t.attr("rowspan") || 1 + }, a); + t.colspan < 2 && n.push(t), + o.cols[i].push(t) + }) + }), + e.find("tbody>tr").each(function (e) { + var a = m(this), + l = {}; + a.children("td").each(function (e, t) { + var a = m(this), + i = a.data("field"); + if (i) + return l[i] = a.html() + }), + layui.each(n, function (e, t) { + e = a.children("td").eq(e); + l[t.field] = e.html() + }), + o.data[e] = l + }), + x.render(o) + }), + this + }, p.that = {}, p.config = {}, function (a, i, e, l) { + var n, + o; + l.colGroup && (n = 0, a++, l.CHILD_COLS = [], o = e + (parseInt(l.rowspan) || 1), layui.each(i[o], function (e, t) { + t.parentKey ? t.parentKey === l.key && (t.PARENT_COL_INDEX = a, l.CHILD_COLS.push(t), F(a, i, o, t)) : t.PARENT_COL_INDEX || 1 <= n && n == (l.colspan || 1) || (t.PARENT_COL_INDEX = a, l.CHILD_COLS.push(t), n += t.hide ? 0 : parseInt(1 < t.colspan ? t.colspan : 1), F(a, i, o, t)) + })) + }); + x.eachCols = function (e, a, i) { + var e = p.config[e] || {}, + l = [], + n = (i = m.extend(!0, [], i || e.cols), layui.each(i, function (a, e) { + if (a) + return !0; + layui.each(e, function (e, t) { + F(0, i, a, t), + t.PARENT_COL_INDEX || l.push(t) + }) + }), function (e) { + layui.each(e || l, function (e, t) { + if (t.CHILD_COLS) + return n(t.CHILD_COLS); + "function" == typeof a && a(e, t) + }) + }); + n() + }, + x.checkStatus = function (e) { + var a = 0, + i = 0, + l = [], + e = x.cache[e] || []; + return layui.each(e, function (e, t) { + "array" === layui.type(t) ? i++ : t[x.config.checkName] && (a++, t[x.config.disabledName] || l.push(x.clearCacheKey(t))) + }), { + data: l, + isAll: !!e.length && a === e.length - i + } + }, + x.getData = function (e) { + var a = [], + e = x.cache[e] || []; + return layui.each(e, function (e, t) { + "array" !== layui.type(t) && a.push(x.clearCacheKey(t)) + }), + a + }, + x.exportFile = function (e, t, a) { + t = t || x.clearCacheKey(x.cache[e]); + var c, + i, + l, + r, + n = (a = "object" == typeof a ? a : (n = {}, a && (n.type = a), n)).type || "csv", + d = p.that[e], + o = p.config[e] || {}, + s = { + csv: "text/csv", + xls: "application/vnd.ms-excel" + } + [n], + u = document.createElement("a"); + if (h.ie) + return f.error("IE_NOT_SUPPORT_EXPORTS"); + u.href = "data:" + s + ";charset=utf-8,\ufeff" + encodeURIComponent((c = [], i = [], l = [], r = {}, layui.each(t, function (l, n) { + var o = []; + "object" == typeof e ? (layui.each(e, function (e, t) { + 0 == l && c.push(t || "") + }), layui.each(x.clearCacheKey(n), function (e, t) { + o.push('"' + (t || "") + '"') + })) : x.eachCols(e, function (e, t) { + var a, + i; + t.field && "normal" == t.type && (t.hide ? 0 == l && (r[t.field] = !0) : (a = n[t.field], i = d.layBody.find('tr[data-index="' + l + '"]>td'), a !== undefined && null !== a || (a = ""), 0 == l && c.push(t.title || ""), o.push('"' + k.call(d, { + item3: t, + content: a, + tplData: n, + text: "text", + obj: d.commonMember.call(i.eq(0), { + td: function (e) { + return i.filter('[data-field="' + e + '"]') + } + }) + }) + '"'))) + }), + i.push(o.join(",")) + }), d && layui.each(d.dataTotal, function (e, t) { + r[e] || l.push(t) + }), c.join(",") + "\r\n" + i.join("\r\n") + "\r\n" + l.join(","))), + u.download = (a.title || o.title || "table_" + (o.index || "")) + "." + n, + document.body.appendChild(u), + u.click(), + document.body.removeChild(u) + }, + x.resize = function (e) { + e ? l(e) && p.that[e].resize() : layui.each(p.that, function () { + this.resize() + }) + }, + x.reload = function (e, t, a, i) { + if (l(e)) + return e = p.that[e], e.reload(t, a, i), p.call(e) + }, + x.reloadData = function () { + var a = m.extend([], arguments), + i = (a[3] = "reloadData", new RegExp("^(" + ["data", "url", "method", "contentType", "dataType", "jsonpCallback", "headers", "where", "page", "limit", "request", "response", "parseData", "scrollPos"].join("|") + ")$")); + return layui.each(a[1], function (e, t) { + i.test(e) || delete a[1][e] + }), + x.reload.apply(null, a) + }, + x.render = function (e) { + e = new i(e); + return p.call(e) + }, + x.clearCacheKey = function (e) { + return delete (e = m.extend({}, e))[x.config.checkName], + delete e[x.config.indexName], + delete e[x.config.disabledName], + e + }, + m(function () { + x.init() + }), + e(C, x) +}); +layui.define("form", function (e) { + "use strict"; + var u = layui.$, + i = layui.form, + p = layui.layer, + n = "tree", + a = { + config: {}, + index: layui[n] ? layui[n].index + 1e4 : 0, + set: function (e) { + var i = this; + return i.config = u.extend({}, i.config, e), + i + }, + on: function (e, i) { + return layui.onevent.call(this, n, e, i) + } + }, + t = function () { + var i = this, + e = i.config, + n = e.id || i.index; + return t.that[n] = i, { + config: t.config[n] = e, + reload: function (e) { + i.reload.call(i, e) + }, + getChecked: function () { + return i.getChecked.call(i) + }, + setChecked: function (e) { + return i.setChecked.call(i, e) + } + } + }, + y = "layui-hide", + d = "layui-disabled", + f = "layui-tree-set", + C = "layui-tree-iconClick", + k = "layui-icon-addition", + v = "layui-icon-subtraction", + m = "layui-tree-entry", + x = "layui-tree-main", + b = "layui-tree-txt", + g = "layui-tree-pack", + w = "layui-tree-spread", + N = "layui-tree-setLineShort", + T = "layui-tree-showLine", + L = "layui-tree-lineExtend", + l = function (e) { + var i = this; + i.index = ++a.index, + i.config = u.extend({}, i.config, a.config, e), + i.render() + }; + l.prototype.config = { + data: [], + showCheckbox: !1, + showLine: !0, + accordion: !1, + onlyIconControl: !1, + isJump: !1, + edit: !1, + text: { + defaultNodeName: "\u672a\u547d\u540d", + none: "\u65e0\u6570\u636e" + } + }, + l.prototype.reload = function (e) { + var n = this; + layui.each(e, function (e, i) { + "array" === layui.type(i) && delete n.config[e] + }), + n.config = u.extend(!0, {}, n.config, e), + n.render() + }, + l.prototype.render = function () { + var e = this, + i = e.config, + n = (e.checkids = [], u('
        ')), + a = (e.tree(n), i.elem = u(i.elem)); + if (a[0]) { + if (e.key = i.id || e.index, e.elem = n, e.elemNone = u('
        ' + i.text.none + "
        "), a.html(e.elem), 0 == e.elem.find(".layui-tree-set").length) + return e.elem.append(e.elemNone); + i.showCheckbox && e.renderForm("checkbox"), + e.elem.find(".layui-tree-set").each(function () { + var e = u(this); + e.parent(".layui-tree-pack")[0] || e.addClass("layui-tree-setHide"), + !e.next()[0] && e.parents(".layui-tree-pack").eq(1).hasClass("layui-tree-lineExtend") && e.addClass(N), + e.next()[0] || e.parents(".layui-tree-set").eq(0).next()[0] || e.addClass(N) + }), + e.events() + } + }, + l.prototype.renderForm = function (e) { + i.render(e, "LAY-tree-" + this.index) + }, + l.prototype.tree = function (l, e) { + var r = this, + c = r.config, + e = e || c.data; + layui.each(e, function (e, i) { + var n = i.children && 0 < i.children.length, + a = u('
        "), + t = u(['
        ', '
        ', '
        ', c.showLine ? n ? '' : '' : '', c.showCheckbox ? '' : "", c.isJump && i.href ? '' + (i.title || i.label || c.text.defaultNodeName) + "" : '' + (i.title || i.label || c.text.defaultNodeName) + "", "
        ", function () { + if (!c.edit) + return ""; + var n = { + add: '', + update: '', + del: '' + }, + a = ['
        ']; + return !0 === c.edit && (c.edit = ["update", "del"]), + "object" == typeof c.edit ? (layui.each(c.edit, function (e, i) { + a.push(n[i] || "") + }), a.join("") + "
        ") : void 0 + } + (), "
        "].join("")); + n && (t.append(a), r.tree(a, i.children)), + l.append(t), + t.prev("." + f)[0] && t.prev().children(".layui-tree-pack").addClass("layui-tree-showLine"), + n || t.parent(".layui-tree-pack").addClass("layui-tree-lineExtend"), + r.spread(t, i), + c.showCheckbox && (i.checked && r.checkids.push(i.id), r.checkClick(t, i)), + c.edit && r.operate(t, i) + }) + }, + l.prototype.spread = function (a, e) { + var t = this.config, + i = a.children("." + m), + n = i.children("." + x), + l = i.find("." + C), + i = i.find("." + b), + r = t.onlyIconControl ? l : n, + c = ""; + r.on("click", function (e) { + var i = a.children("." + g), + n = (r.children(".layui-icon")[0] ? r : r.find(".layui-tree-icon")).children(".layui-icon"); + i[0] ? a.hasClass(w) ? (a.removeClass(w), i.slideUp(200), n.removeClass(v).addClass(k)) : (a.addClass(w), i.slideDown(200), n.addClass(v).removeClass(k), t.accordion && ((i = a.siblings("." + f)).removeClass(w), i.children("." + g).slideUp(200), i.find(".layui-tree-icon").children(".layui-icon").removeClass(v).addClass(k))) : c = "normal" + }), + i.on("click", function () { + u(this).hasClass(d) || (c = a.hasClass(w) ? t.onlyIconControl ? "open" : "close" : t.onlyIconControl ? "close" : "open", t.click && t.click({ + elem: a, + state: c, + data: e + })) + }) + }, + l.prototype.setCheckbox = function (e, i, n) { + this.config; + var t, + l = n.prop("checked"); + n.prop("disabled") || ("object" != typeof i.children && !e.find("." + g)[0] || e.find("." + g).find('input[same="layuiTreeCheck"]').each(function () { + this.disabled || (this.checked = l) + }), (t = function (e) { + var i, + n, + a; + e.parents("." + f)[0] && (n = (e = e.parent("." + g)).parent(), a = e.prev().find('input[same="layuiTreeCheck"]'), l ? a.prop("checked", l) : (e.find('input[same="layuiTreeCheck"]').each(function () { + this.checked && (i = !0) + }), i || a.prop("checked", !1)), t(n)) + })(e), this.renderForm("checkbox")) + }, + l.prototype.checkClick = function (n, a) { + var t = this, + l = t.config; + n.children("." + m).children("." + x).on("click", 'input[same="layuiTreeCheck"]+', function (e) { + layui.stope(e); + var e = u(this).prev(), + i = e.prop("checked"); + e.prop("disabled") || (t.setCheckbox(n, a, e), l.oncheck && l.oncheck({ + elem: n, + checked: i, + data: a + })) + }) + }, + l.prototype.operate = function (c, d) { + var s = this, + o = s.config, + e = c.children("." + m), + h = e.children("." + x); + e.children(".layui-tree-btnGroup").on("click", ".layui-icon", function (e) { + layui.stope(e); + var i, + e = u(this).data("type"), + a = c.children("." + g), + t = { + data: d, + type: e, + elem: c + }; + if ("add" == e) { + a[0] || (o.showLine ? (h.find("." + C).addClass("layui-tree-icon"), h.find("." + C).children(".layui-icon").addClass(k).removeClass("layui-icon-file")) : h.find(".layui-tree-iconArrow").removeClass(y), c.append('
        ')); + var n, + l = o.operate && o.operate(t), + r = {}; + if (r.title = o.text.defaultNodeName, r.id = l, s.tree(c.children("." + g), [r]), o.showLine && (a[0] ? (a.hasClass(L) || a.addClass(L), c.find("." + g).each(function () { + u(this).children("." + f).last().addClass(N) + }), (a.children("." + f).last().prev().hasClass(N) ? a.children("." + f).last().prev() : a.children("." + f).last()).removeClass(N), !c.parent("." + g)[0] && c.next()[0] && a.children("." + f).last().removeClass(N)) : (l = c.siblings("." + f), n = 1, r = c.parent("." + g), layui.each(l, function (e, i) { + u(i).children("." + g)[0] || (n = 0) + }), 1 == n ? (l.children("." + g).addClass(T), l.children("." + g).children("." + f).removeClass(N), c.children("." + g).addClass(T), r.removeClass(L), r.children("." + f).last().children("." + g).children("." + f).last().addClass(N)) : c.children("." + g).children("." + f).addClass(N))), !o.showCheckbox) + return; + h.find('input[same="layuiTreeCheck"]')[0].checked && (c.children("." + g).children("." + f).last().find('input[same="layuiTreeCheck"]')[0].checked = !0), + s.renderForm("checkbox") + } else + "update" == e ? (l = h.children("." + b).html(), h.children("." + b).html(""), h.append(''), h.children(".layui-tree-editInput").val(l).focus(), i = function (e) { + var i = (i = e.val().trim()) || o.text.defaultNodeName; + e.remove(), + h.children("." + b).html(i), + t.data.title = i, + o.operate && o.operate(t) + }, h.children(".layui-tree-editInput").blur(function () { + i(u(this)) + }), h.children(".layui-tree-editInput").on("keydown", function (e) { + 13 === e.keyCode && (e.preventDefault(), i(u(this))) + })) : p.confirm('\u786e\u8ba4\u5220\u9664\u8be5\u8282\u70b9 "' + (d.title || "") + '" \u5417\uff1f', function (e) { + if (o.operate && o.operate(t), t.status = "remove", p.close(e), !c.prev("." + f)[0] && !c.next("." + f)[0] && !c.parent("." + g)[0]) + return c.remove(), void s.elem.append(s.elemNone); + var l, + n, + i; + c.siblings("." + f).children("." + m)[0] ? (o.showCheckbox && (l = function (e) { + var i, + n, + a, + t; + e.parents("." + f)[0] && (i = e.siblings("." + f).children("." + m), n = (e = e.parent("." + g).prev()).find('input[same="layuiTreeCheck"]')[0], a = 1, (t = 0) == n.checked && (i.each(function (e, i) { + i = u(i).find('input[same="layuiTreeCheck"]')[0]; + 0 != i.checked || i.disabled || (a = 0), + i.disabled || (t = 1) + }), 1 == a && 1 == t && (n.checked = !0, s.renderForm("checkbox"), l(e.parent("." + f))))) + })(c), o.showLine && (e = c.siblings("." + f), n = 1, i = c.parent("." + g), layui.each(e, function (e, i) { + u(i).children("." + g)[0] || (n = 0) + }), 1 == n ? (a[0] || (i.removeClass(L), e.children("." + g).addClass(T), e.children("." + g).children("." + f).removeClass(N)), (c.next()[0] ? i.children("." + f).last() : c.prev()).children("." + g).children("." + f).last().addClass(N), c.next()[0] || c.parents("." + f)[1] || c.parents("." + f).eq(0).next()[0] || c.prev("." + f).addClass(N)) : !c.next()[0] && c.hasClass(N) && c.prev().addClass(N))) : (e = c.parent("." + g).prev(), o.showLine ? (e.find("." + C).removeClass("layui-tree-icon"), e.find("." + C).children(".layui-icon").removeClass(v).addClass("layui-icon-file"), (i = e.parents("." + g).eq(0)).addClass(L), i.children("." + f).each(function () { + u(this).children("." + g).children("." + f).last().addClass(N) + })) : e.find(".layui-tree-iconArrow").addClass(y), c.parents("." + f).eq(0).removeClass(w), c.parent("." + g).remove()), + c.remove() + }) + }) + }, + l.prototype.events = function () { + var i = this, + t = i.config; + i.elem.find(".layui-tree-checkedFirst"); + i.setChecked(i.checkids), + i.elem.find(".layui-tree-search").on("keyup", function () { + var e = u(this), + n = e.val(), + e = e.nextAll(), + a = []; + e.find("." + b).each(function () { + var i, + e = u(this).parents("." + m); + -1 != u(this).html().indexOf(n) && (a.push(u(this).parent()), (i = function (e) { + e.addClass("layui-tree-searchShow"), + e.parent("." + g)[0] && i(e.parent("." + g).parent("." + f)) + })(e.parent("." + f))) + }), + e.find("." + m).each(function () { + var e = u(this).parent("." + f); + e.hasClass("layui-tree-searchShow") || e.addClass(y) + }), + 0 == e.find(".layui-tree-searchShow").length && i.elem.append(i.elemNone), + t.onsearch && t.onsearch({ + elem: a + }) + }), + i.elem.find(".layui-tree-search").on("keydown", function () { + u(this).nextAll().find("." + m).each(function () { + u(this).parent("." + f).removeClass("layui-tree-searchShow " + y) + }), + u(".layui-tree-emptyText")[0] && u(".layui-tree-emptyText").remove() + }) + }, + l.prototype.getChecked = function () { + var e = this.config, + i = [], + n = [], + t = (this.elem.find(".layui-form-checked").each(function () { + i.push(u(this).prev()[0].value) + }), function (e, a) { + layui.each(e, function (e, n) { + layui.each(i, function (e, i) { + if (n.id == i) + return delete (i = u.extend({}, n)).children, a.push(i), n.children && (i.children = [], t(n.children, i.children)), !0 + }) + }) + }); + return t(u.extend({}, e.data), n), + n + }, + l.prototype.setChecked = function (l) { + this.config; + this.elem.find("." + f).each(function (e, i) { + var n = u(this).data("id"), + a = u(i).children("." + m).find('input[same="layuiTreeCheck"]'), + t = a.next(); + if ("number" == typeof l) { + if (n == l) + return a[0].checked || t.click(), !1 + } else + "object" == typeof l && layui.each(l, function (e, i) { + if (i == n && !a[0].checked) + return t.click(), !0 + }) + }) + }, + t.that = {}, + t.config = {}, + a.reload = function (e, i) { + e = t.that[e]; + return e.reload(i), + t.call(e) + }, + a.getChecked = function (e) { + return t.that[e].getChecked() + }, + a.setChecked = function (e, i) { + return t.that[e].setChecked(i) + }, + a.render = function (e) { + e = new l(e); + return t.call(e) + }, + e(n, a) +}); +layui.define(["laytpl", "form"], function (e) { + "use strict"; + var s = layui.$, + n = layui.laytpl, + t = layui.form, + a = "transfer", + i = { + config: {}, + index: layui[a] ? layui[a].index + 1e4 : 0, + set: function (e) { + var t = this; + return t.config = s.extend({}, t.config, e), + t + }, + on: function (e, t) { + return layui.onevent.call(this, a, e, t) + } + }, + l = function () { + var t = this, + e = t.config, + a = e.id || t.index; + return l.that[a] = t, { + config: l.config[a] = e, + reload: function (e) { + t.reload.call(t, e) + }, + getData: function () { + return t.getData.call(t) + } + } + }, + d = "layui-hide", + h = "layui-btn-disabled", + r = "layui-none", + c = "layui-transfer-box", + u = "layui-transfer-header", + o = "layui-transfer-search", + f = "layui-transfer-data", + y = function (e) { + return ['
        ', '
        ', '", "
        ", "{{# if(d.data.showSearch){ }}", '", "{{# } }}", '
          ', "
          "].join("") + }, + p = ['
          ', y({ + index: 0, + checkAllName: "layTransferLeftCheckAll" + }), '
          ', '", '", "
          ", y({ + index: 1, + checkAllName: "layTransferRightCheckAll" + }), "
          "].join(""), + v = function (e) { + var t = this; + t.index = ++i.index, + t.config = s.extend({}, t.config, i.config, e), + t.render() + }; + v.prototype.config = { + title: ["\u5217\u8868\u4e00", "\u5217\u8868\u4e8c"], + width: 200, + height: 360, + data: [], + value: [], + showSearch: !1, + id: "", + text: { + none: "\u65e0\u6570\u636e", + searchNone: "\u65e0\u5339\u914d\u6570\u636e" + } + }, + v.prototype.reload = function (e) { + var t = this; + t.config = s.extend({}, t.config, e), + t.render() + }, + v.prototype.render = function () { + var e = this, + t = e.config, + a = e.elem = s(n(p).render({ + data: t, + index: e.index + })), + i = t.elem = s(t.elem); + i[0] && (t.data = t.data || [], t.value = t.value || [], e.key = t.id || e.index, i.html(e.elem), e.layBox = e.elem.find("." + c), e.layHeader = e.elem.find("." + u), e.laySearch = e.elem.find("." + o), e.layData = a.find("." + f), e.layBtn = a.find(".layui-transfer-active .layui-btn"), e.layBox.css({ + width: t.width, + height: t.height + }), e.layData.css({ + height: (i = t.height - e.layHeader.outerHeight(), t.showSearch && (i -= e.laySearch.outerHeight()), i - 2) + }), e.renderData(), e.events()) + }, + v.prototype.renderData = function () { + var e = this, + i = (e.config, [{ + checkName: "layTransferLeftCheck", + views: [] + }, { + checkName: "layTransferRightCheck", + views: [] + } + ]); + e.parseData(function (e) { + var t = e.selected ? 1 : 0, + a = ["
        • ", '', "
        • "].join(""); + i[t].views.push(a), + delete e.selected + }), + e.layData.eq(0).html(i[0].views.join("")), + e.layData.eq(1).html(i[1].views.join("")), + e.renderCheckBtn() + }, + v.prototype.renderForm = function (e) { + t.render(e, "LAY-transfer-" + this.index) + }, + v.prototype.renderCheckBtn = function (r) { + var c = this, + o = c.config; + r = r || {}, + c.layBox.each(function (e) { + var t = s(this), + a = t.find("." + f), + t = t.find("." + u).find('input[type="checkbox"]'), + i = a.find('input[type="checkbox"]'), + n = 0, + l = !1; + i.each(function () { + var e = s(this).data("hide"); + (this.checked || this.disabled || e) && n++, + this.checked && !e && (l = !0) + }), + t.prop("checked", l && n === i.length), + c.layBtn.eq(e)[l ? "removeClass" : "addClass"](h), + r.stopNone || (i = a.children("li:not(." + d + ")").length, c.noneView(a, i ? "" : o.text.none)) + }), + c.renderForm("checkbox") + }, + v.prototype.noneView = function (e, t) { + var a = s('

          ' + (t || "") + "

          "); + e.find("." + r)[0] && e.find("." + r).remove(), + t.replace(/\s/g, "") && e.append(a) + }, + v.prototype.setValue = function () { + var e = this.config, + t = []; + return this.layBox.eq(1).find("." + f + ' input[type="checkbox"]').each(function () { + s(this).data("hide") || t.push(this.value) + }), + e.value = t, + this + }, + v.prototype.parseData = function (t) { + var i = this.config, + n = []; + return layui.each(i.data, function (e, a) { + a = ("function" == typeof i.parseData ? i.parseData(a) : a) || a, + n.push(a = s.extend({}, a)), + layui.each(i.value, function (e, t) { + t == a.value && (a.selected = !0) + }), + t && t(a) + }), + i.data = n, + this + }, + v.prototype.getData = function (e) { + var t = this.config, + i = []; + return this.setValue(), + layui.each(e || t.value, function (e, a) { + layui.each(t.data, function (e, t) { + delete t.selected, + a == t.value && i.push(t) + }) + }), + i + }, + v.prototype.transfer = function (e, t) { + var a, + i = this, + n = i.config, + l = i.layBox.eq(e), + r = [], + t = (t ? ((a = (t = t).find('input[type="checkbox"]'))[0].checked = !1, l.siblings("." + c).find("." + f).append(t.clone()), t.remove(), r.push(a[0].value), i.setValue()) : l.each(function (e) { + s(this).find("." + f).children("li").each(function () { + var e = s(this), + t = e.find('input[type="checkbox"]'), + a = t.data("hide"); + t[0].checked && !a && (t[0].checked = !1, l.siblings("." + c).find("." + f).append(e.clone()), e.remove(), r.push(t[0].value)), + i.setValue() + }) + }), i.renderCheckBtn(), l.siblings("." + c).find("." + o + " input")); + "" !== t.val() && t.trigger("keyup"), + n.onchange && n.onchange(i.getData(r), e) + }, + v.prototype.events = function () { + var n = this, + l = n.config; + n.elem.on("click", 'input[lay-filter="layTransferCheckbox"]+', function () { + var e = s(this).prev(), + t = e[0].checked, + a = e.parents("." + c).eq(0).find("." + f); + e[0].disabled || ("all" === e.attr("lay-type") && a.find('input[type="checkbox"]').each(function () { + this.disabled || (this.checked = t) + }), setTimeout(function () { + n.renderCheckBtn({ + stopNone: !0 + }) + }, 0)) + }), + n.elem.on("dblclick", "." + f + ">li", function (e) { + var t = s(this), + a = t.children('input[type="checkbox"]'), + i = t.parent().parent(); + a[0].disabled || n.transfer(i.data("index"), t) + }), + n.layBtn.on("click", function () { + var e = s(this), + t = e.data("index"); + e.hasClass(h) || n.transfer(t) + }), + n.laySearch.find("input").on("keyup", function () { + var i = this.value, + e = s(this).parents("." + o).eq(0).siblings("." + f), + t = e.children("li"), + t = (t.each(function () { + var e = s(this), + t = e.find('input[type="checkbox"]'), + a = t[0].title, + a = ("cs" !== l.showSearch && (a = a.toLowerCase(), i = i.toLowerCase()), -1 !== a.indexOf(i)); + e[a ? "removeClass" : "addClass"](d), + t.data("hide", !a) + }), n.renderCheckBtn(), t.length === e.children("li." + d).length); + n.noneView(e, t ? l.text.searchNone : "") + }) + }, + l.that = {}, + l.config = {}, + i.reload = function (e, t) { + e = l.that[e]; + return e.reload(t), + l.call(e) + }, + i.getData = function (e) { + return l.that[e].getData() + }, + i.render = function (e) { + e = new v(e); + return l.call(e) + }, + e(a, i) +}); +layui.define("jquery", function (e) { + "use strict"; + var a = layui.$, + n = (layui.hint(), layui.device(), { + config: {}, + set: function (e) { + var i = this; + return i.config = a.extend({}, i.config, e), + i + }, + on: function (e, i) { + return layui.onevent.call(this, d, e, i) + } + }), + d = "carousel", + r = "layui-this", + s = "layui-carousel-left", + u = "layui-carousel-right", + c = "layui-carousel-prev", + m = "layui-carousel-next", + t = "layui-carousel-arrow", + l = "layui-carousel-ind", + i = function (e) { + var i = this; + i.config = a.extend({}, i.config, n.config, e), + i.render() + }; + i.prototype.config = { + width: "600px", + height: "280px", + full: !1, + arrow: "hover", + indicator: "inside", + autoplay: !0, + interval: 3e3, + anim: "", + trigger: "click", + index: 0 + }, + i.prototype.render = function () { + var e = this, + i = e.config; + i.elem = a(i.elem), + i.elem[0] && (e.elemItem = i.elem.find(">*[carousel-item]>*"), i.index < 0 && (i.index = 0), i.index >= e.elemItem.length && (i.index = e.elemItem.length - 1), i.interval < 800 && (i.interval = 800), i.full ? i.elem.css({ + position: "fixed", + width: "100%", + height: "100%", + zIndex: 9999 + }) : i.elem.css({ + width: i.width, + height: i.height + }), i.elem.attr("lay-anim", i.anim), e.elemItem.eq(i.index).addClass(r), e.elemItem.length <= 1 || (e.indicator(), e.arrow(), e.autoplay(), e.events())) + }, + i.prototype.reload = function (e) { + var i = this; + clearInterval(i.timer), + i.config = a.extend({}, i.config, e), + i.render() + }, + i.prototype.prevIndex = function () { + var e = this.config.index - 1; + return e = e < 0 ? this.elemItem.length - 1 : e + }, + i.prototype.nextIndex = function () { + var e = this.config.index + 1; + return e = e >= this.elemItem.length ? 0 : e + }, + i.prototype.addIndex = function (e) { + var i = this.config; + i.index = i.index + (e = e || 1), + i.index >= this.elemItem.length && (i.index = 0) + }, + i.prototype.subIndex = function (e) { + var i = this.config; + i.index = i.index - (e = e || 1), + i.index < 0 && (i.index = this.elemItem.length - 1) + }, + i.prototype.autoplay = function () { + var e = this, + i = e.config; + i.autoplay && (clearInterval(e.timer), e.timer = setInterval(function () { + e.slide() + }, i.interval)) + }, + i.prototype.arrow = function () { + var i = this, + e = i.config, + n = a(['", '"].join("")); + e.elem.attr("lay-arrow", e.arrow), + e.elem.find("." + t)[0] && e.elem.find("." + t).remove(), + e.elem.append(n), + n.on("click", function () { + var e = a(this).attr("lay-type"); + i.slide(e) + }) + }, + i.prototype.indicator = function () { + var i, + n = this, + t = n.config, + e = n.elemInd = a(['
            ', (i = [], layui.each(n.elemItem, function (e) { + i.push("") + }), i.join("")), "
          "].join("")); + t.elem.attr("lay-indicator", t.indicator), + t.elem.find("." + l)[0] && t.elem.find("." + l).remove(), + t.elem.append(e), + "updown" === t.anim && e.css("margin-top", -e.height() / 2), + e.find("li").on("hover" === t.trigger ? "mouseover" : t.trigger, function () { + var e = a(this).index(); + e > t.index ? n.slide("add", e - t.index) : e < t.index && n.slide("sub", t.index - e) + }) + }, + i.prototype.slide = function (e, i) { + var n = this, + t = n.elemItem, + a = n.config, + l = a.index, + o = a.elem.attr("lay-filter"); + n.haveSlide || ("sub" === e ? (n.subIndex(i), t.eq(a.index).addClass(c), setTimeout(function () { + t.eq(l).addClass(u), + t.eq(a.index).addClass(u) + }, 50)) : (n.addIndex(i), t.eq(a.index).addClass(m), setTimeout(function () { + t.eq(l).addClass(s), + t.eq(a.index).addClass(s) + }, 50)), setTimeout(function () { + t.removeClass(r + " " + c + " " + m + " " + s + " " + u), + t.eq(a.index).addClass(r), + n.haveSlide = !1 + }, 300), n.elemInd.find("li").eq(a.index).addClass(r).siblings().removeClass(r), n.haveSlide = !0, e = { + index: a.index, + prevIndex: l, + item: t.eq(a.index) + }, "function" == typeof a.change && a.change(e), layui.event.call(this, d, "change(" + o + ")", e)) + }, + i.prototype.events = function () { + var e = this, + i = e.config; + i.elem.data("haveEvents") || (i.elem.on("mouseenter", function () { + "always" !== e.config.autoplay && clearInterval(e.timer) + }).on("mouseleave", function () { + "always" !== e.config.autoplay && e.autoplay() + }), i.elem.data("haveEvents", !0)) + }, + n.render = function (e) { + return new i(e) + }, + e(d, n) +}); +layui.define("jquery", function (e) { + "use strict"; + var u = layui.jquery, + l = { + config: {}, + index: layui.rate ? layui.rate.index + 1e4 : 0, + set: function (e) { + var a = this; + return a.config = u.extend({}, a.config, e), + a + }, + on: function (e, a) { + return layui.onevent.call(this, i, e, a) + } + }, + i = "rate", + c = "layui-icon-rate", + r = "layui-icon-rate-solid", + o = "layui-icon-rate-half", + s = "layui-icon-rate-solid layui-icon-rate-half", + f = "layui-icon-rate layui-icon-rate-half", + a = function (e) { + var a = this; + a.index = ++l.index, + a.config = u.extend({}, a.config, l.config, e), + a.render() + }; + a.prototype.config = { + length: 5, + text: !1, + readonly: !1, + half: !1, + value: 0, + theme: "" + }, + a.prototype.render = function () { + for (var e = this, a = e.config, l = a.theme ? 'style="color: ' + a.theme + ';"' : "", i = (a.elem = u(a.elem), a.value > a.length && (a.value = a.length), parseInt(a.value) === a.value || a.half || (a.value = Math.ceil(a.value) - a.value < .5 ? Math.ceil(a.value) : Math.floor(a.value)), '
            "), n = 1; n <= a.length; n++) { + var t = '
          • "; + a.half && parseInt(a.value) !== a.value && n == Math.ceil(a.value) ? i = i + '
          • " : i += t + } + i += "
          " + (a.text ? '' + a.value + "\u661f" : "") + ""; + var o = a.elem, + s = o.next(".layui-rate"); + s[0] && s.remove(), + e.elemTemp = u(i), + a.span = e.elemTemp.next("span"), + a.setText && a.setText(a.value), + o.html(e.elemTemp), + o.addClass("layui-inline"), + a.readonly || e.action() + }, + a.prototype.setvalue = function (e) { + this.config.value = e, + this.render() + }, + a.prototype.action = function () { + var i = this.config, + n = this.elemTemp, + t = n.find("i").width(); + n.children("li").each(function (e) { + var a = e + 1, + l = u(this); + l.on("click", function (e) { + i.value = a, + i.half && e.pageX - u(this).offset().left <= t / 2 && (i.value = i.value - .5), + i.text && n.next("span").text(i.value + "\u661f"), + i.choose && i.choose(i.value), + i.setText && i.setText(i.value) + }), + l.on("mousemove", function (e) { + n.find("i").each(function () { + u(this).addClass(c).removeClass(s) + }), + n.find("i:lt(" + a + ")").each(function () { + u(this).addClass(r).removeClass(f) + }), + i.half && e.pageX - u(this).offset().left <= t / 2 && l.children("i").addClass(o).removeClass(r) + }), + l.on("mouseleave", function () { + n.find("i").each(function () { + u(this).addClass(c).removeClass(s) + }), + n.find("i:lt(" + Math.floor(i.value) + ")").each(function () { + u(this).addClass(r).removeClass(f) + }), + i.half && parseInt(i.value) !== i.value && n.children("li:eq(" + Math.floor(i.value) + ")").children("i").addClass(o).removeClass("layui-icon-rate-solid layui-icon-rate") + }) + }) + }, + a.prototype.events = function () { + this.config + }, + l.render = function (e) { + e = new a(e); + return function () { + var a = this; + return { + setvalue: function (e) { + a.setvalue.call(a, e) + }, + config: a.config + } + } + .call(e) + }, + e(i, l) +}); +layui.define("jquery", function (l) { + "use strict"; + var g = layui.$, + e = function (l) {}; + e.prototype.load = function (l) { + var t, + i, + n, + e, + r, + o, + a, + c, + m, + s, + u, + f, + y, + d = this, + p = 0, + h = g((l = l || {}).elem); + if (h[0]) + return e = g(l.scrollElem || document), r = l.mb || 50, o = !("isAuto" in l) || l.isAuto, a = l.end || "\u6ca1\u6709\u66f4\u591a\u4e86", c = l.scrollElem && l.scrollElem !== document, m = "\u52a0\u8f7d\u66f4\u591a", s = g('"), h.find(".layui-flow-more")[0] || h.append(s), u = function (l, e) { + l = g(l), + s.before(l), + (e = 0 == e || null) ? s.html(a) : s.find("a").html(m), + i = e, + t = null, + y && y() + }, + f = function () { + t = !0, + s.find("a").html(''), + "function" == typeof l.done && l.done(++p, u) + }, + f(), + s.find("a").on("click", function () { + g(this); + i || t || f() + }), + l.isLazyimg && (y = d.lazyimg({ + elem: l.elem + " img", + scrollElem: l.scrollElem + })), + o && e.on("scroll", function () { + var e = g(this), + o = e.scrollTop(); + n && clearTimeout(n), + !i && h.width() && (n = setTimeout(function () { + var l = (c ? e : g(window)).height(); + (c ? e.prop("scrollHeight") : document.documentElement.scrollHeight) - o - l <= r && (t || f()) + }, 100)) + }), + d + }, + e.prototype.lazyimg = function (l) { + var e, + c = this, + m = 0, + s = g((l = l || {}).scrollElem || document), + u = l.elem || "img", + f = l.scrollElem && l.scrollElem !== document, + y = function (e, l) { + var o, + t = s.scrollTop(), + l = t + l, + i = f ? e.offset().top - s.offset().top + t : e.offset().top; + t <= i && i <= l && e.attr("lay-src") && (o = e.attr("lay-src"), layui.img(o, function () { + var l = c.lazyimg.elem.eq(m); + e.attr("src", o).removeAttr("lay-src"), + l[0] && n(l), + m++ + }, function () { + c.lazyimg.elem.eq(m); + e.removeAttr("lay-src") + })) + }, + n = function (l, e) { + var o = (f ? e || s : g(window)).height(), + t = s.scrollTop(), + i = t + o; + if (c.lazyimg.elem = g(u), l) + y(l, o); + else + for (var n = 0; n < c.lazyimg.elem.length; n++) { + var r = c.lazyimg.elem.eq(n), + a = f ? r.offset().top - s.offset().top + t : r.offset().top; + if (y(r, o), m = n, i < a) + break + } + }; + return n(), + s.on("scroll", function () { + var l = g(this); + e && clearTimeout(e), + e = setTimeout(function () { + n(null, l) + }, 50) + }), + n + }, + l("flow", new e) +}); +layui.define(["layer", "form"], function (t) { + "use strict"; + var u = layui.$, + c = layui.layer, + a = layui.form, + d = (layui.hint(), layui.device()), + i = "layedit", + y = "layui-disabled", + e = function () { + this.index = 0, + this.config = { + tool: ["strong", "italic", "underline", "del", "|", "left", "center", "right", "|", "link", "unlink"], + hideTool: [], + height: 280 + } + }, + f = (e.prototype.set = function (t) { + return u.extend(!0, this.config, t), + this + }, e.prototype.on = function (t, e) { + return layui.onevent(i, t, e) + }, e.prototype.build = function (t, e) { + e = e || {}; + var i, + l, + a = this, + n = a.config, + o = "layui-layedit", + s = u("string" == typeof t ? "#" + t : t), + r = "LAY_layedit_" + ++a.index, + c = s.next("." + o), + n = u.extend({}, n, e), + e = (i = [], l = {}, layui.each(n.hideTool, function (t, e) { + l[e] = !0 + }), layui.each(n.tool, function (t, e) { + C[e] && !l[e] && i.push(C[e]) + }), i.join("")), + o = u(['
          ', '
          ' + e + "
          ", '
          ', '', "
          ", "
          "].join("")); + return d.ie && d.ie < 8 ? s.removeClass("layui-hide").addClass("layui-show") : (c[0] && c.remove(), f.call(a, o, s[0], n), s.addClass("layui-hide").after(o), a.index) + }, e.prototype.getContent = function (t) { + t = n(t); + if (t[0]) + return l(t[0].document.body.innerHTML) + }, e.prototype.getText = function (t) { + t = n(t); + if (t[0]) + return u(t[0].document.body).text() + }, e.prototype.setContent = function (t, e, i) { + var l = n(t); + l[0] && (i ? u(l[0].document.body).append(e) : u(l[0].document.body).html(e), layedit.sync(t)) + }, e.prototype.sync = function (t) { + t = n(t); + t[0] && u("#" + t[1].attr("textarea")).val(l(t[0].document.body.innerHTML)) + }, e.prototype.getSelection = function (t) { + var t = n(t); + if (t[0]) + return t = p(t[0].document), document.selection ? t.text : t.toString() + }, function (a, n, o) { + var s = this, + r = a.find("iframe"); + r.css({ + height: o.height + }).on("load", function () { + var t = r.contents(), + e = r.prop("contentWindow"), + i = t.find("head"), + l = u([""].join("")), + t = t.find("body"); + i.append(l), + t.attr("contenteditable", "true").css({ + "min-height": o.height + }).html(n.value || ""), + m.apply(s, [e, r, n, o]), + g.call(s, e, a, o) + }) + }), + n = function (t) { + t = u("#LAY_layedit_" + t); + return [t.prop("contentWindow"), t] + }, + l = function (t) { + return t = 8 == d.ie ? t.replace(/<.+>/g, function (t) { + return t.toLowerCase() + }) : t + }, + m = function (e, t, i, l) { + var a = e.document, + n = u(a.body); + n.on("keydown", function (t) { + if (13 === t.keyCode) { + var e = p(a); + if ("pre" === h(e).parentNode.tagName.toLowerCase()) + return t.shiftKey ? void 0 : (c.msg("\u8bf7\u6682\u65f6\u7528shift+enter"), !1); + a.execCommand("formatBlock", !1, "

          ") + } + }), + u(i).parents("form").on("submit", function () { + var t = n.html(); + 8 == d.ie && (t = t.replace(/<.+>/g, function (t) { + return t.toLowerCase() + })), + i.value = t + }), + n.on("paste", function (t) { + a.execCommand("formatBlock", !1, "

          "), + setTimeout(function () { + o.call(e, n), + i.value = n.html() + }, 100) + }) + }, + o = function (t) { + this.document; + t.find("*[style]").each(function () { + var t = this.style.textAlign; + this.removeAttribute("style"), + u(this).css({ + "text-align": t || "" + }) + }), + t.find("table").addClass("layui-table"), + t.find("script,link").remove() + }, + p = function (t) { + return t.selection ? t.selection.createRange() : t.getSelection().getRangeAt(0) + }, + h = function (t) { + return t.endContainer || t.parentElement().childNodes[0] + }, + v = function (t, e, i) { + var l, + a, + n = this.document, + o = document.createElement(t); + for (l in e) + o.setAttribute(l, e[l]); + o.removeAttribute("text"), + n.selection ? (a = i.text || e.text, "a" === t && !a || (a && (o.innerHTML = a), i.pasteHTML(u(o).prop("outerHTML")), i.select())) : (a = i.toString() || e.text, "a" === t && !a || (a && (o.innerHTML = a), i.deleteContents(), i.insertNode(o))) + }, + b = function (e, t) { + var i = this.document, + l = "layedit-tool-active", + i = h(p(i)), + a = function (t) { + return e.find(".layedit-tool-" + t) + }; + t && t[t.hasClass(l) ? "removeClass" : "addClass"](l), + e.find(">i").removeClass(l), + a("unlink").addClass(y), + u(i).parents().each(function () { + var t = this.tagName.toLowerCase(), + e = this.style.textAlign; + "b" !== t && "strong" !== t || a("b").addClass(l), + "i" !== t && "em" !== t || a("i").addClass(l), + "u" === t && a("u").addClass(l), + "strike" === t && a("d").addClass(l), + "p" === t && a("center" === e ? "center" : "right" === e ? "right" : "left").addClass(l), + "a" === t && (a("link").addClass(l), a("unlink").removeClass(y)) + }) + }, + g = function (a, t, e) { + var n = a.document, + o = u(n.body), + s = { + link: function (i) { + var t = h(i), + l = u(t).parent(); + x.call(o, { + href: l.attr("href"), + target: l.attr("target") + }, function (t) { + var e = l[0]; + "A" === e.tagName ? e.href = t.url : v.call(a, "a", { + target: t.target, + href: t.url, + text: t.url + }, i) + }) + }, + unlink: function (t) { + n.execCommand("unlink") + }, + code: function (e) { + k.call(o, function (t) { + v.call(a, "pre", { + text: t.code, + "lay-lang": t.lang + }, e) + }) + }, + help: function () { + c.open({ + type: 2, + title: "\u5e2e\u52a9", + area: ["600px", "380px"], + shadeClose: !0, + shade: .1, + skin: "layui-layer-msg", + content: ["", "no"] + }) + } + }, + r = t.find(".layui-layedit-tool"), + i = function () { + var t, + e = u(this), + i = e.attr("layedit-event"), + l = e.attr("lay-command"); + e.hasClass(y) || (o.focus(), (t = p(n)).commonAncestorContainer, l ? (n.execCommand(l), /justifyLeft|justifyCenter|justifyRight/.test(l) && n.execCommand("formatBlock", !1, "

          "), setTimeout(function () { + o.focus() + }, 10)) : s[i] && s[i].call(this, t), b.call(a, r, e)) + }, + l = /image/; + r.find(">i").on("mousedown", function () { + var t = u(this).attr("layedit-event"); + l.test(t) || i.call(this) + }).on("click", function () { + var t = u(this).attr("layedit-event"); + l.test(t) && i.call(this) + }), + o.on("click", function () { + b.call(a, r) + }) + }, + x = function (t, i) { + var l = this, + t = c.open({ + type: 1, + id: "LAY_layedit_link", + area: "350px", + shade: .05, + shadeClose: !0, + moveType: 1, + title: "\u8d85\u94fe\u63a5", + skin: "layui-layer-msg", + content: ['

            ', '
          • ', '', '
            ', '', "
            ", "
          • ", '
          • ', '', '
            ', '", '", "
            ", "
          • ", '
          • ', '', '', "
          • ", "
          "].join(""), + success: function (t, e) { + a.render("radio"), + t.find(".layui-btn-primary").on("click", function () { + c.close(e), + l.focus() + }), + a.on("submit(layedit-link-yes)", function (t) { + c.close(x.index), + i && i(t.field) + }) + } + }); + x.index = t + }, + k = function (i) { + var l = this, + t = c.open({ + type: 1, + id: "LAY_layedit_code", + area: "550px", + shade: .05, + shadeClose: !0, + moveType: 1, + title: "\u63d2\u5165\u4ee3\u7801", + skin: "layui-layer-msg", + content: ['
            ', '
          • ', '', '
            ', '", "
            ", "
          • ", '
          • ', '', '
            ', '', "
            ", "
          • ", '
          • ', '', '', "
          • ", "
          "].join(""), + success: function (t, e) { + a.render("select"), + t.find(".layui-btn-primary").on("click", function () { + c.close(e), + l.focus() + }), + a.on("submit(layedit-code-yes)", function (t) { + c.close(k.index), + i && i(t.field) + }) + } + }); + k.index = t + }, + C = { + html: '', + strong: '', + italic: '', + underline: '', + del: '', + "|": '', + left: '', + center: '', + right: '', + link: '', + unlink: '', + face: '', + image: '', + code: '', + help: '' + }, + e = new e; + t(i, e) +}); +layui.define(["lay", "util"], function (e) { + "use strict"; + var d = layui.$, + o = layui.util, + u = "layui-code-title", + l = { + elem: ".layui-code", + title: "</>", + about: "", + ln: !0 + }; + e("code", function (e) { + var c = e = d.extend({}, l, e); + e.elem = d(e.elem), + e.elem[0] && layui.each(e.elem.get().reverse(), function (e, l) { + var t, + a = d(l), + i = (i = a.html(), d.trim(i).replace(/^\n|\n$/, "")), + l = d.extend({}, c, lay.options(l), (t = {}, layui.each(["title", "height", "encode", "skin", "about"], function (e, l) { + var i = a.attr("lay-" + l); + "string" == typeof i && (t[l] = i) + }), t)), + s = l.ln ? "ol" : "ul", + s = d("<" + s + ' class="layui-code-' + s + '">'), + n = d('
          '); + a.addClass("layui-code-view layui-box"), + l.skin && ("notepad" === l.skin && (l.skin = "dark"), a.addClass("layui-code-" + l.skin)), + i = (i = l.encode ? o.escape(i) : i).replace(/[\r\t\n]+/g, "
        • "), + a.html(s.html("
        • " + i + "
        • ")), + a.children("." + u)[0] || (n.html(l.title + (l.about ? '
          ' + l.about + "
          " : "")), a.prepend(n)), + 0 < (i = Math.floor(s.find("li").length / 100)) && s.css("margin-left", i + "px"), + l.height && s.css("max-height", l.height) + }) + }) +}).addcss("modules/code.css", "skincodecss"); diff --git a/src/main/resources/com/eco/plugin/shsytzfsds/js/ui.js b/src/main/resources/com/eco/plugin/shsytzfsds/js/ui.js new file mode 100644 index 0000000..5d0f6f3 --- /dev/null +++ b/src/main/resources/com/eco/plugin/shsytzfsds/js/ui.js @@ -0,0 +1,1789 @@ + +//通用配置------------------------------------------------------------------------------------------------------------------------- +//引入菜单 +BI.config("dec.provider.management", function (provider) { + provider.inject({ + modules: [ + { + value: "workflow_data_input", + id: "decision-management-workflow-data_input", + text:"飞书表格数据集配置", + iconCls: "management-connection-font", + cardType:"dec.workflow.data.input.tab", + dev: true + } + ] + }); +}); + +//应用管理------------------------------------------------------------------------------------------------------------------------- +//配置项 +BI.constant("dec.workflow.data.input.tab.items", [{ + value: 1, + text: '应用管理', + card: "dec.workflow.data.input.panel" +} +]) +var tableType = ""; +//标签页 +var e = BI.inherit(BI.Widget, { + props: { + baseCls: "dec-register" + }, + _store: function () { + return BI.Models.getModel("dec.model.workflow.data.input.tab") + }, + watch: { + activeTab: function (e) { + this.tabRegister.setSelect(e) + } + }, + render: function () { + tableType = 1; + var t = this; + return { + type: "bi.vtape", + cls: "bi-background", + items: [{ + type: "bi.htape", + cls: "bi-card bi-border-bottom", + items: [{ + el: { + type: "dec.line_segment", + cls: "dec-font-weight-bold", + layouts: [{ + type: "bi.vertical_adapt" + } + ], + items: BI.map(BI.Constants.getConstant("dec.workflow.data.input.tab.items"), function (e, t) { + return BI.extend({ + type: "dec.line_segment_button", + hgap: 15 + }, t) + }), + value: this.model.activeTab, + height: 40, + listeners: [{ + eventName: "EVENT_CHANGE", + action: function (e) { + t.store.openTab(e) + } + } + ] + }, + lgap: 10 + } + ], + height: 40 + }, { + type: "bi.absolute", + items: [{ + el: { + type: "bi.tab", + ref: function () { + t.tabRegister = this + }, + single: !0, + showIndex: this.model.activeTab, + cardCreator: BI.bind(this._createTab, this) + }, + left: 10, + right: 10, + top: 10, + bottom: 10 + } + ] + } + ] + } + }, + _createTab: function (i) { + var e = BI.find(BI.Constants.getConstant("dec.workflow.data.input.tab.items"), function (e, t) { + return t.value === i + }); + return e && BI.isKey(e.card) ? { + type: e.card + } + : { + type: "bi.label", + text: i + } + } +}); +BI.shortcut("dec.workflow.data.input.tab", e) + +//标签页model +var e = BI.inherit(Fix.Model, { + state: function () { + return { + activeTab: DecCst.Web.Register.Tab.VERSION_INFO + } + }, + computed: {}, + actions: { + openTab: function (e) { + this.model.activeTab = e + } + } +}); +BI.model("dec.model.workflow.data.input.tab", e); + +//应用管理主面板 +var e = BI.inherit(BI.Widget, { + props: { + }, + _store: function () { + + }, + watch: { + + }, + mounted: function () { + }, + render: function () { + var t = this; + return { + type: "bi.vtape", + cls: "bi-card", + rowSize: [30,"fill"], + rgap:5, + items: [ + { + type:"bi.left", + // cls:"bi-border-bottom", + rgap:15, + items:[ + { + type:"wink.icon_button", + width:40, + icon:{ + text:"plus-font", + color:"green" + }, + label:{ + text:"增加" + }, + handler:function(){ + BI.Popovers.removeAll(); + var id = "弹出层id"+BI.UUID(); + BI.Popovers.create(id, { + header: "属性配置", + size: "normal", + logic: { + dynamic: true + }, + body: { + type: "dec.workflow.data.input.add", + from:"add", + ref:function(ref){ + t.inputEditPanel = ref; + } + }, + footer:{ + type:"bi.right", + rgap:10, + items:[ + { + type:"bi.button", + text:"取消", + handler:function(){ + BI.Popovers.remove(id); + } + }, + { + type:"bi.button", + text:"确认", + handler:function(){ + t.inputEditPanel.save(); + BI.Popovers.remove(id); + t.bottom.initData(); + } + }, + ] + } + }).show(id); + } + }, + { + type:"wink.icon_button", + width:40, + icon:{ + text:"delete-font", + color:"red" + }, + label:{ + text:"删除" + }, + handler:function(){ + var dataid=t.bottom.getValue().join(","); + + if(dataid){ + BI.Msg.confirm("提示", "确定要删除所选数据吗", function (v) { + if(v){ + deleteData(dataid); + t.bottom.initData(); + } + }); + } + else{ + BI.Msg.toast("请先选中要删除的数据") + } + } + }, + ] + }, + { + type:"dec.workflow.data.input.bottom", + cls:"bi-border-top", + ref:function(ref){ + t.bottom = ref; + } + } + ] + } + }, +}); +BI.shortcut("dec.workflow.data.input.panel", e); + +//字段列表 +var nodeList = ["id","appname","appid","secret","describtion"]; + +//修改 +var e = BI.inherit(BI.Widget, { + props: { + dataid:"", + }, + _store: function () { + + }, + watch: { + + }, + mounted: function () { + }, + render: function () { + var thisObj = this; + var data = getDataById(this.options.dataid) + return { + type: "bi.vtape", + // cls: "bi-background", + cls: "bi-card", + rowSize: [30,"fill"], + items: [ + { + type: "bi.left", + cls: "bi-border-top", + items:[ + { + type:"dec.wink.item", + text:"id", + tgap:10, + css:{ + "margin-top":"10px", + }, + ref:function(ref){ + thisObj.id = ref; + }, + value:data.id, + disabled:true + }, + { + type:"dec.wink.item", + text:"应用名称", + tgap:10, + css:{ + "margin-top":"10px", + }, + ref:function(ref){ + thisObj.appname = ref; + }, + value:data.appname + }, + { + type:"dec.wink.item", + text:"appid", + css:{ + "margin-top":"10px", + }, + tgap:10, + ref:function(ref){ + thisObj.appid = ref; + }, + value:data.appid + }, + { + type:"dec.wink.item", + text:"secret", + css:{ + "margin-top":"10px", + }, + tgap:10, + ref:function(ref){ + thisObj.secret = ref; + }, + value:data.secret + }, + { + type: "bi.left", + height:25, + css:{ + "margin-top":"10px", + }, + items: [ + { + type: "bi.label", + text:"描述", + textHeight:25, + textAlign:"left", + css:{"font-weight":"bold","color":"black"}, + width:100, + rgap:10 + },{ + type: "bi.textarea_editor", + allowBlank: true, + value:data.describtion, + width: 290, + height: 150, + cls: "bi-border", + validationChecker:function(){ + return true; + }, + ref:function(ref){ + thisObj.describtion = ref; + }, + listeners: [{ + eventName: "EVENT_CHANGE", + action: function() { + thisObj.fireEvent("EVENT_CHANGE", ""); + } + }] + } + ] + } + ] + } + ] + } + }, + getValue:function(){ + var data = getDataById(this.options.dataid); + return { + "id":this.id.getValue(), + "appname":this.appname.getValue(), + "appid":this.appid.getValue(), + "secret":this.secret.getValue(), + "describtion":this.describtion.getValue(), + "enable":data.enable + } + }, + save:function(){ + $.ajax({ + type:"post", + async:false, + url:"decision/fsds/update", + xhrFields:{ + withCredentials:true + }, + contentType:"application/json", + data:JSON.stringify(this.getValue()), + success:function(data){ + result = data.data; + }, + error:function(data){ + } + }) + + return result; + } +}); +BI.shortcut("dec.workflow.data.input.edit", e); + +var e = BI.inherit(BI.Widget, { + props: { + from:"" + }, + _store: function () { + + }, + watch: { + + }, + mounted: function () { + }, + render: function () { + var t = this; + return { + type: "bi.vtape", + // cls: "bi-background", + cls: "bi-card", + rowSize: [30,"fill"], + items: [ + { + type:"dec.workflow.data.field.panel", + tgap:20, + ref:function(ref){ + t.fieldPanel = ref; + } + } + ] + } + }, + getValue:function(){ + return this.fieldPanel.getValue(); + }, + save:function(){ + $.ajax({ + type:"post", + async:false, + url:"decision/fsds/add", + xhrFields:{ + withCredentials:true + }, + contentType:"application/json", + data:JSON.stringify(this.getValue()), + success:function(data){ + result = data.data; + }, + error:function(data){ + } + }) + + return result; + } +}); +BI.shortcut("dec.workflow.data.input.add", e); + +//新增 +var e = BI.inherit(BI.Widget, { + props: { + formid:"" + }, + _store: function () { + + }, + watch: { + + }, + mounted: function () { + }, + render: function () { + var t = this; + return { + type: "bi.left", + cls: "bi-border-top", + items: t.createItems() + } + }, + getItems:function(){ + var formid = this.options.formid; + return getFieldByFormId(formid); + }, + createItems:function(){ + var thisObj = this; + return [ + { + type:"dec.wink.item", + text:"应用名称", + css:{ + "margin-top":"10px", + }, + tgap:10, + ref:function(ref){ + thisObj.appname = ref; + }, + value:"" + }, + { + type:"dec.wink.item", + text:"appid", + css:{ + "margin-top":"10px", + }, + tgap:10, + ref:function(ref){ + thisObj.appid = ref; + }, + value:"" + }, + { + type:"dec.wink.item", + text:"secret", + css:{ + "margin-top":"10px", + }, + tgap:10, + ref:function(ref){ + thisObj.secret = ref; + }, + value:"" + }, + { + type: "bi.left", + height:25, + css:{ + "margin-top":"10px", + }, + items: [ + { + type: "bi.label", + text:"描述", + textHeight:25, + textAlign:"left", + css:{"font-weight":"bold","color":"black"}, + width:100, + rgap:10 + },{ + type: "bi.textarea_editor", + allowBlank: true, + value:"", + width: 290, + height: 150, + cls: "bi-border", + validationChecker:function(){ + return true; + }, + ref:function(ref){ + thisObj.describtion = ref; + }, + listeners: [{ + eventName: "EVENT_CHANGE", + action: function() { + thisObj.fireEvent("EVENT_CHANGE", ""); + } + }] + } + ] + } + + + ]; + }, + getValue:function(){ + var result = { + "appname":this.appname.getValue(), + "enable":true, + "secret":this.secret.getValue(), + "appid":this.appid.getValue(), + "describtion":this.describtion.getValue(), + }; + + + return result; + } +}); +BI.shortcut("dec.workflow.data.field.panel", e); + +//数据底部面板 +var e = BI.inherit(BI.Widget, { + props: { + }, + _store: function () { + + }, + watch: { + + }, + mounted: function () { + }, + render: function () { + var t = this; + return { + type: "bi.vtape", + cls: "bi-background", + items: [ + { + type:"dec.workflow.data.input.bottom.right", + ref:function(_ref){ + t.right = _ref; + }, + listeners: [{ + eventName: "update", + action: function() { + this.initData(); + } + }] + } + ] + } + }, + resetTable:function(formid){ + this.right.resetTable(); + }, + getValue:function(){ + return this.right.getValue(); + }, + initData:function(){ + this.right.initData(); + this.right.resetTable(); + } +}); +BI.shortcut("dec.workflow.data.input.bottom", e); + +//底部右侧 +var e = BI.inherit(BI.Widget, { + props: { + }, + _store: function () { + return BI.Models.getModel("dec.model.workflow.data.input.bottom.right") + }, + childContext: ["userManagementConfigs"], + watch: { + + }, + render: function () { + var t = this; + return { + type: "bi.vtape", + items: [{ + type: "bi.vtape", + rowSize: ["fill"], + cls:"bi-card", + css:{"font-weight":"bold"}, + items: [ + { + type: "dec.workflow.data.table.panel", + ref:function(ref){ + t.tablepanel = ref; + }, + listeners: [{ + eventName: "update", + action: function() { + t.fireEvent("update", e) + } + }] + }] + }] + } + }, + getValue:function(){ + return this.tablepanel.getValue(); + }, + resetTable:function(){ + this.tablepanel.refresh(); + }, + initData:function(){ + this.tablepanel.initData(); + } +}); +BI.shortcut("dec.workflow.data.input.bottom.right", e); + +/** + * 底部仓库 + */ +var e = BI.inherit(Fix.Model, { + state: function () { + var e = BI.Constants.getConstant("dec.constant.user.tabs"); + return { + activeTab: BI.isNotEmptyArray(e) ? e[0].value : "allUser", + userManagementConfigs: { + syncOperationType: { + type: DecCst.System.Info.AuthenticType.DEFAULT + }, + manualOperationType: { + type: DecCst.System.Info.AuthenticType.DEFAULT + } + } + } + }, + childContext: ["userManagementConfigs"], + computed: { + tabs: function () { + return BI.map(BI.Constants.getConstant("dec.constant.user.tabs"), function (e, t) { + return { + text: t.text, + value: t.value, + selected: 0 === e + } + }) + }, + isAdmin: function () { + return BI.Services.getService("dec.service.user.management").isAdmin() + } + }, + actions: { + getUserConfig: function (e) { + this.getManagementConfig(e), + BI.Services.getService("dec.service.user.management").initUserOrganization() + }, + getManagementConfig: function (t) { + var i = this; + Dec.Utils.getUserManagementConfig(function (e) { + i.model.userManagementConfigs = e.data, + t && t() + }) + }, + openTab: function (e) { + this.model.activeTab = e + }, + createCard: function (i) { + var e = BI.find(BI.Constants.getConstant("dec.constant.user.tabs"), function (e, t) { + return t.value === i + }); + return e ? BI.extend({ + type: e.cardType + }, e) : { + type: "bi.label", + text: i + } + } + } +}); +BI.model("dec.model.workflow.data.input.bottom.right", e); + +/** + * 数据表格 + */ +var e = BI.inherit(BI.Widget, { + props: { + baseCls: "dec-user-all bi-card", + }, + _store: function () { + return BI.Models.getModel("dec.model.workflow.data.table.panel") + }, + watch: { + rows: function (e) { + this.populate(e) + }, + allPages: function () { + this.table.setAllPages(this.model.allPages) + }, + currentPage: function (e) { + this.table.setPage(e) + }, + searching: function (e) { + this.userSourceRow.setVisible(!e) + } + }, + beforeInit: function (e) { + this.store.initConfigs(e) + }, + mounted: function () { + var e = this; + this.store.updateUserListHeight(this._calculateUserListHeight()), + BI.Resizers.add(this.getName(), function () { + e.store.updateUserListHeight(e._calculateUserListHeight()) + }) + }, + render: function () { + var i = this; + return { + type: "bi.vtape", + hgap: 10, + items: [ { + type: "dec.workflow.data.table", + ref: function (e) { + i.table = e + }, + itemsCreator: function (e, t) { + i.store.getUsersByPage(e.page, t) + }, + perPage: this.model.perPage, + listeners: [{ + eventName: "EVENT_DELETE", + action: function (e) { + i.store.deleteUsers(e) + } + },{ + eventName: "update", + action: function (e) { + i.fireEvent("update", e) + } + } + ], + onEdit: BI.bind(this.store.onEditUser, this.store) + }] + } + }, + refresh:function(){ + this.table.refresh(); + this.initData(); + }, + _calculateUserListHeight: function () { + return this.element.height() - 40 - 82 + }, + beforeDestroy: function () { + BI.Resizers.remove(this.getName()) + }, + populate: function (e) { + this.table.populate(e) + }, + initData: function () { + this.store.initData() + }, + getValue:function(){ + return this.table.getValue(); + } +}); +BI.shortcut("dec.workflow.data.table.panel", e); + +//数据仓库 +var e = BI.inherit(Fix.Model, { + state: function () { + return { + rows: [], + allCount: 0, + currentPage: 0, + isAllChecked: !1, + sortBy: "userAlias", + asc: !0, + filter: { + searchBy: "", + keyword: "" + }, + enable: DecCst.User.Available.ALL, + syncConfigs: { + turnOn: !1, + strategy: DecCst.User.SyncUserStrategy.FULL_COVER + }, + perPage: 1e3, + selectedValues: [], + creationType: DecCst.User.CreationType.ALL + } + }, + childContext: ["rows", "currentPage", "allCount", "isAllChecked", "sortBy", "asc", "filter", "enable", "syncConfigs", "perPage", "selectedValues", "creationType"], + context: ["userManagementConfigs"], + computed: { + allPages: function () { + return Math.ceil(this.model.allCount / this.model.perPage) + }, + searching: function () { + return BI.isKey(this.model.filter.keyword) + } + }, + watch: { + perPage: function () { + this.initData() + } + }, + created: function () { + this._bindEvents() + }, + destroyed: function () { + this._releaseEvents() + }, + actions: { + initConfigs: function (t) { + var i = this; + Dec.Utils.getSynchronizeDatasetConfig(function (e) { + BI.extend(i.model.syncConfigs, e.data), + BI.isFunction(t) && t() + }) + }, + initData: function () { + var t = this; + this.resetState(); + var param ={ + page: 1, + count: this.model.perPage, + }; + + var pagedata = getPageData(param); + + t._injectUserAttributes(pagedata.items, function () { + t.model.allCount = pagedata.total, + t.model.currentPage = pagedata.page, + t.model.rows = pagedata.items + }) + }, + getUsersByPage: function (e) { + var t = this; + this.resetState(); + var param ={ + page: e, + count: this.model.perPage, + + }; + var pagedata = getPageData(param); + + t._injectUserAttributes(pagedata.items, function () { + t.model.allCount = pagedata.total, + t.model.currentPage = pagedata.page, + t.model.rows = t._packageRows(pagedata.items) + }) + }, + deleteUsers: function (e) { + var t = this; + Dec.Utils.deleteUsersByIds(e, function (e) { + t.onDeleteUsers(e) + }) + }, + onEditUser: function (i, n) { + BI.some(this.model.rows, function (e, t) { + if (t.id === n) + return BI.extend(t, i), !0 + }), + this.model.rows.splice(0, 0) + }, + onDeleteUsers: function (e) { + // e.data.count === this.model.rows.length ? this.getUsersByPage(1 === this.model.currentPage ? 1 : this.model.currentPage - 1) : this.getUsersByPage(this.model.currentPage) + }, + onClearUsers: function () { + this.model.isAllChecked = !1, + this.model.selectedValues = [], + this.model.allCount = 0, + this.model.rows = [], + this.model.currentPage = 1, + this.initData() + }, + updateUserListHeight: function (e) { + this.model.perPage = BI.max([2, Math.floor(e / 36)]) + }, + resetState: function () { + this.model.isAllChecked = !1, + this.model.selectedValues = [] + }, + changeUserSource: function (e) { + this.model.creationType = e + } + }, + _packageRows: function (e) { + var n = this; + return BI.each(e, function (e, t) { + var i = t.creationType === DecCst.User.CreationType.SYNC; + t.keyword = n.model.filter.keyword, + t.limited = BI.Services.getService("dec.service.user.management").isLimitedUser(t), + t.enableEdit = !i || n.model.syncConfigs.strategy === DecCst.User.SyncUserStrategy.INCREMENTAL_UPDATE, + t.enableDelete = !i, + t.roleEditable = !i, + t.enableCheck = !i && !t.limited, + t.passwordEditable = i ? n.model.userManagementConfigs.syncOperationType.type === DecCst.System.Info.AuthenticType.DEFAULT : n.model.userManagementConfigs.manualOperationType.type === DecCst.System.Info.AuthenticType.DEFAULT + }), + BI.remove(e, function (e, t) { + return BI.Services.getService("dec.service.user.management").checkAdmin(t) + }), + e + }, + _injectUserAttributes: function (i, e) { + var n, + t = BI.Providers.getProvider("dec.provider.all_user").getExtraAttributes(); + BI.isEmptyArray(t) ? e() : (n = BI.after(t.length, e), BI.each(t, function (e, t) { + t.attributeGetter(i, n) + })) + }, + _bindEvents: function () { + var e = this; + this.unListen = BI.Services.getService("dec.service.user.all_users").on("EVENT_REFRESH", function () { + e.initData() + }) + }, + _releaseEvents: function () { + this.unListen && this.unListen() + } +}); +BI.model("dec.model.workflow.data.table.panel", e); + +//数据表 +var o = BI.inherit(BI.Widget, { + props: { + baseCls: "dec-user-table", + $testId: "dec-user-table", + columnSize: [50, "fill", 100], + headerRowSize: 32, + rowSize: 36, + pager: {}, + perPage: 10, + header: [], + items: [], + formid:"" + }, + _store: function () { + return BI.Models.getModel("dec.model.user.all.table2") + }, + watch: { + isAllChecked: function () { + this.header.setSelected(this.model.isAllChecked) + } + }, + render: function () { + var i = this, + t = this.options; + return { + type: "bi.vertical", + items: [{ + type: "dec.workflow.data.table.header", + ref: function (e) { + i.header = e + }, + columnSize: t.columnSize, + items: this.createHeaders(), + height: t.headerRowSize, + listeners: [{ + eventName: BI.Controller.EVENT_CHANGE, + action: function (e, t) { + i.store.handleCheckAll(t) + } + } + ] + }, + { + type: "bi.button_group", + ref: function (e) { + i.table = e + }, + chooseType: 1, + layouts: [{ + type: "bi.vertical" + } + ], + items: [{ + type:"bi.label", + value:"test", + text:"test" + }] + }, + // { + // el: { + // type: "dec.pager", + // ref: function (e) { + // i.pager = e + // }, + // height: 30, + // listeners: [{ + // eventName: "EVENT_CHANGE", + // action: function () { + // var e = this.getCurrentPage && this.getCurrentPage(); + // t.itemsCreator({ + // page: e + // }, function (e) { + // i.populate(e) + // }) + // } + // } + // ] + // }, + // vgap: 10 + // } + ] + } + }, + refresh:function(){ + this.reset(); + }, + createHeaders:function(){ + return [ + { + text: "应用名称", + type: "bi.label", + width: (1/4).toFixed(2)*1 + }, + { + text: "appid", + type: "bi.label", + width: (1/4).toFixed(2)*1 + }, + { + text: "secret", + type: "bi.label", + width: (1/4).toFixed(2)*1 + }, + // { + // text: "是否开启", + // type: "bi.label", + // width: (1/5).toFixed(2)*1 + // }, + { + text: "操作", + type: "bi.label", + width: (1/4).toFixed(2)*1, + textAlign:"center" + }, + ] + + return result; + }, + _formatItems: function (e) { + var i = this, + n = this.options; + return BI.map(e, function (e, t) { + return { + type: "dec.workflow.data.table.row", + id: t.id, + css:{ + color:"black", + "font-weight":"normal" + }, + // cls: BI.isOdd(e) ? "odd" : "even", + userInfo: t, + columnSize: n.columnSize, + height: n.rowSize, + onDelete: function (e) { + i.fireEvent(o.EVENT_DELETE, e) + }, + onEdit: n.onEdit, + enableCheck:true, + listeners: [{ + eventName: "update", + action: function() { + i.fireEvent("update", e) + } + }] + } + }) + }, + setCount: function (e) { + // this.pager.setCount(e), + this.setAllPages(Math.ceil(e / this.options.perPage)) + }, + setAllPages: function (e) { + // this.pager.setAllPages(e) + }, + setPage: function (e) { + // this.pager.setPage(e) + }, + getValue: function () { + return this.table.getValue() + }, + empty: function () { + this.header.setSelected(!1) + }, + populate: function (e) { + this.table.populate(this._formatItems(e)) + } +}); +o.EVENT_DELETE = "EVENT_DELETE", + BI.shortcut("dec.workflow.data.table", o); +/** + * dec.model.user.all.table + */ +var e; +e = BI.inherit(Fix.Model, { + _init: function () {}, + state: function () { + return {} + }, + context: ["rows", "isAllChecked", "sortBy", "asc", "selectedValues"], + actions: { + handleCheckAll: function (e) { + var t = []; + e && BI.each(this.model.rows, (function (e, i) { + t.push(i.id) + })), + this.model.selectedValues = t, + this.model.isAllChecked = e + } + } +}), + BI.model("dec.model.user.all.table2", e) + +//数据头 +var e = BI.inherit(BI.Widget, { + props: { + baseCls: "dec-user-table-header", + columnSize: [], + items: [], + onSortChange: BI.emptyFn, + onFilterChange: BI.emptyFn, + height: 32 + }, + _store: function () { + return BI.Models.getModel("dec.model.user.all.table.header") + }, + watch: { + enableCheck: function (e) { + this.checkbox.setEnable(e) + } + }, + render: function () { + var e = this.options; + return { + type: "bi.htape", + columnSize: e.columnSize, + items: this._formatItems(e.items) + } + }, + _formatItems: function (e) { + var t = this, + i = this.options, + n = []; + return n.push(BI.extend({ + type: "bi.center", + width: 50, + height: i.height, + items: [ + { + type: "bi.checkbox", + $testId: "dec-user-row-checkbox", + ref: function (e) { + t.checkbox = e + }, + listeners: [{ + eventName: BI.Controller.EVENT_CHANGE, + action: function () { + arguments[1] = this.isSelected(); + t.fireEvent(BI.Controller.EVENT_CHANGE, arguments) + } + } + ] + } + ] + })), + n.push({ + type: "bi.htape", + items: BI.map(e, function (e, t) { + return { + el: BI.extend({ + rgap: 10, + type: "bi.label", + textAlign: "left" + }, t, { + width: null + }), + width: t.width + } + }) + }), + n + }, + _createExtraItems: function () { + var i = [], + e = BI.Providers.getProvider("dec.provider.all_user").getExtraAttributes(); + return BI.each(e, function (e, t) { + BI.isKey(t.header) ? i.push({ + type: "bi.label", + textAlign: "left", + text: t.header, + title: t.header, + width: t.width + }) : BI.isObject(t.header) ? i.push(BI.extend({ + width: t.width + }, t.header)) : i.push({ + type: "bi.layout", + width: t.width + }) + }), + i + }, + setSelected: function (e) { + this.checkbox.setSelected(e) + }, + setHalfSelected: function (e) { + this.checkbox.setHalfSelected(e) + }, + isHalfSelected: function () { + return this.checkbox.isHalfSelected() + }, + isSelected: function () { + return this.checkbox.isSelected() + } +}); +BI.shortcut("dec.workflow.data.table.header", e); + +var checkboxArray = [] + +/** + * 数据行 + */ +var e = BI.inherit(BI.Widget, { + props: { + baseCls: "dec-user-table-row bi-border-bottom", + columnSize: [50, "fill", 100], + userInfo: {}, + value: BI.UUID() + }, + _store: function () { + return BI.Models.getModel("dec.model.user.all.row2", this.options) + }, + watch: { + selected: function (e) { + this.setSelected(e) + } + }, + render: function () { + var e = this.options; + return { + type: "bi.htape", + $testId: "dec-user-table-row", + $value: e.userInfo.username, + columnSize: e.columnSize, + items: this._formatItem(e.userInfo), + enableCheck:true + } + }, + getFieldRow:function(height){ + var data = this.options.userInfo; + var e = this, + n = this.options, + o = n.columnSize, + r = n.onEdit, + userInfo = n.userInfo; + return [ + { + el: { + type: "bi.label", + textAlign: "left", + text: data.appname, + css:{"color":"black"}, + title: function () { + return data.appname + }, + rgap: 10, + height: height + }, + width: (1/4).toFixed(2)*1 + },{ + el: { + type: "bi.label", + textAlign: "left", + text: data.appid, + css:{"color":"black"}, + title: function () { + return data.appid + }, + rgap: 10, + height: height + }, + width:(1/4).toFixed(2)*1 + },{ + el: { + type: "bi.label", + textAlign: "left", + text: data.secret, + css:{"color":"black"}, + title: function () { + return data.secret + }, + rgap: 10, + height: height + }, + width: (1/4).toFixed(2)*1 + }, + // { + // el: { + // type: "bi.label", + // textAlign: "left", + // css:{"color":"black"}, + // text: data.enable, + // title: function () { + // return data.enable + // }, + // rgap: 10, + // height: height + // }, + // width: (1/5).toFixed(2)*1 + // }, + { + type: "bi.center_adapt", + width: (1 / 4).toFixed(2) * 1, + hgap:10, + items: [ + { + type:"bi.icon_button", + cls: "normal-edit-font cursor-pointer", + height:20, + css:{ + // color:"black" + }, + handler:function(){ + var dataid = data.id; + + BI.Popovers.removeAll(); + var id = "弹出层id"+BI.UUID(); + BI.Popovers.create(id, { + header: "修改", + size: "normal", + logic: { + dynamic: true + }, + body: { + type: "dec.workflow.data.input.edit", + dataid:dataid, + ref:function(ref){ + e.inputEditPaneledit = ref; + } + }, + footer:{ + type:"bi.right", + rgap:10, + items:[ + { + type:"bi.button", + text:"取消", + handler:function(){ + BI.Popovers.remove(id); + } + }, + { + type:"bi.button", + text:"确认", + handler:function(){ + e.inputEditPaneledit.save(); + BI.Popovers.remove(id); + e.fireEvent("update", e) + } + }, + ] + } + }).show(id); + + } + }, + // { + // type:"bi.icon_button", + // cls: data.enable ? "disable-user-font" : "enable-user-font", + // height:20, + // css:{ + // }, + // handler:function(){ + // var tip = data.enable ? "确定要禁用数据吗" : "确定要启用数据吗"; + // BI.Msg.confirm("提示", tip, function (v) { + // if(v){ + // data.enable = !data.enable; + // update(data); + // e.fireEvent("update", e) + // } + // }); + // + // } + // }, + { + type:"bi.icon_button", + cls: "delete-user-font", + height:20, + css:{ + }, + handler:function(){ + BI.Msg.confirm("提示", "确定要删除数据吗", function (v) { + if(v){ + var id =data.id; + deleteData(id); + e.fireEvent("update", e) + } + }); + + } + } + + + + ] + } + ] + }, + _formatItem: function (e) { + var t = this, + i = this.options, + n = [], + o = this.model.keywordMap, + param = e; + var id = param.id; + return n.push({ + type: "bi.center_adapt", + width: 50, + height: i.height, + items: [{ + type: "bi.checkbox", + $testId: "dec-user-row-checkbox", + $value: e.id, + ref: function (e) { + t.checkbox = e + checkboxArray.push({"id":id,"obj":e}) + }, + disabled: false, + selected: e.selected, + listeners: [{ + eventName: "EVENT_CHANGE", + action: function () { + t.store.changeSelected(this.isSelected()) + t.changeOtherSelected(id); + } + } + ] + } + ] + }), + n.push({ + el: { + type: "bi.htape", + height: i.height, + scrollable: !1, + disabled: false, + items: this.getFieldRow(t.height) + } + }), + n + }, + _createExtraItems: function (i) { + var n = [], + e = BI.Providers.getProvider("dec.provider.all_user").getExtraAttributes(); + return BI.each(e, function (e, t) { + BI.isKey(t.column) ? n.push(BI.extend({ + type: t.column, + width: t.width + }, i)) : BI.isFunction(t.column) ? n.push(BI.extend({ + width: t.width + }, t.column(i))) : n.push({ + type: "bi.layout", + width: t.width + }) + }), + n + }, + changeOtherSelected: function(id){ + // $.each(checkboxArray,function(index,item){ + // if(item.id != id){ + // item.obj.setSelected(false); + // } + // }) + }, + isSelected: function () { + return this.checkbox.isSelected() + }, + getValue: function () { + return this.options.userInfo.id + }, + setSelected: function (e) { + // this.options.userInfo.enableCheck && this.checkbox.setSelected(e) + this.checkbox.setSelected(e) + } +}); +e.EVENT_DELETE = "EVENT_DELETE", + BI.shortcut("dec.workflow.data.table.row", e); + +/** + * 数据行数据 + */ +var e; +e = BI.inherit(Fix.Model, { + context: ["rows", "currentPage", "isAllChecked", "filter", "syncConfigs", "selectedValues", "userManagementConfigs"], + computed: { + keywordMap: function () { + var e = {}; + return BI.isEmptyString(this.model.filter.searchBy) ? e = { + username: this.model.filter.keyword, + realName: this.model.filter.keyword + } + : (e[this.model.filter.searchBy] = this.model.filter.keyword, e) + }, + selected: function () { + return BI.some(this.model.selectedValues, (function (e, t) { + return t === this.options.id + }), this) + } + }, + actions: { + disableUser: function (e, t) { + var i = this; + Dec.Utils.forbidUser({ + enable: e, + id: t + }, (function (n) { + BI.some(i.model.rows, (function (i, n) { + if (n.id === t) + return n.enable = e, !0 + })), + i.model.rows.splice(0, 0) + })) + }, + changeSelected: function (e) { + var t = this; + e ? this.model.selectedValues.push(this.options.id) : BI.remove(this.model.selectedValues, this.options.id), + BI.some(t.model.rows, (function (i, n) { + if (n.id === t.options.id) + return n.selected = e, !0 + })), + this.model.isAllChecked = BI.every(this.model.rows, (function (e, i) { + return BI.contains(t.model.selectedValues, i.id) + })); + } + } +}), + BI.model("dec.model.user.all.row2", e) +//应用管理底部----------------------------------------------------------------------------------------------------------------------- + +//--------------------------------------------通用方法-------------------------------------------- +/** + * 获取分页数据 + * @param param 当前页,页数量,创建时间,from + */ +function getPageData(param){ + var result = {}; + $.ajax({ + type:"get", + async:false, + url:"decision/fsds/getAll", + xhrFields:{ + withCredentials:true + }, + success:function(data){ + result = JSON.parse(data.data); + }, + error:function(data){ + } + }) + + return { + "page":param.page, + "count":result.length, + "items":result + } +} + +//获取数据 +function getDataById(id){ + var result = {}; + + $.ajax({ + type:"get", + async:false, + url:"decision/fsds/getById?id="+id, + xhrFields:{ + withCredentials:true + }, + success:function(data){ + result = JSON.parse(data.data); + }, + error:function(data){ + } + }) + + return result; +} + +//删除数据 +function deleteData(id){ + var data = {}; + + $.ajax({ + type:"post", + async:false, + url:"decision/fsds/delete", + xhrFields:{ + withCredentials:true + }, + contentType:"application/json", + data:JSON.stringify({"id":id}), + success:function(data){ + data = data.data; + }, + error:function(data){ + } + }) + + return data; +} + +//修改数据 +function update(param){ + + $.ajax({ + type:"post", + async:false, + url:"decision/fsds/update", + xhrFields:{ + withCredentials:true + }, + contentType:"application/json", + data:JSON.stringify(param), + success:function(data){ + result = data.data; + }, + error:function(data){ + } + }) + + return result; + +} + + +//通用组件------------------------------------------------------------------------------------------------ +//文字+输入框标题 +var e = BI.inherit(BI.Widget, { + props: { + text: "", + value:"", + inputType:"text", + disabled:false + }, + render: function () { + var t = this; + return { + type: "bi.left", + height:25, + + items: [ + { + type: "bi.label", + text:this.options.text, + textHeight:25, + textAlign:"left", + css:{"font-weight":"bold","color":"black"}, + width:100, + rgap:10 + },{ + type: "bi.editor", + allowBlank: true, + value:this.options.value, + width: 290, + height: 25, + cls: "bi-border", + inputType:this.options.inputType, + disabled:this.options.disabled, + validationChecker:function(){ + return true; + }, + ref:function(ref){ + t.input = ref; + }, + listeners: [{ + eventName: "EVENT_CHANGE", + action: function() { + t.fireEvent("EVENT_CHANGE", ""); + } + }] + } + ] + } + }, + getValue:function(){ + return this.input.getValue(); + }, + setValue:function(value){ + this.input.setValue(value) + } +}); + +BI.shortcut("dec.wink.item", e); + +var e = BI.inherit(BI.Widget, { + props: { + icon: { + //样式名称 plus-font + text:"", + //图标颜色 + color:"" + }, + label:{ + text:"" + }, + handler:function(){} + }, + render: function () { + var t = this; + return { + type:"bi.right_vertical_adapt", + width:40, + css:{ + cursor:"pointer" + }, + items:[ + { + type:"bi.icon_button", + cls: this.options.icon.text, + height:20, + css:{ + color:this.options.icon.color + }, + handler:this.options.handler + }, + { + type:"bi.label", + value:this.options.label.text, + handler:this.options.handler + } + ] + } + } +}); + +BI.shortcut("wink.icon_button", e); \ No newline at end of file diff --git a/src/main/resources/com/eco/plugin/shsytzfsds/js/univalsalServerTable.js b/src/main/resources/com/eco/plugin/shsytzfsds/js/univalsalServerTable.js new file mode 100644 index 0000000..835e41e --- /dev/null +++ b/src/main/resources/com/eco/plugin/shsytzfsds/js/univalsalServerTable.js @@ -0,0 +1,382 @@ + +!(function () { + var Model = BI.inherit(Fix.Model, { + _init: function () { + this.service = BI.Services.getService("dec.service.data.set"); + }, + context: ["dataSetName", "ableSave"], + state: function () { + var val = this.options.value.datasetData || {}; + return { + config : val.config || "", + parameters: val.parameters || [] + }; + }, + childContext: ["previewAble", "previewedDataSet"], + watch: { + previewAble: function (v) { + this.setAbleSave(v); + } + }, + computed: { + paramHeader: function () { + //定义参数列表表头 + var map = BI.map(BI.Constants.getConstant("dec.constants.data.set.sql.header"), function (i, v) { + return BI.extend({ + textAlign: "left", + height: 30, + hgap: 10 + }, v); + }); + map.push({ + textAlign: "left", + height: 30, + hgap: 10, + text: "" + }); + return [map]; + }, + paramItems: function () { + var self = this; + return BI.map(this.model.parameters, function (i, param) { + return [{ + type: "bi.text_editor", + value: param.name, + textAlign: "left", + height: 30, + lgap: 10, + listeners: [{ + eventName: BI.TextEditor.EVENT_CHANGE, + action: function () { + self.setParamName(i, this.getValue()); + } + }] + }, { + type: "bi.icon_text_value_combo", + cls: "field-type-change", + height: 30, + items: BI.Constants.getConstant("dec.constants.data.set.sql.field"), + value: param.type, + listeners: [{ + eventName: BI.IconTextValueCombo.EVENT_CHANGE, + action: function () { + self.setParamType(i, this.getValue()[0]); + } + }] + }, self.service.createParameterValueItem(param, function (val) { + self.setParamValue(i, val); + }),{ + type: "bi.icon_button", + cls: "default-delete-font", + height: 30, + lgap: 10, + title: BI.i18nText("Dec-Basic_Delete"), + handler: function () { + self.deleteParameter(i); + } + }]; + }); + }, + previewAble: function () { + return BI.isNotEmptyString(this.model.config); + }, + previewedDataSet: function () { + return { + datasetType: DecCst.DataSet.Type.DEMO_DATA, + datasetName: this.model.dataSetName, + datasetData: { + config: this.model.config, + parameters: this.model.parameters + } + }; + } + }, + actions: { + initPage: function (cb) { + var self = this; + cb(); + }, + setConfig: function(v){ + this.model.config = v; + }, + refreshParam: function () { + var self = this; + Dec.Utils.getDataSetParameters(this.model.previewedDataSet, function (res) { + self.model.parameters = self.service.getParameters(res.data, self.model.parameters); + }); + }, + addParamter:function(v){ + this.model.parameters.push(v); + }, + deleteParameter:function(index){ + this.model.parameters.splice(index, 1); + }, + setParamName: function (index, name) { + this.model.parameters[index].name = name; + }, + setParamType: function (index, type) { + if (this.model.parameters[index].type !== type) { + this.model.parameters[index].type = type; + this.model.parameters[index].value = this.service.getDefaultValueByType(type); + this.model.parameters.splice(0, 0); + } + }, + setParamValue: function (index, val) { + this.model.parameters[index].value = val; + }, + setAbleSave: function (v) { + this.model.ableSave = v; + } + } + }); + BI.model("dec.model.data.set.type.sync.data", Model); + + + var DemoData = BI.inherit(BI.Widget, { + props: { + baseCls: "dec-data-set-sql", + $testId: "dec-data-set-sql", + value: { + datasetData: {} + } + }, + _store: function () { + return BI.Models.getModel("dec.model.data.set.type.sync.data", this.options); + }, + watch: { + config: function (v) { + this.configEditor.setValue(v); + }, + "config || parameters.**": function () { + this.previewPane.resetPreview(); + }, + parameters: function () { + // this.paramSettingPane.populate(this.model.paramItems, this.model.paramHeader); + } + }, + beforeInit: function (cb) { + this.store.initPage(cb); + }, + render: function () { + var self = this; + self.store.setConfig("1"); + var feishuApp = getFeishuApp(); + var parameter = this.model.parameters; + var appid = ""; + var url = ""; + + $.each(parameter,function(index,item){ + if(item.name == 'appid'){ + appid = item.value; + } + + if(item.name == 'url'){ + url = item.value; + } + }) + + return { + type: "bi.htape", + items: [ + //左侧的配置界面 + { + el: { + type: "bi.vtape", + items: [ + + { + type: "bi.left", + height:25, + items: [ + { + type: "bi.label", + text:"飞书应用", + textHeight:25, + textAlign:"left", + css:{"font-weight":"bold","color":"black"}, + width:100, + rgap:10 + },{ + type: "bi.text_value_combo", + text: "", + value: appid, + width: 200, + allowClear: true, + height: 24, + items: feishuApp, + ref:function(obj){ + self.checkbox = obj; + }, + listeners: [{ + eventName: "EVENT_CHANGE", + action: function () { + var appid = self.checkbox.getValue()[0]; + var url =self.url.getValue(); + + self.model.parameters = [{"name":"appid","type":"String","value":appid},{"name":"url","type":"String","value":url}] + } + }], + } + ] + }, + { + type:"dec.wink.item", + text:"多维表url", + value:url, + ref:function(obj){ + self.url = obj + }, + listeners: [{ + eventName: "EVENT_CHANGE", + action: function () { + var appid = self.checkbox.getValue()[0]; + var url =self.url.getValue(); + + self.model.parameters = [{"name":"appid","type":"String","value":appid},{"name":"url","type":"String","value":url}] + } + }], + } + ], + lgap: 10, + vgap: 15 + }, + width: 410, + lgap: 10, + vgap: 15 + }, + //右侧的预览界面 + { + el: { + type: "bi.absolute", + cls: "bi-sortable-holder", + items: [{ + el: { + type: "dec.data.set.preview", + listeners: [{ + eventName: "EVENT_CHANGE", + action: function () { + self.store.refreshParam(); + self.previewPane.previewData(); + } + }], + ref: function (_ref) { + self.previewPane = _ref; + } + }, top: 10, right: 10, bottom: 10, left: 10 + }] + }, + hgap: 10, + vgap: 15 + } + ] + }; + }, + getValue: function () { + var appid = this.checkbox.getValue()[0]; + var url =this.url.getValue(); + + return { + config: this.model.config, + parameters: [{"name":"appid","type":"String","value":appid},{"name":"url","type":"String","value":url}] + }; + } + }); + BI.shortcut("dec.data.set.type.sync.data", DemoData); + + $.extend(DecCst.DataSet.Type,{DEMO_DATA:"飞书多维表数据集"}); + BI.config("dec.provider.data.set", function (provider) { + provider.registerDataSetType({ + value: DecCst.DataSet.Type.DEMO_DATA, + text: "飞书多维表数据集", + cardType: "dec.data.set.type.sync.data", + iconCls: "management-maintenance-cloud-font", + ableSave:true + }); + }); +})(); + +//ajax-------------------------------------------------------------------------------------------------- +function getFeishuApp(){ + var result = {}; + + $.ajax({ + type:"get", + async:false, + url:"decision/fsds/getAll", + xhrFields:{ + withCredentials:true + }, + success:function(data){ + result = JSON.parse(data.data); + }, + error:function(data){ + } + }) + + var resultArray = []; + + $.each(result,function(index,item){ + resultArray.push({"text":item.appname,"value":item.id}) + }) + + return resultArray; +} + +//通用组件------------------------------------------------------------------------------------------------ +//文字+输入框标题 +var e = BI.inherit(BI.Widget, { + props: { + text: "", + value:"", + inputType:"text", + disabled:false + }, + render: function () { + var t = this; + return { + type: "bi.left", + height:25, + + items: [ + { + type: "bi.label", + text:this.options.text, + textHeight:25, + textAlign:"left", + css:{"font-weight":"bold","color":"black"}, + width:100, + rgap:10 + },{ + type: "bi.editor", + allowBlank: true, + value:this.options.value, + width: 200, + height: 25, + cls: "bi-border", + inputType:this.options.inputType, + disabled:this.options.disabled, + validationChecker:function(){ + return true; + }, + ref:function(ref){ + t.input = ref; + }, + listeners: [{ + eventName: "EVENT_CHANGE", + action: function() { + t.fireEvent("EVENT_CHANGE", ""); + } + }] + } + ] + } + }, + getValue:function(){ + return this.input.getValue(); + }, + setValue:function(value){ + this.input.setValue(value) + } +}); + +BI.shortcut("dec.wink.item", e); \ No newline at end of file diff --git a/src/main/resources/com/eco/plugin/shsytzfsds/js/univalsalServerTableSheet.js b/src/main/resources/com/eco/plugin/shsytzfsds/js/univalsalServerTableSheet.js new file mode 100644 index 0000000..525c7fb --- /dev/null +++ b/src/main/resources/com/eco/plugin/shsytzfsds/js/univalsalServerTableSheet.js @@ -0,0 +1,493 @@ + + +/** + * @author 秃破天际 + * @version 10.0 + * Created by 秃破天际 on 2021-03-29 + **/ +!(function () { + var Model = BI.inherit(Fix.Model, { + _init: function () { + this.service = BI.Services.getService("dec.service.data.set"); + }, + context: ["dataSetName", "ableSave"], + state: function () { + var val = this.options.value.datasetData || {}; + return { + config : val.config || "", + parameters: val.parameters || [] + }; + }, + childContext: ["previewAble", "previewedDataSet"], + watch: { + previewAble: function (v) { + this.setAbleSave(v); + } + }, + computed: { + paramHeader: function () { + //定义参数列表表头 + var map = BI.map(BI.Constants.getConstant("dec.constants.data.set.sql.header"), function (i, v) { + return BI.extend({ + textAlign: "left", + height: 30, + hgap: 10 + }, v); + }); + map.push({ + textAlign: "left", + height: 30, + hgap: 10, + text: "" + }); + return [map]; + }, + paramItems: function () { + var self = this; + return BI.map(this.model.parameters, function (i, param) { + return [{ + type: "bi.text_editor", + value: param.name, + textAlign: "left", + height: 30, + lgap: 10, + listeners: [{ + eventName: BI.TextEditor.EVENT_CHANGE, + action: function () { + self.setParamName(i, this.getValue()); + } + }] + }, { + type: "bi.icon_text_value_combo", + cls: "field-type-change", + height: 30, + items: BI.Constants.getConstant("dec.constants.data.set.sql.field"), + value: param.type, + listeners: [{ + eventName: BI.IconTextValueCombo.EVENT_CHANGE, + action: function () { + self.setParamType(i, this.getValue()[0]); + } + }] + }, self.service.createParameterValueItem(param, function (val) { + self.setParamValue(i, val); + }),{ + type: "bi.icon_button", + cls: "default-delete-font", + height: 30, + lgap: 10, + title: BI.i18nText("Dec-Basic_Delete"), + handler: function () { + self.deleteParameter(i); + } + }]; + }); + }, + previewAble: function () { + return BI.isNotEmptyString(this.model.config); + }, + previewedDataSet: function () { + return { + datasetType: DecCst.DataSet.Type.DEMO_DATA2, + datasetName: this.model.dataSetName, + datasetData: { + config: this.model.config, + parameters: this.model.parameters + } + }; + } + }, + actions: { + initPage: function (cb) { + var self = this; + cb(); + }, + setConfig: function(v){ + this.model.config = v; + }, + refreshParam: function () { + var self = this; + Dec.Utils.getDataSetParameters(this.model.previewedDataSet, function (res) { + self.model.parameters = self.service.getParameters(res.data, self.model.parameters); + }); + }, + addParamter:function(v){ + this.model.parameters.push(v); + }, + deleteParameter:function(index){ + this.model.parameters.splice(index, 1); + }, + setParamName: function (index, name) { + this.model.parameters[index].name = name; + }, + setParamType: function (index, type) { + if (this.model.parameters[index].type !== type) { + this.model.parameters[index].type = type; + this.model.parameters[index].value = this.service.getDefaultValueByType(type); + this.model.parameters.splice(0, 0); + } + }, + setParamValue: function (index, val) { + this.model.parameters[index].value = val; + }, + setAbleSave: function (v) { + this.model.ableSave = v; + } + } + }); + BI.model("dec.model.data.set.type.sync.data.sheet", Model); + + + var DemoData = BI.inherit(BI.Widget, { + props: { + baseCls: "dec-data-set-sql", + $testId: "dec-data-set-sql", + value: { + datasetData: {} + } + }, + _store: function () { + return BI.Models.getModel("dec.model.data.set.type.sync.data.sheet", this.options); + }, + watch: { + config: function (v) { + this.configEditor.setValue(v); + }, + "config || parameters.**": function () { + this.previewPane.resetPreview(); + }, + parameters: function () { + // this.paramSettingPane.populate(this.model.paramItems, this.model.paramHeader); + } + }, + beforeInit: function (cb) { + this.store.initPage(cb); + }, + render: function () { + var self = this; + self.store.setConfig("1"); + var feishuApp = getFeishuApp(); + var parameter = this.model.parameters; + var appid = ""; + var url = ""; + var headrow = 0; + var rowsize = 0; + var columnSize = "A"; + + $.each(parameter,function(index,item){ + if(item.name == 'appid'){ + appid = item.value; + } + + if(item.name == 'url'){ + url = item.value; + } + + if(item.name == 'headrow'){ + headrow = item.value; + } + + if(item.name == 'rowsize'){ + rowsize = item.value; + } + + if(item.name == 'columnSize'){ + columnSize = item.value; + } + }) + + return { + type: "bi.htape", + items: [ + //左侧的配置界面 + { + el: { + type: "bi.vtape", + items: [ + + { + type: "bi.left", + height:25, + items: [ + { + type: "bi.label", + text:"飞书应用", + textHeight:25, + textAlign:"left", + css:{"font-weight":"bold","color":"black"}, + width:100, + rgap:10 + },{ + type: "bi.text_value_combo", + text: "", + value: appid, + width: 200, + allowClear: true, + height: 24, + items: feishuApp, + ref:function(obj){ + self.checkbox = obj; + }, + listeners: [{ + eventName: "EVENT_CHANGE", + action: function () { + var appid = self.checkbox.getValue()[0]; + var url =self.url.getValue(); + var headrow = self.headrow.getValue(); + var rowsize = self.rowsize.getValue(); + var columnSize = self.columnSize.getValue(); + + self.model.parameters =[{"name":"appid","type":"String","value":appid},{"name":"url","type":"String","value":url} + ,{"name":"headrow","type":"String","value":headrow},{"name":"rowsize","type":"String","value":rowsize},{"name":"columnSize","type":"String","value":columnSize}, + ] + } + }], + } + ] + }, + { + type: "bi.absolute", + items:[ + { + type:"dec.wink.item", + text:"多维表url", + value:url, + ref:function(obj){ + self.url = obj + }, + listeners: [{ + eventName: "EVENT_CHANGE", + action: function () { + var appid = self.checkbox.getValue()[0]; + var url =self.url.getValue(); + var headrow = self.headrow.getValue(); + var rowsize = self.rowsize.getValue(); + var columnSize = self.columnSize.getValue(); + + self.model.parameters =[{"name":"appid","type":"String","value":appid},{"name":"url","type":"String","value":url} + ,{"name":"headrow","type":"String","value":headrow},{"name":"rowsize","type":"String","value":rowsize},{"name":"columnSize","type":"String","value":columnSize}, + ] + } + }], + }, + { + type:"dec.wink.item", + text:"表头行号", + value:headrow, + ref:function(obj){ + self.headrow = obj + }, + top:40, + listeners: [{ + eventName: "EVENT_CHANGE", + action: function () { + var appid = self.checkbox.getValue()[0]; + var url =self.url.getValue(); + var headrow = self.headrow.getValue(); + var rowsize = self.rowsize.getValue(); + var columnSize = self.columnSize.getValue(); + + self.model.parameters =[{"name":"appid","type":"String","value":appid},{"name":"url","type":"String","value":url} + ,{"name":"headrow","type":"String","value":headrow},{"name":"rowsize","type":"String","value":rowsize},{"name":"columnSize","type":"String","value":columnSize}, + ] + } + }], + }, + { + type:"dec.wink.item", + text:"截止行号", + value:rowsize, + ref:function(obj){ + self.rowsize = obj + }, + top:80, + listeners: [{ + eventName: "EVENT_CHANGE", + action: function () { + var appid = self.checkbox.getValue()[0]; + var url =self.url.getValue(); + var headrow = self.headrow.getValue(); + var rowsize = self.rowsize.getValue(); + var columnSize = self.columnSize.getValue(); + + self.model.parameters =[{"name":"appid","type":"String","value":appid},{"name":"url","type":"String","value":url} + ,{"name":"headrow","type":"String","value":headrow},{"name":"rowsize","type":"String","value":rowsize},{"name":"columnSize","type":"String","value":columnSize}, + ] + } + }], + }, + { + type:"dec.wink.item", + text:"截止列名", + value:columnSize, + ref:function(obj){ + self.columnSize = obj + }, + top:120, + listeners: [{ + eventName: "EVENT_CHANGE", + action: function () { + var appid = self.checkbox.getValue()[0]; + var url =self.url.getValue(); + var headrow = self.headrow.getValue(); + var rowsize = self.rowsize.getValue(); + var columnSize = self.columnSize.getValue(); + + self.model.parameters =[{"name":"appid","type":"String","value":appid},{"name":"url","type":"String","value":url} + ,{"name":"headrow","type":"String","value":headrow},{"name":"rowsize","type":"String","value":rowsize},{"name":"columnSize","type":"String","value":columnSize}, + ] + } + }], + } + ] + }, + + ], + lgap: 10, + vgap: 15 + }, + width: 410, + lgap: 10, + vgap: 15 + }, + //右侧的预览界面 + { + el: { + type: "bi.absolute", + cls: "bi-sortable-holder", + items: [{ + el: { + type: "dec.data.set.preview", + listeners: [{ + eventName: "EVENT_CHANGE", + action: function () { + self.store.refreshParam(); + self.previewPane.previewData(); + } + }], + ref: function (_ref) { + self.previewPane = _ref; + } + }, top: 10, right: 10, bottom: 10, left: 10 + }] + }, + hgap: 10, + vgap: 15 + } + ] + }; + }, + getValue: function () { + var appid = this.checkbox.getValue()[0]; + var url =this.url.getValue(); + var headrow = this.headrow.getValue(); + var rowsize = this.rowsize.getValue(); + var columnSize = this.columnSize.getValue(); + return { + config: this.model.config, + parameters: [{"name":"appid","type":"String","value":appid},{"name":"url","type":"String","value":url} + ,{"name":"headrow","type":"String","value":headrow},{"name":"rowsize","type":"String","value":rowsize},{"name":"columnSize","type":"String","value":columnSize}, + ] + }; + } + }); + BI.shortcut("dec.data.set.type.sync.data.sheet", DemoData); + + $.extend(DecCst.DataSet.Type,{DEMO_DATA2:"飞书表格单sheet数据集"}); + + BI.config("dec.provider.data.set", function (provider) { + provider.registerDataSetType({ + value: DecCst.DataSet.Type.DEMO_DATA2, + text: "飞书表格单sheet数据集", + cardType: "dec.data.set.type.sync.data.sheet", + iconCls: "management-maintenance-cloud-font", + ableSave:true + }); + }); +})(); + +//ajax-------------------------------------------------------------------------------------------------- +function getFeishuApp(){ + var result = {}; + + $.ajax({ + type:"get", + async:false, + url:"decision/fsds/getAll", + xhrFields:{ + withCredentials:true + }, + success:function(data){ + result = JSON.parse(data.data); + }, + error:function(data){ + } + }) + + var resultArray = []; + + $.each(result,function(index,item){ + resultArray.push({"text":item.appname,"value":item.id}) + }) + + return resultArray; +} + +//通用组件------------------------------------------------------------------------------------------------ +//文字+输入框标题 +var e = BI.inherit(BI.Widget, { + props: { + text: "", + value:"", + inputType:"text", + disabled:false + }, + render: function () { + var t = this; + return { + type: "bi.left", + height:25, + + items: [ + { + type: "bi.label", + text:this.options.text, + textHeight:25, + textAlign:"left", + css:{"font-weight":"bold","color":"black"}, + width:100, + rgap:10 + },{ + type: "bi.editor", + allowBlank: true, + value:this.options.value, + width: 200, + height: 25, + cls: "bi-border", + inputType:this.options.inputType, + disabled:this.options.disabled, + validationChecker:function(){ + return true; + }, + ref:function(ref){ + t.input = ref; + }, + listeners: [{ + eventName: "EVENT_CHANGE", + action: function() { + t.fireEvent("EVENT_CHANGE", ""); + } + }] + } + ] + } + }, + getValue:function(){ + return this.input.getValue(); + }, + setValue:function(value){ + this.input.setValue(value) + } +}); + +BI.shortcut("dec.wink.item", e); \ No newline at end of file