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