BatchPublish.vue 33 KB

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