<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??一站式輕松地調用各大LLM模型接口,支持GPT4、智譜、豆包、星火、月之暗面及文生圖、文生視頻 廣告
                static\plugins\siyu-ui.js ``` /** * 通用js方法封裝處理 * Copyright (c) 2019 siyucms */ (function ($) { $.extend({ btTable: {}, // bootstrapTable // 表格封裝處理 table: { _option: {}, // 初始化表格參數 init: function(options) { // 默認參數 var defaults = { id: "bootstrap-table", height: undefined, // 表格的高度,一般不需要設置 sidePagination: "server", // server啟用服務端分頁client客戶端分頁 sortName: "id", // 排序列名稱 sortOrder: "desc", // 排序方式 asc 或者 desc escape: true, // 轉義HTML字符串 pagination: true, // 是否顯示分頁 pageSize: 10, // 每頁的記錄行數 showRefresh: true, // 是否顯示刷新按鈕 showToggle: true, // 是否顯示詳細視圖和列表視圖的切換按鈕 showFullscreen: true, // 是否顯示全屏按鈕 showColumns: true, // 是否顯示隱藏某列下拉框 search: false, // 是否顯示自帶的搜索框功能 showSearchButton: false, // 是否顯示自帶的搜索按鈕 pageList: [10, 25, 50, 100], // 每頁顯示的數量選擇 toolbar: "toolbar", // 自定義工具欄 toolbarAlign: "left", // 工具欄左對齊 buttonsClass: "", // 按鈕樣式 showFooter: false, // 顯示頁腳 showExport: false, // 顯示導出按鈕 clickToSelect: false, // 是否啟用點擊選中行 fixedColumns: false, // 是否啟用固定列功能 rowStyle: {}, // 設置行樣式 classes: 'table table-hover', // 設置表樣式 queryParams: $.table.queryParams, }; var options = $.extend(defaults, options); $.table._option = options; $.btTable = $('#' + options.id); // 初始化新事件對象的屬性 $.table.initEvent(); // 構建bootstrap數據 var option = { url: options.url, // 請求后臺的URL(*) height: options.height, // 表格的高度 sortable: true, // 是否啟用排序 sortName: options.sortName, // 排序列名稱 sortOrder: options.sortOrder, // 排序方式 asc 或者 desc sortStable: true, // 設置為 true 將獲得穩定的排序 method: 'post', // 請求方式(*) cache: false, // 是否使用緩存 contentType: "application/json", // 內容類型 dataType: 'json', // 數據類型 responseHandler: $.table.responseHandler, // 在加載服務器發送來的數據之前處理函數 pagination: options.pagination, // 是否顯示分頁(*) paginationLoop: true, // 是否禁用分頁連續循環模式 sidePagination: options.sidePagination, // server啟用服務端分頁client客戶端分頁 pageNumber: 1, // 初始化加載第一頁,默認第一頁 pageSize: options.pageSize, // 每頁的記錄行數(*) pageList: options.pageList, // 可供選擇的每頁的行數(*) search: options.search, // 是否顯示搜索框功能 showSearchButton: options.showSearchButton, // 是否顯示檢索信息 showColumns: options.showColumns, // 是否顯示隱藏某列下拉框 showRefresh: options.showRefresh, // 是否顯示刷新按鈕 showToggle: options.showToggle, // 是否顯示詳細視圖和列表視圖的切換按鈕 showFullscreen: options.showFullscreen, // 是否顯示全屏按鈕 showFooter: options.showFooter, // 是否顯示頁腳 escape: options.escape, // 轉義HTML字符串 clickToSelect: options.clickToSelect, // 是否啟用點擊選中行 toolbar: '#' + options.toolbar, // 指定工作欄 detailView: options.detailView, // 是否啟用顯示細節視圖 iconSize: 'undefined', // 圖標大小:undefined默認的按鈕尺寸 xs超小按鈕sm小按鈕lg大按鈕 rowStyle: options.rowStyle, // 通過自定義函數設置行樣式 showExport: options.showExport, // 是否支持導出文件 uniqueId: options.uniqueId, // 唯 一的標識符 fixedColumns: options.fixedColumns, // 是否啟用凍結列(左側) detailFormatter: options.detailFormatter, // 在行下面展示其他數據列表 columns: options.columns, // 顯示列信息(*) classes: options.classes, // 設置表樣式 queryParams: options.queryParams, // 傳遞參數(*) onDblClickRow: function (row, $element, field) { // 雙擊一行時觸發編輯動作 var edit = $element.children("td").last().html(); if ($.common.isNotEmpty(edit) && edit.indexOf('$.operate.edit') != -1) { $.operate.edit($element.data('uniqueid')); } } }; // 將tree合并到option[關閉分頁且傳遞父id字段才可以看到tree] if (option.pagination == false && $.common.isNotEmpty(options.parentIdField)) { // 構建tree var tree = { idField: options.uniqueId, treeShowField: options.uniqueId, parentIdField: options.parentIdField, rowStyle: function (row, index) { return classes = [ 'bg-blue', 'bg-green', 'bg-red' ]; }, onPostBody: function onPostBody() { var columns = $.btTable.bootstrapTable('getOptions').columns; if (columns) { // 查看是否默認展開 var initialState = 'collapsed'; if (typeof (Storage) !== 'undefined') { initialState = localStorage.getItem('initialState'); } $.btTable.treegrid({ //initialState: 'collapsed',// 所有節點都折疊 //initialState: 'expanded',// 所有節點都展開 initialState: initialState,// 所有節點都保留上次的效果 treeColumn: 1, // 默認為第三個 // expanderExpandedClass: 'glyphicon glyphicon-minus', //圖標樣式 // expanderCollapsedClass: 'glyphicon glyphicon-plus', onChange: function () { $.btTable.bootstrapTable('resetWidth'); } }); } }, }; $.extend(option, tree); } $.btTable.bootstrapTable(option); }, // 查詢條件 queryParams: function(params) { var curParams = { // 傳遞參數查詢參數 pageSize: params.limit, page: params.offset / params.limit + 1, searchValue: params.search, orderByColumn: params.sort, isAsc: params.order }; var currentId = $.common.isEmpty($.table._option.formId) ? 'search_form' : $.table._option.formId; return $.extend(curParams, $.common.formToJSON(currentId)); }, // 請求獲取數據后處理回調函數 responseHandler: function(res) { if (typeof $.table._option.responseHandler == "function") { $.table._option.responseHandler(res); } return { rows: res.data, total: res.total }; }, // 初始化事件 initEvent: function(data) { // 觸發行點擊事件 加載成功事件 $.btTable.on("check.bs.table uncheck.bs.table check-all.bs.table uncheck-all.bs.table load-success.bs.table", function () { // 工具欄按鈕控制 var rows = $.common.isEmpty($.table._option.uniqueId) ? $.table.selectFirstColumns() : $.table.selectColumns($.table._option.uniqueId); // 非多個禁用 $('#' + $.table._option.toolbar + ' .multiple').toggleClass('disabled', !rows.length); // 非單個禁用 $('#' + $.table._option.toolbar + ' .single').toggleClass('disabled', rows.length!=1); }); // 綁定選中事件、取消事件、全部選中、全部取消 $.btTable.on("check.bs.table check-all.bs.table uncheck.bs.table uncheck-all.bs.table", function (e, rows) { // 復選框分頁保留保存選中數組 var rowIds = $.table.affectedRowIds(rows); if ($.common.isNotEmpty($.table._option.rememberSelected) && $.table._option.rememberSelected) { func = $.inArray(e.type, ['check', 'check-all']) > -1 ? 'union' : 'difference'; selectionIds = _[func](selectionIds, rowIds); } }); }, // 表格銷毀 destroy: function (tableId) { var currentId = $.common.isEmpty(tableId) ? $.table._option.id : tableId; $("#" + currentId).bootstrapTable('destroy'); }, // 圖片預覽 imageView: function (value, height, width, target) { if ($.common.isEmpty(width)) { width = 'auto'; } if ($.common.isEmpty(height)) { height = 'auto'; } // blank or self var _target = $.common.isEmpty(target) ? 'self' : target; if ($.common.isNotEmpty(value)) { return $.common.sprintf("<img class='img-circle img-xs' data-height='%s' data-width='%s' data-target='%s' src='%s'/>", width, height, _target, value); } else { return $.common.nullToStr(value); } }, // 搜索-默認為 search_form search: function(formId, data) { var currentId = $.common.isEmpty(formId) ? 'search_form' : formId; var params = $.btTable.bootstrapTable('getOptions'); params.queryParams = function(params) { // 獲取所有搜索的form元素 var search = $.common.formToJSON(currentId); // 如傳遞data則追加進search中 if ($.common.isNotEmpty(data)) { $.each(data, function (key) { search[key] = data[key]; }); } search.pageSize = params.limit; search.page = params.offset / params.limit + 1; search.searchValue = params.search; search.orderByColumn = params.sort; search.isAsc = params.order; return search; } $.btTable.bootstrapTable('refresh', params); }, // 導出數據 export: function(formId) { $.modal.confirm("確定導出所有數據嗎?", function() { var currentId = $.common.isEmpty(formId) ? 'search_form' : formId; window.open($.table._option.exportUrl + '?' +$("#" + currentId).serialize()); }); }, // 設置排序 sort: function(obj) { var url = $.table._option.sortUrl; var data = {"id": $(obj).data('id'), "sort": $(obj).val()}; $.operate.submit(url, "post", "json", data); }, // 刷新表格 refresh: function() { $.btTable.bootstrapTable('refresh', { silent: true }); }, // 顯示表格指定列 showColumn: function(column) { $.btTable.bootstrapTable('showColumn', column); }, // 隱藏表格指定列 hideColumn: function(column) { $.btTable.bootstrapTable('hideColumn', column); }, // 查詢表格指定列值 selectColumns: function(column) { var rows = $.map($.btTable.bootstrapTable('getSelections'), function (row) { return row[column]; }); if ($.common.isNotEmpty($.table._option.rememberSelected) && $.table._option.rememberSelected) { rows = rows.concat(selectionIds); } return $.common.uniqueFn(rows); }, // 獲取當前頁選中或者取消的行ID affectedRowIds: function(rows) { var column = $.common.isEmpty($.table._option.uniqueId) ? $.table._option.columns[1].field : $.table._option.uniqueId; var rowIds; if ($.isArray(rows)) { rowIds = $.map(rows, function(row) { return row[column]; }); } else { rowIds = [rows[column]]; } return rowIds; }, // 查詢表格首列值 selectFirstColumns: function() { var rows = $.map($.btTable.bootstrapTable('getSelections'), function (row) { return row[$.table._option.columns[1].field]; }); if ($.common.isNotEmpty($.table._option.rememberSelected) && $.table._option.rememberSelected) { rows = rows.concat(selectionIds); } return $.common.uniqueFn(rows); }, }, // 表單封裝處理 form: { // 表單重置 reset: function(formId) { var currentId = $.common.isEmpty(formId) ? 'search_form' : formId; $("#" + currentId)[0].reset(); // 重置select2 $('select.select2').val(null).trigger("change"); // 刷新表格 $.btTable.bootstrapTable('refresh'); }, }, // 彈出層封裝處理 modal: { // 消息提示前顯示圖標(通常不會單獨前臺調用) icon: function (type) { var icon = ""; if (type == "warning") { icon = 0; } else if (type == "success") { icon = 1; } else if (type == "error") { icon = 2; } else { icon = 3; } return icon; }, // 消息提示(第一個參數為內容,第二個為類型,通過類型調用不同的圖標效果) [warning/success/error] msg: function(content, type) { if (type != undefined) { layer.msg(content, {icon: $.modal.icon(type), time: 1500, anim: 5, shade: [0.3]}); } else { layer.msg(content); } }, // 錯誤消息 msgError: function(content) { $.modal.msg(content, "error"); }, // 成功消息 msgSuccess: function(content) { $.modal.msg(content, "success"); }, // 警告消息 msgWarning: function(content) { $.modal.msg(content, "warning"); }, // 彈出提示 alert: function(content, type, callback) { layer.alert(content, { icon: $.modal.icon(type), title: "系統提示", btn: ['確認'], btnclass: ['btn btn-primary'], }, callback); }, // 錯誤提示 alertError: function(content, callback) { $.modal.alert(content, "error", callback); }, // 成功提示 alertSuccess: function(content, callback) { $.modal.alert(content, "success", callback); }, // 警告提示 alertWarning: function(content, callback) { $.modal.alert(content, "warning", callback); }, // 確認窗體 confirm: function (content, callBack) { layer.confirm(content, { icon: 3, title: "系統提示", btn: ['確認', '取消'] }, function (index) { layer.close(index); callBack(true); }); }, // 消息提示并刷新父窗體 msgReload: function(msg, type) { layer.msg(msg, { icon: $.modal.icon(type), time: 500, shade: [0.1, '#8F8F8F'] }, function() { $.modal.reload(); }); }, // 彈出層指定寬度 open: function (title, url, width, height, callback) { // 如果是移動端,就使用自適應大小彈窗 if (navigator.userAgent.match(/(iPhone|iPod|Android|ios)/i)) { width = 'auto'; height = 'auto'; } if ($.common.isEmpty(title)) { title = false; } if ($.common.isEmpty(width)) { width = 800; } if ($.common.isEmpty(height)) { height = ($(window).height() - 50); } if ($.common.isEmpty(callback)) { // 當前層索引參數(index)、當前層的DOM對象(layero) callback = function(index, layero) { //var iframeWin = layero.find('iframe')[0]; //iframeWin.contentWindow.submitHandler(index, layero); // 獲取彈出層中的form表單元素 var formSubmit=layer.getChildFrame('form', index); // 獲取表單中的提交按鈕(在我的表單里第一個button按鈕就是提交按鈕,使用find方法尋找即可) var submited = formSubmit.find('.form-builder-submit').find('button')[0]; // 觸發點擊事件,會對表單進行驗證,驗證成功則提交表單,失敗則返回錯誤信息 submited.click(); //window.parent.location.reload(); //location.reload(); } } layer.open({ // iframe層 type: 2, // 寬高 area: [width + 'px', height + 'px'], // 固定 fix: false, // 最大最小化 maxmin: true, // 遮罩 shade: 0, // 是否允許拖拽到窗口外 moveOut: true, // 標題 title: title, // 內容 content: url, // 按鈕 btn: ['確定', '關閉'], // 是否點擊遮罩關閉 shadeClose: true, // 確定按鈕回調方法 yes: callback, // 層彈出后的成功回調方法 success: function(layero, index){ //var body = layer.getChildFrame('body', index); //body.addClass('layer-body') //body.find('.main-sidebar').hide() //body.find('.main-header').hide() //body.find('.main-footer').hide() //body.find('.content-header').hide() //body.find('.content .search').hide() //body.find('.content-wrapper').hide() }, // 右上角關閉按鈕觸發的回調 cancel: function(index) { return true; } }); }, // 彈出層指定參數選項 openOptions: function (options) { var _url = $.common.isEmpty(options.url) ? "/404.html" : options.url; var _title = $.common.isEmpty(options.title) ? "系統窗口" : options.title; var _width = $.common.isEmpty(options.width) ? "800" : options.width; var _height = $.common.isEmpty(options.height) ? ($(window).height() - 50) : options.height; var _btn = ['<i class="fa fa-check"></i> 確認', '<i class="fa fa-close"></i> 關閉']; if ($.common.isEmpty(options.yes)) { options.yes = function(index, layero) { options.callBack(index, layero); } } layer.open({ type: 2, maxmin: true, shade: 0.3, title: _title, fix: false, area: [_width + 'px', _height + 'px'], content: _url, shadeClose: $.common.isEmpty(options.shadeClose) ? true : options.shadeClose, skin: options.skin, btn: $.common.isEmpty(options.btn) ? _btn : options.btn, yes: options.yes, cancel: function () { return true; } }); }, // 彈出層全屏 openFull: function (title, url, width, height) { //如果是移動端,就使用自適應大小彈窗 if (navigator.userAgent.match(/(iPhone|iPod|Android|ios)/i)) { width = 'auto'; height = 'auto'; } if ($.common.isEmpty(title)) { title = false; } if ($.common.isEmpty(url)) { url = "/404.html"; } if ($.common.isEmpty(width)) { width = 800; } if ($.common.isEmpty(height)) { height = ($(window).height() - 50); } var index = layer.open({ type: 2, area: [width + 'px', height + 'px'], fix: false, //不固定 maxmin: true, shade: 0.3, title: title, content: url, btn: ['確定', '關閉'], // 彈層外區域關閉 shadeClose: true, yes: function(index, layero) { var iframeWin = layero.find('iframe')[0]; iframeWin.contentWindow.submitHandler(index, layero); }, cancel: function(index) { return true; } }); layer.full(index); }, // 重新加載 reload: function () { parent.location.reload(); }, // 關閉窗體 close: function () { var index = parent.layer.getFrameIndex(window.name); parent.layer.close(index); }, }, // 操作封裝處理 operate: { // 修改信息 edit: function(id) { var url = $.operate.editUrl(id) if ($.table._option.layerOpen == "1") { // 通過參數隱藏左側和頂部等數據 if (url.indexOf('?') != -1) { url = url + '&_layer=1' } else { url = url + '?_layer=1' } // 彈窗打開要添加的地址 $.modal.open("修改", url); } else { // 當前窗口打開要添加的地址 $.common.jump(url); } }, // 修改訪問的地址 editUrl: function(id) { var url = ""; if ($.common.isNotEmpty(id)) { url = $.table._option.editUrl.replace("__id__", id); } else { var id = $.common.isEmpty($.table._option.uniqueId) ? $.table.selectFirstColumns() : $.table.selectColumns($.table._option.uniqueId); if (id.length == 0) { $.modal.alertWarning("請至少選擇一條記錄"); return; } url = $.table._option.editUrl.replace("__id__", id); } // 獲取搜索信息 var back = $.common.serializeRemoveNull($("#search_form").serialize()); back = back ? '&back_url=' + encodeURIComponent(back) : ''; return url + back; }, // 添加信息 add: function(id) { var url = $.operate.addUrl(id) if ($.table._option.layerOpen == "1") { // 通過參數隱藏左側和頂部等數據 if (url.indexOf('?') != -1) { url = url + '&_layer=1' } else { url = url + '?_layer=1' } // 彈窗打開要添加的地址 $.modal.open("添加", url); } else { // 當前窗口打開要添加的地址 $.common.jump(url); } }, // 添加訪問的地址 addUrl: function(id) { var url = $.common.isEmpty(id) ? $.table._option.addUrl.replace("__id__", "") : $.table._option.addUrl.replace("__id__", id); // 獲取搜索信息 var back = $.common.serializeRemoveNull($("#search_form").serialize()); if (url.indexOf('?') != -1) { back = back ? '&back_url=' + encodeURIComponent(back) : ''; } else { back = back ? '?back_url=' + encodeURIComponent(back) : ''; } return url + back; }, // 刪除信息 remove: function(id) { $.modal.confirm("確定刪除該條數據嗎?", function() { var url = $.common.isEmpty(id) ? $.table._option.delUrl : $.table._option.delUrl.replace("__id__", id); var data = { "id": id }; $.operate.submit(url, "post", "json", data); }); }, // 批量刪除信息 removeAll: function() { var rows = $.common.isEmpty($.table._option.uniqueId) ? $.table.selectFirstColumns() : $.table.selectColumns($.table._option.uniqueId); if (rows.length == 0) { $.modal.alertWarning("請至少選擇一條記錄"); return; } $.modal.confirm("確認要刪除選中的" + rows.length + "條數據嗎?", function() { var url = $.table._option.delUrl.replace("__id__", rows.join()); var data = { "id": rows.join() }; $.operate.submit(url, "post", "json", data); }); }, // 修改狀態 state: function(id, url) { $.modal.confirm("確認要更改狀態嗎?", function () { var data = {"id": id}; $.operate.submit(url, "post", "json", data); }); }, // 代碼生成 build: function(id, url) { $.modal.confirm("確定要生成代碼嗎?生成代碼會覆蓋原有的控制器、模型和驗證器文件<br>注意:原有文件會被重命名留做備份", function() { if ($.common.isEmpty(id)) { var id = $.common.isEmpty($.table._option.uniqueId) ? $.table.selectFirstColumns() : $.table.selectColumns($.table._option.uniqueId); if (id.length == 0) { $.modal.alertWarning("請至少選擇一條記錄"); return; } } var data = {"id": id[0]}; $.operate.submit(url, "post", "json", data); }); }, // 生成菜單規則 makeRule: function (url) { $.modal.confirm("確定要生成菜單規則嗎,我們會根據模塊的參數生成列表、新增、新增保存、修改、修改保存、刪除、批量刪除、導出、狀態、排序 等規則", function () { var id = $.table.selectFirstColumns(); if (id.length == 0) { $.modal.alertWarning("請至少選擇一條記錄"); return; } var data = {"id": id[0]}; $.operate.submit(url, "post", "json", data); }); }, // 數據庫備份+優化+修復 database: function(url, title) { var rows = $.common.isEmpty($.table._option.uniqueId) ? $.table.selectFirstColumns() : $.table.selectColumns($.table._option.uniqueId); if (rows.length == 0) { $.modal.alertWarning("請至少選擇一條記錄"); return; } $.modal.confirm("確認要" + title + "選中的" + rows.length + "條數據嗎?", function () { var data = { "id": rows.join() }; $.operate.submit(url, "post", "json", data); }); }, // 提交數據 submit: function(url, type, dataType, data, callback) { var config = { url: url, type: type, dataType: dataType, data: data, beforeSend: function () { // "正在處理中,請稍后..." }, success: function(result) { if (typeof callback == "function") { callback(result); } $.operate.ajaxSuccess(result); } }; $.ajax(config) }, // 保存信息 刷新表格 save: function(url, data, callback) { var config = { url: url, type: "post", dataType: "json", data: data, success: function(result) { if (typeof callback == "function") { callback(result); } $.operate.successCallback(result); } }; $.ajax(config) }, // 成功回調執行事件(父窗體靜默更新) successCallback: function(result) { if (result.code == 1) { var parent = window.parent; $.modal.close(); parent.toastr.success(result.msg); // toastr提示 // parent.$.modal.msgSuccess(result.msg); // 消息提示 parent.$.table.refresh(); } else { $.modal.alertError(result.msg); } }, // 保存結果彈出msg刷新table表格 ajaxSuccess: function (result) { if (result.error == 0 || result.code == 1) { toastr.success(result.msg); // toastr提示 //$.modal.msgSuccess(result.msg); // 消息提示 $.table.refresh(); } else { $.modal.alertError(result.msg); } }, // 展開/折疊列表樹 treeStatus: function (result) { // 上次展開則增加樣式 var initialState = 'collapsed'; if (typeof (Storage) !== 'undefined') { initialState = localStorage.getItem('initialState'); } if (initialState == 'expanded') { $('.treeStatus').addClass('expandAll'); } if ($('.treeStatus').hasClass('expandAll')) { $.btTable.treegrid('collapseAll'); $('.treeStatus').removeClass('expandAll'); // 更新 if (typeof (Storage) !== 'undefined') { localStorage.setItem('initialState', 'collapsed'); } } else { $.btTable.treegrid('expandAll'); $('.treeStatus').addClass('expandAll'); // 更新 if (typeof (Storage) !== 'undefined') { localStorage.setItem('initialState', 'expanded'); } } }, // 批量添加欄目 batchAdd: function(url) { if ($.table._option.layerOpen == "1") { // 通過參數隱藏左側和頂部等數據 if (url.indexOf('?') != -1) { url = url + '&_layer=1' } else { url = url + '?_layer=1' } // 彈窗打開要添加的地址 $.modal.open("批量添加", url); } else { // 當前窗口打開要添加的地址 $.common.jump(url); } }, }, // 通用方法封裝處理 common: { // 判斷字符串是否為空 isEmpty: function (value) { if (value == null || this.trim(value) == "") { return true; } return false; }, // 判斷一個字符串是否為非空串 isNotEmpty: function (value) { return !$.common.isEmpty(value); }, // 空格截取 trim: function (value) { if (value == null) { return ""; } return value.toString().replace(/(^\s*)|(\s*$)|\r|\n/g, ""); }, // 比較兩個字符串(大小寫敏感) equals: function (str, that) { return str == that; }, // 比較兩個字符串(大小寫不敏感) equalsIgnoreCase: function (str, that) { return String(str).toUpperCase() === String(that).toUpperCase(); }, // 將字符串按指定字符分割 split: function (str, sep, maxLen) { if ($.common.isEmpty(str)) { return null; } var value = String(str).split(sep); return maxLen ? value.slice(0, maxLen - 1) : value; }, // 字符串格式化(%s ) sprintf: function (str) { var args = arguments, flag = true, i = 1; str = str.replace(/%s/g, function () { var arg = args[i++]; if (typeof arg === 'undefined') { flag = false; return ''; } return arg; }); return flag ? str : ''; }, // 數組去重 uniqueFn: function(array) { var result = []; var hashObj = {}; for (var i = 0; i < array.length; i++) { if (!hashObj[array[i]]) { hashObj[array[i]] = true; result.push(array[i]); } } return result; }, // 獲取form下所有的字段并轉換為json對象 formToJSON: function(formId) { var json = {}; $.each($("#" + formId).serializeArray(), function(i, field) { json[field.name] = field.value; }); return json; }, // pjax跳轉頁 jump: function (url) { $.pjax({url: url, container: '.content-wrapper'}) //window.location.href = url; }, // 序列化表單,不含空元素 serializeRemoveNull: function (serStr) { // return serStr.split("&").filter(str => !str.endsWith("=")).join("&"); // 不兼容ie return serStr.split("&").filter(function (item) { var itemArr = item.split('='); if(itemArr[1]){ return item; } } ).join("&"); }, } }); })(jQuery); ``` \static\plugins\siyucms.js ``` // daterangepicker 動態元素追加后重新綁定(列表搜索) $(document).on('mouseover', "input[daterange='true']", function () { $(this).daterangepicker( { autoUpdateInput: false, // 自動填充日期 showDropdowns: true, // 年月份下拉框 timePicker: true, // 顯示時間 timePicker24Hour: true, // 時間制 timePickerSeconds: true, // 時間顯示到秒 ranges: { '今天': [moment(), moment()], '昨天': [moment().subtract(1, 'days'), moment().subtract(1, 'days')], '上周': [moment().subtract(6, 'days'), moment()], '前30天': [moment().subtract(29, 'days'), moment()], '本月': [moment().startOf('month'), moment().endOf('month')], '上月': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')], '今年第一天':moment().startOf('year').format('YYYY-MM-DD'), '去年第一天':moment().subtract(1,'year').startOf('year').format('YYYY-MM-DD') }, locale: { format: "YYYY/MM/DD", applyLabel: '確定', // 確定按鈕文本 cancelLabel: '取消', // 取消按鈕文本 customRangeLabel: '自定義', } } ).on('cancel.daterangepicker', function (ev, picker) { $(this).val(""); }).on('apply.daterangepicker', function (ev, picker) { $(this).val(picker.startDate.format('YYYY-MM-DD') + " 至 " + picker.endDate.format('YYYY-MM-DD')); }); }) // 列表圖片鼠標移上跟隨效果(兼容ajax分頁) $(document).on('mouseover', '.image_preview', function (e) { var image = $(this).attr("src"); if (image != "") { var zoomView = $('<img src="' + image + '" id="zoomView" />'); // 建立圖片查看框 $(this).after(zoomView); $("#zoomView").fadeIn(100); $("#zoomView").css({"top": (e.pageY - 250) + "px", "left": (e.pageX - 210) + "px"}); //注意得在CSS文件中將其設置為絕對定位 } }) $(document).on('mousemove', '.image_preview', function (e) { var image = $(this).attr("image"); if (image != "") { $("#zoomView").css({"top": (e.pageY - 250) + "px", "left": (e.pageX - 210) + "px"}); //鼠標移動時及時更新圖片查看框的坐標 } }) $(document).on('mouseout', '.image_preview', function (e) { var image = $(this).attr("image"); if (image != "") { $("#zoomView").remove(); //鼠標移出時刪除之前建立的圖片查看框 } }) // 常規表單提交轉變成ajax $(document).on("submit", 'form:not([data-pjax])', function () { var _this = $(this); // 判斷是否開啟了提交確認 if (typeof ($(this).attr("submit_confirm")) == "undefined") { // 不需要提交確認,直接提交表單 formSubmit(_this); } else { // 需要確認提示 $.modal.confirm('確定要提交嗎?', function () { formSubmit(_this); }) } return false; // 阻止表單默認提交 }) // 捐贈 $(document).on("click", '.juanzeng', function () { $.modal.open('捐贈', "/static/admin/images/shoukuan.png", 450, 533); }) // 多圖刪除 $(document).on('click', '.remove_images', function () { var remove = $(this).parent().parent().parent(); remove.remove(); }) // 多圖上移 $(document).on('click', '.move_up_images', function () { var move = $(this).parent().parent().parent(); move.prev().insertAfter(move); }) // 多圖下移 $(document).on('click', '.move_down_images', function () { var move = $(this).parent().parent().parent(); move.next().insertBefore(move); }) // 返回頂部顯示 $(window).scroll(function () { if (document.body.scrollTop > 100 || document.documentElement.scrollTop > 100) { $('#totop').fadeIn(500) } else { $('#totop').fadeOut(500) } }); // 返回頂部點擊 $(document).on("click", '#totop', function (e) { // 防止打開URL e.preventDefault(); $('html,body').animate({ scrollTop: 0 }, 300) }); // pjax 執行完成后執行的方法 $(document).on('pjax:complete', function () { // 首頁重新請求遠程ad if ($(".main_ad").length > 0) { $.getScript("https://www.siyucms.com/ad.js"); } // tag 標簽 if ($(".tags").length > 0) { $('.tags').tagsInput({ 'width': 'auto', 'height': 'auto', 'placeholderColor': '#666666', 'defaultText': '添加標簽', }); } // tooltip 提示 $('[data-toggle="tooltip"]').tooltip() // 更改網站標題 changeWebTitle(); }) $(function () { // 返回上一頁時重新觸發pjax,防止加載重復的bootstrap-table window.addEventListener("popstate", function (e) { $.pjax.reload('.content-wrapper'); }, false); // 左側菜單點擊 /*$(".main-sidebar .nav .nav-treeview a.nav-link").click(function () { if($(this).attr('link') !== '#'){ $(".main-sidebar .nav .nav-treeview a.nav-link").removeClass('active'); $(this).addClass('active'); $(this).parents('.nav-item').last().siblings().children('a').removeClass('active') $(this).parents('.nav-item').last().children('a').addClass('active') } })*/ // 左側菜單高亮 $('.main-sidebar .nav .nav-treeview a.nav-link').on('click', function () { if ($(this).attr('link') !== '#') { $(".main-sidebar .nav .nav-treeview a.nav-link").removeClass('active'); $(this).addClass('active'); $(this).parents('.nav-item').last().siblings().children('a').removeClass('active') $(this).parents('.nav-item').last().children('a').addClass('active') } // 小屏幕上點擊左邊菜單欄按鈕,模擬點擊 xs: 480,sm: 768,md: 992,lg: 1200 if ($(window).width() < 992) { // 觸發左邊菜單欄按鈕點擊事件,關閉菜單欄 $("[data-widget='pushmenu']").trigger('click'); } }); // 刷新后匹配當前URL和標題 $(window).on('load', function () { // 獲取當前頁面面包導航標題 var _title = $(".content-header").find("h1").clone(); _title.find(':nth-child(n)').remove(); if (_title.length > 0) { _title = _title.html().trim(); } // 循環匹配 $('.sidebar .nav-sidebar a.nav-link').each(function () { //$(this).children('p').find(':nth-child(n)').remove() var _html = $(this).children('p').html().replace("|—", "").replace(" ", "").trim() if (this.href !== '#' && _html == _title) { // 打開對應菜單 $(this).addClass('active') .closest('.nav-treeview').show() // 打開二級ul .closest('.has-treeview').addClass('menu-open') // 打開一級li .children('a.nav-link').addClass('active'); // 高亮一級a // 判斷當前所屬的是第幾個 var _index = $(this).parents('.nav-item').last().data('item') // 執行點擊動作 $(".js_left_menu li").eq(_index).click(); } }); // 改變網站標題 changeWebTitle(); }); // tag 標簽 if ($(".tags").length > 0) { $('.tags').tagsInput({ 'width': 'auto', 'height': 'auto', 'placeholderColor': '#666666', 'defaultText': '添加標簽', }); } // tooltip 提示 $('[data-toggle="tooltip"]').tooltip() // 多級聯動 $('.js_linkage').change(function () { var value = $(this).val(); // 當前下拉框選中的值 var nextLevelId = $(this).data('next_level_id'); // 下一級別下拉框的id var ajaxUrl = $(this).data('ajax_url'); // 請求地址 // 下級聯動菜單恢復默認 if (nextLevelId != '') { $('#' + nextLevelId).html('<option value="">' + $(this).data('placeholder') + '</option>'); var hasNextLevel = $('#' + nextLevelId).data('next_level_id'); if (hasNextLevel) { $('#' + hasNextLevel).html('<option value="">' + $(this).data('placeholder') + '</option>'); hasNextLevel = $('#' + hasNextLevel).data('next-next_level_id-id'); if (hasNextLevel) { $('#' + hasNextLevel).html('<option value="">' + $(this).data('placeholder') + '</option>'); } } } if (value != '') { // 獲取數據 $.ajax({ url: ajaxUrl, type: 'POST', dataType: 'json', data: { level: $(this).data('next_level'), // 下一級別(廢棄) pid: value, // 當前下拉框選中的值 model: $(this).data('model'), // 模型名稱 key: $(this).data('key'), // 關聯模型的主鍵 keyValue: $(this).data('key_value'), // 要展示的字段 pidFieldName: $(this).data('pid_field_name'), // 關聯模型的父級id字段名 }, success: function (res) { if (res.code == '1') { var list = res.list; if (list) { for (var item in list) { $('#' + nextLevelId).append("<option value='" + list[item].key + "'>" + list[item].value + "</option>"); } } } else { $.modal.alertError(res.msg); } } }) } }); }) // ============================================= // 表單提交 function formSubmit($this) { $this.ajaxSubmit(function (result) { var url = window.location.href; if (url.indexOf("_layer=1") >= 0) { // layer 彈層 $.operate.successCallback(result); } else { // 普通提交跳轉 if (result.code == 1) { // 提交成功 $.modal.alertSuccess(result.msg, function (index) { layer.close(index); $.common.jump(result.url); }); } else { // 提交失敗 $.modal.alertError(result.msg); } } }); } // pjax 刷新當前頁 function pjaxReplace(url) { $.pjax({url: url, container: '.content-wrapper'}) } // 轉換日期格式(時間戳轉換為datetime格式) function changeDateFormat(cellval) { if (cellval == '') { return '-'; } if (cellval != null && cellval != undefined) { if (cellval.toString().indexOf("-") >= 0) { return cellval; } } var dateVal = cellval * 1000; if (cellval != null) { var date = new Date(dateVal); var month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1; var currentDate = date.getDate() < 10 ? "0" + date.getDate() : date.getDate(); var hours = date.getHours() < 10 ? "0" + date.getHours() : date.getHours(); var minutes = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes(); var seconds = date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds(); return date.getFullYear() + "-" + month + "-" + currentDate + " " + hours + ":" + minutes + ":" + seconds; } } // pjax 改變網站標題 function changeWebTitle() { // 獲取當前頁的名稱 var _title = $(".content-header").find("h1").clone(); _title.find(':nth-child(n)').remove(); if (_title.length > 0) { _title = _title.html().trim(); } else { _title = ''; } // 獲取網站標題 var title = $(document).attr('title').split(' | '); // 設置網站標題 if (title[1] != _title && $.common.isNotEmpty(_title)) { $(document).attr('title', title[0] + ' | ' + _title); } } // 拆分字符串為數組并判斷是否包含某個元素 function checkValInStr(val, str) { var strArr = str.toString().split(','); if ($.inArray(val, strArr) >= 0) { return true; } else { return false; } } ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看