123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- <template>
- <block v-if="!!list">
- <u-select
- :value="value"
- value-name="id"
- label-name="departmentName"
- child-name="children"
- mode="mutil-column-auto"
- :list="list"
- @confirm="confirm"
- @cancel="cancel"
- ></u-select>
- </block>
- </template>
- <script>
- export default {
- model: {
- prop: 'value',
- event: 'change'
- },
- props: {
- value: {
- type: Boolean,
- default: false
- }
- },
- data() {
- return {
- list: ''
- };
- },
- created() {
- this.getAllDepartment();
- },
- methods: {
- confirm(val) {
- this.cancel()
- this.$emit('confirm', val);
- },
- cancel(val) {
- this.$emit('cancel', val);
- },
- getAllDepartment() {
- this.$u.api.getAllDepartment().then(res => {
- // this.list = this.reduceList(res.data);
- this.list = res.data;
- });
- },
- reduceList(list) {
- list.unshift({
- id: 0,
- departmentName: '全部'
- });
- list.forEach(item => {
- if (item.children) {
- item.children = this.reduceList(item.children);
- }
- });
- return list;
- }
- }
- };
- </script>
- <style></style>
|