addAndEdit.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364
  1. <!--
  2. * @Description: 新增/编辑弹框
  3. * @Author: Sugar.
  4. * @Date: 2023-11-24 13:55:00
  5. * @LastEditors: Sugar.
  6. * @LastEditTime: 2023-11-24 13:55:00
  7. * @FilePath: \cattle_webui\src\views\ticket\dialog\AddOrEditDialog.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="900px"
  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="goodsId">
  22. <el-select
  23. :disabled="isDisabled"
  24. v-model="form.goodsId"
  25. placeholder="选择票务"
  26. clearable
  27. style="width: 100%"
  28. >
  29. <el-option
  30. v-for="dict in ticketList"
  31. :key="dict.id"
  32. :label="dict.goodsName + ' (' + dict.salePrice + '元)' "
  33. :value="dict.id"
  34. />
  35. </el-select>
  36. </el-form-item>
  37. <el-form-item label="选择场馆:" prop="venueId">
  38. <el-select
  39. :disabled="isDisabled"
  40. v-model="form.venueId"
  41. placeholder="选择场馆"
  42. clearable
  43. @change="changeTheatre"
  44. style="width: 100%"
  45. >
  46. <el-option
  47. v-for="dict in theatreList"
  48. :key="dict.id"
  49. :label="dict.name"
  50. :value="dict.id"
  51. />
  52. </el-select>
  53. </el-form-item>
  54. <el-form-item label="选择演出厅:" prop="auditoriumId">
  55. <el-select
  56. :disabled="isDisabled"
  57. v-model="form.auditoriumId"
  58. placeholder="选择演出厅"
  59. clearable
  60. style="width: 100%"
  61. >
  62. <el-option
  63. v-for="dict in merchantList"
  64. :key="dict.id"
  65. :label="dict.name"
  66. :value="dict.id"
  67. />
  68. </el-select>
  69. </el-form-item>
  70. <el-form-item label="选择剧目:" prop="performId">
  71. <el-select
  72. :disabled="isDisabled"
  73. v-model="form.performId"
  74. placeholder="选择剧目"
  75. clearable
  76. style="width: 100%"
  77. >
  78. <el-option
  79. v-for="dict in goodsList"
  80. :key="dict.id"
  81. :label="dict.name"
  82. :value="dict.id"
  83. />
  84. </el-select>
  85. </el-form-item>
  86. <el-form-item label="选择座位类型:" prop="seatTypeId">
  87. <el-select
  88. :disabled="isDisabled"
  89. v-model="form.seatTypeId"
  90. placeholder="座位类型"
  91. clearable
  92. style="width: 100%"
  93. >
  94. <el-option
  95. v-for="dict in seatList"
  96. :key="dict.id"
  97. :label="dict.name"
  98. :value="dict.id"
  99. />
  100. </el-select>
  101. </el-form-item>
  102. <el-form-item label="结算方式:" prop="priceType">
  103. <el-radio :disabled="isDisabled" v-model="form.priceType" label="1">基于票务类型打折</el-radio>
  104. <el-radio :disabled="isDisabled" v-model="form.priceType" label="2">固定值</el-radio>
  105. </el-form-item>
  106. <el-form-item label="价格:" prop="priceAmount">
  107. <el-input
  108. :disabled="isDisabled"
  109. type="number"
  110. v-model="form.priceAmount"
  111. placeholder=""
  112. clearable
  113. @change="changePriceAmount"
  114. style="width: 160px;"
  115. >
  116. <template slot="append">{{ form.priceType == 1 ? '%' : '元' }}</template>
  117. </el-input>
  118. </el-form-item>
  119. </el-form>
  120. </div>
  121. <span slot="footer" class="dialog-footer">
  122. <el-button v-if="!isDisabled" @click="cancel">取消</el-button>
  123. <el-button
  124. v-if="!isDisabled"
  125. type="primary"
  126. @click="submitForm"
  127. v-loading.fullscreen.lock="loading"
  128. element-loading-text="提交中..."
  129. element-loading-spinner="el-icon-loading"
  130. element-loading-background="rgba(0, 0, 0, 0.8)"
  131. >
  132. <span v-if="loading">提交中...</span>
  133. <span v-else>保存</span>
  134. </el-button>
  135. <el-button v-if="isDisabled" type="primary" @click="cancel">确定</el-button>
  136. </span>
  137. </el-dialog>
  138. </template>
  139. <script>
  140. import { saveAndEdit } from "@/api/ticketMr/priceMr";
  141. import { SeatTypeList } from '@/api/seatTypeMr/seatTypeMr'
  142. import { pageList } from "@/api/venueMr/venueMr";
  143. import { ticketPageList } from '@/api/ticketMr/ticketMr'
  144. import { goodsPageList } from '@/api/programmeMr/programmeMr'
  145. import { merchantPageList } from '@/api/performanceHallMr/performanceHallMr'
  146. import Editor from "@/components/Editor";
  147. import { getToken } from "@/utils/auth";
  148. export default {
  149. name: "addAndEdit",
  150. props: {
  151. dict: {
  152. type: Object,
  153. default: () => [],
  154. },
  155. },
  156. components: {
  157. Editor,
  158. },
  159. data() {
  160. return {
  161. title: "编辑",
  162. model: "EDIT",
  163. open: false,
  164. loading: false,
  165. tableType: false,
  166. isDisabled: false,
  167. form: {
  168. id: undefined,
  169. priceType: '1'
  170. },
  171. rules: {
  172. venueId: [{ required: true, message: "请选择场馆", trigger: "blur" }],
  173. auditoriumId: [{ required: true, message: "请选择演出厅", trigger: "blur" }],
  174. performId: [{ required: true, message: "请选择剧目", trigger: "blur" }],
  175. goodsId: [{ required: true, message: "请选择票务", trigger: "blur" }],
  176. seatTypeId: [{ required: true, message: "请选择座位类型", trigger: "blur" }],
  177. priceType: [{ required: true, message: "请选择结算方式", trigger: "blur" }],
  178. priceAmount: [{ required: true, message: "请输入价格", trigger: "blur" }],
  179. },
  180. uploadObj: {
  181. url: process.env.VUE_APP_UPLOAD_FILE_API + "/upload/single/minio",
  182. Headers: { Authorization: "Bearer " + getToken() },
  183. },
  184. theatreList: [],
  185. goodsList: [],
  186. merchantList: [],
  187. editType: false,
  188. ticketList: [],
  189. seatList: []
  190. };
  191. },
  192. methods: {
  193. /**
  194. * 打开弹框
  195. * @date 2023-11-22
  196. * @param {any} obj
  197. * @returns {any}
  198. */
  199. openDialog(title, obj, type) {
  200. this.open = true;
  201. this.editType = false;
  202. this.isDisabled = false
  203. this.getList();
  204. this.goodsPageList();
  205. this.ticketListApi();
  206. this.getSeatTypeList();
  207. // this.merchantPageList();
  208. if (obj){
  209. this.editType = true;
  210. if(type) {
  211. this.title = "座位价格";
  212. this.isDisabled = true
  213. } else {
  214. this.title = "编辑座位价格";
  215. }
  216. this.$nextTick(() => {
  217. this.$set(this.form, 'id', obj.id);
  218. this.$set(this.form, 'goodsId', obj.goodsId);
  219. this.$set(this.form, 'seatTypeId', obj.seatTypeId);
  220. this.$set(this.form, 'performId', obj.performId);
  221. this.$set(this.form, 'auditoriumId', obj.auditoriumId);
  222. this.$set(this.form, 'priceType', obj.priceType.toString());
  223. this.$set(this.form, 'priceAmount', obj.priceAmount);
  224. this.getList(obj.theatreName);
  225. });
  226. }else{
  227. this.title = "新增座位价格";
  228. this.form = {
  229. id: undefined,
  230. priceType: '1'
  231. };
  232. this.$nextTick(() => {
  233. this.$refs["form"].clearValidate();
  234. });
  235. }
  236. },
  237. /** 座位类型列表 */
  238. getSeatTypeList() {
  239. SeatTypeList(this.addDateRange({pageNum: 1, pageSize: 100}))
  240. .then(response => {
  241. this.seatList = response.data.rows;
  242. });
  243. },
  244. /** 场馆列表查询 */
  245. getList(name) {
  246. pageList(this.addDateRange({pageNum: 1, pageSize: 100}))
  247. .then(response => {
  248. this.theatreList = response.data.rows;
  249. this.theatreList.forEach(item => {
  250. if(name == item.name){
  251. this.$set(this.form, 'venueId', item.id)
  252. }
  253. })
  254. this.merchantPageList(this.form.venueId)
  255. });
  256. },
  257. /** 场馆选择 */
  258. changeTheatre(id) {
  259. this.merchantPageList(id)
  260. this.$set(this.form, 'auditoriumId', '')
  261. },
  262. /** 剧目列表查询 */
  263. goodsPageList() {
  264. goodsPageList(this.addDateRange({pageNum: 1, pageSize: 100, status: 1}))
  265. .then(response => {
  266. this.goodsList = response.data.rows;
  267. });
  268. },
  269. /** 票务列表查询 */
  270. ticketListApi() {
  271. ticketPageList(this.addDateRange({pageNum: 1, pageSize: 100, goodsType: 2, classifyId: 1, status: 0}))
  272. .then(response => {
  273. this.ticketList = response.data.rows;
  274. });
  275. },
  276. /** 演出厅列表查询 */
  277. merchantPageList(id) {
  278. merchantPageList(this.addDateRange({theatreId: id, pageNum: 1, pageSize: 100}))
  279. .then(response => {
  280. this.merchantList = response.data.rows;
  281. });
  282. },
  283. /** 价格输入事件 */
  284. changePriceAmount(val) {
  285. if(val * 1 < 0){
  286. this.$message.error("输入需大于或等于0!");
  287. this.$set(this.form, 'priceAmount', '');
  288. return false
  289. }
  290. },
  291. /**
  292. * 保存
  293. * @date 2023-11-22
  294. * @returns {any}
  295. */
  296. submitForm() {
  297. this.$refs["form"].validate(async (valid) => {
  298. if (valid) {
  299. try {
  300. this.loading = true;
  301. const { code } = await saveAndEdit({ ...this.form });
  302. if (code === 200) {
  303. this.$message.success("操作成功!");
  304. this.$emit("getList");
  305. this.cancel();
  306. }
  307. } catch (error) {
  308. } finally {
  309. this.loading = false;
  310. }
  311. }
  312. });
  313. },
  314. /**
  315. * 重置
  316. * @date 2023-11-22
  317. * @returns {any}
  318. */
  319. reset() {
  320. this.$refs["form"].resetFields();
  321. this.form.id = undefined;
  322. },
  323. /**
  324. * 关闭弹框
  325. * @date 2023-11-22
  326. * @returns {any}
  327. */
  328. cancel() {
  329. this.reset();
  330. this.open = false;
  331. },
  332. },
  333. };
  334. </script>
  335. <style lang="scss" scoped>
  336. .dialog {
  337. padding: 0 30px;
  338. max-height: 65vh;
  339. overflow-y: auto;
  340. }
  341. .dialog {
  342. padding: 0 30px;
  343. .upload-btn {
  344. width: 100px;
  345. height: 100px;
  346. background-color: #fbfdff;
  347. border: dashed 1px #c0ccda;
  348. border-radius: 5px;
  349. i {
  350. font-size: 30px;
  351. margin-top: 20px;
  352. }
  353. &-text {
  354. margin-top: -10px;
  355. }
  356. }
  357. .avatar {
  358. cursor: pointer;
  359. }
  360. }
  361. </style>