<template>
  <p-card title="养护计划">
    <p-grid-form :label-col="{ span: 8 }" :span="8" :items="config.items" @submit="hanlderSubmit" />
    <p-table ref="table" row-key="id" bordered :columns="config.columns" :remoteParams="remoteParams"
      :remoteUrl="config.remoteUrl" :rowSelectType="false" :data-source="data.list">
      <template slot="operation" slot-scope="text, record">
        <!-- {{ text ? '禁用' : '启用' }} -->
        <a @click="btnOk(text)">确认</a>
      </template>
    </p-table>
  </p-card>
</template>

<script>
  import config from './config.js'
  import {
    confirmMaintain 
  } from './api.js'


  export default {
    data() {
      return {
        config,
        data: [],
        remoteParams: {
          deviceCompany: '',
          deviceType: '',
          equipmentNo: '',
          maintainContent: ''
        },
      }
    },
    methods: {
      //点击弹窗
      async btnOk(text) {
         console.log(text)
        let res = await confirmMaintain({
          id: text.id
        })
        console.log(res)
        if (res.success) {
          this.$message.success(res.message)
        } else {
          this.$exception(res)
        }
      },
      hanlderSubmit(e, form) {
        e.preventDefault()
        form.validateFields((error, values) => {
          console.log(error, values, 'valuesvaluesvaluesvaluesvalues')
          // this.queryName = values.name
          // this.queryType = values.type
          // this.getlistCompanyByAuthId()
          if (!error) {
            this.remoteParams = {
              ...this.remoteParams,
              ...values
            }
          }
        })
      },
    }
  }
</script>

<style>
</style>
