ATX2 二次開發篇(一)

最簡單粗暴新增公告功能

 

首先確定添加的頁面爲index.html

關鍵代碼

<!--            公告-->
      <el-table
              :data="tableData"
              style="width: 100%"
              >
          <el-table-column :sort-method="tableSortBy('prop_ShowCon')" sortable label="公告">
              <template slot-scope="scope">
                  <atx-edit-inline :readonly="!user.admin" :value="scope.row.prop_ShowCon"
                                   @change="updateShow(scope.row.udid, $event)">
                  </atx-edit-inline>
              </template>
          </el-table-column>
      </el-table>

Script代碼:

updateShow(udid, text) { // admin required
    $.ajax({
        url: "/api/v1/devices/" + udid + "/properties",
        method: "put",
        contentType: "application/json",
        data: JSON.stringify({
            "ShowCon": text,
        })
    }).fail(ret => {
        if (ret.status == 400) {
            this.$message.error(ret.responseJSON.description)
        } else {
            this.$message.error(ret.responseText)
        }
    })
},

此方法是用表格顯示數據,當然可以換成其他組件;

在要添加的位置先增加html代碼,把script放到相應位置即可

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章