trade_buy.vue 12 KB

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