BatchPublish.vue 33 KB

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