index.vue 17 KB

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