YardList.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384
  1. <style>
  2. .ant-modal-body {
  3. padding-top: 0px;
  4. }
  5. li {
  6. list-style-type: none;
  7. }
  8. </style>
  9. <style lang="scss" scoped>
  10. .actor-photo-list {
  11. display: flex;
  12. padding-left: 0;
  13. li {
  14. width: 25%;
  15. margin: 10px;
  16. position: relative;
  17. height: 250px;
  18. border: 1px solid #f2f2f2;
  19. img,
  20. video {
  21. width: 100%;
  22. margin-top: auto;
  23. margin-bottom: auto;
  24. top: 0;
  25. bottom: 0;
  26. position: absolute;
  27. max-height: 250px;
  28. }
  29. }
  30. }
  31. </style>
  32. <template>
  33. <a-card :bordered="false">
  34. <!-- 查询区域 -->
  35. <div class="table-page-search-wrapper">
  36. <a-form layout="inline">
  37. <a-row :gutter="24">
  38. <a-col :md="6" :sm="8">
  39. <a-form-item label="场地名称">
  40. <a-input placeholder="请输入场地名称" v-model="queryParam.buildingName"></a-input>
  41. </a-form-item>
  42. </a-col>
  43. <a-col :md="6" :sm="8">
  44. <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
  45. <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
  46. <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
  47. </span>
  48. </a-col>
  49. </a-row>
  50. </a-form>
  51. </div>
  52. <!-- 操作按钮区域 -->
  53. <div class="table-operator">
  54. <a-button @click="handleAdd" v-show="show" type="primary" icon="plus">新增</a-button>
  55. </div>
  56. <!-- table区域-begin -->
  57. <div>
  58. <a-table ref="table" size="middle" bordered rowKey="id" :columns="columns" :dataSource="dataSource"
  59. :pagination="ipagination" :loading="loading">
  60. <!-- 字符串超长截取省略号显示-->
  61. <span slot="esContent" slot-scope="text">
  62. <j-ellipsis :value="text" :length="10" />
  63. </span>
  64. <span slot="action" slot-scope="text, record">
  65. <a href="javascript:;" @click="handleDetail(record)">详情</a>
  66. <a-divider type="vertical" />
  67. <a-dropdown>
  68. <a class="ant-dropdown-link">
  69. 更多
  70. <a-icon type="down" />
  71. </a>
  72. <a-menu slot="overlay">
  73. <a-menu-item v-show="show">
  74. <a @click="handleEdit(record)">编辑</a>
  75. </a-menu-item>
  76. </a-menu>
  77. </a-dropdown>
  78. <a-divider type="vertical" />
  79. <a href="javascript:;" @click="showDetail(record)">场地信息</a>
  80. </span>
  81. </a-table>
  82. </div>
  83. <!-- table区域-end -->
  84. <!-- 表单区域 -->
  85. <a-modal title="查看场地大图" v-model="imgDetail" class="ping" :footer="null" :width="600" style="overflow:hidden">
  86. <img :src="imgUrl" alt="" style="width:100%">
  87. </a-modal>
  88. <a-modal title="详情" v-model="detail" class="ping" :footer="null" :width="800" style="overflow:hidden">
  89. <a-tabs defaultActiveKey="1" @change="callback" v-model="indexDetail">
  90. <a-tab-pane tab="场地图集" key="1" forceRender>
  91. <div>
  92. <a type="primary" style="margin-left:10px" @click="addPhoto=true">新增场地图片</a>
  93. <ul class="actor-photo-list">
  94. <li v-for="(item,index) of photoList" :key="index" @click="showImage(item)">
  95. <a-icon type="close-circle"
  96. style="position:absolute;top:-5px;right:-5px;color:red;z-index:10;cursor: pointer;"
  97. @click="deteleImg(item.id)" />
  98. <img :src="item.photoUrl" alt />
  99. </li>
  100. </ul>
  101. </div>
  102. <div style="text-align:right" v-if="photoList.length>0">
  103. <a-pagination showQuickJumper size="small" :total="total" @change="pageChange" :pageSize.sync="pageSize" />
  104. </div>
  105. </a-tab-pane>
  106. <a-tab-pane tab="场地视频" key="2">
  107. <div>
  108. <a type="primary" style="margin-left:10px" @click="addVideo=true">新增场地视频</a>
  109. <ul class="actor-photo-list">
  110. <li v-for="(item,index) of videoList" :key="index">
  111. <a-icon type="close-circle"
  112. style="position:absolute;top:-5px;right:-5px;color:red;z-index:10;cursor: pointer;"
  113. @click="deteleVideo(item.id)" />
  114. <video class="video" :src="item.videoUrl" controls="controls" style="min-height:160px">您的浏览器不支持 video
  115. 标签。</video>
  116. </li>
  117. </ul>
  118. </div>
  119. <div style="text-align:right" v-if="videoList.length>0">
  120. <a-pagination showQuickJumper size="small" :total="videoTotal" @change="pageChange"
  121. :pageSize.sync="pageSize" />
  122. </div>
  123. </a-tab-pane>
  124. </a-tabs>
  125. </a-modal>
  126. <!-- 新增图集 -->
  127. <a-modal v-model="addPhoto" title="新增图集" @ok="handleOk('photo')" @cancel="handleCancel('photo')">
  128. <upload-to-ali style="margin:10px" v-model="imageUrl" :customDomain="customDomain" preview :region="region"
  129. :bucket="bucket" :accept="acceptImage" :max="1" :size="1024000" :accessKeyId="accessKeyId"
  130. :accessKeySecret="accessKeySecret"></upload-to-ali>
  131. </a-modal>
  132. <!-- 新增作品 -->
  133. <a-modal v-model="addVideo" title="新增作品" @ok="handleOk('video')" @cancel="handleCancel('video')">
  134. <upload-to-ali style="margin:10px" v-model="videoUrl" :customDomain="customDomain" preview :region="region"
  135. :bucket="bucket" :accept="acceptVideo" :max="1" :size="1024000" :accessKeyId="accessKeyId"
  136. :accessKeySecret="accessKeySecret"></upload-to-ali>
  137. </a-modal>
  138. <yard-modal ref="modalForm" @ok="modalFormOk"></yard-modal>
  139. </a-card>
  140. </template>
  141. <script>
  142. import YardModal from './modules/YardModal'
  143. import yardDetail from './modules/yardDetail'
  144. import {
  145. JeecgListMixin
  146. } from '@/mixins/JeecgListMixin'
  147. import JEllipsis from '@/components/jeecg/JEllipsis'
  148. import UploadToAli from '@femessage/upload-to-ali'
  149. import {
  150. yardPhotoList,
  151. yardVideoList,
  152. yardPhotoDelete,
  153. yardVideoDelete,
  154. yardPhotoAdd,
  155. yardVideoAdd
  156. } from '@/api/yard'
  157. export default {
  158. name: 'YardList',
  159. mixins: [JeecgListMixin],
  160. components: {
  161. JEllipsis,
  162. YardModal,
  163. UploadToAli
  164. },
  165. data() {
  166. return {
  167. queryParam: {},
  168. description: '场地管理',
  169. // 新增修改按钮是否显示
  170. show: true,
  171. imgUrl: '',
  172. imgDetail: false,
  173. // 表头
  174. columns: [{
  175. title: 'ID',
  176. align: 'center',
  177. dataIndex: 'id'
  178. },
  179. {
  180. title: '场地名称',
  181. align: 'center',
  182. dataIndex: 'buildingName'
  183. },
  184. {
  185. title: '地址',
  186. align: 'center',
  187. dataIndex: 'address'
  188. },
  189. {
  190. title: '联系人',
  191. align: 'center',
  192. dataIndex: 'contactName'
  193. },
  194. {
  195. title: '联系电话',
  196. align: 'center',
  197. dataIndex: 'contactMobile'
  198. },
  199. {
  200. title: '创建时间',
  201. align: 'center',
  202. dataIndex: 'createTime'
  203. },
  204. {
  205. title: '操作',
  206. dataIndex: 'action',
  207. align: 'center',
  208. scopedSlots: {
  209. customRender: 'action'
  210. }
  211. }
  212. ],
  213. url: {
  214. list: '/ctop/yard/list'
  215. },
  216. detail: false,
  217. indexDetail: '1',
  218. currentPage: 1,
  219. pageSize: 4,
  220. videoTotal: 0,
  221. photoTotal: 0,
  222. total: 0,
  223. videoList: [],
  224. photoList: [],
  225. imageUrl: '',
  226. videoUrl: '',
  227. customDomain: '',
  228. region: 'oss-cn-beijing',
  229. bucket: 'ctop-media',
  230. acceptVideo: 'video/mpeg,video/mp4',
  231. acceptImage: 'image/jpeg,image/jpg,image/png',
  232. accessKeyId: 'LTAIbNbqWzSOklQV',
  233. accessKeySecret: '1rkPz7JNoXk8sJevPaeYHWqfkQXBGh',
  234. addPhoto: false,
  235. addVideo: false,
  236. confirmLoading: true
  237. }
  238. },
  239. methods: {
  240. showDetail(item) {
  241. console.log(item)
  242. this.detail = true
  243. this.id = item.id
  244. // this.currentPage = 1
  245. this.getPhoto()
  246. },
  247. callback(key) {
  248. console.log(key)
  249. this.photoList = []
  250. this.videoList = []
  251. if (key == '1') {
  252. this.currentPage = 1
  253. this.getPhoto()
  254. } else if (key == '2') {
  255. this.currentPage = 1
  256. this.getVideo()
  257. }
  258. },
  259. pageChange: function (page) {
  260. console.log(page)
  261. this.currentPage = page
  262. if (this.indexDetail == '1') {
  263. this.getPhoto()
  264. } else if (this.indexDetail == '2') {
  265. this.getVideo()
  266. }
  267. },
  268. getPhoto() {
  269. // this.photoList = []
  270. yardPhotoList({
  271. pageNo: this.currentPage,
  272. pageSize: 4,
  273. yardId: this.id
  274. }).then(res => {
  275. if (res.code == 0) {
  276. console.log(res)
  277. this.photoList = res.result.records
  278. this.total = res.result.total
  279. }
  280. })
  281. },
  282. getVideo() {
  283. this.videoList = []
  284. yardVideoList({
  285. pageNo: this.currentPage,
  286. pageSize: 4,
  287. yardId: this.id
  288. }).then(res => {
  289. if (res.code == 0) {
  290. console.log(res)
  291. this.videoList = res.result.records
  292. this.videoTotal = res.result.total
  293. }
  294. })
  295. },
  296. handleOk(type) {
  297. const that = this
  298. if (type == 'photo') {
  299. yardPhotoAdd({
  300. yardId: that.id,
  301. photoUrl: that.imageUrl
  302. })
  303. .then(res => {
  304. if (res.success) {
  305. this.getPhoto()
  306. this.handleCancel('photo')
  307. } else {
  308. that.$message.warning(res.message)
  309. }
  310. })
  311. .finally(() => {
  312. that.confirmLoading = false
  313. that.handleCancel('photo')
  314. })
  315. } else {
  316. yardVideoAdd({
  317. yardId: that.id,
  318. videoUrl: that.videoUrl
  319. })
  320. .then(res => {
  321. if (res.success) {
  322. this.getVideo()
  323. this.handleCancel('video')
  324. } else {
  325. that.$message.warning(res.message)
  326. }
  327. })
  328. .finally(() => {
  329. that.confirmLoading = false
  330. that.handleCancel('video')
  331. })
  332. }
  333. },
  334. handleCancel(type) {
  335. if (type == 'photo') {
  336. this.imageUrl = ''
  337. this.addPhoto = false
  338. } else {
  339. this.videoUrl = ''
  340. this.addVideo = false
  341. }
  342. },
  343. showImage(item) {
  344. this.imgDetail = true
  345. this.imgUrl = item.photoUrl
  346. },
  347. deteleImg(id) {
  348. yardPhotoDelete({
  349. id: id
  350. }).then(res => {
  351. if (res.code == 200) {
  352. console.log(res)
  353. this.getPhoto()
  354. }
  355. })
  356. },
  357. deteleVideo(id) {
  358. yardVideoDelete({
  359. id: id
  360. }).then(res => {
  361. if (res.code == 200) {
  362. console.log(res)
  363. this.getVideo()
  364. }
  365. })
  366. }
  367. }
  368. }
  369. </script>
  370. <style scoped>
  371. @import '~@assets/less/common.less';
  372. </style>