1 Star 1 Fork 0

贺强 / royui

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
Artistic-2.0

royui

概述

royui 是一款简单、高效、灵活的 js web 框架,很符合开发者使用习惯。目前有 treetable、分页、水印、时间段选择 插件,作者还在努力编写其它插件,欢迎各位志同道合的朋友一起参与。

适用场景

  • 网站
  • web 应用

当前版本

  • V2.1.0

表格树插件

  • 1 需要引入的 js 文件: jquery.js、layer.js、royui.js
  • 2 参数介绍
let r = new royui();
r.treeTable({
	elem: '#treeTable',     // 容器
	url: 'http://localhost/data.php',     // url ajax模式
	method: 'post',     // url模式请求方式
	where: {'param1': 'value1'},     // url请求参数
	data: $data,     // 直接赋值数据,初始化会优先使用此模式,$data数据两个特别属性:tip:此属性是鼠标悬停在图标列文字上时的提示   has_children:此属性标识此行是否有子项, 若没有子项则不显示图标, 如果没有此属性就是普通的表格
	is_cache: true,     // 是否缓存,默认是
	method: 'post',
	checkbox: true,
	cols: [ // 列参数
		{
			field: 'name',     // 数据字段名
			title: '姓名',     // 表头列名称
			title_style: 'text-align:left',     // 表头列样式
			style: 'width: 300px',     // 数据列样式
        	        is_sort: true,      // 是否支持排序
                        className: '',      // 列的样式类名
                        data: 'id',         // 给列添加 data-id 属性,默认值为当前列的字段名对应的值
                        type: 'select',     // 列的值显示控件类型,select-下拉框,text-文本框,checkbox-复选框,normal-直接显示
			template: function(row){}     // 自定义显示内容
		},
		{
			title: '操作',     // 表头列名称
			action: [{'matter': 'info|details','url': '#','method': 'popup|self','area': ['300px','400px']}, 'hide': {field: '字段名', 'field_value': [字段值]}],     // matter:操作按钮类型(info或details是详情,edit或modify是编辑,delete或del是删除)   url:操作访问的链接   method: 操作链接打开方式(popup是弹窗打开,self是在本窗口打开)  hide: 满足条件隐藏此按钮
			template: function (row){},     // 自定义显示内容,连接action按钮一起显示
			site: 'front|after'     // 自定义内容显示位置,front:在action按钮前  after:在action按钮后
		}
	],
        sort_field: 'ctime',        // 排序字段名
        sort_type: 'desc',          // 排序方式,默认倒序
	tree: {
		iconIndex: 0,     // 图标列的索引
		primary_key: 'id',     // 主键名称,默认id
		icon: '',     // 折叠图标,有默认,可不填
		loading_type: 'circle'     // 动态加载数据时 loading 图标样式, 可选 line: 线状  circle: 圆圈状  默认圆圈状
	},
	paging: false,     // 列表页是否启用分页
	pages: 10,     // 总页数
	first_page: true,     // 是否开启首页按钮,可以设为自定义文字
	last_page: true,     // 是否开启尾页按钮,可以设为自定义文字
	next_page: true,     // 是否开启下一页按钮,可以设为自定义文字
	prev_page: true,     // 是否开启上一页按钮,可以设为自定义文字
	total_page: true,     // 是否显示总页数
    jump_to: false,       // 是否显示跳转到
	checkbox: true,     // 是否显示复选框
	onSelected: function ($item,$obj) {},     // 选择行回调函数,$item是所选行的数据,$obj是所选行的标签
	onSelectAll: function () {},     // 全选回调函数
	onUpdated: function ($result,$obj) {},     // 修改成功后回调函数,$result是修改后的数据,$obj是所点击的修改按钮标签
	onDeleted: function ($result,$obj) {}     // 删除成功后回调函数,$result是删除参数,$obj是所点击的删除按钮标签
})

分页插件

  • 1 需要引入的 js 文件: jquery.js、layer.js、royui.js
  • 2 参数介绍
let r = new royui();
r.paging({
	elem: '#paging',			// 容器
	count: 123,					// 数据总条数
	page_size: 25,				// 每页显示多少条
	first_page: true,			// 是否显示首页按钮, 默认不显示, 可以设想要的文字
	prev_page: '上页',			// 是否显示上一页按钮, 默认不显示, 可以设为想要的文字
	next_page: true,			// 是否显示下一页按钮, 默认不显示, 可以设为想要的文字
	last_page: true,			// 是否显示尾页按钮, 默认不显示, 可以设为想要的文字
	show: 5,					// 页码按钮数量, 默认 5 个
	show_total: false,			// 是否显示总条数, 默认显示
	jump_to: true				// 是否显示跳转框, 默认不显示
})

水印方法

  • 1 需要引入的 js 文件: royui.js
  • 2 参数介绍
let r = new royui();
r.watermark({
    watermark_txt: '某某公司',      // 水印文字
    watermark_x: 20,                // 水印起始位置x轴坐标
    watermark_y: 20,                // 水印起始位置Y轴坐标
    watermark_rows: 0,              // 水印行数
    watermark_cols: 0,              // 水印列数
    watermark_x_space: 100,         // 水印x轴间隔
    watermark_y_space: 50,          // 水印y轴间隔
    watermark_color: '#aaaaaa',     // 水印字体颜色
    watermark_alpha: 0.3,           // 水印透明度
    watermark_fontsize: '16px',     // 水印字体大小
    watermark_font: '微软雅黑',     // 水印字体样式
    watermark_width: 210,           // 水印宽度
    watermark_height: 80,           // 水印长(高)度
    watermark_angle: 15,            // 水印倾斜度数
})

7*24时间段选择

  • 1 需引入的 js 文件:royui.js
  • 2 参数介绍
let r = new royui();
r.timequantum('.ttt')

上传插件

  • 1 需引入的 js 文件:jquery.js、royui.js
  • 2 参数介绍
let r = new royui()
r.upload({
    elem: $options.elem ?? undefined,   // 上传控件
    auto: $options.auto ?? true,        // 是否自动上传,默认true
    method: $options.message ?? 'post', // 上传请求方式,默认post
    fileType: $options.fileType ?? '*', // 可上传的文件类型,默认所有
    buttonText: $options.buttonText ?? 'Select Files',  // 选择文件按钮的文字
    buttonClass: $options.buttonClass ?? false,         // 选择文件按钮的样式类
    fileObjName: $options.fileObjName ?? 'Filedata',    // 上传请求参数名
    fileSizeLimit: $options.fileSizeLimit ?? '0',       // 上传文件大小限制,0为不限制
    multi: $options.multi ?? false,     // 是否可上传多个文件
    limit: $options.limit ?? 0,         // 上传文件个数限制
    formData: $options.formData ?? {},  // 发送给服务端的其它参数
    uploadScript: $options.uploadScript,    // 服务端地址
    onUploadComplete: $options.onUploadComplete ?? undefined,   // 上传成功后回调函数
    onError: $options.onError ?? undefined  // 上传出错回调函数
})

即时修改某字段

  • 需引入的 js 文件:jquery.js、layer.js、royui.js

html代码

  • <span class="edititem" data-type="text" data-name="name">姓名</span>
  • <span class="edititem" data-type="radio" data-url="update/sex" data-name="sex" data-values_url="服务端取可选值的url,以data-values为先" data-values='[{"value":1,"txt":"男"},{"value":2,"txt":"女"}]'>男</span>
  • <div class="edititem" data-type="select" data-url="update/age" data-name="age" data-values_url="服务端取可选值的url,以data-values为先" data-values='[{"value":"35","txt":"35"},{"value":"36","txt":"36"},{"value":"37","txt":"37"}]'>36</div>
  • 标签可以任选,data-type编辑控件类型, data-name发送到服务端的字段名, data-url服务端路由地址(也可以用插件属性的url), data-values若编辑控件为radio或select会用到此属性值(也可设置data-values_url从服务端取数据),数据格式必须为示例中展示的格式
let $r = new royui();
$r.edititem({
    elem: '.edititem',// 要实现编辑效果的控件
    url: 'update/item',// ajax 修改数据 URL,和控件的data-url属性必须有其一,以data-url为先
    param: {id: '111'},// 发送到服务端的参数({id: 'id值'}),必须至少有一项数据的标识
})
  • 接口返回的数据必须为json格式,状态码字段名可为status|code,成功可选值:0|200,状态描述字段message(可不要,默认提示语为“修改成功”|“修改失败”)
The Artistic License 2.0 Copyright (c) 2000-2006, The Perl Foundation. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble This license establishes the terms under which a given free software Package may be copied, modified, distributed, and/or redistributed. The intent is that the Copyright Holder maintains some artistic control over the development of that Package while still keeping the Package available as open source and free software. You are always permitted to make arrangements wholly outside of this license directly with the Copyright Holder of a given Package. If the terms of this license do not permit the full use that you propose to make of the Package, you should contact the Copyright Holder and seek a different licensing arrangement. Definitions "Copyright Holder" means the individual(s) or organization(s) named in the copyright notice for the entire Package. "Contributor" means any party that has contributed code or other material to the Package, in accordance with the Copyright Holder's procedures. "You" and "your" means any person who would like to copy, distribute, or modify the Package. "Package" means the collection of files distributed by the Copyright Holder, and derivatives of that collection and/or of those files. A given Package may consist of either the Standard Version, or a Modified Version. "Distribute" means providing a copy of the Package or making it accessible to anyone else, or in the case of a company or organization, to others outside of your company or organization. "Distributor Fee" means any fee that you charge for Distributing this Package or providing support for this Package to another party. It does not mean licensing fees. "Standard Version" refers to the Package if it has not been modified, or has been modified only in ways explicitly requested by the Copyright Holder. "Modified Version" means the Package, if it has been changed, and such changes were not explicitly requested by the Copyright Holder. "Original License" means this Artistic License as Distributed with the Standard Version of the Package, in its current version or as it may be modified by The Perl Foundation in the future. "Source" form means the source code, documentation source, and configuration files for the Package. "Compiled" form means the compiled bytecode, object code, binary, or any other form resulting from mechanical transformation or translation of the Source form. Permission for Use and Modification Without Distribution (1) You are permitted to use the Standard Version and create and use Modified Versions for any purpose without restriction, provided that you do not Distribute the Modified Version. Permissions for Redistribution of the Standard Version (2) You may Distribute verbatim copies of the Source form of the Standard Version of this Package in any medium without restriction, either gratis or for a Distributor Fee, provided that you duplicate all of the original copyright notices and associated disclaimers. At your discretion, such verbatim copies may or may not include a Compiled form of the Package. (3) You may apply any bug fixes, portability changes, and other modifications made available from the Copyright Holder. The resulting Package will still be considered the Standard Version, and as such will be subject to the Original License. Distribution of Modified Versions of the Package as Source (4) You may Distribute your Modified Version as Source (either gratis or for a Distributor Fee, and with or without a Compiled form of the Modified Version) provided that you clearly document how it differs from the Standard Version, including, but not limited to, documenting any non-standard features, executables, or modules, and provided that you do at least ONE of the following: (a) make the Modified Version available to the Copyright Holder of the Standard Version, under the Original License, so that the Copyright Holder may include your modifications in the Standard Version. (b) ensure that installation of your Modified Version does not prevent the user installing or running the Standard Version. In addition, the Modified Version must bear a name that is different from the name of the Standard Version. (c) allow anyone who receives a copy of the Modified Version to make the Source form of the Modified Version available to others under (i) the Original License or (ii) a license that permits the licensee to freely copy, modify and redistribute the Modified Version using the same licensing terms that apply to the copy that the licensee received, and requires that the Source form of the Modified Version, and of any works derived from it, be made freely available in that license fees are prohibited but Distributor Fees are allowed. Distribution of Compiled Forms of the Standard Version or Modified Versions without the Source (5) You may Distribute Compiled forms of the Standard Version without the Source, provided that you include complete instructions on how to get the Source of the Standard Version. Such instructions must be valid at the time of your distribution. If these instructions, at any time while you are carrying out such distribution, become invalid, you must provide new instructions on demand or cease further distribution. If you provide valid instructions or cease distribution within thirty days after you become aware that the instructions are invalid, then you do not forfeit any of your rights under this license. (6) You may Distribute a Modified Version in Compiled form without the Source, provided that you comply with Section 4 with respect to the Source of the Modified Version. Aggregating or Linking the Package (7) You may aggregate the Package (either the Standard Version or Modified Version) with other packages and Distribute the resulting aggregation provided that you do not charge a licensing fee for the Package. Distributor Fees are permitted, and licensing fees for other components in the aggregation are permitted. The terms of this license apply to the use and Distribution of the Standard or Modified Versions as included in the aggregation. (8) You are permitted to link Modified and Standard Versions with other works, to embed the Package in a larger work of your own, or to build stand-alone binary or bytecode versions of applications that include the Package, and Distribute the result without restriction, provided the result does not expose a direct interface to the Package. Items That are Not Considered Part of a Modified Version (9) Works (including, but not limited to, modules and scripts) that merely extend or make use of the Package, do not, by themselves, cause the Package to be a Modified Version. In addition, such works are not considered parts of the Package itself, and are not subject to the terms of this license. General Provisions (10) Any use, modification, and distribution of the Standard or Modified Versions is governed by this Artistic License. By using, modifying or distributing the Package, you accept this license. Do not use, modify, or distribute the Package, if you do not accept this license. (11) If your Modified Version has been derived from a Modified Version made by someone other than you, you are nevertheless required to ensure that your Modified Version complies with the requirements of this license. (12) This license does not grant you the right to use any trademark, service mark, tradename, or logo of the Copyright Holder. (13) This license includes the non-exclusive, worldwide, free-of-charge patent license to make, have made, use, offer to sell, sell, import and otherwise transfer the Package with respect to any patent claims licensable by the Copyright Holder that are necessarily infringed by the Package. If you institute patent litigation (including a cross-claim or counterclaim) against any party alleging that the Package constitutes direct or contributory patent infringement, then this Artistic License to you shall terminate on the date that such litigation is filed. (14) Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

简介

自己封装的 ui 插件 展开 收起
JavaScript 等 2 种语言
Artistic-2.0
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
JavaScript
1
https://gitee.com/roy_he/royui.git
git@gitee.com:roy_he/royui.git
roy_he
royui
royui
royui-2.1.0

搜索帮助