/* * Author: 众产® https://ciy.cn/code * Version: 0.2.0 */ //卡片列表 类库 ciyclass.cardtable = function (opn) { this.dom = $5(opn.dom); if (this.dom.length == 0) return ciyfn.alert('未找到容器'); this.listdom = $5('ul.list', this.dom); if (this.listdom.length == 0) return ciyfn.alert('未找到ul.list容器'); var _pagedom = $5('.page', this.dom); var thos = this; this.cachecount = -1; //缓存总条数 this.pathname = opn.pathname || location.pathname.replace(".html", ""); this.data = {}; //id为索引的object var localset = ciyfn.getstorage('_t_' + this.pathname, {}); this.pageno = 1; this.nodatatext = opn.nodatatext || '暂无数据'; if (opn.url === undefined) return this.showtip('数据源URL未设置'); this.post = {}; this.post.once = true; this.post.pagecount = localset.pagecount || opn.pagecount || 12; this.post.query = ciyfn.urlparam(); if (opn.query) this.post.query = Object.assign(this.post.query, opn.query); if (opn.post) this.post = Object.assign(this.post, opn.post); ciyfn._table_eventpage(_pagedom, this); ciyfn._table_dragitem(this.dom, opn); this.listdom.on('scroll', function () { ciyfn.lazyimg(); }); this.callpage = function (page, scroll) { if (page === undefined) page = this.pageno; this.post.pageno = toint(page, 1); if (this.post.pageno < 1) return; this.pageno = this.post.pageno; this.post.count = this.cachecount; ciyfn.callfunc(opn.url, this.post, function (json) { thos.post.once = false; thos.json = ciyfn.objdeepmerge(thos.json, json); if (json.once) thos.once = json.once; if (typeof (opn.fn_beforedata) == 'function') json = opn.fn_beforedata(json); if (json.count > -1) thos.cachecount = json.count; else if (thos.cachecount > -1) json.count = thos.cachecount; var html = ''; for (var i = 0; i < json.list.length; i++) { var ldat = json.list[i]; thos.data[ldat['id']] = ldat; html += opn.fn_lihtml(ldat, i); } if (json.list.length == 0 && toint(json.pageno) <= 1) html += '
  • ' + ciyfn.lang(thos.nodatatext) + '
  • '; thos.listdom.html(html).show(); if (scroll) thos.listdom.scroll({ top: 0 }); $5('.loading', thos.dom).remove(); if (typeof (opn.fn_done) == 'function') opn.fn_done(json, thos.post); ciyfn.lazyimg(); ciyfn.domlang(); ciyfn._table_fillpage(_pagedom, json, false); }); } this.updateline = function (json, newdata) { if (!json.data) return; var ids = json.ids; if (!ids) ids = [json.data.id]; var newdata = ciyfn.objclone(json.data); delete json.data; this.json = ciyfn.objdeepmerge(this.json, json); for (var i = 0; i < ids.length; i++) { var id = ids[i]; if (id == 0) return; this.data[id] = ciyfn.objdeepmerge(this.data[id], newdata); this.data[id].id = id; var htmltr = opn.fn_lihtml(this.data[id]); var tr = $5('[data-id="' + id + '"]', this._tabdom); if (tr.length > 0) tr.outhtml(htmltr); else { $5('ul.list', this._tabdom).prepend(htmltr); this.rowtotal(1); $5('[data-none]', this._tabdom).remove(); } } if (typeof (opn.fn_done) == 'function') opn.fn_done(this.json, this.post); } this.delline = function (json) { if (!json.ids) return; var rowcnt = 0; for (var i = 0; i < json.ids.length; i++) { var id = json.ids[i]; if (this.data[id]) { delete this.data[id]; var tr = $5('[data-id="' + id + '"]', this._tabdom); if (tr.length > 0) { rowcnt--; tr.remove(); } } } var tr = $5('[data-id]', this._tabdom); if (tr.length == 0) { this.cachecount = -1; this.callpage(); } else this.rowtotal(rowcnt); } this.rowtotal = function (num) { num = toint(num); if (!num) return; var rowdom = $5('#id_rowtotal', this.dom); rowdom.text(toint(rowdom.text()) + num); } //供页面搜索组件调用 this.search = function (dom, act) { var form = ciyfn.getform(dom); thos.post.query = form; if (act == 'li') thos.post.query.liid = dom.getAttribute('data-liid'); else { var domli = dom.querySelector('li.active[data-liid]'); if (domli !== null) thos.post.query.liid = domli.getAttribute('data-liid'); } if (ciyfn.throttle(dom)) return; thos.cachecount = -1; thos.callpage(1); } } //表格列表 类库 ciyclass.table = function (opn) { this.dom = $5(opn.dom); if (this.dom.length == 0) return ciyfn.alert('未找到容器'); this.listdom = $5('div.list', this.dom); if (this.listdom.length == 0) return ciyfn.alert('未找到div.list容器'); this.pathname = opn.pathname || location.pathname.replace(".html", ""); var localset = ciyfn.getstorage('_t_' + this.pathname, {}); opn.btncolumnset = opn.btncolumnset || 1; opn.nodatatext = opn.nodatatext || '暂无数据'; opn.domid = 'table_' + Math.floor(Math.random() * 1000); this.dom.attr('id', opn.domid); var _pagedom = $5('.page', this.dom); var thos = this; this._tabdom = null;//table dom this.field = {}; //字段属性 this.sortfield = []; //字段列排序 this.pageno = 1; this.cachecount = -1; //缓存总条数 this.data = {}; //id为索引的object this.post = {}; this.post.once = true; this.post.pagecount = localset.pagecount || opn.pagecount || 20; this.post.query = ciyfn.urlparam(); if (opn.query) this.post.query = Object.assign(this.post.query, opn.query); if (opn.post) this.post = Object.assign(this.post, opn.post); var dataready = true; ciyfn._table_eventpage(_pagedom, this); this.listdom.on('scroll', function () { ciyfn.lazyimg(); }); this.callpage = function (page, scroll) { if (!dataready) return ciyfn.toast('数据处理中,请稍后操作'); if (opn.url === undefined) return ciyfn.toast('数据源URL未设置'); if (page === undefined) page = this.pageno; this.post.pageno = toint(page, 1); if (this.post.pageno < 1) return; this.pageno = this.post.pageno; this.post.count = this.cachecount; this.post.field = toint(this.dom.attr('_field')) == 0; ciyfn.callfunc(opn.url, this.post, function (json) { if (typeof (opn.fn_beforedata) == 'function') json = opn.fn_beforedata(json); thos.post.once = false; if (json.once) thos.once = json.once; thos.json = ciyfn.objdeepmerge(thos.json, json); if (json.count > -1) thos.cachecount = json.count; else if (thos.cachecount > -1) json.count = thos.cachecount; thos.filldata(json, scroll); }); } this.updateline = function (json) { if (!json.data) return; var ids = json.ids; if (!ids) ids = [json.data.id]; var newdata = ciyfn.objclone(json.data); delete json.data; this.json = ciyfn.objdeepmerge(this.json, json); for (var i = 0; i < ids.length; i++) { var id = ids[i]; if (id == 0) return; this.data[id] = ciyfn.objdeepmerge(this.data[id], newdata); this.data[id].id = id; var htmltr = this.tabletr_html(this.data[id]); var tr = $5('[data-id="' + id + '"]', this._tabdom); if (tr.length > 0) tr.html(htmltr); else { $5('[data-field]', this._tabdom).after(htmltr); this.rowtotal(1); $5('[data-none]', this._tabdom).remove(); } } if (typeof (opn.fn_done) == 'function') opn.fn_done(this.json, this.post); } this.delline = function (json) { if (!json.ids) return; var rowcnt = 0; for (var i = 0; i < json.ids.length; i++) { var id = json.ids[i]; if (this.data[id]) { delete this.data[id]; var tr = $5('[data-id="' + id + '"]', this._tabdom); if (tr.length > 0) { rowcnt--; tr.remove(); } } } var tr = $5('[data-id]', this._tabdom); if (tr.length == 0) { this.cachecount = -1; this.callpage(); } else this.rowtotal(rowcnt); } this.rowtotal = function (num) { num = toint(num); if (!num) return; var rowdom = $5('#id_rowtotal', this.dom); rowdom.text(toint(rowdom.text()) + num); } this.filldata = function (json, scroll) { var html; if (json.field) { this.field = json.field; this.dom.attr('_field', 1); var index = 0; thos.sortfield = []; var sortfields = localset.thsort || json.fshow; if (sortfields) { thos.sortfield = sortfields.split(','); } else { for (var key in thos.field) { thos.sortfield.push(key); } } html = ''; if (opn.chkbox) html += ''; for (var ki in thos.sortfield) { var key = thos.sortfield[ki]; if (!thos.field[key].c) continue; var colname = thos.field[key].c; var colhide = false; if (colname[0] == '#') {//默认隐藏列设置 colhide = true; colname = colname.substring(1); } var colext = ''; if (colname[0] == ',') {//列表不显示 var ind = colname.indexOf(',', 1); if (ind > 0) { colext = colname.substring(ind + 1); } colname = ''; } else { var ind = colname.indexOf(','); if (ind > 0) { colext = colname.substring(ind + 1); colname = colname.substring(0, ind); } } var ind = colext.indexOf(' //'); if (ind > 0) colext = colext.substring(0, ind).trim(); thos.field[key].ext = colext; //var ind2 = colext.indexOf(','); //thos.field[key].exdata = ind2 > -1 ? colext.substring(ind2 + 1) : ''; //处理字段名称两侧竖线,代表数据对齐方式。|状态| thos.field[key].align = 'left'; if (colname.substring(colname.length - 1) == '|') { if (colname.substring(0, 1) == '|') { colname = colname.substring(1, colname.length - 1); thos.field[key].align = 'center'; } else { colname = colname.substring(0, colname.length - 1); thos.field[key].align = 'right'; } } if (colname.substring(0, 1) == '|') colname = colname.substring(1); if (colname.length == 0) continue; html += ''; } html += '
      0) html += ' data-ext="' + colext + '"'; if (colhide) html += ' data-hide="1"'; html += ' data-align="' + thos.field[key].align + '">'; if (typeof (opn.thfield) == 'function') { var fieldbk = opn.thfield(colname, key, thos.field[key], json); if (fieldbk) html += fieldbk; else html += ciyfn.lang(colname); } else html += ciyfn.lang(colname); if (opn.help && opn.help[key]) { html += ''; } if (thos.field[key].order !== undefined) { var style = ''; if (thos.field[key].order == 'r') style = ' style="right:0.5em;"'; html += ''; html += ''; } html += '
    '; this.listdom.html(html).show('up', 0.5); thos._tabdom = $5('table', this.listdom); $5('.loading', this.dom).remove(); table_adjust(); ciyfn._table_dragitem(this.dom, opn); this.dom.on('click', 'i[data-order]', function (e) {//点击排序 var orderdom = $5(e.currentTarget); if (orderdom.hasClass('db')) return; if (orderdom.hasClass('js')) { thos.post.query = thos.post.query || {}; thos.post.query.order = orderdom.attr('data-order'); thos.callpage(1); return; } $5('th>i.sort', thos.dom).removeClass('js').removeClass('db'); orderdom.addClass('sort').addClass('js'); var trdoms = $5('[data-id]', thos.dom); var ani = new ciyclass.anidom(trdoms, 'data-id'); var arr = []; for (var i = 0; i < trdoms.length; i++) { arr.push(trdoms[i]); } var fod = (orderdom.attr('data-order').indexOf(' desc') > 0); var findex = e.currentTarget.parentNode.getAttribute('data-index'); arr.sort(function (div1, div2) { //Intl var val1 = div1.querySelector('td:nth-child(' + findex + ')').getAttribute('data'); var val2 = div2.querySelector('td:nth-child(' + findex + ')').getAttribute('data'); if (/^(-?\d*)(\.\d+)?$/.test(val1) && /^(-?\d*)(\.\d+)?$/.test(val2)) { if (fod) return tofloat(val2) - tofloat(val1); else return tofloat(val1) - tofloat(val2); } else { if (fod) return val2.localeCompare(val1, "zh"); else return val1.localeCompare(val2, "zh"); } }); for (var i = 0; i < arr.length; i++) thos._tabdom.append(arr[i]); thos._tabdom.append($5('[data-none]', thos.dom)); ani.animate(); }); } if (this._tabdom == null) return; $5('[data-id]', this._tabdom).remove(); $5('[data-none]', this._tabdom).remove(); html = ''; var colspan = thos.sortfield.length; if (opn.chkbox) colspan++; if (json.list) { for (var i = 0; i < json.list.length; i++) { var ldat = json.list[i]; ldat._idx = i; this.data[ldat['id']] = ldat; html += this.tabletr_html(ldat); } if (json.list.length == 0 && json.pageno == 1) html += '' + ciyfn.lang(opn.nodatatext) + ''; } else { html += '' + ciyfn.lang("等待操作") + ''; } ciyfn._table_fillpage(_pagedom, json, opn.btncolumnset == 1); $5('th>i.sort', this.dom).removeClass('js').removeClass('db'); if (json.searchwhere) { $5('i[data-order="' + json.searchwhere.order + '"]', this.dom).addClass('sort').addClass('db'); } dataready = false; pubhtml(html); if (scroll) this.listdom.scroll({ top: 0 }); function pubhtml(htmlshow) { var ind = htmlshow.indexOf(' -1) { htmlappend = htmlshow.substring(ind); setTimeout(function () { console.log('pubhtml', htmlappend.length); pubhtml(htmlappend); }, 100); thos._tabdom.append(htmlshow.substring(0, ind)); return; } thos._tabdom.append(htmlshow); dataready = true; thos._shcolumn(localset); if (typeof (opn.fn_done) == 'function') opn.fn_done(json, thos.post); setTimeout(function () { ciyfn.lazyimg(); }, 1000); } } this.tabletr_html = function (ldat) { var html = '
    ' + (fdata.datashow || datashow) + '
    '; } else { if (typeof (fdata) == 'string') datashow = fdata; html += '
    ' + datashow + '
    '; } } html += ''; return html; } //调整表格列宽。 function table_adjust() { var localset = ciyfn.getstorage('_t_' + thos.pathname, {}); var thdoms = $5('th', thos._tabdom); var txtstyle = ''; if (isobj(localset.thwidth)) { for (var field in localset.thwidth) { txtstyle += "#" + opn.domid + " [field=\"" + field + "\"] > div { max-width: initial;width: " + localset.thwidth[field] + ";}"; } } else { for (var i = 0; i < thdoms.length; i++) { if (!thdoms[i].style.width) continue; txtstyle += "#" + opn.domid + " [field=\"" + thdoms[i].getAttribute('data-field') + "\"] > div { max-width: initial;width: " + thdoms[i].style.width + ";}"; } } for (var i = 0; i < thdoms.length; i++) { thdoms[i].style.width = null; } var tabstyle = document.createElement('style'); thos.dom.append(tabstyle); if (txtstyle) { tabstyle.innerText = txtstyle; } if (thos.dom[0].scrollWidth <= thos.dom[0].clientWidth) thos.dom[0].style.borderRight = null; else thos.dom[0].style.borderRight = '1px solid var(--bg6)'; var dodrag = null; $5(thos._tabdom).on("mousedown", 'th', function (ev) { if (dodrag == null) return; ev.preventDefault(); var field = dodrag.getAttribute('data-field'); var sheet = tabstyle.sheet || tabstyle.styleSheet || {}; var rules = sheet.cssRules || sheet.rules; dodrag.opstyle = null; for (var i = 0; i < rules.length; i++) { var item = rules[i]; if (item.selectorText !== ("#" + opn.domid + " [field=\"" + field + "\"] > div")) continue; dodrag.opstyle = item; break; } if (dodrag.opstyle == null) { var i = 0; if ("insertRule" in sheet) i = sheet.insertRule("#" + opn.domid + " [field=\"" + field + "\"] > div{max-width: initial;}", 0); else if ("addRule" in sheet) i = sheet.addRule("#" + opn.domid + " [field=\"" + field + "\"] > div", "max-width: initial;"); dodrag.opstyle = rules[i]; } dodrag.mouseDown = true; }); $5(thos._tabdom).on("mouseup", function (ev) { if (dodrag == null) return; dodrag.mouseDown = false; dodrag = null; var sheet = tabstyle.sheet || tabstyle.styleSheet || {}; var rules = sheet.cssRules || sheet.rules; var thobj = {}; for (var i = 0; i < rules.length; i++) { var arr = /field="([^"]+)"/.exec(rules[i].selectorText); thobj[arr[1]] = rules[i].style.width; } var localset = ciyfn.getstorage('_t_' + thos.pathname, {}); localset.thwidth = thobj; ciyfn.setstorage('_t_' + thos.pathname, localset); }); $5(thos._tabdom).on("mousemove", 'th', function (ev) { if (dodrag != null && dodrag.mouseDown) { dodrag.opstyle.style.width = (ev.clientX - dodrag.oset - dodrag.getBoundingClientRect().left) + "px"; if (thos.listdom[0].scrollWidth <= thos.listdom[0].clientWidth) thos.listdom[0].style.borderRight = null; else thos.listdom[0].style.borderRight = '1px solid var(--bg6)'; return; } if (ev.target.nodeName != 'TH') return; if (ev.target.clientWidth - ev.offsetX < 8) { dodrag = ev.target; dodrag.oset = ev.offsetX - ev.target.clientWidth; ev.target.style.cursor = 'col-resize'; } else { if (dodrag != null) { dodrag.style.cursor = null; } dodrag = null; if (ev.offsetX < 8) { dodrag = ev.target.previousElementSibling; if (dodrag != null) { dodrag.oset = ev.offsetX; ev.target.style.cursor = 'col-resize'; } } else { ev.target.style.cursor = null; } } }); } this._shcolumn = function (localset, trselector) { trselector = trselector || 'tr[data-id]'; var thdoms = $5('th', thos._tabdom); var fieldids = []; for (var i = 0; i < thdoms.length; i++) { var bshow = true; if (localset.thhide) { if (localset.thhide.indexOf(thdoms[i].getAttribute('data-field')) > -1) bshow = false; } else if (thdoms[i].getAttribute('data-hide') === '1') bshow = false; fieldids.push(bshow); thdoms[i].style.display = bshow ? null : "none"; } var trdoms = $5(trselector, thos.dom); for (var x = 0; x < trdoms.length; x++) { var tddoms = $5('td', trdoms[x]); if (tddoms.length < 2) continue; for (var i = 0; i < tddoms.length; i++) { if (fieldids[i]) tddoms[i].style.display = null; else tddoms[i].style.display = "none"; if (tddoms[i].getAttribute('field') == '_btn') continue; var txt = tddoms[i].textContent; if (txt && txt.length * 14 > tddoms[i].getBoundingClientRect().width) tddoms[i].setAttribute('title', txt); } } } this.filltable = function (html, scroll) { this.listdom.html(html).show(); if (scroll) this.listdom.scroll({ top: 0 }); $5('.loading', this.dom).remove(); } //供页面搜索组件调用 this.search = function (dom, act) { var form = ciyfn.getform(dom); thos.post.query = form; if (act == 'li') thos.post.query.liid = dom.getAttribute('data-liid'); else { var domli = dom.querySelector('li.active[data-liid]'); if (domli !== null) thos.post.query.liid = domli.getAttribute('data-liid'); } //Object.assign(thos.post, form); //ES6 if (ciyfn.throttle(dom)) return; thos.cachecount = -1; thos.callpage(1); } this.tree = function () { thos.dom.on("click", '.exfold', function (ev) { thos.dom.find('div[data-treeid][data-deep=0]').trigger('click'); }); thos.dom.on("click", 'div[data-treeid]', function (ev) { var treedom = $5(ev.currentTarget); treedom.toggleClass('ciy-tree-spread'); var id = treedom.attr('data-treeid'); var min = 99999; var max = 0; var trdoms = thos.dom.find('tr'); thos.dom.find('tr[data-upid="' + id + '"]').each(function (e) { var index = trdoms.index(e); if (min > index) min = index; if (max < index) max = index; }); while (true) { var mmax = max; var n = toint(trdoms.eq(max).attr('data-id')); $5('tr[data-upid="' + n + '"]').each(function (e) { var index = trdoms.index(e); if (max < index) max = index; }); if (mmax == max) break; } var open = false; if (treedom.hasClass('ciy-tree-spread')) open = true; for (var i = min; i <= max; i++) { if (open) { trdoms.eq(i).show('', 0, 'table-row'); trdoms.eq(i).find('[data-treeid]').addClass('ciy-tree-spread'); } else { trdoms.eq(i).hide(); trdoms.eq(i).find('[data-treeid]').removeClass('ciy-tree-spread'); } } }); } //列合并,列排序后,竖向合并相同内容单元格 this.mergecol = function (key) { var trs = thos._tabdom.find('tr[data-id]'); var tds = []; var txt = null; for (var i = 0; i < trs.length; i++) { var td = $5(trs[i]).find('td[field="' + key + '"]'); var tdtxt = td.text(); if (txt === null) txt = tdtxt; if (txt == tdtxt) { tds.push(td); } else { txt = tdtxt; merge(tds); tds = [td]; } } merge(tds); function merge(tds) { if (tds.length == 0) return; if (tds.length == 1) return tds[0].css('background', 'var(--bg3)'); tds[0].attr('rowspan', tds.length).css('background', 'var(--bg3)'); for (var i = 1; i < tds.length; i++) { tds[i].remove(); } } } //任意合并 this.mergefix = function (html, align, col1, row1, col2, row2) { var td = this._tabdom.find('tr').eq(col1).find('td').eq(row1); td.html(html).css('textAlign', align); for (var c = col2; c >= col1; c--) { for (var r = row2; r >= row1; r--) { if (c == col1 && r == row1) continue; this._tabdom.find('tr').eq(c).find('td').eq(r).remove(); } } if (col1 < col2) td.attr('rowspan', col2 - col1 + 1); if (row1 < row2) td.attr('colspan', row2 - row1 + 1); } //挂接汇总数据 this.footertotal = function () { if (thos.data.length == 0) return; ciyfn.callfunc('total', thos.post, function (json) { var html = ''; $5('th', thos._tabdom).each(function (dom) { var key = dom.getAttribute('data-field'); var field = thos.field[key]; html += '
    '; if (key == '_btn') { html += '
    汇总
    '; } else if (json.total[key] !== undefined) { if (json.total[key][0] == '_') html += json.total[key].substring(1); else html += ciyfn.tdshow(key, json.total[key], field.ext, json.total, json); } html += '
    '; }); html += ''; thos._tabdom.append(html); thos._shcolumn(localset, 'tr[data-id],tr[data-none]'); }); } } ciyfn.fillsearch = function (opn) { opn.data = opn.data || {}; var urlp = ciyfn.urlparam(); opn.more = (opn.more === undefined ? true : opn.more); if (isobj(opn.data.searchwhere)) { for (var w in opn.data.searchwhere) { if (!opn.data.searchwhere[w]) continue; if (w == 'liid') { $5('li[data-liid]', '.search').removeClass('active'); $5('li[data-liid="' + opn.data.searchwhere[w] + '"]', '.search').addClass('active'); } else if (w) $5('[sechr=' + w + ']', '.search').val(opn.data.searchwhere[w]); } } if (!opn.data.once || !opn.data.searchinput) return; if (opn.lidata) { opn.lidata = ciyfn.filterdictdata(ciyfn.getdictdata(opn.lidata, opn.data), { limit: opn.lilimit , filter: opn.lifilter , rename: opn.lirename , all: opn.liall }); var uldom = $5('ul', opn.searchdom); var html = ''; for (var i in opn.lidata) { html += '
  • ' + opn.lidata[i].name + '
  • '; } uldom.html(html); uldom.on('click', 'li', function (ev) { $5('.active', uldom).removeClass('active'); var lidom = $5(ev.currentTarget); lidom.addClass('active'); if (typeof (opn.liclick) == 'function') opn.liclick(ev.currentTarget); }); } var inpsdom = $5('.sinps', opn.dom); if (inpsdom.length == 0) return console.warn('search input not found'); inpsdom.children().remove(); for (var idx in opn.data.searchinput) { var html = ''; var sp = opn.data.searchinput[idx]; var name = sp.form; if (sp.type == 'hidden') { html = ''; inpsdom.append(html); continue; } html += '
    '; if (sp.name) html += ''; html += '
    '; var val; val = sp.def || ''; if (urlp[sp.form]) val = urlp[sp.form]; var prop = ''; var seldata = []; if (sp.prop) prop = ' ' + sp.prop; if (sp.type == 'input') html += ''; else if (sp.type == 'num') html += ' - '; else if (sp.type == 'select' || sp.type == 'radio') { if (sp.type == 'select') html += ''; if (sp.type == 'radio') html += ''; sp.def = sp.def || ''; seldata = ciyfn.filterdictdata(ciyfn.getdictdata(sp.select, opn.data), { limit: sp.limit , first: sp.first , filter: sp.filter , rename: sp.rename , all: sp.all }); } else if (sp.type == 'switch') { var vals = sp.value; if (typeof (vals) == 'string') vals = vals.split(','); else { vals[0] = vals[0].name; if (vals[1]) vals[1] = vals[1].name; } if (vals.length == 1) vals[1] = ' '; html += ''; } else if (sp.type == 'daterange') { html += ''; } else if (sp.type == 'month') { html += ''; } else if (sp.type == 'day') { html += ''; } else { html += 'type错误:' + sp.type + ''; } if (sp.behind) html += sp.behind; html += '
    '; inpsdom.append(html); if (sp.type == 'select' || sp.type == 'radio') { ciycmp({ dom: '[com=' + name + ']', range: seldata }); } if (sp.type == 'switch' || sp.type == 'daterange' || sp.type == 'month' || sp.type == 'day') { ciycmp({ dom: '[com=' + name + ']' }); } } if (opn.more) { //如果高度超过,则折叠,并且在sinps后加展开按钮 var rect = inpsdom.rect(); if (rect.height > 50) { inpsdom.css('height', '3em').css('overflow', 'hidden').attr('data-height', rect.height + 'px'); var moredom = $5('
    🔽
    '); moredom.on('click', '.smore', function (e) { if (inpsdom.css('height') == '3em') { $5(e.currentTarget).css('transform', 'rotate(180deg)'); inpsdom.css('height', inpsdom.attr('data-height')); } else { $5(e.currentTarget).css('transform', ''); inpsdom.css('height', '3em'); } }); inpsdom.after(moredom); } } } ciyfn.select_all = function (table) { $5('[data-id]', table.dom).each(function (dom) { $5(dom).addClass("selected"); }); } ciyfn.select_diff = function (table) { $5('[data-id]', table.dom).each(function (dom) { $5(dom).toggleClass("selected"); }); } ciyfn.select_callfunc = function (table, dombtn, funcname, confirmmsg, postparam, successfunc) { if (ciygv._clickduptime) return; postparam = postparam || {}; var array = []; $5('[data-id]', table.dom).each(function (dom) { if ($5(dom).hasClass("selected")) array.push($5(dom).attr("data-id")); }); postparam.ids = array.join(","); if (postparam.ids == "") return ciyfn.toast("请至少选择一条信息"); if (confirmmsg) { ciyfn.alert(ciyfn.lang(confirmmsg).replace(/{n}/g, '' + array.length + ''), function (altopn) { altopn.close(); postparam = Object.assign(postparam, altopn.inputs); if (altopn.btn == "继续") { callfunc(funcname, postparam, successfunc); } }, { btns: ["继续", "*取消"] }); } else { callfunc(funcname, postparam, successfunc); } function callfunc(funcname, postparam, successfunc) { if (typeof (funcname) == 'function') { funcname(postparam.ids); } else { if (ciyfn.throttle(dombtn)) return; ciyfn.callfunc(funcname, postparam, function (json) { $5('[data-id]', table.dom).removeClass("selected"); if (typeof (successfunc) === "function") successfunc(json); else location.reload(); }); } } } ciyfn._table_eventpage = function (_pagedom, thos) { if (_pagedom.length == 0) return; document.addEventListener('keydown', function (e) { var keyCode = e.keyCode || e.which; if (e.ctrlKey && keyCode === 37) { if (ciyfn.callfrequency(2)) return; $5('.pageprev', _pagedom).trigger('click'); } else if (e.ctrlKey && keyCode === 39) { if (ciyfn.callfrequency(2)) return; $5('.pagenext', _pagedom).trigger('click'); } }); _pagedom.on('keydown', function (e) { if (e.keyCode != 13) return; if (e.target.name == 'topage') { thos.callpage(e.target.value); } if (e.target.name == 'pcount') { var localset = ciyfn.getstorage('_t_' + thos.pathname, {}); localset.pagecount = toint(e.target.value); if (localset.pagecount < 2) { ciyfn.removestorage('_t_' + thos.pathname); location.reload(); return; } ciyfn.setstorage('_t_' + thos.pathname, localset); thos.post.pagecount = localset.pagecount; thos.callpage(1); } }); _pagedom.on('click', 'a', function (e) { var act = e.currentTarget.getAttribute('data-act'); if (act == 'pagego') { if (ciyfn.throttle(e.currentTarget)) return; thos.callpage($5('input[name="topage"]', _pagedom).val(), true); } else if (act == 'fulltable') { if (thos.dom.css('position') == 'fixed') { ciyfn.sendsignal(window.top, 'manage_fulldiv', { full: true }); thos.dom.css({ position: null, top: null, left: null, right: null, bottom: null, zIndex: null }); } else { ciyfn.sendsignal(window.top, 'manage_fulldiv', { full: false }); thos.dom.css({ position: 'fixed', top: '0', left: '1em', right: '1em', bottom: '0.5em', zIndex: 20 }); } } else if (act == 'columnset') { var localset = ciyfn.getstorage('_t_' + thos.pathname, {}); var thdoms = $5('th', thos._tabdom); var range = []; var values = []; for (var i = 0; i < thdoms.length; i++) { var key = thdoms[i].getAttribute('data-field'); if (key === null) continue; range.push({ id: key, name: thdoms[i].textContent }); if (isarray(localset.thhide)) { if (localset.thhide.indexOf(key) == -1) values.push(key); } else if (thdoms[i].getAttribute('data-hide') !== '1') values.push(key); } var sorted = false; var html = ''; html += '
    请选择需要显示/隐藏的列
    '; html += ''; html += '
    '; ciyfn.alert({ title: '显示隐藏列操作' , width: 'mb' , content: html , fn_showed: function (doc, dom) { ciycmp({ dom: $5('[com=sh]', dom), value: values.join(','), range: range }); var chkdom = dom[0].querySelector('ciy-checkbox>div'); for (var i = 0; i < chkdom.children.length; i++) { chkdom.children[i].setAttribute('draggable', true); } ciyclass.dragdom({ dom: chkdom , key: 'data-id' , fn_sort: function () { sorted = true; } }); } , btns: ["!重置", "确定", "*关闭"] , cb: function (altopn) { if (altopn.btn == '关闭') return altopn.close();; if (altopn.btn == '重置') { ciyfn.removestorage('_t_' + thos.pathname, {}); altopn.close(); location.reload(); return; } var nos = altopn.inputs.sh_noid.split(','); localset.thhide = []; for (var noi in nos) localset.thhide.push(nos[noi]); if (sorted) { var sfields = []; altopn.dom.find('.ciy-checkbox').each(function (dom, idx) { sfields.push(dom.getAttribute('data-id')); }); localset.thsort = sfields.join(','); } ciyfn.setstorage('_t_' + thos.pathname, localset); altopn.close(); if (sorted) return location.reload(); thos._shcolumn(localset); ciyfn.lazyimg(); } }); } else { if (ciyfn.throttle(e.currentTarget)) return; thos.callpage(e.currentTarget.getAttribute('data-page'), true); } }); } ciyfn._table_fillpage = function (_pagedom, json, btncolumnset) { if (_pagedom.length == 0) return; var showpages = 3; var pagemax; if (json.count > -1) pagemax = Math.ceil(json.count / json.pagecount); else if (json.list.length < json.pagecount) { pagemax = json.pageno; } else { pagemax = json.pageno + showpages; } html = '
    '; if (json.count > -1) html += '' + json.count + '' + ciyfn.lang('条') + ' '; html += ''; html += ciyfn.lang('条/页') + '
    '; if (json.pageno > 1) { html += '<<'; html += '<'; } var spage = 1; if (json.pageno > showpages) spage = json.pageno - showpages; var epage = pagemax; if (json.pageno < pagemax - showpages) epage = json.pageno + showpages; for (var i = spage; i <= epage; i++) { if (i == json.pageno) html += '' + i + ''; else html += '' + i + ''; } if (json.pageno < pagemax) { html += '>'; html += '>>'; } if (pagemax > showpages) html += 'GO'; if (btncolumnset) html += ''; html += ''; _pagedom.html(html); } ciyfn._table_dragitem = function (dom, opn) { dom.on('mousedown', '[data-id]', function (e) { if (opn.chkbox) { if (e.target.className != 'chkbox') return; } else { if (e.target.parentNode.nodeName != 'TD' && e.target.parentNode.nodeName != 'TR') return; } var itemdom = $5(e.currentTarget); var _table_dataid = itemdom.attr('data-id'); if (_table_dataid > 0) { if (!itemdom.hasattr('noselect')) itemdom.toggleClass('selected'); } dom.on('mousemove', '[data-id]', function (e) { e.stopPropagation(); var mdom = $5(e.currentTarget); var newtrid = mdom.attr('data-id'); if (_table_dataid == newtrid) return; _table_dataid = newtrid; if (newtrid > 0) { if (!itemdom.hasattr('noselect')) mdom.toggleClass('selected'); } if ("getSelection" in window) window.getSelection().removeAllRanges(); else document.selection.empty(); }); $5(document).one('mouseup', function (e) { _table_dataid = -1; dom.off('mousemove'); }); }); } ciyfn.conv_treerow = function (rows, upid, deep) { var ret = []; var cnt = rows.length; for (var i = 0; i < cnt; i++) { if (rows[i].upid != upid) continue; var subrows = ciyfn.conv_treerow(rows, rows[i]['id'], deep + 1); rows[i]['_count'] = subrows.length; rows[i]['_deep'] = deep; ret.push(rows[i]); ret = ret.concat(subrows); } if (deep == 0) { for (var i = 0; i < cnt; i++) { if (rows[i]['_deep'] === undefined) { rows[i]['_count'] = 0; rows[i]['_deep'] = 0; ret.push(rows[i]); } } } return ret; } ciyfn.table_multiin = function (func, html, fn_success) { ciyfn.alert({ title: '导入新数据' , width: 'pc' , content: html , fn_showed: function (doc, dom) { ciycmp({ dom: $5('[com=file]', dom), path: 'tmp', type: 'xlsx', stor: '/', showwh: '160px' }); } , btns: ["导入预览", "*关闭"] , cb: function (opn) { if (opn.btn == '关闭') return opn.close(); if (!opn.inputs.file) return ciyfn.toast('未上传文件'); opn.close(); if (ciyfn.throttle(opn.dombtn)) return; ciyfn.callfunc(func + '_in', opn.inputs, function (json) { ciyfn.alert({ title: '导入新数据' , width: 'max' , height: 'max' , content: json.html , btns: ['执行操作', '*关闭'] , cb: function (opn) { if (opn.btn == '关闭') return opn.close(); if (json.count == 0) return ciyfn.alert('无数据可导入'); var errtit = $5('td[title]', opn.dom); if (errtit.length > 0) { var html = '发现' + errtit.length + '条错误。'; for (var i = 0; i < errtit.length; i++) { html += '
    ' + errtit[i].getAttribute('title'); } return ciyfn.alert(html); } ciyfn.callfunc(func + '_data', opn.inputs, function (json) { opn.close(); if (typeof (fn_success) == 'function') fn_success(json); }); } }); }); } }); } ciyfn.table_exportxls = function (func, table, fn_success) { ciyfn.alert({ content: '确认导出符合已查询的数据?' , btns: ["导出", "*关闭"] , cb: function (opn) { if (opn.btn == "关闭") return opn.close(); ciyfn.callfunc(func, table.post, function (json) { opn.close(); if (typeof (fn_success) == 'function') fn_success(json); }); } }); } ciyfn.tonumunit = function (num, bet, pstr, defunit, data) { var ind = pstr.indexOf(','); if (ind > -1) { defunit = pstr.substring(ind + 1); pstr = pstr.substring(0, ind); } if (data && data[defunit]) defunit = data[defunit]; num = num / bet; var unitarr = defunit.split('|'); var u1 = toint(unitarr[1]); var u2 = toint(unitarr[3]); var unit = unitarr[0]; if (u1 > 0 && u2 > 0) { if (num >= u1 * u2) { num = num / u1 / u2; unit = unitarr[4]; } else if (num >= u1) { num = num / u1; unit = unitarr[2]; } } else if (u1 > 0) { if (num >= u1) { num = num / u1; unit = unitarr[2]; } } var cns = (ciyfn.tofix(num, toint(pstr)) + '').split('.'); var ret = cns[0].replace(/\d{1,3}(?=(\d{3})+$)/g, '$&,'); if (cns.length > 1) ret += '.' + cns[1] + ' '; ret += ciyfn.lang(unit); return ret; } ciyfn.tonumbet = function (num, fixlen, bet, unit) { var unitarr = unit.split('.'); var betarr = bet.split('.'); num = toint(num); var betidx = 0; for (var i = betarr.length - 1; i >= 0; i--) { if (num / betarr[i] >= 0.1) { if (betarr[i] >= 1000 && num % parseInt(betarr[i] / 1000) == 0) { betidx = i; break; } } if (num != 0 && num % betarr[i] == 0) { betidx = i; break; } } num = num / betarr[betidx]; var cns = (ciyfn.tofix(num, toint(fixlen)) + '').split('.'); var ret = cns[0].replace(/\d{1,3}(?=(\d{3})+$)/g, '$&,'); if (cns.length > 1) ret += '.' + cns[1] + ' '; var unit = unitarr[betidx]; if (unit.substring(0, 1) == '*') unit = unit.substring(1); ret += ciyfn.lang(unit); return ret; } ciyfn.tdshow = function (fieldname, dataori, ext, linedata, json, isview) { if (!ext) return dataori; var datashow = ''; var preext = ext.substring(0, 6); if (preext == 'FILEMD') { if (dataori == 0) return '--'; if (!isview) return 'V' + dataori; return '
    '; } var preext = ext.substring(0, 5); if (preext == 'FSIZE') { var pint = toint(ext.substring(6)); if (pint < 1) pint = 2; var srcsize = toint(dataori); if (srcsize <= 0) return "--"; var units = new Array("Bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"); var index = Math.floor(Math.log(srcsize) / Math.log(1024)); var size = srcsize / Math.pow(1024, index); return size.toFixed(pint) + units[index]; } if (preext == 'METRE') { if (dataori == 0) return '--'; return ciyfn.tonumunit(dataori, 1000, ext.substring(6), '米|1000|公里'); } preext = ext.substring(0, 4); if (preext == 'DATE') { if (dataori == 0) return '--'; var pstr = ext.substring(5); return ciyfn.todatetime(dataori, pstr); } if (preext == 'TIME') { if (dataori == 0) return '--'; return ciyfn.totimepoint(dataori, ext.substring(5).indexOf(':s') > -1); } if (preext == 'MCNY') { if (dataori == 0) return '--'; var pstr = ext.substring(4) || '4'; return ciyfn.tonumunit(dataori, 10000, pstr, '|1000000|万'); } if (preext == 'WCNY') { if (dataori == 0) return '--'; var pstrs = ext.substring(5).split(','); if (!pstrs[1]) pstrs[1] = '元'; return ciyfn.tonumunit(dataori, 1000000, pstrs[0], '万' + pstrs[1] + '|10000|亿' + pstrs[1]); } if (preext == 'DOWN') { if (!dataori) return ''; var files = dataori.split('~'); for (var fidx in files) { var fsrc = files[fidx]; if (fsrc == '') continue; datashow += ''; } return datashow; } if (preext == 'IMG1') { var pstr = ext.substring(5); //?0,缩略图标,?w,w宽度缩略图 //短地址//img.cdn.ciy.cn/xxx if (!dataori) return ''; var imgsrc = ciyfn.file_stor(dataori); if (isview) { return ''; } if (pstr.substring(0, 1) != '?') pstr = '?100'; return ''; } if (preext == 'BOOL') { var pstr = ext.substring(5); pstr = pstr || '✔.✘'; var slts = pstr.split('.'); if (dataori == 1) return slts[0]; return slts[1] ? slts[1] : ''; } if (preext == 'UNIT') { var pstr = ext.substring(5); var nums = 0; var yuenum = 0; var yuestr = ''; if (pstr) nums = parseInt(linedata[pstr]); var us = dataori.split('|');// 瓶 瓶|24|盒 瓶|24|盒|20|箱 datashow = ''; if (us.length == 5) { datashow += '1' + us[4] + '=' + us[3] + us[2] + ''; yuenum = nums / (parseInt(us[3]) * parseInt(us[1])); if (yuenum > 0.9) yuestr = "≈" + Math.round(yuenum) + us[4]; } if (us.length > 2) { datashow += '1' + us[2] + '=' + us[1] + us[0] + ''; if (yuestr == '') { yuenum = nums / parseInt(us[1]); if (yuenum > 0.9) yuestr = "≈" + Math.round(yuenum) + us[2]; } } if (datashow == '' && us[0] != '') { datashow = '' + us[0] + ''; } if (nums > 0 && yuestr == '' && us[0] != '') yuestr = nums + us[0]; if (yuestr) datashow += '
    ' + yuestr + '
    '; return datashow; } if (preext == 'CATA' || preext == 'CATU') { var pstr = ext.substring(5); var catas = ciyfn.getdictdata(pstr, json); if (dataori == 0) return '--'; if (!isarray(catas)) return dataori + "!"; for (var a in catas) { if (catas[a].id == dataori) { if (catas[a].clas) return '' + catas[a].name + ''; return ciyfn.lang(catas[a].name); } } return '-'; } if (preext == 'CATS') { var pstr = ext.substring(5).replace('|', ','); var ind = pstr.indexOf(','); var datasep = ' - ';//分隔字符 var datactn = '?';//包含html字符,?表示内容 if (ind > 0) { datasep = pstr.substring(ind + 1); pstr = pstr.substring(0, ind); } if (datasep[0] == '<') { datactn = datasep; datasep = ''; } if (dataori == '') return '--'; var catas = ciyfn.getdictdata(pstr, json); if (!isarray(catas)) return dataori + "!"; var vals = dataori.split(','); var datastrs = []; for (var v in vals) { if (vals[v] == '') continue; for (var a in catas) if (catas[a].id == vals[v]) datastrs.push(datactn.replace('?', ciyfn.lang(catas[a].name))); } return datastrs.join(datasep); } if (preext == 'CATM') { var pstr = ext.substring(5).replace('|', ','); var ind = pstr.indexOf(','); var datasep = ' - ';//分隔字符 var datactn = '?';//包含html字符,?表示内容 if (ind > 0) { datasep = pstr.substring(ind + 1); pstr = pstr.substring(0, ind); } if (datasep[0] == '<') { datactn = datasep; datasep = ''; } if (dataori == '') return '--'; var catas = ciyfn.getdictdata(pstr, json); if (!isarray(catas)) return dataori + "!"; var mdatas = ciyfn.mcode(catas, dataori); var datastrs = []; for (var mdata in mdatas) { datastrs.push(datactn.replace('?', ciyfn.lang(mdatas[mdata].name))); } return datastrs.join(datasep); } if (preext == 'TBIN') { var pstr = ext.substring(5).replace('|', ','); var ind = pstr.indexOf(','); var datasep = ' - ';//分隔字符 var datactn = '?';//包含html字符,?表示内容 if (ind > 0) { datasep = pstr.substring(ind + 1); pstr = pstr.substring(0, ind); } if (datasep[0] == '<') { datactn = datasep; datasep = ''; } if (dataori == '') return '--'; var catas = ciyfn.getdictdata(pstr, json); if (!isarray(catas)) return dataori + "!"; var pstrs = {}; for (var i in catas) { pstrs[catas[i].id - 1] = catas[i].name; } var ibin = toint(dataori); var datastrs = []; for (var x = 0; x < 16; x++) { if ((ibin & Math.pow(2, x)) && pstrs[x]) datastrs.push(datactn.replace('?', ciyfn.lang(pstrs[x]))); } return datastrs.join(datasep); } if (preext == 'TINT') { var pstr = ext.substring(5); var catas = ciyfn.getdictdata(pstr, json); if (dataori == 0) return '--'; if (!isarray(catas)) return dataori + "!"; for (var a in catas) { if (catas[a].id == dataori) { if (catas[a].clas) return '' + ciyfn.lang(catas[a].name) + ''; return ciyfn.lang(catas[a].name); } } return '-'; } preext = ext.substring(0, 3); if (preext == 'LNY') { if (dataori == 0) return '--'; var pstrs = ext.substring(4).split(','); pstrs[0] = pstrs[0] || '元.万元.亿元'; pstrs[1] = pstrs[1] || '2'; return ciyfn.tonumbet(dataori, pstrs[1], '100.1000000.10000000000', pstrs[0]); } if (preext == 'SNY') { if (dataori == 0) return '--'; var pstrs = ext.substring(4).split(','); pstrs[0] = pstrs[0] || '.K.M.B.T.Q'; pstrs[1] = pstrs[1] || '2'; return ciyfn.tonumbet(dataori, pstrs[1], '100.100000.100000000.100000000000.100000000000000', pstrs[0]); } if (preext == 'WGT') { if (dataori == 0) return '--'; var pstrs = ext.substring(4).split(','); pstrs[0] = pstrs[0] || '克.千克.吨'; pstrs[1] = pstrs[1] || '2'; return ciyfn.tonumbet(dataori, pstrs[1], '1.1000.1000000', pstrs[0]); } if (preext == 'LGH') { if (dataori == 0) return '--'; var pstrs = ext.substring(4).split(','); pstrs[0] = pstrs[0] || '厘米.米.公里'; pstrs[1] = pstrs[1] || '2'; return ciyfn.tonumbet(dataori, pstrs[1], '10.1000.1000000', pstrs[0]); } if (preext == 'BET') { if (dataori == 0) return '--'; var pstrs = ext.substring(4).split(','); pstrs[1] = pstrs[1] || '100'; pstrs[2] = pstrs[2] || '2'; return ciyfn.tonumbet(dataori, pstrs[2], pstrs[1], pstrs[0]); } if (preext == 'CYC') { if (dataori == 0) return '--'; if (dataori < 0) return -dataori + ciyfn.lang('月'); if (dataori >= 86400) return toint(dataori / 86400) + ciyfn.lang('天'); return toint(dataori / 60) + ciyfn.lang('分钟'); } if (preext == 'SEC') { return ciyfn.totimesec(dataori, '', dataori + ciyfn.lang('秒')); } if (preext == 'INT') { var pstr = ext.substring(4); if (pstr.length == 0) return dataori; if (pstr.indexOf('?') === -1) return dataori + pstr; return pstr.replace('?', dataori); } if (preext == 'IMG') { var pstr = ext.substring(4); if (!dataori) return ''; //多图,~分割。 图片1~图片2~图片3 var oris = dataori.split('~'); var images = []; var pdfs = []; for (var imgidx in oris) { if (oris[imgidx] == '') continue; var realurl = ciyfn.file_stor(oris[imgidx]); var ind = realurl.lastIndexOf('.'); var fext = ciyfn.file_ext(realurl); if (ciyfn.isimg(fext)) images.push(realurl); else pdfs.push(realurl); } if (isview) { for (var imgidx in images) { datashow += ''; } for (var imgidx in pdfs) { var ext = pdfs[imgidx].substring(pdfs[imgidx].lastIndexOf('.') + 1).toUpperCase(); datashow += '' + ext + ''; } return datashow; } if (pstr.substring(0, 1) == '?') { for (var imgidx in images) { var imgsrc = images[imgidx]; datashow += ''; } } else { if (images.length > 0) { datashow += ''; if (images.length > 1) datashow += '×' + images.length; datashow += ''; } } for (var imgidx in pdfs) { var ext = pdfs[imgidx].substring(pdfs[imgidx].lastIndexOf('.') + 1).toUpperCase(); datashow += '' + ext + ''; } return datashow; } if (preext == 'TON') { if (dataori == 0) return '--'; return ciyfn.tonumunit(dataori, 1000000, ext.substring(4), '吨|10000|万吨'); } if (preext == 'PCT') { if (dataori == 0) return '--'; var pstr = ext.substring(4) || '2'; return ciyfn.tonumunit(dataori, 100, pstr, '%'); } if (preext == 'CNY') { if (dataori == 0) return '--'; var pstrs = ext.substring(4).split(','); pstrs[0] = pstrs[0] || '2'; if (!pstrs[1]) pstrs[1] = '元'; return ciyfn.tonumunit(dataori, 100, pstrs[0], pstrs[1] + '|10000|万' + pstrs[1]); } if (preext == 'LOC') { var pstr = ext.substring(4); if (pstr.length == 0) pstr = 'lat'; var pstrs = pstr.split(','); var lng = tofloat(dataori); var lat = tofloat(linedata[pstrs[0]]); var bet = 10000000; if (pstrs.length > 1) bet = toint(pstrs[1]); if (ciyfn.isfloat0(lng) && ciyfn.isfloat0(lat)) return '--'; return '' + ciyfn.lang('打开地图') + ''; } if (preext == 'NUM') { //小数处理 -3 整数或保留3位小数 3只保留3位小数 空 整数 小数去掉.9999999和.0000001 var dnum = tofloat(dataori); if (Math.abs(dnum - Math.round(dnum)) < 0.00001) { dnum = Math.round(dnum); } return ciyfn.tonumunit(dnum, 1, ext.substring(4), '', linedata); } if (preext == 'URL') { var pstr = ext.substring(4); if (!dataori) return ''; if (pstr == '') pstr = ciyfn.lang('链接'); return '' + pstr + ''; } if (preext == 'MSK') { //隐藏部分信息 支持****##** var pstr = ext.substring(4); if (dataori.length == 0) return ''; var retstr = ''; if (dataori.length > pstr.length) { retstr = dataori.substring(0, dataori.length - pstr.length); dataori = dataori.substring(dataori.length - pstr.length); } for (var i = 0; i < Math.min(dataori.length, pstr.length); i++) { if (pstr.charAt(i) == '*') retstr += '*'; else retstr += dataori.charAt(i); } return retstr; } preext = ext.substring(0, 2); if (preext == 'KG') { if (dataori == 0) return '--'; return ciyfn.tonumunit(dataori, 1000, ext.substring(3), 'KG|1000|吨'); } if (preext == 'TC') { if (dataori == 0) return '--'; return ciyfn.tonumunit(dataori, 1000, ext.substring(3), '℃'); } if (preext == 'DB') { if (dataori == 0) return '--'; var pstr = ext.substring(3); var catas = null; if (!catas) catas = json[pstr]; if (!isarray(catas)) return dataori + "!"; for (var a in catas) if (catas[a].id == dataori) return catas[a]['name']; return '-'; } if (preext == 'AV') { var pstr = ext.substring(3); if (pstr == '') pstr = ciyfn.lang('播放'); if (!dataori) return ''; return '' + pstr + ''; } if (preext == 'BR') { if (!dataori) return ''; return dataori.replace(/\n/g, '
    '); } if (preext == 'MD') { if (!dataori) return ''; return '
    ' + ciyfn.markdown(dataori) + '
    '; } return dataori; };