SayPrice.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588
  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/saveQuote', 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: calc(((80vh - 113px) - 133px - 100vh) / 2);
  351. margin-left: -238px;
  352. max-height: calc(80vh - 113px);
  353. overflow-y: auto;
  354. /*-webkit-box-shadow: 0 5px 15px rgba(0,0,0,.5);*/
  355. /*-moz-box-shadow: 0 5px 15px rgba(0,0,0,.5);*/
  356. /*box-shadow: 0 5px 15px rgba(0,0,0,.5);*/
  357. z-index: 1;
  358. .title {
  359. position: relative;
  360. height: 38px;
  361. background: #4290f7;
  362. line-height: 38px;
  363. color: #fff;
  364. border: {
  365. top-right-radius: 5px;
  366. top-left-radius: 5px;
  367. }
  368. padding-left: 20px;
  369. font-weight: bold;
  370. /*> div {*/
  371. /*display: inline-block;*/
  372. /*padding-left: 57px;*/
  373. /*width: 47%;*/
  374. /*overflow: hidden;*/
  375. /*text-overflow: ellipsis;*/
  376. /*white-space: nowrap;*/
  377. /*}*/
  378. i {
  379. position: absolute;
  380. right: 10px;
  381. top: 8px;
  382. cursor: pointer;
  383. }
  384. }
  385. .content {
  386. padding: 9px 0 0 0;
  387. background: #fff;
  388. .content-line {
  389. padding: 0 0 14px 0;
  390. .form-item {
  391. display: inline-block;
  392. width: 49%;
  393. > span {
  394. i {
  395. color: #fd2637;
  396. margin-right: 4px;
  397. }
  398. }
  399. input {
  400. border: 1px solid #bfbfbf;
  401. border-radius: 2px;
  402. height: 28px;
  403. padding: 0 8px;
  404. }
  405. &.form-left {
  406. span {
  407. display: inline-block;
  408. width: 115px;
  409. text-align: right;
  410. }
  411. input {
  412. width: 104px;
  413. padding: 0 8px;
  414. }
  415. &.text-line {
  416. width: 100%;
  417. span {
  418. &.text {
  419. width: 300px;
  420. text-align: left;
  421. color: #4290f7;
  422. word-break: break-all;
  423. word-wrap: break-word;
  424. vertical-align: top;
  425. }
  426. }
  427. }
  428. }
  429. &.form-upload {
  430. text-align: center;
  431. label {
  432. margin-bottom: 0;
  433. cursor: pointer;
  434. input {
  435. display: none;
  436. }
  437. span {
  438. display: block;
  439. width: 94px;
  440. height: 23px;
  441. line-height: 18px;
  442. font-weight: normal;
  443. color: #4290f7;
  444. text-align: center;
  445. border: 1px dashed #4290f7;
  446. border-radius: 11px;
  447. i {
  448. font-weight: bold;
  449. font-style: normal;
  450. font-size: 18px;
  451. margin-right: 5px;
  452. }
  453. }
  454. }
  455. div {
  456. i {
  457. cursor: pointer;
  458. color: #eb222c;
  459. font-size: 16px;
  460. margin-right: 10px;
  461. }
  462. span {
  463. display: inline-block;
  464. max-width: 128px;
  465. overflow: hidden;
  466. text-overflow: ellipsis;
  467. white-space: nowrap;
  468. }
  469. }
  470. }
  471. &.form-right {
  472. position: relative;
  473. input {
  474. width: 104px;
  475. padding: 0 8px;
  476. }
  477. select {
  478. position: absolute;
  479. top: 0;
  480. width: 32px;
  481. height: 28px;
  482. background: url(/images/applyPurchase/arrow-down.png) no-repeat right center;
  483. border: {
  484. left: none;
  485. top: none;
  486. bottom: none;
  487. right: 1px solid #bfbfbf;
  488. bottom-left-radius: 4px;
  489. top-left-radius: 4px;
  490. }
  491. color: #5392f9;
  492. font: small-caption;
  493. padding-left: 8px;
  494. outline: none;
  495. & + input {
  496. padding-left: 36px;
  497. width: 133px;
  498. }
  499. }
  500. > i {
  501. margin-left: 4px;
  502. }
  503. }
  504. &.form-long {
  505. width: 100%;
  506. position: relative;
  507. ul {
  508. line-height: normal;
  509. position: absolute;
  510. top: 27px;
  511. left: 115px;
  512. background: #fff;
  513. border: 1px solid #b5b5b5;
  514. z-index: 1;
  515. max-height: 120px;
  516. overflow-y: auto;
  517. overflow-x: hidden;
  518. border-radius: 3px;
  519. width: 292px;
  520. font-size: 12px;
  521. li {
  522. height: 24px;
  523. line-height: 24px;
  524. cursor: pointer;
  525. overflow: hidden;
  526. text-overflow: ellipsis;
  527. white-space: nowrap;
  528. padding: 0 5px;
  529. &:hover {
  530. background: #ddd;
  531. }
  532. }
  533. }
  534. input {
  535. width: 292px;
  536. }
  537. }
  538. }
  539. }
  540. .switch-say {
  541. text-align: center;
  542. margin: 0 0 14px 0;
  543. font-size: 0;
  544. li {
  545. width: 200px;
  546. height: 34px;
  547. line-height: 34px;
  548. color: #4290f7;
  549. border: 1px solid #4290f7;
  550. display: inline-block;
  551. vertical-align: middle;
  552. font-size: 14px;
  553. cursor: pointer;
  554. &.active {
  555. color: #fff;
  556. background: #4290f7;
  557. }
  558. }
  559. }
  560. }
  561. .operate {
  562. background: #fff;
  563. height: 52px;
  564. text-align: center;
  565. padding-top: 12px;
  566. border: {
  567. top: 1px solid #e4e5e6;
  568. bottom-left-radius: 5px;
  569. bottom-right-radius: 5px;
  570. }
  571. span {
  572. display: inline-block;
  573. width: 64px;
  574. height: 28px;
  575. line-height: 28px;
  576. text-align: center;
  577. background: #4290f7;
  578. color: #fff;
  579. cursor: pointer;
  580. border-radius: 2px;
  581. &:last-child {
  582. margin-left: 15px;
  583. background: #acabab;
  584. }
  585. }
  586. }
  587. }
  588. </style>