<template>
  <div style="box-sizing: border-box; padding: 30px">
    <el-card style="width: 100%">
      <el-table :data="tableData" style="width: 100%">
        <el-table-column prop="title" label="配置类型" align="left" width="280px"> </el-table-column>
        <el-table-column prop="val" label="时间设置" align="left">
          <template slot-scope="scope">
            <el-input type="number" v-model="scope.row.val" placeholder="请输入内容">
              <template slot="append">单位（小时）</template>
            </el-input>
          </template>
        </el-table-column>
        <el-table-column prop="remark" label="" align="left"> </el-table-column>
      </el-table>
      <div style="text-align: right; margin-top: 30px">
        <el-button size="mini" @click="chongzhi">重置</el-button>
        <el-button type="primary" size="mini" @click="queding">保存</el-button>
      </div>
    </el-card>
  </div>
</template>

<script>
import { appraiseApplyConfigList, appraiseApplyConfigSave } from '@/api/workOrderAppealTime'
export default {
  data() {
    return {
      tableData: []
    }
  },
  created() {
    this.getList()
  },
  methods: {
    getList() {
      appraiseApplyConfigList().then(res => {
        this.tableData = res.data.length
          ? res.data
          : [
              {
                title: '首次申诉：网点申诉截止时间',
                val: '',
                remark: '注：首次申诉时间，是从完工时间开始计算倒计时（师傅报完工或网点报完工时间）',
                type: 'FIRST_A'
              },
              {
                title: '二次申诉：网点申诉截止时间',
                val: '',
                remark: '注：二次申诉时间，是从中心审核驳回时间开始计算倒计时',
                type: 'SECOND_A'
              },
              {
                title: '首次申诉：中心审核截止时间',
                val: '',
                remark: '注：首次审核时间，是从网点提交申诉时间开始计算倒计时',
                type: 'FIRST_C'
              },
              {
                title: '二次申诉：中心审核截止时间',
                val: '',
                remark: '注：首次审核时间，是从网点提交申诉时间开始计算倒计时',
                type: 'SECOND_C'
              }
            ]
      })
    },
    chongzhi() {
      this.tableData.map(item => {
        item.val = ''
      })
    },
    queding() {
      appraiseApplyConfigSave(this.tableData).then(res => {
        this.getList()
        this.$message({ type: 'success', message: `保存成功!` })
      })
    }
  }
}
</script>

<style lang="scss" scoped></style>
