trade.vue 14 KB

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