Browse Source

代码提交

shaohao521 2 years ago
parent
commit
62659248e1

+ 133 - 0
core/src/test/java/TestHttp.java

@@ -0,0 +1,133 @@
+import com.alibaba.fastjson.JSONObject;
+import com.alibaba.fastjson.serializer.SerializerFeature;
+import com.alibaba.fastjson.support.config.FastJsonConfig;
+import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
+import org.junit.Before;
+import org.junit.Test;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.MediaType;
+import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
+import org.springframework.http.converter.HttpMessageConverter;
+import org.springframework.web.client.RestTemplate;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class TestHttp {
+
+	private RestTemplate restTemplate;
+
+	@Before
+	public void init() {
+		PoolingHttpClientConnectionManager connMgr = new PoolingHttpClientConnectionManager();
+		connMgr.setMaxTotal(5 + 1);
+		connMgr.setDefaultMaxPerRoute(5);
+		CloseableHttpClient httpClient = HttpClients.custom()
+				.setConnectionManager(connMgr).build();
+		restTemplate = new RestTemplate(
+				new HttpComponentsClientHttpRequestFactory(httpClient));
+		List<HttpMessageConverter<?>> converters = new ArrayList();
+		FastJsonHttpMessageConverter fastjson = new FastJsonHttpMessageConverter();
+        FastJsonConfig fastJsonConfig = new FastJsonConfig();
+
+        fastJsonConfig.setSerializerFeatures(
+                SerializerFeature.WriteMapNullValue,
+                SerializerFeature.WriteNullStringAsEmpty,
+                SerializerFeature.WriteNullListAsEmpty,
+                SerializerFeature.DisableCircularReferenceDetect);
+        fastjson.setFastJsonConfig(fastJsonConfig);
+
+		converters.add(fastjson);
+		restTemplate.setMessageConverters(converters);
+	}
+
+	@Test
+	public void getAccountToken() {
+		String url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=%s&secret=%s";
+		JSONObject forObject = restTemplate.getForObject(String.format(url, appId, secret), JSONObject.class);
+		if (forObject != null) {
+			String access_token = forObject.getString("access_token");
+            System.out.println(access_token);
+		}
+	}
+
+	private String appId = "wxd77d7ae085fe9bf7";
+	private String secret = "981d68987118b6319e0f67fc7bc293eb";
+
+	@Test
+	public void test() {
+		JSONObject weData = getWeData("http://www.baidu.com", "程序测试", "电影名称", "订票人信息", "预订观影时间", "预订票数", "描述内容");
+
+		String accountToken = "21_HS4FV3Y33lpSaYzejhGi4n3bcFjTz3LPnJ-K_XVcAnMTvxaJNVTb0xTWM0wjjw68Ziew2jkTTytA_Mir6sQsg2TG4Q9Sakd8dkUphP3Sazqn7Nf4asbDp21hICNDhq1FtWVqDJhRAChq2S_1BMEeAGAGRJ";
+		weData.put("template_id","6P4JLQEbdmYjMj7j42hdmrGXbTEJYY60aUQ0FL9pkug");
+		weData.put("touser","oGG8b6GaekBR_QDpv9beYTbMyXRE");
+
+		String sdd = "{'template_id':'%s','touser':'%s','url':'%s'}";
+
+		String url = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=%s";
+		HttpHeaders headers = new HttpHeaders();
+		headers.setContentType(MediaType.APPLICATION_JSON_UTF8);
+		headers.add("Accept", "*/*");
+        String s = weData.toJSONString();
+        System.out.println(s);
+        HttpEntity<JSONObject> request = new HttpEntity<JSONObject>(weData, headers);
+
+		restTemplate.postForEntity(String.format(url, accountToken), request, JSONObject.class);
+
+
+
+	}
+
+	@Test
+	public void getOpenId() {
+		String url = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=%s&secret=%s&code=%s&grant_type=authorization_code";
+		JSONObject forObject = restTemplate.getForObject(String.format(url, appId, secret, ""), JSONObject.class);
+		if (forObject != null) {
+			String openid = forObject.getString("openid");
+		}
+	}
+
+	public JSONObject getWeData(String url, String first, String keyword1, String keyword2, String keyword3, String keyword4, String remark) {
+		JSONObject result = new JSONObject();
+		result.put("url", url);
+
+		JSONObject data = new JSONObject();
+
+		JSONObject firstItem = new JSONObject();
+		firstItem.put("value", first);
+		firstItem.put("color", "#173177");
+		data.put("first", firstItem);
+
+		JSONObject keyWord1Item = new JSONObject();
+		keyWord1Item.put("value", keyword1);
+		keyWord1Item.put("color", "#173177");
+		data.put("keyword1", keyWord1Item);
+
+		JSONObject keyWord2Item = new JSONObject();
+		keyWord2Item.put("value", keyword2);
+		keyWord2Item.put("color", "#173177");
+		data.put("keyword2", keyWord2Item);
+
+		JSONObject keyWord3Item = new JSONObject();
+		keyWord3Item.put("value", keyword3);
+		keyWord3Item.put("color", "#173177");
+		data.put("keyword3", keyWord3Item);
+
+		JSONObject keyWord4Item = new JSONObject();
+		keyWord4Item.put("value", keyword4);
+		keyWord4Item.put("color", "#173177");
+		data.put("keyword4", keyWord4Item);
+
+		JSONObject remarkItem = new JSONObject();
+		remarkItem.put("value", remark);
+		remarkItem.put("color", "#173177");
+		data.put("remark", remarkItem);
+
+		result.put("data", data);
+		return result;
+	}
+}

+ 26 - 0
core/src/test/java/com/mw/bigdata/engine/TestSearch.java

@@ -0,0 +1,26 @@
+package com.mw.bigdata.engine;
+
+import java.util.List;
+
+import com.mw.bigdata.engine.search.SerachBase;
+
+public class TestSearch {
+
+	public static void main(String[] args) {
+		SerachBase serachBase = SerachBase.getSerachBase();
+		serachBase.add("1", "你好!", "你好!");
+		serachBase.add("2", "你好!我是张三。", "你好!我是张三。");
+		serachBase.add("3", "今天的天气挺好的。", "今天的天气挺好的。");
+		serachBase.add("4", "你是谁?", "你是谁?");
+		serachBase.add("5", "高数这门学科很难", "高数确实很难。");
+		serachBase.add("6", "测试", "上面的只是测试");
+		String ids = serachBase.getIds("你的高数");
+		System.out.println(ids);
+		List<Object> objs = serachBase.getObjects(ids);
+		if (objs != null) {
+			for (Object obj : objs) {
+				System.out.println((String) obj);
+			}
+		}
+	}
+}

+ 96 - 0
fangchan_manager/src/main/java/com/mw/platform/controller/TestDemo.java

@@ -0,0 +1,96 @@
+package com.mw.platform.controller;
+
+
+import com.mw.platform.util.RandomUtil;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
+
+/**
+ * 描述
+ *
+ * @author GuoPeiZhi
+ * 2020-5-7 11:35
+ */
+public class TestDemo {
+
+    public static void main(String[] args) {
+        new Thread() {
+            public void run() {
+                long start = System.currentTimeMillis();
+                Connection conn = null;
+                PreparedStatement pstmt = null;
+                try {
+                    conn = DriverManager
+                            .getConnection(
+                                    "jdbc:mysql://192.168.0.99:3306/db_agent_business?zeroDateTimeBehavior=convertToNull&useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true",
+                                    "root", "root");
+                    String sql = "INSERT INTO t_personnel (id, rylx, org_id, org_branch_id, zsxm, sfzh, lxdh, rytx, xl, xb, txdz, csny, jjrlx, jjrzslx, qgjjrzz, xljjrzz, zbjjrzz, zjsxrq, hylx, cysj, shzt, shr, bz, create_time, update_time, state) " +
+                            "VALUES " +
+                            "(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
+                    // JAVA默认为TRUE,我们自己处理需要设置为FALSE,并且修改为手动提交,才可以调用rollback()函数
+                    conn.setAutoCommit(false);
+                    pstmt = conn.prepareStatement(sql);
+                    for (int i = 0; i < 10000; i++) {
+                        pstmt.setString(1, null);
+                        pstmt.setInt(2, 1);
+                        pstmt.setInt(3, 13);
+                        pstmt.setString(4, null);
+                        pstmt.setString(5, "李宇春" + i);
+                        pstmt.setString(6, "370305" + RandomUtil.randomNumber(12));
+                        pstmt.setString(7, "130" + RandomUtil.randomNumber(8));
+                        pstmt.setString(8, "face/user/6/1587630451103.jpg");
+                        pstmt.setInt(9, 1);
+                        pstmt.setInt(10, 1);
+                        pstmt.setString(11, "淄博市张店区金石丽城12号楼1201");
+                        pstmt.setString(12, "1982-04-23");
+                        pstmt.setInt(13, 1);
+                        pstmt.setInt(14, 0);
+                        pstmt.setString(15, null);
+                        pstmt.setString(16, null);
+                        pstmt.setString(17, null);
+                        pstmt.setString(18, null);
+                        pstmt.setString(19, null);
+                        pstmt.setString(20, "2006-04-23 00:00:00");
+                        pstmt.setInt(21, 1);
+                        pstmt.setInt(22, 13);
+                        pstmt.setString(23, "");
+                        pstmt.setString(24, "2020-04-23 16:24:31");
+                        pstmt.setString(25, "2020-04-23 16:27:31");
+                        pstmt.setInt(26, 1);
+                        pstmt.addBatch();
+                        //防止内存溢出,我也不是很清楚都这么写
+                        if ((i + 1) % 1000 == 0) {
+                            pstmt.executeBatch();
+                            pstmt.clearBatch();
+                        }
+                    }
+                    pstmt.executeBatch(); // 批量执行
+                    conn.commit();// 提交事务
+                } catch (SQLException e) {
+                    try {
+                        conn.rollback(); // 进行事务回滚
+                    } catch (SQLException ex) {
+                        e.printStackTrace();
+                    }
+                } finally {
+                    if (pstmt != null)
+                        try {
+                            pstmt.close();
+                        } catch (SQLException e) {
+                            e.printStackTrace();
+                        }
+                    if (conn != null)
+                        try {
+                            conn.close();
+                        } catch (SQLException e) {
+                            e.printStackTrace();
+                        }
+                }
+                System.out.println((System.currentTimeMillis() - start) + "ms");
+            };
+        }.start();
+    }
+}

+ 36 - 0
fangchan_manager/src/main/java/com/mw/platform/task/TaskLogCommonBean.java

@@ -0,0 +1,36 @@
+package com.mw.platform.task;
+
+import com.alibaba.fastjson.JSONObject;
+import com.mw.platform.system.mysql.entity.SysLog;
+import com.mw.platform.system.mysql.service.ISysLogService;
+import com.mw.platform.util.DateUtil;
+import org.springframework.stereotype.Component;
+
+import javax.annotation.Resource;
+
+@Component
+public class TaskLogCommonBean {
+
+    @Resource
+    private ISysLogService sysLogService;
+
+    public void logRecord(String title,String resJson,Long useTime,String exception){
+        SysLog sysLog = new SysLog();
+        sysLog.setTitle(title);
+        sysLog.setUsername("管理员-定时任务");
+        sysLog.setOperationType(0);
+        sysLog.setStatus(1);
+
+        //返回内容
+        sysLog.setResponse(resJson.length() > 5000 ? JSONObject.toJSONString("请求参数数据过长不予显示") : resJson);
+        //方法执行时间
+        sysLog.setUseTime(useTime);
+        sysLog.setCreateTime(DateUtil.getCurTime());
+        if (exception != null){
+            sysLog.setStatus(0);
+            sysLog.setException(exception);
+        }
+
+        sysLogService.save(sysLog);
+    }
+}

+ 268 - 0
fangchan_manager/src/main/resources/static/js/tabrightmenu.js

@@ -0,0 +1,268 @@
+layui.define(['element'], function (exports) {
+
+    var element = layui.element;
+    var $ = layui.jquery;
+    var currentActiveTabID = undefined;
+    var currentActiveTabTitle = undefined;
+    var MOD_NAME = 'tabrightmenu';
+    var RIGHTMENUMOD = function () {
+        this.v = '1.0.1';
+        this.author = 'TangHanF';
+        this.email = 'guofu_gh@163.com';
+        this.filter = '';//Tab选项卡的事件过滤
+
+    };
+    String.prototype.format = function () {
+        if (arguments.length == 0) return this;
+        var param = arguments[0];
+        var s = this;
+        if (typeof (param) == 'object') {
+            for (var key in param) s = s.replace(new RegExp("\\{" + key + "\\}", "g"), param[key]);
+            return s;
+        } else {
+            for (var i = 0; i < arguments.length; i++) s = s.replace(new RegExp("\\{" + i + "\\}", "g"), arguments[i]);
+            return s;
+        }
+    }
+
+    function createStyle(ulClassName, width) {
+        var style = '.{name} {position: absolute;width: {width_}px;z-index: 9999;display: none;background-color: #fff;padding: 2px;color: #333;border: 1px solid #eee;border-radius: 2px;cursor: pointer;}.{name} li {text-align: center;display: block;height: 30px;line-height: 32px;}.{name} li:hover {background-color: #666;color: #fff;}'
+            .format({name: ulClassName, width_: width});
+        return style;
+    }
+
+    /**
+     * 初始化
+     */
+    RIGHTMENUMOD.prototype.render = function (opt) {
+        if (!opt.container) {
+            console.error("[ERROR]使用rightmenu组件需要制定'container'属性!");
+            return;
+        }
+        if (!opt.filter) {
+            console.error("[ERROR]使用rightmenu组件需要制定'filter'属性!");
+            return;
+        }
+        this.filter = opt.filter;
+        this.isClickMidCloseTab = opt.isClickMidCloseTab || false;
+        this.width = opt.width ? opt.width : 110;// 右键弹出框的宽度,一般100~110即可
+
+        // pinTabTitles和pintabIDs作用一样,只是便于开发使用考虑加入标题和ID形式进行两种方式的过滤
+        this.pinTabTitles = opt.pinTabTitles;//固定标签的标题集合
+        this.pintabIDs = opt.pintabIDs;//固定标签的ID集合
+
+        var defaultNavArr = [
+            {eventName: 'refresh', title: '刷新当前页'},
+            {eventName: 'closeallbutpin', title: '关闭所有但固定'},
+            {eventName: 'closethis', title: '关闭标签'},
+            {eventName: 'closeothersbutpin', title: '关闭其它但固定'},
+            {eventName: 'closeleftbutpin', title: '关闭左侧标签但固定'},
+            {eventName: 'closerightbutpin', title: '关闭右侧标签但固定'}
+        ];
+        opt = opt || {};
+        opt.navArr = opt.navArr || defaultNavArr;
+        CreateRightMenu(opt);
+        registClickMidCloseTab(this.isClickMidCloseTab,opt);
+    };
+
+
+    /**
+     * 注册点击鼠标中间关闭选项卡事件
+     * @param isClose
+     * @param rightMenuConfig
+     */
+    function registClickMidCloseTab(isClose,rightMenuConfig) {
+        if (!isClose) {
+            return;
+        }
+
+        $("#" + rightmenuObj.filter).on('mousedown', 'li', function (e) {
+            currentActiveTabID = $(e.target).attr('lay-id'); // 获取当前激活的选项卡ID,当前ID改为右键菜单弹出时就获取
+            currentActiveTabTitle = $.trim($(e.target).text()); //获取当前激活选项卡的标题
+            if (rightMenuConfig.pinTabTitles && rightMenuConfig.pinTabTitles.indexOf(currentActiveTabTitle) != -1 || currentActiveTabTitle == undefined) { //特殊ID,弹出默认的右键菜单
+                return true;
+            }
+            if (rightMenuConfig.pintabIDs && rightMenuConfig.pintabIDs.indexOf(currentActiveTabID) != -1 || currentActiveTabID == undefined) { //特殊ID,弹出默认的右键菜单
+                return true;
+            }
+            if (e.which != 2) {
+                return true;
+            }
+            //鼠标中键关闭指定标签页
+            element.tabDelete(rightMenuConfig.filter, currentActiveTabID);
+            //隐藏菜单(如果有)
+            $("." + rightMenuConfig.filter).hide();
+            return false;
+        });
+    }
+
+
+    /**
+     * 创建右键菜单项目
+     * @param rightMenuConfig
+     * @constructor
+     */
+    function CreateRightMenu(rightMenuConfig) {
+        // 使用"filter"属性作为css样式名称
+        $("<style></style>").text(createStyle(rightMenuConfig.filter, rightMenuConfig.width)).appendTo($("head"));
+        var li = '';
+        $.each(rightMenuConfig.navArr, function (index, conf) {
+            if (conf.eventName === 'line')
+                li += '<hr/>';
+            else
+                li += '<li data-type="{eventName}" style="padding: 7px 16px;"><i class="layui-icon {icon}"></i>{title}</li>'
+                    .format({eventName: conf.eventName, icon: conf.icon ? conf.icon : "", title: conf.title});
+        })
+        var tmpHtml = '<ul class="{className}">{liStr} </ul>'.format({liStr: li, className: rightMenuConfig.filter})
+        $(rightMenuConfig.container).after(tmpHtml);
+        _CustomRightClick(rightMenuConfig);
+    }
+
+
+    /**
+     * 绑定右键菜单
+     * @constructor
+     */
+    function _CustomRightClick(rightMenuConfig) {
+        //屏蔽Tab右键
+        //$("#" + rightmenuObj.filter + ' li').on('contextmenu', function (e) {
+        //    return false;
+        //})
+        $('#' + rightmenuObj.filter + ',' + rightmenuObj.filter + ' li').click(function () {
+            $('.' + rightMenuConfig.filter).hide();
+        });
+        //事件委托,处理动态添加的li
+        $("#" + rightmenuObj.filter).on('contextmenu', 'li', function (e) {
+            currentActiveTabID = $(e.target).attr('lay-id');// 获取当前激活的选项卡ID,当前ID改为右键菜单弹出时就获取
+            currentActiveTabTitle = $.trim($(e.target).text());//获取当前激活选项卡的标题
+            if (currentActiveTabTitle.includes("主页")){ //主页标签不触发右键函数
+                return false;
+            }
+            if (rightMenuConfig.pinTabTitles && rightMenuConfig.pinTabTitles.indexOf(currentActiveTabTitle) != -1 || currentActiveTabTitle == undefined) {   //特殊ID,弹出默认的右键菜单
+                return true;
+            }
+            if (rightMenuConfig.pintabIDs && rightMenuConfig.pintabIDs.indexOf(currentActiveTabID) != -1 || currentActiveTabID == undefined) {   //特殊ID,弹出默认的右键菜单
+                return true;
+            }
+            var popupmenu = $("." + rightMenuConfig.filter);
+            var leftValue = ($(document).width() - e.clientX) < popupmenu.width() ? (e.clientX - popupmenu.width()) : e.clientX;
+            var topValue = ($(document).height() - e.clientY) < popupmenu.height() ? (e.clientY - popupmenu.height()) : e.clientY;
+            popupmenu.css({left: leftValue, top: topValue}).show();
+            return false;
+        });
+
+        // 点击空白处隐藏弹出菜单
+        $(document).click(function (event) {
+            event.stopPropagation();
+            $("." + rightMenuConfig.filter).hide();
+        });
+
+        /**
+         * 注册tab右键菜单点击事件
+         */
+        $('.' + rightMenuConfig.filter + ' li').click(function (e) {
+            var tabs = $("#" + rightMenuConfig.filter + " li");
+            var allTabIDArrButPin = [];//所有非固定选项卡集合
+            var allTabIDArr = [];// 所有选项卡集合
+            var idIndexButPin = 0;
+            var idIndex = 0;
+            $.each(tabs, function (i) {
+                var id = $(this).attr("lay-id");
+                var title = $(this).text();
+                if (rightMenuConfig.pinTabTitles == undefined || rightMenuConfig.pintabIDs == undefined) {
+                    allTabIDArrButPin[idIndexButPin] = id;
+                    idIndexButPin++;
+                } else if ((rightMenuConfig.pinTabTitles && rightMenuConfig.pinTabTitles.indexOf(title) == -1) &&
+                    ((rightMenuConfig.pintabIDs && rightMenuConfig.pintabIDs.indexOf(id) == -1) || id == undefined))  //去除特殊ID
+                {
+                    allTabIDArrButPin[idIndexButPin] = id;
+                    idIndexButPin++;
+                }
+                allTabIDArr[idIndex] = id;
+                idIndex++;
+            })
+
+            // 事件处理
+            switch ($(this).attr("data-type")) {
+                case "closethis"://关闭当前,如果开始了tab可关闭,实际意义不大
+                    tabDelete(currentActiveTabID, rightMenuConfig.filter);
+                    break;
+                case "closeallbutpin"://关闭所有但固定
+                    tabDeleteAll(allTabIDArrButPin, rightMenuConfig.filter);
+                    break;
+                case "closeothersbutpin"://关闭非当前但固定
+                    $.each(allTabIDArrButPin, function (i) {
+                        var tmpTabID = allTabIDArrButPin[i];
+                        if (currentActiveTabID != tmpTabID)
+                            tabDelete(tmpTabID, rightMenuConfig.filter);
+                    })
+                    break;
+                case "closeleftbutpin"://关闭左侧全部但固定
+                    var indexCloseleft = allTabIDArrButPin.indexOf(currentActiveTabID);
+                    console.log(allTabIDArrButPin.slice(0, indexCloseleft));
+                    tabDeleteAll(allTabIDArrButPin.slice(0, indexCloseleft), rightMenuConfig.filter);
+                    break;
+                case "closerightbutpin"://关闭右侧全部但固定
+                    var indexCloseright = allTabIDArrButPin.indexOf(currentActiveTabID);
+                    tabDeleteAll(allTabIDArrButPin.slice(indexCloseright + 1), rightMenuConfig.filter);
+                    break;
+
+                case "closeall"://关闭所有
+                    tabDeleteAll(allTabIDArr, rightMenuConfig.filter);
+                    break;
+                case "closeothers"://关闭非当前
+                    $.each(allTabIDArr, function (i) {
+                        var tmpTabID = allTabIDArr[i];
+                        if (currentActiveTabID != tmpTabID)
+                            tabDelete(tmpTabID, rightMenuConfig.filter);
+                    })
+                    break;
+                case "closeleft"://关闭左侧全部
+                    var indexCloseleft = allTabIDArr.indexOf(currentActiveTabID);
+                    tabDeleteAll(allTabIDArr.slice(0, indexCloseleft), rightMenuConfig.filter);
+                    break;
+                case "closeright"://关闭右侧全部
+                    var indexCloseright = allTabIDArr.indexOf(currentActiveTabID);
+                    tabDeleteAll(allTabIDArr.slice(indexCloseright + 1), rightMenuConfig.filter);
+                    break;
+                case "refresh":
+                    refreshiFrame();
+                    break;
+                default:
+                    var currentTitle = $("#" + rightMenuConfig.filter + ">li[class='layui-this']").text();
+                    rightMenuConfig.registMethod[$(this).attr("data-type")](currentActiveTabID, currentTitle, rightMenuConfig.container, $(this)[0]);
+            }
+            $('.rightmenu').hide();
+        })
+    }
+
+    var tabDelete = function (id, currentNav) {
+        if (id != "/manager/sys/welcome"){
+            element.tabDelete(currentNav, id);//删除
+        }
+    }
+    var tabDeleteAll = function (ids, currentNav) {
+       /* $.each(ids, function (i, item) {
+            console.log(i)
+            element.tabDelete(currentNav, item);
+        })*/
+
+        for (let i = 0 ;i<ids.length;i++){
+            if(ids[i] != "/manager/sys/welcome"){
+                element.tabDelete(currentNav, ids[i])
+            }
+        }
+    }
+    /**
+     * 重新加载iFrame,实现更新
+     * @returns {boolean}
+     */
+    var refreshiFrame = function () {
+        var $curFrame = $('iframe:visible');
+        $curFrame.attr("src", $curFrame.attr("src"));
+        return false;
+    }
+
+    var rightmenuObj = new RIGHTMENUMOD();
+    exports(MOD_NAME, rightmenuObj);
+})

+ 257 - 0
fangchan_manager/src/main/resources/static/lay/extends/tableSelect.js

@@ -0,0 +1,257 @@
+layui.define(['table', 'jquery', 'form'], function (exports) {
+    "use strict";
+
+    var MOD_NAME = 'tableSelect',
+        $ = layui.jquery,
+        table = layui.table,
+        form = layui.form;
+    var tableSelect = function () {
+        this.v = '1.1.0';
+    };
+
+    /**
+    * 初始化表格选择器
+    */
+    tableSelect.prototype.render = function (opt) {
+        var elem = $(opt.elem);
+        var tableDone = opt.table.done || function(){};
+		
+        //默认设置
+        opt.searchKey = opt.searchKey || 'keyword';
+        opt.searchPlaceholder = opt.searchPlaceholder || '关键词搜索';
+        opt.checkedKey = opt.checkedKey;
+        opt.table.page = opt.table.page || false;
+        opt.table.height = opt.table.height || 315;
+        
+        elem.off('click').on('click', function(e) {
+            e.stopPropagation();
+
+            if($('div.tableSelect').length >= 1){
+                return false;
+            }
+
+            var t = elem.offset().top + elem.outerHeight()+"px";
+            var l = elem.offset().left +"px";
+            var tableName = "tableSelect_table_" + new Date().getTime();
+            var tableBox = '<div class="tableSelect layui-anim layui-anim-upbit" style="left:'+l+';top:'+t+';border: 1px solid #d2d2d2;background-color: #fff;box-shadow: 0 2px 4px rgba(0,0,0,.12);padding:10px 10px 0 10px;position: absolute;z-index:66666666;margin: 5px 0;border-radius: 2px;width:530px;">';
+                tableBox += '<div class="tableSelectBar">';
+                tableBox += '<form class="layui-form" action="" style="display:inline-block;">';
+                tableBox += '<input style="display:inline-block;width:190px;height:30px;vertical-align:middle;margin-right:-1px;border: 1px solid #C9C9C9;" type="text" name="'+opt.searchKey+'" placeholder="'+opt.searchPlaceholder+'" autocomplete="off" class="layui-input"><button class="layui-btn layui-btn-sm layui-btn-primary tableSelect_btn_search" lay-submit lay-filter="tableSelect_btn_search"><i class="layui-icon layui-icon-search"></i></button>';
+                tableBox += '<button style="float:right;" class="layui-btn layui-btn-sm tableSelect_btn_select">选择<span></span></button>';
+                tableBox += '</form>';
+                tableBox += '</div>';
+                tableBox += '<table id="'+tableName+'" lay-filter="'+tableName+'"></table>';
+                tableBox += '</div>';
+                tableBox = $(tableBox);
+            $('body').append(tableBox);
+            
+            //数据缓存
+            var checkedData = [];
+
+            //渲染TABLE
+            opt.table.elem = "#"+tableName;
+            opt.table.id = tableName;
+            opt.table.done = function(res, curr, count){
+                defaultChecked(res, curr, count);
+                setChecked(res, curr, count);
+                tableDone(res, curr, count);
+            };
+            var tableSelect_table = table.render(opt.table);
+
+            //分页选中保存数组
+            table.on('radio('+tableName+')', function(obj){
+                if(opt.checkedKey){
+                    checkedData = table.checkStatus(tableName).data
+                }
+                updataButton(table.checkStatus(tableName).data.length)
+            })
+			table.on('checkbox('+tableName+')', function(obj){
+                if(opt.checkedKey){
+                    if(obj.checked){
+                        for (var i=0;i<table.checkStatus(tableName).data.length;i++){
+                            checkedData.push(table.checkStatus(tableName).data[i])
+                        }
+                    }else{
+                        if(obj.type=='all'){
+                            for (var j=0;j<table.cache[tableName].length;j++) {
+                                for (var i=0;i<checkedData.length;i++){
+                                    if(checkedData[i][opt.checkedKey] == table.cache[tableName][j][opt.checkedKey]){
+                                        checkedData.splice(i,1)
+                                    }
+                                }
+                            }
+                        }else{
+                            //因为LAYUI问题,操作到变化全选状态时获取到的obj为空,这里用函数获取未选中的项。
+
+                            var noCheckedKey = obj.data[opt.checkedKey] || nu();
+                            for (var i=0;i<checkedData.length;i++){
+                                if(checkedData[i][opt.checkedKey] == noCheckedKey){
+                                    checkedData.splice(i,1);
+                                }
+                            }
+                        }
+                    }
+                    checkedData = uniqueObjArray(checkedData, opt.checkedKey);
+                    updataButton(checkedData.length)
+                }else{
+                    updataButton(table.checkStatus(tableName).data.length)
+                }
+            });
+
+            function nu (){
+                var noCheckedKey = '';
+                for (var i=0;i<table.cache[tableName].length;i++){
+                    if(!table.cache[tableName][i].LAY_CHECKED){
+                        noCheckedKey = table.cache[tableName][i][opt.checkedKey];
+                    }
+                }
+                return noCheckedKey
+            }
+
+            //渲染表格后选中
+            function setChecked (res, curr, count) {
+				for(var i=0;i<res.data.length;i++){
+            		for (var j=0;j<checkedData.length;j++) {
+            			if(res.data[i][opt.checkedKey] == checkedData[j][opt.checkedKey]){
+            				res.data[i].LAY_CHECKED = true;
+                            var index= res.data[i]['LAY_TABLE_INDEX'];
+                            var checkbox = $('#'+tableName+'').next().find('tr[data-index=' + index + '] input[type="checkbox"]');
+            				    checkbox.prop('checked', true).next().addClass('layui-form-checked');
+                            var radio  = $('#'+tableName+'').next().find('tr[data-index=' + index + '] input[type="radio"]');
+                                radio.prop('checked', true).next().addClass('layui-form-radioed').find("i").html('&#xe643;');
+            			}
+            		}
+            	}
+            	var checkStatus = table.checkStatus(tableName);
+				if(checkStatus.isAll){
+					$('#'+tableName+'').next().find('.layui-table-header th[data-field="0"] input[type="checkbox"]').prop('checked', true);
+					$('#'+tableName+'').next().find('.layui-table-header th[data-field="0"] input[type="checkbox"]').next().addClass('layui-form-checked');
+				}
+				updataButton(checkedData.length)
+            }
+            
+            //写入默认选中值(puash checkedData)
+            function defaultChecked (res, curr, count){
+                if(opt.checkedKey && elem.attr('ts-selected')){
+                    var selected = elem.attr('ts-selected').split(",");
+                    for(var i=0;i<res.data.length;i++){
+                        for(var j=0;j<selected.length;j++){
+                            if(res.data[i][opt.checkedKey] == selected[j]){
+                                checkedData.push(res.data[i])
+                            }
+                        }
+                    }
+                    checkedData = uniqueObjArray(checkedData, opt.checkedKey);
+                }
+            }
+
+			//更新选中数量
+			function updataButton (n) {
+				tableBox.find('.tableSelect_btn_select span').html(n==0?'':'('+n+')')
+            }
+            
+            //数组去重
+			function uniqueObjArray(arr, type){
+                var newArr = [];
+                var tArr = [];
+                if(arr.length == 0){
+                    return arr;
+                }else{
+                    if(type){
+                        for(var i=0;i<arr.length;i++){
+                            if(!tArr[arr[i][type]]){
+                                newArr.push(arr[i]);
+                                tArr[arr[i][type]] = true;
+                            }
+                        }
+                        return newArr;
+                    }else{
+                        for(var i=0;i<arr.length;i++){
+                            if(!tArr[arr[i]]){
+                                newArr.push(arr[i]);
+                                tArr[arr[i]] = true;
+                            }
+                        }
+                        return newArr;
+                    }
+                }
+            }
+
+			//FIX位置
+			var overHeight = (elem.offset().top + elem.outerHeight() + tableBox.outerHeight() - $(window).scrollTop()) > $(window).height();
+			var overWidth = (elem.offset().left + tableBox.outerWidth()) > $(window).width();
+			    overHeight && tableBox.css({'top':'auto','bottom':'0px'});
+			    overWidth && tableBox.css({'left':'auto','right':'5px'})
+			
+            //关键词搜索
+            form.on('submit(tableSelect_btn_search)', function(data){
+                tableSelect_table.reload({
+                    where: data.field,
+                    page: {
+                      curr: 1
+                    }
+                  });
+                return false;
+            });
+
+            //双击行选中
+            table.on('rowDouble('+tableName+')', function(obj){
+                var checkStatus = {data:[obj.data]};
+                selectDone(checkStatus);
+            })
+
+            //按钮选中
+            tableBox.find('.tableSelect_btn_select').on('click', function() {
+                var checkStatus = table.checkStatus(tableName);
+                if(checkedData.length > 1){
+                	checkStatus.data = checkedData;
+                }
+                selectDone(checkStatus);
+            })
+
+            //写值回调和关闭
+            function selectDone (checkStatus){
+                if(opt.checkedKey){
+                    var selected = [];
+                    for(var i=0;i<checkStatus.data.length;i++){
+                        selected.push(checkStatus.data[i][opt.checkedKey])
+                    }
+                    elem.attr("ts-selected",selected.join(","));
+                }
+                opt.done(elem, checkStatus);
+                tableBox.remove();
+                delete table.cache[tableName];
+                checkedData = [];
+            }
+            
+            //点击其他区域关闭
+            $(document).mouseup(function(e){
+                var userSet_con = $(''+opt.elem+',.tableSelect');
+                if(!userSet_con.is(e.target) && userSet_con.has(e.target).length === 0){
+                    tableBox.remove();
+                    delete table.cache[tableName];
+                    checkedData = [];
+                }
+            });
+        })
+    }
+
+    /**
+    * 隐藏选择器
+    */
+    tableSelect.prototype.hide = function (opt) {
+        $('.tableSelect').remove();
+    }
+
+    //自动完成渲染
+    var tableSelect = new tableSelect();
+
+    //FIX 滚动时错位
+    if(window.top == window.self){
+        $(window).scroll(function () {
+            tableSelect.hide();
+        });
+    }
+
+    exports(MOD_NAME, tableSelect);
+})

File diff suppressed because it is too large
+ 1 - 0
fangchan_manager/src/main/resources/static/lay/modules/table.js


+ 288 - 0
fangchan_manager/src/main/resources/static/pear/css/pear-module/tab.css

@@ -0,0 +1,288 @@
+.pear-tab {
+	margin: 0px;
+	overflow: hidden;
+	height: 100% !important;
+}
+
+.pear-tab .layui-tab-content {
+	height: calc(100% - 42px) !important;
+}
+
+.pear-tab .layui-tab-content .layui-tab-item {
+	height: 100%;
+}
+
+.pear-tab .layui-tab-content {
+	padding: 0px;
+}
+
+.pear-tab .layui-tab-title {
+	border: none;
+	border: 1px solid whitesmoke;
+	background-color: white;
+}
+
+.pear-tab .layui-tab-title li {
+	border-right: 1px solid whitesmoke;
+	color: dimgray;
+	font-size: 13.5px;
+	line-height: 43px;
+}
+
+.pear-tab .layui-tab-title .layui-tab-bar {
+	display: none;
+}
+
+.pear-tab .layui-tab-title .layui-this:after {
+	display: none;
+}
+
+.pear-tab .layui-tab-title .pear-tab-active {
+	display: inline-block;
+	background-color: lightgray;
+	width: 8px;
+	height: 8px;
+	border-radius: 30px;
+	margin-right: 12px;
+}
+
+.pear-tab .layui-tab-title .layui-this .pear-tab-active {
+	background-color: #5FB878;
+}
+
+.pear-tab .layui-tab-title .layui-tab-close:hover {
+	background-color: white;
+	line-height: 19px;
+	color: gray;
+}
+
+.pear-tab .layui-tab-title .disable-close+.layui-tab-close {
+	display: none;
+}
+
+.pear-tab .layui-tab-title .able-close+.layui-tab-close {
+	display: inline-block;
+}
+
+.pear-tab .layui-tab-close{
+	font-size: 13px;
+}
+
+.pear-tab .layui-tab-control>li {
+	position: absolute;
+	top: 0px;
+	height: 40px;
+	line-height: 40px;
+	width: 40px;
+	text-align: center;
+	background-color: white;
+	border-top: whitesmoke 1px solid;
+	border-bottom: whitesmoke 1px solid;
+}
+
+.pear-tab .layui-tab-prev {
+	left: 0px;
+	border-right: whitesmoke 1px solid;
+}
+
+.pear-tab .layui-tab-next {
+	right: 40px;
+	border-left: 1px solid whitesmoke;
+}
+
+.pear-tab .layui-tab-tool {
+	right: 0px;
+	border-left: 1px solid whitesmoke;
+}
+
+.pear-tab .layui-tab-control .layui-tab-tool,
+.pear-tab .layui-tab-control .layui-tab-prev,
+.pear-tab .layui-tab-control .layui-tab-next {
+	display: none;
+}
+
+.pear-tab.layui-tab-roll .layui-tab-control .layui-tab-prev,
+.pear-tab.layui-tab-roll .layui-tab-control .layui-tab-next {
+	display: block;
+}
+
+.pear-tab.layui-tab-roll .layui-tab-control .layui-tab-next {
+	right: 0px;
+	border-right: 1px solid whitesmoke;
+}
+
+.pear-tab.layui-tab-roll .layui-tab-title {
+	padding-left: 40px;
+	padding-right: 40px;
+}
+
+.pear-tab.layui-tab-tool .layui-tab-control .layui-tab-tool {
+	display: block;
+}
+
+.pear-tab.layui-tab-tool .layui-tab-title {
+	padding-left: 0px;
+	padding-right: 40px;
+}
+
+.pear-tab.layui-tab-rollTool .layui-tab-title {
+	padding-left: 40px;
+	padding-right: 80px;
+}
+
+.pear-tab.layui-tab-rollTool .layui-tab-control .layui-tab-prev,
+.pear-tab.layui-tab-rollTool .layui-tab-control .layui-tab-next,
+.pear-tab.layui-tab-rollTool .layui-tab-control .layui-tab-tool {
+	display: block;
+}
+
+.pear-tab .layui-tab-tool .layui-nav {
+	position: absolute;
+	height: 43px !important;
+	top: 0;
+	width: 100%;
+	height: 100%;
+	padding: 0;
+	background: 0 0;
+}
+
+.pear-tab .layui-tab-tool .layui-nav-item {
+	height: 40px;
+}
+
+.pear-tab .layui-tab-tool .layui-nav-bar {
+	display: none;
+}
+
+.pear-tab .layui-tab-tool .layui-nav-child {
+	left: auto;
+	top: 45px;
+	right: 3px;
+	width: 120px;
+	border: 1px solid whitesmoke;
+}
+
+.pear-tab .layui-tab-tool .layui-this a {
+	background-color: #009688;
+}
+
+.pear-tab-loading {
+	position: absolute;
+	display: none;
+	width: 100%;
+	height: calc(100% - 42px);
+	top: 42px;
+	z-index: 19;
+	background-color: #fff
+}
+
+.pear-tab-loading.close {
+	animation: close 1s;
+	-webkit-animation: close 1s;
+	animation-fill-mode: forwards;
+}
+
+.ball-loader {
+	position: absolute;
+	left: 50%;
+	top: 50%;
+	transform: translate(-50%, -50%);
+	-ms-transform: translate(-50%, -50%);
+	-webkit-transform: translate(-50%, -50%)
+}
+
+.ball-loader>span,
+.signal-loader>span {
+	background-color: #4aca85 !important;
+	display: inline-block
+}
+
+.ball-loader>span:nth-child(1),
+.ball-loader.sm>span:nth-child(1),
+.signal-loader>span:nth-child(1),
+.signal-loader.sm>span:nth-child(1) {
+	-webkit-animation-delay: 0s;
+	animation-delay: 0s
+}
+
+.ball-loader>span:nth-child(2),
+.ball-loader.sm>span:nth-child(2),
+.signal-loader>span:nth-child(2),
+.signal-loader.sm>span:nth-child(2) {
+	-webkit-animation-delay: .1s;
+	animation-delay: .1s
+}
+
+.ball-loader>span:nth-child(3),
+.ball-loader.sm>span:nth-child(3),
+.signal-loader>span:nth-child(3),
+.signal-loader.sm>span:nth-child(3) {
+	-webkit-animation-delay: .15s;
+	animation-delay: .15s
+}
+
+.ball-loader>span:nth-child(4),
+.ball-loader.sm>span:nth-child(4),
+.signal-loader>span:nth-child(4),
+.signal-loader.sm>span:nth-child(4) {
+	-webkit-animation-delay: .2s;
+	animation-delay: .2s
+}
+
+.ball-loader>span {
+	width: 20px;
+	height: 20px;
+	margin: 0 3px;
+	border-radius: 50%;
+	transform: scale(0);
+	-ms-transform: scale(0);
+	-webkit-transform: scale(0);
+	animation: ball-load 1s ease-in-out infinite;
+	-webkit-animation: 1s ball-load ease-in-out infinite
+}
+
+@-webkit-keyframes ball-load {
+	0% {
+		transform: scale(0);
+		-webkit-transform: scale(0)
+	}
+
+	50% {
+		transform: scale(1);
+		-webkit-transform: scale(1)
+	}
+
+	100% {
+		transform: scale(0);
+		-webkit-transform: scale(0)
+	}
+}
+
+@keyframes ball-load {
+	0% {
+		transform: scale(0);
+		-webkit-transform: scale(0)
+	}
+
+	50% {
+		transform: scale(1);
+		-webkit-transform: scale(1)
+	}
+
+	100% {
+		transform: scale(0);
+		-webkit-transform: scale(0)
+	}
+}
+
+@-webkit-keyframes close {
+	0% {
+		opacity: 1;
+		/*display: block;*/
+	}
+
+	100% {
+		opacity: 0;
+		/*display: none;*/
+	}
+}

+ 92 - 0
fangchan_manager/src/main/resources/static/pear/css/pear-module/table.css

@@ -0,0 +1,92 @@
+.layui-table-tool-panel {
+	margin-top: 10px !important;
+}
+
+.layui-table-tool {
+	background-color: white !important;
+	border-bottom: none !important;
+	padding-bottom: 10px !important;
+}
+
+.layui-table-header,
+.layui-table-header th {
+	background-color: white !important;
+}
+
+.layui-table-view {
+	border: none !important;
+}
+
+.layui-table-cell {
+	height: 34px !important;
+	line-height: 34px !important;
+}
+
+.layui-laypage .layui-laypage-curr .layui-laypage-em {
+	border-radius: 50px !important;
+	background-color: #5FB878 !important;
+}
+
+.layui-table tr {
+	height: 34px !important;
+	line-height: 34px !important;
+}
+
+.layui-table-cell {
+	padding-top: 1px !important;
+}
+
+.layui-table-box * {
+	font-size: 13px !important;
+}
+
+.layui-table-page .layui-laypage input {
+    width: 40px;
+    height: 26.5px!important;
+}
+
+.layui-table-box button {
+	font-size: 15px !important;
+}
+
+.layui-table-page {
+	height: 45px !important;
+	padding-top: 10px !important;
+}
+
+.layui-table-tool .layui-inline {
+	border-radius: 3px !important;
+	width: 30px !important;
+	height: 30px !important;
+	line-height: 20px !important;
+}
+
+.layui-table-view .layui-table[lay-skin=line] {
+	border: none !important;
+}
+.layui-table-body::-webkit-scrollbar {
+	width: 0px;
+	height: 0px;
+}
+
+.layui-table-body::-webkit-scrollbar {
+	width: 6px;
+	height: 6px;
+}
+.layui-table-body::-webkit-scrollbar-track {
+	background: white;
+	border-radius: 2px;
+}
+
+.layui-table-body::-webkit-scrollbar-thumb {
+	background: #E6E6E6;
+	border-radius: 2px;
+}
+
+.layui-table-body::-webkit-scrollbar-thumb:hover {
+	background: #E6E6E6;
+}
+
+.layui-table-body::-webkit-scrollbar-corner {
+	background: #f6f6f6;
+}

+ 86 - 0
fangchan_manager/src/main/resources/static/pear/css/pear-module/tag.css

@@ -0,0 +1,86 @@
+.input-new-tag {
+	width: 90px;
+}
+
+.input-new-tag input {
+	height: 100%!important;
+	border: none;
+	padding-left: 0px;
+}
+
+.tag .layui-btn .tag-close:hover {
+	border-radius: 2px;
+	color: #fff;
+}
+
+.tag .layui-btn .tag-close {
+	margin-left: 8px;
+	transition: all .2s;
+	-webkit-transition: all .2s;
+}
+.tag-item {
+	background-color: #5FB878;
+	color: white;
+	border: none;
+}
+
+.tag-item:hover {
+
+	color: white;
+
+}
+
+.tag-item-normal {
+	background-color: #5FB878;
+	color: white;
+	border: none;
+}
+
+.tag-item-warm {
+	background-color: #f6ad55;
+	color: white;
+	border: none;
+}
+
+.tag-item-danger {
+	background-color: #f56c6c;
+	color: white;
+	border: none;
+}
+
+.tag-item-dark {
+	background-color: #525252;
+	color: white;
+	border: none;
+}
+
+.tag-item-primary {
+	background-color: white !important;
+	color: dimgray;
+	border: 1px solid dimgray;
+}
+
+.tag-item-normal:hover {
+
+	color: white !important;
+}
+
+.tag-item-warm:hover {
+
+	color: white;
+}
+
+.tag-item-danger:hover {
+
+	color: white;
+}
+
+.tag-item-dark:hover {
+
+	color: white;
+}
+
+.tag-item-primary:hover {
+	color: dimgray;
+	border: 1px solid dimgray;
+}

+ 517 - 0
fangchan_manager/src/main/resources/static/pear/module/tab.js

@@ -0,0 +1,517 @@
+layui.define(['jquery', 'element'], function(exports) {
+	"use strict";
+
+	var MOD_NAME = 'tab',
+		$ = layui.jquery,
+		element = layui.element;
+
+	var pearTab = function(opt) {
+		this.option = opt;
+	};
+
+
+	pearTab.prototype.render = function(opt) {
+		//默认配置值
+		var option = {
+			elem: opt.elem,
+			data: opt.data,
+			tool: opt.tool,
+			roll: opt.roll,
+			index: opt.index,
+			width: opt.width,
+			height: opt.height,
+			tabMax: opt.tabMax,
+			closeEvent: opt.closeEvent
+		}
+
+		var tab = createTab(option);
+
+		$("#" + option.elem).html(tab);
+
+		$(".layui-tab[lay-filter='" + option.elem + "'] .layui-tab-prev").click(function() {
+			rollPage("left", option);
+		})
+
+		$(".layui-tab[lay-filter='" + option.elem + "'] .layui-tab-next").click(function() {
+			rollPage("right", option);
+		})
+
+		element.init();
+
+		toolEvent(option);
+
+		$("#" + option.elem).width(opt.width);
+		$("#" + option.elem).height(opt.height);
+		$("#" + option.elem).css({
+			position: "relative"
+		});
+
+		closeEvent(option);
+
+		return new pearTab(option);
+	}
+
+	pearTab.prototype.click = function(callback) {
+
+		var elem = this.option.elem;
+
+		element.on('tab(' + this.option.elem + ')', function(data) {
+
+			var id = $("#" + elem + " .layui-tab-title .layui-this").attr("lay-id");
+
+			callback(id);
+
+		});
+	}
+
+	pearTab.prototype.positionTab = function() {
+		var $tabTitle = $('.layui-tab[lay-filter=' + this.option.elem + ']  .layui-tab-title');
+		var autoLeft = 0;
+		$tabTitle.children("li").each(function() {
+			if ($(this).hasClass('layui-this')) {
+				return false;
+			} else {
+				autoLeft += $(this).outerWidth();
+			}
+		});
+		$tabTitle.animate({
+			scrollLeft: autoLeft - $tabTitle.width() / 3
+		}, 200);
+	}
+
+	pearTab.prototype.addTab = function(opt) {
+
+		var title = '';
+
+		if (opt.close) {
+			title += '<span class="pear-tab-active"></span><span class="able-close">' + opt.title +
+				'</span><i class="layui-icon layui-unselect layui-tab-close">ဆ</i>';
+		} else {
+			title += '<span class="pear-tab-active"></span><span class="disable-close">' + opt.title +
+				'</span><i class="layui-icon layui-unselect layui-tab-close">ဆ</i>';
+		}
+		element.tabAdd(this.option.elem, {
+			title: title,
+			content: '<iframe id="' + opt.id + '" data-frameid="' + opt.id + '" scrolling="auto" frameborder="0" src="' +
+				opt.url + '" style="width:100%;height:100%;"></iframe>',
+			id: opt.id
+		});
+		element.tabChange(this.option.elem, opt.id);
+	}
+	var index = 0;
+
+	// 根据过滤 filter 标识, 删除执行选项卡
+	pearTab.prototype.delTabByElem = function(elem, id, callback){
+		var currentTab = $(".layui-tab[lay-filter='" + elem + "'] .layui-tab-title [lay-id='"+id+"']");
+		if (currentTab.find("span").is(".able-close")) {
+			tabDelete(elem, id, callback);
+		}
+	}
+
+	// 根据过滤 filter 标识, 删除当前选项卡
+	pearTab.prototype.delCurrentTabByElem = function(elem,callback){
+		var currentTab = $(".layui-tab[lay-filter='" + elem + "'] .layui-tab-title .layui-this");
+		if (currentTab.find("span").is(".able-close")) {
+			var currentId = currentTab.attr("lay-id");
+			tabDelete(elem, currentId, callback);
+		}
+	}
+
+	// 通过过滤 filter 标识, 新增标签页
+	pearTab.prototype.addTabOnlyByElem = function(elem, opt, time) {
+		var title = '';
+		if (opt.close) {
+			title += '<span class="pear-tab-active"></span><span class="able-close">' + opt.title +
+				'</span><i class="layui-icon layui-unselect layui-tab-close">ဆ</i>'
+		} else {
+			title += '<span class="pear-tab-active"></span><span class="disable-close">' + opt.title +
+				'</span><i class="layui-icon layui-unselect layui-tab-close">ဆ</i>'
+		}
+		if ($(".layui-tab[lay-filter='" + elem + "'] .layui-tab-title li[lay-id]").length <= 0) {
+
+			if (time != false && time != 0) {
+
+				var load = '<div id="pear-tab-loading' + index + '" class="pear-tab-loading">' +
+					'<div class="ball-loader">' +
+					'<span></span><span></span><span></span><span></span>' +
+					'</div>' +
+					'</div>'
+				$("#" + elem).find(".pear-tab").append(load);
+				var pearLoad = $("#" + elem).find("#pear-tab-loading" + index);
+				pearLoad.css({
+					display: "block"
+				});
+				setTimeout(function() {
+					pearLoad.fadeOut(500);
+				}, time);
+				index++;
+			}
+			element.tabAdd(elem, {
+				title: title,
+				content: '<iframe id="' + opt.id + '" data-frameid="' + opt.id + '" scrolling="auto" frameborder="0" src="' +
+					opt.url + '" style="width:100%;height:100%;"></iframe>',
+				id: opt.id
+			});
+		} else {
+			var isData = false;
+			$.each($(".layui-tab[lay-filter='" + elem + "'] .layui-tab-title li[lay-id]"), function() {
+				if ($(this).attr("lay-id") == opt.id) {
+					isData = true;
+				}
+			})
+
+			if (isData == false) {
+				if (time != false && time != 0) {
+					var load = '<div id="pear-tab-loading' + index + '" class="pear-tab-loading">' +
+						'<div class="ball-loader">' +
+						'<span></span><span></span><span></span><span></span>' +
+						'</div>' +
+						'</div>'
+
+					$("#" + elem).find(".pear-tab").append(load);
+					var pearLoad = $("#" + elem).find("#pear-tab-loading" + index);
+					pearLoad.css({
+						display: "block"
+					});
+					setTimeout(function() {
+						pearLoad.fadeOut(500);
+					}, time);
+					index++;
+				}
+				element.tabAdd(elem, {
+					title: title,
+					content: '<iframe id="' + opt.id + '" data-frameid="' + opt.id + '" scrolling="auto" frameborder="0" src="' +
+						opt.url + '" style="width:100%;height:100%;"></iframe>',
+					id: opt.id
+				});
+			}
+		}
+		element.tabChange(elem, opt.id);
+	}
+
+
+	/** 添 加 唯 一 选 项 卡 */
+	pearTab.prototype.addTabOnly = function(opt, time) {
+
+		var title = '';
+
+		if (opt.close) {
+
+			title += '<span class="pear-tab-active"></span><span class="able-close">' + opt.title +
+				'</span><i class="layui-icon layui-unselect layui-tab-close">ဆ</i>'
+
+		} else {
+
+			title += '<span class="pear-tab-active"></span><span class="disable-close">' + opt.title +
+				'</span><i class="layui-icon layui-unselect layui-tab-close">ဆ</i>'
+
+		}
+
+		if ($(".layui-tab[lay-filter='" + this.option.elem + "'] .layui-tab-title li[lay-id]").length <= 0) {
+
+			if (time != false && time != 0) {
+
+				var load = '<div id="pear-tab-loading' + index + '" class="pear-tab-loading">' +
+					'<div class="ball-loader">' +
+					'<span></span><span></span><span></span><span></span>' +
+					'</div>' +
+					'</div>'
+
+				$("#" + this.option.elem).find(".pear-tab").append(load);
+				var pearLoad = $("#" + this.option.elem).find("#pear-tab-loading" + index);
+				pearLoad.css({
+					display: "block"
+				});
+
+				setTimeout(function() {
+					pearLoad.fadeOut(500);
+				}, time);
+				index++;
+			}
+			element.tabAdd(this.option.elem, {
+				title: title,
+				content: '<iframe id="' + opt.id + '" data-frameid="' + opt.id + '" scrolling="auto" frameborder="0" src="' +
+					opt.url + '" style="width:100%;height:100%;"></iframe>',
+				id: opt.id
+			});
+		} else {
+
+			var isData = false;
+
+			//查询当前选项卡数量
+			if ($(".layui-tab[lay-filter='" + this.option.elem + "'] .layui-tab-title li[lay-id]").length >= this.option.tabMax) {
+				layer.msg("最多打开" + this.option.tabMax + "个标签页", {
+					icon: 2,
+					time: 1000,
+					shift : 6 //抖动效果
+				});
+				return false;
+			}
+
+			$.each($(".layui-tab[lay-filter='" + this.option.elem + "'] .layui-tab-title li[lay-id]"), function() {
+
+				if ($(this).attr("lay-id") == opt.id) {
+
+					isData = true;
+				}
+			})
+			if (isData == false) {
+
+				if (time != false && time != 0) {
+
+					var load = '<div id="pear-tab-loading' + index + '" class="pear-tab-loading">' +
+						'<div class="ball-loader">' +
+						'<span></span><span></span><span></span><span></span>' +
+						'</div>' +
+						'</div>'
+
+					$("#" + this.option.elem).find(".pear-tab").append(load);
+					var pearLoad = $("#" + this.option.elem).find("#pear-tab-loading" + index);
+					pearLoad.css({
+						display: "block"
+					});
+
+					setTimeout(function() {
+						pearLoad.fadeOut(500);
+					}, time);
+					index++;
+				}
+
+				element.tabAdd(this.option.elem, {
+					title: title,
+					content: '<iframe id="' + opt.id + '" data-frameid="' + opt.id + '" scrolling="auto" frameborder="0" src="' +
+						opt.url + '" style="width:100%;height:100%;"></iframe>',
+					id: opt.id
+				});
+			}
+		}
+		element.tabChange(this.option.elem, opt.id);
+	}
+
+
+	// 刷 新 指 定 的 选 项 卡
+	pearTab.prototype.refresh = function(time) {
+
+		// 刷 新 指 定 的 选 项 卡
+		if (time != false && time != 0) {
+
+			var load = '<div id="pear-tab-loading' + index + '" class="pear-tab-loading">' +
+				'<div class="ball-loader">' +
+				'<span></span><span></span><span></span><span></span>' +
+				'</div>' +
+				'</div>'
+
+			var elem =  this.option.elem;
+			$("#" + this.option.elem).find(".pear-tab").append(load);
+			var pearLoad = $("#" + this.option.elem).find("#pear-tab-loading" + index);
+			pearLoad.css({
+				display: "block"
+			});
+			index++;
+			setTimeout(function() {
+				pearLoad.fadeOut(500,function(){
+					pearLoad.remove();
+				});
+			}, time);
+			$(".layui-tab[lay-filter='" + elem + "'] .layui-tab-content .layui-show").find("iframe")[0].contentWindow
+				.location.reload(true);
+		} else {
+			$(".layui-tab[lay-filter='" + this.option.elem + "'] .layui-tab-content .layui-show").find("iframe")[0].contentWindow
+				.location.reload(true);
+		}
+	}
+
+	function tabDelete(elem, id, callback) {
+
+		//根据 elem id 来删除指定的 layui title li
+		var tabTitle = $(".layui-tab[lay-filter='" + elem + "']").find(".layui-tab-title");
+
+		// 删除指定 id 的 title
+		var removeTab = tabTitle.find("li[lay-id='" + id + "']");
+		var nextNode = removeTab.next("li");
+
+		if(!removeTab.hasClass("layui-this")){
+
+			removeTab.remove();
+			var tabContent = $(".layui-tab[lay-filter='" + elem + "']").find("iframe[id='" + id + "']").parent();
+			tabContent.remove();
+			return false;
+		}
+
+		var currId;
+
+		if (nextNode.length) {
+
+			nextNode.addClass("layui-this");
+			currId = nextNode.attr("lay-id");
+			$("#" + elem + " [id='" + currId + "']").parent().addClass("layui-show");
+
+		} else {
+
+			var prevNode = removeTab.prev("li");
+			prevNode.addClass("layui-this");
+			currId = prevNode.attr("lay-id");
+			$("#" + elem + " [id='" + currId + "']").parent().addClass("layui-show");
+
+		}
+		callback(currId);
+		removeTab.remove();
+		// 删除 content
+		var tabContent = $(".layui-tab[lay-filter='" + elem + "']").find("iframe[id='" + id + "']").parent();
+		tabContent.remove();
+	}
+
+	function createTab(option) {
+
+		var type = "";
+
+		var types = option.type+" ";
+
+		if (option.roll == true) {
+
+			type = "layui-tab-roll";
+		}
+
+		if (option.tool != false) {
+			type = "layui-tab-tool";
+		}
+
+		if (option.roll == true && option.tool != false) {
+			type = "layui-tab-rollTool";
+		}
+
+		var tab = '<div class="pear-tab ' + types + type + ' layui-tab" lay-filter="' + option.elem + '" lay-allowClose="true">';
+
+		var title = '<ul class="layui-tab-title">';
+
+		var content = '<div class="layui-tab-content">';
+
+		var control =
+			'<div class="layui-tab-control"><li class="layui-tab-prev layui-icon layui-icon-left"></li><li class="layui-tab-next layui-icon layui-icon-right"></li><li class="layui-tab-tool layui-icon layui-icon-down"><ul class="layui-nav" lay-filter=""><li class="layui-nav-item"><a href="javascript:;"></a><dl class="layui-nav-child">';
+
+		// 处 理 选 项 卡 头 部
+
+		var index = 0;
+
+		$.each(option.data, function(i, item) {
+
+			var TitleItem = '';
+
+			if (option.index == index) {
+
+				TitleItem += '<li lay-id="' + item.id + '" class="layui-this"><span class="pear-tab-active"></span>';
+
+			} else {
+
+				TitleItem += '<li lay-id="' + item.id + '" ><span class="pear-tab-active"></span>';
+
+			}
+
+			if (item.close) {
+				// 当 前 选 项 卡 可 以 关 闭
+				TitleItem += '<span class="able-close">' + item.title + '</span>';
+			} else {
+				// 当 前 选 项 卡 不 允 许 关 闭
+				TitleItem += '<span class="disable-close">' + item.title + '</span>';
+			}
+
+			TitleItem += '<i class="layui-icon layui-unselect layui-tab-close">ဆ</i></li>';
+
+			title += TitleItem;
+
+
+			if (option.index == index) {
+
+				// 处 理 显 示 内 容
+				content += '<div class="layui-show layui-tab-item"><iframe id="' + item.id + '" data-frameid="' + item.id +
+					'"  src="' + item.url +
+					'" frameborder="no" border="0" marginwidth="0" marginheight="0" style="width: 100%;height: 100%;"></iframe></div>'
+
+			} else {
+
+				// 处 理 显 示 内 容
+				content += '<div class="layui-tab-item"><iframe id="' + item.id + '" data-frameid="' + item.id + '"  src="' +
+					item.url +
+					'" frameborder="no" border="0" marginwidth="0" marginheight="0" style="width: 100%;height: 100%;"></iframe></div>'
+
+			}
+			index++;
+		});
+
+		title += '</ul>';
+		content += '</div>';
+		control += '<dd id="closeThis"><a href="#">关 闭 当 前</a></dd>'
+		control += '<dd id="closeOther"><a href="#">关 闭 其 他</a></dd>'
+		control += '<dd id="closeAll"><a href="#">关 闭 全 部</a></dd>'
+		control += '</dl></li></ul></li></div>';
+
+		tab += title;
+		tab += control;
+		tab += content;
+		tab += '</div>';
+		tab += ''
+		return tab;
+	}
+
+	function rollPage(d, option) {
+		var $tabTitle = $('#' + option.elem + '  .layui-tab-title');
+
+		var left = $tabTitle.scrollLeft();
+
+		if ('left' === d) {
+
+			$tabTitle.animate({
+				scrollLeft: left - 450
+			}, 200);
+
+		} else {
+
+			$tabTitle.animate({
+				scrollLeft: left + 450
+			}, 200);
+		}
+	}
+
+	function closeEvent(option) {
+		$(".layui-tab[lay-filter='" + option.elem + "']").on("click", ".layui-tab-close", function() {
+			var layid = $(this).parent().attr("lay-id");
+			tabDelete(option.elem, layid, option.closeEvent);
+		})
+	}
+
+	function toolEvent(option) {
+
+		$("body .layui-tab[lay-filter='" + option.elem + "']").on("click", "#closeThis", function() {
+			var currentTab = $(".layui-tab[lay-filter='" + option.elem + "'] .layui-tab-title .layui-this");
+			if (currentTab.find("span").is(".able-close")) {
+				var currentId = currentTab.attr("lay-id");
+				tabDelete(option.elem, currentId, option.closeEvent);
+			}
+
+		})
+
+		$("body .layui-tab[lay-filter='" + option.elem + "']").on("click", "#closeOther", function() {
+			var currentId = $(".layui-tab[lay-filter='" + option.elem + "'] .layui-tab-title .layui-this").attr("lay-id");
+			var tabtitle = $(".layui-tab[lay-filter='" + option.elem + "'] .layui-tab-title li");
+			$.each(tabtitle, function(i) {
+				if ($(this).attr("lay-id") != currentId) {
+					if ($(this).find("span").is(".able-close")) {
+						tabDelete(option.elem, $(this).attr("lay-id"), option.closeEvent);
+					}
+				}
+			})
+		})
+
+		$("body .layui-tab[lay-filter='" + option.elem + "']").on("click", "#closeAll", function() {
+			var currentId = $(".layui-tab[lay-filter='" + option.elem + "'] .layui-tab-title .layui-this").attr("lay-id");
+			var tabtitle = $(".layui-tab[lay-filter='" + option.elem + "'] .layui-tab-title li");
+			$.each(tabtitle, function(i) {
+				if ($(this).find("span").is(".able-close")) {
+					tabDelete(option.elem, $(this).attr("lay-id"), option.closeEvent);
+				}
+			})
+		})
+	}
+
+	exports(MOD_NAME, new pearTab());
+})

+ 162 - 0
fangchan_manager/src/main/resources/static/pear/module/tag.js

@@ -0,0 +1,162 @@
+layui.define('jquery', function(exports){
+  "use strict";
+  
+  var $ = layui.$
+  ,MOD_NAME = 'tag',
+  TAG_CLASS = '.tag',
+  BUTTON_NEW_TAG ='button-new-tag',
+  INPUT_NEW_TAG ='input-new-tag',
+  TAG_ITEM ='tag-item',
+  CLOSE = 'tag-close',
+  DEFAULT_SKIN ='layui-btn layui-btn-primary layui-btn-sm'
+  ,tag = function(){
+    this.config = {
+      likeHref:'../../modules/tag.css',
+      skin: DEFAULT_SKIN,
+      tagText:'+ New Tag'
+    };
+    this.configs = {}
+  };
+  
+  //全局设置
+  tag.prototype.set = function(options){
+    var that = this;
+    $.extend(true, that.config, options);
+    tag.render();
+    return that;
+  };
+  
+  //表单事件监听
+  tag.prototype.on = function(events, callback){
+    return layui.onevent.call(this, MOD_NAME, events, callback);
+  };
+  
+  //外部Tag新增
+  tag.prototype.add = function(filter, options){
+    var tagElem = $(TAG_CLASS + '[lay-filter='+ filter +']')
+    call.add(null, tagElem, options);
+    call.tagAuto(filter);
+    return this;
+  };
+  
+  //外部Tag删除
+  tag.prototype.delete = function(filter, layid){
+    var tagElem = $(TAG_CLASS + '[lay-filter='+ filter +']')
+    ,tagItemElem = tagElem.find('>.' + TAG_ITEM + '[lay-id="'+ layid +'"]');
+    call.delete(null, tagItemElem);
+    return this;
+  };
+
+  //基础事件体
+  var call = {
+    //Tag点击
+    tagClick: function(e, index, tagItemElem, options){
+      options = options || {};
+      var othis = tagItemElem || $(this)
+      ,index = index || othis.index(othis)
+      ,parents = othis.parents(TAG_CLASS).eq(0)
+      ,filter = parents.attr('lay-filter');
+      layui.event.call(this, MOD_NAME, 'click('+ filter +')', {
+        elem: parents
+        ,index: index
+      });
+    }
+    //Tag新增事件
+    ,add: function(e, tagElem, options){
+      var  filter = tagElem.attr('lay-filter'),
+           buttonNewTag = tagElem.children('.' + BUTTON_NEW_TAG),
+           index = buttonNewTag.index()
+          ,newTag = '<button lay-id="'+ (options.id||'') +'"' +(options.attr ? ' lay-attr="'+ options.attr +'"' : '') +' type="button" class="' + TAG_ITEM  + '">'+ (options.text||'unnaming') +'</button>';
+      var result = layui.event.call(this, MOD_NAME, 'add('+ filter +')', {
+        elem: tagElem
+        ,index: index
+        ,othis: newTag
+      })
+      if(result === false) return;
+      buttonNewTag[0] ? buttonNewTag.before(newTag) : tagElem.append(newTag);
+    }
+    //Tag输入事件
+    ,input: function(e, othis){
+      var buttonNewTag = othis || $(this)
+      ,parents = buttonNewTag.parents(TAG_CLASS).eq(0)
+      ,filter = parents.attr('lay-filter')
+      var options = tag.configs[filter] = $.extend({}, tag.config, tag.configs[filter] || {}, options);
+      //标签输入框
+      var inpatNewTag = $('<div class="' + INPUT_NEW_TAG + '"><input type="text" autocomplete="off" class="layui-input"></div>');
+      inpatNewTag.addClass(options.skin);
+      buttonNewTag.after(inpatNewTag).remove();
+      inpatNewTag.children('.layui-input').on('blur', function () {
+        if(this.value){
+          var options = {
+            text: this.value
+          }
+          call.add(null, parents, options);
+        }
+        inpatNewTag.remove();
+        call.tagAuto(filter);
+      }).focus();
+    }
+    //Tag删除
+    ,delete: function(e, othis){
+      var tagItem = othis || $(this).parent(), index = tagItem.index()
+      ,parents = tagItem.parents(TAG_CLASS).eq(0)
+      ,filter = parents.attr('lay-filter');
+
+      var result = layui.event.call(this, MOD_NAME, 'delete('+ filter +')', {
+        elem: parents
+        ,index: index
+      })
+      if(result === false) return;
+      tagItem.remove()
+    }
+    //Tag 自适应
+    ,tagAuto: function(filter){
+      filter = filter || '';
+      var options = filter ? tag.configs[filter] || tag.config : tag.config;
+      var elemFilter = function(){
+        return filter ? ('[lay-filter="' + filter +'"]') : '';
+      }();
+      $(TAG_CLASS + elemFilter).each(function(){
+        var othis = $(this),tagItem = othis.children('.' + TAG_ITEM), buttonNewTag = othis.children('.' + BUTTON_NEW_TAG);
+        tagItem.removeClass(DEFAULT_SKIN).addClass(options.skin);
+        //允许关闭
+        if(othis.attr('lay-allowClose') && tagItem.length){
+          tagItem.each(function(){
+            var li = $(this);
+            if(!li.find('.'+CLOSE)[0]){
+              var close = $('<i class="layui-icon layui-unselect '+ CLOSE +'">&#x1006;</i>');
+              close.on('click', call.delete);
+              li.append(close);
+            }
+          });
+        }
+        //允许新增标签
+        if(othis.attr('lay-newTag') && buttonNewTag.length === 0){
+          buttonNewTag = $('<button type="button" class="' + BUTTON_NEW_TAG + '"></button>');
+          buttonNewTag.on('click', call.input);
+          othis.append(buttonNewTag);
+        }
+        buttonNewTag.html(options.tagText);
+        buttonNewTag.removeClass(DEFAULT_SKIN).addClass(options.skin);
+      });
+    }
+  };
+  
+  //初始化元素操作
+  tag.prototype.init = function(filter, options){
+    layui.addcss(tag.config.likeHref);
+    if(filter){
+      tag.configs[filter] = $.extend({}, tag.config, tag.configs[filter] || {}, options);
+    }
+    return call.tagAuto.call(this, filter);
+  };
+  
+  tag.prototype.render = tag.prototype.init;
+
+  var tag = new tag(), dom = $(document);
+  tag.render();
+
+  dom.on('click', '.' + TAG_ITEM, call.tagClick); //tag 单击事件
+  exports(MOD_NAME, tag);
+});
+

Some files were not shown because too many files changed in this diff