关注Avue表单设计器的使用: 【Avue表单设计器的使用技巧】
关注Avue企业级开发应用官方源代码: 官方源代码
描述: 使用avue.js或者vue.js做后台管理系统时,常常涉及到子组件(子弹窗) 修改,添加操作后,需要刷新父组件重新加载数据:
父组件代码: 重点关注该方法:
父组件中定义该方法:
handleRefreshChange() {
this.getList(this.page); // 父组件获取后台的数据
}
<template>
<div class="user">
<basic-container>
<avue-crud
:option="option"
ref="crud"
v-model="form"
:page="page"
@on-load="getList"
@size-change="sizeChange"
@current-change="currentChange"
:table-loading="listLoading"
@search-change="handleFilter"
@refresh-change="handleRefreshChange"
@row-update="update"
@row-save="create"
:before-open="handleOpenBefore"
:data="list"
>
<template slot="username" slot-scope="scope">
<span>{
{ scope.row.username }}</span>
</template>
<template slot="amount" slot-scope="scope">
<div v-if="scope.row.currType === 'VIR'">
{
{ scope.row.amount }}
</div>
<div v-if="scope.row.currType !== 'VIR'">
{
{ scope.row.amount / 100 }}
</div>
</template>
<template slot="role" slot-scope="scope">
<span v-for="(role, index) in scope.row.roleList" :key="index">
<el-tag>{
{ role.roleName }} </el-tag>
</span>
</template>
<template slot="deptId" slot-scope="scope">
{
{ scope.row.deptName }}
</template>
<template slot="lockFlag" slot-scope="scope">
<el-tag>{
{ scope.label }}</el-tag>
</template>
<template slot="menu" slot-scope="scope">
<el-button v-show = "scope.row.status == 100 || scope.row.status == 110"
type="text"
icon="el-icon-edit"
@click="handleView(scope.row, scope.index)">冲账
</el-button>
<el-button v-show = "scope.row.status === -100"
type="text"
icon="el-icon-edit"
@click="handlePushItem(scope.row, scope.index)">重新记账
</el-button>
</template>
</avue-crud>
</basic-container>
<info-view v-if="infoVisible" ref="infoView"></info-view>
</div>
</template>
<script>
import { fetchList, putObj, putObjStatus } from "@/api/acct/acctTradeRecord";
import { deptRoleList } from "@/api/admin/role";
import { fetchTree } from "@/api/admin/dept";
import { tableOption } from "@/const/crud/acct/acctTradeRecord";
import InfoView from "./record-form";
import { mapGetters } from "vuex";
export default {
name: "table_user",
components: {
InfoView,
},
// data()函数返回对象 : {}
data() {
return {
option: tableOption,
treeDeptData: [],
checkedKeys: [],
roleProps: { // 配置项传递数据
label: "roleName",
value: "roleId",
},
defaultProps: {
label: "name",
value: "id",
},
page: {
total: 0, // 总页数
currentPage: 1, // 当前页数
pageSize: 10, // 每页显示多少条,
isAsc: false, //是否倒序
},
searchParam: {},
list: [],
listLoading: true,
role: [],
form: {}, // 配置项key,value为一个空对象,相当于先声明一个变量,并初始化一个空对象
rolesOptions: [],
infoVisible: false,
};
},
computed: {
...mapGetters(["permissions"])

本文详细介绍了如何在使用Avue表单设计器时,通过子组件操作触发父组件数据的刷新,包括两种方法:直接在父组件中定义刷新方法和通过子组件的自定义事件更新父组件。涉及到了Vue组件间的通信和数据同步技巧。
最低0.47元/天 解锁文章
8217





