BatchPublish.vue 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921
  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)" :title="item.code">{{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')" :title="code.code">{{code.code}}</li>
  37. </ul>
  38. </td>
  39. <td>
  40. <div v-if="item.brand && (!item.brandWord || item.brandWord.length == 0)" :title="item.brand">{{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')" :title="brand.nameEn">{{brand.nameEn}}</li>
  45. </ul>
  46. </td>
  47. <td>
  48. <div :title="item.amount">{{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 :title="item.encapsulation">
  58. {{item.encapsulation || '-'}}
  59. </div>
  60. </td>
  61. <td>
  62. <div :title="item.produceDate">
  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}" @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}" @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 v-if="successResult.goodsAmount && successResult.goodsAmount > 0">其中<span class="count">{{successResult.goodsAmount || 0}}</span>个求购型号有现货在售,</span>您可前往“<span class="count">买家中心-我的求购</span>”查询并直接购买</p>
  145. <div>
  146. <a @click="showRemindBox = false">继续发布</a>
  147. <a href="/user#/seekPurchase" target="_blank">前往我的求购</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(response.data.message)
  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 && index !== 0) {
  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. this.requestModify(this.bomList.content[index])
  589. } else if (type === 'brand') {
  590. this.bomList.content[index].brand = param
  591. this.requestModify(this.bomList.content[index])
  592. } else {
  593. this.$message.error('修改失败')
  594. }
  595. },
  596. requestModify: function (item) {
  597. this.$http.put('/seek/updateSeekPurchaseByBatch', item)
  598. .then(response => {
  599. if (response.data.success) {
  600. this.$message.success('修改成功')
  601. } else {
  602. this.$message.error('修改失败')
  603. }
  604. this.reloadData()
  605. }, err => {
  606. console.log(err)
  607. this.$message.error('系统错误')
  608. this.reloadData()
  609. })
  610. }
  611. }
  612. }
  613. </script>
  614. <style lang="scss">
  615. .batch-publish {
  616. margin: 0 auto;
  617. width: 998px;
  618. .red-text {
  619. color: #ff0000;
  620. }
  621. .blue-text {
  622. color: #3c7cf5;
  623. }
  624. > p {
  625. margin: 59px 0 42px;
  626. font-size: 16px;
  627. }
  628. table {
  629. width: 100%;
  630. table-layout: fixed;
  631. thead {
  632. tr {
  633. th {
  634. background: #b8b8b8;
  635. color: #fff;
  636. font-weight: normal;
  637. height: 50px;
  638. line-height: 50px;
  639. text-align: center;
  640. .com-check-box {
  641. margin-right: 2px;
  642. }
  643. i {
  644. margin-right: 3px;
  645. }
  646. }
  647. }
  648. }
  649. tbody {
  650. tr {
  651. height: 85px;
  652. line-height: 85px;
  653. text-align: center;
  654. border : {
  655. bottom: 1px solid #d9d9d9;
  656. left: 1px solid #d9d9d9;
  657. right: 1px solid #d9d9d9;
  658. }
  659. &:hover {
  660. background: #f3f3f3;
  661. }
  662. td {
  663. position: relative;
  664. font-size: 12px;
  665. > ul {
  666. line-height: normal;
  667. position: absolute;
  668. top: 52px;
  669. left: 24px;
  670. background: #fff;
  671. border: 1px solid #b5b5b5;
  672. z-index: 1;
  673. max-height: 120px;
  674. overflow-y: auto;
  675. overflow-x: hidden;
  676. border-radius: 3px;
  677. width: 114px;
  678. li {
  679. height: 24px;
  680. line-height: 24px;
  681. cursor: pointer;
  682. overflow: hidden;
  683. text-overflow: ellipsis;
  684. white-space: nowrap;
  685. padding: 0 5px;
  686. &:hover {
  687. background: #ddd;
  688. }
  689. }
  690. &.brand-similar-list {
  691. left: 20px;
  692. width: 94px;
  693. }
  694. }
  695. > div {
  696. overflow: hidden;
  697. overflow-y: unset;
  698. text-overflow: ellipsis;
  699. white-space: nowrap;
  700. &.similar-select {
  701. width: 109px;
  702. margin: 0 auto;
  703. border: 1px solid #b5b5b5;
  704. height: 18px;
  705. line-height: 18px;
  706. overflow-y: hidden;
  707. padding: 0 22px 0 5px;
  708. background: url('/images/applyPurchase/select.png') no-repeat;
  709. background-position: 91px 0;
  710. cursor: default;
  711. border-radius: 3px;
  712. & + ul {
  713. width: 110px;
  714. top: 52px;
  715. left: 40px;
  716. &.brand-word-list {
  717. left: 27px;
  718. }
  719. }
  720. }
  721. }
  722. div.red-text {
  723. line-height: normal;
  724. position: absolute;
  725. left: 42px;
  726. top: 49px;
  727. }
  728. &.operate {
  729. a {
  730. display: block;
  731. width: 64px;
  732. height: 24px;
  733. line-height: 22px;
  734. text-align: center;
  735. border-radius: 3px;
  736. margin: 0 auto 4px;
  737. font-size: 14px;
  738. &.submit-btn {
  739. border: 1px solid #f64900;
  740. color: #fff;
  741. background: #f64900;
  742. }
  743. &.cancel-btn {
  744. border: 1px solid #bbb;
  745. color: #fff;
  746. background: #bbb;
  747. }
  748. }
  749. }
  750. }
  751. &.modify-row {
  752. td {
  753. position: relative;
  754. input, select {
  755. height: 20px;
  756. border-radius: 3px;
  757. background: #f4f4f4;
  758. border: 1px solid #b5b5b5;
  759. text-align: center;
  760. padding: 0 5px;
  761. &.error {
  762. border-color: #f4645f !important;
  763. }
  764. }
  765. &:nth-child(1) {
  766. input {
  767. width: 113px;
  768. }
  769. }
  770. &:nth-child(2) {
  771. input {
  772. width: 93px;
  773. }
  774. }
  775. &:nth-child(3) {
  776. input {
  777. width: 71px;
  778. }
  779. }
  780. &:nth-child(4) {
  781. input {
  782. width: 65px;
  783. padding: 0 5px 0 30px;
  784. }
  785. select {
  786. width: 25px;
  787. padding: 0 0 0 2px;
  788. background: url(/images/applyPurchase/select.png) no-repeat right;
  789. background-size: 12px 19px;
  790. background-position: 13px 0;
  791. position: absolute;
  792. top: 33px;
  793. border-bottom: none;
  794. border-top: none;
  795. border-left: 0;
  796. }
  797. }
  798. &:nth-child(5) {
  799. input {
  800. width: 54px;
  801. }
  802. }
  803. &:nth-child(6) {
  804. input {
  805. width: 72px;
  806. }
  807. }
  808. &:nth-child(7) {
  809. div {
  810. width: 101px;
  811. overflow: unset;
  812. input {
  813. width: 101px;
  814. }
  815. }
  816. }
  817. }
  818. }
  819. }
  820. }
  821. }
  822. .modify-btn {
  823. border: 1px solid #3c7cf5;
  824. color: #3c7cf5;
  825. background: #fff;
  826. }
  827. .delete-btn {
  828. border: 1px solid #3c7cf5;
  829. color: #fff;
  830. background: #3c7cf5;
  831. }
  832. .submit-area {
  833. margin: 51px auto 60px;
  834. text-align: center;
  835. clear: both;
  836. a {
  837. display: inline-block;
  838. width: 64px;
  839. height: 24px;
  840. line-height: 22px;
  841. text-align: center;
  842. border-radius: 3px;
  843. &.modify-btn {
  844. width: 90px;
  845. margin-left: 14px;
  846. }
  847. }
  848. }
  849. .apply-del-box{
  850. position: fixed;
  851. z-index: 1000;
  852. height: auto;
  853. opacity: 1;
  854. background-color: white;
  855. width: 310px;
  856. -webkit-box-shadow: 0 5px 15px rgba(0,0,0,.5);
  857. -moz-box-shadow: 0 5px 15px rgba(0,0,0,.5);
  858. -o-box-shadow: 0 5px 15px rgba(0,0,0,.5);
  859. box-shadow: 0 5px 15px rgba(0,0,0,.5);
  860. margin: -155px 0 0 -75px;
  861. top: 55%;
  862. left: 43%;
  863. .title{
  864. height: 24px;
  865. background-color: #007aff;
  866. text-align: right;
  867. padding-right: 15px;
  868. line-height: 24px;
  869. a{
  870. color: white;
  871. font-size: 12px;
  872. }
  873. }
  874. .content{
  875. width: 100%;
  876. text-align: center;
  877. margin: 0 auto;
  878. p{
  879. padding: 12px 31px;
  880. margin: 0;
  881. &:nth-child(2) {
  882. font-size: 12px;
  883. padding-top: 0;
  884. }
  885. i{
  886. color: #5078cb;
  887. font-size: 16px;
  888. margin-right: 10px;
  889. }
  890. .count {
  891. color: #007aff;
  892. }
  893. &:last-child {
  894. font-size: 12px;
  895. }
  896. }
  897. div{
  898. width: 100%;
  899. text-align: center;
  900. margin: 0 auto 20px;
  901. a{
  902. padding: 0 19px;
  903. height: 26px;
  904. line-height: 26px;
  905. display: inline-block;
  906. text-align: center;
  907. font-size: 14px;
  908. color: #fff;
  909. &:first-child{
  910. background: #c8c6c6;
  911. margin-right: 10px;
  912. }
  913. &:last-child{
  914. background: #007aff;
  915. }
  916. }
  917. }
  918. }
  919. }
  920. }
  921. </style>