Commit 051f031e4e263c568a3c9ec9459f3a21058039f6

Authored by fengtao
1 parent f5cb7ffc

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

1 import { FormSchema } from '/@/components/Form'; 1 import { FormSchema } from '/@/components/Form';
2 import { findDictItemByCode } from '/@/api/system/dict'; 2 import { findDictItemByCode } from '/@/api/system/dict';
3 import { deviceProfile, getGATEWAYdevice } from '/@/api/device/deviceManager'; 3 import { deviceProfile, getGATEWAYdevice } from '/@/api/device/deviceManager';
4 -import { getOrganizationList } from '/@/api/system/system';  
5 -import { copyTransFun } from '/@/utils/fnUtils';  
6 4
7 export enum TypeEnum { 5 export enum TypeEnum {
8 IS_GATEWAY = 'GATEWAY', 6 IS_GATEWAY = 'GATEWAY',
@@ -82,25 +80,10 @@ export const step1Schemas: FormSchema[] = [ @@ -82,25 +80,10 @@ export const step1Schemas: FormSchema[] = [
82 }, 80 },
83 { 81 {
84 field: 'organizationId', 82 field: 'organizationId',
85 - required: true,  
86 label: '所属组织', 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 field: 'gatewayId', 89 field: 'gatewayId',
@@ -2,6 +2,25 @@ @@ -2,6 +2,25 @@
2 <div class="step1"> 2 <div class="step1">
3 <div class="step1-form"> 3 <div class="step1-form">
4 <BasicForm @register="register"> 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 <template #iconSelect> 24 <template #iconSelect>
6 <Upload 25 <Upload
7 name="avatar" 26 name="avatar"
@@ -86,10 +105,11 @@ @@ -86,10 +105,11 @@
86 <div ref="wrapRef" style="height: 300px; width: 90%" class="ml-6"></div> 105 <div ref="wrapRef" style="height: 300px; width: 90%" class="ml-6"></div>
87 </div> 106 </div>
88 </Modal> 107 </Modal>
  108 + <DeptDrawer @register="registerModal" @success="handleSuccess" />
89 </div> 109 </div>
90 </template> 110 </template>
91 <script lang="ts"> 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 import { BasicForm, useForm } from '/@/components/Form'; 113 import { BasicForm, useForm } from '/@/components/Form';
94 import { step1Schemas } from '../../config/data'; 114 import { step1Schemas } from '../../config/data';
95 import { useScript } from '/@/hooks/web/useScript'; 115 import { useScript } from '/@/hooks/web/useScript';
@@ -102,6 +122,10 @@ @@ -102,6 +122,10 @@
102 import icon from '/@/assets/images/wz.png'; 122 import icon from '/@/assets/images/wz.png';
103 import { useDebounceFn } from '@vueuse/core'; 123 import { useDebounceFn } from '@vueuse/core';
104 import { validatorLongitude, validatorLatitude } from '/@/utils/rules'; 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 export default defineComponent({ 130 export default defineComponent({
107 components: { 131 components: {
@@ -117,6 +141,7 @@ @@ -117,6 +141,7 @@
117 Row, 141 Row,
118 Col, 142 Col,
119 LoadingOutlined, 143 LoadingOutlined,
  144 + DeptDrawer,
120 }, 145 },
121 props: { 146 props: {
122 isUpdate: { 147 isUpdate: {
@@ -125,6 +150,27 @@ @@ -125,6 +150,27 @@
125 }, 150 },
126 emits: ['next'], 151 emits: ['next'],
127 setup(props, { emit }) { 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 const redirectPosition = () => { 174 const redirectPosition = () => {
129 if (positionState.longitude && positionState.latitude) { 175 if (positionState.longitude && positionState.latitude) {
130 var pt = new BMap.Point(positionState.longitude, positionState.latitude); 176 var pt = new BMap.Point(positionState.longitude, positionState.latitude);
@@ -152,6 +198,7 @@ @@ -152,6 +198,7 @@
152 async function nextStep() { 198 async function nextStep() {
153 try { 199 try {
154 let values = await validate(); 200 let values = await validate();
  201 + console.log(values);
155 values = { devicePic: devicePic.value, ...positionState, ...values }; 202 values = { devicePic: devicePic.value, ...positionState, ...values };
156 delete values.icon; 203 delete values.icon;
157 delete values.deviceAddress; 204 delete values.deviceAddress;
@@ -400,6 +447,10 @@ @@ -400,6 +447,10 @@
400 loading, 447 loading,
401 rules, 448 rules,
402 redirectPosition, 449 redirectPosition,
  450 + treeData,
  451 + registerModal,
  452 + handleOpenOrgDrawer,
  453 + handleSuccess,
403 }; 454 };
404 }, 455 },
405 }); 456 });
@@ -17,7 +17,6 @@ @@ -17,7 +17,6 @@
17 @click="handleCreateOrEdit('add')" 17 @click="handleCreateOrEdit('add')"
18 class="ml-2" 18 class="ml-2"
19 style="color: #409eff; cursor: pointer" 19 style="color: #409eff; cursor: pointer"
20 - type="primary"  
21 size="small" 20 size="small"
22 >新建转换脚本</span 21 >新建转换脚本</span
23 > 22 >