zoukankan      html  css  js  c++  java
  • 工作中使用的一些技巧总结【后续持续性更新】

      "productStatusList": [
        {
          "dictId": 122,
          "dictName": "启用",
          "dictValue": "1",
          "dictType": "status",
          "dictDescription": "状态",
        },
        {
          "dictId": 123,
          "dictName": "停用",
          "dictValue": "2",
          "dictType": "status",
          "dictDescription": "状态",
        }
      ],

    需求: 需要将数字  "dictValue": "2" 转换为对应的汉字状态 "dictName": "停用",

    3种情况 : 表格 、 select选择 和 P标签内的。

    1、 select选择比较简单。就是循环数组

     <el-option
          v-for="item in productTypeList"
          :label="item.dictName"
          :key="item.dictValue"
          :value="item.dictValue"
        >
    </el-option>

    2、 是表格内的。     定义 一个函数 : typeFormat ,然后函数进行处理

      <el-table-column
          label="使用状态"
          prop="productType"
          :formatter="typeFormat"
          sortable
          align="center"
        >
        </el-table-column>
        typeFormat(row, column){
        let obj=this.typeList.find(
        e=>e.dictValue==row.verifyType.toString()
        )
        return obj==null ?"":obj.dictName;
        },

    3、P标签内的

      <el-form-item label="审核状态" prop="auditStatus">
          <span>{{typeFormat(addForm.productType)}}</span>
        </el-form-item>

     分页

            total: 0, //总条数
            page: 1, //每页几条
            limit: 10, //当前第几页
            pagenum: 1,//当前页数
    
    
         <el-pagination
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :page-sizes="[10, 30, 50, 100]"
            :page-size="limit"
            layout="sizes, prev, pager, next"
            :total="total"
            style="float:right;"
            class="pagination"
            :current-page="pagenum"
          ></el-pagination>
    
    
          //每页多少
          handleSizeChange(val) {
            this.limit = val;
            this.search();
          },
          //当前页数
          handleCurrentChange(val) {
            this.page = val;
            this.search();
          },
    
    *搜索的时候,要把 page置为1,不然跨页搜索会出现问题

    树结构坑记录

    <el-tree :data="menus" show-checkbox node-key="id" :props="treeProps" ref="menuAddTree"></el-tree>
    
    data(){
    return {
           sels: [], //列表选中列
            menus: [],
            menuIds: [], //角色拥有的权限
            treeProps: {
              children: "children",
              label: "name"
            },  
    }
    
    }

    addSubmit(){params.menuIds = this.getMenuIds();}
    //获取选中、半选中节点  
    getMenuIds: function () {
    return this.$refs.menuAddTree .getCheckedKeys() .concat(this.$refs.menuAddTree.getHalfCheckedKeys()); },

    /** * (keys, leafOnly) 接收两个参数,1. 勾选节点的 key 的数组 2. boolean 类型的参数,若为 true 则仅设置叶子节点的选中状态,默认值为 false */
    setMenuIds: function (keys) {
    this.$refs.menuAddTree.setCheckedKeys(keys, true); },

    menus数据结构:

    表格内树形展示

     使用插件treeTable进行的渲染 https://gitee.com/njp/shoppingMall.git

     <tree-table
            :data="menuData"
            :columns="columns"
            border
            highlight-current-row
            style=" 100%;"
            :header-cell-style="{background:'rgb(238, 241, 246)',color:'rgb(96, 98, 102)'}"
          >
    <el-table-column label="类型" prop="type" align="center">
    <template slot-scope="scope">
    <el-tag v-if="scope.row.object.type === null"></el-tag>
    <el-tag v-if="scope.row.object.type === 0">目录</el-tag>
    <el-tag v-if="scope.row.object.type === 1">菜单</el-tag>
    <el-tag v-if="scope.row.object.type === 2">操作</el-tag>
    </template>
    </el-table-column>
    /*代码段*/
    <el-button type="primary" plain @click="addLevelOne(0,-1)">添加一级分类</el-button>  //代表一级分类
    <el-button type="primary" plain @click="addLevelOne(scope.row.id,scope.row.type)">添加多级分类</el-button>

    <el-table-column label="路径" prop="object.url" align="center"></el-table-column>
    </tree-table>
    
    data(){
      menuData: [],
        columns: [
              {
                text: "名称",
                value: "text",
                 200
              }
            ],
    },
    method:{
    search(
    parentId, parentType){

     //对一级和多级进行判断
    if (parentType != 2) {
    this.addForm.type = parentType + 1;
    } else {
    this.addForm.type = parentType;
    }
    this.addForm.parentId = parentId;
    this.addDialogVisible = true;
     
    }
    }

    menuData数据类型

     

    启用(可提示的)

     

  • 相关阅读:
    【纯水题】POJ 1852 Ants
    【树形DP】BZOJ 1131 Sta
    【不知道怎么分类】HDU
    【树形DP】CF 1293E Xenon's Attack on the Gangs
    【贪心算法】CF Emergency Evacuation
    【思维】UVA 11300 Spreading the Wealth
    【树形DP】NOI2003 逃学的小孩
    【树形DP】BZOJ 3829 Farmcraft
    【树形DP】JSOI BZOJ4472 salesman
    【迷宫问题】CodeForces 1292A A NEKO's Maze Game
  • 原文地址:https://www.cnblogs.com/0520euv/p/11729498.html
Copyright © 2011-2022 走看看