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.
 
 
 
 
 
 

384 lines
17 KiB

  1. /* * 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园(http://www.learun.cn)
  2. * Copyright (c) 2013-2018 北京泉江科技有限公司
  3. * 创建人:超级管理员
  4. * 日 期:2019-03-29 11:27
  5. * 描 述:在册登记明细
  6. */
  7. var refreshGirdData;
  8. var bootstrap = function ($, learun) {
  9. "use strict";
  10. var page = {
  11. init: function () {
  12. page.initGird();
  13. page.bind();
  14. },
  15. bind: function () {
  16. // 初始化左侧树形数据
  17. $('#dataTree').lrtree({
  18. url: top.$.rootUrl + '/AssetManagementSystem/Ass_AssetsInfoItem/GetTree',
  19. nodeClick: function (item) {
  20. page.search({ AIAssType: item.value });
  21. }
  22. });
  23. $('#multiple_condition_query').lrMultipleQuery(function (queryJson) {
  24. page.search(queryJson);
  25. }, 400, 400);
  26. $('#AIIStorageId').lrDataSourceSelect({ code: 'Ass_StorageData', value: 'sid', text: 'sname' });
  27. $('#AIASSState').lrDataItemSelect({ code: 'AssState' });
  28. $('#AIDepartment').lrDepartmentSelect();
  29. // 刷新
  30. $('#lr_refresh').on('click', function () {
  31. location.reload();
  32. });
  33. // 新增
  34. $('#lr_add').on('click', function () {
  35. learun.layerForm({
  36. id: 'form',
  37. title: '新增',
  38. url: top.$.rootUrl + '/AssetManagementSystem/Ass_AssetsInfoItem/Form',
  39. width: 800,
  40. height: 700,
  41. callBack: function (id) {
  42. return top[id].acceptClick(refreshGirdData);
  43. }
  44. });
  45. });
  46. //标签打印
  47. var qrcode = new QRCode(document.getElementById("qrcode"), {
  48. width: 80,
  49. height: 80
  50. });
  51. $("#lr_printBar").on('click', function () {
  52. var keyValue = $('#gridtable').jfGridValue('AICode');
  53. if (learun.checkrow(keyValue)) {
  54. //todo 打印标签
  55. //$('.qrcodeTxt').html(keyValue);
  56. ////标签打印
  57. //qrcode.makeCode(keyValue);
  58. //setTimeout(function () {
  59. // var html = $('.qrcodeBox').html();
  60. // // console.log(html)
  61. // AddPrintContent(html);
  62. // qrcode.clear();
  63. //}, 300)
  64. //AddPrintContent(html)
  65. learun.layerForm({
  66. id: 'formcardprint',
  67. title: '打印二维码',
  68. url: top.$.rootUrl + '/AssetManagementSystem/Ass_AssetsInfoItem/QRPrint?keyValue=' + keyValue,
  69. width: 700,
  70. height: 300,
  71. btn: null,
  72. end: function () { refreshGirdData(); }
  73. });
  74. }
  75. })
  76. // 编辑
  77. $('#lr_edit').on('click', function () {
  78. var keyValue = $('#gridtable').jfGridValue('AIId');
  79. if (learun.checkrow(keyValue)) {
  80. learun.layerForm({
  81. id: 'forminfoitem',
  82. title: '编辑',
  83. url: top.$.rootUrl + '/AssetManagementSystem/Ass_AssetsInfoItem/Form?keyValue=' + keyValue,
  84. width: 800,
  85. height: 700,
  86. callBack: function (id) {
  87. return top[id].acceptClick(refreshGirdData);
  88. }
  89. });
  90. }
  91. });
  92. //查看
  93. $('#lr_view').on('click', function () {
  94. var keyValue = $('#gridtable').jfGridValue('AIId');
  95. if (learun.checkrow(keyValue)) {
  96. learun.layerForm({
  97. id: 'forminfoitem',
  98. title: '查看',
  99. url: top.$.rootUrl + '/AssetManagementSystem/Ass_AssetsInfoItem/FormView?keyValue=' + keyValue,
  100. width: 800,
  101. height: 700,
  102. btn: '',
  103. callBack: function (id) {
  104. return top[id].acceptClick(refreshGirdData);
  105. }
  106. });
  107. }
  108. });
  109. //出入记录
  110. $('#lr_detail').on('click', function () {
  111. var keyValue = $('#gridtable').jfGridValue('AIId');
  112. if (learun.checkrow(keyValue)) {
  113. learun.layerForm({
  114. id: 'formdetail',
  115. title: '出入库记录',
  116. url: top.$.rootUrl + '/AssetManagementSystem/Ass_AssetsChangeItem/Index?AIId=' + keyValue,
  117. width: 940,
  118. height: 600,
  119. btn: null
  120. });
  121. }
  122. });
  123. // 删除
  124. $('#lr_delete').on('click', function () {
  125. var keyValue = $('#gridtable').jfGridValue('AIId');
  126. if (learun.checkrow(keyValue)) {
  127. learun.layerConfirm('是否恢复使用!', function (res) {
  128. if (res) {
  129. learun.deleteForm(top.$.rootUrl + '/AssetManagementSystem/Ass_AssetsInfoItem/UnScrapForm', { keyValue: keyValue }, function () {
  130. refreshGirdData();
  131. });
  132. }
  133. });
  134. }
  135. });
  136. },
  137. // 初始化列表
  138. initGird: function () {
  139. $('#gridtable').lrAuthorizeJfGrid({
  140. url: top.$.rootUrl + '/AssetManagementSystem/Ass_AssetsInfoItem/GetPageList',
  141. headData: [
  142. { label: "明细编号", name: "AICode", width: 200, align: "left" },
  143. { label: "编号", name: "AICodeNumJY", width: 200, align: "left" },
  144. { label: "名称", name: "AIASSName", width: 200, align: "left" },
  145. {
  146. label: "部门", name: "AIDepartment", width: 100, align: "left",
  147. formatterAsync: function (callback, value, row, op, $cell) {
  148. learun.clientdata.getAsync('department', {
  149. key: value,
  150. callback: function (_data) {
  151. callback(_data.name);
  152. }
  153. });
  154. }
  155. },
  156. {
  157. label: "使用人员", name: "AIUsePeople", width: 100, align: "left",
  158. formatterAsync: function (callback, value, row, op, $cell) {
  159. console.log(value);
  160. learun.clientdata.getAsync('custmerData', {
  161. url: '/LR_SystemModule/DataSource/GetDataTable?code=' + 'BaseUser',
  162. key: value,
  163. keyId: 'f_userid',
  164. callback: function (_data) {
  165. callback(_data['f_realname']);
  166. }
  167. });
  168. }
  169. },
  170. {
  171. label: "所在库房", name: "AIIStorageId", width: 100, align: "left",
  172. formatterAsync: function (callback, value, row, op, $cell) {
  173. learun.clientdata.getAsync('custmerData', {
  174. url: '/LR_SystemModule/DataSource/GetDataTable?code=' + 'Ass_StorageData',
  175. key: value,
  176. keyId: 'sid',
  177. callback: function (_data) {
  178. callback(_data['sname']);
  179. }
  180. });
  181. }
  182. },
  183. { label: "所在库位", name: "AIIStoragePosition", width: 100, align: "left" },
  184. //{
  185. // label: "报废时间", name: "AIIStoragePosition", width: 100, align: "left", formatter: function (cellvalue, row) {
  186. // if (!!row.AScrapTime && row.ScrapRemindTime > (-1)) {
  187. // var validDate2 = new Date(row.AScrapTime.replace(/-/g, "/"));
  188. // var nowDate = new Date();
  189. // var timerange = datedifference(nowDate, validDate2);
  190. // console.log(timerange);
  191. // if (validDate2 > nowDate && timerange > 0) {
  192. // switch (row.ScrapRemindTime) {
  193. // case 0:
  194. // if (timerange < 30) {
  195. // return '<span class=\"label label-warning\">' + validDate2.Format("yyyy-MM-dd") + '</span>';
  196. // } else {
  197. // return '<span class=\"label label-info\">' + validDate2.Format("yyyy-MM-dd") + '</span>';
  198. // }
  199. // case 1:
  200. // if (timerange >= 30 && timerange < 90) {
  201. // return '<span class=\"label label-warning\">' + row.AScrapTime + '</span>';
  202. // } else {
  203. // return '<span class=\"label label-info\">' + row.AScrapTime + '</span>';
  204. // }
  205. // case 2:
  206. // if (timerange >= 90 && timerange < 180) {
  207. // return '<span class=\"label label-warning\">' + row.AScrapTime + '</span>';
  208. // } else {
  209. // return '<span class=\"label label-info\">' + row.AScrapTime + '</span>';
  210. // }
  211. // case 3:
  212. // if (timerange >= 180 && timerange < 360) {
  213. // return '<span class=\"label label-warning\">' + row.AScrapTime + '</span>';
  214. // } else {
  215. // return '<span class=\"label label-info\">' + row.AScrapTime + '</span>';
  216. // }
  217. // default:
  218. // }
  219. // } else {
  220. // return '<span class=\"label label-danger\">已报废</span>';
  221. // }
  222. // } else {
  223. // return '<span class=\"label label-info\">未设置</span>';
  224. // }
  225. // }
  226. //},
  227. {
  228. label: "资产型号", name: "AISpecificationtype", width: 100, align: "left"
  229. },
  230. {
  231. label: "资产属性", name: "AIAssType", width: 100, align: "left",
  232. formatterAsync: function (callback, value, row, op, $cell) {
  233. learun.clientdata.getAsync('dataItem', {
  234. key: value,
  235. code: 'AssType',
  236. callback: function (_data) {
  237. callback(_data.text);
  238. }
  239. });
  240. }
  241. },
  242. {
  243. label: "计量单位", name: "AIUnits", width: 100, align: "left",
  244. formatterAsync: function (callback, value, row, op, $cell) {
  245. learun.clientdata.getAsync('dataItem',
  246. {
  247. key: value,
  248. code: 'sldw',
  249. callback: function (_data) {
  250. callback(_data.text);
  251. }
  252. })
  253. }
  254. },
  255. { label: "资产价值", name: "AIAssValue", width: 100, align: "left" },
  256. { label: "购置日期", name: "AIAddTime", width: 100, align: "left" },
  257. {
  258. label: "资产分类", name: "AIASSClass", width: 100, align: "left",
  259. formatterAsync: function (callback, value, row, op, $cell) {
  260. learun.clientdata.getAsync('custmerData', {
  261. url: '/LR_SystemModule/DataSource/GetDataTable?code=' + 'Ass_AssetsType',
  262. key: value,
  263. keyId: 'atid',
  264. callback: function (_data) {
  265. callback(_data['aname']);
  266. }
  267. });
  268. }
  269. },
  270. //{
  271. // label: "资产状态", name: "AIASSState", width: 100, align: "left",
  272. // formatterAsync: function (callback, value, row, op, $cell) {
  273. // learun.clientdata.getAsync('dataItem', {
  274. // key: value,
  275. // code: 'AssState',
  276. // callback: function (_data) {
  277. // callback(_data.text);
  278. // }
  279. // });
  280. // }
  281. //},
  282. {
  283. label: "增加方式", name: "AIAddType", width: 100, align: "left",
  284. formatterAsync: function (callback, value, row, op, $cell) {
  285. learun.clientdata.getAsync('dataItem', {
  286. key: value,
  287. code: 'zcly',
  288. callback: function (_data) {
  289. callback(_data.text);
  290. }
  291. });
  292. }
  293. },
  294. { label: "生产厂家", name: "AIManufacturer", width: 100, align: "left" },
  295. { label: "资产规格", name: "AISpecification", width: 100, align: "left" },
  296. { label: "用途", name: "AIUse", width: 100, align: "left" },
  297. ],
  298. mainId: 'AIId',
  299. isMultiselect: true,
  300. isPage: true,
  301. sidx: 'AICodeNum'
  302. });
  303. page.search();
  304. },
  305. search: function (param) {
  306. param = param || {};
  307. param.AIASSState = "2";
  308. $('#gridtable').jfGridSet('reload', { queryJson: JSON.stringify(param) });
  309. }
  310. };
  311. refreshGirdData = function () {
  312. page.search();
  313. };
  314. page.init();
  315. }
  316. Date.prototype.Format = function (fmt) { //author: meizz
  317. var o = {
  318. "M+": this.getMonth() + 1, //月份
  319. "d+": this.getDate(), //日
  320. "H+": this.getHours(), //小时
  321. "m+": this.getMinutes(), //分
  322. "s+": this.getSeconds(), //秒
  323. "q+": Math.floor((this.getMonth() + 3) / 3), //季度
  324. "S": this.getMilliseconds() //毫秒
  325. };
  326. if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
  327. for (var k in o)
  328. if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
  329. return fmt;
  330. }
  331. function datedifference(sDate1, sDate2) { //sDate1和sDate2是2006-12-18格式
  332. var dateSpan,
  333. tempDate,
  334. iDays;
  335. sDate1 = Date.parse(sDate1);
  336. sDate2 = Date.parse(sDate2);
  337. dateSpan = sDate2 - sDate1;
  338. dateSpan = Math.abs(dateSpan);
  339. iDays = Math.floor(dateSpan / (24 * 3600 * 1000));
  340. return iDays;
  341. };
  342. function AddPrintContent(html) {
  343. var myHtml = myHtml = html;
  344. // var strBodyStyle="<style>"+document.getElementById("style1").innerHTML+"</style>";
  345. // var strFormHtml=strBodyStyle+"<body>"+myHtml+"</body>";
  346. var strFormHtml = "<body>" + myHtml + "</body>";
  347. LODOP = getLodop();
  348. LODOP.PRINT_INIT("资产编号");
  349. LODOP.SET_PRINT_PAGESIZE(2, '40mm', '32.3mm', "");
  350. LODOP.SET_PRINT_MODE("PRINT_DUPLEX", 2);
  351. LODOP.SET_PRINT_MODE("PRINT_DEFAULTSOURCE", 7);
  352. LODOP.ADD_PRINT_HTM(10, 8, '40mm', '30mm', strFormHtml);
  353. //打印预览
  354. // LODOP.SET_SHOW_MODE("LANDSCAPE_DEFROTATED",1);
  355. // var TaskID1=LODOP.PREVIEW();
  356. // 直接打印
  357. var TaskID1 = LODOP.PRINT();
  358. };