BatchPublish.vue 34 KB

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