动态添加时间范围,如何置灰已选择时间?
问题:
在时间范围选择界面中,需要实现以下规则:
- 开始时段选择后,结束时段的值小于开始时段的置灰不能选择。
- 选择了多个时间段后,已选的时间段置灰不能选择。
解决方法:
父组件代码示例:
<template> <el-table :data="tabledata"> <el-table-column prop="starttime" label="开始时段"></el-table-column> <el-table-column prop="endtime" label="结束时段"></el-table-column> <el-table-column prop="remark" label="备注"></el-table-column> <el-table-column label="操作"> <template slot-scope="scope"> <el-button type="primary" @click="handleedit(scope.row)">编辑</el-button> <el-button type="danger" @click="handledelete(scope.row)">删除</el-button> </template> </el-table-column> </el-table> </template> <script> import { reactive, ref } from 'vue'; import editdialog from './editdialog.vue'; export default { data() { return { tabledata: reactive([]), } }, components: { editdialog }, methods: { // 编辑时间范围 handleedit(row) { this.$refs.editdialog.toggledialog(row); }, // 删除时间范围 handledelete(row) { this.tabledata = this.tabledata.filter(item => item !== row); }, }, } </script>
网友留言2