/** * 工料机汇总相关数据 * * @author CaiAoLin * @date 2017/9/14 * @version */ function ProjectGLJ() { this.datas = null; this.isLoading = false; } /** * 加载数据 * * @return {boolean} */ ProjectGLJ.prototype.loadData = function () { let self = this; if (self.isLoading) { return false; } // 加载工料机数据 $.ajax({ url: '/glj/getData', type: 'post', dataType: 'json', data: {project_id: scUrlUtil.GetQueryString('project')}, error: function() { // alert('数据传输错误'); }, beforeSend: function() { self.isLoading = true; }, success: function(response) { if (response.err === 1) { let msg = response.msg !== undefined && response.msg !== '' ? response.msg : '读取工料机数据失败!'; alert(msg); return false; } self.datas = response.data; // 存入缓存 projectObj.project.projectGLJ = self; } }); }; /** * 获取对应工料机数据 * * @param {String} code * @return {Object} */ ProjectGLJ.prototype.getDataByCode = function (code) { let result = {}; if (this.datas === null) { return result; } let gljList = this.datas.gljList; if (gljList === undefined) { return result; } for(let tmp of gljList) { if (tmp.code === code) { result = tmp; break; } } return result; }; /** * 修改工料机数据 * * @param {String} code * @param {Object} data * @return {boolean} */ ProjectGLJ.prototype.updateData = function(code, data) { };