business_buy.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578
  1. <template>
  2. <view class="center Regular">
  3. <view class="transaction">
  4. <view class="c-row b-b">
  5. <view class="title">卖方</view>
  6. <view class="con-list Medium">
  7. <view v-if='goods.customerTypeFlag==2' class="title" @click="liang">
  8. {{purchaseOrder.compName?purchaseOrder.compName:goods.compName}}
  9. <u-icon name="arrow-right" color="#AFB3BF" :custom-style="{'marginLeft':'10px','marginRight':'0px'}" ></u-icon>
  10. </view>
  11. <view v-else class="title" @click="liang">
  12. {{purchaseOrder.customer?purchaseOrder.customer:goods.customerName}}>
  13. </view>
  14. </view>
  15. </view>
  16. <view class="c-row">
  17. <view class="title">买方</view>
  18. <view class="con-list">
  19. <view class="title Medium">{{purchaseOrder.buyer}}</view>
  20. </view>
  21. </view>
  22. </view>
  23. <view class="transaction">
  24. <view class="c-row b-b margin-top">
  25. <view class="title">收货地区</view>
  26. <view class="con-list">
  27. <view class="title Medium">
  28. {{purchaseOrder.receivePrivate}}{{purchaseOrder.receiveCity}}{{purchaseOrder.receiveArea}}
  29. </view>
  30. </view>
  31. </view>
  32. <view class="c-row b-b ">
  33. <view class="title">收货库</view>
  34. <view class="con-list">
  35. <view class="title Medium">{{purchaseOrder.receiveWarehouse}}</view>
  36. </view>
  37. </view>
  38. <view v-if='companyId!=2' class="c-row b-b">
  39. <view class="title">货名</view>
  40. <view class="con-list">
  41. <text class="Medium">{{purchaseOrder.goodsName}}</text>
  42. </view>
  43. </view>
  44. <view class="c-row b-b">
  45. <view class="title">最小成交量(吨)</view>
  46. <view class="con-list">
  47. <text class="NumberMedium">{{purchaseOrder.minimumVolume}}</text>
  48. </view>
  49. </view>
  50. <view v-if="purchaseOrder.procurementPlanType=='期货'" class="c-row">
  51. <view class="title">今日基差(元/吨)</view>
  52. <view class="con-list">
  53. <view class="picker">
  54. <text class="NumberMedium">{{purchaseOrder.basis}}</text>
  55. </view>
  56. </view>
  57. </view>
  58. <view v-else class="c-row ">
  59. <view class="title">采购单价(元/吨)</view>
  60. <view class="con-list">
  61. <view class="picker">
  62. <text class="NumberMedium">{{purchaseOrder.procurementPrice}}</text>
  63. </view>
  64. </view>
  65. </view>
  66. </view>
  67. <view class="transaction">
  68. <view class="c-row b-b margin-top">
  69. <view class="title">发票类型</view>
  70. <view class="con-list Medium">
  71. <picker @change="invoiceChange" :value="invoiceIndex" :range="invoiceType">
  72. <view class="picker">
  73. {{invoiceIndex>-1?invoiceType[invoiceIndex]:'请选择'}}
  74. </view>
  75. </picker>
  76. </view>
  77. <u-icon name="arrow-right" color="#AFB3BF" :custom-style="{'marginLeft':'10px','marginRight':'0px'}" ></u-icon>
  78. </view>
  79. <view class="c-row b-b">
  80. <view class="title">出售数量(吨)</view>
  81. <view class="con-list NumberMedium">
  82. <input v-model='purchaseOrder.transactionsNumber' type="number" placeholder="请填写出售数量"
  83. placeholder-style="font-size: 12px;" name="input"></input>
  84. </view>
  85. </view>
  86. <view class="c-row b-b">
  87. <view class="title">包装方式</view>
  88. <view class="con-list Medium">
  89. <picker @change="packingChange" :value="packingIndex" :range="packingType">
  90. <view class="picker">
  91. {{packingIndex>-1?packingType[packingIndex]:'请选择'}}
  92. </view>
  93. </picker>
  94. </view>
  95. <u-icon name="arrow-right" color="#AFB3BF" :custom-style="{'marginLeft':'10px','marginRight':'0px'}" ></u-icon>
  96. </view>
  97. <view v-if='packingIndex!=0' class=" beizhu align-start">
  98. <view class="title">袋装备注</view>
  99. <view>
  100. <textarea maxlength="-1" v-model='purchaseOrder.baggingNotes'
  101. placeholder="请填写包装规格、质量、包装物要求。例:50kg袋装、大粒、彩包" placeholder-style="font-size: 12px;"
  102. class="textareas Medium"></textarea>
  103. </view>
  104. </view>
  105. <view v-if="purchaseOrder.procurementPlanType=='期货'" class="c-row b-b align-start">
  106. <view class="title">点价(元/吨)</view>
  107. <view class="con-list NumberMedium">
  108. <input placeholder="请填写点价" name="input" type="number" placeholder-style="font-size: 12px;"
  109. @input='someprice' v-model="purchaseOrder.pointPrice"></input>
  110. </view>
  111. </view>
  112. <view v-if="purchaseOrder.procurementPlanType=='期货'" class="c-row b-b align-start">
  113. <view class="title">发票费用(元/吨)</view>
  114. <view class="con-list NumberMedium">
  115. <input disabled placeholder="请填写发票费用" name="input" @input='someprice'
  116. v-model="purchaseOrder.invoiceFee"></input>
  117. </view>
  118. </view>
  119. <view v-if="purchaseOrder.procurementPlanType=='期货'" class="c-row b-b align-start">
  120. <view class="title">包装费(元/吨)</view>
  121. <view class="con-list NumberMedium">
  122. <input placeholder="请填写包装费" name="input" placeholder-style="font-size: 12px;" @input='someprice' v-model="packingFee"></input>
  123. </view>
  124. </view>
  125. <view v-if="purchaseOrder.procurementPlanType=='期货'" class=" align-start ">
  126. <view class="titles">结算价格</view>
  127. <text class="textA">结算价格=点价+基差+发票费用+包装费</text>
  128. <text style="color:#FD714F;margin-left: 25px;">
  129. <text style="font-size:26rpx;"></text>
  130. <text style="font-size:42rpx;" class="NumberMedium">{{purchaseOrder.settlementPrice}}</text>
  131. </text>
  132. <!-- <input placeholder="请填写 例:袋装XX斤/散装" name="input" @input='packingInput' v-model="purchaseOrder.settlementPrice"></input> -->
  133. </view>
  134. </view>
  135. <button class="btn" @click="commit()">提交</button>
  136. </view>
  137. </template>
  138. <script>
  139. import {
  140. mapState
  141. } from 'vuex';
  142. export default {
  143. data() {
  144. return {
  145. tradeInfo: {
  146. salebuyId: 0,
  147. packing: '',
  148. memo: '',
  149. buyer: '',
  150. buyerPhone: '',
  151. procurementPrice: 0,
  152. address: '',
  153. count: 0,
  154. province: '',
  155. area: '',
  156. priceType: '',
  157. invoiceType: '',
  158. acceptType: '',
  159. seller: '',
  160. sellerPhone: '',
  161. packingMoney: 0,
  162. type: 0,
  163. modalName: "",
  164. },
  165. purchaseOrder: {
  166. invoiceFee: 0,
  167. packingFee: null,
  168. packingType: "散装",
  169. packingTypeKey: 1,
  170. type: '不开发票',
  171. typeKey: 1
  172. },
  173. invoiceTypeIndex: 0,
  174. invoiceTypeIndex1: 0,
  175. acceptTypeIndex: 0,
  176. priceTypeIndex: 0,
  177. bankNameIndex: 0,
  178. packingIndex: 0,
  179. invoiceIndex: 0,
  180. packingType: ['散粮', '大袋', '小袋'],
  181. // invoiceType: ['不开发票', '普通发票', '增值税发票'],
  182. invoiceType: ['不开发票', '增值税发票'],
  183. acceptType: ['第三方检验(国家检验资质)', '交收地库或港出具的检验', '现场看货', '其他'],
  184. priceType: ['库内价', '到库价', '到港价'],
  185. priceTypeIndex1: '库内价',
  186. region: [],
  187. salebuyId: 0,
  188. memo: '',
  189. buyer: '',
  190. buyerPhone: '',
  191. procurementPrice: 0,
  192. address: '',
  193. count: 0,
  194. id: 0,
  195. price: '库内价',
  196. invoice: '不开发票',
  197. accept: '',
  198. seller: '',
  199. sellerPhone: '',
  200. minSale: '',
  201. province: '',
  202. city: '',
  203. area: '',
  204. storeName: '',
  205. exsitCount: 0,
  206. isFutures: '',
  207. bankNameList: '',
  208. Company: [],
  209. goods: {},
  210. companyId: '',
  211. tradeCompanyId: '',
  212. basis: 0,
  213. basisBig: 0,
  214. basisSmall: 0,
  215. invoiceMoney: 0,
  216. unloadingFee: 0,
  217. packingMoney: 0,
  218. packing: '散装',
  219. packingFee: null,
  220. invoiceFeeCompany:0,
  221. invoiceFeePerson:0
  222. // choice : false,
  223. };
  224. },
  225. onLoad(options) {
  226. this.id = options.id
  227. this.purchaseOrder.planId = options.id
  228. this.purchaseOrder.seller = options.seller
  229. this.purchaseOrder.goodsName = options.goodsName
  230. this.purchaseOrder.receivePrivate = options.receivePrivate
  231. this.purchaseOrder.receiveCity = options.receiveCity
  232. this.purchaseOrder.receiveArea = options.receiveArea
  233. this.purchaseOrder.minimumVolume = options.minimumVolume
  234. this.purchaseOrder.buyer = options.buyer
  235. this.purchaseOrder.customer = options.customerName
  236. this.purchaseOrder.basis = options.basisPrice
  237. this.purchaseOrder.procurementPrice = options.procurementPrice
  238. this.purchaseOrder.receiveWarehouse = options.receiveWarehouse
  239. this.purchaseOrder.settlementPrice = options.basisPrice
  240. this.purchaseOrder.procurementPlanType = options.procurementPlanType
  241. this.purchaseOrder.procurementPlan = options.procurementPlan
  242. this.purchaseOrder.compId = options.compId
  243. this.invoiceFeeCompany = options.invoiceFeeCompany
  244. this.invoiceFeePerson = options.invoiceFeePerson
  245. },
  246. computed: {
  247. ...mapState(['hasLogin', 'userInfo']),
  248. },
  249. onShow() {
  250. if( this.$store.state.choice != "" && this.goods.customerTypeFlag){
  251. if(this.goods.customerTypeFlag==1){
  252. this.goods.customerName = this.$store.state.choice
  253. }else if(this.goods.customerTypeFlag==2){
  254. this.goods.compName = this.$store.state.choice
  255. }
  256. }else{
  257. this.$api.doRequest('get', '/identityAuthenticationInfo/getInfo', {
  258. commonId: this.userInfo.id
  259. }).then(res => {
  260. if (res.data.code == 200) {
  261. this.goods = res.data.data
  262. if (this.goods.customerTypeFlag == 1) {
  263. this.purchaseOrder.invoiceFee = this.invoiceFeePerson
  264. this.purchaseOrder.settlementPrice = Number(this.purchaseOrder.basis) + Number(this
  265. .purchaseOrder.invoiceFee)
  266. } else {
  267. this.purchaseOrder.invoiceFee = this.invoiceFeeCompany
  268. this.purchaseOrder.settlementPrice = Number(this.purchaseOrder.basis) + Number(this
  269. .purchaseOrder.invoiceFee)
  270. }
  271. }
  272. uni.hideLoading()
  273. })
  274. }
  275. },
  276. methods: {
  277. liang() {
  278. uni.navigateTo({
  279. url: `/pageA/product/Identity_switching?goodsName=${this.purchaseOrder.goodsName}
  280. &receivePrivate=${this.purchaseOrder.receivePrivate}&receiveCity=${this.purchaseOrder.receiveCity}
  281. &receiveArea=${this.purchaseOrder.receiveArea}&minimumVolume=${this.purchaseOrder.minimumVolume}
  282. &buyer=${this.purchaseOrder.buyer}&basisPrice=${this.purchaseOrder.basis}&procurementPrice=${this.purchaseOrder.procurementPrice}
  283. &receiveWarehouse=${this.purchaseOrder.receiveWarehouse}&procurementPlanType=${this.purchaseOrder.procurementPlanType}
  284. &procurementPlanNo=${this.purchaseOrder.procurementPlan}`
  285. })
  286. },
  287. commit() {
  288. if (!this.purchaseOrder.transactionsNumber) {
  289. this.$api.msg('出售数量不能为空')
  290. return
  291. }
  292. if (this.purchaseOrder.transactionsNumber > 10000 || this.purchaseOrder.transactionsNumber < 1) {
  293. this.$api.msg('出售数量输入错误')
  294. return
  295. }
  296. if (this.purchaseOrder.procurementPlanType == '期货' && !this.purchaseOrder.pointPrice) {
  297. this.$api.msg('点价不能为空')
  298. return
  299. }
  300. if (this.purchaseOrder.procurementPlanType == '期货' && this.purchaseOrder.pointPrice > 10000) {
  301. this.$api.msg('点价输入错误')
  302. return
  303. }
  304. if (this.purchaseOrder.procurementPlanType == '期货' && this.purchaseOrder.pointPrice.indexOf('.') != -1) {
  305. if (this.purchaseOrder.pointPrice.split(".")[1].length > 2) {
  306. this.$api.msg('点价输入错误')
  307. return
  308. }
  309. }
  310. this.purchaseOrder.packingFee = -this.packingFee
  311. if (this.purchaseOrder.packingFee > 0 || this.purchaseOrder.packingFee < -2000) {
  312. this.$api.msg('包装费输入错误')
  313. return
  314. }
  315. if (!this.purchaseOrder.customer) {
  316. if (this.goods.customerTypeFlag == 1) {
  317. this.purchaseOrder.customer = this.goods.customerName
  318. } else {
  319. this.purchaseOrder.customer = this.goods.compName
  320. }
  321. }
  322. if (!this.purchaseOrder.seller) {
  323. if (this.goods.customerTypeFlag == 1) {
  324. this.purchaseOrder.seller = this.goods.customerName
  325. this.purchaseOrder.sellerPhone = this.goods.customerPhone
  326. } else {
  327. this.purchaseOrder.seller = this.goods.compName
  328. this.purchaseOrder.sellerPhone = this.goods.customerPhone
  329. }
  330. }
  331. var that = this
  332. this.purchaseOrder.commonId = that.userInfo.id
  333. this.purchaseOrder.pcFlag = 0
  334. if (this.purchaseOrder.procurementPlanType == "期货") {
  335. this.purchaseOrder.unitPrice = this.purchaseOrder.settlementPrice
  336. }
  337. uni.showModal({
  338. content: '订单提交后将发送给买方,是否确定提交?',
  339. success: function(res) {
  340. if (res.confirm) {
  341. that.$api.doRequest('post', '/purchaseOrder/api/insertPurchaseOrder', that
  342. .purchaseOrder).then(res => {
  343. if (res.data.code == 200) {
  344. that.$api.doRequest('post',
  345. '/purchaseOrder/api/submitPurchaseOrder', {
  346. id: res.data.data
  347. }).then(res1 => {
  348. if (res1.data.code == 200) {
  349. // uni.navigateTo({
  350. // url: `/pageA/product/detail`
  351. // })
  352. uni.showToast({
  353. title: '提交成功,等待买方回复',
  354. icon: 'none',
  355. duration: 1500,
  356. success() {
  357. setTimeout(()=>{
  358. uni.navigateBack(1)
  359. },1500)
  360. }
  361. })
  362. } else {
  363. uni.showToast({
  364. title: res.data.message,
  365. icon: 'none',
  366. duration: 2000
  367. })
  368. }
  369. }).catch(res => {
  370. uni.showToast({
  371. title: res.data.message,
  372. icon: 'none',
  373. duration: 2000
  374. })
  375. })
  376. // uni.navigateBack();
  377. } else {
  378. uni.showToast({
  379. title: '提交失败:' + res.data.message,
  380. icon: 'none',
  381. duration: 2000
  382. })
  383. }
  384. }).catch(res => {
  385. if (res.errmsg) {
  386. uni.showToast({
  387. title: res.errmsg,
  388. icon: 'none',
  389. duration: 2000
  390. })
  391. } else {
  392. uni.showToast({
  393. title: "系统异常,请联系管理员",
  394. icon: 'none',
  395. duration: 2000
  396. })
  397. }
  398. })
  399. }
  400. }
  401. })
  402. },
  403. someprice(e) {
  404. if (this.purchaseOrder.pointPrice && this.purchaseOrder.invoiceFee && this.packingFee) {
  405. this.purchaseOrder.settlementPrice = Number(this.purchaseOrder.basis) + Number(this.purchaseOrder
  406. .pointPrice) + Number(this.purchaseOrder.invoiceFee) + Number(-this.packingFee)
  407. } else if (this.purchaseOrder.pointPrice && this.purchaseOrder.invoiceFee) {
  408. this.purchaseOrder.settlementPrice = Number(this.purchaseOrder.basis) + Number(this.purchaseOrder
  409. .pointPrice) + Number(this.purchaseOrder.invoiceFee)
  410. } else if (this.purchaseOrder.pointPrice && this.packingFee) {
  411. this.purchaseOrder.settlementPrice = Number(this.purchaseOrder.basis) + Number(this.purchaseOrder
  412. .pointPrice) + Number(-this.packingFee)
  413. } else if (this.purchaseOrder.pointPrice) {
  414. this.purchaseOrder.settlementPrice = Number(this.purchaseOrder.basis) + Number(this.purchaseOrder
  415. .pointPrice)
  416. } else if (this.packingFee) {
  417. this.purchaseOrder.settlementPrice = Number(this.purchaseOrder.basis) + Number(-this.packingFee)
  418. } else if (this.purchaseOrder.invoiceFee) {
  419. this.purchaseOrder.settlementPrice = Number(this.purchaseOrder.basis) + Number(this.purchaseOrder
  420. .invoiceFee)
  421. } else {
  422. this.purchaseOrder.settlementPrice = this.purchaseOrder.basis
  423. }
  424. },
  425. bankNameChange(e) {
  426. this.bankNameIndex = e.detail.value
  427. this.buyer = this.Company[e.detail.value].companyName
  428. this.buyerPhone = this.Company[e.detail.value].companyPhone
  429. this.tradeCompanyId = this.Company[e.detail.value].id
  430. },
  431. AcceptTypeChange(e) {
  432. this.acceptTypeIndex = e.detail.value
  433. this.accept = this.acceptType[this.acceptTypeIndex];
  434. },
  435. packingChange(e) {
  436. this.packingIndex = e.detail.value
  437. this.purchaseOrder.packingTypeKey = e.detail.value + 1
  438. this.purchaseOrder.packingType = this.packingType[this.packingIndex];
  439. },
  440. invoiceChange(e) {
  441. this.invoiceIndex = e.detail.value
  442. this.purchaseOrder.typeKey = e.detail.value + 1
  443. this.purchaseOrder.type = this.invoiceType[this.invoiceIndex];
  444. if (this.invoiceIndex == 0) {
  445. if (this.goods.customerTypeFlag == 1) {
  446. this.purchaseOrder.invoiceFee = -20
  447. } else {
  448. this.purchaseOrder.invoiceFee = 0
  449. }
  450. } else {
  451. this.purchaseOrder.invoiceFee = 0
  452. }
  453. },
  454. changeZhihang() {
  455. uni.navigateTo({
  456. url: '/pageA/pages/newcompany'
  457. })
  458. },
  459. PriceTypeChange(e) {
  460. this.priceTypeIndex = e.detail.value
  461. this.price = this.priceType[this.priceTypeIndex]
  462. },
  463. RegionChange(e) {
  464. this.region = e.detail.value
  465. this.province = this.region[0];
  466. this.area = this.region[0] + this.region[1] + this.region[2];
  467. },
  468. textareaInput(e) {
  469. this.memo = e.detail.value
  470. },
  471. buyerInput(e) {
  472. this.buyer = e.detail.value
  473. },
  474. buyerPhoneInput(e) {
  475. this.buyerPhone = e.detail.value
  476. },
  477. addressInput(e) {
  478. this.address = e.detail.value
  479. },
  480. countInput(e) {
  481. this.count = e.detail.value
  482. },
  483. }
  484. }
  485. </script>
  486. <style scoped>
  487. .center {
  488. padding: 10px 20px;
  489. background-color: #F5F6FA;
  490. }
  491. .cu-form-group input {
  492. text-align: right;
  493. }
  494. .cu-form-group textarea {
  495. text-align: right;
  496. }
  497. .margin-bottom {
  498. margin-bottom: 30px;
  499. }
  500. .c-row {
  501. display: -webkit-box;
  502. display: -webkit-flex;
  503. display: flex;
  504. -webkit-box-align: center;
  505. -webkit-align-items: center;
  506. align-items: center;
  507. padding: 20rpx 30rpx;
  508. position: relative;
  509. }
  510. .con-list {
  511. -webkit-box-flex: 1;
  512. -webkit-flex: 1;
  513. flex: 1;
  514. display: -webkit-box;
  515. display: -webkit-flex;
  516. display: flex;
  517. -webkit-box-orient: vertical;
  518. -webkit-box-direction: normal;
  519. -webkit-flex-direction: column;
  520. flex-direction: column;
  521. color: #303133;
  522. line-height: 40rpx;
  523. text-align: right;
  524. }
  525. .transaction {
  526. background-color: #FFFFFF;
  527. margin-top: 10px;
  528. padding-bottom: 10px;
  529. border-radius: 20rpx;
  530. }
  531. .btn {
  532. width: 100%;
  533. background-color: #22C572;
  534. border-radius: 20px;
  535. margin-top: 10px;
  536. color: white;
  537. }
  538. .textareas {
  539. width: 95%;
  540. background-color: #F9F9FA;
  541. padding: 10px 20px 0px 20px;
  542. border-radius: 10px;
  543. }
  544. .beizhu {
  545. margin-left: 15px;
  546. margin-bottom: 20px;
  547. /* margin: 10px; */
  548. margin-top: 10px;
  549. }
  550. .titles {
  551. margin-left: 20px;
  552. margin-top: 10px;
  553. }
  554. .textA {
  555. margin-left: 20px;
  556. color: #AFB3BF;
  557. font-size: 10px;
  558. }
  559. </style>