const transConf = function(arr) {
    window.arr = arr;
    // var arr = [
    //     {hospitalCode: "A001", sysType: 16, name: "推荐诊断", code: "diagnose_show", value: 1},
    //     {hospitalCode: "A001", sysType: 16, name: "问诊症状", code: "inquiry_show", value: 1},
    //     {hospitalCode: "A001", sysType: 16, name: "体格检查", code: "health_show", value: 1},
    //     {hospitalCode: "A001", sysType: 16, name: "病情提示", code: "illness_show", value: 1},
    //     {hospitalCode: "A001", sysType: 16, name: "治疗方案", code: "cure_show", value: 0},
    //     {hospitalCode: "A001", sysType: 16, name: "检验检查", code: "lispacs_show", value: 1},
    //     {hospitalCode: "A001", sysType: 16, name: "推荐诊断", code: "diagnose_no", value: 7},
    //     {hospitalCode: "A001", sysType: 16, name: "问诊症状", code: "inquiry_no", value: 1},
    //     {hospitalCode: "A001", sysType: 16, name: "体格检查", code: "health_no", value: 2},
    //     {hospitalCode: "A001", sysType: 16, name: "病情提示", code: "illness_no", value: 3},
    //     {hospitalCode: "A001", sysType: 16, name: "治疗方案", code: "cure_no", value: 6},
    //     {hospitalCode: "A001", sysType: 16, name: "检验检查", code: "lispacs_no", value: 5},
    //     {hospitalCode: "A001", sysType: 16, name: "是否对接", code: "connect", value: 1},
    //     {hospitalCode: "A001", sysType: 16, name: "医学知识", code: "knowledge_show", value: 0},
    //     {hospitalCode: "A001", sysType: 16, name: "医学知识", code: "knowledge_no", value: 19},
    //     {hospitalCode: "A001", sysType: 16, name: "全部量表", code: "scale_show", value: 0},
    //     {hospitalCode: "A001", sysType: 16, name: "全部量表", code: "scale_no", value: 10},
    //     {hospitalCode: "A001", sysType: 16, name: "警惕诊断", code: "vigilant_show", value: 1},
    //     {hospitalCode: "A001", sysType: 16, name: "警惕诊断", code: "vigilant_no", value: 3}
    // ]
    const reg = /_show$/g;
    let newArr = arr.filter(item => item.code.match(reg) && +item.value === 1 )
    for(let i = 0; i < newArr.length; i++) {
        for (let j = 0; j < arr.length; j++) {
            if(arr[j].code.match(/_no$/g) && arr[j].code.replace('_no', ' ') === newArr[i].code.replace('_show', ' ')) {
                newArr[i].orderNo = +arr[j].value
            }
            if(arr[j].code.match(/_num$/g) && arr[j].code.replace('_num', ' ') === newArr[i].code.replace('_show', ' ')) {
                newArr[i].showNum = +arr[j].value
            }
        }
    }
    newArr.sort((a, b) => {
        return a.orderNo - b.orderNo
    })
    let showLabsNum, showPacsNum, labsAndPacMode
    showLabsNum = arr.filter(item => item.code === 'inspeclis_num')[0]&&arr.filter(item => item.code === 'inspeclis_num')[0].value
    showPacsNum = arr.filter(item => item.code === 'inspecpacs_num')[0]&&arr.filter(item => item.code === 'inspecpacs_num')[0].value
    labsAndPacMode = arr.filter(item => item.code === 'lispacs_place')[0]&&arr.filter(item => item.code === 'lispacs_place')[0].value
    return {
        confArr: newArr,
        showLabsNum,
        showPacsNum,
        labsAndPacMode
    }
}
const $ = require("jquery");

function toggleWarnBox(text) {
    if (text) {
        $(".warning-box .content span").text(text);
        $(".warning-box").show();
    } else {
        $(".warning-box").hide();
    }
}

module.exports = {
    transConf,
    toggleWarnBox
}