Avue中 avue-crud的事件调用:

 

 

<template slot-scope="scope" slot="menu">
        <el-button type="text"
                   size="small"
                   icon="el-icon-view"
                   plain
                   class="none-border"
                   @click.stop="handleView(scope.row,scope.index)">查看
        </el-button>
        <el-button type="text"
                   size="small"
                   icon="el-icon-edit"
                   plain
                   class="none-border"
                   @click.stop="handleEdit(scope.row,scope.index)">编辑
        </el-button>
        <el-button type="text"
                   size="small"
                   icon="el-icon-delete"
                   plain
                   class="none-border"
                   @click.stop="rowDel(scope.row,scope.index)">删除
        </el-button>
      </template>

methods: {
      rowSave(row, done, loading) {
        add(row).then((restt) => {
          this.currEquipmentId = restt.data.data;//新增设备的id   这个参数现在不需要了
          this.onLoad(this.page);
          this.$message({
            type: "success",
            message: "操作成功!"
          });
          done();
        }, error => {
          loading();
          window.console.log(error);
        });
      },
      handleEdit (row, index) {
        this.$refs.crud.rowEdit(row, index);
      },
      handleView (row, index) {
        this.$refs.crud.rowView(row, index);
      },
      handleAdd(row) {
        this.$refs.crud.value.parentId = row.id;
        this.$refs.crud.option.column.filter(item => {
          if (item.prop === "parentId") {
            item.value = row.id;
            item.addDisabled = true;
          }
        });
        this.$refs.crud.rowAdd();
      },
      rowUpdate(row, index, done, loading) {
        update(row).then(() => {
          this.onLoad(this.page);
          this.$message({
            type: "success",
            message: "操作成功!"
          });
          done();
        }, error => {
          loading();
          console.log(error);
        });
      },
      rowDel(row) {
        this.$confirm("确定将选择数据删除?", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        })
          .then(() => {
            return remove(row.id);
          })
          .then(() => {
            this.onLoad(this.page);
            this.$message({
              type: "success",
              message: "操作成功!"
            });
          });
      },
      handleDelete() {
        if (this.selectionList.length === 0) {
          this.$message.warning("请选择至少一条数据");
          return;
        }
        this.$confirm("确定将选择数据删除?", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        })
          .then(() => {
            return remove(this.ids);
          })
          .then(() => {
            this.onLoad(this.page);
            this.$message({
              type: "success",
              message: "操作成功!"
            });
            this.$refs.crud.toggleSelection();
          });
      },
}

 

Logo

前往低代码交流专区

更多推荐