| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224 |
- <!--
- * @Description: 新增/编辑弹框
- * @Author: Sugar.
- * @Date: 2023-11-24 13:55:00
- * @LastEditors: Sugar.
- * @LastEditTime: 2023-11-24 13:55:00
- * @FilePath: \cattle_webui\src\views\otaMr\dialog\AddOrEditDialog.vue
- * @Copyright: Copyright (c) 2016~2023 by Sugar., All Rights Reserved.
- -->
- <template>
- <el-dialog
- :title="title"
- :visible.sync="open"
- width="700px"
- append-to-body
- :close-on-click-modal="false"
- @close="cancel"
- >
- <div class="dialog" style="padding: 0">
- <el-table ref="tables" v-loading="tabLoading" :data="dataList" border @selection-change="handleSelectionChange">
- <el-table-column type="selection" width="50" align="center" />
- <el-table-column label="序号" align="center" type="index" width="50"></el-table-column>
- <el-table-column label="票务名称" align="center" prop="goodsName" />
- <el-table-column label="座位类型" align="center" prop="goodsName" />
- <el-table-column label="市场价" align="center" prop="salePrice" width="160">
- <template slot-scope="scope">
- <span>¥{{ scope.row.salePrice }}</span>
- </template>
- </el-table-column>
- <el-table-column label="销售价" align="center" prop="salePrice" width="160">
- <template slot-scope="scope">
- <span>¥{{ scope.row.salePrice }}</span>
- </template>
- </el-table-column>
- <el-table-column label="结算价" align="center" prop="salePrice" width="160">
- <template slot-scope="scope">
- <el-input
- type="number"
- v-model="scope.row.salePrice"
- placeholder=""
- clearable
- @change="changePriceAmount('salePrice')"
- style="width: 260px;"
- >
- </el-input>
- </template>
- </el-table-column>
- </el-table>
- <pagination
- v-show="total>0"
- :total="total"
- :page.sync="queryParams.pageNum"
- :limit.sync="queryParams.pageSize"
- @pagination="getList"
- />
- </div>
- <span slot="footer" class="dialog-footer">
- <el-button @click="cancel">取消</el-button>
- <el-button
- 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>
- </span>
- </el-dialog>
- </template>
- <script>
- import { goodsList, saveAndEdit } from '@/api/otaMr/otaMr'
- 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,
- tabLoading: false,
- dataList: [],
- total: 0,
- // 查询参数
- queryParams: {
- pageNum: 1,
- pageSize: 10,
- ota: '1'
- },
- selectList: []
- };
- },
- methods: {
- /**
- * 打开弹框
- * @date 2023-11-22
- * @param {any} obj
- * @returns {any}
- */
- openDialog(title, obj) {
- this.open = true;
- this.title = "票务信息";
- this.getList(obj);
- },
- /** 价格输入事件 */
- changePriceAmount(row) {
- if(row.salePrice * 1 < 0){
- this.$message.error("输入需大于或等于0!");
- row.salePrice = '';
- return false
- }
- },
- /** 查询列表 */
- getList(obj) {
- this.tabLoading = true;
- this.queryParams.ota = obj.ota;
- goodsList(this.queryParams)
- .then(response => {
- // this.dataList = response.data.rows;
- // this.total = response.data.total;
- // this.tabLoading = false;
- this.dataList = response.data;
- this.tabLoading = false;
- }
- ).catch(() => {
- this.tabLoading = false;
- });
- },
- // 多选框选中数据
- handleSelectionChange(selection) {
- this.selectList = selection;
- },
- /**
- * 保存
- * @date 2023-11-22
- * @returns {any}
- */
- async submitForm() {
- try {
- if(this.selectList.length <= 0) {
- this.$message.error("请勾选商品!");
- return false
- }
- let postList = [];
- this.selectList.forEach(item => {
- postList.push({
- "ota": this.queryParams.ota,
- "goodsId": item.id,
- "otaPrice": item.salePrice
- })
- })
- this.loading = true;
- const { code } = await saveAndEdit(postList);
- if (code === 200) {
- this.$message.success("操作成功!");
- this.$emit("getList");
- this.cancel();
- }
- } catch (error) {
- } finally {
- this.loading = false;
- }
- },
- /**
- * 重置
- * @date 2023-11-22
- * @returns {any}
- */
- reset() {
- },
- /**
- * 关闭弹框
- * @date 2023-11-22
- * @returns {any}
- */
- cancel() {
- 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>
|