business_buy.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407
  1. <template>
  2. <view class="container">
  3. <view class="cu-form-group">
  4. <view class="title">卖方</view>
  5. <view class="title">{{seller}}</view>
  6. </view>
  7. <view class="cu-form-group">
  8. <view class="title">买方</view>
  9. <view class="title">{{sellerPhone}}</view>
  10. </view>
  11. <view class="cu-form-group margin-top">
  12. <view class="title">收货地区</view>
  13. <view class="title">{{sellerPhone}}</view>
  14. </picker>
  15. </view>
  16. <view class="cu-form-group ">
  17. <view class="title">收货库</view>
  18. <view class="title">{{sellerPhone}}</view>
  19. </picker>
  20. </view>
  21. <view v-if='companyId!=2' class="cu-form-group">
  22. <view class="title">货名</view>
  23. <input placeholder="请填写" name="input" @input="addressInput"></input>
  24. </view>
  25. <view class="cu-form-group">
  26. <view class="title">最小成交量(吨)</view>
  27. <view class="title">{{minSale}}</view>
  28. </view>
  29. <view v-if="companyId==2" class="cu-form-group">
  30. <view class="title">今日基差(元/吨)</view>
  31. <view class="picker">
  32. {{invoiceTypeIndex1>-1?invoiceType1[invoiceTypeIndex1]:'请选择'}}
  33. </view>
  34. </view>
  35. <view v-else class="cu-form-group">
  36. <view class="title">采购单价(元/吨)</view>
  37. <view class="picker">
  38. {{invoiceTypeIndex>-1?invoiceType[invoiceTypeIndex]:'请选择'}}
  39. </view>
  40. </view>
  41. <view class="cu-form-group margin-top">
  42. <view class="title">发票类型</view>
  43. <input placeholder="请填写" name="input" @input="countInput"></input>
  44. </view>
  45. <view class="cu-form-group">
  46. <view class="title">出售数量(吨)</view>
  47. <input placeholder="请填写 例:袋装XX斤/散装" name="input" @input='packingInput'></input>
  48. </view>
  49. <view class="cu-form-group">
  50. <view class="title">包装方式</view>
  51. <picker @change="packingChange" :value="packingIndex" :range="packingType">
  52. <view class="picker">
  53. {{packingIndex>-1?packingType[packingIndex]:'请选择'}}
  54. </view>
  55. </picker>
  56. </view>
  57. <view class="cu-form-group align-start">
  58. <view class="title">袋装备注</view>
  59. <textarea maxlength="-1" :disabled="modalName!=null" @input="textareaInput" placeholder="请填写包装规格、质量、包装物要求。例:50kg袋装、大粒、彩包"></textarea>
  60. </view>
  61. <view class="cu-form-group align-start">
  62. <view class="title">点价(元/吨)</view>
  63. <input placeholder="请填写 例:袋装XX斤/散装" name="input" @input='packingInput'></input>
  64. </view>
  65. <view class="cu-form-group align-start">
  66. <view class="title">发票费用(元/吨)</view>
  67. <input placeholder="请填写 例:袋装XX斤/散装" name="input" @input='packingInput'></input>
  68. </view>
  69. <view class="cu-form-group align-start">
  70. <view class="title">包装费(元/吨)</view>
  71. <input placeholder="请填写 例:袋装XX斤/散装" name="input" @input='packingInput'></input>
  72. </view>
  73. <view class="cu-form-group align-start">
  74. <view class="title">结算价格</view>
  75. <input placeholder="请填写 例:袋装XX斤/散装" name="input" @input='packingInput'></input>
  76. </view>
  77. <view class="padding flex flex-direction">
  78. <button class="cu-btn bg-red margin-tb-sm lg" @click="commit">提交</button>
  79. </view>
  80. </view>
  81. </template>
  82. <script>
  83. export default {
  84. data() {
  85. return {
  86. tradeInfo:{
  87. salebuyId:0,
  88. packing:'',
  89. memo:'',
  90. buyer:'',
  91. buyerPhone:'',
  92. unitPrice:0,
  93. address:'',
  94. count:0,
  95. province:'',
  96. area:'',
  97. priceType:'',
  98. invoiceType:'',
  99. acceptType:'',
  100. seller:'',
  101. sellerPhone:'',
  102. packingMoney:0,
  103. type:0,
  104. },
  105. invoiceTypeIndex:0,
  106. invoiceTypeIndex1:0,
  107. acceptTypeIndex:0,
  108. priceTypeIndex:0,
  109. bankNameIndex:0,
  110. packingIndex:0,
  111. packingType: ['散装', '袋装'],
  112. invoiceType: ['不开发票', '普通发票', '增值税发票'],
  113. invoiceType1: ['不开发票','增值税发票'],
  114. acceptType: ['第三方检验(国家检验资质)', '交收地库或港出具的检验', '现场看货','其他'],
  115. priceType: ['库内价', '到库价', '到港价'],
  116. priceTypeIndex1:'库内价',
  117. region: [],
  118. salebuyId:0,
  119. memo:'',
  120. buyer:'',
  121. buyerPhone:'',
  122. unitPrice:0,
  123. address:'',
  124. count:0,
  125. price:'库内价',
  126. invoice:'不开发票',
  127. accept:'',
  128. seller:'',
  129. sellerPhone:'',
  130. minSale:'',
  131. province:'',
  132. city:'',
  133. area:'',
  134. storeName:'',
  135. exsitCount:0,
  136. isFutures:'',
  137. bankNameList:'',
  138. Company:[],
  139. companyId:'',
  140. tradeCompanyId:'',
  141. basis:0,
  142. basisBig:0,
  143. basisSmall:0,
  144. invoiceMoney:0,
  145. unloadingFee:0,
  146. packingMoney:0,
  147. packing:'散装'
  148. };
  149. },
  150. onLoad(options) {
  151. this.salebuyId = options.id
  152. this.seller = options.seller
  153. this.sellerPhone = options.sellerPhone
  154. this.isFutures = options.isFutures
  155. this.minSale = options.minSale
  156. this.companyId=options.companyId
  157. this.province = options.province
  158. this.city = options.city
  159. this.area = options.area
  160. this.storeName=options.storeName
  161. this.exsitCount = Math.floor(options.exsitCount * 100) / 100
  162. this.basis = options.basis
  163. this.basisBig = options.basisBig
  164. this.basisSmall = options.basisSmall
  165. this.unloadingFee = options.unloadingFee
  166. },
  167. onShow() {
  168. var that=this
  169. this.$api.request('company', 'getCompany', failres => {
  170. that.$api.msg(failres.errmsg)
  171. uni.hideLoading()
  172. }).then(res => {
  173. if(res.data.code=='SUCCESS'){
  174. var data=[]
  175. this.Company=res.data.data
  176. if(res.data.data){
  177. for(let i=0;i<res.data.data.length;i++){
  178. data.push(res.data.data[i].companyName+' '+res.data.data[i].companyPhone)
  179. }
  180. }
  181. if(this.Company){
  182. this.buyer =this.Company[0].companyName
  183. this.buyerPhone=this.Company[0].companyPhone
  184. this.tradeCompanyId=this.Company[0].id
  185. }
  186. that.bankNameList=data
  187. uni.hideLoading()
  188. }else{
  189. that.$api.msg(res.data.code)
  190. uni.hideLoading()
  191. }
  192. })
  193. // uni.getLocation({
  194. // type: 'wgs84',
  195. // geocode:true,
  196. // success: function (res) {
  197. // console.log('当前位置的经度:' + res.longitude);
  198. // console.log('当前位置的纬度:' + res.latitude);
  199. // }
  200. // });
  201. },
  202. methods: {
  203. InvoiceTypeChange(e) {
  204. this.invoiceTypeIndex = e.detail.value
  205. this.invoice = this.invoiceType[this.invoiceTypeIndex];
  206. },
  207. InvoiceTypeChange1(e) {
  208. this.invoiceTypeIndex1 = e.detail.value
  209. this.invoice = this.invoiceType1[this.invoiceTypeIndex1];
  210. if(this.invoiceTypeIndex1 == 0){
  211. this.invoiceMoney = 0
  212. }
  213. else{
  214. this.invoiceMoney = 20
  215. }
  216. },
  217. bankNameChange(e){
  218. this.bankNameIndex=e.detail.value
  219. this.buyer =this.Company[e.detail.value].companyName
  220. this.buyerPhone=this.Company[e.detail.value].companyPhone
  221. this.tradeCompanyId=this.Company[e.detail.value].id
  222. },
  223. AcceptTypeChange(e) {
  224. this.acceptTypeIndex = e.detail.value
  225. this.accept = this.acceptType[this.acceptTypeIndex];
  226. },
  227. packingChange(e){
  228. this.packingIndex = e.detail.value
  229. this.packing = this.packingType[this.packingIndex];
  230. if(this.packingIndex == 0){
  231. this.packingMoney = 0
  232. }
  233. else if(this.packingIndex == 1){
  234. this.packingMoney = this.basisBig - this.basis
  235. }
  236. else if(this.packingIndex == 2){
  237. this.packingMoney = this.basisSmall - this.basis
  238. }
  239. },
  240. changeZhihang(){
  241. uni.navigateTo({
  242. url: '/pageA/pages/newcompany'
  243. })
  244. },
  245. PriceTypeChange(e) {
  246. this.priceTypeIndex = e.detail.value
  247. this.price = this.priceType[this.priceTypeIndex]
  248. },
  249. RegionChange(e) {
  250. this.region = e.detail.value
  251. this.province = this.region[0];
  252. this.area = this.region[0]+this.region[1]+this.region[2];
  253. },
  254. textareaInput(e) {
  255. this.memo = e.detail.value
  256. },
  257. packingInput(e){
  258. this.packing = e.detail.value
  259. },
  260. buyerInput(e){
  261. this.buyer = e.detail.value
  262. },
  263. buyerPhoneInput(e){
  264. this.buyerPhone = e.detail.value
  265. },
  266. unitPriceInput(e){
  267. this.unitPrice = e.detail.value
  268. },
  269. addressInput(e){
  270. this.address = e.detail.value
  271. },
  272. countInput(e){
  273. this.count = e.detail.value
  274. },
  275. commit(){
  276. const that = this
  277. if ( that.companyId !=2 && !that.area ) {
  278. that.$api.msg('请选择省市区');
  279. return
  280. }
  281. if ( that.companyId !=2&& !that.address) {
  282. that.$api.msg('请填写详细交收地址')
  283. return
  284. }
  285. if (!that.price) {
  286. that.$api.msg('请选择价格类型')
  287. return
  288. }
  289. if (!that.invoice) {
  290. that.$api.msg('请选择发票类型')
  291. return
  292. }
  293. // if(!that.accept&&that.isFutures==0){
  294. // that.$api.msg('请选择质量验收方式');
  295. // return
  296. // }
  297. if(!that.unitPrice){
  298. that.$api.msg('请填写协议价格(元/吨)');
  299. return
  300. }
  301. if(!that.count){
  302. that.$api.msg('请填写购买数量(吨)');
  303. return
  304. }
  305. if(Number(that.count) < Number(that.minSale)){
  306. that.$api.msg('购买数量不能小于最小成交量');
  307. return
  308. }
  309. if(!that.tradeCompanyId){
  310. that.$api.msg('请选择公司名头');
  311. return
  312. }
  313. // if(that.count > that.exsitCount){
  314. // that.$api.msg('购买数量大于库存量');
  315. // return
  316. // }
  317. //this.$api.prePage()获取上一页实例,可直接调用上页所有数据和方法,在App.vue定义
  318. //this.$api.msg(`地址${this.manageType=='edit' ? '修改': '添加'}成功`);
  319. that.tradeInfo.salebuyId = that.salebuyId
  320. that.tradeInfo.buyer = that.buyer
  321. that.tradeInfo.buyerPhone = that.buyerPhone
  322. that.tradeInfo.priceType = that.price
  323. that.tradeInfo.unitPrice = that.unitPrice
  324. that.tradeInfo.province = that.province
  325. that.tradeInfo.area = that.area
  326. that.tradeInfo.address = that.address
  327. that.tradeInfo.count = that.count
  328. that.tradeInfo.acceptType = that.accept
  329. that.tradeInfo.invoiceType = that.invoice
  330. that.tradeInfo.packing = that.packing
  331. that.tradeInfo.packingMoney = that.packingMoney
  332. that.tradeInfo.memo = that.memo
  333. that.tradeInfo.seller = that.seller
  334. that.tradeInfo.sellerPhone = that.sellerPhone
  335. that.tradeInfo.tradeCompanyId = that.tradeCompanyId
  336. that.tradeInfo.invoiceMoney = that.invoiceMoney
  337. // that.tradeInfo.unloadingFee = that.unloadingFee
  338. uni.showLoading({
  339. title: '正在提交',
  340. mask:true
  341. })
  342. that.$api.request('trade', 'addTrade',that.tradeInfo, failres => {
  343. uni.hideLoading()
  344. that.$api.msg(failres.errmsg);
  345. }).then(res => {
  346. uni.hideLoading()
  347. uni.showModal({
  348. title: '提示',
  349. content: "交易申请提交成功",
  350. showCancel: false,
  351. confirmText: '确定',
  352. success: () => {
  353. uni.navigateBack({
  354. delta: 2
  355. })
  356. }
  357. })
  358. // that.$api.prePage().refreshList(data, that.manageType);
  359. })
  360. }
  361. }
  362. }
  363. </script>
  364. <style scoped>
  365. .cu-form-group input {
  366. text-align: right;
  367. }
  368. .cu-form-group textarea {
  369. text-align: right;
  370. }
  371. .margin-bottom{
  372. margin-bottom:30px;
  373. }
  374. .c-row {
  375. display: -webkit-box;
  376. display: -webkit-flex;
  377. display: flex;
  378. -webkit-box-align: center;
  379. -webkit-align-items: center;
  380. align-items: center;
  381. padding: 20rpx 30rpx;
  382. position: relative;
  383. }
  384. .con-list {
  385. -webkit-box-flex: 1;
  386. -webkit-flex: 1;
  387. flex: 1;
  388. display: -webkit-box;
  389. display: -webkit-flex;
  390. display: flex;
  391. -webkit-box-orient: vertical;
  392. -webkit-box-direction: normal;
  393. -webkit-flex-direction: column;
  394. flex-direction: column;
  395. color: #303133;
  396. line-height: 40rpx;
  397. text-align: right;
  398. padding-right: 20rpx;
  399. }
  400. </style>