avue页面布局 api 引用

展示

index.vue

<template>
  <basic-container>
    <avue-crud :option="option"
               :table-loading="loading"
               :data="data"
               :page="page"
               :permission="permissionList"
           
               :search.sync="search"
               :before-close='beforeClose'
               v-model="form"
               ref="crud"
               @row-update="rowUpdate"
               @row-save="rowSave"
               @row-del="rowDel"
               @search-change="searchChange"
          @search-reset="resetChange"
               @selection-change="selectionChange"
            
               @on-load="onLoad">
    </avue-crud>
 
  </basic-container>
</template>

<script>
  import {getList,  add, update, remove} from "@/api/budget/budget";
  import {mapGetters} from "vuex";
 
  import Cookies from 'js-cookie'
  export default {

    data() {
      return {
        excelBox: false,
        val: {
          id:'',
          houseNumber:'',
          name:'budget',
        },
        selectHouseNumber:false,
        form: {},  //存储返回值
        query: {},
        loading: true,
        page: {
          pageSize: 10,
          currentPage: 1,
          total: 0
        },
        selectionList: [],
        search:{},
        option: {
       
          indexLabel:'序号',
          align:'center',
          column: [
          {
              label: '基本情况',
              children: [
                {
                  label: "资产编号",
                  prop: "houseNumber",
                  width:140,
                  search: true,
                },
                {
                  label: "资产名称",
                  prop: "assetName",
                  search: true,
                },
              ],
            },
            {
                  label: "使用状态",
                  prop: "zsStatus",
                  formatter:(val,value,label)=>{
                    if(val.zsStatus==1){
                      return  '出租'
                    }
                    if(val.zsStatus==2){
                      return  '出售'
                    }
                  },
                },
  

            {
              label: '支出预算',
              children: [

                {
                  label: "税费",
                  prop: "taxation",
                  value:0
                },
                {
                  label: "暂列金",
                  prop: "provisionalSums",
                  value:0
                }, {
                  label: "支出合计",
                  prop: "expenditureTotal",
                  value:0
                }
                , {
                  label: "relet",
                  prop: "relet",
                  value:0
                },
              ]

            },
            {
              label: "备注",
              prop: "remarks",
            },
          ]
        },
      };
    },
    computed: {
      ...mapGetters(["permission"]),
      permissionList() {

      },
  
    },
    mounted(){
      
    },
    watch: {
      // 有的值 是需要多个值 进行计算的  我们获取值进行计算 然后在进行渲染
      'form.relet' (val) {
        this.form.incomeTotal=parseFloat(val)+parseFloat(this.form.newLease)+parseFloat(this.form.incomeOther)
      },
      

      // 税费
      'form.taxation' (val) {
        this.form.expenditureTotal=parseFloat(val)+
          parseFloat(this.form.upkeepDismantle)+
          parseFloat(this.form.estimateIdentify)+
          parseFloat(this.form.provisionalSums)+
          parseFloat(this.form.expenditureOther)
      },
    
      // 暂列金
      'form.provisionalSums' (val) {
        this.form.expenditureTotal=parseFloat(val)+
          parseFloat(this.form.taxation)+
          parseFloat(this.form.upkeepDismantle)+
          parseFloat(this.form.estimateIdentify)+
          parseFloat(this.form.expenditureOther)
      },
    
      'form'(val){
        if(val.houseNumber!=''){
          val.realitySurplus=val.realityIncome-val.realityExpenditure
          // 合计
          val.expenditureTotal=parseFloat(val.taxation)+parseFloat(val.upkeepDismantle)+parseFloat(val.estimateIdentify)+parseFloat(val.provisionalSums)+parseFloat(val.expenditureOther)
          val.incomeTotal=parseFloat(val.incomeOther)+parseFloat(val.relet)+parseFloat(val.newLease)
        }
      },
    },
    methods: {
      getCookie(){
        if(Cookies.get('username') == ''){
          return false
        }
        else{
          return true
        }
      },
      beforeClose(done,type){
        this.$refs.crud.$refs.dialogForm.boxType=''
        done();
      },
  
  
      budgetDetails(row){
        this.$router.push({path:'/details/budgetDetails',query: {row}});
      },

      // 清空了
      resetChange (item) {
      this.$message.success('清空回调')
    },


 
      // 新增保存提示
      rowSave(row, done, loading) {
        add(row).then(() => {
          done();
          this.onLoad(this.page);
          this.$message({
            type: "success",
            message: "操作成功!"
          });
        }, error => {
          window.console.log(error);
          loading();
        });
      },
      // 点击编辑 提示
      rowUpdate(row, index, done, loading) {
        update(row).then(() => {
          done();
          this.onLoad(this.page);
          this.$message({
            type: "success",
            message: "编辑操作成功!"
          });
        }, error => {
          window.console.log(error);
          loading();
        });
      },
      // 删除
      rowDel(row) {
        this.$confirm("确定将选择数据删除?", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        })
          .then(() => {
            return remove(row.id);
          })
          .then(() => {
            this.onLoad(this.page);
            this.$message({
              type: "success",
              message: "操作成功!"
            });
          });
      },
    // 搜索
      searchChange(params, done) {
        this.query = params;
        this.page.currentPage = 1;
        this.onLoad(this.page, params);
        done();
      },
      selectionChange(list) {
        this.selectionList = list;
      },
      selectionClear() {
        this.selectionList = [];
        this.$refs.crud.toggleSelection();
      },
     
   
      onLoad(page, params = {}) {
        this.loading = true;
        getList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
          const data = res.data.data;
          this.page.total = data.total;
          this.data = data.records;
          this.loading = false;
          this.selectionClear();

          if(Cookies.get('username')!=''){
            this.option.editBtn=false
            this.option.delBtn=false
            this.option.addBtn=false
          }

        });
      }
    }
  };
</script>

<style>
</style>

"@/api/budget/budget";

import request from '@/router/axios';

export const getList = (current, size, params) => {
  return request({
    url: '/api/budget/list',
    method: 'get',
    params: {
      ...params,
      current,
      size,
    }
  })
}



export const remove = (ids) => {
  return request({
    url: '/api/budget/remove',
    method: 'post',
    params: {
      ids,
    }
  })
}

export const add = (row) => {
  return request({
    url: '/api/budget/submit',
    method: 'post',
    data: row
  })
}

export const update = (row) => {
  return request({
    url: '/api/budget/submit',
    method: 'post',
    data: row
  })
}

vue.config.js

module.exports = {
  lintOnSave: true,
  productionSourceMap: false,
  chainWebpack: (config) => {
    //忽略的打包文件
    config.externals({
      'vue': 'Vue',
      'vue-router': 'VueRouter',
      'vuex': 'Vuex',
      'axios': 'axios',
      'element-ui': 'ELEMENT',
    })
    const entry = config.entry('app')
    entry
      .add('babel-polyfill')
      .end()
    entry
      .add('classlist-polyfill')
      .end()
    entry
      .add('@/mock')
      .end()
  },
  devServer: {
    // 端口配置
    port: 1999,
    // 反向代理配置
    proxy: {
      '/api': {
        target: 'http://192.168.56.1:7777',
        ws: true,
        pathRewrite: {
          '^/api': '/'
        }
      }
    },
  }
}

数值参考

文档参考

搜索 | Avue (avuejs.com)

avue-crud属性配置项参数笔记分享 - 小金子J - 博客园 (cnblogs.com)

相关推荐
长天一色9 分钟前
【ECMAScript 从入门到进阶教程】第三部分:高级主题(高级函数与范式,元编程,正则表达式,性能优化)
服务器·开发语言·前端·javascript·性能优化·ecmascript
NiNg_1_23426 分钟前
npm、yarn、pnpm之间的区别
前端·npm·node.js
秋殇与星河29 分钟前
CSS总结
前端·css
NiNg_1_23429 分钟前
Vue3 Pinia持久化存储
开发语言·javascript·ecmascript
读心悦30 分钟前
如何在 Axios 中封装事件中心EventEmitter
javascript·http
BigYe程普1 小时前
我开发了一个出海全栈SaaS工具,还写了一套全栈开发教程
开发语言·前端·chrome·chatgpt·reactjs·个人开发
神之王楠1 小时前
如何通过js加载css和html
javascript·css·html
余生H1 小时前
前端的全栈混合之路Meteor篇:关于前后端分离及与各框架的对比
前端·javascript·node.js·全栈
花花鱼1 小时前
@antv/x6 导出图片下载,或者导出图片为base64由后端去处理。
vue.js
程序员-珍1 小时前
使用openapi生成前端请求文件报错 ‘Token “Integer“ does not exist.‘
java·前端·spring boot·后端·restful·个人开发