create.blade.php 60 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015
  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_short }}</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="seek_order();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="13"
  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="12" 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="12"
  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:[
  412. @foreach($rejectedBills as $bill)
  413. {id:'{{$bill->id}}',created_at_short:'{{$bill->created_at_short}}',owner_name:'{{$bill->owner_name}}',remark:'{{$bill->remark}}'
  414. ,id_owner:'{{$bill->id_owner}}',mobile_sender:'{{$bill->mobile_sender}}',sender:'{{$bill->sender}}'
  415. ,logistic_number:'{{$bill->logistic_number}}',id_logistic_return:'{{$bill->id_logistic_return}}'
  416. ,fee_collected:'{{$bill->fee_collected}}',is_loaded:'{{$bill->is_loaded_null}}',order_number:'{{$bill->order_number}}'
  417. ,logistic_number_return:'{{$bill->logistic_number_return}}',logistic_name:'{{$bill->logistic_name}}',
  418. isEditing:false},
  419. @endforeach
  420. ],
  421. items:[
  422. ],
  423. owners:[
  424. @foreach($owners as $owner)
  425. {id:'{{$owner->id}}',name:'{{$owner->name}}',code:'{{$owner->code}}'},
  426. @endforeach
  427. ],
  428. logistics:[
  429. @foreach($logistics as $logistic)
  430. {id:'{{$logistic->id}}',name:'{{$logistic->name}}',code:'{{$logistic->code}}'},
  431. @endforeach
  432. ],
  433. qualityLabels:[
  434. @foreach($qualityLabels as $qualityLabel)
  435. {id:'{{$qualityLabel->id}}',name:'{{$qualityLabel->name}}'},
  436. @endforeach
  437. ]
  438. },
  439. mounted:function () {
  440. let _this=this;
  441. $('#editPanel').removeClass('d-none');
  442. $('.tooltipOn').tooltip({'trigger':'hover'});
  443. $(document).on('keypress',function(e){
  444. if(_this.itemInputting.barcode_goods){
  445. if(e.key==='*'){
  446. _this.commitItem();
  447. return false;
  448. }
  449. }
  450. });
  451. this.listenEnterAndJump();
  452. },
  453. methods:{
  454. logistic_number_returnChange:function(e){
  455. let _this=this;
  456. let number=$(e.target).val();
  457. if(!number)return;
  458. let url='{{"/apiLocal/logistic/numberFeatures/computeLogisticByNumber"}}';
  459. axios.post(url,{logistic_number_return:number}).then(function (response) {
  460. _this.cleanError();
  461. if(response.data.success==='true'){
  462. if(response.data.logistic){
  463. _this.billInputting.id_logistic_return=response.data.logistic.id;
  464. }
  465. }
  466. }).catch(function (response) {
  467. console.log(response);
  468. });
  469. if(_this.status.editingBill)return;
  470. let url_isUnique='{{"/apiLocal/logistic/logisticNumberReturnIsUnique"}}';
  471. axios.post(url_isUnique,{logistic_number_return:number}).then(function (response) {
  472. _this.cleanError();
  473. if(response.data.success==='true'){
  474. if(response.data.result==='true'){
  475. tempTip.okWindow('该退回单号"'+number+'"已有录入其他单','知道了')
  476. }
  477. }
  478. }).catch(function (response) {
  479. console.log(response);
  480. });
  481. },
  482. barcode_goodsChange:function(e){
  483. let _this=this;
  484. let barcode=$(e.target).val();
  485. let url='{{"/apiLocal/commodity/getCommodityByBarcode"}}';
  486. axios.post(url,{barcode:barcode}).then(function (response) {
  487. _this.cleanError();
  488. if(response.data.success==='true'){
  489. if(response.data.name){
  490. _this.itemInputting.name_goods=response.data.name;
  491. }
  492. }else{
  493. tempTip.setDuration(3000);
  494. tempTip.show('查找商品条码错误:'+response.data.fail_info)
  495. }
  496. }).catch(function (response) {
  497. tempTip.setDuration(3000);
  498. tempTip.show('未连接至商品表,检查网络');
  499. });
  500. },
  501. name_goodsChange:function(e){
  502. let _this=this;
  503. let name=$(e.target).val();
  504. this.items.forEach(function(item){
  505. if(item.barcode_goods+''===_this.itemInputting.barcode_goods+''){
  506. item.name_goods=name;
  507. }
  508. });
  509. },
  510. listenEnterAndJump:function(){
  511. let targets=$('select,input');
  512. targets.off('keypress');
  513. targets.on('keypress',function(e){
  514. if(e.key!=="Enter")return;
  515. let target=$(e.target);
  516. let currentOrder = target.attr('data-focusOrder');
  517. if(currentOrder){
  518. targets.each(function($i,$val){
  519. let checkingTarget = $($val);
  520. let checkingOrder = checkingTarget.attr('data-focusOrder');
  521. if(parseInt(currentOrder)+1===parseInt(checkingOrder)){
  522. checkingTarget.focus();
  523. }
  524. })
  525. }
  526. });
  527. targets.off('change');
  528. targets.on('change',function(e){
  529. let target=$(e.target);
  530. let currentOrder = target.attr('data-focusOrder');
  531. if(currentOrder){
  532. targets.each(function($i,$val){
  533. let checkingTarget = $($val);
  534. let checkingOrder = checkingTarget.attr('data-focusOrder');
  535. if(parseInt(currentOrder)+1===parseInt(checkingOrder)){
  536. checkingTarget.focus();
  537. }
  538. })
  539. }
  540. })
  541. },
  542. cleanHeader:function(){
  543. for(let key in this.billInputting){
  544. this.billInputting[key]='';
  545. }
  546. this.billInputting.id_owner=this.status.inputtingId_owner;
  547. this.billInputting.is_loaded="0";
  548. this.billInputting.isLoadSign=false;
  549. },
  550. cleanItem:function(){
  551. for(let key in this.itemInputting){
  552. this.itemInputting[key]='';
  553. }
  554. this.itemInputting['amount']='1';
  555. },
  556. cleanError:function(){
  557. for(let key in this.errors){
  558. this.errors[key]='';
  559. }
  560. },
  561. setEditingBill:function(id){
  562. let _this=this;
  563. this.status.editingBillId=id;
  564. this.rejectedBills.forEach(function (bill) {
  565. if(bill.id+''===id+''){
  566. _this.status.editingBill=bill;
  567. bill.isEditing=true;
  568. }else{
  569. bill.isEditing=false
  570. }
  571. });
  572. this.$forceUpdate();
  573. },
  574. setEditingItem:function(id){
  575. let _this=this;
  576. this.status.editingItemId=id;
  577. this.items.forEach(function (item) {
  578. if(item.id+''===id+''){
  579. _this.status.editingItem=item;
  580. item.isEditing=true;
  581. }else{
  582. item.isEditing=false
  583. }
  584. });
  585. this.$forceUpdate();
  586. },
  587. commitHeader:function () {
  588. let _this=this;
  589. let url='{{url('apiLocal/rejectedBill/store')}}';
  590. axios.post(url,_this.billInputting).then(function (response) {
  591. _this.cleanError();
  592. if(response.data.success==='true'){
  593. tempTip.setDuration(1000);
  594. tempTip.showSuccess('成功录入退单号:'+_this.billInputting.logistic_number_return);
  595. _this.status.inputtingId_owner=_this.billInputting.id_owner;
  596. _this.setEditingBill(response.data.id);
  597. _this.getItemsUnderBill(response.data.id);
  598. _this.cleanHeader();
  599. _this.getRecentRejectedBills();
  600. _this.lockBillPanel();
  601. _this.status.existItemsBeforeAdd=0;
  602. $('#barcode_goods').focus();
  603. }else{
  604. if(response.data.error_fields){
  605. tempTip.setDuration(3000);
  606. tempTip.show('录入失败,字段填写错误');
  607. _this.errors=response.data.error_fields;
  608. if(_this.errors.remark){
  609. _this.errors.bill_remark=_this.errors.remark;
  610. _this.errors.remark = '';
  611. }
  612. }else{
  613. tempTip.setDuration(3000);
  614. tempTip.show('录入失败:'+response.data.fail_info)
  615. }
  616. }
  617. }).catch(function (response) {
  618. tempTip.setDuration(3000);
  619. tempTip.show('提交失败,请重试:'+response.data.fail_info)
  620. alert('连接错误:'+response)
  621. });
  622. },
  623. commitEditItem:function () {
  624. let _this=this;
  625. if(!confirm("确定要提交修改吗?")){return;}
  626. let url='{{url('apiLocal/rejectedBillItem/update')}}';
  627. axios.post(url,_this.itemInputting).then(function (response) {
  628. _this.cleanError();
  629. if(response.data.success==='true'){
  630. tempTip.setDuration(1000);
  631. tempTip.showSuccess('成功修改商品:'+_this.itemInputting.barcode_goods);
  632. _this.cleanItem();
  633. _this.getItemsUnderBill(_this.status.editingBillId);
  634. _this.shiftToCreateItem();
  635. }else{
  636. if(response.data.error_fields){
  637. tempTip.setDuration(3000);
  638. tempTip.show('修改失败,字段填写错误');
  639. _this.errors=response.data.error_fields;
  640. if(_this.errors.remark){
  641. _this.errors.bill_remark=_this.errors.remark;
  642. _this.errors.remark = '';
  643. }
  644. }else{
  645. tempTip.show('修改失败:'+response.data.fail_info)
  646. }
  647. }
  648. }).catch(function (response) {
  649. tempTip.setDuration(3000);
  650. tempTip.show('提交失败,请重试:'+response.data.fail_info)
  651. alert('连接错误:'+response)
  652. });
  653. },
  654. commitEditHeader:function () {
  655. let _this=this;
  656. if(!confirm("确定要提交修改吗?")){return;}
  657. let url='{{url('apiLocal/rejectedBill/update')}}';
  658. axios.post(url,_this.billInputting).then(function (response) {
  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. axios.post(url,_this.itemInputting).then(function (response) {
  686. _this.cleanError();
  687. if(response.data.success==='true'){
  688. tempTip.setDuration(1000);
  689. tempTip.showSuccess('成功录入退单商品:'+_this.itemInputting.name_goods);
  690. _this.status.endAndPackCommitEdited=false;
  691. _this.lockBillPanel();
  692. _this.getItemsUnderBill(_this.status.editingBill.id);
  693. _this.cleanItem();
  694. $('#barcode_goods').focus();
  695. }else{
  696. if(response.data.error_fields){
  697. tempTip.setDuration(3000);
  698. tempTip.show('录入失败,字段填写错误');
  699. _this.errors=response.data.error_fields;
  700. }else{
  701. tempTip.show('录入失败:'+response.data.fail_info)
  702. }
  703. }
  704. }).catch(function (response) {
  705. tempTip.setDuration(3000);
  706. tempTip.show('提交失败,请重试:'+response.data.fail_info)
  707. alert('连接错误:'+response)
  708. });
  709. },
  710. endAndPackCommitEdit:function () {
  711. let _this=this;
  712. if(_this.items.length===0){
  713. if(confirm('没有填加明细项,确定要退出详细编辑模式吗?')){
  714. _this.cancelPackCommitEdit();
  715. }
  716. return;
  717. }else{
  718. if(!confirm('确定要提交填加的明细项吗?提交后即不可修改')){
  719. return;
  720. }
  721. }
  722. let ids=[];
  723. _this.items.forEach(function(item){
  724. ids.push(item.id);
  725. });
  726. let url='{{url('apiLocal/rejectedBillItem/packConfirm')}}';
  727. tempTip.setDuration(5000);
  728. tempTip.waitingTip('与外部交互中,请稍候');
  729. axios.post(url,{'ids':ids}).then(function (response) {
  730. _this.cleanError();
  731. tempTip.cancelWaitingTip();
  732. if(response&&response.data&&response.data.success!=='false'){
  733. if(response.data.success=='exception'){
  734. _this.status.lockingIsLoadedInput=true;
  735. _this.billInputting.is_loaded=3;
  736. tempTip.show('富勒入库异常,请手动校对');
  737. }else if(typeof(response.data.bill_is_loaded)!='undefined'){
  738. if(response.data.bill_is_loaded===true){
  739. _this.status.editingBill.is_loaded=1;
  740. _this.billInputting.is_loaded=1;
  741. _this.billInputting.isLoadSign=true;
  742. // _this.status.lockingIsLoadedInput=true;
  743. tempTip.okWindow('该批商品状态已改为“入库”','已处理');
  744. }
  745. }
  746. tempTip.setDuration(5000);
  747. switch(response.data.remote_result){
  748. case 'fail': tempTip.show('与客户服务器通讯异常,明细未被外部处理,请联系系统相关同事');break;
  749. case 'none': tempTip.show('客户未返回明细处理信息,请联系系统相关同事检查');break;
  750. case 'received':tempTip.show('该单之前已提交过给客户服务器');break;
  751. case 'storable': tempTip.showSuccess('WMS尚未推单,客户返回可以入库,所以状态为“待推单”','已处理该待推单');break;
  752. default: tempTip.showSuccess('成功录入所有退单商品并已上传至外部');break;
  753. }
  754. _this.status.endAndPackCommitEdited=true;
  755. _this.cancelPackCommitEdit();
  756. }else{
  757. tempTip.setDuration(4000);
  758. let fail_info='';
  759. if(response.data)
  760. fail_info=response.data.fail_info;
  761. tempTip.show('录入明细列表失败,请重试:'+fail_info)
  762. }
  763. }).catch(function (response) {
  764. tempTip.cancelWaitingTip();
  765. tempTip.setDuration(3000);
  766. let fail_info='';
  767. if(response.data)
  768. fail_info=response.data.fail_info;
  769. tempTip.show('提交失败,请重试:'+fail_info);
  770. alert('连接错误:'+response)
  771. });
  772. },
  773. cancelPackCommitEdit:function () {
  774. let _this=this;
  775. if(_this.items.length===0&&!_this.status.endAndPackCommitEdited){
  776. _this.unlockBillPanel();
  777. return;
  778. }else{
  779. if(_this.status.endAndPackCommitEdited){
  780. _this.unlockBillPanel();
  781. return;
  782. }else{
  783. if(!confirm('已填加的明细尚未提交,回到表头编辑将取消已填加明细,是否确定?')){
  784. return;
  785. }
  786. }
  787. }
  788. let ids=[];
  789. for(let i=_this.status.existItemsBeforeAdd;i<_this.items.length;i++){
  790. ids.push(_this.items[i].id);
  791. }
  792. if(ids.length===0){_this.unlockBillPanel();return;}
  793. let url='{{url('apiLocal/rejectedBillItem/packDestroy')}}';
  794. axios.post(url,{'ids':ids}).then(function (response) {
  795. _this.cleanError();
  796. if(response.data.success==='true'){
  797. _this.status.editingBill=null;
  798. _this.unlockBillPanel();
  799. }else{
  800. tempTip.show('数据操作失败,请重试:'+response.data.fail_info)
  801. }
  802. }).catch(function (response) {
  803. tempTip.setDuration(3000);
  804. tempTip.show('提交失败,请重试:'+response.data.fail_info)
  805. alert('连接错误:'+response)
  806. });
  807. },
  808. lockBillPanel:function () {
  809. this.status.lockingBillPanel=true;
  810. $('input,select').blur();
  811. },
  812. unlockBillPanel:function () {
  813. this.status.lockingBillPanel=false;
  814. this.status.editingBill=null;
  815. this.status.editingBillId='';
  816. this.shiftToCreate();
  817. },
  818. getRecentRejectedBills:function () {
  819. let _this=this;
  820. let url='{{url('apiLocal/rejectedBill/apiGetRecent')}}';
  821. axios.post(url).then(function (response) {
  822. if(response.data.success==='true'){
  823. _this.rejectedBills=response.data.rejectedBills;
  824. _this.setEditingBill(_this.status.editingBillId)
  825. }else{
  826. tempTip.show('加载新增内容失败,可尝试刷新页面');
  827. }
  828. }).catch(function (response) {
  829. alert('连接错误:'+response);
  830. tempTip.show('加载新增内容失败,可尝试刷新页面!');
  831. });
  832. },
  833. getItemsUnderBill:function (billId,func) {
  834. let _this=this;
  835. let url='{{url('apiLocal/rejectedBillItem/apiGet')}}';
  836. axios.post(url,{id_rejected_bill:billId}).then(function (response) {
  837. if(response.data.success==='true'){
  838. response.data.items.forEach(function(item){
  839. item.isEditing=false;
  840. });
  841. _this.items=response.data.items;
  842. if(typeof func!=='undefined'){
  843. func()
  844. }
  845. _this.listenEnterAndJump();
  846. setTimeout(function(){$('#barcode_goods').focus();},500)
  847. }else{
  848. tempTip.show('加载相关明细失败,可尝试刷新页面');
  849. }
  850. }).catch(function (response) {
  851. alert('连接错误:'+response);
  852. tempTip.show('加载相关明细失败,可尝试刷新页面!');
  853. });
  854. },
  855. deleteItem:function (e) {
  856. if(!confirm('确定要删除该明细吗?不可恢复')){return}
  857. let _this=this;
  858. let id = $(e.target).parents('tr').attr('data-id');
  859. let url='{{url('apiLocal/rejectedBillItem/apiDelete')}}';
  860. axios.post(url,{id:id}).then(function (response) {
  861. if(response.data.success==='true'){
  862. _this.items.forEach(function(item,i){
  863. if(item.id+''===id+''){
  864. _this.items.splice(i, 1);
  865. }
  866. });
  867. }else{
  868. tempTip.show('删除失败,可尝试刷新页面再操作');
  869. }
  870. }).catch(function (response) {
  871. alert('连接错误:'+response);
  872. tempTip.show('删除失败,可尝试刷新页面!');
  873. });
  874. },
  875. editBill:function (e) {
  876. let _this=this;
  877. let billId = $(e.target).parent('tr').attr('data-id');
  878. let billTarget='';
  879. this.rejectedBills.every(function(bill){
  880. if(bill.id+''===billId+''){
  881. billTarget=bill;
  882. return false;
  883. }
  884. return true;
  885. });
  886. if(billTarget){
  887. this.billInputting = JSON.parse(JSON.stringify(billTarget));
  888. this.shiftToEdit();
  889. this.setEditingBill(billTarget.id)
  890. }
  891. this.getItemsUnderBill(billTarget.id,function () {
  892. _this.status.existItemsBeforeAdd=_this.items.length;
  893. });
  894. },
  895. editItem:function (e) {
  896. let _this=this;
  897. let itemId = $(e.target).parent('tr').attr('data-id');
  898. let itemTarget='';
  899. this.items.every(function(item){
  900. if(item.id+''===itemId+''){
  901. itemTarget=item;
  902. return false;
  903. }
  904. return true;
  905. });
  906. if(itemTarget){
  907. this.itemInputting = JSON.parse(JSON.stringify(itemTarget));
  908. this.shiftToEditItem();
  909. this.setEditingItem(itemTarget.id)
  910. }
  911. // this.getItemsUnderBill(this.status.editingBillId,function () {});
  912. },
  913. shiftToEditItem:function () {
  914. this.cleanError();
  915. this.status.itemCreating=false;
  916. this.status.itemEditing=true;
  917. setTimeout(function () {
  918. $('.tooltipOn').tooltip({'trigger':'hover'});
  919. },50)
  920. },
  921. shiftToEdit:function () {
  922. this.cleanError();
  923. this.status.billCreating=false;
  924. this.status.billEditing=true;
  925. setTimeout(function () {
  926. $('.tooltipOn').tooltip({'trigger':'hover'});
  927. },50)
  928. },
  929. shiftToCreateItem:function () {
  930. this.cleanError();
  931. this.cleanItem();
  932. this.status.itemCreating=true;
  933. this.status.itemEditing=false;
  934. this.items.forEach(function (item) {
  935. item.isEditing=false;
  936. });
  937. $('.tooltipOn').tooltip('hide').tooltip({'trigger':'hover'});
  938. },
  939. shiftToCreate:function () {
  940. this.cleanError();
  941. this.cleanHeader();
  942. this.status.billCreating=true;
  943. this.status.billEditing=false;
  944. this.status.editingBill=null;
  945. this.rejectedBills.forEach(function(rejectedBill){
  946. if(rejectedBill.isEditing===true){
  947. rejectedBill.isEditing=false;
  948. return false;
  949. }
  950. });
  951. $('.tooltipOn').tooltip('hide').tooltip({'trigger':'hover'});
  952. },
  953. locateIdOwner:function (e) {
  954. let _this=this;
  955. let $target=$(e.target);
  956. this.owners.forEach(function(owner){
  957. if(owner.name.includes($target.val())){
  958. _this.billInputting.id_owner=owner.id;
  959. }
  960. });
  961. },
  962. locateLogistic:function (e) {
  963. let _this=this;
  964. let $target=$(e.target);
  965. this.logistics.forEach(function(logistic){
  966. if(logistic.name.includes($target.val())){
  967. _this.billInputting.id_logistic_return=logistic.id;
  968. }
  969. });
  970. },
  971. //根据退回单寻找WMS订单填充已有字段
  972. seek_order(){
  973. let _this=this;
  974. let soreference5=this.billInputting.logistic_number_return;
  975. if (!soreference5) return;
  976. axios.post('{{url('apiLocal/rejectedBill/seekOrder')}}',{soreference5:soreference5})
  977. .then(function (response) {
  978. if (response.data.success){
  979. let id_owner='';
  980. let id_logistic_return='';
  981. _this.owners.every(function (owner) {
  982. if (owner.code===response.data.data.customerid){
  983. id_owner=owner.id;return false;
  984. }
  985. return true;
  986. });
  987. _this.logistics.every(function (logistic) {
  988. if (logistic.code===response.data.data.carrierid){
  989. id_logistic_return=logistic.id;return false;
  990. }
  991. return true;
  992. });
  993. if (id_owner) _this.billInputting.id_owner=id_owner;
  994. _this.billInputting.sender=response.data.data.c_contact;
  995. if (id_logistic_return) _this.billInputting.id_logistic_return=id_logistic_return;
  996. _this.billInputting.order_number=response.data.data.soreference1;
  997. _this.billInputting.mobile_sender=response.data.data.c_tel2;
  998. }
  999. })
  1000. }
  1001. },
  1002. filters:{
  1003. isLoaded:function (value) {
  1004. return value==1?'是':'否';
  1005. }
  1006. }
  1007. });
  1008. </script>
  1009. @endsection