create.blade.php 64 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076
  1. @extends('layouts.app')
  2. @section('title')录入-退货管理@endsection
  3. @section('content')
  4. <div id="nav2">
  5. @component('rejected.menu')@endcomponent
  6. </div>
  7. <div class="container-fluid d-none" id="editPanel">
  8. <div class="card mb-2">
  9. <div style="position: relative" v-if="status.lockingBillPanel">
  10. <div style="background-color: #aaa; height: 535px; opacity: 0.5;
  11. width:100%;z-index: 9; position: absolute" class="d-flex ">
  12. </div>
  13. <div style="height: 550px;
  14. width:100%;z-index: 10; position: absolute" class="d-flex align-items-center ">
  15. <button class="btn btn-info flex-fill" @click="cancelPackCommitEdit">取消锁定</button>
  16. </div>
  17. </div>
  18. <div class="row">
  19. <div class="col-7">
  20. <div class="card-body">
  21. <div class="list-group" style="max-height: 477px;overflow-y: scroll">
  22. <table class="table table-sm table-striped table-info table-hover table-bordered">
  23. <tr>
  24. <th>创建时间</th>
  25. <th>客户名称</th>
  26. <th>退回单号</th>
  27. <th>退回公司</th>
  28. <th>姓名</th>
  29. <th>电话</th>
  30. <th>到付费用</th>
  31. <th>订单号</th>
  32. <th>原单号</th>
  33. <th>是否入库</th>
  34. {{-- <th>备注</th>--}}
  35. <th>操作</th>
  36. </tr>
  37. <tr :class="[rejectedBill.isEditing?'bg-info':'']"
  38. v-for="rejectedBill in rejectedBills" :data-id="rejectedBill.id" @click="editBill">
  39. <td>@{{rejectedBill.created_at | dateNoYear}}</td>
  40. <td>@{{rejectedBill.owner_name }}</td>
  41. <td>@{{rejectedBill.logistic_number_return }}</td>
  42. <td>@{{rejectedBill.logistic_name}}</td>
  43. <td>@{{rejectedBill.sender}}</td>
  44. <td>@{{rejectedBill.mobile_sender}}</td>
  45. <td>@{{rejectedBill.fee_collected}}</td>
  46. <td>@{{rejectedBill.order_number}}</td>
  47. <td>@{{rejectedBill.logistic_number}}</td>
  48. <td>@{{rejectedBill.is_loaded|isLoaded}}</td>
  49. {{-- <td>@{{rejectedBill.remark}}</td>--}}
  50. @can('退货管理-删除')<td><button class="btn btn-sm btn-outline-danger" @click.stop="deleteBill(rejectedBill)">删</button></td>@endcan
  51. </tr>
  52. </table>
  53. </div>
  54. </div>
  55. </div>
  56. <div class="col-5 disabled">
  57. <div class="card-body ml-n4">
  58. <table class="table table-striped table-sm table-bordered" :class="[status.billEditing?'bg-info':'']">
  59. <tr>
  60. <td>
  61. <div class="form-group mb-0">
  62. <label for="id_owner" class="col-form-label text-right">客户名称</label>
  63. <div class="input-group">
  64. <select name="id_owner" id="id_owner" class="form-control" :class="[errors.id_owner?'is-invalid':'']"
  65. v-model="billInputting.id_owner" required data-focusOrder="1">
  66. <option value=""></option>
  67. <option v-for="owner in owners" :value="owner.id">@{{ owner.name }}</option>
  68. </select>
  69. <input type="text" class="form-control input-group-prepend" placeholder="输入关键字定位客户名称"
  70. name="locateOwnerSearch" autocomplete="off" @input="locateIdOwner" v-model="billInputting.locateOwnerSearch">
  71. <span class="invalid-feedback" v-if="errors.id_owner"><strong>@{{ errors.id_owner[0] }}</strong></span>
  72. </div>
  73. </div>
  74. </td>
  75. <td>
  76. <div class="form-group mb-0">
  77. <label for="sender" class="col-form-label text-right">姓名</label>
  78. <input type="text" class="form-control" :class="[errors.sender?'is-invalid':'']"
  79. data-focusOrder="5"
  80. name="sender" id="sender" autocomplete="off" v-model="billInputting.sender">
  81. <span class="invalid-feedback" v-if="errors.sender"><strong>@{{errors.sender[0] }}</strong></span>
  82. </div>
  83. </td>
  84. </tr>
  85. <tr>
  86. <td>
  87. <div class="form-group mb-0">
  88. <label for="logistic_number_return" class="col-form-label text-right">退回单号</label>
  89. <input type="text" class="form-control" :class="[errors.logistic_number_return?'is-invalid':'']"
  90. data-focusOrder="2"
  91. name="logistic_number_return" id="logistic_number_return" autocomplete="off" v-model="billInputting.logistic_number_return"
  92. @change="logistic_number_returnChange"
  93. required>
  94. <span class="invalid-feedback" v-if="errors.logistic_number_return"><strong>@{{errors.logistic_number_return[0] }}</strong></span>
  95. </div>
  96. </td>
  97. <td>
  98. <div class="form-group mb-0">
  99. <label for="fee_collected" class="col-form-label text-right">到付费用</label>
  100. <input type="text" class="form-control" :class="[errors.fee_collected?'is-invalid':'']"
  101. data-focusOrder=""
  102. v-model="billInputting.fee_collected" name="fee_collected" id="fee_collected" autocomplete="off">
  103. <span class="invalid-feedback" v-if="errors.fee_collected"><strong>@{{errors.fee_collected[0] }}</strong></span>
  104. </div>
  105. </td>
  106. </tr>
  107. <tr>
  108. <td>
  109. <div class="form-group mb-0">
  110. <label for="id_logistic_return" class="col-form-label text-right">退回公司</label>
  111. <div class="input-group">
  112. <select name="id_logistic_return" id="id_logistic_return" class="form-control"
  113. data-focusOrder="3"
  114. :class="[errors.id_logistic_return?'is-invalid':'']" v-model="billInputting.id_logistic_return" required>
  115. <option value=""></option>
  116. <option v-for="logistic in logistics" :value="logistic.id">@{{logistic.name}}</option>
  117. </select>
  118. <input type="text" class="form-control input-group-prepend" placeholder="输入关键字定位物流公司"
  119. name="locateLogisticSearch" autocomplete="off" @input="locateLogistic" v-model="billInputting.locateLogisticSearch">
  120. <span class="invalid-feedback" v-if="errors.id_logistic_return"><strong>@{{errors.id_logistic_return[0] }}</strong></span>
  121. </div>
  122. </div>
  123. </td>
  124. <td>
  125. <div class="form-group mb-0">
  126. <label for="order_number" class="col-form-label text-right">订单号</label>
  127. <input type="text" class="form-control" :class="[errors.order_number?'is-invalid':'']"
  128. data-focusOrder="6"
  129. name="order_number" id="order_number" autocomplete="off" v-model="billInputting.order_number">
  130. <span class="invalid-feedback" v-if="errors.order_number"><strong>@{{ errors.order_number[0] }}</strong></span>
  131. </div>
  132. </td>
  133. </tr>
  134. <tr>
  135. <td>
  136. <div class="form-group mb-0">
  137. <label for="mobile_sender" class="col-form-label text-right">电话</label>
  138. <input type="text" class="form-control" :class="[errors.mobile_sender?'is-invalid':'']"
  139. data-focusOrder="4"
  140. name="mobile_sender" id="mobile_sender" autocomplete="off" v-model="billInputting.mobile_sender" required>
  141. <span class="invalid-feedback" v-if="errors.mobile_sender"><strong>@{{ errors.mobile_sender[0] }}</strong></span>
  142. </div>
  143. </td>
  144. <td>
  145. <div class="form-group mb-0">
  146. <label for="logistic_number" class="col-form-label text-right">原单号</label>
  147. <button class="btn btn-outline-primary btn-sm" @click="billInputting.logistic_number='原单退回'" style="transform: scale(0.9)">原单退回</button>
  148. <input type="text" class="form-control" :class="[errors.logistic_number?'is-invalid':'']"
  149. data-focusOrder="7"
  150. name="logistic_number" id="logistic_number" autocomplete="off"
  151. v-model="billInputting.logistic_number"
  152. >
  153. <span class="invalid-feedback" v-if="errors.logistic_number"><strong>@{{errors.logistic_number[0] }}</strong></span>
  154. </div>
  155. </td>
  156. </tr>
  157. <tr>
  158. <td>
  159. <div class="form-group mb-0">
  160. <label for="bill_remark" class="col-form-label text-right">备注</label>
  161. <input type="text" class="form-control" :class="[errors.bill_remark?'is-invalid':'']"
  162. data-focusOrder="9"
  163. name="remark" id="bill_remark" autocomplete="off" v-model="billInputting.remark" required>
  164. <span class="invalid-feedback" v-if="errors.bill_remark"><strong>@{{ errors.remark[0] }}</strong></span>
  165. </div>
  166. </td>
  167. <td>
  168. <div class="form-group mb-0">
  169. <label for="is_loaded" class="col-form-label text-right">是否入库</label>
  170. <div v-if="status.isLoadSign" class="text-danger">系统标计为入库</div>
  171. <select name="is_loaded" id="is_loaded" class="form-control" :class="[errors.is_loaded?'is-invalid':'']"
  172. data-focusOrder="8" :disabled="status.lockingIsLoadedInput"
  173. v-model="billInputting.is_loaded" required>
  174. <option value="0">否</option>
  175. <option value="1">是</option>
  176. <option value="null">无需入库</option>
  177. <option value="3">上传异常</option>
  178. </select>
  179. <span class="invalid-feedback" v-if="errors.is_loaded"><strong>@{{errors.is_loaded[0]}}</strong></span>
  180. </div>
  181. </td>
  182. </tr>
  183. <tr v-if="billInputting.id_owner==='94'">
  184. <td>
  185. <div class="form-group mb-0">
  186. <label for="common_01" class="col-form-label text-right">寄件方省</label>
  187. <input type="text" class="form-control" :class="[errors.common_01?'is-invalid':'']"
  188. data-focusOrder="10"
  189. name="common_01" id="common_01" autocomplete="off" v-model="billInputting.common_01" required>
  190. <span class="invalid-feedback" v-if="errors.common_01"><strong>@{{ errors.common_01[0] }}</strong></span>
  191. </div>
  192. </td>
  193. <td>
  194. <div class="form-group mb-0">
  195. <label for="common_02" class="col-form-label text-right">重量</label>
  196. <input type="text" class="form-control" :class="[errors.common_02?'is-invalid':'']"
  197. data-focusOrder="11"
  198. name="common_02" id="common_02" autocomplete="off" v-model="billInputting.common_02" required>
  199. <span class="invalid-feedback" v-if="errors.common_02"><strong>@{{ errors.common_02[0] }}</strong></span>
  200. </div>
  201. </td>
  202. </tr>
  203. <tr>
  204. <td>
  205. <div class="form-group mb-0 align-items-center row" >
  206. <div class="col-2" v-if="status.billEditing">
  207. <button class="btn btn-success btn-sm tooltipOn" @click="shiftToCreate"
  208. title="点击取消编辑,进入新增状态">取消</button>
  209. </div>
  210. <div class="col-8" :class="[status.billCreating?'offset-2':'']">
  211. <input v-if="status.billCreating" type="button" class="btn btn-success form-control" value="提交新条目" @click="commitHeader">
  212. <input v-if="status.billEditing" type="button" class="btn btn-dark form-control" value="修改" @click="commitEditHeader">
  213. </div>
  214. </div>
  215. </td>
  216. <td>
  217. </td>
  218. </tr>
  219. </table>
  220. </div>
  221. </div>
  222. </div>
  223. </div>
  224. <div class="card" v-if="status.editingBill">
  225. <div class="row">
  226. <div class="col-7">
  227. <div class="card-body">
  228. <div class="list-group">
  229. <table class="table table-sm table-striped table-warning table-hover table-bordered">
  230. <tr>
  231. <th>序号</th>
  232. <th>商品条码</th>
  233. <th>商品名称</th>
  234. <th>数量</th>
  235. <th>是否正品</th>
  236. <th>生产日期</th>
  237. <th>效期</th>
  238. <th>批次号</th>
  239. <th>备注</th>
  240. @can('退货管理-删除')<th></th>@endcan
  241. </tr>
  242. <tr :class="[item.isEditing?'bg-warning':'']"
  243. v-for="(item,i) in items" :data-id="item.id" @click="editItem">
  244. <td>@{{i+1}}</td>
  245. <td>@{{item.barcode_goods }}</td>
  246. <td>@{{item.name_goods }}</td>
  247. <td>@{{item.amount}}</td>
  248. <td>@{{item.quality_label}}</td>
  249. <td>@{{item.made_at}}</td>
  250. <td>@{{item.validity_at}}</td>
  251. <td>@{{item.batch_number}}</td>
  252. <td>@{{item.remark}}</td>
  253. @can('退货管理-删除')<td><button class="btn btn-outline-danger" @click="deleteItem">删</button></td>@endcan
  254. </tr>
  255. </table>
  256. </div>
  257. </div>
  258. </div>
  259. <div class="col-5"><div class="card-body ml-n4">
  260. <table class="table table-striped table-sm table-bordered" :class="[status.itemEditing?'bg-warning':'']">
  261. <tr>
  262. <td>
  263. <div class="form-group mb-0">
  264. <label for="barcode_goods" class="col-form-label text-right">商品条码</label>
  265. <input type="text" class="form-control" :class="[errors.barcode_goods?'is-invalid':'']"
  266. data-focusOrder="11"
  267. name="barcode_goods" id="barcode_goods" autocomplete="off" v-model="itemInputting.barcode_goods"
  268. @change="barcode_goodsChange"
  269. >
  270. <span class="invalid-feedback" v-if="errors.barcode_goods"><strong>@{{errors.barcode_goods[0] }}</strong></span>
  271. </div>
  272. </td>
  273. <td>
  274. <div class="form-group mb-0">
  275. <label for="name_goods" class="col-form-label text-right">商品名称</label>
  276. <input type="text" class="form-control" :class="[errors.name_goods?'is-invalid':'']"
  277. data-focusOrder="14"
  278. name="name_goods" id="name_goods" autocomplete="off" v-model="itemInputting.name_goods"
  279. @change="name_goodsChange"
  280. >
  281. <span class="invalid-feedback" v-if="errors.name_goods"><strong>@{{errors.name_goods[0] }}</strong></span>
  282. </div>
  283. </td>
  284. </tr>
  285. <tr>
  286. <td>
  287. <div class="form-group mb-0">
  288. <label for="amount" class="col-form-label text-right">数量</label>
  289. <input type="" class="form-control" :class="[errors.amount?'is-invalid':'']"
  290. data-focusOrder="12"
  291. name="amount" id="amount" autocomplete="off" v-model="itemInputting.amount" required>
  292. <span class="invalid-feedback" v-if="errors.amount"><strong>@{{errors.amount[0] }}</strong></span>
  293. </div>
  294. </td>
  295. <td>
  296. <div class="form-group mb-0">
  297. <label for="qualityLabel.name" class="col-form-label text-right">是否正品</label>
  298. <div class="form-control" :class="[errors.id_quality_label?'is-invalid':'']">
  299. <span><input id="id_quality_label_space" type="radio" name="id_quality_label"
  300. data-focusOrder="13" required="required" checked><label
  301. for="id_quality_label_space">留空</label>&nbsp;</span>
  302. <span v-for="qualityLabel in qualityLabels">
  303. <input type="radio" name="id_quality_label" :value="qualityLabel.id" data-focusOrder="13"
  304. :id="'id_quality_label_'+qualityLabel.id"
  305. v-model="itemInputting.id_quality_label" required><label
  306. for="'id_quality_label_'+qualityLabel.id">@{{qualityLabel.name}}</label>&nbsp;</span>
  307. </div>
  308. <span class="invalid-feedback" v-if="errors.id_quality_label"><strong>@{{errors.id_quality_label[0] }}</strong></span>
  309. </div>
  310. </td>
  311. </tr>
  312. <tr>
  313. <td>
  314. <div class="form-group mb-0">
  315. <label for="made_at" class="col-form-label text-right">生产日期</label>
  316. <input type="date" class="form-control" :class="[errors.made_at?'is-invalid':'']"
  317. data-focusOrder="16"
  318. name="made_at" id="made_at" autocomplete="off" v-model="itemInputting.made_at">
  319. <span class="invalid-feedback" v-if="errors.made_at"><strong>@{{errors.made_at[0] }}</strong></span>
  320. </div>
  321. </td>
  322. <td>
  323. <div class="form-group mb-0">
  324. <label for="validity_at" class="col-form-label text-right">效期</label>
  325. <input type="date" class="form-control" :class="[errors.validity_at?'is-invalid':'']"
  326. data-focusOrder="17"
  327. name="validity_at" id="validity_at" autocomplete="off" v-model="itemInputting.validity_at">
  328. <span class="invalid-feedback" v-if="errors.validity_at"><strong>@{{errors.validity_at[0] }}</strong></span>
  329. </div>
  330. </td>
  331. </tr>
  332. <tr>
  333. <td>
  334. <div class="form-group mb-0">
  335. <label for="batch_number" class="col-form-label text-right">批次号</label>
  336. <input type="text" class="form-control" :class="[errors.batch_number?'is-invalid':'']"
  337. data-focusOrder="15"
  338. name="batch_number" id="batch_number" autocomplete="off" v-model="itemInputting.batch_number"
  339. >
  340. <span class="invalid-feedback" v-if="errors.batch_number"><strong>@{{errors.batch_number[0] }}</strong></span>
  341. </div>
  342. </td>
  343. <td>
  344. <div class="form-group mb-0">
  345. <label for="remark" class="col-form-label text-right">备注</label>
  346. <input type="text" class="form-control" :class="[errors.remark?'is-invalid':'']"
  347. data-focusOrder="15"
  348. name="remark" id="remark" autocomplete="off" v-model="itemInputting.remark">
  349. <span class="invalid-feedback" v-if="errors.remark"><strong>@{{errors.remark[0] }}</strong></span>
  350. </div>
  351. </td>
  352. </tr>
  353. <tr>
  354. <td>
  355. <div class="form-group mb-0 align-items-center row" >
  356. <div class="col-2" v-if="status.itemEditing">
  357. <button class="btn btn-success btn-sm tooltipOn" @click="shiftToCreateItem"
  358. title="点击取消编辑,进入新增状态">取消</button>
  359. </div>
  360. <div class="col-8" :class="[status.itemCreating?'offset-2':'']">
  361. <button v-if="status.itemCreating" class="btn btn-success form-control" @click="commitItem">添加明细</button>
  362. <input v-if="status.itemEditing" type="button" class="btn btn-dark form-control" value="修改" @click="commitEditItem">
  363. </div>
  364. </div>
  365. </td>
  366. <td>
  367. </td>
  368. </tr>
  369. <tr>
  370. <td colspan="2">
  371. <div class="form-group mb-0">
  372. <div class="col-8 offset-2 mt-2 mb-2">
  373. <button class="btn btn-dark form-control" @click="endAndPackCommitEdit">
  374. 结束添加并提交
  375. </button>
  376. </div>
  377. </div>
  378. </td>
  379. </tr>
  380. </table>
  381. </div>
  382. </div>
  383. </div>
  384. </div>
  385. </div>
  386. @endsection
  387. @section('lastScript')
  388. <script>
  389. let vueList=new Vue({
  390. el: "#editPanel",
  391. data:{
  392. status: {billCreating:true,billEditing:false,itemCreating:true,itemEditing:false
  393. ,editingBill:null,editingBillId:'',editingItem:null,editingItemId:''
  394. ,inputtingId_owner:'',endAndPackCommitEdited:false,lockingBillPanel:false,lockingIsLoadedInput:false,
  395. existItemsBeforeAdd:0},
  396. itemInputting:{
  397. barcode_goods:"",name_goods:"",amount:"1",id_quality_label:"",
  398. batch_number:"",validity_at:"",remark:"",made_at:"",
  399. },
  400. billInputting:{
  401. id_owner:"",mobile_sender:"",sender:"",order_number:"",remark:"",
  402. logistic_number_return:"",logistic_number:"",id_logistic_return:"",
  403. fee_collected:"",is_loaded:"0",locateLogisticSearch:"",locateOwnerSearch:"",
  404. isLoadSign:false,
  405. },
  406. errors:{
  407. id_owner:"",mobile_sender:"",sender:"",bill_remark:"",
  408. logistic_number_return:"",logistic_number:"",id_logistic_return:"",
  409. fee_collected:"",is_loaded:"",
  410. barcode_goods:"",name_goods:"",amount:"",id_quality_label:"",
  411. batch_number:"",validity_at:"",remark:"",made_at:"",
  412. },
  413. rejectedBills:{!! $rejectedBills??[] !!},
  414. items:[
  415. ],
  416. owners:[
  417. @foreach($owners as $owner)
  418. {id:'{{$owner->id}}',name:'{{$owner->name}}',code:'{{$owner->code}}'},
  419. @endforeach
  420. ],
  421. logistics:[
  422. @foreach($logistics as $logistic)
  423. {id:'{{$logistic->id}}',name:'{{$logistic->name}}',code:'{{$logistic->code}}'},
  424. @endforeach
  425. ],
  426. qualityLabels:[
  427. @foreach($qualityLabels as $qualityLabel)
  428. {id:'{{$qualityLabel->id}}',name:'{{$qualityLabel->name}}'},
  429. @endforeach
  430. ],
  431. commodityOwnerId:'',
  432. },
  433. mounted:function () {
  434. let _this=this;
  435. $('#editPanel').removeClass('d-none');
  436. $('.tooltipOn').tooltip({'trigger':'hover'});
  437. $(document).on('keypress',function(e){
  438. if(_this.itemInputting.barcode_goods){
  439. if(e.key==='*'){
  440. _this.commitItem();
  441. return false;
  442. }
  443. }
  444. });
  445. this.listenEnterAndJump();
  446. },
  447. methods:{
  448. logistic_number_returnChange:function(e){
  449. let _this=this;
  450. let number=$(e.target).val();
  451. if(!number)return;
  452. let url='{{"/apiLocal/logistic/numberFeatures/computeLogisticByNumber"}}';
  453. axios.post(url,{logistic_number_return:number}).then(function (response) {
  454. _this.cleanError();
  455. if(response.data.success==='true'){
  456. if(response.data.logistic){
  457. _this.billInputting.id_logistic_return=response.data.logistic.id;
  458. }
  459. }
  460. }).catch(function (response) {
  461. console.log(response);
  462. });
  463. if(_this.status.editingBill)return;
  464. let url_isUnique='{{"/apiLocal/logistic/logisticNumberReturnIsUnique"}}';
  465. axios.post(url_isUnique,{logistic_number_return:number}).then(function (response) {
  466. _this.cleanError();
  467. if(response.data.success==='true'){
  468. if(response.data.result==='true'){
  469. tempTip.okWindow('该退回单号"'+number+'"已有录入其他单','知道了')
  470. }else _this.seek_order();
  471. }
  472. }).catch(function (response) {
  473. console.log(response);
  474. });
  475. },
  476. barcode_goodsChange:function(e){
  477. let _this=this;
  478. let barcode=$(e.target).val();
  479. let url='{{"/apiLocal/commodity/getCommodityByBarcode"}}';
  480. axios.post(url,{barcode:barcode,owner_id:_this.billInputting.id_owner}).then(function (response) {
  481. _this.cleanError();
  482. if(response.data.success==='true'){
  483. if(response.data.commodity){
  484. // _this.itemInputting.name_goods=response.data.name;
  485. _this.itemInputting.name_goods=response.data.commodity.name;
  486. _this.commodityOwnerId=response.data.commodity.owner_id;
  487. }
  488. }else{
  489. tempTip.setDuration(3000);
  490. tempTip.show('查找商品条码错误:'+response.data.fail_info)
  491. }
  492. }).catch(function (response) {
  493. tempTip.setDuration(3000);
  494. tempTip.show('未连接至商品表,检查网络');
  495. });
  496. },
  497. name_goodsChange:function(e){
  498. let _this=this;
  499. let name=$(e.target).val();
  500. this.items.forEach(function(item){
  501. if(item.barcode_goods+''===_this.itemInputting.barcode_goods+''){
  502. item.name_goods=name;
  503. }
  504. });
  505. },
  506. listenEnterAndJump:function(){
  507. let targets=$('select,input');
  508. targets.off('keypress');
  509. targets.on('keypress',function(e){
  510. if(e.key!=="Enter")return;
  511. let target=$(e.target);
  512. let currentOrder = target.attr('data-focusOrder');
  513. if(currentOrder){
  514. targets.each(function($i,$val){
  515. let checkingTarget = $($val);
  516. let checkingOrder = checkingTarget.attr('data-focusOrder');
  517. if(parseInt(currentOrder)+1===parseInt(checkingOrder)){
  518. checkingTarget.focus();
  519. }
  520. })
  521. }
  522. });
  523. targets.off('change');
  524. targets.on('change',function(e){
  525. let target=$(e.target);
  526. let currentOrder = target.attr('data-focusOrder');
  527. if(currentOrder){
  528. targets.each(function($i,$val){
  529. let checkingTarget = $($val);
  530. let checkingOrder = checkingTarget.attr('data-focusOrder');
  531. if(parseInt(currentOrder)+1===parseInt(checkingOrder)){
  532. checkingTarget.focus();
  533. }
  534. })
  535. }
  536. })
  537. },
  538. cleanHeader:function(){
  539. for(let key in this.billInputting){
  540. this.billInputting[key]='';
  541. }
  542. this.billInputting.id_owner=this.status.inputtingId_owner;
  543. this.billInputting.is_loaded="0";
  544. this.billInputting.isLoadSign=false;
  545. },
  546. cleanItem:function(){
  547. for(let key in this.itemInputting){
  548. this.itemInputting[key]='';
  549. }
  550. this.itemInputting['amount']='1';
  551. },
  552. cleanError:function(){
  553. for(let key in this.errors){
  554. this.errors[key]='';
  555. }
  556. },
  557. setEditingBill:function(id){
  558. let _this=this;
  559. this.status.editingBillId=id;
  560. this.rejectedBills.forEach(function (bill) {
  561. if(bill.id+''===id+''){
  562. _this.status.editingBill=bill;
  563. bill.isEditing=true;
  564. }else{
  565. bill.isEditing=false
  566. }
  567. });
  568. this.$forceUpdate();
  569. },
  570. setEditingItem:function(id){
  571. let _this=this;
  572. this.status.editingItemId=id;
  573. this.items.forEach(function (item) {
  574. if(item.id+''===id+''){
  575. _this.status.editingItem=item;
  576. item.isEditing=true;
  577. }else{
  578. item.isEditing=false
  579. }
  580. });
  581. this.$forceUpdate();
  582. },
  583. commitHeader:function () {
  584. let _this=this;
  585. let url='{{url('apiLocal/rejectedBill/store')}}';
  586. tempTip.setDuration(99999);
  587. tempTip.waitingTip('提交中')
  588. axios.post(url,_this.billInputting).then(function (response) {
  589. tempTip.cancelWaitingTip();
  590. _this.cleanError();
  591. if(response.data.success==='true'){
  592. tempTip.setDuration(1000);
  593. tempTip.showSuccess('成功录入退单号:'+_this.billInputting.logistic_number_return);
  594. _this.status.inputtingId_owner=_this.billInputting.id_owner;
  595. _this.setEditingBill(response.data.id);
  596. _this.getItemsUnderBill(response.data.id);
  597. _this.cleanHeader();
  598. _this.getRecentRejectedBills();
  599. _this.lockBillPanel();
  600. _this.status.existItemsBeforeAdd=0;
  601. $('#barcode_goods').focus();
  602. }else{
  603. if(response.data.error_fields){
  604. tempTip.setDuration(3000);
  605. tempTip.show('录入失败,字段填写错误');
  606. _this.errors=response.data.error_fields;
  607. if(_this.errors.remark){
  608. _this.errors.bill_remark=_this.errors.remark;
  609. _this.errors.remark = '';
  610. }
  611. }else{
  612. tempTip.setDuration(3000);
  613. tempTip.show('录入失败:'+response.data.fail_info)
  614. }
  615. }
  616. }).catch(function (response) {
  617. tempTip.setDuration(3000);
  618. tempTip.show('提交失败,请重试:'+response.data.fail_info)
  619. alert('连接错误:'+response)
  620. });
  621. },
  622. commitEditItem:function () {
  623. let _this=this;
  624. if(!confirm("确定要提交修改吗?")){return;}
  625. let url='{{url('apiLocal/rejectedBillItem/update')}}';
  626. axios.post(url,_this.itemInputting).then(function (response) {
  627. _this.cleanError();
  628. if(response.data.success==='true'){
  629. tempTip.setDuration(1000);
  630. tempTip.showSuccess('成功修改商品:'+_this.itemInputting.barcode_goods);
  631. _this.cleanItem();
  632. _this.getItemsUnderBill(_this.status.editingBillId);
  633. _this.shiftToCreateItem();
  634. }else{
  635. if(response.data.error_fields){
  636. tempTip.setDuration(3000);
  637. tempTip.show('修改失败,字段填写错误');
  638. _this.errors=response.data.error_fields;
  639. if(_this.errors.remark){
  640. _this.errors.bill_remark=_this.errors.remark;
  641. _this.errors.remark = '';
  642. }
  643. }else{
  644. tempTip.show('修改失败:'+response.data.fail_info)
  645. }
  646. }
  647. }).catch(function (response) {
  648. tempTip.setDuration(3000);
  649. tempTip.show('提交失败,请重试:'+response.data.fail_info)
  650. alert('连接错误:'+response)
  651. });
  652. },
  653. commitEditHeader:function () {
  654. let _this=this;
  655. if(!confirm("确定要提交修改吗?")){return;}
  656. let url='{{url('apiLocal/rejectedBill/update')}}';
  657. tempTip.setDuration(99999);
  658. tempTip.waitingTip('提交中')
  659. axios.post(url,_this.billInputting).then(function (response) {
  660. tempTip.cancelWaitingTip();
  661. _this.cleanError();
  662. if(response.data.success==='true'){
  663. tempTip.setDuration(1000);
  664. tempTip.showSuccess('成功修改退单号:'+_this.billInputting.logistic_number_return);
  665. _this.cleanHeader();
  666. _this.getRecentRejectedBills();
  667. _this.shiftToCreate();
  668. }else{
  669. if(response.data.error_fields){
  670. tempTip.setDuration(3000);
  671. tempTip.show('修改失败,字段填写错误');
  672. _this.errors=response.data.error_fields;
  673. }else{
  674. tempTip.show('修改失败:'+response.data.fail_info)
  675. }
  676. }
  677. }).catch(function (response) {
  678. tempTip.setDuration(3000);
  679. tempTip.show('提交失败,请重试:'+response.data.fail_info)
  680. alert('连接错误:'+response)
  681. });
  682. },
  683. commitItem:function () {
  684. let _this=this;
  685. let url='{{url('apiLocal/rejectedBillItem/store')}}';
  686. _this.itemInputting.id_rejected_bill=_this.status.editingBill.id;
  687. if (_this.items.length<1){
  688. let baoShiBuFaOwnerId='';
  689. _this.owners.forEach(function (owner){
  690. if (owner.name==='宝时补发') baoShiBuFaOwnerId=owner.id;
  691. });
  692. if(_this.commodityOwnerId!=_this.billInputting.id_owner && _this.billInputting.id_owner!=baoShiBuFaOwnerId){
  693. _this.isChangeOwner(_this.itemInputting.id_rejected_bill);
  694. }
  695. }
  696. axios.post(url,_this.itemInputting).then(function (response) {
  697. _this.cleanError();
  698. if(response.data.success==='true'){
  699. tempTip.setDuration(1000);
  700. tempTip.showSuccess('成功录入退单商品:'+_this.itemInputting.name_goods);
  701. _this.status.endAndPackCommitEdited=false;
  702. _this.lockBillPanel();
  703. _this.getItemsUnderBill(_this.status.editingBill.id);
  704. _this.cleanItem();
  705. $('#barcode_goods').focus();
  706. }else{
  707. if(response.data.error_fields){
  708. tempTip.setDuration(3000);
  709. tempTip.show('录入失败,字段填写错误');
  710. _this.errors=response.data.error_fields;
  711. }else{
  712. tempTip.show('录入失败:'+response.data.fail_info)
  713. }
  714. }
  715. }).catch(function (response) {
  716. tempTip.setDuration(3000);
  717. tempTip.show('提交失败,请重试:'+response.data.fail_info)
  718. alert('连接错误:'+response)
  719. });
  720. },
  721. isChangeOwner(id_rejected_bill){
  722. let _this=this;
  723. let url='{{url('apiLocal/rejectedBillItem/reviseOwner')}}';
  724. window.tempTip.confirm('当前退货记录货主名与录入商品的货主不匹配! '+'确定校正退货记录货主名吗?', () => {
  725. window.axios.post(url,{commodityOwnerId:_this.commodityOwnerId,id_rejected_bill:id_rejected_bill}).then(res => {
  726. if (res.data.success==='true') {
  727. let owner_name='';
  728. _this.owners.forEach(function (owner){
  729. if (owner.id==_this.commodityOwnerId){
  730. owner_name=owner.name;
  731. }
  732. })
  733. _this.billInputting.id_owner= _this.commodityOwnerId;
  734. _this.rejectedBills.forEach(function (rejectedBill){
  735. if (id_rejected_bill==rejectedBill.id)rejectedBill.owner_name=owner_name;
  736. })
  737. } else {
  738. tempTip.setDuration(3000);
  739. tempTip.show(res.data.message);
  740. return;
  741. }
  742. }).catch(err => {
  743. window.tempTip.setDuration(3000);
  744. window.tempTip.show("网络错误:" + err);
  745. return;
  746. });
  747. });
  748. },
  749. endAndPackCommitEdit:function () {
  750. let _this=this;
  751. if(_this.items.length===0){
  752. if(confirm('没有填加明细项,确定要退出详细编辑模式吗?')){
  753. _this.cancelPackCommitEdit();
  754. }
  755. return;
  756. }else{
  757. if(!confirm('确定要提交填加的明细项吗?提交后即不可修改')){
  758. return;
  759. }
  760. }
  761. let ids=[];
  762. _this.items.forEach(function(item){
  763. ids.push(item.id);
  764. });
  765. let url='{{url('apiLocal/rejectedBillItem/packConfirm')}}';
  766. tempTip.setDuration(5000);
  767. tempTip.waitingTip('与外部交互中,请稍候');
  768. axios.post(url,{'ids':ids}).then(function (response) {
  769. _this.cleanError();
  770. tempTip.cancelWaitingTip();
  771. if(response&&response.data&&response.data.success!=='false'){
  772. if(response.data.success=='exception'){
  773. _this.status.lockingIsLoadedInput=true;
  774. _this.billInputting.is_loaded=3;
  775. tempTip.show('富勒入库异常,请手动校对');
  776. }else if(typeof(response.data.bill_is_loaded)!='undefined'){
  777. if(response.data.bill_is_loaded===true){
  778. _this.status.editingBill.is_loaded=1;
  779. _this.billInputting.is_loaded=1;
  780. _this.billInputting.isLoadSign=true;
  781. // _this.status.lockingIsLoadedInput=true;
  782. tempTip.okWindow('该批商品状态已改为“入库”','已处理');
  783. }
  784. }
  785. tempTip.setDuration(5000);
  786. switch(response.data.remote_result){
  787. case 'fail': tempTip.show('与客户服务器通讯异常,明细未被外部处理,请联系系统相关同事');break;
  788. case 'none': tempTip.show('客户未返回明细处理信息,请联系系统相关同事检查');break;
  789. case 'received':tempTip.show('该单之前已提交过给客户服务器');break;
  790. case 'storable': tempTip.showSuccess('WMS尚未推单,客户返回可以入库,所以状态为“待推单”','已处理该待推单');break;
  791. default: tempTip.showSuccess('成功录入所有退单商品并已上传至外部');break;
  792. }
  793. _this.status.endAndPackCommitEdited=true;
  794. _this.cancelPackCommitEdit();
  795. }else{
  796. tempTip.setDuration(4000);
  797. let fail_info='';
  798. if(response.data)
  799. fail_info=response.data.fail_info;
  800. tempTip.show('录入明细列表失败,请重试:'+fail_info)
  801. }
  802. }).catch(function (response) {
  803. tempTip.cancelWaitingTip();
  804. tempTip.setDuration(3000);
  805. let fail_info='';
  806. if(response.data)
  807. fail_info=response.data.fail_info;
  808. tempTip.show('提交失败,请重试:'+fail_info);
  809. alert('连接错误:'+response)
  810. });
  811. },
  812. cancelPackCommitEdit:function () {
  813. let _this=this;
  814. if(_this.items.length===0&&!_this.status.endAndPackCommitEdited){
  815. _this.unlockBillPanel();
  816. return;
  817. }else{
  818. if(_this.status.endAndPackCommitEdited){
  819. _this.unlockBillPanel();
  820. return;
  821. }else{
  822. if(!confirm('已填加的明细尚未提交,回到表头编辑将取消已填加明细,是否确定?')){
  823. return;
  824. }
  825. }
  826. }
  827. let ids=[];
  828. for(let i=_this.status.existItemsBeforeAdd;i<_this.items.length;i++){
  829. ids.push(_this.items[i].id);
  830. }
  831. if(ids.length===0){_this.unlockBillPanel();return;}
  832. let url='{{url('apiLocal/rejectedBillItem/packDestroy')}}';
  833. axios.post(url,{'ids':ids}).then(function (response) {
  834. _this.cleanError();
  835. if(response.data.success==='true'){
  836. _this.status.editingBill=null;
  837. _this.unlockBillPanel();
  838. }else{
  839. tempTip.show('数据操作失败,请重试:'+response.data.fail_info)
  840. }
  841. }).catch(function (response) {
  842. tempTip.setDuration(3000);
  843. tempTip.show('提交失败,请重试:'+response.data.fail_info)
  844. alert('连接错误:'+response)
  845. });
  846. },
  847. lockBillPanel:function () {
  848. this.status.lockingBillPanel=true;
  849. $('input,select').blur();
  850. },
  851. unlockBillPanel:function () {
  852. this.status.lockingBillPanel=false;
  853. this.status.editingBill=null;
  854. this.status.editingBillId='';
  855. this.shiftToCreate();
  856. },
  857. getRecentRejectedBills:function () {
  858. let _this=this;
  859. let url='{{url('apiLocal/rejectedBill/apiGetRecent')}}';
  860. axios.post(url).then(function (response) {
  861. if(response.data.success==='true'){
  862. _this.rejectedBills=response.data.rejectedBills;
  863. _this.setEditingBill(_this.status.editingBillId)
  864. }else{
  865. tempTip.show('加载新增内容失败,可尝试刷新页面');
  866. }
  867. }).catch(function (response) {
  868. alert('连接错误:'+response);
  869. tempTip.show('加载新增内容失败,可尝试刷新页面!');
  870. });
  871. },
  872. getItemsUnderBill:function (billId,func) {
  873. let _this=this;
  874. let url='{{url('apiLocal/rejectedBillItem/apiGet')}}';
  875. axios.post(url,{id_rejected_bill:billId}).then(function (response) {
  876. if(response.data.success==='true'){
  877. response.data.items.forEach(function(item){
  878. item.isEditing=false;
  879. });
  880. _this.items=response.data.items;
  881. if(typeof func!=='undefined'){
  882. func()
  883. }
  884. _this.listenEnterAndJump();
  885. setTimeout(function(){$('#barcode_goods').focus();},500)
  886. }else{
  887. tempTip.show('加载相关明细失败,可尝试刷新页面');
  888. }
  889. }).catch(function (response) {
  890. alert('连接错误:'+response);
  891. tempTip.show('加载相关明细失败,可尝试刷新页面!');
  892. });
  893. },
  894. deleteBill:function(rejectedBill){
  895. if(!confirm('确定要删除退货信息“' + rejectedBill.owner_name+':'+rejectedBill.logistic_number_return+ '”吗?')){return;}
  896. let _this=this;
  897. let url = "{{url('rejectedBill')}}/"+rejectedBill.id;
  898. axios.delete(url,{id:rejectedBill.id})
  899. .then(function (response) {
  900. if(response.data.success){
  901. for (let i = 0; i < _this.rejectedBills.length; i++) {
  902. if (_this.rejectedBills[i].id===rejectedBill.id){
  903. _this.rejectedBills.splice(i,1);
  904. break;
  905. }
  906. }
  907. tempTip.setDuration(1000);
  908. tempTip.showSuccess('删除退货信息"'+rejectedBill.owner_name+':'+rejectedBill.logistic_number_return+'"成功!')
  909. }else{
  910. tempTip.setDuration(1000);
  911. tempTip.show('删除退货信息"'+rejectedBill.owner_name+':'+rejectedBill.logistic_number_return+'"失败!')
  912. }
  913. })
  914. .catch(function (err) {
  915. tempTip.setDuration(3000);
  916. tempTip.show('删除退货信息失败!'+'网络错误:' + err);
  917. });
  918. },
  919. deleteItem:function (e) {
  920. if(!confirm('确定要删除该明细吗?不可恢复')){return}
  921. let _this=this;
  922. let id = $(e.target).parents('tr').attr('data-id');
  923. let url='{{url('apiLocal/rejectedBillItem/apiDelete')}}';
  924. axios.post(url,{id:id}).then(function (response) {
  925. if(response.data.success==='true'){
  926. _this.items.forEach(function(item,i){
  927. if(item.id+''===id+''){
  928. _this.items.splice(i, 1);
  929. }
  930. });
  931. }else{
  932. tempTip.show('删除失败,可尝试刷新页面再操作');
  933. }
  934. }).catch(function (response) {
  935. alert('连接错误:'+response);
  936. tempTip.show('删除失败,可尝试刷新页面!');
  937. });
  938. },
  939. editBill:function (e) {
  940. let _this=this;
  941. let billId = $(e.target).parent('tr').attr('data-id');
  942. let billTarget='';
  943. this.rejectedBills.every(function(bill){
  944. if(bill.id+''===billId+''){
  945. billTarget=bill;
  946. return false;
  947. }
  948. return true;
  949. });
  950. if(billTarget){
  951. this.billInputting = JSON.parse(JSON.stringify(billTarget));
  952. this.shiftToEdit();
  953. this.setEditingBill(billTarget.id)
  954. }
  955. this.getItemsUnderBill(billTarget.id,function () {
  956. _this.status.existItemsBeforeAdd=_this.items.length;
  957. });
  958. },
  959. editItem:function (e) {
  960. let _this=this;
  961. let itemId = $(e.target).parent('tr').attr('data-id');
  962. let itemTarget='';
  963. this.items.every(function(item){
  964. if(item.id+''===itemId+''){
  965. itemTarget=item;
  966. return false;
  967. }
  968. return true;
  969. });
  970. if(itemTarget){
  971. this.itemInputting = JSON.parse(JSON.stringify(itemTarget));
  972. this.shiftToEditItem();
  973. this.setEditingItem(itemTarget.id)
  974. }
  975. // this.getItemsUnderBill(this.status.editingBillId,function () {});
  976. },
  977. shiftToEditItem:function () {
  978. this.cleanError();
  979. this.status.itemCreating=false;
  980. this.status.itemEditing=true;
  981. setTimeout(function () {
  982. $('.tooltipOn').tooltip({'trigger':'hover'});
  983. },50)
  984. },
  985. shiftToEdit:function () {
  986. this.cleanError();
  987. this.status.billCreating=false;
  988. this.status.billEditing=true;
  989. setTimeout(function () {
  990. $('.tooltipOn').tooltip({'trigger':'hover'});
  991. },50)
  992. },
  993. shiftToCreateItem:function () {
  994. this.cleanError();
  995. this.cleanItem();
  996. this.status.itemCreating=true;
  997. this.status.itemEditing=false;
  998. this.items.forEach(function (item) {
  999. item.isEditing=false;
  1000. });
  1001. $('.tooltipOn').tooltip('hide').tooltip({'trigger':'hover'});
  1002. },
  1003. shiftToCreate:function () {
  1004. this.cleanError();
  1005. this.cleanHeader();
  1006. this.status.billCreating=true;
  1007. this.status.billEditing=false;
  1008. this.status.editingBill=null;
  1009. this.rejectedBills.forEach(function(rejectedBill){
  1010. if(rejectedBill.isEditing===true){
  1011. rejectedBill.isEditing=false;
  1012. return false;
  1013. }
  1014. });
  1015. $('.tooltipOn').tooltip('hide').tooltip({'trigger':'hover'});
  1016. },
  1017. locateIdOwner:function (e) {
  1018. let _this=this;
  1019. let $target=$(e.target);
  1020. this.owners.forEach(function(owner){
  1021. if(owner.name.includes($target.val())){
  1022. _this.billInputting.id_owner=owner.id;
  1023. }
  1024. });
  1025. },
  1026. locateLogistic:function (e) {
  1027. let _this=this;
  1028. let $target=$(e.target);
  1029. this.logistics.forEach(function(logistic){
  1030. if(logistic.name.includes($target.val())){
  1031. _this.billInputting.id_logistic_return=logistic.id;
  1032. }
  1033. });
  1034. },
  1035. //根据退回单寻找WMS订单填充已有字段
  1036. seek_order(){
  1037. let _this=this;
  1038. let logistic_number_return=this.billInputting.logistic_number_return;
  1039. if (!logistic_number_return) return;
  1040. axios.post('{{url('apiLocal/rejectedBill/seekOrder')}}',{logistic_number_return:logistic_number_return})
  1041. .then(function (response) {
  1042. if (response.data.success){
  1043. if(response.data.data.owner_id)_this.billInputting.id_owner=response.data.data.owner_id;
  1044. if(response.data.data.logistic_id)_this.billInputting.id_logistic_return = response.data.data.logistic_id;
  1045. if(response.data.data.consignee_name)_this.billInputting.sender = response.data.data.consignee_name;
  1046. if(response.data.data.consignee_phone)_this.billInputting.mobile_sender = response.data.data.consignee_phone;
  1047. if(response.data.data.client_code)_this.billInputting.order_number = response.data.data.client_code;
  1048. if(response.data.data.logistic_number)_this.billInputting.logistic_number = response.data.data.logistic_number;
  1049. tempTip.setDuration(2000);
  1050. tempTip.showSuccess('原单信息已填充');
  1051. return;
  1052. }
  1053. tempTip.setDuration(2000);
  1054. tempTip.show('没有找到对应的数据,可手动填写 ');
  1055. });
  1056. },
  1057. },
  1058. filters:{
  1059. isLoaded:function (value) {
  1060. return value==1?'是':'否';
  1061. },
  1062. dateNoYear:function (value) {
  1063. if(!value)return '';
  1064. return value.substr(5,11);
  1065. }
  1066. }
  1067. });
  1068. </script>
  1069. @endsection