const qs = require('qs'); const imageUrlPrefix = 'http://192.168.2.236:82' //后台图片地址 const getUrlArgObject = (parm) => { let query = window.location.search; let args = qs.parse(query.substr(1)); return args[parm];//返回对象 } const deepClone = (arr) =>{ let newArr = []; for(let i in arr){ newArr.push(arr[i]); } return newArr; } const getModelExpStr = (str) =>{ let result = {} if(str.match(/\${number_(.*})/)){//数字输入框 let matchStr = str.match(/\${number_(.*})/)[0] result = { type:'number', placeholder:matchStr.split('${number_')[1].split('}')[0], prefix:str.split(matchStr)[0]||'', suffix:str.split(matchStr)[1]||'' } }else if(str.match(/\${input_(.*})/)){ let matchStr = str.match(/\${input_(.*})/)[0] result = { type:'text', placeholder:matchStr.split('${input_')[1].split('}')[0], prefix:str.split(matchStr)[0]||'', suffix:str.split(matchStr)[1]||'' } } return result } const getAllStr = (allData) =>{//获取界面数据,拼接字符串 let allStr = '',data = allData.data; for(let i = 0;i < data.length;i++){ if(data[i].controlType != 3&&data[i].value){ allStr += (data[i].value).replace('{','').replace('}','')+';' } if(data[i].controlType == 3){//多列选择 let tmpStr = ''; for(let j = 0;j < data[i].questionDetailList.length;j++){ let tmpName = data[i].questionDetailList[j] if(tmpName&&tmpName.value){ let obj = getModelExpStr(tmpName.name) tmpStr+=obj.prefix+tmpName.value+obj.suffix+(j ==(data[i].questionDetailList.length-1)?';':',') } } allStr+=tmpStr } } return allStr; } const moduleConfig = (config,modules) => { let activeModule = [] for(let i = 0;i < config.length;i++){ let tmpCode = config[i].code for(let j = 0;j < modules.length;j++){ let tmpType = modules[j].type if(tmpCode=="symptoms_show"&&tmpType==1){ activeModule.push(modules[j]) }else if(tmpCode=="diagnosis_show"&&tmpType==51){ activeModule.push(modules[j]) }else if(tmpCode=="omhistory_show"&&tmpType==3){ activeModule.push(modules[j]) }else if(tmpCode=="replenish_show"&&tmpType==52){ activeModule.push(modules[j]) } } } return { data:activeModule, len:activeModule.length||0, order:activeModule.length>0?activeModule[0].type:'' } } // 替换输入框占位符 const patt = /\$\{[^\]]+\}/g; module.exports = { imageUrlPrefix, getUrlArgObject, deepClone, getModelExpStr, getAllStr, moduleConfig, patt }