BatchPublish.vue 33 KB

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