roomLayoutList.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324
  1. <template>
  2. <a-card :bordered="false">
  3. <!-- 查询区域 -->
  4. <div class="table-page-search-wrapper">
  5. <a-form layout="inline" @keyup.enter.native="searchQuery">
  6. <a-row :gutter="24">
  7. <a-col :span="6">
  8. <a-form-item label="房型名称">
  9. <a-input placeholder="房型名称" v-model="queryParam.name" style="width: 200px"></a-input>
  10. </a-form-item>
  11. </a-col>
  12. <a-col :md="6" :sm="8">
  13. <span style="float: left; overflow: hidden" class="table-page-search-submitButtons">
  14. <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
  15. <a-button type="primary" @click="searchReset" icon="reload"
  16. style="margin-left: 8px">重置</a-button>
  17. </span>
  18. </a-col>
  19. </a-row>
  20. </a-form>
  21. </div>
  22. <!-- 查询区域-END -->
  23. <!-- 操作按钮区域 -->
  24. <div class="table-operator">
  25. <a-button @click="handleAdd" type="primary" icon="plus">新增</a-button>
  26. <a-dropdown v-if="selectedRowKeys.length > 0">
  27. <a-button style="margin-left: 8px">
  28. 批量操作 <a-icon type="down" /></a-button>
  29. </a-dropdown>
  30. </div>
  31. <!-- table区域-begin -->
  32. <div>
  33. <!-- <div class="ant-alert ant-alert-info" style="margin-bottom: 16px">
  34. <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择
  35. <a style="font-weight: 600">{{ selectedRowKeys.length }}</a
  36. >项
  37. <a style="margin-left: 24px" @click="onClearSelected">清空</a>
  38. </div> -->
  39. <a-table ref="table" size="middle" :scroll="{ x: true }" bordered rowKey="id" :columns="columns"
  40. :dataSource="dataSource" :pagination="ipagination" :loading="loading" :rowSelection="{
  41. selectedRowKeys: selectedRowKeys,
  42. onChange: onSelectChange,
  43. }" class="j-table-force-nowrap" @change="handleTableChange">
  44. <template slot="stateSlot" slot-scope="text, record, index">
  45. <a-switch checked-children="开" un-checked-children="关" default-checked :checked="record.state == 1"
  46. @change="changeState" />
  47. </template>
  48. <template slot="appStateSlot" slot-scope="text, record, index">
  49. <a-switch checked-children="开" un-checked-children="关" default-checked
  50. :checked="record.appState == 1" @change="changeAppState($event, record)" />
  51. </template>
  52. <template slot="pictureSlot" slot-scope="text, record, index">
  53. <img :src="record.cover" style="width:40px;height40px;" />
  54. </template>
  55. <template slot="htmlSlot" slot-scope="text">
  56. <div v-html="text"></div>
  57. </template>
  58. <template slot="imgSlot" slot-scope="text, record">
  59. <span v-if="!text" style="font-size: 12px; font-style: italic">无图片</span>
  60. <img v-else :src="getImgView(text)" :preview="record.id" height="25px" alt=""
  61. style="max-width: 80px; font-size: 12px; font-style: italic" />
  62. </template>
  63. <template slot="fileSlot" slot-scope="text">
  64. <span v-if="!text" style="font-size: 12px; font-style: italic">无文件</span>
  65. <a-button v-else :ghost="true" type="primary" icon="download" size="small"
  66. @click="downloadFile(text)">
  67. 下载
  68. </a-button>
  69. </template>
  70. <span slot="action" slot-scope="text, record">
  71. <a @click="handleEdit(record)">编辑</a>
  72. <a-divider type="vertical" />
  73. <a-dropdown>
  74. <a class="ant-dropdown-link">更多 <a-icon type="down" /></a>
  75. <a-menu slot="overlay">
  76. <a-menu-item>
  77. <a @click="handlePriceManager(record)">价格管理</a>
  78. </a-menu-item>
  79. <a-menu-item>
  80. <a @click="handleDetailSetting(record)">详细设置</a>
  81. </a-menu-item>
  82. <a-menu-item>
  83. <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
  84. <a>删除</a>
  85. </a-popconfirm>
  86. </a-menu-item>
  87. </a-menu>
  88. </a-dropdown>
  89. </span>
  90. </a-table>
  91. </div>
  92. <room-layout-form ref="modalForm" @ok="modalFormOk"></room-layout-form>
  93. <room-layout-price-modal ref="priceModal" @ok="onPriceSave"></room-layout-price-modal>
  94. <room-layout-detail-modal @saveOk="onSaveOk" ref="detailModal"></room-layout-detail-modal>
  95. </a-card>
  96. </template>
  97. <script>
  98. import { JeecgListMixin } from "@/mixins/JeecgListMixin";
  99. import roomLayoutForm from "./RoomLayoutFormModal"; // todo roomLayoutForm 需要替换成房型的表单弹窗
  100. import RoomLayoutDetailModal from "./RoomLayoutFormDetailModal.vue";
  101. import RoomLayoutPriceModal from "./RoomLayoutPriceModal.vue";
  102. import { modifyAppState } from '@/api/roomLayout'
  103. import { filterObj } from "@/utils/util";
  104. let hotelInfo = JSON.parse(localStorage.getItem('storeInfo'))
  105. export default {
  106. name: "roomLayoutList",
  107. mixins: [JeecgListMixin],
  108. components: {
  109. roomLayoutForm,
  110. RoomLayoutPriceModal,
  111. RoomLayoutDetailModal
  112. },
  113. data() {
  114. return {
  115. queryParam: {},
  116. // 分页参数
  117. ipagination: {
  118. current: 1,
  119. pageSize: 10,
  120. pageSizeOptions: ["10", "20", "30"],
  121. showTotal: (total, range) => {
  122. return range[0] + "-" + range[1] + " 共" + total + "条";
  123. },
  124. showQuickJumper: true,
  125. showSizeChanger: true,
  126. total: 0,
  127. },
  128. // 表头
  129. columns: [
  130. {
  131. title: "商家",
  132. align: "center",
  133. dataIndex: "hotelName",
  134. },
  135. {
  136. title: "房型大图",
  137. align: "center",
  138. dataIndex: "cover",
  139. scopedSlots: { customRender: "pictureSlot" },
  140. },
  141. {
  142. title: "房型名字",
  143. align: "center",
  144. dataIndex: "name",
  145. },
  146. {
  147. title: "门市价",
  148. align: "center",
  149. dataIndex: "marketPrice",
  150. },
  151. {
  152. title: "可住人数",
  153. align: "center",
  154. dataIndex: "canLivePersonNum",
  155. },
  156. {
  157. title: "房间数",
  158. align: "center",
  159. dataIndex: "num",
  160. },
  161. {
  162. title: "状态",
  163. align: "center",
  164. dataIndex: "state",
  165. scopedSlots: { customRender: "stateSlot" },
  166. },
  167. {
  168. title: "APP",
  169. align: "center",
  170. dataIndex: "appState",
  171. scopedSlots: { customRender: "appStateSlot" },
  172. },
  173. {
  174. title: "操作",
  175. dataIndex: "action",
  176. align: "center",
  177. fixed: "right",
  178. width: 147,
  179. scopedSlots: { customRender: "action" },
  180. },
  181. ],
  182. url: {
  183. // list: 'org.jeecg.modules.business/busMarketMember/list',
  184. list: "/rooms/cesRoomLayout/list?hotelId="+hotelInfo.id,
  185. delete: "/rooms/cesRoomLayout/remove",
  186. deleteBatch: "/rooms/cesRoomLayout/deleteBatch",
  187. exportXlsUrl: "/rooms/cesRoomLayout/exportXls",
  188. importExcelUrl:
  189. "rooms/cesRoomLayout/importExcel",
  190. },
  191. dictOptions: {},
  192. superFieldList: [],
  193. selectedRowKeys: [],
  194. isorter: {
  195. column: "createTime",
  196. order: "desc",
  197. },
  198. };
  199. },
  200. created() {
  201. // this.loadData()
  202. },
  203. methods: {
  204. onSaveOk() {
  205. this.loadData()
  206. },
  207. onPriceSave() {
  208. },
  209. handlePriceManager(record) {
  210. this.$refs.priceModal.setRaw(record.id, record.name)
  211. this.$refs.priceModal.visible = true
  212. },
  213. handleDetailSetting(record) {
  214. this.$refs.detailModal.setRaw(record)
  215. this.$refs.detailModal.visible = true
  216. },
  217. changeState(e) {
  218. console.log(e)
  219. },
  220. changeAppState(e, param) {
  221. modifyAppState(param).then(res => {
  222. if (res.code == 200) {
  223. this.loadData();
  224. }
  225. })
  226. },
  227. getAvatarView: function (avatar) {
  228. return getFileAccessHttpUrl(avatar);
  229. },
  230. batchFrozen: function (status) {
  231. if (this.selectedRowKeys.length <= 0) {
  232. this.$message.warning("请选择一条记录!");
  233. return false;
  234. } else {
  235. let ids = "";
  236. let that = this;
  237. let isAdmin = false;
  238. that.selectionRows.forEach(function (row) {
  239. if (row.username == "admin") {
  240. isAdmin = true;
  241. }
  242. });
  243. if (isAdmin) {
  244. that.$message.warning("管理员账号不允许此操作,请重新选择!");
  245. return;
  246. }
  247. that.selectedRowKeys.forEach(function (val) {
  248. ids += val + ",";
  249. });
  250. that.$confirm({
  251. title: "确认操作",
  252. content: "是否" + (status == 1 ? "解冻" : "冻结") + "选中账号?",
  253. onOk: function () {
  254. frozenBatch({ ids: ids, status: status }).then((res) => {
  255. if (res.success) {
  256. that.$message.success(res.message);
  257. that.loadData();
  258. that.onClearSelected();
  259. } else {
  260. that.$message.warning(res.message);
  261. }
  262. });
  263. },
  264. });
  265. }
  266. },
  267. handleMenuClick(e) {
  268. if (e.key == 1) {
  269. this.batchDel();
  270. } else if (e.key == 2) {
  271. this.batchFrozen(2);
  272. } else if (e.key == 3) {
  273. this.batchFrozen(1);
  274. }
  275. },
  276. handleFrozen: function (id, status, username) {
  277. let that = this;
  278. //TODO 后台校验管理员角色
  279. if ("admin" == username) {
  280. that.$message.warning("管理员账号不允许此操作!");
  281. return;
  282. }
  283. frozenBatch({ ids: id, status: status }).then((res) => {
  284. if (res.success) {
  285. that.$message.success(res.message);
  286. that.loadData();
  287. } else {
  288. that.$message.warning(res.message);
  289. }
  290. });
  291. },
  292. handleChangePassword(username) {
  293. this.$refs.passwordmodal.show(username);
  294. },
  295. passwordModalOk() {
  296. //TODO 密码修改完成 不需要刷新页面,可以把datasource中的数据更新一下
  297. },
  298. onSyncFinally({ isToLocal }) {
  299. // 同步到本地时刷新下数据
  300. if (isToLocal) {
  301. this.loadData();
  302. }
  303. },
  304. },
  305. };
  306. </script>
  307. <style scoped>
  308. @import "~@assets/less/common.less";
  309. </style>