<template>
  <div>
    <!-- 保养计划 -->
    <p-card title="保养计划">
      <span slot="extra">
        <!-- <p-button type="primary" style="margin-right:10px" @click="showmodel()">添加</p-button> -->
      </span>
      <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"
        :remoteUrl="config.remoteUrl"
        :remoteParams="remoteParams"
        :rowSelectType="false"
        :data-source="data"
        :scroll="{ x: 1500 }"
      >
        <!-- detailCount -->

        <template slot="operation" slot-scope="text, record">
          <!-- {{ text ? '禁用' : '启用' }} -->
          <a @click="submit(text)">确认</a>
          <a-divider type="vertical" />
          <a @click="del(text)">删除</a>
        </template>
      </p-table>
    </p-card>

    <!-- inboundTaskDetailSubListvisible -->
  </div>
</template>

<script>
import { diffOption } from '@/views/kzyWMS/utils/index.js'
import config from './config.js'
import { maintainTaskConfirm, deletes } from './api'
import { remote } from '@/views/EIS/remote/index.js'
const base = '/api/service-ai-eis-business-center-eistest'
export default {
  data() {
    return {
      config: config(this),
      data: [{ id: 1 }],
      type: true,
      remoteParams: {},
      confirmLoading: false,
    }
  },
  mounted() {
    // this.getinfo()
  },
  created() {
    // diffOption(this.config.columns).then((res) => {
    //   this.config.columns = res
    // })
    // diffOption(this.detailCount.columns).then((res) => {
    //   this.detailCount.columns = res
    // })
  },
  methods: {
    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 }
        }
      })
    },

    submit(text) {
      let that = this
      console.log(text)
      this.$confirm({
        title: '确定是否要确认?',
        content: '',
        async onOk() {
          let res = await maintainTaskConfirm({ id: text.id })
          if (res.success) {
            that.$message.success('确认成功')
            that.remoteParams = { ...that.remoteParams }
          } else {
            that.$exception(res)
          }
        },
        onCancel() {},
      })
    },
    del(text) {
      let that = this
      console.log(text)
      this.$confirm({
        title: '确定是否要删除?',
        content: '',
        async onOk() {
          let res = await deletes({ areaNo: text.areaNo })
          if (res.success) {
            that.$message.success('删除成功')
            that.remoteParams = { ...that.remoteParams }
          } else {
            that.$exception(res)
          }
        },
        onCancel() {},
      })
    },
  },
}
</script>

<style lang="less" scoped>
.count {
  padding: 10px;
  padding-left: 25px;
  padding-right: 25px;
}
</style>
