mirror of
https://gitee.com/ssssssss-team/magic-boot.git
synced 2025-01-31 17:12:49 +08:00
修复switch 选择问题
This commit is contained in:
parent
f338e97208
commit
4fe228fdcb
@ -16,12 +16,10 @@
|
||||
</span>
|
||||
<slot v-else-if="col.type == 'dynamic'" :name="col.field" :row="scope.row" :index="scope.$index" />
|
||||
<div v-else-if="col.type == 'switch'">
|
||||
<el-switch
|
||||
v-if="col.if === undefined ? true : col.if(scope.row)"
|
||||
v-model="scope.row[col.field]"
|
||||
:active-value="(col.activeValue || 1) + ''"
|
||||
:inactive-value="(col.inactiveValue || 0) + ''"
|
||||
@change="col.change(scope.row)"
|
||||
<mb-switch
|
||||
v-if="col.if === undefined ? true : col.if(scope.row)"
|
||||
v-model="scope.row[col.field]"
|
||||
@change="col.change(scope.row)"
|
||||
/>
|
||||
</div>
|
||||
<div v-else-if="col.type == 'btns'">
|
||||
|
@ -4,12 +4,13 @@
|
||||
:active-value="_activeValue"
|
||||
:inactive-value="_inactiveValue"
|
||||
v-bind="props.props"
|
||||
@change="change"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import {ref, watch} from 'vue'
|
||||
const emit = defineEmits(['update:modelValue'])
|
||||
const emit = defineEmits(['update:modelValue', 'change'])
|
||||
const selectValue = ref('')
|
||||
const props = defineProps({
|
||||
modelValue: Boolean | String | Number,
|
||||
@ -20,15 +21,15 @@ const props = defineProps({
|
||||
const _activeValue = ref(true)
|
||||
const _inactiveValue = ref(false)
|
||||
|
||||
function change(){
|
||||
emit('update:modelValue', selectValue.value)
|
||||
emit('change', selectValue.value)
|
||||
}
|
||||
|
||||
function setActive(value){
|
||||
if(typeof(value) == 'boolean'){
|
||||
if(props.activeValue == undefined && props.inactiveValue == undefined){
|
||||
_activeValue.value = true
|
||||
_inactiveValue.value = false
|
||||
}else{
|
||||
_activeValue.value = props.activeValue
|
||||
_inactiveValue.value = props.inactiveValue
|
||||
}
|
||||
_activeValue.value = true
|
||||
_inactiveValue.value = false
|
||||
}else{
|
||||
if(value || value == 0){
|
||||
if(props.activeValue == undefined && props.inactiveValue == undefined){
|
||||
|
Loading…
Reference in New Issue
Block a user