<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 style='position:relative;' v-for="(item,index) in list" :key="index">
        <div>
          <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;border-bottom:1px solid #cccccc">备注：请赶快制作</div>
          <div style="padding:10px 20px;">下单人：xxxxx</div>
        </div>
        <div class="print-area" :class="'item' + index" style="width:180px;">
          <div style="padding:25px 20px 5px;border-bottom:2px solid #cccccc;">
            <div style="display:inline-block;">
              <img class="topIcon" style="display:block;width:60%;margin:0 0 20px 10px;" src="http://jingcheng-resourceplat.oss-cn-shanghai.aliyuncs.com/upload/111101940020.png" alt="">
              <span style="display:block;font-size:20px;font-weight:700;"> <img width='25px' height="25px" src="http://jingcheng-resourceplat.oss-cn-shanghai.aliyuncs.com/upload/111101940020.png" alt=""> A区域1号桌</span>
              <span style="display:block;margin-top:10px;font-size:12px;">下单时间：21:30:39</span>
              <span style="display:block;margin-top:10px;font-size:12px;">已等待：<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;font-size:12px;">热</span>
              <span style="display:inline-block;width:20%;text-align:right;font-size:12px;">x 1</span>
            </div>
            <div style="margin-top:8px;">
              <span style="display:inline-block;width:75%;text-align:left;color:#cccccc;font-size:12px;">冷</span>
              <span style="display:inline-block;width:20%;text-align:right;font-size:12px;">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 { createNamespacedHelpers, mapState } from 'vuex'

import { getLodop } from '@/util/LodopFuncs'

const { mapState: mapOrderState, mapActions: mapOrderActions } = createNamespacedHelpers('goodsorder')

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]
    }
  },
  components: {
    ...mapOrderState({
      orders: x => x.ordersList
    }),
    ...mapState({
      cases: x => x.app.cases.list,
      defaultCaseId: x => x.app.cases.default
    })
  },
  mounted () {
    this.GetOrdersList()
  },
  methods: {
    ...mapOrderActions([
      'GetOrdersList',
    ]),
    submit (cl) {
      this.$confirm('确定完成此饮品?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then((res) => {
        // this.printPdf(cl)
      }).catch((res) => {
        this.$message({
          type: 'info',
          message: '已取消'
        })
      })
    },
    printPdf (cl) {
      this.CreateOneFormPage(cl)
      LODOP.PRINT()
      // LODOP.PREVIEW()
    },
    CreateOneFormPage (cl) {
      LODOP = getLodop()
      LODOP.PRINT_INIT('订单')
      LODOP.SET_PRINT_PAGESIZE(3, 480, 40, '')
      LODOP.ADD_PRINT_HTM(0, 0, document.getElementsByClassName(cl)[0].offsetWidth, document.getElementsByClassName(cl)[0].offsetHeight, document.getElementsByClassName(cl)[0].innerHTML)
    },
    cancel () {
      this.$confirm('确定取消此饮品?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then((res) => {
        // this.cancel()
      }).catch((res) => {
        this.$message({
          type: 'info',
          message: '已取消'
        })
      })
    },
    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)
    }
  }
}
</script>

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