liveBatchCardForm.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538
  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. <a-col :span="21">
  12. <a-form-model-item
  13. label="房型"
  14. :labelCol="labelCol"
  15. :wrapperCol="wrapperCol"
  16. >
  17. <a-checkbox-group @change="checkChange" v-model="checkLayoutList">
  18. <a-row>
  19. <a-col
  20. :span="6"
  21. v-for="(item, index) in roomLayoutList"
  22. :key="item.id"
  23. >
  24. <a-checkbox :value="item.id">
  25. {{ item.name }}
  26. </a-checkbox>
  27. </a-col>
  28. </a-row>
  29. </a-checkbox-group>
  30. </a-form-model-item>
  31. </a-col>
  32. <a-col :span="2" :pull="3" >
  33. <a-input v-model="roomNum" placeholder="房间号" style="width: 70px"></a-input>
  34. </a-col>
  35. <a-col :span="1" :pull="3">
  36. <a-button @click="makeCard" style="margin-left: 10px;" type="primary" ghost >制卡</a-button>
  37. </a-col>
  38. <a-col :span="24">
  39. <a-form-model-item
  40. label="房态"
  41. :labelCol="labelCol"
  42. :wrapperCol="wrapperCol"
  43. prop="roomStatus"
  44. >
  45. <!-- <a-checkbox-group
  46. v-model="checkedRoomStatusList"
  47. :options="roomStatusOptions"
  48. @change="checkChange"
  49. /> -->
  50. <div style="display:flex;flex-wrap:wrap;">
  51. <div v-for="(item, index) in roomStatusOptions" :class="{'check':checkedRoomStatusList.some(ele=> ele==item.value)}" :key="index" class="nocheck room-status" :style="{borderLeft:`2px solid ${item.extend}`}" @click="roomStatusChange(item, index)">
  52. {{item.label}}
  53. </div>
  54. </div>
  55. </a-form-model-item>
  56. </a-col>
  57. <a-col :span="24">
  58. <a-form-model-item
  59. label="已选"
  60. :labelCol="labelCol"
  61. :wrapperCol="{
  62. xs: { span: 24 },
  63. sm: { span: 20 },
  64. }"
  65. prop="roomStatus"
  66. >
  67. <a-tag
  68. color="blue"
  69. closable
  70. :visible="visible"
  71. @close.stop="tagClose2(index, item.name)"
  72. v-for="(item, index) in model.rooms"
  73. :key="index"
  74. >{{ item.name }}</a-tag
  75. >
  76. </a-form-model-item>
  77. </a-col>
  78. <a-col :span="24">
  79. <a-form-model-item
  80. label="房间"
  81. :labelCol="labelCol"
  82. :wrapperCol="{
  83. xs: { span: 24 },
  84. sm: { span: 20 },
  85. }"
  86. >
  87. <!-- <a-tabs
  88. default-active-key="room-all"
  89. tab-position="left"
  90. :style="{ height: '300px' }"
  91. >
  92. <a-tab-pane
  93. tab="全部"
  94. key="room-all"
  95. > -->
  96. <div>
  97. <a-row :gutter="[8, 8]" style="overflow: auto;height:300px;">
  98. <a-col
  99. :span="24"
  100. v-for="(item, index) in (roomList || [])"
  101. :key="index"
  102. >
  103. <div>{{item.name}}</div>
  104. <div style="display:flex;flex-wrap:wrap;">
  105. <div v-for="(r, rIndex) in item.rooms" :style="{'border-left-color':filterColor(r.roomStatus)}" @click="checkRoomClick(r)" :key="'floorRooms' + rIndex" :class="[r.check == 1 ? 'check' : 'nocheck', r.kz == 1 ? 'kz' : '',]" class="nocheck room-status">
  106. <!-- <div
  107. :class="[
  108. r.check == 1 ? 'check' : 'nocheck',
  109. r.kz == 1 ? 'kz' : '',
  110. ]"
  111. style="display:flex;flex-wrap:wrap;"
  112. @click="checkRoomClick(r)"
  113. >
  114. <div class="nocheck room-status">
  115. {{ r.name }}
  116. </div>
  117. </div> -->
  118. {{ r.name }}
  119. </div>
  120. </div>
  121. </a-col>
  122. </a-row>
  123. </div>
  124. <!-- </a-tab-pane>
  125. <a-tab-pane
  126. v-for="(room, index) in roomList"
  127. :key="'room' + index"
  128. :tab="room.name"
  129. >
  130. <div
  131. id="components-grid-demo-playground"
  132. style="height: 300px; overflow: hidden auto"
  133. >
  134. <a-row :gutter="[8, 8]">
  135. <a-col
  136. :span="3"
  137. v-for="(r, rIndex) in room.rooms"
  138. :key="'floorRooms' + rIndex"
  139. >
  140. <div
  141. :class="[
  142. r.check == 1 ? 'check' : 'nocheck',
  143. r.kz == 1 ? 'kz' : '',
  144. ]"
  145. :style="{'border-left-color':filterColor(r.roomStatus)}"
  146. @click="checkRoomClick(r)"
  147. >
  148. {{ r.name }}
  149. </div></a-col
  150. >
  151. </a-row>
  152. </div>
  153. </a-tab-pane>
  154. </a-tabs> -->
  155. </a-form-model-item>
  156. </a-col>
  157. </a-row>
  158. </a-form-model>
  159. </j-form-container>
  160. </a-spin>
  161. </template>
  162. <script>
  163. import { httpAction, getAction } from "@/api/manage";
  164. import { validateDuplicateValue } from "@/utils/util";
  165. export default {
  166. name: "SelectRoomForm",
  167. components: {},
  168. props: {
  169. //表单禁用
  170. disabled: {
  171. type: Boolean,
  172. default: false,
  173. required: false,
  174. },
  175. chooseRooms: []
  176. },
  177. data() {
  178. const rooms = [];
  179. for (let i = 0; i < 100; i++) {
  180. rooms.push({
  181. id: "100" + i,
  182. roomNo: 1000 + i,
  183. check: 0,
  184. kz: i == 1 ? 1 : 0,
  185. });
  186. }
  187. const rooms2 = [];
  188. for (let i = 0; i < 50; i++) {
  189. rooms2.push({
  190. id: "200" + i,
  191. roomNo: 2000 + i,
  192. check: 0,
  193. kz: i == 5 ? 1 : 0,
  194. });
  195. }
  196. return {
  197. visible: true,
  198. roomList: [
  199. // { key: "1层", child: rooms },
  200. // { key: "2层", child: rooms2 },
  201. ],
  202. roomStatusList: [],
  203. checkedRoomStatusList: [],
  204. roomTypeOptions: [],
  205. roomStatusOptions: [],
  206. model: { roomType: "", rooms: [] },
  207. labelCol: {
  208. xs: { span: 24 },
  209. sm: { span: 2 },
  210. },
  211. wrapperCol: {
  212. xs: { span: 24 },
  213. sm: { span: 16 },
  214. },
  215. confirmLoading: false,
  216. validatorRules: {
  217. dateRange: [{ required: true, message: "请选择维修时间!" }],
  218. remark: [{ required: true, message: "请输入维修原因!" }],
  219. },
  220. url: {
  221. add: "/business/busMeetingRoom/add",
  222. edit: "/business/busMeetingRoom/edit",
  223. queryById: "/business/busMeetingRoom/queryById",
  224. },
  225. layoutName: "",
  226. presetNum: 0,
  227. canUserRooms: [],
  228. oldcanUserRooms: [],
  229. checkLayoutList: [],
  230. roomLayoutList: [],
  231. oldroomList: [],
  232. kzfLiving: false,
  233. roomNum: '',
  234. };
  235. },
  236. computed: {
  237. formDisabled() {
  238. return this.disabled;
  239. },
  240. },
  241. created() {
  242. var _info = JSON.parse(localStorage.getItem("storeInfo"));
  243. if (_info) {
  244. this.model.hotelId = _info.id;
  245. }
  246. //备份model原始值
  247. this.modelDefault = JSON.parse(JSON.stringify(this.model));
  248. getAction("/rooms/cesRoomLayout/list", { pageSize: 99999, pageNo: 1 }).then(
  249. (res) => {
  250. if (res.success) {
  251. this.roomLayoutList = res.result.records;
  252. if (this.roomLayoutList && this.roomLayoutList.length > 0) {
  253. this.roomLayoutList.forEach((item) => {
  254. this.checkLayoutList.push(item.id);
  255. });
  256. }
  257. }
  258. }
  259. );
  260. getAction("/rooms/cesRooms/room-status-color", {}).then((res) => {
  261. if (res.success) {
  262. // this.roomStatusColorList = res.result;
  263. var list = [];
  264. res.result.forEach((item) => {
  265. list.push(item);
  266. });
  267. // list = list.filter(item => item.label == '空净' || item.label == '空脏')
  268. console.log(list);
  269. this.roomStatusOptions = list;
  270. this.checkChange('',[this.roomStatusOptions[0].value,this.roomStatusOptions[1].value])
  271. }
  272. });
  273. getAction("/business/busOtherEmptyDirtyRoom/queryByHotelId", {}).then(
  274. (res) => {
  275. if (res.success) {
  276. this.kzfLiving = res.result.status === 1;
  277. }
  278. }
  279. );
  280. this.getData()
  281. },
  282. methods: {
  283. filterColor(state){
  284. var color = '';
  285. let arr = this.roomStatusOptions.filter(item => item.value == state);
  286. color = arr[0] ? arr[0].extend : '';
  287. return color;
  288. },
  289. roomStatusChange(item, index){
  290. console.log('roomStatusChange');
  291. if (this.checkedRoomStatusList.some(ele=> ele==item.value)) {
  292. var index = this.checkedRoomStatusList.findIndex((t) => t == item.value);
  293. this.checkedRoomStatusList.splice(index, 1);
  294. } else {
  295. this.checkedRoomStatusList.push(item.value);
  296. }
  297. this.checkChange()
  298. },
  299. checkChange(e,stateList) {
  300. console.log("e", e);
  301. var list = this.oldroomList;
  302. console.log(list);
  303. console.log(this.checkedRoomStatusList);
  304. if (this.checkLayoutList.length > 0) {
  305. list = this.oldroomList.reduce((acc, curr) => {
  306. const rooms = curr.rooms.filter((room) =>
  307. this.checkLayoutList.includes(room.layoutId)
  308. );
  309. acc.push({
  310. ...curr,
  311. rooms
  312. });
  313. return acc;
  314. }, []);
  315. }
  316. if (this.checkedRoomStatusList.length > 0) {
  317. list = list.reduce((acc, curr) => {
  318. const rooms = curr.rooms.filter((room) =>
  319. this.checkedRoomStatusList.includes(
  320. room.roomStatus.toString()
  321. )
  322. );
  323. acc.push({
  324. ...curr,
  325. rooms
  326. });
  327. return acc;
  328. }, []);
  329. }
  330. if (this.checkedRoomStatusList.length == 0) {
  331. let arr = []
  332. this.roomStatusOptions.forEach(ele=>{
  333. arr.push(ele.value)
  334. })
  335. list = list.reduce((acc, curr) => {
  336. const rooms = curr.rooms.filter((room) =>
  337. arr.includes(
  338. room.roomStatus.toString()
  339. )
  340. );
  341. acc.push({
  342. ...curr,
  343. rooms
  344. });
  345. return acc;
  346. }, []);
  347. }
  348. if (stateList && stateList.length > 0) {
  349. list = list.reduce((acc, curr) => {
  350. const rooms = curr.rooms.filter((room) =>
  351. stateList.includes(room.roomStatus.toString())
  352. );
  353. acc.push({
  354. ...curr,
  355. rooms
  356. });
  357. return acc;
  358. }, []);
  359. }
  360. console.log("list2", list);
  361. this.roomList = list;
  362. },
  363. checkRoomClick(row) {
  364. console.log(row);
  365. if (!this.kzfLiving && row.roomStatus === 2) {
  366. this.$message.warning("空脏房不允许入住");
  367. return;
  368. }
  369. if (row.check === 1) {
  370. row.check = 0;
  371. var index = this.model.rooms.findIndex((t) => t.id == row.id);
  372. this.model.rooms.splice(index, 1);
  373. } else {
  374. row.check = 1;
  375. this.model.rooms.push(row);
  376. }
  377. },
  378. tagClose2(index, key1) {
  379. this.model.rooms.splice(index, 1);
  380. this.roomList.some((t) => {
  381. var r = t.floorRooms.some((c) => {
  382. if (c.name === key1) {
  383. c.check = 0;
  384. return true;
  385. }
  386. return false;
  387. });
  388. if (r === true) {
  389. return true;
  390. }
  391. });
  392. },
  393. onChange(e) {
  394. console.log(e);
  395. var list = [];
  396. this.oldroomList.forEach((item) => {
  397. var floorRooms = [];
  398. item.floorRooms.forEach((f) => {
  399. if (e.includes(f.layoutId)) {
  400. floorRooms.push(f);
  401. }
  402. });
  403. var itemd = JSON.parse(JSON.stringify(item));
  404. itemd.floorRooms = floorRooms;
  405. list.push(itemd);
  406. });
  407. this.roomList = list;
  408. // result = this.oldcustomerList.filter((t) => t.name.includes(value));
  409. console.log("this.oldroomList", this.oldroomList);
  410. console.log("this.roomList", this.roomList);
  411. this.checkChange()
  412. },
  413. add(row) {
  414. console.log("canUserRooms", row);
  415. // this.canUserRooms = row;
  416. this.oldroomList = JSON.parse(JSON.stringify(row[0].buildingRooms));
  417. // this.layoutName = row.layout.name;
  418. // this.presetNum = row.layout.presetNum;
  419. this.roomList = row[0].buildingRooms;
  420. this.edit(this.modelDefault);
  421. },
  422. edit(record) {
  423. this.model = Object.assign({}, record);
  424. this.roomList.forEach((t) => {
  425. t.floorRooms.forEach((f) => {
  426. if (f.check && f.check == 1) {
  427. this.model.rooms.push(f);
  428. }
  429. });
  430. });
  431. this.visible = true;
  432. },
  433. getData(){
  434. getAction("/business/busRoomBookingOrders/rili-fangtai").then((res) => {
  435. if (res.success) {
  436. this.roomList = res.result.floorRoomVos;
  437. this.oldroomList = JSON.parse(JSON.stringify(res.result.floorRoomVos));
  438. this.chooseRooms.forEach(c =>{
  439. this.roomList.forEach(floor =>{
  440. floor.rooms.forEach(room =>{
  441. if (c.id === room.id){
  442. this.$set(room,"check",1);
  443. }
  444. })
  445. })
  446. })
  447. console.log(this.roomList)
  448. this.model.rooms = this.chooseRooms;
  449. }
  450. });
  451. },
  452. submitForm() {
  453. const that = this;
  454. if (that.model.rooms.length === 0) {
  455. that.$message.warning("请先选择房间");
  456. return;
  457. }
  458. that.$emit("ok", that.model.rooms);
  459. },
  460. makeCard() {
  461. const that = this
  462. let findRoom = []
  463. this.oldroomList.forEach(e => {
  464. e.rooms.forEach(room => {
  465. if (room.name === this.roomNum) {
  466. findRoom.push(room)
  467. }
  468. })
  469. })
  470. console.log(findRoom)
  471. if (findRoom.length === 0) {
  472. this.$message.warning('未找到房间:' + this.roomNum)
  473. } else {
  474. that.$emit('ok', findRoom);
  475. }
  476. }
  477. },
  478. };
  479. </script>
  480. <style scoped>
  481. #components-grid-demo-playground [class~="ant-col"] {
  482. background: transparent;
  483. border: 0;
  484. }
  485. #components-grid-demo-playground [class~="ant-col"] > div {
  486. /* background: #00a0e9; */
  487. height: 28px;
  488. line-height: 28px;
  489. font-size: 13px;
  490. text-align: center;
  491. cursor: pointer;
  492. border-radius: 5px;
  493. }
  494. #components-grid-demo-playground .check {
  495. border: 1px solid #00a0e9;
  496. }
  497. #components-grid-demo-playground .kz {
  498. background: rgba(166, 166, 166, 1);
  499. }
  500. #components-grid-demo-playground pre {
  501. background: #f9f9f9;
  502. border-radius: 6px;
  503. font-size: 13px;
  504. padding: 8px 16px;
  505. }
  506. #components-grid-demo-playground .nocheck {
  507. border: 1px solid #cccccc;
  508. border-left-width: 2px;
  509. }
  510. .check {
  511. border: 1px solid #00a0e9 !important;
  512. }
  513. .nocheck {
  514. border: 1px solid #cccccc;
  515. }
  516. .room-status{
  517. /* height: 100%; */
  518. /* line-height: 100%; */
  519. font-size: 13px;
  520. text-align: center;
  521. cursor: pointer;
  522. border-radius: 5px;
  523. margin-right: 10px;
  524. border: 1px solid #cccccc;
  525. padding: 0px 16px;
  526. margin-top: 5px;
  527. border-left-width: 2px;
  528. border-left-style: solid;
  529. }
  530. </style>