create.blade.php 94 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612
  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.src;
  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. this.itemInputting['packageImages'] = [];
  843. this.itemInputting['commodityImages'] = [];
  844. },
  845. cleanError: function () {
  846. for (let key in this.errors) {
  847. this.errors[key] = '';
  848. }
  849. },
  850. setEditingBill: function (id) {
  851. let _this = this;
  852. this.status.editingBillId = id;
  853. this.rejectedBills.forEach(function (bill) {
  854. if (bill.id + '' === id + '') {
  855. _this.status.editingBill = bill;
  856. bill.isEditing = true;
  857. } else {
  858. bill.isEditing = false
  859. }
  860. });
  861. this.$forceUpdate();
  862. },
  863. setEditingItem: function (id) {
  864. let _this = this;
  865. this.status.editingItemId = id;
  866. this.items.forEach(function (item) {
  867. if (item.id + '' === id + '') {
  868. _this.status.editingItem = item;
  869. item.isEditing = true;
  870. } else {
  871. item.isEditing = false
  872. }
  873. });
  874. this.$forceUpdate();
  875. },
  876. commitHeader: function () {
  877. let _this = this;
  878. let url = '{{url('apiLocal/rejectedBill/store')}}';
  879. tempTip.setDuration(99999);
  880. tempTip.waitingTip('提交中')
  881. axios.post(url, _this.billInputting).then(function (response) {
  882. tempTip.cancelWaitingTip();
  883. _this.cleanError();
  884. if (response.data.success === 'true') {
  885. tempTip.setDuration(1000);
  886. tempTip.showSuccess('成功录入退单号:' + _this.billInputting.logistic_number_return);
  887. _this.status.inputtingId_owner = _this.billInputting.id_owner;
  888. _this.setEditingBill(response.data.id);
  889. _this.getItemsUnderBill(response.data.id);
  890. _this.cleanHeader();
  891. _this.getRecentRejectedBills();
  892. _this.lockBillPanel();
  893. _this.status.existItemsBeforeAdd = 0;
  894. $('#barcode_goods').focus();
  895. } else {
  896. if (response.data.error_fields) {
  897. tempTip.setDuration(3000);
  898. tempTip.show('录入失败,字段填写错误');
  899. _this.errors = response.data.error_fields;
  900. if (_this.errors.remark) {
  901. _this.errors.bill_remark = _this.errors.remark;
  902. _this.errors.remark = '';
  903. }
  904. } else {
  905. tempTip.setDuration(3000);
  906. tempTip.show('录入失败:' + response.data.fail_info)
  907. }
  908. }
  909. }).catch(function (response) {
  910. tempTip.setDuration(3000);
  911. tempTip.show('提交失败,请重试:' + response.data.fail_info)
  912. alert('连接错误:' + response)
  913. });
  914. },
  915. commitEditItem: function () {
  916. let _this = this;
  917. if (!confirm("确定要提交修改吗?")) {
  918. return;
  919. }
  920. let url = '{{url('apiLocal/rejectedBillItem/update')}}';
  921. axios.post(url, _this.itemInputting).then(function (response) {
  922. _this.cleanError();
  923. if (response.data.success === 'true') {
  924. tempTip.setDuration(1000);
  925. tempTip.showSuccess('成功修改商品:' + _this.itemInputting.barcode_goods);
  926. _this.cleanItem();
  927. _this.getItemsUnderBill(_this.status.editingBillId);
  928. _this.shiftToCreateItem();
  929. } else {
  930. if (response.data.error_fields) {
  931. tempTip.setDuration(3000);
  932. tempTip.show('修改失败,字段填写错误');
  933. _this.errors = response.data.error_fields;
  934. if (_this.errors.remark) {
  935. _this.errors.bill_remark = _this.errors.remark;
  936. _this.errors.remark = '';
  937. }
  938. } else {
  939. tempTip.show('修改失败:' + response.data.fail_info)
  940. }
  941. }
  942. }).catch(function (response) {
  943. tempTip.setDuration(3000);
  944. tempTip.show('提交失败,请重试:' + response.data.fail_info)
  945. alert('连接错误:' + response)
  946. });
  947. },
  948. commitEditHeader: function () {
  949. let _this = this;
  950. if (!confirm("确定要提交修改吗?")) {
  951. return;
  952. }
  953. let url = '{{url('apiLocal/rejectedBill/update')}}';
  954. tempTip.setDuration(99999);
  955. tempTip.waitingTip('提交中')
  956. axios.post(url, _this.billInputting).then(function (response) {
  957. tempTip.cancelWaitingTip();
  958. _this.cleanError();
  959. if (response.data.success === 'true') {
  960. tempTip.setDuration(1000);
  961. tempTip.showSuccess('成功修改退单号:' + _this.billInputting.logistic_number_return);
  962. _this.cleanHeader();
  963. _this.getRecentRejectedBills();
  964. _this.shiftToCreate();
  965. } else {
  966. if (response.data.error_fields) {
  967. tempTip.setDuration(3000);
  968. tempTip.show('修改失败,字段填写错误');
  969. _this.errors = response.data.error_fields;
  970. } else {
  971. tempTip.show('修改失败:' + response.data.fail_info)
  972. }
  973. }
  974. }).catch(function (response) {
  975. tempTip.setDuration(3000);
  976. tempTip.show('提交失败,请重试:' + response.data.fail_info)
  977. alert('连接错误:' + response)
  978. });
  979. },
  980. checkImageWhetherNeed(item){
  981. if (this.billInputting.id_owner==4)return 0;//幼岚非必要上传外箱及产品图
  982. if (item.id_quality_label!=1){
  983. if (item.commodityImages.length===0){
  984. tempTip.setDuration(3000);
  985. tempTip.show('非正品,请上传外箱图及产品图!');
  986. return 1;
  987. }
  988. }
  989. return 0;
  990. },
  991. setFormDataImage(formData, prefix, images) {
  992. images.forEach((item) => {
  993. formData.append(`${prefix}[]`, item,'rejected_bill_item.jpg');
  994. });
  995. },
  996. compressedImage(_this,packageImages){
  997. let blobs=[];
  998. packageImages.forEach(function (imageFile){
  999. let docImg=document.createElement('img');
  1000. docImg.src=imageFile;
  1001. const { width: originWidth, height: originHeight } = docImg
  1002. let maxWidth = 400;
  1003. let maxHeight = 600;
  1004. // 需要压缩的目标尺寸
  1005. let targetWidth = originWidth
  1006. let targetHeight = originHeight
  1007. // 等比例计算超过最大限制时缩放后的图片尺寸
  1008. if (originWidth > maxWidth || originHeight > maxHeight) {
  1009. if (originWidth / originHeight > maxWidth / maxHeight) {
  1010. targetWidth = maxWidth
  1011. targetHeight = Math.floor(maxWidth * (originHeight / originWidth))
  1012. } else {
  1013. targetWidth = Math.floor(maxHeight * (originWidth / originHeight))
  1014. targetHeight = maxHeight;
  1015. }
  1016. }
  1017. const canvas = document.createElement('canvas')
  1018. const context = canvas.getContext('2d')
  1019. // 设置宽高度为等同于要压缩图片的尺寸
  1020. canvas.width = targetWidth
  1021. canvas.height = targetHeight
  1022. context.clearRect(0, 0, targetWidth, targetHeight)
  1023. //将img绘制到画布上
  1024. context.drawImage(docImg, 0, 0, targetWidth, targetHeight)
  1025. let image = canvas.toDataURL();
  1026. let blob=_this.dataUrlToBlob(image);
  1027. blobs.push(blob)
  1028. });
  1029. return blobs;
  1030. },
  1031. getDamagedFormData(item){
  1032. let _this=this;
  1033. let formData = new FormData();
  1034. if (item.packageImages.length>0){
  1035. let packageImages = _this.getImages(item.packageImages);
  1036. let blobs=_this.compressedImage(_this,packageImages);
  1037. this.setFormDataImage(formData,'packageImages',blobs);
  1038. }
  1039. if (item.commodityImages.length>0){
  1040. let commodityImages = _this.getImages(item.commodityImages);
  1041. let blobs=_this.compressedImage(_this,commodityImages);
  1042. this.setFormDataImage(formData,'commodityImages',blobs);
  1043. }
  1044. formData.append('barcode_goods',item.barcode_goods);
  1045. formData.append('amount',item.amount);
  1046. formData.append('name_goods',item.name_goods);
  1047. formData.append('id_quality_label',item.id_quality_label);
  1048. formData.append('batch_number',item.batch_number);
  1049. formData.append('validity_at',item.validity_at);
  1050. formData.append('made_at',item.made_at);
  1051. formData.append('remark',item.remark);
  1052. formData.append('id_rejected_bill',item.id_rejected_bill);
  1053. return formData;
  1054. },
  1055. commitItem: function () {
  1056. let _this = this;
  1057. if (_this.checkImageWhetherNeed(_this.itemInputting)===1)return;
  1058. let url = '{{url('apiLocal/rejectedBillItem/store')}}';
  1059. _this.itemInputting.id_rejected_bill = _this.status.editingBill.id;
  1060. if (_this.items.length < 1) {
  1061. let baoShiBuFaOwnerId = '';
  1062. _this.owners.forEach(function (owner) {
  1063. if (owner.name === '宝时补发') baoShiBuFaOwnerId = owner.id;
  1064. });
  1065. if (_this.commodityOwnerId != _this.billInputting.id_owner && _this.billInputting.id_owner != baoShiBuFaOwnerId) {
  1066. _this.isChangeOwner(_this.itemInputting.id_rejected_bill);
  1067. }
  1068. }
  1069. let formData = _this.getDamagedFormData(_this.itemInputting);
  1070. axios.post(url, formData,{'Content-Type':'multipart/form-data'}).then(function (response) {
  1071. _this.cleanError();
  1072. if (response.data.success === 'true') {
  1073. tempTip.setDuration(1000);
  1074. tempTip.showSuccess('成功录入退单商品:' + _this.itemInputting.name_goods);
  1075. _this.status.endAndPackCommitEdited = false;
  1076. _this.lockBillPanel();
  1077. _this.getItemsUnderBill(_this.status.editingBill.id);
  1078. _this.cleanItem();
  1079. $('#barcode_goods').focus();
  1080. } else {
  1081. if (response.data.error_fields) {
  1082. tempTip.setDuration(3000);
  1083. tempTip.show('录入失败,字段填写错误');
  1084. _this.errors = response.data.error_fields;
  1085. } else {
  1086. tempTip.show('录入失败:' + response.data.fail_info)
  1087. }
  1088. }
  1089. }).catch(function (response) {
  1090. tempTip.setDuration(3000);
  1091. tempTip.show('提交失败,请重试:' + response.data.fail_info)
  1092. alert('连接错误:' + response)
  1093. });
  1094. },
  1095. isChangeOwner(id_rejected_bill) {
  1096. let _this = this;
  1097. let url = '{{url('apiLocal/rejectedBillItem/reviseOwner')}}';
  1098. window.tempTip.confirm('当前退货记录货主名与录入商品的货主不匹配! ' + '确定校正退货记录货主名吗?', () => {
  1099. window.axios.post(url, {
  1100. commodityOwnerId: _this.commodityOwnerId,
  1101. id_rejected_bill: id_rejected_bill
  1102. }).then(res => {
  1103. if (res.data.success === 'true') {
  1104. let owner_name = '';
  1105. _this.owners.forEach(function (owner) {
  1106. if (owner.id == _this.commodityOwnerId) {
  1107. owner_name = owner.name;
  1108. }
  1109. })
  1110. _this.billInputting.id_owner = _this.commodityOwnerId;
  1111. _this.rejectedBills.forEach(function (rejectedBill) {
  1112. if (id_rejected_bill == rejectedBill.id) rejectedBill.owner_name = owner_name;
  1113. })
  1114. } else {
  1115. tempTip.setDuration(3000);
  1116. tempTip.show(res.data.message);
  1117. return;
  1118. }
  1119. }).catch(err => {
  1120. window.tempTip.setDuration(3000);
  1121. window.tempTip.show("网络错误:" + err);
  1122. return;
  1123. });
  1124. });
  1125. },
  1126. endAndPackCommitEdit: function () {
  1127. let _this = this;
  1128. if (_this.items.length === 0) {
  1129. if (confirm('没有填加明细项,确定要退出详细编辑模式吗?')) {
  1130. _this.cancelPackCommitEdit();
  1131. }
  1132. return;
  1133. } else {
  1134. if (!confirm('确定要提交填加的明细项吗?提交后即不可修改')) {
  1135. return;
  1136. }
  1137. }
  1138. let ids = [];
  1139. _this.items.forEach(function (item) {
  1140. ids.push(item.id);
  1141. });
  1142. let url = '{{url('apiLocal/rejectedBillItem/packConfirm')}}';
  1143. tempTip.setDuration(5000);
  1144. tempTip.waitingTip('与外部交互中,请稍候');
  1145. axios.post(url, {'ids': ids}).then(function (response) {
  1146. _this.cleanError();
  1147. tempTip.cancelWaitingTip();
  1148. if (response && response.data && response.data.success !== 'false') {
  1149. if (response.data.success == 'exception') {
  1150. _this.status.lockingIsLoadedInput = true;
  1151. _this.billInputting.is_loaded = 3;
  1152. tempTip.show('富勒入库异常,请手动校对');
  1153. } else if (typeof (response.data.bill_is_loaded) != 'undefined') {
  1154. if (response.data.bill_is_loaded === true) {
  1155. _this.status.editingBill.is_loaded = 1;
  1156. _this.billInputting.is_loaded = 1;
  1157. _this.billInputting.isLoadSign = true;
  1158. // _this.status.lockingIsLoadedInput=true;
  1159. tempTip.okWindow('该批商品状态已改为“入库”', '已处理');
  1160. }
  1161. }
  1162. tempTip.setDuration(5000);
  1163. switch (response.data.remote_result) {
  1164. case 'fail':
  1165. tempTip.show('与客户服务器通讯异常,明细未被外部处理,请联系系统相关同事');
  1166. break;
  1167. case 'none':
  1168. tempTip.show('客户未返回明细处理信息,请联系系统相关同事检查');
  1169. break;
  1170. case 'received':
  1171. tempTip.show('该单之前已提交过给客户服务器');
  1172. break;
  1173. case 'storable':
  1174. tempTip.showSuccess('WMS尚未推单,客户返回可以入库,所以状态为“待推单”', '已处理该待推单');
  1175. break;
  1176. default:
  1177. tempTip.showSuccess('成功录入所有退单商品并已上传至外部');
  1178. break;
  1179. }
  1180. _this.status.endAndPackCommitEdited = true;
  1181. _this.cancelPackCommitEdit();
  1182. } else {
  1183. tempTip.setDuration(4000);
  1184. let fail_info = '';
  1185. if (response.data)
  1186. fail_info = response.data.fail_info;
  1187. tempTip.show('录入明细列表失败,请重试:' + fail_info)
  1188. }
  1189. }).catch(function (response) {
  1190. tempTip.cancelWaitingTip();
  1191. tempTip.setDuration(3000);
  1192. let fail_info = '';
  1193. if (response.data)
  1194. fail_info = response.data.fail_info;
  1195. tempTip.show('提交失败,请重试:' + fail_info);
  1196. alert('连接错误:' + response)
  1197. });
  1198. },
  1199. cancelPackCommitEdit: function () {
  1200. let _this = this;
  1201. if (_this.items.length === 0 && !_this.status.endAndPackCommitEdited) {
  1202. _this.unlockBillPanel();
  1203. return;
  1204. } else {
  1205. if (_this.status.endAndPackCommitEdited) {
  1206. _this.unlockBillPanel();
  1207. return;
  1208. } else {
  1209. if (!confirm('已填加的明细尚未提交,回到表头编辑将取消已填加明细,是否确定?')) {
  1210. return;
  1211. }
  1212. }
  1213. }
  1214. let ids = [];
  1215. for (let i = _this.status.existItemsBeforeAdd; i < _this.items.length; i++) {
  1216. ids.push(_this.items[i].id);
  1217. }
  1218. if (ids.length === 0) {
  1219. _this.unlockBillPanel();
  1220. return;
  1221. }
  1222. let url = '{{url('apiLocal/rejectedBillItem/packDestroy')}}';
  1223. axios.post(url, {'ids': ids}).then(function (response) {
  1224. _this.cleanError();
  1225. if (response.data.success === 'true') {
  1226. _this.status.editingBill = null;
  1227. _this.unlockBillPanel();
  1228. } else {
  1229. tempTip.show('数据操作失败,请重试:' + response.data.fail_info)
  1230. }
  1231. }).catch(function (response) {
  1232. tempTip.setDuration(3000);
  1233. tempTip.show('提交失败,请重试:' + response.data.fail_info)
  1234. alert('连接错误:' + response)
  1235. });
  1236. },
  1237. lockBillPanel: function () {
  1238. this.status.lockingBillPanel = true;
  1239. $('input,select').blur();
  1240. },
  1241. unlockBillPanel: function () {
  1242. this.status.lockingBillPanel = false;
  1243. this.status.editingBill = null;
  1244. this.status.editingBillId = '';
  1245. this.shiftToCreate();
  1246. },
  1247. getRecentRejectedBills: function () {
  1248. let _this = this;
  1249. let url = '{{url('apiLocal/rejectedBill/apiGetRecent')}}';
  1250. axios.post(url).then(function (response) {
  1251. if (response.data.success === 'true') {
  1252. _this.rejectedBills = response.data.rejectedBills;
  1253. _this.setEditingBill(_this.status.editingBillId)
  1254. } else {
  1255. tempTip.show('加载新增内容失败,可尝试刷新页面');
  1256. }
  1257. }).catch(function (response) {
  1258. alert('连接错误:' + response);
  1259. tempTip.show('加载新增内容失败,可尝试刷新页面!');
  1260. });
  1261. },
  1262. getItemsUnderBill: function (billId, func) {
  1263. let _this = this;
  1264. let url = '{{url('apiLocal/rejectedBillItem/apiGet')}}';
  1265. axios.post(url, {id_rejected_bill: billId}).then(function (response) {
  1266. if (response.data.success === 'true') {
  1267. response.data.items.forEach(function (item) {
  1268. item.isEditing = false;
  1269. });
  1270. _this.items = response.data.items;
  1271. if (typeof func !== 'undefined') {
  1272. func()
  1273. }
  1274. _this.listenEnterAndJump();
  1275. setTimeout(function () {
  1276. $('#barcode_goods').focus();
  1277. }, 500)
  1278. } else {
  1279. tempTip.show('加载相关明细失败,可尝试刷新页面');
  1280. }
  1281. }).catch(function (response) {
  1282. alert('连接错误:' + response);
  1283. tempTip.show('加载相关明细失败,可尝试刷新页面!');
  1284. });
  1285. },
  1286. deleteBill: function (rejectedBill) {
  1287. if (!confirm('确定要删除退货信息“' + rejectedBill.owner_name + ':' + rejectedBill.logistic_number_return + '”吗?')) {
  1288. return;
  1289. }
  1290. let _this = this;
  1291. let url = "{{url('rejectedBill')}}/" + rejectedBill.id;
  1292. axios.delete(url, {id: rejectedBill.id})
  1293. .then(function (response) {
  1294. if (response.data.success) {
  1295. for (let i = 0; i < _this.rejectedBills.length; i++) {
  1296. if (_this.rejectedBills[i].id === rejectedBill.id) {
  1297. _this.rejectedBills.splice(i, 1);
  1298. break;
  1299. }
  1300. }
  1301. tempTip.setDuration(1000);
  1302. tempTip.showSuccess('删除退货信息"' + rejectedBill.owner_name + ':' + rejectedBill.logistic_number_return + '"成功!')
  1303. } else {
  1304. tempTip.setDuration(1000);
  1305. tempTip.show('删除退货信息"' + rejectedBill.owner_name + ':' + rejectedBill.logistic_number_return + '"失败!')
  1306. }
  1307. })
  1308. .catch(function (err) {
  1309. tempTip.setDuration(3000);
  1310. tempTip.show('删除退货信息失败!' + '网络错误:' + err);
  1311. });
  1312. },
  1313. deleteItem: function (e) {
  1314. if (!confirm('确定要删除该明细吗?不可恢复')) {
  1315. return
  1316. }
  1317. let _this = this;
  1318. let id = $(e.target).parents('tr').attr('data-id');
  1319. let url = '{{url('apiLocal/rejectedBillItem/apiDelete')}}';
  1320. axios.post(url, {id: id}).then(function (response) {
  1321. if (response.data.success === 'true') {
  1322. _this.items.forEach(function (item, i) {
  1323. if (item.id + '' === id + '') {
  1324. _this.items.splice(i, 1);
  1325. }
  1326. });
  1327. _this.cleanItem();
  1328. } else {
  1329. tempTip.show('删除失败,可尝试刷新页面再操作');
  1330. }
  1331. }).catch(function (response) {
  1332. tempTip.show('删除失败,可尝试刷新页面!');
  1333. });
  1334. },
  1335. editBill: function (e) {
  1336. let _this = this;
  1337. let billId = $(e.target).parent('tr').attr('data-id');
  1338. let billTarget = '';
  1339. this.rejectedBills.every(function (bill) {
  1340. if (bill.id + '' === billId + '') {
  1341. billTarget = bill;
  1342. return false;
  1343. }
  1344. return true;
  1345. });
  1346. if (billTarget) {
  1347. this.billInputting = JSON.parse(JSON.stringify(billTarget));
  1348. this.shiftToEdit();
  1349. this.setEditingBill(billTarget.id)
  1350. }
  1351. this.getItemsUnderBill(billTarget.id, function () {
  1352. _this.status.existItemsBeforeAdd = _this.items.length;
  1353. });
  1354. },
  1355. editItem: function (e) {
  1356. let _this = this;
  1357. let itemId = $(e.target).parent('tr').attr('data-id');
  1358. let itemTarget = '';
  1359. this.items.every(function (item) {
  1360. if (item.id + '' === itemId + '') {
  1361. itemTarget = item;
  1362. return false;
  1363. }
  1364. return true;
  1365. });
  1366. if (itemTarget) {
  1367. // itemTarget.packageImages = itemTarget.package_images;//package_images
  1368. // itemTarget.commodityImages = itemTarget.commodity_images;//commodity_images
  1369. // delete itemTarget.package_images;
  1370. // delete itemTarget.commodity_images;
  1371. this.itemInputting = JSON.parse(JSON.stringify(itemTarget));
  1372. this.shiftToEditItem();
  1373. this.setEditingItem(itemTarget.id)
  1374. }
  1375. // this.getItemsUnderBill(this.status.editingBillId,function () {});
  1376. },
  1377. shiftToEditItem: function () {
  1378. this.cleanError();
  1379. this.status.itemCreating = false;
  1380. this.status.itemEditing = true;
  1381. setTimeout(function () {
  1382. $('.tooltipOn').tooltip({'trigger': 'hover'});
  1383. }, 50)
  1384. },
  1385. shiftToEdit: function () {
  1386. this.cleanError();
  1387. this.status.billCreating = false;
  1388. this.status.billEditing = true;
  1389. setTimeout(function () {
  1390. $('.tooltipOn').tooltip({'trigger': 'hover'});
  1391. }, 50)
  1392. },
  1393. shiftToCreateItem: function () {
  1394. this.cleanError();
  1395. this.cleanItem();
  1396. this.status.itemCreating = true;
  1397. this.status.itemEditing = false;
  1398. this.items.forEach(function (item) {
  1399. item.isEditing = false;
  1400. });
  1401. $('.tooltipOn').tooltip('hide').tooltip({'trigger': 'hover'});
  1402. },
  1403. shiftToCreate: function () {
  1404. this.cleanError();
  1405. this.cleanHeader();
  1406. this.status.billCreating = true;
  1407. this.status.billEditing = false;
  1408. this.status.editingBill = null;
  1409. this.rejectedBills.forEach(function (rejectedBill) {
  1410. if (rejectedBill.isEditing === true) {
  1411. rejectedBill.isEditing = false;
  1412. return false;
  1413. }
  1414. });
  1415. $('.tooltipOn').tooltip('hide').tooltip({'trigger': 'hover'});
  1416. },
  1417. locateIdOwner: function (e) {
  1418. let _this = this;
  1419. let $target = $(e.target);
  1420. this.owners.forEach(function (owner) {
  1421. if (owner.name.includes($target.val())) {
  1422. _this.billInputting.id_owner = owner.id;
  1423. }
  1424. });
  1425. },
  1426. locateLogistic: function (e) {
  1427. let _this = this;
  1428. let $target = $(e.target);
  1429. this.logistics.forEach(function (logistic) {
  1430. if (logistic.name.includes($target.val())) {
  1431. _this.billInputting.id_logistic_return = logistic.id;
  1432. }
  1433. });
  1434. },
  1435. //根据退回单寻找WMS订单填充已有字段
  1436. seek_order() {
  1437. let _this = this;
  1438. let logistic_number_return = this.billInputting.logistic_number_return;
  1439. if (!logistic_number_return) return;
  1440. axios.post('{{url('apiLocal/rejectedBill/seekOrder')}}', {logistic_number_return: logistic_number_return})
  1441. .then(function (response) {
  1442. if (response.data.success) {
  1443. if (response.data.data.owner_id) _this.billInputting.id_owner = response.data.data.owner_id;
  1444. if (response.data.data.logistic_id) _this.billInputting.id_logistic_return = response.data.data.logistic_id;
  1445. if (response.data.data.consignee_name) _this.billInputting.sender = response.data.data.consignee_name;
  1446. if (response.data.data.consignee_phone) _this.billInputting.mobile_sender = response.data.data.consignee_phone;
  1447. if (response.data.data.client_code) _this.billInputting.order_number = response.data.data.client_code;
  1448. if (response.data.data.logistic_number) _this.billInputting.logistic_number = response.data.data.logistic_number;
  1449. tempTip.setDuration(2000);
  1450. tempTip.showSuccess('原单信息已填充');
  1451. return;
  1452. }
  1453. tempTip.setDuration(2000);
  1454. tempTip.show('没有找到对应的数据,可手动填写 ');
  1455. });
  1456. },
  1457. // 开启摄像头
  1458. enableCamera(enableVideo) {
  1459. this.videoEnabled = enableVideo;
  1460. MediaUtils.getUserMedia(enableVideo, false, function (err, stream) {
  1461. if (err) {
  1462. throw err;
  1463. } else {
  1464. let photo=document.getElementById('photo');
  1465. photo.srcObject = stream;
  1466. photo.play();
  1467. }
  1468. });
  1469. },
  1470. // 关闭摄像头
  1471. closeCamera() {
  1472. let stream = document.getElementById('photo').srcObject;
  1473. let tracks = stream.getTracks();
  1474. tracks.forEach(function(track) {
  1475. track.stop();
  1476. });
  1477. document.getElementById('photo').srcObject = null;
  1478. },
  1479. //拍照
  1480. takePhoto(id,index){
  1481. let photo=document.getElementById('photo');
  1482. let canvas=document.getElementById('canvas');
  1483. //绘制canvas图形
  1484. canvas.getContext('2d').drawImage(photo, 0, 0, 400, 300);
  1485. let img = document.getElementById('canvas').toDataURL();
  1486. // 这里的img就是得到的图片
  1487. this.closeCamera();
  1488. let blob=this.dataUrlToBlob(img);
  1489. this.submitFile(blob,id,index);
  1490. },
  1491. dataUrlToBlob(imgDataUrl) {
  1492. let imgUrl = window.atob(imgDataUrl.split(',')[1])
  1493. let ab = new ArrayBuffer(imgUrl.length)
  1494. let ia = new Uint8Array(ab)
  1495. for (let i = 0; i < imgUrl.length; i++) {
  1496. ia[i] = imgUrl.charCodeAt(i)
  1497. }
  1498. return new Blob([ab],{type:'image/jpeg'})
  1499. },
  1500. submitFile(blob,id,index){
  1501. window.tempTip.setDuration(3000);
  1502. let formData=new FormData();
  1503. formData.append('files[]', blob,'rejected_bill_item'+id+'.jpg')
  1504. formData.append("id",id);
  1505. window.tempTip.postBasicRequest('{{url('apiLocal/rejectedBillItem/apiUpload')}}',formData,res=>{
  1506. if (this.items[index].upload_files.length===0) this.$set(this.items[index],'upload_files',res);
  1507. else this.$set(this.items[index],'upload_files',this.items[index].upload_files.concat(res));
  1508. return "上传成功";
  1509. },false,true);
  1510. },
  1511. certiimg(id,type){
  1512. this.submitImageType=type;
  1513. $('#'+id).click();
  1514. },
  1515. submitImages(e,index){
  1516. let type=this.submitImageType;
  1517. let files=e.target.files;
  1518. window.tempTip.setDuration(3000);
  1519. if (files.length===0){window.tempTip.show("未选定图片!");return;}
  1520. let formData=new FormData();
  1521. for (let i=0;i<files.length;i++){
  1522. if (files[i].size >=5242880){window.tempTip.show("图片大小不能超过5MB!");return;}
  1523. formData.append("files[]",files[i]);
  1524. }
  1525. formData.append("id",this.items[index].id);
  1526. formData.append("type",type);
  1527. window.tempTip.postBasicRequest('{{url('apiLocal/rejectedBillItem/apiUpload')}}',formData,res=>{
  1528. if (type==='外箱'){
  1529. if (this.items[index].package_images.length===0) this.$set(this.items[index],'package_images',res);
  1530. else this.$set(this.items[index],'package_images',this.items[index].package_images.concat(res));
  1531. }
  1532. if (type==='产品'){
  1533. if (this.items[index].commodity_images.length===0) this.$set(this.items[index],'commodity_images',res);
  1534. else this.$set(this.items[index],'commodity_images',this.items[index].commodity_images.concat(res));
  1535. }
  1536. return "上传成功";
  1537. },false,true);
  1538. },
  1539. removeCommonImg(id){
  1540. $('#'+id).remove();
  1541. },
  1542. commonImg(id,uploadFiles){
  1543. let div = "";
  1544. let isBtn = '@can('运输管理-运单-图片删除') true @endcan ';
  1545. for(let i=0;i<uploadFiles.length;i++){
  1546. 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>" : "";
  1547. let href = this.imgPrefix+uploadFiles[i].url+'-common.'+uploadFiles[i].type;
  1548. let src = this.imgPrefix+uploadFiles[i].url+'-common.'+uploadFiles[i].type;
  1549. div += "<div><a target='_blank' href='"+href+"'><img alt='#' src='"+src+"' style='position: relative;' ></a>"+btn+"</div>"
  1550. }
  1551. $('#'+id).after(
  1552. "<div id=\"common_"+id+"\" style='position: absolute;padding-bottom: 2px;z-index: 99'>" +
  1553. "<div style='position:absolute;left: -50px' class='overflow-y-scrollbar-200'>"+div+
  1554. "</div></div>");
  1555. },
  1556. btnDeleteImg(e){
  1557. let idstr = $(e).val();
  1558. let id = idstr.substr( idstr.indexOf('_')+1);
  1559. let url = e.getAttribute("data-url");
  1560. if (!confirm('确定要删除所选图片吗?'))return;
  1561. this.destroyImg(id,url);
  1562. },
  1563. destroyImg(id,url = null){
  1564. id= id.replace(/[^0-9]/ig,"");//抽取数字部分
  1565. window.tempTip.postBasicRequest('{{url('apiLocal/rejectedBillItem/apiDeleteImg')}}',{id:id,url:url},()=>{
  1566. if (url){
  1567. this.items.some((item,i)=>{
  1568. if (item.id==id){
  1569. item.upload_files.some((file,j)=>{
  1570. if (file.url === url){this.$delete(this.items[i].upload_files,j);return true;}
  1571. });
  1572. item.package_images.some((file,j)=>{
  1573. if (file.url === url){this.$delete(this.items[i].package_images,j);return true;}
  1574. });
  1575. item.commodity_images.some((file,j)=>{
  1576. if (file.url === url){this.$delete(this.items[i].commodity_images,j);return true;}
  1577. });
  1578. return true;
  1579. }
  1580. });
  1581. }else{
  1582. this.items.forEach((item,i)=>{
  1583. if (id.includes(item.id))this.$set(this.items[i],'upload_files',[]);
  1584. if (id.includes(item.id))this.$set(this.items[i],'commodity_images',[]);
  1585. if (id.includes(item.id))this.$set(this.items[i],'package_images',[]);
  1586. });
  1587. }
  1588. return "删除成功";
  1589. });
  1590. },
  1591. },
  1592. filters: {
  1593. isLoaded: function (value) {
  1594. return value == 1 ? '是' : '否';
  1595. },
  1596. dateNoYear: function (value) {
  1597. if (!value) return '';
  1598. return value.substr(5, 11);
  1599. }
  1600. },
  1601. });
  1602. </script>
  1603. @endsection