Commit 051f031e4e263c568a3c9ec9459f3a21058039f6

Authored by fengtao
1 parent f5cb7ffc

pref:优化设备列表 没有组织,弹窗组织

1 1 import { FormSchema } from '/@/components/Form';
2 2 import { findDictItemByCode } from '/@/api/system/dict';
3 3 import { deviceProfile, getGATEWAYdevice } from '/@/api/device/deviceManager';
4   -import { getOrganizationList } from '/@/api/system/system';
5   -import { copyTransFun } from '/@/utils/fnUtils';
6 4
7 5 export enum TypeEnum {
8 6 IS_GATEWAY = 'GATEWAY',
... ... @@ -82,25 +80,10 @@ export const step1Schemas: FormSchema[] = [
82 80 },
83 81 {
84 82 field: 'organizationId',
85   - required: true,
86 83 label: '所属组织',
87   - component: 'ApiTreeSelect',
88   - componentProps({ formActionType }) {
89   - const { setFieldsValue } = formActionType;
90   - return {
91   - api: async () => {
92   - const data = await getOrganizationList();
93   - copyTransFun(data as any as any[]);
94   - return data;
95   - },
96   -
97   - onChange() {
98   - setFieldsValue({
99   - gatewayId: null,
100   - });
101   - },
102   - };
103   - },
  84 + component: 'Input',
  85 + required: true,
  86 + slot: 'addOrg',
104 87 },
105 88 {
106 89 field: 'gatewayId',
... ...
... ... @@ -2,6 +2,25 @@
2 2 <div class="step1">
3 3 <div class="step1-form">
4 4 <BasicForm @register="register">
  5 + <template #addOrg="{ model, field }">
  6 + <div style="display: flex; align-items: center">
  7 + <div style="width: 245px">
  8 + <a-tree-select
  9 + v-model:value="model[field]"
  10 + show-search
  11 + style="width: 100%"
  12 + :dropdown-style="{ maxHeight: '400px', overflow: 'auto' }"
  13 + placeholder="请选择组织"
  14 + allow-clear
  15 + tree-default-expand-all
  16 + :tree-data="treeData"
  17 + />
  18 + </div>
  19 + <div>
  20 + <a-button type="link" @click="handleOpenOrgDrawer">新增组织</a-button>
  21 + </div>
  22 + </div>
  23 + </template>
5 24 <template #iconSelect>
6 25 <Upload
7 26 name="avatar"
... ... @@ -86,10 +105,11 @@
86 105 <div ref="wrapRef" style="height: 300px; width: 90%" class="ml-6"></div>
87 106 </div>
88 107 </Modal>
  108 + <DeptDrawer @register="registerModal" @success="handleSuccess" />
89 109 </div>
90 110 </template>
91 111 <script lang="ts">
92   - import { defineComponent, ref, nextTick, unref, reactive } from 'vue';
  112 + import { defineComponent, ref, nextTick, unref, reactive, toRefs, onMounted } from 'vue';
93 113 import { BasicForm, useForm } from '/@/components/Form';
94 114 import { step1Schemas } from '../../config/data';
95 115 import { useScript } from '/@/hooks/web/useScript';
... ... @@ -102,6 +122,10 @@
102 122 import icon from '/@/assets/images/wz.png';
103 123 import { useDebounceFn } from '@vueuse/core';
104 124 import { validatorLongitude, validatorLatitude } from '/@/utils/rules';
  125 + import { getOrganizationList } from '/@/api/system/system';
  126 + import { copyTransFun } from '/@/utils/fnUtils';
  127 + import { useDrawer } from '/@/components/Drawer';
  128 + import DeptDrawer from '/@/views/system/organization/OrganizationDrawer.vue';
105 129
106 130 export default defineComponent({
107 131 components: {
... ... @@ -117,6 +141,7 @@
117 141 Row,
118 142 Col,
119 143 LoadingOutlined,
  144 + DeptDrawer,
120 145 },
121 146 props: {
122 147 isUpdate: {
... ... @@ -125,6 +150,27 @@
125 150 },
126 151 emits: ['next'],
127 152 setup(props, { emit }) {
  153 + const orgData: any = reactive({
  154 + treeData: [],
  155 + });
  156 + const getOrganizationListFunc = async () => {
  157 + const data = await getOrganizationList();
  158 + copyTransFun(data as any as any[]);
  159 + orgData.treeData = data;
  160 + };
  161 + onMounted(async () => {
  162 + await getOrganizationListFunc();
  163 + });
  164 + const { treeData } = toRefs(orgData);
  165 + const [registerModal, { openDrawer }] = useDrawer();
  166 + const handleOpenOrgDrawer = () => {
  167 + openDrawer(true, {
  168 + isUpdate: false,
  169 + });
  170 + };
  171 + const handleSuccess = async () => {
  172 + await getOrganizationListFunc();
  173 + };
128 174 const redirectPosition = () => {
129 175 if (positionState.longitude && positionState.latitude) {
130 176 var pt = new BMap.Point(positionState.longitude, positionState.latitude);
... ... @@ -152,6 +198,7 @@
152 198 async function nextStep() {
153 199 try {
154 200 let values = await validate();
  201 + console.log(values);
155 202 values = { devicePic: devicePic.value, ...positionState, ...values };
156 203 delete values.icon;
157 204 delete values.deviceAddress;
... ... @@ -400,6 +447,10 @@
400 447 loading,
401 448 rules,
402 449 redirectPosition,
  450 + treeData,
  451 + registerModal,
  452 + handleOpenOrgDrawer,
  453 + handleSuccess,
403 454 };
404 455 },
405 456 });
... ...
... ... @@ -17,7 +17,6 @@
17 17 @click="handleCreateOrEdit('add')"
18 18 class="ml-2"
19 19 style="color: #409eff; cursor: pointer"
20   - type="primary"
21 20 size="small"
22 21 >新建转换脚本</span
23 22 >
... ...