resource.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703
  1. <template>
  2. <div class="resource_info">
  3. <div class="container">
  4. <div class="crumbs">
  5. <div class="container">
  6. <div class="menu-com row">
  7. <div class="menu-title col-md-12">
  8. <a href="/">首页 ></a>
  9. <a href="/supplier">供应商资源 ></a>
  10. <span>供应商物料</span>
  11. </div>
  12. </div>
  13. </div>
  14. </div>
  15. <div class="user_info">
  16. <div class="user_title">
  17. <div class="user_name">
  18. <span>{{enUser.enName}}&nbsp;&nbsp;<i class="fa fa-angle-down"></i></span>
  19. <a :href="/store/+ storeInfo.uuid" target="_blank" v-if="storeInfo.uuid">进入店铺</a>
  20. </div>
  21. <div class="user_mes">
  22. <div class="mes-list">
  23. <p>
  24. <span><i class="supplier_icon1"></i>企业执照号:{{enUser.enBussinessCode ? enUser.enBussinessCode : '暂无信息'}}</span>
  25. <span><i class="supplier_icon2"></i> 地址:{{enUser.enAddress ? enUser.enAddress : '暂无信息'}}</span>
  26. </p>
  27. <p>
  28. <span><i class="supplier_icon3"></i> 邮箱:{{enUser.enEmail ? enUser.enEmail : '暂无信息'}}</span>
  29. <span><i class="supplier_icon4"></i> 电话:{{enUser.enTel ? enUser.enTel : '暂无信息'}}</span>
  30. <span><i class="supplier_icon5"></i> 行业:{{enUser.enIndustry ? enUser.enIndustry : '暂无信息'}}</span>
  31. </p>
  32. </div>
  33. </div>
  34. </div>
  35. <div class="search">
  36. <div class="input-group">
  37. <input type="search" class="form-control" placeholder="请输入要查找的内容"
  38. v-model="searchCode" @keyup.13="goodsSearch(searchCode)" @search="goodsSearch(searchCode)"/>
  39. <span class="input-group-btn">
  40. <button type="button" class="btn" id="search_btn" @click="goodsSearch(searchCode)">
  41. 搜索 <i class="fa fa-search"></i>
  42. </button>
  43. </span>
  44. </div>
  45. </div>
  46. </div>
  47. <div class="info_list">
  48. <table>
  49. <thead>
  50. <tr>
  51. <th width="66">序号</th>
  52. <th width="1008">
  53. <span>原厂型号 / 品牌</span>
  54. <span>类目(名称) / 单位</span>
  55. <span>规格</span>
  56. </th>
  57. <th width="116">操作</th>
  58. </tr>
  59. </thead>
  60. <tbody>
  61. <tr v-for="(item, index) in list.content" @click="jumpDetail(item.id)">
  62. <td v-text="index + 1">12</td>
  63. <td>
  64. <ul class="list-inline">
  65. <li class="item">
  66. <span class="fl">原厂型号</span>
  67. <p v-text="item.cmpCode ? spliceString(item.cmpCode, 95) : '暂无信息'">2</p>
  68. </li>
  69. <li class="item">
  70. <span class="fl">类目(名称)</span>
  71. <p v-text="item.prodName ? spliceString(item.prodName, 95) : '暂无信息'">1</p>
  72. </li>
  73. <li class="item">
  74. <span class="fl">规格</span>
  75. <p v-text="item.spec ? spliceString(item.spec, 95) : '暂无信息'">1</p>
  76. </li>
  77. <li class="item">
  78. <span class="fl">品牌</span>
  79. <p v-text="item.brand ? spliceString(item.brand, 95) : '暂无信息'">2</p>
  80. </li>
  81. <li class="item">
  82. <span class="fl">单位</span>
  83. <p v-text="item.unit ? item.unit : '暂无信息'">1</p>
  84. </li>
  85. </ul>
  86. </td>
  87. <td>
  88. <a @click="immediatelyClick(item)" @mouseleave="hasClick = false" @mouseenter="hasClick = true">立即询价</a>
  89. </td>
  90. </tr>
  91. </tbody>
  92. </table>
  93. <div style="float: right;background: #ecf1f1;">
  94. <page :total="list.totalElements" :page-size="pageParams.count"
  95. :current="pageParams.page" v-on:childEvent="handleCurrentChange">
  96. </page>
  97. </div>
  98. </div>
  99. <el-dialog
  100. title="我要询价"
  101. :visible.sync="hasDialog">
  102. <div class="form_dialog">
  103. <ul class="list-inline">
  104. <li class="form-item">
  105. <span>型号:</span>
  106. <p v-text="applyObj.cmpCode ? spliceString(applyObj.cmpCode, 90) : '-'">32432</p>
  107. </li>
  108. <li class="form-item">
  109. <span>类目:</span>
  110. <p v-text="applyObj.prodName ? spliceString(applyObj.prodName, 90) : '-'">32</p>
  111. </li>
  112. <li class="form-item">
  113. <span>品牌:</span>
  114. <p v-text="applyObj.brand ? spliceString(applyObj.brand, 90) : '-'">32432</p>
  115. </li>
  116. <li class="form-item">
  117. <span>规格:</span>
  118. <p v-text="applyObj.spec ? spliceString(applyObj.spec, 90) : '-'">32432</p>
  119. </li>
  120. <li class="form-item">
  121. <span><i>*</i>截止日期:</span>
  122. <el-date-picker
  123. :class="{'error': !validObj.deadline}"
  124. v-model="applyObj.deadline"
  125. type="date"
  126. :picker-options="pickerOptions"
  127. @change="setDeadLineValid"
  128. :editable="false"
  129. :clearable="true"
  130. size="mini">
  131. </el-date-picker>
  132. </li>
  133. <li class="form-item">
  134. <span>封装:</span>
  135. <input type="text" class="form-control" v-model="applyObj.encapsulation"/>
  136. </li>
  137. <li class="form-item">
  138. <span>单价预算:</span>
  139. <select v-model="applyObj.currency" class="form-control" style="width:40px;">
  140. <option value="RMB">¥</option>
  141. <option value="USD">$</option>
  142. </select>
  143. <input type="number" v-model="applyObj.unitPrice" class="form-control" :class="{'error': !validObj.unitPrice}"/>
  144. </li>
  145. <li class="form-item">
  146. <span>生产日期:</span>
  147. <input type="text" class="form-control" v-model="applyObj.produceDate"/>
  148. </li>
  149. <li class="form-item">
  150. <span>采购数量:</span>
  151. <input type="number" class="form-control" v-model="applyObj.amount" :class="{'error': !validObj.amount}"/>
  152. </li>
  153. </ul>
  154. </div>
  155. <span slot="footer" class="dialog-footer">
  156. <a type="button" @click="goPublish">询价提交</a>
  157. </span>
  158. </el-dialog>
  159. </div>
  160. </div>
  161. </template>
  162. <script>
  163. import {spliceStr, formatDate} from '~utils/baseUtils.js'
  164. import Page from '~/components/common/page/pageComponent.vue'
  165. export default {
  166. name: 'ResourceView',
  167. data () {
  168. return {
  169. applyObj: {
  170. cmpCode: '',
  171. brand: '',
  172. unitPrice: '',
  173. currency: 'RMB',
  174. prodName: '',
  175. spec: '',
  176. encapsulation: '',
  177. produceDate: '',
  178. amount: '',
  179. deadline: ''
  180. },
  181. validObj: {
  182. unitPrice: true,
  183. amount: true,
  184. deadline: true
  185. },
  186. pickerOptions: {
  187. disabledDate (time) {
  188. // 大于等于今天 小于三个月后
  189. return time.getTime() < Date.now() - 1000 * 60 * 60 * 24 || time.getTime() > Date.now() + 1000 * 60 * 60 * 24 * 30 * 3
  190. }
  191. },
  192. hasDialog: false,
  193. hasClick: false,
  194. searchCode: '',
  195. pageParams: {
  196. count: 10,
  197. page: 1
  198. }
  199. }
  200. },
  201. components: {
  202. Page
  203. },
  204. computed: {
  205. list () {
  206. return this.$store.state.supplier.material.material.data
  207. },
  208. enUser () {
  209. return this.$store.state.supplier.material.enUser.data
  210. },
  211. storeInfo () {
  212. return this.$store.state.shop.storeInfo.store.data
  213. },
  214. user () {
  215. return this.$store.state.option.user
  216. }
  217. },
  218. methods: {
  219. // 格式化字符串长度
  220. spliceString (str, length) {
  221. return spliceStr(str, length)
  222. },
  223. // 跳转到器件详情页面
  224. jumpDetail (id) {
  225. if (!this.hasClick) {
  226. this.$router.push(this.$route.path + '/' + id)
  227. }
  228. },
  229. // 获取分页数据
  230. handleCurrentChange (type) {
  231. this.pageParams.page = type
  232. this.$store.dispatch('supplier/loadMaterialList', {page: type, size: 20, vendUU: this.$route.params.uuid, keyword: this.searchCode})
  233. },
  234. // 根据搜索信息获取数据
  235. goodsSearch (type) {
  236. this.pageParams.page = 1
  237. this.$store.dispatch('supplier/loadMaterialList', {
  238. page: this.pageParams.page,
  239. size: this.pageParams.count,
  240. vendUU: this.$route.params.uuid,
  241. keyword: type
  242. })
  243. },
  244. // 弹出询价界面
  245. immediatelyClick (type) {
  246. this.hasDialog = true
  247. this.applyObj.cmpCode = type.cmpCode
  248. this.applyObj.brand = type.brand
  249. this.applyObj.spec = type.spec
  250. this.applyObj.prodName = type.prodName
  251. },
  252. // 时间格式化
  253. setDeadLineValid: function () {
  254. this.applyObj.deadline = formatDate(this.applyObj.deadline, 'yyyy-MM-dd hh:mm:ss')
  255. this.validObj.deadline = true
  256. },
  257. // 检查单价预算
  258. checkUnitPrice () {
  259. this.validObj.unitPrice = this.applyObj.unitPrice === '' ? true : this.applyObj.unitPrice > 0 && this.applyObj.unitPrice < 100000000
  260. if (!this.validObj.unitPrice && this.applyObj.unitPrice <= 0) {
  261. this.$message.error('单价必须是大于0的数字')
  262. }
  263. return this.validObj.unitPrice
  264. },
  265. // 检查采购数量
  266. checkAmount () {
  267. this.validObj.amount = this.applyObj.amount === '' ? true : this.applyObj.amount > 0 && this.applyObj.amount < 1000000000
  268. return this.validObj.amount
  269. },
  270. // 检查时间是否有输入
  271. checkDeadline () {
  272. this.validObj.deadline = Boolean(this.applyObj.deadline)
  273. return this.validObj.deadline
  274. },
  275. // 检查各个字段输入正常数据
  276. checkAll () {
  277. return this.checkDeadline() && this.checkUnitPrice() && this.checkAmount()
  278. },
  279. emptyForm () {
  280. for (let attr in this.applyObj) {
  281. this.applyObj[attr] = attr === 'currency' ? 'RMB' : ''
  282. }
  283. },
  284. // 请求询价信息
  285. goPublish () {
  286. if (this.checkAll()) {
  287. let inquiry = {}
  288. let inquiryItem = {}
  289. if (this.user.data.enterprise) {
  290. inquiry.enUU = this.user.data.enterprise.uu
  291. }
  292. let date = new Date()
  293. let currency = this.applyObj.unitPrice ? this.applyObj.currency : null
  294. inquiry.recorderUU = this.user.data.userUU
  295. inquiry.code = 'MALL' + date.getTime()
  296. inquiry.date = date
  297. inquiry.recorder = this.user.data.userName
  298. inquiry.endDate = this.applyObj.deadline
  299. inquiry.sourceapp = 'MALL'
  300. inquiry.amount = 1
  301. inquiryItem.userUU = this.user.data.userUU
  302. inquiryItem.source = 'MALL'
  303. inquiryItem.userName = this.user.data.userName
  304. inquiryItem.userTel = this.user.data.userTel
  305. inquiryItem.needquantity = this.applyObj.amount
  306. inquiryItem.inbrand = this.applyObj.brand
  307. inquiryItem.currency = currency
  308. inquiryItem.cmpCode = this.applyObj.cmpCode.toUpperCase()
  309. inquiryItem.unitPrice = this.applyObj.unitPrice
  310. inquiryItem.produceDate = this.applyObj.produceDate
  311. inquiryItem.date = date
  312. inquiryItem.endDate = this.applyObj.deadline
  313. inquiryItem.encapsulation = this.applyObj.encapsulation
  314. inquiryItem.spec = this.applyObj.spec
  315. inquiryItem.prodTitle = this.applyObj.prodName
  316. let inquiryItems = []
  317. inquiryItems.push(inquiryItem)
  318. inquiry.inquiryItems = inquiryItems
  319. inquiry.currency = this.applyObj.unitPrice ? this.applyObj.currency : null
  320. this.$http.post('/inquiry/buyer/save', inquiry)
  321. .then(res => {
  322. this.$message.success('发布成功')
  323. this.hasDialog = false
  324. this.emptyForm()
  325. }, error => {
  326. console.log(error)
  327. this.$message.error('发布失败')
  328. })
  329. } else {
  330. if (!this.validObj.deadline) {
  331. this.$message.error('截止日期不能为空')
  332. } else if (!this.validObj.amount) {
  333. this.$message.error('请输入正确的数值')
  334. }
  335. }
  336. }
  337. }
  338. }
  339. </script>
  340. <style type="text/scss" lang="scss">
  341. .resource_info{
  342. background: #ecf1f1;
  343. .el-dialog{
  344. width: 680px!important;
  345. .el-dialog__header{
  346. background: #4290f7;
  347. line-height: 40px;
  348. padding: 0 20px 0;
  349. .el-dialog__title{
  350. color:#fff;
  351. }
  352. .el-dialog__headerbtn:hover .el-dialog__close, .el-dialog__headerbtn:focus .el-dialog__close{
  353. color:#fff;
  354. }
  355. }
  356. .el-dialog__body{
  357. padding: 10px 20px;
  358. }
  359. .el-dialog__footer{
  360. text-align: center;
  361. a{
  362. display:inline-block;
  363. background: #3c7cf5;
  364. color:#fff;
  365. font-size: 14px;
  366. line-height: 30px;
  367. height:30px;
  368. padding:0 10px;
  369. border-radius:5px;
  370. }
  371. }
  372. }
  373. .form_dialog{
  374. .el-date-editor--date{
  375. width: 230px;
  376. &.error {
  377. input {
  378. border: 1px solid #f4645f !important;
  379. }
  380. }
  381. }
  382. ul{
  383. li{
  384. width:50%;
  385. font-size: 14px;
  386. color:#666;
  387. vertical-align: top;
  388. margin-bottom:15px;
  389. &.form-item {
  390. position: relative;
  391. p{
  392. margin:0;
  393. margin-left:80px;
  394. word-break: break-all;
  395. word-wrap: break-word;
  396. }
  397. span {
  398. float:left;
  399. width: 80px;
  400. text-align: right;
  401. display: inline-block;
  402. color:#3c7cf5;
  403. i {
  404. position: relative;
  405. top: 2px;
  406. right: 5px;
  407. color: #e41515;
  408. }
  409. }
  410. ul {
  411. line-height: normal;
  412. position: absolute;
  413. top: 19px;
  414. left: 79px;
  415. background: #fff;
  416. border: 1px solid #b5b5b5;
  417. z-index: 1;
  418. max-height: 120px;
  419. overflow-y: auto;
  420. overflow-x: hidden;
  421. border-radius: 3px;
  422. width: 114px;
  423. font-size: 12px;
  424. li {
  425. height: 24px;
  426. line-height: 24px;
  427. cursor: pointer;
  428. overflow: hidden;
  429. text-overflow: ellipsis;
  430. white-space: nowrap;
  431. padding: 0 5px;
  432. &:hover {
  433. background: #ddd;
  434. }
  435. }
  436. }
  437. select {
  438. width: 40px;
  439. position: absolute;
  440. height: 20px;
  441. background: url('/images/applyPurchase/select.png')no-repeat right;
  442. background-position-x: 23px;
  443. padding: 0 0 0 7px;
  444. border-radius: 0;
  445. & + input {
  446. padding-left: 45px;
  447. }
  448. }
  449. .el-input {
  450. width: 230px;
  451. }
  452. input {
  453. font-size: 14px;
  454. width: 230px;
  455. height: 20px;
  456. line-height: 20px;
  457. border-radius: 2px;
  458. padding: 0 3px;
  459. box-shadow: none;
  460. -webkit-box-shadow: none;
  461. -moz-box-shadow: none;
  462. &.error {
  463. border-color: #f4645f!important;
  464. }
  465. }
  466. }
  467. }
  468. }
  469. }
  470. .crumbs{
  471. background: #ecf1f1;
  472. .menu-com{
  473. margin: 0;
  474. .menu-title{
  475. line-height: 40px;
  476. font-size: 14px;
  477. padding-left: 0;
  478. margin:0;
  479. a{
  480. color: #5078cb;
  481. font-size: 14px;
  482. }
  483. }
  484. }
  485. }
  486. .user_info{
  487. margin-bottom:5px;
  488. .user_title{
  489. display:inline-block;
  490. position:relative;
  491. padding-bottom:13px;
  492. margin-right:330px;
  493. &:hover{
  494. .user_mes{
  495. display:block;
  496. }
  497. }
  498. .user_name{
  499. span{
  500. font-size: 20px;
  501. color:#666;
  502. font-weight: bold;
  503. margin-right:10px;
  504. }
  505. a{
  506. display:inline-block;
  507. padding:0 10px;
  508. border-radius:3px;
  509. font-size: 12px;
  510. height:24px;
  511. line-height: 24px;
  512. color:#fff;
  513. background: #ffa200;
  514. }
  515. }
  516. .user_mes{
  517. display:none;
  518. position:absolute;
  519. top:100%;
  520. left:0;
  521. z-index: 200;
  522. height:10px;
  523. &:before{
  524. content: '';
  525. display:block;
  526. position:absolute;
  527. bottom:5px;
  528. left:20px;
  529. z-index: 100;
  530. border: 5px solid rgba(0,0,0,.7);
  531. -webkit-transform: rotate(45deg);
  532. -moz-transform: rotate(45deg);
  533. -o-transform:rotate(45deg);
  534. -ms-transform: rotate(45deg);
  535. transform:rotate(45deg);
  536. }
  537. .mes-list{
  538. padding:10px 10px;
  539. background: rgba(0,0,0,.7);
  540. color:#fff;
  541. p{
  542. max-width:1183px;
  543. min-width:118px;
  544. margin:0;
  545. line-height: 20px;
  546. font-size: 12px;
  547. color:#fff;
  548. overflow: hidden;
  549. white-space: nowrap;
  550. span{
  551. margin: 0 5px;
  552. .supplier_icon1{
  553. display:inline-block;
  554. position: relative;
  555. top: 5px;
  556. width:20px;
  557. height:18px;
  558. background: url(/images/supplier/icon/supplier_icon.png)no-repeat 0 0;
  559. }
  560. .supplier_icon2{
  561. display:inline-block;
  562. position: relative;
  563. top: 5px;
  564. width:20px;
  565. height:18px;
  566. background: url(/images/supplier/icon/supplier_icon.png)no-repeat -20px 0;
  567. }
  568. .supplier_icon3{
  569. display:inline-block;
  570. position: relative;
  571. top: 5px;
  572. width:20px;
  573. height:18px;
  574. background: url(/images/supplier/icon/supplier_icon.png)no-repeat -40px 0;
  575. }
  576. .supplier_icon4{
  577. display:inline-block;
  578. position: relative;
  579. top: 5px;
  580. height:18px;
  581. width:22px;
  582. background: url(/images/supplier/icon/supplier_icon.png)no-repeat -60px 0;
  583. }
  584. .supplier_icon5{
  585. display:inline-block;
  586. position: relative;
  587. top: 5px;
  588. width:20px;
  589. height:18px;
  590. background: url(/images/supplier/icon/supplier_icon.png)no-repeat -85px 0;
  591. }
  592. }
  593. }
  594. }
  595. }
  596. }
  597. .search{
  598. width:310px;
  599. margin:0;
  600. float:right;
  601. .btn{
  602. background: #3c7cf5;
  603. color:#fff;
  604. }
  605. }
  606. }
  607. .info_list{
  608. padding-bottom:200px;
  609. table {
  610. table-layout: fixed;
  611. thead{
  612. tr{
  613. line-height: 32px;
  614. vertical-align: middle;
  615. th{
  616. font-size: 14px;
  617. color:#fff;
  618. text-align: center;
  619. background: #3975f4;
  620. span{
  621. display:inline-block;
  622. width:33%;
  623. }
  624. }
  625. }
  626. }
  627. tbody{
  628. tr{
  629. border:1px solid #dadada;
  630. &:nth-child(odd){
  631. background: #fff;
  632. }
  633. &:nth-child(even){
  634. background: #f8f8f8;
  635. }
  636. &:hover{
  637. cursor:pointer;
  638. background: #f8fafe;
  639. td{
  640. &:first-child{
  641. border-left:1px solid #3975f4;
  642. }
  643. &:last-child{
  644. border-right:1px solid #3975f4;
  645. }
  646. border-top:1px solid #3975f4;
  647. border-bottom:1px solid #3975f4;
  648. }
  649. }
  650. td{
  651. vertical-align: middle;
  652. margin:0 auto;
  653. padding:10px 0;
  654. &:first-child, &:last-child{
  655. color:#ed791c;
  656. text-align: center;
  657. }
  658. a{
  659. display:inline-block;
  660. padding:0 10px;
  661. margin:0 auto;
  662. line-height: 24px;
  663. border-radius:3px;
  664. height:24px;
  665. font-size: 12px;
  666. color:#fff;
  667. background: #3c7cf5;
  668. text-align: center;
  669. }
  670. ul{
  671. margin-left:5px;
  672. }
  673. .item{
  674. font-size: 12px;
  675. line-height: 18px;
  676. padding: 10px 0;
  677. vertical-align: top;
  678. width:33%;
  679. span{
  680. display:inline-block;
  681. width:85px;
  682. text-align: right;
  683. color:#3c7cf5;
  684. }
  685. p{
  686. display:block;
  687. width:210px;
  688. margin-left:100px;
  689. margin-bottom:0;
  690. color:#333;
  691. word-break: break-all;
  692. word-wrap:break-word;
  693. }
  694. }
  695. }
  696. }
  697. }
  698. }
  699. }
  700. }
  701. </style>