Element-UI ( Dropdow )下拉菜單組件command傳輸對象


通過 :command綁定對象數據,handleCommand方法處理數據

template

<div  v-for="(item, index) in FlyWarningList" :key="index">
          <div :class="[isActive === item.isRead ? '':' warning-content', 'first-content']" v-if="item.infoType === '告警信息'">
            <p class='content-item infoType'>{{item.infoType}}</p>
            <p class='content-item'>注冊編號:{{item.content.rescueNum}}</p>
            <p class='content-item'>緊急階段:{{item.content.phase}}</p>
            <p class='content-item'>降落機場:{{item.content.landingStation}}</p>
            <p class='content-item'>備降機場:{{item.content.alternateAirport}}</p>
            <p class='content-item'>最后聯系時間:{{item.content.lastContactTime}}</p>
            <p class='content-item'>最后聯系位置:{{item.content.lastContactLocation}}</p>
            <div class='publish-time'>發布時間:{{item.sendTime}}</div>
            <el-dropdown class='content-menu' trigger="click"  @command="handleCommand">
              <span class="el-dropdown-link">
                <i class="el-icon-arrow-down"></i>
              </span>
              <el-dropdown-menu slot="dropdown">
                <el-dropdown-item :command="item">已讀</el-dropdown-item>
                <el-dropdown-item command="delete">刪除</el-dropdown-item>
              </el-dropdown-menu>
            </el-dropdown>
          </div>
</div>

methods

 handleCommand (command) {
      this.$message({
        message: '消息已讀',
        type: 'success'
      })
      console.log('sendTime11111', command.sendTime)
      console.log('command================2', JSON.stringify(command))
      var data = {
        type: command.type,
        count: command.count,
        active: command.active,
        isRead: false,
        messageNumber: command.messageNumber,
        infoType: command.infoType,
        infoUid: command.infoUid,
        sendTime: command.sendTime,
        content: command.content
      }
      this.$http.get('/seat/read', {
        params: {
          message: data
        }
      })
        .then((res) => {
          console.log('■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■')
          console.log('res:', res)
          console.log('■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■')
          console.log(res.data)
          if (res.data === '狀態改變成功') {
            command.isRead = false
            console.log('active', command.isRead)
            console.log('sendTime2222', command.sendTime)
          }
        }).catch((err) => {
          console.log('請求失敗■■■■■■■■■■■■■■' + err)
        })
      if (command === 'edit') {
        this.$emit('toggleModal', this.activeName)
      }
    }


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM