/* * 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园(http://www.learun.cn) * Copyright (c) 2013-2018 北京泉江科技有限公司 * 创建人:超级管理员 * 日 期:2019-03-29 11:27 * 描 述:在册登记明细 */ var refreshGirdData; var AId = request("AId"); var currentUser = request("currentUser");//我的资产需要用到 var IsDelete = request("IsDelete");//报废资产需要使用 var bootstrap = function ($, learun) { "use strict"; var page = { init: function () { page.initGird(); page.bind(); if (currentUser) { setTimeout("hiddenButton()", 300); } }, bind: function () { // 初始化左侧树形数据lr_printBar //$('#dataTree').lrtree({ // url: top.$.rootUrl + '/AssetManagementSystem/Ass_AssetsInfoItem/GetTree', // nodeClick: function (item) { // page.search({ AIAssType: item.value }); // } //}); $('#dataTree').lrtree({ url: top.$.rootUrl + '/AssetManagementSystem/Ass_AssetsInfo/GetTree', nodeClick: function (item) { page.search({ AIASSClass: item.value }); } }); $('#multiple_condition_query').lrMultipleQuery(function (queryJson) { page.search(queryJson); }, 400, 400); $('#AIIStorageId').lrDataSourceSelect({ code: 'Ass_StorageData', value: 'sid', text: 'sname' }); $('#AIASSState').lrDataItemSelect({ code: 'AssState' }); $('#AIDepartment').lrDepartmentSelect(); // 刷新 $('#lr_refresh').on('click', function () { location.reload(); }); // 新增 $('#lr_add').on('click', function () { learun.layerForm({ id: 'form', title: '新增', url: top.$.rootUrl + '/AssetManagementSystem/Ass_AssetsInfoItem/Form', width: 800, height: 700, callBack: function (id) { return top[id].acceptClick(refreshGirdData); } }); }); //标签打印 var qrcode = new QRCode(document.getElementById("qrcode"), { width: 80, height: 80 }); $("#lr_printBar").on('click', function () { var keyValue = $('#gridtable').jfGridValue('AICode'); var AName = $('#gridtable').jfGridValue('AIASSName'); if (learun.checkrow(keyValue)) { //todo 打印标签 //$('.qrcodeTxt').html(keyValue); ////标签打印 //qrcode.makeCode(keyValue); //setTimeout(function () { // var html = $('.qrcodeBox').html(); // // console.log(html) // AddPrintContent(html); // qrcode.clear(); //}, 300) //AddPrintContent(html) learun.layerForm({ id: 'formcardprint', title: '打印二维码', url: top.$.rootUrl + '/AssetManagementSystem/Ass_AssetsInfoItem/QRPrint?keyValue=' + keyValue+'&aName='+escape(AName), width: 700, height: 300, btn: null, end: function () { refreshGirdData(); } }); } }) // 编辑 $('#lr_edit').on('click', function () { var keyValue = $('#gridtable').jfGridValue('AIId'); if (learun.checkrow(keyValue)) { learun.layerForm({ id: 'forminfoitem', title: '编辑', url: top.$.rootUrl + '/AssetManagementSystem/Ass_AssetsInfoItem/Form?keyValue=' + keyValue, width: 800, height: 700, callBack: function (id) { return top[id].acceptClick(refreshGirdData); } }); } }); //查看 $('#lr_view').on('click', function () { var keyValue = $('#gridtable').jfGridValue('AIId'); if (learun.checkrow(keyValue)) { learun.layerForm({ id: 'forminfoitem', title: '查看', url: top.$.rootUrl + '/AssetManagementSystem/Ass_AssetsInfoItem/FormView?keyValue=' + keyValue, width: 800, height: 700, btn: '', callBack: function (id) { return top[id].acceptClick(refreshGirdData); } }); } }); //出入记录 $('#lr_detail').on('click', function () { var keyValue = $('#gridtable').jfGridValue('AIId'); if (learun.checkrow(keyValue)) { learun.layerForm({ id: 'formdetail', title: '出入库记录', url: top.$.rootUrl + '/AssetManagementSystem/Ass_AssetsChangeItem/Index?AIId=' + keyValue, width: 940, height: 600, btn: null }); } }); //查看使用人员变动记录 $('#lr_usedetail').on('click', function () { var keyValue = $('#gridtable').jfGridValue('AIId'); if (learun.checkrow(keyValue)) { learun.layerForm({ id: 'formusedetail', title: '使用人员变动记录', url: top.$.rootUrl + '/AssetManagementSystem/Ass_UserChangeInfo/Index?AIId=' + keyValue, width: 940, height: 600, btn: null }); } }); // 删除 $('#lr_delete').on('click', function () { var keyValue = $('#gridtable').jfGridValue('AIId'); if (learun.checkrow(keyValue)) { learun.layerConfirm('是否确认删除该项!', function (res) { if (res) { learun.deleteForm(top.$.rootUrl + '/AssetManagementSystem/Ass_AssetsInfoItem/DeleteForm', { keyValue: keyValue }, function () { refreshGirdData(); }); } }); } }); // 报废 $('#lr_scrap').on('click', function () { var keyValue = $('#gridtable').jfGridValue('AIId'); if (learun.checkrow(keyValue)) { learun.layerConfirm('是否确认报废!', function (res) { if (res) { learun.deleteForm(top.$.rootUrl + '/AssetManagementSystem/Ass_AssetsInfoItem/ScrapForm', { keyValue: keyValue }, function () { refreshGirdData(); }); } }); } }); }, // 初始化列表 initGird: function () { $('#gridtable').jfGrid({ url: top.$.rootUrl + '/AssetManagementSystem/Ass_AssetsInfoItem/GetPageList', headData: [ { label: "明细编号", name: "AICode", width: 200, align: "left" }, { label: "资产编号", name: "AICodeNumJY", width: 200, align: "left" }, { label: "名称", name: "AIASSName", width: 200, align: "left" }, { label: "部门", name: "AIDepartment", width: 100, align: "left", formatterAsync: function (callback, value, row, op, $cell) { learun.clientdata.getAsync('department', { key: value, callback: function (_data) { callback(_data.name); } }); } }, { label: "使用人员", name: "AIUsePeople", width: 100, align: "left", formatterAsync: function (callback, value, row, op, $cell) { learun.clientdata.getAsync('custmerData', { url: '/LR_SystemModule/DataSource/GetDataTable?code=' + 'BaseUser', key: value, keyId: 'f_userid', callback: function (_data) { callback(_data['f_realname']); } }); } }, { label: "所在库房", name: "AIIStorageId", width: 100, align: "left", formatterAsync: function (callback, value, row, op, $cell) { learun.clientdata.getAsync('custmerData', { url: '/LR_SystemModule/DataSource/GetDataTable?code=' + 'Ass_StorageData', key: value, keyId: 'sid', callback: function (_data) { callback(_data['sname']); } }); } }, { label: "所在库位", name: "AIIStoragePosition", width: 100, align: "left" }, //{ // label: "报废时间", name: "AIIStoragePosition", width: 100, align: "left", formatter: function (cellvalue, row) { // if (!!row.AScrapTime && row.ScrapRemindTime > (-1)) { // var validDate2 = new Date(row.AScrapTime.replace(/-/g, "/")); // var nowDate = new Date(); // var timerange = datedifference(nowDate, validDate2); // console.log(timerange); // if (validDate2 > nowDate && timerange > 0) { // switch (row.ScrapRemindTime) { // case 0: // if (timerange < 30) { // return '' + validDate2.Format("yyyy-MM-dd") + ''; // } else { // return '' + validDate2.Format("yyyy-MM-dd") + ''; // } // case 1: // if (timerange >= 30 && timerange < 90) { // return '' + row.AScrapTime + ''; // } else { // return '' + row.AScrapTime + ''; // } // case 2: // if (timerange >= 90 && timerange < 180) { // return '' + row.AScrapTime + ''; // } else { // return '' + row.AScrapTime + ''; // } // case 3: // if (timerange >= 180 && timerange < 360) { // return '' + row.AScrapTime + ''; // } else { // return '' + row.AScrapTime + ''; // } // default: // } // } else { // return '已报废'; // } // } else { // return '未设置'; // } // } //}, { label: "资产型号", name: "AISpecificationtype", width: 100, align: "left" }, { label: "资产属性", name: "AIAssType", width: 100, align: "left", formatterAsync: function (callback, value, row, op, $cell) { learun.clientdata.getAsync('dataItem', { key: value, code: 'AssType', callback: function (_data) { callback(_data.text); } }); } }, { label: "计量单位", name: "AIUnits", width: 100, align: "left", formatterAsync: function (callback, value, row, op, $cell) { learun.clientdata.getAsync('dataItem', { key: value, code: 'sldw', callback: function (_data) { callback(_data.text); } }) } }, { label: "资产价值", name: "AIAssValue", width: 100, align: "left" }, { label: "购置日期", name: "AIAddTime", width: 100, align: "left" }, { label: "资产分类", name: "AIASSClass", width: 100, align: "left", formatterAsync: function (callback, value, row, op, $cell) { learun.clientdata.getAsync('custmerData', { url: '/LR_SystemModule/DataSource/GetDataTable?code=' + 'Ass_AssetsType', key: value, keyId: 'atid', callback: function (_data) { callback(_data['aname']); } }); } }, { label: "资产状态", name: "AIASSState", width: 100, align: "left", formatterAsync: function (callback, value, row, op, $cell) { learun.clientdata.getAsync('dataItem', { key: value, code: 'AssState', callback: function (_data) { callback(_data.text); } }); } }, { label: "增加方式", name: "AIAddType", width: 100, align: "left", formatterAsync: function (callback, value, row, op, $cell) { learun.clientdata.getAsync('dataItem', { key: value, code: 'zcly', callback: function (_data) { callback(_data.text); } }); } }, { label: "生产厂家", name: "AIManufacturer", width: 100, align: "left" }, { label: "资产规格", name: "AISpecification", width: 100, align: "left" }, { label: "用途", name: "AIUse", width: 100, align: "left" }, { label: "采购组织形式", name: "ProcurementOrganizationForm", width: 100, align: "left" }, { label: "预算项目编号", name: "BudgetItemNo", width: 100, align: "left" }, { label: "取得方式", name: "MethodOfAcquisition", width: 100, align: "left" }, { label: "取得日期", name: "TimeOfAcquisition", width: 100, align: "left" }, { label: "产品序列号", name: "ProjectID", width: 100, align: "left" }, { label: "销售商", name: "Seller", width: 100, align: "left" }, { label: "合同编号", name: "ContractNo", width: 100, align: "left" }, { label: "发票号", name: "InvoiceNumber", width: 100, align: "left" }, { label: "配置标准分类名称", name: "ConfigurationName", width: 100, align: "left" }, { label: "保修截止日期", name: "GuaranteeEndTime", width: 100, align: "left" }, { label: "入账形式", name: "EntryForm", width: 100, align: "left" }, { label: "价值类型", name: "ValueType", width: 100, align: "left" }, { label: "财政拨款", name: "FinancialAllocation", width: 100, align: "left" }, { label: "非财政拨款", name: "NonFinancialAppropriation", width: 100, align: "left" }, { label: "使用状况", name: "Usage", width: 100, align: "left" }, { label: "投入使用日期", name: "DateOfCommissioning", width: 100, align: "left" }, { label: "管理部门", name: "AdministrativeDepartment", width: 100, align: "left" }, { label: "折旧状态", name: "DepreciationStatus", width: 100, align: "left" }, { label: "折旧方法", name: "DepreciationMethod", width: 100, align: "left" }, { label: "已提折旧月数", name: "MonthsOfDepreciation", width: 100, align: "left" }, { label: "累计折旧", name: "AccumulatedDepreciation", width: 100, align: "left" }, { label: "折旧年限(月)", name: "UsefulLife", width: 100, align: "left" }, { label: "月折旧额", name: "MonthlyDepreciation", width: 100, align: "left" }, { label: "残值率", name: "ResidualValueRate", width: 100, align: "left" }, ], mainId: 'AIId', isMultiselect: true, isPage: true, sidx: 'AICodeNum' }); page.search(); }, search: function (param) { param = param || {}; param.AId = AId; if (currentUser) { var userInfo = top.learun.clientdata.get(['userinfo']); param.userId = userInfo.userId; } param.AIIsScrap = false; $('#gridtable').jfGridSet('reload', { queryJson: JSON.stringify(param) }); } }; refreshGirdData = function () { page.search(); }; page.init(); } Date.prototype.Format = function (fmt) { //author: meizz var o = { "M+": this.getMonth() + 1, //月份 "d+": this.getDate(), //日 "H+": this.getHours(), //小时 "m+": this.getMinutes(), //分 "s+": this.getSeconds(), //秒 "q+": Math.floor((this.getMonth() + 3) / 3), //季度 "S": this.getMilliseconds() //毫秒 }; if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length)); for (var k in o) if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length))); return fmt; } function datedifference(sDate1, sDate2) { //sDate1和sDate2是2006-12-18格式 var dateSpan, tempDate, iDays; sDate1 = Date.parse(sDate1); sDate2 = Date.parse(sDate2); dateSpan = sDate2 - sDate1; dateSpan = Math.abs(dateSpan); iDays = Math.floor(dateSpan / (24 * 3600 * 1000)); return iDays; }; function AddPrintContent(html) { var myHtml = myHtml = html; // var strBodyStyle=""; // var strFormHtml=strBodyStyle+""+myHtml+""; var strFormHtml = "" + myHtml + ""; LODOP = getLodop(); LODOP.PRINT_INIT("资产编号"); LODOP.SET_PRINT_PAGESIZE(2, '40mm', '32.3mm', ""); LODOP.SET_PRINT_MODE("PRINT_DUPLEX", 2); LODOP.SET_PRINT_MODE("PRINT_DEFAULTSOURCE", 7); LODOP.ADD_PRINT_HTM(10, 8, '40mm', '30mm', strFormHtml); //打印预览 // LODOP.SET_SHOW_MODE("LANDSCAPE_DEFROTATED",1); // var TaskID1=LODOP.PREVIEW(); // 直接打印 var TaskID1 = LODOP.PRINT(); }; function hiddenButton() { $("#lr_add").hide(); $("#lr_printBar").hide(); $("#lr_edit").hide(); $("#lr_delete").hide(); $("#lr_detail").hide(); $("#lr_import").hide(); }