posTable.vue 9.6 KB

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