create.blade.php 55 KB

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