123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- Namespace.register("U.MD.O.E.KE");
- /*
- * excel键盘事件总控制函数
- */
- U.MD.O.E.KE.Control = function () {
- U.MD.O.E.KE.cellCut(); //ctrl + x剪切单元格
- U.MD.O.E.KE.cellTaste(); //ctrl + v粘贴单元格
- U.MD.O.E.KE.cellCopy(); //ctrl + c复制单元格
- U.MD.O.E.KE.clearContent(); //backspace删除单元格内容
- }
- /*
- * 复制单元格
- */
- U.MD.O.E.KE.cellCopy = function () {
- $(document).bind("keydown", function (event) {
- if (event.ctrlKey && event.keyCode == 67) {
- U.MD.O.E.RC.cellCopy();
- }
- })
- }
- /*
- * 粘贴单元格
- */
- U.MD.O.E.KE.cellTaste = function () {
- $(document).bind("paste", function (event) {
- var _content = U.UF.C.pasteText();
- var _arr = $$("div");
- _arr.innerHTML = _content;
- var _arrjson = {};
- var _arrcontent = [];
- _arrjson.tr = _arr.getElementsByTagName("tr").length;
- _arrjson.td = _arr.getElementsByTagName("td").length;
- _arrjson.age = _arr.getElementsByTagName("td").length / _arr.getElementsByTagName("tr").length;
- for (let i = 0; i < _arr.getElementsByTagName("td").length; i++) {
- _arrcontent.push(_arr.getElementsByTagName("td")[i].innerText);
- }
- U.MD.O.E.RC.cellTaste(_arrjson,_arrcontent);
- })
- }
- /*
- * 剪切单元格
- */
- U.MD.O.E.KE.cellCut = function () {
- $(document).bind("keydown", function (event) {
- if (event.ctrlKey && event.keyCode == 88) {
- U.MD.O.E.RC.cellCut();
- }
- })
- }
- /*
- * 删除单元格内容
- */
- U.MD.O.E.KE.clearContent = function () {
- $(document).bind("keydown", function (event) {
- if (event.keyCode == 8 || event.keyCode == 46) {
- U.MD.O.E.RC.clearContent();
- }
- })
- }
|