YardList.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493
  1. <style>
  2. li {
  3. list-style-type: none;
  4. }
  5. </style>
  6. <style lang="scss" scoped>
  7. .actor-photo-list {
  8. display: flex;
  9. padding-left: 0;
  10. li {
  11. width: 25%;
  12. margin: 10px;
  13. position: relative;
  14. height: 250px;
  15. border: 1px solid #f2f2f2;
  16. img,
  17. video {
  18. width: 100%;
  19. margin-top: auto;
  20. margin-bottom: auto;
  21. top: 0;
  22. bottom: 0;
  23. position: absolute;
  24. max-height: 250px;
  25. }
  26. }
  27. }
  28. </style>
  29. <template>
  30. <a-card :bordered="false">
  31. <!-- 查询区域 -->
  32. <div class="table-page-search-wrapper">
  33. <a-form layout="inline">
  34. <a-row :gutter="24">
  35. <a-col :md="6" :sm="8">
  36. <a-form-item label="场地名称">
  37. <a-input placeholder="请输入场地名称" v-model="queryParam.buildingName"></a-input>
  38. </a-form-item>
  39. </a-col>
  40. <a-col :md="6" :sm="8">
  41. <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
  42. <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
  43. <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
  44. </span>
  45. </a-col>
  46. </a-row>
  47. </a-form>
  48. </div>
  49. <!-- 操作按钮区域 -->
  50. <div class="table-operator">
  51. <a-button @click="handleAdd" v-show="show" type="primary" icon="plus">新增</a-button>
  52. <a-pagination showQuickJumper :total="ipagination.total" v-model="ipagination.current" style="float:right" @change="totalpageChange" :pageSize.sync="ipagination.pageSize" />
  53. </div>
  54. <!-- table区域-begin -->
  55. <div>
  56. <!-- <a-table ref="table" size="middle" bordered rowKey="id" :columns="columns" :dataSource="dataSource"
  57. :pagination="ipagination" :loading="loading">
  58. <span slot="esContent" slot-scope="text">
  59. <j-ellipsis :value="text" :length="10" />
  60. </span>
  61. <span slot="action" slot-scope="text, record">
  62. <a href="javascript:;" @click="handleDetail(record)">详情</a>
  63. <a-divider type="vertical" />
  64. <a-dropdown>
  65. <a class="ant-dropdown-link">
  66. 更多
  67. <a-icon type="down" />
  68. </a>
  69. <a-menu slot="overlay">
  70. <a-menu-item v-show="show">
  71. <a @click="handleEdit(record)">编辑</a>
  72. </a-menu-item>
  73. <a-menu-item v-show="show">
  74. <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
  75. <a>删除</a>
  76. </a-popconfirm>
  77. </a-menu-item>
  78. </a-menu>
  79. </a-dropdown>
  80. <a-divider type="vertical" />
  81. <a href="javascript:;" @click="showDetail(record)">场地信息</a>
  82. </span>
  83. </a-table> -->
  84. <a-row class="image-list" :gutter="16" style="padding:0 8px">
  85. <a-col :lg="6" :sm="12" class="vm-margin" style="padding:0" v-for="(item, index) of dataSource" :key="index" >
  86. <vm-card
  87. style="margin: 0 15px;"
  88. :editable="true"
  89. :title="item.buildingName"
  90. :img="item.coverUrl"
  91. :desc="item.address"
  92. :detailUrl="item.videoUrl"
  93. :editUrl="item.editUrl"
  94. pageTitle='场地列表'
  95. :id="item.id"
  96. :record="item"
  97. @delete-ok="deleteOk(item)"
  98. @showDetail='showDetail(item)'
  99. @editDetail='handleEdit(item)'
  100. @updateList='updateList(1)'
  101. ></vm-card>
  102. </a-col>
  103. </a-row>
  104. </div>
  105. <!-- table区域-end -->
  106. <!-- 表单区域 -->
  107. <a-modal title="查看场地大图" v-model="imgDetail" class="ping" :footer="null" :width="600" style="overflow:hidden">
  108. <img :src="imgUrl" alt="" style="width:100%">
  109. </a-modal>
  110. <a-modal title="详情" v-model="detail" class="ping" :footer="null" :width="800" style="overflow:hidden">
  111. <a-tabs defaultActiveKey="1" @change="callback" v-model="indexDetail">
  112. <a-tab-pane tab="场地图集" key="1" forceRender>
  113. <div>
  114. <a type="primary" style="margin-left:10px" @click="addPhoto=true">新增场地图片</a>
  115. <ul class="actor-photo-list">
  116. <li v-for="(item,index) of photoList" :key="index" @click="showImage(item)">
  117. <a-icon type="close-circle"
  118. style="position:absolute;top:-5px;right:-5px;color:red;z-index:10;cursor: pointer;"
  119. @click.stop="deteleImg(item.id)" />
  120. <img :src="item.photoUrl" alt />
  121. </li>
  122. </ul>
  123. </div>
  124. <div style="text-align:right" v-if="photoList.length>0">
  125. <a-pagination showQuickJumper size="small" :total="total" @change="pageChange" :pageSize.sync="pageSize" />
  126. </div>
  127. </a-tab-pane>
  128. <a-tab-pane tab="场地信息" key="2">
  129. <div style="display:flex;flex-direction:row;height:300px;">
  130. <div
  131. style="height:200px;width:30%;border:1px solid #f2f2f2;"
  132. :style="{backgroundImage: imageUrl?'url(' +imageUrl+')':'url('+noImgUrl+')', backgroundSize:'contain', backgroundRepeat: 'no-repeat',backgroundPosition:'center center'}"
  133. ></div>
  134. <div style="flex:1;margin:15px">
  135. <a-form >
  136. <a-form-item label="场地名称" :label-col="{ span: 5 }" :wrapper-col="{ span: 12 }">
  137. <span>{{currentYard.buildingName}}</span>
  138. </a-form-item>
  139. <a-form-item label="场地地址" :label-col="{ span: 5 }" :wrapper-col="{ span: 12 }">
  140. <span>{{currentYard.address}}</span>
  141. </a-form-item>
  142. <a-form-item label="联系人名" :label-col="{ span: 5 }" :wrapper-col="{ span: 12 }">
  143. <span>{{currentYard.contactName}}</span>
  144. </a-form-item>
  145. <a-form-item label="联系电话" :label-col="{ span: 5 }" :wrapper-col="{ span: 12 }">
  146. <span>{{currentYard.contactMobile}}</span>
  147. </a-form-item>
  148. </a-form>
  149. </div>
  150. </div>
  151. </a-tab-pane>
  152. <a-tab-pane tab="场地视频" key="3">
  153. <div>
  154. <a type="primary" style="margin-left:10px" @click="addVideo=true">新增场地视频</a>
  155. <ul class="actor-photo-list">
  156. <li v-for="(item,index) of videoList" :key="index">
  157. <a-icon type="close-circle"
  158. style="position:absolute;top:-5px;right:-5px;color:red;z-index:10;cursor: pointer;"
  159. @click="deteleVideo(item.id)" />
  160. <video class="video" :src="item.videoUrl" controls="controls" style="min-height:160px">您的浏览器不支持 video
  161. 标签。</video>
  162. </li>
  163. </ul>
  164. </div>
  165. <div style="text-align:right" v-if="videoList.length>0">
  166. <a-pagination showQuickJumper size="small" :total="videoTotal" @change="pageChange"
  167. :pageSize.sync="pageSize" />
  168. </div>
  169. </a-tab-pane>
  170. </a-tabs>
  171. </a-modal>
  172. <!-- 新增图集 -->
  173. <a-modal v-model="addPhoto" title="新增图集" @ok="handleOk('photo')" @cancel="handleCancel('photo')">
  174. <uploadFile :value.sync="imageUrl" :fileCount="1" uploadType="image" :multiple="false" :sizeCheck="false"/>
  175. <!-- <upload-to-ali style="margin:10px" v-model="imageUrl" :customDomain="customDomain" preview :region="region"
  176. :bucket="bucket" :accept="acceptImage" :max="1" :size="1024000" :accessKeyId="accessKeyId"
  177. :accessKeySecret="accessKeySecret"></upload-to-ali> -->
  178. </a-modal>
  179. <!-- 新增作品 -->
  180. <a-modal v-model="addVideo" title="新增作品" @ok="handleOk('video')" @cancel="handleCancel('video')">
  181. <uploadFile :value.sync="videoUrl" :fileCount="1" uploadType="video" :multiple="false" :sizeCheck="false"/>
  182. <!-- <upload-to-ali style="margin:10px" v-model="videoUrl" :customDomain="customDomain" preview :region="region"
  183. :bucket="bucket" :accept="acceptVideo" :max="1" :size="1024000" :accessKeyId="accessKeyId"
  184. :accessKeySecret="accessKeySecret"></upload-to-ali> -->
  185. </a-modal>
  186. <yard-modal ref="modalForm" @ok="modalFormOk"></yard-modal>
  187. </a-card>
  188. </template>
  189. <script>
  190. import YardModal from './modules/YardModal'
  191. import yardDetail from './modules/yardDetail'
  192. import VmCard from '@/components/ctop/vm-card'
  193. import {
  194. JeecgListMixin
  195. } from '@/mixins/JeecgListMixin'
  196. import JEllipsis from '@/components/jeecg/JEllipsis'
  197. import UploadToAli from '@femessage/upload-to-ali'
  198. import uploadFile from '@/components/uploadFile.vue'
  199. import {
  200. yardPhotoList,
  201. yardVideoList,
  202. yardPhotoDelete,
  203. yardVideoDelete,
  204. yardPhotoAdd,
  205. yardVideoAdd,
  206. yardListDelete
  207. } from '@/api/yard'
  208. export default {
  209. name: 'YardList',
  210. mixins: [JeecgListMixin],
  211. components: {
  212. JEllipsis,
  213. YardModal,
  214. UploadToAli,
  215. uploadFile,
  216. VmCard
  217. },
  218. data() {
  219. return {
  220. ipagination: {
  221. current: 1,
  222. pageSize: 8,
  223. // pageSizeOptions: ['10', '20', '30'],
  224. showTotal: (total, range) => {
  225. return range[0] + "-" + range[1] + " 共" + total + "条"
  226. },
  227. showQuickJumper: true,
  228. showSizeChanger:true,
  229. pageSizeOptions: ['10', '30', '50'],
  230. total: 0,
  231. onChange: (current, pageSize) => {
  232. // 切换分页时的回调,
  233. // 当在页面定义change事件时,切记要把此处的事件清除,因为这两个事件重叠了,可能到时候会导致一些莫名的bug
  234. this.ipagination.current = current;
  235. this.ipagination.pageSize= pageSize;
  236. }
  237. },
  238. noImgUrl:require('@/assets/img/noImg.png'),
  239. queryParam: {},
  240. description: '场地管理',
  241. // 新增修改按钮是否显示
  242. show: true,
  243. imgUrl: '',
  244. imgDetail: false,
  245. // 表头
  246. columns: [{
  247. title: 'ID',
  248. align: 'center',
  249. dataIndex: 'id'
  250. },
  251. {
  252. title: '场地名称',
  253. align: 'center',
  254. dataIndex: 'buildingName'
  255. },
  256. {
  257. title: '地址',
  258. align: 'center',
  259. dataIndex: 'address'
  260. },
  261. {
  262. title: '联系人',
  263. align: 'center',
  264. dataIndex: 'contactName'
  265. },
  266. {
  267. title: '联系电话',
  268. align: 'center',
  269. dataIndex: 'contactMobile'
  270. },
  271. {
  272. title: '创建时间',
  273. align: 'center',
  274. dataIndex: 'createTime'
  275. },
  276. {
  277. title: '操作',
  278. dataIndex: 'action',
  279. align: 'center',
  280. scopedSlots: {
  281. customRender: 'action'
  282. }
  283. }
  284. ],
  285. url: {
  286. list: '/ctop/yard/list',
  287. delete:'/ctop/yard/delete',
  288. },
  289. detail: false,
  290. indexDetail: '1',
  291. currentPage: 1,
  292. pageSize: 4,
  293. videoTotal: 0,
  294. photoTotal: 0,
  295. total: 0,
  296. videoList: [],
  297. photoList: [],
  298. imageUrl: '',
  299. videoUrl: '',
  300. customDomain: '',
  301. region: 'oss-cn-beijing',
  302. bucket: 'ctop-media',
  303. acceptVideo: 'video/mpeg,video/mp4',
  304. acceptImage: 'image/jpeg,image/jpg,image/png',
  305. accessKeyId: 'LTAIbNbqWzSOklQV',
  306. accessKeySecret: '1rkPz7JNoXk8sJevPaeYHWqfkQXBGh',
  307. addPhoto: false,
  308. addVideo: false,
  309. confirmLoading: true,
  310. currentYard:{},
  311. }
  312. },
  313. methods: {
  314. totalpageChange(page){
  315. console.log(page)
  316. this.ipagination.current=page;
  317. this.loadData(this.ipagination.current)
  318. },
  319. showDetail(item) {
  320. console.log(item)
  321. this.currentYard=item
  322. this.detail = true
  323. this.id = item.id
  324. // this.currentPage = 1
  325. this.getPhoto()
  326. },
  327. callback(key) {
  328. console.log(key)
  329. this.photoList = []
  330. this.videoList = []
  331. if (key == '1') {
  332. this.currentPage = 1
  333. this.getPhoto()
  334. } else if (key == '3') {
  335. this.currentPage = 1
  336. this.getVideo()
  337. }
  338. },
  339. pageChange: function (page) {
  340. console.log(page)
  341. this.currentPage = page
  342. if (this.indexDetail == '1') {
  343. this.getPhoto()
  344. } else if (this.indexDetail == '2') {
  345. this.getVideo()
  346. }
  347. },
  348. getPhoto() {
  349. // this.photoList = []
  350. yardPhotoList({
  351. pageNo: this.currentPage,
  352. pageSize: 4,
  353. yardId: this.id
  354. }).then(res => {
  355. if (res.code == 0) {
  356. console.log(res)
  357. this.photoList = res.result.records
  358. this.total = res.result.total
  359. }
  360. })
  361. },
  362. getVideo() {
  363. this.videoList = []
  364. yardVideoList({
  365. pageNo: this.currentPage,
  366. pageSize: 4,
  367. yardId: this.id
  368. }).then(res => {
  369. if (res.code == 0) {
  370. console.log(res)
  371. this.videoList = res.result.records
  372. this.videoTotal = res.result.total
  373. }
  374. })
  375. },
  376. handleOk(type) {
  377. const that = this
  378. if (type == 'photo') {
  379. yardPhotoAdd({
  380. yardId: that.id,
  381. photoUrl: that.imageUrl
  382. })
  383. .then(res => {
  384. if (res.success) {
  385. this.getPhoto()
  386. this.handleCancel('photo')
  387. } else {
  388. that.$message.warning(res.message)
  389. }
  390. })
  391. .finally(() => {
  392. that.confirmLoading = false
  393. that.handleCancel('photo')
  394. })
  395. } else {
  396. yardVideoAdd({
  397. yardId: that.id,
  398. videoUrl: that.videoUrl
  399. })
  400. .then(res => {
  401. if (res.success) {
  402. this.getVideo()
  403. this.handleCancel('video')
  404. } else {
  405. that.$message.warning(res.message)
  406. }
  407. })
  408. .finally(() => {
  409. that.confirmLoading = false
  410. that.handleCancel('video')
  411. })
  412. }
  413. },
  414. handleCancel(type) {
  415. if (type == 'photo') {
  416. this.imageUrl = ''
  417. this.addPhoto = false
  418. } else {
  419. this.videoUrl = ''
  420. this.addVideo = false
  421. }
  422. },
  423. showImage(item) {
  424. this.imgDetail = true
  425. this.imgUrl = item.photoUrl
  426. },
  427. deteleImg(id) {
  428. yardPhotoDelete({
  429. id: id
  430. }).then(res => {
  431. if (res.code == 200) {
  432. console.log(res)
  433. this.getPhoto()
  434. }
  435. })
  436. },
  437. deteleVideo(id) {
  438. yardVideoDelete({
  439. id: id
  440. }).then(res => {
  441. if (res.code == 200) {
  442. console.log(res)
  443. this.getVideo()
  444. }
  445. })
  446. },
  447. deleteOk: function (data) {
  448. console.log('最外层deleteFn执行',data)
  449. yardListDelete({
  450. id:data.id
  451. }).then(res=>{
  452. if(res.success){
  453. this.$message.success('删除成功')
  454. for (let i = 0; i < this.dataSource.length; i++) {
  455. if (this.dataSource[i].id === data.id) {
  456. this.dataSource.splice(i, 1)
  457. }
  458. }
  459. // this.getActorList(data.page)
  460. }else{
  461. this.$message.error('删除失败,稍后再试')
  462. }
  463. })
  464. },
  465. updateList(page){
  466. this.totalpageChange(page)
  467. },
  468. }
  469. }
  470. </script>
  471. <style scoped>
  472. @import '~@assets/less/common.less';
  473. </style>