/* * 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园(http://www.learun.cn) * Copyright (c) 2013-2018 北京泉江科技有限公司 * 创建人:超级管理员 * 日 期:2019-03-29 11:27 * 描 述:在册登记明细 */ var refreshGirdData; var bootstrap = function ($, learun) { "use strict"; var page = { init: function () { page.initGird(); page.bind(); }, bind: function () { // 初始化左侧树形数据 $('#dataTree').lrtree({ url: top.$.rootUrl + '/AssetManagementSystem/Ass_AssetsInfoItem/GetTree', nodeClick: function (item) { page.search({ AIAssType: 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'); 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, 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_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/UnScrapForm', { keyValue: keyValue }, function () { refreshGirdData(); }); } }); } }); }, // 初始化列表 initGird: function () { $('#gridtable').lrAuthorizeJfGrid({ 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) { console.log(value); 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" }, ], mainId: 'AIId', isMultiselect: true, isPage: true, sidx: 'AICodeNum' }); page.search(); }, search: function (param) { param = param || {}; param.AIASSState = "2"; $('#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(); };