addAndEdit.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412
  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\programmeMr\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="800px"
  15. append-to-body
  16. :close-on-click-modal="false"
  17. @close="cancel"
  18. >
  19. <div class="dialog">
  20. <el-form v-if="open" :model="form" ref="form" :rules="rules" label-width="120px">
  21. <el-tabs v-model="activeName">
  22. <!-- 基础信息 -->
  23. <el-tab-pane label="基础信息" name="01">
  24. <el-form-item label="票务名称:" prop="goodsName" style="margin-top: 20px">
  25. <el-input
  26. v-model="form.goodsName"
  27. placeholder="票务名称"
  28. clearable
  29. />
  30. </el-form-item>
  31. <el-form-item label="实名信息:" prop="isAuth">
  32. <el-radio v-model="form.isAuth" label="1">全部观影人员均实名</el-radio>
  33. </el-form-item>
  34. <el-form-item label="核销播报次数:" prop="verificationSpeaker">
  35. <el-input
  36. v-model="form.verificationSpeaker"
  37. @change="changePriceAmount('verificationSpeaker')"
  38. type="number"
  39. placeholder="核销播报次数"
  40. clearable
  41. style="width: 100%;"
  42. >
  43. <template slot="append">次</template>
  44. </el-input>
  45. </el-form-item>
  46. <el-form-item label="票务说明:">
  47. <el-input
  48. type="textarea"
  49. :rows="3"
  50. maxlength="40"
  51. show-word-limit
  52. placeholder="请输入内容"
  53. v-model="form.detail">
  54. </el-input>
  55. </el-form-item>
  56. </el-tab-pane>
  57. <!-- 销售信息 -->
  58. <el-tab-pane label="销售信息" name="02">
  59. <el-form-item label="销售价:" label-width="100px" prop="salePrice">
  60. <el-input
  61. v-model="form.salePrice"
  62. placeholder="销售价"
  63. type="number"
  64. clearable
  65. @change="changePriceAmount('salePrice')"
  66. style="width: 100%;"
  67. >
  68. <template slot="append">元</template>
  69. </el-input>
  70. </el-form-item>
  71. <el-form-item label="是否限购:" prop="buyAstrictType" label-width="100px" style="margin-bottom: 10px">
  72. <el-radio v-model="form.buyAstrictType" label="1">是</el-radio>
  73. <el-radio v-model="form.buyAstrictType" label="2">否</el-radio>
  74. </el-form-item>
  75. <el-form-item label="" prop="buyAstrict" label-width="100px" v-if="form.buyAstrictType == 1">
  76. <span><span style="color: red">*</span>每个账号在每个场次限购</span>
  77. <el-input
  78. v-model.number="form.buyAstrict"
  79. placeholder=""
  80. clearable
  81. style="width: 140px;margin-left: 5px"
  82. >
  83. <template slot="append">张</template>
  84. </el-input>
  85. </el-form-item>
  86. <el-form-item label="售票渠道:" required label-width="100px">
  87. <el-checkbox v-model="form.channelWx">小程序</el-checkbox>
  88. <el-checkbox v-model="form.channelWindow">窗口</el-checkbox>
  89. </el-form-item>
  90. </el-tab-pane>
  91. <!-- 退票信息 -->
  92. <el-tab-pane label="退票信息" name="03">
  93. <el-form-item label="是否支持退票:" prop="backStatus" label-width="120px">
  94. <el-radio v-model="form.backStatus" label="0">是</el-radio>
  95. <el-radio v-model="form.backStatus" label="1">否</el-radio>
  96. </el-form-item>
  97. <el-form-item v-if="form.backStatus == '0'" label="退票时间:" prop="backTime" label-width="120px" style="margin-bottom: 10px">
  98. <el-radio v-model="form.backTime" label="1">按购买日期结算</el-radio>
  99. </el-form-item>
  100. <el-form-item label="" v-if="form.backStatus == '0'" prop="days" label-width="120px">
  101. <span>提前</span>
  102. <el-input
  103. v-model="form.days"
  104. type="number"
  105. placeholder=""
  106. clearable
  107. @change="changePriceAmount('days')"
  108. style="width: 140px;margin-left: 5px"
  109. />
  110. <span style="padding: 0 10px">天</span>
  111. <el-time-select
  112. v-model="form.hour"
  113. :picker-options="{ start: '00:00', step: '00:01', end: '23:59'}"
  114. placeholder="选择时间">
  115. </el-time-select>
  116. <span style="padding-left: 10px">可退</span>
  117. </el-form-item>
  118. </el-tab-pane>
  119. </el-tabs>
  120. </el-form>
  121. </div>
  122. <span slot="footer" class="dialog-footer">
  123. <el-button @click="cancel">取消</el-button>
  124. <el-button
  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. </span>
  136. </el-dialog>
  137. </template>
  138. <script>
  139. // import { updateNoticeMgr } from "@/api/system/noticeMgr";
  140. import { saveAndEdit, getSelectById } from '@/api/ticketMr/ticketMr'
  141. import { getToken } from "@/utils/auth";
  142. import { pageList } from '@/api/performMr/performMr'
  143. export default {
  144. name: "addAndEdit",
  145. data() {
  146. return {
  147. channelList: [
  148. {id: 1, name: '小程序', value: 1},
  149. {id: 2, name: '窗口', value: 2},
  150. ],
  151. title: "编辑",
  152. model: "EDIT",
  153. activeName: '01',
  154. // 演员信息弹窗
  155. performerVisible: false,
  156. // 演员信息
  157. performerList: [],
  158. // 演员上传图片索引
  159. performerIndex: 0,
  160. open: false,
  161. loading: false,
  162. form: {
  163. id: undefined,
  164. type: "",
  165. content: "",
  166. isAuth: '1',
  167. backTime: '1',
  168. goodsPerform: {}
  169. },
  170. rules: {
  171. goodsName: [{ required: true, message: "请输入票务名称", trigger: "blur" }],
  172. verificationSpeaker: [{ required: true, message: "请输入核销播报次数", trigger: "blur" }],
  173. detail: [{ required: true, message: "请输入票务说明", trigger: "blur" }],
  174. salePrice: [{ required: true, message: "请输入销售价", trigger: "blur" }],
  175. buyAstrictType: [{ required: true, message: "请选择是否限购", trigger: "blur" }],
  176. buyAstrict: [{ required: true, message: "请输入每个账号在每个场次限购张数", trigger: "blur" }],
  177. backStatus: [{ required: true, message: "请选择是否支持退票", trigger: "blur" }],
  178. days: [{ 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. statusList: [
  185. {id: 1, name: '是', value: 1},
  186. {id: 2, name: '否', value: 2},
  187. ],
  188. performList: []
  189. };
  190. },
  191. created() {
  192. this.getList()
  193. },
  194. methods: {
  195. /** 查询主办方列表 */
  196. getList() {
  197. pageList({pageNum: 1, pageSize: 100})
  198. .then(response => {
  199. this.performList = response.data.rows;
  200. }
  201. );
  202. },
  203. /** 主办方选择事件 */
  204. changePerform(val) {
  205. this.performList.forEach(item => {
  206. if(item.id == val){
  207. this.form.sponsorName = item.name
  208. }
  209. })
  210. },
  211. /**
  212. * 打开弹框
  213. * @date 2023-11-22
  214. * @param {any} obj
  215. * @returns {any}
  216. */
  217. openDialog(title, obj) {
  218. this.open = true;
  219. this.reset();
  220. this.activeName = '01';
  221. if (obj){
  222. this.title = "编辑票务管理";
  223. this.getSelectByIdApi(obj)
  224. }else{
  225. this.title = "添加票务管理";
  226. this.$nextTick(() => {
  227. this.$refs["form"].clearValidate();
  228. });
  229. }
  230. },
  231. /** 获取详情 */
  232. getSelectByIdApi(row) {
  233. const id = row.id
  234. getSelectById(id).then(response => {
  235. const obj = response.data;
  236. this.$nextTick(() => {
  237. this.$set(this.form, 'id', obj.id);
  238. this.$set(this.form, 'goodsName', obj.goodsName);
  239. this.$set(this.form, 'isAuth', '1');
  240. this.$set(this.form, 'verificationSpeaker', obj.goodsPerform.verificationSpeaker);
  241. this.$set(this.form, 'detail', obj.goodsPerform.detail);
  242. this.$set(this.form, 'salePrice', obj.salePrice);
  243. if(obj.goodsPerform.buyAstrict > -1){
  244. this.$set(this.form, 'buyAstrictType', '1');
  245. this.$set(this.form, 'buyAstrict', obj.goodsPerform.buyAstrict);
  246. } else {
  247. this.$set(this.form, 'buyAstrictType', '2');
  248. this.$set(this.form, 'buyAstrict', '');
  249. }
  250. this.$set(this.form, 'channelWx', obj.goodsPerform.channelWx == 0);
  251. this.$set(this.form, 'channelWindow', obj.goodsPerform.channelWindow == 0);
  252. this.$set(this.form, 'backStatus', obj.goodsPerform.backStatus);
  253. this.$set(this.form, 'backTime', '1');
  254. this.$set(this.form, 'backStatus', obj.goodsPerform.backStatus.toString());
  255. if(obj.goodsPerform.backStatus == '0') {
  256. this.$set(this.form, 'days', obj.performRefundRule.days);
  257. this.$set(this.form, 'hour', obj.performRefundRule.hour);
  258. }
  259. });
  260. });
  261. },
  262. /** 价格输入事件 */
  263. changePriceAmount(key) {
  264. if(this.form[key] * 1 < 0){
  265. this.$message.error("输入需大于或等于0!");
  266. this.$set(this.form, key, '');
  267. return false
  268. }
  269. },
  270. /**
  271. * 保存
  272. * @date 2023-11-22
  273. * @returns {any}
  274. */
  275. submitForm() {
  276. this.$refs["form"].validate(async (valid) => {
  277. if (valid) {
  278. try {
  279. let postMap = {
  280. goodsPerform: {},
  281. performRefundRule: {}
  282. }
  283. if(this.form.id){
  284. postMap.id = this.form.id;
  285. }
  286. postMap.goodsName = this.form.goodsName;
  287. postMap.isAuth = this.form.isAuth;
  288. postMap.goodsPerform.verificationSpeaker = this.form.verificationSpeaker;
  289. postMap.goodsPerform.detail = this.form.detail;
  290. postMap.salePrice = this.form.salePrice;
  291. postMap.goodsPerform.buyAstrict = this.form.buyAstrictType == '1' ? this.form.buyAstrict : '-1';
  292. if(!(this.form.channelWx || this.form.channelWindow)){
  293. this.$message.error("请选择销售渠道!");
  294. return false;
  295. }
  296. postMap.goodsPerform.channelWx = this.form.channelWx ? 0 : 1;
  297. postMap.goodsPerform.channelWindow = this.form.channelWindow ? 0 : 1;
  298. postMap.goodsPerform.backStatus = this.form.backStatus;
  299. if(this.form.backStatus == '0') {
  300. postMap.performRefundRule.days = this.form.days;
  301. postMap.performRefundRule.hour = this.form.hour;
  302. }
  303. postMap.goodsType = 2;
  304. postMap.classifyId = 1;
  305. postMap.classifyName = "门票类";
  306. this.loading = true;
  307. const { code } = await saveAndEdit({ ...postMap });
  308. if (code === 200) {
  309. this.$message.success("操作成功!");
  310. this.$emit("getList");
  311. this.cancel();
  312. }
  313. } catch (error) {
  314. } finally {
  315. this.loading = false;
  316. }
  317. }
  318. });
  319. },
  320. /**
  321. * 重置
  322. * @date 2023-11-22
  323. * @returns {any}
  324. */
  325. reset() {
  326. this.$set(this.form, 'id', '');
  327. this.$set(this.form, 'goodsName', '');
  328. this.$set(this.form, 'isAuth', '1');
  329. this.$set(this.form, 'verificationSpeaker', '');
  330. this.$set(this.form, 'detail', '');
  331. this.$set(this.form, 'goodsPerform', {});
  332. this.$set(this.form, 'salePrice', '');
  333. this.$set(this.form, 'buyAstrictType', '1');
  334. this.$set(this.form, 'buyAstrict', '');
  335. this.$set(this.form, 'channelWx', '');
  336. this.$set(this.form, 'channelWindow', '');
  337. this.$set(this.form, 'backStatus', '');
  338. this.$set(this.form, 'backTime', '1');
  339. this.$set(this.form, 'backStatus', '');
  340. this.$set(this.form, 'days', '');
  341. this.$set(this.form, 'hour', '');
  342. },
  343. /**
  344. * 关闭弹框
  345. * @date 2023-11-22
  346. * @returns {any}
  347. */
  348. cancel() {
  349. // this.reset();
  350. this.open = false;
  351. },
  352. },
  353. };
  354. </script>
  355. <style lang="scss" scoped>
  356. .dialog {
  357. padding: 0 30px;
  358. max-height: 65vh;
  359. overflow-y: auto;
  360. }
  361. .dialog {
  362. padding: 0 30px;
  363. .upload-btn {
  364. width: 100px;
  365. height: 100px;
  366. background-color: #fbfdff;
  367. border: dashed 1px #c0ccda;
  368. border-radius: 5px;
  369. i {
  370. font-size: 30px;
  371. margin-top: 20px;
  372. }
  373. &-text {
  374. margin-top: -10px;
  375. }
  376. }
  377. .avatar {
  378. cursor: pointer;
  379. }
  380. }
  381. .el-table{
  382. .upload-btn {
  383. width: 100px;
  384. height: 100px;
  385. background-color: #fbfdff;
  386. border: dashed 1px #c0ccda;
  387. border-radius: 5px;
  388. i {
  389. font-size: 30px;
  390. margin-top: 20px;
  391. }
  392. &-text {
  393. margin-top: -10px;
  394. }
  395. }
  396. .avatar {
  397. cursor: pointer;
  398. }
  399. }
  400. </style>