Переглянути джерело

feat:单元格绑定数据

ananzhusen 10 місяців тому
батько
коміт
52c19b9392
1 змінених файлів з 56 додано та 0 видалено
  1. 56 0
      src/views/components/PenDatas.vue

+ 56 - 0
src/views/components/PenDatas.vue

@@ -141,6 +141,18 @@
       </t-collapse-panel> -->
 
       <t-collapse-panel value="3" header="数据">
+        <div class="t-space-item" v-if="props.pen.name==='tablePlus'">
+          <div v-if="cell.col!==undefined&&cell.row!==undefined" class="flex between form-item  py-12">
+              <div style="line-height: 30px">
+                当前选中单元格  (第{{ cell.row }}行,第{{ cell.col}}列)
+              </div>
+              <div>
+                <t-tooltip content="快捷绑定" placement="top">
+                 <link-icon style="width: 13px;margin-right: 26px"class="hover ml-4" @click="onQuickBind()"/>
+                </t-tooltip>
+              </div>
+          </div>
+        </div>
         <div class="t-space-item">
           <div class="form-item  py-12">
               <label style="width: 76px">关联设备</label>
@@ -1875,7 +1887,51 @@ const addTrigger = (item:any, e:any, i:any) => {
   }
 }
 
+const cell = ref({
+  col:undefined,
+  row:undefined
+});
+
+const getPenData = (e)=>{
+  if(props.pen.name === 'tablePlus'){
+    if(props.pen.calculative.activeCell){
+      cell.value.col = props.pen.calculative.activeCell.col;
+      cell.value.row = props.pen.calculative.activeCell.row;
+    }else{
+      cell.value.col = undefined;
+      cell.value.row = undefined;
+    }
+  }
+}
+
+const onQuickBind = ()=>{
+  if(cell.value.col !== undefined && cell.value.row !== undefined){
+    if(!props.pen.realTimes){
+      props.pen.realTimes = [];
+    }
+    let found = props.pen.realTimes.findIndex((item:any)=>{
+      return item.key === `data.${cell.value.row}.${cell.value.col}`;
+    });
+    if(found === -1){
+      props.pen.realTimes.push({
+        label: `第${cell.value.row}行,第${cell.value.col}列`,
+        key: `data.${cell.value.row}.${cell.value.col}`,
+        type: 'float',
+      });
+      onBind(props.pen.realTimes[props.pen.realTimes.length-1]);
+    }else{
+      onBind(props.pen.realTimes[found]);
+    }
+  }
+}
+
+onMounted(() => {
+   meta2d.on('click',getPenData);
+   getPenData({});
+});
+
 onUnmounted(() => {
+  meta2d.off('click',getPenData);
   clearInterval(timer);
 });
 </script>