index.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. <template>
  2. <div class="app-container">
  3. <div class="filter-container">
  4. <div class="filter-control">
  5. <span>设备名称:</span>
  6. <el-input v-model="listQuery.productName" placeholder="设备名称" @keyup.enter.native="handleFilter" />
  7. </div>
  8. <div class="filter-control">
  9. <span>设备SN码:</span>
  10. <el-input v-model="listQuery.snCode" placeholder="设备SN码" @keyup.enter.native="handleFilter" />
  11. </div>
  12. <div class="filter-control">
  13. <el-button type="primary" @click="handleFilter">查询</el-button>
  14. </div>
  15. </div>
  16. <!-- 表格区域 -->
  17. <el-table
  18. :key="tableKey"
  19. v-loading="listLoading"
  20. :data="list"
  21. border
  22. fit
  23. highlight-current-row
  24. style="width: 100%"
  25. header-row-class-name="tableHeader"
  26. >
  27. <el-table-column label="序号" :index="indexMethod" type="index" align="center" width="80" />
  28. <el-table-column label="设备名称" align="center" prop="productName" />
  29. <el-table-column label="设备SN码" align="center" prop="snCode" />
  30. <el-table-column label="创建时间" class-name="status-col" width="160px" align="center">
  31. <template slot-scope="{ row }">
  32. <span>{{ row.createTime | formatTime }}</span>
  33. </template>
  34. </el-table-column>
  35. <!-- <el-table-column v-if="false" label="创建人" width="180px" align="center" prop="createBy" /> -->
  36. <el-table-column label="操作" align="center" width="240px" class-name="small-padding fixed-width">
  37. <template slot-scope="{ row }">
  38. <el-button type="primary" size="mini" @click="$_navigationTo(`/logistics/device-detail?productId=${row.productId}`)">
  39. 查看
  40. </el-button>
  41. <el-button :disabled="row.auditStatus !== 1" type="primary" size="mini" @click="handleShowQRcode(row)">
  42. 二维码
  43. </el-button>
  44. </template>
  45. </el-table-column>
  46. </el-table>
  47. <!-- 页码 -->
  48. <pagination :total="total" :page.sync="listQuery.pageNum" :limit.sync="listQuery.pageSize" @pagination="getList" />
  49. <!-- 二维码 -->
  50. <transition name="fade">
  51. <qrcode-device v-if="showQRcode" :product-info="productInfo" @close="showQRcode = false" />
  52. </transition>
  53. </div>
  54. </template>
  55. <script>
  56. import { getProdList } from '@/api/product'
  57. import QrcodeDevice from '@/components/QrcodeDevice'
  58. import { mapGetters } from 'vuex'
  59. import { setStorage } from '@/utils/storage'
  60. export default {
  61. name: 'ComplexTable',
  62. components: { QrcodeDevice },
  63. data() {
  64. return {
  65. tableKey: 0,
  66. list: null,
  67. total: 0,
  68. listLoading: true,
  69. listQuery: {
  70. status: '',
  71. auditStatus: '',
  72. authId: '',
  73. productName: '',
  74. snCode: '',
  75. pageNum: 1,
  76. pageSize: 10
  77. },
  78. showQRcode: false,
  79. productInfo: {}
  80. }
  81. },
  82. computed: {
  83. ...mapGetters(['userIdentity'])
  84. },
  85. created() {
  86. this.listQuery.authId = this.$route.query.authId
  87. // 保存机构id,用于设备管理
  88. setStorage('device-setting-authId', this.listQuery.authId)
  89. this.getList()
  90. },
  91. methods: {
  92. // 获取列表信息
  93. getList() {
  94. getProdList(this.listQuery)
  95. .then((res) => {
  96. const { total, list } = res.data
  97. this.total = total
  98. this.list = list
  99. })
  100. .finally(() => {
  101. this.listLoading = false
  102. })
  103. },
  104. // 过滤列表
  105. handleFilter() {
  106. this.listQuery.page = 1
  107. this.getList()
  108. },
  109. // 显示二维码
  110. handleShowQRcode(item) {
  111. this.productInfo = item
  112. this.productInfo.authParty = item.authParty
  113. this.showQRcode = true
  114. },
  115. indexMethod(index) {
  116. return index + this.listQuery.pageSize * (this.listQuery.pageNum - 1) + 1
  117. }
  118. }
  119. }
  120. </script>
  121. <style lang="scss" scoped></style>