index.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. <template>
  2. <div class="app-container">
  3. <div class="filter-container">
  4. <span>设备名称:</span>
  5. <el-input v-model="listQuery.productName" placeholder="商品名称" style="width: 200px;" class="filter-item" @keyup.enter.native="handleFilter" />
  6. <span>设备SN码:</span>
  7. <el-input v-model="listQuery.snCode" placeholder="商品SN码" style="width: 200px;" class="filter-item" @keyup.enter.native="handleFilter" />
  8. <span>审核状态:</span>
  9. <el-select
  10. v-model="listQuery.auditStatus"
  11. placeholder="审核状态"
  12. clearable
  13. style="width: 200px"
  14. class="filter-item"
  15. @change="getList"
  16. >
  17. <el-option label="全部" value="" />
  18. <el-option label="待审核" :value="2" />
  19. <el-option label="审核通过" :value="1" />
  20. <el-option label="审核未通过" :value="0" />
  21. </el-select>
  22. <span>上线状态:</span>
  23. <el-select
  24. v-model="listQuery.status"
  25. placeholder="上线状态"
  26. clearable
  27. style="width: 200px"
  28. class="filter-item"
  29. @change="getList"
  30. >
  31. <el-option label="全部" value="" />
  32. <el-option label="已上线" :value="1" />
  33. <el-option label="待上线" :value="2" />
  34. <el-option label="未上线" :value="0" />
  35. </el-select>
  36. <el-button type="primary" icon="el-icon-search" @click="handleFilter">查询</el-button>
  37. </div>
  38. <!-- 表格区域 -->
  39. <el-table
  40. :key="tableKey"
  41. v-loading="listLoading"
  42. :data="list"
  43. border
  44. fit
  45. highlight-current-row
  46. style="width: 100%;"
  47. header-row-class-name="tableHeader"
  48. >
  49. <el-table-column label="序号" :index="indexMethod" type="index" align="center" width="80" />
  50. <el-table-column label="设备名称" align="center" prop="productName" />
  51. <el-table-column label="设备SN码" align="center" prop="snCode" />
  52. <el-table-column label="审核状态" width="220px" align="center">
  53. <template slot-scope="{ row }">
  54. <el-tag v-if="row.auditStatus === 2" size="small" type="warning">待审核</el-tag>
  55. <el-tag v-if="row.auditStatus === 1" size="small" type="success">审核通过</el-tag>
  56. <!-- 未通过原因展示 -->
  57. <template v-if="row.auditStatus === 0">
  58. <!-- <span class="status danger">审核未通过&nbsp;</span> -->
  59. <el-popover
  60. placement="top-start"
  61. title="审核说明"
  62. width="400"
  63. trigger="hover"
  64. :content="row.invalidReason"
  65. >
  66. <el-tag slot="reference" size="small" type="danger" class="reason">
  67. <span>审核未通过</span>
  68. <span class="el-icon-question status danger " />
  69. </el-tag>
  70. </el-popover>
  71. <!-- 未通过原因展示END -->
  72. </template>
  73. </template>
  74. </el-table-column>
  75. <el-table-column label="上线状态" width="140px" align="center">
  76. <template slot-scope="{row}">
  77. <!-- 只有审核通过了才能操作上下线 auditStatus :审核状态 -->
  78. <template v-if="row.auditStatus === 1">
  79. <template v-if="row.status === 0">
  80. <span style="margin-right:10px;" class="status danger">已下线</span>
  81. <el-button v-if="userIdentity===2 || proxyInfo !== null" type="primary" size="mini" @click="handleChangeStatus(row)">上线</el-button>
  82. </template>
  83. <template v-else>
  84. <span style="margin-right:10px;" class="status success ">已上线</span>
  85. <el-button v-if="userIdentity===2 || proxyInfo !== null" type="info" size="mini" plain @click="handleChangeStatus(row)">下线</el-button>
  86. </template>
  87. </template>
  88. <template v-else>
  89. <!-- <el-tag type="warning">待上线</el-tag> -->
  90. <span style="margin-right:10px;" class="status warning">待上线</span>
  91. </template>
  92. </template>
  93. </el-table-column>
  94. <el-table-column label="创建时间" class-name="status-col" width="300px" align="center">
  95. <template slot-scope="{row}">
  96. <span>{{ row.createTime | formatTime }}</span>
  97. </template>
  98. </el-table-column>
  99. <el-table-column label="操作" align="center" width="240px" class-name="small-padding fixed-width">
  100. <template slot-scope="{row}">
  101. <el-button type="primary" size="mini" @click="$_navigationTo(`club-device-detail?id=${row.productId}`)">查看</el-button>
  102. <el-button type="primary" size="mini" :disabled="row.auditStatus !== 1" @click="handleShowQRcode(row)">
  103. 二维码
  104. </el-button>
  105. </template>
  106. </el-table-column>
  107. </el-table>
  108. <!-- 页码 -->
  109. <pagination v-show="total>0" :total="total" :page.sync="listQuery.pageNum" :limit.sync="listQuery.pageSize" @pagination="getList" />
  110. <!-- 二维码 -->
  111. <transition name="fade">
  112. <qrcode v-if="showQRcode" :product-info="productInfo" @close="showQRcode = false" />
  113. </transition>
  114. </div>
  115. </template>
  116. <script>
  117. import { getProdList } from '@/api/product'
  118. import Pagination from '@/components/Pagination' // secondary package based on el-pagination
  119. import Qrcode from '@/components/qrcode'
  120. import { formatDate } from '@/utils'
  121. import { mapGetters } from 'vuex'
  122. export default {
  123. name: 'ComplexTable',
  124. components: { Pagination, Qrcode },
  125. filters: {
  126. formatTime(time) {
  127. if (!time) {
  128. return ''
  129. }
  130. return formatDate(time, 'yyyy-MM-DD HH:mm:ss')
  131. }
  132. },
  133. data() {
  134. return {
  135. authParty: '',
  136. tableKey: 0,
  137. list: null,
  138. total: 0,
  139. listLoading: true,
  140. listQuery: {
  141. status: '',
  142. auditStatus: '',
  143. authId: '',
  144. productName: '',
  145. snCode: '',
  146. pageNum: 1,
  147. pageSize: 10
  148. },
  149. showQRcode: false,
  150. productInfo: {}
  151. }
  152. },
  153. computed: {
  154. ...mapGetters(['userIdentity', 'proxyInfo'])
  155. },
  156. created() {
  157. this.listQuery.authId = this.$route.query.id
  158. this.authParty = this.$route.query.authParty
  159. this.getList()
  160. },
  161. methods: {
  162. // 获取列表信息
  163. getList() {
  164. getProdList(this.listQuery).then(res => {
  165. const { total, list } = res.data
  166. this.total = total
  167. this.list = list
  168. // this.checkAuditFailedList(list)
  169. }).finally(() => {
  170. this.listLoading = false
  171. })
  172. },
  173. // 过滤列表
  174. handleFilter() {
  175. this.listQuery.page = 1
  176. this.getList()
  177. },
  178. // 显示二维码
  179. handleShowQRcode(item) {
  180. this.productInfo = item
  181. this.productInfo.authParty = this.authParty
  182. this.showQRcode = true
  183. },
  184. indexMethod(index) {
  185. return index + this.listQuery.pageSize * (this.listQuery.pageNum - 1) + 1
  186. }
  187. }
  188. }
  189. </script>
  190. <style lang="scss" scoped>
  191. .filter-container{
  192. span{
  193. display: inline-block;
  194. margin-bottom: 10px;
  195. vertical-align: middle;
  196. font-size: 14px;
  197. }
  198. .el-button{
  199. display: inline-block;
  200. margin-bottom: 10px;
  201. vertical-align: middle;
  202. }
  203. .el-input,.el-select{
  204. margin-right: 10px;
  205. margin-left: 10px;
  206. }
  207. }
  208. </style>