createOrder.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534
  1. <template>
  2. <view class="page" :style="{'height':(h)+'px','padding-top':mt+'px'}">
  3. <c-nav-bar :title="!dataForm.id?'新增订单':!orderStatus?'编辑订单':'办理入住'" :showIcon="true"></c-nav-bar>
  4. <view class="box box1">
  5. <view class="tit">预订信息</view>
  6. <u-cell-group :border="false" customStyle="margin:0 -30rpx">
  7. <u-cell>
  8. <text slot="icon" class="label">姓名</text>
  9. <view slot="title" class="title">
  10. <u--input border="none" class="input" inputAlign="right" placeholderStyle="font-size:26rpx"
  11. placeholder="请输入姓名" v-model="dataForm.guestName"></u--input>
  12. </view>
  13. </u-cell>
  14. <u-cell>
  15. <text slot="icon" class="label">手机号码</text>
  16. <view slot="title" class="title">
  17. <u--input border="none" class="input" inputAlign="right" placeholderStyle="font-size:26rpx"
  18. placeholder="请输入手机号码" v-model="dataForm.guestPhone"></u--input>
  19. </view>
  20. </u-cell>
  21. <u-cell :isLink="true" @click="showLaiyuan=true">
  22. <text slot="icon" class="label">订单来源</text>
  23. <view slot="title" class="title">
  24. {{dataForm.guestSourceName}}
  25. </view>
  26. </u-cell>
  27. </u-cell-group>
  28. </view>
  29. <view class="box box1">
  30. <view class="tit">房间信息</view>
  31. <u-cell-group :border="false" customStyle="margin:0 -30rpx">
  32. <u-cell>
  33. <text slot="icon" class="label">入住日期</text>
  34. <view slot="title" class="title">
  35. {{dataForm.arriveDate}}
  36. <!-- <u--input border="none" class="input" inputAlign="right" placeholderStyle="font-size:26rpx" :disabled="true"
  37. placeholder="" v-model="dataForm.arriveDate"></u--input> -->
  38. </view>
  39. </u-cell>
  40. <u-cell>
  41. <text slot="icon" class="label">离店日期</text>
  42. <view slot="title" class="title">
  43. {{dataForm.leaveDate}}
  44. <!-- <u--input border="none" class="input" inputAlign="right" placeholderStyle="font-size:26rpx" :disabled="true"
  45. placeholder="" v-model="dataForm.leaveDate"></u--input> -->
  46. </view>
  47. </u-cell>
  48. <u-cell isLink="true">
  49. <text slot="icon" class="label">共几晚</text>
  50. <view slot="title" class="title">
  51. {{dataForm.num}}
  52. </view>
  53. </u-cell>
  54. <u-cell isLink="true" @click="checkInTypeShow=true">
  55. <text slot="icon" class="label">入住类型</text>
  56. <view slot="title" class="title">
  57. {{dataForm.detailFormList[0].checkInTypeName}}
  58. </view>
  59. </u-cell>
  60. <u-cell isLink="true">
  61. <text slot="icon" class="label">房间类型</text>
  62. <view slot="title" class="title">
  63. {{dataForm.houseBaseId}}
  64. </view>
  65. </u-cell>
  66. <u-cell>
  67. <text slot="icon" class="label">房间号</text>
  68. <view slot="title" class="title">
  69. {{dataForm.detailFormList[0].roomNumber}}
  70. </view>
  71. </u-cell>
  72. <u-cell>
  73. <text slot="icon" class="label">房价</text>
  74. <view slot="title" class="title">
  75. {{dataForm.detailFormList[0].roomAmount}}
  76. </view>
  77. </u-cell>
  78. <u-cell>
  79. <text slot="icon" class="label">备注</text>
  80. <view slot="title" class="title">
  81. <u--input border="none" class="input" inputAlign="right" placeholderStyle="font-size:26rpx"
  82. type="textarea" placeholder="请输入" v-model="dataForm.remarks" height="200"></u--input>
  83. </view>
  84. </u-cell>
  85. </u-cell-group>
  86. </view>
  87. <view class="box">
  88. <view class="tit tit2"><text>消费信息</text> <u-icon @click="addBreast()" name="plus-circle" label="添加消费"
  89. labelColor="#1372FF" labelSize="24" color="1372FF" size="30"></u-icon></view>
  90. <u-swipe-action>
  91. <u-swipe-action-item :show="item.show" :index="index" class=""
  92. v-for="(item, index) in dataForm.detailFormList[0].breakfastData" :key="index" @click="click(index)"
  93. :options="options">
  94. <view class="goodsInfo item">
  95. <view class="title-wrap">
  96. <text class="title u-line-2">{{item.breakfastName}}/{{item.num}}/{{item.price}}</text>
  97. </view>
  98. </view>
  99. </u-swipe-action-item>
  100. <u-swipe-action-item :show="item.show" :index="index2" class=""
  101. v-for="(item, index2) in dataForm.detailFormList[0].otherData" :key="index2" @click="click2(index2)"
  102. :options="options">
  103. <view class="goodsInfo item">
  104. <view class="title-wrap">
  105. <text class="title u-line-2">{{item.projectName}}/{{item.num}}/{{item.defaultPrice}}</text>
  106. </view>
  107. </view>
  108. </u-swipe-action-item>
  109. </u-swipe-action>
  110. </view>
  111. <view class="box">
  112. <view class="tit tit2"><text>收款信息</text> <u-icon @click="addpay()" name="plus-circle" label="添加收款"
  113. labelColor="#1372FF" labelSize="24" color="1372FF" size="30"></u-icon></view>
  114. <u-swipe-action>
  115. <u-swipe-action-item :show="item.show" :index="index" class=""
  116. v-for="(item, index) in dataForm.flowRecord" :key="index" @click="click3(index)" :options="options">
  117. <view class="goodsInfo item">
  118. <view class="title-wrap">
  119. <text
  120. class="title u-line-2">{{item.flowTypeName}}/{{item.payTypeName}}/{{item.amount}}</text>
  121. </view>
  122. </view>
  123. </u-swipe-action-item>
  124. </u-swipe-action>
  125. </view>
  126. <view class="footer">
  127. <view class="total"><text>订单金额:</text><text>¥{{totalMOney}}</text></view>
  128. <view class="btns">
  129. {{today}}
  130. <text @click="confirmOrder(2)" v-if="today==1">直接入住</text>
  131. <text @click="confirmOrder(1)">提交</text>
  132. </view>
  133. </view>
  134. <u-picker :itemHeight="88" :immediateChange="true" :show="showLaiyuan" :columns="laiyuan" title="来源选择"
  135. keyName="guestSource" :defaultIndex="passengerDefault" @cancel="showLaiyuan=false;"
  136. @confirm="passengerConfirm"></u-picker>
  137. <u-picker :itemHeight="88" :immediateChange="true" :show="checkInTypeShow" :columns="checkInType" title="入住类型选择"
  138. keyName="label" :defaultIndex="passengerDefault2" @cancel="checkInTypeShow=false;"
  139. @confirm="passengerConfirm2"></u-picker>
  140. </view>
  141. </template>
  142. <script>
  143. export default {
  144. data() {
  145. return {
  146. titleStyle: {
  147. fontSize: '34rpx',
  148. fontWeight: "bold",
  149. },
  150. showLaiyuan: false,
  151. checkInTypeShow: false,
  152. passengerDefault: [0],
  153. passengerDefault2: [0],
  154. options: [{
  155. text: '删除',
  156. style: {
  157. backgroundColor: '#dd524d'
  158. }
  159. }],
  160. orderStatus:'',
  161. totalMOney: 0, //订单总金额
  162. dataForm: {
  163. arriveDate: "",
  164. detailFormList: [{
  165. breakfastAmount: 0,
  166. checkInPersonList: [],
  167. checkInType: 0,
  168. checkInTypeName: '',
  169. id: 0,
  170. otherAmount: 0,
  171. roomAmount: 0,
  172. roomIds: "",
  173. breakfastData: [],
  174. otherData: [],
  175. roomNumber: "",
  176. }],
  177. flowRecord: [],
  178. guestName: "",
  179. guestPhone: "",
  180. guestSourceId: null,
  181. guestSourceName: null,
  182. homestayId: uni.getStorageSync('homestayId'),
  183. houseBaseId: 0,
  184. houseBaseName: '',
  185. leaveDate: "",
  186. num: 0,
  187. orderStatus: null,
  188. remarks: "",
  189. },
  190. checkInType: [
  191. [{
  192. label: '正常入住',
  193. val: 1
  194. }, {
  195. label: '自用房',
  196. val: 2
  197. },
  198. {
  199. label: '免费入住',
  200. val: 3
  201. }
  202. ]
  203. ],
  204. roomId: '',
  205. laiyuan: [
  206. []
  207. ],
  208. currentDate: '',
  209. today:''
  210. }
  211. },
  212. onLoad(opt) {
  213. this.getLaiyuan();
  214. if (opt.roomId) {
  215. this.roomId = opt.roomId.split(',');
  216. }
  217. if (opt.id) { //编辑
  218. if (opt.orderStatus) {
  219. this.orderStatus = opt.orderStatus;
  220. }
  221. console.log(this.orderStatus)
  222. this.dataForm.id = opt.id;
  223. this.getInfo2()
  224. } else {
  225. //新增获取简单信息
  226. this.getInfo();
  227. }
  228. // 当前日期
  229. this.getleftData();
  230. let myDate = new Date();
  231. let year = myDate.getFullYear();
  232. let mon = myDate.getMonth() + 1;
  233. let day = myDate.getDate();
  234. mon = mon > 9 ? mon : '0' + mon;
  235. day = day > 9 ? day : '0' + day;
  236. this.currentDate = year + '-' + mon + '-' + day;
  237. },
  238. methods: {
  239. compareDate(data) {
  240. if (
  241. new Date(data).getTime() < new Date(this.currentDate).getTime()
  242. ) {
  243. this.today = -1;
  244. //v.push("-1"); //有时间小于今天
  245. }
  246. if (
  247. new Date(newval[i]).getTime() == new Date(this.currentDate).getTime()
  248. ) {
  249. this.today = 1;
  250. v.push("1"); //有时间等于今天
  251. }
  252. if (
  253. new Date(newval[i]).getTime() > new Date(this.currentDate).getTime()
  254. ) {
  255. this.today = 2;
  256. //v.push("2"); //有时间大于今天
  257. }
  258. },
  259. //添加早餐
  260. addBreast() {
  261. let list = JSON.stringify(this.dataForm.detailFormList[0].breakfastData);
  262. let list2 = JSON.stringify(this.dataForm.detailFormList[0].otherData)
  263. uni.navigateTo({
  264. url: '/pages/house/breast?list1=' + list + '&list2=' + list2,
  265. events: {
  266. addSuccess: data => {
  267. this.dataForm.detailFormList[0].breakfastData = data.data1.filter((item) => item
  268. .num && item
  269. .num != 0);
  270. this.dataForm.detailFormList[0].otherData = data.data2.filter((item) => item.num &&
  271. item.num !=
  272. 0);
  273. this.totalMOney = this.dataForm.detailFormList[0].roomAmount;
  274. this.dataForm.detailFormList[0].breakfastAmount = 0;
  275. this.dataForm.detailFormList[0].otherAmount = 0;
  276. for (let i = 0; i < this.dataForm.detailFormList[0].breakfastData.length; i++) {
  277. this.totalMOney += parseFloat(this.dataForm.detailFormList[0].breakfastData[i]
  278. .price)*this.dataForm.detailFormList[0].breakfastData[i].num;
  279. this.dataForm.detailFormList[0].breakfastAmount += parseFloat(this.dataForm
  280. .detailFormList[0].breakfastData[i]
  281. .price)*this.dataForm.detailFormList[0].breakfastData[i].num;
  282. }
  283. for (let i = 0; i < this.dataForm.detailFormList[0].otherData.length; i++) {
  284. this.totalMOney += parseFloat(this.dataForm.detailFormList[0].otherData[i]
  285. .defaultPrice)*this.dataForm.detailFormList[0].otherData[i].num;
  286. this.dataForm.detailFormList[0].otherAmount += parseFloat(this.dataForm
  287. .detailFormList[0].otherData[i]
  288. .defaultPrice)*this.dataForm.detailFormList[0].otherData[i].num;
  289. }
  290. }
  291. }
  292. })
  293. },
  294. //添加收款
  295. addpay() {
  296. uni.navigateTo({
  297. url: '/pages/house/payAdd?money=' + this.dataForm.detailFormList[0].roomAmount + '&list=' +
  298. JSON.stringify(this.dataForm.flowRecord),
  299. events: {
  300. addSuccess: data => {
  301. if (data.data.amount != 0) {
  302. this.dataForm.flowRecord = this.dataForm.flowRecord || [];
  303. this.dataForm.flowRecord.push(data.data)
  304. // if(data.data.flowType==1){ //收款
  305. // this.totalMOney+=parseFloat(data.data.amount);
  306. // }else{
  307. // this.totalMOney=parseFloat(data.data.amount);
  308. // }
  309. }
  310. }
  311. }
  312. })
  313. },
  314. confirmOrder(orderStatus) {
  315. //orderStatus//预约入住 1,直接入住2
  316. if(orderStatus){
  317. this.dataForm.orderStatus = orderStatus;
  318. }
  319. let url = '';
  320. if (this.dataForm.id) {
  321. url = '/merchant/hotel/order/updOrder'
  322. if(this.orderStatus){
  323. this.dataForm.orderStatus=this.orderStatus;
  324. }
  325. } else {
  326. url = '/merchant/hotel/order/placeOrder'
  327. }
  328. this.$api.post(url, this.dataForm).then(res => {
  329. if (res.data.code == 0) {
  330. this.$showToast('操作成功');
  331. setTimeout(() => {
  332. uni.reLaunch({
  333. url: '/pagesMy/orderList/orderList'
  334. })
  335. }, 1500)
  336. }
  337. })
  338. },
  339. click(index) {
  340. this.dataForm.detailFormList[0].breakfastAmount-=this.dataForm.detailFormList[0].breakfastData[index].price*this.dataForm.detailFormList[0].breakfastData[index].num;
  341. this.totalMOney-=this.dataForm.detailFormList[0].breakfastData[index].price*this.dataForm.detailFormList[0].breakfastData[index].num;
  342. this.dataForm.detailFormList[0].breakfastData.splice(index, 1);
  343. },
  344. click2(index) {
  345. this.dataForm.detailFormList[0].otherAmount-=this.dataForm.detailFormList[0].otherData[index].defaultPrice*this.dataForm.detailFormList[0].otherData[index].num;
  346. this.totalMOney-=this.dataForm.detailFormList[0].otherData[index].defaultPrice*this.dataForm.detailFormList[0].otherData[index].num;
  347. this.dataForm.detailFormList[0].otherData.splice(index, 1);
  348. },
  349. click3(index) {
  350. this.dataForm.flowRecord.splice(index, 1);
  351. },
  352. getLaiyuan() {
  353. this.$api.get("/merchant/hotel/room/state/getSourceDownBox", {
  354. homestayId: this.dataForm.homestayId,
  355. })
  356. .then((res) => {
  357. if (res.data.code == 0) {
  358. this.laiyuan = [res.data.data];
  359. }
  360. });
  361. },
  362. getInfo2() { //详情信息
  363. this.$api.get('/merchant/hotel/order/getOrderDetail/' + this.dataForm.id).then(res => {
  364. console.log(res)
  365. if (res.data.code == 0) {
  366. this.dataForm = {
  367. ...this.dataForm,
  368. ...res.data.data,
  369. };
  370. this.totalMOney = this.dataForm.orderAmount;
  371. this.compareDate(this.dataForm.arriveDate)
  372. }
  373. })
  374. },
  375. // 房型列表
  376. getInfo() {
  377. this.$api.post('/merchant/hotel/order/getRoomInfoList', this.roomId).then(res => {
  378. console.log(res)
  379. if (res.data.code == 0) {
  380. this.dataForm.detailFormList[0].roomIds = res.data.data.roomIds;
  381. this.dataForm.detailFormList[0].roomNumber = res.data.data.roomNumber;
  382. this.dataForm.detailFormList[0].checkInType = res.data.data.checkInType;
  383. this.dataForm.detailFormList[0].checkInTypeName = this.checkInType[0].filter((item => item
  384. .val == res.data.data.checkInType))[0].label;
  385. this.dataForm.detailFormList[0].roomAmount = res.data.data.roomAmount;
  386. this.dataForm.arriveDate = res.data.data.arriveDate;
  387. this.dataForm.leaveDate = res.data.data.leaveDate;
  388. this.dataForm.houseBaseId = res.data.data.houseBaseId;
  389. this.dataForm.num = res.data.data.num;
  390. this.totalMOney = res.data.data.roomAmount;
  391. }
  392. })
  393. },
  394. // 来源
  395. passengerConfirm(e) {
  396. this.dataForm.guestSourceId = e.value[0].id;
  397. this.dataForm.guestSourceName = e.value[0].guestSource;
  398. this.showLaiyuan = false;
  399. },
  400. //入住类型
  401. passengerConfirm2() {
  402. this.dataForm.detailFormList[0].checkInType = e.value[0].val;
  403. this.dataForm.detailFormList[0].checkInTypeName = e.value[0].guestSource;
  404. this.checkInTypeShow = false;
  405. }
  406. }
  407. }
  408. </script>
  409. <style>
  410. .u-swipe-action-item__right__button__wrapper__text {
  411. font-size: 28rpx !important;
  412. }
  413. </style>
  414. <style lang="scss" scoped>
  415. .u-swipe-action-item__right__button__wrapper {
  416. height: 36px
  417. }
  418. .u-swipe-action-item__right__button__wrapper__text {
  419. font-size: 28rpx;
  420. }
  421. .footer {
  422. position: fixed;
  423. bottom: 0;
  424. width: 100%;
  425. background-color: #fff;
  426. left: 0;
  427. z-index: 99;
  428. padding: 30rpx;
  429. box-sizing: border-box;
  430. .total {
  431. text {
  432. color: #1372FF;
  433. font-size: 32rpx;
  434. &:first-child {
  435. color: #333;
  436. }
  437. }
  438. }
  439. .btns {
  440. display: flex;
  441. justify-content: space-between;
  442. margin-top: 30rpx;
  443. text {
  444. display: inline-block;
  445. width: 48%;
  446. height: 96rpx;
  447. line-height: 96rpx;
  448. text-align: center;
  449. font-size: 34rpx;
  450. border-radius: 48rpx;
  451. border: 1rpx solid #D1D1D1;
  452. color: #999;
  453. flex:1;
  454. &:last-child {
  455. background-color: #1372FF;
  456. color: #fff;
  457. }
  458. }
  459. }
  460. }
  461. .u-cell__body {
  462. padding: 0 !important;
  463. }
  464. .page {
  465. background: #F3F4F4;
  466. padding-bottom: 260rpx;
  467. box-sizing: border-box;
  468. overflow-y: auto;
  469. overflow-x: auto;
  470. }
  471. .box {
  472. background-color: #fff;
  473. margin: 20rpx auto 0;
  474. border-radius: 10rpx;
  475. width: 96%;
  476. padding: 0 30rpx 30rpx;
  477. box-sizing: border-box;
  478. .label {
  479. color: #333;
  480. font-size: 30rpx;
  481. }
  482. &.box1 {
  483. padding: 0 30rpx;
  484. .title {
  485. text-align: right;
  486. }
  487. }
  488. .title {
  489. color: #999;
  490. }
  491. }
  492. .tit,
  493. .tit2 {
  494. font-size: 32rpx;
  495. font-weight: bold;
  496. padding-top: 30rpx;
  497. color: #333;
  498. margin-bottom: 10rpx;
  499. }
  500. .tit2 {
  501. display: flex;
  502. justify-content: space-between;
  503. align-items: center;
  504. }
  505. .goodsInfo.item {
  506. padding: 20rpx 0;
  507. text {
  508. font-size: 30rpx;
  509. }
  510. }
  511. </style>