| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 | /** * 组成物相关数据 * * @author CaiAoLin * @date 2017/10/27 * @version */function Composition() {    this.datas = null;    this.isLoading = false;}/** * 加载数据 * * @param {function} callback * @return {boolean} */Composition.prototype.loadData = function (callback = null) {    let self = this;    if (self.isLoading) {        return false;    }    // 加载组成物数据    $.ajax({        url: '/glj/get-composition',        type: 'post',        dataType: 'json',        data: {project_id: scUrlUtil.GetQueryString('project')},        error: function() {            // alert('数据传输错误');        },        beforeSend: function() {            self.isLoading = true;        },        success: function(response) {            self.isLoading = false;            if (response.err === 1) {                let msg = response.msg !== undefined && response.msg !== '' ? response.msg : '读取组成物数据失败!';                alert(msg);                return false;            }            self.datas = response.data;            // 回调函数            if (callback !== null) {                callback(response.data);            }            // 存入缓存            projectObj.project.composition = self;        }    });};/** * 获取对应code的组成物数据 * * @param {String} code * @param {Number} gljType * @return {Array} */Composition.prototype.getCompositionByCode = function(code, gljType = 0) {    let result = [];    if (code === '') {        return result;    }    if (gljType === 0) {        return this.datas[code] !== undefined ? this.datas[code] : result;    }    for(let composition of this.datas[code]) {        if (composition.glj_type === gljType) {            result.push(composition);        }    }    return result;};Composition.prototype.getCompositionByGLJ = function (glj) {    let mixRatioMap = projectObj.project.projectGLJ.datas.mixRatioMap;    let projectGljs = projectObj.project.projectGLJ.datas.gljList;    let connect_index = gljOprObj.getIndex(glj,gljKeyArray);    let gljList=[];    if(mixRatioMap[connect_index]){ //说明是有组成物的类型        gljList =  gljOprObj.getMixRationShowDatas(mixRatioMap[connect_index], projectGljs);    }    return gljList;}
 |