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.
 
 
 
 
 
 

465 lines
21 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 AId = request("AId");
  9. var currentUser = 1;//我的资产需要用到
  10. var IsDelete = request("IsDelete");//报废资产需要使用
  11. var bootstrap = function ($, learun) {
  12. "use strict";
  13. var page = {
  14. init: function () {
  15. page.initGird();
  16. page.bind();
  17. if (currentUser) {
  18. setTimeout("hiddenButton()", 300);
  19. }
  20. },
  21. bind: function () {
  22. // 初始化左侧树形数据lr_printBar
  23. $('#dataTree').lrtree({
  24. url: top.$.rootUrl + '/AssetManagementSystem/Ass_AssetsInfoItem/GetTree',
  25. nodeClick: function (item) {
  26. page.search({ AIAssType: item.value });
  27. }
  28. });
  29. $('#multiple_condition_query').lrMultipleQuery(function (queryJson) {
  30. page.search(queryJson);
  31. }, 400, 400);
  32. //$('#AIIStorageId').lrDataSourceSelect({ code: 'Ass_StorageData', value: 'sid', text: 'sname' });
  33. $('#AIIStorageId').lrselect({
  34. type: 'tree',
  35. allowSearch: true,
  36. url: top.$.rootUrl + '/AssetManagementSystem/AssStorageRoom/GetTree',
  37. param: {},
  38. select: function (val) {
  39. var storageId = "";
  40. if (val) {
  41. storageId = val.value;
  42. }
  43. $('#AIIStoragePosition').lrselectRefresh({
  44. url: top.$.rootUrl + '/AssetManagementSystem/AssStorageRoom/GetListForStorageId?storageId=' + storageId,
  45. text: "RCode",
  46. value: "RId", allowSearch: true
  47. });
  48. }
  49. });
  50. //房间
  51. $('#AIIStoragePosition').lrselect({ value: 'RId', text: 'RCode', allowSearch: true });
  52. $('#AIASSState').lrDataItemSelect({ code: 'AssState' });
  53. $('#AIDepartment').lrDepartmentSelect();
  54. // 刷新
  55. $('#lr_refresh').on('click', function () {
  56. location.reload();
  57. });
  58. // 新增
  59. $('#lr_add').on('click', function () {
  60. learun.layerForm({
  61. id: 'form',
  62. title: '新增',
  63. url: top.$.rootUrl + '/AssetManagementSystem/Ass_AssetsInfoItem/Form',
  64. width: 800,
  65. height: 700,
  66. callBack: function (id) {
  67. return top[id].acceptClick(refreshGirdData);
  68. }
  69. });
  70. });
  71. //标签打印
  72. var qrcode = new QRCode(document.getElementById("qrcode"), {
  73. width: 80,
  74. height: 80
  75. });
  76. $("#lr_printBar").on('click', function () {
  77. var keyValue = $('#gridtable').jfGridValue('AICode');
  78. if (learun.checkrow(keyValue)) {
  79. //todo 打印标签
  80. //$('.qrcodeTxt').html(keyValue);
  81. ////标签打印
  82. //qrcode.makeCode(keyValue);
  83. //setTimeout(function () {
  84. // var html = $('.qrcodeBox').html();
  85. // // console.log(html)
  86. // AddPrintContent(html);
  87. // qrcode.clear();
  88. //}, 300)
  89. //AddPrintContent(html)
  90. learun.layerForm({
  91. id: 'formcardprint',
  92. title: '打印二维码',
  93. url: top.$.rootUrl + '/AssetManagementSystem/Ass_AssetsInfoItem/QRPrint?keyValue=' + keyValue,
  94. width: 700,
  95. height: 300,
  96. btn: null,
  97. end: function () { refreshGirdData(); }
  98. });
  99. }
  100. })
  101. // 编辑
  102. $('#lr_edit').on('click', function () {
  103. var keyValue = $('#gridtable').jfGridValue('AIId');
  104. if (learun.checkrow(keyValue)) {
  105. learun.layerForm({
  106. id: 'forminfoitem',
  107. title: '编辑',
  108. url: top.$.rootUrl + '/AssetManagementSystem/Ass_AssetsInfoItem/Form?keyValue=' + keyValue,
  109. width: 800,
  110. height: 700,
  111. callBack: function (id) {
  112. return top[id].acceptClick(refreshGirdData);
  113. }
  114. });
  115. }
  116. });
  117. //查看
  118. $('#lr_view').on('click', function () {
  119. var keyValue = $('#gridtable').jfGridValue('AIId');
  120. if (learun.checkrow(keyValue)) {
  121. learun.layerForm({
  122. id: 'forminfoitem',
  123. title: '查看',
  124. url: top.$.rootUrl + '/AssetManagementSystem/Ass_AssetsInfoItem/FormView?keyValue=' + keyValue,
  125. width: 800,
  126. height: 700,
  127. btn: '',
  128. callBack: function (id) {
  129. return top[id].acceptClick(refreshGirdData);
  130. }
  131. });
  132. }
  133. });
  134. //出入记录
  135. $('#lr_detail').on('click', function () {
  136. var keyValue = $('#gridtable').jfGridValue('AIId');
  137. if (learun.checkrow(keyValue)) {
  138. learun.layerForm({
  139. id: 'formdetail',
  140. title: '出入库记录',
  141. url: top.$.rootUrl + '/AssetManagementSystem/Ass_AssetsChangeItem/Index?AIId=' + keyValue,
  142. width: 940,
  143. height: 600,
  144. btn: null
  145. });
  146. }
  147. });
  148. //查看使用人员变动记录
  149. $('#lr_usedetail').on('click', function () {
  150. var keyValue = $('#gridtable').jfGridValue('AIId');
  151. if (learun.checkrow(keyValue)) {
  152. learun.layerForm({
  153. id: 'formusedetail',
  154. title: '使用人员变动记录',
  155. url: top.$.rootUrl + '/AssetManagementSystem/Ass_UserChangeInfo/Index?AIId=' + keyValue,
  156. width: 940,
  157. height: 600,
  158. btn: null
  159. });
  160. }
  161. });
  162. // 删除
  163. $('#lr_delete').on('click', function () {
  164. var keyValue = $('#gridtable').jfGridValue('AIId');
  165. if (learun.checkrow(keyValue)) {
  166. learun.layerConfirm('是否确认删除该项!', function (res) {
  167. if (res) {
  168. learun.deleteForm(top.$.rootUrl + '/AssetManagementSystem/Ass_AssetsInfoItem/DeleteForm', { keyValue: keyValue }, function () {
  169. refreshGirdData();
  170. });
  171. }
  172. });
  173. }
  174. });
  175. // 报废
  176. $('#lr_scrap').on('click', function () {
  177. var keyValue = $('#gridtable').jfGridValue('AIId');
  178. if (learun.checkrow(keyValue)) {
  179. learun.layerConfirm('是否确认报废!', function (res) {
  180. if (res) {
  181. learun.deleteForm(top.$.rootUrl + '/AssetManagementSystem/Ass_AssetsInfoItem/ScrapForm', { keyValue: keyValue }, function () {
  182. refreshGirdData();
  183. });
  184. }
  185. });
  186. }
  187. });
  188. },
  189. // 初始化列表
  190. initGird: function () {
  191. $('#gridtable').lrAuthorizeJfGrid({
  192. url: top.$.rootUrl + '/AssetManagementSystem/Ass_AssetsInfoItem/GetPageList',
  193. headData: [
  194. { label: "明细编号", name: "AICode", width: 200, align: "left" },
  195. { label: "编号", name: "AICodeNumJY", width: 200, align: "left" },
  196. { label: "名称", name: "AIASSName", width: 200, align: "left" },
  197. {
  198. label: "部门", name: "AIDepartment", width: 100, align: "left",
  199. formatterAsync: function (callback, value, row, op, $cell) {
  200. learun.clientdata.getAsync('department', {
  201. key: value,
  202. callback: function (_data) {
  203. callback(_data.name);
  204. }
  205. });
  206. }
  207. },
  208. {
  209. label: "使用人员", name: "AIUsePeople", width: 100, align: "left",
  210. formatterAsync: function (callback, value, row, op, $cell) {
  211. console.log(value);
  212. learun.clientdata.getAsync('custmerData', {
  213. url: '/LR_SystemModule/DataSource/GetDataTable?code=' + 'BaseUser',
  214. key: value,
  215. keyId: 'f_userid',
  216. callback: function (_data) {
  217. callback(_data['f_realname']);
  218. }
  219. });
  220. }
  221. },
  222. {
  223. label: "楼宇名称", name: "AIIStorageId", width: 100, align: "left",
  224. formatterAsync: function (callback, value, row, op, $cell) {
  225. learun.clientdata.getAsync('custmerData', {
  226. url: '/LR_SystemModule/DataSource/GetDataTable?code=' + 'Ass_StorageData',
  227. key: value,
  228. keyId: 'sid',
  229. callback: function (_data) {
  230. callback(_data['sname']);
  231. }
  232. });
  233. }
  234. },
  235. {
  236. label: "房间号", name: "AIIStoragePosition", width: 150, align: "left",
  237. formatterAsync: function (callback, value, row, op, $cell) {
  238. learun.clientdata.getAsync('custmerData', {
  239. url: '/LR_SystemModule/DataSource/GetDataTable?code=' + 'Ass_Storage_Room',
  240. key: value,
  241. keyId: 'rid',
  242. callback: function (_data) {
  243. callback(_data['rcode'] + '(' + _data['rname'] + ')');
  244. }
  245. });
  246. }
  247. },
  248. //{
  249. // label: "报废时间", name: "AIIStoragePosition", width: 100, align: "left", formatter: function (cellvalue, row) {
  250. // if (!!row.AScrapTime && row.ScrapRemindTime > (-1)) {
  251. // var validDate2 = new Date(row.AScrapTime.replace(/-/g, "/"));
  252. // var nowDate = new Date();
  253. // var timerange = datedifference(nowDate, validDate2);
  254. // console.log(timerange);
  255. // if (validDate2 > nowDate && timerange > 0) {
  256. // switch (row.ScrapRemindTime) {
  257. // case 0:
  258. // if (timerange < 30) {
  259. // return '<span class=\"label label-warning\">' + validDate2.Format("yyyy-MM-dd") + '</span>';
  260. // } else {
  261. // return '<span class=\"label label-info\">' + validDate2.Format("yyyy-MM-dd") + '</span>';
  262. // }
  263. // case 1:
  264. // if (timerange >= 30 && timerange < 90) {
  265. // return '<span class=\"label label-warning\">' + row.AScrapTime + '</span>';
  266. // } else {
  267. // return '<span class=\"label label-info\">' + row.AScrapTime + '</span>';
  268. // }
  269. // case 2:
  270. // if (timerange >= 90 && timerange < 180) {
  271. // return '<span class=\"label label-warning\">' + row.AScrapTime + '</span>';
  272. // } else {
  273. // return '<span class=\"label label-info\">' + row.AScrapTime + '</span>';
  274. // }
  275. // case 3:
  276. // if (timerange >= 180 && timerange < 360) {
  277. // return '<span class=\"label label-warning\">' + row.AScrapTime + '</span>';
  278. // } else {
  279. // return '<span class=\"label label-info\">' + row.AScrapTime + '</span>';
  280. // }
  281. // default:
  282. // }
  283. // } else {
  284. // return '<span class=\"label label-danger\">已报废</span>';
  285. // }
  286. // } else {
  287. // return '<span class=\"label label-info\">未设置</span>';
  288. // }
  289. // }
  290. //},
  291. {
  292. label: "规格型号", name: "AISpecificationtype", width: 100, align: "left"
  293. },
  294. {
  295. label: "资产属性", name: "AIAssType", width: 100, align: "left",
  296. formatterAsync: function (callback, value, row, op, $cell) {
  297. learun.clientdata.getAsync('dataItem', {
  298. key: value,
  299. code: 'AssType',
  300. callback: function (_data) {
  301. callback(_data.text);
  302. }
  303. });
  304. }
  305. },
  306. {
  307. label: "计量单位", name: "AIUnits", width: 100, align: "left",
  308. formatterAsync: function (callback, value, row, op, $cell) {
  309. learun.clientdata.getAsync('dataItem',
  310. {
  311. key: value,
  312. code: 'sldw',
  313. callback: function (_data) {
  314. callback(_data.text);
  315. }
  316. })
  317. }
  318. },
  319. { label: "资产价值", name: "AIAssValue", width: 100, align: "left" },
  320. { label: "入账日期", name: "AIAddTime", width: 100, align: "left" },
  321. {
  322. label: "资产分类", name: "AIASSClass", width: 100, align: "left",
  323. formatterAsync: function (callback, value, row, op, $cell) {
  324. learun.clientdata.getAsync('custmerData', {
  325. url: '/LR_SystemModule/DataSource/GetDataTable?code=' + 'Ass_AssetsType',
  326. key: value,
  327. keyId: 'atid',
  328. callback: function (_data) {
  329. callback(_data['aname']);
  330. }
  331. });
  332. }
  333. },
  334. {
  335. label: "资产状态", name: "AIASSState", width: 100, align: "left",
  336. formatterAsync: function (callback, value, row, op, $cell) {
  337. learun.clientdata.getAsync('dataItem', {
  338. key: value,
  339. code: 'AssState',
  340. callback: function (_data) {
  341. callback(_data.text);
  342. }
  343. });
  344. }
  345. },
  346. {
  347. label: "增加方式", name: "AIAddType", width: 100, align: "left",
  348. formatterAsync: function (callback, value, row, op, $cell) {
  349. learun.clientdata.getAsync('dataItem', {
  350. key: value,
  351. code: 'zcly',
  352. callback: function (_data) {
  353. callback(_data.text);
  354. }
  355. });
  356. }
  357. },
  358. { label: "生产厂家", name: "AIManufacturer", width: 100, align: "left" },
  359. { label: "资产品牌", name: "AISpecification", width: 100, align: "left" },
  360. { label: "用途", name: "AIUse", width: 100, align: "left" },
  361. ],
  362. mainId: 'AIId',
  363. isMultiselect: true,
  364. isPage: true,
  365. sidx: 'AICodeNum'
  366. });
  367. page.search();
  368. },
  369. search: function (param) {
  370. param = param || {};
  371. param.AId = AId;
  372. if (currentUser) {
  373. var userInfo = top.learun.clientdata.get(['userinfo']);
  374. param.userId = userInfo.userId;
  375. }
  376. param.AIIsScrap = false;
  377. $('#gridtable').jfGridSet('reload', { queryJson: JSON.stringify(param) });
  378. }
  379. };
  380. refreshGirdData = function () {
  381. page.search();
  382. };
  383. page.init();
  384. }
  385. Date.prototype.Format = function (fmt) { //author: meizz
  386. var o = {
  387. "M+": this.getMonth() + 1, //月份
  388. "d+": this.getDate(), //日
  389. "H+": this.getHours(), //小时
  390. "m+": this.getMinutes(), //分
  391. "s+": this.getSeconds(), //秒
  392. "q+": Math.floor((this.getMonth() + 3) / 3), //季度
  393. "S": this.getMilliseconds() //毫秒
  394. };
  395. if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
  396. for (var k in o)
  397. if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
  398. return fmt;
  399. }
  400. function datedifference(sDate1, sDate2) { //sDate1和sDate2是2006-12-18格式
  401. var dateSpan,
  402. tempDate,
  403. iDays;
  404. sDate1 = Date.parse(sDate1);
  405. sDate2 = Date.parse(sDate2);
  406. dateSpan = sDate2 - sDate1;
  407. dateSpan = Math.abs(dateSpan);
  408. iDays = Math.floor(dateSpan / (24 * 3600 * 1000));
  409. return iDays;
  410. };
  411. function AddPrintContent(html) {
  412. var myHtml = myHtml = html;
  413. // var strBodyStyle="<style>"+document.getElementById("style1").innerHTML+"</style>";
  414. // var strFormHtml=strBodyStyle+"<body>"+myHtml+"</body>";
  415. var strFormHtml = "<body>" + myHtml + "</body>";
  416. LODOP = getLodop();
  417. LODOP.PRINT_INIT("资产编号");
  418. LODOP.SET_PRINT_PAGESIZE(2, '40mm', '32.3mm', "");
  419. LODOP.SET_PRINT_MODE("PRINT_DUPLEX", 2);
  420. LODOP.SET_PRINT_MODE("PRINT_DEFAULTSOURCE", 7);
  421. LODOP.ADD_PRINT_HTM(10, 8, '40mm', '30mm', strFormHtml);
  422. //打印预览
  423. // LODOP.SET_SHOW_MODE("LANDSCAPE_DEFROTATED",1);
  424. // var TaskID1=LODOP.PREVIEW();
  425. // 直接打印
  426. var TaskID1 = LODOP.PRINT();
  427. };
  428. function hiddenButton() {
  429. $("#lr_add").hide();
  430. $("#lr_printBar").hide();
  431. $("#lr_edit").hide();
  432. $("#lr_delete").hide();
  433. $("#lr_detail").hide();
  434. $("#lr_import").hide();
  435. }