|
|
@@ -6,7 +6,7 @@
|
|
|
<a-form-model ref="form" :model="model" :rules="validatorRules" slot="detail">
|
|
|
<a-row>
|
|
|
<a-col :span="24">
|
|
|
- <a-form-model-item label="续住总价" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="">
|
|
|
+ <a-form-model-item label="续住总价" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="" v-if="isAddDate">
|
|
|
<!-- <a-input v-model="model.name" placeholder="请输入餐桌名称"></a-input> -->
|
|
|
{{PriceData.reduce((pre,cur)=> pre+cur.price*1,0 ) || 0}}
|
|
|
<a-popover placement="right" v-if="dayNum>0">
|
|
|
@@ -49,9 +49,12 @@
|
|
|
</a-form-model-item>
|
|
|
</a-col>
|
|
|
<a-col :span="24">
|
|
|
- <a-form-model-item label="续住天数" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="">
|
|
|
+ <a-form-model-item label="续住天数" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="" v-if="isAddDate">
|
|
|
<a-input-number :min="0" v-model="dayNum" placeholder="请输入续住天数" style="width: 40%" @change="dayChange" />
|
|
|
</a-form-model-item>
|
|
|
+ <a-form-model-item label="退租天数" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="" v-if="!isAddDate">
|
|
|
+ <a-input-number :min="0" v-model="dayNum" placeholder="请输退租住天数" style="width: 40%" @change="dayChange" />
|
|
|
+ </a-form-model-item>
|
|
|
</a-col>
|
|
|
<a-col :span="24">
|
|
|
<a-form-model-item label="收款方式" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="">
|
|
|
@@ -89,8 +92,10 @@ import {
|
|
|
getAction
|
|
|
} from "@/api/manage";
|
|
|
import {
|
|
|
- validateDuplicateValue
|
|
|
-} from "@/utils/util";
|
|
|
+ formatDate,
|
|
|
+ validateDuplicateValue
|
|
|
+} from '@/utils/util'
|
|
|
+import moment from 'moment/moment'
|
|
|
|
|
|
export default {
|
|
|
name: "PosTableForm",
|
|
|
@@ -150,10 +155,6 @@ export default {
|
|
|
required: true,
|
|
|
message: "请输入pos餐桌区域id!"
|
|
|
}],
|
|
|
- num: [{
|
|
|
- required: true,
|
|
|
- message: "请输入金额!"
|
|
|
- }],
|
|
|
tableNo: [{
|
|
|
required: true,
|
|
|
message: "请输入餐桌序号!"
|
|
|
@@ -172,7 +173,8 @@ export default {
|
|
|
tableTypeList: [],
|
|
|
regionList: [],
|
|
|
PriceData: [],
|
|
|
- dayNum:0
|
|
|
+ dayNum:0,
|
|
|
+ isAddDate: true
|
|
|
};
|
|
|
},
|
|
|
watch:{
|
|
|
@@ -286,16 +288,16 @@ export default {
|
|
|
const oneDay = 24 * 60 * 60 * 1000; // hours*minutes*seconds*milliseconds
|
|
|
const firstDate = new Date(date1);
|
|
|
const secondDate = new Date(date2);
|
|
|
- if (secondDate<firstDate) {
|
|
|
- this.$message.warning("离开时间不能小于预离时间");
|
|
|
- return
|
|
|
- }
|
|
|
- const diffDays = Math.round(Math.abs((firstDate - secondDate) / oneDay));
|
|
|
- return diffDays;
|
|
|
+ const diffDays = (secondDate - firstDate) / oneDay;
|
|
|
+ this.isAddDate = diffDays >= 0;
|
|
|
+ if (Math.round(diffDays) <= 0) {
|
|
|
+ this.PriceData = []
|
|
|
+ }
|
|
|
+ return Math.round(Math.abs(diffDays));
|
|
|
},
|
|
|
batchPrice(e){
|
|
|
console.log(e);
|
|
|
- this.PriceData.forEach(item=>{
|
|
|
+ this.PriceData.forEach(item => {
|
|
|
item.price = e;
|
|
|
})
|
|
|
},
|
|
|
@@ -304,16 +306,15 @@ export default {
|
|
|
this.edit(this.modelDefault);
|
|
|
},
|
|
|
edit(record) {
|
|
|
- this.model = Object.assign({}, record);
|
|
|
+ this.model = Object.assign({}, record)
|
|
|
// this.model.startValue = record.livingData.livingOrder.dueOutTime
|
|
|
- this.visible = true;
|
|
|
+ this.visible = true
|
|
|
},
|
|
|
submitForm() {
|
|
|
const that = this;
|
|
|
// 触发表单验证
|
|
|
this.$refs.form.validate((valid) => {
|
|
|
if (valid) {
|
|
|
- that.confirmLoading = true;
|
|
|
let httpurl = "";
|
|
|
let method = "";
|
|
|
// if (!this.model.id) {
|
|
|
@@ -335,20 +336,56 @@ export default {
|
|
|
price:item.price,
|
|
|
}))
|
|
|
}
|
|
|
- // console.log(this.model.startValue);
|
|
|
- // return
|
|
|
- httpAction(`/business/busRoomBookingOrders/continue-living?livingOrderId=${this.model.roomInfo.livingOrderId}&dueOutTime=${this.model.startValue}`, obj, 'post')
|
|
|
- .then((res) => {
|
|
|
- if (res.success) {
|
|
|
- that.$message.success(res.message);
|
|
|
- that.$emit("ok");
|
|
|
- } else {
|
|
|
- that.$message.warning(res.message);
|
|
|
- }
|
|
|
- })
|
|
|
- .finally(() => {
|
|
|
- that.confirmLoading = false;
|
|
|
- });
|
|
|
+ console.log()
|
|
|
+ if (typeof (this.model.startValue) === 'undefined') {
|
|
|
+ this.model.startValue = this.model.livingData.livingOrder.dueOutTime
|
|
|
+ }
|
|
|
+ var date = new Date(this.model.startValue)
|
|
|
+ let startValueFormat = date.format('yyyy-MM-dd hh:mm:ss')
|
|
|
+
|
|
|
+// debugger
|
|
|
+ httpAction(`/business/busRoomBookingOrders/isBooked?livingOrderId=${this.model.roomInfo.livingOrderId}&dueOutTime=${startValueFormat}`,{},"post")
|
|
|
+ .then(res => {
|
|
|
+ if (!res.success) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ debugger
|
|
|
+ if (res.result !== null){
|
|
|
+ this.$confirm({
|
|
|
+ title: '提示',
|
|
|
+ content: '房间被 ' + res.result.contactName + ',电话 '+ res.result.phone +' 预定,是否续住?',
|
|
|
+ onOk: function () {
|
|
|
+ that.confirmLoading = true;
|
|
|
+ httpAction(`/business/busRoomBookingOrders/continue-living?livingOrderId=${this.model.roomInfo.livingOrderId}&dueOutTime=${startValueFormat}`, obj, 'post')
|
|
|
+ .then((res) => {
|
|
|
+ if (res.success) {
|
|
|
+ that.$message.success(res.message);
|
|
|
+ that.$emit("ok");
|
|
|
+ } else {
|
|
|
+ that.$message.warning(res.message);
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .finally(() => {
|
|
|
+ that.confirmLoading = false;
|
|
|
+ });
|
|
|
+ },
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ that.confirmLoading = true;
|
|
|
+ httpAction(`/business/busRoomBookingOrders/continue-living?livingOrderId=${this.model.roomInfo.livingOrderId}&dueOutTime=${startValueFormat}`, obj, 'post')
|
|
|
+ .then((res) => {
|
|
|
+ if (res.success) {
|
|
|
+ that.$message.success(res.message);
|
|
|
+ that.$emit("ok");
|
|
|
+ } else {
|
|
|
+ that.$message.warning(res.message);
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .finally(() => {
|
|
|
+ that.confirmLoading = false;
|
|
|
+ });
|
|
|
+ }
|
|
|
+ })
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
@@ -357,22 +394,31 @@ export default {
|
|
|
console.log(key)
|
|
|
},
|
|
|
handleStartOpenChange(e) {
|
|
|
- console.log(e)
|
|
|
+ let nowDate = new Date()
|
|
|
+ if (e._d < nowDate) {
|
|
|
+ this.$message.warning('退租时间不能小于当前时间')
|
|
|
+ this.model.startValue = nowDate
|
|
|
+ return
|
|
|
+ }
|
|
|
this.dayNum = this.daysBetween(this.model.livingData.livingOrder.dueOutTime, e._d)
|
|
|
// this.model.startValue = e._i;
|
|
|
},
|
|
|
dayChange(e) {
|
|
|
console.log(e);
|
|
|
+ if (!this.isAddDate) {
|
|
|
+ e = -e
|
|
|
+ }
|
|
|
this.model.startValue = this.addDate(this.model.livingData.livingOrder.dueOutTime, e);
|
|
|
},
|
|
|
|
|
|
disabledStartDate(endValue) {
|
|
|
- // const endValue =
|
|
|
- const startValue = this.model.livingData.livingOrder.dueOutTime
|
|
|
- if (!endValue || !startValue) {
|
|
|
- return false;
|
|
|
- }
|
|
|
- return startValue.valueOf() >= endValue.valueOf();
|
|
|
+ // const endValue =
|
|
|
+ // const startValue = this.model.livingData.livingOrder.dueOutTime
|
|
|
+ // if (!endValue || !startValue) {
|
|
|
+ // return false;
|
|
|
+ // }
|
|
|
+ // return startValue.valueOf() >= endValue.valueOf();
|
|
|
+ return endValue && endValue < moment().add(-1, 'days').endOf('day')
|
|
|
},
|
|
|
},
|
|
|
};
|