buyGrain.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396
  1. <template>
  2. <view class="center">
  3. <view class="c-row b-b">
  4. <text class="tit">名头</text>
  5. <view class="con-list">
  6. <input placeholder="请填写名头" name="input" v-model="deptList.procurementPlanNo"></input>
  7. </view>
  8. </view>
  9. <view class="c-row b-b">
  10. <text class="tit">标题</text>
  11. <view class="con-list">
  12. <input placeholder="请填写标题,2-16个字" name="input" v-model="deptList.title"></input>
  13. </view>
  14. </view>
  15. <view class="c-row b-b">
  16. <text class="tit">货名</text>
  17. <view class="con-list">
  18. <input placeholder="请填写货名" name="input" v-model="deptList.goodsName"></input>
  19. </view>
  20. </view>
  21. <view class="c-row b-b">
  22. <text class="tit">采购量(吨)</text>
  23. <view class="con-list">
  24. <input placeholder="请填写采购重量" name="input" v-model="deptList.plannedPurchaseVolume"></input>
  25. </view>
  26. </view>
  27. <view class="c-row b-b">
  28. <text class="tit">最小成交量(吨)</text>
  29. <view class="con-list">
  30. <input placeholder="请填写最小成交量" name="input" v-model="deptList.minimumVolume"></input>
  31. </view>
  32. </view>
  33. <view class="c-row b-b">
  34. <text class="tit">类型</text>
  35. <picker @change="typeChange" :value="typesIndex" :range="typesType" class="con-list"
  36. >
  37. <view class="picker" v-model="deptList.procurementPlanType">
  38. {{typesIndex>-1?typesType[typesIndex]:'请选择类型'}}
  39. </view>
  40. </picker>
  41. </view>
  42. <view class="c-row b-b">
  43. <text class="tit">价格类型</text>
  44. <view class="con-list">
  45. <!-- <input placeholder="请填写价格类型" name="input" v-model="deptList.priceType"></input> -->
  46. {{deptList.priceType}}
  47. </view>
  48. </view>
  49. <view class="c-row b-b" v-if="this.typesIndex != 1">
  50. <text class="tit">单价(元/吨)</text>
  51. <view class="con-list">
  52. <input placeholder="请填写单价(元/吨)" name="input" v-model="deptList.unitPrice"></input>
  53. </view>
  54. </view>
  55. <view class="c-row b-b" v-if="this.typesIndex == 1">
  56. <text class="tit">基差(元/吨)</text>
  57. <view class="con-list">
  58. <input placeholder="请填写单价(元/吨)" name="input" v-model="deptList.basisPrice"></input>
  59. </view>
  60. </view>
  61. <view class="c-row b-b">
  62. <text class="tit">收货地区</text>
  63. <view class="con-list">
  64. <input placeholder="请填写收货地区" name="input" v-model="deptList.receiveArea"></input>
  65. </view>
  66. </view>
  67. <view class="c-row b-b">
  68. <text class="tit">买方手机号</text>
  69. <view class="con-list">
  70. <input placeholder="请填写卖方手机号" name="input" v-model="deptList.buyerPhone"></input>
  71. </view>
  72. </view>
  73. <view class="c-row b-b">
  74. <button type="default">获取验证码</button>
  75. <view class="con-list">
  76. <input placeholder="请填写6位短信验证码" name="input" v-model="deptList.title1"></input>
  77. </view>
  78. </view>
  79. <view class="c-row b-b">
  80. <text class="tit">水分(%)<= </text>
  81. <view class="con-list">
  82. <input placeholder="请填写水分占比" name="input" v-model="deptList.waterContent"></input>
  83. </view>
  84. </view>
  85. <view class="c-row b-b">
  86. <text class="tit">容重(g/L)<= </text>
  87. <view class="con-list">
  88. <input placeholder="请填写容重" name="input" v-model="deptList.bulkDensity"></input>
  89. </view>
  90. </view>
  91. <view class="c-row b-b">
  92. <text class="tit">热损伤(%)<= </text>
  93. <view class="con-list">
  94. <input placeholder="请填写热损伤占比" name="input" v-model="deptList.jiaorenli"></input>
  95. </view>
  96. </view>
  97. <view class="c-row b-b">
  98. <text class="tit">杂质(%)<= </text>
  99. <view class="con-list">
  100. <input placeholder="请填写杂质占比" name="input" v-model="deptList.impurity"></input>
  101. </view>
  102. </view>
  103. <view class="c-row b-b">
  104. <text class="tit">霉变粒(%)<= </text>
  105. <view class="con-list">
  106. <input placeholder="请填写霉变粒占比" name="input" v-model="deptList.mildewGrain"></input>
  107. </view>
  108. </view>
  109. <view class="c-row b-b">
  110. <text class="tit">不完整粒(%)<= </text>
  111. <view class="con-list">
  112. <input placeholder="请填写不完整粒占比" name="input" v-model="deptList.imperfectGrain"></input>
  113. </view>
  114. </view>
  115. <view class="c-row b-b">
  116. <text class="tit">蛋白(%)<= </text>
  117. <view class="con-list">
  118. <input placeholder="请填写蛋白占比" name="input" v-model="deptList.protein"></input>
  119. </view>
  120. </view>
  121. <view class="c-row b-b">
  122. <text class="tit">粒型 </text>
  123. <picker @change="liChange" :value="liIndex" :range="liType" class="con-list" v-model="deptList.grain">
  124. <view class="con-list">
  125. {{liIndex>-1?liType[liIndex]:'请选择粒型'}}
  126. </view>
  127. </picker>
  128. </view>
  129. <view class="c-row b-b">
  130. <text class="tit">品级 </text>
  131. <picker @change="pinChange" :value="pinIndex" :range="pinType" class="con-list">
  132. <view class="con-list">
  133. {{pinIndex>-1?pinType[pinIndex]:'请选择品级'}}
  134. </view>
  135. </picker>
  136. </view>
  137. <view class="c-row b-b">
  138. <text class="tit">产出年份</text>
  139. <picker @change="nianChange" :value="nianIndex" :range="nianType" class="con-list">
  140. <view class="con-list">
  141. {{nianIndex>-1?nianType[nianIndex]:'请选择产出年份'}}
  142. </view>
  143. </picker>
  144. </view>
  145. <view class="c-row b-b">
  146. <text class="tit">包装方式</text>
  147. <picker @change="baoChange" :value="baoIndex" :range="baoType" class="con-list">
  148. <view class="con-list">
  149. {{baoIndex>-1?baoType[baoIndex]:'请选择包装方式'}}
  150. </view>
  151. </picker>
  152. </view>
  153. <view class="c-row b-b">
  154. <text class="tit">袋装备注</text>
  155. <view class="con-list">
  156. <input placeholder="请填写袋装备注" name="input" v-model="deptList.baggingNotes"></input>
  157. </view>
  158. </view>
  159. <view class="c-row b-b">
  160. <text class="tit">运费承担方</text>
  161. <picker @change="chengChange" :value="chengIndex" :range="chengType" class="con-list">
  162. <view class="con-list">
  163. {{chengIndex>-1?chengType[chengIndex]:'请选择运费承担方'}}
  164. </view>
  165. </picker>
  166. </view>
  167. <button @click="commit()">发布</button>
  168. </view>
  169. </template>
  170. <script>
  171. import {
  172. mapState
  173. } from 'vuex';
  174. export default {
  175. data() {
  176. return {
  177. types: '',
  178. typesType: ["现货", "期货"],
  179. typesIndex: 0,
  180. deptList: {
  181. priceType: "定价采购",
  182. procurementPlanType:"现货",
  183. grain:"塔粮",
  184. grade:"不限(默认)",
  185. outputYear:"2020",
  186. packingType:"不限(默认)",
  187. freightPayer:"",
  188. },
  189. insertProcurementPlanInfo: {},
  190. liIndex: 0,
  191. liType: ['塔粮', '筛粮', '中粒', '大粒'],
  192. pinIndex: 0,
  193. pinType: ['不限(默认)', '一等品', '二等品', '三等品', '等外'],
  194. nianIndex: 3,
  195. nianType: ['2023', '2022', '2021', '2020', '2019', '2018', '2017', '2016', '2015', '2014', '2013', '2012',
  196. '2011'
  197. ],
  198. baoIndex: 0,
  199. baoType: ['不限(默认)', '散装', '大袋', '小袋'],
  200. chengIndex: -1,
  201. chengType: ['可议', '买方承担', '卖方承担']
  202. }
  203. },
  204. computed: {
  205. ...mapState(['hasLogin','userInfo'])
  206. },
  207. methods: {
  208. typeChange(e) {
  209. this.typesIndex = e.detail.value
  210. this.types = this.typesType[this.typesIndex];
  211. this.deptList.procurementPlanType = this.typesType[this.typesIndex];
  212. if (this.typesIndex == 0) {
  213. this.deptList.priceType = '定价采购'
  214. } else {
  215. this.deptList.priceType = '期货盘面价+基差'
  216. }
  217. },
  218. commit() {
  219. this.insertProcurementPlanInfo = this.deptList
  220. // if (!this.deptList.goodsName) {
  221. // this.$api.msg('货名1不能为空')
  222. // return
  223. // }
  224. // if (!this.deptList.title) {
  225. // this.$api.msg('标题不能为空')
  226. // return
  227. // }
  228. if (!this.deptList.goodsName) {
  229. this.$api.msg('货名不能为空')
  230. return
  231. }
  232. if (!this.insertProcurementPlanInfo.plannedPurchaseVolume) {
  233. this.$api.msg('采购量不能为空')
  234. return
  235. }
  236. if (!this.insertProcurementPlanInfo.minimumVolume) {
  237. this.$api.msg('最小成交量不能为空')
  238. return
  239. }
  240. if (!this.insertProcurementPlanInfo.procurementPlanType) {
  241. this.$api.msg('类型不能为空')
  242. return
  243. }
  244. if (!this.insertProcurementPlanInfo.priceType) {
  245. this.$api.msg('价格类型不能为空')
  246. return
  247. }
  248. if(this.insertProcurementPlanInfo.procurementPlanType == '现货'){
  249. if (!this.insertProcurementPlanInfo.unitPrice) {
  250. this.$api.msg('单价不能为空')
  251. return
  252. }
  253. }else if(this.insertProcurementPlanInfo.procurementPlanType == '期货'){
  254. if (!this.insertProcurementPlanInfo.basisPrice) {
  255. this.$api.msg('基差(元/吨)不能为空')
  256. return
  257. }
  258. }
  259. if (!this.insertProcurementPlanInfo.buyerPhone) {
  260. this.$api.msg('买方手机号不能为空')
  261. return
  262. }
  263. if (!this.insertProcurementPlanInfo.waterContent) {
  264. this.$api.msg('水分不能为空')
  265. return
  266. }
  267. if (!this.insertProcurementPlanInfo.bulkDensity) {
  268. this.$api.msg('容重不能为空')
  269. return
  270. }
  271. if (!this.insertProcurementPlanInfo.jiaorenli) {
  272. this.$api.msg('热损伤不能为空')
  273. return
  274. }
  275. if (!this.insertProcurementPlanInfo.impurity) {
  276. this.$api.msg('杂质不能为空')
  277. return
  278. }
  279. if (!this.insertProcurementPlanInfo.mildewGrain) {
  280. this.$api.msg('霉变粒不能为空')
  281. return
  282. }
  283. if (!this.insertProcurementPlanInfo.imperfectGrain) {
  284. this.$api.msg('不完整粒不能为空')
  285. return
  286. }
  287. if (!this.insertProcurementPlanInfo.bulkDensity) {
  288. this.$api.msg('蛋白不能为空')
  289. return
  290. }
  291. if (!this.insertProcurementPlanInfo.grain) {
  292. this.$api.msg('粒型不能为空')
  293. return
  294. }
  295. if (!this.insertProcurementPlanInfo.grade) {
  296. this.$api.msg('品级不能为空')
  297. return
  298. }
  299. if (!this.insertProcurementPlanInfo.outputYear) {
  300. this.$api.msg('产出年份不能为空')
  301. return
  302. }
  303. if (!this.insertProcurementPlanInfo.packingType) {
  304. this.$api.msg('包装方式不能为空')
  305. return
  306. }
  307. if (!this.insertProcurementPlanInfo.baggingNotes) {
  308. this.$api.msg('装袋备注不能为空')
  309. return
  310. }
  311. if (!this.insertProcurementPlanInfo.freightPayer) {
  312. this.$api.msg('运费承担方不能为空')
  313. return
  314. }
  315. this.insertProcurementPlanInfo.commonId = this.userInfo.id
  316. this.$api.doRequest('post', '/procurementPlanInfo/api/insertProcurementPlanInfo', this
  317. .insertProcurementPlanInfo).then(res => {
  318. console.log("添加成功")
  319. this.procurementPlanInfos = res.data.data
  320. })
  321. .catch(res => {
  322. uni.showToast({
  323. title: res.errmsg,
  324. icon: 'none',
  325. duration: 2000
  326. })
  327. });
  328. },
  329. liChange(e) {
  330. this.liIndex = e.detail.value
  331. this.litypes = this.liType[this.liIndex];
  332. this.deptList.grain = this.liType[this.liIndex]
  333. },
  334. pinChange(e) {
  335. this.pinIndex = e.detail.value
  336. this.pintypes = this.pinType[this.pinIndex];
  337. this.deptList.grade = this.pinType[this.pinIndex]
  338. },
  339. nianChange(e) {
  340. this.nianIndex = e.detail.value
  341. this.niantypes = this.nianType[this.nianIndex];
  342. this.deptList.outputYear = this.baoType[this.baoIndex]
  343. },
  344. baoChange(e) {
  345. this.baoIndex = e.detail.value
  346. this.baotypes = this.baoType[this.baoIndex];
  347. this.deptList.packingType = this.chengType[this.chengIndex];
  348. },
  349. chengChange(e) {
  350. this.chengIndex = e.detail.value
  351. this.chengtypes = this.chengType[this.chengIndex];
  352. this.deptList.freightPayer = this.chengType[this.chengIndex];
  353. }
  354. }
  355. }
  356. </script>
  357. <style>
  358. .center {
  359. padding: 10px 20px;
  360. }
  361. .c-row {
  362. display: -webkit-box;
  363. display: -webkit-flex;
  364. display: flex;
  365. -webkit-box-align: center;
  366. -webkit-align-items: center;
  367. align-items: center;
  368. padding: 20rpx 30rpx;
  369. position: relative;
  370. }
  371. .con-list {
  372. -webkit-box-flex: 1;
  373. -webkit-flex: 1;
  374. flex: 1;
  375. display: -webkit-box;
  376. display: -webkit-flex;
  377. display: flex;
  378. -webkit-box-orient: vertical;
  379. -webkit-box-direction: normal;
  380. -webkit-flex-direction: column;
  381. flex-direction: column;
  382. color: #303133;
  383. line-height: 40rpx;
  384. text-align: right;
  385. padding-right: 20rpx;
  386. font-size: 14px;
  387. }
  388. </style>