create.blade.php 92 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573
  1. @extends('layouts.app')
  2. @section('title')录入-退货管理@endsection
  3. @section('content')
  4. <div class="container-fluid d-none" id="editPanel">
  5. <div class="card mb-2">
  6. <div style="position: relative" v-if="status.lockingBillPanel">
  7. <div style="background-color: #aaa; height: 535px; opacity: 0.5;
  8. width:100%;z-index: 9; position: absolute" class="d-flex ">
  9. </div>
  10. <div style="height: 550px;
  11. width:100%;z-index: 10; position: absolute" class="d-flex align-items-center ">
  12. <button class="btn btn-info flex-fill" @click="cancelPackCommitEdit">取消锁定</button>
  13. </div>
  14. </div>
  15. <div class="row">
  16. <div class="col-7">
  17. <div class="card-body">
  18. <div class="list-group" style="max-height: 477px;overflow-y: scroll">
  19. <table class="table table-sm table-striped table-info table-hover table-bordered">
  20. <tr>
  21. <th>创建时间</th>
  22. <th>客户名称</th>
  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. </tr>
  34. <tr :class="[rejectedBill.isEditing?'bg-info':'']"
  35. v-for="rejectedBill in rejectedBills" :data-id="rejectedBill.id" @click="editBill">
  36. <td>@{{rejectedBill.created_at | dateNoYear}}</td>
  37. <td>@{{rejectedBill.owner_name }}</td>
  38. <td>@{{rejectedBill.logistic_number_return }}</td>
  39. <td>@{{rejectedBill.logistic_name}}</td>
  40. <td>@{{rejectedBill.sender}}</td>
  41. <td>@{{rejectedBill.mobile_sender}}</td>
  42. <td>@{{rejectedBill.fee_collected}}</td>
  43. <td>@{{rejectedBill.order_number}}</td>
  44. <td>@{{rejectedBill.logistic_number}}</td>
  45. <td>@{{rejectedBill.is_loaded|isLoaded}}</td>
  46. {{-- <td>@{{rejectedBill.remark}}</td>--}}
  47. @can('退货管理-删除')
  48. <td>
  49. <button class="btn btn-sm btn-outline-danger"
  50. @click.stop="deleteBill(rejectedBill)">删
  51. </button>
  52. </td>@endcan
  53. </tr>
  54. </table>
  55. </div>
  56. </div>
  57. </div>
  58. <div class="col-5 disabled">
  59. <div class="card-body ml-n4">
  60. <table class="table table-striped table-sm table-bordered"
  61. :class="[status.billEditing?'bg-info':'']">
  62. <tr>
  63. <td>
  64. <div class="form-group mb-0">
  65. <label for="id_owner" class="col-form-label text-right">客户名称</label>
  66. <div class="input-group">
  67. <select name="id_owner" id="id_owner" class="form-control"
  68. :class="[errors.id_owner?'is-invalid':'']"
  69. v-model="billInputting.id_owner" required data-focusOrder="1">
  70. <option value=""></option>
  71. <option v-for="owner in owners" :value="owner.id">@{{ owner.name }}
  72. </option>
  73. </select>
  74. <input type="text" class="form-control input-group-prepend"
  75. placeholder="输入关键字定位客户名称"
  76. name="locateOwnerSearch" autocomplete="off" @input="locateIdOwner"
  77. v-model="billInputting.locateOwnerSearch">
  78. <span class="invalid-feedback" v-if="errors.id_owner"><strong>@{{ errors.id_owner[0] }}</strong></span>
  79. </div>
  80. </div>
  81. </td>
  82. <td>
  83. <div class="form-group mb-0">
  84. <label for="sender" class="col-form-label text-right">姓名</label>
  85. <input type="text" class="form-control" :class="[errors.sender?'is-invalid':'']"
  86. data-focusOrder="5"
  87. name="sender" id="sender" autocomplete="off"
  88. v-model="billInputting.sender">
  89. <span class="invalid-feedback" v-if="errors.sender"><strong>@{{errors.sender[0] }}</strong></span>
  90. </div>
  91. </td>
  92. </tr>
  93. <tr>
  94. <td>
  95. <div class="form-group mb-0">
  96. <label for="logistic_number_return"
  97. class="col-form-label text-right">退回单号</label>
  98. <input type="text" class="form-control"
  99. :class="[errors.logistic_number_return?'is-invalid':'']"
  100. data-focusOrder="2"
  101. name="logistic_number_return" id="logistic_number_return"
  102. autocomplete="off" v-model="billInputting.logistic_number_return"
  103. @change="logistic_number_returnChange"
  104. required>
  105. <span class="invalid-feedback" v-if="errors.logistic_number_return"><strong>@{{errors.logistic_number_return[0] }}</strong></span>
  106. </div>
  107. </td>
  108. <td>
  109. <div class="form-group mb-0">
  110. <label for="fee_collected" class="col-form-label text-right">到付费用</label>
  111. <input type="text" class="form-control"
  112. :class="[errors.fee_collected?'is-invalid':'']"
  113. data-focusOrder=""
  114. v-model="billInputting.fee_collected" name="fee_collected"
  115. id="fee_collected" autocomplete="off">
  116. <span class="invalid-feedback" v-if="errors.fee_collected"><strong>@{{errors.fee_collected[0] }}</strong></span>
  117. </div>
  118. </td>
  119. </tr>
  120. <tr>
  121. <td>
  122. <div class="form-group mb-0">
  123. <label for="id_logistic_return" class="col-form-label text-right">退回公司</label>
  124. <div class="input-group">
  125. <select name="id_logistic_return" id="id_logistic_return"
  126. class="form-control"
  127. data-focusOrder="3"
  128. :class="[errors.id_logistic_return?'is-invalid':'']"
  129. v-model="billInputting.id_logistic_return" required>
  130. <option value=""></option>
  131. <option v-for="logistic in logistics" :value="logistic.id">
  132. @{{logistic.name}}
  133. </option>
  134. </select>
  135. <input type="text" class="form-control input-group-prepend"
  136. placeholder="输入关键字定位物流公司"
  137. name="locateLogisticSearch" autocomplete="off"
  138. @input="locateLogistic" v-model="billInputting.locateLogisticSearch">
  139. <span class="invalid-feedback" v-if="errors.id_logistic_return"><strong>@{{errors.id_logistic_return[0] }}</strong></span>
  140. </div>
  141. </div>
  142. </td>
  143. <td>
  144. <div class="form-group mb-0">
  145. <label for="order_number" class="col-form-label text-right">订单号</label>
  146. <input type="text" class="form-control"
  147. :class="[errors.order_number?'is-invalid':'']"
  148. data-focusOrder="6"
  149. name="order_number" id="order_number" autocomplete="off"
  150. v-model="billInputting.order_number">
  151. <span class="invalid-feedback" v-if="errors.order_number"><strong>@{{ errors.order_number[0] }}</strong></span>
  152. </div>
  153. </td>
  154. </tr>
  155. <tr>
  156. <td>
  157. <div class="form-group mb-0">
  158. <label for="mobile_sender" class="col-form-label text-right">电话</label>
  159. <input type="text" class="form-control"
  160. :class="[errors.mobile_sender?'is-invalid':'']"
  161. data-focusOrder="4"
  162. name="mobile_sender" id="mobile_sender" autocomplete="off"
  163. v-model="billInputting.mobile_sender" required>
  164. <span class="invalid-feedback" v-if="errors.mobile_sender"><strong>@{{ errors.mobile_sender[0] }}</strong></span>
  165. </div>
  166. </td>
  167. <td>
  168. <div class="form-group mb-0">
  169. <label for="logistic_number" class="col-form-label text-right">原单号</label>
  170. <button class="btn btn-outline-primary btn-sm"
  171. @click="billInputting.logistic_number='原单退回'"
  172. style="transform: scale(0.9)">原单退回
  173. </button>
  174. <input type="text" class="form-control"
  175. :class="[errors.logistic_number?'is-invalid':'']"
  176. data-focusOrder="7"
  177. name="logistic_number" id="logistic_number" autocomplete="off"
  178. v-model="billInputting.logistic_number"
  179. >
  180. <span class="invalid-feedback" v-if="errors.logistic_number"><strong>@{{errors.logistic_number[0] }}</strong></span>
  181. </div>
  182. </td>
  183. </tr>
  184. <tr>
  185. <td>
  186. <div class="form-group mb-0">
  187. <label for="bill_remark" class="col-form-label text-right">备注</label>
  188. <input type="text" class="form-control"
  189. :class="[errors.bill_remark?'is-invalid':'']"
  190. data-focusOrder="9"
  191. name="remark" id="bill_remark" autocomplete="off"
  192. v-model="billInputting.remark" required>
  193. <span class="invalid-feedback" v-if="errors.bill_remark"><strong>@{{ errors.remark[0] }}</strong></span>
  194. </div>
  195. </td>
  196. <td>
  197. <div class="form-group mb-0">
  198. <label for="is_loaded" class="col-form-label text-right">是否入库</label>
  199. <div v-if="status.isLoadSign" class="text-danger">系统标计为入库</div>
  200. <select name="is_loaded" id="is_loaded" class="form-control"
  201. :class="[errors.is_loaded?'is-invalid':'']"
  202. data-focusOrder="8" :disabled="status.lockingIsLoadedInput"
  203. v-model="billInputting.is_loaded" required>
  204. <option value="0">否</option>
  205. <option value="1">是</option>
  206. <option value="null">无需入库</option>
  207. <option value="3">上传异常</option>
  208. </select>
  209. <span class="invalid-feedback" v-if="errors.is_loaded"><strong>@{{errors.is_loaded[0]}}</strong></span>
  210. </div>
  211. </td>
  212. </tr>
  213. <tr v-if="billInputting.id_owner==='94'">
  214. <td>
  215. <div class="form-group mb-0">
  216. <label for="common_01" class="col-form-label text-right">寄件方省</label>
  217. <input type="text" class="form-control"
  218. :class="[errors.common_01?'is-invalid':'']"
  219. data-focusOrder="10"
  220. name="common_01" id="common_01" autocomplete="off"
  221. v-model="billInputting.common_01" required>
  222. <span class="invalid-feedback" v-if="errors.common_01"><strong>@{{ errors.common_01[0] }}</strong></span>
  223. </div>
  224. </td>
  225. <td>
  226. <div class="form-group mb-0">
  227. <label for="common_02" class="col-form-label text-right">重量</label>
  228. <input type="text" class="form-control"
  229. :class="[errors.common_02?'is-invalid':'']"
  230. data-focusOrder="11"
  231. name="common_02" id="common_02" autocomplete="off"
  232. v-model="billInputting.common_02" required>
  233. <span class="invalid-feedback" v-if="errors.common_02"><strong>@{{ errors.common_02[0] }}</strong></span>
  234. </div>
  235. </td>
  236. </tr>
  237. <tr>
  238. <td>
  239. <div class="form-group mb-0 align-items-center row">
  240. <div class="col-2" v-if="status.billEditing">
  241. <button class="btn btn-success btn-sm tooltipOn" @click="shiftToCreate"
  242. title="点击取消编辑,进入新增状态">取消
  243. </button>
  244. </div>
  245. <div class="col-8" :class="[status.billCreating?'offset-2':'']">
  246. <input v-if="status.billCreating" type="button"
  247. class="btn btn-success form-control" value="提交新条目"
  248. @click="commitHeader">
  249. <input v-if="status.billEditing" type="button"
  250. class="btn btn-dark form-control" value="修改"
  251. @click="commitEditHeader">
  252. </div>
  253. </div>
  254. </td>
  255. <td>
  256. </td>
  257. </tr>
  258. </table>
  259. </div>
  260. </div>
  261. </div>
  262. </div>
  263. <div class="card" v-if="status.editingBill">
  264. <div class="row">
  265. <div class="col-7">
  266. <div class="card-body">
  267. <div class="list-group">
  268. <table class="table table-sm table-striped table-warning table-hover table-bordered">
  269. <tr>
  270. <th class="text-center">序号</th>
  271. <th class="text-center">商品条码</th>
  272. <th class="text-center">商品名称</th>
  273. <th class="text-center">数量</th>
  274. <th class="text-center">是否正品</th>
  275. <th class="text-center">生产日期</th>
  276. <th class="text-center">效期</th>
  277. <th class="text-center">批次号</th>
  278. <th class="text-center">备注</th>
  279. <th class="text-center">外箱图</th>
  280. <th class="text-center">产品图</th>
  281. <th class="text-center">照片</th>
  282. @can('退货管理-删除')
  283. <th class="text-center">操作</th>@endcan
  284. </tr>
  285. <tr :class="[item.isEditing?'bg-warning':'']"
  286. v-for="(item,i) in items" :data-id="item.id" @click="editItem">
  287. <td>@{{i+1}}</td>
  288. <td>@{{item.barcode_goods }}</td>
  289. <td>@{{item.name_goods }}</td>
  290. <td>@{{item.amount}}</td>
  291. <td>@{{item.quality_label}}</td>
  292. <td>@{{item.made_at}}</td>
  293. <td>@{{item.validity_at}}</td>
  294. <td>@{{item.batch_number}}</td>
  295. <td>@{{item.remark}}</td>
  296. <td>
  297. <div align="center" @mouseleave="removeCommonImg('common_img_package'+item.id)" @mouseenter="commonImg('img_package'+item.id,item.package_images)">
  298. <div>
  299. <input class="btn btn-sm btn-outline-secondary" type="button" @click="certiimg(item.id,'外箱')" value="上传图片 "/>
  300. <input multiple type="file" @change="submitImages($event,i)" :id="item.id"
  301. style="display: none" accept="image/gif,image/jpeg,image/jpg,image/png,image/svg"/>
  302. </div>
  303. <div :id="'img_package'+item.id">
  304. <img v-for="uploadFile in item.package_images" :src="imgPrefix+uploadFile.url+'-thumbnail.'+uploadFile.type">
  305. </div>
  306. </div>
  307. </td>
  308. <td>
  309. <div align="center" @mouseleave="removeCommonImg('common_img_commodity'+item.id)" @mouseenter="commonImg('img_commodity'+item.id,item.commodity_images)">
  310. <div>
  311. <input class="btn btn-sm btn-outline-secondary" type="button" @click="certiimg(item.id,'产品')" value="上传图片 "/>
  312. <input multiple type="file" @change="submitImages($event,i)" :id="item.id"
  313. style="display: none" accept="image/gif,image/jpeg,image/jpg,image/png,image/svg"/>
  314. </div>
  315. <div :id="'img_commodity'+item.id">
  316. <img v-for="uploadFile in item.commodity_images" :src="imgPrefix+uploadFile.url+'-thumbnail.'+uploadFile.type">
  317. </div>
  318. </div>
  319. </td>
  320. <td>
  321. <div align="center" @mouseleave="removeCommonImg('common_img_'+item.id)" @mouseenter="commonImg('img_'+item.id,item.upload_files)">
  322. <button class="btn btn-outline-secondary btn-sm" @click="takePhoto(item.id,i)">拍照上传</button>
  323. <div :id="'img_'+item.id">
  324. <img v-for="uploadFile in item.upload_files" :src="imgPrefix+uploadFile.url+'-thumbnail.'+uploadFile.type">
  325. </div>
  326. </div>
  327. </td>
  328. <td class="text-center">
  329. <button class="btn btn-outline-success btn-sm" @click="enableCamera(true);">开启摄像头</button>
  330. @can('退货管理-删除')<button class="btn btn-outline-danger btn-sm" @click="deleteItem">删</button>@endcan
  331. </td>
  332. </tr>
  333. </table>
  334. </div>
  335. </div>
  336. </div>
  337. <div class="col-5">
  338. <div class="card-body ml-n4">
  339. <table class="table table-striped table-sm table-bordered"
  340. :class="[status.itemEditing?'bg-warning':'']">
  341. <tr>
  342. <td>
  343. <div class="form-group mb-0">
  344. <label for="barcode_goods" class="col-form-label text-right">商品条码</label>
  345. <input type="text" class="form-control"
  346. :class="[errors.barcode_goods?'is-invalid':'']"
  347. data-focusOrder="11"
  348. name="barcode_goods" id="barcode_goods" autocomplete="off"
  349. v-model="itemInputting.barcode_goods"
  350. @change="barcode_goodsChange"
  351. >
  352. <span class="invalid-feedback" v-if="errors.barcode_goods"><strong>@{{errors.barcode_goods[0] }}</strong></span>
  353. </div>
  354. </td>
  355. <td>
  356. <div class="form-group mb-0">
  357. <label for="name_goods" class="col-form-label text-right">商品名称</label>
  358. <input type="text" class="form-control"
  359. :class="[errors.name_goods?'is-invalid':'']"
  360. data-focusOrder="14"
  361. name="name_goods" id="name_goods" autocomplete="off"
  362. v-model="itemInputting.name_goods"
  363. @change="name_goodsChange"
  364. >
  365. <span class="invalid-feedback" v-if="errors.name_goods"><strong>@{{errors.name_goods[0] }}</strong></span>
  366. </div>
  367. </td>
  368. </tr>
  369. <tr>
  370. <td>
  371. <div class="form-group mb-0">
  372. <label for="amount" class="col-form-label text-right">数量</label>
  373. <input type="" class="form-control" :class="[errors.amount?'is-invalid':'']"
  374. data-focusOrder="12"
  375. name="amount" id="amount" autocomplete="off"
  376. v-model="itemInputting.amount" required>
  377. <span class="invalid-feedback" v-if="errors.amount"><strong>@{{errors.amount[0] }}</strong></span>
  378. </div>
  379. </td>
  380. <td>
  381. <div class="form-group mb-0">
  382. <label for="qualityLabel.name" class="col-form-label text-right">是否正品</label>
  383. <div class="form-control" :class="[errors.id_quality_label?'is-invalid':'']">
  384. <span><input id="id_quality_label_space" type="radio"
  385. name="id_quality_label"
  386. data-focusOrder="13" required="required" checked><label
  387. for="id_quality_label_space">留空</label>&nbsp;</span>
  388. <span v-for="qualityLabel in qualityLabels">
  389. <input type="radio" name="id_quality_label" :value="qualityLabel.id"
  390. data-focusOrder="13"
  391. :id="'id_quality_label_'+qualityLabel.id"
  392. v-model="itemInputting.id_quality_label" required><label
  393. for="'id_quality_label_'+qualityLabel.id">@{{qualityLabel.name}}</label>&nbsp;</span>
  394. </div>
  395. <span class="invalid-feedback" v-if="errors.id_quality_label"><strong>@{{errors.id_quality_label[0] }}</strong></span>
  396. </div>
  397. </td>
  398. </tr>
  399. <tr>
  400. <td>
  401. <div class="form-group mb-0">
  402. <label for="made_at" class="col-form-label text-right">生产日期</label>
  403. <input type="date" class="form-control"
  404. :class="[errors.made_at?'is-invalid':'']"
  405. data-focusOrder="16"
  406. name="made_at" id="made_at" autocomplete="off"
  407. v-model="itemInputting.made_at">
  408. <span class="invalid-feedback" v-if="errors.made_at"><strong>@{{errors.made_at[0] }}</strong></span>
  409. </div>
  410. </td>
  411. <td>
  412. <div class="form-group mb-0">
  413. <label for="validity_at" class="col-form-label text-right">效期</label>
  414. <input type="date" class="form-control"
  415. :class="[errors.validity_at?'is-invalid':'']"
  416. data-focusOrder="17"
  417. name="validity_at" id="validity_at" autocomplete="off"
  418. v-model="itemInputting.validity_at">
  419. <span class="invalid-feedback" v-if="errors.validity_at"><strong>@{{errors.validity_at[0] }}</strong></span>
  420. </div>
  421. </td>
  422. </tr>
  423. <tr>
  424. <td>
  425. <div class="form-group mb-0">
  426. <label for="batch_number" class="col-form-label text-right">批次号</label>
  427. <input type="text" class="form-control"
  428. :class="[errors.batch_number?'is-invalid':'']"
  429. data-focusOrder="15"
  430. name="batch_number" id="batch_number" autocomplete="off"
  431. v-model="itemInputting.batch_number"
  432. >
  433. <span class="invalid-feedback" v-if="errors.batch_number"><strong>@{{errors.batch_number[0] }}</strong></span>
  434. </div>
  435. </td>
  436. <td>
  437. <div class="form-group mb-0">
  438. <label for="remark" class="col-form-label text-right">备注</label>
  439. <input type="text" class="form-control" :class="[errors.remark?'is-invalid':'']"
  440. data-focusOrder="15"
  441. name="remark" id="remark" autocomplete="off"
  442. v-model="itemInputting.remark">
  443. <span class="invalid-feedback" v-if="errors.remark"><strong>@{{errors.remark[0] }}</strong></span>
  444. </div>
  445. </td>
  446. </tr>
  447. <tr v-if="!status.itemEditing">
  448. <td>
  449. <div class="form-group mb-0">
  450. <label for="package-image" class="col-form-label text-right">外箱图</label>
  451. <div class="border border-secondary h-auto" id="package-image" style="min-height: 65px"
  452. contenteditable="true"
  453. @paste="pasteImage($event,itemInputting.packageImages)">
  454. <div v-for="(image,i) in itemInputting.packageImages"
  455. class="d-inline-block col-4 position-relative card">
  456. <div class="card-body">
  457. <img :src="image.src" class="card-img-top" :alt="image.file.name">
  458. <div class="float-right position-relative" >
  459. <button type="button" class="btn btn-sm btn-outline-danger"
  460. @click="spliceImage(i,itemInputting.packageImages)">取消
  461. </button>
  462. </div>
  463. </div>
  464. </div>
  465. </div>
  466. </div>
  467. </td>
  468. <td>
  469. <div class="form-group mb-0">
  470. <label for="commodity-image" class="col-form-label text-right">产品图</label>
  471. <div class="border border-secondary h-auto" id="commodity-image" style="min-height: 65px"
  472. contenteditable="true"
  473. @paste="pasteImage($event,itemInputting.commodityImages)">
  474. <div v-for="(image,i) in itemInputting.commodityImages"
  475. class="d-inline-block col-4 position-relative card">
  476. <div class="card-body">
  477. <img :src="image.src" class="card-img-top" :alt="image.file.name">
  478. <div class="float-right position-relative">
  479. <button type="button" class="btn btn-sm btn-outline-danger"
  480. @click="spliceImage(i,itemInputting.commodityImages)">取消
  481. </button>
  482. </div>
  483. </div>
  484. </div>
  485. </div>
  486. </div>
  487. </td>
  488. </tr>
  489. <tr>
  490. <td>
  491. <div class="form-group mb-0 align-items-center row">
  492. <div class="col-2" v-if="status.itemEditing">
  493. <button class="btn btn-success btn-sm tooltipOn" @click="shiftToCreateItem"
  494. title="点击取消编辑,进入新增状态">取消
  495. </button>
  496. </div>
  497. <div class="col-8" :class="[status.itemCreating?'offset-2':'']">
  498. <button v-if="status.itemCreating" class="btn btn-success form-control"
  499. @click="commitItem">添加明细
  500. </button>
  501. <input v-if="status.itemEditing" type="button"
  502. class="btn btn-dark form-control" value="修改" @click="commitEditItem">
  503. </div>
  504. </div>
  505. </td>
  506. <td>
  507. </td>
  508. </tr>
  509. <tr>
  510. <td colspan="2">
  511. <div class="form-group mb-0">
  512. <div class="col-8 offset-2 mt-2 mb-2">
  513. <button class="btn btn-dark form-control" @click="endAndPackCommitEdit">
  514. 结束添加并提交
  515. </button>
  516. </div>
  517. </div>
  518. </td>
  519. </tr>
  520. </table>
  521. </div>
  522. </div>
  523. </div>
  524. </div>
  525. <div id="drag" class="col-4 p-0" style="position:fixed;bottom: 30px;left: 10px;">
  526. <div class="text-left text-success">连接摄像头拍照</div>
  527. <video id="photo" width="50%" height="auto" controls></video>
  528. <canvas id='canvas'width='400' height='300' hidden></canvas>
  529. </div>
  530. </div>
  531. @endsection
  532. @section('lastScript')
  533. <script>
  534. //鼠标拖动 drag
  535. $(function() {
  536. let posX,posY;
  537. let drag = document.getElementById("drag");
  538. drag.onmousedown = function(e) {
  539. posX = event.x - drag.offsetLeft; //获得横坐标x
  540. posY = event.y - drag.offsetTop; //获得纵坐标y
  541. document.onmousemove = mousemove; //调用函数,只要一直按着按钮就能一直调用
  542. }
  543. document.onmouseup = function() {
  544. document.onmousemove = null; //鼠标举起,停止
  545. }
  546. function mousemove(ev) {
  547. if (ev == null) ev = window.event;
  548. let left= (ev.clientX - posX);
  549. let top= (ev.clientY - posY);
  550. let pageWidth=document.body.scrollWidth;//网页正文宽度
  551. let pageHeight=window.screen.availHeight;//屏幕工作区高度
  552. //限定拖动区域
  553. if (left <0)left=0;
  554. if (left >pageWidth)left=pageWidth;
  555. if (top <0)top=0;
  556. if (top >pageHeight)top=pageHeight;
  557. drag.style.left = left + "px";
  558. drag.style.top = top + "px";
  559. }
  560. })
  561. let MediaUtils = {
  562. /**
  563. * 获取用户媒体设备(处理兼容的问题)
  564. * @param videoEnable {boolean} - 是否启用摄像头
  565. * @param audioEnable {boolean} - 是否启用麦克风
  566. * @param callback {Function} - 处理回调
  567. */
  568. getUserMedia: function (videoEnable, audioEnable, callback) {
  569. navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia
  570. || navigator.msGetUserMedia || window.getUserMedia;
  571. let constraints = {video: videoEnable, audio: audioEnable};
  572. if (navigator.mediaDevices && navigator.mediaDevices.getUserMedia) {
  573. navigator.mediaDevices.getUserMedia(constraints).then(function (stream) {
  574. callback(false, stream);
  575. })['catch'](function (err) {
  576. callback(err);
  577. });
  578. } else if (navigator.getUserMedia) {
  579. navigator.getUserMedia(constraints, function (stream) {
  580. callback(false, stream);
  581. }, function (err) {
  582. callback(err);
  583. });
  584. } else {
  585. callback(new Error('Not support userMedia'));
  586. }
  587. },
  588. /**
  589. * 关闭媒体流
  590. * @param stream {MediaStream} - 需要关闭的流
  591. */
  592. closeStream: function (stream) {
  593. if (typeof stream.stop === 'function') {
  594. stream.stop();
  595. } else {
  596. let trackList = [stream.getAudioTracks(), stream.getVideoTracks()];
  597. for (let i = 0; i < trackList.length; i++) {
  598. let tracks = trackList[i];
  599. if (tracks && tracks.length > 0) {
  600. for (let j = 0; j < tracks.length; j++) {
  601. let track = tracks[j];
  602. if (typeof track.stop === 'function') {
  603. track.stop();
  604. }
  605. }
  606. }
  607. }
  608. }
  609. }
  610. };
  611. let vueList = new Vue({
  612. el: "#editPanel",
  613. data: {
  614. imgPrefix:"{{asset("/storage")}}",
  615. // 用于存放 MediaRecorder 对象和音频Track,关闭录制和关闭媒体设备需要用到
  616. recorder:'',
  617. mediaStream:'',
  618. // 用于存放录制后的音频文件对象和录制结束回调
  619. recorderFile:'',
  620. stopRecordCallback:'',
  621. // 用于存放是否开启了视频录制
  622. videoEnabled:false,
  623. status: {
  624. billCreating: true,
  625. billEditing: false,
  626. itemCreating: true,
  627. itemEditing: false
  628. ,
  629. editingBill: null,
  630. editingBillId: '',
  631. editingItem: null,
  632. editingItemId: ''
  633. ,
  634. inputtingId_owner: '',
  635. endAndPackCommitEdited: false,
  636. lockingBillPanel: false,
  637. lockingIsLoadedInput: false,
  638. existItemsBeforeAdd: 0
  639. },
  640. itemInputting: {
  641. barcode_goods: "", name_goods: "", amount: "1", id_quality_label: "",
  642. batch_number: "", validity_at: "", remark: "", made_at: "",
  643. packageImages: [], commodityImages: [],
  644. },
  645. billInputting: {
  646. id_owner: "", mobile_sender: "", sender: "", order_number: "", remark: "",
  647. logistic_number_return: "", logistic_number: "", id_logistic_return: "",
  648. fee_collected: "", is_loaded: "0", locateLogisticSearch: "", locateOwnerSearch: "",
  649. isLoadSign: false,
  650. },
  651. errors: {
  652. id_owner: "", mobile_sender: "", sender: "", bill_remark: "",
  653. logistic_number_return: "", logistic_number: "", id_logistic_return: "",
  654. fee_collected: "", is_loaded: "",
  655. barcode_goods: "", name_goods: "", amount: "", id_quality_label: "",
  656. batch_number: "", validity_at: "", remark: "", made_at: "",
  657. },
  658. rejectedBills: {!! $rejectedBills??[] !!},
  659. submitImageType:'',
  660. items: [],
  661. owners: [
  662. @foreach($owners as $owner)
  663. {
  664. id: '{{$owner->id}}', name: '{{$owner->name}}', code: '{{$owner->code}}'
  665. },
  666. @endforeach
  667. ],
  668. logistics: [
  669. @foreach($logistics as $logistic)
  670. {
  671. id: '{{$logistic->id}}', name: '{{$logistic->name}}', code: '{{$logistic->code}}'
  672. },
  673. @endforeach
  674. ],
  675. qualityLabels: [
  676. @foreach($qualityLabels as $qualityLabel)
  677. {
  678. id: '{{$qualityLabel->id}}', name: '{{$qualityLabel->name}}'
  679. },
  680. @endforeach
  681. ],
  682. commodityOwnerId: '',
  683. },
  684. mounted: function () {
  685. let _this = this;
  686. $('#editPanel').removeClass('d-none');
  687. $('.tooltipOn').tooltip({'trigger': 'hover'});
  688. $(document).on('keypress', function (e) {
  689. if (_this.itemInputting.barcode_goods) {
  690. if (e.key === '*') {
  691. _this.commitItem();
  692. return false;
  693. }
  694. }
  695. });
  696. this.listenEnterAndJump();
  697. },
  698. methods: {
  699. logistic_number_returnChange: function (e) {
  700. let _this = this;
  701. let number = $(e.target).val();
  702. if (!number) return;
  703. let url = '{{"/apiLocal/logistic/numberFeatures/computeLogisticByNumber"}}';
  704. axios.post(url, {logistic_number_return: number}).then(function (response) {
  705. _this.cleanError();
  706. if (response.data.success === 'true') {
  707. if (response.data.logistic) {
  708. _this.billInputting.id_logistic_return = response.data.logistic.id;
  709. }
  710. }
  711. }).catch(function (response) {
  712. console.log(response);
  713. });
  714. if (_this.status.editingBill) return;
  715. let url_isUnique = '{{"/apiLocal/logistic/logisticNumberReturnIsUnique"}}';
  716. axios.post(url_isUnique, {logistic_number_return: number}).then(function (response) {
  717. _this.cleanError();
  718. if (response.data.success === 'true') {
  719. if (response.data.result === 'true') {
  720. tempTip.okWindow('该退回单号"' + number + '"已有录入其他单', '知道了')
  721. } else _this.seek_order();
  722. }
  723. }).catch(function (response) {
  724. console.log(response);
  725. });
  726. },
  727. spliceImage(i, images) {
  728. if (!confirm('是否取消选择该图片')) return;
  729. images.splice(i, 1);
  730. },
  731. getImages(images) {
  732. return images.map((item) => {
  733. return item.file;
  734. })
  735. },
  736. pasteImage(event,imageArray){
  737. for (let i = 0; i < event.clipboardData.items.length; i++) {
  738. let item = event.clipboardData.items[i];
  739. if (item.kind === 'string') continue;
  740. if (item.type.indexOf('image') === -1) continue;
  741. if (item.kind === 'file'){
  742. let blob = item.getAsFile();
  743. let src = null;
  744. this.blobToBase64(blob).then(res => {
  745. src = res;
  746. imageArray.push({src:res,file:blob});
  747. });
  748. }
  749. }
  750. event.preventDefault();
  751. },
  752. blobToBase64(blob) {
  753. return new Promise((resolve, reject) => {
  754. const fileReader = new FileReader();
  755. fileReader.onload = (e) => {
  756. resolve(e.target.result);
  757. };
  758. fileReader.readAsDataURL(blob);
  759. fileReader.onerror = () => {
  760. reject(new Error('blobToBase64 error'));
  761. };
  762. });
  763. },
  764. barcode_goodsChange: function (e) {
  765. let _this = this;
  766. let barcode = $(e.target).val();
  767. let url = '{{"/apiLocal/commodity/getCommodityByBarcode"}}';
  768. axios.post(url, {
  769. barcode: barcode,
  770. owner_id: _this.billInputting.id_owner
  771. }).then(function (response) {
  772. _this.cleanError();
  773. if (response.data.success === 'true') {
  774. if (response.data.commodity) {
  775. // _this.itemInputting.name_goods=response.data.name;
  776. _this.itemInputting.name_goods = response.data.commodity.name;
  777. _this.commodityOwnerId = response.data.commodity.owner_id;
  778. }
  779. } else {
  780. tempTip.setDuration(3000);
  781. tempTip.show('查找商品条码错误:' + response.data.fail_info)
  782. }
  783. }).catch(function (response) {
  784. tempTip.setDuration(3000);
  785. tempTip.show('未连接至商品表,检查网络');
  786. });
  787. },
  788. name_goodsChange: function (e) {
  789. let _this = this;
  790. let name = $(e.target).val();
  791. this.items.forEach(function (item) {
  792. if (item.barcode_goods + '' === _this.itemInputting.barcode_goods + '') {
  793. item.name_goods = name;
  794. }
  795. });
  796. },
  797. listenEnterAndJump: function () {
  798. let targets = $('select,input');
  799. targets.off('keypress');
  800. targets.on('keypress', function (e) {
  801. if (e.key !== "Enter") return;
  802. let target = $(e.target);
  803. let currentOrder = target.attr('data-focusOrder');
  804. if (currentOrder) {
  805. targets.each(function ($i, $val) {
  806. let checkingTarget = $($val);
  807. let checkingOrder = checkingTarget.attr('data-focusOrder');
  808. if (parseInt(currentOrder) + 1 === parseInt(checkingOrder)) {
  809. checkingTarget.focus();
  810. }
  811. })
  812. }
  813. });
  814. targets.off('change');
  815. targets.on('change', function (e) {
  816. let target = $(e.target);
  817. let currentOrder = target.attr('data-focusOrder');
  818. if (currentOrder) {
  819. targets.each(function ($i, $val) {
  820. let checkingTarget = $($val);
  821. let checkingOrder = checkingTarget.attr('data-focusOrder');
  822. if (parseInt(currentOrder) + 1 === parseInt(checkingOrder)) {
  823. checkingTarget.focus();
  824. }
  825. })
  826. }
  827. })
  828. },
  829. cleanHeader: function () {
  830. for (let key in this.billInputting) {
  831. this.billInputting[key] = '';
  832. }
  833. this.billInputting.id_owner = this.status.inputtingId_owner;
  834. this.billInputting.is_loaded = "0";
  835. this.billInputting.isLoadSign = false;
  836. },
  837. cleanItem: function () {
  838. for (let key in this.itemInputting) {
  839. this.itemInputting[key] = '';
  840. }
  841. this.itemInputting['amount'] = '1';
  842. },
  843. cleanError: function () {
  844. for (let key in this.errors) {
  845. this.errors[key] = '';
  846. }
  847. },
  848. setEditingBill: function (id) {
  849. let _this = this;
  850. this.status.editingBillId = id;
  851. this.rejectedBills.forEach(function (bill) {
  852. if (bill.id + '' === id + '') {
  853. _this.status.editingBill = bill;
  854. bill.isEditing = true;
  855. } else {
  856. bill.isEditing = false
  857. }
  858. });
  859. this.$forceUpdate();
  860. },
  861. setEditingItem: function (id) {
  862. let _this = this;
  863. this.status.editingItemId = id;
  864. this.items.forEach(function (item) {
  865. if (item.id + '' === id + '') {
  866. _this.status.editingItem = item;
  867. item.isEditing = true;
  868. } else {
  869. item.isEditing = false
  870. }
  871. });
  872. this.$forceUpdate();
  873. },
  874. commitHeader: function () {
  875. let _this = this;
  876. let url = '{{url('apiLocal/rejectedBill/store')}}';
  877. tempTip.setDuration(99999);
  878. tempTip.waitingTip('提交中')
  879. axios.post(url, _this.billInputting).then(function (response) {
  880. tempTip.cancelWaitingTip();
  881. _this.cleanError();
  882. if (response.data.success === 'true') {
  883. tempTip.setDuration(1000);
  884. tempTip.showSuccess('成功录入退单号:' + _this.billInputting.logistic_number_return);
  885. _this.status.inputtingId_owner = _this.billInputting.id_owner;
  886. _this.setEditingBill(response.data.id);
  887. _this.getItemsUnderBill(response.data.id);
  888. _this.cleanHeader();
  889. _this.getRecentRejectedBills();
  890. _this.lockBillPanel();
  891. _this.status.existItemsBeforeAdd = 0;
  892. $('#barcode_goods').focus();
  893. } else {
  894. if (response.data.error_fields) {
  895. tempTip.setDuration(3000);
  896. tempTip.show('录入失败,字段填写错误');
  897. _this.errors = response.data.error_fields;
  898. if (_this.errors.remark) {
  899. _this.errors.bill_remark = _this.errors.remark;
  900. _this.errors.remark = '';
  901. }
  902. } else {
  903. tempTip.setDuration(3000);
  904. tempTip.show('录入失败:' + response.data.fail_info)
  905. }
  906. }
  907. }).catch(function (response) {
  908. tempTip.setDuration(3000);
  909. tempTip.show('提交失败,请重试:' + response.data.fail_info)
  910. alert('连接错误:' + response)
  911. });
  912. },
  913. commitEditItem: function () {
  914. let _this = this;
  915. if (!confirm("确定要提交修改吗?")) {
  916. return;
  917. }
  918. let url = '{{url('apiLocal/rejectedBillItem/update')}}';
  919. axios.post(url, _this.itemInputting).then(function (response) {
  920. _this.cleanError();
  921. if (response.data.success === 'true') {
  922. tempTip.setDuration(1000);
  923. tempTip.showSuccess('成功修改商品:' + _this.itemInputting.barcode_goods);
  924. _this.cleanItem();
  925. _this.getItemsUnderBill(_this.status.editingBillId);
  926. _this.shiftToCreateItem();
  927. } else {
  928. if (response.data.error_fields) {
  929. tempTip.setDuration(3000);
  930. tempTip.show('修改失败,字段填写错误');
  931. _this.errors = response.data.error_fields;
  932. if (_this.errors.remark) {
  933. _this.errors.bill_remark = _this.errors.remark;
  934. _this.errors.remark = '';
  935. }
  936. } else {
  937. tempTip.show('修改失败:' + response.data.fail_info)
  938. }
  939. }
  940. }).catch(function (response) {
  941. tempTip.setDuration(3000);
  942. tempTip.show('提交失败,请重试:' + response.data.fail_info)
  943. alert('连接错误:' + response)
  944. });
  945. },
  946. commitEditHeader: function () {
  947. let _this = this;
  948. if (!confirm("确定要提交修改吗?")) {
  949. return;
  950. }
  951. let url = '{{url('apiLocal/rejectedBill/update')}}';
  952. tempTip.setDuration(99999);
  953. tempTip.waitingTip('提交中')
  954. axios.post(url, _this.billInputting).then(function (response) {
  955. tempTip.cancelWaitingTip();
  956. _this.cleanError();
  957. if (response.data.success === 'true') {
  958. tempTip.setDuration(1000);
  959. tempTip.showSuccess('成功修改退单号:' + _this.billInputting.logistic_number_return);
  960. _this.cleanHeader();
  961. _this.getRecentRejectedBills();
  962. _this.shiftToCreate();
  963. } else {
  964. if (response.data.error_fields) {
  965. tempTip.setDuration(3000);
  966. tempTip.show('修改失败,字段填写错误');
  967. _this.errors = response.data.error_fields;
  968. } else {
  969. tempTip.show('修改失败:' + response.data.fail_info)
  970. }
  971. }
  972. }).catch(function (response) {
  973. tempTip.setDuration(3000);
  974. tempTip.show('提交失败,请重试:' + response.data.fail_info)
  975. alert('连接错误:' + response)
  976. });
  977. },
  978. checkImageWhetherNeed(item){
  979. if (this.billInputting.id_owner==4)return 0;//幼岚非必要上传外箱及产品图
  980. if (item.id_quality_label!=1){
  981. if (item.commodityImages.length===0){
  982. tempTip.setDuration(3000);
  983. tempTip.show('非正品,请上传外箱图及产品图!');
  984. return 1;
  985. }
  986. }
  987. return 0;
  988. },
  989. setFormDataImage(formData, prefix, images) {
  990. images.forEach((item) => {
  991. formData.append(`${prefix}[]`, item);
  992. });
  993. },
  994. getDamagedFormData(item){
  995. let _this=this;
  996. let formData = new FormData();
  997. if (item.packageImages.length>0){
  998. let packageImages = _this.getImages(item.packageImages);
  999. this.setFormDataImage(formData,'packageImages',packageImages);
  1000. }
  1001. if (item.commodityImages.length>0){
  1002. let commodityImages = _this.getImages(item.commodityImages);
  1003. this.setFormDataImage(formData,'commodityImages',commodityImages);
  1004. }
  1005. formData.append('barcode_goods',item.barcode_goods);
  1006. formData.append('amount',item.amount);
  1007. formData.append('name_goods',item.name_goods);
  1008. formData.append('id_quality_label',item.id_quality_label);
  1009. formData.append('batch_number',item.batch_number);
  1010. formData.append('validity_at',item.validity_at);
  1011. formData.append('made_at',item.made_at);
  1012. formData.append('remark',item.remark);
  1013. formData.append('id_rejected_bill',item.id_rejected_bill);
  1014. return formData;
  1015. },
  1016. commitItem: function () {
  1017. let _this = this;
  1018. if (_this.checkImageWhetherNeed(_this.itemInputting)===1)return;
  1019. let url = '{{url('apiLocal/rejectedBillItem/store')}}';
  1020. _this.itemInputting.id_rejected_bill = _this.status.editingBill.id;
  1021. if (_this.items.length < 1) {
  1022. let baoShiBuFaOwnerId = '';
  1023. _this.owners.forEach(function (owner) {
  1024. if (owner.name === '宝时补发') baoShiBuFaOwnerId = owner.id;
  1025. });
  1026. if (_this.commodityOwnerId != _this.billInputting.id_owner && _this.billInputting.id_owner != baoShiBuFaOwnerId) {
  1027. _this.isChangeOwner(_this.itemInputting.id_rejected_bill);
  1028. }
  1029. }
  1030. let formData = _this.getDamagedFormData(_this.itemInputting);
  1031. axios.post(url, formData,{'Content-Type':'multipart/form-data'}).then(function (response) {
  1032. _this.cleanError();
  1033. if (response.data.success === 'true') {
  1034. tempTip.setDuration(1000);
  1035. tempTip.showSuccess('成功录入退单商品:' + _this.itemInputting.name_goods);
  1036. _this.status.endAndPackCommitEdited = false;
  1037. _this.lockBillPanel();
  1038. _this.getItemsUnderBill(_this.status.editingBill.id);
  1039. _this.cleanItem();
  1040. $('#barcode_goods').focus();
  1041. } else {
  1042. if (response.data.error_fields) {
  1043. tempTip.setDuration(3000);
  1044. tempTip.show('录入失败,字段填写错误');
  1045. _this.errors = response.data.error_fields;
  1046. } else {
  1047. tempTip.show('录入失败:' + response.data.fail_info)
  1048. }
  1049. }
  1050. }).catch(function (response) {
  1051. tempTip.setDuration(3000);
  1052. tempTip.show('提交失败,请重试:' + response.data.fail_info)
  1053. alert('连接错误:' + response)
  1054. });
  1055. },
  1056. isChangeOwner(id_rejected_bill) {
  1057. let _this = this;
  1058. let url = '{{url('apiLocal/rejectedBillItem/reviseOwner')}}';
  1059. window.tempTip.confirm('当前退货记录货主名与录入商品的货主不匹配! ' + '确定校正退货记录货主名吗?', () => {
  1060. window.axios.post(url, {
  1061. commodityOwnerId: _this.commodityOwnerId,
  1062. id_rejected_bill: id_rejected_bill
  1063. }).then(res => {
  1064. if (res.data.success === 'true') {
  1065. let owner_name = '';
  1066. _this.owners.forEach(function (owner) {
  1067. if (owner.id == _this.commodityOwnerId) {
  1068. owner_name = owner.name;
  1069. }
  1070. })
  1071. _this.billInputting.id_owner = _this.commodityOwnerId;
  1072. _this.rejectedBills.forEach(function (rejectedBill) {
  1073. if (id_rejected_bill == rejectedBill.id) rejectedBill.owner_name = owner_name;
  1074. })
  1075. } else {
  1076. tempTip.setDuration(3000);
  1077. tempTip.show(res.data.message);
  1078. return;
  1079. }
  1080. }).catch(err => {
  1081. window.tempTip.setDuration(3000);
  1082. window.tempTip.show("网络错误:" + err);
  1083. return;
  1084. });
  1085. });
  1086. },
  1087. endAndPackCommitEdit: function () {
  1088. let _this = this;
  1089. if (_this.items.length === 0) {
  1090. if (confirm('没有填加明细项,确定要退出详细编辑模式吗?')) {
  1091. _this.cancelPackCommitEdit();
  1092. }
  1093. return;
  1094. } else {
  1095. if (!confirm('确定要提交填加的明细项吗?提交后即不可修改')) {
  1096. return;
  1097. }
  1098. }
  1099. let ids = [];
  1100. _this.items.forEach(function (item) {
  1101. ids.push(item.id);
  1102. });
  1103. let url = '{{url('apiLocal/rejectedBillItem/packConfirm')}}';
  1104. tempTip.setDuration(5000);
  1105. tempTip.waitingTip('与外部交互中,请稍候');
  1106. axios.post(url, {'ids': ids}).then(function (response) {
  1107. _this.cleanError();
  1108. tempTip.cancelWaitingTip();
  1109. if (response && response.data && response.data.success !== 'false') {
  1110. if (response.data.success == 'exception') {
  1111. _this.status.lockingIsLoadedInput = true;
  1112. _this.billInputting.is_loaded = 3;
  1113. tempTip.show('富勒入库异常,请手动校对');
  1114. } else if (typeof (response.data.bill_is_loaded) != 'undefined') {
  1115. if (response.data.bill_is_loaded === true) {
  1116. _this.status.editingBill.is_loaded = 1;
  1117. _this.billInputting.is_loaded = 1;
  1118. _this.billInputting.isLoadSign = true;
  1119. // _this.status.lockingIsLoadedInput=true;
  1120. tempTip.okWindow('该批商品状态已改为“入库”', '已处理');
  1121. }
  1122. }
  1123. tempTip.setDuration(5000);
  1124. switch (response.data.remote_result) {
  1125. case 'fail':
  1126. tempTip.show('与客户服务器通讯异常,明细未被外部处理,请联系系统相关同事');
  1127. break;
  1128. case 'none':
  1129. tempTip.show('客户未返回明细处理信息,请联系系统相关同事检查');
  1130. break;
  1131. case 'received':
  1132. tempTip.show('该单之前已提交过给客户服务器');
  1133. break;
  1134. case 'storable':
  1135. tempTip.showSuccess('WMS尚未推单,客户返回可以入库,所以状态为“待推单”', '已处理该待推单');
  1136. break;
  1137. default:
  1138. tempTip.showSuccess('成功录入所有退单商品并已上传至外部');
  1139. break;
  1140. }
  1141. _this.status.endAndPackCommitEdited = true;
  1142. _this.cancelPackCommitEdit();
  1143. } else {
  1144. tempTip.setDuration(4000);
  1145. let fail_info = '';
  1146. if (response.data)
  1147. fail_info = response.data.fail_info;
  1148. tempTip.show('录入明细列表失败,请重试:' + fail_info)
  1149. }
  1150. }).catch(function (response) {
  1151. tempTip.cancelWaitingTip();
  1152. tempTip.setDuration(3000);
  1153. let fail_info = '';
  1154. if (response.data)
  1155. fail_info = response.data.fail_info;
  1156. tempTip.show('提交失败,请重试:' + fail_info);
  1157. alert('连接错误:' + response)
  1158. });
  1159. },
  1160. cancelPackCommitEdit: function () {
  1161. let _this = this;
  1162. if (_this.items.length === 0 && !_this.status.endAndPackCommitEdited) {
  1163. _this.unlockBillPanel();
  1164. return;
  1165. } else {
  1166. if (_this.status.endAndPackCommitEdited) {
  1167. _this.unlockBillPanel();
  1168. return;
  1169. } else {
  1170. if (!confirm('已填加的明细尚未提交,回到表头编辑将取消已填加明细,是否确定?')) {
  1171. return;
  1172. }
  1173. }
  1174. }
  1175. let ids = [];
  1176. for (let i = _this.status.existItemsBeforeAdd; i < _this.items.length; i++) {
  1177. ids.push(_this.items[i].id);
  1178. }
  1179. if (ids.length === 0) {
  1180. _this.unlockBillPanel();
  1181. return;
  1182. }
  1183. let url = '{{url('apiLocal/rejectedBillItem/packDestroy')}}';
  1184. axios.post(url, {'ids': ids}).then(function (response) {
  1185. _this.cleanError();
  1186. if (response.data.success === 'true') {
  1187. _this.status.editingBill = null;
  1188. _this.unlockBillPanel();
  1189. } else {
  1190. tempTip.show('数据操作失败,请重试:' + response.data.fail_info)
  1191. }
  1192. }).catch(function (response) {
  1193. tempTip.setDuration(3000);
  1194. tempTip.show('提交失败,请重试:' + response.data.fail_info)
  1195. alert('连接错误:' + response)
  1196. });
  1197. },
  1198. lockBillPanel: function () {
  1199. this.status.lockingBillPanel = true;
  1200. $('input,select').blur();
  1201. },
  1202. unlockBillPanel: function () {
  1203. this.status.lockingBillPanel = false;
  1204. this.status.editingBill = null;
  1205. this.status.editingBillId = '';
  1206. this.shiftToCreate();
  1207. },
  1208. getRecentRejectedBills: function () {
  1209. let _this = this;
  1210. let url = '{{url('apiLocal/rejectedBill/apiGetRecent')}}';
  1211. axios.post(url).then(function (response) {
  1212. if (response.data.success === 'true') {
  1213. _this.rejectedBills = response.data.rejectedBills;
  1214. _this.setEditingBill(_this.status.editingBillId)
  1215. } else {
  1216. tempTip.show('加载新增内容失败,可尝试刷新页面');
  1217. }
  1218. }).catch(function (response) {
  1219. alert('连接错误:' + response);
  1220. tempTip.show('加载新增内容失败,可尝试刷新页面!');
  1221. });
  1222. },
  1223. getItemsUnderBill: function (billId, func) {
  1224. let _this = this;
  1225. let url = '{{url('apiLocal/rejectedBillItem/apiGet')}}';
  1226. axios.post(url, {id_rejected_bill: billId}).then(function (response) {
  1227. if (response.data.success === 'true') {
  1228. response.data.items.forEach(function (item) {
  1229. item.isEditing = false;
  1230. });
  1231. _this.items = response.data.items;
  1232. if (typeof func !== 'undefined') {
  1233. func()
  1234. }
  1235. _this.listenEnterAndJump();
  1236. setTimeout(function () {
  1237. $('#barcode_goods').focus();
  1238. }, 500)
  1239. } else {
  1240. tempTip.show('加载相关明细失败,可尝试刷新页面');
  1241. }
  1242. }).catch(function (response) {
  1243. alert('连接错误:' + response);
  1244. tempTip.show('加载相关明细失败,可尝试刷新页面!');
  1245. });
  1246. },
  1247. deleteBill: function (rejectedBill) {
  1248. if (!confirm('确定要删除退货信息“' + rejectedBill.owner_name + ':' + rejectedBill.logistic_number_return + '”吗?')) {
  1249. return;
  1250. }
  1251. let _this = this;
  1252. let url = "{{url('rejectedBill')}}/" + rejectedBill.id;
  1253. axios.delete(url, {id: rejectedBill.id})
  1254. .then(function (response) {
  1255. if (response.data.success) {
  1256. for (let i = 0; i < _this.rejectedBills.length; i++) {
  1257. if (_this.rejectedBills[i].id === rejectedBill.id) {
  1258. _this.rejectedBills.splice(i, 1);
  1259. break;
  1260. }
  1261. }
  1262. tempTip.setDuration(1000);
  1263. tempTip.showSuccess('删除退货信息"' + rejectedBill.owner_name + ':' + rejectedBill.logistic_number_return + '"成功!')
  1264. } else {
  1265. tempTip.setDuration(1000);
  1266. tempTip.show('删除退货信息"' + rejectedBill.owner_name + ':' + rejectedBill.logistic_number_return + '"失败!')
  1267. }
  1268. })
  1269. .catch(function (err) {
  1270. tempTip.setDuration(3000);
  1271. tempTip.show('删除退货信息失败!' + '网络错误:' + err);
  1272. });
  1273. },
  1274. deleteItem: function (e) {
  1275. if (!confirm('确定要删除该明细吗?不可恢复')) {
  1276. return
  1277. }
  1278. let _this = this;
  1279. let id = $(e.target).parents('tr').attr('data-id');
  1280. let url = '{{url('apiLocal/rejectedBillItem/apiDelete')}}';
  1281. axios.post(url, {id: id}).then(function (response) {
  1282. if (response.data.success === 'true') {
  1283. _this.items.forEach(function (item, i) {
  1284. if (item.id + '' === id + '') {
  1285. _this.items.splice(i, 1);
  1286. }
  1287. });
  1288. } else {
  1289. tempTip.show('删除失败,可尝试刷新页面再操作');
  1290. }
  1291. }).catch(function (response) {
  1292. alert('连接错误:' + response);
  1293. tempTip.show('删除失败,可尝试刷新页面!');
  1294. });
  1295. },
  1296. editBill: function (e) {
  1297. let _this = this;
  1298. let billId = $(e.target).parent('tr').attr('data-id');
  1299. let billTarget = '';
  1300. this.rejectedBills.every(function (bill) {
  1301. if (bill.id + '' === billId + '') {
  1302. billTarget = bill;
  1303. return false;
  1304. }
  1305. return true;
  1306. });
  1307. if (billTarget) {
  1308. this.billInputting = JSON.parse(JSON.stringify(billTarget));
  1309. this.shiftToEdit();
  1310. this.setEditingBill(billTarget.id)
  1311. }
  1312. this.getItemsUnderBill(billTarget.id, function () {
  1313. _this.status.existItemsBeforeAdd = _this.items.length;
  1314. });
  1315. },
  1316. editItem: function (e) {
  1317. let _this = this;
  1318. let itemId = $(e.target).parent('tr').attr('data-id');
  1319. let itemTarget = '';
  1320. this.items.every(function (item) {
  1321. if (item.id + '' === itemId + '') {
  1322. itemTarget = item;
  1323. return false;
  1324. }
  1325. return true;
  1326. });
  1327. if (itemTarget) {
  1328. // itemTarget.packageImages = itemTarget.package_images;//package_images
  1329. // itemTarget.commodityImages = itemTarget.commodity_images;//commodity_images
  1330. // delete itemTarget.package_images;
  1331. // delete itemTarget.commodity_images;
  1332. this.itemInputting = JSON.parse(JSON.stringify(itemTarget));
  1333. this.shiftToEditItem();
  1334. this.setEditingItem(itemTarget.id)
  1335. }
  1336. // this.getItemsUnderBill(this.status.editingBillId,function () {});
  1337. },
  1338. shiftToEditItem: function () {
  1339. this.cleanError();
  1340. this.status.itemCreating = false;
  1341. this.status.itemEditing = true;
  1342. setTimeout(function () {
  1343. $('.tooltipOn').tooltip({'trigger': 'hover'});
  1344. }, 50)
  1345. },
  1346. shiftToEdit: function () {
  1347. this.cleanError();
  1348. this.status.billCreating = false;
  1349. this.status.billEditing = true;
  1350. setTimeout(function () {
  1351. $('.tooltipOn').tooltip({'trigger': 'hover'});
  1352. }, 50)
  1353. },
  1354. shiftToCreateItem: function () {
  1355. this.cleanError();
  1356. this.cleanItem();
  1357. this.status.itemCreating = true;
  1358. this.status.itemEditing = false;
  1359. this.items.forEach(function (item) {
  1360. item.isEditing = false;
  1361. });
  1362. $('.tooltipOn').tooltip('hide').tooltip({'trigger': 'hover'});
  1363. },
  1364. shiftToCreate: function () {
  1365. this.cleanError();
  1366. this.cleanHeader();
  1367. this.status.billCreating = true;
  1368. this.status.billEditing = false;
  1369. this.status.editingBill = null;
  1370. this.rejectedBills.forEach(function (rejectedBill) {
  1371. if (rejectedBill.isEditing === true) {
  1372. rejectedBill.isEditing = false;
  1373. return false;
  1374. }
  1375. });
  1376. $('.tooltipOn').tooltip('hide').tooltip({'trigger': 'hover'});
  1377. },
  1378. locateIdOwner: function (e) {
  1379. let _this = this;
  1380. let $target = $(e.target);
  1381. this.owners.forEach(function (owner) {
  1382. if (owner.name.includes($target.val())) {
  1383. _this.billInputting.id_owner = owner.id;
  1384. }
  1385. });
  1386. },
  1387. locateLogistic: function (e) {
  1388. let _this = this;
  1389. let $target = $(e.target);
  1390. this.logistics.forEach(function (logistic) {
  1391. if (logistic.name.includes($target.val())) {
  1392. _this.billInputting.id_logistic_return = logistic.id;
  1393. }
  1394. });
  1395. },
  1396. //根据退回单寻找WMS订单填充已有字段
  1397. seek_order() {
  1398. let _this = this;
  1399. let logistic_number_return = this.billInputting.logistic_number_return;
  1400. if (!logistic_number_return) return;
  1401. axios.post('{{url('apiLocal/rejectedBill/seekOrder')}}', {logistic_number_return: logistic_number_return})
  1402. .then(function (response) {
  1403. if (response.data.success) {
  1404. if (response.data.data.owner_id) _this.billInputting.id_owner = response.data.data.owner_id;
  1405. if (response.data.data.logistic_id) _this.billInputting.id_logistic_return = response.data.data.logistic_id;
  1406. if (response.data.data.consignee_name) _this.billInputting.sender = response.data.data.consignee_name;
  1407. if (response.data.data.consignee_phone) _this.billInputting.mobile_sender = response.data.data.consignee_phone;
  1408. if (response.data.data.client_code) _this.billInputting.order_number = response.data.data.client_code;
  1409. if (response.data.data.logistic_number) _this.billInputting.logistic_number = response.data.data.logistic_number;
  1410. tempTip.setDuration(2000);
  1411. tempTip.showSuccess('原单信息已填充');
  1412. return;
  1413. }
  1414. tempTip.setDuration(2000);
  1415. tempTip.show('没有找到对应的数据,可手动填写 ');
  1416. });
  1417. },
  1418. // 开启摄像头
  1419. enableCamera(enableVideo) {
  1420. this.videoEnabled = enableVideo;
  1421. MediaUtils.getUserMedia(enableVideo, false, function (err, stream) {
  1422. if (err) {
  1423. throw err;
  1424. } else {
  1425. let photo=document.getElementById('photo');
  1426. photo.srcObject = stream;
  1427. photo.play();
  1428. }
  1429. });
  1430. },
  1431. // 关闭摄像头
  1432. closeCamera() {
  1433. let stream = document.getElementById('photo').srcObject;
  1434. let tracks = stream.getTracks();
  1435. tracks.forEach(function(track) {
  1436. track.stop();
  1437. });
  1438. document.getElementById('photo').srcObject = null;
  1439. },
  1440. //拍照
  1441. takePhoto(id,index){
  1442. let photo=document.getElementById('photo');
  1443. let canvas=document.getElementById('canvas');
  1444. //绘制canvas图形
  1445. canvas.getContext('2d').drawImage(photo, 0, 0, 400, 300);
  1446. let img = document.getElementById('canvas').toDataURL();
  1447. // 这里的img就是得到的图片
  1448. this.closeCamera();
  1449. let blob=this.dataUrlToBlob(img);
  1450. this.submitFile(blob,id,index);
  1451. },
  1452. dataUrlToBlob(imgDataUrl) {
  1453. let imgUrl = window.atob(imgDataUrl.split(',')[1])
  1454. let ab = new ArrayBuffer(imgUrl.length)
  1455. let ia = new Uint8Array(ab)
  1456. for (let i = 0; i < imgUrl.length; i++) {
  1457. ia[i] = imgUrl.charCodeAt(i)
  1458. }
  1459. return new Blob([ab],{type:'image/jpeg'})
  1460. },
  1461. submitFile(blob,id,index){
  1462. window.tempTip.setDuration(3000);
  1463. let formData=new FormData();
  1464. formData.append('files[]', blob,'rejected_bill_item'+id+'.jpg')
  1465. formData.append("id",id);
  1466. window.tempTip.postBasicRequest('{{url('apiLocal/rejectedBillItem/apiUpload')}}',formData,res=>{
  1467. if (this.items[index].upload_files.length===0) this.$set(this.items[index],'upload_files',res);
  1468. else this.$set(this.items[index],'upload_files',this.items[index].upload_files.concat(res));
  1469. return "上传成功";
  1470. },false,true);
  1471. },
  1472. certiimg(id,type){
  1473. this.submitImageType=type;
  1474. $('#'+id).click();
  1475. },
  1476. submitImages(e,index){
  1477. let type=this.submitImageType;
  1478. let files=e.target.files;
  1479. window.tempTip.setDuration(3000);
  1480. if (files.length===0){window.tempTip.show("未选定图片!");return;}
  1481. let formData=new FormData();
  1482. for (let i=0;i<files.length;i++){
  1483. if (files[i].size >=5242880){window.tempTip.show("图片大小不能超过5MB!");return;}
  1484. formData.append("files[]",files[i]);
  1485. }
  1486. formData.append("id",this.items[index].id);
  1487. formData.append("type",type);
  1488. window.tempTip.postBasicRequest('{{url('apiLocal/rejectedBillItem/apiUpload')}}',formData,res=>{
  1489. if (type==='外箱'){
  1490. if (this.items[index].package_images.length===0) this.$set(this.items[index],'package_images',res);
  1491. else this.$set(this.items[index],'package_images',this.items[index].package_images.concat(res));
  1492. }
  1493. if (type==='产品'){
  1494. if (this.items[index].commodity_images.length===0) this.$set(this.items[index],'commodity_images',res);
  1495. else this.$set(this.items[index],'commodity_images',this.items[index].commodity_images.concat(res));
  1496. }
  1497. return "上传成功";
  1498. },false,true);
  1499. },
  1500. removeCommonImg(id){
  1501. $('#'+id).remove();
  1502. },
  1503. commonImg(id,uploadFiles){
  1504. let div = "";
  1505. let isBtn = '@can('运输管理-运单-图片删除') true @endcan ';
  1506. for(let i=0;i<uploadFiles.length;i++){
  1507. let btn = isBtn ? "<button type='button' class='btn btn-sm btn-danger' onclick='vueList.btnDeleteImg(this)' data-url='"+uploadFiles[i].url+"' value='"+id+"' style='position: relative;float: right;margin-top: -30px;' >删除</button>" : "";
  1508. let href = this.imgPrefix+uploadFiles[i].url+'-bulky.'+uploadFiles[i].type;
  1509. let src = this.imgPrefix+uploadFiles[i].url+'-common.'+uploadFiles[i].type;
  1510. div += "<div><a target='_blank' href='"+href+"'><img alt='#' src='"+src+"' style='position: relative;' ></a>"+btn+"</div>"
  1511. }
  1512. $('#'+id).after(
  1513. "<div id=\"common_"+id+"\" style='position: absolute;padding-bottom: 2px;z-index: 99'>" +
  1514. "<div style='position:absolute;left: -50px' class='overflow-y-scrollbar-200'>"+div+
  1515. "</div></div>");
  1516. },
  1517. btnDeleteImg(e){
  1518. let idstr = $(e).val();
  1519. let id = idstr.substr( idstr.indexOf('_')+1);
  1520. let url = e.getAttribute("data-url");
  1521. if (!confirm('确定要删除所选图片吗?'))return;
  1522. this.destroyImg(id,url);
  1523. },
  1524. destroyImg(id,url = null){
  1525. id= id.replace(/[^0-9]/ig,"");//抽取数字部分
  1526. window.tempTip.postBasicRequest('{{url('apiLocal/rejectedBillItem/apiDeleteImg')}}',{id:id,url:url},()=>{
  1527. if (url){
  1528. this.items.some((item,i)=>{
  1529. if (item.id==id){
  1530. item.upload_files.some((file,j)=>{
  1531. if (file.url === url){this.$delete(this.items[i].upload_files,j);return true;}
  1532. });
  1533. item.package_images.some((file,j)=>{
  1534. if (file.url === url){this.$delete(this.items[i].package_images,j);return true;}
  1535. });
  1536. item.commodity_images.some((file,j)=>{
  1537. if (file.url === url){this.$delete(this.items[i].commodity_images,j);return true;}
  1538. });
  1539. return true;
  1540. }
  1541. });
  1542. }else{
  1543. this.items.forEach((item,i)=>{
  1544. if (id.includes(item.id))this.$set(this.items[i],'upload_files',[]);
  1545. if (id.includes(item.id))this.$set(this.items[i],'commodity_images',[]);
  1546. if (id.includes(item.id))this.$set(this.items[i],'package_images',[]);
  1547. });
  1548. }
  1549. return "删除成功";
  1550. });
  1551. },
  1552. },
  1553. filters: {
  1554. isLoaded: function (value) {
  1555. return value == 1 ? '是' : '否';
  1556. },
  1557. dateNoYear: function (value) {
  1558. if (!value) return '';
  1559. return value.substr(5, 11);
  1560. }
  1561. },
  1562. });
  1563. </script>
  1564. @endsection