Pārlūkot izejas kodu

编辑任务时选择框默认当前值

一只小菜杨 1 mēnesi atpakaļ
vecāks
revīzija
111dcc70e8
1 mainītis faili ar 13 papildinājumiem un 7 dzēšanām
  1. 13 7
      src/views/CommandInfo.vue

+ 13 - 7
src/views/CommandInfo.vue

@@ -39,7 +39,8 @@
                             cItem.label.includes('DI') || cItem.label.includes('AI') ? 'inputLabel' : 'outputLabel',
                             index,
                             cIndex,
-                            'label'
+                            'label',
+                            cItem.label
                           )
                         "
                       />
@@ -50,7 +51,7 @@
                           readonly
                           placeholder="请选择"
                           style="width: 70%"
-                          @click="showSelect('commandValue', index, cIndex, 'value')"
+                          @click="showSelect('commandValue', index, cIndex, 'value', cItem.value)"
                         />
                       </template>
                       <template v-if="cItem.label.includes('AI') || cItem.label.includes('AO')">
@@ -61,7 +62,7 @@
                           readonly
                           placeholder="请选择"
                           style="width: 35%"
-                          @click="showSelect('operation', index, cIndex, 'operation')"
+                          @click="showSelect('operation', index, cIndex, 'operation', cItem.operation!)"
                         />
                         <div class="operation" v-if="item.type === 'exec'">=</div>
                         <van-field
@@ -80,7 +81,7 @@
                         readonly
                         placeholder="请选择"
                         style="width: 60%"
-                        @click="showSelect('timeLabel', index, cIndex, 'label')"
+                        @click="showSelect('timeLabel', index, cIndex, 'label', cItem.label)"
                       />
                       <van-field
                         v-model="cItem.value"
@@ -88,7 +89,7 @@
                         readonly
                         placeholder="请选择"
                         style="width: 40%"
-                        @click="showSelect('timeValue', index, cIndex, 'value')"
+                        @click="showSelect('timeValue', index, cIndex, 'value', cItem.value)"
                       />
                     </template>
                   </div>
@@ -307,18 +308,23 @@ const changeInfo: ChangeInfo = {
   index: 0,
   key: 'label' as keyof ConditionType
 }
-const showSelect = (colType: string, stepIndex: number, index: number, key: keyof ConditionType) => {
+const showSelect = (colType: string, stepIndex: number, index: number, key: keyof ConditionType, value: string) => {
   pickerType.value = colType
   changeInfo.stepIndex = stepIndex
   changeInfo.index = index
   changeInfo.key = key
   showOptionsPicker.value = true
+  if (pickerType.value !== 'timeValue') {
+    pickerValue.value = [value]
+  } else {
+    currentTime.value = value.split(':')
+  }
 }
 
 const showCalendar = ref(false)
 const calendarType = ref<'single' | 'range'>('single')
 const onConfirm = () => {
-  console.log(pickerValue.value, pickerType.value)
+  console.log(pickerValue.value, currentTime.value, pickerType.value)
   if (crtCommand.value) {
     if (pickerType.value !== 'timeValue') {
       if (pickerValue.value.length && pickerValue.value[0] === '自定义') {