<template>
  <div class="view-carrierListExecutionRegistration">
    <div class="view-carrierFlightMission-FlightMission-btn">
      <div class="view-carrierFlightMission-FlightMission-btn-right">
        <div class="common-box">
          <div class="input-with-select">
            <span>状态</span>
            <el-select v-model="statusValue" placeholder="请选择" @change="fetchTableData('search')">
              <el-option v-for="item in statusList" :key="item.value" :label="item.label" :value="item.value"> </el-option>
            </el-select>
          </div>

          <el-input @keyup.enter.native="fetchTableData('search')" placeholder="请输入任务名称/代号/带队领导" v-model="searchValue" class="input-select">
            <el-button @click="fetchTableData('search')" slot="append" icon="el-icon-search"></el-button>
          </el-input>
        </div>
      </div>
    </div>

    <LTable ref="table" :columns="columns" :dataSource="tableData" :options="options" :fetch="fetchTableData"></LTable>
  </div>
</template>

<script>
import { columns, options } from './index'
import { getTaskExecondRegister } from '@/api/carrierStandard/carrierListExecutionRegistration'
import { updateFlyTask } from '@/api/task/carrierFlightMission'
import { statusList } from '@/utils/status'
export default {
  name: 'carrierListExecutionRegistration',
  components: {},
  data() {
    // 这里存放数据
    return {
      statusList: statusList,
      statusValue: null,
      searchValue: '',
      options,
      columns: columns(this),
      tableData: [],
      tableRequset: {
        searchValue: ''
      }
    }
  },
  created() {},
  methods: {
    async fetchTableData(search) {
      let postData = {
        status: this.statusValue,
        queryParam: this.searchValue,
        taskId: '',
        aircaftCatalogId: ''
      }
      const { code, data } = await getTaskExecondRegister(postData)
      if (code == 200) {
        this.tableData = data
      }
    },

    toCompile() {
      this.$router.push('/carrierStandard/carrierListExecutionRegistration/compile')
    },
    look(row) {
      const { taskId } = row
      this.$router.push(`/carrierStandard/carrierListExecutionRegistration/look/${taskId}`)
    },

    toRegistering(row) {
      const { taskId } = row
      this.$router.push(`/carrierStandard/carrierListExecutionRegistration/registering/${taskId}`)
    },

    registering(rwo) {
      this.$confirm('是否登记该任务', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
        .then(() => {
          this.$message({
            type: 'success',
            message: '操作成功!'
          })
        })
        .catch(() => {})
    },

    completion(row) {
      this.$confirm('是否完成该任务', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
        .then(async () => {
          const { taskId, parentId } = row
          const { success } = await updateFlyTask({ taskId, parentId, status: 9 })
          if (success) {
            this.$message({
              type: 'success',
              message: '操作成功!'
            })
            this.fetchTableData()
          }
        })
        .catch(() => {})
    }
  }
}
</script>

<style lang="scss">
@import './index.scss';
</style>
