create.blade.php 94 KB

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