fix: 解决物模型TODO
This commit is contained in:
parent
4e0670b362
commit
c07199ca2b
|
@ -1,5 +1,6 @@
|
|||
import { OperatorItem } from '@/components/FRuleEditor/Operator/typings'
|
||||
import server from '@/utils/request'
|
||||
import { DeviceMetadata, ProductItem, DepartmentItem } from '@/views/device/Product/typings'
|
||||
import { DeviceMetadata, ProductItem, DepartmentItem, MetadataType } from '@/views/device/Product/typings'
|
||||
|
||||
/**
|
||||
* 根据条件查询产品(不带翻页)
|
||||
|
|
|
@ -17,11 +17,11 @@ import { ProductItem } from '@/views/device/Product/typings';
|
|||
import { message } from 'ant-design-vue/es';
|
||||
import type { FormInstance } from 'ant-design-vue/es';
|
||||
import { updateMetadata, asyncUpdateMetadata } from '../../metadata'
|
||||
import { Store } from 'jetlinks-store';
|
||||
import { detail } from '@/api/device/instance';
|
||||
import { DeviceInstance } from '@/views/device/Instance/typings';
|
||||
import BaseForm from './BaseForm.vue';
|
||||
import { PropType } from 'vue';
|
||||
import { _deploy } from '@/api/device/product';
|
||||
|
||||
const props = defineProps({
|
||||
type: {
|
||||
|
@ -104,10 +104,16 @@ const save = reactive({
|
|||
setTimeout(() => window.close(), 300);
|
||||
}
|
||||
} else {
|
||||
const { id } = route.params
|
||||
if (props?.type === 'device') {
|
||||
instanceStore.refresh(id as string)
|
||||
} else {
|
||||
productStore.refresh(id as string)
|
||||
}
|
||||
// Store.set(SystemConst.REFRESH_METADATA_TABLE, true);
|
||||
if (deploy) {
|
||||
// TODO 是否发布
|
||||
Store.set('product-deploy', deploy);
|
||||
_deploy(id as string)
|
||||
// Store.set('product-deploy', deploy);
|
||||
} else {
|
||||
save.resetMetadata();
|
||||
message.success({
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
<a-tabs @change="handleConvertMetadata">
|
||||
<a-tab-pane v-for="item in codecs" :key="item.id" :tab="item.name">
|
||||
<div class="cat-panel">
|
||||
<!-- TODO 代码编辑器 -->
|
||||
<MonacoEditor v-model="value" theme="vs" style="height: 100%"></MonacoEditor>
|
||||
</div>
|
||||
</a-tab-pane>
|
||||
|
|
|
@ -43,7 +43,6 @@
|
|||
</a-input>
|
||||
</a-form-item>
|
||||
<a-form-item label="物模型" v-bind="validateInfos.import" v-if="formModel.metadataType === 'script'">
|
||||
<!-- TODO代码编辑器 -->
|
||||
<MonacoEditor v-model="formModel.import" theme="vs" style="height: 300px"></MonacoEditor>
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
|
@ -57,8 +56,6 @@ import type { DefaultOptionType } from 'ant-design-vue/es/select';
|
|||
import type { UploadProps, UploadFile, UploadChangeParam } from 'ant-design-vue/es';
|
||||
import type { DeviceMetadata, ProductItem } from '@/views/device/Product/typings'
|
||||
import { message } from 'ant-design-vue/es';
|
||||
import { Store } from 'jetlinks-store';
|
||||
import { SystemConst } from '@/utils/consts';
|
||||
import { useInstanceStore } from '@/store/instance'
|
||||
import { useProductStore } from '@/store/product';
|
||||
import { FILE_UPLOAD } from '@/api/comm';
|
||||
|
@ -139,11 +136,6 @@ const rules = reactive({
|
|||
],
|
||||
})
|
||||
const { validate, validateInfos } = useForm(formModel, rules);
|
||||
const onSubmit = () => {
|
||||
validate().then(() => {
|
||||
|
||||
})
|
||||
}
|
||||
const fileList = ref<UploadFile[]>([])
|
||||
|
||||
const productList = ref<DefaultOptionType[]>([])
|
||||
|
@ -208,11 +200,11 @@ const operateLimits = (mdata: DeviceMetadata) => {
|
|||
const handleImport = async () => {
|
||||
validate().then(async (data) => {
|
||||
loading.value = true
|
||||
const { id } = route.params || {}
|
||||
if (data.metadata === 'alink') {
|
||||
const res = await convertMetadata('from', 'alink', data.import)
|
||||
if (res.status === 200) {
|
||||
const metadata = JSON.stringify(operateLimits(res.result))
|
||||
const { id } = route.params || {}
|
||||
if (props?.type === 'device') {
|
||||
await saveMetadata(id as string, metadata)
|
||||
instanceStore.setCurrent(JSON.parse(metadata || '{}'))
|
||||
|
@ -227,8 +219,13 @@ const handleImport = async () => {
|
|||
loading.value = false
|
||||
message.error('发生错误!')
|
||||
}
|
||||
Store.set(SystemConst.GET_METADATA, true)
|
||||
Store.set(SystemConst.REFRESH_METADATA_TABLE, true)
|
||||
if (props?.type === 'device') {
|
||||
instanceStore.refresh(id as string)
|
||||
} else {
|
||||
productStore.refresh(id as string)
|
||||
}
|
||||
// Store.set(SystemConst.GET_METADATA, true)
|
||||
// Store.set(SystemConst.REFRESH_METADATA_TABLE, true)
|
||||
close()
|
||||
} else {
|
||||
try {
|
||||
|
@ -255,21 +252,24 @@ const handleImport = async () => {
|
|||
loading.value = false
|
||||
if (resp.status === 200) {
|
||||
if (props?.type === 'device') {
|
||||
const metadata: DeviceMetadata = JSON.parse(paramsDevice || '{}')
|
||||
// TODO导入
|
||||
// MetadataAction.insert(metadata);
|
||||
// instanceStore.setCurrent(metadata)
|
||||
const detail = instanceStore.current
|
||||
detail.metadata = paramsDevice
|
||||
instanceStore.setCurrent(detail)
|
||||
message.success('导入成功')
|
||||
} else {
|
||||
const metadata: ProductItem = JSON.parse(params?.metadata || '{}')
|
||||
// TODO导入
|
||||
// MetadataAction.insert(metadata);
|
||||
// productStore.setCurrent(metadata)
|
||||
const detail = productStore.current
|
||||
detail.metadata = params.metadata
|
||||
productStore.setCurrent(detail)
|
||||
message.success('导入成功')
|
||||
}
|
||||
}
|
||||
Store.set(SystemConst.GET_METADATA, true)
|
||||
Store.set(SystemConst.REFRESH_METADATA_TABLE, true)
|
||||
// Store.set(SystemConst.GET_METADATA, true)
|
||||
// Store.set(SystemConst.REFRESH_METADATA_TABLE, true)
|
||||
if (props?.type === 'device') {
|
||||
instanceStore.refresh(id as string)
|
||||
} else {
|
||||
productStore.refresh(id as string)
|
||||
}
|
||||
close();
|
||||
} catch (e) {
|
||||
loading.value = false
|
||||
|
|
|
@ -23,8 +23,8 @@
|
|||
:tooltip="{ title: '重置后将使用产品的物模型配置' }" key="reload">
|
||||
重置操作
|
||||
</PermissionButton>
|
||||
<PermissionButton :uhasPermission="`${permission}:update`" @click="visible = true">快速导入</PermissionButton>
|
||||
<PermissionButton :uhasPermission="`${permission}:update`" @click="cat = true">物模型TSL</PermissionButton>
|
||||
<PermissionButton :hasPermission="`${permission}:update`" @click="visible = true">快速导入</PermissionButton>
|
||||
<PermissionButton :hasPermission="`${permission}:update`" @click="cat = true">物模型TSL</PermissionButton>
|
||||
</a-space>
|
||||
</template>
|
||||
|
||||
|
@ -50,7 +50,6 @@
|
|||
import PermissionButton from '@/components/PermissionButton/index.vue'
|
||||
import { deleteMetadata } from '@/api/device/instance.js'
|
||||
import { message } from 'ant-design-vue'
|
||||
import { Store } from 'jetlinks-store'
|
||||
import { SystemConst } from '@/utils/consts'
|
||||
import { useInstanceStore } from '@/store/instance'
|
||||
import Import from './Import/index.vue'
|
||||
|
@ -75,11 +74,11 @@ const resetMetadata = async () => {
|
|||
const resp = await deleteMetadata(id as string)
|
||||
if (resp.status === 200) {
|
||||
message.info('操作成功')
|
||||
|
||||
Store.set(SystemConst.REFRESH_DEVICE, true)
|
||||
setTimeout(() => {
|
||||
Store.set(SystemConst.REFRESH_METADATA_TABLE, true)
|
||||
}, 400)
|
||||
instanceStore.refresh(id as string)
|
||||
// Store.set(SystemConst.REFRESH_DEVICE, true)
|
||||
// setTimeout(() => {
|
||||
// Store.set(SystemConst.REFRESH_METADATA_TABLE, true)
|
||||
// }, 400)
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
|
Loading…
Reference in New Issue