index.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517
  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="添加产品" @click="selectProduct()">
  30. </u-cell>
  31. <u-cell v-for="(item,index) in dataList" :key="index">
  32. <view slot="label">
  33. <!-- customStyle="margin-bottom: 10px" -->
  34. <u-row>
  35. <u-col span="2.9">
  36. <u--image :showLoading="true" :src="item.url?item.url:'../../../static/images/404.png'"
  37. width="80px" height="80px" radius="10">
  38. </u--image>
  39. </u-col>
  40. <u-col span="9.1">
  41. <view
  42. style="font-size: 36rpx;width: 530rpx;overflow: hidden;white-space: nowrap;text-overflow: ellipsis;">
  43. {{item.cname}}
  44. </view>
  45. <view style="display: flex;justify-content: space-between;">
  46. <view style="color: #707070;">单价:¥{{item.price}}</view>
  47. <view style="color: #707070;">数量:{{item.storageInQuantity}}</view>
  48. </view>
  49. <view style="display: flex;justify-content: space-between;">
  50. <view style="color: #707070;">金额:¥{{item.amount}}</view>
  51. <view style="color: #707070; color: red;" @click="deleteProduct(index)">
  52. <u-button type="error" size="mini" text="删除"></u-button>
  53. </view>
  54. </view>
  55. </u-col>
  56. </u-row>
  57. </view>
  58. </u-cell>
  59. </u-cell-group>
  60. </view>
  61. <view class="submitBar">
  62. <view style="width: 100%;position: fixed;bottom: 0;background-color: #fff;border-top: 1rpx solid #ccc;">
  63. <view style="width: 100%;display: flex;font-size: 24rpx;justify-content: space-between;">
  64. <view style="width: 50%;display: flex;">
  65. <view style="margin-top: 10rpx;">
  66. <u-icon name="shopping-cart" color="#FD4B09" size="50"></u-icon>
  67. </view>
  68. <view style="margin-top: 40rpx;color: #000;">
  69. 金额:<text style="color: red;">¥{{amount}}</text>
  70. </view>
  71. </view>
  72. <view @click="billingCollection"
  73. style="width: 25%;background-color: #5ac725;display: grid;justify-items: center;">
  74. <u-icon name="rmb" color="#fff"></u-icon>
  75. <view style="color: #fff;">开单并收款</view>
  76. </view>
  77. <view @click="saveOrder"
  78. style="width: 25%;background-color: #fd4b09;display: grid;justify-items: center;">
  79. <u-icon name="checkmark" color="#fff"></u-icon>
  80. <view style="color: #fff;">确认开单</view>
  81. </view>
  82. </view>
  83. </view>
  84. </view>
  85. <u-popup zIndex="10070" :closeOnClickOverlay="false" :show="openPopup" @close="openPopup = false,mask = false,uni.navigateBack()"
  86. mode="center" closeable round="10rpx">
  87. <u--form labelPosition="left" :labelStyle="{color: '#fd4b09'}" :model="formTwo" ref="formTwo"
  88. labelWidth="150rpx">
  89. <view style="width: calc(700rpx - 20px);margin: 10px;">
  90. <text>收款台</text>
  91. <view>
  92. <!-- <u-form-item label="订单金额" prop="cname" borderBottom>
  93. <u-input type="number" v-model="formTwo.purchaseAmount" border="none" inputAlign="right" placeholder="请输入"
  94. disabled disabledColor="#ffffff" />
  95. </u-form-item> -->
  96. <!-- <u-form-item label="优惠金额" prop="cname" borderBottom>
  97. <u-input type="number" v-model="formTwo.thisUsedProfit" border="none" inputAlign="right" placeholder="请输入" disabledColor="#ffffff" @blur="discount(0)"/>
  98. </u-form-item> -->
  99. <u-form-item label="应收金额" prop="cname" borderBottom>
  100. <u-input type="number" v-model="formTwo.orderAmount" border="none" inputAlign="right"
  101. placeholder="请输入" disabled disabledColor="#ffffff" />
  102. </u-form-item>
  103. <u-form-item label="已收金额" prop="cname" borderBottom>
  104. <u-input type="number" v-model="formTwo.settlmentAmount" border="none" inputAlign="right"
  105. placeholder="请输入" disabled disabledColor="#ffffff" />
  106. </u-form-item>
  107. <u-form-item label="溢付款" prop="cname" borderBottom>
  108. <u-input type="number" v-model="formTwo.overPayment" border="none" inputAlign="right"
  109. disabled disabledColor="#ffffff" />
  110. </u-form-item>
  111. <u-form-item label="本次收款" prop="cname" borderBottom>
  112. <u-input type="number" clearable v-model="formTwo.currentAmount" border="none"
  113. inputAlign="right" placeholder="请输入" disabledColor="#ffffff" @blur="discount(1)" />
  114. </u-form-item>
  115. <u-form-item label="收款日期" labelWidth="190rpx" prop="cname" borderBottom
  116. @click="filterAll(['advanceCollectionDate','advanceCollectionDate'])">
  117. <view style="width: 100%;text-align: right;">
  118. {{formTwo.advanceCollectionDate?formTwo.advanceCollectionDate.slice(0,10):''}}
  119. </view>
  120. </u-form-item>
  121. <u-form-item label="收款账户" prop="cname" borderBottom @click="filterAll(['account','account'])">
  122. <u-input v-model="formTwo.account" border="none" inputAlign="right" placeholder="请选择"
  123. disabled disabledColor="#ffffff">
  124. <template slot="suffix" style="text-align: center;">
  125. <u-icon name="plus-circle" size="18" @click.native.stop="newCompany()"></u-icon>
  126. </template>
  127. </u-input>
  128. </u-form-item>
  129. <view style="display: flex;margin-top: 20rpx;">
  130. <u-button text="取消" style="width: 45%;"
  131. @click="openPopup = false,mask = false,uni.navigateBack()"></u-button>
  132. <u-button type="primary" text="收款" color="#FD4B09" style="width: 45%;"
  133. @click="collectionConfirm"></u-button>
  134. </view>
  135. </view>
  136. </view>
  137. </u--form>
  138. </u-popup>
  139. <u-datetime-picker :show="show" v-model="timeValue" mode="date" @confirm="confirm" @cancel="show = false">
  140. </u-datetime-picker>
  141. <u-datetime-picker :show="timeOpen" v-model="datetime" mode="date" @cancel="timeOpen = false,mask = false"
  142. @confirm="confirmTiem"></u-datetime-picker>
  143. <u-picker :show="showWarehouse" :columns="columns" :keyName="keyName" @confirm="confirmWarehouse"
  144. @cancel="showWarehouse = false"></u-picker>
  145. <u-notify ref="uNotify"></u-notify>
  146. </view>
  147. </template>
  148. <script>
  149. import {
  150. customerList,
  151. quickBilling,
  152. typeSave,
  153. gainUser
  154. } from '@/api/views/sale/index.js'
  155. import {
  156. collectPayment
  157. } from '@/api/views/sale/salesOrderDetails.js'
  158. import {
  159. dateFormat
  160. } from '@/common/dateFormat'
  161. export default {
  162. data() {
  163. return {
  164. show: false,
  165. timeOpen: false,
  166. openPopup: false,
  167. showWarehouse: false,
  168. timeValue: Number(new Date()),
  169. datetime: Number(new Date()),
  170. columns: [],
  171. dataList: [],
  172. amount: 0.00,
  173. numberAll: 0,
  174. screen: [],
  175. keyName: '',
  176. form: {
  177. corpId: '',
  178. corpName: '',
  179. customer: '',
  180. businesDate: '',
  181. storageName: '',
  182. total: 0
  183. },
  184. formTwo: {
  185. },
  186. revenueTop: 0
  187. }
  188. },
  189. onLoad() {
  190. uni.getSystemInfo({
  191. success: (e) => {
  192. this.revenueTop = e.statusBarHeight + 44
  193. }
  194. })
  195. },
  196. created() {
  197. this.form.businesDate = new Date((new Date()).getTime() + 8 * 60 * 60 * 1000).toJSON().split('T').join(' ')
  198. .substr(0, 19)
  199. },
  200. methods: {
  201. newCompany() {
  202. uni.$u.route('/pages/views/product/createCompany', {
  203. code: "account",
  204. title: "收款账户"
  205. });
  206. },
  207. //时间确认选择
  208. confirmTiem(e) {
  209. this.formTwo[this.screen[1]] = dateFormat(new Date(e.value), "YYYY-MM-DD HH:mm:ss")
  210. this.timeOpen = false
  211. this.mask = false
  212. },
  213. collectionConfirm() {
  214. if (!this.formTwo.thisUsedProfit) {
  215. return uni.showToast({
  216. icon: "none",
  217. title: '优惠金额不能为空',
  218. mask: true
  219. });
  220. }
  221. if (!this.formTwo.orderAmount) {
  222. return uni.showToast({
  223. icon: "none",
  224. title: '合同金额不能为空',
  225. mask: true
  226. });
  227. }
  228. if (!this.formTwo.currentAmount) {
  229. return uni.showToast({
  230. icon: "none",
  231. title: '本次收款金额不能为空',
  232. mask: true
  233. });
  234. }
  235. if (!this.formTwo.account) {
  236. return uni.showToast({
  237. icon: "none",
  238. title: '收款帐户不能为空',
  239. mask: true
  240. });
  241. }
  242. let this_ = this
  243. uni.showModal({
  244. title: '是否确认收款',
  245. content: '本次收款金额' + this_.formTwo.currentAmount,
  246. success: function(rest) {
  247. if (rest.confirm == true) {
  248. uni.showLoading({
  249. title: '加载中',
  250. mask: true
  251. });
  252. collectPayment(this_.formTwo).then(res => {
  253. uni.showToast({
  254. icon: "none",
  255. title: '收款成功',
  256. mask: true,
  257. duration: 2000
  258. });
  259. this.openPopup = false
  260. setTimeout(function() {
  261. uni.hideLoading();
  262. uni.navigateBack();
  263. }, 2000);
  264. })
  265. }
  266. }
  267. })
  268. },
  269. //集合筛选条件
  270. filterAll(screen) {
  271. this.screen = screen
  272. switch (screen[1]) {
  273. case "account":
  274. this.$u.api.getWorkDicts('account').then(res => {
  275. this.columns = [res.data]
  276. this.keyName = "dictValue"
  277. this.showWarehouse = true
  278. })
  279. break;
  280. case "advanceCollectionDate":
  281. this.timeOpen = true
  282. this.mask = true
  283. break;
  284. case "storageId":
  285. customerList({
  286. size: 1,
  287. current: 1
  288. }).then(request => {
  289. customerList({
  290. size: request.data.total,
  291. current: 1
  292. }).then(res => {
  293. this.columns = [res.data.records]
  294. this.keyName = 'cname'
  295. this.showWarehouse = true
  296. })
  297. })
  298. break;
  299. case "salesName":
  300. gainUser().then(res => {
  301. this.columns = [res.data]
  302. this.keyName = 'name'
  303. this.showWarehouse = true
  304. })
  305. break;
  306. }
  307. },
  308. discount(type) {
  309. if (type == 0) {
  310. if (this.formTwo.thisUsedProfit < 0) {
  311. return this.formTwo.thisUsedProfit = null
  312. }
  313. this.formTwo.orderAmount = (this.formTwo.purchaseAmount - this.formTwo.thisUsedProfit).toFixed(2)
  314. if (this.formTwo.orderAmount < 0) {
  315. this.$set(this.formTwo, "orderAmount", null)
  316. this.$set(this.formTwo, "thisUsedProfit", null)
  317. uni.showToast({
  318. icon: "none",
  319. title: '优惠金额不能大于订单金额',
  320. mask: true
  321. });
  322. }
  323. if ((this.formTwo.currentAmount - this.formTwo.orderAmount) > 0) {
  324. this.formTwo.overPayment = (this.formTwo.currentAmount - this.formTwo.orderAmount).toFixed(2)
  325. } else {
  326. this.formTwo.overPayment = '0.00'
  327. }
  328. } else if (type == 1) {
  329. if (this.formTwo.currentAmount < 0) {
  330. return this.formTwo.currentAmount = null
  331. }
  332. if ((this.formTwo.currentAmount - this.formTwo.orderAmount) > 0) {
  333. this.formTwo.overPayment = (this.formTwo.currentAmount - this.formTwo.orderAmount).toFixed(2)
  334. } else {
  335. this.formTwo.overPayment = '0.00'
  336. }
  337. }
  338. },
  339. deleteProduct(index) {
  340. this.amount = Number(this.amount) - Number(this.dataList[index].amount)
  341. this.amount.toFixed(2)
  342. this.dataList.splice(index, 1)
  343. this.numberAll = 0
  344. for (let item of this.dataList) {
  345. this.numberAll += Number(item.storageInQuantity)
  346. }
  347. },
  348. //客户选择返回触发
  349. otherFun(customer) {
  350. this.form.corpName = customer.cname
  351. this.form.corpId = customer.id
  352. this.form.belongToCorpId = customer.belongtocompany
  353. },
  354. //商品选择返回
  355. getProduct(dataList) {
  356. this.amount = Number(this.amount)
  357. for (let item of dataList) {
  358. this.dataList.push(item)
  359. this.amount += Number(item.amount)
  360. this.numberAll += Number(item.storageInQuantity)
  361. }
  362. this.amount = this.amount.toFixed(2)
  363. },
  364. selectCustomer() {
  365. this.$u.route('/pages/views/salesSlip/selectCustomer', {
  366. corpType: 'KH'
  367. });
  368. },
  369. historical0rders() {
  370. this.$u.route('/pages/views/salesSlip/salesOrderList');
  371. },
  372. selectProduct() {
  373. if (this.form.storageId) {
  374. this.$u.route('/pages/views/salesSlip/selectProduct', {
  375. form: JSON.stringify(this.form),
  376. data: JSON.stringify(this.dataList)
  377. });
  378. } else {
  379. this.$refs.uNotify.show({
  380. top: this.revenueTop,
  381. type: 'warning',
  382. message: '请选择发货仓库!'
  383. })
  384. }
  385. },
  386. confirm(e) {
  387. this.show = false
  388. this.form.businesDate = new Date((new Date(e.value)).getTime() + 8 * 60 * 60 * 1000).toJSON().split('T')
  389. .join(' ').substr(0, 19)
  390. },
  391. confirmWarehouse(e) {
  392. if (this.screen[1] == "account") {
  393. this.formTwo.account = e.value[0].dictValue
  394. this.showWarehouse = false
  395. } else if(this.screen[1] == "salesName") {
  396. this.form.sales = e.value[0].name
  397. this.form.salesName = e.value[0].id
  398. this.showWarehouse = false
  399. } else {
  400. this.form.storageName = e.value[0].cname
  401. this.form.storageId = e.value[0].id
  402. this.showWarehouse = false
  403. }
  404. },
  405. //开单收款
  406. billingCollection() {
  407. if (!this.form.corpId) return this.$refs.uNotify.show({
  408. top: this.revenueTop,
  409. type: 'warning',
  410. message: '请选择客户!'
  411. })
  412. if (!this.form.businesDate) return this.$refs.uNotify.show({
  413. top: this.revenueTop,
  414. type: 'warning',
  415. message: '请选择日期!'
  416. })
  417. if (!this.form.storageId) return this.$refs.uNotify.show({
  418. top: this.revenueTop,
  419. type: 'warning',
  420. message: '请选择发货仓库!'
  421. })
  422. if (this.dataList.length == 0) return this.$refs.uNotify.show({
  423. top: this.revenueTop,
  424. type: 'warning',
  425. message: '请选择商品!'
  426. })
  427. this.form.billType = "XS";
  428. this.$set(this.form, "orderItemsList", this.dataList);
  429. let form = JSON.parse(JSON.stringify(this.form))
  430. delete form.corpName
  431. uni.showLoading({
  432. title: '加载中',
  433. mask: true
  434. });
  435. quickBilling(form).then(res => {
  436. uni.showToast({
  437. icon: "none",
  438. title: '提交成功',
  439. mask: true
  440. });
  441. this.openPopup = true
  442. this.formTwo = res.data
  443. this.formTwo.currentAmount = (this.formTwo.orderAmount - this.formTwo.settlmentAmount).toFixed(
  444. 2)
  445. this.formTwo.advanceCollectionDate = dateFormat(new Date(), "YYYY-MM-DD HH:mm:ss")
  446. })
  447. },
  448. //保存订单
  449. saveOrder() {
  450. if (!this.form.corpId) return this.$refs.uNotify.show({
  451. top: this.revenueTop,
  452. type: 'warning',
  453. message: '请选择客户!'
  454. })
  455. if (!this.form.businesDate) return this.$refs.uNotify.show({
  456. top: this.revenueTop,
  457. type: 'warning',
  458. message: '请选择日期!'
  459. })
  460. if (!this.form.storageId) return this.$refs.uNotify.show({
  461. top: this.revenueTop,
  462. type: 'warning',
  463. message: '请选择发货仓库!'
  464. })
  465. if (this.dataList.length == 0) return this.$refs.uNotify.show({
  466. top: this.revenueTop,
  467. type: 'warning',
  468. message: '请选择商品!'
  469. })
  470. this.form.billType = "XS";
  471. this.$set(this.form, "orderItemsList", this.dataList);
  472. let form = JSON.parse(JSON.stringify(this.form))
  473. delete form.corpName
  474. uni.showLoading({
  475. title: '加载中',
  476. mask: true
  477. });
  478. // typeSave(暂存方法)
  479. quickBilling(form).then(res => {
  480. uni.showToast({
  481. icon: "none",
  482. title: '开单成功',
  483. mask: true
  484. });
  485. setTimeout(function() {
  486. uni.hideLoading();
  487. uni.navigateBack();
  488. }, 1000);
  489. })
  490. }
  491. }
  492. }
  493. </script>
  494. <style scoped>
  495. .submitBar {
  496. width: 100%;
  497. position: fixed;
  498. bottom: 0rpx;
  499. padding-bottom: 20rpx;
  500. font-size: 32rpx;
  501. color: #000;
  502. text-align: center;
  503. border-top: 2rpx solid #f2f2f6;
  504. background-color: #fff;
  505. }
  506. ::v-deep .u-navbar__content {
  507. background-image: linear-gradient(to bottom, #FD4B09, #FF6F3B);
  508. }
  509. ::v-deep .u-cell__title-text {
  510. color: #FD4B09;
  511. }
  512. </style>