vue+java实现预约时间段、数量设置

本文将会介绍如何制作一个预约时间段、数量的设置;

笔者前端使用vue3+javaScript+element-plus编写;

后端采用springboot+mybatis-plus进行编写。

 效果演示

设置效果演示

  • 模板
<el-dialog :title="title" v-model="open" width="50vw" append-to-body :before-close="handleClose">
      <el-table
          :data="timeOptions"
          style="width: 100%;"
          border
      >
        <el-table-column label="预约时段" align="center">
          <template #default="scope">
            <el-row>
              <el-col :span="10">
                <el-time-picker
                    v-model="scope.row.startTime"
                    placeholder="开始时间"
                    format="HH:mm"
                    value-format="HH"
                    :editable="false"
                    :disabled-minutes = disabledMinutes
                ></el-time-picker>
              </el-col>
              <el-col :span="2" class="text-center">至</el-col>
              <el-col :span="10">
                <el-time-picker
                    v-model="scope.row.endTime"
                    placeholder="结束时间"
                    format="HH:mm"
                    value-format="HH"
                    :editable="false"
                    :disabled-minutes = disabledMinutes
                ></el-time-picker>
              </el-col>
            </el-row>
          </template>
        </el-table-column>

        <el-table-column label="可预约车辆数" align="center">
          <template #default="scope">
            <el-input-number
                v-model="scope.row.amount"
                :min="1"
                :max="20"
                placeholder="请输入数量"
            ></el-input-number>
          </template>
        </el-table-column>

        <el-table-column label="操作" align="center" width="100">
          <template #default="scope">
            <el-button
                type="success"
                :icon="Plus"
                circle
                size="small"
                v-if="!scope.row.configId"
                @click="saveRow(scope.row)"
            ></el-button>
            <el-button
                type="success"
                :icon="Edit"
                circle
                size="small"
                v-if="scope.row.configId"
                @click="updateRow(scope.row)"
            ></el-button>
            <el-button
                type="danger"
                :icon="Delete"
                circle
                size="small"
                @click="removeRow(scope.$index,scope.row)"
            ></el-button>
          </template>
        </el-table-column>
      </el-table>

      <el-button
          type="primary"
          :icon="Edit"
          size="default"
          @click="addRow"
          style="margin-top: 10px;"
      >
        新增时间段
      </el-button>
    </el-dialog>
  • 脚本
function  makeRange(start, end) {
    const result = [];
    for (let i = start; i < end; i++) {
        result.push(i);
    }
    return result;
}
export function disabledMinutes(){
    return makeRange(0, 60)
}
export function getTimeList(){
    listTime().then(res=>{
        open.value = true
        title.value = '设置工作时间'
        timeOptions.value = res.data
    })
}
export function addRow(){
    if (timeOptions.value.length == 0 || timeOptions.value[timeOptions.value.length - 1].configId){
        timeOptions.value.push({
            startTime:'',
            endTime:'',
            amount:0
        })
    }else {
        ElMessage.error('请先填写并提交预约时间配置');
    }
}
export function saveRow(row){
    if (!row.startTime || !row.endTime || !row.amount){
        ElMessage.error('请填写完整信息');
        return
    }
    const requestBody = {
        startTime:formatTime(row.startTime),
        endTime:formatTime(row.endTime),
        amount:row.amount
    }
    addTime(requestBody).then(res=>{
        ElMessage.success('保存成功')
        getTimeList()
    })
}
export function updateRow(row){
    const startTime = row.startTime.split(":")[0]
    const endTime = row.endTime.split(":")[0]
    const requestBody = {
        configId:row.configId,
        startTime:formatTime(startTime),
        endTime:formatTime(endTime),
        amount:row.amount
    }
    updateTime(requestBody).then(res=>{
        ElMessage.success('修改成功')
        getTimeList()
    })
}
export function removeRow(index, row){
    if (row.configId){
        ElMessageBox.confirm(
            '确定要删除该配置吗?',
            '系统提示',
            {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning',
            }
        ).then(() => {
            deleteTime(row.configId).then(res=>{
                ElMessage.success('删除成功')
                getTimeList()
            })
        }).catch(() => {
            ElMessage.info('已取消删除')
        })
    }else {
        timeOptions.value.splice(index,1)
    }
}
export function handleClose(){
    ElMessageBox.confirm('你确定要关闭该对话框吗?').then(() =>{
        open.value = false
    })
}
  •  后端
@RestController
@RequestMapping("/calendar/holiday")
public class CalendarController {
    @Autowired
    private final WechatTimeConfigService timeConfigService;
    public CalendarController(WechatCalendarService calendarService) {
        this.timeConfigService = timeConfigService;
    }
    
    @GetMapping("/time/list")
    public AjaxResult timeList(){
        List<WechatTimeConfig> list = timeConfigService.list();
        return AjaxResult.success(list);
    }
    @PostMapping("/time/add")
    public AjaxResult addTime(@RequestBody WechatTimeConfig timeConfig){
        timeConfig.setCreateTime(LocalDateTime.now());
        timeConfigService.save(timeConfig);
        return AjaxResult.success();
    }
    @PutMapping("/time/update")
    public AjaxResult updateTime(@RequestBody WechatTimeConfig timeConfig){
        timeConfigService.updateById(timeConfig);
        return AjaxResult.success();
    }
    @DeleteMapping("/time/delete/{configId}")
    public AjaxResult deleteTime(@PathVariable Long configId){
        timeConfigService.removeById(configId);
        return AjaxResult.success();
    }
}

基于java的实验室网上预约系统设计与实现 技术:后端:java前端:html+js+css 框架:springBoot SSM 运行工具:idea 数据库:mysql 源码:详见文章最后 1、    登录页面: 2、首页 3、用户管理  4、添加用户  5、角色管理  6、添加角色  7、编辑角色 8、预约管理  9、新增预约  10、数据统计 数据库脚本如下: CREATE TABLE `sys_user_t` ( `id` INT(11) NOT NULL AUTO_INCREMENT, `role_id` VARCHAR(500) NULL DEFAULT NULL COMMENT '角色ID', `user_id` VARCHAR(50) NOT NULL COMMENT '用户ID', `user_name` VARCHAR(100) NOT NULL COMMENT '用户名', `status` VARCHAR(50) NOT NULL COMMENT '是否有效0:false\\\\\\\\1:true', `create_date` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP, `create_by` VARCHAR(100) NULL DEFAULT NULL, `last_update_date` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP, `last_update_by` VARCHAR(100) NULL DEFAULT NULL, `password` VARCHAR(128) NOT NULL, `tenantcode` VARCHAR(50) NOT NULL, `diskId` VARCHAR(500) NULL DEFAULT NULL, `remarks` VARCHAR(500) NULL DEFAULT NULL, PRIMARY KEY (`id`) ) COMMENT='系统用户表' COLLATE='utf8_general_ci' ENGINE=InnoDB AUTO_INCREMENT=52 ; CREATE TABLE `sys_role_t` ( `role_id` INT(11) NOT NULL COMMENT '角色ID', `role_name` VARCHAR(200) NOT NULL COMMENT '权限名称', `status` INT(11) NOT NULL COMMENT '是否有效0:true\\\\1:false', `create_date` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP, `create_by` VARCHAR(100) NULL DEFAULT NULL, `last_update_date` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP, `last_update_by` VARCHAR(100) NULL DEFAULT NULL ) COMMENT='系统角色表' COLLATE='utf8_general_ci' ENGINE=InnoDB ; CREATE TABLE `sys_menu_t` ( `id` INT(11) NOT NULL AUTO_INCREMENT COMMENT '序列', `parent_id` VARCHAR(50) NOT NULL COMMENT '父节点ID', `menu_id` VARCHAR(50) NOT NULL COMMENT '菜单ID', `menu_name` VARCHAR(200) NOT NULL COMMENT '菜单名称', `menu_url` VARCHAR(200) NULL DEFAULT NULL COMMENT '菜单URL', `status` INT(11) NOT NULL COMMENT '有效(0有效,1失效)', `create_date` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP, `create_by` VARCHAR(200) NULL DEFAULT NULL, `last_update_date` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP, `last_update_by` VARCHAR(200) NULL DEFAULT NULL, PRIMARY KEY (`id`) ) COMMENT='菜单表' COLLATE='utf8_general_ci' ENGINE=InnoDB AUTO_INCREMENT=33 ; CREATE TABLE `client_manager_t` ( `id` INT(11) NOT NULL AUTO_INCREMENT COMMENT '序列', `clientId` VARCHAR(50) NULL DEFAULT NULL COMMENT '客户编号', `clientName` VARCHAR(50) NULL DEFAULT NULL COMMENT '客户姓名', `address` VARCHAR(200) NULL DEFAULT NULL COMMENT '客户住址', `source` VARCHAR(200) NULL DEFAULT NULL COMMENT '客户所属公司', `sourceDate` VARCHAR(200) NULL DEFAULT NULL COMMENT '客户发展时间', `status` VARCHAR(200) NULL DEFAULT NULL COMMENT '客户级别', `clientNum` VARCHAR(200) NULL DEFAULT NULL COMMENT '拜访客户次数', `isTrue` VARCHAR(200) NULL DEFAULT NULL COMMENT '客户是否有效', PRIMARY KEY (`id`) ) COMMENT='客户人员信息表' COLLATE='utf8_general_ci' ENGINE=InnoDB AUTO_INCREMENT=47 ;
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值