SayPrice.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584
  1. <template>
  2. <div>
  3. <div class="modal-wrap" v-if="currentSayPriceIndex > -1" @click="clearSimilar">
  4. <div class="say-price-box" >
  5. <div class="title">
  6. <!--<div>型号:<span :title="purchaseManList.content[currentSayPriceIndex].cmpCode">{{purchaseManList.content[currentSayPriceIndex].cmpCode}}</span></div>-->
  7. <!--<div>品牌:<span :title="purchaseManList.content[currentSayPriceIndex].inbrand">{{purchaseManList.content[currentSayPriceIndex].inbrand}}</span></div>-->
  8. <div>我要报价</div>
  9. <i class="fa fa-close" @click="cancelSayPrice"></i>
  10. </div>
  11. <div class="content">
  12. <div class="content-line">
  13. <div class="form-item form-left text-line">
  14. <span>品牌:</span><span class="text" :title="purchaseManList.content[currentSayPriceIndex].inbrand">{{purchaseManList.content[currentSayPriceIndex].inbrand}}</span>
  15. </div>
  16. </div>
  17. <div class="content-line">
  18. <div class="form-item form-left text-line">
  19. <span>物料名称:</span><span class="text" :title="purchaseManList.content[currentSayPriceIndex].prodTitle">{{purchaseManList.content[currentSayPriceIndex].prodTitle || '-'}}</span>
  20. </div>
  21. </div>
  22. <div class="content-line">
  23. <div class="form-item form-left text-line">
  24. <span>型号:</span><span class="text" :title="purchaseManList.content[currentSayPriceIndex].cmpCode">{{purchaseManList.content[currentSayPriceIndex].cmpCode}}</span>
  25. </div>
  26. </div>
  27. <div class="content-line">
  28. <div class="form-item form-left text-line">
  29. <span>规格:</span><span class="text" :title="purchaseManList.content[currentSayPriceIndex].spec">{{purchaseManList.content[currentSayPriceIndex].spec || '-'}}</span>
  30. </div>
  31. </div>
  32. <ul class="switch-say">
  33. <li :class="{'active': sayType == 'current'}" @click="setSayType('current')">当前型号报价</li>
  34. <li :class="{'active': sayType == 'replace'}" @click="setSayType('replace')">替代型号报价</li>
  35. </ul>
  36. <template v-if="sayType == 'replace'">
  37. <div class="content-line">
  38. <div class="form-item form-left form-long">
  39. <span><i>*</i>品牌:</span>
  40. <input type="text" class="form-control" @blur="checkBrand" @input="onBrandChange" v-model="sayPriceObj.replaceBrand" placeholder="请勿填中文符号">
  41. <ul class="similar-list" v-show="showSimilarBrandList && sayPriceObj.replaceBrand">
  42. <li v-for="sBrand in similarBrand" @click="setBrand(sBrand.nameEn)">{{sBrand.nameEn}}</li>
  43. </ul>
  44. </div>
  45. </div>
  46. <div class="content-line">
  47. <div class="form-item form-left form-long">
  48. <span><i>*</i>型号:</span>
  49. <input type="text" class="form-control" v-model="sayPriceObj.replaceCmpCode" @blur="checkCode" @input="onCodeChange" placeholder="请勿填中文符号">
  50. <ul v-show="showSimilarCodeList && sayPriceObj.replaceCmpCode">
  51. <li v-for="sCode in similarCode" @click="setCode(sCode.code)">{{sCode.code}}</li>
  52. </ul>
  53. </div>
  54. </div>
  55. <div class="content-line">
  56. <div class="form-item form-left form-long">
  57. <span>规格:</span>
  58. <input type="text" class="form-control" v-model="sayPriceObj.replaceSpec">
  59. </div>
  60. </div>
  61. </template>
  62. <div class="content-line">
  63. <div class="form-item form-left">
  64. <span><i>*</i>交期:</span>
  65. <input type="number" class="form-control" placeholder="天数" @input="onLeadtimeInput" @blur="onLeadtimeBlur" v-model="sayPriceObj.leadtime">
  66. </div>
  67. <!--<div class="form-item form-upload">
  68. <label>
  69. <span><i>+</i>添加附件</span>
  70. <input type="file">
  71. </label>
  72. &lt;!&ndash;<div>
  73. <span>我是Excel的名字111</span>
  74. <i class="fa fa-times-circle"></i>
  75. <a href="">更换</a>
  76. </div>&ndash;&gt;
  77. </div>-->
  78. </div>
  79. <div class="content-line" v-for="(reply, index) in sayPriceObj.replies">
  80. <div class="form-item form-left">
  81. <span><i>*</i>价格梯度:</span>
  82. <input type="number" class="form-control" @blur="onReplyLapQtyBlur(index)" @input="onReplyLapQtyInput(index)" v-model="reply.lapQty" placeholder="分段数量">
  83. <!-- -
  84. <input type="text" class="form-control" placeholder="数量">-->
  85. </div>
  86. <div class="form-item form-right">
  87. <span><i>*</i>单价<span v-if="purchaseManList.content[currentSayPriceIndex].currency" v-text="purchaseManList.content[currentSayPriceIndex].currency == 'USD' ? '($)' : '(¥)'"></span>:</span>
  88. <!--{{purchaseManList.content[currentSayPriceIndex].currency == 'USD' ? '$' : '¥'}})-->
  89. <select v-if="!purchaseManList.content[currentSayPriceIndex].currency" v-model="sayPriceObj.currency">
  90. <option value="RMB">¥</option>
  91. <option value="USD">$</option>
  92. </select>
  93. <input type="number" class="form-control" @input="onReplyPriceInput(index)" @blur="onReplyPriceBlur(index)" placeholder="分段单价" v-model="reply.price">
  94. <i class="fa fa-minus-circle" v-if="sayPriceObj.replies.length > 1" @click="setReplies('sub', index)"></i>
  95. <i class="fa fa-plus-circle" v-if="sayPriceObj.replies.length < 5" @click="setReplies('add', index)"></i>
  96. </div>
  97. </div>
  98. </div>
  99. <div class="operate">
  100. <span @click="commitSayPrice">确定</span>
  101. <span @click="cancelSayPrice">取消</span>
  102. </div>
  103. </div>
  104. </div>
  105. <loading v-show="showLoading"></loading>
  106. </div>
  107. </template>
  108. <script>
  109. import Loading from '~components/common/loading/PageLoading.vue'
  110. import { sayPriceReplace } from '~utils/mixin'
  111. export default {
  112. props: {
  113. purchase: Object,
  114. current: Number
  115. },
  116. data () {
  117. return {
  118. sayPriceObj: {
  119. currency: 'RMB',
  120. leadtime: '',
  121. replies: [
  122. {
  123. lapQty: '',
  124. price: ''
  125. }
  126. ],
  127. replaceBrand: '',
  128. replaceCmpCode: '',
  129. replaceSpec: ''
  130. },
  131. validSayPrice: {
  132. leadtime: false,
  133. repliesPrice: false,
  134. repliesLapQty: false,
  135. replaceBrand: false,
  136. replaceCmpCode: false,
  137. replaceSpec: true
  138. },
  139. showLoading: false,
  140. sayType: 'current'
  141. }
  142. },
  143. components: {
  144. Loading
  145. },
  146. mixins: [sayPriceReplace],
  147. computed: {
  148. purchaseManList () {
  149. return this.purchase || []
  150. },
  151. currentSayPriceIndex () {
  152. this.resetSayPrice()
  153. this.sayType = 'current'
  154. return this.current
  155. },
  156. user () {
  157. return this.$store.state.option.user
  158. }
  159. },
  160. methods: {
  161. setIndex: function (index) {
  162. this.$emit('sayPriceIndexAction', index)
  163. },
  164. sayPrice: function (purchaseMan, index) {
  165. if (this.user.logged) {
  166. if (this.user.data.enterprise.uu) {
  167. if (this.user.data.enterprise.isVendor && this.user.data.enterprise.isVendor !== '1690') {
  168. this.resetSayPrice()
  169. // purchaseMan.active = true
  170. this.setIndex(index)
  171. } else {
  172. this.$message.error('抱歉,您需开通卖家功能才可报价')
  173. }
  174. } else {
  175. this.$message.error('个人账户暂不可报价')
  176. }
  177. } else {
  178. this.$router.push('/auth/login?returnUrl=' + window.location.href)
  179. }
  180. },
  181. cancelSayPrice: function () {
  182. this.$emit('cancelSayPriceAction')
  183. },
  184. commitSayPrice: function () {
  185. if (this.checkValid()) {
  186. let purchaseMan = JSON.parse(JSON.stringify(this.purchaseManList.content[this.currentSayPriceIndex]))
  187. this.showLoading = true
  188. purchaseMan.leadtime = this.sayPriceObj.leadtime
  189. purchaseMan.replies = this.sayPriceObj.replies
  190. purchaseMan.vendUU = this.user.data.enterprise.uu
  191. purchaseMan.vendUserUU = this.user.data.userUU
  192. purchaseMan.qutoApp = 'MALL'
  193. if (!purchaseMan.currency) {
  194. purchaseMan.currency = this.sayPriceObj.currency
  195. }
  196. if (this.sayType === 'replace') {
  197. purchaseMan.replaceBrand = this.sayPriceObj.replaceBrand
  198. purchaseMan.replaceCmpCode = this.sayPriceObj.replaceCmpCode
  199. purchaseMan.replaceSpec = this.sayPriceObj.replaceSpec
  200. purchaseMan.isReplace = 1
  201. }
  202. this.$http.post('/inquiry/sale/item/save', purchaseMan).then(response => {
  203. this.showLoading = false
  204. if (response.data.success === false) {
  205. this.$message.error(response.data.message)
  206. } else {
  207. this.$message.success('感谢您参与报价,敬请期待回复')
  208. this.resetSayPrice()
  209. this.resetList()
  210. }
  211. }, error => {
  212. console.log(error)
  213. this.$message.error('请勿重复报价或报价自己的求购')
  214. this.showLoading = false
  215. })
  216. } else {
  217. this.$message.error('请输入正确的报价信息')
  218. }
  219. },
  220. resetList: function () {
  221. this.$emit('resetListAction')
  222. },
  223. resetSayPrice: function () {
  224. this.sayPriceObj = {
  225. currency: 'RMB',
  226. leadtime: '',
  227. replies: [
  228. {
  229. lapQty: '',
  230. price: ''
  231. }
  232. ],
  233. replaceBrand: '',
  234. replaceCmpCode: '',
  235. replaceSpec: ''
  236. }
  237. },
  238. onLeadtimeInput: function () {
  239. if (this.sayPriceObj.leadtime.length > 3) {
  240. this.sayPriceObj.leadtime = this.sayPriceObj.leadtime.substring(0, 3)
  241. }
  242. },
  243. onLeadtimeBlur: function () {
  244. if (!this.sayPriceObj.leadtime || this.sayPriceObj.leadtime < 1 || this.sayPriceObj.leadtime >= 1000 || this.sayPriceObj.leadtime.toString().indexOf('.') !== -1) {
  245. this.validSayPrice.leadtime = false
  246. this.$message.error('交期请填写1-999之间的正整数')
  247. } else {
  248. this.validSayPrice.leadtime = true
  249. }
  250. },
  251. onReplyPriceInput: function (index) {
  252. let price = this.sayPriceObj.replies[index].price
  253. if (price >= 10000) {
  254. this.sayPriceObj.replies[index].price = price.substring(0, 4)
  255. } else if (price.indexOf('.') > -1) {
  256. let arr = price.split('.')
  257. if (arr[0].length > 4) {
  258. this.sayPriceObj.replies[index].price = Number(arr[0].substring(0, 4) + '.' + arr[1])
  259. } else if (arr[1].length > 6) {
  260. this.sayPriceObj.replies[index].price = Number(arr[0] + '.' + arr[1].substring(0, 6))
  261. }
  262. }
  263. },
  264. onReplyPriceBlur: function (index) {
  265. let price = this.sayPriceObj.replies[index].price
  266. if (!price) {
  267. this.sayPriceObj.replies[index].price = ''
  268. this.$message.error('价格不能为空')
  269. this.validSayPrice.repliesPrice = false
  270. } else if (price <= 0) {
  271. this.sayPriceObj.replies[index].price = ''
  272. this.$message.error('输入值必须为正整数')
  273. this.validSayPrice.repliesPrice = false
  274. } else {
  275. this.validSayPrice.repliesPrice = true
  276. }
  277. },
  278. onReplyLapQtyBlur: function (index) {
  279. let lapQty = Number(this.sayPriceObj.replies[index].lapQty)
  280. let limitDownObj = Number(this.getLimitDownQty())
  281. if (!lapQty || lapQty < 1) {
  282. this.sayPriceObj.replies[index].lapQty = ''
  283. this.$message.error('输入值必须为正整数')
  284. this.validSayPrice.repliesLapQty = false
  285. } else if (limitDownObj.index !== index && limitDownObj.lapQty > lapQty) {
  286. this.$message.error('输入值必须大于#该梯度的下限#')
  287. this.sayPriceObj.replies[index].lapQty = ''
  288. this.validSayPrice.repliesLapQty = false
  289. } else if ((index - 1 >= 0 && this.sayPriceObj.replies[index - 1].lapQty && this.sayPriceObj.replies[index - 1].lapQty >= lapQty) || (index + 1 < this.sayPriceObj.replies.length && this.sayPriceObj.replies[index + 1].lapQty && this.sayPriceObj.replies[index + 1].lapQty <= lapQty)) {
  290. this.$message.error('输入值会导致梯度重叠,请重新修改')
  291. this.sayPriceObj.replies[index].lapQty = ''
  292. this.validSayPrice.repliesLapQty = false
  293. } else {
  294. this.validSayPrice.repliesLapQty = true
  295. }
  296. },
  297. onReplyLapQtyInput: function (index) {
  298. let lapQty = this.sayPriceObj.replies[index].lapQty
  299. if (lapQty.length > 9) {
  300. this.sayPriceObj.replies[index].lapQty = lapQty.substring(0, 9)
  301. }
  302. },
  303. getLimitDownQty: function () {
  304. for (let i = 0; i < this.sayPriceObj.replies.length; i++) {
  305. if (this.sayPriceObj.replies[i].lapQty) {
  306. return {
  307. lapQty: this.sayPriceObj.replies[i].lapQty,
  308. index: i
  309. }
  310. }
  311. }
  312. return {index: -1}
  313. },
  314. checkValid: function () {
  315. let validReplace = this.sayType === 'replace' ? this.validSayPrice.replaceBrand && this.validSayPrice.replaceCmpCode && this.validSayPrice.replaceSpec : true
  316. for (let i = 0; i < this.sayPriceObj.replies.length; i++) {
  317. if (!this.sayPriceObj.replies[i].lapQty || !this.sayPriceObj.replies[i].price) {
  318. return false
  319. }
  320. }
  321. return this.validSayPrice.leadtime && this.validSayPrice.repliesLapQty && this.validSayPrice.repliesPrice && validReplace
  322. },
  323. setReplies: function (type, index) {
  324. if (type === 'add' && this.sayPriceObj.replies.length < 5) {
  325. if (this.sayPriceObj.replies[index].lapQty && this.sayPriceObj.replies[index].price) {
  326. this.sayPriceObj.replies.splice(index + 1, 0, {
  327. lapQty: '',
  328. price: ''
  329. })
  330. } else {
  331. this.$message.error('请填完整信息')
  332. }
  333. } else if (type === 'sub' && this.sayPriceObj.replies.length > 1) {
  334. this.sayPriceObj.replies.splice(index, 1)
  335. }
  336. },
  337. setSayType: function (type) {
  338. this.sayType = type
  339. this.resetSayPrice()
  340. }
  341. }
  342. }
  343. </script>
  344. <style scoped lang="scss">
  345. .say-price-box {
  346. position: fixed;
  347. width: 476px;
  348. top: 50%;
  349. left: 50%;
  350. margin-top: -162px;
  351. margin-left: -238px;
  352. overflow-y: auto;
  353. /*-webkit-box-shadow: 0 5px 15px rgba(0,0,0,.5);*/
  354. /*-moz-box-shadow: 0 5px 15px rgba(0,0,0,.5);*/
  355. /*box-shadow: 0 5px 15px rgba(0,0,0,.5);*/
  356. z-index: 1;
  357. .title {
  358. position: relative;
  359. height: 38px;
  360. background: #4290f7;
  361. line-height: 38px;
  362. color: #fff;
  363. border: {
  364. top-right-radius: 5px;
  365. top-left-radius: 5px;
  366. }
  367. padding-left: 20px;
  368. font-weight: bold;
  369. /*> div {*/
  370. /*display: inline-block;*/
  371. /*padding-left: 57px;*/
  372. /*width: 47%;*/
  373. /*overflow: hidden;*/
  374. /*text-overflow: ellipsis;*/
  375. /*white-space: nowrap;*/
  376. /*}*/
  377. i {
  378. position: absolute;
  379. right: 10px;
  380. top: 8px;
  381. cursor: pointer;
  382. }
  383. }
  384. .content {
  385. padding: 9px 0 0 0;
  386. background: #fff;
  387. .content-line {
  388. padding: 0 0 14px 0;
  389. .form-item {
  390. display: inline-block;
  391. width: 49%;
  392. > span {
  393. i {
  394. color: #fd2637;
  395. margin-right: 4px;
  396. }
  397. }
  398. input {
  399. border: 1px solid #bfbfbf;
  400. border-radius: 2px;
  401. height: 28px;
  402. padding: 0 8px;
  403. }
  404. &.form-left {
  405. span {
  406. display: inline-block;
  407. width: 115px;
  408. text-align: right;
  409. }
  410. input {
  411. width: 104px;
  412. padding: 0 8px;
  413. }
  414. &.text-line {
  415. width: 100%;
  416. span {
  417. &.text {
  418. width: 300px;
  419. text-align: left;
  420. color: #4290f7;
  421. }
  422. }
  423. }
  424. }
  425. &.form-upload {
  426. text-align: center;
  427. label {
  428. margin-bottom: 0;
  429. cursor: pointer;
  430. input {
  431. display: none;
  432. }
  433. span {
  434. display: block;
  435. width: 94px;
  436. height: 23px;
  437. line-height: 18px;
  438. font-weight: normal;
  439. color: #4290f7;
  440. text-align: center;
  441. border: 1px dashed #4290f7;
  442. border-radius: 11px;
  443. i {
  444. font-weight: bold;
  445. font-style: normal;
  446. font-size: 18px;
  447. margin-right: 5px;
  448. }
  449. }
  450. }
  451. div {
  452. i {
  453. cursor: pointer;
  454. color: #eb222c;
  455. font-size: 16px;
  456. margin-right: 10px;
  457. }
  458. span {
  459. display: inline-block;
  460. max-width: 128px;
  461. overflow: hidden;
  462. text-overflow: ellipsis;
  463. white-space: nowrap;
  464. }
  465. }
  466. }
  467. &.form-right {
  468. position: relative;
  469. input {
  470. width: 104px;
  471. padding: 0 8px;
  472. }
  473. select {
  474. position: absolute;
  475. top: 0;
  476. width: 32px;
  477. height: 28px;
  478. background: url(/images/applyPurchase/arrow-down.png) no-repeat right center;
  479. border: {
  480. left: none;
  481. top: none;
  482. bottom: none;
  483. right: 1px solid #bfbfbf;
  484. bottom-left-radius: 4px;
  485. top-left-radius: 4px;
  486. }
  487. color: #5392f9;
  488. font: small-caption;
  489. padding-left: 8px;
  490. outline: none;
  491. & + input {
  492. padding-left: 36px;
  493. width: 133px;
  494. }
  495. }
  496. > i {
  497. margin-left: 4px;
  498. }
  499. }
  500. &.form-long {
  501. width: 100%;
  502. position: relative;
  503. ul {
  504. line-height: normal;
  505. position: absolute;
  506. top: 27px;
  507. left: 115px;
  508. background: #fff;
  509. border: 1px solid #b5b5b5;
  510. z-index: 1;
  511. max-height: 120px;
  512. overflow-y: auto;
  513. overflow-x: hidden;
  514. border-radius: 3px;
  515. width: 292px;
  516. font-size: 12px;
  517. li {
  518. height: 24px;
  519. line-height: 24px;
  520. cursor: pointer;
  521. overflow: hidden;
  522. text-overflow: ellipsis;
  523. white-space: nowrap;
  524. padding: 0 5px;
  525. &:hover {
  526. background: #ddd;
  527. }
  528. }
  529. }
  530. input {
  531. width: 292px;
  532. }
  533. }
  534. }
  535. }
  536. .switch-say {
  537. text-align: center;
  538. margin: 0 0 14px 0;
  539. font-size: 0;
  540. li {
  541. width: 200px;
  542. height: 34px;
  543. line-height: 34px;
  544. color: #4290f7;
  545. border: 1px solid #4290f7;
  546. display: inline-block;
  547. vertical-align: middle;
  548. font-size: 14px;
  549. cursor: pointer;
  550. &.active {
  551. color: #fff;
  552. background: #4290f7;
  553. }
  554. }
  555. }
  556. }
  557. .operate {
  558. background: #fff;
  559. height: 52px;
  560. text-align: center;
  561. padding-top: 12px;
  562. border: {
  563. top: 1px solid #e4e5e6;
  564. bottom-left-radius: 5px;
  565. bottom-right-radius: 5px;
  566. }
  567. span {
  568. display: inline-block;
  569. width: 64px;
  570. height: 28px;
  571. line-height: 28px;
  572. text-align: center;
  573. background: #4290f7;
  574. color: #fff;
  575. cursor: pointer;
  576. border-radius: 2px;
  577. &:last-child {
  578. margin-left: 15px;
  579. background: #acabab;
  580. }
  581. }
  582. }
  583. }
  584. </style>