posTable.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363
  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="3">
  8. <a-form-item label="">
  9. <j-input
  10. placeholder="餐桌名称"
  11. v-model="queryParam.name"
  12. ></j-input>
  13. </a-form-item>
  14. </a-col>
  15. <a-col :md="6" :sm="8">
  16. <span
  17. style="float: left; overflow: hidden"
  18. class="table-page-search-submitButtons"
  19. >
  20. <a-button type="primary" @click="searchQuery" icon="search"
  21. >查询</a-button
  22. >
  23. <a-button
  24. type="primary"
  25. @click="searchReset"
  26. icon="reload"
  27. style="margin-left: 8px"
  28. >重置</a-button
  29. >
  30. </span>
  31. </a-col>
  32. </a-row>
  33. </a-form>
  34. </div>
  35. <!-- 查询区域-END -->
  36. <!-- 操作按钮区域 -->
  37. <div class="table-operator">
  38. <a-button @click="handleAdd" type="primary" icon="plus">新增</a-button>
  39. <a-button :disabled="selectedRowKeys.length == 0" @click="downloadQRcode" type="primary">下载二维码</a-button>
  40. <a-button @click="batchDel" :disabled="selectedRowKeys.length == 0" icon="stop" type="danger" >批量删除</a-button>
  41. <a-button @click="batchAdd" type="primary">批量新增</a-button>
  42. </div>
  43. <!-- table区域-begin -->
  44. <div>
  45. <!-- <div class="ant-alert ant-alert-info" style="margin-bottom: 16px">
  46. <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择
  47. <a style="font-weight: 600">{{ selectedRowKeys.length }}</a
  48. >项
  49. <a style="margin-left: 24px" @click="onClearSelected">清空</a>
  50. </div> -->
  51. <a-table
  52. ref="table"
  53. size="middle"
  54. :scroll="{ x: true }"
  55. bordered
  56. rowKey="id"
  57. :columns="columns"
  58. :dataSource="dataSource"
  59. :pagination="ipagination"
  60. :loading="loading"
  61. :rowSelection="{
  62. selectedRowKeys: selectedRowKeys,
  63. onChange: onSelectChange,
  64. }"
  65. class="j-table-force-nowrap"
  66. @change="handleTableChange"
  67. >
  68. <template slot="payFlagslot" slot-scope="text, record, index">
  69. {{ record.payFlag == 1 ? "是" : "否" }}
  70. </template>
  71. <template slot="iconslot" slot-scope="text, record, index">
  72. <a-icon :type="record.icon" theme="filled" />
  73. </template>
  74. <template slot="htmlSlot" slot-scope="text">
  75. <div v-html="text"></div>
  76. </template>
  77. <template slot="imgSlot" slot-scope="text, record">
  78. <span v-if="!text" style="font-size: 12px; font-style: italic"
  79. >无图片</span
  80. >
  81. <img
  82. v-else
  83. :src="getImgView(text)"
  84. :preview="record.id"
  85. height="25px"
  86. alt=""
  87. style="max-width: 80px; font-size: 12px; font-style: italic"
  88. />
  89. </template>
  90. <template slot="fileSlot" slot-scope="text">
  91. <span v-if="!text" style="font-size: 12px; font-style: italic"
  92. >无文件</span
  93. >
  94. <a-button
  95. v-else
  96. :ghost="true"
  97. type="primary"
  98. icon="download"
  99. size="small"
  100. @click="downloadFile(text)"
  101. >
  102. 下载
  103. </a-button>
  104. </template>
  105. <span slot="action" slot-scope="text, record">
  106. <a @click="QRcode(record)">二维码</a>
  107. <a-divider type="vertical" />
  108. <a @click="handleEdit(record)">编辑</a>
  109. <a-divider type="vertical" />
  110. <a-popconfirm
  111. title="确定删除吗?"
  112. @confirm="() => handleDelete(record.id)"
  113. >
  114. <a>删除</a>
  115. </a-popconfirm>
  116. </span>
  117. </a-table>
  118. </div>
  119. <a-modal title="二维码" :visible="QRcodeVisible" @cancel="QRcodeVisible = false" @ok="QRcodeVisible = false">
  120. <div style="text-align:center;">
  121. <a-avatar :size="264" shape="square" :src="selectQRcode" alt="暂无二维码" />
  122. </div>
  123. </a-modal>
  124. <pos-table-modal ref="modalForm" @ok="modalFormOk"></pos-table-modal>
  125. <batchAddModal ref="modalFormBatch" @ok="modalFormBatchOk" />
  126. </a-card>
  127. </template>
  128. <script>
  129. import { JeecgListMixin } from "@/mixins/JeecgListMixin";
  130. import PosTableModal from "./modules/PosTableModal";
  131. import { filterObj } from "@/utils/util";
  132. import { getAction, downloadFileZIP } from "@/api/manage";
  133. import batchAddModal from './modules/batchAddModal.vue';
  134. export default {
  135. name: "memberList",
  136. mixins: [JeecgListMixin],
  137. components: {
  138. PosTableModal,
  139. batchAddModal
  140. },
  141. data() {
  142. return {
  143. QRcodeVisible: false,
  144. selectQRcode: null,
  145. queryParam: {},
  146. // 分页参数
  147. ipagination: {
  148. current: 1,
  149. pageSize: 10,
  150. pageSizeOptions: ["10", "20", "30"],
  151. showTotal: (total, range) => {
  152. return range[0] + "-" + range[1] + " 共" + total + "条";
  153. },
  154. showQuickJumper: true,
  155. showSizeChanger: true,
  156. total: 0,
  157. },
  158. // 表头
  159. columns: [
  160. {
  161. title: "pos类型",
  162. align: "center",
  163. dataIndex: "typeName",
  164. },
  165. {
  166. title: "餐桌区域",
  167. align: "center",
  168. dataIndex: "regionName",
  169. },
  170. {
  171. title: "餐桌名称",
  172. align: "center",
  173. dataIndex: "name",
  174. },
  175. {
  176. title: "桌型",
  177. align: "center",
  178. dataIndex: "tableTypeName",
  179. },
  180. {
  181. title: "座位数",
  182. align: "center",
  183. dataIndex: "num",
  184. },
  185. {
  186. title: "餐桌序号",
  187. align: "center",
  188. dataIndex: "tableNo",
  189. },
  190. {
  191. title: "状态",
  192. align: "center",
  193. dataIndex: "state",
  194. customRender: function (text) {
  195. return text == 0 ? "空桌台" : "用餐中";
  196. },
  197. },
  198. {
  199. title: "操作",
  200. dataIndex: "action",
  201. align: "center",
  202. fixed: "right",
  203. width: 147,
  204. scopedSlots: { customRender: "action" },
  205. },
  206. ],
  207. url: {
  208. list: "/pos/posTable/list",
  209. delete: "/pos/posTable/delete",
  210. deleteBatch: "/pos/posTable/deleteBatch",
  211. exportXlsUrl: "/pos/posTable/exportXls",
  212. importExcelUrl: "pos/posTable/importExcel",
  213. },
  214. dictOptions: {},
  215. superFieldList: [],
  216. selectedRowKeys: [],
  217. isorter: {
  218. column: "createTime",
  219. order: "desc",
  220. },
  221. };
  222. },
  223. created() {
  224. },
  225. methods: {
  226. QRcode(record){
  227. console.log(record);
  228. this.selectQRcode = null;
  229. if (record.qrCode) {
  230. this.selectQRcode = record.qrCode;
  231. this.QRcodeVisible = true;
  232. }else{
  233. getAction('/pos/posTable/generateQRCode?id=' + record.id).then((res) => {
  234. console.log(res);
  235. if (res.success) {
  236. this.selectQRcode = res.result.qrCode;
  237. this.QRcodeVisible = true;
  238. }else{
  239. this.$message.warning(res.message);
  240. }
  241. });
  242. }
  243. // this.selectQRcode = record.qrCode;
  244. // this.QRcodeVisible = true;
  245. },
  246. batchAdd(){
  247. this.$refs.modalFormBatch.add();
  248. },
  249. modalFormBatchOk(e){
  250. console.log(e);
  251. },
  252. downloadQRcode(){
  253. if (this.selectedRowKeys.length <= 0) {
  254. this.$message.warning('请选择一条记录!');
  255. return;
  256. } else {
  257. var ids = "";
  258. for (var a = 0; a < this.selectedRowKeys.length; a++) {
  259. ids += this.selectedRowKeys[a] + ",";
  260. }
  261. var that = this;
  262. console.log(ids);
  263. downloadFileZIP('/pos/posTable/makeQRCode?ids=' + ids, '二维码', {}).then((res) => {
  264. console.log(res);
  265. that.onClearSelected();
  266. });
  267. }
  268. },
  269. getAvatarView: function (avatar) {
  270. return getFileAccessHttpUrl(avatar);
  271. },
  272. batchFrozen: function (status) {
  273. if (this.selectedRowKeys.length <= 0) {
  274. this.$message.warning("请选择一条记录!");
  275. return false;
  276. } else {
  277. let ids = "";
  278. let that = this;
  279. let isAdmin = false;
  280. that.selectionRows.forEach(function (row) {
  281. if (row.username == "admin") {
  282. isAdmin = true;
  283. }
  284. });
  285. if (isAdmin) {
  286. that.$message.warning("管理员账号不允许此操作,请重新选择!");
  287. return;
  288. }
  289. that.selectedRowKeys.forEach(function (val) {
  290. ids += val + ",";
  291. });
  292. that.$confirm({
  293. title: "确认操作",
  294. content: "是否" + (status == 1 ? "解冻" : "冻结") + "选中账号?",
  295. onOk: function () {
  296. frozenBatch({ ids: ids, status: status }).then((res) => {
  297. if (res.success) {
  298. that.$message.success(res.message);
  299. that.loadData();
  300. that.onClearSelected();
  301. } else {
  302. that.$message.warning(res.message);
  303. }
  304. });
  305. },
  306. });
  307. }
  308. },
  309. handleMenuClick(e) {
  310. if (e.key == 1) {
  311. this.batchDel();
  312. } else if (e.key == 2) {
  313. this.batchFrozen(2);
  314. } else if (e.key == 3) {
  315. this.batchFrozen(1);
  316. }
  317. },
  318. handleFrozen: function (id, status, username) {
  319. let that = this;
  320. //TODO 后台校验管理员角色
  321. if ("admin" == username) {
  322. that.$message.warning("管理员账号不允许此操作!");
  323. return;
  324. }
  325. frozenBatch({ ids: id, status: status }).then((res) => {
  326. if (res.success) {
  327. that.$message.success(res.message);
  328. that.loadData();
  329. } else {
  330. that.$message.warning(res.message);
  331. }
  332. });
  333. },
  334. handleChangePassword(username) {
  335. this.$refs.passwordmodal.show(username);
  336. },
  337. passwordModalOk() {
  338. //TODO 密码修改完成 不需要刷新页面,可以把datasource中的数据更新一下
  339. },
  340. onSyncFinally({ isToLocal }) {
  341. // 同步到本地时刷新下数据
  342. if (isToLocal) {
  343. this.loadData();
  344. }
  345. },
  346. },
  347. };
  348. </script>
  349. <style scoped>
  350. @import "~@assets/less/common.less";
  351. </style>