1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- $(function () {
- let url = `http://8.135.106.227:8004/`
- let gName = 'Gridtable'
- let grtable = document.querySelector("#gridtb")
- grtable.GM({
- gridManagerName: gName,
- height: '400px',
- ajaxData: function (setting) {
- // 传入分页及排序的配置项
- return getList(Object.assign({}, setting.pageData, setting.sortData));
- },
- ajaxType: "POST",
- supportCheckbox:false,
- supportAjaxPage: true,
- useNoTotalsMode: true,
- columnData: [
- {
- key: "code",
- text: "硬件编号",
- },
- {
- key: "devTypeName",
- text: "硬件状态",
- },
- {
- key: "name",
- text: "热点名字",
- },
- ,{
- key: 'id',
- width: '100px',
- align: 'center',
- text: '查看',
- template: function(username){
- var titleNode = document.createElement('div');
- // titleNode.attr('href', `https://www.lovejavascript.com/#!zone/blog/content.html?id=${rowObject.id}`);
- titleNode.setAttribute('title', username);
- titleNode.classList.add('plugin-action');
- titleNode.innerHTML = `<img src="./images/jiantou2.png" alt="">`;
- return titleNode
- }
- },
- ],
- });
- // 阻止冒泡
- $('.hardware-list').on('click keydown keyup keypress',function (event) {
- event.stopPropagation();
- })
- //点击前往查看
- $(grtable).on('click', '.plugin-action', function(e) {
- const row = GridManager.getRowData(gName, e.currentTarget.parentElement.parentElement);
- console.log(row);
- });
- let getList = function(params) {
- return new Promise((resolve, reject) => {
- $.ajax({
- method: 'GET',
- headers: {
- 'Content-Type': 'application/json'
- },
- dataType: 'json',
- contentType: 'application/json',
- url: url + '/api/device/list',
- success: function(data) {
- console.log(data);
- if (data.code === 0) {
- resolve({
- ...data,
- totals:data.data.length
- });
- }
- else {
- reject(data);
- }
- }
- })
- })
- };
- })
|