<template>
  <el-dialog
    :title="option.title != null ? option.title : $t2('拼多多打印', 'components.pddPrint.title')"
    :visible.sync="showWrap"
    :close-on-click-modal="false"
    width="411px"
    custom-class="dialog-style"
    :append-to-body="true"
    v-el-drag-dialog
    v-el-dialog-center
    @close="dialogClose"
  >
    <div class="print-box">
      <div class="tips">
        <i class="el-icon-warning-outline"></i>
        {{ $t2('请先下载打印控件', 'components.pddPrint.tip') }}
        <el-button class="button-sty fr" type="warning" plain @click="download" icon="el-icon-download">
          {{ $t2('打印控件下载', 'components.pddPrint.downloadBUtton') }}
        </el-button>
      </div>
      <div class="cont">
        <div class="oper">
          <template v-if="isSocketOpen">
            <!-- <el-button @click="getPrints" class="button-sty" type="primary" icon="el-icon-mouse">选择打印机</el-button> -->
            <el-select v-model="printerVal" v-if="printerList.length > 0"
                       :placeholder="$t2('选择打印机', 'components.pddPrint.selectPlaceholder')" clearable>
              <el-option v-for="(item, index) in printerList" :key="index" :value="item.name" :label="item.name"></el-option>
            </el-select>
<!--            <el-button @click="selectPrint(true)" class="button-sty" type="primary" icon="el-icon-view">
              {{ $t2('预览', 'components.pddPrint.preview') }}
            </el-button>-->
            <el-button @click="selectPrint(false)" class="button-sty" type="success" icon="el-icon-printer">
              {{ $t2('打印', 'components.pddPrint.print') }}
            </el-button>
          </template>
          <el-button @click="openWebSocket" v-if="!isSocketOpen" class="button-sty" type="primary"
                     icon="el-icon-video-play">{{ $t2('启动', 'components.pddPrint.start') }}
          </el-button>
        </div>
        <!-- <div class="return-msg"><pre>返回的信息</pre></div> -->
      </div>
    </div>
  </el-dialog>
</template>

<script>
import mixins from './mixins.js'

export default {
  name: 'cnprint',
  mixins: [mixins]
}
</script>
<style scoped></style>
