list.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. <template>
  2. <div v-loading="loading">
  3. <div class="white-box">
  4. <el-table ref="multipleTable" :data="tableData" stripe style="width: 100%;"
  5. @selection-change="handleSelectionChange" @row-click="handleExpand">
  6. <el-table-column type="expand">
  7. <template slot-scope="scope">
  8. <img :src="getImage(scope.row.IMAGE)" width="100%" height="100%" :alt="scope.row.TITLE">
  9. </template>
  10. </el-table-column>
  11. <el-table-column type="selection" width="55"></el-table-column>
  12. <el-table-column label="广告标题" prop="TITLE" width="250">
  13. <template slot-scope="scope">
  14. <el-tag type="" size="small" class="no-border">{{scope.row.TITLE}}</el-tag>
  15. </template>
  16. </el-table-column>
  17. <el-table-column label="广告位" width="150">
  18. <template slot-scope="scope">
  19. <el-tag type="warning" size="small" class="no-border">{{allData.allLocation[scope.row.LID].LOCATION_NAME}}</el-tag>
  20. </template>
  21. </el-table-column>
  22. <el-table-column label="类型">
  23. <template slot-scope="scope">
  24. <template v-if="scope.row.TYPE === '1'">
  25. <el-tag type="success">外链</el-tag>
  26. </template>
  27. <template v-else-if="scope.row.TYPE === '2'">
  28. <el-tag>文章</el-tag>
  29. </template>
  30. </template>
  31. </el-table-column>
  32. <el-table-column label="连接或文章ID" prop="CONTENT" width="120"></el-table-column>
  33. <el-table-column label="排序" width="100">
  34. <template slot-scope="scope">
  35. <el-input v-model="scope.row.SORT" min="0" max="99" @change="handleChangeSort(scope.row, scope.row.SORT)"
  36. @click.native.stop=""></el-input>
  37. </template>
  38. </el-table-column>
  39. <el-table-column label="创建人">
  40. <template slot-scope="scope">
  41. {{scope.row.CREATE_ADMIN_NAME}}
  42. </template>
  43. </el-table-column>
  44. <el-table-column label="创建时间" width="180">
  45. <template slot-scope="scope">
  46. {{tool.formatDate(scope.row.CREATED_AT)}}
  47. </template>
  48. </el-table-column>
  49. <el-table-column label="修改人">
  50. <template slot-scope="scope">
  51. {{scope.row.UPDATE_ADMIN_NAME}}
  52. </template>
  53. </el-table-column>
  54. <el-table-column label="修改时间" width="180">
  55. <template slot-scope="scope">
  56. {{tool.formatDate(scope.row.UPDATED_AT)}}
  57. </template>
  58. </el-table-column>
  59. <el-table-column fixed="right" label="操作" width="180">
  60. <template slot-scope="scope">
  61. <el-dropdown size="small" trigger="click" v-if="permission.hasPermission(`ad/ad-delete`) || permission.hasPermission(`ad/edit`)">
  62. <el-button type="primary" size="small" @click.stop="">
  63. 操作该数据<i class="el-icon-arrow-down el-icon--right"></i>
  64. </el-button>
  65. <el-dropdown-menu slot="dropdown">
  66. <el-dropdown-item command="edit" @click.native="handleEdit(scope.row)" v-if="permission.hasPermission(`ad/edit`)">编辑</el-dropdown-item>
  67. <el-dropdown-item command="delete" @click.native="handleDelete(scope.row)" v-if="permission.hasPermission(`ad/ad-delete`)">删除</el-dropdown-item>
  68. </el-dropdown-menu>
  69. </el-dropdown>
  70. </template>
  71. </el-table-column>
  72. </el-table>
  73. <div class="white-box-footer">
  74. <el-dropdown size="small" trigger="click" v-if="permission.hasPermission(`ad/ad-delete`)">
  75. <el-button type="primary" size="small">
  76. 所选数据<i class="el-icon-arrow-down el-icon--right"></i>
  77. </el-button>
  78. <el-dropdown-menu slot="dropdown">
  79. <el-dropdown-item command="delete" @click.native="handleMuliDel()">删除</el-dropdown-item>
  80. </el-dropdown-menu>
  81. </el-dropdown>
  82. <el-button type="primary" size="small" @click="handleAdd" icon="el-icon-plus" v-if="permission.hasPermission(`ad/add`)">添加广告</el-button>
  83. <pagination :total="totalCount" :page_size="pageSize" @size-change="handleSizeChange" @current-change="handleCurrentChange"></pagination>
  84. </div>
  85. </div>
  86. </div>
  87. </template>
  88. <script>
  89. import Vue from 'vue'
  90. import network from '@/utils/network'
  91. import tool from '@/utils/tool'
  92. import store from '@/utils/vuexStore'
  93. import permission from '@/utils/permission'
  94. import Pagination from '@/components/Pagination'
  95. export default {
  96. name: 'ad_list',
  97. components: {Pagination},
  98. mounted () {
  99. this.getData()
  100. },
  101. data () {
  102. return {
  103. allData: null,
  104. tableData: null,
  105. loading: true,
  106. multipleSelection: [],
  107. currentPage: 1,
  108. totalPages: 1,
  109. totalCount: 1,
  110. pageSize: 20,
  111. tool: tool,
  112. permission: permission,
  113. }
  114. },
  115. methods: {
  116. handleExpand (row, event, column) {
  117. this.$refs.multipleTable.toggleRowExpansion(row)
  118. },
  119. handleSelectionChange (val) {
  120. this.multipleSelection = val
  121. },
  122. handleCurrentChange (page) {
  123. this.getData(page, this.pageSize)
  124. },
  125. handleSizeChange (pageSize) {
  126. this.getData(this.currentPage, pageSize)
  127. },
  128. handleAdd () {
  129. this.$router.push({path: `/ad/add`})
  130. },
  131. handleEdit (row) {
  132. this.$router.push({path: `/ad/edit/${row.ID}`})
  133. },
  134. handleDelete (row) {
  135. this.delData(row.ID)
  136. },
  137. handleMuliDel () {
  138. this.delData()
  139. },
  140. handleChangeSort (row, sort) {
  141. network.getData('/ad/sort', {id: row.ID, sort: sort}).then(response => {
  142. this.getData(this.currentPage, this.pageSize)
  143. }).catch(response => {
  144. })
  145. },
  146. getData (page, pageSize) {
  147. let obj = this
  148. network.getPageData(this, `ad/list/${this.$route.params.lid}`, page, pageSize, null, function (response) {
  149. obj.allData = response
  150. })
  151. },
  152. delData (id = null) {
  153. let obj = this
  154. obj.$confirm('确定删除选定的数据?', '提示', {
  155. confirmButtonText: '确定',
  156. cancelButtonText: '取消',
  157. type: 'warning'
  158. }).then(() => {
  159. let selectedIds = []
  160. if (id === null) {
  161. for (let val of obj.multipleSelection) {
  162. selectedIds.push(val.ID)
  163. }
  164. } else {
  165. selectedIds.push(id)
  166. }
  167. return network.postData(`ad/ad-delete`, {
  168. selected: selectedIds
  169. })
  170. }).then(response => {
  171. this.$message({
  172. message: response,
  173. type: 'success'
  174. })
  175. obj.getData(obj.currentPage, obj.pageSize)
  176. }).catch(response => {
  177. })
  178. },
  179. getImage(imageUrl) {
  180. return tool.getLocaleLink(imageUrl, '/files/');
  181. },
  182. }
  183. }
  184. </script>
  185. <style scoped>
  186. </style>