create.blade.php 64 KB

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