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.
 
 
 
 
 
 

498 lines
24 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 = request("currentUser");//我的资产需要用到
  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. $('#dataTree').lrtree({
  30. url: top.$.rootUrl + '/AssetManagementSystem/Ass_AssetsInfo/GetTree',
  31. nodeClick: function (item) {
  32. page.search({ AIASSClass: item.value });
  33. }
  34. });
  35. $('#multiple_condition_query').lrMultipleQuery(function (queryJson) {
  36. page.search(queryJson);
  37. }, 400, 400);
  38. $('#AIIStorageId').lrDataSourceSelect({ code: 'Ass_StorageData', value: 'sid', text: 'sname' });
  39. $('#AIASSState').lrDataItemSelect({ code: 'AssState' });
  40. $('#AIDepartment').lrDepartmentSelect();
  41. // 刷新
  42. $('#lr_refresh').on('click', function () {
  43. location.reload();
  44. });
  45. // 新增
  46. $('#lr_add').on('click', function () {
  47. learun.layerForm({
  48. id: 'form',
  49. title: '新增',
  50. url: top.$.rootUrl + '/AssetManagementSystem/Ass_AssetsInfoItem/Form',
  51. width: 800,
  52. height: 700,
  53. callBack: function (id) {
  54. return top[id].acceptClick(refreshGirdData);
  55. }
  56. });
  57. });
  58. //标签打印
  59. var qrcode = new QRCode(document.getElementById("qrcode"), {
  60. width: 80,
  61. height: 80
  62. });
  63. $("#lr_printBar").on('click', function () {
  64. //var keyValue = $('#gridtable').jfGridValue('AICode');
  65. var keyValue = $('#gridtable').jfGridValue('AIId');
  66. var AName = $('#gridtable').jfGridValue('AIASSName');
  67. if (learun.checkrow(keyValue)) {
  68. //todo 打印标签
  69. //$('.qrcodeTxt').html(keyValue);
  70. ////标签打印
  71. //qrcode.makeCode(keyValue);
  72. //setTimeout(function () {
  73. // var html = $('.qrcodeBox').html();
  74. // // console.log(html)
  75. // AddPrintContent(html);
  76. // qrcode.clear();
  77. //}, 300)
  78. //AddPrintContent(html)
  79. learun.layerForm({
  80. id: 'formcardprint',
  81. title: '打印二维码',
  82. url: top.$.rootUrl + '/AssetManagementSystem/Ass_AssetsInfoItem/QRPrint?keyValue=' + keyValue + '&aName=' + escape(AName),
  83. width: 700,
  84. height: 300,
  85. btn: null,
  86. end: function () { refreshGirdData(); }
  87. });
  88. }
  89. })
  90. // 编辑
  91. $('#lr_edit').on('click', function () {
  92. var keyValue = $('#gridtable').jfGridValue('AIId');
  93. if (learun.checkrow(keyValue)) {
  94. learun.layerForm({
  95. id: 'forminfoitem',
  96. title: '编辑',
  97. url: top.$.rootUrl + '/AssetManagementSystem/Ass_AssetsInfoItem/Form?keyValue=' + keyValue,
  98. width: 800,
  99. height: 700,
  100. callBack: function (id) {
  101. return top[id].acceptClick(refreshGirdData);
  102. }
  103. });
  104. }
  105. });
  106. //查看
  107. $('#lr_view').on('click', function () {
  108. var keyValue = $('#gridtable').jfGridValue('AIId');
  109. if (learun.checkrow(keyValue)) {
  110. learun.layerForm({
  111. id: 'forminfoitem',
  112. title: '查看',
  113. url: top.$.rootUrl + '/AssetManagementSystem/Ass_AssetsInfoItem/FormView?keyValue=' + keyValue,
  114. width: 800,
  115. height: 700,
  116. btn: '',
  117. callBack: function (id) {
  118. return top[id].acceptClick(refreshGirdData);
  119. }
  120. });
  121. }
  122. });
  123. //出入记录
  124. $('#lr_detail').on('click', function () {
  125. var keyValue = $('#gridtable').jfGridValue('AIId');
  126. if (learun.checkrow(keyValue)) {
  127. learun.layerForm({
  128. id: 'formdetail',
  129. title: '出入库记录',
  130. url: top.$.rootUrl + '/AssetManagementSystem/Ass_AssetsChangeItem/Index?AIId=' + keyValue,
  131. width: 940,
  132. height: 600,
  133. btn: null
  134. });
  135. }
  136. });
  137. //查看使用人员变动记录
  138. $('#lr_usedetail').on('click', function () {
  139. var keyValue = $('#gridtable').jfGridValue('AIId');
  140. if (learun.checkrow(keyValue)) {
  141. learun.layerForm({
  142. id: 'formusedetail',
  143. title: '使用人员变动记录',
  144. url: top.$.rootUrl + '/AssetManagementSystem/Ass_UserChangeInfo/Index?AIId=' + keyValue,
  145. width: 940,
  146. height: 600,
  147. btn: null
  148. });
  149. }
  150. });
  151. // 删除
  152. $('#lr_delete').on('click', function () {
  153. var keyValue = $('#gridtable').jfGridValue('AIId');
  154. if (learun.checkrow(keyValue)) {
  155. learun.layerConfirm('是否确认删除该项!', function (res) {
  156. if (res) {
  157. learun.deleteForm(top.$.rootUrl + '/AssetManagementSystem/Ass_AssetsInfoItem/DeleteForm', { keyValue: keyValue }, function () {
  158. refreshGirdData();
  159. });
  160. }
  161. });
  162. }
  163. });
  164. // 报废
  165. $('#lr_scrap').on('click', function () {
  166. var keyValue = $('#gridtable').jfGridValue('AIId');
  167. if (learun.checkrow(keyValue)) {
  168. learun.layerConfirm('是否确认报废!', function (res) {
  169. if (res) {
  170. learun.deleteForm(top.$.rootUrl + '/AssetManagementSystem/Ass_AssetsInfoItem/ScrapForm', { keyValue: keyValue }, function () {
  171. refreshGirdData();
  172. });
  173. }
  174. });
  175. }
  176. });
  177. //生成二维码
  178. $('#lr_getqrcode').on('click', function () {
  179. //console.log($('#gridtable')[0].dfop.running);
  180. var keyValue = $('#gridtable').jfGridValue('AIId');
  181. //js方法:
  182. //if (keyValue != null && keyValue != "" && keyValue != undefined) {
  183. // //console.log("有选中");
  184. //} else {
  185. // //console.log("无选中");
  186. // if ($('#gridtable')[0].dfop.running.rowdata.length > 100) {
  187. // learun.alert.warning("最多可以选择100条数据!");
  188. // return false;
  189. // }
  190. // var bb = new Array();
  191. // for (var i = 0; i < $('#gridtable')[0].dfop.running.rowdata.length; i++) {
  192. // bb.push($('#gridtable')[0].dfop.running.rowdata[i]["jfgridRowData"]["AIId"]);
  193. // }
  194. // keyValue = bb.toString();
  195. //}
  196. learun.postForm(top.$.rootUrl + '/AssetManagementSystem/Ass_AssetsInfoItem/GetQRCode', { keyValue: keyValue, pagination: $('#gridtable')[0].dfop.running.pageparam }, function (res) {
  197. //console.log(res);
  198. if (res && res.code == "200") {
  199. //top.layer.alert("二维码图片地址为:" + res.data, { icon: 7, title: "提示", yes: function (index) { layer.close(index) } });
  200. //下载文件
  201. for (var i = 0; i < res.data.length; i++) {
  202. learun.download({ url: top.$.rootUrl + '/AssetManagementSystem/Ass_AssetsInfoItem/DownFile', param: { path: res.data[i], __RequestVerificationToken: $.lrToken }, method: 'POST' });
  203. }
  204. }
  205. });
  206. });
  207. },
  208. // 初始化列表
  209. initGird: function () {
  210. $('#gridtable').jfGrid({
  211. url: top.$.rootUrl + '/AssetManagementSystem/Ass_AssetsInfoItem/GetPageList',
  212. headData: [
  213. { label: "明细编号", name: "AICode", width: 200, align: "left" },
  214. { label: "资产编号", name: "AICodeNumJY", width: 200, align: "left" },
  215. { label: "名称", name: "AIASSName", width: 200, align: "left" },
  216. {
  217. label: "部门", name: "AIDepartment", width: 100, align: "left",
  218. formatterAsync: function (callback, value, row, op, $cell) {
  219. learun.clientdata.getAsync('department', {
  220. key: value,
  221. callback: function (_data) {
  222. callback(_data.name);
  223. }
  224. });
  225. }
  226. },
  227. {
  228. label: "使用人员", name: "AIUsePeople", width: 100, align: "left",
  229. formatterAsync: function (callback, value, row, op, $cell) {
  230. learun.clientdata.getAsync('custmerData', {
  231. url: '/LR_SystemModule/DataSource/GetDataTable?code=' + 'BaseUser',
  232. key: value,
  233. keyId: 'f_userid',
  234. callback: function (_data) {
  235. callback(_data['f_realname']);
  236. }
  237. });
  238. }
  239. },
  240. {
  241. label: "所在库房", name: "AIIStorageId", width: 100, align: "left",
  242. formatterAsync: function (callback, value, row, op, $cell) {
  243. learun.clientdata.getAsync('custmerData', {
  244. url: '/LR_SystemModule/DataSource/GetDataTable?code=' + 'Ass_StorageData',
  245. key: value,
  246. keyId: 'sid',
  247. callback: function (_data) {
  248. callback(_data['sname']);
  249. }
  250. });
  251. }
  252. },
  253. { label: "所在库位", name: "AIIStoragePosition", width: 100, align: "left" },
  254. //{
  255. // label: "报废时间", name: "AIIStoragePosition", width: 100, align: "left", formatter: function (cellvalue, row) {
  256. // if (!!row.AScrapTime && row.ScrapRemindTime > (-1)) {
  257. // var validDate2 = new Date(row.AScrapTime.replace(/-/g, "/"));
  258. // var nowDate = new Date();
  259. // var timerange = datedifference(nowDate, validDate2);
  260. // console.log(timerange);
  261. // if (validDate2 > nowDate && timerange > 0) {
  262. // switch (row.ScrapRemindTime) {
  263. // case 0:
  264. // if (timerange < 30) {
  265. // return '<span class=\"label label-warning\">' + validDate2.Format("yyyy-MM-dd") + '</span>';
  266. // } else {
  267. // return '<span class=\"label label-info\">' + validDate2.Format("yyyy-MM-dd") + '</span>';
  268. // }
  269. // case 1:
  270. // if (timerange >= 30 && timerange < 90) {
  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 2:
  276. // if (timerange >= 90 && timerange < 180) {
  277. // return '<span class=\"label label-warning\">' + row.AScrapTime + '</span>';
  278. // } else {
  279. // return '<span class=\"label label-info\">' + row.AScrapTime + '</span>';
  280. // }
  281. // case 3:
  282. // if (timerange >= 180 && timerange < 360) {
  283. // return '<span class=\"label label-warning\">' + row.AScrapTime + '</span>';
  284. // } else {
  285. // return '<span class=\"label label-info\">' + row.AScrapTime + '</span>';
  286. // }
  287. // default:
  288. // }
  289. // } else {
  290. // return '<span class=\"label label-danger\">已报废</span>';
  291. // }
  292. // } else {
  293. // return '<span class=\"label label-info\">未设置</span>';
  294. // }
  295. // }
  296. //},
  297. {
  298. label: "资产型号", name: "AISpecificationtype", width: 100, align: "left"
  299. },
  300. {
  301. label: "资产属性", name: "AIAssType", width: 100, align: "left",
  302. formatterAsync: function (callback, value, row, op, $cell) {
  303. learun.clientdata.getAsync('dataItem', {
  304. key: value,
  305. code: 'AssType',
  306. callback: function (_data) {
  307. callback(_data.text);
  308. }
  309. });
  310. }
  311. },
  312. {
  313. label: "计量单位", name: "AIUnits", width: 100, align: "left",
  314. formatterAsync: function (callback, value, row, op, $cell) {
  315. learun.clientdata.getAsync('dataItem',
  316. {
  317. key: value,
  318. code: 'sldw',
  319. callback: function (_data) {
  320. callback(_data.text);
  321. }
  322. })
  323. }
  324. },
  325. { label: "资产价值", name: "AIAssValue", width: 100, align: "left" },
  326. { label: "购置日期", name: "AIAddTime", width: 100, align: "left" },
  327. {
  328. label: "资产分类", name: "AIASSClass", width: 100, align: "left",
  329. formatterAsync: function (callback, value, row, op, $cell) {
  330. learun.clientdata.getAsync('custmerData', {
  331. url: '/LR_SystemModule/DataSource/GetDataTable?code=' + 'Ass_AssetsType',
  332. key: value,
  333. keyId: 'atid',
  334. callback: function (_data) {
  335. callback(_data['aname']);
  336. }
  337. });
  338. }
  339. },
  340. {
  341. label: "资产状态", name: "AIASSState", width: 100, align: "left",
  342. formatterAsync: function (callback, value, row, op, $cell) {
  343. learun.clientdata.getAsync('dataItem', {
  344. key: value,
  345. code: 'AssState',
  346. callback: function (_data) {
  347. callback(_data.text);
  348. }
  349. });
  350. }
  351. },
  352. {
  353. label: "增加方式", name: "AIAddType", width: 100, align: "left",
  354. formatterAsync: function (callback, value, row, op, $cell) {
  355. learun.clientdata.getAsync('dataItem', {
  356. key: value,
  357. code: 'zcly',
  358. callback: function (_data) {
  359. callback(_data.text);
  360. }
  361. });
  362. }
  363. },
  364. { label: "生产厂家", name: "AIManufacturer", width: 100, align: "left" },
  365. { label: "资产规格", name: "AISpecification", width: 100, align: "left" },
  366. { label: "用途", name: "AIUse", width: 100, align: "left" },
  367. { label: "采购组织形式", name: "ProcurementOrganizationForm", width: 100, align: "left" },
  368. { label: "预算项目编号", name: "BudgetItemNo", width: 100, align: "left" },
  369. { label: "取得方式", name: "MethodOfAcquisition", width: 100, align: "left" },
  370. { label: "取得日期", name: "TimeOfAcquisition", width: 100, align: "left" },
  371. { label: "产品序列号", name: "ProjectID", width: 100, align: "left" },
  372. { label: "销售商", name: "Seller", width: 100, align: "left" },
  373. { label: "合同编号", name: "ContractNo", width: 100, align: "left" },
  374. { label: "发票号", name: "InvoiceNumber", width: 100, align: "left" },
  375. { label: "配置标准分类名称", name: "ConfigurationName", width: 100, align: "left" },
  376. { label: "保修截止日期", name: "GuaranteeEndTime", width: 100, align: "left" },
  377. { label: "入账形式", name: "EntryForm", width: 100, align: "left" },
  378. { label: "价值类型", name: "ValueType", width: 100, align: "left" },
  379. { label: "财政拨款", name: "FinancialAllocation", width: 100, align: "left" },
  380. { label: "非财政拨款", name: "NonFinancialAppropriation", width: 100, align: "left" },
  381. { label: "使用状况", name: "Usage", width: 100, align: "left" },
  382. { label: "投入使用日期", name: "DateOfCommissioning", width: 100, align: "left" },
  383. { label: "管理部门", name: "AdministrativeDepartment", width: 100, align: "left" },
  384. { label: "折旧状态", name: "DepreciationStatus", width: 100, align: "left" },
  385. { label: "折旧方法", name: "DepreciationMethod", width: 100, align: "left" },
  386. { label: "已提折旧月数", name: "MonthsOfDepreciation", width: 100, align: "left" },
  387. { label: "累计折旧", name: "AccumulatedDepreciation", width: 100, align: "left" },
  388. { label: "折旧年限(月)", name: "UsefulLife", width: 100, align: "left" },
  389. { label: "月折旧额", name: "MonthlyDepreciation", width: 100, align: "left" },
  390. { label: "残值率", name: "ResidualValueRate", width: 100, align: "left" },
  391. ],
  392. mainId: 'AIId',
  393. isMultiselect: true,
  394. isPage: true,
  395. sidx: 'AICodeNum',
  396. });
  397. page.search();
  398. },
  399. search: function (param) {
  400. param = param || {};
  401. param.AId = AId;
  402. if (currentUser) {
  403. var userInfo = top.learun.clientdata.get(['userinfo']);
  404. param.userId = userInfo.userId;
  405. }
  406. param.AIIsScrap = false;
  407. $('#gridtable').jfGridSet('reload', { queryJson: JSON.stringify(param) });
  408. }
  409. };
  410. refreshGirdData = function () {
  411. page.search();
  412. };
  413. page.init();
  414. }
  415. Date.prototype.Format = function (fmt) { //author: meizz
  416. var o = {
  417. "M+": this.getMonth() + 1, //月份
  418. "d+": this.getDate(), //日
  419. "H+": this.getHours(), //小时
  420. "m+": this.getMinutes(), //分
  421. "s+": this.getSeconds(), //秒
  422. "q+": Math.floor((this.getMonth() + 3) / 3), //季度
  423. "S": this.getMilliseconds() //毫秒
  424. };
  425. if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
  426. for (var k in o)
  427. if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
  428. return fmt;
  429. }
  430. function datedifference(sDate1, sDate2) { //sDate1和sDate2是2006-12-18格式
  431. var dateSpan,
  432. tempDate,
  433. iDays;
  434. sDate1 = Date.parse(sDate1);
  435. sDate2 = Date.parse(sDate2);
  436. dateSpan = sDate2 - sDate1;
  437. dateSpan = Math.abs(dateSpan);
  438. iDays = Math.floor(dateSpan / (24 * 3600 * 1000));
  439. return iDays;
  440. };
  441. function AddPrintContent(html) {
  442. var myHtml = myHtml = html;
  443. // var strBodyStyle="<style>"+document.getElementById("style1").innerHTML+"</style>";
  444. // var strFormHtml=strBodyStyle+"<body>"+myHtml+"</body>";
  445. var strFormHtml = "<body>" + myHtml + "</body>";
  446. LODOP = getLodop();
  447. LODOP.PRINT_INIT("资产编号");
  448. LODOP.SET_PRINT_PAGESIZE(2, '40mm', '32.3mm', "");
  449. LODOP.SET_PRINT_MODE("PRINT_DUPLEX", 2);
  450. LODOP.SET_PRINT_MODE("PRINT_DEFAULTSOURCE", 7);
  451. LODOP.ADD_PRINT_HTM(10, 8, '40mm', '30mm', strFormHtml);
  452. //打印预览
  453. // LODOP.SET_SHOW_MODE("LANDSCAPE_DEFROTATED",1);
  454. // var TaskID1=LODOP.PREVIEW();
  455. // 直接打印
  456. var TaskID1 = LODOP.PRINT();
  457. };
  458. function hiddenButton() {
  459. $("#lr_add").hide();
  460. $("#lr_printBar").hide();
  461. $("#lr_edit").hide();
  462. $("#lr_delete").hide();
  463. $("#lr_detail").hide();
  464. $("#lr_import").hide();
  465. }