index.vue 18 KB

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