<template v-if="column.key === 'status'">
            <a-switch
              :disabled="!user.authorities.includes('schedule:update')"
              :loading="loading"
              :checked="record.status"
              :checked-value="1"
              :unchecked-value="2"
              @change="editStatus(record)"
            />
          </template>
checkedValue选中时的值
unCheckedValue非选中时的值
checked(v-model)指定当前是否选中
/** 修改用户状态 */
  const editStatus = async (row: InspectionScheduleDTO) => {
    loading = true
    const status = row.status === 1 ? 2 : 1

    try {
      await putInspectionScheduleEffective({
        id: row.id,
        status
      })
      row.status = status
      message.success('修改成功')
      reload()
    } catch (err: any) {
      message.error(err.message)
    } finally {
      loading = false
    }
  }

 const status = row.status === 1 ? 2 : 1   如果选中的值为1的话就把它变成2,否则就变成1

Logo

前往低代码交流专区

更多推荐