Browse Source

init

master
xubinxcode 3 years ago
parent
commit
a79e68e9e6
4 changed files with 395 additions and 275 deletions
  1. +109
    -0
      build/cp.js
  2. +2
    -1
      package.json
  3. +260
    -261
      src/components/hotel.vue
  4. +24
    -13
      src/components/hotelother.vue

+ 109
- 0
build/cp.js View File

@@ -0,0 +1,109 @@
var fs = require('fs');
var readline = require('readline');
var os = require('os');
var path = require('path');

// Node.js readline 逐行读取、写入文件内容的示例
// https://www.jb51.net/article/135706.htm
// nodejs读取文件、按行读取
// https://blog.csdn.net/weixin_42171955/article/details/100156212

var strInputFileName = '../dist/index.html';
var strOutputFileName = 'E:\\code\\lou\\application\\admin\\view\\order_main\\add.html';
var strOutputFileName2 = 'E:\\code\\lou\\application\\admin\\view\\order_main\\edit.html';

var fRead = fs.createReadStream(strInputFileName);
var fWrite = fs.createWriteStream(strOutputFileName);
var fWrite2 = fs.createWriteStream(strOutputFileName2);

fRead.on('end', () => {
console.log('end');
});

var objReadline = readline.createInterface({
input: fRead,
output: fWrite,
terminal: false
});
objReadline.on('line', (strLine) => {
let strTemp = `<script>window.id = ''</script>${strLine}`;
let strTemp2 = `<input id="c-id" type="hidden" value="{$row.id}"><script>window.id = document.getElementById('c-id').value</script>${strLine}`;
fWrite.write(strTemp);
fWrite2.write(strTemp2);
});


objReadline.on('close', () => {
console.log('readline close...');
});
function removeDir(dir) {
let files = fs.readdirSync(dir)
for(var i=0;i<files.length;i++){
let newPath = path.join(dir,files[i]);
let stat = fs.statSync(newPath)
if(stat.isDirectory()){
//如果是文件夹就递归下去
removeDir(newPath);
}else {
//删除文件
fs.unlinkSync(newPath);
}
}
fs.rmdirSync(dir)//如果文件夹是空的,就将自己删除掉
}
if(fs.statSync("E:\\code\\lou\\public\\static").isDirectory()){
//如果是文件夹就递归下去
removeDir('E:\\code\\lou\\public\\static');
}else {
//删除文件
fs.unlinkSync(newPath);
}
fs.mkdir("E:\\code\\lou\\public\\static",function(){//创建目录

})

var stat=fs.stat;

var copy=function(src,dst){
//读取目录
fs.readdir(src,function(err,paths){
console.log(paths)
if(err){
throw err;
}
paths.forEach(function(path){
var _src=src+'/'+path;
var _dst=dst+'/'+path;
var readable;
var writable;
stat(_src,function(err,st){
if(err){
throw err;
}

if(st.isFile()){
readable=fs.createReadStream(_src);//创建读取流
writable=fs.createWriteStream(_dst);//创建写入流
readable.pipe(writable);
}else if(st.isDirectory()){
exists(_src,_dst,copy);
}
});
});
});
}

var exists=function(src,dst,callback){
//测试某个路径下文件是否存在
fs.exists(dst,function(exists){
if(exists){//不存在
callback(src,dst);
}else{//存在
fs.mkdir(dst,function(){//创建目录
callback(src,dst)
})
}
})
}

exists('../dist/static','E:\\code\\lou\\public\\static',copy)

+ 2
- 1
package.json View File

@@ -7,7 +7,8 @@
"scripts": {
"dev": "webpack-dev-server --inline --progress --config build/webpack.dev.conf.js",
"start": "npm run dev",
"build": "node build/build.js"
"build": "node build/build.js",
"cp": "node build/cp.js"
},
"dependencies": {
"axios": "^0.23.0",


+ 260
- 261
src/components/hotel.vue View File

@@ -164,7 +164,7 @@
<el-row>
<el-col :span="12">
<el-form-item label-width="100px" label="床型说明">
<span>{{ dataObj.room_memo }}</span>
<el-input readonly v-model="dataObjTemp.room_memo"></el-input>
</el-form-item>
</el-col>
<el-col :span="12">
@@ -181,7 +181,7 @@
</el-col>
<el-col :span="12">
<el-form-item label-width="100px" label="价格方案说明">
<span>{{ dataObj.plan_mome }}</span>
<el-input readonly type="textarea" v-model="dataObjTemp.plan_memo"></el-input>
</el-form-item>
</el-col>
</el-row>
@@ -337,7 +337,7 @@
<el-row>
<el-col :span="12">
<el-form-item label-width="100px" label="床型说明">
<span>{{ dataObj.room_memo }}</span>
<el-input readonly v-model="dataObjTemp.room_memo"></el-input>
</el-form-item>
</el-col>
<el-col :span="12">
@@ -354,7 +354,7 @@
</el-col>
<el-col :span="12">
<el-form-item label-width="100px" label="价格方案说明">
<span>{{ dataObj.plan_mome }}</span>
<el-input readonly type="textarea" v-model="dataObjTemp.plan_memo"></el-input>
</el-form-item>
</el-col>
</el-row>
@@ -365,270 +365,269 @@

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

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)
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)
})
}
},
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';
}
});
}
},
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.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)
})
return sums;
},
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)
})
},
roomselectChange(item) {
let obj = this.roomListOpt.find((items) => {
return items.id == item
})
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)
})

},
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' //关键代码
}
}
}
},
priceselectChange(item) {
console.log(this.roomPlan)
let obj = this.$lo.cloneDeep(this.roomPlan.find((items) => {
return items.id == item
}))
this.dataObjTemp.plan_memo = obj.plan_memo;
this.dataObj.purchase_user_id = obj.purchase_user_id;
this.$set(this.dataObj, 'purchase_user_id', obj.purchase_user_id)
},
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>

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

@@ -28,7 +28,7 @@
<el-option
v-for="item in cf_itemOpt"
:key="'item_id'+item.id"
:label="item.item_name"
:label="item.name"
:value="item.id">
</el-option>
</el-select>
@@ -103,7 +103,8 @@
prop="supplier_id"
label="供应商">
<template slot-scope="scope">
<el-select style="width: 100%" v-model="scope.row.supplier_id" @change="changesupplier_id" filterable placeholder="请选择">
<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"
@@ -154,7 +155,7 @@
<el-row>
<el-col :span="24">
<el-form-item label-width="100px" label="附加项目说明">
<span>{{dataObjTemp.item_memo}}</span>
<el-input readonly type="textarea" v-model="dataObjTemp.item_memo"></el-input>
</el-form-item>
</el-col>
</el-row>
@@ -171,7 +172,7 @@
<el-option
v-for="item in cf_itemOpt"
:key="'item_id'+item.id"
:label="item.item_name"
:label="item.name"
:value="item.id">
</el-option>
</el-select>
@@ -191,8 +192,8 @@
<el-row>
<el-col :span="10">
<el-form-item label="使用日期">
<el-date-picker type="date" placeholder="选择日期" v-model="check_in_date"
style="width: 100%;"></el-date-picker>
<el-date-picker type="date" placeholder="选择日期" v-model="check_in_date"
style="width: 100%;"></el-date-picker>
</el-form-item>
</el-col>
<el-col :span="8">
@@ -245,7 +246,8 @@
prop="supplier_id"
label="供应商">
<template slot-scope="scope">
<el-select style="width: 100%" v-model="scope.row.supplier_id" @change="changesupplier_id" filterable placeholder="请选择">
<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"
@@ -296,7 +298,7 @@
<el-row>
<el-col :span="24">
<el-form-item label-width="100px" label="附加项目说明">
<div class="left">{{dataObjTemp.item_memo}}</div>
<el-input readonly type="textarea" v-model="dataObjTemp.item_memo"></el-input>
</el-form-item>
</el-col>
</el-row>
@@ -310,7 +312,14 @@

export default {
name: "hotelother",
props: {supplier_idList: Array, 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),
@@ -357,7 +366,7 @@
price: '',
cost: '',
count: '',
customer_comments: '',
customer_comments: '',
supplier_id: ''
})
this.dataObj.purchasePriceList = purchasePriceList;
@@ -369,7 +378,7 @@
let data = this.cf_itemOpt.find((item) => {
return item.id == id
})
console.log(data)
console.log(data)
data.item_name = data.name
this.dataObjTemp = Object.assign(this.dataObjTemp, data);
},
@@ -385,7 +394,8 @@
this.dataObj.purchasePriceList.forEach((item) => {
this.$set(item, 'supplier_id', value)
})
this.$set(this.dataObj, 'supplier_id', value)
this.dataObj.supplier_id = value
this.$set(this.dataObj, 'supplier_id', value)
}
},
changeNote(value) {
@@ -393,7 +403,8 @@
this.dataObj.purchasePriceList.forEach((item) => {
this.$set(item, 'customer_comments', value)
})
this.$set(this.dataObj, 'customer_comments', value)
this.dataObj.customer_comments = value
this.$set(this.dataObj, 'customer_comments', value)
}
},
arraySpanMethod({row, column, rowIndex, columnIndex}) {


Loading…
Cancel
Save