export default {
    filters: {
      calcRispCount(data,type){
        let preUrlArr = [];
          if (type == "frozenUrl") {
          // 手术标本病理诊断冰冻按钮
          preUrlArr = data.filter((item) => {  return item.type == "冰冻病理";});
        } else if (type == "conventionalUrl") {
          // 手术标本病理诊断 常规
          preUrlArr = data.filter((item) => {  return item.type !== "冰冻病理" ;});
        } else {
          preUrlArr = data;
        }
        return preUrlArr.length
      }
    },
    methods: {
        // el-table样式
      rowDClass() {
        return "line-height: 30px;height: 30px;padding:0px 20px;;font-size:14px;font-family: Microsoft YaHei;";
      },
      headClass() {
        return "color:#000; line-height: 30px;height: 30px;padding:5px 20px;;font-size:14px;font-family: Microsoft YaHei;";
      },
        // 区分冰冻和常规
      setSortPathology (row,type) {
        if (!row?.data?.meetingType) {
          return row[type] == 'pathology' && !row.urls && row.data.length
        } else {
          return false
        }
      },
      outpatientshospitalRecordType(subCategory){
        let types = [
          { subCategory:"inHospital", type:'入院'},
          { subCategory:"outHospital", type:'出院'},
          { subCategory:"appointment", type:'预约'},
          { subCategory:"outpatient", type:'门诊'},
          { subCategory: "diagnose", type: '诊断'}
        ];
        let result = types.find(item=>item.subCategory==subCategory);
        return result ? result.type : ''
      },
      outpatientshospitalRecord(val){
        if(val.subCategory=='outHospital'){
          if(val.data.outHospitalDeptName||val.data.doctorName){
            return `${val.data.outHospitalDeptName?val.data.outHospitalDeptName:''}${val.data.doctorName?'-'+val.data.doctorName:''}`
          }else{
            return ''
          }
        }else if(val.subCategory=='inHospital'){
          if(val.data.opDeptName||val.data.doctorName){
            return `${val.data.opDeptName?val.data.opDeptName:''}${val.data.doctorName?'-'+val.data.doctorName:''}`
          }else{
            return ''
          }
        }
      },
      //外院附件数量
      outerCourtAttachmentNumber(val){
        //console.log(val)
        if(val.filePath!=''){
          return val.filePath.split(",").length
        }else if(val.urls!=''){
          return val.urls.split(",").length

        }
      },
      //获取诊断的title，拼接了des
      getTitleStr(item) {
        if(!item) return '';
        if(item.subCategory == 'diagnose') return item.title;
        return item.title && item.des ? (item.title + '-' + item.des) : (item.title ? item.title : item.des)
      },
      // 打开链接
      openUrlList(arr) {
        arr.forEach((item, index) => {
          window.open(item, index + item);
        });
      },
    }
}