<template>
  <div class="subPage">
    <div class="system-table-search">
      <div class="flex-h">
        <div class="flex-item flex-h">
          <el-button size="mini" type="danger">营业</el-button>
        </div>
      </div>
      <div class="moreFilter"></div>
    </div>
    <div class="order-list-box">
      <div v-for="(item,index) in list" :key="index">
        <div class="print-area" :class="'item' + index">
          <div style="padding:25px 20px 5px;border-bottom:2px solid #cccccc;">
            <i class="iconfont icon-yinchenglogo" style="font-size:70px;color:red;position: relative;bottom: 20px;margin-right:10px;"></i>
            <div style="display:inline-block;">
              <span style="display:block;font-size:20px;font-weight:700;">A区域1号桌</span>
              <span style="display:block;margin-top:10px">下单时间：21:30:39</span>
              <span style="display:block;margin-top:10px">已等待：<span style="color:red;font-weight:700;">30:29</span></span>
            </div>
          </div>
          <div style="padding:10px 20px 5px;border-bottom:1px solid #cccccc;">
            <div>卡布奇诺</div>
            <div style="margin-top:8px;">
              <span style="display:inline-block;width:75%;text-align:left;color:#cccccc">热</span>
              <span style="display:inline-block;width:20%;text-align:right">x 1</span>
            </div>
            <div style="margin-top:8px;">
              <span style="display:inline-block;width:75%;text-align:left;color:#cccccc">冷</span>
              <span style="display:inline-block;width:20%;text-align:right">x 2</span>
            </div>
          </div>
          <div style="padding:10px 20px 5px;border-bottom:1px solid #cccccc;">
            <div>卡布奇诺</div>
            <div style="margin-top:8px;">
              <span style="display:inline-block;width:75%;text-align:left;color:#cccccc">热</span>
              <span style="display:inline-block;width:20%;text-align:right">x 1</span>
            </div>
            <div style="margin-top:8px;">
              <span style="display:inline-block;width:75%;text-align:left;color:#cccccc">冷</span>
              <span style="display:inline-block;width:20%;text-align:right">x 2</span>
            </div>
          </div>
          <div style="padding:10px 20px 5px;border-bottom:1px solid #cccccc;">
            <div>卡布奇诺</div>
            <div style="margin-top:8px;">
              <span style="display:inline-block;width:75%;text-align:left;color:#cccccc">热</span>
              <span style="display:inline-block;width:20%;text-align:right">x 1</span>
            </div>
            <div style="margin-top:8px;">
              <span style="display:inline-block;width:75%;text-align:left;color:#cccccc">冷</span>
              <span style="display:inline-block;width:20%;text-align:right">x 2</span>
            </div>
          </div>
          <div style="padding:10px 20px 5px;border-bottom:1px solid #cccccc;">
            <div>卡布奇诺</div>
            <div style="margin-top:8px;">
              <span style="display:inline-block;width:75%;text-align:left;color:#cccccc">热</span>
              <span style="display:inline-block;width:20%;text-align:right">x 1</span>
            </div>
            <div style="margin-top:8px;">
              <span style="display:inline-block;width:75%;text-align:left;color:#cccccc">冷</span>
              <span style="display:inline-block;width:20%;text-align:right">x 2</span>
            </div>
          </div>
          <div style="padding:10px 20px;border-bottom:1px solid #cccccc">备注：请赶快制作</div>
          <div style="padding:10px 20px;">下单人：xxxxx</div>
        </div>
        <div class="btns">
          <span @click="cancel">取消</span>
          <span @click="submit(`item${index}`)">确定</span>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { getLodop } from '@/util/LodopFuncs'
const baseUrl = process.env.NODE_ENV === 'development' ? 'ws://192.168.0.148:8078/admin' : 'ws://cdkj.ycjcjy.com/admin' // 'ws://cdkj.ycjcjy.com/admin'
var LODOP
export default {
  name: '',
  data () {
    return {
      total: 0,
      postData: { // 表格搜索条件
        phone: '', // 手机号
        page: 1, // 当前页码
        pagesize: 10, // 请求数据量
      },
      currentList: [],
      list: [1, 2, 3, 4, 5]
    }
  },
  components: {
  },
  mounted () {

  },
  methods: {
    submit (cl) {
      this.printPdf(cl)
    },
    printPdf (cl) {
      this.CreateOneFormPage(cl)
      //        LODOP.PRINT();
      LODOP.PREVIEW()
    },
    CreateOneFormPage (cl) {
      LODOP = getLodop()
      LODOP.PRINT_INIT('订单')
      LODOP.SET_PRINT_PAGESIZE(0, document.getElementsByClassName(cl)[0].offsetWidth * 10 / 4 + 100, document.getElementsByClassName(cl)[0].offsetHeight * 10 / 4 + 120, 'CreateCustomPage')
      LODOP.ADD_PRINT_HTM(0, 0, document.getElementsByClassName(cl)[0].offsetWidth, document.getElementsByClassName(cl)[0].offsetHeight, document.getElementsByClassName(cl)[0].innerHTML)
    },
    cancel () {

    },
    initWebSocket (code) {
      const wsuri = `${baseUrl}/websocket/${code}`
      try {
        this.websock = new WebSocket(wsuri)
      } catch (e) {
        console.log(e)
      }
      this.websock.onmessage = this.websocketonmessage
      this.websock.onclose = this.websocketclose
    },
    websocketonmessage (e) {
      const redata = JSON.parse(e.data)
      if (redata.code === '1') {
        this.$toast({
          message: '核销成功',
          position: 'center',
          duration: 1000
        })
        setTimeout(() => {
          this.$router.go(-1)
        }, 1000)
      } else {
        // this.$toast({
        //   message: redata.message,
        //   position: 'center',
        //   duration: 1000
        // })
      }
    }
  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style lang="scss" scoped>
@import "page.scss";
</style>
