1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
<template>
<div>
<span>分类:</span>
<a-tree-select
v-model="breedId"
show-search
style="width: 200px"
:tree-data="medicalTypeList"
:replaceFields="replaceFields"
treeNodeFilterProp="title"
:dropdown-style="{ maxHeight: '400px', overflow: 'auto' }"
placeholder="选择分类"
allow-clear
:disabled="disabled"
@change="medicalTypeChange"
@click="getMedicalType"
></a-tree-select>
<span style="margin-left: 20px">品种名称:</span>
<a-select style="width: 200px" placeholder="选择品种名称" @change="medicalNameChange" v-model="medicalId" :disabled="disabled">
<a-select-option v-for="item in medicalNameList"
:key="item.id"
:dropdownMatchSelectWidth="false"
>
{{ item.medicineName }}
</a-select-option>
</a-select>
<span style="margin-left: 20px" v-if="enableBatch">生产批次:</span>
<a-select style="width: 200px" v-if="enableBatch" placeholder="选择生产批次" v-model="batchId" :disabled="disabled">
<a-select-option v-for="item in medicalBatchList" :key="item.id">
{{ item.batchNumber }}
</a-select-option>
</a-select>
</div>
</template>
<script>
import {toTree} from "../../utils/common";
export default {
name: "medicalAllSelect",
props: {
enableBatch: false,
},
data() {
return {
breedId: null,
medicalId: undefined,
batchId: undefined,
medicalTypeList: [],
medicalNameList: [],
medicalBatchList: [],
replaceFields: {
title: 'typeName',
key: 'id',
value: 'id',
children: 'children',
},
disabled: false
}
},
created() {
this.getMedicalType();
},
methods: {
getMedicalType() {
let params = {};
this.$api.common.fetchMedicalType(params).then(({code, data}) => {
this.medicalTypeList = toTree(data, '0', 'parentId', 'id');
});
},
medicalTypeChange(breedId) {
if (this.$api.utils.isBlank(breedId)) {
return;
}
this.$api.stockManage.fetchMedicineByType({breedId: breedId}).then(({data = []}) => {
this.medicalNameList = data;
this.medicalId = null;
this.batchId = null;
})
},
medicalNameChange(medicalId) {
if (!this.enableBatch) {
return;
}
this.$api.stockManage.fetchBatchByTypeAName({medicalId: medicalId}).then(({data = []}) => {
this.medicalBatchList = data;
this.batchId = null;
});
},
getValue() {
let content = [this.breedId, this.medicalId, this.batchId];
return content;
},
setValue(values, isDisabled = false) {
this.disabled = isDisabled;
this.breedId = values[0];
this.medicalId = values[1];
this.batchId = values[2];
},
},
}
</script>
<style scoped>
</style>