fix(AiEartagPicker): 修复耳标选择器组件
- 优化代码格式和缩进 - 修复 penId 属性未使用的问题 - 改进 getEartag 方法,确保正确处理返回数据 - 更新模板中的点击事件和样式
This commit is contained in:
@@ -3,8 +3,8 @@ export default {
|
||||
name: "AiEartagPicker",
|
||||
props: {
|
||||
instance: Function,
|
||||
value: {default: () => []},
|
||||
action: {default: "/api/breed/earTag/getEarTagByPenId"},
|
||||
value: { default: () => [] },
|
||||
action: { default: "/api/breed/earTag/getEarTagByPenId" },
|
||||
penId: String
|
||||
},
|
||||
model: {
|
||||
@@ -39,7 +39,7 @@ export default {
|
||||
getEartag() {
|
||||
!/undefined/.test(this.api) && this.instance.post(this.api).then(res => {
|
||||
if (res?.data) {
|
||||
this.list = res.data
|
||||
this.list = res.data?.map(v => ({ key: v, label: v })) || []
|
||||
}
|
||||
})
|
||||
},
|
||||
@@ -54,15 +54,16 @@ export default {
|
||||
|
||||
<template>
|
||||
<section class="AiEartagPicker">
|
||||
<div style="width: auto;" v-if="$slots.default" @click="dialog=true">
|
||||
<slot/>
|
||||
<div style="width: auto;" v-if="$slots.default" @click="dialog = true">
|
||||
<slot />
|
||||
</div>
|
||||
<el-select v-else :value="value" clearable multiple placeholder="请选择">
|
||||
<el-option v-for="op in list" :key="op.id" :label="op.earTag" :value="op.id"/>
|
||||
<div slot="prefix" @click.stop="dialog=true"/>
|
||||
<el-option v-for="op in list" :key="op.id" :label="op.earTag" :value="op.id" />
|
||||
<div slot="prefix" @click.stop="dialog = true" />
|
||||
</el-select>
|
||||
<ai-dialog v-model="dialog" title="选择牲畜" width="640px" @confirm="handleConfirm" @closed="selected=[]" @open="selected=value">
|
||||
<el-transfer :data="list" v-model="selected" :titles="['可选','已选择']"/>
|
||||
<ai-dialog v-model="dialog" title="选择牲畜" width="640px" @confirm="handleConfirm" @closed="selected = []"
|
||||
@open="selected = value">
|
||||
<el-transfer :data="list" v-model="selected" :titles="['可选', '已选择']" />
|
||||
</ai-dialog>
|
||||
</section>
|
||||
</template>
|
||||
@@ -84,7 +85,7 @@ export default {
|
||||
right: 0;
|
||||
z-index: 999;
|
||||
|
||||
& > div {
|
||||
&>div {
|
||||
height: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user