create.blade.php 59 KB

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