<template>
  <div class="l-flex--col center has-border radius has-padding ">
    <i
      class="o-icon lg u-pointer"
      @click="invoke"
    />
    <div class="has-padding u-color--black u-bold">{{ type }}</div>
    <c-dialog
      ref="dialog"
      size="medium"
      :title="settings"
    >
      <template #default>
        <tabbar
          :items="tabs"
          :active.sync="active"
        />
        <template v-if="isImmediate">
          <div class="l-flex__auto l-flex--col jcenter center has-bottom-padding">
            <div class="c-sibling-item--v c-grid-form auto">
              <span class="c-grid-form__label u-required">{{ tip }}</span>
              <div class="l-flex--row">
                <el-input-number
                  v-model="taskValue"
                  :min="0"
                  :max="100"
                  step-strictly
                />&nbsp;%
              </div>
            </div>
            <button
              class="c-sibling-item--v o-button"
              @click="onInvoke"
            >
              应用
            </button>
          </div>
        </template>
        <schema-table
          v-else
          ref="table"
          :schema="schema"
          :proxy.sync="options"
        />
      </template>
    </c-dialog>
    <task-dialog
      ref="taskDialog"
      :title="dialogTitle"
      @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>
    </task-dialog>
  </div>
</template>

<script>
import simpleTaskMixin from './mixins/simple-task'

export default {
  name: 'ScreenLight',
  mixins: [simpleTaskMixin],
  data () {
    return {
      type: '亮度',
      functionKey: 'brightnessControl',
      valueKey: 'brigthness',
      schema: this.createSchema([
        { label: '亮度值（%）', render ({ inputs }) { return inputs[0]?.value } }
      ])
    }
  }
}
</script>

<style lang="scss" scoped>
.o-icon {
  background-image: url("~@/assets/icon_screen_light.png");
}
</style>
