美文网首页
1、常数项类别添加

1、常数项类别添加

作者: wqjcarnation | 来源:发表于2020-05-07 10:01 被阅读0次

目标

  • 前台和路由配置
  • 后台

前台

components/sys/constanttype/ConstantAdd.vue

<template>
<el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="130px" class="demo-ruleForm">
  <el-form-item label="常数类别编码" prop="constantTypeCode">
    <el-input v-model="ruleForm.constantTypeCode"></el-input>
  </el-form-item>
<el-form-item label="常数类别名称" prop="constantTypeName">
    <el-input v-model="ruleForm.constantTypeName"></el-input>
  </el-form-item>
  <el-form-item>
    <el-button type="primary" @click="submitForm('ruleForm')">立即创建</el-button>
    <el-button @click="resetForm('ruleForm')">重置</el-button>
  </el-form-item>
</el-form>
</template>
<script>
  export default {
    data() {
      return {
        ruleForm: {
          constantTypeCode: '',
          constantTypeName: ''
        },
        rules: {
          constantTypeCode: [
            { required: true, message: '请输入常数类别编码', trigger: 'blur' },
            { min: 3, max: 64, message: '长度在 3 到 64 个字符', trigger: 'blur' }
          ],
          constantTypeName: [
           { required: true, message: '请输入常数类别名称', trigger: 'blur' },
           { min: 3, max: 64, message: '长度在 3 到 64 个字符', trigger: 'blur' }
          ]
        }
      };
    },
    methods: {
      submitForm(formName) {
        this.$refs[formName].validate((valid) => {
          if (valid) {
            //如果验证通过,向后台请求添加 
            alert('submit!');
            this.$axios.post('http://localhost:8082/sys/constanttype/add',this.ruleForm,{headers: {
                    'Content-Type': 'application/json;charset=UTF-8'
                }})
                .then(response=>{
                    let code=response.data.code;
                    if(code=='0'){
                        alert('添加成功')
                        //回到列表页
                    }else{
                        //失败,打印错误原因
                        alert(response.data.msg)
                    }
                })
            
          } else {
            console.log('error submit!!');
            return false;
          }
        });
      },
      resetForm(formName) {
        this.$refs[formName].resetFields();
      }
    }
  }
</script>

路由配置

      {
        path:'/constantAdd',
        name:'ConstantAdd',
        component:ConstantAdd
    }

后台关键代码

  • ConstantTypeController
package com.neuedu.demo.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.neuedu.demo.domain.Constanttype;
import com.neuedu.demo.domain.ResponseBean;
import com.neuedu.demo.service.IConstantTypeService;

@RestController
@RequestMapping("/sys/constanttype")
public class ConstantTypeController {
    @Autowired
    IConstantTypeService constantTypeServiceImpl;
    
    @RequestMapping("add")
    public ResponseBean add(@RequestBody Constanttype type){
        ResponseBean result=new ResponseBean();
        Constanttype db_type=constantTypeServiceImpl.save(type);
        if(db_type!=null){
            result.setCode("0");
            result.setMsg("操作成功");
        }else{
            result.setCode("-1");
            result.setMsg("操作失败");
        }
        return result;
    }

}
  • Constanttype实体

    package com.neuedu.demo.domain;

    import java.io.Serializable;
    import javax.persistence.*;

/**
 * The persistent class for the constanttype database table.
 * 常数类别管理
 */
@Entity
@NamedQuery(name="Constanttype.findAll", query="SELECT c FROM Constanttype c")
public class Constanttype implements Serializable {
    private static final long serialVersionUID = 1L;
    @Column(name = "constantTypeCode", nullable = true, length = 64)
    private String constantTypeCode;
    @Column(name = "constantTypeName", nullable = true, length = 64)
    private String constantTypeName;

    private int delMark=1;
    @GeneratedValue(strategy=GenerationType.IDENTITY)
    @Id
    private int id;

    public Constanttype() {
    }

    public String getConstantTypeCode() {
        return this.constantTypeCode;
    }

    public void setConstantTypeCode(String constantTypeCode) {
        this.constantTypeCode = constantTypeCode;
    }

    public String getConstantTypeName() {
        return this.constantTypeName;
    }

    public void setConstantTypeName(String constantTypeName) {
        this.constantTypeName = constantTypeName;
    }

    public int getDelMark() {
        return this.delMark;
    }

    public void setDelMark(int delMark) {
        this.delMark = delMark;
    }

    public int getId() {
        return this.id;
    }

    public void setId(int id) {
        this.id = id;
    }
}

相关文章

  • 1、常数项类别添加

    目标 前台和路由配置 后台 前台 components/sys/constanttype/ConstantAdd....

  • 10-挂号页面开发(讲)

    性别 结算类别 收费方式从后台常数项中读取

  • IOS学习笔记之类别与扩展

    1. 类别 (1)为已有的类添加新的方法 (2)可以在类别中添加新属性,但是不能为类别添加新的实例变量。 (3)缺...

  • 4、常数项添加

    前台 后台 ConstantTypeController中新增加 新建ConstantItemController...

  • 3、 基本信息任务分配

    学生分组完成以下功能 常数项管理 科室管理 挂号级别管理(做到常数项里) 结算类别管理 疾病分类管理 病症管理 费...

  • 8、基本信息管理-任务分配

    学生分组完成以下功能 常数项管理(每人必做) 科室管理 挂号级别管理 结算类别管理(合并到常数项里) 疾病分类管理...

  • 十六、关联对象

    分类和类别 1: category: 类别,分类 专门用来给类添加新的方法 不能给类添加成员 属性,添加了成员变量...

  • iOS 简单理解分类(category)和类扩展(extensi

    类别(category): 1.类别不能为已存在的类添加实例变量。 2.类别中添加的方法优先级高,会覆盖原类中的方...

  • 为Category添加属性

    1.创建UIViewController的类别并添加几个属性 2.UIViewController类别.m的实现 ...

  • iOS中的runTime

    运行时,我们最常见的可能就是创建类别(Category),为类别添加属性,类别是不能直接添加属性的,可以添加方法,...

网友评论

      本文标题:1、常数项类别添加

      本文链接:https://www.haomeiwen.com/subject/pidoghtx.html