seatTemplateEdit.vue 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345
  1. <!--
  2. * @Description: 新增/编辑弹框
  3. * @Author: Sugar.
  4. * @Date: 2023-11-24 13:55:00
  5. * @LastEditors: Sugar.
  6. * @LastEditTime: 22023-11-24 13:55:00
  7. * @FilePath: \cattle_webui\src\views\venue\performanceHallMr\dialog\seatTemplateEdit.vue
  8. * @Copyright: Copyright (c) 2016~2023 by Sugar., All Rights Reserved.
  9. -->
  10. <template>
  11. <el-dialog
  12. :visible.sync="open"
  13. width="90%"
  14. append-to-body
  15. :close-on-click-modal="false"
  16. @close="cancel"
  17. :fullscreen="dialogFull"
  18. :show-close="false"
  19. class="ygh-dialog"
  20. >
  21. <template slot="title">
  22. <div class="avue-crud__dialog__header">
  23. <span class="el-dialog__title">
  24. <span style="display:inline-block;background-color: #3478f5;width:3px;height:20px;margin-right:5px; float: left;margin-top:2px"></span>
  25. {{ title }}
  26. </span>
  27. <div class="avue-crud__dialog__menu">
  28. <span class="dialog-footer">
  29. <el-button @click="cancel">关闭</el-button>
  30. <el-button
  31. type="primary"
  32. @click="submitFormCopy"
  33. v-loading.fullscreen.lock="loading"
  34. element-loading-text="提交中..."
  35. element-loading-spinner="el-icon-loading"
  36. element-loading-background="rgba(0, 0, 0, 0.8)"
  37. >
  38. <span v-if="loading">提交中...</span>
  39. <span v-else>保存</span>
  40. </el-button>
  41. </span>
  42. <span style="margin-left: 40px;" @click="dialogFull? dialogFull=false: dialogFull=true">
  43. <i size="" class="el-icon-full-screen"></i>
  44. </span>
  45. <span style="margin-left: 10px;" @click="cancel">
  46. <i class="el-icon-close"></i>
  47. </span>
  48. </div>
  49. </div>
  50. </template>
  51. <div class="dialog-ygh">
  52. <!-- 座位管理器 -->
  53. <seatManagementTable
  54. ref="seatManagementTable"
  55. @saveSeat="submitForm"
  56. />
  57. </div>
  58. </el-dialog>
  59. </template>
  60. <script>
  61. import { seatSaveAndEdit, saveAndEdit, getSelectById } from "@/api/performanceHallMr/performanceHallMr";
  62. import seatManagementTable from "../model/seatManagementTable"
  63. export default {
  64. name: "seatTemplateEdit",
  65. that: this,
  66. components: {
  67. seatManagementTable
  68. },
  69. data() {
  70. return {
  71. title: "座位配置",
  72. open: false, // 打开弹窗
  73. loading: false,
  74. seatWidth: null,
  75. seatMap: {
  76. row: 0,
  77. col: 0,
  78. },
  79. colSeatMap: {},
  80. form: {
  81. id: undefined,
  82. status: "1",
  83. content: "",
  84. },
  85. seatList: [],
  86. auditoriumId: '',
  87. zoom: 10,
  88. boxWidth: '',
  89. initWidth: '',
  90. moveStatus: false,
  91. mouseMap: {},
  92. mousemoveMap: {},
  93. scrollTop: 0,
  94. scrollLeft: 0,
  95. scrollEvenTop: 0,
  96. scrollEvenLeft: 0,
  97. dragStatus: true,
  98. canNum: [],
  99. unCanNum: [],
  100. drawForm: {
  101. status: '1'
  102. },
  103. dialogFull: false, // 全屏状态
  104. };
  105. },
  106. methods: {
  107. /**
  108. * 打开弹框
  109. * @date 2023-11-22
  110. * @param {any} obj
  111. * @returns {any}
  112. */
  113. openDialog(title, obj) {
  114. console.log('obj====',obj)
  115. this.open = true;
  116. this.colSeatMap = {}
  117. this.boxWidth = 0;
  118. this.dragStatus = true;
  119. this.$set(this.form, 'status', '1')
  120. if (obj){ // 编辑模式
  121. this.title = "座位模板";
  122. this.auditoriumId = obj.id; // 演出厅 ID
  123. this.getSelectByIdApi(obj) // 获取座位
  124. }else{ // 新增模式
  125. this.title = "座位模板";
  126. }
  127. },
  128. /** 获取详情 */
  129. getSelectByIdApi(row) {
  130. const id = row.id
  131. getSelectById(id).then(response => {
  132. const dataList = response.data;
  133. this.$nextTick(() =>{
  134. dataList.forEach(item => {
  135. if(item.status == 2){
  136. item.color = '#7d7d7e';
  137. }
  138. this.$set(this.colSeatMap, item.sortId + '_', item);
  139. })
  140. this.$refs.seatManagementTable.initData(row,dataList,'edit')
  141. })
  142. });
  143. },
  144. /** 调用 座位保存功能 */
  145. submitFormCopy(){
  146. this.$refs.seatManagementTable.saveSeat()
  147. },
  148. /**
  149. * 保存
  150. * @date 2023-11-22
  151. * @returns {any}
  152. */
  153. async submitForm(rowAll,colsAll,list,style) {
  154. console.log('rowAll,colsAll,list,style===',rowAll,colsAll,list,style)
  155. try {
  156. this.loading = true;
  157. /** 保存行号 */
  158. const { code } = await saveAndEdit({
  159. id: this.auditoriumId,
  160. rows: rowAll,
  161. cols: colsAll,
  162. styleCss: style
  163. });
  164. if (code === 200) {
  165. let listCopy = []
  166. list.forEach((item,index)=>{
  167. listCopy.push({
  168. ...item,
  169. auditoriumId: this.auditoriumId
  170. })
  171. })
  172. /** 保存座位 */
  173. const { code } = await seatSaveAndEdit(listCopy);
  174. if (code === 200) {
  175. this.$message.success("操作成功!");
  176. this.$emit("getList");
  177. this.cancel();
  178. }
  179. }
  180. } catch (error) {
  181. console.error("error===",error)
  182. } finally {
  183. this.loading = false;
  184. }
  185. },
  186. /**
  187. * 关闭弹框
  188. * @date 2023-11-22
  189. * @returns {any}
  190. */
  191. cancel() {
  192. this.open = false;
  193. },
  194. },
  195. };
  196. </script>
  197. <style lang="scss" scoped>
  198. .dialog-ygh {
  199. // padding: 0 30px;
  200. height: calc( 100vh - 20vh );
  201. overflow-y: auto;
  202. }
  203. .draw-dialog-class{
  204. border-radius: 10px;
  205. height: 240px;
  206. width: 220px;
  207. background-color: #fff;
  208. position: absolute;
  209. z-index: 55;
  210. box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
  211. }
  212. .dialog-ygh {
  213. //padding: 0 30px;
  214. .title-class{
  215. text-align: center;
  216. color: #6e6e6e;
  217. margin: 10px auto;
  218. }
  219. .box-top-class{
  220. .stage-class{
  221. margin: 10px auto;
  222. width: 160px;
  223. height: 80px;
  224. border: 2px solid #7d7d7e;
  225. text-align: center;
  226. line-height: 80px;
  227. }
  228. }
  229. .box-class ::-webkit-scrollbar{ /*滚动条基本样式,高度*/
  230. width:10px;height:10px;
  231. }
  232. .box-class{
  233. width: 100%;
  234. height: 500px;
  235. border: 2px solid #7d7d7e;
  236. border-radius: 4px;
  237. padding: 10px;
  238. .box-bottom-class{
  239. //border: 2px solid #5656c2;
  240. //margin-top: 15px;
  241. //padding-left: 4px;
  242. .seat-tag{
  243. display: inline-block;
  244. border: 1px solid #7d7d7e;
  245. margin-right: 2px;
  246. cursor: pointer;
  247. background: url("../../../../assets/images/seat-icon.png") no-repeat;
  248. background-size: 100% 100%;
  249. position: relative;
  250. &:hover{
  251. opacity: 0.8;
  252. }
  253. }
  254. .seat-p-class{
  255. position: absolute;
  256. left: 0;
  257. top: 0;
  258. text-align: center;
  259. font-size: 18px;
  260. display: inline-block;
  261. color: white;
  262. }
  263. }
  264. }
  265. .upload-btn {
  266. width: 100px;
  267. height: 100px;
  268. background-color: #fbfdff;
  269. border: dashed 1px #c0ccda;
  270. border-radius: 5px;
  271. i {
  272. font-size: 30px;
  273. margin-top: 20px;
  274. }
  275. &-text {
  276. margin-top: -10px;
  277. }
  278. }
  279. .avatar {
  280. cursor: pointer;
  281. }
  282. }
  283. //这里注意:我当前将css样式加载全局上,如果单页添加样式需要每个样式前添加 ‘/deep/’ 修饰符
  284. /* dialog*/
  285. .ygh-dialog ::v-deep .el-dialog__header {
  286. padding: 16px 20px 15px;
  287. }
  288. .ygh-dialog ::v-deep .el-dialog__body {
  289. padding:0 10px 10px !important;
  290. }
  291. .el-dialog__headerbtn{
  292. top: 15px;
  293. }
  294. /*dialog header*/
  295. .el-dialog__header{
  296. background: #e3eaed;
  297. }
  298. .avue-crud__dialog__header {
  299. display: -webkit-box;
  300. display: -ms-flexbox;
  301. display: flex;
  302. -webkit-box-align: center;
  303. -ms-flex-align: center;
  304. -webkit-box-pack: justify;
  305. -ms-flex-pack: justify;
  306. justify-content: space-between;
  307. align-items: center;
  308. }
  309. .el-dialog__title {
  310. color: rgba(0,0,0,.85);
  311. font-weight: 500;
  312. word-wrap: break-word;
  313. }
  314. .avue-crud__dialog__menu {
  315. padding-right: 20px;
  316. float: left;
  317. display: flex;
  318. align-items: center;
  319. }
  320. .avue-crud__dialog__menu i {
  321. color: #909399;
  322. font-size: 30px;
  323. }
  324. .el-icon-full-screen{
  325. cursor: pointer;
  326. }
  327. .el-icon-full-screen:before {
  328. content: "\e719";
  329. }
  330. </style>