sellGrain.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606
  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.plannedSaleVolume"></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.salePlanType">
  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 == 0">
  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='regionchange1'>{{region1}}</view>
  66. <u-picker :params='params1' @confirm='regionpicker1' mode="region" v-model="show1"></u-picker>
  67. </view>
  68. </view>
  69. <view class="c-row b-b">
  70. <text class="tit">发货地区</text>
  71. <view class="con-list">
  72. <view @click='regionchange'>{{region}}</view>
  73. <u-picker :params='params' @confirm='regionpicker' mode="region" v-model="show"></u-picker>
  74. </view>
  75. </view>
  76. <view class="c-row b-b">
  77. <text class="tit">卖方手机号</text>
  78. <view class="con-list">
  79. <input placeholder="请输入买方手机号" name="input" v-model="deptList.sellerPhone"></input>
  80. </view>
  81. </view>
  82. <view class="c-row ">
  83. <text class="validate">获取验证码</text>
  84. <view class="con-list">
  85. <input placeholder="请填写6位短信验证码" name="input" v-model="deptList.title1"></input>
  86. </view>
  87. </view>
  88. </view>
  89. <view class="buylow">
  90. <view class="c-row ">
  91. <checkbox style='transform: scale(0.8);' :checked="checked" @click='checkedbox'></checkbox><text
  92. style="font-size: 14px; ">完善更多信息<text
  93. style="font-size: 10px; color: #AFB3BF;">(选填,可由客服人员代为完善)</text></text>
  94. </view>
  95. <view v-if='!checked' class="c-row b-b">
  96. <text class="tit">水分(%)<= </text>
  97. <view class="con-list">
  98. <input placeholder="请填写水分占比" name="input" v-model="deptList.waterContent"></input>
  99. </view>
  100. </view>
  101. <view v-if='!checked' class="c-row b-b">
  102. <text class="tit">容重(g/L)<= </text>
  103. <view class="con-list">
  104. <input placeholder="请填写容重" name="input" v-model="deptList.bulkDensity"></input>
  105. </view>
  106. </view>
  107. <view v-if='!checked' class="c-row b-b">
  108. <text class="tit">热损伤(%)<= </text>
  109. <view class="con-list">
  110. <input placeholder="请填写热损伤占比" name="input" v-model="deptList.jiaorenli"></input>
  111. </view>
  112. </view>
  113. <view v-if='!checked' class="c-row b-b">
  114. <text class="tit">杂质(%)<= </text>
  115. <view class="con-list">
  116. <input placeholder="请填写杂质占比" name="input" v-model="deptList.impurity"></input>
  117. </view>
  118. </view>
  119. <view v-if='!checked' class="c-row b-b">
  120. <text class="tit">霉变粒(%)<= </text>
  121. <view class="con-list">
  122. <input placeholder="请填写霉变粒占比" name="input" v-model="deptList.mildewGrain"></input>
  123. </view>
  124. </view>
  125. <view v-if='!checked' class="c-row b-b">
  126. <text class="tit">不完整粒(%)<= </text>
  127. <view class="con-list">
  128. <input placeholder="请填写不完整粒占比" name="input" v-model="deptList.imperfectGrain"></input>
  129. </view>
  130. </view>
  131. <view v-if='!checked' class="c-row b-b">
  132. <text class="tit">蛋白(%)<= </text>
  133. <view class="con-list">
  134. <input placeholder="请填写蛋白占比" name="input" v-model="deptList.protein"></input>
  135. </view>
  136. </view>
  137. <view v-if='!checked' class="c-row b-b">
  138. <text class="tit">粒型 </text>
  139. <picker @change="liChange" :value="liIndex" :range="liType" class="con-list" v-model="deptList.grain">
  140. <view class="con-list">
  141. {{liIndex>-1?liType[liIndex]:'请选择粒型'}}
  142. </view>
  143. </picker>
  144. </view>
  145. <view v-if='!checked' class="c-row b-b">
  146. <text class="tit">品级 </text>
  147. <picker @change="pinChange" :value="pinIndex" :range="pinType" class="con-list">
  148. <view class="con-list">
  149. {{pinIndex>-1?pinType[pinIndex]:'请选择品级'}}
  150. </view>
  151. </picker>
  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:-1,
  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.sendPrivate = e.province.label
  268. this.deptList.sendCity = e.city.label
  269. this.deptList.sendArea = 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.salePlanTypeKey = e.detail.value+1
  290. this.deptList.salePlanType = this.typesType[this.typesIndex];
  291. if (this.typesIndex == 0) {
  292. this.deptList.priceType = '定价采购'
  293. } else {
  294. this.deptList.priceType = '期货盘面价+基差'
  295. }
  296. },
  297. navToDetailPage() {
  298. // if (index == 1) {
  299. uni.navigateTo({
  300. url: `/pageD/myRelease/Identity_switching`
  301. })
  302. },
  303. commit() {
  304. if (!this.deptList.title) {
  305. this.$api.msg('标题不能为空')
  306. return
  307. }
  308. if (this.deptList.title.length > 16 || this.deptList.title.length < 2) {
  309. this.$api.msg('标题输入错误')
  310. return
  311. }
  312. if (!this.deptList.goodsName) {
  313. this.$api.msg('货名不能为空')
  314. return
  315. }
  316. if (this.deptList.goodsName.length > 6 || this.deptList.goodsName.length < 1) {
  317. this.$api.msg('货名输入错误')
  318. return
  319. }
  320. if (!this.deptList.plannedSaleVolume) {
  321. this.$api.msg('出货量不能为空')
  322. return
  323. }
  324. if (this.deptList.plannedSaleVolume > 100000 || this.deptList.plannedSaleVolume < 1) {
  325. this.$api.msg('出货量输入错误')
  326. return
  327. }
  328. if (this.deptList.plannedSaleVolume.indexOf('.') != -1) {
  329. if (this.deptList.plannedSaleVolume.split('.')[1].length > 2) {
  330. this.$api.msg('出货量输入错误')
  331. return
  332. }
  333. }
  334. if (!this.deptList.minimumVolume) {
  335. this.$api.msg('最小成交量不能为空')
  336. return
  337. }
  338. if (this.deptList.minimumVolume > 100000 || this.deptList.minimumVolume < 1) {
  339. this.$api.msg('最小成交量输入错误')
  340. return
  341. }
  342. if (this.deptList.minimumVolume.indexOf('.') != -1) {
  343. if (this.deptList.minimumVolume.split('.')[1].length > 2) {
  344. this.$api.msg('最小成交量输入错误')
  345. return
  346. }
  347. }
  348. if (!this.deptList.salePlanType) {
  349. this.$api.msg('类型不能为空')
  350. return
  351. }
  352. if (!this.deptList.priceType) {
  353. this.$api.msg('价格类型不能为空')
  354. return
  355. }
  356. if (this.deptList.salePlanType == '现货') {
  357. if (!this.deptList.unitPrice) {
  358. this.$api.msg('单价不能为空')
  359. return
  360. }
  361. if (this.deptList.unitPrice > 100000 || this.deptList.unitPrice < 1) {
  362. this.$api.msg('单价输入错误')
  363. return
  364. }
  365. if (this.deptList.unitPrice.indexOf('.') != -1) {
  366. if (this.deptList.unitPrice.split('.')[1].length > 2) {
  367. this.$api.msg('单价输入错误')
  368. return
  369. }
  370. }
  371. } else if (this.deptList.salePlanType == '期货') {
  372. if (!this.deptList.basisPrice) {
  373. this.$api.msg('基差(元/吨)不能为空')
  374. return
  375. }
  376. if (this.deptList.basisPrice > 10000 || this.deptList.basisPrice < 1) {
  377. this.$api.msg('基差输入错误')
  378. return
  379. }
  380. if (this.deptList.basisPrice.indexOf('.') != -1) {
  381. if (this.deptList.basisPrice.split('.')[1].length > 2) {
  382. this.$api.msg('基差输入错误')
  383. return
  384. }
  385. }
  386. }
  387. if (!this.deptList.sellerPhone) {
  388. this.$api.msg('卖方手机号不能为空')
  389. return
  390. }
  391. if (this.checked == false) {
  392. if (this.deptList.waterContent && this.deptList.waterContent < 1 ||
  393. this.deptList.waterContent && this.deptList.waterContent > 40) {
  394. this.$api.msg('水分输入错误')
  395. return
  396. }
  397. if (this.deptList.waterContent && this.deptList.waterContent.indexOf('.') != -1) {
  398. if (this.deptList.waterContent.split('.')[1].length > 2) {
  399. this.$api.msg('水分输入错误')
  400. return
  401. }
  402. }
  403. if (this.deptList.bulkDensity && this.deptList.bulkDensity < 500 ||
  404. this.deptList.bulkDensity && this.deptList.bulkDensity > 1000) {
  405. this.$api.msg('容重输入错误')
  406. return
  407. }
  408. if (this.deptList.jiaorenli && this.deptList.jiaorenli < 1 ||
  409. this.deptList.jiaorenli && this.deptList.jiaorenli > 40) {
  410. this.$api.msg('热损伤输入错误')
  411. return
  412. }
  413. if (this.deptList.jiaorenli && this.deptList.jiaorenli.indexOf('.') != -1) {
  414. if (this.deptList.jiaorenli.split('.')[1].length > 2) {
  415. this.$api.msg('热损伤输入错误')
  416. return
  417. }
  418. }
  419. if (this.deptList.impurity && this.deptList.impurity < 1 ||
  420. this.deptList.impurity && this.deptList.impurity > 40) {
  421. this.$api.msg('杂质输入错误')
  422. return
  423. }
  424. if (this.deptList.impurity && this.deptList.impurity.indexOf('.') != -1) {
  425. if (this.deptList.impurity.split('.')[1].length > 2) {
  426. this.$api.msg('杂质输入错误')
  427. return
  428. }
  429. }
  430. if (this.deptList.mildewGrain && this.deptList.mildewGrain < 1 ||
  431. this.deptList.mildewGrain && this.deptList.mildewGrain > 40) {
  432. this.$api.msg('霉变粒输入错误')
  433. return
  434. }
  435. if (this.deptList.mildewGrain && this.deptList.mildewGrain.indexOf('.') != -1) {
  436. if (this.deptList.mildewGrain.split('.')[1].length > 2) {
  437. this.$api.msg('霉变粒输入错误')
  438. return
  439. }
  440. }
  441. if (this.deptList.imperfectGrain && this.deptList.imperfectGrain < 1 ||
  442. this.deptList.imperfectGrain && this.deptList.imperfectGrain > 40) {
  443. this.$api.msg('不完整粒输入错误')
  444. return
  445. }
  446. if (this.deptList.imperfectGrain && this.deptList.imperfectGrain.indexOf('.') != -1) {
  447. if (this.deptList.imperfectGrain.split('.')[1].length > 2) {
  448. this.$api.msg('不完整粒输入错误')
  449. return
  450. }
  451. }
  452. if (this.deptList.protein && this.deptList.protein < 1 ||
  453. this.deptList.protein && this.deptList.protein > 80) {
  454. this.$api.msg('蛋白输入错误')
  455. return
  456. }
  457. if (this.deptList.protein && this.deptList.protein.indexOf('.') != -1) {
  458. if (this.deptList.protein.split('.')[1].length > 2) {
  459. this.$api.msg('蛋白输入错误')
  460. return
  461. }
  462. }
  463. }
  464. this.insertProcurementPlanInfo = this.deptList
  465. this.insertProcurementPlanInfo.basisPrice = -this.insertProcurementPlanInfo.basisPrice
  466. this.insertProcurementPlanInfo.commonId = this.userInfo.id
  467. this.insertProcurementPlanInfo.compId = "2710b21efc1e4393930c5dc800010dc4"
  468. this.$api.doRequest('post', '/salePlanInfo/api/insertSalePlanInfo', this
  469. .insertProcurementPlanInfo).then(res => {
  470. if (res.data.code == 200) {
  471. uni.showToast({
  472. title: "发布成功",
  473. icon: 'none',
  474. })
  475. // setTimeout(() => {
  476. // uni.navigateBack({})
  477. // }, 1000)
  478. this.deptList = {}
  479. uni.navigateTo({
  480. url: `/pages/release/release`
  481. })
  482. } else {
  483. uni.showToast({
  484. title: res.data.message,
  485. icon: 'none',
  486. duration: 2000
  487. })
  488. }
  489. })
  490. .catch(res => {
  491. uni.showToast({
  492. title: res.errmsg,
  493. icon: 'none',
  494. duration: 2000
  495. })
  496. });
  497. },
  498. liChange(e) {
  499. this.liIndex = e.detail.value
  500. this.litypes = this.liType[this.liIndex];
  501. this.deptList.grainKey = e.detail.value+1
  502. this.deptList.grain = this.liType[this.liIndex]
  503. },
  504. pinChange(e) {
  505. this.pinIndex = e.detail.value
  506. this.pintypes = this.pinType[this.pinIndex];
  507. this.deptList.gradeKey = e.detail.value
  508. this.deptList.grade = this.pinType[this.pinIndex]
  509. },
  510. nianChange(e) {
  511. this.nianIndex = e.detail.value
  512. this.niantypes = this.nianType[this.nianIndex];
  513. this.deptList.outputYear = this.baoType[this.baoIndex]
  514. },
  515. baoChange(e) {
  516. this.baoIndex = e.detail.value
  517. this.baotypes = this.baoType[this.baoIndex];
  518. this.deptList.packingTypeKey = e.detail.value
  519. this.deptList.packingType = this.baoType[this.baoIndex];
  520. },
  521. chengChange(e) {
  522. this.chengIndex = e.detail.value
  523. this.chengtypes = this.chengType[this.chengIndex];
  524. this.deptList.freightPayerKey = e.detail.value+1
  525. this.deptList.freightPayer = this.chengType[this.chengIndex];
  526. }
  527. }
  528. }
  529. </script>
  530. <style>
  531. .center {
  532. padding: 10px 20px;
  533. background-color: #F5F6FA;
  534. }
  535. .c-row {
  536. display: -webkit-box;
  537. display: -webkit-flex;
  538. display: flex;
  539. -webkit-box-align: center;
  540. -webkit-align-items: center;
  541. align-items: center;
  542. padding: 20rpx 30rpx;
  543. position: relative;
  544. }
  545. .con-list {
  546. -webkit-box-flex: 1;
  547. -webkit-flex: 1;
  548. flex: 1;
  549. display: -webkit-box;
  550. display: -webkit-flex;
  551. display: flex;
  552. -webkit-box-orient: vertical;
  553. -webkit-box-direction: normal;
  554. -webkit-flex-direction: column;
  555. flex-direction: column;
  556. color: #AFB3BF;
  557. line-height: 40rpx;
  558. text-align: right;
  559. padding-right: 20rpx;
  560. font-size: 14px;
  561. }
  562. .buyup {
  563. background-color: #FFFFFF;
  564. border-radius: 20px;
  565. margin-top: 10px;
  566. }
  567. .buylow {
  568. background-color: #FFFFFF;
  569. border-radius: 20px;
  570. margin-top: 10px;
  571. }
  572. .btn {
  573. border-radius: 20px;
  574. margin-top: 10px;
  575. background-color: #22C572;
  576. color: #FFFFFF;
  577. }
  578. .validate {
  579. width: 100px;
  580. height: 32px;
  581. background-color: #F5F6F9;
  582. color: #AFB3BF;
  583. border-radius: 10px;
  584. border: none;
  585. text-align: center;
  586. line-height: 30px;
  587. }
  588. </style>