create.blade.php 79 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389
  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. @can('退货管理-删除')
  281. <th class="text-center">操作</th>@endcan
  282. </tr>
  283. <tr :class="[item.isEditing?'bg-warning':'']"
  284. v-for="(item,i) in items" :data-id="item.id" @click="editItem">
  285. <td>@{{i+1}}</td>
  286. <td>@{{item.barcode_goods }}</td>
  287. <td>@{{item.name_goods }}</td>
  288. <td>@{{item.amount}}</td>
  289. <td>@{{item.quality_label}}</td>
  290. <td>@{{item.made_at}}</td>
  291. <td>@{{item.validity_at}}</td>
  292. <td>@{{item.batch_number}}</td>
  293. <td>@{{item.remark}}</td>
  294. <td>
  295. <div align="center" @mouseleave="removeCommonImg('common_img_'+item.id)" @mouseenter="commonImg('img_'+item.id,item.upload_files)">
  296. <button class="btn btn-outline-secondary" @click="takePhoto(item.id,i)">拍照上传</button>
  297. <div :id="'img_'+item.id">
  298. <img v-for="uploadFile in item.upload_files" :src="imgPrefix+uploadFile.url+'-thumbnail.'+uploadFile.type">
  299. </div>
  300. </div>
  301. </td>
  302. @can('退货管理-删除')
  303. <td>
  304. <button class="btn btn-outline-danger" @click="deleteItem">删</button>
  305. </td>
  306. @endcan
  307. </tr>
  308. </table>
  309. </div>
  310. </div>
  311. </div>
  312. <div class="col-5">
  313. <div class="card-body ml-n4">
  314. <table class="table table-striped table-sm table-bordered"
  315. :class="[status.itemEditing?'bg-warning':'']">
  316. <tr>
  317. <td>
  318. <div class="form-group mb-0">
  319. <label for="barcode_goods" class="col-form-label text-right">商品条码</label>
  320. <input type="text" class="form-control"
  321. :class="[errors.barcode_goods?'is-invalid':'']"
  322. data-focusOrder="11"
  323. name="barcode_goods" id="barcode_goods" autocomplete="off"
  324. v-model="itemInputting.barcode_goods"
  325. @change="barcode_goodsChange"
  326. >
  327. <span class="invalid-feedback" v-if="errors.barcode_goods"><strong>@{{errors.barcode_goods[0] }}</strong></span>
  328. </div>
  329. </td>
  330. <td>
  331. <div class="form-group mb-0">
  332. <label for="name_goods" class="col-form-label text-right">商品名称</label>
  333. <input type="text" class="form-control"
  334. :class="[errors.name_goods?'is-invalid':'']"
  335. data-focusOrder="14"
  336. name="name_goods" id="name_goods" autocomplete="off"
  337. v-model="itemInputting.name_goods"
  338. @change="name_goodsChange"
  339. >
  340. <span class="invalid-feedback" v-if="errors.name_goods"><strong>@{{errors.name_goods[0] }}</strong></span>
  341. </div>
  342. </td>
  343. </tr>
  344. <tr>
  345. <td>
  346. <div class="form-group mb-0">
  347. <label for="amount" class="col-form-label text-right">数量</label>
  348. <input type="" class="form-control" :class="[errors.amount?'is-invalid':'']"
  349. data-focusOrder="12"
  350. name="amount" id="amount" autocomplete="off"
  351. v-model="itemInputting.amount" required>
  352. <span class="invalid-feedback" v-if="errors.amount"><strong>@{{errors.amount[0] }}</strong></span>
  353. </div>
  354. </td>
  355. <td>
  356. <div class="form-group mb-0">
  357. <label for="qualityLabel.name" class="col-form-label text-right">是否正品</label>
  358. <div class="form-control" :class="[errors.id_quality_label?'is-invalid':'']">
  359. <span><input id="id_quality_label_space" type="radio"
  360. name="id_quality_label"
  361. data-focusOrder="13" required="required" checked><label
  362. for="id_quality_label_space">留空</label>&nbsp;</span>
  363. <span v-for="qualityLabel in qualityLabels">
  364. <input type="radio" name="id_quality_label" :value="qualityLabel.id"
  365. data-focusOrder="13"
  366. :id="'id_quality_label_'+qualityLabel.id"
  367. v-model="itemInputting.id_quality_label" required><label
  368. for="'id_quality_label_'+qualityLabel.id">@{{qualityLabel.name}}</label>&nbsp;</span>
  369. </div>
  370. <span class="invalid-feedback" v-if="errors.id_quality_label"><strong>@{{errors.id_quality_label[0] }}</strong></span>
  371. </div>
  372. </td>
  373. </tr>
  374. <tr>
  375. <td>
  376. <div class="form-group mb-0">
  377. <label for="made_at" class="col-form-label text-right">生产日期</label>
  378. <input type="date" class="form-control"
  379. :class="[errors.made_at?'is-invalid':'']"
  380. data-focusOrder="16"
  381. name="made_at" id="made_at" autocomplete="off"
  382. v-model="itemInputting.made_at">
  383. <span class="invalid-feedback" v-if="errors.made_at"><strong>@{{errors.made_at[0] }}</strong></span>
  384. </div>
  385. </td>
  386. <td>
  387. <div class="form-group mb-0">
  388. <label for="validity_at" class="col-form-label text-right">效期</label>
  389. <input type="date" class="form-control"
  390. :class="[errors.validity_at?'is-invalid':'']"
  391. data-focusOrder="17"
  392. name="validity_at" id="validity_at" autocomplete="off"
  393. v-model="itemInputting.validity_at">
  394. <span class="invalid-feedback" v-if="errors.validity_at"><strong>@{{errors.validity_at[0] }}</strong></span>
  395. </div>
  396. </td>
  397. </tr>
  398. <tr>
  399. <td>
  400. <div class="form-group mb-0">
  401. <label for="batch_number" class="col-form-label text-right">批次号</label>
  402. <input type="text" class="form-control"
  403. :class="[errors.batch_number?'is-invalid':'']"
  404. data-focusOrder="15"
  405. name="batch_number" id="batch_number" autocomplete="off"
  406. v-model="itemInputting.batch_number"
  407. >
  408. <span class="invalid-feedback" v-if="errors.batch_number"><strong>@{{errors.batch_number[0] }}</strong></span>
  409. </div>
  410. </td>
  411. <td>
  412. <div class="form-group mb-0">
  413. <label for="remark" class="col-form-label text-right">备注</label>
  414. <input type="text" class="form-control" :class="[errors.remark?'is-invalid':'']"
  415. data-focusOrder="15"
  416. name="remark" id="remark" autocomplete="off"
  417. v-model="itemInputting.remark">
  418. <span class="invalid-feedback" v-if="errors.remark"><strong>@{{errors.remark[0] }}</strong></span>
  419. </div>
  420. </td>
  421. </tr>
  422. <tr>
  423. <td>
  424. <div class="form-group mb-0 align-items-center row">
  425. <div class="col-2" v-if="status.itemEditing">
  426. <button class="btn btn-success btn-sm tooltipOn" @click="shiftToCreateItem"
  427. title="点击取消编辑,进入新增状态">取消
  428. </button>
  429. </div>
  430. <div class="col-8" :class="[status.itemCreating?'offset-2':'']">
  431. <button v-if="status.itemCreating" class="btn btn-success form-control"
  432. @click="commitItem">添加明细
  433. </button>
  434. <input v-if="status.itemEditing" type="button"
  435. class="btn btn-dark form-control" value="修改" @click="commitEditItem">
  436. </div>
  437. </div>
  438. </td>
  439. <td>
  440. </td>
  441. </tr>
  442. <tr>
  443. <td colspan="2">
  444. <div class="form-group mb-0">
  445. <div class="col-8 offset-2 mt-2 mb-2">
  446. <button class="btn btn-dark form-control" @click="endAndPackCommitEdit">
  447. 结束添加并提交
  448. </button>
  449. </div>
  450. </div>
  451. </td>
  452. </tr>
  453. </table>
  454. </div>
  455. </div>
  456. </div>
  457. </div>
  458. <div id="drag" class="col-4 p-0" style="position:fixed;bottom: 30px;left: 10px;">
  459. <div class="text-left text-success">连接摄像头拍照</div>
  460. <video id="photo" width="50%" height="auto" controls></video>
  461. <canvas id='canvas'width='400' height='300' hidden></canvas>
  462. </div>
  463. </div>
  464. @endsection
  465. @section('lastScript')
  466. <script>
  467. //鼠标拖动 drag
  468. $(function() {
  469. let posX,posY;
  470. let drag = document.getElementById("drag");
  471. drag.onmousedown = function(e) {
  472. posX = event.x - drag.offsetLeft; //获得横坐标x
  473. posY = event.y - drag.offsetTop; //获得纵坐标y
  474. document.onmousemove = mousemove; //调用函数,只要一直按着按钮就能一直调用
  475. }
  476. document.onmouseup = function() {
  477. document.onmousemove = null; //鼠标举起,停止
  478. }
  479. function mousemove(ev) {
  480. if (ev == null) ev = window.event;
  481. let left= (ev.clientX - posX);
  482. let top= (ev.clientY - posY);
  483. let pageWidth=document.body.scrollWidth;//网页正文宽度
  484. let pageHeight=window.screen.availHeight;//屏幕工作区高度
  485. //限定拖动区域
  486. if (left <0)left=0;
  487. if (left >pageWidth)left=pageWidth;
  488. if (top <0)top=0;
  489. if (top >pageHeight)top=pageHeight;
  490. drag.style.left = left + "px";
  491. drag.style.top = top + "px";
  492. }
  493. })
  494. let MediaUtils = {
  495. /**
  496. * 获取用户媒体设备(处理兼容的问题)
  497. * @param videoEnable {boolean} - 是否启用摄像头
  498. * @param audioEnable {boolean} - 是否启用麦克风
  499. * @param callback {Function} - 处理回调
  500. */
  501. getUserMedia: function (videoEnable, audioEnable, callback) {
  502. navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia
  503. || navigator.msGetUserMedia || window.getUserMedia;
  504. let constraints = {video: videoEnable, audio: audioEnable};
  505. if (navigator.mediaDevices && navigator.mediaDevices.getUserMedia) {
  506. navigator.mediaDevices.getUserMedia(constraints).then(function (stream) {
  507. callback(false, stream);
  508. })['catch'](function (err) {
  509. callback(err);
  510. });
  511. } else if (navigator.getUserMedia) {
  512. navigator.getUserMedia(constraints, function (stream) {
  513. callback(false, stream);
  514. }, function (err) {
  515. callback(err);
  516. });
  517. } else {
  518. callback(new Error('Not support userMedia'));
  519. }
  520. },
  521. /**
  522. * 关闭媒体流
  523. * @param stream {MediaStream} - 需要关闭的流
  524. */
  525. closeStream: function (stream) {
  526. if (typeof stream.stop === 'function') {
  527. stream.stop();
  528. } else {
  529. let trackList = [stream.getAudioTracks(), stream.getVideoTracks()];
  530. for (let i = 0; i < trackList.length; i++) {
  531. let tracks = trackList[i];
  532. if (tracks && tracks.length > 0) {
  533. for (let j = 0; j < tracks.length; j++) {
  534. let track = tracks[j];
  535. if (typeof track.stop === 'function') {
  536. track.stop();
  537. }
  538. }
  539. }
  540. }
  541. }
  542. }
  543. };
  544. let vueList = new Vue({
  545. el: "#editPanel",
  546. data: {
  547. imgPrefix:"{{asset("/storage")}}",
  548. // 用于存放 MediaRecorder 对象和音频Track,关闭录制和关闭媒体设备需要用到
  549. recorder:'',
  550. mediaStream:'',
  551. // 用于存放录制后的音频文件对象和录制结束回调
  552. recorderFile:'',
  553. stopRecordCallback:'',
  554. // 用于存放是否开启了视频录制
  555. videoEnabled:false,
  556. status: {
  557. billCreating: true,
  558. billEditing: false,
  559. itemCreating: true,
  560. itemEditing: false
  561. ,
  562. editingBill: null,
  563. editingBillId: '',
  564. editingItem: null,
  565. editingItemId: ''
  566. ,
  567. inputtingId_owner: '',
  568. endAndPackCommitEdited: false,
  569. lockingBillPanel: false,
  570. lockingIsLoadedInput: false,
  571. existItemsBeforeAdd: 0
  572. },
  573. itemInputting: {
  574. barcode_goods: "", name_goods: "", amount: "1", id_quality_label: "",
  575. batch_number: "", validity_at: "", remark: "", made_at: "",
  576. },
  577. billInputting: {
  578. id_owner: "", mobile_sender: "", sender: "", order_number: "", remark: "",
  579. logistic_number_return: "", logistic_number: "", id_logistic_return: "",
  580. fee_collected: "", is_loaded: "0", locateLogisticSearch: "", locateOwnerSearch: "",
  581. isLoadSign: false,
  582. },
  583. errors: {
  584. id_owner: "", mobile_sender: "", sender: "", bill_remark: "",
  585. logistic_number_return: "", logistic_number: "", id_logistic_return: "",
  586. fee_collected: "", is_loaded: "",
  587. barcode_goods: "", name_goods: "", amount: "", id_quality_label: "",
  588. batch_number: "", validity_at: "", remark: "", made_at: "",
  589. },
  590. rejectedBills: {!! $rejectedBills??[] !!},
  591. items: [],
  592. owners: [
  593. @foreach($owners as $owner)
  594. {
  595. id: '{{$owner->id}}', name: '{{$owner->name}}', code: '{{$owner->code}}'
  596. },
  597. @endforeach
  598. ],
  599. logistics: [
  600. @foreach($logistics as $logistic)
  601. {
  602. id: '{{$logistic->id}}', name: '{{$logistic->name}}', code: '{{$logistic->code}}'
  603. },
  604. @endforeach
  605. ],
  606. qualityLabels: [
  607. @foreach($qualityLabels as $qualityLabel)
  608. {
  609. id: '{{$qualityLabel->id}}', name: '{{$qualityLabel->name}}'
  610. },
  611. @endforeach
  612. ],
  613. commodityOwnerId: '',
  614. },
  615. mounted: function () {
  616. let _this = this;
  617. $('#editPanel').removeClass('d-none');
  618. $('.tooltipOn').tooltip({'trigger': 'hover'});
  619. $(document).on('keypress', function (e) {
  620. if (_this.itemInputting.barcode_goods) {
  621. if (e.key === '*') {
  622. _this.commitItem();
  623. return false;
  624. }
  625. }
  626. });
  627. this.listenEnterAndJump();
  628. },
  629. methods: {
  630. logistic_number_returnChange: function (e) {
  631. let _this = this;
  632. let number = $(e.target).val();
  633. if (!number) return;
  634. let url = '{{"/apiLocal/logistic/numberFeatures/computeLogisticByNumber"}}';
  635. axios.post(url, {logistic_number_return: number}).then(function (response) {
  636. _this.cleanError();
  637. if (response.data.success === 'true') {
  638. if (response.data.logistic) {
  639. _this.billInputting.id_logistic_return = response.data.logistic.id;
  640. }
  641. }
  642. }).catch(function (response) {
  643. console.log(response);
  644. });
  645. if (_this.status.editingBill) return;
  646. let url_isUnique = '{{"/apiLocal/logistic/logisticNumberReturnIsUnique"}}';
  647. axios.post(url_isUnique, {logistic_number_return: number}).then(function (response) {
  648. _this.cleanError();
  649. if (response.data.success === 'true') {
  650. if (response.data.result === 'true') {
  651. tempTip.okWindow('该退回单号"' + number + '"已有录入其他单', '知道了')
  652. } else _this.seek_order();
  653. }
  654. }).catch(function (response) {
  655. console.log(response);
  656. });
  657. },
  658. barcode_goodsChange: function (e) {
  659. let _this = this;
  660. let barcode = $(e.target).val();
  661. let url = '{{"/apiLocal/commodity/getCommodityByBarcode"}}';
  662. axios.post(url, {
  663. barcode: barcode,
  664. owner_id: _this.billInputting.id_owner
  665. }).then(function (response) {
  666. _this.cleanError();
  667. if (response.data.success === 'true') {
  668. if (response.data.commodity) {
  669. // _this.itemInputting.name_goods=response.data.name;
  670. _this.itemInputting.name_goods = response.data.commodity.name;
  671. _this.commodityOwnerId = response.data.commodity.owner_id;
  672. }
  673. } else {
  674. tempTip.setDuration(3000);
  675. tempTip.show('查找商品条码错误:' + response.data.fail_info)
  676. }
  677. }).catch(function (response) {
  678. tempTip.setDuration(3000);
  679. tempTip.show('未连接至商品表,检查网络');
  680. });
  681. },
  682. name_goodsChange: function (e) {
  683. let _this = this;
  684. let name = $(e.target).val();
  685. this.items.forEach(function (item) {
  686. if (item.barcode_goods + '' === _this.itemInputting.barcode_goods + '') {
  687. item.name_goods = name;
  688. }
  689. });
  690. },
  691. listenEnterAndJump: function () {
  692. let targets = $('select,input');
  693. targets.off('keypress');
  694. targets.on('keypress', function (e) {
  695. if (e.key !== "Enter") return;
  696. let target = $(e.target);
  697. let currentOrder = target.attr('data-focusOrder');
  698. if (currentOrder) {
  699. targets.each(function ($i, $val) {
  700. let checkingTarget = $($val);
  701. let checkingOrder = checkingTarget.attr('data-focusOrder');
  702. if (parseInt(currentOrder) + 1 === parseInt(checkingOrder)) {
  703. checkingTarget.focus();
  704. }
  705. })
  706. }
  707. });
  708. targets.off('change');
  709. targets.on('change', function (e) {
  710. let target = $(e.target);
  711. let currentOrder = target.attr('data-focusOrder');
  712. if (currentOrder) {
  713. targets.each(function ($i, $val) {
  714. let checkingTarget = $($val);
  715. let checkingOrder = checkingTarget.attr('data-focusOrder');
  716. if (parseInt(currentOrder) + 1 === parseInt(checkingOrder)) {
  717. checkingTarget.focus();
  718. }
  719. })
  720. }
  721. })
  722. },
  723. cleanHeader: function () {
  724. for (let key in this.billInputting) {
  725. this.billInputting[key] = '';
  726. }
  727. this.billInputting.id_owner = this.status.inputtingId_owner;
  728. this.billInputting.is_loaded = "0";
  729. this.billInputting.isLoadSign = false;
  730. },
  731. cleanItem: function () {
  732. for (let key in this.itemInputting) {
  733. this.itemInputting[key] = '';
  734. }
  735. this.itemInputting['amount'] = '1';
  736. },
  737. cleanError: function () {
  738. for (let key in this.errors) {
  739. this.errors[key] = '';
  740. }
  741. },
  742. setEditingBill: function (id) {
  743. let _this = this;
  744. this.status.editingBillId = id;
  745. this.rejectedBills.forEach(function (bill) {
  746. if (bill.id + '' === id + '') {
  747. _this.status.editingBill = bill;
  748. bill.isEditing = true;
  749. } else {
  750. bill.isEditing = false
  751. }
  752. });
  753. this.$forceUpdate();
  754. },
  755. setEditingItem: function (id) {
  756. let _this = this;
  757. this.status.editingItemId = id;
  758. this.items.forEach(function (item) {
  759. if (item.id + '' === id + '') {
  760. _this.status.editingItem = item;
  761. item.isEditing = true;
  762. } else {
  763. item.isEditing = false
  764. }
  765. });
  766. this.$forceUpdate();
  767. },
  768. commitHeader: function () {
  769. let _this = this;
  770. let url = '{{url('apiLocal/rejectedBill/store')}}';
  771. tempTip.setDuration(99999);
  772. tempTip.waitingTip('提交中')
  773. axios.post(url, _this.billInputting).then(function (response) {
  774. tempTip.cancelWaitingTip();
  775. _this.cleanError();
  776. if (response.data.success === 'true') {
  777. tempTip.setDuration(1000);
  778. tempTip.showSuccess('成功录入退单号:' + _this.billInputting.logistic_number_return);
  779. _this.status.inputtingId_owner = _this.billInputting.id_owner;
  780. _this.setEditingBill(response.data.id);
  781. _this.getItemsUnderBill(response.data.id);
  782. _this.cleanHeader();
  783. _this.getRecentRejectedBills();
  784. _this.lockBillPanel();
  785. _this.status.existItemsBeforeAdd = 0;
  786. $('#barcode_goods').focus();
  787. } else {
  788. if (response.data.error_fields) {
  789. tempTip.setDuration(3000);
  790. tempTip.show('录入失败,字段填写错误');
  791. _this.errors = response.data.error_fields;
  792. if (_this.errors.remark) {
  793. _this.errors.bill_remark = _this.errors.remark;
  794. _this.errors.remark = '';
  795. }
  796. } else {
  797. tempTip.setDuration(3000);
  798. tempTip.show('录入失败:' + response.data.fail_info)
  799. }
  800. }
  801. }).catch(function (response) {
  802. tempTip.setDuration(3000);
  803. tempTip.show('提交失败,请重试:' + response.data.fail_info)
  804. alert('连接错误:' + response)
  805. });
  806. },
  807. commitEditItem: function () {
  808. let _this = this;
  809. if (!confirm("确定要提交修改吗?")) {
  810. return;
  811. }
  812. let url = '{{url('apiLocal/rejectedBillItem/update')}}';
  813. axios.post(url, _this.itemInputting).then(function (response) {
  814. _this.cleanError();
  815. if (response.data.success === 'true') {
  816. tempTip.setDuration(1000);
  817. tempTip.showSuccess('成功修改商品:' + _this.itemInputting.barcode_goods);
  818. _this.cleanItem();
  819. _this.getItemsUnderBill(_this.status.editingBillId);
  820. _this.shiftToCreateItem();
  821. } else {
  822. if (response.data.error_fields) {
  823. tempTip.setDuration(3000);
  824. tempTip.show('修改失败,字段填写错误');
  825. _this.errors = response.data.error_fields;
  826. if (_this.errors.remark) {
  827. _this.errors.bill_remark = _this.errors.remark;
  828. _this.errors.remark = '';
  829. }
  830. } else {
  831. tempTip.show('修改失败:' + response.data.fail_info)
  832. }
  833. }
  834. }).catch(function (response) {
  835. tempTip.setDuration(3000);
  836. tempTip.show('提交失败,请重试:' + response.data.fail_info)
  837. alert('连接错误:' + response)
  838. });
  839. },
  840. commitEditHeader: function () {
  841. let _this = this;
  842. if (!confirm("确定要提交修改吗?")) {
  843. return;
  844. }
  845. let url = '{{url('apiLocal/rejectedBill/update')}}';
  846. tempTip.setDuration(99999);
  847. tempTip.waitingTip('提交中')
  848. axios.post(url, _this.billInputting).then(function (response) {
  849. tempTip.cancelWaitingTip();
  850. _this.cleanError();
  851. if (response.data.success === 'true') {
  852. tempTip.setDuration(1000);
  853. tempTip.showSuccess('成功修改退单号:' + _this.billInputting.logistic_number_return);
  854. _this.cleanHeader();
  855. _this.getRecentRejectedBills();
  856. _this.shiftToCreate();
  857. } else {
  858. if (response.data.error_fields) {
  859. tempTip.setDuration(3000);
  860. tempTip.show('修改失败,字段填写错误');
  861. _this.errors = response.data.error_fields;
  862. } else {
  863. tempTip.show('修改失败:' + response.data.fail_info)
  864. }
  865. }
  866. }).catch(function (response) {
  867. tempTip.setDuration(3000);
  868. tempTip.show('提交失败,请重试:' + response.data.fail_info)
  869. alert('连接错误:' + response)
  870. });
  871. },
  872. commitItem: function () {
  873. let _this = this;
  874. let url = '{{url('apiLocal/rejectedBillItem/store')}}';
  875. _this.itemInputting.id_rejected_bill = _this.status.editingBill.id;
  876. if (_this.items.length < 1) {
  877. let baoShiBuFaOwnerId = '';
  878. _this.owners.forEach(function (owner) {
  879. if (owner.name === '宝时补发') baoShiBuFaOwnerId = owner.id;
  880. });
  881. if (_this.commodityOwnerId != _this.billInputting.id_owner && _this.billInputting.id_owner != baoShiBuFaOwnerId) {
  882. _this.isChangeOwner(_this.itemInputting.id_rejected_bill);
  883. }
  884. }
  885. axios.post(url, _this.itemInputting).then(function (response) {
  886. _this.cleanError();
  887. if (response.data.success === 'true') {
  888. tempTip.setDuration(1000);
  889. tempTip.showSuccess('成功录入退单商品:' + _this.itemInputting.name_goods);
  890. _this.status.endAndPackCommitEdited = false;
  891. _this.lockBillPanel();
  892. _this.getItemsUnderBill(_this.status.editingBill.id);
  893. _this.cleanItem();
  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. } else {
  901. tempTip.show('录入失败:' + response.data.fail_info)
  902. }
  903. }
  904. }).catch(function (response) {
  905. tempTip.setDuration(3000);
  906. tempTip.show('提交失败,请重试:' + response.data.fail_info)
  907. alert('连接错误:' + response)
  908. });
  909. },
  910. isChangeOwner(id_rejected_bill) {
  911. let _this = this;
  912. let url = '{{url('apiLocal/rejectedBillItem/reviseOwner')}}';
  913. window.tempTip.confirm('当前退货记录货主名与录入商品的货主不匹配! ' + '确定校正退货记录货主名吗?', () => {
  914. window.axios.post(url, {
  915. commodityOwnerId: _this.commodityOwnerId,
  916. id_rejected_bill: id_rejected_bill
  917. }).then(res => {
  918. if (res.data.success === 'true') {
  919. let owner_name = '';
  920. _this.owners.forEach(function (owner) {
  921. if (owner.id == _this.commodityOwnerId) {
  922. owner_name = owner.name;
  923. }
  924. })
  925. _this.billInputting.id_owner = _this.commodityOwnerId;
  926. _this.rejectedBills.forEach(function (rejectedBill) {
  927. if (id_rejected_bill == rejectedBill.id) rejectedBill.owner_name = owner_name;
  928. })
  929. } else {
  930. tempTip.setDuration(3000);
  931. tempTip.show(res.data.message);
  932. return;
  933. }
  934. }).catch(err => {
  935. window.tempTip.setDuration(3000);
  936. window.tempTip.show("网络错误:" + err);
  937. return;
  938. });
  939. });
  940. },
  941. endAndPackCommitEdit: function () {
  942. let _this = this;
  943. if (_this.items.length === 0) {
  944. if (confirm('没有填加明细项,确定要退出详细编辑模式吗?')) {
  945. _this.cancelPackCommitEdit();
  946. }
  947. return;
  948. } else {
  949. if (!confirm('确定要提交填加的明细项吗?提交后即不可修改')) {
  950. return;
  951. }
  952. }
  953. let ids = [];
  954. _this.items.forEach(function (item) {
  955. ids.push(item.id);
  956. });
  957. let url = '{{url('apiLocal/rejectedBillItem/packConfirm')}}';
  958. tempTip.setDuration(5000);
  959. tempTip.waitingTip('与外部交互中,请稍候');
  960. axios.post(url, {'ids': ids}).then(function (response) {
  961. _this.cleanError();
  962. tempTip.cancelWaitingTip();
  963. if (response && response.data && response.data.success !== 'false') {
  964. if (response.data.success == 'exception') {
  965. _this.status.lockingIsLoadedInput = true;
  966. _this.billInputting.is_loaded = 3;
  967. tempTip.show('富勒入库异常,请手动校对');
  968. } else if (typeof (response.data.bill_is_loaded) != 'undefined') {
  969. if (response.data.bill_is_loaded === true) {
  970. _this.status.editingBill.is_loaded = 1;
  971. _this.billInputting.is_loaded = 1;
  972. _this.billInputting.isLoadSign = true;
  973. // _this.status.lockingIsLoadedInput=true;
  974. tempTip.okWindow('该批商品状态已改为“入库”', '已处理');
  975. }
  976. }
  977. tempTip.setDuration(5000);
  978. switch (response.data.remote_result) {
  979. case 'fail':
  980. tempTip.show('与客户服务器通讯异常,明细未被外部处理,请联系系统相关同事');
  981. break;
  982. case 'none':
  983. tempTip.show('客户未返回明细处理信息,请联系系统相关同事检查');
  984. break;
  985. case 'received':
  986. tempTip.show('该单之前已提交过给客户服务器');
  987. break;
  988. case 'storable':
  989. tempTip.showSuccess('WMS尚未推单,客户返回可以入库,所以状态为“待推单”', '已处理该待推单');
  990. break;
  991. default:
  992. tempTip.showSuccess('成功录入所有退单商品并已上传至外部');
  993. break;
  994. }
  995. _this.status.endAndPackCommitEdited = true;
  996. _this.cancelPackCommitEdit();
  997. } else {
  998. tempTip.setDuration(4000);
  999. let fail_info = '';
  1000. if (response.data)
  1001. fail_info = response.data.fail_info;
  1002. tempTip.show('录入明细列表失败,请重试:' + fail_info)
  1003. }
  1004. }).catch(function (response) {
  1005. tempTip.cancelWaitingTip();
  1006. tempTip.setDuration(3000);
  1007. let fail_info = '';
  1008. if (response.data)
  1009. fail_info = response.data.fail_info;
  1010. tempTip.show('提交失败,请重试:' + fail_info);
  1011. alert('连接错误:' + response)
  1012. });
  1013. },
  1014. cancelPackCommitEdit: function () {
  1015. let _this = this;
  1016. if (_this.items.length === 0 && !_this.status.endAndPackCommitEdited) {
  1017. _this.unlockBillPanel();
  1018. return;
  1019. } else {
  1020. if (_this.status.endAndPackCommitEdited) {
  1021. _this.unlockBillPanel();
  1022. return;
  1023. } else {
  1024. if (!confirm('已填加的明细尚未提交,回到表头编辑将取消已填加明细,是否确定?')) {
  1025. return;
  1026. }
  1027. }
  1028. }
  1029. let ids = [];
  1030. for (let i = _this.status.existItemsBeforeAdd; i < _this.items.length; i++) {
  1031. ids.push(_this.items[i].id);
  1032. }
  1033. if (ids.length === 0) {
  1034. _this.unlockBillPanel();
  1035. return;
  1036. }
  1037. let url = '{{url('apiLocal/rejectedBillItem/packDestroy')}}';
  1038. axios.post(url, {'ids': ids}).then(function (response) {
  1039. _this.cleanError();
  1040. if (response.data.success === 'true') {
  1041. _this.status.editingBill = null;
  1042. _this.unlockBillPanel();
  1043. } else {
  1044. tempTip.show('数据操作失败,请重试:' + response.data.fail_info)
  1045. }
  1046. }).catch(function (response) {
  1047. tempTip.setDuration(3000);
  1048. tempTip.show('提交失败,请重试:' + response.data.fail_info)
  1049. alert('连接错误:' + response)
  1050. });
  1051. },
  1052. lockBillPanel: function () {
  1053. this.status.lockingBillPanel = true;
  1054. $('input,select').blur();
  1055. },
  1056. unlockBillPanel: function () {
  1057. this.status.lockingBillPanel = false;
  1058. this.status.editingBill = null;
  1059. this.status.editingBillId = '';
  1060. this.shiftToCreate();
  1061. },
  1062. getRecentRejectedBills: function () {
  1063. let _this = this;
  1064. let url = '{{url('apiLocal/rejectedBill/apiGetRecent')}}';
  1065. axios.post(url).then(function (response) {
  1066. if (response.data.success === 'true') {
  1067. _this.rejectedBills = response.data.rejectedBills;
  1068. _this.setEditingBill(_this.status.editingBillId)
  1069. } else {
  1070. tempTip.show('加载新增内容失败,可尝试刷新页面');
  1071. }
  1072. }).catch(function (response) {
  1073. alert('连接错误:' + response);
  1074. tempTip.show('加载新增内容失败,可尝试刷新页面!');
  1075. });
  1076. },
  1077. getItemsUnderBill: function (billId, func) {
  1078. let _this = this;
  1079. let url = '{{url('apiLocal/rejectedBillItem/apiGet')}}';
  1080. axios.post(url, {id_rejected_bill: billId}).then(function (response) {
  1081. if (response.data.success === 'true') {
  1082. response.data.items.forEach(function (item) {
  1083. item.isEditing = false;
  1084. });
  1085. _this.items = response.data.items;
  1086. if (typeof func !== 'undefined') {
  1087. func()
  1088. }
  1089. _this.listenEnterAndJump();
  1090. setTimeout(function () {
  1091. $('#barcode_goods').focus();
  1092. }, 500)
  1093. } else {
  1094. tempTip.show('加载相关明细失败,可尝试刷新页面');
  1095. }
  1096. }).catch(function (response) {
  1097. alert('连接错误:' + response);
  1098. tempTip.show('加载相关明细失败,可尝试刷新页面!');
  1099. });
  1100. },
  1101. deleteBill: function (rejectedBill) {
  1102. if (!confirm('确定要删除退货信息“' + rejectedBill.owner_name + ':' + rejectedBill.logistic_number_return + '”吗?')) {
  1103. return;
  1104. }
  1105. let _this = this;
  1106. let url = "{{url('rejectedBill')}}/" + rejectedBill.id;
  1107. axios.delete(url, {id: rejectedBill.id})
  1108. .then(function (response) {
  1109. if (response.data.success) {
  1110. for (let i = 0; i < _this.rejectedBills.length; i++) {
  1111. if (_this.rejectedBills[i].id === rejectedBill.id) {
  1112. _this.rejectedBills.splice(i, 1);
  1113. break;
  1114. }
  1115. }
  1116. tempTip.setDuration(1000);
  1117. tempTip.showSuccess('删除退货信息"' + rejectedBill.owner_name + ':' + rejectedBill.logistic_number_return + '"成功!')
  1118. } else {
  1119. tempTip.setDuration(1000);
  1120. tempTip.show('删除退货信息"' + rejectedBill.owner_name + ':' + rejectedBill.logistic_number_return + '"失败!')
  1121. }
  1122. })
  1123. .catch(function (err) {
  1124. tempTip.setDuration(3000);
  1125. tempTip.show('删除退货信息失败!' + '网络错误:' + err);
  1126. });
  1127. },
  1128. deleteItem: function (e) {
  1129. if (!confirm('确定要删除该明细吗?不可恢复')) {
  1130. return
  1131. }
  1132. let _this = this;
  1133. let id = $(e.target).parents('tr').attr('data-id');
  1134. let url = '{{url('apiLocal/rejectedBillItem/apiDelete')}}';
  1135. axios.post(url, {id: id}).then(function (response) {
  1136. if (response.data.success === 'true') {
  1137. _this.items.forEach(function (item, i) {
  1138. if (item.id + '' === id + '') {
  1139. _this.items.splice(i, 1);
  1140. }
  1141. });
  1142. } else {
  1143. tempTip.show('删除失败,可尝试刷新页面再操作');
  1144. }
  1145. }).catch(function (response) {
  1146. alert('连接错误:' + response);
  1147. tempTip.show('删除失败,可尝试刷新页面!');
  1148. });
  1149. },
  1150. editBill: function (e) {
  1151. let _this = this;
  1152. let billId = $(e.target).parent('tr').attr('data-id');
  1153. let billTarget = '';
  1154. this.rejectedBills.every(function (bill) {
  1155. if (bill.id + '' === billId + '') {
  1156. billTarget = bill;
  1157. return false;
  1158. }
  1159. return true;
  1160. });
  1161. if (billTarget) {
  1162. this.billInputting = JSON.parse(JSON.stringify(billTarget));
  1163. this.shiftToEdit();
  1164. this.setEditingBill(billTarget.id)
  1165. }
  1166. this.getItemsUnderBill(billTarget.id, function () {
  1167. _this.status.existItemsBeforeAdd = _this.items.length;
  1168. });
  1169. },
  1170. editItem: function (e) {
  1171. let _this = this;
  1172. let itemId = $(e.target).parent('tr').attr('data-id');
  1173. let itemTarget = '';
  1174. this.items.every(function (item) {
  1175. if (item.id + '' === itemId + '') {
  1176. itemTarget = item;
  1177. return false;
  1178. }
  1179. return true;
  1180. });
  1181. if (itemTarget) {
  1182. this.itemInputting = JSON.parse(JSON.stringify(itemTarget));
  1183. this.shiftToEditItem();
  1184. this.setEditingItem(itemTarget.id)
  1185. }
  1186. // this.getItemsUnderBill(this.status.editingBillId,function () {});
  1187. },
  1188. shiftToEditItem: function () {
  1189. this.cleanError();
  1190. this.status.itemCreating = false;
  1191. this.status.itemEditing = true;
  1192. setTimeout(function () {
  1193. $('.tooltipOn').tooltip({'trigger': 'hover'});
  1194. }, 50)
  1195. },
  1196. shiftToEdit: function () {
  1197. this.cleanError();
  1198. this.status.billCreating = false;
  1199. this.status.billEditing = true;
  1200. setTimeout(function () {
  1201. $('.tooltipOn').tooltip({'trigger': 'hover'});
  1202. }, 50)
  1203. },
  1204. shiftToCreateItem: function () {
  1205. this.cleanError();
  1206. this.cleanItem();
  1207. this.status.itemCreating = true;
  1208. this.status.itemEditing = false;
  1209. this.items.forEach(function (item) {
  1210. item.isEditing = false;
  1211. });
  1212. $('.tooltipOn').tooltip('hide').tooltip({'trigger': 'hover'});
  1213. },
  1214. shiftToCreate: function () {
  1215. this.cleanError();
  1216. this.cleanHeader();
  1217. this.status.billCreating = true;
  1218. this.status.billEditing = false;
  1219. this.status.editingBill = null;
  1220. this.rejectedBills.forEach(function (rejectedBill) {
  1221. if (rejectedBill.isEditing === true) {
  1222. rejectedBill.isEditing = false;
  1223. return false;
  1224. }
  1225. });
  1226. $('.tooltipOn').tooltip('hide').tooltip({'trigger': 'hover'});
  1227. },
  1228. locateIdOwner: function (e) {
  1229. let _this = this;
  1230. let $target = $(e.target);
  1231. this.owners.forEach(function (owner) {
  1232. if (owner.name.includes($target.val())) {
  1233. _this.billInputting.id_owner = owner.id;
  1234. }
  1235. });
  1236. },
  1237. locateLogistic: function (e) {
  1238. let _this = this;
  1239. let $target = $(e.target);
  1240. this.logistics.forEach(function (logistic) {
  1241. if (logistic.name.includes($target.val())) {
  1242. _this.billInputting.id_logistic_return = logistic.id;
  1243. }
  1244. });
  1245. },
  1246. //根据退回单寻找WMS订单填充已有字段
  1247. seek_order() {
  1248. let _this = this;
  1249. let logistic_number_return = this.billInputting.logistic_number_return;
  1250. if (!logistic_number_return) return;
  1251. axios.post('{{url('apiLocal/rejectedBill/seekOrder')}}', {logistic_number_return: logistic_number_return})
  1252. .then(function (response) {
  1253. if (response.data.success) {
  1254. if (response.data.data.owner_id) _this.billInputting.id_owner = response.data.data.owner_id;
  1255. if (response.data.data.logistic_id) _this.billInputting.id_logistic_return = response.data.data.logistic_id;
  1256. if (response.data.data.consignee_name) _this.billInputting.sender = response.data.data.consignee_name;
  1257. if (response.data.data.consignee_phone) _this.billInputting.mobile_sender = response.data.data.consignee_phone;
  1258. if (response.data.data.client_code) _this.billInputting.order_number = response.data.data.client_code;
  1259. if (response.data.data.logistic_number) _this.billInputting.logistic_number = response.data.data.logistic_number;
  1260. tempTip.setDuration(2000);
  1261. tempTip.showSuccess('原单信息已填充');
  1262. return;
  1263. }
  1264. tempTip.setDuration(2000);
  1265. tempTip.show('没有找到对应的数据,可手动填写 ');
  1266. });
  1267. },
  1268. // 开启摄像头
  1269. enableCamera(enableVideo) {
  1270. this.videoEnabled = enableVideo;
  1271. MediaUtils.getUserMedia(enableVideo, false, function (err, stream) {
  1272. if (err) {
  1273. throw err;
  1274. } else {
  1275. let photo=document.getElementById('photo');
  1276. photo.srcObject = stream;
  1277. photo.play();
  1278. }
  1279. });
  1280. },
  1281. // 关闭摄像头
  1282. closeCamera() {
  1283. let stream = document.getElementById('photo').srcObject;
  1284. let tracks = stream.getTracks();
  1285. tracks.forEach(function(track) {
  1286. track.stop();
  1287. });
  1288. document.getElementById('photo').srcObject = null;
  1289. },
  1290. //拍照
  1291. takePhoto(id,index){
  1292. this.enableCamera(true);
  1293. setTimeout(()=>{
  1294. let photo=document.getElementById('photo');
  1295. let canvas=document.getElementById('canvas');
  1296. //绘制canvas图形
  1297. canvas.getContext('2d').drawImage(photo, 0, 0, 400, 300);
  1298. let img = document.getElementById('canvas').toDataURL();
  1299. // 这里的img就是得到的图片
  1300. this.closeCamera();
  1301. let blob=this.dataUrlToBlob(img);
  1302. this.submitFile(blob,id,index);
  1303. // photo.style.display='none';
  1304. },2500)
  1305. },
  1306. dataUrlToBlob(imgDataUrl) {
  1307. let imgUrl = window.atob(imgDataUrl.split(',')[1])
  1308. let ab = new ArrayBuffer(imgUrl.length)
  1309. let ia = new Uint8Array(ab)
  1310. for (let i = 0; i < imgUrl.length; i++) {
  1311. ia[i] = imgUrl.charCodeAt(i)
  1312. }
  1313. return new Blob([ab],{type:'image/jpeg'})
  1314. },
  1315. submitFile(blob,id,index){
  1316. window.tempTip.setDuration(3000);
  1317. let formData=new FormData();
  1318. formData.append('files[]', blob,'rejected_bill_item'+id+'.jpg')
  1319. formData.append("id",id);
  1320. window.tempTip.postBasicRequest('{{url('apiLocal/rejectedBillItem/apiUpload')}}',formData,res=>{
  1321. if (this.items[index].upload_files.length===0) this.$set(this.items[index],'upload_files',res);
  1322. else this.$set(this.items[index],'upload_files',this.items[index].upload_files.concat(res));
  1323. return "上传成功";
  1324. },false,true);
  1325. },
  1326. removeCommonImg(id){
  1327. $('#'+id).remove();
  1328. },
  1329. commonImg(id,uploadFiles){
  1330. let div = "";
  1331. let isBtn = '@can('运输管理-运单-图片删除') true @endcan ';
  1332. for(let i=0;i<uploadFiles.length;i++){
  1333. 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>" : "";
  1334. let href = this.imgPrefix+uploadFiles[i].url+'-bulky.'+uploadFiles[i].type;
  1335. let src = this.imgPrefix+uploadFiles[i].url+'-common.'+uploadFiles[i].type;
  1336. div += "<div><a target='_blank' href='"+href+"'><img alt='#' src='"+src+"' style='position: relative;' ></a>"+btn+"</div>"
  1337. }
  1338. $('#'+id).after(
  1339. "<div id=\"common_"+id+"\" style='position: absolute;padding-bottom: 2px;z-index: 99'>" +
  1340. "<div style='position:absolute;left: -50px' class='overflow-y-scrollbar-200'>"+div+
  1341. "</div></div>");
  1342. },
  1343. btnDeleteImg(e){
  1344. let idstr = $(e).val();
  1345. let id = idstr.substr( idstr.indexOf('_')+1);
  1346. let url = e.getAttribute("data-url");
  1347. if (!confirm('确定要删除所选图片吗?'))return;
  1348. this.destroyImg(id,url);
  1349. },
  1350. destroyImg(id,url = null){
  1351. window.tempTip.postBasicRequest('{{url('apiLocal/rejectedBillItem/apiDeleteImg')}}',{id:id,url:url},()=>{
  1352. if (url){
  1353. this.items.some((item,i)=>{
  1354. if (item.id==id){
  1355. item.upload_files.some((file,j)=>{
  1356. if (file.url === url){this.$delete(this.items[i].upload_files,j);return true;}
  1357. });
  1358. return true;
  1359. }
  1360. });
  1361. }else{
  1362. this.items.forEach((item,i)=>{
  1363. if (id.includes(item.id))this.$set(this.items[i],'upload_files',[]);
  1364. });
  1365. }
  1366. return "删除成功";
  1367. });
  1368. },
  1369. },
  1370. filters: {
  1371. isLoaded: function (value) {
  1372. return value == 1 ? '是' : '否';
  1373. },
  1374. dateNoYear: function (value) {
  1375. if (!value) return '';
  1376. return value.substr(5, 11);
  1377. }
  1378. },
  1379. });
  1380. </script>
  1381. @endsection