yvanui.core.js 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819
  1. /**
  2. * power
  3. * @author luoyifan
  4. * 2018-11-22 17:32:00
  5. */
  6. "use strict";
  7. var sidm = 0;
  8. (function ($) {
  9. // 取消jQuery缓存
  10. $.ajaxSetup({
  11. cache: false
  12. });
  13. $.yvan = $.yvan || {};
  14. $.extend($.yvan, {
  15. version: '1.0.0',
  16. get: function (obj, exp) {
  17. if ($.type(exp) === 'string') {
  18. exp = exp.split('.');
  19. }
  20. return exp.reduce(function (acc, key) {
  21. return acc && key in acc ? acc[key] : null;
  22. }, obj);
  23. },
  24. set: function (obj, exp, value) {
  25. if ($.type(exp) === 'string') {
  26. exp = exp.split('.');
  27. }
  28. for (var i = exp.length - 1; i >= 0; i--) {
  29. var c = {};
  30. c[exp[i]] = value;
  31. value = c;
  32. }
  33. $.extend(true, obj, value);
  34. },
  35. props: function (p1, p2) {
  36. var target = {}, i;
  37. if ($.type(p2) === 'array') {
  38. for (i = 0; i < p2.length; i++) {
  39. if (p1.hasOwnProperty(p2[i])) {
  40. target[p2[i]] = p1[p2[i]];
  41. }
  42. }
  43. } else if ($.type(p2) === 'object') {
  44. for (var name in p2) {
  45. if (!p2.hasOwnProperty(name)) continue;
  46. target[p2[name]] = p1[name];
  47. }
  48. }
  49. return target;
  50. },
  51. upload: function (ajaxOpts) {
  52. var $dom = $('<form id="uploadForm" enctype="multipart/form-data">'
  53. + '<input type="file" name="file" multiple="multiple"/>'
  54. + '</form>');
  55. $('body').append($dom.hide());
  56. $dom.change(function () {
  57. var formData = new FormData($dom[0]);
  58. if (ajaxOpts.data) {
  59. for (var name in ajaxOpts.data) {
  60. if (!ajaxOpts.data.hasOwnProperty(name)) continue;
  61. formData.append(name, ajaxOpts.data[name]);
  62. }
  63. }
  64. $.yvan.ajax($.extend({}, ajaxOpts, {
  65. type: 'post',
  66. data: formData,
  67. cache: false,
  68. processData: false,
  69. contentType: false,
  70. }));
  71. $dom.remove();
  72. }).find('input').trigger("click");
  73. },
  74. createId: function (prefix) {
  75. return (prefix || 'd') + '_' + (sidm++);
  76. },
  77. getRandomNum: function (a, b) {
  78. switch (arguments.length) {
  79. case 1:
  80. return parseInt(Math.random() * a + 1);
  81. case 2:
  82. return parseInt(Math.random() * (b - a + 1) + a);
  83. default:
  84. return 0;
  85. }
  86. },
  87. unparam: function (query) {
  88. var query_string = {};
  89. if (query.slice(0, 1) === '#') {
  90. query = query.slice(1);
  91. }
  92. var vars = query.split("&");
  93. for (var i = 0; i < vars.length; i++) {
  94. var pair = vars[i].split("=");
  95. pair[0] = decodeURIComponent(pair[0]);
  96. pair[1] = decodeURIComponent(pair[1]);
  97. // If first entry with this name
  98. if (typeof query_string[pair[0]] === "undefined") {
  99. query_string[pair[0]] = pair[1];
  100. } else if (typeof query_string[pair[0]] === "string") {
  101. var arr = [query_string[pair[0]], pair[1]];
  102. query_string[pair[0]] = arr;
  103. } else {
  104. query_string[pair[0]].push(pair[1]);
  105. }
  106. }
  107. return query_string;
  108. },
  109. getRandomNumByDef: function () {
  110. return this.getRandomNum(1e5, 999999);
  111. },
  112. fillCommonProperties: function ($target, opts) {
  113. for (var name in opts) {
  114. if (!opts.hasOwnProperty(name)) continue;
  115. switch (name) {
  116. case 'xtype':
  117. $target.attr('xtype', opts[name]);
  118. break;
  119. case 'attr':
  120. for (var attrKey in opts[name]) {
  121. if (!opts[name].hasOwnProperty(attrKey)) continue;
  122. $target.attr(attrKey, opts[name][attrKey]);
  123. }
  124. break;
  125. case 'dialogId':
  126. $target.addClass('dlg_' + opts[name]);
  127. break;
  128. case 'name':
  129. $target.attr('itemId', opts[name]);
  130. break;
  131. case 'id':
  132. $target.attr('id', opts[name]);
  133. break;
  134. case 'html':
  135. $target.html(opts[name]);
  136. break;
  137. case 'class':
  138. $target.addClass(opts[name]);
  139. break;
  140. case 'css':
  141. $target.css(opts[name]);
  142. break;
  143. }
  144. }
  145. },
  146. xtypeIsInput: function (xtype) {
  147. return ($.inArray(xtype, ['textbox', 'combobox', 'searchbox', 'datebox', 'numberbox', 'combotree', 'combotreegrid', 'combogrid', 'datetimebox', 'tagbox', 'maskedbox', 'passwordbox', 'filebox', 'numberspinner', 'hidden']) >= 0);
  148. },
  149. copyData: function (str) {
  150. var save = function (e) {
  151. e.clipboardData.setData('text/plain', str);
  152. e.preventDefault();
  153. document.removeEventListener('copy', save);
  154. };
  155. document.addEventListener('copy', save);
  156. document.execCommand("copy");
  157. },
  158. getItems: function (item, context) {
  159. if (!item.items) return [];
  160. if ($.type(item.items) === 'array') return item.items;
  161. if ($.type(item.items) === 'function') {
  162. var r = item.items.apply(this, context);
  163. if (!r) return [];
  164. if ($.type(r) === 'array') return r;
  165. return [r];
  166. }
  167. return [item.items];
  168. },
  169. formClear: function () {
  170. var jq = this;
  171. if (jq.length <= 0) return;
  172. jq.each(function (index, ele) {
  173. if (ele.tagName === 'FORM') {
  174. var $ele = $(ele);
  175. $ele.form('clear');
  176. $ele.find('input[type="hidden"]').change();
  177. $ele.find('input[type=select]').trigger('change');
  178. //解决 formClear 但 searchbox 仍然会还原值的问题
  179. $ele.find('.easyui-searchbox').each(function (a1, a2) {
  180. $(a2).data().widgetTmpValue = '';
  181. $(a2).data().widgetValue = '';
  182. });
  183. }
  184. });
  185. jq.find('form').each(function (index, form) {
  186. var $form = $(form);
  187. $form.form('clear');
  188. $form.find('input[type="hidden"]').change();
  189. $form.find('input[type=select]').trigger('change');
  190. //解决 formClear 但 searchbox 仍然会还原值的问题
  191. $(form).find('.easyui-searchbox').each(function (a1, a2) {
  192. $(a2).data().widgetTmpValue = '';
  193. $(a2).data().widgetValue = '';
  194. });
  195. });
  196. },
  197. formSet: function (data) {
  198. var jq = this;
  199. if (jq.length <= 0) {
  200. return {};
  201. }
  202. var r = jq.each(function (index, ele) {
  203. if (ele.tagName === 'FORM') {
  204. var $ele = $(ele);
  205. $ele.form('load', data);
  206. $ele.find('input[type="hidden"]').change();
  207. $ele.find('input[type=select]').trigger('change');
  208. //解决对焦之后,值会消失的问题
  209. $(ele).find('.easyui-searchbox').each(function (a1, a2) {
  210. $(a2).data().widgetTmpValue = data[$(a2).attr('itemid')];
  211. $(a2).data().widgetValue = data[$(a2).attr('itemid')];
  212. });
  213. }
  214. });
  215. jq.find('form').each(function (index, form) {
  216. var $form = $(form);
  217. if ($form.attr('name')) {
  218. var formName = $form.attr('name');
  219. if (data.hasOwnProperty(formName) && $.type(data[formName]) === 'object') {
  220. //子对象赋值
  221. $form.form('load', data[formName]);
  222. $form.find('input[type="hidden"]').change();
  223. $form.find('input[type=select]').trigger('change');
  224. //解决对焦之后,值会消失的问题
  225. $form.find('.easyui-searchbox').each(function (a1, a2) {
  226. $(a2).data().widgetTmpValue = data[$(a2).attr('itemid')];
  227. $(a2).data().widgetValue = data[$(a2).attr('itemid')];
  228. });
  229. }
  230. } else {
  231. //没有名字,平级赋值
  232. $form.form('load', data);
  233. $form.find('input[type="hidden"]').change();
  234. $form.find('input[type=select]').trigger('change');
  235. //解决对焦之后,值会消失的问题
  236. $form.find('.easyui-searchbox').each(function (a1, a2) {
  237. $(a2).data().widgetTmpValue = data[$(a2).attr('itemid')];
  238. $(a2).data().widgetValue = data[$(a2).attr('itemid')];
  239. });
  240. }
  241. });
  242. return r;
  243. },
  244. formGet: function (validate) {
  245. var jq = this;
  246. if (jq.length <= 0) {
  247. return {};
  248. }
  249. var vra = [];
  250. var m = [];
  251. jq.each(function (index, ele) {
  252. if (ele.tagName === 'FORM') {
  253. var $form = $(this);
  254. if (validate) {
  255. //需要强制校验
  256. var vr = $form.form('enableValidation').form('validate');
  257. if (!vr) {
  258. vra.push($form);
  259. }
  260. if (vra.length > 0) {
  261. //校验失败
  262. return vra;
  263. }
  264. }
  265. m.push({
  266. id: '',
  267. obj: $form.serializeObject()
  268. });
  269. }
  270. });
  271. jq.find('form').each(function (index, form) {
  272. var $form = $(form);
  273. if (validate) {
  274. //需要强制校验
  275. var vr = $form.form('enableValidation').form('validate');
  276. if (!vr) {
  277. vra.push($form);
  278. }
  279. if (vra.length > 0) {
  280. //校验失败
  281. return vra;
  282. }
  283. }
  284. if ($form.attr('name')) {
  285. m.push({
  286. id: $form.attr('name'),
  287. obj: $form.serializeObject()
  288. });
  289. } else {
  290. m.push({
  291. id: '',
  292. obj: $form.serializeObject()
  293. });
  294. }
  295. });
  296. if (validate && vra.length > 0) {
  297. return {
  298. validate: false,
  299. validateError: vra
  300. };
  301. }
  302. var r = {};
  303. if (validate) {
  304. $.extend(r, {
  305. validate: true
  306. });
  307. }
  308. for (var i = 0; i < m.length; i++) {
  309. if (m[i].id) {
  310. if (r.hasOwnProperty(m[i].id)) {
  311. $.extend(r[m[i].id], m[i].obj);
  312. } else {
  313. r[m[i].id] = m[i].obj;
  314. }
  315. } else {
  316. $.extend(r, m[i].obj);
  317. }
  318. }
  319. return r;
  320. },
  321. postJson: function (opts) {
  322. var data = opts.data;
  323. $.yvan.ajax($.extend(opts, {
  324. type: 'post',
  325. dataType: 'json',
  326. data: JSON.stringify(data),
  327. contentType: "application/json; charset=utf-8"
  328. }));
  329. },
  330. uploadFormData: function ($form, opts) {
  331. var vr = $form.form('enableValidation').form('validate');
  332. if (!vr) {
  333. return;
  334. }
  335. var formData = new FormData($form[0]);
  336. formData.delete("file");
  337. $.yvan.ajax($.extend({}, opts, {
  338. type: 'post',
  339. data: formData,
  340. cache: false,
  341. processData: false,
  342. contentType: false,
  343. }));
  344. },
  345. uploadFile: function (formData, opts) {
  346. $.yvan.ajax($.extend({}, opts, {
  347. type: 'post',
  348. data: formData,
  349. cache: false,
  350. processData: false,
  351. contentType: false,
  352. }));
  353. },
  354. uploadFileCheckMd5: function (formData, opts) {
  355. $.yvan.getFileMd5(formData.get('file'), function (md5) {
  356. formData.append('fileMd5', md5);
  357. $.yvan.ajax({
  358. url: fileUrl('/file/isExist'),
  359. method: 'get',
  360. data: {fileMd5: md5, param: formData.get('param')},
  361. success: function (data) {
  362. if (data.data === '') {
  363. $.yvan.uploadFile(formData, opts);
  364. } else {
  365. opts.success(data);
  366. }
  367. }
  368. });
  369. });
  370. },
  371. getFileMd5: function (file, valueCallback) {
  372. var blobSlice = File.prototype.slice || File.prototype.mozSlice || File.prototype.webkitSlice,
  373. md5value = '',
  374. chunkSize = 2097152, // Read in chunks of 2MB
  375. chunks = Math.ceil(file.size / chunkSize),
  376. currentChunk = 0,
  377. spark = new SparkMD5.ArrayBuffer(),
  378. fileReader = new FileReader();
  379. fileReader.onload = function (e) {
  380. console.log('read chunk nr', currentChunk + 1, 'of', chunks);
  381. spark.append(e.target.result); // Append array buffer
  382. currentChunk++;
  383. if (currentChunk < chunks) {
  384. loadNext();
  385. } else {
  386. console.log('finished loading');
  387. md5value = spark.end();
  388. console.info('computed hash', md5value); // Compute hash
  389. valueCallback(md5value);
  390. }
  391. };
  392. fileReader.onerror = function () {
  393. console.warn('oops, something went wrong.');
  394. };
  395. function loadNext() {
  396. var start = currentChunk * chunkSize,
  397. end = ((start + chunkSize) >= file.size) ? file.size : start + chunkSize;
  398. fileReader.readAsArrayBuffer(blobSlice.call(file, start, end));
  399. }
  400. loadNext();
  401. },
  402. postForm: function ($form, opts) {
  403. var vr = $form.form('enableValidation').form('validate');
  404. if (!vr) {
  405. return false;
  406. }
  407. //var data = $form.serializeObject();
  408. var data = $form.formGet();
  409. if (opts.dataProcess) {
  410. opts.dataProcess(data);
  411. }
  412. this.postJson($.extend(opts, {
  413. data: data
  414. }));
  415. },
  416. //不验证提交Form,物资编码使用
  417. postFormNoValidate: function ($form, opts) {
  418. // var vr = $form.form('enableValidation').form('validate');
  419. // if (!vr) {
  420. // return false;
  421. // }
  422. //var data = $form.serializeObject();
  423. var data = $form.formGet();
  424. if (opts.dataProcess) {
  425. opts.dataProcess(data);
  426. }
  427. this.postJson($.extend(opts, {
  428. data: data
  429. }));
  430. },
  431. easyuiAjax: function (opts, param, success, error) {
  432. if (!opts.url) {
  433. if ($.type(opts.bizDict) === 'string') {
  434. //数据来源于 biz 字典
  435. success($.yvan.sysDict(opts.bizDict).combo());
  436. return;
  437. }
  438. if ($.type(opts.sysDict) === 'string') {
  439. //数据来源于 sys 字典
  440. success($.yvan.sysDict(opts.sysDict).combo());
  441. return;
  442. }
  443. //其他情况
  444. error();
  445. return false;
  446. }
  447. if (opts.hasOwnProperty('loadCondition')) {
  448. //有ajax条件的情况
  449. if (!opts.loadCondition(opts, param)) {
  450. error();
  451. return false;
  452. }
  453. }
  454. $.yvan.ajax({
  455. type: opts.method,
  456. url: opts.url,
  457. data: param,
  458. loadingMask: opts.loadingMask || false,
  459. success: function (data, textStatus, res) {
  460. if (opts.dataProcess) {
  461. opts.dataProcess.apply(this, arguments);
  462. }
  463. if (opts.pagination) {
  464. success({
  465. total: data.pagination.count,
  466. rows: data.data
  467. });
  468. } else {
  469. success(data.data);
  470. }
  471. },
  472. error: function (event, xhr, options, exc) {
  473. error.apply(this, arguments);
  474. }
  475. });
  476. }
  477. });
  478. $.fn.extend({
  479. progress: function (method) {
  480. if ($.type(method) === 'string') {
  481. if (method === 'close') {
  482. this.find('.loading-wrap').remove();
  483. } else {
  484. console.error('no method: progress(' + method + ')');
  485. }
  486. } else {
  487. if ($('.loading-wrap').length > 0) {
  488. return;
  489. }
  490. var $dom = $(
  491. '<div class="loading-wrap" style="opacity:.6">' +
  492. '<div class="spinner">' +
  493. ' <div class="spinner-container container1">\n' +
  494. ' <div class="circle1"></div>\n' +
  495. ' <div class="circle2"></div>\n' +
  496. ' <div class="circle3"></div>\n' +
  497. ' <div class="circle4"></div>\n' +
  498. ' </div>\n' +
  499. ' <div class="spinner-container container2">\n' +
  500. ' <div class="circle1"></div>\n' +
  501. ' <div class="circle2"></div>\n' +
  502. ' <div class="circle3"></div>\n' +
  503. ' <div class="circle4"></div>\n' +
  504. ' </div>\n' +
  505. ' <div class="spinner-container container3">\n' +
  506. ' <div class="circle1"></div>\n' +
  507. ' <div class="circle2"></div>\n' +
  508. ' <div class="circle3"></div>\n' +
  509. ' <div class="circle4"></div>\n' +
  510. ' </div>' +
  511. '</div>' +
  512. '</div>'
  513. );
  514. this.append($dom);
  515. }
  516. },
  517. serializeObject: function () {
  518. var o = {};
  519. var a = this.serializeArray();
  520. $.each(a, function () {
  521. if (o[this.name] !== undefined) {
  522. if (!o[this.name].push) {
  523. o[this.name] = [o[this.name]];
  524. }
  525. o[this.name].push(this.value || '');
  526. } else {
  527. o[this.name] = this.value || '';
  528. }
  529. });
  530. return o;
  531. },
  532. findWindow: function () {
  533. var $me = $(this);
  534. if ($me.parent().is('.panel-footer')) {
  535. return $(this).closest('.window').down('dialog');
  536. }
  537. return $(this).closest('.window').down('dialog');
  538. },
  539. up: function (xtype) {
  540. return this.closest("[xtype='" + xtype + "']");
  541. },
  542. down: function (xtype) {
  543. return this.find("[xtype='" + xtype + "']");
  544. },
  545. item: function (itemId) {
  546. return this.find('[itemId="' + itemId + '"]');
  547. },
  548. findForm: function () {
  549. //找到最可能的上级容器
  550. var container = this.closest('form');
  551. if (container.length > 0) return container;
  552. container = this.up('group');
  553. if (container.length > 0) return container;
  554. container = this.up('tab');
  555. if (container.length > 0) return container;
  556. container = this.up('dialog');
  557. return container;
  558. },
  559. formGet: function () {
  560. return $.yvan.formGet.apply(this, arguments);
  561. },
  562. formSet: function () {
  563. return $.yvan.formSet.apply(this, arguments);
  564. },
  565. formClear: function () {
  566. return $.yvan.formClear.apply(this, arguments);
  567. },
  568. showItem: function (validate) {
  569. var tabs = this.up('tabs');
  570. if (tabs.length <= 0) {
  571. return;
  572. }
  573. var tab = this.up('tab');
  574. var i = tabs.tabs('getTabIndex', tab);
  575. if (i >= 0) {
  576. var i = this.up('tabs').tabs('select', i);
  577. }
  578. if (validate) {
  579. //this.form('enableValidation').form('validate');
  580. this.find(".validatebox-invalid:first").focus();
  581. }
  582. }
  583. });
  584. $.extend(true, $.fn.combobox.defaults, {
  585. loader: function (param, success, error) {
  586. var me = $(this);
  587. var opts = me.combobox("options");
  588. $.yvan.easyuiAjax(opts, param, success, error);
  589. },
  590. width: 280,
  591. labelWidth: 120,
  592. editable: false,
  593. panelHeight: 'auto',
  594. labelAlign: 'right',
  595. valueField: 'id',
  596. textField: 'text'
  597. });
  598. $.extend($.fn.menubutton.defaults, {
  599. hasDownArrow: false,
  600. showEvent: 'click',
  601. menuAlign: 'left',
  602. iconCls: 'fa fa-caret-down'
  603. });
  604. $.extend($.fn.textbox.defaults, {
  605. width: 280,
  606. labelWidth: 120,
  607. labelAlign: 'right'
  608. });
  609. $.extend($.fn.passwordbox.defaults, {
  610. width: 280,
  611. labelWidth: 120,
  612. labelAlign: 'right'
  613. });
  614. $.extend($.fn.checkbox.defaults, {
  615. labelPosition: 'after'
  616. });
  617. $.extend($.fn.radiobutton.defaults, {
  618. labelPosition: 'after'
  619. });
  620. $.extend($.fn.maskedbox.defaults, {
  621. width: 280,
  622. labelWidth: 120,
  623. labelAlign: 'right'
  624. });
  625. $.extend($.fn.numberbox.defaults, {
  626. width: 280,
  627. labelWidth: 120,
  628. labelAlign: 'right'
  629. });
  630. $.extend($.fn.datebox.defaults, {
  631. panelMinWidth: 272,
  632. panelHeight: 301,
  633. width: 280,
  634. labelWidth: 120,
  635. labelAlign: 'right',
  636. validType: "dateValidate"
  637. });
  638. $.extend($.fn.filebox.defaults, {
  639. width: 280,
  640. labelWidth: 120,
  641. labelAlign: 'right',
  642. label: '上传文件',
  643. buttonText: '选择文件'
  644. });
  645. $.extend($.fn.datetimebox.defaults, {
  646. panelMinWidth: 422,
  647. panelHeight: 301,
  648. width: 280,
  649. labelWidth: 120,
  650. labelAlign: 'right'
  651. });
  652. $.extend($.fn.datetimebox.defaults, {
  653. width: 280,
  654. labelWidth: 120,
  655. labelAlign: 'right',
  656. });
  657. $.extend($.fn.searchbox.defaults, {
  658. width: 280,
  659. labelWidth: 120,
  660. labelAlign: 'right'
  661. });
  662. $.extend($.fn.treegrid.defaults, {
  663. loader: function (param, success, error) {
  664. var me = $(this);
  665. var opts = me.treegrid("options");
  666. $.yvan.easyuiAjax(opts, param, success, error);
  667. },
  668. method: 'get',
  669. });
  670. $.extend($.fn.tree.defaults, {
  671. loader: function (param, success, error) {
  672. var me = $(this);
  673. var opts = me.tree("options");
  674. $.yvan.easyuiAjax(opts, param, success, error);
  675. },
  676. method: 'get',
  677. });
  678. $.extend($.fn.datalist.defaults, {
  679. loader: function (param, success, error) {
  680. var me = $(this);
  681. var opts = me.datalist("options");
  682. $.yvan.easyuiAjax(opts, param, success, error);
  683. },
  684. lines: true,
  685. method: 'get',
  686. pagination: false,
  687. emptyMsg: "暂无数据",
  688. pageSize: 50,
  689. pageList: [10, 30, 50, 100],
  690. remoteSort: true,
  691. striped: true,
  692. fitColumns: true,
  693. fit: true,
  694. singleSelect: true,
  695. onLoadSuccess: function (data) {
  696. if (data.rows.length > 0) {
  697. $(this).datalist('selectRow', 0);
  698. }
  699. }
  700. });
  701. $.extend($.fn.combogrid.defaults, {
  702. loader: function (param, success, error) {
  703. var me = $(this);
  704. var opts = me.datagrid("options");
  705. $.yvan.easyuiAjax(opts, param, success, error);
  706. },
  707. width: 280,
  708. editable: false,
  709. labelWidth: 120,
  710. labelAlign: 'right',
  711. method: 'get',
  712. pagination: false,
  713. rownumbers: true,
  714. pageList: [10, 30, 50, 100],
  715. pageSize: 10,
  716. remoteSort: true,
  717. striped: true,
  718. fitColumns: true,
  719. singleSelect: true
  720. });
  721. $.extend($.fn.tabs.defaults, {
  722. tabPosition: 'top',
  723. plain: true,
  724. fit: true
  725. });
  726. $.extend($.fn.datagrid.defaults, {
  727. loader: function (param, success, error) {
  728. var me = $(this);
  729. var opts = me.datagrid("options");
  730. $.yvan.easyuiAjax(opts, param, success, error);
  731. },
  732. method: 'get',
  733. pagination: true,
  734. rownumbers: true,
  735. emptyMsg: "暂无数据",
  736. pageSize: 50,
  737. pageList: [10, 30, 50, 100],
  738. remoteSort: true,
  739. striped: true,
  740. fitColumns: true,
  741. fit: true,
  742. singleSelect: true
  743. });
  744. if ($.fn.edatagrid) {
  745. $.extend($.fn.edatagrid.defaults, {
  746. loader: function (param, success, error) {
  747. var me = $(this);
  748. var opts = me.datagrid("options");
  749. $.yvan.easyuiAjax(opts, param, success, error);
  750. },
  751. method: 'get',
  752. pagination: true,
  753. rownumbers: true,
  754. emptyMsg: "暂无数据",
  755. pageList: [10, 30, 50, 100],
  756. pageSize: 50,
  757. remoteSort: true,
  758. striped: true,
  759. fitColumns: true,
  760. fit: true,
  761. singleSelect: true
  762. });
  763. }
  764. })(jQuery);