ScheduleRoomForm.vue 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999
  1. <template>
  2. <a-spin :spinning="confirmLoading">
  3. <j-form-container :disabled="formDisabled">
  4. <a-form-model
  5. ref="form"
  6. :model="model"
  7. :rules="validatorRules"
  8. slot="detail"
  9. >
  10. <a-row>
  11. <div style="display: flex; gap: 15px">
  12. <div style="width: 39%">
  13. <h4 style="color: rgba(255, 141, 26, 1); font-weight: 600">
  14. 订价信息
  15. </h4>
  16. <a-divider />
  17. <a-col :span="24">
  18. <a-form-model-item
  19. label="入住类型"
  20. :labelCol="labelCol"
  21. :wrapperCol="wrapperCol"
  22. prop="orderInfo.bookingType"
  23. >
  24. <a-select
  25. placeholder="入住类型"
  26. v-model="model.orderInfo.bookingType"
  27. @change="bookingTypeChange"
  28. >
  29. <a-select-option :value="1"> 全天 </a-select-option>
  30. <a-select-option :value="2"> 钟点 </a-select-option>
  31. </a-select>
  32. </a-form-model-item>
  33. </a-col>
  34. <a-col :span="24">
  35. <a-form-model-item
  36. label="预抵时间"
  37. :labelCol="labelCol"
  38. :wrapperCol="wrapperCol"
  39. prop="orderInfo.arrivalTime2"
  40. >
  41. <j-date
  42. placeholder="预抵时间"
  43. v-model="model.orderInfo.arrivalTime2"
  44. style="width: 180px"
  45. :allowClear="false"
  46. :disabled-date="disabledDate"
  47. @change="arrivalTimeChange"
  48. />
  49. <a-time-picker
  50. style="width: 80px; margin-left: 2px"
  51. v-model="model.orderInfo.arrivalTimeSpan"
  52. :default-value="moment('12:00', 'HH:mm')"
  53. format="HH:mm"
  54. :allowClear="false"
  55. @change="arrivalTimeSpanChange"
  56. />
  57. </a-form-model-item>
  58. </a-col>
  59. <a-col :span="24">
  60. <a-form-model-item
  61. label="预离时间"
  62. :labelCol="labelCol"
  63. :wrapperCol="wrapperCol"
  64. prop="orderInfo.dueOutTime2"
  65. >
  66. <j-date
  67. placeholder="预离时间"
  68. v-model="model.orderInfo.dueOutTime2"
  69. style="width: 180px"
  70. :allowClear="false"
  71. :disabled-date="disabledDate"
  72. :disabled="model.orderInfo.bookingType === 2"
  73. @change="arrivalTimeChange2"
  74. />
  75. <a-time-picker
  76. style="width: 80px; margin-left: 2px"
  77. v-model="model.orderInfo.dueOutTimeSpan"
  78. format="HH:mm"
  79. :allowClear="false"
  80. :disabled="model.orderInfo.bookingType === 2"
  81. />
  82. </a-form-model-item>
  83. </a-col>
  84. <a-col :span="24">
  85. <a-form-model-item
  86. label="客人来源"
  87. :labelCol="labelCol"
  88. :wrapperCol="wrapperCol"
  89. prop="orderInfo.customerSource"
  90. >
  91. <a-select
  92. placeholder="客人来源"
  93. v-model="model.orderInfo.customerSource"
  94. >
  95. <a-select-option
  96. :value="item.id"
  97. v-for="(item, index) in customerSourceList"
  98. :key="item.id"
  99. >
  100. {{ item.itemText }}
  101. </a-select-option>
  102. </a-select>
  103. </a-form-model-item>
  104. </a-col>
  105. <a-col :span="24" v-if="model.orderInfo.bookingType == 2">
  106. <a-form-model-item
  107. label="时长"
  108. :labelCol="labelCol"
  109. :wrapperCol="wrapperCol"
  110. prop="orderInfo.hourRoomId"
  111. >
  112. <a-select
  113. placeholder="时长"
  114. v-model="model.orderInfo.hourRoomId"
  115. @change="hourRoomIdChange"
  116. >
  117. <a-select-option
  118. :value="item.id"
  119. v-for="(item, index) in hourRoomRuleList"
  120. :key="item.id"
  121. >
  122. {{ item.hourRoomName }}
  123. </a-select-option>
  124. </a-select>
  125. </a-form-model-item>
  126. </a-col>
  127. <a-col :span="24" v-else>
  128. <a-form-model-item
  129. label="天数"
  130. :labelCol="labelCol"
  131. :wrapperCol="wrapperCol"
  132. prop="orderInfo.dayCount"
  133. >
  134. <a-input-number
  135. v-model="model.orderInfo.dayCount"
  136. placeholder="天数"
  137. :min="1"
  138. @change="dayCountChange"
  139. ></a-input-number>
  140. </a-form-model-item>
  141. </a-col>
  142. <a-col :span="24">
  143. <a-form-model-item
  144. label="早餐"
  145. :labelCol="labelCol"
  146. :wrapperCol="wrapperCol"
  147. prop="orderInfo.breakfastNum"
  148. >
  149. <a-input-number
  150. v-model="model.orderInfo.breakfastNum"
  151. placeholder="早餐"
  152. :min="0"
  153. ></a-input-number>
  154. </a-form-model-item>
  155. </a-col>
  156. <a-col :span="24">
  157. <a-form-model-item
  158. label="预定方式"
  159. :labelCol="labelCol"
  160. :wrapperCol="wrapperCol"
  161. prop="orderInfo.bookingDicWay"
  162. >
  163. <a-select
  164. placeholder="预定方式"
  165. v-model="model.orderInfo.bookingDicWay"
  166. >
  167. <a-select-option
  168. :value="item.id"
  169. v-for="(item, index) in bookingdicWayList"
  170. :key="item.id"
  171. >
  172. {{ item.itemText }}
  173. </a-select-option>
  174. </a-select>
  175. </a-form-model-item>
  176. </a-col>
  177. <a-col :span="24">
  178. <a-form-model-item
  179. label="客人类型"
  180. :labelCol="labelCol"
  181. :wrapperCol="wrapperCol"
  182. prop="orderInfo.customerType"
  183. >
  184. <a-select
  185. placeholder="客人类型"
  186. v-model="model.orderInfo.customerType"
  187. >
  188. <a-select-option :value="1"> 散客 </a-select-option>
  189. <a-select-option :value="2"> 会员 </a-select-option>
  190. <a-select-option :value="3"> 协议单位 </a-select-option>
  191. <a-select-option :value="4"> 中介 </a-select-option>
  192. </a-select>
  193. </a-form-model-item>
  194. </a-col>
  195. <a-col :span="24" v-if="model.orderInfo.bookingType === 1">
  196. <a-form-model-item
  197. label="房价方案"
  198. :labelCol="labelCol"
  199. :wrapperCol="wrapperCol"
  200. prop="orderInfo.roomPriceSlnId"
  201. >
  202. <a-select
  203. placeholder="房价方案"
  204. v-model="model.orderInfo.roomPriceSlnId"
  205. >
  206. <a-select-option value="会员价"> 会员价 </a-select-option>
  207. <a-select-option value="平日价"> 平日价 </a-select-option>
  208. </a-select>
  209. </a-form-model-item>
  210. </a-col>
  211. <h4 style="color: rgba(255, 141, 26, 1); font-weight: 600">
  212. 其他信息
  213. </h4>
  214. <a-divider />
  215. <a-col :span="24">
  216. <a-form-model-item
  217. label="联系人"
  218. :labelCol="labelCol"
  219. :wrapperCol="wrapperCol"
  220. prop="contactName"
  221. >
  222. <a-auto-complete
  223. v-model="model.contactName"
  224. placeholder="联系人"
  225. @search="handleSearch"
  226. @select="(e) => handleSelectMember(e)"
  227. >
  228. <template slot="dataSource">
  229. <a-select-option
  230. v-for="item in customerList"
  231. :key="item.id"
  232. >{{ item.name }}-{{ item.phone }}</a-select-option
  233. >
  234. </template>
  235. </a-auto-complete>
  236. </a-form-model-item>
  237. </a-col>
  238. <a-col :span="24">
  239. <a-form-model-item
  240. label="电话"
  241. :labelCol="labelCol"
  242. :wrapperCol="wrapperCol"
  243. prop="phone"
  244. >
  245. <a-input v-model="model.phone" placeholder="电话"></a-input>
  246. </a-form-model-item>
  247. </a-col>
  248. <a-col :span="24">
  249. <a-form-model-item
  250. label="担保方式"
  251. :labelCol="labelCol"
  252. :wrapperCol="wrapperCol"
  253. prop="orderInfo.warrantType"
  254. >
  255. <a-select
  256. placeholder="担保方式"
  257. v-model="model.orderInfo.warrantType"
  258. >
  259. <a-select-option :value="1"> 无担保 </a-select-option>
  260. <a-select-option :value="2"> 有担保 </a-select-option>
  261. <a-select-option :value="3"> OTA担保 </a-select-option>
  262. </a-select>
  263. </a-form-model-item>
  264. </a-col>
  265. <a-col :span="24">
  266. <a-form-model-item
  267. label="销售员"
  268. :labelCol="labelCol"
  269. :wrapperCol="wrapperCol"
  270. prop="orderInfo.warranter"
  271. >
  272. <a-select
  273. placeholder="销售员"
  274. v-model="model.orderInfo.warranter"
  275. >
  276. <a-select-option
  277. :value="item.id"
  278. v-for="item in warranterList"
  279. :key="item.id"
  280. >
  281. {{ item.name }}
  282. </a-select-option>
  283. </a-select>
  284. </a-form-model-item>
  285. </a-col>
  286. <a-col :span="24">
  287. <a-form-model-item
  288. label="外部单号"
  289. :labelCol="labelCol"
  290. :wrapperCol="wrapperCol"
  291. prop="orderInfo.outerOrdersNo"
  292. >
  293. <a-input
  294. v-model="model.orderInfo.outerOrdersNo"
  295. placeholder="外部单号"
  296. ></a-input>
  297. </a-form-model-item>
  298. </a-col>
  299. <a-col :span="24">
  300. <a-form-model-item
  301. label="备注"
  302. :labelCol="labelCol"
  303. :wrapperCol="wrapperCol"
  304. prop="orderInfo.remark"
  305. >
  306. <a-textarea
  307. v-model="model.orderInfo.remark"
  308. rows="4"
  309. placeholder="备注"
  310. />
  311. </a-form-model-item>
  312. </a-col>
  313. </div>
  314. <div style="width: 61%">
  315. <h4 style="color: rgba(255, 141, 26, 1); font-weight: 600">
  316. 选择房间
  317. </h4>
  318. <a-divider />
  319. <p>
  320. <span>占房天数:{{ model.orderInfo.dayCount }}晚</span>
  321. <span style="padding-left: 10px">总价:{{ amount }}</span>
  322. </p>
  323. <a-table
  324. v-if="canUserRoomsShow"
  325. :columns="columns"
  326. :data-source="canUserRooms"
  327. :pagination="false"
  328. :rowKey="rowKey"
  329. >
  330. <div
  331. slot="expandedRowRender"
  332. slot-scope="record, index, indent, expanded"
  333. style="margin: 0"
  334. >
  335. <p>
  336. 已排房:
  337. <template
  338. v-for="(building, bIndex) in record.buildingRooms"
  339. >
  340. <a-tag
  341. color="blue"
  342. closable
  343. :visible="visible"
  344. @close.stop="tagClose2(rindex, bIndex, index)"
  345. v-for="(item, rindex) in building.floorRooms"
  346. :key="rindex"
  347. v-if="item.check && item.check == 1"
  348. >{{ item.name }}</a-tag
  349. >
  350. <!-- <a-tag
  351. color="blue"
  352. closable
  353. :visible="visible"
  354. @close.stop="tagClose2(rindex, index)"
  355. v-for="(item, rindex) in record.rooms"
  356. :key="rindex"
  357. >{{ item.name }}</a-tag
  358. > -->
  359. </template>
  360. </p>
  361. <p>
  362. 未排房:{{
  363. record.layout.presetNum - (record.rooms || []).length
  364. }}间
  365. </p>
  366. </div>
  367. <template slot="favPrice" slot-scope="text, record, index">
  368. <!-- <editable-cell
  369. :text="record.layout.favPrice"
  370. @change="onCellChange('favPrice', index, $event)"
  371. /> -->
  372. {{ record.layout.favPrice }}
  373. </template>
  374. <template slot="presetNum" slot-scope="text, record, index">
  375. <div>
  376. <a-input-number
  377. v-model="record.layout.presetNum"
  378. :min="(record.rooms || []).length"
  379. :max="record.layout.oldTags"
  380. @change="presetNumChange($event, record)"
  381. />
  382. </div>
  383. </template>
  384. <span slot="action" slot-scope="text, record, index">
  385. <a
  386. :disabled="record.layout.presetNum <= 0"
  387. @click="pulsRoom(index)"
  388. >排房</a
  389. >
  390. </span>
  391. </a-table>
  392. </div>
  393. </div>
  394. </a-row>
  395. </a-form-model>
  396. </j-form-container>
  397. <select-room-form-modal
  398. ref="modalSelectRoomForm"
  399. @ok="modalFormOk"
  400. ></select-room-form-modal>
  401. </a-spin>
  402. </template>
  403. <script>
  404. import { httpAction, getAction, postAction } from "@/api/manage";
  405. import { validateDuplicateValue } from "@/utils/util";
  406. import moment from "moment";
  407. import EditableCell from "@views/room/modules/checkIn/EditableCell.vue";
  408. import SelectRoomFormModal from "./SelectRoomFormModal.vue";
  409. const date = new Date();
  410. const endDate = new Date(date.setDate(date.getDate() + 1));
  411. const columns = [
  412. // {
  413. // title: "",
  414. // dataIndex: "key",
  415. // width: 20,
  416. // },
  417. {
  418. title: "房型",
  419. dataIndex: "name",
  420. width: 150,
  421. customRender: function (text, record) {
  422. return record.layout.name;
  423. },
  424. },
  425. {
  426. title: "门市价",
  427. dataIndex: "marketPrice",
  428. width: 100,
  429. customRender: function (text, record) {
  430. return record.layout.marketPrice;
  431. },
  432. },
  433. {
  434. title: "优惠价",
  435. dataIndex: "favPrice",
  436. width: 120,
  437. scopedSlots: { customRender: "favPrice" },
  438. },
  439. {
  440. title: "可订数/可超数",
  441. dataIndex: "canUseCount",
  442. width: 170,
  443. customRender: function (text, record) {
  444. return record.layout.canUseCount + "/0";
  445. },
  446. },
  447. {
  448. title: "预定间数",
  449. dataIndex: "presetNum",
  450. width: 100,
  451. scopedSlots: { customRender: "presetNum" },
  452. },
  453. {
  454. title: "操作",
  455. dataIndex: "action",
  456. align: "center",
  457. fixed: "right",
  458. width: 70,
  459. scopedSlots: { customRender: "action" },
  460. },
  461. ];
  462. const data = [];
  463. for (let i = 0; i < 2; i++) {
  464. data.push({
  465. id: i,
  466. key1: `双人床` + i,
  467. key2: 298,
  468. key3: 298,
  469. key4: 8,
  470. key5: 0,
  471. key6: 0,
  472. });
  473. }
  474. export default {
  475. name: "ScheduleRoomForm",
  476. components: { EditableCell, SelectRoomFormModal },
  477. props: {
  478. //表单禁用
  479. disabled: {
  480. type: Boolean,
  481. default: false,
  482. required: false,
  483. },
  484. bookingOrdersId: {
  485. type: String,
  486. default: "",
  487. },
  488. },
  489. data() {
  490. return {
  491. canUserRoomsShow: true,
  492. visible: true,
  493. columns,
  494. model: {
  495. // data: data,
  496. orderInfo: {
  497. bookingOrdersType: this.bookingOrdersId ? 2 : 1,
  498. arrivalTime2: moment(new Date()).format("YYYY-MM-DD"),
  499. dueOutTime2: moment(endDate).format("YYYY-MM-DD"),
  500. arrivalTimeSpan: moment("18:00", "HH:mm"),
  501. dueOutTimeSpan: moment("12:00", "HH:mm"),
  502. bookingType: 1,
  503. dayCount: 1,
  504. warrantType: 1,
  505. hourRoomId: "",
  506. breakfastNum: 0,
  507. },
  508. roomIds: [],
  509. layoutDayPrices: [],
  510. },
  511. labelCol: {
  512. xs: { span: 24 },
  513. sm: { span: 5 },
  514. },
  515. wrapperCol: {
  516. xs: { span: 24 },
  517. sm: { span: 16 },
  518. },
  519. confirmLoading: false,
  520. validatorRules: {
  521. "orderInfo.bookingType": [
  522. { required: true, message: "请选择入住类型!" },
  523. ],
  524. "orderInfo.arrivalTime2": [
  525. { required: true, message: "请选择预抵时间!" },
  526. ],
  527. "orderInfo.dueOutTime2": [
  528. { required: true, message: "请选择预离时间!" },
  529. ],
  530. "orderInfo.customerSource": [
  531. { required: true, message: "请选择客人来源!" },
  532. ],
  533. "orderInfo.bookingDicWay": [
  534. { required: true, message: "请选择预定方式!" },
  535. ],
  536. "orderInfo.customerType": [
  537. { required: true, message: "请选择客人类型!" },
  538. ],
  539. contactName: [{ required: true, message: "请输入联系人!" }],
  540. phone: [{ required: true, message: "请输入电话!" }],
  541. },
  542. url: {
  543. add: "/business/busRoomBookingOrders/add",
  544. edit: "/business/busMeetingRoom/edit",
  545. queryById: "/business/busMeetingRoom/queryById",
  546. },
  547. result: [],
  548. selectIndex: 0,
  549. customerSourceList: [],
  550. bookingdicWayList: [],
  551. warranterList: [],
  552. hourRoomRuleList: [],
  553. canUserRooms: [],
  554. customerList: [],
  555. oldcustomerList: [],
  556. };
  557. },
  558. computed: {
  559. formDisabled() {
  560. return this.disabled;
  561. },
  562. amount() {
  563. var sum = 0;
  564. this.canUserRooms.forEach((t) => {
  565. sum += t.layout.favPrice * t.layout.presetNum;
  566. });
  567. return sum.toFixed(2);
  568. },
  569. },
  570. created() {
  571. var _info = JSON.parse(localStorage.getItem("storeInfo"));
  572. if (_info) {
  573. this.model.hotelId = _info.id;
  574. }
  575. //备份model原始值
  576. this.modelDefault = JSON.parse(JSON.stringify(this.model));
  577. getAction("/business/busDictItem/list", {
  578. hotelId: _info.id,
  579. dictId: "1639538915239743490",
  580. }).then((res) => {
  581. if (res.success) {
  582. this.customerSourceList = res.result.records;
  583. }
  584. });
  585. getAction("/business/busDictItem/list", {
  586. hotelId: _info.id,
  587. dictId: "1639544187093995521",
  588. }).then((res) => {
  589. if (res.success) {
  590. this.bookingdicWayList = res.result.records;
  591. }
  592. });
  593. getAction("/business/busSalesPerson/list", {
  594. hotelId: _info.id,
  595. pageNo: 1,
  596. pageSize: 100,
  597. }).then((res) => {
  598. if (res.success) {
  599. this.warranterList = res.result.records;
  600. }
  601. });
  602. getAction("/rooms/cesHourRoomRule/list", {
  603. pageNo: 1,
  604. pageSize: 100,
  605. }).then((res) => {
  606. if (res.success) {
  607. this.hourRoomRuleList = res.result.records;
  608. }
  609. });
  610. getAction("/bus/busCustomer/list", {}).then((res) => {
  611. if (res.success) {
  612. this.customerList = res.result.records;
  613. this.oldcustomerList = JSON.parse(JSON.stringify(this.customerList));
  614. }
  615. });
  616. postAction("/rooms/cesAllDayPriceRule/fetch", { hotelId: _info.id }).then(
  617. (res) => {
  618. if (res.success) {
  619. if (
  620. res.result &&
  621. res.result.cesAllDayPriceRule &&
  622. res.result.cesAllDayPriceRule.leaveTime
  623. ) {
  624. this.model.orderInfo.dueOutTimeSpan = moment(
  625. res.result.cesAllDayPriceRule.leaveTime,
  626. "HH:mm"
  627. );
  628. }
  629. }
  630. this.loadRooms();
  631. }
  632. );
  633. },
  634. methods: {
  635. presetNumChange(e, record) {
  636. console.log(e);
  637. record.layout.canUseCount = record.layout.oldTags - e;
  638. },
  639. onCellChange(key, dataIndex, value) {
  640. const dataSource = [...this.canUserRooms];
  641. const target = dataSource[dataIndex];
  642. console.log("target", target);
  643. if (target && target.layout) {
  644. target.layout[key] = value;
  645. this.canUserRooms = dataSource;
  646. }
  647. console.log("this.canUserRooms", this.canUserRooms);
  648. },
  649. rowKey(record) {
  650. return record.layout.id;
  651. },
  652. async loadRooms() {
  653. await getAction("/rooms/cesRooms/can-user-rooms", {
  654. startOf:
  655. this.model.orderInfo.arrivalTime2 +
  656. " " +
  657. moment(this.model.orderInfo.arrivalTimeSpan).format("HH:mm"),
  658. endOf:
  659. this.model.orderInfo.dueOutTime2 +
  660. " " +
  661. moment(this.model.orderInfo.dueOutTimeSpan).format("HH:mm"),
  662. bookingType: this.model.orderInfo.bookingType,
  663. hourRoomRuleId: this.model.orderInfo.hourRoomId,
  664. }).then((res) => {
  665. if (res.success) {
  666. res.result.forEach((t) => {
  667. // t.layout = Object.assign({}, t.layout, {
  668. // presetNum: 0,
  669. // oldTags: t.layout.canUseCount,
  670. // });
  671. this.$set(t.layout, "presetNum", 0);
  672. this.$set(t.layout, "oldTags", t.layout.canUseCount);
  673. this.$set(t, "rooms", []);
  674. t.buildingRooms.forEach((b) => {
  675. b.floorRooms.forEach((f) => {
  676. this.$set(f, "check", 0);
  677. });
  678. });
  679. });
  680. this.canUserRooms = res.result;
  681. }
  682. });
  683. },
  684. bookingTypeChange(e) {
  685. if (this.model.orderInfo.bookingType == 1) {
  686. this.model.orderInfo.hourRoomId = "";
  687. } else {
  688. var hourRoomRule = this.hourRoomRuleList[0];
  689. if (hourRoomRule) {
  690. this.model.orderInfo.hourRoomId = hourRoomRule.id;
  691. }
  692. }
  693. if (this.model.orderInfo.bookingType === 2) {
  694. var find = this.hourRoomRuleList.find(
  695. (t) => t.id === this.model.orderInfo.hourRoomId
  696. );
  697. if (find) {
  698. var mDate = moment(
  699. this.model.orderInfo.arrivalTime2 +
  700. " " +
  701. moment(this.model.orderInfo.arrivalTimeSpan).format("HH:mm")
  702. ).add(find.afterOpenRoom, "minutes");
  703. this.model.orderInfo.dueOutTime2 = mDate.format("YYYY-MM-DD");
  704. this.model.orderInfo.dueOutTimeSpan = moment(
  705. mDate.format("HH:mm"),
  706. "HH:mm"
  707. );
  708. }
  709. } else if (this.model.orderInfo.bookingType === 1) {
  710. var mDate = moment(this.model.orderInfo.arrivalTime2).add(1, "days");
  711. this.model.orderInfo.dueOutTime2 = mDate.format("YYYY-MM-DD");
  712. }
  713. this.loadRooms();
  714. },
  715. dayCountChange(e) {
  716. this.model.orderInfo.dueOutTime2 = moment(
  717. this.model.orderInfo.arrivalTime2
  718. )
  719. .add(e, "days")
  720. .format("YYYY-MM-DD");
  721. this.loadRooms();
  722. },
  723. disabledDate(current) {
  724. return current && current < moment().add(-1, "days").endOf("day");
  725. },
  726. arrivalTimeChange(e) {
  727. var v = parseInt(
  728. (new Date(this.model.orderInfo.dueOutTime2).getTime() -
  729. new Date(this.model.orderInfo.arrivalTime2).getTime()) /
  730. (1000 * 60 * 60 * 24)
  731. );
  732. if (v <= 0) {
  733. this.model.orderInfo.dueOutTime2 = moment(
  734. this.model.orderInfo.arrivalTime2
  735. )
  736. .add(1, "days")
  737. .format("YYYY-MM-DD");
  738. }
  739. v = parseInt(
  740. (new Date(this.model.orderInfo.dueOutTime2).getTime() -
  741. new Date(this.model.orderInfo.arrivalTime2).getTime()) /
  742. (1000 * 60 * 60 * 24)
  743. );
  744. this.model.orderInfo.dayCount = Math.abs(v);
  745. this.loadRooms();
  746. },
  747. arrivalTimeChange2(e) {
  748. var v = parseInt(
  749. (new Date(this.model.orderInfo.dueOutTime2).getTime() -
  750. new Date(this.model.orderInfo.arrivalTime2).getTime()) /
  751. (1000 * 60 * 60 * 24)
  752. );
  753. if (v <= 0) {
  754. this.model.orderInfo.arrivalTime2 = moment(
  755. this.model.orderInfo.dueOutTime2
  756. )
  757. .add(-1, "days")
  758. .format("YYYY-MM-DD");
  759. }
  760. v = parseInt(
  761. (new Date(this.model.orderInfo.dueOutTime2).getTime() -
  762. new Date(this.model.orderInfo.arrivalTime2).getTime()) /
  763. (1000 * 60 * 60 * 24)
  764. );
  765. this.model.orderInfo.dayCount = Math.abs(v);
  766. this.loadRooms();
  767. },
  768. arrivalTimeSpanChange(m, time) {
  769. console.log(time);
  770. console.log(moment(m).format("HH:mm"));
  771. if (this.model.orderInfo.bookingType === 2) {
  772. var find = this.hourRoomRuleList.find(
  773. (t) => t.id === this.model.orderInfo.hourRoomId
  774. );
  775. if (find) {
  776. var mDate = moment(
  777. this.model.orderInfo.arrivalTime2 +
  778. " " +
  779. moment(this.model.orderInfo.arrivalTimeSpan).format("HH:mm")
  780. ).add(find.afterOpenRoom, "minutes");
  781. this.model.orderInfo.dueOutTime2 = mDate.format("YYYY-MM-DD");
  782. this.model.orderInfo.dueOutTimeSpan = moment(
  783. mDate.format("HH:mm"),
  784. "HH:mm"
  785. );
  786. }
  787. }
  788. this.loadRooms();
  789. },
  790. hourRoomIdChange() {
  791. if (this.model.orderInfo.bookingType === 2) {
  792. var find = this.hourRoomRuleList.find(
  793. (t) => t.id === this.model.orderInfo.hourRoomId
  794. );
  795. if (find) {
  796. var mDate = moment(
  797. this.model.orderInfo.arrivalTime2 +
  798. " " +
  799. moment(this.model.orderInfo.arrivalTimeSpan).format("HH:mm")
  800. ).add(find.afterOpenRoom, "minutes");
  801. this.model.orderInfo.dueOutTime2 = mDate.format("YYYY-MM-DD");
  802. this.model.orderInfo.dueOutTimeSpan = moment(
  803. mDate.format("HH:mm"),
  804. "HH:mm"
  805. );
  806. }
  807. }
  808. this.loadRooms();
  809. },
  810. tagClose2(rindex, bindex, index) {
  811. var id =
  812. this.canUserRooms[index].buildingRooms[bindex].floorRooms[rindex].id;
  813. var findIndex = this.canUserRooms[index].rooms.findIndex(
  814. (t) => t.id === id
  815. );
  816. this.canUserRooms[index].rooms.splice(findIndex, 1);
  817. this.$set(
  818. this.canUserRooms[index].buildingRooms[bindex].floorRooms[rindex],
  819. "check",
  820. 0
  821. );
  822. console.log(this.canUserRooms);
  823. },
  824. modalFormOk(e) {
  825. // this.modelDefault = Object.assign({}, this.modelDefault, {
  826. // rooms: e,
  827. // });
  828. // this.edit(this.modelDefault);
  829. this.$set(this.canUserRooms[this.selectIndex], "rooms", e);
  830. console.log(this.canUserRooms[this.selectIndex]);
  831. },
  832. pulsRoom(index) {
  833. this.selectIndex = index;
  834. this.$refs.modalSelectRoomForm.add(this.canUserRooms[this.selectIndex]);
  835. this.$refs.modalSelectRoomForm.title = "排房";
  836. this.$refs.modalSelectRoomForm.disableSubmit = false;
  837. },
  838. handleSearch(value) {
  839. let result;
  840. if (!value) {
  841. result = this.oldcustomerList;
  842. } else {
  843. result = this.oldcustomerList.filter((t) => t.name.includes(value));
  844. }
  845. this.customerList = result;
  846. },
  847. handleSelectMember(e) {
  848. var find = this.customerList.find((t) => t.id === e);
  849. this.model.phone = find.phone;
  850. this.model.contactName = find.name;
  851. this.model.orderInfo.contactId = find.id;
  852. },
  853. moment,
  854. onChange(date, dateString) {
  855. console.log(date, dateString);
  856. },
  857. add() {
  858. this.edit(this.modelDefault);
  859. },
  860. addList(roomLiveList, key) {
  861. console.log('roomLiveList',roomLiveList)
  862. this.modelDefault = Object.assign({}, this.modelDefault, {
  863. rooms: roomLiveList,
  864. });
  865. this.modelDefault.orderInfo.bookingOrdersType = key;
  866. this.edit(this.modelDefault);
  867. },
  868. async edit(record) {
  869. this.model = Object.assign({}, record);
  870. this.visible = true;
  871. await this.loadRooms();
  872. console.log("this.canUserRooms", this.canUserRooms);
  873. const dataSource = JSON.parse(JSON.stringify(this.canUserRooms));
  874. if (this.model.rooms && this.model.rooms.length > 0) {
  875. this.model.rooms.forEach((item) => {
  876. var findIndex = dataSource.findIndex(
  877. (t) => t.layout.id == item.layoutId
  878. );
  879. if (findIndex >= 0) {
  880. const target = dataSource[findIndex];
  881. if (target && target.layout) {
  882. target.layout["presetNum"] += 1;
  883. target.layout["canUseCount"] = this.canUserRooms[findIndex].layout.canUseCount - target.layout["presetNum"];
  884. target.buildingRooms.forEach((b) => {
  885. var room = b.floorRooms.find((f) => f.id == item.id);
  886. if (room) {
  887. room.check = 1;
  888. target.rooms.push(room);
  889. }
  890. });
  891. }
  892. }
  893. });
  894. }
  895. setTimeout(() => {
  896. this.canUserRooms = dataSource;
  897. }, 500);
  898. },
  899. submitForm() {
  900. const that = this;
  901. that.model.roomIds = [];
  902. that.canUserRooms.forEach((t) => {
  903. var lastlayoutId = t.layout.id;
  904. t.buildingRooms.forEach((b) => {
  905. b.floorRooms.forEach((f) => {
  906. if (f.check && f.check === 1) {
  907. that.model.roomIds.push({ layoutId: t.layout.id, roomId: f.id });
  908. }
  909. });
  910. });
  911. const roomIds = that.model.roomIds.filter(
  912. (it) => it.layoutId === lastlayoutId
  913. );
  914. var len = roomIds.length;
  915. for (var i = len; i < t.layout.presetNum; i++) {
  916. that.model.roomIds.push({ layoutId: t.layout.id, roomId: null });
  917. }
  918. for (var b = 0; b < that.model.orderInfo.dayCount; b++) {
  919. if (t.layout.presetNum > 0) {
  920. var dayTime = moment(this.model.orderInfo.arrivalTime2)
  921. .add(b, "days")
  922. .format("YYYY-MM-DD");
  923. that.model.layoutDayPrices.push({
  924. bookingType: 1,
  925. dayTime: dayTime,
  926. price: t.layout.favPrice,
  927. roomLayoutId: t.layout.id,
  928. });
  929. }
  930. }
  931. });
  932. that.model.orderInfo.bookingOrdersId = this.bookingOrdersId;
  933. console.log("this.model", this.model);
  934. if (that.model.roomIds.length <= 0) {
  935. that.$message.warning("请先添加房间");
  936. return;
  937. }
  938. // 触发表单验证
  939. this.$refs.form.validate((valid) => {
  940. if (valid) {
  941. this.model.orderInfo.arrivalTime =
  942. this.model.orderInfo.arrivalTime2 +
  943. " " +
  944. moment(this.model.orderInfo.arrivalTimeSpan).format("HH:mm");
  945. this.model.orderInfo.dueOutTime =
  946. this.model.orderInfo.dueOutTime2 +
  947. " " +
  948. moment(this.model.orderInfo.dueOutTimeSpan).format("HH:mm");
  949. that.confirmLoading = true;
  950. let httpurl = "";
  951. let method = "";
  952. if (!this.model.id) {
  953. httpurl += this.url.add;
  954. method = "post";
  955. } else {
  956. httpurl += this.url.edit;
  957. method = "put";
  958. }
  959. if (this.model.orderInfo.bookingOrdersId) {
  960. httpurl = "/business/busRoomBookingOrders/add-batch";
  961. method = "post";
  962. }
  963. httpAction(httpurl, this.model, method)
  964. .then((res) => {
  965. if (res.success) {
  966. that.$message.success(res.message);
  967. that.$emit("ok", res.result);
  968. } else {
  969. that.$message.warning(res.message);
  970. }
  971. })
  972. .finally(() => {
  973. that.confirmLoading = false;
  974. });
  975. }
  976. });
  977. },
  978. },
  979. };
  980. </script>
  981. <style scoped>
  982. /deep/.ant-divider-horizontal {
  983. margin: 12px 0 !important;
  984. }
  985. /deep/ .ant-form-item {
  986. margin-bottom: 5px !important;
  987. }
  988. </style>