list.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  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="Ad Title" 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="Ad Location" 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="Type"> <!-- 类型 -->
  23. <template slot-scope="scope">
  24. <template v-if="scope.row.TYPE === '1'">
  25. <el-tag type="success">External Links</el-tag> <!-- 外链 -->
  26. </template>
  27. <template v-else-if="scope.row.TYPE === '2'">
  28. <el-tag>Article</el-tag> <!-- 文章 -->
  29. </template>
  30. </template>
  31. </el-table-column>
  32. <el-table-column label="Content" prop="CONTENT" width="120">
  33. <template slot-scope="scope">
  34. <div v-if="scope.row.TYPE === '1'">
  35. <el-link type="primary" target="_blank" :href="getHref(scope.row.CONTENT)">{{ scope.row.CONTENT }}</el-link>
  36. </div><!-- 链接 -->
  37. <div v-else-if="scope.row.TYPE === '2'">
  38. <router-link :to="`/article/detail/${scope.row.CONTENT}`" target="_blank" style="cursor: pointer;">{{ getContent(scope.row.CONTENT) }}</router-link>
  39. </div><!-- 文章 -->
  40. </template>
  41. </el-table-column>
  42. <el-table-column label="Sort" width="100"> <!-- 排序 -->
  43. <template slot-scope="scope">
  44. <el-input v-model="scope.row.SORT" min="0" max="99" @change="handleChangeSort(scope.row, scope.row.SORT)"
  45. @click.native.stop=""></el-input>
  46. </template>
  47. </el-table-column>
  48. <el-table-column label="Creator"> <!-- 创建人 -->
  49. <template slot-scope="scope">
  50. {{scope.row.CREATE_ADMIN_NAME}}
  51. </template>
  52. </el-table-column>
  53. <el-table-column label="Created Time" width="180"> <!-- 创建时间 -->
  54. <template slot-scope="scope">
  55. {{tool.formatDate(scope.row.CREATED_AT)}}
  56. </template>
  57. </el-table-column>
  58. <el-table-column label="Modified By"> <!-- 修改人 -->
  59. <template slot-scope="scope">
  60. {{scope.row.UPDATE_ADMIN_NAME}}
  61. </template>
  62. </el-table-column>
  63. <el-table-column label="Modified Time" width="180"> <!-- 修改时间 -->
  64. <template slot-scope="scope">
  65. {{tool.formatDate(scope.row.UPDATED_AT)}}
  66. </template>
  67. </el-table-column>
  68. <el-table-column label="Status"> <!-- 状态 -->
  69. <template slot-scope="scope">
  70. <div v-if="scope.row.STATUS === '1'">Show</div>
  71. <div v-else>Hide</div>
  72. </template>
  73. </el-table-column>
  74. <el-table-column fixed="right" label="Action" width="180"> <!-- 操作 -->
  75. <template slot-scope="scope">
  76. <el-dropdown size="small" trigger="click" v-if="permission.hasPermission(`ad/ad-delete`) || permission.hasPermission(`ad/edit`)">
  77. <el-button type="primary" size="small" @click.stop="">
  78. Action<i class="el-icon-arrow-down el-icon--right"></i>
  79. </el-button>
  80. <el-dropdown-menu slot="dropdown">
  81. <el-dropdown-item command="edit" @click.native="handleEdit(scope.row)" v-if="permission.hasPermission(`ad/edit`)">Edit</el-dropdown-item>
  82. <el-dropdown-item command="delete" @click.native="handleDelete(scope.row)" v-if="permission.hasPermission(`ad/ad-delete`)">Delete</el-dropdown-item>
  83. <el-dropdown-item command="hide" @click.native="handleHide(scope.row)" v-if="permission.hasPermission(`ad/ad-hide`)">Hide</el-dropdown-item>
  84. <el-dropdown-item command="un-hide" @click.native="handleUnHide(scope.row)" v-if="permission.hasPermission(`ad/ad-un-hide`)">Unhide</el-dropdown-item>
  85. </el-dropdown-menu>
  86. </el-dropdown>
  87. </template>
  88. </el-table-column>
  89. </el-table>
  90. <div class="white-box-footer">
  91. <el-dropdown size="small" trigger="click" v-if="permission.hasPermission(`ad/ad-delete`)">
  92. <el-button type="primary" size="small">
  93. Selected data<!--所选数据--><i class="el-icon-arrow-down el-icon--right"></i>
  94. </el-button>
  95. <el-dropdown-menu slot="dropdown">
  96. <el-dropdown-item command="delete" @click.native="handleMuliDel()">Delete</el-dropdown-item>
  97. <el-dropdown-item command="hide" @click.native="handleMultiHide()">Hide</el-dropdown-item>
  98. <el-dropdown-item command="un-hide" @click.native="handleMultiUnHide()">Unhide</el-dropdown-item>
  99. </el-dropdown-menu>
  100. </el-dropdown>
  101. <el-button type="primary" size="small" @click="handleAdd" icon="el-icon-plus" v-if="permission.hasPermission(`ad/add`)">Add Ad</el-button>
  102. <pagination :total="totalCount" :page_size="pageSize" @size-change="handleSizeChange" @current-change="handleCurrentChange"></pagination>
  103. </div>
  104. </div>
  105. </div>
  106. </template>
  107. <script>
  108. import Vue from 'vue'
  109. import network from '@/utils/network'
  110. import tool from '@/utils/tool'
  111. import store from '@/utils/vuexStore'
  112. import permission from '@/utils/permission'
  113. import Pagination from '@/components/Pagination'
  114. import {SERVER_API_HTTP_TYPE,SERVER_API_DOMAIN,CDN_BASE_URL} from '@/utils/config'
  115. import article from "../article";
  116. export default {
  117. name: 'ad_list',
  118. components: {Pagination},
  119. mounted () {
  120. this.getData()
  121. },
  122. data () {
  123. return {
  124. allData: null,
  125. tableData: null,
  126. loading: true,
  127. multipleSelection: [],
  128. currentPage: 1,
  129. totalPages: 1,
  130. totalCount: 1,
  131. pageSize: 20,
  132. tool: tool,
  133. permission: permission,
  134. allArticle: [],
  135. }
  136. },
  137. methods: {
  138. handleExpand (row, event, column) {
  139. this.$refs.multipleTable.toggleRowExpansion(row)
  140. },
  141. handleSelectionChange (val) {
  142. this.multipleSelection = val
  143. },
  144. handleCurrentChange (page) {
  145. this.getData(page, this.pageSize)
  146. },
  147. handleSizeChange (pageSize) {
  148. this.getData(this.currentPage, pageSize)
  149. },
  150. handleAdd () {
  151. this.$router.push({path: `/ad/add`})
  152. },
  153. handleEdit (row) {
  154. this.$router.push({path: `/ad/edit/${row.ID}`})
  155. },
  156. handleDelete (row) {
  157. this.delData(row.ID)
  158. },
  159. handleHide (row) {
  160. this.hideData(row.ID)
  161. },
  162. handleUnHide(row) {
  163. this.unHideData(row.ID)
  164. },
  165. handleMuliDel () {
  166. this.delData()
  167. },
  168. handleMultiHide () {
  169. this.hideData()
  170. },
  171. handleMultiUnHide () {
  172. this.unHideData()
  173. },
  174. handleChangeSort (row, sort) {
  175. network.getData('/ad/sort', {id: row.ID, sort: sort}).then(response => {
  176. this.getData(this.currentPage, this.pageSize)
  177. }).catch(response => {
  178. })
  179. },
  180. getData (page, pageSize) {
  181. let obj = this
  182. network.getPageData(this, `ad/list/${this.$route.params.lid}`, page, pageSize, null, function (response) {
  183. obj.allData = response
  184. obj.allArticle = response.allArticle
  185. })
  186. },
  187. delData (id = null) {
  188. let obj = this
  189. obj.$confirm('Are you sure to delete the selected data?', 'Notice', { // 确定删除选定的数据?
  190. confirmButtonText: 'confirm', // 确定
  191. cancelButtonText: 'cancel', // 取消
  192. type: 'warning'
  193. }).then(() => {
  194. let selectedIds = []
  195. if (id === null) {
  196. for (let val of obj.multipleSelection) {
  197. selectedIds.push(val.ID)
  198. }
  199. } else {
  200. selectedIds.push(id)
  201. }
  202. return network.postData(`ad/ad-delete`, {
  203. selected: selectedIds
  204. })
  205. }).then(response => {
  206. this.$message({
  207. message: response,
  208. type: 'success'
  209. })
  210. obj.getData(obj.currentPage, obj.pageSize)
  211. }).catch(response => {
  212. })
  213. },
  214. hideData (id = null) {
  215. let obj = this
  216. obj.$confirm('Are you sure to hide the selected data?', 'Notice', { // 确定删除选定的数据?
  217. confirmButtonText: 'confirm', // 确定
  218. cancelButtonText: 'cancel', // 取消
  219. type: 'warning'
  220. }).then(() => {
  221. let selectedIds = []
  222. if (id === null) {
  223. for (let val of obj.multipleSelection) {
  224. selectedIds.push(val.ID)
  225. }
  226. } else {
  227. selectedIds.push(id)
  228. }
  229. return network.postData(`ad/ad-hide`, {
  230. selected: selectedIds
  231. })
  232. }).then(response => {
  233. this.$message({
  234. message: response,
  235. type: 'success'
  236. })
  237. obj.getData(obj.currentPage, obj.pageSize)
  238. }).catch(response => {
  239. })
  240. },
  241. unHideData (id = null) {
  242. let obj = this
  243. obj.$confirm('Are you sure to un-hide the selected data?', 'Notice', { // 确定删除选定的数据?
  244. confirmButtonText: 'confirm', // 确定
  245. cancelButtonText: 'cancel', // 取消
  246. type: 'warning'
  247. }).then(() => {
  248. let selectedIds = []
  249. if (id === null) {
  250. for (let val of obj.multipleSelection) {
  251. selectedIds.push(val.ID)
  252. }
  253. } else {
  254. selectedIds.push(id)
  255. }
  256. return network.postData(`ad/ad-un-hide`, {
  257. selected: selectedIds
  258. })
  259. }).then(response => {
  260. this.$message({
  261. message: response,
  262. type: 'success'
  263. })
  264. obj.getData(obj.currentPage, obj.pageSize)
  265. }).catch(response => {
  266. })
  267. },
  268. getImage(imageUrl) {
  269. return tool.getArImage(imageUrl, '/files/');
  270. },
  271. getContent(aid) {
  272. let titles = this.allArticle.filter(article => article.ID === aid).map(article => article.TITLE);
  273. return titles.length > 0 ? titles[0] : aid;
  274. },
  275. getHref(link) {
  276. return link.indexOf('http') > -1 ? link : 'http://' + link;
  277. },
  278. }
  279. }
  280. </script>
  281. <style scoped>
  282. </style>