YardList.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388
  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. <uploadFile :value.sync="imageUrl" :fileCount="1" uploadType="image" :multiple="false" />
  129. <!-- <upload-to-ali style="margin:10px" v-model="imageUrl" :customDomain="customDomain" preview :region="region"
  130. :bucket="bucket" :accept="acceptImage" :max="1" :size="1024000" :accessKeyId="accessKeyId"
  131. :accessKeySecret="accessKeySecret"></upload-to-ali> -->
  132. </a-modal>
  133. <!-- 新增作品 -->
  134. <a-modal v-model="addVideo" title="新增作品" @ok="handleOk('video')" @cancel="handleCancel('video')">
  135. <uploadFile :value.sync="videoUrl" :fileCount="1" uploadType="video" :multiple="false" />
  136. <!-- <upload-to-ali style="margin:10px" v-model="videoUrl" :customDomain="customDomain" preview :region="region"
  137. :bucket="bucket" :accept="acceptVideo" :max="1" :size="1024000" :accessKeyId="accessKeyId"
  138. :accessKeySecret="accessKeySecret"></upload-to-ali> -->
  139. </a-modal>
  140. <yard-modal ref="modalForm" @ok="modalFormOk"></yard-modal>
  141. </a-card>
  142. </template>
  143. <script>
  144. import YardModal from './modules/YardModal'
  145. import yardDetail from './modules/yardDetail'
  146. import {
  147. JeecgListMixin
  148. } from '@/mixins/JeecgListMixin'
  149. import JEllipsis from '@/components/jeecg/JEllipsis'
  150. import UploadToAli from '@femessage/upload-to-ali'
  151. import uploadFile from '@/components/uploadFile.vue'
  152. import {
  153. yardPhotoList,
  154. yardVideoList,
  155. yardPhotoDelete,
  156. yardVideoDelete,
  157. yardPhotoAdd,
  158. yardVideoAdd
  159. } from '@/api/yard'
  160. export default {
  161. name: 'YardList',
  162. mixins: [JeecgListMixin],
  163. components: {
  164. JEllipsis,
  165. YardModal,
  166. UploadToAli,
  167. uploadFile
  168. },
  169. data() {
  170. return {
  171. queryParam: {},
  172. description: '场地管理',
  173. // 新增修改按钮是否显示
  174. show: true,
  175. imgUrl: '',
  176. imgDetail: false,
  177. // 表头
  178. columns: [{
  179. title: 'ID',
  180. align: 'center',
  181. dataIndex: 'id'
  182. },
  183. {
  184. title: '场地名称',
  185. align: 'center',
  186. dataIndex: 'buildingName'
  187. },
  188. {
  189. title: '地址',
  190. align: 'center',
  191. dataIndex: 'address'
  192. },
  193. {
  194. title: '联系人',
  195. align: 'center',
  196. dataIndex: 'contactName'
  197. },
  198. {
  199. title: '联系电话',
  200. align: 'center',
  201. dataIndex: 'contactMobile'
  202. },
  203. {
  204. title: '创建时间',
  205. align: 'center',
  206. dataIndex: 'createTime'
  207. },
  208. {
  209. title: '操作',
  210. dataIndex: 'action',
  211. align: 'center',
  212. scopedSlots: {
  213. customRender: 'action'
  214. }
  215. }
  216. ],
  217. url: {
  218. list: '/ctop/yard/list'
  219. },
  220. detail: false,
  221. indexDetail: '1',
  222. currentPage: 1,
  223. pageSize: 4,
  224. videoTotal: 0,
  225. photoTotal: 0,
  226. total: 0,
  227. videoList: [],
  228. photoList: [],
  229. imageUrl: '',
  230. videoUrl: '',
  231. customDomain: '',
  232. region: 'oss-cn-beijing',
  233. bucket: 'ctop-media',
  234. acceptVideo: 'video/mpeg,video/mp4',
  235. acceptImage: 'image/jpeg,image/jpg,image/png',
  236. accessKeyId: 'LTAIbNbqWzSOklQV',
  237. accessKeySecret: '1rkPz7JNoXk8sJevPaeYHWqfkQXBGh',
  238. addPhoto: false,
  239. addVideo: false,
  240. confirmLoading: true
  241. }
  242. },
  243. methods: {
  244. showDetail(item) {
  245. console.log(item)
  246. this.detail = true
  247. this.id = item.id
  248. // this.currentPage = 1
  249. this.getPhoto()
  250. },
  251. callback(key) {
  252. console.log(key)
  253. this.photoList = []
  254. this.videoList = []
  255. if (key == '1') {
  256. this.currentPage = 1
  257. this.getPhoto()
  258. } else if (key == '2') {
  259. this.currentPage = 1
  260. this.getVideo()
  261. }
  262. },
  263. pageChange: function (page) {
  264. console.log(page)
  265. this.currentPage = page
  266. if (this.indexDetail == '1') {
  267. this.getPhoto()
  268. } else if (this.indexDetail == '2') {
  269. this.getVideo()
  270. }
  271. },
  272. getPhoto() {
  273. // this.photoList = []
  274. yardPhotoList({
  275. pageNo: this.currentPage,
  276. pageSize: 4,
  277. yardId: this.id
  278. }).then(res => {
  279. if (res.code == 0) {
  280. console.log(res)
  281. this.photoList = res.result.records
  282. this.total = res.result.total
  283. }
  284. })
  285. },
  286. getVideo() {
  287. this.videoList = []
  288. yardVideoList({
  289. pageNo: this.currentPage,
  290. pageSize: 4,
  291. yardId: this.id
  292. }).then(res => {
  293. if (res.code == 0) {
  294. console.log(res)
  295. this.videoList = res.result.records
  296. this.videoTotal = res.result.total
  297. }
  298. })
  299. },
  300. handleOk(type) {
  301. const that = this
  302. if (type == 'photo') {
  303. yardPhotoAdd({
  304. yardId: that.id,
  305. photoUrl: that.imageUrl
  306. })
  307. .then(res => {
  308. if (res.success) {
  309. this.getPhoto()
  310. this.handleCancel('photo')
  311. } else {
  312. that.$message.warning(res.message)
  313. }
  314. })
  315. .finally(() => {
  316. that.confirmLoading = false
  317. that.handleCancel('photo')
  318. })
  319. } else {
  320. yardVideoAdd({
  321. yardId: that.id,
  322. videoUrl: that.videoUrl
  323. })
  324. .then(res => {
  325. if (res.success) {
  326. this.getVideo()
  327. this.handleCancel('video')
  328. } else {
  329. that.$message.warning(res.message)
  330. }
  331. })
  332. .finally(() => {
  333. that.confirmLoading = false
  334. that.handleCancel('video')
  335. })
  336. }
  337. },
  338. handleCancel(type) {
  339. if (type == 'photo') {
  340. this.imageUrl = ''
  341. this.addPhoto = false
  342. } else {
  343. this.videoUrl = ''
  344. this.addVideo = false
  345. }
  346. },
  347. showImage(item) {
  348. this.imgDetail = true
  349. this.imgUrl = item.photoUrl
  350. },
  351. deteleImg(id) {
  352. yardPhotoDelete({
  353. id: id
  354. }).then(res => {
  355. if (res.code == 200) {
  356. console.log(res)
  357. this.getPhoto()
  358. }
  359. })
  360. },
  361. deteleVideo(id) {
  362. yardVideoDelete({
  363. id: id
  364. }).then(res => {
  365. if (res.code == 200) {
  366. console.log(res)
  367. this.getVideo()
  368. }
  369. })
  370. }
  371. }
  372. }
  373. </script>
  374. <style scoped>
  375. @import '~@assets/less/common.less';
  376. </style>