工作中使用的一些技巧总结【后续持续性更新】

  "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>

需求: 在表格内增加序号

<el-table-column fixed label="序号">
      <template slot-scope="scope">
        <span>{{scope.$index + 1}}</span>
      </template>
</el-table-column>

需求: 一堆同类的input提交

1、 使用form表单包住全部内容

2、 把form表单内容进行拷贝到params中

  this.$refs.addForm.validate(valid => {
        if (valid) {
          let params = Object.assign({}, this.addForm);
        //请求代码
       
};

 

猜你喜欢

转载自www.cnblogs.com/0520euv/p/11729498.html