index.vue 8.0 KB

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