ananzhusen 1 жил өмнө
parent
commit
5935e5c95d

+ 15 - 1
src/views/components/PenDatas.vue

@@ -125,6 +125,7 @@
       <t-input
         v-model="addDataDialog.data.key"
         placeholder="关键字"
+        @blur="onKeyBlur"
         :disabled="!!addDataDialog.data.keywords"
       />
     </div>
@@ -136,7 +137,7 @@
         v-model="addDataDialog.data.type"
         placeholder="字符串"
         :disabled="!!addDataDialog.data.keywords"
-        @change="addDataDialog.data.value = null"
+        @change="onKeyBlur"
       />
     </div>
     <div class="form-item mt-16">
@@ -622,6 +623,17 @@ const addRealTime = (e: any) => {
   addDataDialog.show = true;
 };
 
+const onKeyBlur = () => {
+  if (addDataDialog.data) {
+    let value = getter(props.pen, addDataDialog.data.key);
+    if (value) {
+      setter(addDataDialog.data, 'value', value);
+    } else {
+      addDataDialog.data.value = null;
+    }
+  }
+};
+
 const onChangeLabel = () => {
   if (!addDataDialog.data.key) {
     addDataDialog.data.key = addDataDialog.data.label;
@@ -649,6 +661,7 @@ const onConfirmData = () => {
   }
 
   meta2d.penMock(props.pen);
+  meta2d.render();
 
   addDataDialog.show = false;
 };
@@ -657,6 +670,7 @@ const onMenuMore = (e: any, item: any, i: number) => {
   switch (e.value) {
     case 'edit':
       addDataDialog.header = '编辑动态数据';
+      setter(item, 'value', getter(props.pen, item.key));
       addDataDialog.data = item;
       addDataDialog.show = true;
       break;