create.blade.php 56 KB

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