diff --git a/src/components/HelloWorld.vue b/src/components/HelloWorld.vue
index c9b2626..2bc82a0 100644
--- a/src/components/HelloWorld.vue
+++ b/src/components/HelloWorld.vue
@@ -81,7 +81,8 @@
-
@@ -96,7 +97,8 @@
-
@@ -178,7 +180,7 @@
cost: '',
count: '',
customer_comments: '',
- supplier_id: 0
+ supplier_id: null
}]
},
hotelList: [],
@@ -204,7 +206,7 @@
cost: '',
count: '',
customer_comments: '',
- supplier_id: 0
+ supplier_id: null
}]
},
hotelotherList: [],
@@ -243,19 +245,42 @@
console.log('submit!');
this.$refs['form'].validate((valid) => {
if (valid) {
- let data = {}
- let subOrderList = [...this.hotelList, ...this.hotelotherList]
- data = Object.assign({}, this.orderMain, {'subOrderList': subOrderList})
- axios.post("/hotel.php/order_main/save", data).then((res) => {
- this.$alert('新增成功', '提示', {
- confirmButtonText: '确定',
- callback: action => {
- Fast.api.close()
+ let flagArr = []
+ for (let i in this.hotelList) {
+ console.log(this.$refs['formhotel' + i])
+ this.$refs['formhotel' + i][0].$refs['form'].validate((valid) => {
+ if (valid) {
+ flagArr.push('true')
+ } else {
+ flagArr.push('false')
}
- });
- }).catch((err) => {
- console.log(err)
- })
+ })
+ }
+ for (let i in this.hotelotherList) {
+ this.$refs['formhotelother' + i][0].$refs['form'].validate((valid) => {
+ if (valid) {
+ flagArr.push('true')
+ } else {
+ flagArr.push('false')
+ }
+ })
+ }
+ if (flagArr.indexOf('false') < 0) {
+ let data = {}
+ let subOrderList = [...this.hotelList, ...this.hotelotherList]
+ data = Object.assign({}, this.orderMain, {'subOrderList': subOrderList})
+ axios.post("/hotel.php/order_main/save", data).then((res) => {
+ this.$alert('新增成功', '提示', {
+ confirmButtonText: '确定',
+ callback: action => {
+ Fast.api.close()
+ }
+ });
+ }).catch((err) => {
+ console.log(err)
+ })
+ }
+
} else {
console.log('error submit!!');
return false;
@@ -267,16 +292,24 @@
save() {
this.editSingle = false;
let data = this.orderMain
- axios.post("/hotel.php/order_main/save", data).then((res) => {
- if (res.data.flag) {
+ this.$refs['form'].validate((valid) => {
+ if (valid) {
+ axios.post("/hotel.php/order_main/save", data).then((res) => {
+ if (res.data.flag) {
+ }
+ this.$alert(res.data.msg, '提示', {
+ confirmButtonText: '确定',
+ });
+ }).catch((err) => {
+ console.log(err)
+ })
+ } else {
+ console.log('error submit!!');
+ return false;
}
- this.$alert(res.data.msg, '提示', {
- confirmButtonText: '确定',
- });
- }).catch((err) => {
- console.log(err)
- })
+ });
+
},
cancel() {
this.editSingle = false;
diff --git a/src/components/hotel.vue b/src/components/hotel.vue
index b374414..700d28e 100644
--- a/src/components/hotel.vue
+++ b/src/components/hotel.vue
@@ -18,11 +18,11 @@
-
+
-
+
@@ -36,7 +36,7 @@
-
+
-
+
-
+
-
+
-
+
@@ -104,36 +104,42 @@
prop="price"
label="售卖价">
-
+
-
+
-
+
+
+
-
-
-
-
+
+
+
+
+
+
-
+
-
+
未发单
已发单
@@ -165,7 +171,7 @@
-
+
@@ -182,7 +188,7 @@
-
+
@@ -191,10 +197,10 @@
-
+
-
+
@@ -208,7 +214,7 @@
-
+
-
+
-
+
-
+
-
+
@@ -277,36 +283,41 @@
prop="price"
label="售卖价">
-
+
-
+
-
+
+
+
-
-
-
-
+
+
+
+
+
+
-
+
-
+
未发单
已发单
@@ -338,7 +349,7 @@
-
+
@@ -355,7 +366,7 @@
-
+
@@ -381,11 +392,41 @@
data() {
return {
dataObjTemp: this.$lo.cloneDeep(this.dataObj),
+ init: true,
opened: '1',
roomListOpt: [],
date: [],
roomPlan: [],
- day: []
+ day: [],
+ rules: {
+ hotel_id: [
+ {required: true, message: '请输入', trigger: 'blur'},
+ ],
+ room_id: [
+ {required: true, message: '请输入', trigger: 'blur'},
+ ],
+ plan_id: [
+ {required: true, message: '请输入', trigger: 'blur'},
+ ],
+ customer_name: [
+ {required: true, message: '请输入', trigger: 'blur'},
+ ],
+ trade_order_number: [
+ {required: true, message: '请输入', trigger: 'blur'},
+ ],
+ confirm_status: [
+ {required: true, message: '请输入', trigger: 'blur'},
+ ],
+ count: [
+ {required: true, message: '请输入', trigger: 'blur'},
+ ],
+ supplier_id: [
+ {required: true, message: '请输入', trigger: 'blur'},
+ ],
+ purchasePriceList: [
+ {type: 'array', required: true, message: '请选择', trigger: 'change'},
+ ]
+ },
}
},
computed: {
@@ -400,52 +441,47 @@
},
date(val) {
console.log(val)
- this.$set(this.dataObj, "check_in_date", val[0])
- this.$set(this.dataObj, "check_out_date", val[1])
- let date1 = new Date(val[0]);
- let date2 = new Date(val[1]);
- let day = this.getAllDateCN(date1, date2)
- let purchasePriceList = [];
- for (let item of day) {
- purchasePriceList.push({
- run_date: item,
- price: '',
- cost: '',
- count: '',
- customer_comments: '',
- supplier_id: ''
- })
+ if (val && val.length > 0) {
+ this.$set(this.dataObj, "check_in_date", val[0])
+ this.$set(this.dataObj, "check_out_date", val[1])
+ let date1 = new Date(val[0]);
+ let date2 = new Date(val[1]);
+ let day = this.getAllDateCN(date1, date2)
+ let purchasePriceList = [];
+ for (let item of day) {
+ purchasePriceList.push({
+ run_date: item,
+ price: '',
+ cost: '',
+ count: '',
+ customer_comments: '',
+ supplier_id: ''
+ })
+ }
+ this.dataObj.purchasePriceList = purchasePriceList;
+ this.$set(this.dataObj, 'purchasePriceList', purchasePriceList)
}
- this.dataObj.purchasePriceList = purchasePriceList;
- this.$set(this.dataObj, 'purchasePriceList', purchasePriceList)
-
}
},
methods: {
changeNum(value) {
- if (this.type == 'add') {
- this.dataObj.purchasePriceList.forEach((item) => {
- this.$set(item, 'count', value)
- })
- }
+ this.dataObj.purchasePriceList.forEach((item) => {
+ this.$set(item, 'count', value)
+ })
},
changesupplier_id(value) {
- if (this.type == 'add') {
- this.dataObj.purchasePriceList.forEach((item) => {
- this.$set(item, 'supplier_id', value)
- })
- // this.$set(this.dataObj, 'supplier_id', value)
- this.dataObj.supplier_id = value;
- }
+ this.dataObj.purchasePriceList.forEach((item) => {
+ this.$set(item, 'supplier_id', value)
+ })
+ // this.$set(this.dataObj, 'supplier_id', value)
+ this.dataObj.supplier_id = value;
},
changeNote(value) {
- if (this.type == 'add') {
- this.dataObj.purchasePriceList.forEach((item) => {
- this.$set(item, 'customer_comments', value)
- })
- this.dataObj.customer_comments = value;
- // this.$set(this.dataObj, 'customer_comments', value)
- }
+ this.dataObj.purchasePriceList.forEach((item) => {
+ this.$set(item, 'customer_comments', value)
+ })
+ this.dataObj.customer_comments = value;
+ // this.$set(this.dataObj, 'customer_comments', value)
},
arraySpanMethod({row, column, rowIndex, columnIndex}) {
// console.log({row, column, rowIndex, columnIndex})
@@ -538,15 +574,21 @@
selectChange(item) {
console.log(item)
this.roomListOpt = []
- axios.get("/hotel.php/cf_room_info/getRoomList?hotelId=" + item).then((res) => {
- console.log(res)
- this.roomListOpt = res.data.list
- this.dataObj.room_id = '';
- this.$set(this.dataObj, 'room_id', '')
- // this.roomListOpt = [{"id": 1, "name": "111"}]
- }).catch((err) => {
- console.log(err)
+ return new Promise(resolve => {
+ axios.get("/hotel.php/cf_room_info/getRoomList?hotelId=" + item).then((res) => {
+ console.log(res)
+ this.roomListOpt = res.data.list
+ if (!this.init) {
+ this.dataObj.room_id = '';
+ this.$set(this.dataObj, 'room_id', '')
+ }
+ resolve()
+ // this.roomListOpt = [{"id": 1, "name": "111"}]
+ }).catch((err) => {
+ console.log(err)
+ })
})
+
},
roomselectChange(item) {
let obj = this.roomListOpt.find((items) => {
@@ -555,15 +597,19 @@
console.log(obj)
this.dataObjTemp.room_memo = obj.room_memo;
this.roomPlan = []
- axios.get("/hotel.php/cf_room_plan/getList?room_id=" + item).then((res) => {
- console.log(res)
- this.roomPlan = res.data.list //取酒店价格方案
- this.dataObj.plan_id = '';
- this.$set(this.dataObj, 'plan_id', '')
- }).catch((err) => {
- console.log(err)
+ return new Promise(resolve => {
+ axios.get("/hotel.php/cf_room_plan/getList?room_id=" + item).then((res) => {
+ console.log(res)
+ this.roomPlan = res.data.list //取酒店价格方案
+ if (!this.init) {
+ this.dataObj.plan_id = '';
+ this.$set(this.dataObj, 'plan_id', '')
+ }
+ resolve()
+ }).catch((err) => {
+ console.log(err)
+ })
})
-
},
priceselectChange(item) {
console.log(this.roomPlan)
@@ -579,28 +625,52 @@
// this.$set(this.dataObj, 'editType', 'edit');
},
save() {
- axios.post("/hotel.php/order_main/subOrderSave", this.dataObj).then((res) => {
- console.log(res.data)
- if (res.data.flag) {
- this.dataObjTemp.editType = 'view';
+ this.$refs['form'].validate((valid) => {
+ if (valid) {
+ axios.post("/hotel.php/order_main/subOrderSave", this.dataObj).then((res) => {
+ console.log(res.data)
+ if (res.data.flag) {
+ this.dataObjTemp.editType = 'view';
+ }
+ this.$alert(res.data.msg, '提示', {
+ confirmButtonText: '确定',
+ });
+ }).catch((err) => {
+ console.log(err)
+ })
+ } else {
+ console.log('error submit!!');
+ return false;
}
- this.$alert(res.data.msg, '提示', {
- confirmButtonText: '确定',
- });
- }).catch((err) => {
- console.log(err)
- })
+ });
+
},
cancel() {
this.dataObjTemp.editType = 'view';
this.$set(this.dataObj, 'editType', 'view');
- this.$set(this, 'dataObj', this.dataObj);
+ this.$set(this, 'dataObj', this.dataObjTemp);
+ this.$refs['form'].clearValidate()
}
},
mounted() {
if (process.env.NODE_ENV !== 'production') {
axios.defaults.baseURL = '/api' //关键代码
}
+
+
+ if (this.dataObj.hotel_id && this.dataObj.hotel_id && this.dataObj.hotel_id) {
+ // let hotel_id = this.dataObj.hotel_id
+ // let room_id = this.dataObj.room_id
+ // let plan_id = this.dataObj.plan_id
+ this.selectChange(this.dataObj.hotel_id).then(() => {
+ this.roomselectChange(this.dataObj.room_id).then(() => {
+ // this.dataObj.hotel_id = hotel_id
+ // this.dataObj.room_id = room_id
+ // this.dataObj.plan_id = plan_id
+ this.init = false;
+ })
+ })
+ }
}
}
diff --git a/src/components/hotelother.vue b/src/components/hotelother.vue
index 882337e..5683225 100644
--- a/src/components/hotelother.vue
+++ b/src/components/hotelother.vue
@@ -18,11 +18,11 @@
-
+
-
+
-
+
-
+
-
+
@@ -55,12 +55,12 @@
-
+
-
+
@@ -83,36 +83,42 @@
prop="price"
label="售卖价">
-
+
-
+
-
+
+
+
-
-
-
-
+
+
+
+
+
+
-
+
-
+
-
+
未发单
已发单
@@ -156,7 +162,7 @@
-
+
@@ -164,10 +170,10 @@
-
+
-
+
-
+
-
+
-
+
-
+
-
+
@@ -226,36 +232,41 @@
prop="price"
label="售卖价">
-
+
-
+
-
+
+
+
-
-
-
-
+
+
+
+
+
+
-
+
-
+
-
+
未发单
已发单
@@ -299,7 +310,7 @@
-
+
@@ -326,7 +337,36 @@
dataObjTemp: this.$lo.cloneDeep(this.dataObj),
opened: '1',
check_in_date: '',
- day: []
+ day: [],
+ rules: {
+ item_id: [
+ {required: true, message: '请输入', trigger: 'blur'},
+ ],
+ customer_name: [
+ {required: true, message: '请输入', trigger: 'blur'},
+ ],
+ confirm_no: [
+ {required: true, message: '请输入', trigger: 'blur'},
+ ],
+ trade_order_number: [
+ {required: true, message: '请输入', trigger: 'blur'},
+ ],
+ purchase_user_id: [
+ {required: true, message: '请输入', trigger: 'blur'},
+ ],
+ confirm_status: [
+ {required: true, message: '请输入', trigger: 'blur'},
+ ],
+ count: [
+ {required: true, message: '请输入', trigger: 'blur'},
+ ],
+ supplier_id: [
+ {required: true, message: '请输入', trigger: 'blur'},
+ ],
+ purchasePriceList: [
+ {type: 'array', required: true, message: '请输入', trigger: 'change'},
+ ]
+ },
}
},
computed: {
@@ -340,20 +380,22 @@
this.dataObjTemp = this.$lo.cloneDeep(this.dataObj)
},
check_in_date(val) {
- let time = this.getAllDateCN(val)
- console.log(time)
- this.$set(this.dataObj, "check_in_date", time)
- let purchasePriceList = [];
- purchasePriceList.push({
- run_date: time,
- price: '',
- cost: '',
- count: '',
- customer_comments: '',
- supplier_id: ''
- })
- this.dataObj.purchasePriceList = purchasePriceList;
- this.$set(this.dataObj, 'purchasePriceList', purchasePriceList)
+ if (val) {
+ let time = this.getAllDateCN(val)
+ console.log(time)
+ this.$set(this.dataObj, "check_in_date", time)
+ let purchasePriceList = [];
+ purchasePriceList.push({
+ run_date: time,
+ price: '',
+ cost: '',
+ count: '',
+ customer_comments: '',
+ supplier_id: ''
+ })
+ this.dataObj.purchasePriceList = purchasePriceList;
+ this.$set(this.dataObj, 'purchasePriceList', purchasePriceList)
+ }
}
},
methods: {
@@ -366,29 +408,23 @@
this.dataObjTemp = Object.assign(this.dataObjTemp, data);
},
changeNum(value) {
- if (this.type == 'add') {
- this.dataObj.purchasePriceList.forEach((item) => {
- this.$set(item, 'count', value)
- })
- }
+ this.dataObj.purchasePriceList.forEach((item) => {
+ this.$set(item, 'count', value)
+ })
},
changesupplier_id(value) {
- if (this.type == 'add') {
- this.dataObj.purchasePriceList.forEach((item) => {
- this.$set(item, 'supplier_id', value)
- })
- this.dataObj.supplier_id = value
- // this.$set(this.dataObj, 'supplier_id', value)
- }
+ this.dataObj.purchasePriceList.forEach((item) => {
+ this.$set(item, 'supplier_id', value)
+ })
+ this.dataObj.supplier_id = value
+ // this.$set(this.dataObj, 'supplier_id', value)
},
changeNote(value) {
- if (this.type == 'add') {
- this.dataObj.purchasePriceList.forEach((item) => {
- this.$set(item, 'customer_comments', value)
- })
- this.dataObj.customer_comments = value
- // this.$set(this.dataObj, 'customer_comments', value)
- }
+ this.dataObj.purchasePriceList.forEach((item) => {
+ this.$set(item, 'customer_comments', value)
+ })
+ this.dataObj.customer_comments = value
+ // this.$set(this.dataObj, 'customer_comments', value)
},
arraySpanMethod({row, column, rowIndex, columnIndex}) {
// console.log({row, column, rowIndex, columnIndex})
@@ -476,22 +512,30 @@
this.dataObjTemp.editType = 'edit';
},
save() {
- axios.post("/hotel.php/order_main/subOrderSave", this.dataObj).then((res) => {
- console.log(res)
- if (res.data.flag) {
- this.dataObjTemp.editType = 'view';
+ this.$refs['form'].validate((valid) => {
+ if (valid) {
+ axios.post("/hotel.php/order_main/subOrderSave", this.dataObj).then((res) => {
+ console.log(res)
+ if (res.data.flag) {
+ this.dataObjTemp.editType = 'view';
+ }
+ this.$alert(res.data.msg, '提示', {
+ confirmButtonText: '确定',
+ });
+ }).catch((err) => {
+ console.log(err)
+ })
+ } else {
+ console.log('error submit!!');
+ return false;
}
- this.$alert(res.data.msg, '提示', {
- confirmButtonText: '确定',
- });
- }).catch((err) => {
- console.log(err)
- })
+ });
},
cancel() {
this.dataObjTemp.editType = 'view';
this.$set(this.dataObj, 'editType', 'view');
- this.$set(this, 'dataObj', this.dataObj);
+ this.$set(this, 'dataObj', this.dataObjTemp);
+ this.$refs['form'].clearValidate()
}
},
mounted() {