<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"
        :wrapperCol="{ span: 8, offset: 2 }"
        :items="config.items"
        @submit="hanlderSubmit"
      />
      <p-table
        ref="table"
        row-key="taskGroupNo"
        bordered
        :columns="config.columns"
        :remoteUrl="config.remoteUrl"
        :remoteParams="remoteParams"
        :rowSelectType="false"
        :doneBefore="doneBefore"
        :data-source="data"
      >
        <template slot="operation" slot-scope="text, record">
          <!-- {{ text ? '禁用' : '启用' }} -->
          <a @click="showmodel('taskGroupContainerData', record)">托盘</a>
          <a-divider type="vertical" />
          <a @click="showmodeltaskGroupStationData('taskGroupStationData', record)">站台</a>
          <a-divider type="vertical" />
          <a @click="showmodeltaskPackageData('taskPackageData', record)">任务包</a>
        </template>
      </p-table>
    </p-card>

    <p-modal
      title="任务组托盘查询"
      width="80%"
      :visible="taskGroupContainerData"
      :confirm-loading="confirmLoading"
      @ok="taskGroupContainerData = false"
      @cancel="taskGroupContainerData = false"
    >
      <p-table
        ref="table"
        row-key="id"
        bordered
        :columns="config.taskGroupContainerData.columns"
        :remoteUrl="config.taskGroupContainerData.remoteUrl"
        :remoteParams="taskGroupContainerDataremoteParams"
        :rowSelectType="false"
        :doneBefore="doneBefore"
        :data-source="data"
      />
    </p-modal>

    <p-modal
      title="任务组站台查询"
      width="80%"
      :visible="taskGroupStationData"
      :confirm-loading="confirmLoading"
      @ok="taskGroupStationData = false"
      @cancel="taskGroupStationData = false"
    >
      <p-table
        ref="table"
        row-key="id"
        bordered
        :columns="config.taskGroupStationData.columns"
        :remoteUrl="config.taskGroupStationData.remoteUrl"
        :remoteParams="taskGroupStationDataremoteParams"
        :rowSelectType="false"
        :doneBefore="doneBefore"
        :data-source="data"
      />
    </p-modal>

    <p-modal
      title="任务组查询任务包"
      width="80%"
      :visible="taskPackageData"
      :confirm-loading="confirmLoading"
      @ok="taskPackageData = false"
      @cancel="taskPackageData = false"
    >
      <p-table
        ref="table"
        row-key="taskNo"
        bordered
        :columns="config.taskPackageData.columns"
        :remoteUrl="config.taskPackageData.remoteUrl"
        :remoteParams="taskPackageDataremoteParams"
        :rowSelectType="false"
        :doneBefore="doneBefore"
        :data-source="data"
      >
        <template slot="operation" slot-scope="text, record">
          <a @click="showmodeltaskPackageBoxData('taskPackageBoxData', record)">任务包周转箱</a>
          <a-divider type="vertical" />
          <a @click="showmodeltaskPackageOrderData('taskPackageOrderData', record)">任务包订单</a>
        </template>
      </p-table>
    </p-modal>

    <p-modal
      title="任务包周转箱"
      width="80%"
      :visible="taskPackageBoxData"
      :confirm-loading="confirmLoading"
      @ok="taskPackageBoxData = false"
      @cancel="taskPackageBoxData = false"
    >
      <p-table
        ref="table"
        row-key="id"
        bordered
        :columns="config.taskPackageBoxData.columns"
        :remoteUrl="config.taskPackageBoxData.remoteUrl"
        :remoteParams="taskPackageBoxDataremoteParams"
        :rowSelectType="false"
        :doneBefore="doneBefore"
        :data-source="data"
      >
        <template slot="operation" slot-scope="text, record">
          <a @click="showmodeltaskPackageBoxDetailData('taskPackageBoxDetailData', record)">周转箱明细</a>
        </template>
      </p-table>
    </p-modal>

    <p-modal
      title="周转箱明细"
      width="80%"
      :visible="taskPackageBoxDetailData"
      :confirm-loading="confirmLoading"
      @ok="taskPackageBoxDetailData = false"
      @cancel="taskPackageBoxDetailData = false"
    >
      <p-table
        ref="table"
        row-key="id"
        bordered
        :columns="config.taskPackageBoxDetailData.columns"
        :remoteUrl="config.taskPackageBoxDetailData.remoteUrl"
        :remoteParams="taskPackageBoxDetailDataremoteParams"
        :rowSelectType="false"
        :doneBefore="doneBefore"
        :data-source="data"
      />
    </p-modal>

    <p-modal
      title="任务包订单查询"
      width="80%"
      :visible="taskPackageOrderData"
      :confirm-loading="confirmLoading"
      @ok="taskPackageOrderData = false"
      @cancel="taskPackageOrderData = false"
    >
      <p-table
        ref="table"
        row-key="id"
        bordered
        :columns="config.taskPackageOrderData.columns"
        :remoteUrl="config.taskPackageOrderData.remoteUrl"
        :remoteParams="taskPackageOrderDataremoteParams"
        :rowSelectType="false"
        :doneBefore="doneBefore"
        :data-source="data"
      >
        <template slot="operation" slot-scope="text, record">
          <a @click="showmodeltaskPackageOrderDetailData('taskPackageOrderDetailData', record)">订单明细</a>
        </template>
      </p-table>
    </p-modal>

    <p-modal
      title="任务包订单明细"
      width="80%"
      :visible="taskPackageOrderDetailData"
      :confirm-loading="confirmLoading"
      @ok="taskPackageOrderDetailData = false"
      @cancel="taskPackageOrderDetailData = false"
    >
      <p-table
        ref="table"
        row-key="id"
        bordered
        :columns="config.taskPackageOrderDetailData.columns"
        :remoteUrl="config.taskPackageOrderDetailData.remoteUrl"
        :remoteParams="taskPackageOrderDetailDataremoteParams"
        :rowSelectType="false"
        :doneBefore="doneBefore"
        :data-source="data"
      />
    </p-modal>

    <!-- <p-modal
      title="任务包订单详情"
      width="80%"
      :visible="taskPackageOrderDetailData"
      :confirm-loading="confirmLoading"
      @ok="taskGroupContainerData = false"
      @cancel="taskGroupContainerData = false"
    >
      <p-table
        ref="table"
        row-key="id"
        bordered
        :columns="config.columns"
        :remoteUrl="config.remoteUrl"
        :remoteParams="remoteParams"
        :rowSelectType="false"
        :doneBefore="doneBefore"
        :data-source="data"
      />
    </p-modal> -->

    <p-modal
      title="订单贴标查询"
      width="80%"
      :visible="labelTaskData"
      :confirm-loading="confirmLoading"
      @ok="labelTaskData = false"
      @cancel="labelTaskData = false"
    >
      <p-table
        ref="table"
        row-key="id"
        bordered
        :columns="config.columns"
        :remoteUrl="config.remoteUrl"
        :remoteParams="remoteParams"
        :rowSelectType="false"
        :doneBefore="doneBefore"
        :data-source="data"
      />
    </p-modal>

    <p-modal
      title="订单封箱查询"
      width="80%"
      :visible="sealBoxTaskData"
      :confirm-loading="confirmLoading"
      @ok="sealBoxTaskData = false"
      @cancel="sealBoxTaskData = false"
    >
      <p-table
        ref="table"
        row-key="id"
        bordered
        :columns="config.columns"
        :remoteUrl="config.remoteUrl"
        :remoteParams="remoteParams"
        :rowSelectType="false"
        :doneBefore="doneBefore"
        :data-source="data"
      />
    </p-modal>
  </div>
</template>

<script>
import config from './config.js'
import pick from 'lodash.pick'
import { add, deletes, update } from './api'
import { diffOption } from '@/views/kzyWMS/utils/index.js'
export default {
  data() {
    return {
      taskGroupData: false, //任务组查询
      taskGroupContainerData: false, //托盘任务组数据查询
      taskPackageData: false, //根据任务组查询任务包
      taskGroupStationData: false, //任务组站台查询
      taskPackageBoxData: false, //任务包料箱查询
      taskPackageBoxDetailData: false, //任务包料箱明细查询
      taskPackageOrderData: false, //任务包订单查询
      taskPackageOrderDetailData: false, //任务包订单明细查询
      labelTaskData: false, //订单贴标查询
      sealBoxTaskData: false, //订单封箱查询
      config: config(this),
      data: [{ id: 1 }, { id: 2 }, { id: 3 }],
      type: true,
      remoteParams: {},
      taskGroupContainerDataremoteParams: {},
      taskGroupStationDataremoteParams: {},
      taskPackageDataremoteParams: {}, //任务包订单
      taskPackageBoxDataremoteParams: {}, //任务包周转箱
      taskPackageBoxDetailDataremoteParams: {}, //周转箱明细
      taskPackageOrderDataremoteParams: {}, //订单查询
      taskPackageOrderDetailDataremoteParams: {}, //订单明细
      visible: false,
      confirmLoading: false,
      columns: [],
    }
  },
  mounted() {
    // this.getinfo()
  },
  created() {
    // diffOption(this.config.columns).then((res) => {
    //   this.columns = res
    // })
  },
  methods: {
    doneBefore(res) {
      res.data.list.forEach((item) => {
        item.id = item.areaNo
      })
      console.log(res)
      return res
    },
    hanlderSubmit(e, form) {
      e.preventDefault()
      form.validateFields((error, values) => {
        if (!error) {
          console.log(error, values, 'valuesvaluesvaluesvaluesvalues')
          this.remoteParams = { ...this.remoteParams, ...values }
        }
      })
    },

    handleCancel(e) {
      console.log('Clicked cancel button')
      this.visible = false
    },
    //点击弹出
    showmodel(data, record) {
      console.log(data, record)
      this[data] = true
      this[data + 'remoteParams'] = { ...this[data + 'remoteParams'], taskGroupNo: record.taskGroupNo }
    },
    showmodeltaskGroupStationData(data, record) {
      this[data] = true
      this[data + 'remoteParams'] = { ...this[data + 'remoteParams'], taskGroupList: [record.taskGroupNo] }
    },
    //任务包订单
    showmodeltaskPackageData(data, record) {
      this[data] = true
      this[data + 'remoteParams'] = { ...this[data + 'remoteParams'], taskGroupList: [record.taskGroupNo] }
    },
    //任务包周转箱
    showmodeltaskPackageBoxData(data, record) {
      this[data] = true
      this[data + 'remoteParams'] = { ...this[data + 'remoteParams'], packageList: [record.taskNo] }
    },
    //任务包周转箱明细
    showmodeltaskPackageBoxDetailData(data, record) {
      this[data] = true
      this[data + 'remoteParams'] = { ...this[data + 'remoteParams'], packageList: [record.taskPackageId] }
    },
    //任务包订单
    showmodeltaskPackageOrderData(data, record) {
      console.log(record)
      this[data] = true
      this[data + 'remoteParams'] = { ...this[data + 'remoteParams'], packageList: [record.taskGroupNo] }
    },
    //订单明细
    showmodeltaskPackageOrderDetailData(data, record) {
      this[data] = true
      this[data + 'remoteParams'] = { ...this[data + 'remoteParams'], orderList: [record.orderNo] }
    },
  },
}
</script>

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