BatchPublish.vue 33 KB

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