BatchPublish.vue 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918
  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="190"><i class="red-text">*</i>型号</th>
  14. <th width="162"><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>
  32. <div v-if="item.code && (!item.codeWord || item.codeWord.length == 0)">{{item.code}}</div>
  33. <span class="red-text" v-if="!item.code">请完善信息</span>
  34. <div class="similar-select" v-if="item.codeWord && item.codeWord.length > 0" @click="setShowCodeWord(index, $event)">{{item.code}}</div>
  35. <ul v-show="item.showCodeWord">
  36. <li v-for="code in item.codeWord" @click="modifyItemByWord(index, code.code, 'code')">{{code.code}}</li>
  37. </ul>
  38. </td>
  39. <td>
  40. <div v-if="item.brand && (!item.brandWord || item.brandWord.length == 0)">{{item.brand}}</div>
  41. <span class="red-text" v-if="!item.brand">请完善信息</span>
  42. <div class="similar-select" v-if="item.brandWord && item.brandWord.length > 0" @click="setShowBrandWord(index, $event)">{{item.brand}}</div>
  43. <ul v-show="item.showBrandWord" class="brand-word-list">
  44. <li v-for="brand in item.brandWord" @click="modifyItemByWord(index, brand.nameEn, 'brand')">{{brand.nameEn}}</li>
  45. </ul>
  46. </td>
  47. <td>
  48. <div>{{item.amount || '-'}}</div>
  49. </td>
  50. <td class="blue-text">
  51. <div>
  52. <span v-if="item.unitPrice">{{(item.currency === 'RMB' ? '¥' : '$') + item.unitPrice}}</span>
  53. <span v-if="!item.unitPrice">-</span>
  54. </div>
  55. </td>
  56. <td>
  57. <div>
  58. {{item.encapsulation || '-'}}
  59. </div>
  60. </td>
  61. <td>
  62. <div>
  63. {{item.produceDate || '-'}}
  64. </div>
  65. </td>
  66. <td>
  67. <span v-if="item.deadline">{{item.deadline | date}}</span>
  68. <span class="red-text" v-if="!item.deadline">请完善信息</span>
  69. <div class="red-text" v-if="!isValidTime(item.deadline)">默认≤90天</div>
  70. </td>
  71. <td class="operate">
  72. <a class="delete-btn" @click="modifyItem(index)">编辑</a>
  73. <a class="modify-btn" @click="deleteItem(index)">删除</a>
  74. </td>
  75. </tr>
  76. <tr class="modify-row" v-if="item.active">
  77. <!-- <td>
  78. <label class="com-check-box">
  79. <input type="checkbox" @change="onCheck(index)" v-model="item.checked" :id="index">
  80. <label :for="index"></label>
  81. </label>
  82. </td>-->
  83. <td>
  84. <input type="text" class="form-control" v-model="modifyObj.code" :class="{'error': !validObj.code}" maxlength="30" @blur="checkCode" @input="onCodeChange" >
  85. <ul v-show="showSimilarCodeList">
  86. <li v-for="sCode in similarCode" @click="setCode(sCode.code)">{{sCode.code}}</li>
  87. </ul>
  88. </td>
  89. <td>
  90. <input type="text" class="form-control" v-model="modifyObj.brand" :class="{'error': !validObj.brand}" maxlength="20" @blur="checkBrand" @input="onBrandChange">
  91. <ul class="brand-similar-list" v-show="showSimilarBrandList">
  92. <li v-for="sBrand in similarBrand" @click="setBrand(sBrand.nameEn)">{{sBrand.nameEn}}</li>
  93. </ul>
  94. </td>
  95. <td>
  96. <input type="text" class="form-control" v-model="modifyObj.amount" :class="{'error': !validObj.amount}" @blur="checkAmount" @input="onAmountInput">
  97. </td>
  98. <td>
  99. <select class="form-control" v-model="modifyObj.currency">
  100. <option value="RMB">¥</option>
  101. <option value="USD">$</option>
  102. </select>
  103. <input class="form-control" type="number" v-model="modifyObj.unitPrice" :class="{'error': !validObj.unitPrice}" @blur="checkUnitPrice" @input="onUnitPriceInput">
  104. </td>
  105. <td>
  106. <input type="text" class="form-control" v-model="modifyObj.encapsulation" @input="onEncapsulationChange">
  107. </td>
  108. <td>
  109. <input type="text" class="form-control" v-model="modifyObj.produceDate" @input="onProduceDateChange">
  110. </td>
  111. <td>
  112. <el-date-picker
  113. v-model="modifyObj.deadline"
  114. type="date"
  115. :picker-options="pickerOptions"
  116. :editable="false"
  117. :class="{'error': !validObj.deadline}"
  118. size="mini">
  119. </el-date-picker>
  120. <!--<input type="text" class="form-control" v-model="modifyObj.deadline">-->
  121. </td>
  122. <td class="operate">
  123. <a class="submit-btn" @click="submitModify(index)">确认</a>
  124. <a class="cancel-btn" @click="cancelModify(index)">取消</a>
  125. </td>
  126. </tr>
  127. </tbody>
  128. </table>
  129. <page :total="bomList.totalElements" :page-size="pageSize"
  130. :current="nowPage" @childEvent="listenPage"></page>
  131. <div class="submit-area" v-if="bomList.content.length">
  132. <!-- <a class="modify-btn" @click="deleteItem()">删除</a>-->
  133. <a class="modify-btn delete-btn" @click="submitBOM">确认发布</a>
  134. </div>
  135. <!--提示框-->
  136. <div class="apply-del-box" v-if="showRemindBox">
  137. <div class="title">
  138. <a @click="showRemindBox = false"><i class="fa fa-close fa-lg"></i></a>
  139. </div>
  140. <div class="content">
  141. <!--<p style="line-height: 20px;margin-top: 10px;padding:0 10px">非常抱歉,目前暂无此品牌!<br>若直接前往“品牌申请”,我们将为您先开通寄售功能,待申请通过后再提交开店申请。</p>-->
  142. <!--<p style="line-height: 20px;">前往<a @click="goBrandApply()" target="_blank" style="color: #5078CB">品牌申请&nbsp;<i class="fa fa-arrow-right"></i></a></p>-->
  143. <p><img src="/images/applyPurchase/check.png" alt="">成功发布{{successResult.successAmount || 0}}个</p>
  144. <p>其中<span>{{successResult.goodsAmount || 0}}</span>个求购型号有现货在售,您可前往“<span>买家中心-我的求购</span>”查询并直接购买</p>
  145. <div>
  146. <a @click="showRemindBox = false">继续发布</a>
  147. <a href="/user#/seekPurchase">前往我的求购</a>
  148. </div>
  149. </div>
  150. </div>
  151. </div>
  152. </template>
  153. <script>
  154. let getRealLen = function (str) {
  155. let len = 0
  156. for (let i = 0; i < str.length; i++) {
  157. if (str.charCodeAt(i) > 127 || str.charCodeAt(i) === 94) {
  158. len += 2
  159. } else {
  160. len++
  161. }
  162. }
  163. return len
  164. }
  165. let cutOutString = function (str, length) {
  166. for (let i = 1; i <= str.length; i++) {
  167. if (getRealLen(str.substr(0, i)) > length) {
  168. str = str.substr(0, i - 1)
  169. break
  170. }
  171. }
  172. return str
  173. }
  174. import Page from '~components/common/page/pageComponent.vue'
  175. export default {
  176. data () {
  177. return {
  178. pageSize: 10,
  179. nowPage: 1,
  180. isCheckAll: false,
  181. showRemindBox: false,
  182. modifyObj: {
  183. code: '',
  184. brand: '',
  185. unitPrice: '',
  186. currency: 'RMB',
  187. encapsulation: '',
  188. produceDate: '',
  189. amount: '',
  190. deadline: ''
  191. },
  192. pickerOptions: {
  193. disabledDate (time) {
  194. // 大于等于今天 小于三个月后
  195. return time.getTime() < Date.now() - 1000 * 60 * 60 * 24 || time.getTime() > Date.now() + 1000 * 60 * 60 * 24 * 30 * 3
  196. }
  197. },
  198. similarCode: [],
  199. similarBrand: [],
  200. validObj: {
  201. code: true,
  202. brand: true,
  203. unitPrice: true,
  204. // encapsulation: true,
  205. // produceDate: true,
  206. amount: true,
  207. deadline: true
  208. },
  209. successResult: 0,
  210. showSimilarCodeList: false,
  211. showSimilarBrandList: false
  212. }
  213. },
  214. components: {
  215. Page
  216. },
  217. computed: {
  218. bomList () {
  219. let _this = this
  220. let list = this.$store.state.applyPurchase.bomMaterial.bomList.data
  221. for (let i = 0; i < list.content.length; i++) {
  222. _this.$set(list.content[i], 'checked', false)
  223. _this.$set(list.content[i], 'active', false)
  224. _this.$set(list.content[i], 'showCodeWord', false)
  225. _this.$set(list.content[i], 'showBrandWord', false)
  226. // list.content[i].checked = false
  227. // list.content[i].active = false
  228. // if (!list.content[i].code || list.content[i].brand || !list.content[i].deadline || !this.isValidDate(list.content[i].deadline)) {
  229. // _this.validList = false
  230. // }
  231. }
  232. return list
  233. },
  234. bomNumber () {
  235. return this.$store.state.applyPurchase.bomMaterial.bomNumber.data
  236. }
  237. },
  238. mounted () {
  239. let _this = this
  240. document.body.onclick = function () {
  241. _this.showSimilarCodeList = false
  242. _this.showSimilarBrandList = false
  243. for (let i = 0; i < _this.bomList.content.length; i++) {
  244. _this.bomList.content[i].showCodeWord = false
  245. _this.bomList.content[i].showBrandWord = false
  246. }
  247. }
  248. },
  249. filters: {
  250. date: function (input) {
  251. if (input) {
  252. const d = new Date(input)
  253. const year = d.getFullYear()
  254. const monthTemp = d.getMonth() + 1
  255. const month = monthTemp < 10 ? '0' + monthTemp : '' + monthTemp
  256. const day = d.getDate() < 10 ? '0' + d.getDate() : '' + d.getDate()
  257. return year + '-' + month + '-' + day
  258. } else {
  259. return null
  260. }
  261. }
  262. },
  263. methods: {
  264. initModifyObj: function () {
  265. this.modifyObj = {
  266. code: '',
  267. brand: '',
  268. unitPrice: '',
  269. currency: 'RMB',
  270. encapsulation: '',
  271. produceDate: '',
  272. amount: '',
  273. deadline: ''
  274. }
  275. },
  276. initValidObj: function () {
  277. this.validObj = {
  278. code: true,
  279. brand: true,
  280. unitPrice: true,
  281. amount: true,
  282. deadline: true
  283. }
  284. },
  285. listenPage: function (page) {
  286. this.nowPage = page
  287. this.reloadData()
  288. },
  289. reloadData: function () {
  290. this.$store.dispatch('applyPurchase/loadBOMMaterialList', {bomId: this.$route.params.id, page: this.nowPage, count: this.pageSize})
  291. },
  292. submitBOM: function () {
  293. let str = ''
  294. // let _this = this
  295. for (let i = 0; i < this.bomList.content.length; i++) {
  296. if (this.bomList.content[i].checked) {
  297. if (!this.getSingleValidInfo(this.bomList.content[i])) {
  298. this.$message.error('请选择信息完善的产品发布求购')
  299. return
  300. }
  301. str += this.bomList.content[i].id + ','
  302. }
  303. }
  304. let param = {'bomId': Number(this.$route.params.id)}
  305. if (str.length) {
  306. str = str.substring(0, str.length - 1)
  307. param.spIds = str
  308. }
  309. this.$http.post('/seek/confirmBom', param)
  310. .then(response => {
  311. if (response.data.success) {
  312. this.showRemindBox = true
  313. this.successResult = response.data.data
  314. this.listenPage(1)
  315. this.$store.dispatch('applyPurchase/loadBOMNumber', {bomId: this.$route.params.id})
  316. } else {
  317. this.$message.error('发布失败')
  318. }
  319. }, err => {
  320. console.log(err)
  321. this.$message.error('系统错误')
  322. })
  323. },
  324. onCheck: function (index) {
  325. if (typeof index === 'undefined') {
  326. let isCheckedAll = true
  327. for (let i = 0; i < this.bomList.content.length; i++) {
  328. if (!this.bomList.content[i].checked) {
  329. isCheckedAll = false
  330. break
  331. }
  332. }
  333. this.setAllCheck(!isCheckedAll)
  334. this.isCheckAll = !isCheckedAll
  335. }
  336. },
  337. setAllCheck: function (flag) {
  338. for (let i = 0; i < this.bomList.content.length; i++) {
  339. this.bomList.content[i].checked = flag
  340. }
  341. },
  342. modifyItem: function (index) {
  343. for (let i = 0; i < this.bomList.content.length; i++) {
  344. this.bomList.content[i].active = false
  345. }
  346. // this.$set(this.bomList.content[index], 'active', true)
  347. this.bomList.content[index].active = true
  348. let _this = this
  349. this.initModifyObj()
  350. this.initValidObj()
  351. for (let attr in this.bomList.content[index]) {
  352. // console.log(attr + ':' + _this.bomList.content[index][attr])
  353. _this.$set(_this.modifyObj, attr, _this.bomList.content[index][attr])
  354. // _this.modifyObj[attr] = _this.bomList.content[index][attr]
  355. }
  356. // this.modifyObj = this.bomList.content[index]
  357. this.modifyObj.deadline = this.bomList.content[index].deadline ? this.getDate(this.bomList.content[index].deadline) : ''
  358. },
  359. cancelModify: function (index) {
  360. this.bomList.content[index].active = false
  361. },
  362. getDate: function (input) {
  363. const d = new Date(input)
  364. const year = d.getFullYear()
  365. const monthTemp = d.getMonth() + 1
  366. const month = monthTemp < 10 ? '0' + monthTemp : '' + monthTemp
  367. const day = d.getDate() < 10 ? '0' + d.getDate() : '' + d.getDate()
  368. return year + '-' + month + '-' + day
  369. },
  370. // validDate: function (timestamp) {
  371. // let now = new Date().getTime()
  372. // return timestamp - now <= 1000 * 60 * 60 * 24 * 90 && timestamp - now > 0
  373. // },
  374. submitModify: function (index) {
  375. let checkValid = this.checkAll()
  376. if (this.getSingleValidInfo(this.modifyObj) && checkValid) {
  377. this.$http.put('/seek/updateSeekPurchaseByBatch', this.modifyObj)
  378. .then(response => {
  379. if (response.data.success) {
  380. this.reloadData()
  381. this.$message.success('修改成功')
  382. // this.bomList.content[index].active = false
  383. } else {
  384. this.$message.error('修改失败')
  385. }
  386. }, err => {
  387. console.log(err)
  388. this.$message.error('系统错误')
  389. })
  390. } else {
  391. if (!checkValid) {
  392. if (!this.validObj.code) {
  393. this.$message.error('型号不能为空')
  394. } else if (!this.validObj.brand) {
  395. this.$message.error('品牌不能为空')
  396. } else if (!this.validObj.deadline) {
  397. if (!this.isValidDate(this.modifyObj.deadline)) {
  398. this.$message.error('截止日期需在90天以内')
  399. } else {
  400. this.$message.error('截止日期不能为空')
  401. }
  402. } else if (!this.validObj.amount || !this.validObj.unitPrice) {
  403. this.$message.error('请输入正确的数值')
  404. }
  405. } else {
  406. this.$message.error('请完善信息')
  407. }
  408. }
  409. },
  410. deleteItem: function (index) {
  411. if (!index) {
  412. let str = ''
  413. for (let i = 0; i < this.bomList.content.length; i++) {
  414. if (this.bomList.content[i].checked) {
  415. str += this.bomList.content[i].id + ','
  416. }
  417. }
  418. let param = {}
  419. if (str.length) {
  420. str = str.substring(0, str.length - 1)
  421. param.spIds = str
  422. this.doDelete(param)
  423. } else {
  424. this.$message.error('请勾选')
  425. return
  426. }
  427. } else {
  428. this.doDelete({spIds: this.bomList.content[index].id})
  429. }
  430. },
  431. doDelete: function (param) {
  432. this.$http.put('/seek/deleteSeekPurchaseByBatch', param)
  433. .then(response => {
  434. if (response.data.success) {
  435. this.listenPage(1)
  436. this.$message.success('删除成功')
  437. } else {
  438. this.$message.error('删除失败')
  439. }
  440. }, err => {
  441. console.log(err)
  442. this.$message.error('系统错误')
  443. })
  444. },
  445. isValidTime: function (time) {
  446. let now = new Date().getTime()
  447. return !time || (time >= now && time <= now + 1000 * 60 * 60 * 24 * 90)
  448. },
  449. isValidDate: function (date) {
  450. let now = new Date().getTime()
  451. let time = new Date(date).getTime()
  452. return !time || (time >= now && time <= now + 1000 * 60 * 60 * 24 * 90)
  453. },
  454. getSimilarCode: function () {
  455. this.$http.get('/search/similarComponents', {params: {keyword: this.modifyObj.code}})
  456. .then(response => {
  457. this.similarCode = response.data
  458. if (response.data.length) {
  459. this.showSimilarCodeList = true
  460. }
  461. })
  462. },
  463. getSimilarBrand: function () {
  464. this.$http.get('/search/similarBrands', {params: {keyword: this.modifyObj.brand}})
  465. .then(response => {
  466. this.similarBrand = response.data
  467. if (response.data.length) {
  468. this.showSimilarBrandList = true
  469. }
  470. })
  471. },
  472. getSingleValidInfo: function (item) {
  473. return item.code && item.brand && item.deadline && this.isValidDate(item.deadline)
  474. },
  475. checkCode: function () {
  476. this.validObj.code = this.modifyObj.code && this.modifyObj.code !== ''
  477. return this.validObj.code
  478. },
  479. checkBrand: function () {
  480. this.validObj.brand = this.modifyObj.brand && this.modifyObj.brand !== ''
  481. return this.validObj.brand
  482. },
  483. checkUnitPrice: function () {
  484. this.validObj.unitPrice = (!this.modifyObj.unitPrice || this.modifyObj.unitPrice === '') ? true : this.modifyObj.unitPrice > 0 && this.modifyObj.unitPrice < 100000000
  485. return this.validObj.unitPrice
  486. },
  487. checkAmount: function () {
  488. this.validObj.amount = (!this.modifyObj.amount || this.modifyObj.amount === '') ? true : this.modifyObj.amount > 0 && this.modifyObj.amount < 100000000
  489. return this.validObj.amount
  490. },
  491. checkAll: function () {
  492. return this.checkCode() && this.checkBrand() && this.checkDeadline() && this.checkUnitPrice() && this.checkAmount()
  493. },
  494. checkDeadline: function () {
  495. this.validObj.deadline = this.modifyObj.deadline && this.modifyObj.deadline !== '' && this.isValidDate(this.modifyObj.deadline)
  496. return this.validObj.deadline
  497. },
  498. onUnitPriceInput: function () {
  499. let price = this.modifyObj.unitPrice
  500. if (price >= 10000) {
  501. this.modifyObj.unitPrice = price.substring(0, 4)
  502. } else if (price.indexOf('.') > -1) {
  503. let arr = price.split('.')
  504. if (arr[0].length > 4) {
  505. this.modifyObj.unitPrice = Number(arr[0].substring(0, 4) + '.' + arr[1])
  506. } else if (arr[1].length > 6) {
  507. this.modifyObj.unitPrice = Number(arr[0] + '.' + arr[1].substring(0, 6))
  508. }
  509. }
  510. },
  511. onProduceDateChange: function () {
  512. if (this.modifyObj.produceDate && getRealLen(this.modifyObj.produceDate) > 12) {
  513. this.modifyObj.produceDate = cutOutString(this.modifyObj.produceDate, 12)
  514. }
  515. },
  516. onEncapsulationChange: function () {
  517. if (this.modifyObj.encapsulation && getRealLen(this.modifyObj.encapsulation) > 20) {
  518. this.modifyObj.encapsulation = cutOutString(this.modifyObj.encapsulation, 20)
  519. }
  520. },
  521. onCodeChange: function () {
  522. this.modifyObj.code = this.modifyObj.code.trim()
  523. if ((/[^\x00-\xff]/g).test(this.modifyObj.code)) {
  524. let chineseIndex = -1
  525. for (let i = 0; i < this.modifyObj.code.length; i++) {
  526. if ((/[^\x00-\xff]/g).test(this.modifyObj.code.charAt(i))) {
  527. chineseIndex = i
  528. break
  529. }
  530. }
  531. this.modifyObj.code = cutOutString(this.modifyObj.code, chineseIndex)
  532. } else if (this.modifyObj.code && getRealLen(this.modifyObj.code) > 100) {
  533. this.modifyObj.code = cutOutString(this.modifyObj.code, 100)
  534. } else {
  535. this.getSimilarCode()
  536. }
  537. },
  538. onBrandChange: function () {
  539. this.modifyObj.brand = this.modifyObj.brand.trim()
  540. if ((/[^\x00-\xff]/g).test(this.modifyObj.brand)) {
  541. let chineseIndex = -1
  542. for (let i = 0; i < this.modifyObj.brand.length; i++) {
  543. if ((/[^\x00-\xff]/g).test(this.modifyObj.brand.charAt(i))) {
  544. chineseIndex = i
  545. break
  546. }
  547. }
  548. this.modifyObj.brand = cutOutString(this.modifyObj.brand, chineseIndex)
  549. } else if (this.modifyObj.brand && getRealLen(this.modifyObj.brand) > 50) {
  550. this.modifyObj.brand = cutOutString(this.modifyObj.brand, 50)
  551. } else {
  552. this.getSimilarBrand()
  553. }
  554. },
  555. onAmountInput: function () {
  556. if (!(/^[0-9]*$/).test(this.modifyObj.amount)) {
  557. let chineseIndex = -1
  558. for (let i = 0; i < this.modifyObj.amount.length; i++) {
  559. if (!(/^[0-9]*$/).test(this.modifyObj.amount.charAt(i))) {
  560. chineseIndex = i
  561. break
  562. }
  563. }
  564. this.modifyObj.amount = cutOutString(this.modifyObj.amount, chineseIndex)
  565. } else if (this.modifyObj.amount.length > 8) {
  566. this.modifyObj.amount = cutOutString(this.modifyObj.amount, 8)
  567. }
  568. },
  569. setCode: function (code) {
  570. this.modifyObj.code = code
  571. this.showSimilarCodeList = false
  572. },
  573. setBrand: function (brand) {
  574. this.modifyObj.brand = brand
  575. this.showSimilarBrandList = false
  576. },
  577. setShowCodeWord: function (index, event) {
  578. event.stopPropagation()
  579. this.bomList.content[index].showCodeWord = !this.bomList.content[index].showCodeWord
  580. },
  581. setShowBrandWord: function (index, event) {
  582. event.stopPropagation()
  583. this.bomList.content[index].showBrandWord = !this.bomList.content[index].showBrandWord
  584. },
  585. modifyItemByWord: function (index, param, type) {
  586. if (type === 'code') {
  587. this.bomList.content[index].code = param
  588. } else if (type === 'code') {
  589. this.bomList.content[index].brand = param
  590. }
  591. this.requestModify(this.bomList.content[index])
  592. },
  593. requestModify: function (item) {
  594. this.$http.put('/seek/updateSeekPurchaseByBatch', item)
  595. .then(response => {
  596. if (response.data.success) {
  597. this.$message.success('修改成功')
  598. } else {
  599. this.$message.error('修改失败')
  600. }
  601. this.reloadData()
  602. }, err => {
  603. console.log(err)
  604. this.$message.error('系统错误')
  605. this.reloadData()
  606. })
  607. }
  608. }
  609. }
  610. </script>
  611. <style lang="scss">
  612. .batch-publish {
  613. margin: 0 auto;
  614. width: 998px;
  615. .red-text {
  616. color: #ff0000;
  617. }
  618. .blue-text {
  619. color: #3c7cf5;
  620. }
  621. > p {
  622. margin: 59px 0 42px;
  623. font-size: 16px;
  624. }
  625. table {
  626. width: 100%;
  627. table-layout: fixed;
  628. thead {
  629. tr {
  630. th {
  631. background: #b8b8b8;
  632. color: #fff;
  633. font-weight: normal;
  634. height: 50px;
  635. line-height: 50px;
  636. text-align: center;
  637. .com-check-box {
  638. margin-right: 2px;
  639. }
  640. i {
  641. margin-right: 3px;
  642. }
  643. }
  644. }
  645. }
  646. tbody {
  647. tr {
  648. height: 85px;
  649. line-height: 85px;
  650. text-align: center;
  651. border : {
  652. bottom: 1px solid #d9d9d9;
  653. left: 1px solid #d9d9d9;
  654. right: 1px solid #d9d9d9;
  655. }
  656. &:hover {
  657. background: #f3f3f3;
  658. }
  659. td {
  660. position: relative;
  661. font-size: 12px;
  662. > ul {
  663. line-height: normal;
  664. position: absolute;
  665. top: 52px;
  666. left: 24px;
  667. background: #fff;
  668. border: 1px solid #b5b5b5;
  669. z-index: 1;
  670. max-height: 120px;
  671. overflow-y: auto;
  672. overflow-x: hidden;
  673. border-radius: 3px;
  674. width: 114px;
  675. li {
  676. height: 24px;
  677. line-height: 24px;
  678. cursor: pointer;
  679. overflow: hidden;
  680. text-overflow: ellipsis;
  681. white-space: nowrap;
  682. padding: 0 5px;
  683. &:hover {
  684. background: #ddd;
  685. }
  686. }
  687. &.brand-similar-list {
  688. left: 20px;
  689. width: 94px;
  690. }
  691. }
  692. > div {
  693. overflow: hidden;
  694. overflow-y: unset;
  695. text-overflow: ellipsis;
  696. white-space: nowrap;
  697. &.similar-select {
  698. width: 109px;
  699. margin: 0 auto;
  700. border: 1px solid #b5b5b5;
  701. height: 18px;
  702. line-height: 18px;
  703. overflow-y: hidden;
  704. padding: 0 22px 0 5px;
  705. background: url('/images/applyPurchase/select.png') no-repeat;
  706. background-position: 91px 0;
  707. cursor: default;
  708. border-radius: 3px;
  709. & + ul {
  710. width: 110px;
  711. top: 52px;
  712. left: 40px;
  713. &.brand-word-list {
  714. left: 27px;
  715. }
  716. }
  717. }
  718. }
  719. div.red-text {
  720. line-height: normal;
  721. position: absolute;
  722. left: 42px;
  723. top: 49px;
  724. }
  725. &.operate {
  726. a {
  727. display: block;
  728. width: 64px;
  729. height: 24px;
  730. line-height: 22px;
  731. text-align: center;
  732. border-radius: 3px;
  733. margin: 0 auto 4px;
  734. font-size: 14px;
  735. &.submit-btn {
  736. border: 1px solid #f64900;
  737. color: #fff;
  738. background: #f64900;
  739. }
  740. &.cancel-btn {
  741. border: 1px solid #bbb;
  742. color: #fff;
  743. background: #bbb;
  744. }
  745. }
  746. }
  747. }
  748. &.modify-row {
  749. td {
  750. position: relative;
  751. input, select {
  752. height: 20px;
  753. border-radius: 3px;
  754. background: #f4f4f4;
  755. border: 1px solid #b5b5b5;
  756. text-align: center;
  757. padding: 0 5px;
  758. &.error {
  759. border-color: #f4645f !important;
  760. }
  761. }
  762. &:nth-child(1) {
  763. input {
  764. width: 113px;
  765. }
  766. }
  767. &:nth-child(2) {
  768. input {
  769. width: 93px;
  770. }
  771. }
  772. &:nth-child(3) {
  773. input {
  774. width: 71px;
  775. }
  776. }
  777. &:nth-child(4) {
  778. input {
  779. width: 65px;
  780. padding: 0 5px 0 30px;
  781. }
  782. select {
  783. width: 25px;
  784. padding: 0 0 0 2px;
  785. background: url(/images/applyPurchase/select.png) no-repeat right;
  786. background-size: 12px 19px;
  787. background-position: 13px 0;
  788. position: absolute;
  789. top: 33px;
  790. border-bottom: none;
  791. border-top: none;
  792. border-left: 0;
  793. }
  794. }
  795. &:nth-child(5) {
  796. input {
  797. width: 54px;
  798. }
  799. }
  800. &:nth-child(6) {
  801. input {
  802. width: 72px;
  803. }
  804. }
  805. &:nth-child(7) {
  806. div {
  807. width: 101px;
  808. overflow: unset;
  809. input {
  810. width: 101px;
  811. }
  812. }
  813. }
  814. }
  815. }
  816. }
  817. }
  818. }
  819. .modify-btn {
  820. border: 1px solid #3c7cf5;
  821. color: #3c7cf5;
  822. background: #fff;
  823. }
  824. .delete-btn {
  825. border: 1px solid #3c7cf5;
  826. color: #fff;
  827. background: #3c7cf5;
  828. }
  829. .submit-area {
  830. margin: 51px auto 60px;
  831. text-align: center;
  832. clear: both;
  833. a {
  834. display: inline-block;
  835. width: 64px;
  836. height: 24px;
  837. line-height: 22px;
  838. text-align: center;
  839. border-radius: 3px;
  840. &.modify-btn {
  841. width: 90px;
  842. margin-left: 14px;
  843. }
  844. }
  845. }
  846. .apply-del-box{
  847. position: fixed;
  848. z-index: 1000;
  849. height: auto;
  850. opacity: 1;
  851. background-color: white;
  852. width: 310px;
  853. -webkit-box-shadow: 0 5px 15px rgba(0,0,0,.5);
  854. -moz-box-shadow: 0 5px 15px rgba(0,0,0,.5);
  855. -o-box-shadow: 0 5px 15px rgba(0,0,0,.5);
  856. box-shadow: 0 5px 15px rgba(0,0,0,.5);
  857. margin: -155px 0 0 -75px;
  858. top: 55%;
  859. left: 43%;
  860. .title{
  861. height: 24px;
  862. background-color: #007aff;
  863. text-align: right;
  864. padding-right: 15px;
  865. line-height: 24px;
  866. a{
  867. color: white;
  868. font-size: 12px;
  869. }
  870. }
  871. .content{
  872. width: 100%;
  873. text-align: center;
  874. margin: 0 auto;
  875. p{
  876. padding: 12px 31px;
  877. margin: 0;
  878. &:nth-child(2) {
  879. font-size: 12px;
  880. padding-top: 0;
  881. }
  882. i{
  883. color: #5078cb;
  884. font-size: 16px;
  885. margin-right: 10px;
  886. }
  887. span {
  888. color: #007aff;
  889. }
  890. &:last-child {
  891. font-size: 12px;
  892. }
  893. }
  894. div{
  895. width: 100%;
  896. text-align: center;
  897. margin: 0 auto 20px;
  898. a{
  899. padding: 0 19px;
  900. height: 26px;
  901. line-height: 26px;
  902. display: inline-block;
  903. text-align: center;
  904. font-size: 14px;
  905. color: #fff;
  906. &:first-child{
  907. background: #c8c6c6;
  908. margin-right: 10px;
  909. }
  910. &:last-child{
  911. background: #007aff;
  912. }
  913. }
  914. }
  915. }
  916. }
  917. }
  918. </style>