Răsfoiți Sursa

fix: some bugs

1. new tasks are enabled by default
2. unable to refresh the current page when obtaining abnormal list data
3. power status refresh in device info page
4. some prompts have been adjusted
Casper Dai 2 ani în urmă
părinte
comite
4f2af9a5f6

+ 39 - 40
src/components/dialog/TaskDialog/index.vue

@@ -5,47 +5,46 @@
     v-bind="$attrs"
     v-bind="$attrs"
     @confirm="onSave"
     @confirm="onSave"
   >
   >
-    <div
-      v-if="task"
-      class="c-grid-form auto u-align-self--center"
-    >
-      <div class="c-grid-form__label">重复方式</div>
-      <div>
-        <el-select v-model="task.freq">
-          <el-option
-            v-for="option in freqOptions"
-            :key="option.value"
-            :label="option.label"
-            :value="option.value"
-          />
-        </el-select>
-      </div>
-      <template v-if="isWeekly">
-        <div class="c-grid-form__label c-grid-form__auto u-required">每周</div>
-        <el-checkbox-group
-          v-model="task.dayOfWeek"
-          class="c-grid-form__auto l-flex--row"
-          size="mini"
-          fill="#1c5cb0"
-        >
-          <el-checkbox-button
-            v-for="week in weeks"
-            :key="week.value"
-            :label="week.value"
+    <template #default>
+      <div class="c-grid-form auto u-align-self--center">
+        <div class="c-grid-form__label">重复方式</div>
+        <div>
+          <el-select v-model="task.freq">
+            <el-option
+              v-for="option in freqOptions"
+              :key="option.value"
+              :label="option.label"
+              :value="option.value"
+            />
+          </el-select>
+        </div>
+        <template v-if="isWeekly">
+          <div class="c-grid-form__label c-grid-form__auto u-required">每周</div>
+          <el-checkbox-group
+            v-model="task.dayOfWeek"
+            class="c-grid-form__auto l-flex--row"
+            size="mini"
+            fill="#1c5cb0"
           >
           >
-            {{ week.label }}
-          </el-checkbox-button>
-        </el-checkbox-group>
-      </template>
-      <div class="c-grid-form__label u-required">执行时间</div>
-      <el-time-picker
-        v-model="task.executeTime"
-        placeholder="请选择执行时间"
-        value-format="HH:mm:ss"
-        :clearable="false"
-      />
-      <slot :freq="task.freq" />
-    </div>
+            <el-checkbox-button
+              v-for="week in weeks"
+              :key="week.value"
+              :label="week.value"
+            >
+              {{ week.label }}
+            </el-checkbox-button>
+          </el-checkbox-group>
+        </template>
+        <div class="c-grid-form__label u-required">执行时间</div>
+        <el-time-picker
+          v-model="task.executeTime"
+          placeholder="请选择执行时间"
+          value-format="HH:mm:ss"
+          :clearable="false"
+        />
+        <slot :freq="task.freq" />
+      </div>
+    </template>
   </confirm-dialog>
   </confirm-dialog>
 </template>
 </template>
 
 

+ 8 - 4
src/components/table/Table/index.vue

@@ -105,11 +105,15 @@
         :key="index"
         :key="index"
         :schema="col"
         :schema="col"
       />
       />
-      <status-wrapper
+      <slot
         slot="empty"
         slot="empty"
-        :error="options.error"
-        @click="onPagination"
-      />
+        name="empty"
+      >
+        <status-wrapper
+          :error="options.error"
+          @click="onPagination"
+        />
+      </slot>
     </el-table>
     </el-table>
     <slot
     <slot
       v-if="isNeedPagination"
       v-if="isNeedPagination"

+ 7 - 6
src/components/table/mixins/table.js

@@ -171,10 +171,10 @@ export default {
       const options = this.options
       const options = this.options
       if (!options.loading) {
       if (!options.loading) {
         options.loading = true
         options.loading = true
+        options.error = false
         this.onFetchList(options).then(
         this.onFetchList(options).then(
           ({ data, totalCount }) => {
           ({ data, totalCount }) => {
             options.loading = false
             options.loading = false
-            options.error = false
             options.totalCount = totalCount || data.length
             options.totalCount = totalCount || data.length
             if (this.isNeedPagination && this.isManualPagination) {
             if (this.isNeedPagination && this.isManualPagination) {
               const { pageNum, pageSize } = options.params
               const { pageNum, pageSize } = options.params
@@ -189,11 +189,12 @@ export default {
             const { transform } = this.schema
             const { transform } = this.schema
             options.list = transform ? data.map(transform) : data
             options.list = transform ? data.map(transform) : data
           },
           },
-          () => {
-            options.loading = false
-            options.error = true
-            options.totalCount = 0
-            options.list = []
+          e => {
+            if (!e?.isCancel) {
+              options.loading = false
+              options.error = true
+              options.list = []
+            }
           }
           }
         ).finally(() => {
         ).finally(() => {
           !options.death && this.$emit('changed', options.list)
           !options.death && this.$emit('changed', options.list)

+ 1 - 1
src/views/dashboard/components/Device.vue

@@ -191,7 +191,7 @@ export default {
     warningTip () {
     warningTip () {
       return this.isOnline
       return this.isOnline
         ? this.powerStatus === Status.WARNING
         ? this.powerStatus === Status.WARNING
-          ? `电源状态异常,最后上报时间<br/><br/>${this.timestamp}`
+          ? `电源状态异常,${this.switchStatus === Power.LOADING ? '检测' : '最后上报'}}时间<br/><br/>${this.timestamp}`
           : '屏幕未开启'
           : '屏幕未开启'
         : this.device.lastOnline
         : this.device.lastOnline
           ? `${this.device.lastOnline} 离线`
           ? `${this.device.lastOnline} 离线`

+ 10 - 41
src/views/device/detail/components/DeviceInfo/components/Power.vue

@@ -5,7 +5,13 @@
       ref="powerTable"
       ref="powerTable"
       class="c-sibling-item--v near"
       class="c-sibling-item--v near"
       :schema="powerSchema"
       :schema="powerSchema"
-    />
+    >
+      <template #empty>
+        <div class="u-font-size--md u-color--warning has-padding">
+          {{ emptyWarningTip }}
+        </div>
+      </template>
+    </schema-table>
     <template v-if="hasMulti">
     <template v-if="hasMulti">
       <div class="l-flex--row c-sibling-item--v u-color--black u-font-size--sm u-bold">
       <div class="l-flex--row c-sibling-item--v u-color--black u-font-size--sm u-bold">
         <div class="c-sibling-item">定时任务</div>
         <div class="c-sibling-item">定时任务</div>
@@ -64,6 +70,7 @@ export default {
   data () {
   data () {
     return {
     return {
       actionInfo: ['开启', '关闭'],
       actionInfo: ['开启', '关闭'],
+      emptyWarningTip: '',
       hasMulti: false,
       hasMulti: false,
       hasRelay: false,
       hasRelay: false,
       powerSchema: {
       powerSchema: {
@@ -135,7 +142,7 @@ export default {
       })
       })
     },
     },
     onPowerMessage (value, key) {
     onPowerMessage (value, key) {
-      if (this.hasMulti || key && key !== ThirdPartyDevice.MULTI_FUNCTION_CARD) {
+      if (key && key !== ThirdPartyDevice.MULTI_FUNCTION_CARD) {
         return
         return
       }
       }
       const multiCard = value[ThirdPartyDevice.MULTI_FUNCTION_CARD]
       const multiCard = value[ThirdPartyDevice.MULTI_FUNCTION_CARD]
@@ -159,6 +166,7 @@ export default {
           }
           }
         })
         })
         this.$typeMap = map
         this.$typeMap = map
+        this.emptyWarningTip = `直至 ${timestamp} 未收到上报数据`
         this.hasMulti = multiCard.status === Status.OK
         this.hasMulti = multiCard.status === Status.OK
         this.$refs.powerTable?.pageTo()
         this.$refs.powerTable?.pageTo()
       }
       }
@@ -244,9 +252,6 @@ export default {
       }
       }
       let tableData = []
       let tableData = []
       switch (message.function) {
       switch (message.function) {
-        case GET_POWER_STATUS:
-          tableData = this.setPowerStatus(data)
-          break
         case GET_MULTI_POWER_TIMING:
         case GET_MULTI_POWER_TIMING:
           tableData = this.setMultiPowerTasks(data.data)
           tableData = this.setMultiPowerTasks(data.data)
           break
           break
@@ -256,42 +261,6 @@ export default {
       this.$tableData[status.key] = tableData
       this.$tableData[status.key] = tableData
       status.resolve({ data: tableData })
       status.resolve({ data: tableData })
     },
     },
-    getPowers () {
-      return this.getData(GET_POWER_STATUS)
-    },
-    setPowerStatus ({ current_status_info }) {
-      const map = {}
-      const powers = []
-      let hasMulti = false
-      let hasRelay = false
-      current_status_info.forEach(({ connectIndex, portIndex, updatePowerIndexStates }) => {
-        updatePowerIndexStates.forEach(({ powerIndex, type, action }) => {
-          if (portIndex === RELAY_KEY) {
-            return
-          }
-          const key = portIndex === RELAY_KEY ? RELAY_KEY : `${connectIndex}_${portIndex}_${type}`
-          if (!map[key]) {
-            map[key] = {
-              connectIndex,
-              portIndex,
-              type,
-              label: portIndex === RELAY_KEY ? '' : `${portIndex} ${type}`
-            }
-            if (portIndex === RELAY_KEY) {
-              hasRelay = true
-            } else {
-              hasMulti = true
-            }
-          }
-          powers.push({ connectIndex, portIndex, powerIndex, type, action })
-        })
-      })
-      this.$typeMap = map
-      this.hasMulti = hasMulti
-      this.hasRelay = !hasMulti && hasRelay
-      this.$hasRelay = hasRelay
-      return powers
-    },
     getMultiTasks () {
     getMultiTasks () {
       return this.getData(GET_MULTI_POWER_TIMING)
       return this.getData(GET_MULTI_POWER_TIMING)
     },
     },

+ 1 - 1
src/views/device/detail/components/DeviceInvoke/MultifunctionCardPowerSwitch.vue

@@ -967,7 +967,7 @@ export default {
         params: JSON.stringify({
         params: JSON.stringify({
           id: this.device.id,
           id: this.device.id,
           name: this.device.name,
           name: this.device.name,
-          tasks: this.$tasks.map(({ action, enable, freqInfo, startTime, endTime, executeTime, type }) => `${enable ? '启用' : '禁用'} ${startTime === endTime ? startTime : `${startTime} - ${endTime}`} ${freqInfo} ${executeTime} ${['开启', '关闭'][action]} ${type}`).join(';')
+          tasks: this.$tasks.map(({ action, enable, freqInfo, startTime, endTime, executeTime, type }) => `${enable ? '启用' : '禁用'} ${startTime === endTime ? startTime : `${startTime} - ${endTime} ${freqInfo}`} ${executeTime} ${['开启', '关闭'][action]} ${type}`).join(';')
         })
         })
       })
       })
       return data.filter(({ conditions }) => conditions.length)
       return data.filter(({ conditions }) => conditions.length)

+ 11 - 9
src/views/device/detail/components/DeviceInvoke/ScreenLight.vue

@@ -49,15 +49,17 @@
       :title="dialogTitle"
       :title="dialogTitle"
       @confirm="onSave"
       @confirm="onSave"
     >
     >
-      <span class="c-grid-form__label u-required">{{ tip }}</span>
-      <div class="l-flex--row">
-        <el-input-number
-          v-model="task"
-          :min="0"
-          :max="100"
-          step-strictly
-        />&nbsp;%
-      </div>
+      <template #default>
+        <span class="c-grid-form__label u-required">{{ tip }}</span>
+        <div class="l-flex--row">
+          <el-input-number
+            v-model="task"
+            :min="0"
+            :max="100"
+            step-strictly
+          />&nbsp;%
+        </div>
+      </template>
     </task-dialog>
     </task-dialog>
   </div>
   </div>
 </template>
 </template>

+ 11 - 9
src/views/device/detail/components/DeviceInvoke/ScreenVolume.vue

@@ -54,15 +54,17 @@
       :title="dialogTitle"
       :title="dialogTitle"
       @confirm="onSave"
       @confirm="onSave"
     >
     >
-      <span class="c-grid-form__label u-required">{{ tip }}</span>
-      <div class="l-flex--row">
-        <el-input-number
-          v-model="task"
-          :min="0"
-          :max="100"
-          step-strictly
-        />&nbsp;%
-      </div>
+      <template #default>
+        <span class="c-grid-form__label u-required">{{ tip }}</span>
+        <div class="l-flex--row">
+          <el-input-number
+            v-model="task"
+            :min="0"
+            :max="100"
+            step-strictly
+          />&nbsp;%
+        </div>
+      </template>
     </task-dialog>
     </task-dialog>
   </div>
   </div>
 </template>
 </template>

+ 3 - 2
src/views/device/detail/components/DeviceInvoke/mixins/task.js

@@ -15,7 +15,7 @@ export default {
       isAdd: false,
       isAdd: false,
       active: 'immediate',
       active: 'immediate',
       options: null,
       options: null,
-      task: {}
+      task: null
     }
     }
   },
   },
   computed: {
   computed: {
@@ -90,6 +90,7 @@ export default {
       return addTask({
       return addTask({
         deviceId: this.deviceId,
         deviceId: this.deviceId,
         functionKey: this.$refs.table.getCondition().functionKey,
         functionKey: this.$refs.table.getCondition().functionKey,
+        status: 1,
         ...task,
         ...task,
         ...this.getTask()
         ...this.getTask()
       }).then(() => {
       }).then(() => {
@@ -145,7 +146,7 @@ export default {
           task.type = '每天'
           task.type = '每天'
           break
           break
         case 1:
         case 1:
-          task.type = `每周${task.dayOfWeek.split(',').map(val => ['一', '二', '三', '四', '五', '六', '日'][val])}`
+          task.type = `每周${task.dayOfWeek.split(',').map(val => ['', '日', '一', '二', '三', '四', '五', '六'][val])}`
           break
           break
         default:
         default:
           break
           break

+ 0 - 1
src/views/external/mesh/index.vue

@@ -266,7 +266,6 @@ const sensors = Object.values(SensorToThirdPartyMap)
 
 
 const PortThirdPartyDevices = [
 const PortThirdPartyDevices = [
   ThirdPartyDevice.PLC,
   ThirdPartyDevice.PLC,
-  ThirdPartyDevice.MULTI_FUNCTION_CARD,
   ...sensors
   ...sensors
 ]
 ]