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.
 
 
 
 
 
 

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