create.blade.php 62 KB

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