SayPrice.vue 22 KB

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