28723
4 months ago
18 changed files with 498 additions and 189 deletions
After Width: | Height: | Size: 1.9 KiB |
@ -1,10 +1,11 @@ |
|||
const BASE_URL = '/carbon-smart'; |
|||
import { BASE_URL } from './index'; |
|||
export enum device { |
|||
queryDeviceTree = `${BASE_URL}/deviceInfo/queryDeviceTree`, |
|||
queryDevicePage = `${BASE_URL}/deviceInfo/queryDevicePage`, |
|||
dropArea = `${BASE_URL}/deviceInfo/dropArea`, |
|||
queryDeviceTree = `${BASE_URL}/deviceInfo/queryDeviceTree`, // 左侧树
|
|||
queryDevicePage = `${BASE_URL}/deviceInfo/queryDevicePage`, // 列表
|
|||
dropArea = `${BASE_URL}/deviceInfo/dropArea`, // 查询下拉区域
|
|||
} |
|||
|
|||
export enum group { |
|||
queryDeviceGroupTree = `${BASE_URL}/deviceGroup/queryDeviceGroupTree`, |
|||
queryDeviceGroupTree = `${BASE_URL}/deviceGroup/queryDeviceGroupTree`, // 左侧树
|
|||
creatOrUpdate = `${BASE_URL}/deviceGroup/creatOrUpdate`, // 左侧树节点新增编辑
|
|||
} |
|||
|
@ -0,0 +1,88 @@ |
|||
<template> |
|||
<ns-modal |
|||
ref="modalRef" |
|||
v-bind="extraModalConfig" |
|||
destroyOnClose |
|||
v-model:visible="visible" |
|||
:title="title" |
|||
:okButtonProps="buttonProps" |
|||
@ok="handleOk"> |
|||
<ns-form ref="formRef" :schemas="schemas" :model="formData" formLayout="formVertical" /> |
|||
</ns-modal> |
|||
</template> |
|||
|
|||
<script lang="ts" setup> |
|||
import { computed, ref, toRefs, watch } from 'vue'; |
|||
import { HttpRequestConfig, NsMessage, useApi } from '/nerv-lib/saas'; |
|||
import { useRoute } from 'vue-router'; |
|||
type Props = { |
|||
title?: string; |
|||
schemas: Array<any>; |
|||
api: string | object | Function; |
|||
data?: object; |
|||
extraModalConfig?: object; |
|||
}; |
|||
const route = useRoute(); |
|||
const { httpRequest } = useApi(); |
|||
|
|||
const props = withDefaults(defineProps<Props>(), { |
|||
title: '新增', |
|||
}); |
|||
const { schemas } = toRefs(props); |
|||
const formData = ref(); |
|||
watch( |
|||
() => props?.data, |
|||
(val) => { |
|||
formData.value = val; |
|||
}, |
|||
{ |
|||
immediate: true, |
|||
deep: true, |
|||
}, |
|||
); |
|||
const modalRef = ref(); |
|||
const formRef = ref(); |
|||
const visible = ref(false); |
|||
const validateResult = computed(() => { |
|||
return !formRef.value?.validateResult; |
|||
}); |
|||
const toggle = () => { |
|||
visible.value = !visible.value; |
|||
}; |
|||
|
|||
const setLoading = (loading = true) => { |
|||
buttonProps.value.loading = loading; |
|||
}; |
|||
|
|||
const handleOk = () => { |
|||
setLoading(true); |
|||
formRef.value |
|||
.triggerSubmit() |
|||
.then((data: any) => { |
|||
const { api } = props; |
|||
const requestConfig: HttpRequestConfig = { method: 'POST' }; |
|||
const { params } = route; |
|||
|
|||
httpRequest({ api, params: data, pathParams: params, requestConfig }) |
|||
.then(() => { |
|||
NsMessage.success('操作成功', 1, () => { |
|||
toggle(); |
|||
}); |
|||
}) |
|||
.finally(() => { |
|||
setLoading(false); |
|||
}); |
|||
}) |
|||
.catch(() => {}); |
|||
}; |
|||
|
|||
const buttonProps = ref({ |
|||
disabled: validateResult, |
|||
loading: false, |
|||
}); |
|||
|
|||
defineExpose({ |
|||
toggle, |
|||
}); |
|||
</script> |
|||
<style lang="less"></style> |
Loading…
Reference in new issue