| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381 |
- <!--
- * @Description: 新增/编辑弹框
- * @Author: Sugar.
- * @Date: 2023-11-24 13:55:00
- * @LastEditors: Sugar.
- * @LastEditTime: 2023-11-24 13:55:00
- * @FilePath: \cattle_webui\src\views\ticket\dialog\AddOrEditDialog.vue
- * @Copyright: Copyright (c) 2016~2023 by Sugar., All Rights Reserved.
- -->
- <template>
- <el-dialog
- :title="title"
- :visible.sync="open"
- width="900px"
- append-to-body
- :close-on-click-modal="false"
- @close="cancel"
- >
- <div class="dialog">
- <el-form :model="form" ref="form" :rules="rules" label-width="120px">
- <el-form-item label="票务选择:" prop="goodsId">
- <el-select
- :disabled="isDisabled"
- v-model="form.goodsId"
- placeholder="选择票务"
- clearable
- style="width: 100%"
- >
- <el-option
- v-for="dict in ticketList"
- :key="dict.id"
- :label="dict.goodsName + ' (' + dict.salePrice + '元)' "
- :value="dict.id"
- />
- </el-select>
- </el-form-item>
- <el-form-item label="选择场馆:" prop="venueId">
- <el-select
- :disabled="isDisabled"
- v-model="form.venueId"
- placeholder="选择场馆"
- clearable
- @change="changeTheatre"
- style="width: 100%"
- >
- <el-option
- v-for="dict in theatreList"
- :key="dict.id"
- :label="dict.name"
- :value="dict.id"
- />
- </el-select>
- </el-form-item>
- <el-form-item label="选择演出厅:" prop="auditoriumId">
- <el-select
- :disabled="isDisabled"
- v-model="form.auditoriumId"
- placeholder="选择演出厅"
- clearable
- style="width: 100%"
- >
- <el-option
- v-for="dict in merchantList"
- :key="dict.id"
- :label="dict.name"
- :value="dict.id"
- />
- </el-select>
- </el-form-item>
- <el-form-item label="选择剧目:" prop="performId">
- <el-select
- :disabled="isDisabled"
- v-model="form.performId"
- placeholder="选择剧目"
- clearable
- style="width: 100%"
- >
- <el-option
- v-for="dict in goodsList"
- :key="dict.id"
- :label="dict.name"
- :value="dict.id"
- />
- </el-select>
- </el-form-item>
- <el-form-item label="选择座位类型:" prop="seatTypeId">
- <el-select
- :disabled="isDisabled"
- v-model="form.seatTypeId"
- placeholder="座位类型"
- clearable
- style="width: 100%"
- >
- <el-option
- v-for="dict in seatList"
- :key="dict.id"
- :label="dict.name"
- :value="dict.id"
- />
- </el-select>
- </el-form-item>
- <!-- <el-form-item label="结算方式:" prop="priceType">-->
- <!-- <el-radio :disabled="isDisabled" v-model="form.priceType" label="1">基于票务类型打折</el-radio>-->
- <!-- <el-radio :disabled="isDisabled" v-model="form.priceType" label="2">固定值</el-radio>-->
- <!-- </el-form-item>-->
- <el-form-item label="价格:" prop="priceAmount">
- <el-input
- :disabled="isDisabled"
- type="number"
- v-model="form.priceAmount"
- placeholder=""
- clearable
- @change="changePriceAmount"
- style="width: 160px;"
- >
- <!-- <template slot="append">{{ form.priceType == 1 ? '%' : '元' }}</template>-->
- <template slot="append">元</template>
- </el-input>
- </el-form-item>
- </el-form>
- </div>
- <span slot="footer" class="dialog-footer">
- <el-button v-if="!isDisabled" @click="cancel">取消</el-button>
- <el-button
- v-if="!isDisabled"
- type="primary"
- @click="submitForm"
- v-loading.fullscreen.lock="loading"
- element-loading-text="提交中..."
- element-loading-spinner="el-icon-loading"
- element-loading-background="rgba(0, 0, 0, 0.8)"
- >
- <span v-if="loading">提交中...</span>
- <span v-else>保存</span>
- </el-button>
- <el-button v-if="isDisabled" type="primary" @click="cancel">确定</el-button>
- </span>
- </el-dialog>
- </template>
- <script>
- import { saveAndEdit } from "@/api/ticketMr/priceMr";
- import { SeatTypeList } from '@/api/seatTypeMr/seatTypeMr'
- import { pageList } from "@/api/venueMr/venueMr";
- import { ticketPageList } from '@/api/ticketMr/ticketMr'
- import { goodsPageList } from '@/api/programmeMr/programmeMr'
- import { merchantPageList } from '@/api/performanceHallMr/performanceHallMr'
- import Editor from "@/components/Editor";
- import { getToken } from "@/utils/auth";
- export default {
- name: "addAndEdit",
- props: {
- dict: {
- type: Object,
- default: () => [],
- },
- },
- components: {
- Editor,
- },
- data() {
- return {
- title: "编辑",
- model: "EDIT",
- open: false,
- loading: false,
- tableType: false,
- isDisabled: false,
- form: {
- id: undefined,
- priceType: '2'
- },
- rules: {
- venueId: [{ required: true, message: "请选择场馆", trigger: "blur" }],
- auditoriumId: [{ required: true, message: "请选择演出厅", trigger: "blur" }],
- performId: [{ required: true, message: "请选择剧目", trigger: "blur" }],
- goodsId: [{ required: true, message: "请选择票务", trigger: "blur" }],
- seatTypeId: [{ required: true, message: "请选择座位类型", trigger: "blur" }],
- priceType: [{ required: true, message: "请选择结算方式", trigger: "blur" }],
- priceAmount: [{ required: true, message: "请输入价格", trigger: "blur" }],
- },
- uploadObj: {
- url: process.env.VUE_APP_UPLOAD_FILE_API + "/upload/single/minio",
- Headers: { Authorization: "Bearer " + getToken() },
- },
- theatreList: [],
- goodsList: [],
- merchantList: [],
- editType: false,
- ticketList: [],
- seatList: []
- };
- },
- methods: {
- /**
- * 打开弹框
- * @date 2023-11-22
- * @param {any} obj
- * @returns {any}
- */
- openDialog(title, obj, type) {
- this.open = true;
- this.editType = false;
- this.isDisabled = false
- this.reset();
- this.getList();
- this.goodsPageList();
- this.ticketListApi();
- this.getSeatTypeList();
- // this.merchantPageList();
- if (obj){
- this.editType = true;
- if(type) {
- this.title = "座位价格";
- this.isDisabled = true
- } else {
- this.title = "编辑座位价格";
- }
- this.$nextTick(() => {
- this.$set(this.form, 'id', obj.id);
- this.$set(this.form, 'goodsId', obj.goodsId);
- this.$set(this.form, 'seatTypeId', obj.seatTypeId);
- this.$set(this.form, 'performId', obj.performId);
- this.$set(this.form, 'auditoriumId', obj.auditoriumId);
- this.$set(this.form, 'priceType', obj.priceType.toString());
- this.$set(this.form, 'priceAmount', obj.priceAmount);
- this.getList(obj.theatreName);
- });
- }else{
- this.title = "新增座位价格";
- this.$nextTick(() => {
- this.$refs["form"].clearValidate();
- });
- }
- },
- /** 座位类型列表 */
- getSeatTypeList() {
- SeatTypeList(this.addDateRange({pageNum: 1, pageSize: 100}))
- .then(response => {
- this.seatList = response.data.rows;
- });
- },
- /** 场馆列表查询 */
- getList(name) {
- pageList(this.addDateRange({pageNum: 1, pageSize: 100}))
- .then(response => {
- this.theatreList = response.data.rows;
- this.theatreList.forEach(item => {
- if(name == item.name){
- this.$set(this.form, 'venueId', item.id)
- }
- })
- this.merchantPageList(this.form.venueId)
- });
- },
- /** 场馆选择 */
- changeTheatre(id) {
- this.merchantPageList(id)
- this.$set(this.form, 'auditoriumId', '')
- },
- /** 剧目列表查询 */
- goodsPageList() {
- goodsPageList(this.addDateRange({pageNum: 1, pageSize: 100, status: 1}))
- .then(response => {
- this.goodsList = response.data.rows;
- });
- },
- /** 票务列表查询 */
- ticketListApi() {
- ticketPageList(this.addDateRange({pageNum: 1, pageSize: 100, goodsType: 2, classifyId: 1, status: 0}))
- .then(response => {
- this.ticketList = response.data.rows;
- // 判断票务回写时 是否被删除或者关闭 如果是goodsId为空
- if(this.form.goodsId && this.form.goodsId != ''){
- let goodsType = false
- this.ticketList.forEach(item => {
- if(item.id == this.form.goodsId){
- goodsType = true;
- }
- })
- if(!goodsType){
- this.$set(this.form, 'goodsId', "");
- }
- }
- });
- },
- /** 演出厅列表查询 */
- merchantPageList(id) {
- merchantPageList(this.addDateRange({theatreId: id, pageNum: 1, pageSize: 100}))
- .then(response => {
- this.merchantList = response.data.rows;
- });
- },
- /** 价格输入事件 */
- changePriceAmount(val) {
- if(val * 1 < 0){
- this.$message.error("输入需大于或等于0!");
- this.$set(this.form, 'priceAmount', '');
- return false
- }
- },
- /**
- * 保存
- * @date 2023-11-22
- * @returns {any}
- */
- submitForm() {
- this.$refs["form"].validate(async (valid) => {
- if (valid) {
- try {
- this.loading = true;
- const { code } = await saveAndEdit({ ...this.form });
- if (code === 200) {
- this.$message.success("操作成功!");
- this.$emit("getList");
- this.cancel();
- }
- } catch (error) {
- } finally {
- this.loading = false;
- }
- }
- });
- },
- /**
- * 重置
- * @date 2023-11-22
- * @returns {any}
- */
- reset() {
- this.$set(this.form, 'id', '');
- this.$set(this.form, 'goodsId', '');
- this.$set(this.form, 'venueId', '');
- this.$set(this.form, 'seatTypeId', '');
- this.$set(this.form, 'performId', '');
- this.$set(this.form, 'auditoriumId', '');
- this.$set(this.form, 'priceType', '2');
- this.$set(this.form, 'priceAmount', '');
- },
- /**
- * 关闭弹框
- * @date 2023-11-22
- * @returns {any}
- */
- cancel() {
- this.reset();
- this.open = false;
- },
- },
- };
- </script>
- <style lang="scss" scoped>
- .dialog {
- padding: 0 30px;
- max-height: 65vh;
- overflow-y: auto;
- }
- .dialog {
- padding: 0 30px;
- .upload-btn {
- width: 100px;
- height: 100px;
- background-color: #fbfdff;
- border: dashed 1px #c0ccda;
- border-radius: 5px;
- i {
- font-size: 30px;
- margin-top: 20px;
- }
- &-text {
- margin-top: -10px;
- }
- }
- .avatar {
- cursor: pointer;
- }
- }
- </style>
|