var selectionIds = []; //保存选中ids var locationFun = function (id){ stopBubbleDefaultEvent(); $.post(ext.contextPath + '/cmd/cmdController/locationEquipment.do', {id: id}, function (data) { alert('已发送定位指令'); }); } //新增设备卡片 var addFun = function () { stopBubbleDefaultEvent(); $.post(ext.contextPath + '/equipment/doadd.do', {unitId: unitId}, function (data) { $("#subDiv").html(data); openModal('subModal'); }); }; // 批量新增申请 var addScrapApplyFuns = function () { stopBubbleDefaultEvent(); // 检查数据是否选中 var checkedItems = $("#table").bootstrapTable('getSelections'); var datas = ""; $.each(checkedItems, function (index, item) { datas += item.id + ","; }); if (datas == "") { showAlert('d', '请先选择记录', 'mainAlertdiv'); } else { // 查看当前设备是否已存在报废明细表中 $.post(ext.contextPath + '/equipment/EquipmentScrapApply/doCheckAcrap.do', {ids: datas}, function (data) { var result = eval("(" + data + ")"); if (result.res == 1) { showAlert('d', result.data, 'mainAlertdiv'); } else { swal({ text: "确认后将保存当前选中设备并生成报废申请!", dangerMode: true, buttons: { cancel: { text: "取消", value: null, visible: true, className: "btn btn-default btn-sm", closeModal: true, }, confirm: { text: "确定", value: true, visible: true, className: "btn btn-danger btn-sm", closeModal: true } } }).then(function (will) { if (will) { // 调用报废申请保存接口 $.post(ext.contextPath + "/equipment/EquipmentScrapApply/doEquipmentCardSrcapSave.do", {companyId: unitId, ids: datas}, function (data) { if (data.res == 1) { $("#table").bootstrapTable('refresh'); // 报废申请编辑 $.post(ext.contextPath + "/equipment/EquipmentScrapApply/edit.do", {id: data.id}, function (data1) { $("#subDiv_Scrap").html(data1); openModal('subModal'); }); } else if (data.res == 0) { showAlert('d', '保存失败'); } else { showAlert('d', data.res); } }, 'json'); } }) } }); } }; // 新增申请 var addScrapApplyFun = function (id) { stopBubbleDefaultEvent(); // 查看当前设备是否已存在报废明细表中 $.post(ext.contextPath + '/equipment/EquipmentScrapApply/doCheckAcrap.do', {ids: id}, function (data) { var result = eval("(" + data + ")"); if (result.res == 1) { showAlert('d', result.data, 'mainAlertdiv'); } else { swal({ text: "确认后将保存当前选中设备并生成报废申请!", dangerMode: true, buttons: { cancel: { text: "取消", value: null, visible: true, className: "btn btn-default btn-sm", closeModal: true, }, confirm: { text: "确定", value: true, visible: true, className: "btn btn-danger btn-sm", closeModal: true } } }).then(function (will) { if (will) { // 调用报废申请保存接口 $.post(ext.contextPath + "/equipment/EquipmentScrapApply/doEquipmentCardSrcapSave.do", {companyId: unitId, ids: id}, function (data) { if (data.res == 1) { $("#table").bootstrapTable('refresh'); // 报废申请编辑 $.post(ext.contextPath + "/equipment/EquipmentScrapApply/edit.do", {id: data.id}, function (data1) { $("#subDiv_Scrap").html(data1); openModal('subModal'); }); } else if (data.res == 0) { showAlert('d', '保存失败'); } else { showAlert('d', data.res); } }, 'json'); } }) } }); }; //编辑资产类型 var editFun = function (id) { stopBubbleDefaultEvent(); $.post(ext.contextPath + '/equipment/doedit.do', {id: id, unitId: unitId}, function (data) { $("#subDiv").html(data); openModal('subModal'); }); }; //查看设备详情 var viewFun = function (id) { stopBubbleDefaultEvent(); $.post(ext.contextPath + '/equipment/doview.do', {id: id}, function (data) { $("#subDiv").html(data); openModal('subModal'); }); }; //删除多条资产类型数据 var deletesFun = function () { var checkedItems = $("#table").bootstrapTable('getSelections'); var datas = ""; $.each(checkedItems, function (index, item) { datas += item.id + ","; }); if (datas == "") { showAlert('d', '请先选择记录', 'mainAlertdiv'); } else { swal({ text: "您确定要删除此记录?", dangerMode: true, buttons: { cancel: { text: "取消", value: null, visible: true, className: "btn btn-default btn-sm", closeModal: true, }, confirm: { text: "确定", value: true, visible: true, className: "btn btn-danger btn-sm", closeModal: true } } }) .then(function (willDelete) { if (willDelete) { $.post(ext.contextPath + '/equipment/dodeletes.do', {ids: datas}, function (data) { var res = eval('(' + data + ')'); if (res.code > 0) { $("#table").bootstrapTable('refresh'); } else { $("#table").bootstrapTable('refresh'); showAlert('d', res.msg, 'mainAlertdiv'); } }); } }); } }; //删除一条资产类型数据 var deleteFun = function (id) { stopBubbleDefaultEvent(); swal({ text: "您确定要删除此记录?", dangerMode: true, buttons: { cancel: { text: "取消", value: null, visible: true, className: "btn btn-default btn-sm", closeModal: true, }, confirm: { text: "确定", value: true, visible: true, className: "btn btn-danger btn-sm", closeModal: true } } }) .then(function (willDelete) { if (willDelete) { $.post(ext.contextPath + '/equipment/dodelete.do', {id: id}, function (data) { var res = eval('(' + data + ')'); if (res.code == 1) { $("#table").bootstrapTable('refresh'); } else { showAlert('d', res.msg, 'mainAlertdiv'); } }); } }); }; /** * 获取工艺段 */ function getProcessSection() { var selectType = $("#processSection").select2({minimumResultsForSearch: 10}) $.post(ext.contextPath + "/user/processSection/getList4EquipmentCard.do", {unitId: unitId}, function (data) { $("#processSection").empty(); var selelct_ = $("#processSection").select2({ data: data, placeholder: '请选择',//默认文字提示 allowClear: false,//允许清空 escapeMarkup: function (markup) { return markup; }, // 自定义格式化防止xss注入 language: "zh-CN", minimumInputLength: 0, minimumResultsForSearch: 10,//数据超过10个启用搜索框 formatResult: function formatRepo(repo) { return repo.text; }, // 函数用来渲染结果 formatSelection: function formatRepoSelection(repo) { return repo.text; } // 函数用于呈现当前的选择 }); selelct_.val('').trigger("change"); selelct_.on('change', function (e) { // dosearch(); }) }, 'json'); } //导入设备列表 function importFun() { var companyId = unitId; $.post(ext.contextPath + '/equipment/importEquipmentCard.do', {companyId: companyId}, function (data) { $("#subDiv").html(data); openModal('subModal'); }); } //导出设备列表 function downloadFun() { var search_name = $("#equipment_search_name").val(); var companyId = $("#unitId").val(); var processSectionId = $("#processSectionId").val(); var equipmentClassId = $("#equipmentClassId").val(); var equipmentClassCode = $("#equipmentClassCode").val(); window.open(ext.contextPath + "/equipment/downloadEquipmentExcel.do?unitId=" + companyId + "&search_name=" + search_name + "&processSectionId=" + processSectionId + "&equipmentClassId=" + equipmentClassId + "&equipmentClassCode=" + equipmentClassCode ); } var dosearch = function () { $("#table").bootstrapTable('refresh'); };