<template>
  <div>
    <!-- 路径执行记录 -->
    <p-card>
      <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"
      >
        <template slot="operation" slot-scope="text, record">
          <!-- {{ text ? '禁用' : '启用' }} -->
          <a @click="showmodel(text)">路径明细</a>
        </template>
      </p-table>
    </p-card>

    <p-modal
      title="路径明细"
      width="80%"
      :visible="visible"
      :confirm-loading="confirmLoading"
      @ok="handleOk"
      @cancel="handleCancel"
    >
      <p-table
        ref="table"
        row-key="id"
        bordered
        :columns="config.modelcolumns"
        :rowSelectType="false"
        :data-source="Modeldata"
      />
    </p-modal>
  </div>
</template>

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

import { diffOption } from '@/views/kzyWMS/utils/index.js'
export default {
  data() {
    return {
      config,
      data: [],
      Modeldata: [],
      remoteParams: {
        containerNo: '',
        palletNo: ''
      },
      visible: false,
      confirmLoading: false
    }
  },
  mounted() {
    // this.getinfo()
  },
  created() {
    diffOption(this.config.columns).then(res => {
      this.config.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 }
        }
      })
    },
    handleOk(e) {
      this.confirmLoading = true
      setTimeout(() => {
        this.visible = false
        this.confirmLoading = false
      }, 2000)
    },
    handleCancel(e) {
      console.log('Clicked cancel button')
      this.visible = false
    },
    //点击弹窗
    async showmodel(text) {
      console.log(text)

      let res = await containerpath({ taskNo: text.taskNo })
      console.log(res)
      if (res.success) {
        this.Modeldata = res.data
        this.visible = true
      } else {
        this.$exception(res)
      }
    }
  }
}
</script>

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