BatchPublish.vue 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973
  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. &lt;!&ndash;<a @click="showRemindBox = false"><i class="fa fa-close fa-lg"></i></a>&ndash;&gt;
  141. </div>
  142. <div class="content">
  143. &lt;!&ndash;<p style="line-height: 20px;margin-top: 10px;padding:0 10px">非常抱歉,目前暂无此品牌!<br>若直接前往“品牌申请”,我们将为您先开通寄售功能,待申请通过后再提交开店申请。</p>&ndash;&gt;
  144. &lt;!&ndash;<p style="line-height: 20px;">前往<a @click="goBrandApply()" target="_blank" style="color: #5078CB">品牌申请&nbsp;<i class="fa fa-arrow-right"></i></a></p>&ndash;&gt;
  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. &lt;!&ndash;<a @click="showRemindBox = false">继续发布</a>&ndash;&gt;
  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. if (response.data.data.successAmount) {
  346. this.$router.push('/applyPurchase/result?status=success&count=' + response.data.data.successAmount)
  347. } else {
  348. this.$message.error('发布失败,请完善信息')
  349. }
  350. } else {
  351. // this.$message.error(response.data.message)
  352. this.$router.push('/applyPurchase/result?status=error')
  353. }
  354. }, err => {
  355. console.log(err)
  356. this.$message.error('系统错误')
  357. })
  358. },
  359. onCheck: function (index) {
  360. if (typeof index === 'undefined') {
  361. let isCheckedAll = true
  362. for (let i = 0; i < this.bomList.content.length; i++) {
  363. if (!this.bomList.content[i].checked) {
  364. isCheckedAll = false
  365. break
  366. }
  367. }
  368. this.setAllCheck(!isCheckedAll)
  369. this.isCheckAll = !isCheckedAll
  370. }
  371. },
  372. setAllCheck: function (flag) {
  373. for (let i = 0; i < this.bomList.content.length; i++) {
  374. this.bomList.content[i].checked = flag
  375. }
  376. },
  377. modifyItem: function (index) {
  378. for (let i = 0; i < this.bomList.content.length; i++) {
  379. this.bomList.content[i].active = false
  380. }
  381. // this.$set(this.bomList.content[index], 'active', true)
  382. this.bomList.content[index].active = true
  383. let _this = this
  384. this.initModifyObj()
  385. this.initValidObj()
  386. for (let attr in this.bomList.content[index]) {
  387. // console.log(attr + ':' + _this.bomList.content[index][attr])
  388. _this.$set(_this.modifyObj, attr, _this.bomList.content[index][attr])
  389. // _this.modifyObj[attr] = _this.bomList.content[index][attr]
  390. }
  391. // this.modifyObj = this.bomList.content[index]
  392. this.modifyObj.deadline = this.bomList.content[index].deadline ? this.getDate(this.bomList.content[index].deadline) : ''
  393. },
  394. cancelModify: function (index) {
  395. this.bomList.content[index].active = false
  396. },
  397. getDate: function (input) {
  398. const d = new Date(input)
  399. const year = d.getFullYear()
  400. const monthTemp = d.getMonth() + 1
  401. const month = monthTemp < 10 ? '0' + monthTemp : '' + monthTemp
  402. const day = d.getDate() < 10 ? '0' + d.getDate() : '' + d.getDate()
  403. return year + '-' + month + '-' + day
  404. },
  405. // validDate: function (timestamp) {
  406. // let now = new Date().getTime()
  407. // return timestamp - now <= 1000 * 60 * 60 * 24 * 90 && timestamp - now > 0
  408. // },
  409. submitModify: function (index) {
  410. let checkValid = this.checkAll()
  411. if (this.getSingleValidInfo(this.modifyObj) && checkValid) {
  412. if (!this.modifyObj.unitPrice) {
  413. this.modifyObj.currency = null
  414. }
  415. this.$http.put('/seek/updateSeekPurchaseByBatch', this.modifyObj)
  416. .then(response => {
  417. if (response.data.success) {
  418. this.reloadData()
  419. this.$message.success('修改成功')
  420. // this.bomList.content[index].active = false
  421. } else {
  422. this.$message.error('修改失败')
  423. }
  424. }, err => {
  425. console.log(err)
  426. this.$message.error('系统错误')
  427. })
  428. } else {
  429. if (!checkValid) {
  430. if (!this.validObj.code) {
  431. this.$message.error('型号不能为空')
  432. } else if (!this.validObj.brand) {
  433. this.$message.error('品牌不能为空')
  434. } else if (!this.validObj.deadline) {
  435. if (!this.isValidDate(this.modifyObj.deadline)) {
  436. this.$message.error('截止日期需在90天以内')
  437. } else {
  438. this.$message.error('截止日期不能为空')
  439. }
  440. } else if (!this.validObj.amount || !this.validObj.unitPrice) {
  441. this.$message.error('请输入正确的数值')
  442. }
  443. } else {
  444. this.$message.error('请完善信息')
  445. }
  446. }
  447. },
  448. deleteItem: function (index) {
  449. if (!index && index !== 0) {
  450. let str = ''
  451. for (let i = 0; i < this.bomList.content.length; i++) {
  452. if (this.bomList.content[i].checked) {
  453. str += this.bomList.content[i].id + ','
  454. }
  455. }
  456. let param = {}
  457. if (str.length) {
  458. str = str.substring(0, str.length - 1)
  459. param.spIds = str
  460. this.doDelete(param)
  461. } else {
  462. this.$message.error('请勾选')
  463. return
  464. }
  465. } else {
  466. this.doDelete({spIds: this.bomList.content[index].id})
  467. }
  468. },
  469. doDelete: function (param) {
  470. this.$http.put('/seek/deleteSeekPurchaseByBatch', param)
  471. .then(response => {
  472. if (response.data.success) {
  473. this.listenPage(1)
  474. this.$message.success('删除成功')
  475. } else {
  476. this.$message.error('删除失败')
  477. }
  478. }, err => {
  479. console.log(err)
  480. this.$message.error('系统错误')
  481. })
  482. },
  483. isValidTime: function (time) {
  484. let now = new Date().getTime()
  485. return !time || (time >= now && time <= now + 1000 * 60 * 60 * 24 * 91)
  486. },
  487. isValidDate: function (date) {
  488. date = formatDate(date, 'yyyy-MM-dd hh:mm:ss')
  489. this.modifyObj.deadline = date
  490. let now = new Date().getTime()
  491. let time = new Date(date).getTime()
  492. return !time || (time >= now && time <= now + 1000 * 60 * 60 * 24 * 91)
  493. },
  494. getSimilarCode: function () {
  495. this.$http.get('/search/similarComponents', {params: {keyword: this.modifyObj.code}})
  496. .then(response => {
  497. this.similarCode = response.data
  498. if (response.data.length) {
  499. this.showSimilarCodeList = true
  500. }
  501. })
  502. },
  503. getSimilarBrand: function () {
  504. this.$http.get('/search/similarBrands', {params: {keyword: this.modifyObj.brand}})
  505. .then(response => {
  506. this.similarBrand = response.data
  507. if (response.data.length) {
  508. this.showSimilarBrandList = true
  509. }
  510. })
  511. },
  512. getSingleValidInfo: function (item) {
  513. return item.code && item.brand && item.deadline && this.isValidDate(item.deadline)
  514. },
  515. checkCode: function () {
  516. this.validObj.code = this.modifyObj.code && this.modifyObj.code !== ''
  517. return this.validObj.code
  518. },
  519. checkBrand: function () {
  520. this.validObj.brand = this.modifyObj.brand && this.modifyObj.brand !== ''
  521. return this.validObj.brand
  522. },
  523. checkUnitPrice: function () {
  524. this.validObj.unitPrice = (!this.modifyObj.unitPrice || this.modifyObj.unitPrice === '') ? true : this.modifyObj.unitPrice > 0 && this.modifyObj.unitPrice < 100000000
  525. return this.validObj.unitPrice
  526. },
  527. checkAmount: function () {
  528. this.validObj.amount = (!this.modifyObj.amount || this.modifyObj.amount === '') ? true : this.modifyObj.amount > 0 && this.modifyObj.amount < 1000000000
  529. return this.validObj.amount
  530. },
  531. checkAll: function () {
  532. return this.checkCode() && this.checkBrand() && this.checkDeadline() && this.checkUnitPrice() && this.checkAmount()
  533. },
  534. checkDeadline: function () {
  535. this.validObj.deadline = this.modifyObj.deadline && this.modifyObj.deadline !== '' && this.isValidDate(this.modifyObj.deadline)
  536. return this.validObj.deadline
  537. },
  538. onUnitPriceInput: function () {
  539. let price = this.modifyObj.unitPrice
  540. if (price >= 10000) {
  541. this.modifyObj.unitPrice = price.substring(0, 4)
  542. } else if (price.indexOf('.') > -1) {
  543. let arr = price.split('.')
  544. if (arr[0].length > 4) {
  545. this.modifyObj.unitPrice = Number(arr[0].substring(0, 4) + '.' + arr[1])
  546. } else if (arr[1].length > 6) {
  547. this.modifyObj.unitPrice = Number(arr[0] + '.' + arr[1].substring(0, 6))
  548. }
  549. }
  550. },
  551. onProduceDateChange: function () {
  552. if (this.modifyObj.produceDate && getRealLen(this.modifyObj.produceDate) > 12) {
  553. this.modifyObj.produceDate = cutOutString(this.modifyObj.produceDate, 12)
  554. }
  555. },
  556. onEncapsulationChange: function () {
  557. if (this.modifyObj.encapsulation && getRealLen(this.modifyObj.encapsulation) > 20) {
  558. this.modifyObj.encapsulation = cutOutString(this.modifyObj.encapsulation, 20)
  559. }
  560. },
  561. onCodeChange: function () {
  562. this.modifyObj.code = this.modifyObj.code.trim()
  563. if ((/[^\x00-\xff]/g).test(this.modifyObj.code)) {
  564. let chineseIndex = -1
  565. for (let i = 0; i < this.modifyObj.code.length; i++) {
  566. if ((/[^\x00-\xff]/g).test(this.modifyObj.code.charAt(i))) {
  567. chineseIndex = i
  568. break
  569. }
  570. }
  571. this.modifyObj.code = cutOutString(this.modifyObj.code, chineseIndex)
  572. } else if (this.modifyObj.code && getRealLen(this.modifyObj.code) > 100) {
  573. this.modifyObj.code = cutOutString(this.modifyObj.code, 100)
  574. } else {
  575. this.getSimilarCode()
  576. }
  577. },
  578. onBrandChange: function () {
  579. this.modifyObj.brand = this.modifyObj.brand.trim()
  580. if ((/[^\x00-\xff]/g).test(this.modifyObj.brand)) {
  581. let chineseIndex = -1
  582. for (let i = 0; i < this.modifyObj.brand.length; i++) {
  583. if ((/[^\x00-\xff]/g).test(this.modifyObj.brand.charAt(i))) {
  584. chineseIndex = i
  585. break
  586. }
  587. }
  588. this.modifyObj.brand = cutOutString(this.modifyObj.brand, chineseIndex)
  589. } else if (this.modifyObj.brand && getRealLen(this.modifyObj.brand) > 50) {
  590. this.modifyObj.brand = cutOutString(this.modifyObj.brand, 50)
  591. } else {
  592. this.getSimilarBrand()
  593. }
  594. },
  595. onAmountInput: function () {
  596. if (!(/^[0-9]*$/).test(this.modifyObj.amount)) {
  597. let chineseIndex = -1
  598. for (let i = 0; i < this.modifyObj.amount.length; i++) {
  599. if (!(/^[0-9]*$/).test(this.modifyObj.amount.charAt(i))) {
  600. chineseIndex = i
  601. break
  602. }
  603. }
  604. this.modifyObj.amount = cutOutString(this.modifyObj.amount, chineseIndex)
  605. } else if (this.modifyObj.amount.length > 9) {
  606. this.modifyObj.amount = cutOutString(this.modifyObj.amount, 9)
  607. }
  608. },
  609. setCode: function (code) {
  610. this.modifyObj.code = code
  611. this.showSimilarCodeList = false
  612. },
  613. setBrand: function (brand) {
  614. this.modifyObj.brand = brand
  615. this.showSimilarBrandList = false
  616. },
  617. setShowCodeWord: function (index, event) {
  618. event.stopPropagation()
  619. for (let i = 0; i < this.bomList.content.length; i++) {
  620. if (i !== index) {
  621. this.bomList.content[i].showCodeWord = false
  622. }
  623. this.bomList.content[i].showBrandWord = false
  624. }
  625. this.bomList.content[index].showCodeWord = !this.bomList.content[index].showCodeWord
  626. },
  627. setShowBrandWord: function (index, event) {
  628. event.stopPropagation()
  629. for (let i = 0; i < this.bomList.content.length; i++) {
  630. if (i !== index) {
  631. this.bomList.content[i].showBrandWord = false
  632. }
  633. this.bomList.content[i].showCodeWord = false
  634. }
  635. this.bomList.content[index].showBrandWord = !this.bomList.content[index].showBrandWord
  636. },
  637. modifyItemByWord: function (index, param, type) {
  638. if (type === 'code') {
  639. this.bomList.content[index].code = param
  640. this.requestModify(this.bomList.content[index])
  641. } else if (type === 'brand') {
  642. this.bomList.content[index].brand = param
  643. this.requestModify(this.bomList.content[index])
  644. } else {
  645. this.$message.error('修改失败')
  646. }
  647. },
  648. requestModify: function (item) {
  649. this.$http.put('/seek/updateSeekPurchaseByBatch', item)
  650. .then(response => {
  651. if (response.data.success) {
  652. this.$message.success('修改成功')
  653. } else {
  654. this.$message.error('修改失败')
  655. }
  656. this.reloadData()
  657. }, err => {
  658. console.log(err)
  659. this.$message.error('系统错误')
  660. this.reloadData()
  661. })
  662. }
  663. }
  664. }
  665. </script>
  666. <style lang="scss">
  667. .batch-publish {
  668. margin: 0 auto;
  669. width: 998px;
  670. .red-text {
  671. color: #ff0000;
  672. }
  673. .blue-text {
  674. color: #3c7cf5;
  675. }
  676. > p {
  677. margin: 59px 0 42px;
  678. font-size: 16px;
  679. }
  680. table {
  681. width: 100%;
  682. table-layout: fixed;
  683. thead {
  684. tr {
  685. th {
  686. background: #b8b8b8;
  687. color: #fff;
  688. font-weight: normal;
  689. height: 50px;
  690. line-height: 50px;
  691. text-align: center;
  692. .com-check-box {
  693. margin-right: 2px;
  694. }
  695. i {
  696. margin-right: 3px;
  697. }
  698. }
  699. }
  700. }
  701. tbody {
  702. tr {
  703. height: 85px;
  704. line-height: 85px;
  705. text-align: center;
  706. border : {
  707. bottom: 1px solid #d9d9d9;
  708. left: 1px solid #d9d9d9;
  709. right: 1px solid #d9d9d9;
  710. }
  711. &:hover {
  712. background: #f3f3f3;
  713. }
  714. td {
  715. position: relative;
  716. font-size: 12px;
  717. > ul {
  718. line-height: normal;
  719. position: absolute;
  720. top: 52px;
  721. left: 24px;
  722. background: #fff;
  723. border: 1px solid #b5b5b5;
  724. z-index: 1;
  725. max-height: 120px;
  726. overflow-y: auto;
  727. overflow-x: hidden;
  728. border-radius: 3px;
  729. width: 114px;
  730. li {
  731. height: 24px;
  732. line-height: 24px;
  733. cursor: pointer;
  734. overflow: hidden;
  735. text-overflow: ellipsis;
  736. white-space: nowrap;
  737. padding: 0 5px;
  738. &:hover {
  739. background: #ddd;
  740. }
  741. }
  742. &.brand-similar-list {
  743. left: 20px;
  744. width: 94px;
  745. }
  746. }
  747. > div {
  748. overflow: hidden;
  749. overflow-y: unset;
  750. text-overflow: ellipsis;
  751. white-space: nowrap;
  752. &.similar-select {
  753. width: 109px;
  754. margin: 0 auto;
  755. border: 1px solid #b5b5b5;
  756. height: 18px;
  757. line-height: 18px;
  758. overflow-y: hidden;
  759. padding: 0 22px 0 5px;
  760. background: url('/images/applyPurchase/select.png') no-repeat;
  761. background-position: 91px 0;
  762. cursor: default;
  763. border-radius: 3px;
  764. & + ul {
  765. width: 110px;
  766. top: 52px;
  767. left: 40px;
  768. &.brand-word-list {
  769. left: 27px;
  770. }
  771. }
  772. }
  773. }
  774. div.red-text {
  775. line-height: normal;
  776. position: absolute;
  777. left: 42px;
  778. top: 49px;
  779. }
  780. &.operate {
  781. a {
  782. display: block;
  783. width: 64px;
  784. height: 24px;
  785. line-height: 22px;
  786. text-align: center;
  787. border-radius: 3px;
  788. margin: 0 auto 4px;
  789. font-size: 14px;
  790. &.submit-btn {
  791. border: 1px solid #f64900;
  792. color: #fff;
  793. background: #f64900;
  794. }
  795. &.cancel-btn {
  796. border: 1px solid #bbb;
  797. color: #fff;
  798. background: #bbb;
  799. }
  800. }
  801. }
  802. }
  803. &.modify-row {
  804. td {
  805. position: relative;
  806. input, select {
  807. height: 20px;
  808. border-radius: 3px;
  809. background: #f4f4f4;
  810. border: 1px solid #b5b5b5;
  811. text-align: center;
  812. padding: 0 5px;
  813. &.error {
  814. border-color: #f4645f !important;
  815. }
  816. }
  817. &:nth-child(1) {
  818. input {
  819. width: 113px;
  820. }
  821. }
  822. &:nth-child(2) {
  823. input {
  824. width: 93px;
  825. }
  826. }
  827. &:nth-child(3) {
  828. input {
  829. width: 71px;
  830. }
  831. }
  832. &:nth-child(4) {
  833. input {
  834. width: 65px;
  835. padding: 0 5px 0 30px;
  836. }
  837. select {
  838. width: 25px;
  839. padding: 0 0 0 2px;
  840. background: url(/images/applyPurchase/select.png) no-repeat right;
  841. background-size: 12px 19px;
  842. background-position: 13px 0;
  843. position: absolute;
  844. top: 33px;
  845. border-bottom: none;
  846. border-top: none;
  847. border-left: 0;
  848. }
  849. }
  850. &:nth-child(5) {
  851. input {
  852. width: 54px;
  853. }
  854. }
  855. &:nth-child(6) {
  856. input {
  857. width: 72px;
  858. }
  859. }
  860. &:nth-child(7) {
  861. div {
  862. width: 101px;
  863. overflow: unset;
  864. input {
  865. width: 101px;
  866. }
  867. }
  868. }
  869. }
  870. }
  871. }
  872. }
  873. }
  874. .modify-btn {
  875. border: 1px solid #3c7cf5;
  876. color: #3c7cf5;
  877. background: #fff;
  878. }
  879. .delete-btn {
  880. border: 1px solid #3c7cf5;
  881. color: #fff;
  882. background: #3c7cf5;
  883. }
  884. .submit-area {
  885. margin: 51px auto 60px;
  886. text-align: center;
  887. clear: both;
  888. a {
  889. display: inline-block;
  890. width: 64px;
  891. height: 24px;
  892. line-height: 22px;
  893. text-align: center;
  894. border-radius: 3px;
  895. &.modify-btn {
  896. width: 90px;
  897. margin-left: 14px;
  898. }
  899. }
  900. }
  901. .apply-del-box{
  902. position: fixed;
  903. z-index: 1000;
  904. height: auto;
  905. opacity: 1;
  906. background-color: white;
  907. width: 310px;
  908. /*-webkit-box-shadow: 0 5px 15px rgba(0,0,0,.5);*/
  909. /*-moz-box-shadow: 0 5px 15px rgba(0,0,0,.5);*/
  910. /*-o-box-shadow: 0 5px 15px rgba(0,0,0,.5);*/
  911. /*box-shadow: 0 5px 15px rgba(0,0,0,.5);*/
  912. margin: -155px 0 0 -75px;
  913. top: 55%;
  914. left: 43%;
  915. .title{
  916. height: 24px;
  917. background-color: #007aff;
  918. text-align: right;
  919. padding-right: 15px;
  920. line-height: 24px;
  921. a{
  922. color: white;
  923. font-size: 12px;
  924. }
  925. }
  926. .content{
  927. width: 100%;
  928. text-align: center;
  929. margin: 0 auto;
  930. p{
  931. padding: 12px 31px;
  932. margin: 0;
  933. &:nth-child(2) {
  934. font-size: 12px;
  935. padding-top: 0;
  936. }
  937. i{
  938. color: #5078cb;
  939. font-size: 16px;
  940. margin-right: 10px;
  941. }
  942. span {
  943. color: #007aff;
  944. }
  945. &:last-child {
  946. font-size: 12px;
  947. }
  948. }
  949. div{
  950. width: 100%;
  951. text-align: center;
  952. margin: 0 auto 20px;
  953. a{
  954. padding: 0 19px;
  955. height: 26px;
  956. line-height: 26px;
  957. display: inline-block;
  958. text-align: center;
  959. font-size: 14px;
  960. color: #fff;
  961. &:first-child{
  962. background: #c8c6c6;
  963. margin-right: 10px;
  964. }
  965. &:last-child{
  966. background: #007aff;
  967. }
  968. }
  969. }
  970. }
  971. }
  972. }
  973. </style>