index.vue 16 KB

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