index.vue 18 KB

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