addAndEdit.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585
  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\team\applicationMr\addAndEdit.vue
  8. * @Copyright: Copyright (c) 2016~2023 by Sugar., All Rights Reserved.
  9. -->
  10. <template>
  11. <el-dialog
  12. :title="title"
  13. :visible.sync="open"
  14. width="700px"
  15. append-to-body
  16. :close-on-click-modal="false"
  17. @close="cancel"
  18. >
  19. <div class="dialog">
  20. <el-form :model="form" ref="form" :rules="rules" label-width="120px">
  21. <el-form-item label="选择团队:" prop="teamId">
  22. <el-select
  23. v-model="form.teamId"
  24. placeholder="选择团队"
  25. clearable
  26. @change="teamChange"
  27. style="width: 100%;"
  28. >
  29. <el-option
  30. v-for="dict in teamList"
  31. :key="dict.id"
  32. :label="dict.name"
  33. :value="dict.id"
  34. />
  35. </el-select>
  36. </el-form-item>
  37. <el-form-item label="选择场馆:" prop="theatreId">
  38. <el-select
  39. v-model="form.theatreId"
  40. placeholder="选择场馆"
  41. clearable
  42. @change="changeTheatre"
  43. style="width: 100%;"
  44. >
  45. <el-option
  46. v-for="dict in theatreList"
  47. :key="dict.id"
  48. :label="dict.name"
  49. :value="dict.id"
  50. />
  51. </el-select>
  52. </el-form-item>
  53. <el-form-item label="选择演出厅:" prop="auditoriumId">
  54. <el-select
  55. v-model="form.auditoriumId"
  56. placeholder="选择演出厅"
  57. @change="auditoriumChange"
  58. clearable
  59. style="width: 100%;"
  60. >
  61. <el-option
  62. v-for="dict in merchantList"
  63. :key="dict.id"
  64. :label="dict.name"
  65. :value="dict.id"
  66. />
  67. </el-select>
  68. </el-form-item>
  69. <el-form-item label="选择剧目:" prop="performId">
  70. <el-select
  71. v-model="form.performId"
  72. placeholder="选择剧目"
  73. clearable
  74. @change="performChangeEven"
  75. style="width: 100%;"
  76. >
  77. <el-option
  78. v-for="dict in goodsList"
  79. :key="dict.id"
  80. :label="dict.name"
  81. :value="dict.id"
  82. />
  83. </el-select>
  84. </el-form-item>
  85. <el-form-item label="票务管理:" prop="goodsId">
  86. <el-select
  87. v-model="form.goodsId"
  88. placeholder="票务管理"
  89. clearable
  90. @change="goodsChangeEven"
  91. style="width: 100%;"
  92. >
  93. <el-option
  94. v-for="dict in ticketList"
  95. :key="dict.id"
  96. :label="dict.goodsName"
  97. :value="dict.goodsId"
  98. />
  99. </el-select>
  100. </el-form-item>
  101. <el-form-item label="座位类型:" prop="seatTypeId">
  102. <el-select
  103. v-model="form.seatTypeId"
  104. placeholder="座位类型"
  105. clearable
  106. @change="seatChangeEven"
  107. style="width: 100%;"
  108. >
  109. <el-option
  110. v-for="dict in seatList"
  111. :key="dict.seatTypeId"
  112. :label="dict.seatTypeName"
  113. :value="dict.seatTypeId"
  114. />
  115. </el-select>
  116. </el-form-item>
  117. <el-form-item label="团购单价:" prop="price">
  118. <el-input
  119. type="number"
  120. disabled
  121. v-model="form.price"
  122. placeholder=""
  123. clearable
  124. @change="changePriceAmount('salePrice')"
  125. style="width: 260px;"
  126. >
  127. <template slot="append">元/人</template>
  128. </el-input>
  129. </el-form-item>
  130. <el-form-item label="选择日期" prop="performDate">
  131. <el-date-picker
  132. v-model="form.performDate"
  133. type="date"
  134. @change="performDateEven"
  135. value-format="yyyy-MM-dd"
  136. placeholder="选择日期">
  137. </el-date-picker>
  138. </el-form-item>
  139. <el-form-item label="预约场次:" prop="performTimeId">
  140. <el-select
  141. v-model="form.performTimeId"
  142. placeholder="预约场次"
  143. clearable
  144. style="width: 100%;"
  145. >
  146. <el-option
  147. v-for="dict in performTimeList"
  148. :key="dict.id"
  149. :label="dict.timeSnapshot + '场次: ' + dict.performDate + ' 开始时间' + dict.performTimeStart + ', 结束时间' + dict.performTimeEnd"
  150. :value="dict.id"
  151. />
  152. </el-select>
  153. </el-form-item>
  154. <el-form-item label="观影人员:" prop="viewerList">
  155. <el-upload
  156. class="upload-demo"
  157. :action="uploadObj.url"
  158. :headers="uploadObj.headers"
  159. :auto-upload="false"
  160. :disabled="uploadLoading"
  161. :show-file-list="false"
  162. :on-change="beforeAvatarUpload"
  163. :file-list="form.fileList">
  164. <el-button size="small" type="primary" :loading="uploadLoading">{{form.viewerList && form.viewerList.length == 0 ? '导入excel' : '重新导入excel'}}</el-button>
  165. <div slot="tip" class="el-upload__tip">上传excel文件,导入模板表头序号、姓名、身份证号码</div>
  166. </el-upload>
  167. <div v-if="form.viewerList && form.viewerList.length > 0">
  168. <el-table :data="form.viewerList" style="width: 100%" border>
  169. <el-table-column label="序号" align="center" type="index" width="50"></el-table-column>
  170. <el-table-column prop="name" label="姓名" align="center" ></el-table-column>
  171. <el-table-column prop="cardId" label="身份证号码" align="center"> </el-table-column>
  172. </el-table>
  173. </div>
  174. </el-form-item>
  175. </el-form>
  176. </div>
  177. <span slot="footer" class="dialog-footer">
  178. <el-button @click="cancel">取消</el-button>
  179. <el-button
  180. type="primary"
  181. @click="submitForm"
  182. v-loading.fullscreen.lock="loading"
  183. element-loading-text="提交中..."
  184. element-loading-spinner="el-icon-loading"
  185. element-loading-background="rgba(0, 0, 0, 0.8)"
  186. >
  187. <span v-if="loading">提交中...</span>
  188. <span v-else>保存</span>
  189. </el-button>
  190. </span>
  191. </el-dialog>
  192. </template>
  193. <script>
  194. import { saveAndEdit, getSelectById, uploadExcel, queryPrice } from "@/api/team/applicationMr";
  195. import { pagePerformTimeList } from '@/api/schedulingMr/schedulingMr'
  196. import Editor from "@/components/Editor";
  197. import { getToken } from "@/utils/auth";
  198. import { goodsPageList } from '@/api/programmeMr/programmeMr'
  199. import { seatPricePageList } from '@/api/distribution/ticketMr'
  200. import { merchantPageList } from '@/api/performanceHallMr/performanceHallMr'
  201. import { pageList } from "@/api/venueMr/venueMr";
  202. import { teamPageList } from '@/api/team/teamMr'
  203. export default {
  204. name: "addAndEdit",
  205. props: {
  206. dict: {
  207. type: Object,
  208. default: () => [],
  209. },
  210. },
  211. components: {
  212. Editor,
  213. },
  214. data() {
  215. return {
  216. title: "编辑",
  217. model: "EDIT",
  218. activeName: '01',
  219. open: false,
  220. loading: false,
  221. uploadLoading: false,
  222. form: {
  223. id: undefined,
  224. },
  225. rules: {
  226. teamId: [{ required: true, message: "请选择团队", trigger: "blur" }],
  227. theatreId: [{ required: true, message: "请选择场馆", trigger: "blur" }],
  228. auditoriumId: [{ required: true, message: "请选择演出厅", trigger: "blur" }],
  229. performId: [{ required: true, message: "请选择选择剧目", trigger: "blur" }],
  230. goodsId: [{ required: true, message: "请选择票务", trigger: "blur" }],
  231. seatTypeId: [{ required: true, message: "请选择座位类型", trigger: "blur" }],
  232. price: [{ required: true, message: "请输入团购单价", trigger: "blur" }],
  233. teamPersonNum: [{ required: true, message: "请输入人数", trigger: "blur" }],
  234. performTimeId: [{ required: true, message: "请选择预约场次", trigger: "blur" }],
  235. viewerList: [{ required: true, message: "请上传观影人员excel", trigger: "blur" }],
  236. },
  237. uploadObj: {
  238. url: process.env.VUE_APP_UPLOAD_FILE_API + "/upload/single/minio",
  239. Headers: { Authorization: "Bearer " + getToken() },
  240. },
  241. goodsList: [],
  242. ticketList: [],
  243. seatList: [],
  244. merchantList: [],
  245. theatreList: [],
  246. teamList: [],
  247. sessionList: [],
  248. performTimeList: []
  249. };
  250. },
  251. methods: {
  252. /**
  253. * 打开弹框
  254. * @date 2023-11-22
  255. * @param {any} obj
  256. * @returns {any}
  257. */
  258. openDialog(title, obj) {
  259. this.open = true;
  260. this.teamPageListApi();
  261. this.getList();
  262. this.goodsPageList();
  263. this.reset();
  264. if (obj){
  265. this.title = "编辑报名";
  266. this.getSelectByIdApi(obj);
  267. }else{
  268. this.title = "添加报名";
  269. this.$nextTick(() => {
  270. this.$refs["form"].clearValidate();
  271. });
  272. }
  273. },
  274. /** 获取详情 */
  275. getSelectByIdApi(row) {
  276. const id = row.id
  277. getSelectById(id).then(response => {
  278. const obj = response.data;
  279. this.$nextTick(() => {
  280. this.$set(this.form, 'id', obj.id);
  281. this.$set(this.form, 'goodsId', obj.goodsId);
  282. this.$set(this.form, 'seatTypeId', obj.seatTypeId);
  283. this.$set(this.form, 'performId', obj.performId);
  284. this.$set(this.form, 'originalSalePrice', obj.originalSalePrice);
  285. this.$set(this.form, 'salePrice', obj.salePrice);
  286. this.$set(this.form, 'brokeragePrice', obj.brokeragePrice);
  287. this.ticketListApi();
  288. this.getSeatTypeList({goodsId: this.form.goodsId, performId: this.form.performId});
  289. });
  290. });
  291. },
  292. /** 团队列表查询 */
  293. teamPageListApi() {
  294. teamPageList(this.addDateRange({pageNum: 1, pageSize: 100}))
  295. .then(response => {
  296. this.teamList = response.data.rows;
  297. });
  298. },
  299. /** 场馆列表查询 */
  300. getList(name) {
  301. pageList(this.addDateRange({pageNum: 1, pageSize: 100}))
  302. .then(response => {
  303. this.theatreList = response.data.rows;
  304. });
  305. },
  306. /** 团队选择 */
  307. teamChange(val) {
  308. this.teamList.forEach(item => {
  309. if(val == item.id){
  310. this.$set(this.form, 'teamName', item.name)
  311. }
  312. })
  313. },
  314. /** 场馆选择 */
  315. changeTheatre(id) {
  316. this.merchantPageList(id)
  317. this.theatreList.forEach(item => {
  318. if(id == item.id){
  319. this.$set(this.form, 'theatreName', item.name)
  320. }
  321. })
  322. this.$set(this.form, 'auditoriumId', '')
  323. this.$set(this.form, 'performId', '')
  324. this.$set(this.form, 'goodsId', '')
  325. this.$set(this.form, 'seatTypeId', '')
  326. this.$set(this.form, 'price', '')
  327. this.$set(this.form, 'performDate', '');
  328. this.$set(this.form, 'performTimeId', '');
  329. },
  330. /** 演出厅选择 */
  331. auditoriumChange(id) {
  332. this.$set(this.form, 'performDate', '');
  333. this.$set(this.form, 'performTimeId', '');
  334. this.$set(this.form, 'performId', '');
  335. this.$set(this.form, 'goodsId', '')
  336. this.$set(this.form, 'seatTypeId', '')
  337. this.$set(this.form, 'price', '')
  338. this.merchantList.forEach(item => {
  339. if(id == item.id){
  340. this.$set(this.form, 'auditoriumName', item.name)
  341. }
  342. })
  343. this.getPerformTimeList();
  344. },
  345. /** 演出厅列表查询 */
  346. merchantPageList(id) {
  347. merchantPageList(this.addDateRange({theatreId: id, pageNum: 1, pageSize: 100}))
  348. .then(response => {
  349. this.merchantList = response.data.rows;
  350. });
  351. },
  352. /** 剧目列表查询 */
  353. goodsPageList() {
  354. goodsPageList(this.addDateRange({pageNum: 1, pageSize: 100, status: 1}))
  355. .then(response => {
  356. this.goodsList = response.data.rows;
  357. });
  358. },
  359. /** 票务列表查询 */
  360. ticketListApi(performId) {
  361. this.ticketList = []
  362. seatPricePageList(this.addDateRange({pageNum: 1, pageSize: 100, performId: performId}))
  363. .then(response => {
  364. let ticketList = []
  365. response.data.rows.forEach(item => {
  366. if(ticketList.indexOf(item.goodsId) == -1){
  367. this.ticketList.push(item);
  368. ticketList.push(item.goodsId);
  369. }
  370. })
  371. });
  372. },
  373. /** 座位类型列表 */
  374. getSeatTypeList(obj) {
  375. seatPricePageList({pageNum: 1, pageSize: 100, goodsId: obj.goodsId, performId: obj.performId})
  376. .then(response => {
  377. let ticketList = []
  378. response.data.rows.forEach(item => {
  379. if(ticketList.indexOf(item.seatTypeId) == -1){
  380. this.seatList.push(item);
  381. ticketList.push(item.seatTypeId);
  382. }
  383. })
  384. });
  385. },
  386. /** 团购价格查询 */
  387. queryPriceApi() {
  388. let postMap = {
  389. teamId: this.form.teamId,
  390. goodsId: this.form.goodsId,
  391. performId: this.form.performId,
  392. seatTypeId: this.form.seatTypeId,
  393. }
  394. queryPrice(postMap)
  395. .then(response => {
  396. if(response.data){
  397. let data = response.data;
  398. this.$set(this.form, 'price', data.salePrice);
  399. }
  400. });
  401. },
  402. /** 预约场次列表 */
  403. getPerformTimeList() {
  404. if(this.form.performDate && this.form.performDate == '') {
  405. this.$message.error("请选择日期!");
  406. return false
  407. }
  408. pagePerformTimeList(this.addDateRange(
  409. {pageNum: 1, pageSize: 100, performDate: this.form.performDate, performId: this.form.performId, auditoriumId: this.form.auditoriumId, status: 1}
  410. ))
  411. .then(response => {
  412. this.performTimeList = response.data.rows;
  413. });
  414. },
  415. /** 价格输入事件 */
  416. changePriceAmount(key) {
  417. if(this.form[key] * 1 < 0){
  418. this.$message.error("输入需大于或等于0!");
  419. this.$set(this.form, key, '');
  420. return false
  421. }
  422. },
  423. // 剧目改变事件
  424. performChangeEven(val) {
  425. this.seatList = [];
  426. this.ticketList = [];
  427. this.$set(this.form, 'performDate', '');
  428. this.$set(this.form, 'performTimeId', '');
  429. this.$set(this.form, 'goodsId', '');
  430. this.$set(this.form, 'seatTypeId', '');
  431. this.$set(this.form, 'price', '')
  432. this.goodsList.forEach(item => {
  433. if(item.id == val){
  434. this.$set(this.form, 'performName', item.name)
  435. }
  436. })
  437. this.ticketListApi(val);
  438. this.getPerformTimeList()
  439. },
  440. // 票务改变事件
  441. goodsChangeEven(id) {
  442. this.seatList = [];
  443. this.ticketList.forEach(item => {
  444. if(item.goodsId == id){
  445. this.$set(this.form, 'goodsName', item.goodsName)
  446. }
  447. })
  448. this.$set(this.form, 'price', '');
  449. this.$set(this.form, 'seatTypeId', '');
  450. let selectMap = {goodsId: this.form.goodsId, performId: this.form.performId}
  451. this.getSeatTypeList(selectMap);
  452. },
  453. // 座位类型改变事件
  454. seatChangeEven(val) {
  455. this.seatList.forEach(item =>{
  456. if(item.seatTypeId == val){
  457. this.$set(this.form, 'seatTypeName', item.seatTypeName);
  458. this.$set(this.form, 'price', item.priceAmount);
  459. }
  460. })
  461. this.queryPriceApi();
  462. },
  463. // 预约时间
  464. performDateEven() {
  465. this.$set(this.form, 'performTimeId', '')
  466. this.getPerformTimeList();
  467. },
  468. /**
  469. * 保存
  470. * @date 2023-11-22
  471. * @returns {any}
  472. */
  473. submitForm() {
  474. this.$refs["form"].validate(async (valid) => {
  475. if (valid) {
  476. try {
  477. this.loading = true;
  478. const { code } = await saveAndEdit({ ...this.form });
  479. if (code === 200) {
  480. this.$message.success("操作成功!");
  481. this.$emit("getList");
  482. this.cancel();
  483. }
  484. } catch (error) {
  485. } finally {
  486. this.loading = false;
  487. }
  488. }
  489. });
  490. },
  491. /**
  492. * 重置
  493. * @date 2023-11-22
  494. * @returns {any}
  495. */
  496. reset() {
  497. this.$set(this.form, 'id', '');
  498. this.$set(this.form, 'teamId', '');
  499. this.$set(this.form, 'teamName', '');
  500. this.$set(this.form, 'theatreId', '');
  501. this.$set(this.form, 'theatreName', '');
  502. this.$set(this.form, 'auditoriumId', '');
  503. this.$set(this.form, 'auditoriumName', '');
  504. this.$set(this.form, 'performId', '');
  505. this.$set(this.form, 'performName', '');
  506. this.$set(this.form, 'seatTypeId', '');
  507. this.$set(this.form, 'seatTypeName', '');
  508. this.$set(this.form, 'goodsId', '');
  509. this.$set(this.form, 'goodsName', '');
  510. this.$set(this.form, 'performTimeId', '');
  511. this.$set(this.form, 'performDate', '');
  512. this.$set(this.form, 'price', '');
  513. this.$set(this.form, 'viewerList', []);
  514. },
  515. /**
  516. * 关闭弹框
  517. * @date 2023-11-22
  518. * @returns {any}
  519. */
  520. cancel() {
  521. this.reset();
  522. this.open = false;
  523. },
  524. /**
  525. * 上传文件之前之前
  526. * @date 2023-11-22
  527. * @param {any} file
  528. * @returns {any}
  529. */
  530. beforeAvatarUpload(file) {
  531. this.uploadExcelApi(file.raw);
  532. },
  533. // 上传
  534. uploadExcelApi(file) {
  535. try {
  536. let formData = new FormData();
  537. formData.append("file", file);
  538. this.uploadLoading = true;
  539. uploadExcel(formData).then(response => {
  540. this.$message.success("上传成功!");
  541. this.$set(this.form, 'viewerList', response.data)
  542. });
  543. } catch (e) {
  544. } finally {
  545. this.uploadLoading = false;
  546. }
  547. },
  548. },
  549. };
  550. </script>
  551. <style lang="scss" scoped>
  552. .dialog {
  553. padding: 0 30px;
  554. max-height: 65vh;
  555. overflow-y: auto;
  556. }
  557. .dialog {
  558. padding: 0 30px;
  559. .upload-btn {
  560. width: 100px;
  561. height: 100px;
  562. background-color: #fbfdff;
  563. border: dashed 1px #c0ccda;
  564. border-radius: 5px;
  565. i {
  566. font-size: 30px;
  567. margin-top: 20px;
  568. }
  569. &-text {
  570. margin-top: -10px;
  571. }
  572. }
  573. .avatar {
  574. cursor: pointer;
  575. }
  576. }
  577. </style>