|
|
@@ -87,35 +87,23 @@
|
|
|
</el-row>
|
|
|
<Doctor ref="AddDoctor" title="添加" @formSuccess="getData" />
|
|
|
<Doctor ref="EditDoctor" title="编辑" @formSuccess="getData" />
|
|
|
- <qrcode ref="qrcode" />
|
|
|
- <div id="qrcode" ref="qrcodeModal" style="position:fixed;top:-9999px;" />
|
|
|
+ <QrCode ref="Qrcode" />
|
|
|
<MiniProgramTargetConfig ref="MiniTargetConfig" :target-type="targetType" @formSuccess="getData" />
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import QRCode from 'qrcodejs2'
|
|
|
-import html2canvas from 'html2canvas'
|
|
|
-import JSZip from 'jszip'
|
|
|
-import saveAs from 'file-saver'
|
|
|
-
|
|
|
import Doctor from './components/Doctor'
|
|
|
import Pagination from '@/components/Pagination'
|
|
|
-import qrcodeComponents from '@/views/hos/components/qrcode.vue'
|
|
|
-import MiniProgramTargetConfig from '@/components/MiniProgramTargetConfig/index.vue'
|
|
|
+import { MiniProgramTargetConfig, QrCode } from '@/components'
|
|
|
import { getDoctorByPage, deleteDoctorById } from '@/api/hos/doctorApi'
|
|
|
-
|
|
|
-import { getSettingById } from '@/api/system/settingApi'
|
|
|
-import { getUserData } from '@/utils/auth'
|
|
|
-
|
|
|
-let zip = new JSZip()
|
|
|
export default {
|
|
|
name: 'DoctorIndex',
|
|
|
components: {
|
|
|
Pagination,
|
|
|
Doctor,
|
|
|
MiniProgramTargetConfig,
|
|
|
- qrcode: qrcodeComponents
|
|
|
+ QrCode
|
|
|
},
|
|
|
filters: {
|
|
|
doctorProfessionalIdFilter(val) {
|
|
|
@@ -134,34 +122,16 @@ export default {
|
|
|
limit: 10,
|
|
|
keywords: ''
|
|
|
},
|
|
|
- ocId: undefined,
|
|
|
- miniUrl: '',
|
|
|
exportItems: []
|
|
|
}
|
|
|
},
|
|
|
|
|
|
mounted() {
|
|
|
- const userData = getUserData()
|
|
|
- this.ocId = userData.ocId
|
|
|
- this.getMiniUrl()
|
|
|
this.getData()
|
|
|
},
|
|
|
|
|
|
methods: {
|
|
|
|
|
|
- // 获取小程序地址
|
|
|
- getMiniUrl() {
|
|
|
- const settingId = 1
|
|
|
- this.listLoading = true
|
|
|
- getSettingById(settingId).then((resp) => {
|
|
|
- const { data } = resp
|
|
|
- this.listLoading = false
|
|
|
- this.miniUrl = data.settingValue
|
|
|
- }).catch((error) => {
|
|
|
- console.log(error)
|
|
|
- })
|
|
|
- },
|
|
|
-
|
|
|
// 初始化数据
|
|
|
getData() {
|
|
|
this.listLoading = true
|
|
|
@@ -205,85 +175,31 @@ export default {
|
|
|
this.$message({ type: 'info', message: '已取消删除' })
|
|
|
})
|
|
|
},
|
|
|
+
|
|
|
+ // 多选
|
|
|
changeSelection(selection) {
|
|
|
const len = selection.length
|
|
|
this.hanleModal = (len > 0)
|
|
|
this.exportItems = selection
|
|
|
},
|
|
|
+
|
|
|
+ // 显示二维码
|
|
|
showQrcode(row) {
|
|
|
- const code = this.miniUrl + '?ocId=' + this.ocId + '&code=' + row.doctorCode
|
|
|
- this.$refs.qrcode.draw(code)
|
|
|
+ const code = row.doctorCode
|
|
|
+ this.$refs.Qrcode.draw(code)
|
|
|
},
|
|
|
+
|
|
|
+ // 下载二维码
|
|
|
downloadQrcode() {
|
|
|
if (this.exportItems && this.exportItems.length > 0) {
|
|
|
- var content = JSON.parse(JSON.stringify(this.exportItems))
|
|
|
- this.downloadMaterial(content)
|
|
|
+ const arrData = []
|
|
|
+ for (let i = 0; i < this.exportItems.length; i++) {
|
|
|
+ const item = this.exportItems[i]
|
|
|
+ arrData.push({ type: 5, code: item.doctorCode, title: item.doctorName })
|
|
|
+ }
|
|
|
+ this.$refs.Qrcode.download(arrData, '医生')
|
|
|
} else { this.$message.error('没有可下载的数据!') }
|
|
|
},
|
|
|
- downloadMaterial(content) { // 下载物料
|
|
|
- this.batch(content, '医生管理')
|
|
|
- },
|
|
|
- async batch(arr, fileName) {
|
|
|
- var self = this
|
|
|
- window.loading = this.$loading({
|
|
|
- lock: true,
|
|
|
- text: '制作二维码中!',
|
|
|
- spinner: 'el-icon-loading',
|
|
|
- background: 'rgba(0, 0, 0, 0.7)'
|
|
|
- })
|
|
|
-
|
|
|
- zip = new JSZip()
|
|
|
- for (var i = 0; i < arr.length; i++) {
|
|
|
- var item = arr[i]
|
|
|
- const code = this.miniUrl + '?ocId=' + this.ocId + '&code=' + item.doctorCode
|
|
|
- await self.drawQrcode(code).catch(() => {
|
|
|
- window.loading.close()
|
|
|
- this.$message.error('导出失败')
|
|
|
- })
|
|
|
- await self.packMaterial(item.doctorName).catch(() => {
|
|
|
- window.loading.close()
|
|
|
- this.$message.error('导出失败')
|
|
|
- })
|
|
|
- }
|
|
|
- zip.generateAsync({
|
|
|
- type: 'blob'
|
|
|
- }).then((blob) => {
|
|
|
- saveAs(blob, fileName + '二维码物料.zip')
|
|
|
- window.loading.close()
|
|
|
- })
|
|
|
- },
|
|
|
- drawQrcode(url, sleep = 300) { // 绘制二维码
|
|
|
- this.$refs.qrcodeModal.innerHTML = ''
|
|
|
- return new Promise((resolve, reject) => {
|
|
|
- new QRCode('qrcode', {
|
|
|
- width: 400,
|
|
|
- height: 400,
|
|
|
- text: url.toString()
|
|
|
- })
|
|
|
- setTimeout(function() {
|
|
|
- resolve()
|
|
|
- }, sleep)
|
|
|
- })
|
|
|
- },
|
|
|
-
|
|
|
- packMaterial(name) { // 打包处理
|
|
|
- if (!name) name = 'xxx'
|
|
|
- return new Promise((resolve, reject) => {
|
|
|
- html2canvas(document.getElementById('qrcode'), {
|
|
|
- backgroundColor: null,
|
|
|
- useCORS: true,
|
|
|
- dpi: 500,
|
|
|
- scale: 5
|
|
|
- }).then((canvas) => {
|
|
|
- let dataURL = canvas.toDataURL('photo/png')
|
|
|
- dataURL = dataURL.replace(/^data:image\/(png|jpg);base64,/, '')
|
|
|
- zip.file(name + '.jpg', dataURL, { base64: true })
|
|
|
- resolve()
|
|
|
- }).catch((e) => {
|
|
|
- reject(e)
|
|
|
- })
|
|
|
- })
|
|
|
- },
|
|
|
|
|
|
// 显示App绑定配置
|
|
|
handleMini(data) {
|