12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- import { shelfTemplateList } from '@/api/shelfTemplate'
- const custType = {
- template: `
- <a-select
- :placeholder="placeholder"
- :id="id"
- allowClear
- :value="defaultVal"
- :showSearch="true"
- @change="handleChange"
- option-filter-prop="children"
- :dropdownMatchSelectWidth="false"
- :filter-option="filterOption">
- <a-select-option v-for="item in list" :key="item.templateSn" :value="item.templateSn">{{ item.templateName }}</a-select-option>
- </a-select>
- `,
- props: {
- value: {
- type: String,
- },
- id: {
- type: String,
- default: ''
- },
- placeholder: {
- type: String,
- default: '请选择货架模板'
- }
- },
- data() {
- return {
- defaultVal: this.value,
- list: []
- };
- },
- mounted() {
- this.getList()
- },
- watch: {
- value(newValue, oldValue) {
- this.defaultVal = newValue
- }
- },
- methods: {
- filterOption (input, option) {
- return (
- option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
- )
- },
- handleChange(value) {
- this.defaultVal = value;
- this.$emit('change', value);
- this.$emit('input', value);
- },
- getList () {
- shelfTemplateList({pageNo:1,pageSize:100}).then(res => {
- if (res.status == 200) {
- this.list = res.data.list
- } else {
- this.list = []
- }
- })
- },
- },
- };
- export default custType
|