<template>
  <!-- 生产进度报表 -->
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :md="6" :sm="8">
            <a-form-item label="销售订单号">
              <a-input placeholder="请输入订单号" v-model="queryParam.salesOrderNo"></a-input>
            </a-form-item>
          </a-col>

          <a-col :md="6" :sm="8">
            <a-form-item label="部门">
              <a-input placeholder="请输入部门" v-model="queryParam.department"></a-input>
            </a-form-item>
          </a-col>

          <a-col :md="6" :sm="8">
            <a-form-item label="物料名称">
              <a-input placeholder="请输入物料名称" v-model="queryParam.materialName"></a-input>
            </a-form-item>
          </a-col>

          <template v-if="toggleSearchStatus">
            <a-col :md="6" :sm="8">
              <a-form-item label="成衣加工厂">
                <a-select placeholder="请选择成衣加工厂" v-model="queryParam.garmentFactory">
                  <a-select-option :value="''">请选择</a-select-option>
                  <a-select-option :value="0">成衣加工厂1</a-select-option>
                  <a-select-option :value="1">成衣加工厂2</a-select-option>
                  <a-select-option :value="2">成衣加工厂3</a-select-option>
                </a-select>
              </a-form-item>
            </a-col>

            <a-col :md="6" :sm="8">
              <a-form-item label="业务员">
                <a-input placeholder="请输入业务员" v-model="queryParam.salesman"></a-input>
              </a-form-item>
            </a-col>

            <a-col :md="6" :sm="8">
              <a-form-item label="计划单号">
                <a-input placeholder="请输入计划单号" v-model="queryParam.planOrderNo"></a-input>
              </a-form-item>
            </a-col>

            <a-col :md="6" :sm="8">
              <a-form-item label="日期" has-feedback>
                <a-date-picker style="width: 100%" v-model="queryParam.date"></a-date-picker>
              </a-form-item>
            </a-col>

            <a-col :md="6" :sm="8">
              <a-form-item label="颜色">
                <a-input placeholder="请输入颜色" v-model="queryParam.color"></a-input>
              </a-form-item>
            </a-col>

            <a-col :md="6" :sm="8">
              <a-form-item label="交期" has-feedback>
                <a-date-picker style="width: 100%" v-model="queryParam.deliveryDate"></a-date-picker>
              </a-form-item>
            </a-col>
          </template>

          <!-- 重置 -->
          <a-col :md="6" :sm="8">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
              <a @click="handleToggleSearch" style="margin-left: 8px">
                {{ toggleSearchStatus ? '收起' : '展开' }}
                <a-icon :type="toggleSearchStatus ? 'up' : 'down'" />
              </a>
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>

    <!-- 操作按钮区域 -->
    <!-- <div class="table-operator">
      <a-button type="primary" @click="synchronization" icon="reload">同步</a-button>
    </div> -->

    <!-- table区域  -->
    <div>
      <a-table
        bordered
        rowKey="id"
        :columns="proProgressColumns"
        :data-source="proProgressData"
        :loading="loading"
        :pagination="ipagination"
        :scroll="{ x: 1500 }"
        @change="handleTableChange"
      >
        <!--字符串超长截取省略号显示 订单备注 -->
        <span slot="**" slot-scope="text">
          <j-ellipsis :value="text" :length="25" />
        </span>

        <!-- 销售订单号  链接-->
        <span slot="salesOrderNo" slot-scope="text">
          <a>{{ text }}</a>
        </span>
      </a-table>
    </div>

    <!-- 订单数据明细 抽屉 -->
    <singleOrderReport-drawer ref="singleOrderReportDrawer" :father="aa" @ok="modalFormOk"></singleOrderReport-drawer>
  </a-card>
</template>

<script>
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import JEllipsis from '@/components/jeecg/JEllipsis'
import moment from 'moment'
import singleOrderReportDrawer from '@views/reportForms/pro-progress-report/singleOrderReportDrawer.vue'

export default {
  name: 'OrderList',
  mixins: [JeecgListMixin],
  components: { JEllipsis, moment, singleOrderReportDrawer },

  data() {
    let ellipsis = (v, l = 20) => <j-ellipsis value={v} length={l} /> // 省略

    return {
      description: '生产进度报表',
      // 表头
      proProgressColumns: [
        {
          title: '部门',
          width: 120,
          dataIndex: 'department',
          fixed: 'left',
          className: 'replacecolor'
        },

        {
          title: '销售订单号',
          width: 210,
          fixed: 'left',
          dataIndex: 'salesOrderNo',
          className: 'replacecolor',
          customCell: this.showDrawer,
          scopedSlots: { customRender: 'salesOrderNo' }
        },
        { title: '业务员', width: 120, dataIndex: 'salesman', className: 'replacecolor' },
        { title: '计划单号', width: 120, dataIndex: 'planOrderNo', className: 'replacecolor' },
        {
          title: '成衣加工厂',
          width: 120,
          dataIndex: 'garmentFactory',
          className: 'replacecolor'
        },
        { title: '物料编号（多个分行显示）', width: 210, dataIndex: 'materialNum', className: 'replacecolor' },
        {
          title: '物料名称',
          width: 210,
          dataIndex: 'materialName',
          customRender: t => ellipsis(t),
          className: 'replacecolor'
        },
        { title: '款号', width: 90, dataIndex: 'styleNum', className: 'replacecolor' },
        { title: '颜色', width: 210, dataIndex: 'color', customRender: t => ellipsis(t), className: 'replacecolor' },
        // {
        //   title: '创建时间',
        //   dataIndex: 'createTime',
        //   align: 'center',
        //   sorter: true,
        //   customRender: text => {
        //     return moment(text).format('YYYY-MM-DD')
        //   }
        // },
        { title: '交期', width: 120, dataIndex: 'deliveryDate', className: 'replacecolor' },
        { title: '订单数量', width: 120, dataIndex: 'orderQuantity', className: 'replacecolor' },
        { title: '单价(原币)', width: 120, dataIndex: 'priceOriginal', className: 'replacecolor' },
        { title: '总额(原币)', width: 120, dataIndex: 'totalAmountOriginal', className: 'replacecolor' },
        { title: '单价(本币)', width: 120, dataIndex: 'priceLocal', className: 'replacecolor' },
        { title: '总额(本币)', width: 120, dataIndex: 'totalAmountLocal', className: 'replacecolor' },
        { title: '实际发票成本', width: 120, dataIndex: 'actualInvoiceCost', className: 'replacecolor' },
        { title: '已出库数量', width: 120, dataIndex: 'quantityDelivered', className: 'replacecolor' },
        { title: '累计开票数量', width: 120, dataIndex: 'invoicesCumulativeNum', className: 'replacecolor' },
        { title: '图片', width: 120, dataIndex: 'image', fixed: 'right', className: 'replacecolor' },
        { title: '附件', width: 120, dataIndex: 'accessory', fixed: 'right', className: 'replacecolor' }
      ],
      proProgressData: [
        {
          department: '业务二部',
          salesman: '陈',
          salesOrderNo: 'SS22-71499-PH1-GY SEN',
          materialNum: '1901000890',
          materialName: '春夏女装印花袋鼠袋拉毛绒布带帽衫',
          styleNum: '71499',
          color: '浅绿green14-0114tcx',
          deliveryDate: '2021-10-07',
          orderQuantity: '69270',
          priceOriginal: '2.53',
          totalAmountOriginal: '175253.1',
          priceLocal: '18',
          totalAmountLocal: '1246860',
          quantityDelivered: '69270'
        },
        {
          department: '业务一部',
          salesman: '张',
          salesOrderNo: 'SS22-51349-PH1-GY SEN',
          materialNum: '1902300890',
          materialName: '裙子',
          styleNum: '71249',
          color: 'orange',
          deliveryDate: '2022-04-07',
          orderQuantity: '624570',
          priceOriginal: '2.53',
          totalAmountOriginal: '335253.1',
          priceLocal: '18',
          totalAmountLocal: '1346860',
          quantityDelivered: '624570'
        },
        {},
        {}
      ],
      loading: false, // 表格加载

      // 查询条件
      queryParam: {
        salesOrderNo: '', // 销售订单号
        department: '', // 部门
        materialName: '',
        garmentFactory: '', // 成衣加工厂
        salesman: '',
        planOrderNo: '', // 计划单号
        date: '',
        color: '',
        deliveryDate: '' // 交期
      }
    }
  },
  created() {
    // 渲染订单销售列表
  },
  methods: {
    // 同步
    // synchronization() {},

    // 查询按钮
    searchQuery() {
      // 渲染订单销售列表
    },
    searchReset() {
      // console.log('>>>>重置')
      this.queryParam = {}
      // 重新渲染生产进度表报
    },

    // 【销售订单号】 抽屉
    showDrawer(record) {
      return {
        on: {
          click: event => {
            console.log('点击了【销售订单号】--【单个订单报表】')
            this.$refs.singleOrderReportDrawer.visible = true
          }
        }
      }
    },

    // father 抽屉方法
    aa() {}

    // 分页、排序、筛选变化时触发
    // handleTableChange(pagination, filters, sorter) {
    //   // console.log('当前页信息>>>>',pagination)
    //   this.queryParam.pageNo = pagination.current
    //   // this.getOrderList()
    // }
  },
  computed: {},
  mounted() {}
}
</script>
<style lang="less" scoped>
@import '~@assets/less/common.less';
@import '~@assets/less/overwriter.less';
/deep/ .ant-table-thead > tr > th {
  text-align: center;
  // font-weight: 700;
}

/deep/ .ant-table-tbody {
  text-align: center;
}

// /deep/ th.replacecolor {
//   background-color: #ccc;
// }
</style>
