ScheduleRoomForm.vue 32 KB

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