2020年10月29日过滤查询(数组的几种方法)


图片展示

代码展示

handleSubmit (e) {
      e.preventDefault()
      const that = this
      that.form.validateFields(async (err, values) => {
        if (!err) {
          values['areaCode'] = that.areaCode || 33
          values['datetime'] = getCurrentTime()
          let resultList = []
          // 全部数据
          resultList = await that.GetSearchDangerousCompanyList(values)
          // 化学品名称过滤
          if (that.processNames && that.processNames.length > 0) {
            resultList = resultList.filter(item => {
              const itemProcessNameList = item.processNames ? item.processNames.split(',') : []
              let result = false
              itemProcessNameList.forEach(i => {
                const findResult = that.processNames.find(d => {
                  return d === i
                })
                if (findResult) {
                  result = true
                }
              })
              return result
            })
          }
          // 等级过滤
          if (that.Grade && that.Grade.length > 0) {
            resultList = resultList.filter(item => {
              return that.Grade.includes(item.hazardRankName)
            })
          }
          this.searchDangerousList = resultList
        }
      })
    }

输入图片说明

drawRiskBar () {
     const canvas = document.getElementById('riskBar')
     const context = canvas.getContext('2d')
     const majorHeight = this.majorRiskCount / this.total * canvas.height
     const largerHeight = this.largerRiskCount / this.total * canvas.height
     const generalHeight = this.generalRiskCount / this.total * canvas.height
     const lowHeight = this.lowRiskCount / this.total * canvas.height
     const offlineHeight = this.offlineCount / this.total * canvas.height
     context.fillStyle = '#FF4646'
     context.fillRect(0, 0, 20, majorHeight)
     context.fillStyle = '#FE9056'
     context.fillRect(0, majorHeight, 20, largerHeight)
     context.fillStyle = '#FFC900'
     context.fillRect(0, majorHeight + largerHeight, 20, generalHeight)
     context.fillStyle = '#81BCFF'
     context.fillRect(0, majorHeight + largerHeight + generalHeight, 20, lowHeight)
     context.fillStyle = '#7D8B8D'
     context.fillRect(0, majorHeight + largerHeight + generalHeight + lowHeight, 20, offlineHeight)
     // 绘制切面
     context.beginPath()
     context.arc(10, 10, 10.5, Math.PI, 0)
     context.lineTo(21, 0)
     context.lineTo(0, 0)
     context.closePath()
     context.arc(10, 170, 10.5, Math.PI, 0, true)
     context.lineTo(21, 180)
     context.lineTo(0, 180)
     context.closePath()
     context.clip()
     context.clearRect(0, 0, 20, 180)
   }
 }

Author: wxy
Reprint policy: All articles in this blog are used except for special statements CC BY 4.0 reprint policy. If reproduced, please indicate source wxy !
  TOC