ananzhusen преди 3 месеца
родител
ревизия
4c37570bae
променени са 1 файла, в които са добавени 88 реда и са изтрити 11 реда
  1. 88 11
      src/views/components/PenDatas.vue

+ 88 - 11
src/views/components/PenDatas.vue

@@ -1,5 +1,17 @@
 <template>
   <div class="props">
+    <t-space direction="vertical" class="py-16 w-full">
+
+    <div class="form-item px-16">
+      <label style="width: 50px">ID</label>
+      <t-input
+        class="w-full"
+        placeholder="ID"
+        :value="props.pen.id"
+        @change="changeID($event)"
+      />
+    </div>
+    </t-space>
     <t-collapse
       :defaultValue="['1', '2', '3','4', '7']"
       expandIconPlacement="right"
@@ -229,12 +241,12 @@
         </div>
       </t-collapse-panel>
       <t-collapse-panel value="3" header="数据">
-        <div class="t-space-item">
+        <!-- <div class="t-space-item">
           <div class="form-item  py-12">
               <label style="width: 76px">{{$t('关联设备')}}</label>
               <t-input class="w-full" v-model="props.pen.deviceId" @change="changeValue('deviceId')" :placeholder="$t('设备ID')"></t-input>
           </div>
-        </div>
+        </div> -->
         <template  v-if="props.pen.name==='tablePlus'">
         <div class="t-space-item">
           <div v-if="cell.row!==undefined" class="flex between form-item  py-12">
@@ -259,7 +271,7 @@
           <div class="grid head">
             <div class="title">{{$t('数据名')}}</div>
             <div class="title">{{$t('值')}}</div>
-            <div class="title" style="text-align: center;">{{$t('绑定')}}</div>
+            <!-- <div class="title" style="text-align: center;">{{$t('绑定')}}</div> -->
             <div class="title" style="text-align: center;">{{$t('操作')}}</div>
 
             <!-- <div class="actions">
@@ -304,13 +316,19 @@
 
              
             </div>
-            <div style="text-align: center;">
+            <div class="flex"> 
+            <div class="mr-8" style="text-align: center;">
               <t-tooltip :content="getBindsDesc(item)" placement="top">
                 <link-icon class="hover ml-4"
                   :class="{ primary: item.enableMock || item.bind?.id }"
                   @click="onBind(item)"/>
               </t-tooltip>
             </div>
+            <div class="mr-8" @click="gotoTrigger(item.trigger)" style="text-align: center;">
+              <t-tooltip :content="item.trigger!==undefined?'配置了状态':''" placement="top">
+                <ErrorCircleIcon class="hover"  :class="{ primary: item.trigger!==undefined }" />
+              </t-tooltip>
+            </div>
             <div style="text-align: center;">
               <!-- <t-tooltip :content="item.triggers?.length || '状态'">
                 <t-badge
@@ -327,7 +345,8 @@
                   @click="addTrigger(item, $event, i)"
                   :minColumnWidth="120"
                 >
-                  <ViewListIcon class="hover"/>
+                  <!-- <ViewListIcon class="hover"/> -->
+                  <MoreIcon class="hover"/>
                   <template #dropdown>
                     <t-dropdown-menu >
                       <t-dropdown-item v-for="(option) in triggerOptions" :value="option.value">
@@ -339,6 +358,7 @@
                   </template>
                 </t-dropdown>
             </div>
+          </div>
             <!-- <div class="actions">
               <t-dropdown
                 :options="moreOptions"
@@ -932,7 +952,7 @@ import Actions from './Actions.vue';
 import { useSelection } from '@/services/selections';
 import { defaultGradientColor, defaultPureColor } from '@/services/defaults';
 import { getLe5le3d, getLe5leV, getLe5le2d } from '@/services/api';
-import { EllipsisIcon, MoreIcon, LinkIcon, RelativityIcon, AddRectangleIcon, SearchIcon ,DeleteIcon, ArrowRightIcon, CloseIcon, ChevronLeftDoubleIcon, AddIcon, ViewListIcon, CheckIcon, HelpCircleIcon } from 'tdesign-icons-vue-next';
+import { EllipsisIcon, MoreIcon, LinkIcon, RelativityIcon, AddRectangleIcon, SearchIcon ,DeleteIcon, ArrowRightIcon, CloseIcon, ChevronLeftDoubleIcon, AddIcon, ViewListIcon, CheckIcon, HelpCircleIcon, ErrorCircleIcon } from 'tdesign-icons-vue-next';
 import { s8 } from '@/services/random';
 import { importExcel } from '@/services/excel';
 import { importCSV } from '@/services/file';
@@ -991,6 +1011,11 @@ const options = ref<any>([
     content: $t('文字'),
     // keywords: true,
   },
+  {
+    value: 'deviceId',
+    content: '关联设备',
+    keywords: true,
+  },
   {
     value: 'progress',
     content: $t('进度'),
@@ -1185,6 +1210,23 @@ const penTree: any = ref([]);
 
 let timer: any;
 
+const changeID = (value: any) => {
+  if (!value) {
+    // initPenData();
+    MessagePlugin.error('id 不能为空');
+    return;
+  }
+  const oldID: string = props.pen.id;
+  try {
+    meta2d.changePenId(oldID, value);
+    // initPenData();
+  } catch (error) {
+    console.warn(error.message);
+    MessagePlugin.error('id 修改失败,请检查 id 是否重复');
+    return;
+  }
+};
+
 onBeforeMount(() => {
   // realTimesOptions - 扩展的动态数据下拉列表
   if (props.pen.realTimesOptions) {
@@ -1791,6 +1833,7 @@ watch(
     if(props.pen.children?.length){
       childrenPens.value = getAllChildren(meta2d.store.pens[props.pen.id],meta2d.store);
     }
+    getRealTimesTrigger();
   }
 );
 
@@ -1799,8 +1842,35 @@ onMounted(() => {
   if(props.pen.children?.length){
     childrenPens.value = getAllChildren(meta2d.store.pens[props.pen.id],meta2d.store);
   }
+  getRealTimesTrigger();
 });
 
+const getRealTimesTrigger = ()=>{
+  if(!props.pen.triggers?.length){
+    return;
+  }
+  props.pen.realTimes?.forEach((real)=>{
+    let shouldBreak = false;
+    props.pen.triggers.forEach((item,index)=>{
+      if (shouldBreak) return;
+      item.status.forEach((_item)=>{
+        const trigger = _item.conditions.filter((i)=>i.key===real.key);
+        if(trigger?.length){
+          real.trigger = index;
+          shouldBreak = true;
+        }
+      })
+    });
+  })
+}
+
+const gotoTrigger = (i:any)=>{
+  if(i===undefined){
+    return;
+  }
+  emit('tabchange',i);
+}
+
 const changeCValue = (prop: string, pen:Pen)=>{
   updatePen(pen, prop);
   selections.pen[prop] = getter(pen, prop);
@@ -1964,7 +2034,7 @@ const addTrigger = (item:any, e:any, i:any) => {
       break;
     case 'switch':
       props.pen.triggers.push({
-        "name": e.content,
+        "name": "状态切换",
         "status": [
             {
               "name": $t("满足条件,切换到状态1"),
@@ -2009,7 +2079,7 @@ const addTrigger = (item:any, e:any, i:any) => {
       break;
     case 'warning':
       props.pen.triggers.push({
-        "name": e.content,
+        "name": "条件告警",
         "status": [
             {
                 "name": $t("满足条件,触发告警"),
@@ -2055,7 +2125,7 @@ const addTrigger = (item:any, e:any, i:any) => {
       break;
     case 'warningAnimate':
       props.pen.triggers.push({
-        "name": e.content,
+        "name": "条件动画",
         "status": [
             {
                 "name": $t("满足条件,触发动画执行"),
@@ -2362,6 +2432,10 @@ const watcher = watch(
   }
 );
 
+const moreDataDialog = reactive({
+  show:false
+})
+
 onMounted(() => {
    meta2d.on('click',getPenData);
    leaderPen.value = meta2d.store.pens[props.pen.formId];
@@ -2381,7 +2455,7 @@ onUnmounted(() => {
   height: 100%;
 
   .grid {
-    grid-template-columns: 70px 70px 50px 65px;
+    grid-template-columns: 80px 110px 75px;
     padding: 0 12px;
 
     &.head {
@@ -2421,6 +2495,9 @@ onUnmounted(() => {
       font-size: 10px;
       line-height: 28px;
       color: var(--color-desc);
+      overflow: hidden;
+      white-space: nowrap;
+      text-overflow: ellipsis;
     }
   }
 
@@ -2436,7 +2513,7 @@ onUnmounted(() => {
     }
 
     & > div {
-      width: 72px;
+      /* width: 72px; */
       &.t-switch {
         width: fit-content;
         margin-left: 4px;