BatchPublish.vue 34 KB

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