buyEdit.vue 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961
  1. <template>
  2. <view class="center">
  3. <view class="area">
  4. <view class="c-row b-b">
  5. <text class="tit">名头</text>
  6. <view class="con-list">
  7. <text @click="navToDetailPage">{{deptList.buyer}}<text class='tip_text cuIcon-right'></text></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. <view class="con-list">
  38. {{deptList.procurementPlanType}}
  39. </view>
  40. </view>
  41. <view class="c-row b-b">
  42. <text class="tit">价格类型</text>
  43. <view class="con-list">
  44. {{deptList.priceType}}
  45. </view>
  46. </view>
  47. <view class="c-row b-b" v-if="this.typesIndex != 1">
  48. <text class="tit">单价(元/吨)</text>
  49. <view class="con-list">
  50. <input placeholder="请填写单价" name="input" v-model="deptList.procurementPrice"></input>
  51. </view>
  52. </view>
  53. <view class="c-row b-b" v-if="this.typesIndex == 1">
  54. <text class="tit">基差(元/吨)</text>
  55. <view class="con-list">
  56. <input placeholder="请输入基差" name="input" v-model="deptList.basisPrice"></input>
  57. </view>
  58. </view>
  59. <view class="c-row b-b">
  60. <text class="tit">收货地区</text>
  61. <view class="con-list">
  62. <view @click='regionchange'>{{region}}</view>
  63. <u-picker :params='params' @confirm='regionpicker' mode="region" v-model="show"></u-picker>
  64. </view>
  65. </view>
  66. <view class="c-row b-b">
  67. <text class="tit">买方手机号</text>
  68. <view class="con-list">
  69. <input placeholder="请输入买方手机号" @input='phoneinput' name="input"
  70. v-model="deptList.buyerPhone"></input>
  71. </view>
  72. </view>
  73. <view class="c-row">
  74. <button :class='codestatus&&!sendDisabled?"active":""' @click='getcode'
  75. class='getcode'>{{sendText}}</button>
  76. <view class="con-list">
  77. <input v-model='verifyCode' placeholder="请输入验证码" type="text">
  78. </view>
  79. </view>
  80. </view>
  81. <view class="area">
  82. <view class="c-row b-b">
  83. <checkbox style='transform: scale(0.8);' :checked="checked" @click='checkedbox'></checkbox><text
  84. style="font-size: 14px; ">完善更多信息<text
  85. style="font-size: 10px; color: #AFB3BF;">(选填,可由客服人员代为完善)</text></text>
  86. </view>
  87. <view v-if='checked' class="c-row b-b">
  88. <text class="tit">水分(%)<= </text>
  89. <view class="con-list">
  90. <input placeholder="请填写水分占比" name="input" v-model="deptList.waterContent"></input>
  91. </view>
  92. </view>
  93. <view v-if='checked' class="c-row b-b">
  94. <text class="tit">容重(g/L)<= </text>
  95. <view class="con-list">
  96. <input placeholder="请填写容重" name="input" v-model="deptList.bulkDensity"></input>
  97. </view>
  98. </view>
  99. <view v-if='checked' class="c-row b-b">
  100. <text class="tit">热损伤(%)<= </text>
  101. <view class="con-list">
  102. <input placeholder="请填写热损伤占比" name="input" v-model="deptList.jiaorenli"></input>
  103. </view>
  104. </view>
  105. <view v-if='checked' class="c-row b-b">
  106. <text class="tit">杂质(%)<= </text>
  107. <view class="con-list">
  108. <input placeholder="请填写杂质占比" name="input" v-model="deptList.impurity"></input>
  109. </view>
  110. </view>
  111. <view v-if='checked' class="c-row b-b">
  112. <text class="tit">霉变粒(%)<= </text>
  113. <view class="con-list">
  114. <input placeholder="请填写霉变粒占比" name="input" v-model="deptList.mildewGrain"></input>
  115. </view>
  116. </view>
  117. <view v-if='checked' class="c-row b-b">
  118. <text class="tit">不完整粒(%)<= </text>
  119. <view class="con-list">
  120. <input placeholder="请填写不完整粒占比" name="input" v-model="deptList.imperfectGrain"></input>
  121. </view>
  122. </view>
  123. <view v-if='checked' class="c-row b-b">
  124. <text class="tit">蛋白(%)<= </text>
  125. <view class="con-list">
  126. <input placeholder="请填写蛋白占比" name="input" v-model="deptList.protein"></input>
  127. </view>
  128. </view>
  129. <view v-if='checked' class="c-row b-b">
  130. <text class="tit">粒型 </text>
  131. <picker @change="liChange" :value="liIndex" :range="liType" class="con-list" v-model="deptList.grain">
  132. <view class="con-list">
  133. {{liIndex>-1?liType[liIndex]:'请选择粒型'}}
  134. </view>
  135. </picker>
  136. </view>
  137. <view v-if='checked' class="c-row b-b">
  138. <text class="tit">品级 </text>
  139. <picker @change="pinChange" :value="pinIndex" :range="pinType" class="con-list"
  140. v-model="deptList.grade">
  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. <view class="con-list">
  156. <view @click='yearchange'>{{deptList.outputYear == null?"请选择出厂年份":deptList.outputYear}}</view>
  157. <u-picker :params='params2' @confirm='yearpicker($event)' v-model="show2" mode="time"
  158. :start-year="startData" :end-year="endData">
  159. </u-picker>
  160. </view>
  161. </view>
  162. <view v-if='checked' class="c-row b-b">
  163. <text class="tit">包装方式</text>
  164. <picker @change="baoChange" :value="baoIndex" :range="baoType" class="con-list">
  165. <view class="con-list">
  166. {{baoIndex>-1?baoType[baoIndex]:'请选择包装方式'}}
  167. </view>
  168. </picker>
  169. </view>
  170. <view v-if='checked&&baoIndex!=0' class="c-row b-b">
  171. <text class="tit">袋装备注</text>
  172. <view class="con-list">
  173. <input placeholder="请填写袋装备注" name="input" v-model="deptList.baggingNotes"></input>
  174. </view>
  175. </view>
  176. <view v-if='checked' class="c-row">
  177. <text class="tit">运费承担方</text>
  178. <picker @change="chengChange" :value="chengIndex" :range="chengType" class="con-list">
  179. <view class="con-list">
  180. {{chengIndex>-1?chengType[chengIndex]:'请选择运费承担方'}}
  181. </view>
  182. </picker>
  183. </view>
  184. </view>
  185. <view class="remark">
  186. <view class="c-row b-b">
  187. <text class="tit">备注</text>
  188. </view>
  189. <view style='position:relative;' class="wrap no-boder">
  190. <u-input class='textarea' v-model="deptList.remark" :type="type" :border="border" :height="height"
  191. :auto-height="autoHeight" maxlength="500" />
  192. <view style='position:absolute;right:10px;bottom:20px;color:#AFB3BF;'>
  193. {{deptList.remark.length}}/500个字
  194. </view>
  195. </view>
  196. <view class="c-row b-b" style="display: block;">
  197. <text class="tit">附件</text>
  198. <view style="display: flex;flex-wrap: wrap;">
  199. <view v-for='(item,index) in imglist2' v-if="imglist2 && imglist2.length > 0"
  200. style="position: relative;margin-left: 20rpx;">
  201. <view class="delete_img" @click="deleteImg(index)">X</view>
  202. <image :src="item.appendixPath" mode="" style="width: 100px;height: 100px;"></image>
  203. </view>
  204. <view class="biankuang" @click="uploadClick" v-if="imglist2.length < 30">
  205. <view class="tubiao">
  206. <image class="upload" src="../../static/img/oa_office/upload.png" mode="">
  207. </image>
  208. <view class="" style="color:#8c8f98;">
  209. 选择图片
  210. </view>
  211. </view>
  212. </view>
  213. </view>
  214. </view>
  215. </view>
  216. <button @click="commit()" class="btn">重新发布</button>
  217. </view>
  218. </template>
  219. <script>
  220. import * as config from '../../config'
  221. import {
  222. mapState
  223. } from 'vuex';
  224. export default {
  225. data() {
  226. return {
  227. dotStyle: false,
  228. currentImg: 0,
  229. imgUrl: [],
  230. type: 'textarea',
  231. border: true,
  232. height: 150,
  233. autoHeight: true,
  234. types: '',
  235. goods: {},
  236. typesType: ["现货", "期货"],
  237. typesIndex: 0,
  238. deptList: {
  239. buyer: "",
  240. salePlanTypeKey: 0,
  241. grainKey: 0,
  242. gradeKey: 0,
  243. packingTypeKey: 0,
  244. freightPayerKey: -1,
  245. priceType: "定价采购",
  246. procurementPlanType: "现货",
  247. grain: "塔粮",
  248. grade: "一等品",
  249. outputYear: "2020",
  250. packingType: "散装",
  251. freightPayer: "",
  252. imglist2: [], //展示
  253. imglist: [], //存
  254. },
  255. imglist2: [], //展示
  256. imglist: [], //存
  257. params: {
  258. province: true,
  259. city: true,
  260. area: true,
  261. },
  262. params1: {
  263. province: true,
  264. city: true,
  265. },
  266. checked: true,
  267. insertProcurementPlanInfo: {},
  268. liIndex: -1,
  269. liType: ['塔粮', '筛粮', '中粒', '大粒'],
  270. pinIndex: -1,
  271. pinType: ['一等品', '二等品', '三等品', '等外'],
  272. nianIndex: 3,
  273. nianType: ['2023', '2022', '2021', '2020', '2019', '2018', '2017', '2016', '2015', '2014', '2013', '2012',
  274. '2011'
  275. ],
  276. id: 0,
  277. sendText: '获取验证码',
  278. show: false,
  279. show1: false,
  280. show2: false,
  281. region: '请选择收货地区',
  282. region1: '请选择产地',
  283. baoIndex: -1,
  284. baoType: ['散装', '大袋', '小袋'],
  285. chengIndex: -1,
  286. chengType: ['可议', '买方承担', '卖方承担'],
  287. codestatus: true,
  288. sendDisabled: false,
  289. sendText: '获取验证码',
  290. verifyCode: "",
  291. params2: {
  292. year: true,
  293. },
  294. }
  295. },
  296. computed: {
  297. ...mapState(['hasLogin', 'userInfo']),
  298. startData() {
  299. var data = new Date()
  300. return data.getFullYear() - 30
  301. },
  302. endData() {
  303. var data = new Date()
  304. return data.getFullYear()
  305. }
  306. },
  307. onLoad(options) {
  308. this.id = options.id
  309. this.getList()
  310. },
  311. onShow() {
  312. var that = this
  313. this.$api.doRequest('get', '/identityAuthenticationInfo/getInfo', {
  314. commonId: that.userInfo.id
  315. }).then(res => {
  316. if (res.data.code == 200) {
  317. if (res.data.data.customerTypeFlag == 1) {
  318. that.$set(that.deptList, 'buyer', res.data.data.customerName)
  319. } else {
  320. that.$set(that.deptList, 'buyer', res.data.data.compName)
  321. }
  322. that.goods = res.data.data
  323. }
  324. uni.hideLoading()
  325. })
  326. },
  327. watch: {
  328. imglist: {
  329. handler: function() {
  330. this.$api.doRequest('get', 'appendix/query/getFileList', {
  331. appendixIds: this.imglist.toString()
  332. }).then(res => {
  333. this.imglist2 = res.data.data
  334. for (let i = 0; i < this.imglist2.length; i++) {
  335. if (this.imglist2[i].appendixPath) {
  336. this.imgUrl.push(this.imglist2[i].appendixPath)
  337. }
  338. }
  339. })
  340. },
  341. deep: true
  342. }
  343. },
  344. methods: {
  345. deleteImg(index) {
  346. this.imglist.splice(index, 1)
  347. },
  348. phoneinput(e) {
  349. if (e.detail.value.length == 11) {
  350. this.codestatus = true
  351. }
  352. },
  353. async uploadClick() {
  354. let baseUrlNew = config.def().baseUrlNew
  355. console.log('baseUrlNew',baseUrlNew)
  356. uni.chooseImage({
  357. count:10,
  358. success: (chooseImageRes) => {
  359. console.log('chooseImageRes',chooseImageRes)
  360. let files = []
  361. for (let item of chooseImageRes.tempFiles) {
  362. files.push({
  363. name: 'fileName',
  364. url : item.path
  365. });
  366. }
  367. console.log(files)
  368. for (let i = 0; i < files.length; i++) {
  369. uni.uploadFile({
  370. url: baseUrlNew + 'appendix/api/uploadFiles',
  371. // url: baseUrlNew+'appendix/api/uploadFiles', //仅为示例,非真实的接口地址
  372. // files: files[i],
  373. filePath:files[i].url,
  374. name:files[i].name,
  375. formData: {
  376. // fileName: chooseImageRes.tempFiles[0],
  377. companyId: "2710b21efc1e4393930c5dc800010dc4",
  378. modelId: '',
  379. vesselId: '',
  380. },
  381. success: (uploadFileRes) => {
  382. console.log(JSON.parse(uploadFileRes.data))
  383. var data = JSON.parse(uploadFileRes.data).data
  384. this.$api.doRequest('post', '/appendix/api/saveFiles', {
  385. newAppendixs: [data],
  386. oldAppendixIds: ""
  387. }).then(res => {
  388. this.imglist.push(res.data.data[0])
  389. console.log(res)
  390. })
  391. console.log(uploadFileRes.data);
  392. },
  393. fail(res) {
  394. console.log(res);
  395. }
  396. });
  397. }
  398. }
  399. });
  400. },
  401. getList() {
  402. this.$api.doRequest('get', '/procurementPlanInfo/getProcurementPlan', {
  403. id: this.id
  404. }).then(res => {
  405. if (res.data.code == 200) {
  406. this.deptList = res.data.data
  407. this.imglist = this.deptList.addressUrl.split(',')
  408. if (this.deptList.waterContent != null || this.deptList.bulkDensity != null || this
  409. .deptList.jiaorenli != null || this.deptList.impurity != null || this.deptList
  410. .mildewGrain != null || this.deptList.imperfectGrain != null || this.deptList
  411. .protein != null || this.deptList.grade != null || this.deptList.outputYear != null ||
  412. this.deptList.packingType != null || this.deptList.freightPayer != null) {
  413. this.checked = false
  414. }
  415. let number = this.deptList.basisPrice
  416. this.deptList.basisPrice = Math.abs(number)
  417. if (this.deptList.outputPrivate && this.deptList.outputCity) {
  418. this.region1 = this.deptList.outputPrivate + '-' + this.deptList.outputCity
  419. }
  420. if (this.deptList.procurementPlanType == '期货') {
  421. let number = this.deptList.basisPrice
  422. this.deptList.basisPrice = Math.abs(number)
  423. }
  424. this.region = this.deptList.receivePrivate + '-' + this.deptList.receiveCity + '-' + this
  425. .deptList.receiveArea
  426. if (this.deptList.procurementPlanTypeKey == 2) {
  427. this.typesIndex = 1
  428. } else if (this.deptList.procurementPlanTypeKey == 1) {
  429. this.typesIndex = 0
  430. }
  431. this.liIndex = this.deptList.grainKey
  432. this.baoIndex = this.deptList.packingTypeKey
  433. this.pinIndex = this.deptList.gradeKey
  434. if (this.deptList.freightPayerKey == 1) {
  435. this.chengIndex = 0
  436. } else if (this.deptList.freightPayerKey == 2) {
  437. this.chengIndex = 1
  438. } else if (this.deptList.freightPayerKey == 3) {
  439. this.chengIndex = 2
  440. }
  441. }
  442. })
  443. .catch(res => {
  444. if (res.errmsg) {
  445. uni.showToast({
  446. title: res.errmsg,
  447. icon: 'none',
  448. duration: 2000
  449. })
  450. } else {
  451. uni.showToast({
  452. title: "系统异常,请联系管理员",
  453. icon: 'none',
  454. duration: 2000
  455. })
  456. }
  457. });
  458. },
  459. yearpicker(e) {
  460. if (e != null) {
  461. this.morestatus = true
  462. } else {
  463. this.morestatus = false
  464. }
  465. this.deptList.outputYear = e.year
  466. },
  467. yearchange() {
  468. this.show2 = true
  469. },
  470. getcode() {
  471. var that = this
  472. if (/^0?1[3|4|5|6|7|8][0-9]\d{8}$/.test(this.deptList.buyerPhone)) {
  473. this.$api.doRequest('get', '/commonUser/sendVerifyCode', {
  474. phone: this.deptList.buyerPhone
  475. }).then(res => {
  476. if (res.data.code == 200) {
  477. that.sendDisabled = true
  478. let sec = 60
  479. let interval = setInterval(() => {
  480. sec--;
  481. that.sendText = sec + 's后重发'
  482. if (sec <= 0) {
  483. that.sendDisabled = false
  484. that.sendText = "获取验证码"
  485. clearInterval(interval)
  486. }
  487. }, 1000)
  488. } else {
  489. uni.showToast({
  490. title: res.data.message,
  491. icon: 'none',
  492. duration: 2000
  493. })
  494. }
  495. })
  496. .catch(res => {
  497. uni.showToast({
  498. title: res.data.message,
  499. icon: 'none',
  500. duration: 2000
  501. })
  502. });
  503. } else {
  504. uni.showToast({
  505. title: '请输入正确的手机号',
  506. icon: 'none',
  507. duration: 2000
  508. })
  509. }
  510. },
  511. regionpicker(e) {
  512. this.deptList.receivePrivate = e.province.label
  513. this.deptList.receiveCity = e.city.label
  514. this.deptList.receiveArea = e.area.label
  515. this.region = e.province.label + '-' + e.city.label + '-' + e.area.label
  516. },
  517. regionchange() {
  518. this.show = true
  519. },
  520. regionpicker1(e) {
  521. this.deptList.outputPrivate = e.province.label
  522. this.deptList.outputCity = e.city.label
  523. this.region1 = e.province.label + '-' + e.city.label
  524. },
  525. regionchange1() {
  526. this.show1 = true
  527. },
  528. checkedbox(e) {
  529. this.checked = !this.checked
  530. },
  531. typeChange(e) {
  532. this.typesIndex = e.detail.value
  533. if (e.detail.value == 0) {
  534. this.deptList.priceType = '定价采购'
  535. this.deptList.procurementPlanTypeKey = 2
  536. } else {
  537. this.deptList.priceType = '期货盘面价+基差'
  538. this.deptList.procurementPlanTypeKey = 1
  539. }
  540. this.deptList.procurementPlanType = this.typesType[this.typesIndex];
  541. },
  542. navToDetailPage() {
  543. // if (index == 1) {
  544. uni.navigateTo({
  545. url: `/pageD/myRelease/Identity_switching?id=` + this.id
  546. })
  547. },
  548. commit() {
  549. // if (!this.deptList.goodsName) {
  550. // this.$api.msg('货名1不能为空')
  551. // return
  552. // }
  553. if (!this.deptList.title) {
  554. this.$api.msg('标题不能为空')
  555. return
  556. }
  557. if (this.deptList.title.length > 16 || this.deptList.title.length < 2) {
  558. this.$api.msg('标题输入错误')
  559. return
  560. }
  561. if (!this.deptList.goodsName) {
  562. this.$api.msg('货名不能为空')
  563. return
  564. }
  565. if (this.deptList.goodsName.length > 6 || this.deptList.goodsName.length < 1) {
  566. this.$api.msg('货名输入错误')
  567. return
  568. }
  569. if (!this.deptList.plannedPurchaseVolume) {
  570. this.$api.msg('采购量不能为空')
  571. return
  572. }
  573. if (this.deptList.plannedPurchaseVolume > 100000 || this.deptList.plannedPurchaseVolume < 1) {
  574. this.$api.msg('采购量输入错误')
  575. return
  576. }
  577. // var plannedPurchaseVolume = this.deptList.plannedPurchaseVolume.toString()
  578. if (this.deptList.plannedPurchaseVolume.toString().indexOf(".") != -1) {
  579. if (this.deptList.plannedPurchaseVolume.split('.')[1].length > 2) {
  580. this.$api.msg('采购量输入错误')
  581. return
  582. }
  583. }
  584. if (!this.deptList.minimumVolume) {
  585. this.$api.msg('最小成交量不能为空')
  586. return
  587. }
  588. if (this.deptList.minimumVolume > 100000 || this.deptList.minimumVolume < 1) {
  589. this.$api.msg('最小成交量输入错误')
  590. return
  591. }
  592. if (this.deptList.minimumVolume.toString().indexOf('.') != -1) {
  593. if (this.deptList.minimumVolume.split('.')[1].length > 2) {
  594. this.$api.msg('最小成交量输入错误')
  595. return
  596. }
  597. }
  598. if (!this.deptList.procurementPlanType) {
  599. this.$api.msg('类型不能为空')
  600. return
  601. }
  602. if (!this.deptList.priceType) {
  603. this.$api.msg('价格类型不能为空')
  604. return
  605. }
  606. if (this.deptList.procurementPlanType == '现货') {
  607. if (!this.deptList.procurementPrice) {
  608. this.$api.msg('单价不能为空')
  609. return
  610. }
  611. if (this.deptList.procurementPrice > 100000 || this.deptList.procurementPrice < 1) {
  612. this.$api.msg('单价输入错误')
  613. return
  614. }
  615. if (this.deptList.procurementPrice.indexOf('.') != -1) {
  616. if (this.deptList.procurementPrice.split('.')[1].length > 2) {
  617. this.$api.msg('单价输入错误')
  618. return
  619. }
  620. }
  621. } else if (this.deptList.procurementPlanType == '期货') {
  622. if (!String(this.deptList.basisPrice)) {
  623. this.$api.msg('基差不能为空')
  624. return
  625. }
  626. if (this.deptList.basisPrice > 10000 || this.deptList.basisPrice < 0) {
  627. this.$api.msg('基差输入错误')
  628. return
  629. }
  630. if (this.deptList.basisPrice.toString().indexOf('.') != -1) {
  631. if (this.deptList.basisPrice.toString().split('.')[1].length > 2) {
  632. this.$api.msg('基差输入错误')
  633. return
  634. }
  635. }
  636. }
  637. if (!this.deptList.buyerPhone) {
  638. this.$api.msg('买方手机号不能为空')
  639. return
  640. }
  641. if (!this.verifyCode) {
  642. this.$api.msg('验证码不能为空')
  643. return
  644. }
  645. if (this.checked == false) {
  646. if (this.deptList.waterContent && this.deptList.waterContent < 0 ||
  647. this.deptList.waterContent && this.deptList.waterContent > 40) {
  648. this.$api.msg('水分输入错误')
  649. return
  650. }
  651. if (this.deptList.waterContent && this.deptList.waterContent.indexOf('.') != -1) {
  652. if (this.deptList.waterContent.split('.')[1].length > 2) {
  653. this.$api.msg('水分输入错误')
  654. return
  655. }
  656. }
  657. if (this.deptList.bulkDensity && this.deptList.bulkDensity < 0 ||
  658. this.deptList.bulkDensity && this.deptList.bulkDensity > 1000) {
  659. this.$api.msg('容重输入错误')
  660. return
  661. }
  662. if (this.deptList.jiaorenli && this.deptList.jiaorenli < 0 ||
  663. this.deptList.jiaorenli && this.deptList.jiaorenli > 40) {
  664. this.$api.msg('热损伤输入错误')
  665. return
  666. }
  667. if (this.deptList.jiaorenli && this.deptList.jiaorenli.indexOf('.') != -1) {
  668. if (this.deptList.jiaorenli.split('.')[1].length > 2) {
  669. this.$api.msg('热损伤输入错误')
  670. return
  671. }
  672. }
  673. if (this.deptList.impurity && this.deptList.impurity < 0 ||
  674. this.deptList.impurity && this.deptList.impurity > 40) {
  675. this.$api.msg('杂质输入错误')
  676. return
  677. }
  678. if (this.deptList.impurity && this.deptList.impurity.indexOf('.') != -1) {
  679. if (this.deptList.impurity.split('.')[1].length > 2) {
  680. this.$api.msg('杂质输入错误')
  681. return
  682. }
  683. }
  684. if (this.deptList.mildewGrain && this.deptList.mildewGrain < 0 ||
  685. this.deptList.mildewGrain && this.deptList.mildewGrain > 40) {
  686. this.$api.msg('霉变粒输入错误')
  687. return
  688. }
  689. if (this.deptList.mildewGrain && this.deptList.mildewGrain.indexOf('.') != -1) {
  690. if (this.deptList.mildewGrain.split('.')[1].length > 2) {
  691. this.$api.msg('霉变粒输入错误')
  692. return
  693. }
  694. }
  695. if (this.deptList.imperfectGrain && this.deptList.imperfectGrain < 0 ||
  696. this.deptList.imperfectGrain && this.deptList.imperfectGrain > 40) {
  697. this.$api.msg('不完整粒输入错误')
  698. return
  699. }
  700. if (this.deptList.imperfectGrain && this.deptList.imperfectGrain.indexOf('.') != -1) {
  701. if (this.deptList.imperfectGrain.split('.')[1].length > 2) {
  702. this.$api.msg('不完整粒输入错误')
  703. return
  704. }
  705. }
  706. if (this.deptList.protein && this.deptList.protein < 0 ||
  707. this.deptList.protein && this.deptList.protein > 80) {
  708. this.$api.msg('蛋白输入错误')
  709. return
  710. }
  711. if (this.deptList.protein && this.deptList.protein.indexOf('.') != -1) {
  712. if (this.deptList.protein.split('.')[1].length > 2) {
  713. this.$api.msg('蛋白输入错误')
  714. return
  715. }
  716. }
  717. }
  718. this.insertProcurementPlanInfo = this.deptList
  719. if (this.deptList.procurementPlanType == '期货') {
  720. this.insertProcurementPlanInfo.basisPrice = -this.insertProcurementPlanInfo.basisPrice
  721. }
  722. this.insertProcurementPlanInfo.commonId = this.userInfo.id
  723. this.insertProcurementPlanInfo.compId = "2710b21efc1e4393930c5dc800010dc4"
  724. if (this.imglist.length > 0) {
  725. this.insertProcurementPlanInfo.addressUrl = this.imglist.toString()
  726. }
  727. uni.showModal({
  728. content: '重新发布后交易信息将进入待审核状态,是否确定重新发布?',
  729. success: (res) => {
  730. if (res.confirm) {
  731. var that = this
  732. this.$api.doRequest('get', '/commonUser/loginVerifyCode', {
  733. phone: this.deptList.buyerPhone,
  734. verifyCode: this.verifyCode
  735. }).then(res => {
  736. if (res.data.code == 200) {
  737. this.$api.doRequest('post',
  738. '/procurementPlanInfo/api/editProcurementPlan', this
  739. .insertProcurementPlanInfo).then(res => {
  740. if (res.data.code == 200) {
  741. uni.showToast({
  742. title: "发布成功",
  743. icon: 'none',
  744. duration: 2000
  745. })
  746. setTimeout(function() {
  747. uni.navigateBack({
  748. delta: 2
  749. })
  750. }, 2000)
  751. this.deptList = {}
  752. uni.navigateTo({
  753. url: `/pages/release/release`
  754. })
  755. } else {
  756. uni.showToast({
  757. title: res.data.message,
  758. icon: 'none',
  759. duration: 2000
  760. })
  761. }
  762. })
  763. .catch(res => {
  764. if (res.errmsg) {
  765. uni.showToast({
  766. title: res.errmsg,
  767. icon: 'none',
  768. duration: 2000
  769. })
  770. } else {
  771. uni.showToast({
  772. title: "系统异常,请联系管理员",
  773. icon: 'none',
  774. duration: 2000
  775. })
  776. }
  777. });
  778. } else if (res.data.code == '11003') {
  779. uni.showModal({
  780. title: '提示',
  781. content: '验证码不正确',
  782. });
  783. } else {
  784. uni.showToast({
  785. title: res.data.message,
  786. icon: 'none',
  787. duration: 2000
  788. })
  789. }
  790. })
  791. .catch(res => {
  792. uni.showToast({
  793. title: res.data.message,
  794. icon: 'none',
  795. duration: 2000
  796. })
  797. });
  798. }
  799. }
  800. })
  801. },
  802. liChange(e) {
  803. this.liIndex = e.detail.value
  804. this.litypes = this.liType[this.liIndex];
  805. this.deptList.grainKey = e.detail.value + 1
  806. this.deptList.grain = this.liType[this.liIndex]
  807. },
  808. pinChange(e) {
  809. this.pinIndex = e.detail.value
  810. this.pintypes = this.pinType[this.pinIndex];
  811. this.deptList.gradeKey = e.detail.value
  812. this.deptList.grade = this.pinType[this.pinIndex]
  813. },
  814. nianChange(e) {
  815. this.nianIndex = e.detail.value
  816. this.niantypes = this.nianType[this.nianIndex];
  817. this.deptList.outputYear = this.nianType[this.niantypes]
  818. },
  819. baoChange(e) {
  820. this.baoIndex = e.detail.value
  821. this.baotypes = this.baoType[this.baoIndex];
  822. this.deptList.packingTypeKey = e.detail.value
  823. this.deptList.packingType = this.baoType[this.baoIndex];
  824. },
  825. chengChange(e) {
  826. this.chengIndex = e.detail.value
  827. this.chengtypes = this.chengType[this.chengIndex];
  828. this.deptList.freightPayerKey = e.detail.value + 1
  829. this.deptList.freightPayer = this.chengType[this.chengIndex];
  830. }
  831. }
  832. }
  833. </script>
  834. <style>
  835. .center {
  836. padding: 10px 20px;
  837. background-color: #F5F6FA;
  838. }
  839. .c-row {
  840. display: -webkit-box;
  841. display: -webkit-flex;
  842. display: flex;
  843. -webkit-box-align: center;
  844. -webkit-align-items: center;
  845. align-items: center;
  846. padding: 20rpx 30rpx;
  847. position: relative;
  848. }
  849. .con-list {
  850. -webkit-box-flex: 1;
  851. -webkit-flex: 1;
  852. flex: 1;
  853. display: -webkit-box;
  854. display: -webkit-flex;
  855. display: flex;
  856. -webkit-box-orient: vertical;
  857. -webkit-box-direction: normal;
  858. -webkit-flex-direction: column;
  859. flex-direction: column;
  860. line-height: 40rpx;
  861. text-align: right;
  862. padding-right: 20rpx;
  863. font-size: 14px;
  864. }
  865. .con-list input {
  866. font-size: 14px !important;
  867. }
  868. .area {
  869. background-color: #FFFFFF;
  870. border-radius: 20px;
  871. margin-top: 10px;
  872. }
  873. .btn {
  874. margin-top: 10px;
  875. border-radius: 20px;
  876. background-color: #22C572;
  877. color: #FFFFFF;
  878. }
  879. .getcode {
  880. font-size: 14px;
  881. color: #AFB3BF;
  882. background: #F5F6F9;
  883. height: 30px;
  884. line-height: 30px;
  885. }
  886. .getcode.active {
  887. background: #22C572;
  888. color: #fff;
  889. }
  890. .remark {
  891. background-color: #FFFFFF;
  892. border-radius: 20px;
  893. margin-top: 10px;
  894. }
  895. .wrap {
  896. padding-top: 5px;
  897. font-size: 14px;
  898. background: #fff;
  899. margin: 10px;
  900. border-radius: 10px;
  901. input {
  902. font-size: 14px;
  903. }
  904. }
  905. .textarea {
  906. background: #F9F9FA;
  907. border: 1px solid #EEEEEE;
  908. }
  909. .delete_img {
  910. position: absolute;
  911. z-index: 100;
  912. left: 84px;
  913. color: #ffffff;
  914. font-size: 28rpx;
  915. border: 1px;
  916. border-radius: 5rpx;
  917. width: 32rpx;
  918. height: 32rpx;
  919. background-color: #ff0000;
  920. text-align: center;
  921. }
  922. .tubiao {
  923. margin: 0 auto;
  924. text-align: center;
  925. margin-top: 35rpx;
  926. }
  927. .biankuang {
  928. border: 1px dashed #AFB3BF;
  929. border-radius: 10rpx;
  930. width: 200rpx;
  931. height: 200rpx;
  932. margin-left: 20rpx;
  933. }
  934. .upload {
  935. width: 80rpx;
  936. height: 80rpx;
  937. }
  938. </style>