index.vue 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728
  1. <template>
  2. <view style="background-color: #f2f2f6;padding-top: 1rpx;">
  3. <u-navbar title="销售" bgColor="#FD4B09" :autoBack="true" :placeholder="true" leftIconColor="#fff"
  4. :titleStyle="{color: '#fff'}">
  5. <view slot="right">
  6. <u-icon name="clock" size="40rpx" color="#fff" @click="historical0rders()"></u-icon>
  7. </view>
  8. </u-navbar>
  9. <view style="padding: 0 10rpx;width:96%;border-radius:10rpx;margin: 20rpx auto;background-color: #fff;">
  10. <u-cell-group :border="false">
  11. <u-cell icon="account" :iconStyle="{color: '#FD4B09'}" title="客户" :value="form.corpName" :isLink="true"
  12. @click="selectCustomer">
  13. </u-cell>
  14. <u-cell icon="home" :iconStyle="{color: '#FD4B09'}" title="业务员" :value="form.sales" :isLink="true"
  15. @click="filterAll(['sales','salesName'])">
  16. </u-cell>
  17. <u-cell icon="calendar" :iconStyle="{color: '#FD4B09'}" title="日期"
  18. :value="form.businesDate?form.businesDate.slice(0,10):''" :isLink="true" @click="show = true">
  19. </u-cell>
  20. <u-cell icon="home" :iconStyle="{color: '#FD4B09'}" title="发货仓库" :value="form.storageName"
  21. :isLink="true" @click="filterAll(['storageName','storageId'])">
  22. </u-cell>
  23. </u-cell-group>
  24. </view>
  25. <view
  26. style="padding: 0 10rpx;width:96%;border-radius:10rpx;margin: 20rpx auto;background-color: #fff;padding-top: 10rpx;">
  27. <u-cell-group :border="false">
  28. <u-cell icon="list-dot" :iconStyle="{color: '#FD4B09'}"
  29. :title="'产品列表('+dataList.length+') '+' 数量'+ numberAll" value="添加产品">
  30. <view slot="value" class="u-slot-value">
  31. <u-button type="primary" text="添加产品" shape="circle" size="small" color="#FD4B09" @click="selectProduct()"></u-button>
  32. </view>
  33. </u-cell>
  34. <u-cell v-for="(item,index) in dataList" :key="index">
  35. <view slot="label">
  36. <!-- customStyle="margin-bottom: 10px" -->
  37. <u-row>
  38. <u-col span="2.9">
  39. <u--image :showLoading="true" :src="item.url?item.url:'../../../static/images/404.png'"
  40. width="80px" height="80px" radius="10">
  41. </u--image>
  42. </u-col>
  43. <u-col span="9.1">
  44. <view
  45. style="font-size: 36rpx;width: 530rpx;overflow: hidden;white-space: nowrap;text-overflow: ellipsis;">
  46. {{item.cname}}
  47. </view>
  48. <view style="display: flex;justify-content: space-between;">
  49. <view style="color: #707070;">单价:¥{{item.price}}</view>
  50. <view style="color: #707070;">数量:{{item.storageInQuantity}}</view>
  51. </view>
  52. <view style="display: flex;justify-content: space-between;">
  53. <view style="color: #707070;">金额:¥{{item.amount}}</view>
  54. <view style="color: #707070; color: red;" @click="deleteProduct(index)">
  55. <u-button type="error" size="mini" text="删除"></u-button>
  56. </view>
  57. </view>
  58. </u-col>
  59. </u-row>
  60. </view>
  61. </u-cell>
  62. </u-cell-group>
  63. </view>
  64. <view style="width: 100%;height: 110rpx;"></view>
  65. <view class="submitBar">
  66. <view style="width: 100%;position: fixed;bottom: 0;background-color: #fff;border-top: 1rpx solid #ccc;">
  67. <view style="width: 100%;display: flex;font-size: 24rpx;justify-content: space-between;">
  68. <view style="width: 50%;display: flex;">
  69. <view style="margin-top: 10rpx;">
  70. <u-icon name="shopping-cart" color="#FD4B09" size="50"></u-icon>
  71. </view>
  72. <view style="margin-top: 40rpx;color: #000;">
  73. 金额:<text style="color: red;">¥{{amount}}</text>
  74. </view>
  75. </view>
  76. <view @click="billingCollection"
  77. style="width: 25%;background-color: #5ac725;display: grid;justify-items: center;">
  78. <u-icon name="rmb" color="#fff"></u-icon>
  79. <view style="color: #fff;">开单并收款</view>
  80. </view>
  81. <view @click="saveOrder"
  82. style="width: 25%;background-color: #fd4b09;display: grid;justify-items: center;">
  83. <u-icon name="checkmark" color="#fff"></u-icon>
  84. <view style="color: #fff;">确认开单</view>
  85. </view>
  86. </view>
  87. </view>
  88. </view>
  89. <u-popup zIndex="10070" :closeOnClickOverlay="false" :show="openPopup" @close="openPopup = false,mask = false,uni.navigateBack()"
  90. mode="center" closeable round="10rpx">
  91. <u--form labelPosition="left" :labelStyle="{color: '#fd4b09'}" :model="formTwo" ref="formTwo"
  92. labelWidth="150rpx">
  93. <view style="width: calc(700rpx - 20px);margin: 10px;">
  94. <text>收款台</text>
  95. <view>
  96. <!-- <u-form-item label="订单金额" prop="cname" borderBottom>
  97. <u-input type="number" v-model="formTwo.purchaseAmount" border="none" inputAlign="right" placeholder="请输入"
  98. disabled disabledColor="#ffffff" />
  99. </u-form-item> -->
  100. <!-- <u-form-item label="优惠金额" prop="cname" borderBottom>
  101. <u-input type="number" v-model="formTwo.thisUsedProfit" border="none" inputAlign="right" placeholder="请输入" disabledColor="#ffffff" @blur="discount(0)"/>
  102. </u-form-item> -->
  103. <u-form-item label="订单金额" prop="cname" borderBottom>
  104. <u-input type="number" v-model="formTwo.orderAmount" border="none" inputAlign="right" placeholder="请输入"
  105. disabled disabledColor="#ffffff" />
  106. </u-form-item>
  107. <u-form-item label="优惠金额" prop="cname" borderBottom>
  108. <u-input type="number" v-model="formTwo.thisUsedProfit"
  109. border="none" inputAlign="right" placeholder="请输入" disabledColor="#ffffff"
  110. @blur="thisUsedProfitchange"/>
  111. <!-- @blur="discount(0)" 之前的失焦事件具体干啥的我也不知道,因为他没有写注释 -->
  112. </u-form-item>
  113. <u-form-item label="应收金额" prop="cname" borderBottom>
  114. <u-input type="number" v-model="formTwo.debitAmount" border="none" inputAlign="right"
  115. placeholder="请输入" disabled disabledColor="#ffffff" />
  116. </u-form-item>
  117. <u-form-item label="已收金额" prop="cname" borderBottom>
  118. <u-input type="number" v-model="formTwo.settlmentAmount" border="none" inputAlign="right"
  119. placeholder="请输入" disabled disabledColor="#ffffff" />
  120. </u-form-item>
  121. <u-form-item label="溢付款" prop="cname" borderBottom>
  122. <u-input type="number" v-model="formTwo.overPayment" border="none" inputAlign="right"
  123. disabled disabledColor="#ffffff" />
  124. </u-form-item>
  125. <u-form-item label="会员卡金额" prop="cname" borderBottom labelWidth="190rpx" >
  126. <u-input type="digit" v-model="formTwo.memberAmout" border="none" inputAlign="right"
  127. disabledColor="#ffffff" @blur="memberBalancechange" >
  128. <template slot="suffix">
  129. <text style="margin-left: 10rpx; border-left: 1rpx solid #000;padding-left: 10rpx;">余额:{{balanceAmount}}</text>
  130. </template>
  131. </u-input>
  132. </u-form-item>
  133. <u-form-item label="本次收款" prop="cname" borderBottom>
  134. <u-input type="number" clearable v-model="formTwo.currentAmount" border="none"
  135. inputAlign="right" placeholder="请输入" disabledColor="#ffffff" @blur="discount(1)" />
  136. </u-form-item>
  137. <u-form-item label="收款日期" labelWidth="190rpx" prop="cname" borderBottom
  138. @click="filterAll(['advanceCollectionDate','advanceCollectionDate'])">
  139. <view style="width: 100%;text-align: right;">
  140. {{formTwo.advanceCollectionDate?formTwo.advanceCollectionDate.slice(0,10):''}}
  141. </view>
  142. </u-form-item>
  143. <u-form-item label="收款账户" prop="cname" borderBottom @click="filterAll(['account','account'])">
  144. <u-input v-model="formTwo.account" border="none" inputAlign="right" placeholder="请选择"
  145. disabled disabledColor="#ffffff">
  146. <template slot="suffix" style="text-align: center;">
  147. <u-icon name="plus-circle" size="18" @click.native.stop="newCompany()"></u-icon>
  148. </template>
  149. </u-input>
  150. </u-form-item>
  151. <view style="display: flex;margin-top: 20rpx;">
  152. <u-button text="取消" style="width: 45%;"
  153. @click="quxiaofun"></u-button>
  154. <u-button type="primary" text="收款" color="#FD4B09" style="width: 45%;"
  155. @click="collectionConfirm"></u-button>
  156. </view>
  157. </view>
  158. </view>
  159. </u--form>
  160. </u-popup>
  161. <u-datetime-picker :show="show" v-model="timeValue" mode="date" @confirm="confirm" @cancel="show = false">
  162. </u-datetime-picker>
  163. <u-datetime-picker :show="timeOpen" v-model="datetime" mode="date" @cancel="timeOpen = false,mask = false"
  164. @confirm="confirmTiem"></u-datetime-picker>
  165. <u-picker :show="showWarehouse" :columns="columns" :keyName="keyName" @confirm="confirmWarehouse"
  166. @cancel="showWarehouse = false"></u-picker>
  167. <u-notify ref="uNotify"></u-notify>
  168. </view>
  169. </template>
  170. <script>
  171. import {
  172. customerList,
  173. quickBilling,
  174. typeSave,
  175. gainUser
  176. } from '@/api/views/sale/index.js'
  177. import {
  178. collectPayment,getCorpDesc
  179. } from '@/api/views/sale/salesOrderDetails.js'
  180. import {
  181. dateFormat
  182. } from '@/common/dateFormat'
  183. export default {
  184. data() {
  185. return {
  186. show: false,
  187. timeOpen: false,
  188. openPopup: false,
  189. showWarehouse: false,
  190. timeValue: Number(new Date()),
  191. datetime: Number(new Date()),
  192. columns: [],
  193. dataList: [],
  194. amount: 0.00,
  195. numberAll: 0,
  196. screen: [],
  197. keyName: '',
  198. form: {
  199. corpId: '',
  200. corpName: '',
  201. customer: '',
  202. businesDate: '',
  203. storageName: '',
  204. total: 0
  205. },
  206. formTwo: {
  207. },
  208. revenueTop: 0,
  209. // 会员卡余额
  210. balanceAmount:0
  211. }
  212. },
  213. onLoad() {
  214. uni.getSystemInfo({
  215. success: (e) => {
  216. this.revenueTop = e.statusBarHeight + 44
  217. }
  218. })
  219. },
  220. created() {
  221. this.form.businesDate = new Date((new Date()).getTime() + 8 * 60 * 60 * 1000).toJSON().split('T').join(' ').substr(0, 19);
  222. this.form.salesName = uni.getStorageSync('userInfo').user_id
  223. this.form.sales = uni.getStorageSync('userInfo').user_name
  224. customerList({
  225. size: 1,
  226. current: 1
  227. }).then(res => {
  228. if(res.data.records.length > 0){
  229. this.form.storageName = res.data.records[0].cname
  230. this.form.storageId = res.data.records[0].id
  231. }
  232. })
  233. },
  234. methods: {
  235. // 优惠金额的监听
  236. thisUsedProfitchange(value){
  237. // let data = {
  238. // // 订单金额
  239. // orderAmount: this.formTwo.orderAmount ? Number(this.formTwo.orderAmount) : 0,
  240. // // 优惠金额
  241. // thisUsedProfit:this.formTwo.thisUsedProfit ? Number(this.formTwo.thisUsedProfit) : 0,
  242. // // 已收金额
  243. // settlmentAmount:this.formTwo.settlmentAmount ? Number(this.formTwo.settlmentAmount) : 0,
  244. // // 会员卡金额
  245. // memberAmout: this.formTwo.memberAmout ? Number(this.formTwo.memberAmout) : 0
  246. // }
  247. // let curr = (data.orderAmount - data.thisUsedProfit - data.settlmentAmount).toFixed(2)
  248. // if (curr <= Number(this.balanceAmount)) {
  249. // this.formTwo.memberAmout = curr
  250. // this.formTwo.currentAmount = 0
  251. // }else {
  252. // this.formTwo.memberAmout = Number(this.balanceAmount)
  253. // this.formTwo.currentAmount = (data.orderAmount - data.thisUsedProfit - data.settlmentAmount - data.memberAmout).toFixed(2)
  254. // }
  255. // 订单金额
  256. this.formTwo.orderAmount = this.formTwo.orderAmount ? Number(this.formTwo.orderAmount) : 0
  257. // 优惠金额
  258. this.formTwo.thisUsedProfit = this.formTwo.thisUsedProfit ? Number(this.formTwo.thisUsedProfit) : 0
  259. // 已收金额
  260. this.formTwo.settlmentAmount = this.formTwo.settlmentAmount ? Number(this.formTwo.settlmentAmount) : 0
  261. // 应收金额
  262. this.formTwo.debitAmount = this.formTwo.debitAmount?Number(this.formTwo.debitAmount):0
  263. // 会员卡金额
  264. this.formTwo.memberAmout = this.formTwo.memberAmout ? Number(this.formTwo.memberAmout) : 0
  265. if (this.formTwo.thisUsedProfit < 0) {
  266. this.$refs.uToast.show({
  267. type: 'error',
  268. icon: false,
  269. message: "优惠金额不能小于零",
  270. })
  271. this.formTwo.thisUsedProfit = 0
  272. }
  273. if (this.formTwo.thisUsedProfit > this.formTwo.orderAmount) {
  274. this.$refs.uToast.show({
  275. type: 'error',
  276. icon: false,
  277. message: "优惠金额不能大于订单金额",
  278. })
  279. this.formTwo.thisUsedProfit = 0
  280. }
  281. // this.formTwo.currentAmount =
  282. this.formTwo.debitAmount = this.formTwo.orderAmount - this.formTwo.thisUsedProfit
  283. },
  284. // 会员卡收款监听事件
  285. memberBalancechange(value){
  286. // let data = {
  287. // // 订单金额
  288. // orderAmount: this.formTwo.orderAmount ? Number(this.formTwo.orderAmount) : 0,
  289. // // 优惠金额
  290. // thisUsedProfit:this.formTwo.thisUsedProfit ? Number(this.formTwo.thisUsedProfit) : 0,
  291. // // 已收金额
  292. // settlmentAmount:this.formTwo.settlmentAmount ? Number(this.formTwo.settlmentAmount) : 0,
  293. // // 会员卡金额
  294. // memberAmout: this.formTwo.memberAmout ? Number(this.formTwo.memberAmout) : 0
  295. // }
  296. // if (Number(this.formTwo.memberAmout) < 0) {
  297. // this.formTwo.memberAmout = 0
  298. // data.memberAmout = 0
  299. // }
  300. // const curr = (data.orderAmount - data.thisUsedProfit - data.settlmentAmount).toFixed(2)
  301. // if (Number(this.formTwo.memberAmout) > curr) {
  302. // this.formTwo.memberAmout = curr
  303. // data.memberAmout = curr
  304. // }
  305. // this.formTwo.currentAmount = (data.orderAmount - data.thisUsedProfit - data.settlmentAmount - data.memberAmout).toFixed(2)
  306. // 订单金额
  307. this.formTwo.orderAmount = this.formTwo.orderAmount ? Number(this.formTwo.orderAmount) : 0
  308. // 优惠金额
  309. this.formTwo.thisUsedProfit = this.formTwo.thisUsedProfit ? Number(this.formTwo.thisUsedProfit) : 0
  310. // 已收金额
  311. this.formTwo.settlmentAmount = this.formTwo.settlmentAmount ? Number(this.formTwo.settlmentAmount) : 0
  312. // 应收金额
  313. this.formTwo.debitAmount = this.formTwo.debitAmount?Number(this.formTwo.debitAmount):0
  314. // 会员卡金额
  315. this.formTwo.memberAmout = this.formTwo.memberAmout ? Number(this.formTwo.memberAmout) : 0
  316. if (this.formTwo.memberAmout < 0) {
  317. this.$delete(this.formTwo, 'memberAmout')
  318. this.$set(this.formTwo, 'memberAmout', 0)
  319. this.$refs.uToast.show({
  320. type: 'error',
  321. icon: false,
  322. message: "会员卡金额不能小于零",
  323. })
  324. // this.formTwo.memberAmout = 0
  325. }
  326. if (this.formTwo.memberAmout >= this.balanceAmount) {
  327. this.$delete(this.formTwo, 'memberAmout')
  328. this.$set(this.formTwo, 'memberAmout', this.balanceAmount)
  329. // this.formTwo.memberAmout = this.balanceAmount
  330. this.formTwo.currentAmount = 0
  331. this.$refs.uToast.show({
  332. type: 'error',
  333. icon: false,
  334. message: "会员卡金额不能大于余额",
  335. })
  336. }
  337. const curr = this.formTwo.debitAmount - this.formTwo.settlmentAmount
  338. if (this.formTwo.memberAmout > curr) {
  339. // this.formTwo.memberAmout = curr
  340. this.$delete(this.formTwo, 'memberAmout')
  341. this.$set(this.formTwo, 'memberAmout', curr)
  342. }
  343. this.formTwo.currentAmount = this.formTwo.debitAmount - this.formTwo.settlmentAmount - this.formTwo.memberAmout
  344. },
  345. newCompany() {
  346. uni.$u.route('/pages/views/product/createCompany', {
  347. code: "account",
  348. title: "收款账户"
  349. });
  350. },
  351. //时间确认选择
  352. confirmTiem(e) {
  353. this.formTwo[this.screen[1]] = dateFormat(new Date(e.value), "YYYY-MM-DD HH:mm:ss")
  354. this.timeOpen = false
  355. this.mask = false
  356. },
  357. // 开单弹窗取消
  358. quxiaofun(){
  359. this.openPopup = false,
  360. this.mask = false,
  361. uni.navigateBack()
  362. },
  363. // 收款
  364. collectionConfirm() {
  365. // if (!this.formTwo.thisUsedProfit) {
  366. // return uni.showToast({
  367. // icon: "none",
  368. // title: '优惠金额不能为空',
  369. // mask: true
  370. // });
  371. // }
  372. if (!this.formTwo.orderAmount) {
  373. return uni.showToast({
  374. icon: "none",
  375. title: '合同金额不能为空',
  376. mask: true
  377. });
  378. }
  379. // 判断本次收款和会员卡收款不能为空
  380. if (!this.formTwo.currentAmount || this.formTwo.currentAmount == 0) {
  381. if (!this.formTwo.memberAmout || this.formTwo.memberAmout == 0) {
  382. return uni.showToast({
  383. icon: "none",
  384. title: '本次收款金额或会员卡金额不能为空或零',
  385. mask: true
  386. });
  387. }
  388. }
  389. if (!this.formTwo.account) {
  390. return uni.showToast({
  391. icon: "none",
  392. title: '收款帐户不能为空',
  393. mask: true
  394. });
  395. }
  396. let this_ = this
  397. uni.showModal({
  398. title: '是否确认收款',
  399. content: '本次收款金额' + this_.formTwo.currentAmount + '会员卡收款金额' + this_.formTwo.memberAmout,
  400. success: function(rest) {
  401. if (rest.confirm == true) {
  402. uni.showLoading({
  403. title: '加载中',
  404. mask: true
  405. });
  406. collectPayment(this_.formTwo).then(res => {
  407. uni.showToast({
  408. icon: "none",
  409. title: '收款成功',
  410. mask: true,
  411. duration: 2000
  412. });
  413. this.openPopup = false
  414. setTimeout(function() {
  415. uni.hideLoading();
  416. uni.navigateBack();
  417. }, 2000);
  418. })
  419. }
  420. }
  421. })
  422. },
  423. //集合筛选条件
  424. filterAll(screen) {
  425. this.screen = screen
  426. switch (screen[1]) {
  427. case "account":
  428. this.$u.api.getWorkDicts('account').then(res => {
  429. this.columns = [res.data]
  430. this.keyName = "dictValue"
  431. this.showWarehouse = true
  432. })
  433. break;
  434. case "advanceCollectionDate":
  435. this.timeOpen = true
  436. this.mask = true
  437. break;
  438. case "storageId":
  439. customerList({
  440. size: 1,
  441. current: 1
  442. }).then(request => {
  443. customerList({
  444. size: request.data.total,
  445. current: 1
  446. }).then(res => {
  447. this.columns = [res.data.records]
  448. this.keyName = 'cname'
  449. this.showWarehouse = true
  450. })
  451. })
  452. break;
  453. case "salesName":
  454. gainUser({
  455. roleName:'业务员'
  456. }).then(res => {
  457. this.columns = [res.data]
  458. this.keyName = 'name'
  459. this.showWarehouse = true
  460. })
  461. break;
  462. }
  463. },
  464. discount(type) {
  465. if (type == 0) {
  466. if (this.formTwo.thisUsedProfit < 0) {
  467. return this.formTwo.thisUsedProfit = null
  468. }
  469. this.formTwo.orderAmount = (this.formTwo.costAmount - this.formTwo.thisUsedProfit).toFixed(2)
  470. this.formTwo.currentAmount = this.formTwo.orderAmount
  471. if (this.formTwo.orderAmount < 0) {
  472. this.$set(this.formTwo, "orderAmount", null)
  473. this.$set(this.formTwo, "thisUsedProfit", null)
  474. uni.showToast({
  475. icon: "none",
  476. title: '优惠金额不能大于订单金额',
  477. mask: true
  478. });
  479. }
  480. if ((this.formTwo.currentAmount - this.formTwo.orderAmount) > 0) {
  481. this.formTwo.overPayment = (this.formTwo.currentAmount - this.formTwo.orderAmount).toFixed(2)
  482. } else {
  483. this.formTwo.overPayment = '0.00'
  484. }
  485. } else if (type == 1) {
  486. // 已收金额
  487. this.formTwo.settlmentAmount = this.formTwo.settlmentAmount ? Number(this.formTwo.settlmentAmount) : 0
  488. // 应收金额
  489. this.formTwo.debitAmount = this.formTwo.debitAmount?Number(this.formTwo.debitAmount):0
  490. this.formTwo.memberAmout = this.formTwo.memberAmout?Number(this.formTwo.memberAmout):0
  491. this.formTwo.currentAmount = this.formTwo.currentAmount?Number(this.formTwo.currentAmount):0
  492. console.log((this.formTwo.debitAmount - this.formTwo.settlmentAmount - this.formTwo.memberAmout),353);
  493. if (this.formTwo.currentAmount > (this.formTwo.debitAmount - this.formTwo.settlmentAmount - this.formTwo.memberAmout)) {
  494. this.$refs.uToast.show({
  495. type: 'error',
  496. icon: false,
  497. message: "收款和会员卡金额不能大于应收金额",
  498. })
  499. this.formTwo.currentAmount = 0
  500. }
  501. if (this.formTwo.currentAmount < 0) {
  502. return this.formTwo.currentAmount = 0
  503. }
  504. // if (this.formTwo.currentAmount < 0) {
  505. // return this.formTwo.currentAmount = null
  506. // }
  507. // if ((this.formTwo.currentAmount - this.formTwo.orderAmount) > 0) {
  508. // this.formTwo.overPayment = (this.formTwo.currentAmount - this.formTwo.orderAmount).toFixed(2)
  509. // } else {
  510. // this.formTwo.overPayment = '0.00'
  511. // }
  512. }
  513. },
  514. deleteProduct(index) {
  515. this.amount = Number(this.amount) - Number(this.dataList[index].amount)
  516. this.amount.toFixed(2)
  517. this.dataList.splice(index, 1)
  518. this.numberAll = 0
  519. for (let item of this.dataList) {
  520. this.numberAll += Number(item.storageInQuantity)
  521. }
  522. },
  523. //客户选择返回触发
  524. otherFun(customer) {
  525. this.form.corpName = customer.cname
  526. this.form.corpId = customer.id
  527. this.form.belongToCorpId = customer.belongtocompany
  528. },
  529. //商品选择返回
  530. getProduct(dataList) {
  531. this.amount = Number(this.amount)
  532. for (let item of dataList) {
  533. this.dataList.push(item)
  534. this.amount += Number(item.amount)
  535. this.numberAll += Number(item.storageInQuantity)
  536. }
  537. this.amount = this.amount.toFixed(2)
  538. },
  539. selectCustomer() {
  540. this.$u.route('/pages/views/salesSlip/selectCustomer', {
  541. corpType: 'KH'
  542. });
  543. },
  544. historical0rders() {
  545. this.$u.route('/pages/views/salesSlip/salesOrderList');
  546. },
  547. selectProduct() {
  548. if (!this.form.corpId) return this.$refs.uNotify.show({
  549. top: this.revenueTop,
  550. type: 'warning',
  551. message: '请选择客户!'
  552. })
  553. console.log(this.form.corpId,554);
  554. if (this.form.storageId) {
  555. this.$u.route('/pages/views/salesSlip/selectProduct', {
  556. form: JSON.stringify(this.form),
  557. data: JSON.stringify(this.dataList),
  558. corpId:this.form.corpId
  559. });
  560. } else {
  561. this.$refs.uNotify.show({
  562. top: this.revenueTop,
  563. type: 'warning',
  564. message: '请选择发货仓库!'
  565. })
  566. }
  567. },
  568. confirm(e) {
  569. this.show = false
  570. this.form.businesDate = new Date((new Date(e.value)).getTime() + 8 * 60 * 60 * 1000).toJSON().split('T')
  571. .join(' ').substr(0, 19)
  572. },
  573. confirmWarehouse(e) {
  574. if (this.screen[1] == "account") {
  575. this.formTwo.account = e.value[0].dictValue
  576. this.showWarehouse = false
  577. } else if(this.screen[1] == "salesName") {
  578. this.form.sales = e.value[0].name
  579. this.form.salesName = e.value[0].id
  580. this.showWarehouse = false
  581. } else {
  582. this.form.storageName = e.value[0].cname
  583. this.form.storageId = e.value[0].id
  584. this.showWarehouse = false
  585. }
  586. },
  587. //开单收款
  588. billingCollection() {
  589. if (!this.form.corpId) return this.$refs.uNotify.show({
  590. top: this.revenueTop,
  591. type: 'warning',
  592. message: '请选择客户!'
  593. })
  594. if (!this.form.businesDate) return this.$refs.uNotify.show({
  595. top: this.revenueTop,
  596. type: 'warning',
  597. message: '请选择日期!'
  598. })
  599. if (!this.form.storageId) return this.$refs.uNotify.show({
  600. top: this.revenueTop,
  601. type: 'warning',
  602. message: '请选择发货仓库!'
  603. })
  604. if (this.dataList.length == 0) return this.$refs.uNotify.show({
  605. top: this.revenueTop,
  606. type: 'warning',
  607. message: '请选择商品!'
  608. })
  609. this.form.billType = "XS";
  610. this.$set(this.form, "orderItemsList", this.dataList);
  611. this.form.whetherIntegral = 0 //为了区分是否是积分支付还是会员卡支付
  612. let form = JSON.parse(JSON.stringify(this.form))
  613. delete form.corpName
  614. uni.showLoading({
  615. title: '加载中',
  616. mask: true
  617. });
  618. quickBilling(form).then(res => {
  619. uni.showToast({
  620. icon: "none",
  621. title: '提交成功',
  622. mask: true
  623. });
  624. // 打开开单收款弹窗
  625. this.openPopup = true
  626. this.formTwo = res.data
  627. this.formTwo.memberAmout = 0
  628. const curr = this.formTwo.debitAmount - this.formTwo.settlmentAmount
  629. // const curr = (this.formTwo.orderAmount - this.formTwo.thisUsedProfit - this.formTwo.settlmentAmount).toFixed(2)
  630. // this.formTwo.currentAmount = (this.formTwo.orderAmount - this.formTwo.thisUsedProfit - this.formTwo.settlmentAmount).toFixed(2)
  631. // 获取会员卡余额
  632. getCorpDesc({id:this.form.corpId}).then(res=>{
  633. this.balanceAmount = res.data.balanceAmount?res.data.balanceAmount:0
  634. if (curr > this.balanceAmount) {
  635. this.formTwo.memberAmout = this.balanceAmount
  636. this.formTwo.currentAmount = curr - this.formTwo.memberAmout
  637. }else {
  638. this.formTwo.memberAmout = curr
  639. this.formTwo.currentAmount = 0
  640. }
  641. })
  642. // 判断剪掉的值是不是大于会员卡余额
  643. // if (curr > this.balanceAmounts) {
  644. // this.formTwo.memberAmout = this.balanceAmount
  645. // this.formTwo.currentAmount = curr - this.formTwo.memberAmout
  646. // }else {
  647. // this.formTwo.memberAmout = curr
  648. // this.formTwo.currentAmount = curr - this.formTwo.memberAmout
  649. // }
  650. this.formTwo.advanceCollectionDate = dateFormat(new Date(), "YYYY-MM-DD HH:mm:ss")
  651. })
  652. },
  653. //保存订单
  654. saveOrder() {
  655. if (!this.form.corpId) return this.$refs.uNotify.show({
  656. top: this.revenueTop,
  657. type: 'warning',
  658. message: '请选择客户!'
  659. })
  660. if (!this.form.businesDate) return this.$refs.uNotify.show({
  661. top: this.revenueTop,
  662. type: 'warning',
  663. message: '请选择日期!'
  664. })
  665. if (!this.form.storageId) return this.$refs.uNotify.show({
  666. top: this.revenueTop,
  667. type: 'warning',
  668. message: '请选择发货仓库!'
  669. })
  670. if (this.dataList.length == 0) return this.$refs.uNotify.show({
  671. top: this.revenueTop,
  672. type: 'warning',
  673. message: '请选择商品!'
  674. })
  675. this.form.billType = "XS";
  676. this.$set(this.form, "orderItemsList", this.dataList);
  677. this.form.whetherIntegral = 0
  678. let form = JSON.parse(JSON.stringify(this.form))
  679. delete form.corpName
  680. uni.showLoading({
  681. title: '加载中',
  682. mask: true
  683. });
  684. // typeSave(暂存方法)
  685. quickBilling(form).then(res => {
  686. uni.showToast({
  687. icon: "none",
  688. title: '开单成功',
  689. mask: true
  690. });
  691. setTimeout(function() {
  692. uni.hideLoading();
  693. uni.navigateBack();
  694. }, 1000);
  695. })
  696. }
  697. }
  698. }
  699. </script>
  700. <style scoped>
  701. .submitBar {
  702. width: 100%;
  703. position: fixed;
  704. bottom: 0rpx;
  705. padding-bottom: 20rpx;
  706. font-size: 32rpx;
  707. color: #000;
  708. text-align: center;
  709. border-top: 2rpx solid #f2f2f6;
  710. background-color: #fff;
  711. }
  712. ::v-deep .u-navbar__content {
  713. background-image: linear-gradient(to bottom, #FD4B09, #FF6F3B);
  714. }
  715. ::v-deep .u-cell__title-text {
  716. color: #FD4B09;
  717. }
  718. </style>