Ben Lin
2024-03-24 b72cc34ab2fef7d6bcaca3e2b11231713d622fce
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
<!--
 * @Author: Vben
 * @Description: logo component
-->
<template>
  <div class="anticon">
    <a-row class="enter-x">
      <a-col :md="24" :xs="24" :span="24">
        <BasicForm @register="registerForm" />
      </a-col>
    </a-row>
  </div>
</template>
<script lang="ts" setup>
  import { onMounted } from 'vue';
  import { Row, Col } from 'ant-design-vue';
  import { BasicForm, useForm } from '/@/components/Form/index';
  import { getTreeList, optionsListApi } from '/@/api/tigerapi/dept';
  import { appFormDept } from './appFormDept.data';
  import { useUserStore } from '/@/store/modules/user';
  
  const ARow = Row
  const ACol = Col
  onMounted(async () => {
    const temp = await getTreeList();
    const treeData = [];
    const treeOption = await optionsListApi(useUserStore().getUserInfo.userId);
    let newArr = []
    //newArr.push(treeOption.Data.Items[0])
    for (let i = 0; i < treeOption.Data.Items.length; i++) {
    // 设置一个开关,如果是true,就存进去,不是就不存
    let flag = true
    for (let j = 0; j < newArr.length; j++) {
      // 原数组和新数组作比较,如果一致,开关变为 false
      treeOption.Data.Items[i].ORG_CODE === newArr[j].ORG_CODE ? flag = false : flag
    };
      flag ? newArr.push(treeOption.Data.Items[i]) : newArr
    };
      
    
      
    newArr.map((item) => {
      let options = temp.find((obj) => obj.id == item.ORG_ID);
      treeData.push(options);
    });
 
    updateSchema([
      {
        field: 'dept',
        componentProps: { treeData },
      },
    ]);
    setFieldsValue({
      dept: useUserStore().getUserInfo.orgCode,
    });
  });
 
  const [registerForm, { updateSchema, setFieldsValue }] = useForm({
    // labelWidth: 200,
    baseColProps: { span: 24 },
    schemas: appFormDept,
    showActionButtonGroup: false,
    actionColOptions: {
      span: 23,
    },
  });
</script>
<style lang="less" scoped>
  @prefix-cls: ~'@{namespace}-app-logo';
 
  .@{prefix-cls} {
    display: flex;
    align-items: center;
    padding-left: 7px;
    transition: all 0.2s ease;
    cursor: pointer;
 
    &.light {
      border-bottom: 1px solid @border-color-base;
    }
 
    &.collapsed-show-title {
      padding-left: 20px;
    }
 
    &.light &__title {
      color: @primary-color;
    }
 
    &.dark &__title {
      color: @white;
      font-size: 16px;
    }
 
    &__title {
      transition: all 0.5s;
      // font-size: 16px;
      font-weight: 700;
      line-height: normal;
    }
  }
</style>