resource.vue 21 KB

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