BatchPublish.vue 16 KB

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