create.blade.php 96 KB

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