BatchPublish.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477
  1. <template>
  2. <div class="batch-publish">
  3. <p>成功上传<b class="red-text">{{bomNumber.successImport || 0}}</b>个<br/>另有<span class="red-text">{{bomNumber.nullField || 0}}</span>个必填项缺失,请在当前页完善信息</p>
  4. <table>
  5. <thead>
  6. <tr>
  7. <th width="60">
  8. <label class="com-check-box">
  9. <input type="checkbox" id="all" @change="onCheck()" v-model="isCheckAll">
  10. <label for="all"></label>
  11. </label>全选
  12. </th>
  13. <th width="160"><i class="red-text">*</i>型号</th>
  14. <th width="132"><i class="red-text">*</i>品牌</th>
  15. <th width="100">采购数量</th>
  16. <th width="128">单价预算</th>
  17. <th width="76">封装</th>
  18. <th width="102">生产日期</th>
  19. <th width="144"><i class="red-text">*</i>截止时间</th>
  20. <th width="92">操作</th>
  21. </tr>
  22. </thead>
  23. <tbody v-for="(item, index) in bomList.content">
  24. <tr v-if="!item.active">
  25. <td>
  26. <label class="com-check-box">
  27. <input type="checkbox" @change="onCheck(index)" v-model="item.checked" :id="index">
  28. <label :for="index"></label>
  29. </label>
  30. </td>
  31. <td>{{item.code}}</td>
  32. <td>{{item.brand}}</td>
  33. <td>{{item.amount || '-'}}</td>
  34. <td class="blue-text">{{(item.currency === 'RMB' ? '¥' : '$') + item.unitPrice}}</td>
  35. <td>{{item.encapsulation || '-'}}</td>
  36. <td>{{item.produceDate}}</td>
  37. <td>{{item.releaseDate | date}}</td>
  38. <td class="operate">
  39. <a class="modify-btn" @click="modifyItem(index)">修改</a>
  40. <a class="delete-btn" @click="deleteItem(index)">删除</a>
  41. </td>
  42. </tr>
  43. <tr class="modify-row" v-if="item.active">
  44. <td>
  45. <label class="com-check-box">
  46. <input type="checkbox" @change="onCheck(index)" v-model="item.checked" :id="index">
  47. <label :for="index"></label>
  48. </label>
  49. </td>
  50. <td>
  51. <input type="text" class="form-control" v-model="modifyObj.code">
  52. </td>
  53. <td>
  54. <input type="text" class="form-control" v-model="modifyObj.brand">
  55. </td>
  56. <td>
  57. <input type="text" class="form-control" v-model="modifyObj.amount">
  58. </td>
  59. <td>
  60. <select class="form-control" v-model="modifyObj.currency">
  61. <option value="RMB">¥</option>
  62. <option value="USD">$</option>
  63. </select>
  64. <input class="form-control" type="text" v-model="modifyObj.unitPrice">
  65. </td>
  66. <td>
  67. <input type="text" class="form-control" v-model="modifyObj.encapsulation">
  68. </td>
  69. <td>
  70. <input type="text" class="form-control" v-model="modifyObj.produceDate">
  71. </td>
  72. <td>
  73. <input type="text" class="form-control" v-model="modifyObj.releaseDate">
  74. </td>
  75. <td class="operate">
  76. <a class="submit-btn" @click="submitModify(index)">确认</a>
  77. <a class="cancel-btn" @click="cancelModify(index)">取消</a>
  78. </td>
  79. </tr>
  80. </tbody>
  81. </table>
  82. <page :total="bomList.totalElements" :page-size="pageSize"
  83. :current="nowPage" @childEvent="listenPage"></page>
  84. <div class="submit-area">
  85. <a class="delete-btn">删除</a>
  86. <a class="modify-btn" @click="submitBOM">确认发布</a>
  87. </div>
  88. <!--提示框-->
  89. <div class="apply-del-box" v-if="showRemindBox">
  90. <div class="title">
  91. <a @click="showRemindBox = false"><i class="fa fa-close fa-lg"></i></a>
  92. </div>
  93. <div class="content">
  94. <!--<p style="line-height: 20px;margin-top: 10px;padding:0 10px">非常抱歉,目前暂无此品牌!<br>若直接前往“品牌申请”,我们将为您先开通寄售功能,待申请通过后再提交开店申请。</p>-->
  95. <!--<p style="line-height: 20px;">前往<a @click="goBrandApply()" target="_blank" style="color: #5078CB">品牌申请&nbsp;<i class="fa fa-arrow-right"></i></a></p>-->
  96. <p><img src="/images/applyPurchase/check.png" alt="">发布成功</p>
  97. <p>其中<span>100</span>个求购型号有现货在售,您可前往“<span>买家中心-我的求购</span>”查询并直接购买</p>
  98. <div>
  99. <a @click="showRemindBox = false">我知道了</a>
  100. <a href="/user#/seekPurchase">前往我的求购</a>
  101. </div>
  102. </div>
  103. </div>
  104. </div>
  105. </template>
  106. <script>
  107. import Page from '~components/common/page/pageComponent.vue'
  108. export default {
  109. data () {
  110. return {
  111. pageSize: 10,
  112. nowPage: 1,
  113. isCheckAll: false,
  114. showRemindBox: false,
  115. modifyObj: {}
  116. }
  117. },
  118. components: {
  119. Page
  120. },
  121. computed: {
  122. bomList () {
  123. let list = this.$store.state.applyPurchase.bomMaterial.bomList.data
  124. for (let i = 0; i < list.content.length; i++) {
  125. list.content[i].checked = false
  126. list.content[i].active = false
  127. }
  128. return list
  129. },
  130. bomNumber () {
  131. return this.$store.state.applyPurchase.bomMaterial.bomNumber.data
  132. }
  133. },
  134. filters: {
  135. date: function (input) {
  136. const d = new Date(input)
  137. const year = d.getFullYear()
  138. const monthTemp = d.getMonth() + 1
  139. const month = monthTemp < 10 ? '0' + monthTemp : '' + monthTemp
  140. const day = d.getDate() < 10 ? '0' + d.getDate() : '' + d.getDate()
  141. return year + '-' + month + '-' + day
  142. }
  143. },
  144. methods: {
  145. listenPage: function (page) {
  146. this.nowPage = page
  147. this.$store.dispatch('applyPurchase/loadBOMMaterialList', {bomId: this.$route.params.id, page: this.nowPage, count: this.pageSize})
  148. },
  149. submitBOM: function () {
  150. let str = ''
  151. for (let i = 0; i < this.bomList.content.length; i++) {
  152. if (this.bomList.content[i].checked) {
  153. str += this.bomList.content[i].id + ','
  154. }
  155. }
  156. let param = {'bomId': Number(this.$route.params.id)}
  157. if (str.length) {
  158. str = str.substring(0, str.length - 1)
  159. param.spIds = str
  160. }
  161. this.$http.post('/seek/confirmBom', param)
  162. .then(response => {
  163. if (response.data.success) {
  164. this.showRemindBox = true
  165. this.listenPage(1)
  166. this.$store.dispatch('applyPurchase/loadBOMNumber', {bomId: this.$route.params.id})
  167. } else {
  168. this.$message.error('发布失败')
  169. }
  170. }, err => {
  171. console.log(err)
  172. this.$message.error('系统错误')
  173. })
  174. },
  175. onCheck: function (index) {
  176. if (typeof index === 'undefined') {
  177. let isCheckedAll = true
  178. for (let i = 0; i < this.bomList.content.length; i++) {
  179. if (!this.bomList.content[i].checked) {
  180. isCheckedAll = false
  181. break
  182. }
  183. }
  184. this.setAllCheck(!isCheckedAll)
  185. this.isCheckAll = !isCheckedAll
  186. }
  187. },
  188. setAllCheck: function (flag) {
  189. for (let i = 0; i < this.bomList.content.length; i++) {
  190. this.bomList.content[i].checked = flag
  191. }
  192. },
  193. modifyItem: function (index) {
  194. for (let i = 0; i < this.bomList.content.length; i++) {
  195. this.bomList.content[i].active = false
  196. }
  197. this.bomList.content[index].active = true
  198. this.modifyObj = this.bomList.content[index]
  199. this.modifyObj.releaseDate = this.getDate(this.bomList.content[index].releaseDate)
  200. },
  201. cancelModify: function (index) {
  202. this.bomList.content[index].active = false
  203. },
  204. getDate: function (input) {
  205. const d = new Date(input)
  206. const year = d.getFullYear()
  207. const monthTemp = d.getMonth() + 1
  208. const month = monthTemp < 10 ? '0' + monthTemp : '' + monthTemp
  209. const day = d.getDate() < 10 ? '0' + d.getDate() : '' + d.getDate()
  210. return year + '-' + month + '-' + day
  211. },
  212. submitModify: function (index) {
  213. this.$http.put('/seek/updateSeekPurchaseByBatch', this.modifyObj)
  214. .then(response => {
  215. console.log(response.data)
  216. if (response.data.success) {
  217. this.listenPage(1)
  218. this.$message.success('修改成功')
  219. this.bomList.content[index].active = false
  220. } else {
  221. this.$message.error('修改失败')
  222. }
  223. }, err => {
  224. console.log(err)
  225. this.$message.error('系统错误')
  226. })
  227. },
  228. deleteItem: function (index) {
  229. this.$http.put('/seek/deleteSeekPurchaseByBatch', this.bomList.content[index])
  230. .then(response => {
  231. if (response.data.success) {
  232. this.listenPage(1)
  233. this.$message.success('删除成功')
  234. } else {
  235. this.$message.error('删除失败')
  236. }
  237. }, err => {
  238. console.log(err)
  239. this.$message.error('系统错误')
  240. })
  241. }
  242. }
  243. }
  244. </script>
  245. <style lang="scss" scoped>
  246. .batch-publish {
  247. margin: 0 auto;
  248. width: 998px;
  249. .red-text {
  250. color: #ff0000;
  251. }
  252. .blue-text {
  253. color: #3c7cf5;
  254. }
  255. > p {
  256. margin: 59px 0 42px;
  257. font-size: 16px;
  258. }
  259. table {
  260. width: 100%;
  261. table-layout: fixed;
  262. thead {
  263. tr {
  264. th {
  265. background: #b8b8b8;
  266. color: #fff;
  267. font-weight: normal;
  268. height: 50px;
  269. line-height: 50px;
  270. text-align: center;
  271. .com-check-box {
  272. margin-right: 2px;
  273. }
  274. i {
  275. margin-right: 3px;
  276. }
  277. }
  278. }
  279. }
  280. tbody {
  281. tr {
  282. height: 85px;
  283. line-height: 85px;
  284. text-align: center;
  285. border : {
  286. bottom: 1px solid #d9d9d9;
  287. left: 1px solid #d9d9d9;
  288. right: 1px solid #d9d9d9;
  289. }
  290. &:hover {
  291. background: #f3f3f3;
  292. }
  293. td {
  294. overflow: hidden;
  295. text-overflow: ellipsis;
  296. white-space: nowrap;
  297. &.operate {
  298. a {
  299. display: block;
  300. width: 64px;
  301. height: 24px;
  302. line-height: 22px;
  303. text-align: center;
  304. border-radius: 3px;
  305. margin: 0 auto 4px;
  306. &.submit-btn {
  307. border: 1px solid #f64900;
  308. color: #fff;
  309. background: #f64900;
  310. }
  311. &.cancel-btn {
  312. border: 1px solid #dddddd;
  313. color: #fff;
  314. background: #dddddd;
  315. }
  316. }
  317. }
  318. }
  319. &.modify-row {
  320. td {
  321. position: relative;
  322. input, select {
  323. height: 20px;
  324. border-radius: 3px;
  325. background: #f4f4f4;
  326. border: 1px solid #b5b5b5;
  327. text-align: center;
  328. padding: 0 5px;
  329. }
  330. &:nth-child(2) {
  331. input {
  332. width: 113px;
  333. }
  334. }
  335. &:nth-child(3) {
  336. input {
  337. width: 93px;
  338. }
  339. }
  340. &:nth-child(4) {
  341. input {
  342. width: 71px;
  343. }
  344. }
  345. &:nth-child(5) {
  346. input {
  347. width: 65px;
  348. padding: 0 5px 0 30px;
  349. }
  350. select {
  351. width: 25px;
  352. padding: 0 0 0 2px;
  353. background: url(/images/applyPurchase/select.png) no-repeat right;
  354. background-size: 12px 19px;
  355. background-position: 13px 0px;
  356. position: absolute;
  357. top: 33px;
  358. border-bottom: none;
  359. border-top: none;
  360. border-left: 0;
  361. }
  362. }
  363. &:nth-child(6) {
  364. input {
  365. width: 54px;
  366. }
  367. }
  368. &:nth-child(7) {
  369. input {
  370. width: 72px;
  371. }
  372. }
  373. &:nth-child(8) {
  374. input {
  375. width: 101px;
  376. }
  377. }
  378. }
  379. }
  380. }
  381. }
  382. }
  383. .modify-btn {
  384. border: 1px solid #3c7cf5;
  385. color: #3c7cf5;
  386. }
  387. .delete-btn {
  388. border: 1px solid #3c7cf5;
  389. color: #fff;
  390. background: #3c7cf5;
  391. }
  392. .submit-area {
  393. margin: 51px auto 60px;
  394. text-align: center;
  395. clear: both;
  396. a {
  397. display: inline-block;
  398. width: 64px;
  399. height: 24px;
  400. line-height: 22px;
  401. text-align: center;
  402. border-radius: 3px;
  403. &.modify-btn {
  404. width: 90px;
  405. margin-left: 14px;
  406. }
  407. }
  408. }
  409. .apply-del-box{
  410. position: fixed;
  411. z-index: 1000;
  412. height: auto;
  413. opacity: 1;
  414. background-color: white;
  415. width: 310px;
  416. -webkit-box-shadow: 0 5px 15px rgba(0,0,0,.5);
  417. -moz-box-shadow: 0 5px 15px rgba(0,0,0,.5);
  418. -o-box-shadow: 0 5px 15px rgba(0,0,0,.5);
  419. box-shadow: 0 5px 15px rgba(0,0,0,.5);
  420. margin: -155px 0 0 -75px;
  421. top: 55%;
  422. left: 43%;
  423. .title{
  424. height: 24px;
  425. background-color: #007aff;
  426. text-align: right;
  427. padding-right: 15px;
  428. line-height: 24px;
  429. a{
  430. color: white;
  431. font-size: 12px;
  432. }
  433. }
  434. .content{
  435. width: 100%;
  436. text-align: center;
  437. margin: 0 auto;
  438. p{
  439. padding: 12px 31px;
  440. margin: 0;
  441. i{
  442. color: #5078cb;
  443. font-size: 16px;
  444. margin-right: 10px;
  445. }
  446. span {
  447. color: #007aff;
  448. }
  449. &:last-child {
  450. font-size: 12px;
  451. }
  452. }
  453. div{
  454. width: 100%;
  455. text-align: center;
  456. margin: 0 auto 20px;
  457. a{
  458. padding: 0 19px;
  459. height: 26px;
  460. line-height: 26px;
  461. display: inline-block;
  462. text-align: center;
  463. font-size: 14px;
  464. color: #fff;
  465. &:first-child{
  466. background: #c8c6c6;
  467. margin-right: 10px;
  468. }
  469. &:last-child{
  470. background: #007aff;
  471. }
  472. }
  473. }
  474. }
  475. }
  476. }
  477. </style>