create.blade.php 61 KB

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