authorize.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. <template>
  2. <div>
  3. <el-button type="primary" plain icon="User" @click="showDialog"
  4. >批量授权
  5. </el-button>
  6. <el-dialog v-model="show" width="880px">
  7. <template #header>
  8. <div class="full-width flex flex-center flex-justify-between">
  9. <h4>批量授权</h4>
  10. </div>
  11. </template>
  12. <div class="flex flex-center flex-justify-between">
  13. <div class="from">
  14. <div class="padding flex full-width flex-col flex-justify-start">
  15. <span class="full-width text-left bold mt-20">访问权限:</span>
  16. <div class="flex flex-center flex-justify-start mt-10">
  17. <el-radio-group v-model="query.status">
  18. <el-radio :label="1">可看</el-radio>
  19. <el-radio :label="2">可编辑</el-radio>
  20. <el-radio :label="3">不可查看</el-radio>
  21. </el-radio-group>
  22. </div>
  23. <span class="full-width text-left bold mt-20">授权时间:</span>
  24. <el-date-picker
  25. style="width: 360px"
  26. v-model="time"
  27. type="daterange"
  28. clearable
  29. class="mt-10"
  30. range-separator="至"
  31. start-placeholder="开始时间"
  32. end-placeholder="截止时间"
  33. format="YYYY-MM-DD"
  34. value-format="YYYY-MM-DD"
  35. @change="dateChange"
  36. />
  37. </div>
  38. <el-checkbox
  39. class="full-width flex flex-justify-start mt-20"
  40. label="应用到此文件夹、子文件夹及文件"
  41. @change="changeApplyAll"
  42. />
  43. <el-divider />
  44. <span class="grey-6">- 复制二维码并通过他微信分享给被授权用户 -</span>
  45. </div>
  46. <el-divider direction="vertical" style="height: 350px" />
  47. <div class="qrcode">
  48. <el-empty
  49. description="请选择授权配置后点击生成二维码"
  50. v-if="qrCodeText.length === 0"
  51. ></el-empty>
  52. <vue-qr
  53. v-else
  54. :currentLevel="3"
  55. :logoCornerRadius="4"
  56. :logoScale="0.25"
  57. :logoSrc="logoSrc"
  58. :text="qrCodeText"
  59. size="360"
  60. />
  61. </div>
  62. </div>
  63. <div class="mt-20 full-width flex flex-center">
  64. <el-button type="primary" plain @click="show = false">取 消</el-button>
  65. <el-button type="primary" @click="qrCode()">生成二维码</el-button>
  66. </div>
  67. </el-dialog>
  68. </div>
  69. </template>
  70. <script>
  71. import VueQr from 'vue-qr/src/packages/vue-qr.vue'
  72. export default {
  73. components: {
  74. VueQr
  75. },
  76. props: {
  77. list: {
  78. type: Array,
  79. default: []
  80. }
  81. },
  82. data() {
  83. return {
  84. show: false,
  85. access: 1,
  86. logoSrc: new URL('@/assets/img/logo.png', import.meta.url).href,
  87. qrCodeText: '',
  88. time: '',
  89. query: {
  90. ids: '',
  91. status: 2,
  92. startTime: '',
  93. endTime: '',
  94. type: 1,
  95. isApplyAll: 0
  96. }
  97. }
  98. },
  99. methods: {
  100. showDialog() {
  101. if (this.list.length === 0) {
  102. this.$message.error('请先选择要授权的文件夹、文件')
  103. return
  104. }
  105. this.show = true
  106. },
  107. qrCode() {
  108. if (this.list.length === 0) {
  109. return
  110. }
  111. if (this.time.length === 0) {
  112. this.$message.error('请选择授权时间')
  113. return
  114. }
  115. this.query.ids = this.list.map(e => e.id).join(',')
  116. this.$api.resource.fileAuthorize(this.query).then(res => {
  117. if (res.code === 200) {
  118. this.qrCodeText =
  119. 'https://prod.wutongshucloud.com/apply?id=' + res.data
  120. }
  121. })
  122. },
  123. changeApplyAll(res) {
  124. if (res) {
  125. this.query.isApplyAll = 1
  126. } else {
  127. this.query.isApplyAll = 0
  128. }
  129. },
  130. dateChange() {
  131. if (this.time.length === 0) {
  132. return
  133. }
  134. this.query.startTime = this.time[0]
  135. this.query.endTime = this.time[1]
  136. }
  137. }
  138. }
  139. </script>
  140. <style lang="scss" scoped>
  141. .from {
  142. width: 400px;
  143. height: 400px;
  144. }
  145. .qrcode {
  146. width: 400px;
  147. height: 400px;
  148. }
  149. </style>