关注我们: 微信公众号

微信公众号

电脑用户请使用手机扫描二维码

手机用户请微信打开后长按二维码 -> 识别二维码

动态添加时间范围,如何实现已选时间段的置灰效果?

IT技术 2024-11-12 829

动态添加时间范围,如何实现已选时间段的置灰效果?

动态添加时间范围,如何置灰已选择时间?

问题:
在时间范围选择界面中,需要实现以下规则:

  1. 开始时段选择后,结束时段的值小于开始时段的置灰不能选择。
  2. 选择了多个时间段后,已选的时间段置灰不能选择。

解决方法:

父组件代码示例:

<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

未查询到任何数据!
◎欢迎您留言咨询,请在这里提交您想咨询的内容。