BatchPublish.vue 59 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542
  1. <template>
  2. <div class="batch-publish">
  3. <div class="batch-publish-top clearfix">
  4. <div class="w50">
  5. <img src="/images/applyPurchase/batch-icon.png" alt="">
  6. Bom名称:<input type="text" v-model="bomInfo.name" class="text" />
  7. 共上传<b class="blue-text">{{bomNumber.successImport || 0}}</b>个产品
  8. <!--,其中<span class="red-text">{{bomNumber.nullField || 0}}</span>个产品的必填项缺失,请在当前页完善信息-->
  9. </div>
  10. <div class="w50">
  11. 采购套数:<input type="text" v-model="bomInfo.count" class="text"/>
  12. </div>
  13. <div class="w50" style="padding-left: 62px;">
  14. 规格:<input type="text" v-model="bomInfo.spec" class="text" />
  15. </div>
  16. <div class="w50">
  17. <span style="margin-right: 1px;">*截止时间: </span><el-date-picker
  18. v-model="bomInfo.endTime"
  19. type="date"
  20. :picker-options="pickerOptions"
  21. :editable="false"
  22. :class="{'error': !bomInfo.flag}"
  23. @change="getDate1()"
  24. size="mini">
  25. </el-date-picker>
  26. </div>
  27. <a class="modify-btn" @click="submitBOM">确认发布</a>
  28. </div>
  29. <div class="list-wrap" v-if="bomList.content.length">
  30. <table class="list-content">
  31. <thead>
  32. <tr>
  33. <!--<th width="60">-->
  34. <!--<label class="com-check-box">-->
  35. <!--<input type="checkbox" id="all" @change="onCheck()" v-model="isCheckAll">-->
  36. <!--<label for="all"></label>-->
  37. <!--</label>全选-->
  38. <!--</th>-->
  39. <th width="307">品牌/物料名称</th>
  40. <th width="307">型号/规格</th>
  41. <th width="95">单位用量(PCS)</th>
  42. <!--<th width="114">生产日期</th>-->
  43. <!--<th width="136"><i class="red-text">*</i>截止时间</th>-->
  44. <th width="186">操作</th>
  45. </tr>
  46. </thead>
  47. <tbody v-for="(item, index) in bomList.content">
  48. <tr v-if="!item.active">
  49. <!--<td>
  50. <label class="com-check-box">
  51. <input type="checkbox" @change="onCheck(index)" v-model="item.checked" :id="index">
  52. <label :for="index"></label>
  53. </label>
  54. </td>-->
  55. <td>
  56. <div class="prod-items">
  57. <div class="prod-item prod-item-large" :title="item.brand">
  58. <span class="pi-title"><i class="red-text">*</i>品牌:</span>
  59. <div class="pi-content over-ell" v-if="item.brand && (!item.brandWord || item.brandWord.length == 0)" :title="item.brand">{{item.brand}}</div>
  60. <div class="pi-content red-text" v-if="!item.brand">请完善信息</div>
  61. <div class="pi-content similar-select over-ell" v-if="item.brandWord && item.brandWord.length > 0" @click="setShowBrandWord(index, $event)">{{item.brand}}</div>
  62. <ul v-show="item.showBrandWord">
  63. <li v-for="brand in item.brandWord" @click="modifyItemByWord(index, brand.nameEn, 'brand')" :title="brand.nameEn">{{brand.nameEn}}</li>
  64. </ul>
  65. </div>
  66. <!--<div class="prod-item prod-item-small">
  67. <span class="pi-title">单价预算:</span>
  68. <div class="pi-content over-ell" v-if="item.unitPrice">{{(item.currency === 'RMB' ? '¥' : '$') + item.unitPrice}}</div>
  69. <div class="pi-content over-ell" v-else="!item.unitPrice">-</div>
  70. </div>-->
  71. <div class="prod-item prod-item-large" :title="item.kind">
  72. <span class="pi-title"><i class="red-text">*</i>物料名称:</span>
  73. <div class="pi-content over-ell" v-if="item.kind && (!item.kindWord || item.kindWord.length == 0)" :title="item.kind">{{item.kind}}</div>
  74. <div class="pi-content red-text" v-if="!item.kind">请完善信息</div>
  75. <!--<div class="pi-content over-ell">{{item.kind || '-'}}</div>-->
  76. </div>
  77. <!--<div class="prod-item prod-item-small" :title="item.encapsulation">
  78. <span class="pi-title">封装:</span>
  79. <div class="pi-content over-ell">
  80. {{item.encapsulation || '-'}}
  81. </div>
  82. </div>-->
  83. </div>
  84. </td>
  85. <td>
  86. <div class="prod-items">
  87. <div class="prod-item prod-item-large" :title="item.code">
  88. <span class="pi-title"><i class="red-text">*</i>型号:</span>
  89. <div class="pi-content over-ell" v-if="item.code && (!item.codeWord || item.codeWord.length == 0)" :title="item.code">{{item.code}}</div>
  90. <div class="pi-content red-text" v-if="!item.code">请完善信息</div>
  91. <div class="pi-content over-ell similar-select" v-if="item.codeWord && item.codeWord.length > 0" @click="setShowCodeWord(index, $event)">{{item.code}}</div>
  92. <ul v-show="item.showCodeWord">
  93. <li v-for="code in item.codeWord" @click="modifyItemByWord(index, code.code, 'code')" :title="code.code">{{code.code}}</li>
  94. </ul>
  95. </div>
  96. <!--<div class="prod-item prod-item-small">
  97. <span class="pi-title">单价预算:</span>
  98. <div class="pi-content over-ell" v-if="item.unitPrice">{{(item.currency === 'RMB' ? '¥' : '$') + item.unitPrice}}</div>
  99. <div class="pi-content over-ell" v-else="!item.unitPrice">-</div>
  100. </div>-->
  101. <div class="prod-item prod-item-large" :title="item.spec">
  102. <span class="pi-title">规格:</span>
  103. <div class="pi-content over-ell">{{item.spec || '-'}}</div>
  104. </div>
  105. <!--<div class="prod-item prod-item-small" :title="item.encapsulation">
  106. <span class="pi-title">封装:</span>
  107. <div class="pi-content over-ell">
  108. {{item.encapsulation || '-'}}
  109. </div>
  110. </div>-->
  111. </div>
  112. </td>
  113. <td>
  114. <div class="over-ell" :title="item.amount">{{item.amount || '-'}}</div>
  115. </td>
  116. <!--<td>
  117. <div class="over-ell" :title="item.produceDate">
  118. {{item.produceDate || '-'}}
  119. </div>
  120. </td>-->
  121. <!--<td>-->
  122. <!--<span v-if="item.deadline">{{item.deadline | date}}</span>-->
  123. <!--<span class="red-text" v-if="!item.deadline">请完善信息</span>-->
  124. <!--<div class="red-text remind" v-if="!isValidTime(item.deadline)">默认≤90天</div>-->
  125. <!--</td>-->
  126. <td class="operate">
  127. <a @click="modifyItem(index)" class="size-s">编辑</a>
  128. <a @click="deleteItem(index)" class="size-s">删除</a>
  129. <!-- -->
  130. <a @click="setShowSpotGoods(true, item)" class="size-m" v-if="item.spotGoods && item.spotGoods.length && !item.showSpotGoods">商城现货&nbsp;<i class="fa fa-angle-double-down"></i></a>
  131. <a @click="setShowSpotGoods(false)" class="size-m" v-if="item.spotGoods && item.spotGoods.length && item.showSpotGoods">收起&nbsp;<i class="fa fa-angle-double-up"></i></a>
  132. </td>
  133. </tr>
  134. <tr class="spot-goods" v-if="item.showSpotGoods">
  135. <td colspan="4">
  136. <div class="spot-goods-body">
  137. <div class="spot-goods-title">商城现货({{spotGoodsData.length || 0}})</div>
  138. <table>
  139. <thead>
  140. <tr>
  141. <th width="214">卖家</th>
  142. <th width="83">交期(天)</th>
  143. <th width="104">单价</th>
  144. <th width="137">生产日期</th>
  145. <th width="111">库存</th>
  146. <th width="142">购买数量</th>
  147. <th width="186">操作</th>
  148. </tr>
  149. </thead>
  150. </table>
  151. <div class="spot-goods-list">
  152. <table>
  153. <tbody>
  154. <tr v-for="(spotGoods, index) in spotGoodsData">
  155. <td width="214" v-text="spotGoods.storeName"></td>
  156. <td width="83" class="red-text" v-text="spotGoods.b2cMinDelivery + '-' + spotGoods.b2cMaxDelivery">4-6</td>
  157. <td width="104" class="red-text" v-text="spotGoods.currencyName == 'RMB' ? '¥' + spotGoods.prices[0].rMBPrice: '$' + spotGoods.prices[0].uSDPrice"></td>
  158. <td width="137" v-text="spotGoods.produceDate"></td>
  159. <td width="111" v-text="spotGoods.reserve">21412</td>
  160. <td width="142" class="input-number">
  161. <div>
  162. <span @click="subNum(index)" :class="{'not-allowed': !fragments[index].canSub}">-</span>
  163. <input type="number" v-model="fragments[index].num" @blur="inputNum(index)">
  164. <span @click="addNum(index)" :class="{'not-allowed': !fragments[index].canAdd}">+</span>
  165. </div>
  166. </td>
  167. <td width="186" class="operate">
  168. <a href="javascript:void(0)" @click="linkSaler(spotGoods)">联系卖家<img src="/images/applyPurchase/link-buyer.png" alt=""></a>
  169. <span @click="buyNow(spotGoods, index)">立即购买</span>
  170. </td>
  171. </tr>
  172. </tbody>
  173. </table>
  174. </div>
  175. </div>
  176. </td>
  177. </tr>
  178. <tr class="modify-row" v-if="item.active">
  179. <!-- <td>
  180. <label class="com-check-box">
  181. <input type="checkbox" @change="onCheck(index)" v-model="item.checked" :id="index">
  182. <label :for="index"></label>
  183. </label>
  184. </td>-->
  185. <td>
  186. <div class="prod-items">
  187. <div class="prod-item prod-item-large">
  188. <span class="pi-title"><i class="red-text">*</i>品牌:</span>
  189. <input type="text" class="form-control" v-model="modifyObj.brand" :class="{'error': !validObj.brand}" @blur="checkBrand" @input="onBrandChange">
  190. <ul class="brand-similar-list" v-show="showSimilarBrandList">
  191. <li v-for="sBrand in similarBrand" @click="setBrand(sBrand.nameEn)">{{sBrand.nameEn}}</li>
  192. </ul>
  193. </div>
  194. <div class="prod-item prod-item-large">
  195. <span class="pi-title"><i class="red-text">*</i>物料名称:</span>
  196. <input type="text" class="form-control" v-model="modifyObj.kind" :class="{'error': !validObj.kind}" @input="onProdTitleInput" @blur="checkKind">
  197. </div>
  198. <!--<div class="prod-item prod-item-small pi-select">
  199. <span class="pi-title">单价预算:</span>
  200. <select class="form-control" v-model="modifyObj.currency">
  201. <option value="RMB">¥</option>
  202. <option value="USD">$</option>
  203. </select>
  204. <input class="form-control" type="number" v-model="modifyObj.unitPrice" :class="{'error': !validObj.unitPrice}" @blur="checkUnitPrice" @input="onUnitPriceInput">
  205. </div>-->
  206. <!--<div class="prod-item prod-item-small">
  207. <span class="pi-title">封装:</span>
  208. <input type="text" class="form-control" v-model="modifyObj.encapsulation" @input="onEncapsulationChange">
  209. </div>-->
  210. </div>
  211. </td>
  212. <td>
  213. <div class="prod-items">
  214. <div class="prod-item prod-item-large">
  215. <span class="pi-title"><i class="red-text">*</i>型号:</span>
  216. <input type="text" class="form-control" v-model="modifyObj.code" :class="{'error': !validObj.code}" @blur="checkCode" @input="onCodeChange" >
  217. <ul v-show="showSimilarCodeList">
  218. <li v-for="sCode in similarCode" @click="setCode(sCode.code)">{{sCode.code}}</li>
  219. </ul>
  220. </div>
  221. <div class="prod-item prod-item-large">
  222. <span class="pi-title">规格:</span>
  223. <input type="text" class="form-control" v-model="modifyObj.spec" :class="{'error': !validObj.spec}" @input="onSpecInput" @blur="checkSpec">
  224. </div>
  225. </div>
  226. </td>
  227. <td>
  228. <input type="text" class="form-control" v-model="modifyObj.amount" :class="{'error': !validObj.amount}" @blur="checkAmount" @input="onAmountInput">
  229. </td>
  230. <!--<td>
  231. <input type="text" class="form-control" v-model="modifyObj.produceDate" @input="onProduceDateChange">
  232. </td>-->
  233. <!--<td>-->
  234. <!--<el-date-picker-->
  235. <!--v-model="modifyObj.deadline"-->
  236. <!--type="date"-->
  237. <!--:picker-options="pickerOptions"-->
  238. <!--:editable="false"-->
  239. <!--:class="{'error': !validObj.deadline}"-->
  240. <!--@change="getDate1()"-->
  241. <!--size="mini">-->
  242. <!--</el-date-picker>-->
  243. <!--<input type="text" class="form-control" v-model="modifyObj.deadline">-->
  244. <!--</td>-->
  245. <td class="operate">
  246. <a class="btn-ok size-s" @click="submitModify(index)">确认</a>
  247. <a class="btn-cancel size-s" @click="cancelModify(index)">取消</a>
  248. </td>
  249. </tr>
  250. </tbody>
  251. </table>
  252. <page :total="bomList.totalElements" :page-size="pageSize"
  253. :current="nowPage" @childEvent="listenPage"></page>
  254. <div class="submit-area" v-if="bomList.content.length">
  255. <!-- <a class="modify-btn" @click="deleteItem()">删除</a>-->
  256. <a class="modify-btn" @click="submitBOM">确认发布</a>
  257. </div>
  258. </div>
  259. </div>
  260. </template>
  261. <script>
  262. import Page from '~components/common/page/pageComponent.vue'
  263. export default {
  264. data () {
  265. return {
  266. pageSize: 10,
  267. nowPage: 1,
  268. isCheckAll: false,
  269. // showRemindBox: false,
  270. modifyObj: {
  271. code: '',
  272. brand: '',
  273. unitPrice: '',
  274. currency: 'RMB',
  275. encapsulation: '',
  276. produceDate: '',
  277. amount: '',
  278. deadline: '',
  279. kind: '',
  280. spec: '',
  281. },
  282. pickerOptions: {
  283. disabledDate (time) {
  284. // 大于等于今天 小于三个月后
  285. return time.getTime() < Date.now() - 1000 * 60 * 60 * 24 || time.getTime() > Date.now() + 1000 * 60 * 60 * 24 * 30 * 3
  286. }
  287. },
  288. similarCode: [],
  289. similarBrand: [],
  290. validObj: {
  291. code: true,
  292. brand: true,
  293. unitPrice: true,
  294. // encapsulation: true,
  295. // produceDate: true,
  296. amount: true,
  297. deadline: true,
  298. spec: true,
  299. kind: true
  300. },
  301. // successResult: 0,
  302. showSimilarCodeList: false,
  303. showSimilarBrandList: false,
  304. spotGoodsData: [],
  305. fragments: [],
  306. bomList: {},
  307. bomInfo: {}
  308. }
  309. },
  310. components: {
  311. Page
  312. },
  313. watch: {
  314. '$store.state.applyPurchase.bomMaterial.bomList.data': {
  315. handler: function (val) {
  316. let _this = this
  317. let list = JSON.parse(JSON.stringify(val))
  318. list.content = list.content.slice()
  319. for (let i = 0; i < list.content.length; i++) {
  320. _this.$set(list.content[i], 'checked', false)
  321. _this.$set(list.content[i], 'active', false)
  322. _this.$set(list.content[i], 'showCodeWord', false)
  323. _this.$set(list.content[i], 'showBrandWord', false)
  324. _this.$set(list.content[i], 'showSpotGoods', false)
  325. }
  326. this.bomList = list
  327. },
  328. immediate: true
  329. }
  330. },
  331. computed: {
  332. // bomList () {
  333. // let _this = this
  334. // let list = JSON.parse(JSON.stringify(this.$store.state.applyPurchase.bomMaterial.bomList.data))
  335. // list.content = list.content.slice()
  336. // for (let i = 0; i < list.content.length; i++) {
  337. // _this.$set(list.content[i], 'checked', false)
  338. // _this.$set(list.content[i], 'active', false)
  339. // _this.$set(list.content[i], 'showCodeWord', false)
  340. // _this.$set(list.content[i], 'showBrandWord', false)
  341. // _this.$set(list.content[i], 'showSpotGoods', false)
  342. // // list.content[i].checked = false
  343. // // list.content[i].active = false
  344. // // if (!list.content[i].code || list.content[i].brand || !list.content[i].deadline || !this.isValidDate(list.content[i].deadline)) {
  345. // // _this.validList = false
  346. // // }
  347. // }
  348. // console.log(list)
  349. // return list
  350. // },
  351. bomNumber () {
  352. return this.$store.state.applyPurchase.bomMaterial.bomNumber.data
  353. },
  354. tab () {
  355. return this.$store.state.chat.tab.tab.data
  356. },
  357. user () {
  358. return this.$store.state.option.user
  359. }
  360. },
  361. mounted () {
  362. let _this = this
  363. document.body.onclick = function () {
  364. _this.showSimilarCodeList = false
  365. _this.showSimilarBrandList = false
  366. for (let i = 0; i < _this.bomList.content.length; i++) {
  367. _this.bomList.content[i].showCodeWord = false
  368. _this.bomList.content[i].showBrandWord = false
  369. }
  370. }
  371. },
  372. filters: {
  373. date: function (input) {
  374. if (input) {
  375. const d = new Date(input)
  376. const year = d.getFullYear()
  377. const monthTemp = d.getMonth() + 1
  378. const month = monthTemp < 10 ? '0' + monthTemp : '' + monthTemp
  379. const day = d.getDate() < 10 ? '0' + d.getDate() : '' + d.getDate()
  380. return year + '-' + month + '-' + day
  381. } else {
  382. return null
  383. }
  384. },
  385. currencyStr: function (str) {
  386. return typeof str === 'string' && str !== 'RMB' && str !== 'USD' ? str.startsWith('RMB') ? '¥' + str.substring(3, str.length) : '$' + str.substring(3, str.length) : '-'
  387. }
  388. },
  389. methods: {
  390. getDate1: function () {
  391. this.bomInfo.endTime = this.bomInfo.endTime ? this.baseUtils.getFullDay(this.baseUtils.getClearDay(new Date(this.baseUtils.formatDate(new Date(this.bomInfo.endTime), 'yyyy-MM-dd')))) : null
  392. this.bomInfo.flag = true
  393. // this.modifyObj.deadline = this.modifyObj.deadline ? this.baseUtils.getFullDay(this.baseUtils.getClearDay(new Date(this.baseUtils.formatDate(new Date(this.modifyObj.deadline), 'yyyy-MM-dd')))) : null
  394. // this.validObj.deadline = true
  395. },
  396. initModifyObj: function () {
  397. for (let attr in this.modifyObj) {
  398. this.modifyObj[attr] = attr === 'currency' ? 'RMB' : ''
  399. }
  400. },
  401. initValidObj: function () {
  402. this.validObj = {
  403. code: true,
  404. brand: true,
  405. unitPrice: true,
  406. amount: true,
  407. deadline: true,
  408. spec: true,
  409. kind: true
  410. }
  411. },
  412. listenPage: function (page) {
  413. this.nowPage = page
  414. this.reloadData()
  415. },
  416. reloadData: function () {
  417. this.$store.dispatch('applyPurchase/loadBOMMaterialList', {bomId: this.$route.params.id, page: this.nowPage, count: this.pageSize})
  418. },
  419. submitBOM: function () {
  420. // let str = ''
  421. // for (let i = 0; i < this.bomList.content.length; i++) {
  422. // if (this.bomList.content[i].checked) {
  423. // if (!this.getSingleValidInfo(this.bomList.content[i])) {
  424. // this.$message.error('请选择信息完善的产品发布求购')
  425. // return
  426. // }
  427. // str += this.bomList.content[i].id + ','
  428. // }
  429. // }
  430. // let param = {'bomId': Number(this.$route.params.id)}
  431. // if (str.length) {
  432. // str = str.substring(0, str.length - 1)
  433. // param.spIds = str
  434. // }
  435. if (!this.bomInfo.count || this.bomInfo.count === '') {
  436. this.$message.error('请输入采购套数')
  437. return
  438. } else if (!this.bomInfo.endTime || this.bomInfo.endTime === '') {
  439. this.$message.error('请选择截止时间')
  440. return
  441. } else if (!this.bomInfo.spec || this.bomInfo.spec === '') {
  442. this.$message.error('请输入规格')
  443. return
  444. }
  445. let bom = this.bomInfo
  446. this.$http.post('/seek/bom/edit', bom).then(response => {
  447. this.$http.post('/seek/confirmBom?bomId=' + Number(this.$route.params.id) + '&endTime=' + this.bomInfo.endTime.getTime() + '&count=' + this.bomInfo.count)
  448. .then(response => {
  449. if (response.data.success) {
  450. // this.showRemindBox = true
  451. // this.successResult = response.data.data
  452. // this.listenPage(1)
  453. // this.$store.dispatch('applyPurchase/loadBOMNumber', {bomId: this.$route.params.id})
  454. if (response.data.data.successAmount && response.data.data.successAmount > 0) {
  455. this.$router.push('/applyPurchase/result?status=success&count=' + response.data.data.successAmount)
  456. } else {
  457. this.$router.push('/applyPurchase/result?status=error')
  458. }
  459. } else {
  460. // this.$message.error(response.data.message)
  461. this.$router.push('/applyPurchase/result?status=error')
  462. }
  463. }, err => {
  464. console.log(err)
  465. this.$message.error('系统错误')
  466. })
  467. })
  468. },
  469. onCheck: function (index) {
  470. if (typeof index === 'undefined') {
  471. let isCheckedAll = true
  472. for (let i = 0; i < this.bomList.content.length; i++) {
  473. if (!this.bomList.content[i].checked) {
  474. isCheckedAll = false
  475. break
  476. }
  477. }
  478. this.setAllCheck(!isCheckedAll)
  479. this.isCheckAll = !isCheckedAll
  480. }
  481. },
  482. setAllCheck: function (flag) {
  483. for (let i = 0; i < this.bomList.content.length; i++) {
  484. this.bomList.content[i].checked = flag
  485. }
  486. },
  487. cancelModifyItem: function () {
  488. for (let i = 0; i < this.bomList.content.length; i++) {
  489. if (this.bomList.content[i].active) {
  490. this.$message.error('抱歉,您尚有未保存的信息')
  491. return false
  492. }
  493. this.bomList.content[i].active = false
  494. }
  495. return true
  496. },
  497. modifyItem: function (index) {
  498. if (!this.cancelModifyItem()) {
  499. return
  500. }
  501. this.cancelShowSpotGoods()
  502. // this.$set(this.bomList.content[index], 'active', true)
  503. this.bomList.content[index].active = true
  504. let _this = this
  505. this.initModifyObj()
  506. this.initValidObj()
  507. for (let attr in this.bomList.content[index]) {
  508. // console.log(attr + ':' + _this.bomList.content[index][attr])
  509. _this.$set(_this.modifyObj, attr, _this.bomList.content[index][attr])
  510. // _this.modifyObj[attr] = _this.bomList.content[index][attr]
  511. }
  512. // this.modifyObj = this.bomList.content[index]
  513. this.modifyObj.deadline = this.bomList.content[index].deadline ? this.bomList.content[index].deadline : ''
  514. },
  515. cancelModify: function (index) {
  516. this.bomList.content[index].active = false
  517. },
  518. // getDate: function (input) {
  519. // const d = new Date(input)
  520. // const year = d.getFullYear()
  521. // const monthTemp = d.getMonth() + 1
  522. // const month = monthTemp < 10 ? '0' + monthTemp : '' + monthTemp
  523. // const day = d.getDate() < 10 ? '0' + d.getDate() : '' + d.getDate()
  524. // return year + '-' + month + '-' + day
  525. // },
  526. // validDate: function (timestamp) {
  527. // let now = new Date().getTime()
  528. // return timestamp - now <= 1000 * 60 * 60 * 24 * 90 && timestamp - now > 0
  529. // },
  530. submitModify: function (index) {
  531. let checkValid = this.checkAll()
  532. if (this.getSingleValidInfo(this.modifyObj) && checkValid) {
  533. if (!this.modifyObj.unitPrice) {
  534. this.modifyObj.currency = null
  535. }
  536. this.modifyObj.code = this.modifyObj.code.trim()
  537. delete this.modifyObj.brandWord
  538. delete this.modifyObj.codeWord
  539. this.$http.put('/seek/updateSeekPurchaseByBatch', this.modifyObj)
  540. .then(response => {
  541. if (response.data.success) {
  542. this.reloadData()
  543. this.$message.success('修改成功')
  544. // this.bomList.content[index].active = false
  545. } else {
  546. this.$message.error('修改失败')
  547. }
  548. }, err => {
  549. console.log(err)
  550. this.$message.error('系统错误')
  551. })
  552. } else {
  553. if (!checkValid) {
  554. // if (!this.validObj.deadline) {
  555. // if (!this.isValidDate(this.modifyObj.deadline)) {
  556. // this.$message.error('截止日期需在90天以内')
  557. // } else {
  558. // this.$message.error('截止日期不能为空')
  559. // }
  560. // } else
  561. if (!this.validObj.amount || !this.validObj.unitPrice) {
  562. this.$message.error('请输入正确的数值')
  563. }
  564. } else {
  565. this.$message.error('请完善信息')
  566. }
  567. }
  568. },
  569. deleteItem: function (index) {
  570. if (!index && index !== 0) {
  571. let str = ''
  572. for (let i = 0; i < this.bomList.content.length; i++) {
  573. if (this.bomList.content[i].checked) {
  574. str += this.bomList.content[i].id + ','
  575. }
  576. }
  577. let param = {}
  578. if (str.length) {
  579. str = str.substring(0, str.length - 1)
  580. param.spIds = str
  581. this.doDelete(param)
  582. } else {
  583. this.$message.error('请勾选')
  584. return
  585. }
  586. } else {
  587. this.doDelete({spIds: this.bomList.content[index].id})
  588. }
  589. },
  590. doDelete: function (param) {
  591. this.$http.put('/seek/deleteSeekPurchaseByBatch', param)
  592. .then(response => {
  593. if (response.data.success) {
  594. this.listenPage(1)
  595. this.$message.success('删除成功')
  596. } else {
  597. this.$message.error('删除失败')
  598. }
  599. }, err => {
  600. console.log(err)
  601. this.$message.error('系统错误')
  602. })
  603. },
  604. isValidTime: function (time) {
  605. let now = this.baseUtils.getClearDay(this.baseUtils.formatDate(new Date(), 'yyyy-MM-dd'))
  606. return !time || (time >= now && time <= now + 1000 * 60 * 60 * 24 * 91)
  607. },
  608. isValidDate: function (date) {
  609. console.log(date)
  610. let dateTmp = new Date(this.baseUtils.formatDate(new Date(dateTmp), 'yyyy-MM-dd')).getTime()
  611. // this.modifyObj.deadline = date
  612. // console.log(date)
  613. let now = this.baseUtils.getClearDay(this.baseUtils.formatDate(new Date(), 'yyyy-MM-dd'))
  614. // let time = new Date(date).getTime()
  615. return !dateTmp || (dateTmp >= now && dateTmp <= now + 1000 * 60 * 60 * 24 * 91)
  616. },
  617. getSimilarCode: function () {
  618. if (this.modifyObj.code) {
  619. this.$http.get('/search/similarComponents', {params: {keyword: this.modifyObj.code}})
  620. .then(response => {
  621. this.similarCode = response.data
  622. if (response.data.length) {
  623. this.showSimilarCodeList = true
  624. } else {
  625. this.showSimilarCodeList = false
  626. }
  627. })
  628. } else {
  629. this.showSimilarCodeList = false
  630. }
  631. },
  632. getSimilarBrand: function () {
  633. if (this.modifyObj.brand) {
  634. this.$http.get('/search/similarBrands', {params: {keyword: this.modifyObj.brand}})
  635. .then(response => {
  636. this.similarBrand = response.data
  637. if (response.data.length) {
  638. this.showSimilarBrandList = true
  639. } else {
  640. this.showSimilarBrandList = false
  641. }
  642. })
  643. } else {
  644. this.showSimilarBrandList = false
  645. }
  646. },
  647. getSingleValidInfo: function (item) {
  648. // && item.deadline && this.isValidDate(item.deadline)
  649. return item.code && item.brand
  650. },
  651. checkCode: function () {
  652. let code = this.modifyObj.code.trim()
  653. let nullStrFlag = this.baseUtils.checkNullStr(code)
  654. this.validObj.code = code && code !== '' && nullStrFlag
  655. if (!this.validObj.code) {
  656. if (!nullStrFlag) {
  657. this.$message.error('型号输入不合法')
  658. } else {
  659. this.$message.error('型号不能为空')
  660. }
  661. }
  662. return this.validObj.code
  663. },
  664. checkBrand: function () {
  665. let nullStrFlag = this.baseUtils.checkNullStr(this.modifyObj.brand)
  666. this.validObj.brand = this.modifyObj.brand && this.modifyObj.brand !== '' && nullStrFlag
  667. if (!this.validObj.brand) {
  668. if (!nullStrFlag) {
  669. this.$message.error('品牌输入不合法')
  670. } else {
  671. this.$message.error('品牌不能为空')
  672. }
  673. }
  674. return this.validObj.brand
  675. },
  676. checkUnitPrice: function () {
  677. this.validObj.unitPrice = (!this.modifyObj.unitPrice || this.modifyObj.unitPrice === '') ? true : this.modifyObj.unitPrice > 0 && this.modifyObj.unitPrice < 100000000
  678. return this.validObj.unitPrice
  679. },
  680. checkAmount: function () {
  681. this.validObj.amount = (!this.modifyObj.amount || this.modifyObj.amount === '') ? true : this.modifyObj.amount > 0 && this.modifyObj.amount < 1000000000
  682. return this.validObj.amount
  683. },
  684. checkKind: function() {
  685. let nullStrFlag = this.baseUtils.checkNullStr(this.modifyObj.kind)
  686. this.validObj.kind = this.modifyObj.kind && this.modifyObj.kind !== ''
  687. // if (!this.validObj.kind) {
  688. if (!nullStrFlag) {
  689. this.$message.error('物料名称输入不合法')
  690. } else if (!this.validObj.kind) {
  691. this.$message.error('物料名称不能为空')
  692. }
  693. // }
  694. return this.validObj.kind
  695. },
  696. checkSpec: function () {
  697. let nullStrFlag = this.baseUtils.checkNullStr(this.modifyObj.spec)
  698. this.validObj.spec = nullStrFlag
  699. if (!nullStrFlag) {
  700. this.$message.error('规格输入不合法')
  701. }
  702. return this.validObj.spec
  703. },
  704. checkAll: function () {
  705. // && this.checkSpec()
  706. // && this.checkUnitPrice()
  707. // && this.checkDeadline()
  708. return this.checkBrand() && this.checkCode() && this.checkKind() && this.checkAmount()
  709. },
  710. checkDeadline: function () {
  711. this.validObj.deadline = this.modifyObj.deadline && this.modifyObj.deadline !== '' && this.isValidDate(this.modifyObj.deadline)
  712. return this.validObj.deadline
  713. },
  714. onUnitPriceInput: function () {
  715. let price = this.modifyObj.unitPrice
  716. if (price >= 10000) {
  717. this.modifyObj.unitPrice = price.substring(0, 4)
  718. } else if (price.indexOf('.') > -1) {
  719. let arr = price.split('.')
  720. if (arr[0].length > 4) {
  721. this.modifyObj.unitPrice = Number(arr[0].substring(0, 4) + '.' + arr[1])
  722. } else if (arr[1].length > 6) {
  723. this.modifyObj.unitPrice = Number(arr[0] + '.' + arr[1].substring(0, 6))
  724. }
  725. }
  726. },
  727. onProduceDateChange: function () {
  728. if (this.modifyObj.produceDate && this.baseUtils.getRealLen(this.modifyObj.produceDate) > 12) {
  729. this.modifyObj.produceDate = this.baseUtils.cutOutString(this.modifyObj.produceDate, 12)
  730. }
  731. },
  732. onEncapsulationChange: function () {
  733. if (this.modifyObj.encapsulation && this.baseUtils.getRealLen(this.modifyObj.encapsulation) > 20) {
  734. this.modifyObj.encapsulation = this.baseUtils.cutOutString(this.modifyObj.encapsulation, 20)
  735. }
  736. },
  737. onCodeChange: function () {
  738. if ((/[^\x00-\xff]/g).test(this.modifyObj.code)) {
  739. let chineseIndex = -1
  740. for (let i = 0; i < this.modifyObj.code.length; i++) {
  741. if ((/[^\x00-\xff]/g).test(this.modifyObj.code.charAt(i))) {
  742. chineseIndex = i
  743. break
  744. }
  745. }
  746. this.modifyObj.code = this.baseUtils.cutOutString(this.modifyObj.code, chineseIndex)
  747. } else if (this.modifyObj.code && this.baseUtils.getRealLen(this.modifyObj.code) > 100) {
  748. this.modifyObj.code = this.baseUtils.cutOutString(this.modifyObj.code, 100)
  749. } else {
  750. this.getSimilarCode()
  751. }
  752. },
  753. onBrandChange: function () {
  754. this.modifyObj.brand = this.modifyObj.brand.trim()
  755. if ((/[^\x00-\xff]/g).test(this.modifyObj.brand)) {
  756. let chineseIndex = -1
  757. for (let i = 0; i < this.modifyObj.brand.length; i++) {
  758. if ((/[^\x00-\xff]/g).test(this.modifyObj.brand.charAt(i)) && !(/[\u4e00-\u9fa5]/).test(this.modifyObj.brand.charAt(i))) {
  759. chineseIndex = i
  760. break
  761. }
  762. }
  763. if (chineseIndex > -1) {
  764. this.modifyObj.brand = this.modifyObj.brand.substring(0, chineseIndex)
  765. }
  766. } else if (this.modifyObj.brand && this.baseUtils.getRealLen(this.modifyObj.brand) > 50) {
  767. this.modifyObj.brand = this.baseUtils.cutOutString(this.modifyObj.brand, 50)
  768. }
  769. this.getSimilarBrand()
  770. },
  771. onProdTitleInput: function () {
  772. if (this.modifyObj.kind && this.baseUtils.getRealLen(this.modifyObj.kind) > 40) {
  773. this.modifyObj.kind = this.baseUtils.cutOutString(this.modifyObj.kind, 40)
  774. }
  775. },
  776. onSpecInput: function () {
  777. if (this.modifyObj.spec && this.baseUtils.getRealLen(this.modifyObj.spec) > 100) {
  778. this.modifyObj.spec = this.baseUtils.cutOutString(this.modifyObj.spec, 100)
  779. }
  780. },
  781. onAmountInput: function () {
  782. if (!(/^[0-9]*$/).test(this.modifyObj.amount)) {
  783. let chineseIndex = -1
  784. for (let i = 0; i < this.modifyObj.amount.length; i++) {
  785. if (!(/^[0-9]*$/).test(this.modifyObj.amount.charAt(i))) {
  786. chineseIndex = i
  787. break
  788. }
  789. }
  790. this.modifyObj.amount = this.baseUtils.cutOutString(this.modifyObj.amount, chineseIndex)
  791. } else if (this.modifyObj.amount.length > 9) {
  792. this.modifyObj.amount = this.baseUtils.cutOutString(this.modifyObj.amount, 9)
  793. }
  794. },
  795. setCode: function (code) {
  796. this.modifyObj.code = code
  797. this.showSimilarCodeList = false
  798. },
  799. setBrand: function (brand) {
  800. this.modifyObj.brand = brand
  801. this.showSimilarBrandList = false
  802. },
  803. setShowCodeWord: function (index, event) {
  804. event.stopPropagation()
  805. for (let i = 0; i < this.bomList.content.length; i++) {
  806. if (i !== index) {
  807. this.bomList.content[i].showCodeWord = false
  808. }
  809. this.bomList.content[i].showBrandWord = false
  810. }
  811. this.bomList.content[index].showCodeWord = !this.bomList.content[index].showCodeWord
  812. },
  813. setShowBrandWord: function (index, event) {
  814. event.stopPropagation()
  815. for (let i = 0; i < this.bomList.content.length; i++) {
  816. if (i !== index) {
  817. this.bomList.content[i].showBrandWord = false
  818. }
  819. this.bomList.content[i].showCodeWord = false
  820. }
  821. this.bomList.content[index].showBrandWord = !this.bomList.content[index].showBrandWord
  822. },
  823. modifyItemByWord: function (index, param, type) {
  824. if (type === 'code') {
  825. this.bomList.content[index].code = param
  826. this.requestModify(this.bomList.content[index])
  827. } else if (type === 'brand') {
  828. this.bomList.content[index].brand = param
  829. this.requestModify(this.bomList.content[index])
  830. } else {
  831. this.$message.error('修改失败')
  832. }
  833. },
  834. requestModify: function (item) {
  835. this.$http.put('/seek/updateSeekPurchaseByBatch', item)
  836. .then(response => {
  837. if (response.data.success) {
  838. this.$message.success('修改成功')
  839. } else {
  840. this.$message.error('修改失败')
  841. }
  842. this.reloadData()
  843. }, err => {
  844. console.log(err)
  845. this.$message.error('系统错误')
  846. // this.reloadData()
  847. })
  848. },
  849. cancelShowSpotGoods: function () {
  850. for (let i = 0; i < this.bomList.content.length; i++) {
  851. this.bomList.content[i].showSpotGoods = false
  852. }
  853. },
  854. setShowSpotGoods: function (flag, item) {
  855. if (flag && item && item.spotGoods.length) {
  856. this.spotGoodsData = item.spotGoods
  857. this.initFragments()
  858. }
  859. if (!this.cancelModifyItem()) {
  860. return
  861. }
  862. this.cancelShowSpotGoods()
  863. item.showSpotGoods = flag
  864. },
  865. initFragment: function (commodity) {
  866. if (!commodity) {
  867. return {}
  868. }
  869. let fragment = {}
  870. let prices = commodity.prices[0]
  871. fragment.num = commodity.minBuyQty
  872. fragment.prices = prices
  873. if (commodity.currencyName !== 'USD') {
  874. fragment.currency = 'RMB'
  875. } else {
  876. fragment.currency = 'USD'
  877. }
  878. if (fragment.currency !== 'USD') {
  879. fragment.price = prices.rMBPrice
  880. } else {
  881. fragment.price = prices.uSDPrice
  882. }
  883. fragment.canAdd = true
  884. fragment.canSub = false
  885. return fragment
  886. },
  887. initFragments: function () {
  888. for (let i = 0; i < this.spotGoodsData.length; i++) {
  889. this.fragments.push(this.initFragment(this.spotGoodsData[i]))
  890. }
  891. },
  892. getFragment: function (commodity, fragment) {
  893. // 判断是否小于第一分段的起订量
  894. if (commodity.prices[0].start > fragment.num) {
  895. fragment.num = commodity.prices[0].start
  896. }
  897. // 获取分段的信息
  898. let prices = commodity.prices
  899. for (let i = 0; i < prices.length; i++) {
  900. if (fragment.num <= prices[i].end) {
  901. fragment.prices = prices[i]
  902. break
  903. }
  904. }
  905. },
  906. onInput: function (index) {
  907. let prices = this.spotGoodsData[index].prices
  908. if (prices && prices.length) {
  909. for (let i = 0; i < prices.length; i++) {
  910. if (this.fragments[index].num >= prices[i].start && this.fragments[index].num <= prices[i].end) {
  911. this.fragments[index].price = this.fragments[index].currency === 'RMB' ? prices[i].rMBPrice : prices[i].uSDPrice
  912. break
  913. }
  914. }
  915. }
  916. },
  917. changeNum: function (newNum, index) {
  918. let pack = this.spotGoodsData[index].perQty || this.spotGoodsData[index].minPackQty
  919. let buy = this.spotGoodsData[index].minBuyQty
  920. let reserve = this.spotGoodsData[index].reserve
  921. let breakUp = this.spotGoodsData[index].breakUp
  922. let nowFragment = this.fragments[index]
  923. if (!newNum) {
  924. nowFragment.num = buy
  925. } else {
  926. newNum = parseInt(newNum)
  927. if (breakUp) {
  928. if (newNum < buy) {
  929. this.$message.error('最小起订量为' + buy)
  930. nowFragment.num = buy
  931. nowFragment.canSub = false
  932. nowFragment.canAdd = true
  933. } else if (newNum > reserve) {
  934. this.$message.error('库存不足')
  935. nowFragment.num = reserve
  936. nowFragment.canAdd = false
  937. nowFragment.canSub = true
  938. } else {
  939. nowFragment.canSub = true
  940. nowFragment.canAdd = true
  941. nowFragment.num = newNum
  942. newNum === buy && (nowFragment.canSub = false)
  943. newNum === reserve && (nowFragment.canAdd = false)
  944. }
  945. } else {
  946. if (newNum < buy) {
  947. this.$message.error('最小起订量为' + buy)
  948. nowFragment.num = buy
  949. nowFragment.canSub = false
  950. if (newNum > reserve) {
  951. this.$message.error('库存不足')
  952. nowFragment.num = reserve - (reserve % pack)
  953. nowFragment.canAdd = false
  954. }
  955. } else if (newNum > reserve) {
  956. nowFragment.canSub = true
  957. nowFragment.canAdd = false
  958. this.$message.error('库存不足')
  959. nowFragment.num = reserve - (reserve % pack)
  960. } else {
  961. nowFragment.canSub = true
  962. nowFragment.canAdd = true
  963. let remainder = newNum % pack
  964. if (remainder !== 0) {
  965. this.$message.error('不支持拆包且包装量为' + pack)
  966. let res = (Math.floor(newNum / pack) + 1) * pack
  967. nowFragment.num = res > reserve ? Math.floor(newNum / pack) * pack : res
  968. } else {
  969. nowFragment.num = newNum
  970. }
  971. newNum === buy && (nowFragment.canSub = false)
  972. newNum === reserve && (nowFragment.canAdd = false)
  973. }
  974. }
  975. }
  976. },
  977. subNum: function (index) {
  978. let nowFragment = this.fragments[index]
  979. if (nowFragment.canSub) {
  980. let pack = this.spotGoodsData[index].perQty || this.spotGoodsData[index].minPackQty
  981. let newNum = 0
  982. if (this.spotGoodsData[index].breakUp) {
  983. newNum = nowFragment.num - 1
  984. } else {
  985. newNum = nowFragment.num - pack
  986. }
  987. this.changeNum(newNum, index)
  988. this.getFragment(this.spotGoodsData[index], nowFragment)
  989. this.onInput(index)
  990. } else {
  991. this.$message.error('该商品最少购买' + this.spotGoodsData[index].minBuyQty + '件')
  992. }
  993. },
  994. addNum: function (index) {
  995. let nowFragment = this.fragments[index]
  996. if (nowFragment.canAdd) {
  997. let pack = this.spotGoodsData[index].perQty || this.spotGoodsData[index].minPackQty
  998. let newNum = 0
  999. if (this.spotGoodsData[index].breakUp) {
  1000. newNum = nowFragment.num + 1
  1001. } else {
  1002. newNum = nowFragment.num + pack
  1003. }
  1004. this.changeNum(newNum, index)
  1005. this.getFragment(this.spotGoodsData[index], nowFragment)
  1006. this.onInput(index)
  1007. } else {
  1008. this.$message.error('库存不足')
  1009. }
  1010. },
  1011. inputNum: function (index) {
  1012. if ((/^[\d]*$/).test(this.fragments[index].num)) {
  1013. this.changeNum(this.fragments[index].num, index)
  1014. this.getFragment(this.spotGoodsData[index], this.fragments[index])
  1015. } else {
  1016. this.message.error('请输入整数')
  1017. this.fragments[index].num = this.spotGoodsData[index].minBuyQty
  1018. }
  1019. this.onInput(index)
  1020. },
  1021. buyNow: function (goods, index) {
  1022. this.$http.post('/trade/order/buyNow', [{
  1023. uuid: goods.uuid,
  1024. batchCode: goods.batchCode,
  1025. number: this.fragments[index].num,
  1026. storeid: goods.storeid ? goods.storeid : goods.storeId,
  1027. storeUuid: goods.storeid ? goods.storeid : goods.storeId,
  1028. currencyName: goods.currencyName,
  1029. minPackQty: goods.minPackQty
  1030. }])
  1031. .then(response => {
  1032. if (response.data.success) {
  1033. if (response.data.message) {
  1034. this.$message({
  1035. message: response.data.message,
  1036. type: 'success'
  1037. })
  1038. window.setTimeout(function () {
  1039. window.open('/user#/order/pay/' + this.baseUtils.enidfilter(response.data.data.orderid))
  1040. }, 1000)
  1041. } else {
  1042. window.open('/user#/order/pay/' + this.baseUtils.enidfilter(response.data.data.orderid))
  1043. }
  1044. } else {
  1045. if (response.data.data && response.data.data.unvailable === 1) {
  1046. this.$message.error('产品信息已失效,请刷新页面')
  1047. } else {
  1048. this.$message.error(response.data.message)
  1049. }
  1050. }
  1051. }, err => {
  1052. console.log(err)
  1053. if (goods.minBuyQty > goods.reserve) {
  1054. this.$message.error('商品' + goods.code + '的库存已经不满足最小起订量')
  1055. }
  1056. })
  1057. },
  1058. linkSaler: function (commodity) {
  1059. // 获得窗口的垂直位置
  1060. let iTop = (window.screen.availHeight - 30 - 780) / 2
  1061. // 获得窗口的水平位置
  1062. let iLeft = (window.screen.availWidth - 10 - 1030) / 2
  1063. if (this.tab.close) {
  1064. this.tab.close()
  1065. }
  1066. let newTab = window.open('', '即时对话框', 'height=750, width=1000, top=' + iTop + ', left=' + iLeft + ', toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, status=no')
  1067. newTab.close()
  1068. newTab = window.open('', '即时对话框', 'height=750, width=1000, top=' + iTop + ', left=' + iLeft + ', toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, status=no')
  1069. this.$store.dispatch('chat/setChatTab', {tab: newTab})
  1070. this.$http.get('/basic/enterprise/' + commodity.enUU + '/info')
  1071. .then(response => {
  1072. let obj = {}
  1073. obj.userPhone = this.user.data.userTel
  1074. obj.userType = 'ENTERPRISE'
  1075. this.user.data.enterprises.forEach(function (item, index) {
  1076. if (item.current) {
  1077. obj.enUU = item.uu
  1078. obj.enterprise = {enUU: item.uu, name: item.enName}
  1079. }
  1080. })
  1081. obj.otherEnUU = response.data.uu
  1082. obj.otherUserType = 'STORE'
  1083. obj.otherEnterprise = {enUU: response.data.uu, name: response.data.enName}
  1084. obj.type = 'CHAT'
  1085. if (!(/^1\d{10}$/).test(response.data.enTel)) {
  1086. this.$http.get('/basic/enterprise/' + response.data.uu + '/admin').then(response => {
  1087. obj.toPhone = response.data.userTel
  1088. this.openWebChat(newTab, obj)
  1089. }, err => {
  1090. console.log(err)
  1091. this.$message.error('暂无卖家管理员手机号!')
  1092. })
  1093. } else {
  1094. obj.toPhone = response.data.enTel
  1095. this.openWebChat(newTab, obj)
  1096. }
  1097. }, err => {
  1098. console.log(err)
  1099. })
  1100. },
  1101. openWebChat: function (newTab, obj) {
  1102. this.$http.post('https://im.ubtob.com/api/chat/infos?condition=chat_info', obj)
  1103. .then(response => {
  1104. if (response.data.success) {
  1105. newTab.location.href = 'https://im.ubtob.com/chat/visit?gid=' + response.data.content
  1106. } else {
  1107. newTab.close()
  1108. this.$message.error(response.data.message)
  1109. }
  1110. })
  1111. }
  1112. },
  1113. created() {
  1114. // noDetail
  1115. this.$http.get('/seek/bom/noDetail?bomId=' + this.$route.params.id).then(res => {
  1116. this.bomInfo = res.data
  1117. })
  1118. }
  1119. }
  1120. </script>
  1121. <style lang="scss">
  1122. .batch-publish {
  1123. margin: 0 auto;
  1124. width: 1190px;
  1125. .red-text {
  1126. color: #ff0000;
  1127. }
  1128. .blue-text {
  1129. color: #3c7cf5;
  1130. }
  1131. .over-ell {
  1132. overflow: hidden;
  1133. text-overflow: ellipsis;
  1134. white-space: nowrap;
  1135. }
  1136. div.batch-publish-top {
  1137. margin: 30px 0 0 0;
  1138. font-size: 16px;
  1139. /*height: 60px;*/
  1140. line-height: 60px;
  1141. background: #f7f9fd;
  1142. padding-left: 24px;
  1143. position: relative;
  1144. .modify-btn {
  1145. position: absolute;
  1146. right: 20px;
  1147. top: 40px;
  1148. font-size: 14px;
  1149. width: 126px;
  1150. height: 34px;
  1151. line-height: 34px;
  1152. text-align: center;
  1153. border-radius: 2px;
  1154. color: #fff;
  1155. background: #ff8522;
  1156. }
  1157. > img {
  1158. width: 23px;
  1159. height: 31px;
  1160. margin-right: 12px;
  1161. }
  1162. .w50 {
  1163. width: 50%;
  1164. float: left
  1165. }
  1166. input {
  1167. height: 28px;
  1168. line-height: 28px;
  1169. color: #333;
  1170. border-radius: 5px;
  1171. font-size: 14px;
  1172. border: 1px solid #ddd;
  1173. }
  1174. input.text {
  1175. width: 280px;
  1176. text-indent: 12px;
  1177. }
  1178. }
  1179. .list-wrap {
  1180. padding: 30px 0 72px 0;
  1181. margin: 26px 0 109px 0;
  1182. -webkit-box-shadow: 0 0 3px #e2eae8;
  1183. -moz-box-shadow: 0 0 3px #e2eae8;
  1184. box-shadow: 0 0 3px #e2eae8;
  1185. .list-content {
  1186. width: 1150px;
  1187. margin: 0 auto;
  1188. table-layout: fixed;
  1189. > thead {
  1190. tr {
  1191. th {
  1192. background: #89aefa;
  1193. color: #fff;
  1194. font-weight: normal;
  1195. height: 40px;
  1196. line-height: 40px;
  1197. text-align: center;
  1198. .com-check-box {
  1199. margin-right: 2px;
  1200. }
  1201. i {
  1202. margin-right: 3px;
  1203. }
  1204. }
  1205. }
  1206. }
  1207. > tbody {
  1208. > tr {
  1209. height: 101px;
  1210. text-align: center;
  1211. border : {
  1212. bottom: 1px solid #bcd2ff;
  1213. left: 1px solid #bcd2ff;
  1214. right: 1px solid #bcd2ff;
  1215. }
  1216. &:hover {
  1217. background: #f1f5ff;
  1218. }
  1219. > td {
  1220. position: relative;
  1221. .prod-items {
  1222. height: 100px;
  1223. padding-top: 17px;
  1224. .prod-item {
  1225. position: relative;
  1226. display: inline-block;
  1227. height: 30px;
  1228. line-height: 30px;
  1229. float: left;
  1230. &:nth-child(2) {
  1231. margin-top: 9px;
  1232. margin-right: 0;
  1233. }
  1234. .pi-title {
  1235. display: inline-block;
  1236. vertical-align: middle;
  1237. text-align: right;
  1238. color: #999;
  1239. .red-text {
  1240. margin-right: 3px;
  1241. }
  1242. }
  1243. .pi-content {
  1244. display: inline-block;
  1245. text-align: left;
  1246. vertical-align: middle;
  1247. }
  1248. &.prod-item-large {
  1249. .pi-content {
  1250. width: 224px;
  1251. }
  1252. .pi-title {
  1253. width: 117px;
  1254. }
  1255. }
  1256. &.prod-item-small {
  1257. .pi-content {
  1258. width: 105px;
  1259. }
  1260. .pi-title {
  1261. width: 70px;
  1262. }
  1263. }
  1264. > ul {
  1265. line-height: normal;
  1266. position: absolute;
  1267. top: 31px;
  1268. left: 115px;
  1269. background: #fff;
  1270. border: 1px solid #b5b5b5;
  1271. z-index: 1;
  1272. max-height: 120px;
  1273. overflow-y: auto;
  1274. overflow-x: hidden;
  1275. border-radius: 2px;
  1276. width: 224px;
  1277. li {
  1278. height: 30px;
  1279. line-height: 30px;
  1280. cursor: pointer;
  1281. overflow: hidden;
  1282. text-overflow: ellipsis;
  1283. white-space: nowrap;
  1284. padding: 0 5px;
  1285. text-align: left;
  1286. &:hover {
  1287. background: #89aefa;
  1288. color: #fff;
  1289. }
  1290. }
  1291. }
  1292. }
  1293. }
  1294. .similar-select {
  1295. width: 145px;
  1296. margin: 0 auto;
  1297. border: 1px solid #b5b5b5;
  1298. height: 30px;
  1299. line-height: 30px;
  1300. overflow-y: hidden;
  1301. padding: 0 22px 0 5px;
  1302. background: url('/images/all/select-icon-full.png') no-repeat;
  1303. background-color: #fff;
  1304. background-position: 194px 10px;
  1305. cursor: default;
  1306. border-radius: 2px;
  1307. & + ul {
  1308. width: 145px;
  1309. top: 48px;
  1310. left: 12px;
  1311. &.brand-word-list {
  1312. left: 7px;
  1313. }
  1314. }
  1315. }
  1316. &.operate {
  1317. text-align: left;
  1318. font-size: 12px;
  1319. a {
  1320. color: #3c7cf5;
  1321. margin-left: 5px;
  1322. &.size-s {
  1323. padding: 4px 12px;
  1324. }
  1325. &.size-m {
  1326. padding: 4px 7px;
  1327. }
  1328. &:hover {
  1329. color: #fff;
  1330. background: #3c7cf5;
  1331. border-radius: 3px;
  1332. }
  1333. &.btn-ok {
  1334. background: #ff8522;
  1335. color: #fff;
  1336. border-radius: 3px;
  1337. }
  1338. }
  1339. }
  1340. .remind {
  1341. font-size: 12px;
  1342. }
  1343. }
  1344. &.spot-goods {
  1345. background: #fff;
  1346. > td {
  1347. .spot-goods-body {
  1348. .spot-goods-title {
  1349. height: 36px;
  1350. line-height: 36px;
  1351. background: #414140;
  1352. color: #fff;
  1353. }
  1354. table {
  1355. width: 1130px;
  1356. margin-left: 9px;
  1357. table-layout: fixed;
  1358. thead tr th {
  1359. text-align: center;
  1360. height: 34px;
  1361. line-height: 34px;
  1362. background: #fce8df;
  1363. font-weight: normal;
  1364. }
  1365. }
  1366. .spot-goods-list {
  1367. max-height: 250px;
  1368. overflow-y: auto;
  1369. overflow-x: hidden;
  1370. table {
  1371. margin-bottom: 10px;
  1372. tbody tr {
  1373. border: 1px solid #fce8df;
  1374. &:nth-child(even) {
  1375. background: #fdf8f5;
  1376. }
  1377. td {
  1378. height: 48px;
  1379. line-height: 48px;
  1380. &.input-number {
  1381. > div {
  1382. position: relative;
  1383. width: 100px;
  1384. margin: 0 auto;
  1385. span {
  1386. width: 17px;
  1387. height: 26px;
  1388. background: #4290f7;
  1389. line-height: 26px;
  1390. color: #fff;
  1391. display: inline-block;
  1392. font-size: 16px;
  1393. vertical-align: middle;
  1394. position: absolute;
  1395. top: 12px;
  1396. cursor: pointer;
  1397. &.not-allowed {
  1398. cursor: not-allowed;
  1399. background: #d7d5d5;
  1400. }
  1401. &:first-child {
  1402. left: -7px;
  1403. }
  1404. &:last-child {
  1405. right: -7px;
  1406. }
  1407. }
  1408. input {
  1409. width: 81px;
  1410. height: 26px;
  1411. text-align: center;
  1412. line-height: normal;
  1413. vertical-align: middle;
  1414. outline: none;
  1415. border: 1px solid #d1d0d0;
  1416. padding: 0 5px;
  1417. }
  1418. }
  1419. }
  1420. &.operate {
  1421. a {
  1422. color: #5078cb;
  1423. font-size: 12px;
  1424. }
  1425. span {
  1426. display: inline-block;
  1427. width: 64px;
  1428. height: 24px;
  1429. line-height: 24px;
  1430. text-align: center;
  1431. background: #4290f7;
  1432. color: #fff;
  1433. margin-left: 13px;
  1434. cursor: pointer;
  1435. font-size: 12px;
  1436. border-radius: 2px;
  1437. }
  1438. }
  1439. }
  1440. }
  1441. }
  1442. }
  1443. }
  1444. }
  1445. }
  1446. &.modify-row {
  1447. td {
  1448. input, select {
  1449. height: 30px;
  1450. border-radius: 2px;
  1451. border: 1px solid #dadada;
  1452. text-align: center;
  1453. padding: 0 5px;
  1454. display: inline-block;
  1455. &.error {
  1456. border-color: #f4645f !important;
  1457. }
  1458. }
  1459. input:focus {
  1460. -webkit-box-shadow: none;
  1461. -moz-box-shadow: none;
  1462. box-shadow: none;
  1463. border: 1px solid #3c7cf5;
  1464. }
  1465. .prod-item {
  1466. position: relative;
  1467. &.prod-item-large {
  1468. input {
  1469. width: 224px;
  1470. }
  1471. }
  1472. &.prod-item-small {
  1473. input {
  1474. width: 105px;
  1475. }
  1476. }
  1477. &.pi-select {
  1478. input {
  1479. width: 103px;
  1480. padding: 0 5px 0 30px;
  1481. }
  1482. select {
  1483. width: 25px;
  1484. padding: 0 0 0 2px;
  1485. background: url(/images/applyPurchase/select2.png) no-repeat right;
  1486. background-size: 12px 28px;
  1487. background-position: 12px 0;
  1488. position: absolute;
  1489. top: 1px;
  1490. border-bottom: none;
  1491. border-top: none;
  1492. border-left: 0;
  1493. }
  1494. }
  1495. }
  1496. &:nth-child(2) {
  1497. input {
  1498. width: 83px;
  1499. }
  1500. }
  1501. &:nth-child(3) {
  1502. input {
  1503. width: 90px;
  1504. }
  1505. }
  1506. &:nth-child(4) {
  1507. div {
  1508. width: 125px;
  1509. overflow: unset;
  1510. input {
  1511. width: 115px;
  1512. border-radius: 2px;
  1513. border: 1px solid #dadada;
  1514. }
  1515. }
  1516. }
  1517. }
  1518. }
  1519. }
  1520. }
  1521. }
  1522. .submit-area {
  1523. margin: 51px auto 0;
  1524. text-align: center;
  1525. clear: both;
  1526. a {
  1527. display: inline-block;
  1528. width: 126px;
  1529. height: 34px;
  1530. line-height: 34px;
  1531. text-align: center;
  1532. border-radius: 2px;
  1533. color: #fff;
  1534. background: #ff8522;
  1535. }
  1536. }
  1537. }
  1538. }
  1539. </style>