addAndEdit.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381
  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. <template slot="append">元</template>
  118. </el-input>
  119. </el-form-item>
  120. </el-form>
  121. </div>
  122. <span slot="footer" class="dialog-footer">
  123. <el-button v-if="!isDisabled" @click="cancel">取消</el-button>
  124. <el-button
  125. v-if="!isDisabled"
  126. type="primary"
  127. @click="submitForm"
  128. v-loading.fullscreen.lock="loading"
  129. element-loading-text="提交中..."
  130. element-loading-spinner="el-icon-loading"
  131. element-loading-background="rgba(0, 0, 0, 0.8)"
  132. >
  133. <span v-if="loading">提交中...</span>
  134. <span v-else>保存</span>
  135. </el-button>
  136. <el-button v-if="isDisabled" type="primary" @click="cancel">确定</el-button>
  137. </span>
  138. </el-dialog>
  139. </template>
  140. <script>
  141. import { saveAndEdit } from "@/api/ticketMr/priceMr";
  142. import { SeatTypeList } from '@/api/seatTypeMr/seatTypeMr'
  143. import { pageList } from "@/api/venueMr/venueMr";
  144. import { ticketPageList } from '@/api/ticketMr/ticketMr'
  145. import { goodsPageList } from '@/api/programmeMr/programmeMr'
  146. import { merchantPageList } from '@/api/performanceHallMr/performanceHallMr'
  147. import Editor from "@/components/Editor";
  148. import { getToken } from "@/utils/auth";
  149. export default {
  150. name: "addAndEdit",
  151. props: {
  152. dict: {
  153. type: Object,
  154. default: () => [],
  155. },
  156. },
  157. components: {
  158. Editor,
  159. },
  160. data() {
  161. return {
  162. title: "编辑",
  163. model: "EDIT",
  164. open: false,
  165. loading: false,
  166. tableType: false,
  167. isDisabled: false,
  168. form: {
  169. id: undefined,
  170. priceType: '2'
  171. },
  172. rules: {
  173. venueId: [{ required: true, message: "请选择场馆", trigger: "blur" }],
  174. auditoriumId: [{ required: true, message: "请选择演出厅", trigger: "blur" }],
  175. performId: [{ required: true, message: "请选择剧目", trigger: "blur" }],
  176. goodsId: [{ required: true, message: "请选择票务", trigger: "blur" }],
  177. seatTypeId: [{ required: true, message: "请选择座位类型", trigger: "blur" }],
  178. priceType: [{ required: true, message: "请选择结算方式", trigger: "blur" }],
  179. priceAmount: [{ required: true, message: "请输入价格", trigger: "blur" }],
  180. },
  181. uploadObj: {
  182. url: process.env.VUE_APP_UPLOAD_FILE_API + "/upload/single/minio",
  183. Headers: { Authorization: "Bearer " + getToken() },
  184. },
  185. theatreList: [],
  186. goodsList: [],
  187. merchantList: [],
  188. editType: false,
  189. ticketList: [],
  190. seatList: []
  191. };
  192. },
  193. methods: {
  194. /**
  195. * 打开弹框
  196. * @date 2023-11-22
  197. * @param {any} obj
  198. * @returns {any}
  199. */
  200. openDialog(title, obj, type) {
  201. this.open = true;
  202. this.editType = false;
  203. this.isDisabled = false
  204. this.reset();
  205. this.getList();
  206. this.goodsPageList();
  207. this.ticketListApi();
  208. this.getSeatTypeList();
  209. // this.merchantPageList();
  210. if (obj){
  211. this.editType = true;
  212. if(type) {
  213. this.title = "座位价格";
  214. this.isDisabled = true
  215. } else {
  216. this.title = "编辑座位价格";
  217. }
  218. this.$nextTick(() => {
  219. this.$set(this.form, 'id', obj.id);
  220. this.$set(this.form, 'goodsId', obj.goodsId);
  221. this.$set(this.form, 'seatTypeId', obj.seatTypeId);
  222. this.$set(this.form, 'performId', obj.performId);
  223. this.$set(this.form, 'auditoriumId', obj.auditoriumId);
  224. this.$set(this.form, 'priceType', obj.priceType.toString());
  225. this.$set(this.form, 'priceAmount', obj.priceAmount);
  226. this.getList(obj.theatreName);
  227. });
  228. }else{
  229. this.title = "新增座位价格";
  230. this.$nextTick(() => {
  231. this.$refs["form"].clearValidate();
  232. });
  233. }
  234. },
  235. /** 座位类型列表 */
  236. getSeatTypeList() {
  237. SeatTypeList(this.addDateRange({pageNum: 1, pageSize: 100}))
  238. .then(response => {
  239. this.seatList = response.data.rows;
  240. });
  241. },
  242. /** 场馆列表查询 */
  243. getList(name) {
  244. pageList(this.addDateRange({pageNum: 1, pageSize: 100}))
  245. .then(response => {
  246. this.theatreList = response.data.rows;
  247. this.theatreList.forEach(item => {
  248. if(name == item.name){
  249. this.$set(this.form, 'venueId', item.id)
  250. }
  251. })
  252. this.merchantPageList(this.form.venueId)
  253. });
  254. },
  255. /** 场馆选择 */
  256. changeTheatre(id) {
  257. this.merchantPageList(id)
  258. this.$set(this.form, 'auditoriumId', '')
  259. },
  260. /** 剧目列表查询 */
  261. goodsPageList() {
  262. goodsPageList(this.addDateRange({pageNum: 1, pageSize: 100, status: 1}))
  263. .then(response => {
  264. this.goodsList = response.data.rows;
  265. });
  266. },
  267. /** 票务列表查询 */
  268. ticketListApi() {
  269. ticketPageList(this.addDateRange({pageNum: 1, pageSize: 100, goodsType: 2, classifyId: 1, status: 0}))
  270. .then(response => {
  271. this.ticketList = response.data.rows;
  272. // 判断票务回写时 是否被删除或者关闭 如果是goodsId为空
  273. if(this.form.goodsId && this.form.goodsId != ''){
  274. let goodsType = false
  275. this.ticketList.forEach(item => {
  276. if(item.id == this.form.goodsId){
  277. goodsType = true;
  278. }
  279. })
  280. if(!goodsType){
  281. this.$set(this.form, 'goodsId', "");
  282. }
  283. }
  284. });
  285. },
  286. /** 演出厅列表查询 */
  287. merchantPageList(id) {
  288. merchantPageList(this.addDateRange({theatreId: id, pageNum: 1, pageSize: 100}))
  289. .then(response => {
  290. this.merchantList = response.data.rows;
  291. });
  292. },
  293. /** 价格输入事件 */
  294. changePriceAmount(val) {
  295. if(val * 1 < 0){
  296. this.$message.error("输入需大于或等于0!");
  297. this.$set(this.form, 'priceAmount', '');
  298. return false
  299. }
  300. },
  301. /**
  302. * 保存
  303. * @date 2023-11-22
  304. * @returns {any}
  305. */
  306. submitForm() {
  307. this.$refs["form"].validate(async (valid) => {
  308. if (valid) {
  309. try {
  310. this.loading = true;
  311. const { code } = await saveAndEdit({ ...this.form });
  312. if (code === 200) {
  313. this.$message.success("操作成功!");
  314. this.$emit("getList");
  315. this.cancel();
  316. }
  317. } catch (error) {
  318. } finally {
  319. this.loading = false;
  320. }
  321. }
  322. });
  323. },
  324. /**
  325. * 重置
  326. * @date 2023-11-22
  327. * @returns {any}
  328. */
  329. reset() {
  330. this.$set(this.form, 'id', '');
  331. this.$set(this.form, 'goodsId', '');
  332. this.$set(this.form, 'venueId', '');
  333. this.$set(this.form, 'seatTypeId', '');
  334. this.$set(this.form, 'performId', '');
  335. this.$set(this.form, 'auditoriumId', '');
  336. this.$set(this.form, 'priceType', '2');
  337. this.$set(this.form, 'priceAmount', '');
  338. },
  339. /**
  340. * 关闭弹框
  341. * @date 2023-11-22
  342. * @returns {any}
  343. */
  344. cancel() {
  345. this.reset();
  346. this.open = false;
  347. },
  348. },
  349. };
  350. </script>
  351. <style lang="scss" scoped>
  352. .dialog {
  353. padding: 0 30px;
  354. max-height: 65vh;
  355. overflow-y: auto;
  356. }
  357. .dialog {
  358. padding: 0 30px;
  359. .upload-btn {
  360. width: 100px;
  361. height: 100px;
  362. background-color: #fbfdff;
  363. border: dashed 1px #c0ccda;
  364. border-radius: 5px;
  365. i {
  366. font-size: 30px;
  367. margin-top: 20px;
  368. }
  369. &-text {
  370. margin-top: -10px;
  371. }
  372. }
  373. .avatar {
  374. cursor: pointer;
  375. }
  376. }
  377. </style>