SelectRoomForm.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  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="24">
  12. <a-form-model-item
  13. label="房型"
  14. :labelCol="labelCol"
  15. :wrapperCol="wrapperCol"
  16. prop="roomType"
  17. >
  18. <a-checkbox-group
  19. v-model="model.roomType"
  20. :options="roomTypeOptions"
  21. />
  22. </a-form-model-item>
  23. </a-col>
  24. <a-col :span="24">
  25. <a-form-model-item
  26. label="房态"
  27. :labelCol="labelCol"
  28. :wrapperCol="wrapperCol"
  29. prop="roomStatus"
  30. >
  31. <a-checkbox-group
  32. v-model="model.roomStatus"
  33. :options="roomStatusOptions"
  34. />
  35. </a-form-model-item>
  36. </a-col>
  37. <a-col :span="24">
  38. <a-form-model-item
  39. label="已选"
  40. :labelCol="labelCol"
  41. :wrapperCol="{
  42. xs: { span: 24 },
  43. sm: { span: 20 },
  44. }"
  45. prop="roomStatus"
  46. >
  47. <a-tag
  48. color="blue"
  49. closable
  50. :visible="visible"
  51. @close.stop="tagClose2(index, item.roomNo)"
  52. v-for="(item, index) in model.rooms"
  53. :key="index"
  54. >{{ item.roomNo }}</a-tag
  55. >
  56. </a-form-model-item>
  57. </a-col>
  58. <a-col :span="24">
  59. <a-form-model-item
  60. label="房间"
  61. :labelCol="labelCol"
  62. :wrapperCol="{
  63. xs: { span: 24 },
  64. sm: { span: 20 },
  65. }"
  66. >
  67. <a-tabs
  68. :default-active-key="0"
  69. tab-position="left"
  70. :style="{ height: '300px' }"
  71. >
  72. <a-tab-pane
  73. v-for="(room, index) in roomList"
  74. :key="index"
  75. :tab="room.key"
  76. >
  77. <div
  78. id="components-grid-demo-playground"
  79. style="height: 300px; overflow: hidden auto"
  80. >
  81. <a-row :gutter="[8, 8]">
  82. <a-col
  83. :span="3"
  84. v-for="(r, rIndex) in room.child"
  85. :key="rIndex"
  86. >
  87. <div
  88. :class="[
  89. r.check == 1 ? 'check' : '',
  90. r.kz == 1 ? 'kz' : '',
  91. ]"
  92. @click="checkRoomClick(r)"
  93. >
  94. {{ r.roomNo }}
  95. </div></a-col
  96. >
  97. </a-row>
  98. </div>
  99. </a-tab-pane>
  100. </a-tabs>
  101. </a-form-model-item>
  102. </a-col>
  103. </a-row>
  104. </a-form-model>
  105. </j-form-container>
  106. </a-spin>
  107. </template>
  108. <script>
  109. import { httpAction, getAction } from "@/api/manage";
  110. import { validateDuplicateValue } from "@/utils/util";
  111. export default {
  112. name: "SelectRoomForm",
  113. components: {},
  114. props: {
  115. //表单禁用
  116. disabled: {
  117. type: Boolean,
  118. default: false,
  119. required: false,
  120. },
  121. },
  122. data() {
  123. const rooms = [];
  124. for (let i = 0; i < 100; i++) {
  125. rooms.push({
  126. id: "100" + i,
  127. roomNo: 1000 + i,
  128. check: 0,
  129. kz: i == 1 ? 1 : 0,
  130. });
  131. }
  132. const rooms2 = [];
  133. for (let i = 0; i < 50; i++) {
  134. rooms2.push({
  135. id: "200" + i,
  136. roomNo: 2000 + i,
  137. check: 0,
  138. kz: i == 5 ? 1 : 0,
  139. });
  140. }
  141. return {
  142. visible: true,
  143. roomList: [
  144. { key: "1层", child: rooms },
  145. { key: "2层", child: rooms2 },
  146. ],
  147. roomTypeOptions: ["休闲家庭房", "特价房"],
  148. roomStatusOptions: ["空净", "空脏"],
  149. model: { rooms: [] },
  150. labelCol: {
  151. xs: { span: 24 },
  152. sm: { span: 2 },
  153. },
  154. wrapperCol: {
  155. xs: { span: 24 },
  156. sm: { span: 16 },
  157. },
  158. confirmLoading: false,
  159. validatorRules: {
  160. dateRange: [{ required: true, message: "请选择维修时间!" }],
  161. remark: [{ required: true, message: "请输入维修原因!" }],
  162. },
  163. url: {
  164. add: "/business/busMeetingRoom/add",
  165. edit: "/business/busMeetingRoom/edit",
  166. queryById: "/business/busMeetingRoom/queryById",
  167. },
  168. };
  169. },
  170. computed: {
  171. formDisabled() {
  172. return this.disabled;
  173. },
  174. },
  175. created() {
  176. var _info = JSON.parse(localStorage.getItem("storeInfo"));
  177. if (_info) {
  178. this.model.hotelId = _info.id;
  179. }
  180. //备份model原始值
  181. this.modelDefault = JSON.parse(JSON.stringify(this.model));
  182. },
  183. methods: {
  184. checkRoomClick(row) {
  185. if (row.check === 1) {
  186. row.check = 0;
  187. var index = this.model.rooms.findIndex((t) => t.key1 == row.key1);
  188. this.model.rooms.splice(index, 1);
  189. } else {
  190. row.check = 1;
  191. this.model.rooms.push(row);
  192. }
  193. },
  194. tagClose2(index, key1) {
  195. this.model.rooms.splice(index, 1);
  196. this.roomList.some((t) => {
  197. var r = t.child.some((c) => {
  198. if (c.roomNo === key1) {
  199. c.check = 0;
  200. return true;
  201. }
  202. return false;
  203. });
  204. if (r === true) {
  205. return true;
  206. }
  207. });
  208. },
  209. onChange(date, dateString) {
  210. console.log(date, dateString);
  211. },
  212. add() {
  213. this.edit(this.modelDefault);
  214. },
  215. edit(record) {
  216. this.model = Object.assign({}, record);
  217. this.visible = true;
  218. },
  219. submitForm() {
  220. const that = this;
  221. if (that.model.rooms.length === 0) {
  222. that.$message.warning("请先选择房间");
  223. return;
  224. }
  225. that.$emit("ok", that.model.rooms);
  226. },
  227. },
  228. };
  229. </script>
  230. <style scoped>
  231. #components-grid-demo-playground [class~="ant-col"] {
  232. background: transparent;
  233. border: 0;
  234. }
  235. #components-grid-demo-playground [class~="ant-col"] > div {
  236. /* background: #00a0e9; */
  237. height: 28px;
  238. line-height: 28px;
  239. font-size: 13px;
  240. text-align: center;
  241. cursor: pointer;
  242. border-radius: 5px;
  243. }
  244. #components-grid-demo-playground .check {
  245. border: 1px solid #00a0e9;
  246. }
  247. #components-grid-demo-playground .kz {
  248. background: rgba(166, 166, 166, 1);
  249. }
  250. #components-grid-demo-playground pre {
  251. background: #f9f9f9;
  252. border-radius: 6px;
  253. font-size: 13px;
  254. padding: 8px 16px;
  255. }
  256. </style>