define(function (require) { return function () { var $grid1, $form; var widgets = { // 派工号 selectPmgPghWidget: { url: '/app/wms/widget/selectPmsPgh.js', bind: { pghId: 'pghId', pghCode: 'pghCode' }, widgetPrompt: "派工号编号" }, }; function enterQueryGrid1(e) { if (e.keyCode === 13) { var tmp = $(this).val(); $form.formSet({queryProperties: tmp}); queryGrid1(); } } // 查询列表 function queryGrid1() { var obj = $form.formGet(); var startTime = new Date(obj.startTime.replace("-", "/")); var endTime = new Date(obj.endTime.replace("-", "/")); if (startTime > endTime) { $.yvan.msg('起止日期必须大于起始日期'); return; } var queryUrl = '/wms/wmsOutPoolmat/queryStockMiss';// 自行替换此参数 $grid1.jqGrid("clearGridData"); var queryForm1 = $form.formGet(); $grid1.reload({ mtype: 'post', url: api(queryUrl), queryParams: queryForm1 }, true); } //获取库区 function getFarmList() { var _datas = []; _datas.push({ "id": '', "text": '全部' }) $.yvan.ajax({ url: api('/wms/whFarm/queryAll'), data: {}, method: 'post', async: false, success: function (data) { if (data.data != null && data.data != undefined) { for (var i = 0; i < data.data.length; i++) { _datas.push({ "id": data.data[i].farmId, "text": data.data[i].farmName }) } } } }); return _datas; } //获取车间信息 function getRoomList() { var _datas = [{"id": '', "text": '全部'}]; $.yvan.ajax({ url: api('/wms/wmsOutPoolmat/queryRoomByMiss'), method: 'post', async: false, success: function (data) { if (data.data != null && data.data != undefined) { for (var i = 0; i < data.data.length; i++) { _datas.push({ "id": data.data[i].roomId, "text": data.data[i].roomName }) } } } }); return _datas; } // 搜索按钮 var queryToolbarTitle = '缺件查询';// 自行替换此参数 var queryToolbar = { xtype: 'toolbar', title: queryToolbarTitle, items: [ { text: '查询', iconCls: 'fa fa-search', onClick: function () { queryGrid1(); } }, { text: '重置', iconCls: 'fa fa-refresh', onClick: function () { $form.formClear(); queryGrid1(); } }, { text: '关闭', iconCls: 'fa fa-times-circle', onClick: function () { App.closeMe(this); } } ] }; // 搜索条件 var queryFormPrompt = '需求单号/派工号/物资编码/图号型号/物资名称/申请人';// 自行替换此参数 var queryForm = { onRender: function () { $form = $(this); }, xtype: 'form', items: [ [ {xtype: 'hidden', name: 'pghId'}, { xtype: 'searchbox', label: '派工号', name: 'pghCode', labelWidth: 'auto', width: 250, prompt: '派工号编号', widget: widgets.selectPmgPghWidget, onChange: function (data) { queryGrid1(); } }, { xtype: 'yvselect', label: '需求车间', name: 'roomId', labelWidth: 'auto', width: 240, data: getRoomList(), onChange: function () { queryGrid1(); } }, { xtype: 'yvselect', label: '需求阶段', name: 'outapType', labelWidth: 'auto', width: 180, value: '', data: $.yvan.sysDict('outapType').combowithAll(), onChange: function () { queryGrid1(); } }, { xtype: 'yvselect', label: '需求库区', name: 'farmId', labelWidth: 'auto', width: 200, value: '', data: getFarmList(), onChange: function () { queryGrid1(); } }, { xtype: 'yvselect', label: '允许混批', name: 'batchMix', labelWidth: 'auto', width: 180, value: '', data: $.yvan.sysDict('batchMix').combowithAll(), onChange: function () { queryGrid1(); } }, { xtype: 'yvselect', label: '物资分类', name: 'matType', labelWidth: 'auto', width: 180, data: $.yvan.sysDict('matType').combowithAll(), value: '', onChange: function () { queryGrid1(); } }, ], [ { xtype: 'textbox', label: '检索条件', name: 'queryProperties', prompt: queryFormPrompt, labelWidth: 'auto', width: 450, events: {keydown: enterQueryGrid1} }, { name: 'startTime', label: '需求日期', prompt: '开始时间', xtype: 'datebox', labelWidth: 'auto', width: 210, onChange: function () { queryGrid1(); } }, { name: 'endTime', label: '至', prompt: '结束时间', xtype: 'datebox', labelWidth: 'auto', width: 170, onChange: function () { queryGrid1(); } }, ] ] }; // 列表1增删改查按钮 var gridToolbarTitle1 = '缺件详情';// 自行替换此参数 var gridToolbar1 = { xtype: 'toolbar', title: gridToolbarTitle1, items: [ { text: '导出数据', iconCls: 'fa fa-cloud-upload', onClick: function () { var para = ""; if ($form.formGet().pghId != "") { para = (para == "") ? "" : para + "&"; para += "pghId=" + $form.formGet().pghId; } if ($form.formGet().outapType != "") { para = (para == "") ? "" : para + "&"; para += "outapType=" + $form.formGet().outapType; } if ($form.formGet().farmId != "") { para = (para == "") ? "" : para + "&"; para += "farmId=" + $form.formGet().farmId; } if ($form.formGet().roomId != "") { para = (para == "") ? "" : para + "&"; para += "roomId=" + $form.formGet().roomId; } if ($form.formGet().batchMix != "") { para = (para == "") ? "" : para + "&"; para += "batchMix=" + $form.formGet().batchMix; } if ($form.formGet().matType != "") { para = (para == "") ? "" : para + "&"; para += "matType=" + $form.formGet().matType; } if ($form.formGet().queryProperties != "") { para = (para == "") ? "" : para + "&"; para += "queryProperties=" + $form.formGet().queryProperties; } if ($form.formGet().startTime != "") { para = (para == "") ? "" : para + "&"; para += "startTime=" + $form.formGet().startTime; } if ($form.formGet().endTime != "") { para = (para == "") ? "" : para + "&"; para += "endTime=" + $form.formGet().endTime; } para = (para == "") ? "/wms/wmsOutPoolmat/exportStockMissExcel" : "/wms/wmsOutPoolmat/exportStockMissExcel?" + para; $.yvan.download({ method: 'get', url: api(para), fileName: "缺件项统计表" + $.yvan.getMoment().format('YYYY-MM-DD HH:mm:ss') + '.xlsx' }); } }, ] }; return { north: { height: 140, split: true, border: false, items: [ queryToolbar, queryForm, ] }, center: { height: '100%', split: true, items: { onRender: function () { $grid1 = $(this); queryGrid1(); }, xtype: 'grid', toolbar: gridToolbar1, columns: [[ {title: '物资类型', field: 'matType', align: 'center', formatter: $.fn.fmatter.matType}, {title: '物资编码', field: 'matBar'}, {title: '图号/型号', field: 'matCode'}, {title: '物资名称', field: 'matName'}, {title: '物资编码属性', field: 'matAttrCode'}, {title: '计量单位', field: 'unitName'}, {title: '计划价', field: 'planPrice', align: 'right', formatter: $.fn.fmatter.formatCurrency}, {title: '计划金额', field: 'planMoney', align: 'right', formatter: $.fn.fmatter.formatCurrency}, {title: '允许混批', field: 'batchMix', align: 'center', formatter: $.fn.fmatter.batchMix}, { title: '需求数', field: 'amount', align: 'right', formatter: $.fn.fmatter.formatNumberBigDecimal, }, { title: '领用数', field: 'amountTake', align: 'right', formatter: $.fn.fmatter.formatNumberBigDecimal, hidden: true, }, {title: '待发数', field: 'dfAmount', align: 'right', formatter: $.fn.fmatter.formatNumberBigDecimal}, {title: '库存数', field: 'stockAmount', align: 'right', formatter: $.fn.fmatter.formatNumberBigDecimal}, {title: '最大批次数', field: 'batchAmount', align: 'right', formatter: $.fn.fmatter.formatNumberBigDecimal}, {title: '缺件数', field: 'missAmount', align: 'right', formatter: $.fn.fmatter.formatNumberBigDecimal}, {title: '需求单号', field: 'billCode'}, {title: '派工号', field: 'pghCode'}, {title: '需求类型', field: 'outapType', align: 'center', formatter: $.fn.fmatter.outapType}, {title: '需求车间', field: 'roomName'}, {title: '备货库区', field: 'farmName'}, {title: '申请人', field: 'takeUser'}, {title: '需求日期', field: 'dateUse', align: 'center', formatter: $.fn.fmatter.tsymd} ]] } } }; }; });