applyPurchase.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. <template>
  2. <div class="apply_purchase_mobile" @click="showSimilarBrandList = false">
  3. <div class="com-mobile-header mobile-center-header">
  4. <a @click.stop="goLastPage"><i class="iconfont icon-fanhui"></i></a>
  5. <p>发布求购</p>
  6. <p class="en-name"><img :src="`/images/mobile/center/${user.data.enterprise.uu ? 'en' : 'self'}.png`" alt="">{{currentEnName}}</p>
  7. </div>
  8. <div class="mobile-fix-content mobile-centerfix-content" id="mobileFixContent">
  9. <div class="search-content search-content2" style="position: relative">
  10. <input type="text" placeholder="请输入您要询价求购的型号" @input="onBrandChange" v-model="keyword" @keyup.13="searchComplist">
  11. <span @click.stop="searchComplist" >
  12. <i class="iconfont icon-sousuo"></i>
  13. </span>
  14. <ul class="similar brand-similar-list" v-show="showSimilarBrandList && keyword">
  15. <li v-for="sBrand in similarBrand" @click.stop="setBrand(sBrand.code)">{{sBrand.code}}</li>
  16. </ul>
  17. </div>
  18. <publish-seek v-if="showPublishBox" :dataObj="componentSeekObj" @remindAction="onRemind" :isNumberReg="true"></publish-seek>
  19. <template v-else>
  20. <ul v-if="compList && compList.length">
  21. <li v-for="comp in compList">
  22. <div class="listInfo">
  23. <p>品牌:<span v-text="comp.brand || '-'"></span></p>
  24. <p>物料名称:<span v-text="comp.kind || '-'"></span></p>
  25. <p>型号:<span v-text="comp.cmpCode || '-'"></span></p>
  26. <p>规格:<span v-text="comp.spec || '-'"></span></p>
  27. <p>单位:<span v-text="comp.unit || 'PCS'"></span></p>
  28. </div>
  29. <a class="sa-pub" @click.stop="compInquiry(comp, $event)">立即询价</a>
  30. </li>
  31. </ul>
  32. <empty-status :type="'collect'" :showLink="true" :text="'抱歉,没有相关信息'" v-else></empty-status>
  33. </template>
  34. </div>
  35. <remind-box :title="remindText" :timeoutCount="timeoutCount"></remind-box>
  36. <pull-up :fixId="'mobileFixContent'" :searchMore="fetching" :allPage="allPage" :page="page" @pullUpAction="onPullUpAction"></pull-up>
  37. </div>
  38. </template>
  39. <script>
  40. import { RemindBox, PullUp, EmptyStatus } from '~components/mobile/common'
  41. import {PublishSeek} from '~components/mobile/applyPurchase'
  42. export default {
  43. middleware: 'authenticated',
  44. layout: 'mobileNoHeader',
  45. fetch ({ store }) {
  46. return Promise.all([
  47. store.dispatch('product/loadPublishList', { count: 10, page: 1, keyword: null })
  48. ])
  49. },
  50. data () {
  51. return {
  52. keyword: '',
  53. remindText: '',
  54. timeoutCount: 0,
  55. page: 1,
  56. count: 10,
  57. isChange: false,
  58. compList: [],
  59. componentSeekObj: {
  60. code: '',
  61. brand: '',
  62. spec: '',
  63. prodTitle: ''
  64. },
  65. showPublishBox: true,
  66. showSimilarBrandList: false,
  67. similarBrand: []
  68. }
  69. },
  70. watch: {
  71. 'compCollectList.data': {
  72. handler: function (val) {
  73. if (this.isChange) {
  74. this.compList = val.content
  75. this.isChange = false
  76. } else {
  77. this.compList = [...this.compList, ...val.content]
  78. }
  79. },
  80. immediate: true
  81. }
  82. },
  83. computed: {
  84. compCollectList () {
  85. return this.$store.state.product.common.publishMobile
  86. },
  87. fetching () {
  88. return this.compCollectList.fetching
  89. },
  90. allPage () {
  91. return Math.floor(this.compCollectList.data.totalElements / this.compCollectList.data.size) + Math.floor(this.compCollectList.data.totalElements % this.compCollectList.data.size > 0 ? 1 : 0)
  92. }
  93. },
  94. components: {
  95. RemindBox,
  96. PullUp,
  97. EmptyStatus,
  98. PublishSeek
  99. },
  100. methods: {
  101. onBrandChange: function () {
  102. this.keyword = this.keyword.trim()
  103. if ((/[^\x00-\xff]/g).test(this.keyword)) {
  104. let chineseIndex = -1
  105. for (let i = 0; i < this.keyword.length; i++) {
  106. if ((/[^\x00-\xff]/g).test(this.keyword.charAt(i)) && !(/[\u4e00-\u9fa5]/).test(this.keyword.charAt(i))) {
  107. chineseIndex = i
  108. break
  109. }
  110. }
  111. if (chineseIndex > -1) {
  112. this.keyword = this.keyword.substring(0, chineseIndex)
  113. }
  114. } else if (this.keyword && this.baseUtils.getRealLen(this.keyword) > 50) {
  115. this.keyword = this.baseUtils.cutOutString(this.keyword, 50)
  116. } else {
  117. this.getSimilarBrand()
  118. }
  119. },
  120. getSimilarBrand: function () {
  121. if (this.keyword) {
  122. this.$http.get('/search/similarKeywords', {params: {keyword: this.keyword, type: 'component'}})
  123. .then(response => {
  124. this.similarBrand = response.data.result
  125. this.showSimilarBrandList = response.data.result.length > 0
  126. })
  127. } else {
  128. this.showSimilarBrandList = false
  129. }
  130. },
  131. setBrand: function (brand) {
  132. this.keyword = brand
  133. this.showSimilarBrandList = false
  134. this.searchComplist()
  135. },
  136. searchComplist () {
  137. if (this.keyword !== '') {
  138. this.showSimilarBrandList = false
  139. this.reloadList()
  140. this.showPublishBox = false
  141. this.page = 1
  142. this.isChange = true
  143. } else {
  144. this.remindText = '请输入您要询价求购型号'
  145. this.timeoutCount++
  146. }
  147. },
  148. onRemind: function (str) {
  149. this.remindText = str
  150. this.timeoutCount++
  151. },
  152. reloadList: function () {
  153. this.$store.dispatch('product/loadPublishList', { page: this.page, count: this.count, keyword: this.keyword })
  154. },
  155. onPullUpAction: function () {
  156. this.page++
  157. this.reloadList()
  158. },
  159. compInquiry: function (item, e) {
  160. if (e) {
  161. e.stopPropagation()
  162. }
  163. this.componentSeekObj.code = item.cmpCode ? item.cmpCode : ''
  164. this.componentSeekObj.brand = item.brand ? item.brand : ''
  165. this.componentSeekObj.spec = item.spec ? item.spec : ''
  166. this.componentSeekObj.prodTitle = item.kind ? item.kind : ''
  167. this.componentSeekObj = JSON.parse(JSON.stringify(this.componentSeekObj))
  168. this.showPublishBox = true
  169. },
  170. goUrl: function (url) {
  171. this.$router.push(url)
  172. }
  173. }
  174. }
  175. </script>
  176. <style lang="scss" scoped>
  177. .mobile-fix-content {
  178. .similar {
  179. position: absolute;
  180. width: 6.5rem;
  181. max-height: 2.5rem;
  182. overflow-y: auto;
  183. z-index: 12;
  184. border: 1px solid #7e7e7e;
  185. border-radius: .05rem;
  186. top: .7rem;
  187. background: #fff;
  188. left: 0.1rem;
  189. right: 0;
  190. margin: 0 auto;
  191. li {
  192. height: .5rem;
  193. line-height: .5rem;
  194. font-size: .26rem;
  195. color: #999;
  196. padding-left: .19rem;
  197. text-align: left;
  198. overflow: hidden;
  199. text-overflow: ellipsis;
  200. white-space: nowrap;
  201. &:focus, &:active, &:hover {
  202. background: #999;
  203. color: #fff;
  204. }
  205. }
  206. }
  207. .search-content {
  208. text-align: center;
  209. input {
  210. border: 1px solid #376ff3;
  211. }
  212. span{
  213. top:0;
  214. }
  215. }
  216. ul {
  217. margin: .2rem;
  218. li {
  219. border-radius: .05rem;
  220. margin: .25rem 0 0 0;
  221. position: relative;
  222. background: #fff;
  223. .listInfo {
  224. padding: .25rem .1rem .25rem .23rem;
  225. p {
  226. color: #666;
  227. font-size: .3rem;
  228. line-height: .45rem;
  229. overflow: hidden;
  230. text-overflow: ellipsis;
  231. white-space: nowrap;
  232. span {
  233. color: #333;
  234. }
  235. }
  236. }
  237. .sa-pub {
  238. position: absolute;
  239. bottom: .2rem;
  240. right:0;
  241. display: block;
  242. width: 1.7rem;
  243. height: .47rem;
  244. line-height: .47rem;
  245. text-align: center;
  246. font-size: .26rem;
  247. color: #fff;
  248. background: #008bf7;
  249. margin-right:.2rem;
  250. border-radius: .05rem;
  251. }
  252. }
  253. }
  254. }
  255. </style>