index.vue 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  1. <template>
  2. <div class="app-container">
  3. <div class="filter-container">
  4. <div class="filter-control">
  5. <span>机构名称:</span>
  6. <el-input
  7. v-model="listQuery.authParty"
  8. placeholder="授权机构"
  9. style="width: 280px;"
  10. class="filter-item"
  11. @keyup.enter.native="handleFilter"
  12. />
  13. </div>
  14. <div class="filter-control">
  15. <span>审核状态:</span>
  16. <el-select
  17. v-model="listQuery.auditStatus"
  18. placeholder="审核状态"
  19. clearable
  20. style="width: 200px"
  21. class="filter-item"
  22. @change="getList"
  23. >
  24. <el-option label="全部" value="" />
  25. <el-option label="待审核" :value="2" />
  26. <el-option label="审核通过" :value="1" />
  27. <el-option label="审核未通过" :value="0" />
  28. </el-select>
  29. </div>
  30. <div class="filter-control">
  31. <span>上线状态:</span>
  32. <el-select
  33. v-model="listQuery.status"
  34. placeholder="上线状态"
  35. clearable
  36. style="width: 200px"
  37. class="filter-item"
  38. @change="getList"
  39. >
  40. <el-option label="全部" value="" />
  41. <el-option label="已上线" :value="1" />
  42. <el-option label="待上线" :value="2" />
  43. <el-option label="未上线" :value="0" />
  44. </el-select>
  45. </div>
  46. <div class="filter-control">
  47. <el-button type="primary" @click="getList">查询</el-button>
  48. <!-- <el-button icon="el-icon-upload" type="primary" @click="improtDialogVisible = true">导入</el-button> -->
  49. <el-button type="primary" @click="handleExportExcel">导出</el-button>
  50. <!-- <el-button icon="el-icon-document-copy" type="primary" @click="downLoadExportExcel">获取导入模板</el-button> -->
  51. </div>
  52. </div>
  53. <!-- 表格区域 -->
  54. <el-table
  55. :key="tableKey"
  56. v-loading="listLoading"
  57. :data="list"
  58. border
  59. fit
  60. highlight-current-row
  61. style="width: 100%;"
  62. header-row-class-name="tableHeader"
  63. >
  64. <el-table-column label="序号" :index="indexMethod" align="center" width="80" type="index" />
  65. <el-table-column label="机构名称" align="center" prop="authParty" />
  66. <el-table-column label="审核状态" width="120px" align="center">
  67. <template slot-scope="{ row }">
  68. <el-tag v-if="row.auditStatus === 2" size="small" type="warning">待审核</el-tag>
  69. <el-tag v-if="row.auditStatus === 1" size="small" type="success">审核通过</el-tag>
  70. <!-- 未通过原因展示 -->
  71. <template v-if="row.auditStatus === 0">
  72. <!-- <span class="status danger">审核未通过&nbsp;</span> -->
  73. <el-popover placement="top-start" title="审核说明" width="400" trigger="hover" :content="row.invalidReason">
  74. <el-tag slot="reference" size="small" type="danger" class="reason">
  75. <span>审核未通过</span>
  76. <span class="el-icon-question status danger " />
  77. </el-tag>
  78. </el-popover>
  79. <!-- 未通过原因展示END -->
  80. </template>
  81. </template>
  82. </el-table-column>
  83. <el-table-column label="上线状态" width="120px" align="center">
  84. <template slot-scope="{ row }">
  85. <!-- 只有审核通过了才能操作上下线 auditStatus :审核状态 -->
  86. <template v-if="row.auditStatus === 1">
  87. <template v-if="row.status === 0">
  88. <span style="margin-right:10px;" class="status danger">已下线</span>
  89. </template>
  90. <template v-else>
  91. <span style="margin-right:10px;" class="status success ">已上线</span>
  92. </template>
  93. </template>
  94. <template v-else>
  95. <!-- <el-tag type="warning">待上线</el-tag> -->
  96. <span style="margin-right:10px;" class="status warning">待上线</span>
  97. </template>
  98. </template>
  99. </el-table-column>
  100. <el-table-column label="创建时间" class-name="status-col" width="160px">
  101. <template slot-scope="{ row }">
  102. <span>{{ row.createTime | formatTime }}</span>
  103. </template>
  104. </el-table-column>
  105. <!-- <el-table-column label="创建人" class-name="status-col" width="160px" prop="createBy" /> -->
  106. <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="240px">
  107. <template slot-scope="{ row }">
  108. <el-button
  109. type="primary"
  110. size="mini"
  111. @click="$_navigationTo(`club-detail?id=${row.authId}&authParty=${row.authParty}`)"
  112. >
  113. 查看
  114. </el-button>
  115. <el-button
  116. type="primary"
  117. size="mini"
  118. @click="$_navigationTo(`club-device-list?id=${row.authId}&authParty=${row.authParty}`)"
  119. >
  120. 查看设备认证
  121. </el-button>
  122. </template>
  123. </el-table-column>
  124. </el-table>
  125. <!-- 页码 -->
  126. <pagination
  127. v-show="total > 0"
  128. :total="total"
  129. :page.sync="listQuery.pageNum"
  130. :limit.sync="listQuery.pageSize"
  131. @pagination="getList"
  132. />
  133. </div>
  134. </template>
  135. <script>
  136. import { fecthAuthList, authImportExcel } from '@/api/auth'
  137. import Pagination from '@/components/Pagination' // secondary package based on el-pagination
  138. import { mapGetters } from 'vuex'
  139. import { debounce, downLoadWithATag } from '@/utils/tools'
  140. export default {
  141. name: 'ComplexTable',
  142. components: { Pagination },
  143. data() {
  144. return {
  145. tableKey: 0,
  146. list: null,
  147. total: 0,
  148. listLoading: true,
  149. // 查询参数
  150. listQuery: {
  151. authParty: '', // 授权机构
  152. authUserId: '', // 供应商用户id
  153. pageNum: 1, // 页码
  154. pageSize: 10, // 分页
  155. status: ''
  156. },
  157. disabled: false,
  158. // ------------------
  159. improtDialogVisible: false,
  160. requestLoading: false,
  161. uploadFileList: [],
  162. improtDialogFormData: {
  163. fileUrl: ''
  164. },
  165. improtDialogFormRules: {
  166. fileUrl: [
  167. {
  168. required: true,
  169. message: '请选择文件',
  170. trigger: 'change'
  171. }
  172. ]
  173. },
  174. chooseFile: ''
  175. }
  176. },
  177. computed: {
  178. ...mapGetters(['authUserId', 'userIdentity', 'proxyInfo', 'copyUserInfo']),
  179. saveBtnClickable() {
  180. return this.uploadFileList.length > 0
  181. }
  182. },
  183. created() {
  184. this.listQuery.authUserId = this.$route.query.id || this.proxyInfo?.authUserId || this.authUserId
  185. const type = this.$route.query.type
  186. // 如果是通过路由参数传递的type,则需要同步到store
  187. if (type) {
  188. this.$store.commit('user/SET_SHOP_TYPE', parseInt(type))
  189. }
  190. this.getList()
  191. },
  192. methods: {
  193. // 下载模板
  194. downLoadExportExcel() {
  195. downLoadWithATag(
  196. `${process.env.VUE_APP_BASE_API}/download/file?ossName=%E6%AD%A3%E5%93%81%E8%81%94%E7%9B%9F%E6%9C%BA%E6%9E%84%E3%80%81%E5%95%86%E5%93%81%E5%AF%BC%E5%85%A5%E6%A8%A1%E6%9D%BF.xlsx&fileName=%E6%AD%A3%E5%93%81%E8%81%94%E7%9B%9F%E6%9C%BA%E6%9E%84%E3%80%81%E5%95%86%E5%93%81%E5%AF%BC%E5%85%A5%E6%A8%A1%E6%9D%BF.xlsx`
  197. )
  198. },
  199. // 导出为Excel
  200. async handleExportExcel() {
  201. const text = await this.$confirm('确认导出所有授权机构的数据吗?', '提示', {
  202. confirmButtonText: '确定',
  203. cancelButtonText: '取消',
  204. type: 'warning'
  205. }).catch(() => {
  206. this.$message.info('已取消操作')
  207. })
  208. if (text !== 'confirm') return
  209. // 使用a链接下载
  210. downLoadWithATag(`${process.env.VUE_APP_BASE_API}/auth/export/excel?authUserId=${this.authUserId}`)
  211. },
  212. // 导入Excel 并提交
  213. handleSave: debounce(function() {
  214. console.log('保存')
  215. console.log(this.improtDialogFormData)
  216. console.log(this.proxyInfo, this.authUserId)
  217. // 上传文件使用 multipart/form-data
  218. const formData = new FormData()
  219. formData.append('authUserId', this.authUserId)
  220. formData.append('createBy', this.copyUserInfo.authUserId)
  221. formData.append('file', this.chooseFile)
  222. authImportExcel(formData)
  223. .then(res => {
  224. this.$message.success(res.data)
  225. this.improtDialogVisible = false
  226. this.getList()
  227. })
  228. .catch(err => {
  229. console.log(err)
  230. })
  231. .finally(() => {
  232. this.requestLoading = false
  233. })
  234. }, 200),
  235. // 获取授权列表
  236. getList() {
  237. this.listLoading = true
  238. fecthAuthList(this.listQuery)
  239. .then(response => {
  240. if (response.code !== 0) {
  241. return this.$message.error('授权列表信息获取失败')
  242. }
  243. const { list, total } = response.data
  244. this.list = list
  245. this.total = total
  246. })
  247. .catch(err => {
  248. console.log(err)
  249. return this.$message.error('授权列表信息获取失败')
  250. })
  251. .finally(() => {
  252. this.listLoading = false
  253. })
  254. },
  255. // 过滤列表
  256. handleFilter() {
  257. this.listQuery.page = 1
  258. this.getList()
  259. },
  260. indexMethod(index) {
  261. return index + this.listQuery.pageSize * (this.listQuery.pageNum - 1) + 1
  262. }
  263. }
  264. }
  265. </script>
  266. <style lang="scss" scoped>
  267. </style>