<template>
  <div v-loading="loading">
    <div class="base-dialog-body" style="height:380px;overflow-y: auto;">
      <el-form ref="otherForm" :model="form">
        <el-form-item
          :label="$t('trials:reading:label:autoSwitch')"
          prop="AutoCutNextTask"
          :rules="[
            { required: true, message: $t('common:ruleMessage:select')}
          ]"
        >
          <el-switch v-model="form.AutoCutNextTask" />
        </el-form-item>
      </el-form>
    </div>
    <div class="base-dialog-footer" style="text-align:right;margin-top:10px;">
      <el-button size="small" type="primary" @click="handleSave"> {{ $t('common:button:save') }}</el-button>

    </div>
  </div>
</template>
<script>
import { setAutoCutNextTask, getAutoCutNextTask } from '@/api/user'
export default {
  name: 'Others',
  data() {
    return {
      form: {
        AutoCutNextTask: false
      },
      loading: false
    }
  },
  mounted() {
    this.initForm()
  },
  methods: {
    async initForm() {
      this.loading = true
      try{
        await getAutoCutNextTask()
        this.form.AutoCutNextTask = res.Result.AutoCutNextTask
        this.loading = false
      }catch(e){
        this.loading = false
      }
    },
    async handleSave() {
      let valid = await this.$refs.otherForm.validate()
      if (!valid) return
      this.loading = true
      try{
        await setAutoCutNextTask(this.form)
        this.loading = false
        this.$message.success(this.$t('common:message:savedSuccessfully'))
      }catch(e){
        this.loading = false
      }
    }
  }
}
</script>

<style lang="scss">

</style>
