roomNumTable.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  1. <template>
  2. <a-card :bordered="false">
  3. <!-- 查询区域-END -->
  4. <!-- 操作按钮区域 -->
  5. <div class="table-operator">
  6. <a-tag color="pink" v-if="buildingFloorSearchTag.name" >
  7. {{ buildingFloorSearchTag.name }}
  8. <a-icon type="close" @click="onFliterClose" />
  9. </a-tag>
  10. <a-button @click="handleAdd" type="primary" icon="plus"
  11. >新增房间</a-button
  12. >
  13. <a-button @click="onAddBatch" type="primary" icon="tags"
  14. >批量新增</a-button
  15. >
  16. <a-popconfirm
  17. title="确定全部删除吗?"
  18. @confirm="delAll"
  19. >
  20. <a-button :disabled="delLoading" :loading="delLoading" type="primary" icon="stop">全部删除</a-button>
  21. </a-popconfirm>
  22. <a-popconfirm
  23. v-if="selectedRowKeys.length > 0"
  24. title="确定删除吗?"
  25. @confirm="delBatch"
  26. >
  27. <a-button :disabled="delLoading" :loading="delLoading" icon="stop" style="margin-left: 8px">
  28. 批量删除</a-button>
  29. </a-popconfirm>
  30. <!-- <a-dropdown v-if="selectedRowKeys.length > 0">
  31. <a-button style="margin-left: 8px">
  32. 批量操作 <a-icon type="down"
  33. /></a-button>
  34. </a-dropdown> -->
  35. <a-button type="primary" @click="searchQuery" icon="search"
  36. >查询</a-button
  37. >
  38. </div>
  39. <!-- table区域-begin -->
  40. <div>
  41. <a-table
  42. ref="table"
  43. size="middle"
  44. :scroll="{ x: true }"
  45. bordered
  46. rowKey="id"
  47. :columns="columns"
  48. :dataSource="dataSource"
  49. :pagination="ipagination"
  50. :loading="loading"
  51. :rowSelection="{
  52. selectedRowKeys: selectedRowKeys,
  53. onChange: onSelectChange,
  54. }"
  55. class="j-table-force-nowrap"
  56. @change="handleTableChange"
  57. >
  58. <template slot="layoutId" slot-scope="text, record">
  59. {{ getLayoutName(record) }}
  60. </template>
  61. <template slot="prefix_name" slot-scope="text, record">
  62. {{ (record.prefix || "") + record.name }}
  63. </template>
  64. <template slot="pictureSlot" slot-scope="text, record">
  65. <img :src="record.cover" style="width:40px;height40px;" />
  66. </template>
  67. <template slot="htmlSlot" slot-scope="text">
  68. <div v-html="text"></div>
  69. </template>
  70. <span slot="action" slot-scope="text, record">
  71. <a @click="handleEdit(record)">编辑</a>
  72. <a-divider type="vertical" />
  73. <a-popconfirm
  74. title="确定删除吗?"
  75. @confirm="() => handleDelete(record.id)"
  76. >
  77. <a>删除</a>
  78. </a-popconfirm>
  79. <a-divider type="vertical" />
  80. <a @click="handleImage(record)">图片</a>
  81. </span>
  82. </a-table>
  83. </div>
  84. <room-num-modal ref="modalForm" @ok="modalFormOk"></room-num-modal>
  85. <room-imgs @saveOk="onImgSave" ref="roomimgmodal"></room-imgs>
  86. </a-card>
  87. </template>
  88. <script>
  89. import { JeecgListMixin } from "@/mixins/JeecgListMixin";
  90. import roomNumModal from "./roomNumModal.vue"; // todo roomLayoutForm 需要替换成房型的表单弹窗
  91. import roomImgs from './roomImagesForm.vue'
  92. import { getAllLayouts } from "@/api/roomLayout";
  93. import { delBatch, delAll } from '@/api/roomBuildingApi'
  94. let hotelInfo = JSON.parse(localStorage.getItem("storeInfo"));
  95. export default {
  96. mixins: [JeecgListMixin],
  97. components: {
  98. roomNumModal,
  99. roomImgs
  100. },
  101. data() {
  102. return {
  103. delLoading: false,
  104. layouts: [],
  105. queryParam: {},
  106. // 分页参数
  107. ipagination: {
  108. current: 1,
  109. pageSize: 10,
  110. pageSizeOptions: ["10", "20", "30"],
  111. showTotal: (total, range) => {
  112. return range[0] + "-" + range[1] + " 共" + total + "条";
  113. },
  114. showQuickJumper: true,
  115. showSizeChanger: true,
  116. total: 0,
  117. },
  118. // 表头
  119. columns: [
  120. {
  121. title: "商家",
  122. align: "center",
  123. dataIndex: "hotelName",
  124. },
  125. {
  126. title: "楼栋",
  127. align: "center",
  128. dataIndex: "buildName",
  129. },
  130. {
  131. title: "楼层",
  132. align: "center",
  133. dataIndex: "floorName",
  134. },
  135. {
  136. title: "房型",
  137. align: "center",
  138. dataIndex: "layoutId",
  139. scopedSlots: { customRender: "layoutId" },
  140. },
  141. {
  142. title: "房号",
  143. align: "center",
  144. dataIndex: "name",
  145. scopedSlots: { customRender: "prefix_name" },
  146. },
  147. {
  148. title: "创建时间",
  149. align: "center",
  150. dataIndex: "createAt",
  151. },
  152. {
  153. title: "操作",
  154. dataIndex: "action",
  155. align: "center",
  156. fixed: "right",
  157. width: 147,
  158. scopedSlots: { customRender: "action" },
  159. },
  160. ],
  161. url: {
  162. // list: 'org.jeecg.modules.business/busMarketMember/list',
  163. list: "/rooms/cesRooms/list",
  164. delete: "/rooms/cesRooms/remove",
  165. deleteBatch: "/rooms/cesRooms/deleteBatch",
  166. exportXlsUrl: "/rooms/cesRooms/exportXls",
  167. importExcelUrl: "rooms/cesRooms/importExcel",
  168. },
  169. buildingFloorSearchTag: {
  170. name: null
  171. },
  172. dictOptions: {},
  173. superFieldList: [],
  174. selectedRowKeys: [],
  175. isorter: {
  176. column: "createTime",
  177. order: "desc",
  178. },
  179. };
  180. },
  181. created() {
  182. // this.loadData()
  183. getAllLayouts().then((res) => {
  184. if (res.code == 200) {
  185. this.layouts = res.result.records;
  186. this.loadData();
  187. }
  188. });
  189. },
  190. methods: {
  191. onImgSave() {
  192. this.loadData()
  193. },
  194. onFliterClose() {
  195. this.filters['buildId'] = null
  196. this.filters['floorId'] = null
  197. this.ipagination.current = 1
  198. this.buildingFloorSearchTag.name = null
  199. this.loadData()
  200. },
  201. // 搜索
  202. searchParam(id, name, isBuilding) {
  203. this.$set(this.buildingFloorSearchTag,'name',name)
  204. if(isBuilding) {
  205. this.filters['buildId'] = id
  206. if(this.filters['floorId']) {
  207. delete this.filters.floorId
  208. }
  209. } else {
  210. this.filters['floorId'] = id
  211. if(this.filters['buildId']) {
  212. delete this.filters.buildId
  213. }
  214. }
  215. this.loadData()
  216. },
  217. getLayoutName(row) {
  218. let i = this.layouts.findIndex((s) => s.id == row.layoutId);
  219. if (i > -1) {
  220. return this.layouts[i].name;
  221. }
  222. return "";
  223. },
  224. // 批量删除
  225. delBatch() {
  226. let hotelInfo = JSON.parse(localStorage.getItem('storeInfo'))
  227. let keys = this.selectedRowKeys
  228. this.delLoading = true
  229. delBatch({
  230. hotelId: hotelInfo.id,
  231. idStr: keys.toString()
  232. }).then(res => {
  233. if(res.code == 200) {
  234. this.selectedRowKeys = []
  235. this.$message.success('删除成功');
  236. this.loadData()
  237. }
  238. }).finally(_ => {
  239. this.delLoading = false
  240. })
  241. },
  242. // 删除所有
  243. delAll() {
  244. let hotelInfo = JSON.parse(localStorage.getItem('storeInfo'))
  245. this.delLoading = true
  246. delAll({
  247. hotelId: hotelInfo.id,
  248. }).then(res => {
  249. if(res.code == 200) {
  250. this.selectedRowKeys = []
  251. this.$message.success('全部删除成功');
  252. this.loadData()
  253. }
  254. }).finally(_ => {
  255. this.delLoading = false
  256. })
  257. },
  258. // 批量添加按钮
  259. onAddBatch() {
  260. this.$router.push('/tenant/gen/rooms');
  261. },
  262. // 全部删除
  263. onDelAll() {},
  264. // 显示图片弹窗
  265. handleImage(row) {
  266. this.$refs.roomimgmodal.setModel(row)
  267. },
  268. onSaveOk() {
  269. this.loadData();
  270. },
  271. },
  272. };
  273. </script>
  274. <style scoped>
  275. @import "~@assets/less/common.less";
  276. </style>