create.blade.php 56 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966
  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: 500px;
  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="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>
  182. <td>
  183. <div class="form-group mb-0 align-items-center row" >
  184. <div class="col-2 mt-3" v-if="status.billEditing">
  185. <button class="btn btn-success btn-sm tooltipOn" @click="shiftToCreate"
  186. title="点击取消编辑,进入新增状态">取消</button>
  187. </div>
  188. <div class="col-8 mt-3" :class="[status.billCreating?'offset-2':'']">
  189. <input v-if="status.billCreating" type="button" class="btn btn-success form-control" value="提交新条目" @click="commitHeader">
  190. <input v-if="status.billEditing" type="button" class="btn btn-dark form-control" value="修改" @click="commitEditHeader">
  191. </div>
  192. </div>
  193. </td>
  194. <td>
  195. </td>
  196. </tr>
  197. </table>
  198. </div>
  199. </div>
  200. </div>
  201. </div>
  202. <div class="card" v-if="status.editingBill">
  203. <div class="row">
  204. <div class="col-7">
  205. <div class="card-body">
  206. <div class="list-group">
  207. <table class="table table-sm table-striped table-warning table-hover table-bordered">
  208. <tr>
  209. <th>序号</th>
  210. <th>商品条码</th>
  211. <th>商品名称</th>
  212. <th>数量</th>
  213. <th>是否正品</th>
  214. <th>生产日期</th>
  215. <th>效期</th>
  216. <th>批次号</th>
  217. <th>备注</th>
  218. @can('退货管理-删除')<th></th>@endcan
  219. </tr>
  220. <tr :class="[item.isEditing?'bg-warning':'']"
  221. v-for="(item,i) in items" :data-id="item.id" @click="editItem">
  222. <td>@{{i+1}}</td>
  223. <td>@{{item.barcode_goods }}</td>
  224. <td>@{{item.name_goods }}</td>
  225. <td>@{{item.amount}}</td>
  226. <td>@{{item.quality_label}}</td>
  227. <td>@{{item.made_at}}</td>
  228. <td>@{{item.validity_at}}</td>
  229. <td>@{{item.batch_number}}</td>
  230. <td>@{{item.remark}}</td>
  231. @can('退货管理-删除')<td><button class="btn btn-outline-danger" @click="deleteItem">删</button></td>@endcan
  232. </tr>
  233. </table>
  234. </div>
  235. </div>
  236. </div>
  237. <div class="col-5"><div class="card-body ml-n4">
  238. <table class="table table-striped table-sm table-bordered" :class="[status.itemEditing?'bg-warning':'']">
  239. <tr>
  240. <td>
  241. <div class="form-group mb-0">
  242. <label for="barcode_goods" class="col-form-label text-right">商品条码</label>
  243. <input type="text" class="form-control" :class="[errors.barcode_goods?'is-invalid':'']"
  244. data-focusOrder="11"
  245. name="barcode_goods" id="barcode_goods" autocomplete="off" v-model="itemInputting.barcode_goods"
  246. @change="barcode_goodsChange"
  247. >
  248. <span class="invalid-feedback" v-if="errors.barcode_goods"><strong>@{{errors.barcode_goods[0] }}</strong></span>
  249. </div>
  250. </td>
  251. <td>
  252. <div class="form-group mb-0">
  253. <label for="name_goods" class="col-form-label text-right">商品名称</label>
  254. <input type="text" class="form-control" :class="[errors.name_goods?'is-invalid':'']"
  255. data-focusOrder="14"
  256. name="name_goods" id="name_goods" autocomplete="off" v-model="itemInputting.name_goods"
  257. @change="name_goodsChange"
  258. >
  259. <span class="invalid-feedback" v-if="errors.name_goods"><strong>@{{errors.name_goods[0] }}</strong></span>
  260. </div>
  261. </td>
  262. </tr>
  263. <tr>
  264. <td>
  265. <div class="form-group mb-0">
  266. <label for="amount" class="col-form-label text-right">数量</label>
  267. <input type="" class="form-control" :class="[errors.amount?'is-invalid':'']"
  268. data-focusOrder="13"
  269. name="amount" id="amount" autocomplete="off" v-model="itemInputting.amount" required>
  270. <span class="invalid-feedback" v-if="errors.amount"><strong>@{{errors.amount[0] }}</strong></span>
  271. </div>
  272. </td>
  273. <td>
  274. <div class="form-group mb-0">
  275. <label for="qualityLabel.name" class="col-form-label text-right">是否正品</label>
  276. <div class="form-control" :class="[errors.id_quality_label?'is-invalid':'']">
  277. <span><input id="id_quality_label_space" type="radio" name="id_quality_label"
  278. data-focusOrder="12" required="required" checked><label
  279. for="id_quality_label_space">留空</label>&nbsp;</span>
  280. <span v-for="qualityLabel in qualityLabels">
  281. <input type="radio" name="id_quality_label" :value="qualityLabel.id" data-focusOrder="12"
  282. :id="'id_quality_label_'+qualityLabel.id"
  283. v-model="itemInputting.id_quality_label" required><label
  284. for="'id_quality_label_'+qualityLabel.id">@{{qualityLabel.name}}</label>&nbsp;</span>
  285. </div>
  286. <span class="invalid-feedback" v-if="errors.id_quality_label"><strong>@{{errors.id_quality_label[0] }}</strong></span>
  287. </div>
  288. </td>
  289. </tr>
  290. <tr>
  291. <td>
  292. <div class="form-group mb-0">
  293. <label for="made_at" class="col-form-label text-right">生产日期</label>
  294. <input type="date" class="form-control" :class="[errors.made_at?'is-invalid':'']"
  295. data-focusOrder="16"
  296. name="made_at" id="made_at" autocomplete="off" v-model="itemInputting.made_at">
  297. <span class="invalid-feedback" v-if="errors.made_at"><strong>@{{errors.made_at[0] }}</strong></span>
  298. </div>
  299. </td>
  300. <td>
  301. <div class="form-group mb-0">
  302. <label for="validity_at" class="col-form-label text-right">效期</label>
  303. <input type="date" class="form-control" :class="[errors.validity_at?'is-invalid':'']"
  304. data-focusOrder="17"
  305. name="validity_at" id="validity_at" autocomplete="off" v-model="itemInputting.validity_at">
  306. <span class="invalid-feedback" v-if="errors.validity_at"><strong>@{{errors.validity_at[0] }}</strong></span>
  307. </div>
  308. </td>
  309. </tr>
  310. <tr>
  311. <td>
  312. <div class="form-group mb-0">
  313. <label for="batch_number" class="col-form-label text-right">批次号</label>
  314. <input type="text" class="form-control" :class="[errors.batch_number?'is-invalid':'']"
  315. data-focusOrder="15"
  316. name="batch_number" id="batch_number" autocomplete="off" v-model="itemInputting.batch_number"
  317. >
  318. <span class="invalid-feedback" v-if="errors.batch_number"><strong>@{{errors.batch_number[0] }}</strong></span>
  319. </div>
  320. </td>
  321. <td>
  322. <div class="form-group mb-0">
  323. <label for="remark" class="col-form-label text-right">备注</label>
  324. <input type="text" class="form-control" :class="[errors.remark?'is-invalid':'']"
  325. data-focusOrder="15"
  326. name="remark" id="remark" autocomplete="off" v-model="itemInputting.remark">
  327. <span class="invalid-feedback" v-if="errors.remark"><strong>@{{errors.remark[0] }}</strong></span>
  328. </div>
  329. </td>
  330. </tr>
  331. <tr>
  332. <td>
  333. <div class="form-group mb-0 align-items-center row" >
  334. <div class="col-2 mt-3" v-if="status.itemEditing">
  335. <button class="btn btn-success btn-sm tooltipOn" @click="shiftToCreateItem"
  336. title="点击取消编辑,进入新增状态">取消</button>
  337. </div>
  338. <div class="col-8 mt-3" :class="[status.itemCreating?'offset-2':'']">
  339. <button v-if="status.itemCreating" class="btn btn-success form-control" @click="commitItem">添加明细</button>
  340. <input v-if="status.itemEditing" type="button" class="btn btn-dark form-control" value="修改" @click="commitEditItem">
  341. </div>
  342. </div>
  343. </td>
  344. <td>
  345. </td>
  346. </tr>
  347. <tr>
  348. <td colspan="2">
  349. <div class="form-group mb-0">
  350. <div class="col-8 offset-2 mt-2 mb-2">
  351. <button class="btn btn-dark form-control" @click="endAndPackCommitEdit">
  352. 结束添加并提交
  353. </button>
  354. </div>
  355. </div>
  356. </td>
  357. </tr>
  358. </table>
  359. </div>
  360. </div>
  361. </div>
  362. </div>
  363. </div>
  364. @endsection
  365. @section('lastScript')
  366. <script>
  367. let vueList=new Vue({
  368. el: "#editPanel",
  369. data:{
  370. status: {billCreating:true,billEditing:false,itemCreating:true,itemEditing:false
  371. ,editingBill:null,editingBillId:'',editingItem:null,editingItemId:''
  372. ,inputtingId_owner:'',endAndPackCommitEdited:false,lockingBillPanel:false,lockingIsLoadedInput:false,
  373. existItemsBeforeAdd:0},
  374. itemInputting:{
  375. barcode_goods:"",name_goods:"",amount:"1",id_quality_label:"",
  376. batch_number:"",validity_at:"",remark:"",made_at:"",
  377. },
  378. billInputting:{
  379. id_owner:"",mobile_sender:"",sender:"",order_number:"",remark:"",
  380. logistic_number_return:"",logistic_number:"",id_logistic_return:"",
  381. fee_collected:"",is_loaded:"0",locateLogisticSearch:"",locateOwnerSearch:"",
  382. isLoadSign:false,
  383. },
  384. errors:{
  385. id_owner:"",mobile_sender:"",sender:"",bill_remark:"",
  386. logistic_number_return:"",logistic_number:"",id_logistic_return:"",
  387. fee_collected:"",is_loaded:"",
  388. barcode_goods:"",name_goods:"",amount:"",id_quality_label:"",
  389. batch_number:"",validity_at:"",remark:"",made_at:"",
  390. },
  391. rejectedBills:[
  392. @foreach($rejectedBills as $bill)
  393. {id:'{{$bill->id}}',created_at_short:'{{$bill->created_at_short}}',owner_name:'{{$bill->owner_name}}',remark:'{{$bill->remark}}'
  394. ,id_owner:'{{$bill->id_owner}}',mobile_sender:'{{$bill->mobile_sender}}',sender:'{{$bill->sender}}'
  395. ,logistic_number:'{{$bill->logistic_number}}',id_logistic_return:'{{$bill->id_logistic_return}}'
  396. ,fee_collected:'{{$bill->fee_collected}}',is_loaded:'{{$bill->is_loaded_null}}',order_number:'{{$bill->order_number}}'
  397. ,logistic_number_return:'{{$bill->logistic_number_return}}',logistic_name:'{{$bill->logistic_name}}',
  398. isEditing:false},
  399. @endforeach
  400. ],
  401. items:[
  402. ],
  403. owners:[
  404. @foreach($owners as $owner)
  405. {id:'{{$owner->id}}',name:'{{$owner->name}}'},
  406. @endforeach
  407. ],
  408. logistics:[
  409. @foreach($logistics as $logistic)
  410. {id:'{{$logistic->id}}',name:'{{$logistic->name}}'},
  411. @endforeach
  412. ],
  413. qualityLabels:[
  414. @foreach($qualityLabels as $qualityLabel)
  415. {id:'{{$qualityLabel->id}}',name:'{{$qualityLabel->name}}'},
  416. @endforeach
  417. ]
  418. },
  419. mounted:function () {
  420. let _this=this;
  421. $('#editPanel').removeClass('d-none');
  422. $('.tooltipOn').tooltip({'trigger':'hover'});
  423. $(document).on('keypress',function(e){
  424. if(_this.itemInputting.barcode_goods){
  425. if(e.key==='*'){
  426. _this.commitItem();
  427. return false;
  428. }
  429. }
  430. });
  431. this.listenEnterAndJump();
  432. },
  433. methods:{
  434. logistic_number_returnChange:function(e){
  435. let _this=this;
  436. let number=$(e.target).val();
  437. if(!number)return;
  438. let url='{{"/apiLocal/logistic/numberFeatures/computeLogisticByNumber"}}';
  439. axios.post(url,{logistic_number_return:number}).then(function (response) {
  440. _this.cleanError();
  441. if(response.data.success==='true'){
  442. if(response.data.logistic){
  443. _this.billInputting.id_logistic_return=response.data.logistic.id;
  444. }
  445. }
  446. }).catch(function (response) {
  447. console.log(response);
  448. });
  449. if(_this.status.editingBill)return;
  450. let url_isUnique='{{"/apiLocal/logistic/logisticNumberReturnIsUnique"}}';
  451. axios.post(url_isUnique,{logistic_number_return:number}).then(function (response) {
  452. _this.cleanError();
  453. if(response.data.success==='true'){
  454. if(response.data.result==='true'){
  455. tempTip.okWindow('该退回单号"'+number+'"已有录入其他单','知道了')
  456. }
  457. }
  458. }).catch(function (response) {
  459. console.log(response);
  460. });
  461. },
  462. barcode_goodsChange:function(e){
  463. let _this=this;
  464. let barcode=$(e.target).val();
  465. let url='{{"/apiLocal/commodity/getCommodityByBarcode"}}';
  466. axios.post(url,{barcode:barcode}).then(function (response) {
  467. _this.cleanError();
  468. if(response.data.success==='true'){
  469. if(response.data.name){
  470. _this.itemInputting.name_goods=response.data.name;
  471. }
  472. }else{
  473. tempTip.setDuration(3000);
  474. tempTip.show('查找商品条码错误:'+response.data.fail_info)
  475. }
  476. }).catch(function (response) {
  477. tempTip.setDuration(3000);
  478. tempTip.show('未连接至商品表,检查网络');
  479. });
  480. },
  481. name_goodsChange:function(e){
  482. let _this=this;
  483. let name=$(e.target).val();
  484. this.items.forEach(function(item){
  485. if(item.barcode_goods+''===_this.itemInputting.barcode_goods+''){
  486. item.name_goods=name;
  487. }
  488. });
  489. },
  490. listenEnterAndJump:function(){
  491. let targets=$('select,input');
  492. targets.off('keypress');
  493. targets.on('keypress',function(e){
  494. if(e.key!=="Enter")return;
  495. let target=$(e.target);
  496. let currentOrder = target.attr('data-focusOrder');
  497. if(currentOrder){
  498. targets.each(function($i,$val){
  499. let checkingTarget = $($val);
  500. let checkingOrder = checkingTarget.attr('data-focusOrder');
  501. if(parseInt(currentOrder)+1===parseInt(checkingOrder)){
  502. checkingTarget.focus();
  503. }
  504. })
  505. }
  506. });
  507. targets.off('change');
  508. targets.on('change',function(e){
  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. },
  522. cleanHeader:function(){
  523. for(let key in this.billInputting){
  524. this.billInputting[key]='';
  525. }
  526. this.billInputting.id_owner=this.status.inputtingId_owner;
  527. this.billInputting.is_loaded="0";
  528. this.billInputting.isLoadSign=false;
  529. },
  530. cleanItem:function(){
  531. for(let key in this.itemInputting){
  532. this.itemInputting[key]='';
  533. }
  534. this.itemInputting['amount']='1';
  535. },
  536. cleanError:function(){
  537. for(let key in this.errors){
  538. this.errors[key]='';
  539. }
  540. },
  541. setEditingBill:function(id){
  542. let _this=this;
  543. this.status.editingBillId=id;
  544. this.rejectedBills.forEach(function (bill) {
  545. if(bill.id+''===id+''){
  546. _this.status.editingBill=bill;
  547. bill.isEditing=true;
  548. }else{
  549. bill.isEditing=false
  550. }
  551. });
  552. this.$forceUpdate();
  553. },
  554. setEditingItem:function(id){
  555. let _this=this;
  556. this.status.editingItemId=id;
  557. this.items.forEach(function (item) {
  558. if(item.id+''===id+''){
  559. _this.status.editingItem=item;
  560. item.isEditing=true;
  561. }else{
  562. item.isEditing=false
  563. }
  564. });
  565. this.$forceUpdate();
  566. },
  567. commitHeader:function () {
  568. let _this=this;
  569. let url='{{url('apiLocal/rejectedBill/store')}}';
  570. axios.post(url,_this.billInputting).then(function (response) {
  571. _this.cleanError();
  572. if(response.data.success==='true'){
  573. tempTip.setDuration(1000);
  574. tempTip.showSuccess('成功录入退单号:'+_this.billInputting.logistic_number_return);
  575. _this.status.inputtingId_owner=_this.billInputting.id_owner;
  576. _this.setEditingBill(response.data.id);
  577. _this.getItemsUnderBill(response.data.id);
  578. _this.cleanHeader();
  579. _this.getRecentRejectedBills();
  580. _this.lockBillPanel();
  581. _this.status.existItemsBeforeAdd=0;
  582. $('#barcode_goods').focus();
  583. }else{
  584. if(response.data.error_fields){
  585. tempTip.setDuration(3000);
  586. tempTip.show('录入失败,字段填写错误');
  587. _this.errors=response.data.error_fields;
  588. if(_this.errors.remark){
  589. _this.errors.bill_remark=_this.errors.remark;
  590. _this.errors.remark = '';
  591. }
  592. }else{
  593. tempTip.setDuration(3000);
  594. tempTip.show('录入失败:'+response.data.fail_info)
  595. }
  596. }
  597. }).catch(function (response) {
  598. tempTip.setDuration(3000);
  599. tempTip.show('提交失败,请重试:'+response.data.fail_info)
  600. alert('连接错误:'+response)
  601. });
  602. },
  603. commitEditItem:function () {
  604. let _this=this;
  605. if(!confirm("确定要提交修改吗?")){return;}
  606. let url='{{url('apiLocal/rejectedBillItem/update')}}';
  607. axios.post(url,_this.itemInputting).then(function (response) {
  608. _this.cleanError();
  609. if(response.data.success==='true'){
  610. tempTip.setDuration(1000);
  611. tempTip.showSuccess('成功修改商品:'+_this.itemInputting.barcode_goods);
  612. _this.cleanItem();
  613. _this.getItemsUnderBill(_this.status.editingBillId);
  614. _this.shiftToCreateItem();
  615. }else{
  616. if(response.data.error_fields){
  617. tempTip.setDuration(3000);
  618. tempTip.show('修改失败,字段填写错误');
  619. _this.errors=response.data.error_fields;
  620. if(_this.errors.remark){
  621. _this.errors.bill_remark=_this.errors.remark;
  622. _this.errors.remark = '';
  623. }
  624. }else{
  625. tempTip.show('修改失败:'+response.data.fail_info)
  626. }
  627. }
  628. }).catch(function (response) {
  629. tempTip.setDuration(3000);
  630. tempTip.show('提交失败,请重试:'+response.data.fail_info)
  631. alert('连接错误:'+response)
  632. });
  633. },
  634. commitEditHeader:function () {
  635. let _this=this;
  636. if(!confirm("确定要提交修改吗?")){return;}
  637. let url='{{url('apiLocal/rejectedBill/update')}}';
  638. axios.post(url,_this.billInputting).then(function (response) {
  639. _this.cleanError();
  640. if(response.data.success==='true'){
  641. tempTip.setDuration(1000);
  642. tempTip.showSuccess('成功修改退单号:'+_this.billInputting.logistic_number_return);
  643. _this.cleanHeader();
  644. _this.getRecentRejectedBills();
  645. _this.shiftToCreate();
  646. }else{
  647. if(response.data.error_fields){
  648. tempTip.setDuration(3000);
  649. tempTip.show('修改失败,字段填写错误');
  650. _this.errors=response.data.error_fields;
  651. }else{
  652. tempTip.show('修改失败:'+response.data.fail_info)
  653. }
  654. }
  655. }).catch(function (response) {
  656. tempTip.setDuration(3000);
  657. tempTip.show('提交失败,请重试:'+response.data.fail_info)
  658. alert('连接错误:'+response)
  659. });
  660. },
  661. commitItem:function () {
  662. let _this=this;
  663. let url='{{url('apiLocal/rejectedBillItem/store')}}';
  664. _this.itemInputting.id_rejected_bill=_this.status.editingBill.id;
  665. axios.post(url,_this.itemInputting).then(function (response) {
  666. _this.cleanError();
  667. if(response.data.success==='true'){
  668. tempTip.setDuration(1000);
  669. tempTip.showSuccess('成功录入退单商品:'+_this.itemInputting.name_goods);
  670. _this.status.endAndPackCommitEdited=false;
  671. _this.lockBillPanel();
  672. _this.getItemsUnderBill(_this.status.editingBill.id);
  673. _this.cleanItem();
  674. $('#barcode_goods').focus();
  675. }else{
  676. if(response.data.error_fields){
  677. tempTip.setDuration(3000);
  678. tempTip.show('录入失败,字段填写错误');
  679. _this.errors=response.data.error_fields;
  680. }else{
  681. tempTip.show('录入失败:'+response.data.fail_info)
  682. }
  683. }
  684. }).catch(function (response) {
  685. tempTip.setDuration(3000);
  686. tempTip.show('提交失败,请重试:'+response.data.fail_info)
  687. alert('连接错误:'+response)
  688. });
  689. },
  690. endAndPackCommitEdit:function () {
  691. let _this=this;
  692. if(_this.items.length===0){
  693. if(confirm('没有填加明细项,确定要退出详细编辑模式吗?')){
  694. _this.cancelPackCommitEdit();
  695. }
  696. return;
  697. }else{
  698. if(!confirm('确定要提交填加的明细项吗?提交后即不可修改')){
  699. return;
  700. }
  701. }
  702. let ids=[];
  703. _this.items.forEach(function(item){
  704. ids.push(item.id);
  705. });
  706. let url='{{url('apiLocal/rejectedBillItem/packConfirm')}}';
  707. tempTip.setDuration(5000);
  708. tempTip.waitingTip('与外部交互中,请稍候');
  709. axios.post(url,{'ids':ids}).then(function (response) {
  710. _this.cleanError();
  711. tempTip.cancelWaitingTip();
  712. if(response&&response.data&&response.data.success!=='false'){
  713. if(response.data.success=='exception'){
  714. _this.status.lockingIsLoadedInput=true;
  715. _this.billInputting.is_loaded=3;
  716. tempTip.show('富勒入库异常,请手动校对');
  717. }else if(typeof(response.data.bill_is_loaded)!='undefined'){
  718. if(response.data.bill_is_loaded===true){
  719. _this.status.editingBill.is_loaded=1;
  720. _this.billInputting.is_loaded=1;
  721. _this.billInputting.isLoadSign=true;
  722. // _this.status.lockingIsLoadedInput=true;
  723. tempTip.okWindow('该批商品状态已改为“入库”','已处理');
  724. }
  725. }
  726. tempTip.setDuration(5000);
  727. switch(response.data.remote_result){
  728. case 'fail': tempTip.show('与客户服务器通讯异常,明细未被外部处理,请联系系统相关同事');break;
  729. case 'none': tempTip.show('客户未返回明细处理信息,请联系系统相关同事检查');break;
  730. case 'received':tempTip.show('该单之前已提交过给客户服务器');break;
  731. case 'storable': tempTip.showSuccess('WMS尚未推单,客户返回可以入库,所以状态为“待推单”','已处理该待推单');break;
  732. default: tempTip.showSuccess('成功录入所有退单商品并已上传至外部');break;
  733. }
  734. _this.status.endAndPackCommitEdited=true;
  735. _this.cancelPackCommitEdit();
  736. }else{
  737. tempTip.setDuration(4000);
  738. let fail_info='';
  739. if(response.data)
  740. fail_info=response.data.fail_info;
  741. tempTip.show('录入明细列表失败,请重试:'+fail_info)
  742. }
  743. }).catch(function (response) {
  744. tempTip.cancelWaitingTip();
  745. tempTip.setDuration(3000);
  746. let fail_info='';
  747. if(response.data)
  748. fail_info=response.data.fail_info;
  749. tempTip.show('提交失败,请重试:'+fail_info);
  750. alert('连接错误:'+response)
  751. });
  752. },
  753. cancelPackCommitEdit:function () {
  754. let _this=this;
  755. if(_this.items.length===0&&!_this.status.endAndPackCommitEdited){
  756. _this.unlockBillPanel();
  757. return;
  758. }else{
  759. if(_this.status.endAndPackCommitEdited){
  760. _this.unlockBillPanel();
  761. return;
  762. }else{
  763. if(!confirm('已填加的明细尚未提交,回到表头编辑将取消已填加明细,是否确定?')){
  764. return;
  765. }
  766. }
  767. }
  768. let ids=[];
  769. for(let i=_this.status.existItemsBeforeAdd;i<_this.items.length;i++){
  770. ids.push(_this.items[i].id);
  771. }
  772. if(ids.length===0){_this.unlockBillPanel();return;}
  773. let url='{{url('apiLocal/rejectedBillItem/packDestroy')}}';
  774. axios.post(url,{'ids':ids}).then(function (response) {
  775. _this.cleanError();
  776. if(response.data.success==='true'){
  777. _this.status.editingBill=null;
  778. _this.unlockBillPanel();
  779. }else{
  780. tempTip.show('数据操作失败,请重试:'+response.data.fail_info)
  781. }
  782. }).catch(function (response) {
  783. tempTip.setDuration(3000);
  784. tempTip.show('提交失败,请重试:'+response.data.fail_info)
  785. alert('连接错误:'+response)
  786. });
  787. },
  788. lockBillPanel:function () {
  789. this.status.lockingBillPanel=true;
  790. $('input,select').blur();
  791. },
  792. unlockBillPanel:function () {
  793. this.status.lockingBillPanel=false;
  794. this.status.editingBill=null;
  795. this.status.editingBillId='';
  796. this.shiftToCreate();
  797. },
  798. getRecentRejectedBills:function () {
  799. let _this=this;
  800. let url='{{url('apiLocal/rejectedBill/apiGetRecent')}}';
  801. axios.post(url).then(function (response) {
  802. if(response.data.success==='true'){
  803. _this.rejectedBills=response.data.rejectedBills;
  804. _this.setEditingBill(_this.status.editingBillId)
  805. }else{
  806. tempTip.show('加载新增内容失败,可尝试刷新页面');
  807. }
  808. }).catch(function (response) {
  809. alert('连接错误:'+response);
  810. tempTip.show('加载新增内容失败,可尝试刷新页面!');
  811. });
  812. },
  813. getItemsUnderBill:function (billId,func) {
  814. let _this=this;
  815. let url='{{url('apiLocal/rejectedBillItem/apiGet')}}';
  816. axios.post(url,{id_rejected_bill:billId}).then(function (response) {
  817. if(response.data.success==='true'){
  818. response.data.items.forEach(function(item){
  819. item.isEditing=false;
  820. });
  821. _this.items=response.data.items;
  822. if(typeof func!=='undefined'){
  823. func()
  824. }
  825. _this.listenEnterAndJump();
  826. setTimeout(function(){$('#barcode_goods').focus();},500)
  827. }else{
  828. tempTip.show('加载相关明细失败,可尝试刷新页面');
  829. }
  830. }).catch(function (response) {
  831. alert('连接错误:'+response);
  832. tempTip.show('加载相关明细失败,可尝试刷新页面!');
  833. });
  834. },
  835. deleteItem:function (e) {
  836. if(!confirm('确定要删除该明细吗?不可恢复')){return}
  837. let _this=this;
  838. let id = $(e.target).parents('tr').attr('data-id');
  839. let url='{{url('apiLocal/rejectedBillItem/apiDelete')}}';
  840. axios.post(url,{id:id}).then(function (response) {
  841. if(response.data.success==='true'){
  842. _this.items.forEach(function(item,i){
  843. if(item.id+''===id+''){
  844. _this.items.splice(i, 1);
  845. }
  846. });
  847. }else{
  848. tempTip.show('删除失败,可尝试刷新页面再操作');
  849. }
  850. }).catch(function (response) {
  851. alert('连接错误:'+response);
  852. tempTip.show('删除失败,可尝试刷新页面!');
  853. });
  854. },
  855. editBill:function (e) {
  856. let _this=this;
  857. let billId = $(e.target).parent('tr').attr('data-id');
  858. let billTarget='';
  859. this.rejectedBills.every(function(bill){
  860. if(bill.id+''===billId+''){
  861. billTarget=bill;
  862. return false;
  863. }
  864. return true;
  865. });
  866. if(billTarget){
  867. this.billInputting = JSON.parse(JSON.stringify(billTarget));
  868. this.shiftToEdit();
  869. this.setEditingBill(billTarget.id)
  870. }
  871. this.getItemsUnderBill(billTarget.id,function () {
  872. _this.status.existItemsBeforeAdd=_this.items.length;
  873. });
  874. },
  875. editItem:function (e) {
  876. let _this=this;
  877. let itemId = $(e.target).parent('tr').attr('data-id');
  878. let itemTarget='';
  879. this.items.every(function(item){
  880. if(item.id+''===itemId+''){
  881. itemTarget=item;
  882. return false;
  883. }
  884. return true;
  885. });
  886. if(itemTarget){
  887. this.itemInputting = JSON.parse(JSON.stringify(itemTarget));
  888. this.shiftToEditItem();
  889. this.setEditingItem(itemTarget.id)
  890. }
  891. // this.getItemsUnderBill(this.status.editingBillId,function () {});
  892. },
  893. shiftToEditItem:function () {
  894. this.cleanError();
  895. this.status.itemCreating=false;
  896. this.status.itemEditing=true;
  897. setTimeout(function () {
  898. $('.tooltipOn').tooltip({'trigger':'hover'});
  899. },50)
  900. },
  901. shiftToEdit:function () {
  902. this.cleanError();
  903. this.status.billCreating=false;
  904. this.status.billEditing=true;
  905. setTimeout(function () {
  906. $('.tooltipOn').tooltip({'trigger':'hover'});
  907. },50)
  908. },
  909. shiftToCreateItem:function () {
  910. this.cleanError();
  911. this.cleanItem();
  912. this.status.itemCreating=true;
  913. this.status.itemEditing=false;
  914. this.items.forEach(function (item) {
  915. item.isEditing=false;
  916. });
  917. $('.tooltipOn').tooltip('hide').tooltip({'trigger':'hover'});
  918. },
  919. shiftToCreate:function () {
  920. this.cleanError();
  921. this.cleanHeader();
  922. this.status.billCreating=true;
  923. this.status.billEditing=false;
  924. this.status.editingBill=null;
  925. this.rejectedBills.forEach(function(rejectedBill){
  926. if(rejectedBill.isEditing===true){
  927. rejectedBill.isEditing=false;
  928. return false;
  929. }
  930. });
  931. $('.tooltipOn').tooltip('hide').tooltip({'trigger':'hover'});
  932. },
  933. locateIdOwner:function (e) {
  934. let _this=this;
  935. let $target=$(e.target);
  936. this.owners.forEach(function(owner){
  937. if(owner.name.includes($target.val())){
  938. _this.billInputting.id_owner=owner.id;
  939. }
  940. });
  941. },
  942. locateLogistic:function (e) {
  943. let _this=this;
  944. let $target=$(e.target);
  945. this.logistics.forEach(function(logistic){
  946. if(logistic.name.includes($target.val())){
  947. _this.billInputting.id_logistic_return=logistic.id;
  948. }
  949. });
  950. },
  951. },
  952. filters:{
  953. isLoaded:function (value) {
  954. return value==1?'是':'否';
  955. }
  956. }
  957. });
  958. </script>
  959. @endsection