Explorar o código

修改change事件

wangh %!s(int64=2) %!d(string=hai) anos
pai
achega
307c375028
Modificáronse 2 ficheiros con 94 adicións e 69 borrados
  1. 92 67
      src/components/OP/OpAirTicketRes.vue
  2. 2 2
      src/main.js

+ 92 - 67
src/components/OP/OpAirTicketRes.vue

@@ -72,9 +72,11 @@
                     </div>
                     <div style="width: 33%;">
                         <el-form-item label="机票单价:" prop="prePrice" label-width="160px">
-                            <el-input placeholder="机票单价" v-model="prePrice" style="width: 58%;" @input="peiceinput">
+                            <el-input placeholder="机票单价" v-model="airTicketResOpData.prePrice" style="width: 58%;"
+                                @input="peiceinput">
                             </el-input>
-                            <el-select v-model="currencyId" style="width: 35%;">
+                            <el-select v-model="airTicketResOpData.preCurrency" style="width: 35%;"
+                                @change="currencyChange">
                                 <el-option key="48" label="CNY" :value="48"></el-option>
                                 <el-option key="49" label="USD" :value="49"></el-option>
                                 <el-option key="51" label="EUR" :value="51"></el-option>
@@ -86,7 +88,7 @@
                             <el-input placeholder="机票总价" v-model="airTicketResOpData.price" style="width: 58%;"
                                 :disabled="true">
                             </el-input>
-                            <el-select v-model="currencyId" style="width: 35%;" :disabled="true">
+                            <el-select v-model="airTicketResOpData.currency" style="width: 35%;" :disabled="true">
                                 <el-option key="48" label="CNY" :value="48"></el-option>
                                 <el-option key="49" label="USD" :value="49"></el-option>
                                 <el-option key="51" label="EUR" :value="51"></el-option>
@@ -99,7 +101,7 @@
                 <div style="display: flex;">
                     <div style="width: 33%;">
                         <el-form-item label="此舱位人数:" prop="clientNum" label-width="160px">
-                            <el-input placeholder="此舱位人数" v-model="clientNum" @input="peiceinput">
+                            <el-input placeholder="此舱位人数" v-model="airTicketResOpData.clientNum" @input="peiceinput">
                             </el-input>
                         </el-form-item>
                     </div>
@@ -216,7 +218,7 @@
                         </el-form-item>
                     </div>
                     <div style="width: 25%;">
-                        <el-form-item label="消费方式:" prop="visitCountry">
+                        <el-form-item label="消费方式:" prop="consumptionPatterns">
                             <el-input placeholder="消费方式" v-model="cardPaymentOpData.consumptionPatterns">
                             </el-input>
                         </el-form-item>
@@ -233,7 +235,7 @@
                             <el-input placeholder="付款金额" v-model="cardPaymentOpData.payMoney" style="width: 52%;"
                                 :disabled="true">
                             </el-input>
-                            <el-select v-model="currencyId" style="width: 45%;" :disabled="true">
+                            <el-select v-model="cardPaymentOpData.paymentCurrency" style="width: 45%;" :disabled="true">
                                 <el-option key="48" label="CNY" :value="48"></el-option>
                                 <el-option key="49" label="USD" :value="49"></el-option>
                                 <el-option key="51" label="EUR" :value="51"></el-option>
@@ -244,7 +246,7 @@
                 <div v-if="cardPaymentOpData.payDId == 72">
                     <div style="display: flex;">
                         <div style="width: 25%;">
-                            <el-form-item label="卡类型:">
+                            <el-form-item label="卡类型:" prop="ctdId">
                                 <el-select v-model="cardPaymentOpData.ctdId" placeholder="卡类型" style="width: 100%;"
                                     @change="ctdChange">
                                     <el-option v-for="item in cardType" :key="item.id" :label="item.name" :value="item.id">
@@ -320,13 +322,13 @@
                 <div v-else></div>
                 <div style="display:flex;">
                     <div style="width: 25%;">
-                        <el-form-item label="收款方:">
+                        <el-form-item label="收款方:" prop="payee">
                             <el-input placeholder="对方姓名:" v-model="cardPaymentOpData.payee">
                             </el-input>
                         </el-form-item>
                     </div>
                     <div style="width: 25%;">
-                        <el-form-item label="费用标识:" prop="visitCountry">
+                        <el-form-item label="费用标识:" prop="orbitalPrivateTransfer">
                             <el-select v-model="cardPaymentOpData.orbitalPrivateTransfer" placeholder="费用标识"
                                 style="width: 100%;">
                                 <el-option key="0" label="公转" :value=0>
@@ -388,12 +390,30 @@ export default {
                 ],
                 flightsCity: [
                     { required: true, message: '请输入城市', trigger: 'change' },
-                ]
+                ],
+                clientName: [
+                    { required: true, message: '请输入客人姓名', trigger: 'change' },
+                ],
+                flightsDescription: [
+                    { required: true, message: '请严格遵守格式,正确填写', trigger: 'change' },
+                ],
             },
             cardPaymentRules: {
                 payDId: [
                     { required: true, message: '请选择支付方式', trigger: 'blur' },
-                ]
+                ],
+                consumptionPatterns: [
+                    { required: true, message: '请输入消费方式', trigger: 'blur' },
+                ],
+                payee: [
+                    { required: true, message: '请输入收款方', trigger: 'blur' },
+                ],
+                orbitalPrivateTransfer: [
+                    { required: true, message: '请选择费用表示', trigger: 'blur' },
+                ],
+                // ctdId: [
+                //     { required: true, message: '请选择卡类型', trigger: 'blur' },
+                // ]
             },
             title: "新增机票费用录入",
             token: '',
@@ -404,13 +424,10 @@ export default {
             delegationInfo: {},
             AirTicketResSelectData: [],//团组下拉框
             ticketClass: [],//舱位下拉框
-            currencyId: 48,
             payment: [],//支付方式下拉框
             cardType: [],//卡类型下拉框
             airTicketAgents: [],//合作的代理资料
             airTicketAgentsId: '',
-            prePrice: '',
-            clientNum: '',
             airGroupCostParameter: {},//机票成本预算
             jjccb: 0,
             jjcrs: 0,
@@ -424,9 +441,9 @@ export default {
                 diId: 0,
                 cType: '',
                 prePrice: 0,
-                preCurrency: this.currencyId,
+                preCurrency: 48,
                 price: 0,
-                currency: this.currencyId,
+                currency: 48,
                 clientNum: 0,
                 clientName: '',
                 isCheckIn: 0,
@@ -450,7 +467,7 @@ export default {
                 bankNo: '',
                 cardholderName: 'Zhang Hailin',
                 payMoney: 0,
-                paymentCurrency: this.currencyId,
+                paymentCurrency: 48,
                 companyBankNo: '',
                 otherBankName: '',
                 otherSideNo: '',
@@ -527,52 +544,59 @@ export default {
         //点击保存事件
         addBtn() {
             const that = this;
-            that.$refs.airTicketResOpData.validate((valid) => {
-                if (valid) {
-
-                    that.airTicketResOpData.diId = that.DiId;
-                    that.airTicketResOpData.clientNum = that.clientNum;
-                    that.airTicketResOpData.createUserId = that.userId;
-                    that.airTicketResOpData.currency = that.currencyId;
-                    that.airTicketResOpData.preCurrency = that.currencyId;
-                    that.airTicketResOpData.prePrice = that.prePrice
-                    console.log(that.airTicketResOpData)
+            let formArr = ['airTicketResOpData', 'cardPaymentOpData']//三个form表单的ref
+            var resultArr = [] //用来接受返回结果的数组
+            function checkForm(formName) { //封装验证表单的函数
+                var result = new Promise(function (resolve, reject) {
+                    that.$refs[formName].validate((valid) => {
+                        if (valid) {
+                            resolve();
+                        } else { reject() }
+                    })
+                })
+                resultArr.push(result) //push 得到promise的结果
+            }
+            formArr.forEach(item => { //根据表单的ref校验
+                checkForm(item)
+            })
+            Promise.all(resultArr).then(values => {
+                that.airTicketResOpData.diId = that.DiId;
+                that.airTicketResOpData.createUserId = that.userId;
 
-                    that.cardPaymentOpData.createUserId = that.userId;
-                    that.cardPaymentOpData.diId = that.DiId;
-                    that.cardPaymentOpData.paymentCurrency = that.currencyId
+                that.cardPaymentOpData.createUserId = that.userId;
+                that.cardPaymentOpData.diId = that.DiId;
+                if (that.cardPaymentOpData.ctdId == '') {
                     that.cardPaymentOpData.ctdId = 0;
-                    console.log(that.cardPaymentOpData)
-                    var url = "/api/Groups/OpAirTicketRes"
-                    that.$axios({
-                        method: 'post',
-                        url: url,
-                        headers: {
-                            Authorization: 'Bearer ' + that.token
-                        },
-                        data: {
-                            status: that.status,
-                            airTicketResOpData: that.airTicketResOpData,
-                            cardPaymentOpData: that.cardPaymentOpData
-                        }
-                    }).then(function (res) {
-                        if (res.data.code == 200) {
-                            that.$message({
-                                message: res.data.msg,
-                                type: 'success'
-                            });
-                            that.loading = true;
-                            setTimeout(() => {
-                                that.$router.push('/home/AirTicketRes')
-                            }, 3000);
-                        } else {
-                            that.$message.error(res.data.msg);
-                        }
-                    })
-                } else {
-                    this.$message.error('请完善信息在保存!');
-                    return false;
                 }
+                var url = "/api/Groups/OpAirTicketRes"
+                that.$axios({
+                    method: 'post',
+                    url: url,
+                    headers: {
+                        Authorization: 'Bearer ' + that.token
+                    },
+                    data: {
+                        status: that.status,
+                        airTicketResOpData: that.airTicketResOpData,
+                        cardPaymentOpData: that.cardPaymentOpData
+                    }
+                }).then(function (res) {
+                    if (res.data.code == 200) {
+                        that.$message({
+                            message: res.data.msg,
+                            type: 'success'
+                        });
+                        that.loading = true;
+                        setTimeout(() => {
+                            that.$router.push('/home/AirTicketRes')
+                        }, 3000);
+                    } else {
+                        that.$message.error(res.data.msg);
+                    }
+                })// 此时必填完成,做保存后的业务操作
+            }).catch(_ => {
+                this.$message.error('请完善信息在保存!');
+                return false;
             })
         },
         //根据机票费用录入Id查询c表和机票费用信息
@@ -599,6 +623,7 @@ export default {
                 }
             })
         },
+        //支付方式change事件
         payChange() {
             this.cardPaymentOpData.ctdId = '';
             this.cardPaymentOpData.bankNo = '';
@@ -634,9 +659,14 @@ export default {
         },
         //单价值改变事件
         peiceinput() {
-            this.cardPaymentOpData.payMoney = parseFloat(this.prePrice * this.clientNum)
+            this.cardPaymentOpData.payMoney = parseFloat(parseFloat(this.airTicketResOpData.prePrice) * parseFloat(this.airTicketResOpData.clientNum)).toFixed(2)
             this.cardPaymentOpData.payThenMoney = this.cardPaymentOpData.payMoney
-            this.airTicketResOpData.price = parseFloat(this.prePrice * this.clientNum)
+            this.airTicketResOpData.price = parseFloat(parseFloat(this.airTicketResOpData.prePrice) * parseFloat(this.airTicketResOpData.clientNum)).toFixed(2)
+        },
+        currencyChange(Id) {
+            this.cardPaymentOpData.paymentCurrency = Id;
+            this.airTicketResOpData.preCurrency = Id;
+            this.airTicketResOpData.currency = Id;
         }
     },
 
@@ -647,11 +677,6 @@ export default {
         this.AirTicketResSelect();
         this.id = this.$route.query.id
         this.DiId = this.$route.query.DiId
-
-        this.cardPaymentOpData.payMoney = parseFloat(this.prePrice * this.clientNum)
-        this.cardPaymentOpData.payThenMoney = this.cardPaymentOpData.payMoney
-        this.airTicketResOpData.price = parseFloat(this.prePrice * this.clientNum)
-
     }
 }
 </script>

+ 2 - 2
src/main.js

@@ -10,8 +10,8 @@ import store from './store/index.js';
 import VueTypedJs from 'vue-typed-js'
 Vue.use(VueTypedJs)
 import axios from 'axios';
-axios.defaults.baseURL = 'http://132.232.92.186:8888';
-// axios.defaults.baseURL = 'http://localhost:5256/';
+//axios.defaults.baseURL = 'http://132.232.92.186:8888';
+axios.defaults.baseURL = 'http://localhost:5256/';
 import { Message } from "element-ui";
 Vue.prototype.$message = Message
 Vue.prototype.$axios = axios;