ananzhusen 3 сар өмнө
parent
commit
9f09f52855

+ 5 - 6
src/views/components/DataSource.vue

@@ -858,7 +858,7 @@
         placeholder="属性名"
       />
     </div>
-    <!-- <div class="form-item mt-16">
+    <div class="form-item mt-16">
       <label>类型</label>
       <t-select
         class="w-full"
@@ -868,6 +868,7 @@
         @change="addDataDialog.data.value = null"
       />
     </div>
+     <!-- 
     <div class="form-item mt-16">
       <label
         >值范围
@@ -1056,8 +1057,8 @@
         :filter="iotFilter"
         :scroll="{
           // rowHeight: 34,
-          bufferSize: 10,
-          threshold: 10,
+          bufferSize: 50,
+          threshold: 30,
           type: 'virtual',
         }"
       />
@@ -1292,6 +1293,7 @@ const getIotTree = async () => {
         _label: item.name + '#' + prop.name,
         token: item.token,
         class: 'iot',
+        type: prop.type
       };
     });
     if (!item.children.length) {
@@ -2184,10 +2186,8 @@ const onCheckAllChange = (e) => {
     allChecked.value = [];
     networksCheked.value = [];
     sqlsCheked.value = [];
-    console.log("进入",allChecked.value,networksCheked.value, sqlsCheked.value)
   }
   data.checkAll =!data.checkAll;
-  console.log("data.checkAll",data.checkAll);
   
   // if (!e) {
   //   data.dataset?.devices?.forEach((item) => {
@@ -2202,7 +2202,6 @@ const sqlsCheked = ref([]);
 const onAddShape = (e, _data,type) => {
   e.stopPropagation();
   let data: any;
-  console.log("_data",_data);
 
   if (Array.isArray(_data)) {
     const dragElem = document.getElementById(`dragElem-${type}`);

+ 75 - 5
src/views/components/common/PropModal.vue

@@ -6,7 +6,9 @@
     @close="close"
     @confirm="confirm"
   >
-    <div class="input-search">
+  <t-tabs v-model="tabValue" @change="tabChange">
+    <t-tab-panel :value="1" label="数据列表">
+    <div class="input-search mt-8">
       <div class="btn">
         <search-icon class="hover" />
       </div>
@@ -28,12 +30,41 @@
         @click="onClick"
       />
     </div>
+    </t-tab-panel>
+    <t-tab-panel :value="2" label="自定义数据">
+      <div class="form-item mt-16">
+        <label>显示名称</label>
+        <t-input
+            v-model:value="activeObj.label"
+            placeholder="属性简短描述"
+          />
+      </div>
+      <div class="form-item mt-16">
+      <label>属性名</label>
+      <t-input
+        v-model:value="activeObj.value"
+        placeholder="属性名"
+      />
+    </div>
+    <div class="form-item mt-16">
+      <label>类型</label>
+      <t-select
+        class="w-full"
+        :options="typeOptions"
+        v-model="activeObj.type"
+        placeholder="字符串"
+      />
+    </div>
+    </t-tab-panel>
+  </t-tabs>
   </t-dialog>
 </template>
 
 <script lang="ts" setup>
 import { SearchIcon } from 'tdesign-icons-vue-next';
 import { ref, toRaw, onMounted } from 'vue';
+import { typeOptions } from '@/services/common';
+import { MessagePlugin } from 'tdesign-vue-next';
 
 const props = defineProps<{
   visible: boolean;
@@ -139,16 +170,50 @@ const onSearch = () => {
 
 const selectedIds = ref([]);
 
+let activeObj:any = ref({
+  label:'',
+  type:'',
+  value:''
+});
+
 const onClick = (context) => {
   const { node } = context;
-  // activeObj = JSON.parse(JSON.stringify(node.data));
+  if(!node.isLeaf()){
+    return;
+  }
+  const data = JSON.parse(JSON.stringify(node.data));
+  const root = node?.getRoot()?.data;
+  if(data._label){
+    data._label = root.label+'#'+data._label;
+  }else{
+    data._label =node?.getParents()?.map((item)=>item.data.label+'#')?.reverse()?.join('') +data.label;
+  }
+  activeObj.value = data;
 };
 
+const tabValue = ref(1);
+
 const confirm = () => {
-  emit('change', activedProp.value[0]);
-  // activeObj.value = {};
+  if(!activeObj.value.value){
+    if(tabValue.value===1){
+      MessagePlugin.info("请选择一项设备属性!");
+    }else{
+      MessagePlugin.info("属性名必填!");
+    }
+    return;
+  }
+  emit('change', activeObj.value);
 };
 
+const tabChange = ()=>{
+
+  activeObj.value={
+    label:'',
+    type:'',
+    value:''
+  };
+}
+
 const doBind = () => {};
 </script>
 
@@ -156,15 +221,20 @@ const doBind = () => {};
 .props {
   height: 300px;
   overflow-y: auto;
+  padding-bottom: 16px;
 }
 
 .input-search {
   width: 100%;
-  margin-top: 0px;
   padding: 4px 0px;
 
   .btn {
     left: 14px;
   }
 }
+
+.t-tab-panel{
+  height: 340px;
+  overflow-y: hidden;
+}
 </style>