You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
1.8 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

// 测试用例
// changeLayuiTableCellContent("tableZhuanYe",0,2,"zhuanye_jihua_code","黄海的测试值","<a href=#>黄海的测试值</a>");
//声明本地存储器
var storage = window.localStorage;
//已经存在的人员id array
var exist_person_id_array = "exist_person_id_array";
//选择后的人员id array
var select_person_id_array = "select_person_id_array";
//封装了将指定id的layui的table进行指定行和列单元格的修改
window.changeLayuiTableCellContent = function (table_id, row, col, value, html) {
//找到表的索引
var table_index = 0;
$(".layui-table-body.layui-table-main").each(function (i, n) {
if ($(this).parent().parent().attr("lay-id") === table_id) {
table_index = i;
//相当于break
return false;
}
});
//指定表格id的行选择器
var trSelector = '.layui-table-body.layui-table-main:eq(' + table_index + ') tr';
//找到指定的单元格
var td = $(trSelector + ":eq(" + row + ") td:eq(" + col + ")");
var field_name = $(td[0]).attr("data-field");
//修改一下内容
td.html(html);
//数据修改为content
//内存中的数据
var data = layui.table.cache[table_id];
data[row][field_name] = value;
};
//扩展从上一页获取get方式参数的方法
window.GetQueryString = function (name, istop) {
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
var r = window.location.search.substr(1).match(reg);
if (typeof (istop) != "undefined") r = top.location.search.substr(1).match(reg);
if (r != null) return unescape(r[2]);
return null;
};
//获取cookie
window.getCookie = function (name) {
var arr, reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)");
if (arr = document.cookie.match(reg))
return unescape(arr[2]);
else
return null;
};