欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

vue仿odata通用增删改查  

程序员文章站 2024-03-19 20:35:34
...

 

 

1 列表  
  listApiEntity

this.params.entityName = "FinanceRateCondtion";    //必填,表名称
      this.params.orderBy ="-baseId";   //必填,排序字段
      var inputFields = {};
      inputFields["noConditionFind"] = "Y"; //必填 如果为N则不执行查询.
 

     inputFields.xxx = xxx;    //查询,
      inputFields.xxx_op = xxx;  //查询条件;

如greaterThanEqualTo,lessThanEqualTo,notEqual 等等.不写这个值则默认为等于
      ......
      this.params.inputFields = inputFields;
      this.initTableData(this.$api.listApiEntity,this.params);

 2 新建  
  createApiEntity     var inputFields = {};
      inputFields["baseId"]= "10000";    //主键,可以不填,不填则后台自动产生
      inputFields["baseTypeId"]= xxxx;   //非主键字段,
      ......
      this.dataInfo.inputFields = inputFields;
      this.dataInfo.entityName = "FinanceRateCondtion";  //表名称
      this.saveDataInfo(state,this.$api.createApiEntity,this.dataInfo , "list");
      //返回的数据中的outputFields 包含了所有字段,按需使用
 3  修改  
   updateApiEntity    var inputFields = {};
      inputFields["baseId"]= "10000";    //主键
      inputFields["baseTypeId"]= xxxx;   //非主键字段,
      ......
      this.dataInfo.inputFields = inputFields;
      this.dataInfo.entityName = "FinanceRateCondtion";  //表名称
      this.updateDataInfo(state,this.$api.updateApiEntity,this.dataInfo , "list");
      //返回的数据中的outputFields 包含了所有字段,按需使用 
 4  删除  
   deleteApiEntity  var inputFields = {};
      inputFields["baseId"]= "10000";    //主键
      this.dataInfo.inputFields = inputFields;
      this.dataInfo.entityName = "FinanceRateCondtion";  //表名称
      axios.post(this.$api.deleteApiEntity,this.dataInfo).then(res => {
this.loading = false;
          }).catch(err => {
          this.loading = false;
        });
 5  根据主键查询一条数据  
   getApiEntity     var inputFields = {};
      inputFields["baseId"]= "10001";   //主键
      this.dataInfo.inputFields = inputFields;
      this.dataInfo.entityName = "FinanceRateCondtion";
      axios.post(this.$api.getApiEntity,this.dataInfo).then(res => {
            this.loading = false;
            this.inputFields = res.body.outputFields; 
      }).catch(err => {
            this.loading = false;
      });