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放到相应位置即可

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