<template> | <template> | ||||
<n-switch v-bind="getSwitchProps" v-model:value="switchVlue" @update:value="changeValue" /> | |||||
<n-switch v-bind="getSwitchProps" v-model:value="getSwitchValue" @update:value="changeValue" /> | |||||
</template> | </template> | ||||
<script> | <script> | ||||
import { defineComponent, ref, unref, computed } from 'vue' | |||||
import { defineComponent, unref, computed } from 'vue' | |||||
export default defineComponent({ | export default defineComponent({ | ||||
name: 'TableSwitch', | name: 'TableSwitch', | ||||
props: { | props: { | ||||
}, | }, | ||||
emits: ['change'], | emits: ['change'], | ||||
setup(props, { emit }) { | setup(props, { emit }) { | ||||
const switchVlue = ref() | |||||
const { data, rowKey } = unref(props) | |||||
switchVlue.value = rowKey ? data[rowKey] : data | |||||
// const switchValue = ref() | |||||
// const { data, rowKey } = unref(props) | |||||
// switchValue.value = rowKey ? data[rowKey] : data | |||||
const getSwitchValue = computed(() => { | |||||
const { data, rowKey } = unref(props) | |||||
const value = rowKey ? data[rowKey] : data | |||||
return value | |||||
}) | |||||
const getSwitchProps = computed(() => { | const getSwitchProps = computed(() => { | ||||
console.log(111) | |||||
return { | return { | ||||
...unref(props) | ...unref(props) | ||||
} | } | ||||
emit('change', params) | emit('change', params) | ||||
} | } | ||||
return { | return { | ||||
switchVlue, | |||||
// switchValue, | |||||
getSwitchValue, | |||||
getSwitchProps, | getSwitchProps, | ||||
changeValue | changeValue | ||||
} | } |
<!-- 基本信息 --> | <!-- 基本信息 --> | ||||
<div class="cont"> | <div class="cont"> | ||||
<n-descriptions label-placement="left" label-align="right" :column="4" title="任务基本信息"> | <n-descriptions label-placement="left" label-align="right" :column="4" title="任务基本信息"> | ||||
<n-descriptions-item v-for="(it, i) in (basicInfo.slice(0, -1))" :key="i + it.label" :label="it.label"> | |||||
{{ it.value }} | |||||
</n-descriptions-item> | |||||
<template v-for="(it, i) in (basicInfo.slice(0, -1))" :key="i + it.label"> | |||||
<n-descriptions-item v-if="!it.isShow" :label="it.label"> | |||||
{{ it.value }} | |||||
</n-descriptions-item> | |||||
</template> | |||||
</n-descriptions> | </n-descriptions> | ||||
<!-- 为了格式,折腾 --> | <!-- 为了格式,折腾 --> | ||||
<n-descriptions label-placement="left" label-align="right" class="note"> | <n-descriptions label-placement="left" label-align="right" class="note"> |
import { customRef } from 'vue' | import { customRef } from 'vue' | ||||
export default function(data) { | export default function(data) { | ||||
console.log(data) | |||||
const list = [ | const list = [ | ||||
{ | { | ||||
label: '平台', | label: '平台', | ||||
label: '客户名称', | label: '客户名称', | ||||
value: data.tenantName | value: data.tenantName | ||||
}, | }, | ||||
{ | |||||
label: '任务名称', | |||||
value: data.taskName | |||||
}, | |||||
{ | { | ||||
label: '任务编号', | label: '任务编号', | ||||
value: data.taskCode | value: data.taskCode | ||||
}, | }, | ||||
{ | { | ||||
label: '是否直播', | label: '是否直播', | ||||
value: data.isLive === 2 ? '否' : '是' | |||||
value: data.isLive === 2 ? '否' : '是', | |||||
isShow: data.inspectionType === 1 | |||||
}, | }, | ||||
{ | { | ||||
label: '备注', | label: '备注', |