123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109 |
- <template>
- <div>
- <el-dialog :visible.sync="dialogTableVisible" :width="width + 'px'">
- <!--<vue-qr
- ref="qrCode"
- :text="qrUrl"
- :size="width"
- :correct-level="3"
- :margin="5"
- :callback="qrCodeCallback"
- />-->
- <div class="qrCode">
- <el-image :src="itemObj.qrCodeImage" style="width: 200px;" />
- <div class="btn">
- <el-button type="primary" @click="downLoad">下载</el-button>
- <el-button @click="dialogTableVisible = false">关闭</el-button>
- </div>
- </div>
- </el-dialog>
- </div>
- </template>
- <script>
- // import VueQr from 'vue-qr'
- import serviceMixin from '../../mixin/index'
- export default {
- components: {
- // VueQr
- },
- mixins: [serviceMixin],
- props: {
- showQrCode: {
- type: Boolean,
- default: () => false
- },
- width: {
- type: Number,
- default: () => 300
- },
- itemObj: {
- type: Object,
- default: () => ({})
- }
- },
- data() {
- return {
- dialogTableVisible: false,
- dataUrl: ''
- }
- },
- watch: {
- showQrCode(val) {
- if (val) {
- this.dialogTableVisible = true
- }
- },
- dialogTableVisible(val) {
- if (!val) {
- this.$emit('showQrCode')
- }
- }
- },
- methods: {
- // qrCodeCallback(val) {
- // console.log(val)
- // this.dataUrl = val
- // },
- downLoad() {
- this.$confirm('是否下载二维码?', '提示', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning'
- }).then(async() => {
- this.isLoading = true
- // 使用a链接下载
- const downUrl = `${process.env.VUE_APP_BASE_API}/providers/download/image?ids=${this.itemObj.id}&type=1`
- this.downloadWithUrl(downUrl, this.itemObj.name)
- .catch((err) => {
- console.log(err)
- this.$message.error(`下载${this.itemObj.name}二维码失败`)
- })
- .finally(() => {
- this.$message({
- message: '下载成功',
- type: 'success'
- })
- this.dialogTableVisible = false
- })
- })
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .qrCode {
- width: 100%;
- display: flex;
- flex-direction: column;
- align-items: center;
- .btn {
- width: 100%;
- display: flex;
- justify-content: space-around;
- margin-top: 30px;
- }
- }
- </style>
|