123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143 |
- <template>
- <a-modal
- centered
- class="common-modal"
- :footer="null"
- :maskClosable="false"
- :z-index="1001"
- v-model="isShow"
- :title="modalTit"
- :bodyStyle="{padding: modalTit?'25px 32px 20px':'50px 32px 15px'}"
- @cancel="handleCommonCancel"
- :width="416">
- <a-spin :spinning="spinning" tip="Loading...">
- <div class="common-main">
- <a-select v-model="printIndex" @change="changePrint" style="width: 100%" placeholder="选择打印机">
- <a-select-option v-for="item in printList" :key="'print-'+item.value" :value="item.value">
- {{ item.name }}
- </a-select-option>
- </a-select>
- </div>
- <div class="btn-box">
- <a-button type="default" style="margin-right:20px;" @click="handleCommonCancel" v-if="isCancel">{{ cancelText }}</a-button>
- <a-button type="primary" class="button-error" @click="handleCommonOk">{{ okText }}</a-button>
- </div>
- </a-spin>
- </a-modal>
- </template>
- <script>
- import { getPrintList, pdfPrint } from '@/libs/JGPrint'
- export default {
- name: 'CommonModal',
- props: {
- openModal: { // 弹框显示状态
- type: Boolean,
- default: false
- },
- modalTit: { // 弹框标题
- type: String,
- default: '请选择打印机'
- },
- modalHtml: {
- type: String,
- default: ''
- },
- okText: { // 确定 按钮文字
- type: String,
- default: '确定'
- },
- cancelText: { // 取消 按钮文字
- type: String,
- default: '取消'
- },
- isCancel: { // 是否显示 取消 按钮
- type: Boolean,
- default: true
- },
- spinning: { // 加载中
- type: Boolean,
- default: false
- }
- },
- data () {
- return {
- isShow: this.openModal, // 是否打开弹框
- printIndex: undefined,
- printList: []
- }
- },
- methods: {
- // 确定
- handleCommonOk () {
- if (this.printIndex >= 0) {
- // 关闭弹框
- this.$store.commit('SET_showSelectPrint', false)
- this.$emit('cancel')
- // 继续打印
- pdfPrint(this.$store.state.app.pdfPrintList)
- } else {
- this.$message.info('请选择打印机')
- }
- },
- // 取消
- handleCommonCancel () {
- this.$emit('cancel')
- this.$store.commit('SET_pdfPrintList', [])
- this.$store.commit('SET_showSelectPrint', false)
- },
- getPrintList () {
- this.printList = getPrintList()
- this.printIndex = this.$store.state.app.defaultPrint
- },
- changePrint (v) {
- this.$store.state.app.defaultPrint = v
- this.printIndex = v
- }
- },
- watch: {
- // 父页面传过来的弹框状态
- openModal (newValue, oldValue) {
- this.isShow = newValue
- },
- // 重定义的弹框状态
- isShow (newValue, oldValue) {
- if (!newValue) {
- this.$emit('close')
- } else {
- // 获取打印机列表
- this.getPrintList()
- }
- }
- }
- }
- </script>
- <style lang="less">
- .common-modal{
- .common-main{
- display: flex;
- line-height: 24px;
- .common-cont{
- .common-tit{
- color: rgba(0, 0, 0);
- font-weight: 500;
- font-size: 16px;
- line-height: 1.4;
- margin: 0;
- }
- .common-txt{
- margin: 8px 0 0;
- color: rgba(0, 0, 0);
- font-size: 14px;
- line-height: 1.5;
- }
- }
- }
- .btn-box{
- text-align: center;
- margin-top: 20px;
- }
- }
- </style>
|