exhibitorList.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  1. <script>
  2. import Vue from 'vue'
  3. import expoPopover from '@/views/components/expoPopover.vue'
  4. import { getExpoList, deleteExpo, setExpoStatus } from '@/api/expo'
  5. import { copyValue } from '@/utils'
  6. export default Vue.extend({
  7. name: 'Index',
  8. components: {
  9. expoPopover
  10. },
  11. data() {
  12. return {
  13. expoList: [],
  14. current_page: 0,
  15. last_page: 1,
  16. total: 0,
  17. page_size: 20,
  18. searchWord: '',
  19. searchTimer: null,
  20. loading: false,
  21. popover_data: {},
  22. ossUrl: process.env.VUE_APP_OSS_DOMAIN
  23. }
  24. },
  25. mounted() {
  26. this.getList()
  27. },
  28. methods: {
  29. copyValue,
  30. search(event) {
  31. if (this.searchTimer) {
  32. clearTimeout(this.searchTimer)
  33. }
  34. this.searchTimer = setTimeout(() => {
  35. this.current_page = 1
  36. this.getList()
  37. }, 500)
  38. },
  39. edit(row) {
  40. if (row.form_count) {
  41. this.$notify({
  42. title: '提示',
  43. message: '此展会已经有人报名了,无法修改',
  44. type: 'warning'
  45. })
  46. return
  47. }
  48. this.$router.push({ path: '/exhibitor/edit/' + row.id })
  49. },
  50. copy(row) {
  51. this.$router.push({ path: '/exhibitor/add?copy=' + row.id })
  52. },
  53. setStatus(row) {
  54. this.loading = true
  55. setExpoStatus(row.id, row.status ? 0 : 1).then(res => {
  56. this.loading = false
  57. this.refresh()
  58. }).catch(err => {
  59. this.loading = false
  60. })
  61. },
  62. del(row) {
  63. this.$confirm('确定删除展商"' + row.expo_name + '"吗?此操作无法撤销!', '删除展商', {
  64. confirmButtonText: '确定',
  65. cancelButtonText: '取消',
  66. type: 'warning',
  67. callback: action => {
  68. if (action === 'confirm') {
  69. deleteExpo(row.id).then(res => {
  70. this.loading = false
  71. this.refresh()
  72. }).catch(err => {
  73. this.loading = false
  74. })
  75. }
  76. }
  77. })
  78. },
  79. refresh() {
  80. if (this.loading || this.current_page > this.last_page) return
  81. this.loading = true
  82. getExpoList(this.current_page, this.page_size, this.searchWord).then(res => {
  83. this.current_page = res.data.current_page
  84. this.last_page = res.data.last_page
  85. this.total = res.data.total
  86. this.expoList = res.data.data
  87. this.loading = false
  88. })
  89. },
  90. getList() {
  91. if (this.loading || this.current_page >= this.last_page) return
  92. this.loading = true
  93. getExpoList(this.current_page, this.page_size, this.searchWord).then(res => {
  94. this.current_page = res.data.current_page
  95. this.last_page = res.data.last_page
  96. this.total = res.data.total
  97. this.expoList = res.data.data
  98. this.loading = false
  99. })
  100. },
  101. add() {
  102. this.$router.push({ path: '/exhibitor/add' })
  103. }
  104. }
  105. })
  106. </script>
  107. <template>
  108. <div class="main-box">
  109. <div class="head">
  110. <el-input v-model="searchWord" v-permission="'exhibitor.search'" prefix-icon="el-icon-search" placeholder="搜索展商名称" class="input" @input="search">
  111. <el-button v-if="searchWord" slot="append" icon="el-icon-delete" @click="searchWord='';search()" />
  112. </el-input>
  113. <el-button v-permission="'exhibitor.addList'" icon="el-icon-plus" type="primary" @click="add">添加展商</el-button>
  114. </div>
  115. <div class="body">
  116. <el-table v-loading="loading" :data="expoList" height="100%" class="table">
  117. <el-table-column
  118. label="展商名称"
  119. prop="expo_name"
  120. width="300"
  121. :show-overflow-tooltip="true"
  122. />
  123. <el-table-column
  124. label="状态"
  125. width="80"
  126. >
  127. <template slot-scope="scope">
  128. <div :class="['status','type-'+scope.row.status]">
  129. {{ ['正常','禁用'][scope.row.status] }}
  130. </div>
  131. </template>
  132. </el-table-column>
  133. <<el-table-column
  134. label="预约观众"
  135. width="80"
  136. prop="form_count"
  137. />
  138. <el-table-column
  139. label="展会地点"
  140. prop="location"
  141. width="300"
  142. :show-overflow-tooltip="true"
  143. />
  144. <el-table-column
  145. label="主办单位"
  146. prop="organizer"
  147. width="300"
  148. :show-overflow-tooltip="true"
  149. />
  150. <el-table-column
  151. label="联系电话"
  152. prop="contact_phone"
  153. width="200"
  154. />
  155. <el-table-column
  156. label="联系邮箱"
  157. prop="contact_email"
  158. width="200"
  159. />
  160. <el-table-column
  161. label="开始时间"
  162. prop="start_date"
  163. width="200"
  164. />
  165. <el-table-column
  166. label="结束时间"
  167. prop="end_date"
  168. width="200"
  169. />
  170. <el-table-column
  171. label="最后编辑"
  172. prop="update_time"
  173. width="200"
  174. />
  175. <el-table-column
  176. label="操作"
  177. fixed="right"
  178. width="210"
  179. >
  180. <template slot-scope="scope">
  181. <expo-popover placement="left" trigger="click" :expo-id="''+scope.row.id">
  182. <span v-permission="'exhibitor.handelView'" class="button">预览</span>
  183. </expo-popover>
  184. <span v-permission="'exhibitor.handelEdit'" :class="['button',scope.row.form_count?'disable':'']" @click="edit(scope.row)">编辑</span>
  185. <span v-permission="'exhibitor.handelCopy'" class="button" @click="copy(scope.row)">复制</span>
  186. <span v-permission="'exhibitor.handelDisable'" class="button" @click="setStatus(scope.row)">{{ scope.row.status?'启用':'禁用' }}</span>
  187. <span v-permission="'exhibitor.handelDelete'" class="button del" @click="del(scope.row)">删除</span>
  188. </template>
  189. </el-table-column>
  190. </el-table>
  191. </div>
  192. <div class="foot">
  193. <el-pagination
  194. background
  195. :page-size="page_size"
  196. layout="total"
  197. :total="total"
  198. />
  199. <el-pagination
  200. v-permission="'exhibitor.handel'"
  201. background
  202. :page-size="page_size"
  203. layout="prev, pager, next"
  204. :total="total"
  205. @current-change="current_page=$event;getList()"
  206. />
  207. </div>
  208. </div>
  209. </template>
  210. <style scoped lang="scss">
  211. @use '@/styles/variables.scss' as *;
  212. .main-box{
  213. height: 100%;
  214. display: grid;
  215. grid-template-rows: auto 1fr auto;
  216. grid-gap: 24px;
  217. .head{
  218. display: flex;
  219. .input{
  220. width: 50%;
  221. margin-right: auto;
  222. }
  223. }
  224. .body{
  225. height: 100%;
  226. position: relative;
  227. .table{
  228. width: 100%;
  229. height: 100%;
  230. position: absolute;
  231. top: 0;
  232. left: 0;
  233. .button{
  234. cursor: pointer;
  235. padding: 0 5px;
  236. color: $menuActiveText;
  237. &.del{
  238. color: #DC2626;
  239. }
  240. &.disable{
  241. cursor: not-allowed;
  242. color: grey;
  243. }
  244. }
  245. .status{
  246. padding: 0 12px;
  247. border-radius: 32px;
  248. width: fit-content;
  249. &.type-0{
  250. background: #DCFCE7;
  251. color: #166534;
  252. }
  253. &.type-1{
  254. background: #FEE2E2;
  255. color: #991B1B;
  256. }
  257. }
  258. }
  259. }
  260. .foot{
  261. display: flex;
  262. justify-content: space-between;
  263. }
  264. }
  265. </style>