Commit 6248e99a authored by 徐俊's avatar 徐俊

xujun

parent ae681571
...@@ -2,13 +2,14 @@ ...@@ -2,13 +2,14 @@
<a-cascader v-model="selected" :style="{width:'80%'}" :options="options" :show-search="{ filter }" :display-render="displayRender" expand-trigger="hover" placeholder="请选择学科代码" @change="onChange" /> <a-cascader v-model="selected" :style="{width:'80%'}" :options="options" :show-search="{ filter }" :display-render="displayRender" expand-trigger="hover" placeholder="请选择学科代码" @change="onChange" />
</template> </template>
<script> <script>
import { specList, getSpecArray } from "@/views/components/common/config" //import { specList, getSpecArray } from "@/views/components/common/config"
export default { export default {
name: "cascaderSelect", name: "cascaderSelect",
data () { data () {
return { return {
options: specList, options: [],
selected: null, selected: null,
specArray: [],
}; };
}, },
props: { props: {
...@@ -20,13 +21,41 @@ export default { ...@@ -20,13 +21,41 @@ export default {
}, },
}, },
created () { created () {
if (!!this.value) { this.loadSpecList()
this.selected = getSpecArray(this.value) //this.selected = getSpecArray(this.value)
// this.$emit("change"); // this.$emit("change");
// this.$emit("input", this.selected) // this.$emit("input", this.selected)
}
}, },
methods: { methods: {
loadSpecList () {
this.$api.parameter.getKnowledgeInfoList2().then(({ data = {} }) => {
if (data) {
this.options = data
this.loadSpecArray()
this.loading = true
}
})
},
loadSpecArray () {
this.$api.parameter.getSpecArray().then(({ data = {} }) => {
if (data) {
this.specArray = data
if (!!this.value)
this.selected = this.getSpecInfo(this.value)
}
})
},
getSpecInfo(key) {
let newArray = this.specArray.filter(
function (el) {
return el.key == key
}
);
if (!!newArray && newArray.length > 0)
return [newArray[0].ppkey, newArray[0].pkey, newArray[0].key]
else
return null
},
onChange (value, selectedOptions) { onChange (value, selectedOptions) {
this.selected = value this.selected = value
if (!!this.selected && this.selected.length == 3) { if (!!this.selected && this.selected.length == 3) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment