<template>
  <div class="app-container">

    <div class="filter-container">

      <el-input :size="sizeType" v-model="search.keyWord" placeholder="关键字" style="width: 200px;" class="filter-item"/>

      <el-button :size="sizeType" class="filter-item" type="primary" icon="el-icon-search" @click="searchData">
        搜索
      </el-button>
      <el-button :size="sizeType" type="warning" @click="combinedQuery = !combinedQuery">组合查询</el-button>
      <el-card class="box-card" v-if="combinedQuery">
        <el-form :size="sizeType" ref="searchForm" :model="searchForm">
          <el-row :gutter="20">
            <el-col :span="6">
              <el-form-item prop="orderCode">
                <el-input placeholder="订单编号" :size="sizeType" v-model="searchForm.orderCode"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item prop="printBillCode">
                <el-input placeholder="施工单号" :size="sizeType" v-model="searchForm.printBillCode"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item prop="clientCode">
                <el-input placeholder="客户编号" :size="sizeType" v-model="searchForm.clientCode"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item prop="clientName">
                <el-input placeholder="客户名称" :size="sizeType" v-model="searchForm.clientName"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item prop="orderName">
                <el-input placeholder="订单名称" :size="sizeType" v-model="searchForm.orderName"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item prop="orderCode">
                <el-date-picker
                  :size="sizeType"
                  v-model="searchTime"
                  type="daterange"
                  range-separator="-"
                  start-placeholder="开始日期"
                  end-placeholder="结束日期"
                  format="yyyy-MM-dd"
                  value-format="yyyy-MM-dd"
                  :default-time="['00:00:00', '23:59:59']">
                </el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item prop="createMan">
                <el-input placeholder="制单人" :size="sizeType" v-model="searchForm.createMan"></el-input>
              </el-form-item>
            </el-col>

            <!--                    <el-col :span='6'>物流货号</el-col>-->
          </el-row>
          <el-row :gutter="20" style="margin-bottom: 0px">
            <el-col :span="6">
              <el-form-item label="产品类型" prop="idProduct">
                <el-select v-model="searchForm.idProduct" :size="sizeType" filterable placeholder="产品类型" value-key="id">
                  <el-option
                    label="全部"
                    value="-1">
                  </el-option>
                  <el-option
                    v-for="item in productList"
                    :key="item.id"
                    :label="item.productName"
                    :value="item.id">
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="订单状态" prop="voidFlag">
                <el-select v-model="searchForm.voidFlag" :size="sizeType" filterable placeholder="订单状态" value-key="id">
                  <el-option
                    label="正常"
                    value="0">
                  </el-option>
                  <el-option
                    label="已作废"
                    value="1">
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="业务类型" prop="businessKind">
                <el-select
                  v-model="searchForm.businessKind"
                  :size="sizeType"
                  filterable
                  placeholder="业务类型"
                  value-key="id">
                  <el-option
                    label="全部"
                    value="-1">
                  </el-option>
                  <el-option
                    label="正常业务"
                    value="0">
                  </el-option>
                  <el-option
                    label="外协业务"
                    value="1">
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="订单类型" prop="orderType">
                <el-select v-model="searchForm.orderType" :size="sizeType" filterable placeholder="订单类型" value-key="id">
                  <el-option
                    label="全部"
                    value="-1">
                  </el-option>
                  <el-option
                    label="短版订单"
                    value="0">
                  </el-option>
                  <el-option
                    label="长版订单"
                    value="1">
                  </el-option>
                  <el-option
                    label="通货订单"
                    value="2">
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>
          <el-button
            style="margin-bottom: 10px;margin-right: 10px"
            type="primary"
            :size="sizeType"
            @click="combinedQueryBtn">搜索
          </el-button>
          <el-button style="margin-bottom: 10px" @click="resetForm('searchForm')" :size="sizeType">重置</el-button>
        </el-form>
      </el-card>
      <div class="top-right-btn">
        <el-tooltip class="item" effect="dark" content="刷新" placement="top">
          <el-button size="mini" circle icon="el-icon-refresh" @click="getList"/>
        </el-tooltip>
      </div>
      <el-table
        :data="tableData"
        v-loading="listLoading"
        row-key="id"
        border
        stripe
        :size="sizeType"
        style="margin-top: 10px"
        :row-class-name="rowClassName"
        :row-style="customRowStyle"
        @row-click="handleOrderClickTableRow"
        @sort-change="changeSort"
        :stripe="false"
        default-expand-all>
        <el-table-column fixed label="操作" align="left" width="80" class-name="small-padding fixed-width">
          <template slot-scope="{row}">
            <el-button
              title="编辑发货通知"
              @click="openNotices(row)"
              type="green"
              icon="el-icon-location-information"
              size="mini">
            </el-button>
          </template>
        </el-table-column>
        <el-table-column
          label="序号"
          fixed
          align="center"
          width="50"
          type="index">
          <template slot-scope="scope">
            <span>{{ (listData.page - 1) * listData.pageSize + scope.$index + 1 }}</span>
          </template>
        </el-table-column>
        <template v-for="column in columnnames">
          <el-table-column
            v-if="column.id == 3"
            :prop="column.field"
            :label="column.name"
            :width="column.width"
            sortable="custom"
            fixed
            show-overflow-tooltip>
            <template slot-scope="{row}">
              <a href="javascript:;" style="color: #20a0ff" @click="getOrderStep(row)">{{ row[column.field] }}
                <span v-if="row.businessKind==3" style="display: inline-block;color: red">(补{{ row.rePrintIndex}})</span>
                <el-image v-if="row.firstOrderFlag == 1" :src="new_badge"></el-image></a>
            </template>
          </el-table-column>
          <el-table-column
            v-else-if="column.id == 22"
            :prop="column.field"
            :label="column.name"
            :width="column.width"
            fixed
            show-overflow-tooltip>
            <template slot-scope="{row}">
              <a v-if="row.idProduct<=0" href="javascript:;" style="color: #20a0ff"
                 @click="openMaterialDetail(row)">{{ row[column.field] }}</a>
              <a v-else href="javascript:;" style="color: #20a0ff" @click="openDetail(row)">{{ row[column.field] }}</a>
            </template>
          </el-table-column>
          <el-table-column
            v-else-if="column.id == 2"
            :prop="column.field"
            :label="column.name"
            :width="column.width"
            sortable="custom"
            align="left"
            show-overflow-tooltip>
            <template slot-scope="{row}">
              <el-tag size="mini" v-if="row[column.field] == '待编辑'" type="info">{{ row[column.field] }}</el-tag>
              <el-tag size="mini" v-else-if="row[column.field] == '待审核'" type="success">{{ row[column.field] }}</el-tag>
              <el-tag size="mini" v-else-if="row[column.field] == '待组版'">{{ row[column.field] }}</el-tag>
              <el-tag size="mini" v-else-if="row[column.field] == '已组版'" type="danger">{{ row[column.field] }}</el-tag>
              <el-tag size="mini" v-else-if="row[column.field] == '生产中'" type="danger">{{ row[column.field] }}</el-tag>
              <el-tag size="mini" v-else-if="row[column.field] == '待入库'" type="green">{{ row[column.field] }}</el-tag>
              <el-tag size="mini" v-else-if="row[column.field] == '待发货'" >{{ row[column.field] }}</el-tag>
              <el-tag size="mini" v-else-if="row[column.field] == '已发货'" type="info">{{ row[column.field] }}</el-tag>
              <el-tag size="mini" v-else-if="row[column.field] == '文件待处理'" type="warning">{{ row[column.field] }}</el-tag>
              <el-button size="mini" class="button-new-tag" v-else>{{ row[column.field] }}</el-button>
            </template>
          </el-table-column>
          <el-table-column
            v-else-if="column.id == 6"
            header-align="center"
            :prop="column.field"
            :label="column.name"
            show-overflow-tooltip
            :width="column.width">
            <template slot-scope="{row}">
              <template v-if="row.orderMessage">
                <el-button size="mini" circle icon="el-icon-plus" @click="openMessage(row)"></el-button>
                <a href="javascript:;" style="color: #20a0ff" @click="openMessage(row)">{{ row.orderMessage }}</a>
              </template>
              <template v-else>
                <el-button size="mini" circle icon="el-icon-plus" @click="openMessage(row)"></el-button>
              </template>
            </template>
          </el-table-column>
          <el-table-column
            v-else-if="column.id == 11"
            header-align="center"
            :prop="column.field"
            :label="column.name"
            :width="column.width"
            show-overflow-tooltip
          >
            <template slot-scope="{row}">
              <el-link :href="row.originFileLink" target="_blank" style="color: #20a0ff">{{ row[column.field] }}
              </el-link>
            </template>
          </el-table-column>
          <el-table-column
            v-else-if="column.id == 12"
            align="center"
            header-align="center"
            :prop="column.field"
            :label="column.name"
            :width="column.width"
            sortable="custom"
          >
            <template slot-scope="{row}">
              <span v-if="row.createTime">{{ row.createTime | getTime }}</span>
            </template>
          </el-table-column>
          <el-table-column
            v-else-if="column.id == 1 || column.id == 8"
            :prop="column.field"
            :label="column.name"
            :width="column.width"
            sortable="custom"
            show-overflow-tooltip>
          </el-table-column>
          <el-table-column
            v-else
            :prop="column.field"
            :label="column.name"
            :width="column.width"
            show-overflow-tooltip>
          </el-table-column>
        </template>

      </el-table>
      <!--      <span>总计：</span>-->
      <pagination
        v-show="listData.total>0"
        :total="listData.total"
        :page.sync="listData.page"
        :limit.sync="listData.pageSize"
        @pagination="getList"/>

      <el-card class="box-card">
        <div slot="header" class="clearfix">
          <span style="size: 20px">发货通知</span>
        </div>
        <div style="position: relative">
          <el-table
            :data="deliveryTableData"
            v-loading="deliveryListLoading"
            :size="sizeType"
            ref="deliveryItemTable"
            row-key="id"
            border
            style="margin-bottom: 20px">
            <template v-for="column in deliveryColumns">

              <el-table-column
                v-if="column.label =='状态'"
                :key="column.field"
                :prop="column.field"
                :label="column.label"
                :width="column.width"
                show-overflow-tooltip>
                <template slot-scope="{row}">
                  <template v-if="row.voidFlag == 1">
                    <el-tag size="mini" type="info">已作废</el-tag>
                  </template>
                  <template v-else>
                  <el-tag size="mini" v-if="row[column.field] == '0'" type="warning">待入库</el-tag>
                  <el-tag size="mini" v-if="row[column.field] == '1'">待发货</el-tag>
                  <el-tag size="mini" v-if="row[column.field] == '2'" type="success">已发货</el-tag>
                  </template>
                </template>
              </el-table-column>
              <el-table-column
                v-else
                :key="column.field"
                :prop="column.field"
                :label="column.label"
                :width="column.width"
                show-overflow-tooltip>
              </el-table-column>
            </template>
          </el-table>
        </div>
      </el-card>


    </div>
    <cancledialog @tableRefresh="tableRefresh" ref="confirmDialog"></cancledialog>
    <el-dialog title="编辑发货通知" :close-on-click-modal="false" :visible.sync="noticeVisible" width="1200px" class="addressDialog">
      <delivery-notice ref="deliveryNotice"></delivery-notice>
    </el-dialog>
    <order-step ref="orderStep"></order-step>
    <el-drawer
      title="订单消息"
      :reverse="true"
      :visible.sync="memoDrawer"
      size="600px">
      <order-message ref="orderMessage"></order-message>
    </el-drawer>

    <el-dialog title="订单详情" :close-on-click-modal="false" class="orderDetailDialog" :visible.sync="detailVisible" top="10px" width="1200px">
      <order-detail ref="orderDetail"></order-detail>
    </el-dialog>
    <material-detail ref="materialDetail"></material-detail>
  </div>
</template>

<script>
import {
  addOrderDeliverInform,
  cancelOrderPayRequest,
  deleteOrderDeliverInform,
  editOrderDeliverInform,
  getOrderDeliverInform,
  getOrderList,
  getOrderReceivableByOrder,
  getPaymentBillByOrder,
  getshipAreaListInfo,
  getshipModeListInfo,
  getSimpleProductInfoList,
  orderPayRequest,
  orderPayRequest3,
  reOrderPayRequest,
  voidPrintOrder
} from '@/api/order/orderList.js'
import Cancledialog from '@/components/Dialog/Cancledialog.vue'
import productInfo from '@/views/productFile/product/productInfo'
import clientInfo from '@/views/doc/client/clientList'
import Kanban from '@/components/Kanban'
import OrderMessage from '@/components/orderMessage/orderMessage'
import plupload from '@/components/plupload/plupload.vue'
import Addressdny from '@/components/Dialog/Addressdny'
import {CodeToText, regionData, TextToCode} from 'element-china-area-data'
import OrderDetail from '@/components/orderDetail/orderDetail'
import {doLocalPrint} from '@/utils'
import {getConfigInfo} from '@/api/system/config'
import OrderStep from '@/components/orderStep/orderStep'
import {getLogisticsInfoList} from "@/api/order/orderDetail";
import DeliveryNotice from "@/components/deliveryNotice/deliveryNotice";
import {getWaitSendPrintOrderList} from "@/api/order/tobeShipped";
import new_badge from '@/assets/new_badge.gif'
import MaterialDetail from "@/components/materialDetail/materialDetail";

const searchForm = {
  orderCode: '',
  printBillCode: '',
  clientCode: '',
  clientName: '',
  orderName: '',
  beginTime: '',
  endTime: '',
  createMan: '',
  idProduct: '-1',
  voidFlag: '0',
  businessKind: '-1',
  orderType: '-1'
}
const defaultItems = [
  {
    name: '订单编号', id: 3, field: 'orderCode', width: '132px'
  },
  {
    name: '印品名称', id: 22, field: 'orderName', width: '180px'
  },
  {
    name: '库存数量', id: 10, field: 'stockQty', width: ''
  },
  {
    name: '已入库总包数', id: 23, field: 'inStockBoxCount', width: ''
  },
  {
    name: '未发货包数', id: 24, field: 'waitSendBoxCount', width: ''
  },
  {
    name: '产品类型', id: 1, field: 'productName', width: '130px'
  },
  {
    name: '制单时间', id: 12, field: 'createTime', width: '160'
  },
  {
    name: '订单状态', id: 2, field: 'stateMemo', width: ''
  },
  // {
  //   name: '应收单号', id: 4, field: 'financeCode', width: '125px'
  // },
  {
    name: '施工单号', id: 5, field: 'printBillCode', width: '125px'
  }, {
    name: '订单消息', id: 6, field: 'orderMessage', width: '170'
  }, {
    name: '客户编码', id: 7, field: 'clientCode', width: '100'
  }, {
    name: '客户名称', id: 8, field: 'clientName', width: '120'
  },
  // {
  // name: '客户级别', id: 9, field: 'clientLevel', width: ''
  // },
  {
    name: '文件描述', id: 11, field: 'fileDescription', width: '190px'
  }, {
    name: '制单人', id: 13, field: 'createMan', width: '75'
  },
  {
    name: '订单印量', id: 14, field: 'orderQty', width: '120'
  },
  // {
  //   name: '成品规格', id: 15, field: 'productSize', width: '125px '
  // },
  {
    name: '定金', id: 16, field: 'orderMoneyPre', width: '100'
  }, {
    name: '总金额', id: 17, field: 'orderMoneyTotal', width: '120'
  }, {
    name: '已收金额', id: 18, field: 'payMoney', width: '120'
  },
  // {
  //   name: '提成比例', id: 19, field: '', width: ''
  // },
  {
    name: '平台单号', id: 20, field: 'platformOrderID', width: '220px'
  },
  {
    name: 'p数', id: 21, field: 'pageQty', width: ''
  }
]

const deliveryItems = [
  {
    label: '状态', field: 'sendState', width: '100'
  },
  {
    label: '联系人', field: 'linkMan', width: '100'
  },
  {
    label: '联系电话', field: 'linkPhone', width: '120'
  },
  {
    label: '发货方式', field: 'sendKind', width: '130'
  },
  {
    label: '发货数量', field: 'needDeliverQty', width: '100'
  },
  {
    label: '发货地址省', field: 'sendProvince', width: '80'
  },
  {
    label: '发货地址市', field: 'sendCity', width: '80'
  },
  {
    label: '发货地址区', field: 'sendDistrict', width: '90'
  },
  {
    label: '详细地址', field: 'sendAddress', width: ''
  }
]

const createInfo = {
  idProduct: '',
  productName: '',
  clientName: '',
  idClient: '',
  orderName: '',
  orderType: 0,
  businessKind: 0
}

var STORAGE_KEY = 'column'
var columnStorage = {
  fetch() {
    var list = JSON.parse(localStorage.getItem(STORAGE_KEY) || '[]')
    list.forEach((item, index) => {
      item.id = index
    })
    columnStorage.uid = list.length
    return list
  },
  save(list) {
    localStorage.setItem(STORAGE_KEY, JSON.stringify(list))
  }
}
export default {
  name: 'TobeShipped',
  components: {
    MaterialDetail,
    DeliveryNotice,
    OrderStep,
    OrderDetail,
    OrderMessage,
    Cancledialog, Kanban, productInfo, clientInfo, plupload, Addressdny
  },
  data() {
    return {
      rowId:"",
      new_badge: new_badge,
      rowIndex:"",
      sizeType: 'mini',
      orderByString: '', // 排序
      detailVisible: false,
      voidVisible: false,
      drawer: false,
      timeString: '',
      memoDrawer: false,
      noticeVisible: false, // 编辑发货通知弹窗
      dialogStatus: 1, // 1增加，2修改
      dialogTitle: '',
      dialogVisible: false,
      queryType: 1, // 1模糊搜索，2组合搜索
      searchTime: [],
      search: {
        keyWord: '',
        searchOrderToDeliver: 2
      },
      combinedQuery: false,
      searchForm: Object.assign({}, searchForm),

      balanceLimit: '',
      balance: {
        clientId: '',
        debtFlag: 0,
        balacneLimit: '',
        debtTime: '',
        activePassword: ''
      },
      options: [],
      productList: [],
      columnSelect: '',
      defaultColumnName: columnStorage.fetch(),
      columnnames: Object.assign([], defaultItems), // 选中的列名
      defaultItem: Object.assign([], defaultItems), // 默认列

      deliveryColumns: Object.assign([], deliveryItems),
      deliveryTableData: [],
      deliveryListLoading: false,

      tableItem: [], // 选中列
      group: 'col',
      columnVisible: false,
      columnList: {
        name: '',
        columnItem: []

      },

      listData: {
        total: 0,
        page: 1,
        pageSize: 10
      },

      confirmdialog: false,
      listLoading: false,
      tableData: [],

      /* 创建订单弹窗 */
      createOrderVisible: false,
      createInnerVisible: false,
      innerTitle: '',
      innerType: 1,
      createInfo: Object.assign({}, createInfo), // 创建信息
      orderCategory: 1,
      stepList: [],

      sMemo: '',
      voidId: '',

      pluploadVisible: false,
      showUpload: true,
      files: [],
      upIdOrder: '',
      upOrderCode: '',

      // 发货信息
      sendAddressList: [],
      sendAddressListBySend: [],
      sendAddressListByDisable: [],
      // 省市区选项
      addressOption: [],
      // 发货方式
      sendKinds: [],
      // 发货区域
      shipAreaList: [],
      option: regionData,
      addressDialogInfo: {
        orderState: '',
        boxCount: ''
      },
      activeTabName: 'first',

      // 订单收款
      orderPayVisible: false,
      orderPayInfo: {
        orderInfo: {},
        orderReceivableList: [],
        receivableMoney: ''
      },
      // 支付单
      paymentBillVisible: false,
      paymentBillList: [],
      orderPayListData: {
        total: 0,
        page: 1,
        pageSize: 10
      },

      // 验证规则
      rules: {
        productName: [{required: true, trigger: 'blur', message: '请选择产品类型'}],
        clientName: [{required: true, trigger: 'blur', message: '请选择客户'}]
      }
    }
  },
  watch: {
    defaultColumnName(val) {
      columnStorage.save(val)
    },
    memoDrawer(val) {
      // console.log(val)
      if (!val) {
        this.getList()
      }
    }
  },
  mounted() {
    this.getList()
    this.getAreaList()
    this.getSendKind()
    this.getProductInfo()
    this.getConfig('FileUploadServerIp')
    this.getConfig('OrderShareRoot')
  },
  created() {
    // window.clickImg = this.clickImg
  },
  methods: {
    /**
     * 显示字符串中间加星号
     */
    plusXing(str, frontLen, endLen) {
      // var len = str.length - frontLen - endLen
      var xing = ''
      for (var i = 0; i < 6; i++) {
        xing += '*'
      }
      return str.substr(0, frontLen) + xing + str.substr(str.length - endLen)
    },
    // 排序
    changeSort(val) {
      // console.log(val)
      var _that = this
      if (val.order == 'ascending') {
        _that.orderByString = val.prop + ',' + 'asc'
      } else if (val.order == 'descending') {
        _that.orderByString = val.prop + ',' + 'desc'
      } else {
        _that.orderByString = ''
      }
      _that.getList()
    },
    // 获取客户列表
    getList() {
      const _that = this
      _that.listLoading = true
      if (_that.searchTime == null || _that.searchTime < 0) {
        _that.searchForm.beginTime = ''
        _that.searchForm.endTime = ''
      } else {
        _that.searchForm.beginTime = _that.searchTime[0]
        _that.searchForm.endTime = _that.searchTime[1]
      }
      // if (_that.search.keyWord != '') {
      //   if (_that.searchTime == null || _that.searchTime < 0) {
      //     _that.$message.error('请选择时间')
      //     return
      //   }
      // }
      // if (_that.listData.pageSize == 10) {
      //   _that.sizeType = 'medium'
      // } else {
      //   _that.sizeType = 'mini'
      // }
      var params
      if (_that.queryType == 1) {
        params = _that.search
      } else {
        params = _that.searchForm
      }
      var orderBy = _that.orderByString
      var page = {
        pageIndex: _that.listData.page,
        pageSize: _that.listData.pageSize
      }
      var data = {
        'params': JSON.stringify(params),
        'orderBy': orderBy,
        'page': JSON.stringify(page)
      }
      // console.log(data)
      // return;
      getWaitSendPrintOrderList(data).then(response => {
        // console.log(response)
        const data = response.data
        // //  组合表单数据
        _that.tableData = data
        _that.listData.total = response.total
        // console.log(_that.tableData)
        _that.listLoading = false
      }).catch(err => {
        _that.$message.error(err)
        _that.listLoading = false
      })
    },

    // 获取产品列表
    getProductInfo() {
      const _that = this
      var data = {}
      // console.log(data);
      getSimpleProductInfoList(data).then(response => {
        // console.log(response)
        const data = response.data
        _that.productList = data
      }).catch(err => {
        _that.$message.error(err)
      })
    },

    productInfoChange(val) {
      // console.log(val)
      this.createInfo.idProduct = val.id
      this.createInfo.productName = val.productName
    },

    // 获取脚印
    getOrderStep(row) {
      const _that = this
      _that.$refs.orderStep.idOrder = row.id
      _that.$refs.orderStep.getOrderStep()
    },

    // 刷新变革
    tableRefresh() {
      // 刷新变革
      this.getList()
    },
    // 搜索
    searchData() {
      this.queryType = 1
      this.listData.page = 1
      this.getList()
      this.combinedQuery = false
    },
    combinedQueryBtn() {
      this.queryType = 2
      this.listData.page = 1
      this.getList()
    },
    resetForm(formName) {
      this.$refs[formName].resetFields()
      this.searchTime = []
    },

    // 选择产品
    chooseProduct(data) {
      this.createInnerVisible = false
      // console.log(data);
      this.createInfo.productName = data.productName
      this.createInfo.idProduct = data.id
    },
    // 选择客户
    chooseClient(data) {
      this.createInnerVisible = false
      // console.log(data);
      this.createInfo.clientName = data.clientName
      this.createInfo.idClient = data.id
    },


    openDetail(row) {
      var _that = this
      _that.detailVisible = true
      _that.$nextTick(() => {
        _that.$refs.orderDetail.idOrder = row.id
        _that.$refs.orderDetail.getInfo()
      })
    },
    openMaterialDetail(row) {
      const _that = this
      // _that.timer = new Date().getTime()
      _that.$nextTick(function () {
        _that.$refs.materialDetail.materialDialog = true
        _that.$refs.materialDetail.seeFlag = true
        _that.$refs.materialDetail.idOrder = row.id
        _that.$refs.materialDetail.getOrderInfo()
      })
    },
    // 编辑发货通知
    openNotices(row) {
      const _that = this;
      _that.noticeVisible = true;
      // console.log(row.idClient);
      // console.log(_that.$refs.deliveryNotice);
      _that.$nextTick(function () {
        _that.$refs.deliveryNotice.currentIdClient = row.idClient;
        _that.$refs.deliveryNotice.currentIdOrder = row.id;
        _that.$refs.deliveryNotice.inStockBoxCount = row.inStockBoxCount;
        _that.$refs.deliveryNotice.waitSendBoxCount = row.waitSendBoxCount;
        _that.$refs.deliveryNotice.addressDialogInfo.orderState = row.stateMemo;
        _that.$refs.deliveryNotice.openNotices();
      })


    },
    handleOrderClickTableRow(row, column, event) {
      this.rowIndex = row.index;
      if(row.rowClick==false){
        return
      }
      this.getTableDeliverInform(row);


    },
    getTableDeliverInform(row) {
      const _that = this;
      // console.log("999",row);
      const data = {
        idOrder: row.id,
        available: true
      };
      getOrderDeliverInform(data).then(response => {
        const data = response.data

        _that.deliveryTableData = data;

        for (let i = 0; i < _that.tableData.length; i++) {
          var datas = _that.tableData[i];
          if(row.id==datas.id){
            _that.$set(datas, 'rowClick', false);
          }else {
            _that.$set(datas, 'rowClick', true);
          }
        }

      }).catch(err => {
      })
    },

    // 获取发货方式
    getSendKind() {
      var _that = this
      getshipModeListInfo().then(response => {
        // console.log('getSendKind', response)
        _that.sendKinds = response.data
      }).catch(err => {
        console.log(err)
      })
    },

    // 获取物流档案
    getLogisticsInfo() {
      var _that = this
      var data = {
        params: {
          enable: 1
        }
      }
      getLogisticsInfoList(data).then(response => {
        // console.log('getSendKind', response)
        _that.sendKinds = response.data
      }).catch(err => {
        // console.log(err)
      })
    },
    // 获取发货区域
    getAreaList() {
      var _that = this
      getshipAreaListInfo().then(response => {
        // console.log('shipArea', response)
        const data = response.data
        // //  组合表单数据
        _that.shipAreaList = response.data
      }).catch(err => {
        console.log(err)
      })
    },

    // 获取配置信息
    getConfig(key) {
      const _that = this
      const data = {
        configKey: key
      }
      // console.log(data);
      getConfigInfo(data).then(res => {
        // console.log(res)
        if (key == 'FileUploadServerIp') {
          _that.configValue1 = res.data.configValue1
        } else if (key == 'OrderShareRoot') {
          _that.configValue2 = res.data.configValue1
        }
      }).catch(err => {
        _that.$message.error(err)
      })
    },

    // 订单消息
    openMessage(row) {
      var _that = this
      _that.memoDrawer = true
      _that.$nextTick(function () {
        // console.log(_that.$refs.orderMemo);
        _that.$refs.orderMessage.idOrder = row.id
        _that.$refs.orderMessage.getList()
      })
    },


    customRowStyle({row, rowIndex}) {
      if (row.orderDeliveryInfoCount === 0) {
        return {
          // color: '#F56C6C'
          background: '#f7b1b1'
        }
      }
      if (this.rowIndex === rowIndex) {
        return {
          'background-color': '#8cc5ff !important',
          'color': '#fff !important',
        }
      }
    },
    rowClassName ({ row, rowIndex }) {
      row.index = rowIndex
    },
    // 批量下单
    delphiWin() {
      // alert('delphi弹窗')
      var _that = this
      var userAgent = navigator.userAgent
      // console.log(_that.item)
      if (userAgent.indexOf('DnyERPBrowser') > 0) {
        var data = {
          package: 'dyMultiplePrintOrder',
          runParam: 'Form:Show:TfrmMultiplePrintOrder@1',
          menuName: '批量下单'
        }
        dyERP.sendRunForm(JSON.stringify(data))
      } else {
        // alert('请使用开发商提供的ERP客户端')
        _that.$message({
          message: '请使用开发商提供的ERP客户端',
          type: 'warning'
        })
      }
    }
  }
}
</script>
<style>
/*1.显示滚动条：当内容超出容器的时候，可以拖动：*/
.el-drawer__body {
  overflow: auto;
}

.stepList .el-card__body {
  padding: 10px;
}

:focus {
  outline: 0;
}
.el-table tbody tr:hover>td {
  background-color:transparent !important;
}
/*// 如果td没有颜色，可以去掉，这里加上保险*/
.el-table__body tr.hover-row>td {
     background-color: transparent !important;
 }
</style>

<style lang="scss" scoped>
.app-container {
  ::v-deep .el-card__header {
    padding: 5px 15px !important;
    font-size: 14px !important;
  }
}

.filter-container {
  margin-bottom: 15px;
}

.board-column {
  min-width: 100px;
  min-height: 100px;
  height: auto;
  overflow: hidden;
  background: #f0f0f0;
  border-radius: 3px;

  .board-column-header {
    height: 50px;
    line-height: 50px;
    overflow: hidden;
    padding: 0 20px;
    text-align: center;
    background: #333;
    color: #fff;
    border-radius: 3px 3px 0 0;
  }

  .board-column-content {
    height: auto;
    overflow: hidden;
    border: 10px solid transparent;
    min-height: 60px;
    display: flex;
    justify-content: flex-start;
    flex-direction: column;
    align-items: center;

    .board-item {
      cursor: pointer;
      width: 100%;
      height: 64px;
      margin: 5px 0;
      background-color: #fff;
      text-align: left;
      line-height: 54px;
      padding: 5px 10px;
      box-sizing: border-box;
      box-shadow: 0px 1px 3px 0 rgba(0, 0, 0, 0.2);
    }
  }
}

.button-new-tag {
  display: inline-block;
  font-size: 12px;
  box-sizing: border-box;
  white-space: nowrap;
  padding: 0 5px;
  height: 20px;
  line-height: 19px;
}

.box-card {
  margin-top: 10px;

  ::v-deep .el-card__body {
    padding-bottom: 0;
  }
}

.orderPayDialog {
  .infoItem {
    display: inline-block;
    margin-right: 20px;
  }
}

.addressDialog {
  // 鼠标滑过td上作用的样式，ie6不支持:hover伪类属性，如果是ie6要写成tr.over样式
  ::v-deep .el-table tbody tr:hover>td {
    background-color:transparent !important;
  }
  // 如果td没有颜色，可以去掉，这里加上保险
  ::v-deep .el-table__body tr.hover-row>td {
    background-color: transparent !important;
  }
}
</style>
