StrikeBalanceModel.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  1. <template>
  2. <j-modal
  3. :title="title"
  4. :width="width"
  5. :visible="visible"
  6. switchFullscreen
  7. @ok="handleOk"
  8. :okButtonProps="{ class: { 'jee-hidden': disableSubmit } }"
  9. @cancel="handleCancel"
  10. cancelText="关闭"
  11. >
  12. <a-radio-group v-model="tebdata" style="margin-bottom: 16px">
  13. <a-radio-button value="small">金额冲账</a-radio-button>
  14. <a-radio-button value="default">商品冲账</a-radio-button>
  15. </a-radio-group>
  16. <a-table
  17. v-if="tebdata == 'small'"
  18. :columns="columns"
  19. :data-source="feesList"
  20. :pagination="false"
  21. :scroll="{ y: 160 }"
  22. rowKey="id">
  23. <template slot="subjectType" slot-scope="text, record">
  24. {{ getSubjectTypeText(text, record) }}
  25. </template>
  26. <template slot="money" slot-scope="text, record">
  27. <a-input-number v-model=record.money @blur="handleBlur()" :min="0"></a-input-number>
  28. </template>
  29. <template slot="remark" slot-scope="text, record">
  30. <a-textarea v-model=record.remark></a-textarea>
  31. </template>
  32. </a-table>
  33. <a-table
  34. v-if="tebdata == 'default'"
  35. :columns="columnstwo"
  36. :data-source="productList"
  37. :pagination="false"
  38. :scroll="{ y: 160 }"
  39. rowKey="id">
  40. <template slot="subjectType" slot-scope="text, record">
  41. {{ getSubjectTypeText(text, record) }}
  42. </template>
  43. <template slot="money" slot-scope="text, record">
  44. <!-- <a-input-number v-model=record.money @blur="handleBlur()" :min="0"></a-input-number> -->
  45. {{ record.money }}
  46. </template>
  47. <template slot="num" slot-scope="text, record">
  48. <a-input-number v-model='record.num' :min="1" :max="record.feeGoodVo.num"></a-input-number>
  49. <!-- {{ record.money }} -->
  50. </template>
  51. <template slot="remark" slot-scope="text, record">
  52. <a-textarea v-model=record.remark></a-textarea>
  53. </template>
  54. </a-table>
  55. </j-modal>
  56. </template>
  57. <script>
  58. import { postAction } from '@api/manage'
  59. const columns = [
  60. {
  61. title: '房间',
  62. dataIndex: 'roomName',
  63. width: 30,
  64. align: 'center'
  65. },
  66. {
  67. title: '费项',
  68. dataIndex: 'subjectType',
  69. width: 60,
  70. align: 'center',
  71. scopedSlots: { customRender: 'subjectType' }
  72. },
  73. {
  74. title: '日期',
  75. dataIndex: 'dayTime',
  76. width: 100,
  77. align: 'center'
  78. },
  79. {
  80. title: '金额',
  81. dataIndex: 'oldPrice',
  82. width: 60,
  83. align: 'center'
  84. },
  85. {
  86. title: '冲账金额',
  87. dataIndex: 'money',
  88. width: 60,
  89. align: 'center',
  90. scopedSlots: { customRender: 'money'}
  91. },
  92. {
  93. title: '备注',
  94. dataIndex: 'remark',
  95. width: 60,
  96. align: 'center',
  97. scopedSlots: { customRender: 'remark'}
  98. },
  99. ]
  100. const columnstwo = [
  101. {
  102. title: '房间',
  103. dataIndex: 'roomName',
  104. width: 30,
  105. align: 'center'
  106. },
  107. {
  108. title: '费项',
  109. dataIndex: 'subjectType',
  110. width: 60,
  111. align: 'center',
  112. scopedSlots: { customRender: 'subjectType' }
  113. },
  114. {
  115. title: '日期',
  116. dataIndex: 'dayTime',
  117. width: 100,
  118. align: 'center'
  119. },
  120. {
  121. title: '金额',
  122. dataIndex: 'oldPrice',
  123. width: 60,
  124. align: 'center'
  125. },
  126. {
  127. title: '数量',
  128. // dataIndex: 'oldPrice',
  129. width: 60,
  130. align: 'center',
  131. customRender: function (text, record) {
  132. return record.feeGoodVo.num
  133. }
  134. },
  135. {
  136. title: '冲账数量',
  137. dataIndex: 'num',
  138. width: 60,
  139. align: 'center',
  140. scopedSlots: { customRender: 'num'},
  141. customRender: function (text, record) {
  142. return record.feeGoodVo.num
  143. }
  144. },
  145. {
  146. title: '冲账金额',
  147. dataIndex: 'money',
  148. width: 60,
  149. align: 'center',
  150. scopedSlots: { customRender: 'money'}
  151. },
  152. {
  153. title: '备注',
  154. dataIndex: 'remark',
  155. width: 60,
  156. align: 'center',
  157. scopedSlots: { customRender: 'remark'}
  158. },
  159. ]
  160. export default {
  161. name: 'StrikeBalanceModel',
  162. components: {
  163. },
  164. data() {
  165. return {
  166. title: '',
  167. width: 800,
  168. visible: false,
  169. disableSubmit: false,
  170. showYinshou: true,
  171. columns: columns,
  172. columnstwo: columnstwo,
  173. feesList: [],
  174. tebdata: 'small',
  175. // 商品
  176. productList:[]
  177. }
  178. },
  179. methods: {
  180. edit(record, map) {
  181. this.visible = true
  182. console.log(record)
  183. record.forEach(index => {
  184. if (index.feeGoodVo == null) {
  185. this.feesList.push(index)
  186. } else if (index.feeGoodVo !== null) [
  187. this.productList.push(index)
  188. ]
  189. })
  190. console.log(this.feesList);
  191. console.log(this.productList);
  192. // this.feesList = record
  193. this.feesList.forEach(e => {
  194. e.roomName = map.get(e.roomId)
  195. e.oldPrice = e.money
  196. })
  197. this.productList.forEach(e => {
  198. e.roomName = map.get(e.roomId)
  199. e.oldPrice = e.money
  200. })
  201. },
  202. close() {
  203. this.$emit('close')
  204. this.visible = false
  205. },
  206. handleOk() {
  207. // console.log(111);
  208. let fees = []
  209. if (this.feesList.some(e => e.money > e.oldPrice || e.money < 0)) {
  210. this.$message.warning('冲账金额不能超过原金额,且不能小于0')
  211. return
  212. } else {
  213. this.feesList.forEach(e => {
  214. // 一条消费可能有多次冲账,所以传入后端的money是冲账的负数差值
  215. if (e.oldPrice - e.money > 0) {
  216. let param = Object.assign({}, e)
  217. param.money = -param.money
  218. // param.money = param.money - param.oldPrice
  219. fees.push(param)
  220. }
  221. })
  222. }
  223. if (fees.length === 0) {
  224. return
  225. }
  226. console.log(fees);
  227. postAction('/business/busOrderFee/strike-balance', fees).then(resp => {
  228. if (resp.result === true) {
  229. this.$message.success('冲账成功')
  230. this.$emit('ok')
  231. this.visible = false
  232. } else {
  233. this.$message.warning('冲账失败')
  234. }
  235. });
  236. },
  237. handleCancel() {
  238. this.close()
  239. },
  240. getSubjectTypeText(text, record) {
  241. var msg = ''
  242. if (text === 1) {
  243. msg = '押金'
  244. } else if (text === 2) {
  245. msg = '预收房费'
  246. } else if (text === 3) {
  247. msg = '每日房费'
  248. } else if (text === 4) {
  249. msg = '优惠金额'
  250. } else if (text === 5) {
  251. msg = '结账收款'
  252. } else if (text === 6) {
  253. msg = '商品-' + record.feeGoodVo.name
  254. } else if (text === 7) {
  255. msg = '点餐'
  256. } else if (text === 8) {
  257. msg = '夜审房费'
  258. } else if (text === 9) {
  259. msg = '会议室'
  260. } else if (text === 10) {
  261. msg = '手工房费'
  262. } else if (text === 11) {
  263. msg = '水电煤抄表'
  264. } else if (text === 12) {
  265. msg = '赔偿费'
  266. } else if (text === 13) {
  267. msg = '退单结账'
  268. }
  269. return msg
  270. },
  271. handleBlur() {
  272. this.$forceUpdate()
  273. }
  274. }
  275. }
  276. </script>