Browse Source

init

master
xcodebin 3 years ago
parent
commit
ecb71a4bf2
3 changed files with 647 additions and 523 deletions
  1. +308
    -264
      src/components/HelloWorld.vue
  2. +297
    -235
      src/components/hotel.vue
  3. +42
    -24
      src/components/hotelother.vue

+ 308
- 264
src/components/HelloWorld.vue View File

@@ -12,11 +12,18 @@
</div>
</el-row>
</template>
<el-form ref="form" :model="orderMain" label-width="100px" :disabled="disable">
<el-form ref="form" :model="orderMain" :rules="rules" label-width="120px" :disabled="disable">
<el-row>
<el-col :span="12">
<el-form-item label="订单专员">
<el-input v-model="orderMain.commissioner"></el-input>
<el-form-item label="订单专员" prop="commissioner_id">
<el-select style="width: 100%" v-model="orderMain.commissioner_id" filterable placeholder="请选择">
<el-option
v-for="item in userOpt"
:key="item.id"
:label="item.name"
:value="item.id">
</el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12"></el-col>
@@ -24,7 +31,7 @@
</el-row>
<el-row>
<el-col :span="12">
<el-form-item label="订单渠道">
<el-form-item label="订单渠道" prop="channel_id">
<el-select style="width: 100%" v-model="orderMain.channel_id" filterable placeholder="请选择"
@change="selectChange">
<el-option
@@ -37,7 +44,7 @@
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="渠道订单编号">
<el-form-item label="渠道订单编号" prop="channel_order_no">
<el-input v-model="orderMain.channel_order_no"></el-input>
</el-form-item>
</el-col>
@@ -45,12 +52,12 @@
</el-row>
<el-row>
<el-col :span="12">
<el-form-item label="用户姓名">
<el-form-item label="用户姓名" prop="user_name">
<el-input v-model="orderMain.user_name"></el-input>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="用户电话">
<el-form-item label="用户电话" prop="user_phone">
<el-input v-model="orderMain.user_phone"></el-input>
</el-form-item>
</el-col>
@@ -74,7 +81,8 @@
<el-row type="flex" justify="end" v-if="type=='add'">
<i class="el-icon-close" @click="delSinHotel(index)"></i>
</el-row>
<hotel :userOpt="userOpt" :dataObj="item" :hotelListOpt="hotelListOpt" :saleCount="saleCount"
<hotel :userOpt="userOpt" :supplier_idList="supplier_idList" :dataObj="item" :hotelListOpt="hotelListOpt"
:saleCount="saleCount"
:type="type"></hotel>
</el-card>
</template>
@@ -88,7 +96,8 @@
<el-row type="flex" justify="end" v-if="type=='add'">
<i class="el-icon-close" @click="delSinHotelOther(index)"></i>
</el-row>
<hotelother :userOpt="userOpt" :dataObj="item" :cf_itemOpt="cf_itemOpt" :saleCount="saleCount"
<hotelother :userOpt="userOpt" :supplier_idList="supplier_idList" :dataObj="item" :cf_itemOpt="cf_itemOpt"
:saleCount="saleCount"
:type="type"></hotelother>
</el-card>
</template>
@@ -101,264 +110,299 @@

</template>
<script>
import hotel from "./hotel"
import hotelother from "./hotelother"
import axios from "axios"
import hotel from "./hotel"
import hotelother from "./hotelother"
import axios from "axios"

export default {
components: {
hotel,
hotelother
},
data() {
return {
active: '1',
type: window.id ? 'view' : 'add',
saleCount: 1,
editSingle: false,
orderMain: {
commissioner_id: '',
channel_id: '',
channel_order_no: '',
user_name: '',
user_phone: "",
order_memo: "",
},
rules: {
commissioner_id: [
{required: true, message: '请输入', trigger: 'blur'},
],
channel_id: [
{required: true, message: '请输入', trigger: 'blur'},
],
channel_order_no: [
{required: true, message: '请输入', trigger: 'blur'},
],
user_name: [
{required: true, message: '请输入', trigger: 'blur'},
],
user_phone: [
{required: true, message: '请输入', trigger: 'blur'},
],
order_memo: [
{required: true, message: '请输入', trigger: 'blur'},
]
},
orderMainCopy: {},
hotelListObj: {
prod_type: 'hotel',
hotel_id: '',
room_id: '',
plan_id: '',
check_in_date: '',
check_out_date: '',
customer_name: '',
confirm_no: '',
trade_order_number: '',
confirm_status: '1',
room_memo: '',
purchase_user_id: '',
plan_memo: '',
total_price: '',
total_cost: '',
profit: '',
editType: 'add',
purchasePriceList: [{
run_date: '请选择日期',
price: '',
cost: '',
count: '',
note: '',
supplier_id: 0
}]
},
hotelList: [],
hotelotherListObj: {
prod_type: 'item',
item_id: '',
item_name: '',
item_unit: '',
check_in_date: '',
customer_name: '',
confirm_no: '',
trade_order_number: '',
purchase_user_id: '',
confirm_status: '1',
item_memo: '',
total_price: '',
total_cost: '',
profit: '',
editType: 'add',
purchasePriceList: [{
run_date: '请选择日期',
price: '',
cost: '',
count: '',
note: '',
supplier_id: 0
}]
},
hotelotherList: [],
hotelListOpt: [],
channelListOpt: [],
userOpt: [],
// roomPlan: [],
cf_itemOpt: [],
supplier_idList: [],
}
},
computed: {
disable() {
return !(this.type == 'add' || this.editSingle)
}
},
methods: {
selectChange(val) {
this.saleCount = this.channelListOpt.filter((item) => item.id == val)//佣金比例
this.saleCount = Number(this.saleCount.commission_rate) || 1//佣金比例
console.log(this.saleCount)
},
addHotel() {
this.hotelList.push(JSON.parse(JSON.stringify(this.hotelListObj)))
},
addHotelOther() {
this.hotelotherList.push(JSON.parse(JSON.stringify(this.hotelotherListObj)))
},
delSinHotel(index) {
this.hotelList.splice(index, 1)
},
delSinHotelOther(index) {
this.hotelotherList.splice(index, 1)
},
onSubmit() {
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) => {
console.log(res)
}).catch((err) => {
console.log(err)
})
} else {
console.log('error submit!!');
return false;
}
});
// axios.post("/hotel.php/order_main/newAdd?id=1", {}).then((res) => {

export default {
components: {
hotel,
hotelother
},
data() {
return {
active: '1',
type: window.id ? 'view' : 'add',
saleCount: 1,
editSingle: false,
orderMain: {
commissioner: '',
channel_id: '',
channel_order_no: '',
user_name: '',
user_phone: "",
order_memo: "",
},
orderMainCopy: {},
hotelListObj: {
prod_type: 'hotel',
hotel_id: '',
room_id: '',
plan_id: '',
check_in_date: '',
check_out_date: '',
customer_name: '',
confirm_no: '',
trade_order_number: '',
confirm_status: '1',
room_memo: '',
purchase_user_id: '',
plan_memo: '',
total_price: '',
total_cost: '',
profit: '',
editType: 'add',
purchasePriceList: [{
run_date: '请选择日期',
price: '',
cost: '',
count: '',
note: '',
provider: 0
}]
},
hotelList: [],
hotelotherListObj: {
prod_type: 'item',
item_id: '',
item_name: '',
item_unit: '',
check_in_date: '',
customer_name: '',
confirm_no: '',
trade_order_number: '',
purchase_user_id: '',
confirm_status: '1',
item_memo: '',
total_price: '',
total_cost: '',
profit: '',
editType: 'add',
purchasePriceList: [{
run_date: '请选择日期',
price: '',
cost: '',
count: '',
note: '',
provider: 0
}]
},
hotelotherList: [],
hotelListOpt: [],
channelListOpt: [],
userOpt: [],
roomPlan: [],
cf_itemOpt: [],
}
},
computed: {
disable() {
return !(this.type == 'add' || this.editSingle)
}
},
methods: {
selectChange(val) {
this.saleCount = this.channelListOpt.filter((item) => item.id == val)//佣金比例
this.saleCount = Number(this.saleCount.commission_rate) || 1//佣金比例
console.log(this.saleCount)
},
addHotel() {
this.hotelList.push(JSON.parse(JSON.stringify(this.hotelListObj)))
},
addHotelOther() {
this.hotelotherList.push(JSON.parse(JSON.stringify(this.hotelotherListObj)))
},
delSinHotel(index) {
this.hotelList.splice(index, 1)
},
delSinHotelOther(index) {
this.hotelotherList.splice(index, 1)
},
onSubmit() {
console.log('submit!');
// axios.post("/hotel.php/order_main/newAdd?id=1", {}).then((res) => {
let data = {}
let subOrderList = [...this.hotelList, ...this.hotelotherList]
data = Object.assign({}, this.orderMain, {'subOrderList': subOrderList})
axios.post("/hotel.php/order_main/newAdd?id=1", data).then((res) => {
console.log(res)
}).catch((err) => {
console.log(err)
})
},
save() {
this.editSingle = false;
let data = this.orderMain
axios.post("/hotel.php/order_main/save", data).then((res) => {
console.log(res)
if (res.flag) {
this.$alert('提示', res.msg, {
confirmButtonText: '确定',
});
}
}).catch((err) => {
console.log(err)
})
},
cancel() {
this.editSingle = false;
this.orderMain = this.orderMainCopy
}
},
mounted() {
if (process.env.NODE_ENV !== 'production') {
axios.defaults.baseURL = '/api' //关键代码
}
axios.get("/hotel.php/cf_item/getList").then((res) => {
console.log(res)
this.cf_itemOpt = res.data.list
// this.cf_itemOpt = [{
// "id": 1,
// "name": "附加项目1",
// "item_unit": "件",
// "item_type": 1,
// "item_memo": "说说说",
// "item_type_name": "一日游"
// }, {
// "id": 2,
// "name": "附加项2222",
// "item_unit": "张",
// "item_type": 2,
// "item_memo": "说说说",
// "item_type_name": "交通接驳"
// }]
}).catch((err) => {
console.log(err)
})
axios.get("/hotel.php/auth/admin/getList").then((res) => {
console.log(res)
this.userOpt = res.data.list
// this.userOpt = [{"id": 1, "name": "Admin"}, {"id": 2, "name": "瞿殿斌"}, {
// "id": 3,
// "name": "宋晓明"
// }, {"id": 4, "name": "庄亮"}, {"id": 5, "name": "testlkx"}]
}).catch((err) => {
console.log(err)
})
axios.get("/hotel.php/cf_hotel_info/getHotelList").then((res) => {
console.log(res)
this.hotelListOpt = res.data.list
// this.hotelListOpt = [{"id": 0, "name": "暂无"}, {"id": 1, "name": "111"}, {"id": 2, "name": "222"}]
}).catch((err) => {
console.log(err)
})
},
save() {
this.editSingle = false;
let data = this.orderMain
axios.post("/hotel.php/order_main/save", data).then((res) => {
console.log(res)
if (res.flag) {
this.$alert('提示', res.msg, {
confirmButtonText: '确定',
});
}
}).catch((err) => {
console.log(err)
})
},
cancel() {
this.editSingle = false;
this.orderMain = this.orderMainCopy
}
},
mounted() {
if (process.env.NODE_ENV !== 'production') {
axios.defaults.baseURL = '/api' //关键代码
}
axios.get("/hotel.php/cf_item/getList").then((res) => {
console.log(res)
this.cf_itemOpt = res.data.list
// this.cf_itemOpt = [{
// "id": 1,
// "name": "附加项目1",
// "item_unit": "件",
// "item_type": 1,
// "item_memo": "说说说",
// "item_type_name": "一日游"
// }, {
// "id": 2,
// "name": "附加项2222",
// "item_unit": "张",
// "item_type": 2,
// "item_memo": "说说说",
// "item_type_name": "交通接驳"
// }]
}).catch((err) => {
console.log(err)
})
axios.get("/hotel.php/auth/admin/getList").then((res) => {
console.log(res)
this.userOpt = res.data.list
// this.userOpt = [{"id": 1, "name": "Admin"}, {"id": 2, "name": "瞿殿斌"}, {
// "id": 3,
// "name": "宋晓明"
// }, {"id": 4, "name": "庄亮"}, {"id": 5, "name": "testlkx"}]
}).catch((err) => {
console.log(err)
})
axios.get("/hotel.php/cf_hotel_info/getHotelList").then((res) => {
console.log(res)
this.hotelListOpt = res.data.list //取酒店下拉
// this.hotelListOpt = [{"id": 0, "name": "暂无"}, {"id": 1, "name": "111"}, {"id": 2, "name": "222"}]
}).catch((err) => {
console.log(err)
})
axios.get("/hotel.php/cf_suplier_info/getList").then((res) => {
console.log(res)
this.supplier_idList = res.data.list //取供应商下拉
// this.hotelListOpt = [{"id": 0, "name": "暂无"}, {"id": 1, "name": "111"}, {"id": 2, "name": "222"}]
}).catch((err) => {
console.log(err)
})

console.log(item)
axios.get("/hotel.php/cf_room_plan/getList").then((res) => {
console.log(res)
this.roomPlan = res.data.list
// this.roomPlan = [{"id": 1, "name": "111"}]
}).catch((err) => {
console.log(err)
})
axios.get("/hotel.php/cf_channel_info/getList").then((res) => {
console.log(res)
this.channelListOpt = res.data.list
// this.channelListOpt = [{"id": 1, "name": "测试飞猪", "commission_rate": "10.00"}, {
// "id": 2,
// "name": "【昊瀚】飞猪日历房",
// "commission_rate": "8.00"
// }, {"id": 3, "name": "【昊瀚】飞猪套餐", "commission_rate": "3.50"}, {
// "id": 4,
// "name": "【水汪清】携程",
// "commission_rate": "0.00"
// }, {"id": 5, "name": "【昊瀚】美团大众", "commission_rate": "0.00"}, {
// "id": 6,
// "name": "【守则固】携程",
// "commission_rate": "0.00"
// }, {"id": 7, "name": "【守则固】同程艺龙", "commission_rate": "0.00"}, {
// "id": 8,
// "name": "【守则固】途牛",
// "commission_rate": "0.00"
// }, {"id": 9, "name": "【水汪清】去哪儿", "commission_rate": "0.00"}, {
// "id": 10,
// "name": "【昊瀚】小红书",
// "commission_rate": "0.00"
// }, {"id": 11, "name": "【冲抵】唯途", "commission_rate": "0.00"}, {
// "id": 12,
// "name": "【昊瀚】淘1站",
// "commission_rate": "0.00"
// }, {"id": 13, "name": "【昊瀚】线下", "commission_rate": "0.00"}, {
// "id": 14,
// "name": "【水汪清】浪客行",
// "commission_rate": "0.00"
// }, {"id": 15, "name": "【毛木宁】日历房", "commission_rate": "8.00"}, {
// "id": 16,
// "name": "【毛木宁】套餐",
// "commission_rate": "3.50"
// }]
}).catch((err) => {
console.log(err)
})
console.log(this.type)
if (this.type != 'add') {
axios.post("/hotel.php/order_main/getShowInfo", {id: window.id}).then((res) => {
console.log(res)
if (res.flag) {
let orderMain = this.$lo.cloneDeep(res.data)
delete orderMain.subOrderList
this.orderMain = orderMain
this.orderMainCopy = this.$lo.cloneDeep(orderMain)
res.data.subOrderList.forEach((item) => {
item.editType = 'view'
})
this.hotelList = res.data.subOrderList.filter((item) => item.hotel_id)
this.hotelotherList = res.data.subOrderList.filter((item) => item.item_id)
}
// this.channelListOpt = res.data.list
}).catch((err) => {
console.log(err)
})
}
}
}
// axios.get("/hotel.php/cf_room_plan/getList").then((res) => {
// console.log(res)
// this.roomPlan = res.data.list //取酒店价格方案
// // this.roomPlan = [{"id": 1, "name": "111"}]
// }).catch((err) => {
// console.log(err)
// })
axios.get("/hotel.php/cf_channel_info/getList").then((res) => {
console.log(res)
this.channelListOpt = res.data.list
// this.channelListOpt = [{"id": 1, "name": "测试飞猪", "commission_rate": "10.00"}, {
// "id": 2,
// "name": "【昊瀚】飞猪日历房",
// "commission_rate": "8.00"
// }, {"id": 3, "name": "【昊瀚】飞猪套餐", "commission_rate": "3.50"}, {
// "id": 4,
// "name": "【水汪清】携程",
// "commission_rate": "0.00"
// }, {"id": 5, "name": "【昊瀚】美团大众", "commission_rate": "0.00"}, {
// "id": 6,
// "name": "【守则固】携程",
// "commission_rate": "0.00"
// }, {"id": 7, "name": "【守则固】同程艺龙", "commission_rate": "0.00"}, {
// "id": 8,
// "name": "【守则固】途牛",
// "commission_rate": "0.00"
// }, {"id": 9, "name": "【水汪清】去哪儿", "commission_rate": "0.00"}, {
// "id": 10,
// "name": "【昊瀚】小红书",
// "commission_rate": "0.00"
// }, {"id": 11, "name": "【冲抵】唯途", "commission_rate": "0.00"}, {
// "id": 12,
// "name": "【昊瀚】淘1站",
// "commission_rate": "0.00"
// }, {"id": 13, "name": "【昊瀚】线下", "commission_rate": "0.00"}, {
// "id": 14,
// "name": "【水汪清】浪客行",
// "commission_rate": "0.00"
// }, {"id": 15, "name": "【毛木宁】日历房", "commission_rate": "8.00"}, {
// "id": 16,
// "name": "【毛木宁】套餐",
// "commission_rate": "3.50"
// }]
}).catch((err) => {
console.log(err)
})
console.log(this.type)
if (this.type != 'add') {
axios.post("/hotel.php/order_main/getShowInfo", {id: window.id}).then((res) => {
console.log(res)
if (res.flag) {
let orderMain = this.$lo.cloneDeep(res.data)
delete orderMain.subOrderList
this.orderMain = orderMain
this.orderMainCopy = this.$lo.cloneDeep(orderMain)
res.data.subOrderList.forEach((item) => {
item.editType = 'view'
})
this.hotelList = res.data.subOrderList.filter((item) => item.hotel_id)
this.hotelotherList = res.data.subOrderList.filter((item) => item.item_id)
}
// this.channelListOpt = res.data.list
}).catch((err) => {
console.log(err)
})
}
}
}
</script>
<style lang="css">
.left {
text-align: left;
}
.left {
text-align: left;
}

.card {
overflow-x: scroll;
}
.card {
overflow-x: scroll;
}
</style>

+ 297
- 235
src/components/hotel.vue View File

@@ -6,7 +6,7 @@
<el-row style="width:100%;margin-top:10px;margin-bottom:10px;padding-right: 20px;" type="flex"
justify="space-between" align="middle">
<el-col :span="2">
{{'酒店'}}
{{ '酒店' }}
</el-col>
<!-- <el-col :span="2" :push="3">-->
<!-- <el-button>增补采购单</el-button>-->
@@ -24,7 +24,8 @@
<el-col :span="10">
<el-form-item label="酒店名称">

<el-select style="width: 100%" v-model="dataObj.hotel_id" filterable placeholder="请选择" @change="selectChange">
<el-select style="width: 100%" v-model="dataObj.hotel_id" filterable placeholder="请选择"
@change="selectChange">
<el-option
v-for="item in hotelListOpt"
:key="'hotel_id'+item.id"
@@ -36,7 +37,8 @@
</el-col>
<el-col :span="8">
<el-form-item label="房型名称">
<el-select style="width: 100%" v-model="dataObj.room_id" filterable placeholder="请选择" @change="roomselectChange">
<el-select style="width: 100%" v-model="dataObj.room_id" filterable placeholder="请选择"
@change="roomselectChange">
<el-option
v-for="item in roomListOpt"
:key="'room_id'+item.id"
@@ -48,7 +50,8 @@
</el-col>
<el-col :span="6">
<el-form-item label="价格方案">
<el-select style="width: 100%" v-model="dataObj.plan_id" filterable placeholder="请选择" @change="selectChange">
<el-select style="width: 100%" v-model="dataObj.plan_id" filterable placeholder="请选择"
@change="priceselectChange">
<el-option
v-for="item in roomPlan"
:key="item.id"
@@ -118,10 +121,18 @@
</template>
</el-table-column>
<el-table-column
prop="provider"
prop="supplier_id"
label="供应商">
<template slot-scope="scope">
<el-input v-model="scope.row.provider"></el-input>
<el-select style="width: 100%" v-model="scope.row.supplier_id" @change="changesupplier_id" filterable
placeholder="请选择">
<el-option
v-for="item in supplier_idList"
:key="item.id"
:label="item.name"
:value="item.id">
</el-option>
</el-select>
</template>
</el-table-column>
<el-table-column
@@ -153,12 +164,12 @@
<el-row>
<el-col :span="12">
<el-form-item label-width="100px" label="床型说明">
<span>{{dataObj.room_memo}}</span>
<span>{{ dataObj.room_memo }}</span>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label-width="100px" label="资源负责人">
<el-select style="width: 100%" v-model="dataObj.purchase_user_id" filterable placeholder="请选择">
<el-select style="width: 100%" v-model="dataObj.purchase_user_id" disabled placeholder="请选择">
<el-option
v-for="item in userOpt"
:key="item.id"
@@ -170,7 +181,7 @@
</el-col>
<el-col :span="12">
<el-form-item label-width="100px" label="价格方案说明">
<span>{{dataObj.priceIntro}}</span>
<span>{{ dataObj.plan_mome }}</span>
</el-form-item>
</el-col>
</el-row>
@@ -184,7 +195,8 @@
<el-col :span="10">
<el-form-item label="酒店名称">

<el-select style="width: 100%" v-model="dataObj.hotel_id" filterable placeholder="请选择" @change="selectChange">
<el-select style="width: 100%" v-model="dataObj.hotel_id" filterable placeholder="请选择"
@change="selectChange">
<el-option
v-for="item in hotelListOpt"
:key="item.id"
@@ -196,7 +208,8 @@
</el-col>
<el-col :span="8">
<el-form-item label="房型名称">
<el-select style="width: 100%" v-model="dataObj.room_id" filterable placeholder="请选择" @change="selectChange">
<el-select style="width: 100%" v-model="dataObj.room_id" filterable placeholder="请选择"
@change="roomselectChange">
<el-option
v-for="item in roomListOpt"
:key="item.id"
@@ -208,7 +221,8 @@
</el-col>
<el-col :span="6">
<el-form-item label="价格方案">
<el-select style="width: 100%" v-model="dataObj.plan_id" filterable placeholder="请选择" @change="selectChange">
<el-select style="width: 100%" v-model="dataObj.plan_id" filterable placeholder="请选择"
@change="priceselectChange">
<el-option
v-for="item in roomPlan"
:key="item.id"
@@ -280,10 +294,18 @@
</template>
</el-table-column>
<el-table-column
prop="provider"
prop="supplier_id"
label="供应商">
<template slot-scope="scope">
<el-input v-model="scope.row.provider" @change="changeProvider"></el-input>
<el-select style="width: 100%" v-model="scope.row.supplier_id" @change="changesupplier_id" filterable
placeholder="请选择">
<el-option
v-for="item in supplier_idList"
:key="item.id"
:label="item.name"
:value="item.id">
</el-option>
</el-select>
</template>
</el-table-column>
<el-table-column
@@ -315,12 +337,12 @@
<el-row>
<el-col :span="12">
<el-form-item label-width="100px" label="床型说明">
<span>{{dataObj.room_memo}}</span>
<span>{{ dataObj.room_memo }}</span>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label-width="100px" label="资源负责人">
<el-select style="width: 100%" v-model="dataObj.purchase_user_id" filterable placeholder="请选择">
<el-select style="width: 100%" v-model="dataObj.purchase_user_id" disabled placeholder="请选择">
<el-option
v-for="item in userOpt"
:key="item.id"
@@ -332,7 +354,7 @@
</el-col>
<el-col :span="12">
<el-form-item label-width="100px" label="价格方案说明">
<span>{{dataObj.priceIntro}}</span>
<span>{{ dataObj.plan_mome }}</span>
</el-form-item>
</el-col>
</el-row>
@@ -343,230 +365,270 @@

</template>
<script>
import axios from "axios"
import axios from "axios"

export default {
name: "hotel",
props: {roomPlan: Array, userOpt: Array, type: String, saleCount: Number, dataObj: Object, hotelListOpt: Array},
data() {
return {
dataObjTemp: this.$lo.cloneDeep(this.dataObj),
confirm_status: '未发单',
roomListOpt: [],
date: [],
day: []
}
},
computed: {
disable() {
return this.dataObjTemp.editType != 'add'
}
},
watch: {
dataObj(val) {
console.log('change')
this.dataObjTemp = this.$lo.cloneDeep(this.dataObj)
},
confirm_status(val) {
let type = '';
switch (val) {
case "未发单":
type = '1'
break;
case "已发单":
type = '2'
break;
case "已确认":
type = '3'
break;
case "已取消":
type = '4'
break;
}
this.$set(this.dataObj, "confirm_status", type)
},
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: '',
note: '',
provider: ''
})
}
this.dataObj.purchasePriceList = purchasePriceList;
this.$set(this.dataObj, 'purchasePriceList', purchasePriceList)
export default {
name: "hotel",
props: {
supplier_idList: Array,
userOpt: Array,
type: String,
saleCount: Number,
dataObj: Object,
hotelListOpt: Array
},
data() {
return {
dataObjTemp: this.$lo.cloneDeep(this.dataObj),
confirm_status: '未发单',
roomListOpt: [],
date: [],
roomPlan: [],
day: []
}
},
computed: {
disable() {
return this.dataObjTemp.editType != 'add'
}
},
watch: {
dataObj(val) {
console.log('change')
this.dataObjTemp = this.$lo.cloneDeep(this.dataObj)
},
confirm_status(val) {
let type = '';
switch (val) {
case "未发单":
type = '1'
break;
case "已发单":
type = '2'
break;
case "已确认":
type = '3'
break;
case "已取消":
type = '4'
break;
}
this.$set(this.dataObj, "confirm_status", type)
},
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: '',
note: '',
supplier_id: ''
})
}
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)
})
}
},
changeProvider(value) {
if (this.type == 'add') {
this.dataObj.purchasePriceList.forEach((item) => {
this.$set(item, 'provider', value)
})
}
},
changeNote(value) {
if (this.type == 'add') {
this.dataObj.purchasePriceList.forEach((item) => {
this.$set(item, 'note', value)
})
}
},
arraySpanMethod({row, column, rowIndex, columnIndex}) {
// console.log({row, column, rowIndex, columnIndex})
if (columnIndex === 3) {
return [this.dataObj.purchasePriceList.length, 1];
} else if (columnIndex === 4) {
return [this.dataObj.purchasePriceList.length, 1];
} else if (columnIndex === 5) {
return [this.dataObj.purchasePriceList.length, 1];
} else {
return [1, 1];
}
},
getAllDateCN(startTime, endTime) {
var date_all = []
var i = 0
while ((endTime.getTime() - startTime.getTime()) > 0) {
var year = startTime.getFullYear()
var month = startTime.getMonth() + 1
var day = startTime.getDate()
date_all[i] = year + '-' + month + '-' + day
startTime.setDate(startTime.getDate() + 1)
i += 1
}
return date_all
},
getSummaries(param) {
const {columns, data} = param;
// console.log(param)
const sums = [];
columns.forEach((column, index) => {
if (index === 0) {
sums[index] = '总价';
return;
}
if (index === 3) {
sums[index] = '利润';
return;
}
if (index === 5) {
return;
}
if (index === 4) {
let sum = data.map(item => (Number(item[columns[1].property]) * this.saleCount - Number(item[columns[2].property])) * Number(item[columns[3].property]));
if (!sum.every(value => isNaN(value))) {
sums[index] = sum.reduce((prev, curr) => {
const value = Number(curr);
if (!isNaN(value)) {
return prev + curr;
} else {
return prev;
}
}, 0);
sums[index] += ' 元';
} else {
sums[index] = 'N/A';
}
return;
}
const values = data.map(item => Number(item[column.property]) * Number(item[columns[3].property]));
if (!values.every(value => isNaN(value))) {
sums[index] = values.reduce((prev, curr) => {
const value = Number(curr);
if (!isNaN(value)) {
return prev + curr;
} else {
return prev;
}
}, 0);
if (index == 1) {
this.dataObj.total_price = sums[index];
this.$set(this.dataObj, 'total_price', sums[index]);
}
if (index == 2) {
this.dataObj.total_cost = sums[index];
this.$set(this.dataObj, 'total_cost', sums[index]);
}
if (index == 4) {
this.dataObj.profit = sums[index];
this.$set(this.dataObj, 'profit', sums[index]);
}
sums[index] += ' 元';
} else {
sums[index] = 'N/A';
}
});
}
},
methods: {
changeNum(value) {
if (this.type == 'add') {
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)
}
},
changeNote(value) {
if (this.type == 'add') {
this.dataObj.purchasePriceList.forEach((item) => {
this.$set(item, 'customer_comments', value)
})
this.$set(this.dataObj, 'customer_comments', value)
}
},
arraySpanMethod({row, column, rowIndex, columnIndex}) {
// console.log({row, column, rowIndex, columnIndex})
if (columnIndex === 3) {
return [this.dataObj.purchasePriceList.length, 1];
} else if (columnIndex === 4) {
return [this.dataObj.purchasePriceList.length, 1];
} else if (columnIndex === 5) {
return [this.dataObj.purchasePriceList.length, 1];
} else {
return [1, 1];
}
},
getAllDateCN(startTime, endTime) {
var date_all = []
var i = 0
while ((endTime.getTime() - startTime.getTime()) > 0) {
var year = startTime.getFullYear()
var month = startTime.getMonth() + 1
var day = startTime.getDate()
date_all[i] = year + '-' + month + '-' + day
startTime.setDate(startTime.getDate() + 1)
i += 1
}
return date_all
},
getSummaries(param) {
const {columns, data} = param;
// console.log(param)
const sums = [];
columns.forEach((column, index) => {
if (index === 0) {
sums[index] = '总价';
return;
}
if (index === 3) {
sums[index] = '利润';
return;
}
if (index === 5) {
return;
}
if (index === 4) {
let sum = data.map(item => (Number(item[columns[1].property]) * this.saleCount - Number(item[columns[2].property])) * Number(item[columns[3].property]));
if (!sum.every(value => isNaN(value))) {
sums[index] = sum.reduce((prev, curr) => {
const value = Number(curr);
if (!isNaN(value)) {
return prev + curr;
} else {
return prev;
}
}, 0);
sums[index] += ' 元';
} else {
sums[index] = 'N/A';
}
return;
}
const values = data.map(item => Number(item[column.property]) * Number(item[columns[3].property]));
if (!values.every(value => isNaN(value))) {
sums[index] = values.reduce((prev, curr) => {
const value = Number(curr);
if (!isNaN(value)) {
return prev + curr;
} else {
return prev;
}
}, 0);
if (index == 1) {
this.dataObj.total_price = sums[index];
this.$set(this.dataObj, 'total_price', sums[index]);
}
if (index == 2) {
this.dataObj.total_cost = sums[index];
this.$set(this.dataObj, 'total_cost', sums[index]);
}
if (index == 4) {
this.dataObj.profit = sums[index];
this.$set(this.dataObj, 'profit', sums[index]);
}
sums[index] += ' 元';
} else {
sums[index] = 'N/A';
}
});

return sums;
},
selectChange(item) {
console.log(item)
axios.get("/hotel.php/cf_room_info/getRoomList?hotelId=" + item).then((res) => {
console.log(res)
// this.roomListOpt = res.data.list
this.roomListOpt = [{"id": 1, "name": "111"}]
}).catch((err) => {
console.log(err)
})
},
edit() {
this.dataObjTemp.editType = 'edit';
},
save() {
this.dataObjTemp.editType = 'view';
axios.post("/hotel.php/order_main/subOrderSave", this.dataObj).then((res) => {
console.log(res)
if (res.flag) {
this.$alert('提示', res.msg, {
confirmButtonText: '确定',
});
}
}).catch((err) => {
console.log(err)
})
},
cancel() {
this.$set(this.dataObj, 'editType', 'view');
this.$set(this, 'dataObj', this.dataObj);
}
},
mounted() {
if (process.env.NODE_ENV !== 'production') {
axios.defaults.baseURL = '/api' //关键代码
}
}
}
return sums;
},
selectChange(item) {
console.log(item)
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)
})
},
roomselectChange(item) {
let obj = this.roomListOpt.find((items) => {
return items.id = item
})
console.log(obj)
this.dataObj.room_memo = obj.room_memo;
this.$set(this.dataObj, 'room_memo', obj.room_memo)
axios.get("/hotel.php/cf_room_plan/getList?room_id=" + item).then((res) => {
console.log(res)
this.roomPlan = res.data.list //取酒店价格方案
// this.roomPlan = [{"id": 1, "name": "111"}]
this.dataObj.plan_id = '';
this.$set(this.dataObj, 'plan_id', '')
}).catch((err) => {
console.log(err)
})

},
priceselectChange(item) {
console.log(item)
let obj = this.roomPlan.find((items) => {
return items.id = item
})
this.dataObj.purchase_user_id = obj.purchase_user_id;
this.dataObj.plan_mome = obj.plan_mome;
this.$set(this.dataObj, 'purchase_user_id', obj.purchase_user_id)
this.$set(this.dataObj, 'plan_mome', obj.plan_mome)
},
edit() {
this.dataObjTemp.editType = 'edit';
},
save() {
this.dataObjTemp.editType = 'view';
axios.post("/hotel.php/order_main/subOrderSave", this.dataObj).then((res) => {
console.log(res)
if (res.flag) {
this.$alert('提示', res.msg, {
confirmButtonText: '确定',
});
}
}).catch((err) => {
console.log(err)
})
},
cancel() {
this.$set(this.dataObj, 'editType', 'view');
this.$set(this, 'dataObj', this.dataObj);
}
},
mounted() {
if (process.env.NODE_ENV !== 'production') {
axios.defaults.baseURL = '/api' //关键代码
}
}
}
</script>
<style scoped>
.card {
margin: 20px;
.card {
margin: 20px;

}
}

.card /deep/ .el-collapse-item__header {
height: auto;
}
.card /deep/ .el-collapse-item__header {
height: auto;
}

.left {
text-align: left;
}
.left {
text-align: left;
}
</style>

+ 42
- 24
src/components/hotelother.vue View File

@@ -22,21 +22,21 @@

<el-row style="margin-top: 25px;">
<el-col :span="10">
<el-form-item label="附加项目类型">
<el-form-item label="附加项目名称">
<el-select style="width: 100%" v-model="dataObj.item_id" filterable placeholder="请选择"
@change="changeItem">
<el-option
v-for="item in cf_itemOpt"
:key="'item_id'+item.id"
:label="item.item_type_name"
:label="item.item_name"
:value="item.id">
</el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="附加项目名称">
<el-input readonly v-model="dataObjTemp.item_name"></el-input>
<el-form-item label="附加项目类型">
<el-input readonly v-model="dataObjTemp.item_type_name"></el-input>
</el-form-item>
</el-col>
<el-col :span="6">
@@ -100,17 +100,24 @@
</template>
</el-table-column>
<el-table-column
prop="provider"
prop="supplier_id"
label="供应商">
<template slot-scope="scope">
<el-input v-model="scope.row.provider"></el-input>
<el-select style="width: 100%" v-model="scope.row.supplier_id" @change="changesupplier_id" filterable placeholder="请选择">
<el-option
v-for="item in supplier_idList"
:key="item.id"
:label="item.name"
:value="item.id">
</el-option>
</el-select>
</template>
</el-table-column>
<el-table-column
prop="note"
prop="customer_comments"
label="备注">
<template slot-scope="scope">
<el-input type="textarea" v-model="scope.row.note"></el-input>
<el-input type="textarea" v-model="scope.row.customer_comments"></el-input>
</template>
</el-table-column>
</el-table>
@@ -158,20 +165,21 @@
<el-form ref="form" :model="dataObj" label-width="100px" :disabled="disable">
<el-row style="margin-top: 25px;">
<el-col :span="10">
<el-form-item label="附加项目类型">
<el-select style="width: 100%" v-model="dataObj.item_id" filterable placeholder="请选择">
<el-form-item label="附加项目名称">
<el-select style="width: 100%" v-model="dataObj.item_id" filterable placeholder="请选择"
@change="changeItem">
<el-option
v-for="item in cf_itemOpt"
:key="'item_id2'+item.id"
:label="item.item_type_name"
:key="'item_id'+item.id"
:label="item.item_name"
:value="item.id">
</el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="附加项目名称">
<el-input readonly v-model="dataObjTemp.item_name"></el-input>
<el-form-item label="附加项目类型">
<el-input readonly v-model="dataObjTemp.item_type_name"></el-input>
</el-form-item>
</el-col>
<el-col :span="6">
@@ -234,17 +242,24 @@
</template>
</el-table-column>
<el-table-column
prop="provider"
prop="supplier_id"
label="供应商">
<template slot-scope="scope">
<el-input v-model="scope.row.provider" @change="changeProvider"></el-input>
<el-select style="width: 100%" v-model="scope.row.supplier_id" @change="changesupplier_id" filterable placeholder="请选择">
<el-option
v-for="item in supplier_idList"
:key="item.id"
:label="item.name"
:value="item.id">
</el-option>
</el-select>
</template>
</el-table-column>
<el-table-column
prop="note"
prop="customer_comments"
label="备注">
<template slot-scope="scope">
<el-input type="textarea" v-model="scope.row.note" @change="changeNote"></el-input>
<el-input type="textarea" v-model="scope.row.customer_comments" @change="changeNote"></el-input>
</template>
</el-table-column>
</el-table>
@@ -295,7 +310,7 @@

export default {
name: "hotelother",
props: {cf_itemOpt: Array, userOpt: Array, type: String, saleCount: Number, dataObj: Object},
props: {supplier_idList: Array, cf_itemOpt: Array, userOpt: Array, type: String, saleCount: Number, dataObj: Object},
data() {
return {
dataObjTemp: this.$lo.cloneDeep(this.dataObj),
@@ -342,8 +357,8 @@
price: '',
cost: '',
count: '',
note: '',
provider: ''
customer_comments: '',
supplier_id: ''
})
this.dataObj.purchasePriceList = purchasePriceList;
this.$set(this.dataObj, 'purchasePriceList', purchasePriceList)
@@ -354,6 +369,7 @@
let data = this.cf_itemOpt.find((item) => {
return item.id == id
})
console.log(data)
data.item_name = data.name
this.dataObjTemp = Object.assign(this.dataObjTemp, data);
},
@@ -364,18 +380,20 @@
})
}
},
changeProvider(value) {
changesupplier_id(value) {
if (this.type == 'add') {
this.dataObj.purchasePriceList.forEach((item) => {
this.$set(item, 'provider', value)
this.$set(item, 'supplier_id', value)
})
this.$set(this.dataObj, 'supplier_id', value)
}
},
changeNote(value) {
if (this.type == 'add') {
this.dataObj.purchasePriceList.forEach((item) => {
this.$set(item, 'note', value)
this.$set(item, 'customer_comments', value)
})
this.$set(this.dataObj, 'customer_comments', value)
}
},
arraySpanMethod({row, column, rowIndex, columnIndex}) {


Loading…
Cancel
Save