index.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. <template>
  2. <div class="padding-20">
  3. <div class="search-box">
  4. <el-form
  5. ref="form"
  6. :inline="true"
  7. :model="searchForm"
  8. clearable
  9. class="mt-10">
  10. <el-form-item label="vr名称:">
  11. <el-input v-model="searchForm.vr_name" placeholder="请输入vr名称" clearable></el-input>
  12. </el-form-item>
  13. <el-form-item label="状态:">
  14. <el-select
  15. v-model="searchForm.status"
  16. filterable
  17. clearable
  18. placeholder="请选择状态">
  19. <el-option
  20. v-for="item in arrLunboStatus"
  21. :key="item.value"
  22. :label="item.name"
  23. :value="item.value">
  24. </el-option>
  25. </el-select>
  26. </el-form-item>
  27. <el-form-item label="创建时间:">
  28. <el-date-picker
  29. :editable="false"
  30. v-model="time"
  31. @change="timearr => {timearr ? (searchForm.start_time = timearr[0] + ' 00:00:00', searchForm.end_time = timearr[1] + ' 23:59:59') : searchForm.start_time = searchForm.end_time = undefined}"
  32. type="daterange"
  33. value-format="yyyy-MM-dd"
  34. start-placeholder="开始时间"
  35. end-placeholder="结束时间"
  36. ></el-date-picker>
  37. </el-form-item>
  38. <el-form-item class="ml-10">
  39. <el-button icon="el-icon-search" type="primary" @click="searchSubmit">查询</el-button>
  40. </el-form-item>
  41. <el-form-item class="ml-10">
  42. <el-button icon="el-icon-plus"
  43. type="primary"
  44. @click="add">新增
  45. </el-button>
  46. </el-form-item>
  47. </el-form>
  48. </div>
  49. <el-table
  50. :data="tableData"
  51. stripe
  52. v-loading="tableLoading"
  53. fit
  54. class="marginT-10 order-table"
  55. :max-height="vheight">
  56. <el-table-column label="名称" prop="vr_name" show-overflow-tooltip></el-table-column>
  57. <el-table-column label="介绍" prop="vr_introduce" show-overflow-tooltip min-width="140"></el-table-column>
  58. <el-table-column label="地址" prop="vr_url" show-overflow-tooltip min-width="140"></el-table-column>
  59. <el-table-column label="vr封面" prop="vr_img_url" min-width="100">
  60. <template slot-scope="scope">
  61. <el-image
  62. style="display:block;width: 80px; height: 80px;font-size: 0;"
  63. :src="scope.row.vr_img_url"
  64. :preview-src-list="[scope.row.vr_img_url]">
  65. </el-image>
  66. </template>
  67. </el-table-column>
  68. <el-table-column label="状态" prop="status">
  69. <template slot-scope="scope">
  70. <p>{{ getText(arrLunboStatus, scope.row.status) }}</p>
  71. </template>
  72. </el-table-column>
  73. <el-table-column label="是否置顶" prop="top">
  74. <template slot-scope="scope">
  75. <p>{{ getText(arrProductIsRecommend, scope.row.top) }}</p>
  76. </template>
  77. </el-table-column>
  78. <el-table-column label="创建时间" prop="created_at" min-width="160"></el-table-column>
  79. <el-table-column label="更新时间" prop="updated_at" min-width="160"></el-table-column>
  80. <el-table-column label="操作" width="160">
  81. <template slot-scope="scope">
  82. <el-button type="text" @click="edit(scope.row)">编辑</el-button>
  83. <el-button type="text" @click="del(scope.row)">删除</el-button>
  84. </template>
  85. </el-table-column>
  86. </el-table>
  87. <el-pagination
  88. class="marginT-20"
  89. @size-change="handleSizeChange"
  90. @current-change="handleCurrentChange"
  91. :hide-on-single-page="true"
  92. :current-page="page"
  93. :page-size="page_size"
  94. :page-sizes="[10, 20, 100, 200, 300, 400]"
  95. background
  96. layout="total, sizes, prev, pager, next, jumper"
  97. :total="totalCount"/>
  98. <detail v-if="detailsDialog.show"
  99. v-model="detailsDialog.show"
  100. :exData="detailsDialog.exData"
  101. @success="init"></detail>
  102. </div>
  103. </template>
  104. <script>
  105. import page from '@/mixin/page'
  106. import detail from './details'
  107. export default {
  108. mixins: [page],
  109. components: {
  110. detail
  111. },
  112. data() {
  113. return {
  114. detailsDialog: {
  115. show: false,
  116. exData: {}
  117. },
  118. time: [],
  119. searchForm: {},
  120. tableData: [],
  121. tableUrl: '/api/admin/vr/list'
  122. }
  123. },
  124. computed: {
  125. arrLunboStatus() {
  126. return this.$store.state.common.arrLunboStatus
  127. },
  128. arrProductIsRecommend() {
  129. return this.$store.state.common.arrProductIsRecommend
  130. }
  131. },
  132. methods: {
  133. add() {
  134. this.detailsDialog.exData = {}
  135. this.detailsDialog.show = true
  136. },
  137. edit(row) {
  138. this.detailsDialog.exData = row
  139. this.detailsDialog.show = true
  140. },
  141. del(row) {
  142. this.$confirm('确定要删除吗', '确认', {
  143. type: 'warning'
  144. }).then(async () => {
  145. const data = await this.$fetch('/api/admin/vr/delete', { id: row.id })
  146. if (data.code === 200) {
  147. this.$message.success('删除成功')
  148. this.init()
  149. }
  150. }).catch(() => {
  151. })
  152. },
  153. getText(arr, value) {
  154. const temp = arr.filter(item => item.value === value)
  155. if (temp.length > 0) {
  156. return temp[0].name
  157. }
  158. return ''
  159. }
  160. },
  161. mounted() {
  162. this.init()
  163. }
  164. }
  165. </script>
  166. <style lang="scss" scoped>
  167. </style>