buyGrain.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597
  1. <template>
  2. <view class="center">
  3. <view class="buyup">
  4. <view class="c-row b-b">
  5. <text class="tit">名头</text>
  6. <view class="con-list">
  7. <text @click="navToDetailPage">{{deptList.procurementPlanNo}}</text>
  8. </view>
  9. </view>
  10. <view class="c-row b-b">
  11. <text class="tit">标题</text>
  12. <view class="con-list">
  13. <input maxlength='16' minlength='2' placeholder="请输入标题,不超过16个字" name="input"
  14. v-model="deptList.title"></input>
  15. </view>
  16. </view>
  17. <view class="c-row b-b">
  18. <text class="tit">货名</text>
  19. <view class="con-list">
  20. <input placeholder="请输入货名,如玉米" name="input" v-model="deptList.goodsName"></input>
  21. </view>
  22. </view>
  23. <view class="c-row b-b">
  24. <text class="tit">采购量(吨)</text>
  25. <view class="con-list">
  26. <input placeholder="请输入采购重量,如1000" name="input" v-model="deptList.plannedPurchaseVolume"></input>
  27. </view>
  28. </view>
  29. <view class="c-row b-b">
  30. <text class="tit">最小成交量(吨)</text>
  31. <view class="con-list">
  32. <input placeholder="请输入最小成交量" name="input" v-model="deptList.minimumVolume"></input>
  33. </view>
  34. </view>
  35. <view class="c-row b-b">
  36. <text class="tit">类型</text>
  37. <picker @change="typeChange" :value="typesIndex" :range="typesType" class="con-list">
  38. <view class="picker" v-model="deptList.procurementPlanType">
  39. {{typesIndex>-1?typesType[typesIndex]:'请选择类型'}}
  40. </view>
  41. </picker>
  42. </view>
  43. <view class="c-row b-b">
  44. <text class="tit">价格类型</text>
  45. <view class="con-list">
  46. <!-- <input placeholder="请填写价格类型" name="input" v-model="deptList.priceType"></input> -->
  47. {{deptList.priceType}}
  48. </view>
  49. </view>
  50. <view class="c-row b-b" v-if="this.typesIndex != 1">
  51. <text class="tit">单价(元/吨)</text>
  52. <view class="con-list">
  53. <input placeholder="请填写单价" name="input" v-model="deptList.unitPrice"></input>
  54. </view>
  55. </view>
  56. <view class="c-row b-b" v-if="this.typesIndex == 1">
  57. <text class="tit">基差(元/吨)</text>
  58. <view class="con-list">
  59. <input placeholder="请输入基差" name="input" v-model="deptList.basisPrice"></input>
  60. </view>
  61. </view>
  62. <view class="c-row b-b">
  63. <text class="tit">收货地区</text>
  64. <view class="con-list">
  65. <view @click='regionchange'>{{region}}</view>
  66. <u-picker :params='params' @confirm='regionpicker' mode="region" v-model="show"></u-picker>
  67. </view>
  68. </view>
  69. <view class="c-row b-b">
  70. <text class="tit">买方手机号</text>
  71. <view class="con-list">
  72. <input placeholder="请输入买方手机号" name="input" v-model="deptList.buyerPhone"></input>
  73. </view>
  74. </view>
  75. <view class="c-row ">
  76. <text class="validate">获取验证码</text>
  77. <view class="con-list">
  78. <input placeholder="请填写6位短信验证码" name="input" v-model="deptList.title1"></input>
  79. </view>
  80. </view>
  81. </view>
  82. <view class="buylow">
  83. <view class="c-row ">
  84. <checkbox style='transform: scale(0.8);' :checked="checked" @click='checkedbox'></checkbox><text
  85. style="font-size: 14px; ">完善更多信息<text
  86. style="font-size: 10px; color: #AFB3BF;">(选填,可由客服人员代为完善)</text></text>
  87. </view>
  88. <view v-if='!checked' class="c-row b-b">
  89. <text class="tit">水分(%)<= </text>
  90. <view class="con-list">
  91. <input placeholder="请填写水分占比" name="input" v-model="deptList.waterContent"></input>
  92. </view>
  93. </view>
  94. <view v-if='!checked' class="c-row b-b">
  95. <text class="tit">容重(g/L)<= </text>
  96. <view class="con-list">
  97. <input placeholder="请填写容重" name="input" v-model="deptList.bulkDensity"></input>
  98. </view>
  99. </view>
  100. <view v-if='!checked' class="c-row b-b">
  101. <text class="tit">热损伤(%)<= </text>
  102. <view class="con-list">
  103. <input placeholder="请填写热损伤占比" name="input" v-model="deptList.jiaorenli"></input>
  104. </view>
  105. </view>
  106. <view v-if='!checked' class="c-row b-b">
  107. <text class="tit">杂质(%)<= </text>
  108. <view class="con-list">
  109. <input placeholder="请填写杂质占比" name="input" v-model="deptList.impurity"></input>
  110. </view>
  111. </view>
  112. <view v-if='!checked' class="c-row b-b">
  113. <text class="tit">霉变粒(%)<= </text>
  114. <view class="con-list">
  115. <input placeholder="请填写霉变粒占比" name="input" v-model="deptList.mildewGrain"></input>
  116. </view>
  117. </view>
  118. <view v-if='!checked' class="c-row b-b">
  119. <text class="tit">不完整粒(%)<= </text>
  120. <view class="con-list">
  121. <input placeholder="请填写不完整粒占比" name="input" v-model="deptList.imperfectGrain"></input>
  122. </view>
  123. </view>
  124. <view v-if='!checked' class="c-row b-b">
  125. <text class="tit">蛋白(%)<= </text>
  126. <view class="con-list">
  127. <input placeholder="请填写蛋白占比" name="input" v-model="deptList.protein"></input>
  128. </view>
  129. </view>
  130. <view v-if='!checked' class="c-row b-b">
  131. <text class="tit">粒型 </text>
  132. <picker @change="liChange" :value="liIndex" :range="liType" class="con-list" v-model="deptList.grain">
  133. <view class="con-list">
  134. {{liIndex>-1?liType[liIndex]:'请选择粒型'}}
  135. </view>
  136. </picker>
  137. </view>
  138. <view v-if='!checked' class="c-row b-b">
  139. <text class="tit">品级 </text>
  140. <picker @change="pinChange" :value="pinIndex" :range="pinType" class="con-list">
  141. <view class="con-list">
  142. {{pinIndex>-1?pinType[pinIndex]:'请选择品级'}}
  143. </view>
  144. </picker>
  145. </view>
  146. <view v-if='!checked' class="c-row b-b">
  147. <text class="tit">产地</text>
  148. <view class="con-list">
  149. <view @click='regionchange1'>{{region1}}</view>
  150. <u-picker :params='params1' @confirm='regionpicker1' mode="region" v-model="show1"></u-picker>
  151. </view>
  152. </view>
  153. <view v-if='!checked' class="c-row b-b">
  154. <text class="tit">产出年份</text>
  155. <picker @change="nianChange" :value="nianIndex" :range="nianType" class="con-list">
  156. <view class="con-list">
  157. {{nianIndex>-1?nianType[nianIndex]:'请选择产出年份'}}
  158. </view>
  159. </picker>
  160. </view>
  161. <view v-if='!checked' class="c-row b-b">
  162. <text class="tit">包装方式</text>
  163. <picker @change="baoChange" :value="baoIndex" :range="baoType" class="con-list">
  164. <view class="con-list">
  165. {{baoIndex>-1?baoType[baoIndex]:'请选择包装方式'}}
  166. </view>
  167. </picker>
  168. </view>
  169. <view v-if='!checked&&baoIndex==2||!checked&&baoIndex==3' class="c-row b-b">
  170. <text class="tit">袋装备注</text>
  171. <view class="con-list">
  172. <input placeholder="请填写袋装备注" name="input" v-model="deptList.baggingNotes"></input>
  173. </view>
  174. </view>
  175. <view v-if='!checked' class="c-row b-b">
  176. <text class="tit">运费承担方</text>
  177. <picker @change="chengChange" :value="chengIndex" :range="chengType" class="con-list">
  178. <view class="con-list">
  179. {{chengIndex>-1?chengType[chengIndex]:'请选择运费承担方'}}
  180. </view>
  181. </picker>
  182. </view>
  183. </view>
  184. <button @click="commit()" class="btn">发布</button>
  185. </view>
  186. </template>
  187. <script>
  188. import {
  189. mapState
  190. } from 'vuex';
  191. export default {
  192. data() {
  193. return {
  194. types: '',
  195. goods: {},
  196. typesType: ["现货", "期货"],
  197. typesIndex: 0,
  198. deptList: {
  199. salePlanTypeKey: 0,
  200. grainKey: 0,
  201. gradeKey: 0,
  202. packingTypeKey: 0,
  203. freightPayerKey: 0,
  204. priceType: "定价采购",
  205. procurementPlanType: "现货",
  206. grain: "塔粮",
  207. grade: "不限(默认)",
  208. outputYear: "2020",
  209. packingType: "不限(默认)",
  210. freightPayer: "",
  211. },
  212. params: {
  213. province: true,
  214. city: true,
  215. area: true,
  216. },
  217. params1: {
  218. province: true,
  219. city: true,
  220. },
  221. checked: true,
  222. insertProcurementPlanInfo: {},
  223. liIndex: 0,
  224. liType: ['塔粮', '筛粮', '中粒', '大粒'],
  225. pinIndex: 0,
  226. pinType: ['不限(默认)', '一等品', '二等品', '三等品', '等外'],
  227. nianIndex: 3,
  228. nianType: ['2023', '2022', '2021', '2020', '2019', '2018', '2017', '2016', '2015', '2014', '2013', '2012',
  229. '2011'
  230. ],
  231. show: false,
  232. show1: false,
  233. region: '请选择收货地区',
  234. region1: '请选择产地',
  235. baoIndex: 0,
  236. baoType: ['不限(默认)', '散装', '大袋', '小袋'],
  237. chengIndex: -1,
  238. chengType: ['可议', '买方承担', '卖方承担']
  239. }
  240. },
  241. computed: {
  242. ...mapState(['hasLogin', 'userInfo'])
  243. },
  244. onLoad(options) {
  245. if (options.customerName) {
  246. this.deptList.procurementPlanNo = options.customerName
  247. }
  248. },
  249. onShow() {
  250. var that = this
  251. this.$api.doRequest('get', '/identityAuthenticationInfo/getInfo', {
  252. commonId: this.userInfo.id
  253. }).then(res => {
  254. if (res.data.code == 200) {
  255. if (res.data.data.customerTypeFlag == 1) {
  256. that.$set(this.deptList, 'procurementPlanNo', res.data.data.customerName)
  257. } else {
  258. that.$set(this.deptList, 'procurementPlanNo', res.data.data.compName)
  259. }
  260. this.goods = res.data.data
  261. }
  262. uni.hideLoading()
  263. })
  264. },
  265. methods: {
  266. regionpicker(e) {
  267. this.deptList.receivePrivate = e.province.label
  268. this.deptList.receiveCity = e.city.label
  269. this.deptList.receiveArea = e.area.label
  270. this.region = e.province.label + '-' + e.city.label + '-' + e.area.label
  271. },
  272. regionchange() {
  273. this.show = true
  274. },
  275. regionpicker1(e) {
  276. this.deptList.outputPrivate = e.province.label
  277. this.deptList.outputCity = e.city.label
  278. this.region1 = e.province.label + '-' + e.city.label
  279. },
  280. regionchange1() {
  281. this.show1 = true
  282. },
  283. checkedbox(e) {
  284. this.checked = !this.checked
  285. },
  286. typeChange(e) {
  287. this.typesIndex = e.detail.value
  288. this.types = this.typesType[this.typesIndex];
  289. this.deptList.procurementPlanTypeKey = e.detail.value + 1
  290. this.deptList.procurementPlanType = this.typesType[this.typesIndex];
  291. if (this.typesIndex == 0) {
  292. this.deptList.priceType = '定价采购'
  293. } else {
  294. this.deptList.priceType = '期货盘面价+基差'
  295. }
  296. },
  297. navToDetailPage() {
  298. uni.navigateTo({
  299. url: `/pageD/myRelease/Identity_switching`
  300. })
  301. },
  302. commit() {
  303. if (!this.deptList.title) {
  304. this.$api.msg('标题不能为空')
  305. return
  306. }
  307. if (this.deptList.title.length > 16 || this.deptList.title.length < 2) {
  308. this.$api.msg('标题输入错误')
  309. return
  310. }
  311. if (!this.deptList.goodsName) {
  312. this.$api.msg('货名不能为空')
  313. return
  314. }
  315. if (this.deptList.goodsName.length > 6 || this.deptList.goodsName.length < 1) {
  316. this.$api.msg('货名输入错误')
  317. return
  318. }
  319. if (!this.deptList.plannedPurchaseVolume) {
  320. this.$api.msg('采购量不能为空')
  321. return
  322. }
  323. if (this.deptList.plannedPurchaseVolume > 100000 || this.deptList.plannedPurchaseVolume < 1) {
  324. this.$api.msg('采购量输入错误')
  325. return
  326. }
  327. if (this.deptList.plannedPurchaseVolume.indexOf('.') != -1) {
  328. if (this.deptList.plannedPurchaseVolume.split('.')[1].length > 2) {
  329. this.$api.msg('采购量输入错误')
  330. return
  331. }
  332. }
  333. if (!this.deptList.minimumVolume) {
  334. this.$api.msg('最小成交量不能为空')
  335. return
  336. }
  337. if (this.deptList.minimumVolume > 100000 || this.deptList.minimumVolume < 1) {
  338. this.$api.msg('最小成交量输入错误')
  339. return
  340. }
  341. if (this.deptList.minimumVolume.indexOf('.') != -1) {
  342. if (this.deptList.minimumVolume.split('.')[1].length > 2) {
  343. this.$api.msg('最小成交量输入错误')
  344. return
  345. }
  346. }
  347. if (!this.deptList.procurementPlanType) {
  348. this.$api.msg('类型不能为空')
  349. return
  350. }
  351. if (!this.deptList.priceType) {
  352. this.$api.msg('价格类型不能为空')
  353. return
  354. }
  355. if (this.deptList.procurementPlanType == '现货') {
  356. if (!this.deptList.unitPrice) {
  357. this.$api.msg('单价不能为空')
  358. return
  359. }
  360. if (this.deptList.unitPrice > 100000 || this.deptList.unitPrice < 1) {
  361. this.$api.msg('单价输入错误')
  362. return
  363. }
  364. if (this.deptList.unitPrice.indexOf('.') != -1) {
  365. if (this.deptList.unitPrice.split('.')[1].length > 2) {
  366. this.$api.msg('单价输入错误')
  367. return
  368. }
  369. }
  370. } else if (this.deptList.procurementPlanType == '期货') {
  371. if (!this.deptList.basisPrice) {
  372. this.$api.msg('基差(元/吨)不能为空')
  373. return
  374. }
  375. if (this.deptList.basisPrice > 10000 || this.deptList.basisPrice < 1) {
  376. this.$api.msg('基差输入错误')
  377. return
  378. }
  379. if (this.deptList.basisPrice.indexOf('.') != -1) {
  380. if (this.deptList.basisPrice.split('.')[1].length > 2) {
  381. this.$api.msg('基差输入错误')
  382. return
  383. }
  384. }
  385. }
  386. if (!this.deptList.buyerPhone) {
  387. this.$api.msg('买方手机号不能为空')
  388. return
  389. }
  390. if (this.checked == false) {
  391. if (this.deptList.waterContent && this.deptList.waterContent < 1 ||
  392. this.deptList.waterContent && this.deptList.waterContent > 40) {
  393. this.$api.msg('水分输入错误')
  394. return
  395. }
  396. if (this.deptList.waterContent && this.deptList.waterContent.indexOf('.') != -1) {
  397. if (this.deptList.waterContent.split('.')[1].length > 2) {
  398. this.$api.msg('水分输入错误')
  399. return
  400. }
  401. }
  402. if (this.deptList.bulkDensity && this.deptList.bulkDensity < 500 ||
  403. this.deptList.bulkDensity && this.deptList.bulkDensity > 1000) {
  404. this.$api.msg('容重输入错误')
  405. return
  406. }
  407. if (this.deptList.jiaorenli && this.deptList.jiaorenli < 1 ||
  408. this.deptList.jiaorenli && this.deptList.jiaorenli > 40) {
  409. this.$api.msg('热损伤输入错误')
  410. return
  411. }
  412. if (this.deptList.jiaorenli && this.deptList.jiaorenli.indexOf('.') != -1) {
  413. if (this.deptList.jiaorenli.split('.')[1].length > 2) {
  414. this.$api.msg('热损伤输入错误')
  415. return
  416. }
  417. }
  418. if (this.deptList.impurity && this.deptList.impurity < 1 ||
  419. this.deptList.impurity && this.deptList.impurity > 40) {
  420. this.$api.msg('杂质输入错误')
  421. return
  422. }
  423. if (this.deptList.impurity && this.deptList.impurity.indexOf('.') != -1) {
  424. if (this.deptList.impurity.split('.')[1].length > 2) {
  425. this.$api.msg('杂质输入错误')
  426. return
  427. }
  428. }
  429. if (this.deptList.mildewGrain && this.deptList.mildewGrain < 1 ||
  430. this.deptList.mildewGrain && this.deptList.mildewGrain > 40) {
  431. this.$api.msg('霉变粒输入错误')
  432. return
  433. }
  434. if (this.deptList.mildewGrain && this.deptList.mildewGrain.indexOf('.') != -1) {
  435. if (this.deptList.mildewGrain.split('.')[1].length > 2) {
  436. this.$api.msg('霉变粒输入错误')
  437. return
  438. }
  439. }
  440. if (this.deptList.imperfectGrain && this.deptList.imperfectGrain < 1 ||
  441. this.deptList.imperfectGrain && this.deptList.imperfectGrain > 40) {
  442. this.$api.msg('不完整粒输入错误')
  443. return
  444. }
  445. if (this.deptList.imperfectGrain && this.deptList.imperfectGrain.indexOf('.') != -1) {
  446. if (this.deptList.imperfectGrain.split('.')[1].length > 2) {
  447. this.$api.msg('不完整粒输入错误')
  448. return
  449. }
  450. }
  451. if (this.deptList.protein && this.deptList.protein < 1 ||
  452. this.deptList.protein && this.deptList.protein > 80) {
  453. this.$api.msg('蛋白输入错误')
  454. return
  455. }
  456. if (this.deptList.protein && this.deptList.protein.indexOf('.') != -1) {
  457. if (this.deptList.protein.split('.')[1].length > 2) {
  458. this.$api.msg('蛋白输入错误')
  459. return
  460. }
  461. }
  462. }
  463. this.insertProcurementPlanInfo = this.deptList
  464. this.insertProcurementPlanInfo.basisPrice = -this.insertProcurementPlanInfo.basisPrice
  465. this.insertProcurementPlanInfo.commonId = this.userInfo.id
  466. this.insertProcurementPlanInfo.compId = "2710b21efc1e4393930c5dc800010dc4"
  467. this.$api.doRequest('post', '/procurementPlanInfo/api/insertProcurementPlanInfo', this
  468. .insertProcurementPlanInfo).then(res => {
  469. if (res.data.code == 200) {
  470. uni.showToast({
  471. title: "发布成功",
  472. icon: 'none',
  473. })
  474. // setTimeout(() => {
  475. // uni.navigateBack({})
  476. // }, 1000)
  477. this.deptList = {}
  478. uni.navigateTo({
  479. url: `/pages/release/release`
  480. })
  481. } else {
  482. uni.showToast({
  483. title: res.data.message,
  484. icon: 'none',
  485. duration: 2000
  486. })
  487. }
  488. })
  489. .catch(res => {
  490. uni.showToast({
  491. title: res.errmsg,
  492. icon: 'none',
  493. duration: 2000
  494. })
  495. });
  496. },
  497. liChange(e) {
  498. this.liIndex = e.detail.value
  499. this.litypes = this.liType[this.liIndex];
  500. this.deptList.grainKey = e.detail.value + 1
  501. this.deptList.grain = this.liType[this.liIndex]
  502. },
  503. pinChange(e) {
  504. this.pinIndex = e.detail.value
  505. this.pintypes = this.pinType[this.pinIndex];
  506. this.deptList.gradeKey = e.detail.value
  507. this.deptList.grade = this.pinType[this.pinIndex]
  508. },
  509. nianChange(e) {
  510. this.nianIndex = e.detail.value
  511. this.niantypes = this.nianType[this.nianIndex];
  512. this.deptList.outputYear = this.baoType[this.baoIndex]
  513. },
  514. baoChange(e) {
  515. this.baoIndex = e.detail.value
  516. this.baotypes = this.baoType[this.baoIndex];
  517. this.deptList.packingTypeKey = e.detail.value
  518. this.deptList.packingType = this.baoType[this.baoIndex];
  519. },
  520. chengChange(e) {
  521. this.chengIndex = e.detail.value
  522. this.chengtypes = this.chengType[this.chengIndex];
  523. this.deptList.freightPayerKey = e.detail.value + 1
  524. this.deptList.freightPayer = this.chengType[this.chengIndex];
  525. }
  526. }
  527. }
  528. </script>
  529. <style>
  530. .center {
  531. padding: 10px 20px;
  532. background-color: #F5F6FA;
  533. }
  534. .c-row {
  535. display: -webkit-box;
  536. display: -webkit-flex;
  537. display: flex;
  538. -webkit-box-align: center;
  539. -webkit-align-items: center;
  540. align-items: center;
  541. padding: 20rpx 30rpx;
  542. position: relative;
  543. }
  544. .con-list {
  545. -webkit-box-flex: 1;
  546. -webkit-flex: 1;
  547. flex: 1;
  548. display: -webkit-box;
  549. display: -webkit-flex;
  550. display: flex;
  551. -webkit-box-orient: vertical;
  552. -webkit-box-direction: normal;
  553. -webkit-flex-direction: column;
  554. flex-direction: column;
  555. color: #AFB3BF;
  556. line-height: 40rpx;
  557. text-align: right;
  558. padding-right: 20rpx;
  559. font-size: 14px;
  560. }
  561. .buyup {
  562. background-color: #FFFFFF;
  563. border-radius: 20px;
  564. margin-top: 10px;
  565. }
  566. .buylow {
  567. background-color: #FFFFFF;
  568. border-radius: 20px;
  569. margin-top: 10px;
  570. }
  571. .btn {
  572. border-radius: 20px;
  573. margin-top: 10px;
  574. background-color: #22C572;
  575. color: #FFFFFF;
  576. }
  577. .validate {
  578. width: 100px;
  579. height: 32px;
  580. background-color: #F5F6F9;
  581. color: #AFB3BF;
  582. border-radius: 10px;
  583. border: none;
  584. text-align: center;
  585. line-height: 30px;
  586. }
  587. </style>