feat(xumu): 优化耳标号选择功能
- 在 AppInsuranceApply 和 AppLoanApply 组件中添加 value-key 属性 - 在 AiEartagPicker 组件中增加对 valueKey 属性的支持- 优化 AiEartagPicker 组件的样式和布局
This commit is contained in:
@@ -125,7 +125,7 @@ export default {
|
||||
</ai-card>
|
||||
<ai-card title="投保对象">
|
||||
<template #right v-if="isAdd||isEdit">
|
||||
<ai-eartag-picker @select="v=>detail.detailList=v" :instance="instance"
|
||||
<ai-eartag-picker @select="v=>detail.detailList=v" :instance="instance" value-key="biochipEarNumber"
|
||||
:action="`/api/insurance/apply/getEarNumberList?farmId=${detail.farmId}`">
|
||||
<el-button type="text">选择</el-button>
|
||||
</ai-eartag-picker>
|
||||
|
||||
@@ -129,7 +129,7 @@ export default {
|
||||
<ai-card title="质押标的">
|
||||
<template #right>
|
||||
<ai-input placeholder="请输入/扫描耳标号" v-model="filterText" class="shrink"/>
|
||||
<ai-eartag-picker @select="v=>detail.detailList=v" :instance="instance" v-if="isAdd||isEdit"
|
||||
<ai-eartag-picker @select="v=>detail.detailList=v" :instance="instance" v-if="isAdd||isEdit" value-key="biochipEarNumber"
|
||||
:action="`/api/insurance/apply/getEarNumberList?farmId=${detail.farmId}`">
|
||||
<el-button type="text">选择</el-button>
|
||||
</ai-eartag-picker>
|
||||
|
||||
@@ -3,9 +3,10 @@ export default {
|
||||
name: "AiEartagPicker",
|
||||
props: {
|
||||
instance: Function,
|
||||
value: { default: () => [] },
|
||||
action: { default: "/api/breed/earTag/getEarTagByPenId" },
|
||||
penId: String
|
||||
value: {default: () => []},
|
||||
action: {default: "/api/breed/earTag/getEarTagByPenId"},
|
||||
penId: String,
|
||||
valueKey: String
|
||||
},
|
||||
model: {
|
||||
prop: "value",
|
||||
@@ -39,7 +40,14 @@ export default {
|
||||
getEartag() {
|
||||
!/undefined/.test(this.api) && this.instance.post(this.api).then(res => {
|
||||
if (res?.data) {
|
||||
this.list = res.data?.map(v => ({ key: v, label: v })) || []
|
||||
const key = this.valueKey
|
||||
this.list = res.data?.map(v => {
|
||||
if (typeof v == 'string') {
|
||||
return {key: v, label: v}
|
||||
} else if (key) {
|
||||
return {key: v[key], label: v[key]}
|
||||
}
|
||||
}) || []
|
||||
}
|
||||
})
|
||||
},
|
||||
@@ -55,15 +63,15 @@ export default {
|
||||
<template>
|
||||
<section class="AiEartagPicker">
|
||||
<div style="width: auto;" v-if="$slots.default" @click="dialog = true">
|
||||
<slot />
|
||||
<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,i) in list" :key="i" :label="op.label" :value="op.key"/>
|
||||
<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="800px" @confirm="handleConfirm" @closed="selected = []"
|
||||
@open="selected = value">
|
||||
<el-transfer :data="list" v-model="selected" :titles="['可选', '已选择']"/>
|
||||
</ai-dialog>
|
||||
</section>
|
||||
</template>
|
||||
@@ -85,10 +93,21 @@ export default {
|
||||
right: 0;
|
||||
z-index: 999;
|
||||
|
||||
&>div {
|
||||
& > div {
|
||||
height: 100%;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
:deep(.el-transfer) {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
|
||||
.el-transfer-panel {
|
||||
width: auto;
|
||||
min-width: 200px;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user