diandan.vue 32 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060
  1. <template>
  2. <a-card :bordered="false" class="card-pd">
  3. <a-tabs v-model="tabPosTypeId" @change="tabPosTypeChange">
  4. <a-tab-pane
  5. :key="item.id"
  6. :tab="item.name"
  7. v-for="item in posTypeList"
  8. ></a-tab-pane>
  9. </a-tabs>
  10. <div style="display: flex; height: calc(100vh - 350px)">
  11. <a-card style="width: 30%;">
  12. <a href="#" @click="remarkModal"> <a-icon type="edit" />整单备注</a>
  13. &nbsp;&nbsp;<a-icon type="user" />
  14. <spn v-if="posTableId !=''">桌台: {{ posTableName }}</spn>
  15. <span v-if="selectRoomOrder && selectRoomOrder.roomName">
  16. 房间:{{ selectRoomOrder.roomName }},姓名:{{
  17. selectRoomOrder.customerName
  18. }}
  19. </span>
  20. <a-table
  21. bordered
  22. :columns="columns"
  23. :data-source="selectGoodsList"
  24. :row-selection="rowSelection"
  25. rowKey="id"
  26. style=" overflow-y: scroll;"
  27. >
  28. <template slot="num" slot-scope="text, record, index">
  29. <div style="text-align: center">
  30. <a-input-number
  31. v-if="record.detailId == null"
  32. v-model="record.num"
  33. style="width: auto; "
  34. :max="record.inventory"
  35. @change="(event) => numChange(event, index)"/>
  36. <span v-else>{{ record.num }}</span>
  37. </div>
  38. </template>
  39. <template slot="required" slot-scope="text, record, index">
  40. <div>
  41. <a-switch v-model="record.required" />
  42. </div>
  43. </template>
  44. <span slot="action" slot-scope="text, record, index">
  45. <a @click="handleDelete(index)">删除</a>
  46. </span>
  47. </a-table>
  48. <p>数量:{{ sum }}</p>
  49. <div v-if="this.posTableState === 1">
  50. <a-button @click="placeOrder" :disabled="btnDisabled">下单</a-button>
  51. <a-button @click="unionStation('联台','5')" style="margin-left: 10px;">联台</a-button>
  52. <a-button v-if="!btnDisabled && selectGoodsList.length !== 0" @click="unionStation('转菜','2')" :disabled="transferDishesList.length == 0" style="margin-left: 10px;">转菜</a-button>
  53. <a-button @click="unionStation('换台','0')" style="margin-left: 10px;">换台</a-button>
  54. <!-- <a-button @click="addClear" :disabled="btnDisabled">清空新加</a-button>-->
  55. </div>
  56. <div v-else style="display: flex; gap: 5px; flex-flow: wrap">
  57. <a-button @click="clean" :disabled="btnDisabled">清空</a-button>
  58. <!-- <a-button @click="handleAdd" :disabled="btnDisabled">备注</a-button> -->
  59. <!-- <a-button :disabled="btnDisabled">退货</a-button> -->
  60. <div v-if="posTableId === ''">
  61. <a-button v-if="!btnDisabled" @click="pendingOrder">挂单</a-button>
  62. <a-button v-else @click="handlePickingGoodsOrder">取单</a-button>
  63. </div>
  64. <div>
  65. <a-button v-if="!btnDisabled" @click="unionStation('联台','5')" style="margin-left: 10px;">联台</a-button>
  66. <a-button v-if="!btnDisabled && selectGoodsList.length !== 0" @click="unionStation('转菜','2')" :disabled="transferDishesList.length == 0" style="margin-left: 10px;">转菜</a-button>
  67. <a-button v-if="!btnDisabled" @click="unionStation('换台','0')" style="margin-left: 10px;">换台</a-button>
  68. <a-button v-if="isUnionStation" @click="unlink" style="margin-left: 10px;">取消联台</a-button>
  69. <!-- <a-button @click="pendingOrder">挂单</a-button> -->
  70. <!-- <a-button v-else @click="handlePickingGoodsOrder">取单</a-button> -->
  71. </div>
  72. <a-button
  73. v-if="selectRoomOrder && selectRoomOrder.roomName && !btnDisabled"
  74. @click="handleToRoomFeePayment"
  75. >确定挂房帐</a-button
  76. >
  77. <a-button
  78. v-else
  79. @click="handleSelectCheckInRoomOrder">
  80. 挂房帐
  81. </a-button
  82. >
  83. <a-button
  84. :disabled="btnDisabled"
  85. type="danger"
  86. @click="handlePayment"
  87. >结账¥{{ amount.toFixed(2) }}</a-button
  88. >
  89. <a-button :disabled="btnDisabled" @click="refundChange">退货</a-button>
  90. </div>
  91. </a-card>
  92. <a-card style="width: 75%; position: relative">
  93. <a-tabs v-model="tabgoodsTypeId" @change="tabGoodsTypeChange">
  94. <a-tab-pane key="1" tab="全部"></a-tab-pane>
  95. <a-tab-pane
  96. :key="item.id"
  97. :tab="item.name"
  98. v-for="item in goodsTypeList"
  99. ></a-tab-pane>
  100. </a-tabs>
  101. <a-row :gutter="[5, 5]">
  102. <a-col
  103. v-for="item in dataSource"
  104. :key="item.id"
  105. :span="3"
  106. @click.stop="itemClick(item)"
  107. >
  108. <div class="room-item check">
  109. <div class="select-cell"></div>
  110. <template v-if="item.id != '0'">
  111. <div>{{ item.name }}</div>
  112. <div style="margin-top: 10px; color: red">
  113. ¥{{ item.sellingPrice.toFixed(2) }}
  114. </div>
  115. <div style="margin-top: 10px">库{{ item.inventory }}</div>
  116. <!-- <div-->
  117. <!-- v-if="item.isSellClear"-->
  118. <!-- style="display: flex; justify-content: right">-->
  119. <!-- <a-tag color="#f50"> 沽清 </a-tag>-->
  120. <!-- </div>-->
  121. <div
  122. v-if="item.inventory <= 0"
  123. style="display: flex; justify-content: right">
  124. <a-tag color="#f50"> 沽清 </a-tag>
  125. </div>
  126. </template>
  127. <template v-else>
  128. <div style="font-weight: 800; text-align: center">+临时菜</div>
  129. </template>
  130. </div>
  131. </a-col>
  132. <a-col
  133. v-for="item in dataSource2"
  134. :key="item.id"
  135. :span="3"
  136. @click.stop="itemClick2(item)"
  137. >
  138. <div class="room-item check">
  139. <div class="select-cell"></div>
  140. <div style="display: flex">
  141. <a-tag color="#506fee"> 套 </a-tag>
  142. </div>
  143. <div>{{ item.name }}</div>
  144. <div style="margin-top: 10px; color: red">
  145. ¥{{ item.sellingPrice.toFixed(2) }}
  146. </div>
  147. </div>
  148. </a-col>
  149. </a-row>
  150. <a-row style="margin-top: 30px">
  151. <a-space>
  152. <a-input
  153. v-if="!isSaoma"
  154. placeholder="输入名称、简拼、条码"
  155. ></a-input>
  156. <a-input v-else placeholder="请扫描条码"></a-input>
  157. <a-button v-if="!isSaoma">查询</a-button>
  158. <a-button
  159. @click="isSaoma = !isSaoma"
  160. >切换为{{ isSaoma ? "查询" : "扫码" }}模式</a-button
  161. >
  162. </a-space>
  163. </a-row>
  164. </a-card>
  165. <a-modal v-model="unionOpen" width="1200px" :title="unionTitle" @ok="handleOk">
  166. <a-tabs v-model="tabPosRegionId" @change="tabRegionChange">
  167. <a-tab-pane key="1" tab="全部"></a-tab-pane>
  168. <a-tab-pane
  169. :key="item.id"
  170. :tab="item.name"
  171. v-for="item in regionList"
  172. ></a-tab-pane>
  173. </a-tabs>
  174. <a-row :gutter="[5, 5]">
  175. <a-col
  176. v-for="item in uniteDataSource"
  177. :key="item.id"
  178. :span="2"
  179. @click="orderMeal(item)"
  180. >
  181. <template>
  182. <div :style="item.state == '1' ? 'backgroundColor: #00a0e9;border: 2px solid #000;color: #fff;' : 'backgroundColor: #0a7a72;border: 2px solid #000;color: #fff;'" :class="{'active': model.reserveTableList.some(t => t.id == item.id) }">
  183. <div>{{ item.name }}</div>
  184. <div style="margin-top: 10px">
  185. <div v-if="item.state == '2'">¥{{ item.posOrderGoods ? item.posOrderGoods.money : 0 }}</div>
  186. <div v-else>待下单</div>
  187. </div>
  188. <div
  189. style="
  190. margin-top: 10px;
  191. display: flex;
  192. justify-content: space-between;
  193. "
  194. >
  195. <div>
  196. <a-icon type="user" />{{ item.userNum }}/{{ item.num }}人
  197. </div>
  198. <div>
  199. <a-icon type="clock-circle" />{{ hours(item.orderTime) }}
  200. </div>
  201. </div>
  202. </div></template
  203. >
  204. </a-col>
  205. </a-row>
  206. </a-modal>
  207. </div>
  208. <payment-modal ref="modalPaymentForm" @ok="modalFormOk" @close="modalFormClose"></payment-modal>
  209. <goods-modal ref="modalGoodsForm" @ok="modalFormOk2"></goods-modal>
  210. <picking-goods-order-modal
  211. ref="modalPickingGoodsOrderForm"
  212. @ok="modalPickingGoodsOrderFormOk"
  213. ></picking-goods-order-modal>
  214. <select-check-in-room-order-modal
  215. ref="modalSelectCheckInRoomOrderModal"
  216. @ok="modalSelectCheckInRoomOrderFormOk"
  217. ></select-check-in-room-order-modal>
  218. <!-- 整单备注弹窗 -->
  219. <a-modal
  220. @cancel="isRemarkModal = false"
  221. :visible="isRemarkModal"
  222. title="添加备注"
  223. @ok="remarkModalOk"
  224. >
  225. <a-form-model>
  226. <a-form-model-item label="备注">
  227. <a-input v-model="remark" type="textarea" />
  228. </a-form-model-item>
  229. </a-form-model>
  230. </a-modal>
  231. <!-- 退货弹窗 -->
  232. <a-modal
  233. @cancel="isRefund = false"
  234. :visible="isRefund"
  235. title="退货"
  236. @ok="refundModalOk"
  237. >
  238. <a-form-model>
  239. <a-form-model-item label="备注">
  240. <a-input v-model="refundRemark" />
  241. </a-form-model-item>
  242. </a-form-model>
  243. </a-modal>
  244. </a-card>
  245. </template>
  246. <script>
  247. // import { JeecgListMixin } from "@/mixins/JeecgListMixin";
  248. // import PosRegionModal from "./modules/PosRegionModal";
  249. import { filterObj } from '@/utils/util'
  250. import { getAction, postAction, deleteAction } from '@/api/manage'
  251. import PaymentModal from './modules/PaymentModal.vue'
  252. import goodsModal from './modules/goodStock/goodsModal.vue'
  253. import PickingGoodsOrderModal from './modules/PickingGoodsOrderModal.vue'
  254. import SelectCheckInRoomOrderModal from './modules/SelectCheckInRoomOrderModal.vue'
  255. import { computed } from 'vue'
  256. import { tree } from '@/api/good'
  257. const columns = [
  258. {
  259. title: '商品名称',
  260. dataIndex: 'name',
  261. width: '50%'
  262. },
  263. {
  264. title: '数量',
  265. dataIndex: 'num',
  266. width: '25%',
  267. scopedSlots: {
  268. customRender: 'num'
  269. }
  270. },
  271. {
  272. title: '售价',
  273. dataIndex: 'sellingPrice',
  274. width: '25%'
  275. }
  276. ]
  277. export default {
  278. name: 'MemberList',
  279. components: {
  280. PaymentModal,
  281. goodsModal,
  282. PickingGoodsOrderModal,
  283. SelectCheckInRoomOrderModal
  284. },
  285. props: {
  286. tableId: {
  287. type: String,
  288. default: ''
  289. },
  290. tableState: {
  291. type: Number,
  292. default: -1
  293. },
  294. tableName: {
  295. type: String,
  296. default: ''
  297. },
  298. orderId: {
  299. type: String,
  300. default: ''
  301. },
  302. isUnionStation: {
  303. type: Boolean,
  304. default: false
  305. }
  306. },
  307. watch: {
  308. tableId: function (newValue, oldValue) {
  309. this.posTableId = this.tableId
  310. this.posTableState = this.tableState
  311. this.posTableName = this.tableName
  312. if (this.tableId !== '' && this.tableState === 2) {
  313. this.getOrderByTableId(this.tableId)
  314. }
  315. }
  316. },
  317. data() {
  318. return {
  319. posTableId: '',
  320. posTableState: -1,
  321. posTableName: '',
  322. tableState2: -1,
  323. isRemarkModal: false,
  324. isSaoma: false,
  325. remark: '',
  326. columns,
  327. isRefund: false,
  328. refundRemark: '',
  329. sellClear: 0,
  330. queryParam: {},
  331. // 分页参数
  332. ipagination: {
  333. current: 1,
  334. pageSize: 99999,
  335. pageSizeOptions: ['10', '20', '30'],
  336. showTotal: (total, range) => {
  337. return range[0] + '-' + range[1] + ' 共' + total + '条'
  338. },
  339. showQuickJumper: true,
  340. showSizeChanger: true,
  341. total: 0
  342. },
  343. url: {
  344. list: '/pos/posSellClearGoods/list',
  345. delete: '/pos/posSellClearGoods/delete',
  346. deleteBatch: '/pos/posSellClearGoods/deleteBatch',
  347. exportXlsUrl: '/pos/posSellClearGoods/exportXls',
  348. importExcelUrl: 'pos/posSellClearGoods/importExcel'
  349. },
  350. dictOptions: {},
  351. superFieldList: [],
  352. selectedRowKeys: [],
  353. selectedRows: [],
  354. isorter: {
  355. column: 'createTime',
  356. order: 'desc'
  357. },
  358. treeData: [],
  359. selectGoods: {},
  360. posTypeList: [],
  361. tabPosTypeId: '',
  362. selectGoodsList: [],
  363. goodsTypeList: [],
  364. tabgoodsTypeId: '1',
  365. dataSource: [],
  366. dataSource2: [],
  367. oldSelectGoodsList: [],
  368. selectOrderInfo: {},
  369. selectRoomOrder: {},
  370. // 联台显示隐藏
  371. unionOpen: false,
  372. // 联台id
  373. tabPosRegionId: '1',
  374. // 联台房间tab
  375. regionList: [],
  376. // 列表数据
  377. uniteDataSource: [],
  378. model: {
  379. reserveTableList: []
  380. },
  381. // 联台弹框标题文本
  382. unionTitle: '',
  383. // 转菜储存数组
  384. transferDishesList: []
  385. }
  386. },
  387. provide() {
  388. return {
  389. treeData: computed(() => this.treeData)
  390. }
  391. },
  392. computed: {
  393. rowSelection() {
  394. return {
  395. onChange: (selectedRowKeys, selectedRows) => {
  396. console.log(
  397. `selectedRowKeys: ${selectedRowKeys}`,
  398. 'selectedRows: ',
  399. selectedRows
  400. )
  401. this.selectedRowKeys = selectedRowKeys
  402. this.selectedRows = selectedRows
  403. this.transferDishesList = this.selectedRows.filter(item => {
  404. return ('id' in item)
  405. })
  406. console.log(this.transferDishesList);
  407. },
  408. getCheckboxProps: (record) => ({
  409. props: {
  410. disabled: record.name === 'Disabled User', // Column configuration not to be checked
  411. name: record.name
  412. }
  413. })
  414. }
  415. },
  416. sum() {
  417. return this.selectGoodsList.reduce(function (total, item) {
  418. return total + item.num
  419. }, 0)
  420. },
  421. amount() {
  422. console.log(this.selectGoodsList)
  423. return this.selectGoodsList.reduce(function (total, item) {
  424. return total + item.sellingPrice * item.num
  425. }, 0)
  426. },
  427. btnDisabled() {
  428. console.log(this.selectGoodsList);
  429. var res = this.selectGoodsList && this.selectGoodsList.length >= 0
  430. return !res
  431. }
  432. },
  433. created() {
  434. console.log(this.tableId);
  435. console.log(this.tableState);
  436. console.log(this.tableName);
  437. console.log(this.orderId);
  438. this.dataSource = [
  439. {
  440. id: '0'
  441. }
  442. ]
  443. getAction('/pos/posType/list', {
  444. pageNo: 1,
  445. pageSize: 99
  446. }).then((res) => {
  447. if (res.success) {
  448. this.posTypeList = res.result.records
  449. if (this.posTypeList && this.posTypeList.length > 0) {
  450. this.tabPosTypeId = this.posTypeList[0].id
  451. this.loadGoodsType()
  452. }
  453. }
  454. })
  455. this.loadTree()
  456. },
  457. methods: {
  458. // 处理小时
  459. hours(start) {
  460. var beginDate = new Date(start);
  461. var endDate = new Date();
  462. let hours = parseInt((endDate - beginDate) / (1000 * 60 * 60));
  463. let leave1 =
  464. (endDate.getTime() - beginDate.getTime()) % (24 * 3600 * 1000);
  465. let leave2 = leave1 % (3600 * 1000);
  466. let minutes = Math.floor(leave2 / (60 * 1000));
  467. // return minutes == 0 ? hours : hours + 1;
  468. return hours.toString().padStart(2, "0") + ":" + minutes.toString().padStart(2, "0");
  469. },
  470. getStatusColor(status) {
  471. var find = this.statusColorList.find((t) => t.status == status);
  472. return find ? find.color : "#fff";
  473. },
  474. loadTree() {
  475. var that = this;
  476. tree().then((res) => {
  477. if (res.success) {
  478. this.treeData = res.result;
  479. }
  480. });
  481. },
  482. /** 通过桌号查询订单 */
  483. getOrderByTableId(tableId) {
  484. getAction('/pos/posOrderGoods/getOrderByTableId', { tableId }).then(resp => {
  485. console.log(resp);
  486. if (resp.success) {
  487. this.selectOrderInfo = resp.result
  488. this.selectGoodsList = resp.result.posOrderGoodsDetailList
  489. this.selectGoodsList.forEach(e => {
  490. this.$set(e, 'sellingPrice', e.money)
  491. this.$set(e, 'name', e.goodsName)
  492. })
  493. this.oldSelectGoodsList = JSON.parse(JSON.stringify(this.selectGoodsList))
  494. } else {
  495. this.$message.warning('查询订单失败')
  496. }
  497. })
  498. },
  499. remarkModal() {
  500. if (!this.selectGoodsList || this.selectGoodsList.length <= 0) {
  501. this.$message.warning('请先选择商品')
  502. return
  503. }
  504. this.isRemarkModal = true
  505. },
  506. refundModalOk() {
  507. },
  508. /**
  509. * 退货
  510. */
  511. refundChange() {
  512. this.$message.warning('未下单餐品不支持退菜,请重新选择')
  513. return
  514. if (this.selectedRows.length == 0) {
  515. this.$message.warning('请先选择菜品')
  516. }
  517. this.isRefund = true
  518. },
  519. remarkModalOk() {
  520. this.handleAdd()
  521. this.remark = ''
  522. this.isRemarkModal = false
  523. },
  524. onClearSelected() {
  525. this.selectedRowKeys = []
  526. this.selectionRows = []
  527. },
  528. loadTree() {
  529. var that = this
  530. tree().then((res) => {
  531. if (res.success) {
  532. this.treeData = res.result
  533. }
  534. })
  535. },
  536. modalFormOk() {
  537. this.clean()
  538. this.loadGoods()
  539. },
  540. /** 不支付,关闭弹窗,要刷新选中的商品表 */
  541. modalFormClose() {
  542. getAction('/pos/posOrderGoodsDetail/getDetailByOrderId', {
  543. orderId: this.selectOrderInfo.code
  544. }).then((res) => {
  545. if (res.success) {
  546. this.selectGoodsList = res.result;
  547. res.result.forEach((t) => {
  548. t.sellingPrice = t.payMoney
  549. t.name = t.goodsName
  550. t.id = t.goodsId
  551. })
  552. this.selectGoodsList = res.result
  553. }
  554. });
  555. },
  556. clean() {
  557. this.selectGoodsList = []
  558. this.selectOrderInfo = {}
  559. this.selectRoomOrder = {}
  560. },
  561. modalFormOk2(e) {
  562. console.log(e)
  563. var good = JSON.parse(JSON.stringify(e))
  564. this.$set(good, 'num', 1)
  565. this.selectGoodsList.push(good)
  566. },
  567. modalSelectCheckInRoomOrderFormOk(e) {
  568. console.log(e)
  569. this.selectRoomOrder = e
  570. },
  571. modalPickingGoodsOrderFormOk(e) {
  572. console.log(e)
  573. if (e && e.orderDetailList && e.orderDetailList.length > 0) {
  574. this.selectOrderInfo = e.orderInfo
  575. e.orderDetailList.forEach((t) => {
  576. t.sellingPrice = t.payMoney
  577. t.name = t.goodsName
  578. t.detailId = t.id
  579. t.id = t.goodsId
  580. })
  581. this.selectGoodsList = e.orderDetailList
  582. }
  583. },
  584. numChange(e, index) {
  585. console.log(e)
  586. if (e <= 0) {
  587. this.selectGoodsList.splice(index, 1)
  588. }
  589. },
  590. addClear() {
  591. let findList = this.selectGoodsList.filter(e => e.id != null)
  592. this.selectGoodsList = findList
  593. // this.selectOrderInfo = {};
  594. },
  595. handleClear() {
  596. this.selectGoodsList = []
  597. // this.selectOrderInfo = {};
  598. },
  599. tabPosTypeChange(e) {
  600. this.loadGoodsType()
  601. },
  602. tabGoodsTypeChange(e) {
  603. this.loadGoods()
  604. },
  605. loadGoodsType() {
  606. getAction('/rooms/cesStockType/getTopTypesByPosType', {
  607. posType: this.tabPosTypeId
  608. }).then((res2) => {
  609. if (res2.success) {
  610. this.goodsTypeList = res2.result
  611. if (this.goodsTypeList && this.goodsTypeList.length > 0) {
  612. this.loadGoods()
  613. }
  614. }
  615. })
  616. },
  617. loadGoods() {
  618. var ids = []
  619. if (this.tabgoodsTypeId === '1') {
  620. this.goodsTypeList.forEach((t) => {
  621. ids.push(t.id)
  622. })
  623. } else {
  624. ids.push(this.tabgoodsTypeId)
  625. }
  626. this.dataSource = [
  627. {
  628. id: '0'
  629. }
  630. ]
  631. getAction('/pos/posSellClearGoods/list', {
  632. pageNo: 1,
  633. pageSize: 99999,
  634. goodTypes: ids
  635. }).then((res) => {
  636. if (res.success) {
  637. this.dataSource = [...this.dataSource, ...res.result.records]
  638. }
  639. })
  640. getAction('/pos/posSellClearGoods/thali-list', {
  641. pageNo: 1,
  642. pageSize: 99999,
  643. goodTypes: ids
  644. }).then((res) => {
  645. if (res.success) {
  646. this.dataSource2 = res.result.records
  647. }
  648. })
  649. },
  650. handleDelete() {
  651. deleteAction('/pos/posSellClearGoods/delete', {
  652. goodsId: this.selectGoods.id
  653. })
  654. .then((res) => {
  655. if (res.success) {
  656. this.$message.success(res.message)
  657. this.loadData()
  658. this.sellClear = 0
  659. } else {
  660. this.$message.warning(res.message)
  661. }
  662. })
  663. .finally(() => {})
  664. },
  665. handleSelectCheckInRoomOrder() {
  666. this.$refs.modalSelectCheckInRoomOrderModal.add()
  667. this.$refs.modalSelectCheckInRoomOrderModal.title = '选择转帐人'
  668. this.$refs.modalSelectCheckInRoomOrderModal.disableSubmit = false
  669. },
  670. handlePickingGoodsOrder() {
  671. this.$refs.modalPickingGoodsOrderForm.add()
  672. this.$refs.modalPickingGoodsOrderForm.title = '取单'
  673. this.$refs.modalPickingGoodsOrderForm.disableSubmit = false
  674. },
  675. handleAddTempGoods() {
  676. this.$refs.modalGoodsForm.add()
  677. this.$refs.modalGoodsForm.title = '新增菜品'
  678. this.$refs.modalGoodsForm.disableSubmit = false
  679. },
  680. /**
  681. * 确认挂房账
  682. */
  683. handleToRoomFeePayment() {
  684. let param = Object.assign({ toRoomFeeOrderId: this.selectRoomOrder.livingOrderId }, this.getParam())
  685. postAction('/pos/posOrderGoods/addRoomFee', param).then(resp => {
  686. if (resp.result === true) {
  687. this.$message.success('挂账成功')
  688. this.modalFormOk()
  689. } else {
  690. this.$message.warning('挂账失败')
  691. }
  692. })
  693. },
  694. /** 结账 */
  695. handlePayment() {
  696. if (!this.selectGoodsList || this.selectGoodsList.length <= 0) {
  697. this.$message.warning('请先选择商品')
  698. return
  699. }
  700. if (this.posTableId === '') {
  701. this.handleAdd()
  702. this.settleAccounts(this.selectOrderInfo.code, this.getParam())
  703. } else {
  704. // 桌台结账时,订单在下单的时候就添加了,不用传参
  705. this.settleAccounts(this.selectOrderInfo.code, null)
  706. }
  707. },
  708. settleAccounts(orderCode, params) {
  709. console.log(orderCode)
  710. var amount = this.selectGoodsList.reduce(function (total, item) {
  711. return total + item.sellingPrice * item.num
  712. }, 0)
  713. console.log('2222222', params)
  714. this.$refs.modalPaymentForm.edit({
  715. billAmount: amount,
  716. deposit: 0,
  717. roomFee: amount,
  718. subjectType: 5,
  719. feeType: 2,
  720. preferentialType: 1,
  721. couponFirstAmount: 0,
  722. discount: 9,
  723. orderCode: orderCode,
  724. params: params
  725. })
  726. this.$refs.modalPaymentForm.title = 'POS结账'
  727. this.$refs.modalPaymentForm.disableSubmit = false
  728. },
  729. /**
  730. * 下单
  731. */
  732. placeOrder() {
  733. this.handleAdd()
  734. },
  735. pendingOrder() {
  736. this.selectOrderInfo.isPending = true
  737. this.handleAdd()
  738. this.clean()
  739. },
  740. handleAdd(callback) {
  741. if (!this.selectGoodsList || this.selectGoodsList.length <= 0) {
  742. this.$message.warning('请先选择商品')
  743. return
  744. }
  745. console.log(this.selectGoodsList)
  746. let param = this.getParam()
  747. postAction('/pos/posOrderGoods/add', param)
  748. .then((res) => {
  749. if (res.success) {
  750. this.oldSelectGoodsList = JSON.parse(JSON.stringify(this.selectGoodsList))
  751. this.selectOrderInfo = res.result
  752. this.loadGoods()
  753. if (this.posTableId !== '') {
  754. this.$emit('reTable')
  755. }
  756. if (callback) {
  757. callback(res.result.code)
  758. }
  759. } else {
  760. this.$message.warning(res.message)
  761. }
  762. })
  763. .finally(() => {})
  764. },
  765. getParam() {
  766. var _info = JSON.parse(localStorage.getItem('storeInfo'))
  767. var model = {
  768. goodsId: this.selectGoods.id,
  769. posTableId: this.posTableId,
  770. id: this.selectOrderInfo.id,
  771. posType: this.tabPosTypeId,
  772. isPending: this.selectOrderInfo.isPending
  773. }
  774. if (_info) {
  775. model.hotelId = _info.id
  776. }
  777. if (this.remark) {
  778. model.remarks = this.remark
  779. }
  780. var posOrderGoodsDetailList = []
  781. this.selectGoodsList.forEach((t) => {
  782. // 过滤掉订单中已经保存的商品
  783. if (t.detailId != null) {
  784. return
  785. }
  786. if (t.cesGoodsList == null) {
  787. posOrderGoodsDetailList.push({
  788. goodsId: t.goodsId,
  789. num: t.num,
  790. money: t.sellingPrice
  791. })
  792. } else {
  793. let childDetails = []
  794. t.cesGoodsList.forEach(goods => {
  795. childDetails.push({
  796. goodsId: goods.id,
  797. thaliId: t.goodsId,
  798. num: t.num * goods.thaliNum,
  799. money: 0
  800. })
  801. })
  802. posOrderGoodsDetailList.push({
  803. childDetails,
  804. id: t.id,
  805. thaliId: t.goodsId,
  806. num: t.num,
  807. money: t.sellingPrice
  808. })
  809. }
  810. })
  811. model.posOrderGoodsDetailList = posOrderGoodsDetailList
  812. return model
  813. },
  814. itemClick(row) {
  815. console.log(row)
  816. if (row.id == '0') {
  817. this.handleAddTempGoods()
  818. return
  819. }
  820. // if (row.isSellClear) {
  821. // this.$message.warning('选择的商品已沽清')
  822. // return
  823. // }
  824. if (row.inventory <= 0) {
  825. this.$message.warning('选择的商品已沽清')
  826. return
  827. }
  828. if (this.posTableId !== '' && this.posTableState !== 1) {
  829. this.posTableState = 1
  830. }
  831. var good = JSON.parse(JSON.stringify(row))
  832. this.$set(good, 'num', 1)
  833. // 如果选的是套餐,这个地方是套餐id
  834. this.$set(good, 'goodsId', good.id)
  835. delete good.id
  836. var find = this.selectGoodsList.find((t) => t.inventory != null && t.goodsId === row.id)
  837. if (find) {
  838. if (find.inventory > find.num) {
  839. find.num++
  840. }
  841. } else {
  842. this.selectGoodsList.push(good)
  843. }
  844. },
  845. itemClick2(row) {
  846. console.log(row)
  847. var good = JSON.parse(JSON.stringify(row))
  848. this.$set(good, 'num', 1)
  849. this.$set(good, 'goodsId', good.id)
  850. delete good.id
  851. var find = this.selectGoodsList.find((t) => t.goodsId === row.id)
  852. if (find) {
  853. find.num++
  854. } else {
  855. this.selectGoodsList.push(good)
  856. }
  857. },
  858. // 联台按钮
  859. unionStation(val,index) {
  860. if (val == '转菜' && (this.transferDishesList.length !== this.selectedRows.length)) {
  861. this.$message.error('勾选的商品中有未下单的商品,不能进行转菜操作')
  862. return
  863. }
  864. this.unionTitle = val
  865. this.unionOpen = true
  866. this.uniteDataSource = []
  867. this.loadRegion(index)
  868. },
  869. // 联台确认
  870. handleOk() {
  871. console.log(this.model.reserveTableList);
  872. if (this.unionTitle == '换台') {
  873. console.log(111);
  874. getAction(`/pos/posOrderGoods/change-table?posOrderId=${this.orderId}&tableId=${this.model.reserveTableList[0].id}`).then(res => {
  875. console.log(res);
  876. if (res.success) {
  877. this.$message.success('换台成功')
  878. }
  879. this.unionOpen = false
  880. })
  881. } else if (this.unionTitle == '转菜') {
  882. let tempList = []
  883. this.transferDishesList.forEach(index => {
  884. tempList.push(index.id)
  885. })
  886. postAction(`/pos/posOrderGoods/transfer-dishes?posOrderId=` + this.model.reserveTableList[0].posOrderGoods.id,tempList).then(res => {
  887. console.log(res);
  888. if (res.success) {
  889. this.$message.success('转菜成功')
  890. }
  891. // this.itemClick2()
  892. this.getOrderByTableId(this.tableId)
  893. this.loadGoods()
  894. this.unionOpen = false
  895. })
  896. } else {
  897. let tempdata = []
  898. this.model.reserveTableList.forEach(index => {
  899. tempdata.push(index.posOrderGoods.id)
  900. })
  901. postAction(`/pos/posOrderGoods/merge-order?mainPosOrderId=` + this.selectOrderInfo.id,tempdata).then(res => {
  902. console.log(res);
  903. if (res.success) {
  904. this.$message.success('联台成功')
  905. }
  906. this.unionOpen = false
  907. })
  908. }
  909. console.log(this.posTableId);
  910. },
  911. // 联台大厅tab切换
  912. tabRegionChange() {
  913. this.loadTables();
  914. },
  915. // 联台大厅tab获取
  916. loadRegion(index) {
  917. getAction("/pos/posRegion/list", {
  918. posTypeId: this.tabPosTypeId,
  919. }).then((res) => {
  920. console.log(res);
  921. if (res.success) {
  922. this.regionList = res.result.records;
  923. }
  924. });
  925. this.loadTables(index);
  926. },
  927. // 联台大厅数据获取
  928. loadTables(index) {
  929. var obj = {
  930. pageNo: 1,
  931. pageSize: 99999,
  932. posTypeId: this.tabPosTypeId,
  933. state: index,
  934. };
  935. if (this.tabPosRegionId != "1") {
  936. obj.posRegionId = this.tabPosRegionId;
  937. }
  938. // getAction("/pos/posTable/tableList", obj).then((res) => {
  939. // console.log(res);
  940. // if (res.success) {
  941. // this.uniteDataSource = res.result.records;
  942. // console.log(this.uniteDataSource);
  943. // }
  944. // });
  945. getAction("/pos/posTable/getCanUseTable", obj).then((res) => {
  946. console.log(res);
  947. if (res.success) {
  948. this.uniteDataSource = res.result.records;
  949. console.log(this.uniteDataSource);
  950. }
  951. });
  952. },
  953. // 联台点击
  954. orderMeal(item) {
  955. console.log(this.unionTitle);
  956. if (this.unionTitle == '换台' || this.unionTitle == '转菜') {
  957. this.model.reserveTableList = []
  958. if (this.model.reserveTableList.some((t) => t.id == item.id)) {
  959. this.model.reserveTableList = this.model.reserveTableList.filter(
  960. (t) => t.id != item.id
  961. );
  962. } else {
  963. this.model.reserveTableList = [item];
  964. }
  965. } else {
  966. if (this.model.reserveTableList.some((t) => t.id == item.id)) {
  967. this.model.reserveTableList = this.model.reserveTableList.filter(
  968. (t) => t.id != item.id
  969. );
  970. } else {
  971. this.model.reserveTableList.push(item);
  972. }
  973. }
  974. console.log(this.model.reserveTableList);
  975. },
  976. // 取消联台
  977. unlink() {
  978. getAction(`/pos/posOrderGoods/return-merge-order?posOrderId=${this.orderId}`).then((res) => {
  979. if (res.success) {
  980. this.$message.success('取消联台成功')
  981. }
  982. this.unionOpen = false
  983. });
  984. }
  985. }
  986. }
  987. </script>
  988. <style scoped>
  989. @import "~@assets/less/common.less";
  990. .room-item {
  991. height: 110px;
  992. /* line-height: 200px; */
  993. font-size: 13px;
  994. padding: 0px 5px;
  995. border-radius: 5px;
  996. cursor: pointer;
  997. position: relative;
  998. display: flex;
  999. flex-direction: column;
  1000. justify-content: center;
  1001. }
  1002. .check {
  1003. border: #000 solid 3px;
  1004. }
  1005. .ant-table-wrapper {
  1006. height: calc(100vh - 500px);
  1007. }
  1008. /deep/ .card-pd .ant-card-body {
  1009. padding: 0 !important;
  1010. }
  1011. .select-cell {
  1012. position: absolute;
  1013. width: 100%;
  1014. height: 100%;
  1015. left: 0;
  1016. top: 0;
  1017. z-index: 10;
  1018. -webkit-user-select: none;
  1019. -moz-user-select: none;
  1020. -ms-user-select: none;
  1021. user-select: none;
  1022. }
  1023. .to_be_ordered_style {
  1024. border: 2px solid #000;
  1025. color: #fff;
  1026. }
  1027. /* .to_be_ordered_style {
  1028. background-color: #00a0e9;
  1029. border: 2px solid #000;
  1030. color: #fff;
  1031. }
  1032. .wait_for_account_style{
  1033. border: 2px solid #000;
  1034. background-color: #0a7a72;
  1035. color: #fff;
  1036. } */
  1037. .active {
  1038. border: #ff5500 2px solid !important;
  1039. }
  1040. </style>