inventoryMission.blade.php 131 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158
  1. @extends('layouts.app')
  2. @section('title')盘点-任务-{!! $inventoryAccount->id !!}@endsection
  3. @section('content')
  4. @component('inventory.stockInventory.menu')
  5. <li class="nav-item">
  6. <a class="nav-link" href="{{URL::current()}}" :class="{active:isActive('enterStockInventory',3)}">盘点中({!! $inventoryAccount->id !!})</a>
  7. </li>
  8. @endcomponent
  9. <div class="text-center h5 mt-2" id="loadingPage">
  10. 载入中……
  11. </div>
  12. <div id="list" class="d-none container-fluid" >
  13. <div class="mt-3">
  14. <span class="mt-3" >
  15. @can('库存管理-盘点-完结')
  16. <span><button class="btn btn-sm btn-outline-info" v-if="inventory.status==='复盘中' &&!listMode" @click="完结盘点任务(inventory.id,inventory.owner.name,inventory.type)">完结</button></span>
  17. @endcan
  18. @can('库存管理-盘点-查看')
  19. <button class="btn btn-sm" @click="listMode?listMode=false:listMode=true" :class="listMode?'btn-dark':'btn-outline-dark'" v-if="!listMode">切换为列表</button>
  20. @endcan
  21. @can('库存管理-盘点')
  22. <button class="btn btn-sm" @click="listMode?listMode=false:listMode=true" :class="listMode?'btn-dark':'btn-outline-dark'" v-if="listMode&&inventory.status!=='已完成'&&inventory.status!=='已审核'">切换为盘点</button>
  23. @endcan
  24. </span>
  25. <span class="dropdown">
  26. <button class="btn btn-outline-dark btn-sm form-control-sm dropdown-toggle tooltipTarget" :class="[checkData.length>0?'btn-dark text-light':'']"
  27. data-toggle="dropdown" title="导出所有页将会以搜索条件得到的过滤结果,将其全部记录(每一页)导出">
  28. 导出Excel
  29. </button>
  30. <div class="dropdown-menu">
  31. <a class="dropdown-item" @click="inventoryAccountMissionExport(false)" href="javascript:">导出勾选内容</a>
  32. <a class="dropdown-item" @click="inventoryAccountMissionExport(true)" href="javascript:">导出所有</a>
  33. </div>
  34. </span>
  35. <span>
  36. <button class="btn btn-sm" @click="盲收()" :class="listMode?'btn-dark':'btn-outline-dark'" v-if="!listMode&&!blindReceive">盲收</button>
  37. <button class="btn btn-sm" @click="正常盘点()" :class="blindReceive?'btn-dark':'btn-outline-dark'" v-if="blindReceive">正常盘点</button>
  38. </span>
  39. <span>
  40. <button class="btn btn-outline-dark btn-sm form-control-sm tooltipTarget"
  41. @click="批量跳过或确认差异()" title="勾选指定盘点记录行,进行批量跳过或批量确认差异">
  42. 批量跳过
  43. </button>
  44. </span>
  45. <span>
  46. <button class="btn btn-sm btn-info" @click="新增盘点记录()" :class="listMode?'btn-dark':'btn-outline-dark'" v-if="!listMode&&!addInventoryMission">新增盘点记录</button>
  47. <button class="btn btn-sm" @click="收起新增()" :class="addInventoryMission?'btn-dark':'btn-outline-dark'" v-if="addInventoryMission">收起新增</button>
  48. </span>
  49. <span class="form-group mb-5">
  50. <label class="text-muted">货主:</label><span class="font-weight-bold">@{{ inventory.owner.name }}</span>
  51. </span>
  52. <span class="form-group p-2 mb-5">
  53. <label >盘点单号:</label><span>@{{ inventory.id }}</span>
  54. </span>
  55. <span class="form-group p-2 mb-5">
  56. <label class="text-muted">时间范围:</label><span>@{{ inventory.start_at }} 至 @{{ inventory.end_at }}</span>
  57. </span>
  58. </div>
  59. <div class="mt-3">
  60. <span class="h5">
  61. <span class="form-group mb-5" v-if="inventory.status==='盘点中' || inventory.status==='待盘点'">
  62. <label class=" font-weight-bold">已盘点:</label><span>@{{ inventory.processed }}/总数:@{{ inventory.total }}</span>
  63. </span>
  64. <span class="form-group mb-5" v-if="inventory.status==='盘点中' || inventory.status==='待盘点'">
  65. <label class=" font-weight-bold">剩余数:</label><span>@{{ inventory.surplus }}</span>
  66. </span>
  67. <span class="form-group mb-5" v-if="inventory.status==='复盘中'&&未复盘有差异列">
  68. <label class=" font-weight-bold">有差异未复盘数:</label><span>@{{ 未复盘有差异列.length }}</span>
  69. </span>
  70. <span class="form-group mb-5" v-if="inventory.status==='复盘中'&&未盘列">
  71. <label class=" font-weight-bold">未盘点数:</label><span>@{{ 未盘列.length }}</span>
  72. </span>
  73. <span class="form-group mb-5" v-if="inventory.status==='复盘中'">
  74. <label class=" font-weight-bold">总数:</label><span>@{{ inventory.total }}</span>
  75. </span>
  76. </span>
  77. </div>
  78. <div class="mt-3" >
  79. <span v-if="!listMode" class="btn col-md-2 font-weight-bold" style="cursor: default;max-width: 160px" :class="inventory.status=='盘点中' ||inventory.status=='待盘点'?'bg-info':'btn-outline-info disabled'">
  80. @{{ inventory.type }}
  81. </span>
  82. <span v-if="!listMode">
  83. @can('库存管理-盘点-结束初盘')
  84. <span v-if="inventory.status==='盘点中' ||inventory.status=='待盘点'" class="btn col-md-2 font-weight-bold btn-outline-secondary" style="max-width: 160px" @click="stockInventoryEnd(inventory.id)">结束</span>
  85. @endcan
  86. <span v-if="inventory.status==='复盘中'" class="btn col-md-2 font-weight-bold" style="cursor: default;max-width: 160px" :class="inventory.status=='盘点中' ||inventory.status=='待盘点'?'btn-outline-info disabled':'bg-info'">复盘</span>
  87. </span>
  88. </div>
  89. <div v-if="blindReceive">
  90. <audio src="{{asset('sound/warning_otherBarcode.mp3')}}" controls="controls" preload id="soundWarning" hidden>
  91. </audio>
  92. <audio src="{{asset('sound/ding.mp3')}}" controls="controls" preload id="soundDing" hidden>
  93. </audio>
  94. <div class="row mt-2 mb-2 rounded" style="border:solid 3px #999999;">
  95. <div class="col-12" id="scanColumn">
  96. <div class="card" :class="borderByMode">
  97. <div class="card-body">
  98. <div class="row">
  99. <div class="col-12">
  100. <div >
  101. <div class="text-danger font-weight-bold">
  102. 库位(必填项):
  103. </div>
  104. <input type="text" class="form-control mb-2" v-model="location" @focusin="focusOutDocument" @focusout="focusDocument" @keyup="oninputEnter">
  105. </div>
  106. <p class="text-muted" style="font-size: 0.5em" v-if="inputMode=='regular'">常规:可输入效期,相同条码记录不会合并</p>
  107. <p class="text-muted" style="font-size: 0.5em" v-if="inputMode=='increasing'">逐一扫描:处理单一重复商品,每扫一次对应隔口总数量自动递增,扫到不同条码会提示</p>
  108. <p class="text-muted" style="font-size: 0.5em" v-if="inputMode=='multiIncreasing'">边扫边分:处理多种商品,自动将扫到的不同条码数量递增到各自隔口号</p>
  109. <ul class="nav nav-tabs mb-4 mt-n3">
  110. <li class="nav-item"><a href="#" class="nav-link" :class="inputMode=='regular'?'active':''"
  111. @click="inputMode='regular';changeToManualInputAmount();cleanInputs();inputting.fromIncreasing=false">常规</a></li>
  112. <li class="nav-item"><a href="#" class="nav-link" :class="inputMode=='increasing'?'active':''"
  113. @click="inputMode='increasing';changeToScanInputAmount();cleanInputs();inputting.fromIncreasing=true;">逐一扫描</a></li>
  114. <li class="nav-item"><a href="#" class="nav-link" :class="inputMode=='multiIncreasing'?'active':''"
  115. @click="inputMode='multiIncreasing';changeToScanInputAmount();cleanInputs();inputting.fromIncreasing=true">边扫边分</a></li>
  116. </ul>
  117. </div>
  118. <div class="col-6">
  119. <div v-if="inputMode=='regular'">
  120. <div class="btn btn-sm btn-outline-primary"
  121. v-if="!isManualInputtingBarcode" @click="changeToManualInputBarcode">手动输入</div>
  122. <div class="btn btn-sm btn-outline-danger"
  123. @click="changeToScanInputBarcode" v-if="isManualInputtingBarcode">扫描输入</div>
  124. </div>
  125. <input type="text" id="barcode" class="form-control" :disabled="status.barcodeDisable" placeholder="扫入条码" @focusin="focusOutDocument" @focusout="focusDocument" v-model="inputting.barcode" autocomplete="off">
  126. <div v-if="inputMode=='regular'">
  127. <div class="card-title">
  128. 生产日期:
  129. </div>
  130. <input type="date" class="form-control mb-2" v-model="inputting.produce_date" @focusin="focusOutDocument" @focusout="focusDocument" @keyup="oninputEnter">
  131. </div>
  132. <div v-if="inputMode=='regular'">
  133. <div class="card-title">
  134. 失效日期:
  135. </div>
  136. <input type="date" class="form-control mb-2" v-model="inputting.valid_date" @focusin="focusOutDocument" @focusout="focusDocument" @keyup="oninputEnter">
  137. </div>
  138. </div>
  139. <div class="col-6">
  140. <div class="card-title" id="amountLabel">
  141. 手动输入数量:
  142. </div>
  143. <div class="input-group mt-n2 mb-2">
  144. <input type="number" id="amount" class="form-control" placeholder="" :disabled="status.amountDisable"
  145. v-model="inputting.amount" @focusin="focusOutDocument" @focusout="focusDocument" @keyup="oninputEnter"
  146. style='height: 40px;font-size: 1.6em;color:blue;font-weight: bolder;padding: 3px;text-align: center'>
  147. </div>
  148. {{-- <div class="card-title">--}}
  149. {{-- 格口号:--}}
  150. {{-- </div>--}}
  151. {{-- <input type="number" id="bin" class="form-control mt-n2 mb-2"--}}
  152. {{-- v-model="inputting.bin"--}}
  153. {{-- :disabled="status.binDisable" @focusin="focusOutDocument" @focusout="focusDocument" @keyup="oninputEnter"--}}
  154. {{-- style='height: 80px;font-size: 5em;color:red;font-weight: bolder;padding: 3px;text-align: center'>--}}
  155. <div v-if="inputMode=='regular'">
  156. <div class="card-title">
  157. 批次号:
  158. </div>
  159. <input type="text" class="form-control mb-2" v-model="inputting.batch_number" @focusin="focusOutDocument" @focusout="focusDocument" @keyup="oninputEnter">
  160. </div>
  161. </div>
  162. <div class="col-12" v-if="commitButtonVisible && inputMode=='regular'" >
  163. <button class="btn btn-success btn form-control" @click="commitGoods">确定</button>
  164. </div>
  165. </div>
  166. <p class="card-text text-muted mt-3 mb-n3 text-center">
  167. 已完成:
  168. </p>
  169. <hr>
  170. <table class="table table-sm table-striped" v-if="goodses.length>0">
  171. <tr>
  172. {{-- <th>隔口号</th>--}}
  173. <th>数量</th>
  174. <th>条码</th>
  175. <th>生产日期</th>
  176. <th>失效日期</th>
  177. <th>批次号</th>
  178. <th>操作</th>
  179. </tr>
  180. <tr v-for="goods in goodses">
  181. {{-- <td>@{{ goods.bin }}</td>--}}
  182. <td>@{{ goods.amount }}</td>
  183. <td>@{{ goods.barcode }}</td>
  184. <td>@{{ goods.produce_date }}</td>
  185. <td>@{{ goods.valid_date }}</td>
  186. <td>@{{ goods.batch_number }}</td>
  187. <td><button class="btn btn-outline-danger btn-sm" @click="removeGoods($event,goods.barcode)">删</button></td>
  188. </tr>
  189. </table>
  190. <hr>
  191. <span class="btn btn-outline-dark btn form-control" style="cursor: pointer" @click="submitStockInventory">结束并生成盘点</span>
  192. </div>
  193. </div>
  194. </div>
  195. </div>
  196. </div>
  197. <form id="form">
  198. <div v-if="!blindReceive">
  199. <div class="mt-3 form-inline " v-if="!listMode" :class="inventory.status=='盘点中' ||inventory.status=='待盘点'?'row-cols-3':'row-cols-5'">
  200. <span class="form-group">
  201. <label for="location" class="text-secondary font-weight-bold">请输库位</label>
  202. <input id="locationInput" @keypress="locationPress($event)"
  203. @change="locationChange($event)"
  204. name="location" type="text" class="form-control input" autocomplete="off" value="@if(old('location')){{old('location')}}@endif">
  205. </span>
  206. <span class="form-group ml-4" v-if="addInventoryMission">
  207. <label for="barcode" class="text-secondary font-weight-bold">请输产品条码</label>
  208. <input id="barcodeInput" name="barcode" @keypress="barcodePress($event)"
  209. @change="barcodeChange($event)"
  210. type="text" value="@if(old('barcode')){{old('barcode')}}@endif" class="form-control input" autocomplete="off">
  211. </span>
  212. <span class="form-group ml-4" v-if="dataExtraStatus.addingNew&&addInventoryMission" id="countBlock">
  213. <label for="count" class="text-secondary font-weight-bold">请输盘点数</label>
  214. <input type="number" id="amountInput" @keypress="amountPress($event)"
  215. name="count" class="form-control input" value="@if(old('count')){{old('count')}}@endif" autocomplete="off">
  216. </span>
  217. <span type="button" class="btn btn-sm btn-outline-danger col-md-2 form-group ml-4" v-if="location" style="max-width: 160px" @click="stockInventoryByLocation()">盘点该库位下所有记录</span>
  218. </div>
  219. </div>
  220. <!--相同库位和条码 pc端-->
  221. <div class="row d-none d-xl-block">
  222. <div class="col-12 col-md-12 col-sm-12 showBlueTable d-none">
  223. <table class="table table-sm table-bordered table-info mt-2" :class="!listMode?'':'d-none'" id="blueTablePc">
  224. <tr>
  225. <td class="font-weight-bold">输入盘点数</td>
  226. <td>操作</td>
  227. <td>库位</td>
  228. <td>产品名</td>
  229. <td>产品条码</td>
  230. <td>产品编码</td>
  231. <td>生产日期</td>
  232. <td>失效时期</td>
  233. <td>批号</td>
  234. <th>属性仓</th>
  235. <th>质量状态</th>
  236. <td>盘点数量</td>
  237. <td>复盘数量</td>
  238. <td>复盘差异</td>
  239. </tr>
  240. <tr class="selectingRow" id="blueTrPc">
  241. <td>
  242. <input type="number" onkeypress="listVue.selectingRow(event)" name="amount" class="form-control-sm blueAmountPc" autocomplete="off" oninput="inputs.amount=event.target.value">
  243. </td>
  244. <td>
  245. <span class="btn btn-sm btn-outline-primary stockButtonPc" onclick="listVue.盘点选中任务(event)">选定盘点</span>
  246. </td>
  247. <td class="location"></td>
  248. <td class="commodity_name"></td>
  249. <td class="commodity_barcode"></td>
  250. <td class="commodity_sku"></td>
  251. <td><input type="date" class="form-control-sm produced_at" name="produced_at" onchange="producedAtChange(event)"></td>
  252. <td><input type="date" class="form-control-sm valid_at" name="valid_at" onchange="validAtChange(event)"></td>
  253. <td><input type="text" class="form-control-sm batch_number" name="batch_number" onchange="batchNumberChange(event)"></td>
  254. <td class="erp_type_position"></td>
  255. <td class="quality"></td>
  256. <td class="verified_amount font-weight-bold text-success"></td>
  257. <td class="re_checked_amount"></td>
  258. <td class="difference_amount"></td>
  259. </tr>
  260. </table>
  261. </div>
  262. </div>
  263. <!--相同库位和条码 移动端-->
  264. <div class="showBlueTable d-none">
  265. <table class="table table-striped table-sm table-bordered table-hover p-0 d-xl-none mt-2" style="background: rgb(179, 214, 245);" {{--v-if="!listMode"--}} :class="!listMode?'':'d-none'" id="blueTable">
  266. <tr class="selectingRow移动端" id="blueTr">
  267. <td style="filter:grayscale(30%); ">
  268. <div class="mt-3">
  269. <div>
  270. <span class="mr-3 text-nowrap"><span class="font-weight-bold">输入盘点数:</span>
  271. <span>
  272. <input type="number" onkeypress="listVue.selectingRow(event)" name="amount" class="form-control-sm blueAmount" autocomplete="off" oninput="inputs.amount=event.target.value">
  273. </span>
  274. </span>
  275. <span class="mr-3 text-nowrap"><span class="font-weight-bold">操作:</span><span class="btn btn-sm btn-outline-primary stockButton" onclick="listVue.盘点选中任务(event)">选定盘点</span></span>
  276. </div>
  277. <div style="transform:scale(0.9)" class="pl-0">
  278. <span class="mr-3 text-nowrap"><span class="font-weight-bold">库位:</span><span class="location"></span></span>
  279. <span class="mr-3 text-nowrap"><span class="font-weight-bold">产品名称:</span><span class="commodity_name"></span></span>
  280. <span class="mr-3 text-nowrap"><span class="font-weight-bold">产品条码:</span><span class="commodity_barcode"></span>
  281. </span>
  282. <span class="mr-3 text-nowrap"><span class="font-weight-bold">产品编码:</span><span class="commodity_sku"></span></span>
  283. <span class="mr-3 text-nowrap"><span class="font-weight-bold">生产日期:</span><input type="date" class="form-control-sm produced_at" name="produced_at" onchange="producedAtChange(event)"></span>
  284. <span class="mr-3 text-nowrap"><span class="font-weight-bold">失效时期:</span><input type="date" class="form-control-sm valid_at" name="valid_at" onchange="validAtChange(event)"></span>
  285. <span class="mr-3 text-nowrap"><span class="font-weight-bold">批号:</span><input type="text" class="form-control-sm batch_number" name="batch_number" onchange="batchNumberChange(event)"></span>
  286. <span class="mr-3 text-nowrap"><span>属性仓:</span><span class="erp_type_position"></span></span>
  287. <span class="mr-3 text-nowrap"><span>质量状态:</span><span class="quality"></span></span>
  288. <div>
  289. <span class="mr-3 text-nowrap"><span style="color:#783000">盘点数量:</span><span class="verified_amount font-weight-bold text-success"></span></span>
  290. <span class="mr-3 text-nowrap"><span style="color:#783000">复盘数量:</span><span style="color:#af7651" class="re_checked_amount"></span></span>
  291. <span class="mr-3 text-nowrap"><span style="color:#783000">盘点差异:</span><span class="difference_amount"></span></span>
  292. </div>
  293. </div>
  294. </div>
  295. </td>
  296. </tr>
  297. </table>
  298. </div>
  299. </form>
  300. <div class="card-body pt-1">
  301. <label for="all" class="d-none" id="cloneCheckAll">
  302. <input id="all" type="checkbox" @click="checkAll($event)">全选
  303. </label>
  304. <table class="table table-sm table-bordered d-none text-nowrap " id="headerRoll"></table>
  305. <table class="table table-sm table-striped d-none d-xl-block p-0 text-nowrap table-bordered"
  306. id="headerParent" ref="boxPc">
  307. <tr class="p-0" id="header"></tr>
  308. <tr v-for="(inventoryMission, i) in 显示记录列" :key="i"
  309. :style="{'opacity': inventoryMission.mark==='跳过'?'0.7':'','opacity': inventoryMission.mark==='确认差异'?'0.7':''}" :class="[
  310. inventoryMission.mark==='已复盘有差异'?'td-cool':'',
  311. inventoryMission.mark==='已复盘无差异'?'td-cool text-muted':'',
  312. inventoryMission.mark==='未复盘有差异'?'td-warm font-weight-bold':'',
  313. inventoryMission.mark==='确认差异'?'td-warm font-weight-bold':'',
  314. inventoryMission.mark==='无差异'?'text-muted':'',
  315. inventoryMission.mark==='未盘'?'td-yellow':'',
  316. inventoryMission.mark==='跳过'?'text-muted':'',
  317. ]">
  318. <td>
  319. <input type="checkbox" :value="inventoryMission" v-model="checkData">
  320. <span :id="'lockLine'+(i+1)"></span>
  321. </td>
  322. <td>@{{ i+1 }}</td>
  323. <td>@{{ inventoryMission.location }}</td>
  324. <td v-if="inventoryMission.commodity"><span
  325. v-if="inventoryMission.checked==='是'||inventoryMission.checked==='确认差异'||inventoryMission.checked==='跳过'||inventory.status==='复盘中'||listMode">@{{ inventoryMission.commodity.name }}</span>
  326. </td>
  327. <td>
  328. <span
  329. v-if="inventoryMission.checked==='是'||inventoryMission.checked==='确认差异'||inventoryMission.checked==='跳过'||inventory.status==='复盘中'||listMode">
  330. <span
  331. v-if="inventoryMission.commodity_barcodes && inventoryMission.commodity_barcodes.length>0">
  332. <span v-if="inventoryMission.commodity_barcodes.length==1">
  333. @{{ inventoryMission.commodity_barcodes[0].code }}
  334. </span>
  335. <span v-if="inventoryMission.commodity_barcodes.length>1">
  336. <small
  337. v-for="barcode in inventoryMission.commodity_barcodes">@{{ barcode.code }}<br></small>
  338. </span>
  339. </span>
  340. </span>
  341. </td>
  342. <td v-if="inventoryMission.commodity"><span
  343. v-if="inventoryMission.checked==='是'||inventoryMission.checked==='确认差异'||inventoryMission.checked==='跳过'||inventory.status==='复盘中'||listMode">@{{ inventoryMission.commodity.sku }}</span>
  344. </td>
  345. <td><span
  346. v-if="inventoryMission.checked==='是'||inventoryMission.checked==='确认差异'||inventoryMission.checked==='跳过'||inventory.status==='复盘中'||listMode">@{{ inventoryMission.produced_at }}</span>
  347. </td>
  348. <td><span
  349. v-if="inventoryMission.checked==='是'||inventoryMission.checked==='确认差异'||inventoryMission.checked==='跳过'||inventory.status==='复盘中'||listMode">@{{ inventoryMission.valid_at }}</span>
  350. </td>
  351. <td class="text-muted"><span
  352. v-if="inventoryMission.checked==='是'||inventoryMission.checked==='确认差异'||inventoryMission.checked==='跳过'||inventory.status==='复盘中'||listMode">@{{ inventoryMission.batch_number }}</span>
  353. </td>
  354. <td v-if="inventoryMission.stockInventoryPersons" class="text-muted"
  355. :rowspan="inventoryMission.is_multi_row?2:''">
  356. <span
  357. v-if="inventoryMission.checked==='是'||inventoryMission.checked==='确认差异'||inventoryMission.checked==='跳过'||inventory.status==='复盘中'||listMode">
  358. <a href="#" v-if="inventoryMission.stockInventoryPersons.length>0" class="dropdown-toggle"
  359. data-toggle="dropdown">
  360. @{{ inventoryMission.stockInventoryPersons[0].mark }}<b class="caret"></b>
  361. </a>
  362. <div
  363. style="position: absolute;width:320px;margin-left:-100px;background-color: white;max-height:150px ;overflow-y:auto"
  364. class="small mt-0 dropdown-menu">
  365. <table class="table table-sm table-striped table-bordered">
  366. <tr>
  367. <th>盘点人</th>
  368. <th>时间</th>
  369. </tr>
  370. <tr v-for="stockInventoryPerson in inventoryMission.stockInventoryPersons">
  371. <td>@{{ stockInventoryPerson.mark }}</td>
  372. <td>@{{ stockInventoryPerson.created_at }}</td>
  373. </tr>
  374. </table>
  375. </div>
  376. </span>
  377. </td>
  378. <td><span
  379. v-if="inventoryMission.checked==='是'||inventoryMission.checked==='确认差异'||inventoryMission.checked==='跳过'||inventory.status==='复盘中'||listMode">@{{ inventoryMission.erp_type_position }}</span>
  380. </td>
  381. <td><span
  382. v-if="inventoryMission.checked==='是'||inventoryMission.checked==='确认差异'||inventoryMission.checked==='跳过'||inventory.status==='复盘中'||listMode">
  383. <span v-if="listMode">@{{ inventoryMission.quality }}</span>
  384. <select v-else class="form-control-sm" name="quality" id="quality"
  385. v-model="inventoryMission.quality"
  386. @change="updateQuality(inventoryMission.id,inventoryMission.location,inventoryMission.commodity.sku,inventoryMission.quality,inventory.owner.code)">
  387. <option value="正品">正品</option>
  388. <option value="残次">残次</option>
  389. </select>
  390. </span>
  391. </td>
  392. <td><span
  393. v-if="inventoryMission.checked==='是'||inventoryMission.checked==='确认差异'||inventoryMission.checked==='跳过'||inventory.status==='复盘中'||listMode">@{{ inventoryMission.stored_amount }}</span>
  394. </td>
  395. <td><span
  396. v-if="inventoryMission.checked==='是'||inventoryMission.checked==='确认差异'||inventoryMission.checked==='跳过'||inventory.status==='复盘中'||listMode">@{{ inventoryMission.valid_amount }}</span>
  397. </td>
  398. <td><span
  399. v-if="inventoryMission.checked==='是'||inventoryMission.checked==='确认差异'||inventoryMission.checked==='跳过'||inventory.status==='复盘中'||listMode">@{{ inventoryMission.verified_amount }}
  400. <span v-if="inventoryMission.checked==='跳过'" class="badge badge-pill badge-secondary">跳过</span></span>
  401. </td>
  402. <td><span
  403. v-if="inventoryMission.checked==='是'||inventoryMission.checked==='确认差异'||inventoryMission.checked==='跳过'||inventory.status==='复盘中'||listMode">@{{ inventoryMission.re_checked_amount }}</span>
  404. </td>
  405. <td><span
  406. v-if="inventoryMission.checked==='是'||inventoryMission.checked==='确认差异'||inventoryMission.checked==='跳过'||inventory.status==='复盘中'||listMode">@{{ inventoryMission.difference_amount }}</span>
  407. </td>
  408. <td><span
  409. v-if="inventoryMission.checked==='是'||inventoryMission.checked==='确认差异'||inventoryMission.checked==='跳过'||inventory.status==='复盘中'||listMode">@{{ inventoryMission.occupied_amount }}</span>
  410. </td>
  411. @can('库存管理-盘点')
  412. <td>
  413. {{-- <span class="btn btn-sm btn-outline-danger" @click="删除盘点记录(inventoryMission.id,inventory.id,inventoryMission.commodity.name)">删除</span>--}}
  414. <span class="btn btn-sm btn-outline-secondary" v-if="inventoryMission.checked==='否'"
  415. @click="跳过盘点记录(inventoryMission.id,inventory.id,inventoryMission.commodity.name)">跳过</span>
  416. <span class="btn btn-sm btn-outline-secondary" v-if="inventoryMission.mark==='已复盘有差异'||inventoryMission.mark==='未复盘有差异'"
  417. @click="确认盘点差异(inventoryMission.id,inventory.id,inventoryMission.commodity.name)">跳过</span>
  418. <span class="btn btn-sm btn-outline-secondary"
  419. v-if="inventory.type=='动盘'&& inventoryMission.mark=='未盘' &&!listMode"
  420. @click="选中盘点起始位置(inventoryMission.id,inventoryMission.location)">以此为起点</span>
  421. </td>
  422. @endcan
  423. </tr>
  424. </table>
  425. </div>
  426. <!--盘点记录移动端-->
  427. <table id="listOnPad" class="table table-striped table-sm table-bordered table-hover p-0 d-table d-xl-none"
  428. style="background: rgb(255, 255, 255);" ref="box">
  429. <tbody>
  430. <tr {{--v-for="(inventoryMission,i) in 显示记录列"--}} v-for="(inventoryMission, i) in 显示记录列" :key="i"
  431. :style="{'opacity': inventoryMission.mark==='跳过'?'0.7':'','opacity': inventoryMission.mark==='确认差异'?'0.7':''}"
  432. :class="[
  433. inventoryMission.mark==='已复盘有差异'?'td-cool':'',
  434. inventoryMission.mark==='已复盘无差异'?'td-cool text-muted':'',
  435. inventoryMission.mark==='未复盘有差异'?'td-warm font-weight-bold':'',
  436. inventoryMission.mark==='确认差异'?'td-warm font-weight-bold':'',
  437. inventoryMission.mark==='无差异'?'text-muted':'',
  438. inventoryMission.mark==='未盘'?'td-yellow':'',
  439. inventoryMission.mark==='跳过'?'text-muted':'',
  440. ]">
  441. <td style="filter:grayscale(30%); ">
  442. <span :id="'lockLinePhone'+(i+1)"></span>
  443. <div class="mt-3">
  444. <div style="transform:scale(0.9)" class="pl-0">
  445. <span type="hidden">@{{ i+1 }}</span>
  446. <span class="mr-3 text-nowrap"><span class="font-weight-bold">库位:</span><span
  447. style="color:#af7651">
  448. @{{ inventoryMission.location }}</span></span>
  449. <span class="mr-3 text-nowrap"
  450. v-if="inventoryMission.checked==='是'||inventoryMission.checked==='确认差异'||inventoryMission.checked==='跳过'||inventory.status==='复盘中'||listMode"><span
  451. class="font-weight-bold">产品名称:</span><span style="color:#af7651"
  452. v-if="inventoryMission.commodity">
  453. @{{ inventoryMission.commodity.name }}</span></span>
  454. <span class="mr-3 text-nowrap"
  455. v-if="inventoryMission.checked==='是'||inventoryMission.checked==='确认差异'||inventoryMission.checked==='跳过'||inventory.status==='复盘中'||listMode">
  456. <span class="font-weight-bold">质量状态:</span>
  457. <span v-if="listMode">@{{ inventoryMission.quality }}</span>
  458. <select v-else class="form-control-sm" name="quality" id="quality"
  459. v-model="inventoryMission.quality"
  460. @change="updateQuality(inventoryMission.id,inventoryMission.location,inventoryMission.commodity.sku,inventoryMission.quality,inventory.owner.code)">
  461. <option value="正品">正品</option>
  462. <option value="残次">残次</option>
  463. </select>
  464. </span>
  465. <span class="mr-3 text-nowrap"
  466. v-if="inventoryMission.checked==='是'||inventoryMission.checked==='确认差异'||inventoryMission.checked==='跳过'||inventory.status==='复盘中'||listMode">
  467. <span class="font-weight-bold">产品条码:</span>
  468. <span
  469. v-if="inventoryMission.checked==='是'||inventoryMission.checked==='确认差异'||inventoryMission.checked==='跳过'||inventory.status==='复盘中'||listMode">
  470. <span
  471. v-if="inventoryMission.commodity_barcodes && inventoryMission.commodity_barcodes.length>0">
  472. <span v-if="inventoryMission.commodity_barcodes.length==1">
  473. @{{ inventoryMission.commodity_barcodes[0].code }}
  474. </span>
  475. <span v-if="inventoryMission.commodity_barcodes.length>1">
  476. <small
  477. v-for="barcode in inventoryMission.commodity_barcodes">@{{ barcode.code }}<br></small>
  478. </span>
  479. </span>
  480. </span>
  481. </span>
  482. <div v-if="inventory.status==='复盘中'">
  483. <span class="mr-3 text-nowrap"><span style="color:#783000" class="font-weight-bold">盘点数量:</span><span
  484. style="color:#af7651">
  485. @{{ inventoryMission.verified_amount }}</span></span>
  486. <span class="mr-3 text-nowrap"><span style="color:#783000" class="font-weight-bold">复盘数量:</span><span
  487. style="color:#af7651">
  488. @{{ inventoryMission.re_checked_amount }}</span></span>
  489. <span class="mr-3 text-nowrap"><span style="color:#783000" class="font-weight-bold">盘点差异:</span><span>
  490. @{{ inventoryMission.difference_amount }}</span></span>
  491. </div>
  492. @can('库存管理-盘点')
  493. <div>
  494. <span class="mr-3 text-nowrap" v-if="!listMode"><span
  495. class="font-weight-bold">操作:</span>
  496. {{-- <span class="btn btn-sm btn-outline-danger" @click="删除盘点记录(inventoryMission.id,inventory.id,inventoryMission.commodity.name)">删除</span>--}}
  497. <span class="btn btn-sm btn-outline-secondary" v-if="inventoryMission.checked==='否'"
  498. @click="跳过盘点记录(inventoryMission.id,inventory.id,inventoryMission.commodity.name)">跳过</span>
  499. <span class="btn btn-sm btn-outline-secondary" v-if="inventoryMission.mark==='已复盘有差异'||inventoryMission.mark==='未复盘有差异'"
  500. @click="确认盘点差异(inventoryMission.id,inventory.id,inventoryMission.commodity.name)">跳过</span>
  501. <span class="btn btn-sm btn-outline-secondary"
  502. v-if="inventory.type=='动盘'&& inventoryMission.mark=='未盘' &&!listMode"
  503. @click="选中盘点起始位置(inventoryMission.id,inventoryMission.location)">以此为起点</span>
  504. </span>
  505. </div>
  506. @endcan
  507. </div>
  508. </div>
  509. </td>
  510. </tr>
  511. </tbody>
  512. </table>
  513. <!--上次盘点记录-->
  514. <div class="modal" id="lastStockInventoryRecord" tabindex="-1" role="dialog">
  515. <div class="modal-dialog modal-xl">
  516. <div class="modal-content">
  517. <div class="modal-header">
  518. <h5 class="modal-title font-weight-bold">该盘点记录已存在,是否覆盖之前记录?</h5>
  519. <button type="button" class="close" data-dismiss="modal" aria-label="Close">
  520. <span aria-hidden="true">&times;</span>
  521. </button>
  522. </div>
  523. <div class="modal-body">
  524. <table class="table table-sm table-striped table-bordered">
  525. <tr class="text-muted text-center">
  526. <th>库位</th>
  527. <th>产品条码</th>
  528. <th>盘点人</th>
  529. <th>盘点数量</th>
  530. <th>产品名</th>
  531. <th>产品编号</th>
  532. <th>属性仓</th>
  533. <th>质量状态</th>
  534. <th>库存数量</th>
  535. <th>盘点差异</th>
  536. <th>时间</th>
  537. </tr>
  538. <tr class="text-center ">
  539. <td>@{{ lastStockInventoryRecord.location }}</td>
  540. <td><span v-if="lastStockInventoryRecord.commodity">@{{ lastStockInventoryRecord.commodity.barcode }}</span></td>
  541. <td><span v-if="stockInventoryPersons.length>0">@{{ stockInventoryPersons[stockInventoryPersons.length-1].mark }}</span></td>
  542. <td>@{{ lastStockInventoryRecord.verified_amount }}</td>
  543. <td><span v-if="lastStockInventoryRecord.commodity">@{{ lastStockInventoryRecord.commodity_name }}</span></td>
  544. <td><span v-if="lastStockInventoryRecord.commodity">@{{ lastStockInventoryRecord.commodity.sku }}</span>
  545. </td>
  546. <td>@{{ lastStockInventoryRecord.erp_type_position }}</td>
  547. <td>@{{ lastStockInventoryRecord.quality }}</td>
  548. <td>@{{ lastStockInventoryRecord.stored_amount }}</td>
  549. <td>@{{ lastStockInventoryRecord.difference_amount }}</td>
  550. <td><span v-if="stockInventoryPersons.length>0">@{{ stockInventoryPersons[stockInventoryPersons.length-1].created_at }}</span>
  551. </td>
  552. </tr>
  553. </table>
  554. </div>
  555. <div class="modal-footer">
  556. <button type="button" class="close" data-dismiss="modal" aria-label="Close">
  557. <span aria-hidden="true" class="btn btn-outline-secondary" @click="不覆盖()">否</span>
  558. </button>
  559. <button type="button" class="btn btn-primary" data-dismiss="modal" @click="覆盖()">是</button>
  560. </div>
  561. </div>
  562. </div>
  563. </div>
  564. </div>
  565. @endsection
  566. @section('lastScript')
  567. <script type="text/javascript" src="{{mix('js/queryForm/export.js')}}"></script>
  568. <script type="text/javascript" src="{{mix('js/queryForm/header.js')}}"></script>
  569. <script>
  570. let hideHeaderTitle = function () {
  571. let $listOnPad = $('#listOnPad');
  572. let $headerRoll = $('#headerRoll');
  573. if ($listOnPad.css('display') !== 'none') {
  574. $headerRoll.attr('hidden', true)
  575. } else {
  576. $headerRoll.attr('hidden', false)
  577. $headerRoll.find('tr').css('width', $(document).width());
  578. }
  579. };
  580. window.onresize = hideHeaderTitle;
  581. window.onscroll = hideHeaderTitle;
  582. let $showBlueTable=null;
  583. let $barcodeInput=null;
  584. let $locationInput=null;
  585. let $amountInput=null;
  586. let $prototype_ = null;
  587. let $blueTable = null;
  588. let $prototypePc_ = null;
  589. let $blueTablePc = null;
  590. let inputs={location:'',barcode:'',amount:'',produced_at:'',valid_at:'',batch_number:''};//双向绑定在本页太慢,所以用外部变量
  591. let $appointInventoryList=[];
  592. let $jqueryTable=[];
  593. function producedAtChange(e){
  594. inputs.produced_at = e.target.value;
  595. }
  596. function validAtChange(e){
  597. inputs.valid_at = e.target.value;
  598. }
  599. function batchNumberChange(e){
  600. inputs.batch_number = e.target.value;
  601. }
  602. let listVue = new Vue({
  603. el: "#list",
  604. data: {
  605. selectingId:'',
  606. dataExtraStatus:{addingNew:false, displayingLastCounting:false,showBlueTable:false},
  607. inventory:{!! $inventoryAccount!!},
  608. inventoryMissions : [
  609. @foreach($inventoryAccountMissions as $inventoryMission)
  610. {
  611. id: '{{$inventoryMission->id}}',
  612. location: '{{$inventoryMission->location}}',
  613. created_at: '{{$inventoryMission->created_at}}',
  614. commodity_name: '{{$inventoryMission->commodity ? $inventoryMission->commodity->name : ''}}',
  615. commodity_sku: '{{$inventoryMission->commodity ? $inventoryMission->commodity->sku : ''}}',
  616. commodity_barcode: '{{$inventoryMission->commodity ? $inventoryMission->commodity->barcode : ''}}',
  617. commodity:{!! $inventoryMission->commodity !!},
  618. stockInventoryPersons:{!! $inventoryMission->stockInventoryPersons !!},
  619. commodity_barcodes: [
  620. @foreach($inventoryMission->commodity ? $inventoryMission->commodity->barcodes ?? [] : [] as $barcode)
  621. {code: '{{$barcode->code}}'},
  622. @endforeach
  623. ],
  624. stock_persons: [
  625. @foreach($inventoryMission->stockInventoryPersons ? $inventoryMission->stockInventoryPersons ?? [] : [] as $person)
  626. {name: '{{$person->mark}}'},
  627. @endforeach
  628. ],
  629. produced_at: '{{$inventoryMission->produced_at}}',
  630. valid_at: '{{$inventoryMission->valid_at}}',
  631. verified_amount: '{{$inventoryMission->verified_amount}}',
  632. stored_amount: '{{$inventoryMission->stored_amount}}',
  633. valid_amount: '{{$inventoryMission->valid_amount}}',
  634. stored_at: '{{$inventoryMission->stored_at}}',
  635. batch_number: '{{$inventoryMission->batch_number}}',
  636. erp_type_position: '{{$inventoryMission->erp_type_position}}',
  637. quality: '{{$inventoryMission->quality}}',
  638. difference_amount: '{{$inventoryMission->difference_amount}}',
  639. occupied_amount: '{{$inventoryMission->occupied_amount}}',
  640. checked: '{{$inventoryMission->checked}}',
  641. returned: '{{$inventoryMission->returned}}',
  642. re_checked_amount: '{{$inventoryMission->re_checked_amount}}'
  643. },
  644. @endforeach
  645. ],
  646. 库位盘点记录:[],
  647. 条码索引_记录: {},
  648. 库位索引_记录: {},
  649. checkData: [],
  650. selectedStyle:'',
  651. 指定盘点记录列:[],
  652. lastStockInventoryRecord:{},
  653. stockInventoryPersons:[],
  654. inventoryAccountMissions:[],
  655. listMode:false,
  656. blindReceive:false,
  657. addInventoryMission:false,
  658. 分割位置id:null,
  659. 显示记录列:[],
  660. focusing:'document',
  661. commitButtonVisible:false,
  662. isManualInputtingBarcode:false,
  663. isManualInputtingAmount:true,
  664. lastScannedBarcode:'',
  665. inputMode:'regular',//regular,increasing,multiIncreasing
  666. location:'',
  667. inputting:{
  668. barcode:'',amount:'',bin:'',produce_date:'',valid_date:'',batch_number:'',fromIncreasing:false
  669. },
  670. status:{
  671. scanEndInputted:false,binDisable:false,barcodeDisable:true,amountDisable:false,
  672. },
  673. goodses:[],//{barcode,amount,bin,produce_date,valid_date,batch_number}
  674. },
  675. beforeMount: function () {
  676. this.重排序并标记全列表类型();
  677. this.加载下方数据并置空上方数据()//初始化先调用一次
  678. },
  679. watch: {
  680. checkData: {
  681. handler() {
  682. if (this.checkData.length === this.inventoryMissions.length) {
  683. document.querySelector('#all').checked = true;
  684. document.querySelector('#all_temp').checked = true;
  685. } else {
  686. document.querySelector('#all').checked = false;
  687. document.querySelector('#all_temp').checked = false;
  688. }
  689. },
  690. deep: true
  691. }
  692. },
  693. destroyed() {
  694. window.removeEventListener('scroll', this.lazy)
  695. },
  696. updated: function () {
  697. $barcodeInput=$('#barcodeInput');
  698. $locationInput=$('#locationInput');
  699. $amountInput=$('#amountInput');
  700. },
  701. mounted: function () {
  702. let _this = this;
  703. _this.lazy();
  704. window.addEventListener('scroll', this.lazy);
  705. (function 显示渲染后页面(){
  706. $('#loadingPage').remove();
  707. $('#list').removeClass('d-none');
  708. })()
  709. $(".tooltipTarget").tooltip({'trigger': 'hover'});
  710. $barcodeInput=$('#barcodeInput');
  711. $locationInput=$('#locationInput');
  712. $amountInput=$('#amountInput');
  713. $showBlueTable=$('.showBlueTable');
  714. $prototype_ = $('#blueTr');
  715. $blueTable = $('#blueTable');
  716. $prototypePc_ = $('#blueTrPc');
  717. $blueTablePc = $('#blueTablePc');
  718. this.放置焦点光标至正确位置();
  719. (function 初始化列表模式() {
  720. let listMode = getGetVal('listMode')
  721. if (listMode === 'true') {
  722. _this.listMode = true;
  723. return;
  724. }
  725. _this.listMode = false;
  726. })();
  727. let column = [
  728. {name:'cloneCheckAll',customization:true,type:'checkAll',column:'id',
  729. dom:$('#cloneCheckAll').removeClass('d-none'), neglect: true},
  730. {name:'index',value: '序号', neglect: true},
  731. {name:'location',value: '库位'},
  732. {name: 'commodity_name', value: '产品名'},
  733. {name: 'commodity_barcode', value: '产品条码'},
  734. {name:'commodity_sku',value: '产品编码'},
  735. {name: 'produced_at', value: '生产日期', neglect: true},
  736. {name: 'valid_at', value: '失效日期', neglect: true},
  737. {name: 'batch_number', value: '批号', neglect: true},
  738. {name: 'stockInventoryPersons',value: '盘点人', neglect: true},
  739. {name: 'erp_type_position', value: 'ERP属性仓', neglect: true},
  740. {name: 'quality', value: '质量状态', neglect: true},
  741. {name: 'stored_amount', value: '库存数量', neglect: true},
  742. {name: 'valid_amount', value: '可用数量', neglect: true},
  743. {name: 'verified_amount', value: '盘点数量', neglect: true},
  744. {name: 're_checked_amount', value: '复盘数量', neglect: true},
  745. {name: 'difference_amount', value: '复盘差异', neglect: true},
  746. {name: 'occupied_amount', value: '分配数量', neglect: true},
  747. {name: '跳过', value: '操作', neglect: true},
  748. ];
  749. setTimeout(function () {
  750. let _this=this;
  751. let header = new Header({
  752. el: "#header",
  753. column: column,
  754. data: _this.inventoryMissions,
  755. restorationColumn: 'id',
  756. fixedTop:($('#form').height())+2,
  757. vue:listVue,
  758. });
  759. header.init();
  760. },0);
  761. _this.建立记录索引();
  762. },
  763. methods:{
  764. lazy(){
  765. let _this=this;
  766. let scrollTop = document.documentElement.scrollTop || document.body.scrollTop;//滚动条距离顶部的高度
  767. let scrollHeight = $(document).height();//当前页面的总高度
  768. let clientHeight=window.innerHeight;//当前可视的页面高度
  769. let count = parseFloat(clientHeight) + parseFloat(scrollTop);//浏览器底部位置
  770. if (scrollHeight - count < 40) {
  771. if (_this.显示记录列.length < _this.inventoryMissions.length) {
  772. _this.加载下方数据并置空上方数据()
  773. }
  774. }
  775. },
  776. 加载下方数据并置空上方数据(){
  777. let _this=this;
  778. const count = _this.显示记录列.length;
  779. if (count > 30) {
  780. _this.inventoryMissions.map((inventoryMission, index) => {
  781. if (_this.显示记录列.length < 5 + count) {
  782. if (_this.显示记录列.length < _this.inventoryMissions.length) {
  783. _this.显示记录列.push(_this.inventoryMissions[_this.显示记录列.length]);
  784. }
  785. }
  786. })
  787. } else {
  788. _this.inventoryMissions.map((inventoryMission, index) => {
  789. if (_this.显示记录列.length < 25 + count) {
  790. if (_this.显示记录列.length < _this.inventoryMissions.length) {
  791. _this.显示记录列.push(_this.inventoryMissions[_this.显示记录列.length])
  792. }
  793. }
  794. })
  795. }
  796. },
  797. cloneBlueTrDom($appointInventoryList) {
  798. for(let i =0;i<$appointInventoryList.length;i++){
  799. let newDom= $prototype_.clone();
  800. newDom.find('.location').text($appointInventoryList[i].location);
  801. newDom.find('.commodity_name').text($appointInventoryList[i].commodity_name);
  802. newDom.find('.commodity_barcode').text($appointInventoryList[i].commodity_barcode);
  803. newDom.find('.commodity_sku').text($appointInventoryList[i].commodity_sku);
  804. newDom.find('.produced_at').val($appointInventoryList[i].produced_at.substr(0,10));
  805. newDom.find('.valid_at').val($appointInventoryList[i].valid_at.substr(0,10));
  806. newDom.find('.batch_number').val($appointInventoryList[i].batch_number);
  807. newDom.find('.erp_type_position').text($appointInventoryList[i].erp_type_position);
  808. newDom.find('.quality').text($appointInventoryList[i].quality);
  809. newDom.find('.verified_amount').text($appointInventoryList[i].verified_amount);
  810. newDom.find('.re_checked_amount').text($appointInventoryList[i].re_checked_amount);
  811. newDom.find('.difference_amount').text($appointInventoryList[i].difference_amount);
  812. newDom.show();
  813. newDom.find('.blueAmount').attr('data_id', $appointInventoryList[i].id);
  814. newDom.find('.blueAmount').attr('stored_amount', $appointInventoryList[i].stored_amount);
  815. newDom.find('.stockButton').attr('data_id', $appointInventoryList[i].id);
  816. newDom.addClass('blueTr'+i);
  817. newDom.appendTo($blueTable);
  818. $jqueryTable.push(newDom);
  819. }
  820. $prototype_.hide();
  821. },
  822. cloneBlueTrPcDom($appointInventoryList) {
  823. for(let i =0;i<$appointInventoryList.length;i++){
  824. let newDom= $prototypePc_.clone();
  825. newDom.find('.location').text($appointInventoryList[i].location);
  826. newDom.find('.commodity_name').text($appointInventoryList[i].commodity_name);
  827. newDom.find('.commodity_barcode').text($appointInventoryList[i].commodity_barcode);
  828. newDom.find('.commodity_sku').text($appointInventoryList[i].commodity_sku);
  829. newDom.find('.produced_at').val($appointInventoryList[i].produced_at.substr(0,10));
  830. newDom.find('.valid_at').val($appointInventoryList[i].valid_at.substr(0,10));
  831. newDom.find('.batch_number').val($appointInventoryList[i].batch_number);
  832. newDom.find('.erp_type_position').text($appointInventoryList[i].erp_type_position);
  833. newDom.find('.quality').text($appointInventoryList[i].quality);
  834. newDom.find('.verified_amount').text($appointInventoryList[i].verified_amount);
  835. newDom.find('.re_checked_amount').text($appointInventoryList[i].re_checked_amount);
  836. newDom.find('.difference_amount').text($appointInventoryList[i].difference_amount);
  837. newDom.show();
  838. newDom.find('.blueAmountPc').attr('data_id', $appointInventoryList[i].id);
  839. newDom.find('.blueAmountPc').attr('stored_amount', $appointInventoryList[i].stored_amount);
  840. newDom.find('.stockButtonPc').attr('data_id', $appointInventoryList[i].id);
  841. newDom.addClass('blueTrPc'+i);
  842. newDom.appendTo($blueTablePc);
  843. $jqueryTable.push(newDom);
  844. }
  845. $prototypePc_.hide();
  846. },
  847. inputs() {
  848. return inputs;
  849. },
  850. checkAll(e) {
  851. if (e.target.checked) {
  852. this.inventoryMissions.forEach((el,i)=>{
  853. if (this.checkData.indexOf(el) == '-1'){
  854. this.checkData.push(el);
  855. }
  856. });
  857. } else {
  858. this.checkData = [];
  859. }
  860. },
  861. barcodePress(e){
  862. if(e.key==='Enter') {
  863. this.barcodeChange(e);
  864. }
  865. },
  866. barcodeChange(e){
  867. this.inputs().barcode = e.target.value;
  868. this.提交部分输入();
  869. },
  870. amountPress(e){
  871. if(e.key==='Enter'){
  872. this.提交新增(e);
  873. }
  874. },
  875. locationPress(e){
  876. if(e.key==='Enter'){
  877. this.locationChange(e);
  878. }
  879. },
  880. locationChange(e){
  881. this.inputs().location = e.target.value;
  882. this.提交部分输入();
  883. if(!this.addInventoryMission){
  884. this.location=this.inputs().location ;
  885. }
  886. },
  887. 提交部分输入:_.throttle(function(){
  888. let _this = this;
  889. this.放置焦点光标至正确位置();
  890. _this.显示盘点计数input_按情况();
  891. (new Promise(function (resolve, reject) {
  892. resolve()
  893. })).then(function () {
  894. if(_this.addInventoryMission){
  895. _this.提交库位和条码();
  896. }else{
  897. _this.提交库位();
  898. }
  899. _this.显示盘点计数input_按情况();
  900. })
  901. },100,{trailing:false}),
  902. 提交新增:_.throttle(function(e){
  903. this.inputs().amount=e.target.value;
  904. this.提交新增并盘点();
  905. },100,{trailing:false}),
  906. selectingRow(e){
  907. let _this=this;
  908. let id = $(e.target).attr('data_id');
  909. _this.selectingId=id;
  910. if(e.key==='Enter'){
  911. _this.提交盘点();
  912. }
  913. },
  914. 提交库位和条码:_.throttle(async function(){
  915. let _this=this;
  916. this.清空指定盘点记录列();
  917. if (!_this.inputs().barcode) return;
  918. if(!(await this.is条码存在于WMS(_this.inputs().barcode))){
  919. tempTip.setDuration(2000);
  920. tempTip.show('输入的商品条码没有对应的商品!');
  921. }
  922. this.筛选出记录(_this.inputs().location,_this.inputs().barcode);
  923. },100,{ 'trailing': false }),
  924. 提交库位:_.throttle(async function(){
  925. let _this=this;
  926. this.清空指定盘点记录列();
  927. this.筛选库位出记录(_this.inputs().location);
  928. },100,{ 'trailing': false }),
  929. 建立记录索引(){
  930. let _this=this;
  931. _this.inventoryMissions.forEach(function (inventoryMission) {
  932. inventoryMission.commodity_barcodes.forEach(function (barcode) {
  933. if(!Array.isArray(_this.条码索引_记录[barcode.code])) _this.条码索引_记录[barcode.code]=[];
  934. _this.条码索引_记录[barcode.code].push(inventoryMission);
  935. })
  936. if(!Array.isArray(_this.库位索引_记录[inventoryMission.location])) _this.库位索引_记录[inventoryMission.location]=[];
  937. _this.库位索引_记录[inventoryMission.location].push(inventoryMission);
  938. });
  939. },
  940. 清空指定盘点记录列(){
  941. let _this=this;
  942. $jqueryTable.forEach(function (newDom,i) {
  943. newDom.remove();
  944. })
  945. // $appointInventoryList.forEach(function (inventoryMission,i) {
  946. // $appointInventoryList.splice(i,1);
  947. // });
  948. $appointInventoryList=[];
  949. $showBlueTable.attr('class','d-none');
  950. _this.selectingId='';
  951. _this.location='';
  952. _this.库位盘点记录=[];
  953. },
  954. 显示盘点计数input_按情况(){
  955. let _this=this;
  956. setTimeout(function(){
  957. if($appointInventoryList.length>0){
  958. _this.dataExtraStatus.addingNew=false;
  959. }else{
  960. _this.dataExtraStatus.addingNew=true;
  961. }
  962. },10)
  963. },
  964. async 筛选出记录(库位, 条码){
  965. 条码=条码.trim();
  966. 库位=库位.trim();
  967. let _this=this;
  968. if(!库位)return false;
  969. if(!条码)return false;;
  970. if (!_this.库位索引_记录[库位]
  971. ||(!_this.条码索引_记录[条码]
  972. &&!(await _this.is条码存在于WMS(条码)))
  973. ) return;
  974. if(Array.isArray(_this.条码索引_记录[条码])){
  975. _this.条码索引_记录[条码].forEach(function(inventoryMission){
  976. if (inventoryMission.location===库位){
  977. $appointInventoryList.push(inventoryMission);
  978. $appointInventoryList=_this.unique($appointInventoryList);
  979. }
  980. });
  981. $showBlueTable.removeClass('d-none');
  982. _this.cloneBlueTrDom($appointInventoryList);
  983. _this.cloneBlueTrPcDom($appointInventoryList);
  984. }
  985. },
  986. async 筛选库位出记录(库位){
  987. 库位=库位.trim();
  988. let _this=this;
  989. if(!库位)return false;
  990. if (!_this.库位索引_记录[库位]) return;
  991. if(Array.isArray(_this.库位索引_记录[库位])){
  992. _this.库位索引_记录[库位].forEach(function(inventoryMission){
  993. if (inventoryMission.location===库位){
  994. $appointInventoryList.push(inventoryMission);
  995. $appointInventoryList=_this.unique($appointInventoryList);
  996. }
  997. });
  998. $showBlueTable.removeClass('d-none');
  999. _this.cloneBlueTrDom($appointInventoryList);
  1000. _this.cloneBlueTrPcDom($appointInventoryList);
  1001. }
  1002. },
  1003. unique(arr){
  1004. return Array.from(new Set(arr));
  1005. },
  1006. 放置焦点光标至正确位置:_.throttle(function(){
  1007. let _this=this;
  1008. _this.显示盘点计数input_按情况();
  1009. if (!$locationInput.val().trim()){
  1010. $locationInput.focus();
  1011. return;
  1012. }
  1013. if (_this.addInventoryMission){
  1014. if (!$barcodeInput.val().trim()){
  1015. $barcodeInput.focus();
  1016. return;
  1017. }
  1018. }
  1019. setTimeout(function(){
  1020. if(_this.dataExtraStatus.addingNew){
  1021. let $count = $('#amountInput');
  1022. if (!$count.val().trim()){
  1023. $count.focus();
  1024. return;
  1025. }
  1026. }
  1027. if ($appointInventoryList.length >0) {
  1028. $blueTablePc.find('.blueTrPc0 input').first().focus();
  1029. $blueTable.find('.blueTr0 input').first().focus();
  1030. }
  1031. },10)
  1032. },100,{ 'trailing': false }),
  1033. async is条码存在于WMS(条码){
  1034. 条码=条码.trim();
  1035. let _this=this;
  1036. if (!条码) return false;
  1037. if (_this.条码索引_记录[条码]) return true;
  1038. if (_this.条码索引_记录[条码] === false) return false;
  1039. let url = '{{url('inventory/stockInventory/searchCommodityByBarcode')}}';
  1040. let is成功 = false;
  1041. await axios.post(url, {
  1042. barcode: 条码,
  1043. owner_code: _this.inventory.owner.code
  1044. }).then(function (response) {
  1045. if (response.data.success) {
  1046. is成功 = true;
  1047. _this.条码索引_记录[条码] = {barcodeExsitingAtWMS: true};
  1048. } else {
  1049. _this.条码索引_记录[条码] = false;
  1050. }
  1051. }).catch(function (err) {
  1052. tempTip.setDuration(2000);
  1053. tempTip.show('网络错误' + err);
  1054. });
  1055. return is成功;
  1056. },
  1057. is条码存在于当前记录(条码) {
  1058. 条码 = 条码.trim();
  1059. let _this = this;
  1060. if (!条码) return false;
  1061. return !!_this.条码索引_记录[条码];
  1062. },
  1063. is库位存在于当前记录(库位) {
  1064. 库位 = 库位.trim();
  1065. let _this = this;
  1066. if (!库位) return false;
  1067. return !!_this.库位索引_记录[库位];
  1068. },
  1069. 提交新增并盘点:async function(){
  1070. let _this=this;
  1071. let inventoryId=_this.inventory.id;
  1072. if(!_this.inputs().location.trim()|| !_this.inputs().barcode.trim() || !_this.inputs().amount.trim())return false;
  1073. let 条码存在于当前记录 = _this.is条码存在于当前记录(_this.inputs().barcode);
  1074. let 条码存在于WMS = await _this.is条码存在于WMS(_this.inputs().barcode);
  1075. let 库位存在于当前记录 = _this.is库位存在于当前记录(_this.inputs().location);
  1076. if(!条码存在于当前记录 && !条码存在于WMS)return false;
  1077. if(库位存在于当前记录 && 条码存在于当前记录)return false;
  1078. if(!confirm('该'+_this.inputs().barcode+'条码和'+_this.inputs().location+'库位相加的条件于WAS系统盘点记录中不存在! 是否确定需要添加至系统盘点记录中?')){return false};
  1079. let 新增字段标记='';
  1080. if(!库位存在于当前记录&&!条码存在于当前记录)新增字段标记='库位和商品新增';
  1081. if(!库位存在于当前记录)新增字段标记='库位新增';
  1082. if(!条码存在于当前记录)新增字段标记='商品新增';
  1083. _this.增加系统之外的盘点记录(_this.inputs().location,_this.inputs().barcode,_this.inputs().amount,inventoryId,_this.inventory.owner.code,新增字段标记);
  1084. return true;
  1085. },
  1086. 提交盘点:_.throttle(function(){
  1087. let _this=this;
  1088. let 条码=_this.inputs().barcode.trim();
  1089. let 库位=_this.inputs().location.trim();
  1090. let 盘点数=_this.inputs().amount.trim();
  1091. let 选定盘点记录id=_this.selectingId;
  1092. $appointInventoryList.forEach(function (inventoryMission) {
  1093. if (inventoryMission.location === 库位) {
  1094. if (inventoryMission.stockInventoryPersons.length > 0 && inventoryMission.id === _this.selectingId) {
  1095. _this.lastStockInventoryRecord = inventoryMission;
  1096. _this.stockInventoryPersons = inventoryMission.stockInventoryPersons;
  1097. if (_this.inventory.status !== '复盘中'){
  1098. $("#lastStockInventoryRecord").modal('show');
  1099. return;
  1100. }
  1101. }
  1102. _this.盘点(选定盘点记录id,库位,条码,_this.inventory.id,盘点数);
  1103. _this.清空指定盘点记录列();
  1104. }
  1105. });
  1106. },100,{ 'trailing': false }),
  1107. //结束初盘任务
  1108. stockInventoryEnd(id) {
  1109. let _this = this;
  1110. let url = '{{url('inventory/stockInventoryEnd')}}';
  1111. if (!confirm('确定要结束初盘任务,进入复盘吗?')) {return;}
  1112. axios.post(url, {id: id}).then(function (response) {
  1113. if (!response.data.success) {
  1114. tempTip.setDuration(2000);
  1115. tempTip.show('结束初盘失败!' + ' ' + response.data.data);
  1116. } else {
  1117. _this.inventory.status = response.data.data;
  1118. tempTip.setDuration(2000);
  1119. tempTip.showSuccess('结束初盘,进入复盘!');
  1120. }
  1121. }).catch(function (err) {
  1122. tempTip.setDuration(2000);
  1123. tempTip.show('结束初盘失败!' + '网络错误' + err);
  1124. })
  1125. },
  1126. updateQuality(id, location, sku, quality, ownerCode) {
  1127. let url = '{{url('inventory/修改质量状态')}}';
  1128. axios.post(url, {
  1129. id: id,
  1130. location: location,
  1131. sku: sku,
  1132. quality: quality,
  1133. ownerCode: ownerCode
  1134. }).then(function (response) {
  1135. if (!response.data.success) {
  1136. tempTip.setDuration(3000);
  1137. tempTip.show('修改质量状态失败!' + ' ' + response.data.data);
  1138. } else {
  1139. tempTip.setDuration(2000);
  1140. tempTip.showSuccess('修改质量状态成功!');
  1141. }
  1142. }).catch(function (err) {
  1143. tempTip.setDuration(2000);
  1144. tempTip.show('修改质量状态失败!' + '网络错误' + err);
  1145. })
  1146. },
  1147. 重排序并标记全列表类型() {
  1148. let _this = this;
  1149. _this.已复盘有差异列 = [];
  1150. _this.未复盘有差异列 = [];
  1151. _this.已复盘无差异列 = [];
  1152. _this.确认差异列=[];
  1153. _this.无差异列 = [];
  1154. _this.未盘列 = [];
  1155. _this.跳过列 = [];
  1156. _this.未盘列总 = [];
  1157. _this.未盘列1 = [];
  1158. _this.未盘列2 = [];
  1159. _this.inventoryMissions.forEach(function (mission, i) {
  1160. switch (mission.checked) {
  1161. case '已复核':
  1162. if (parseInt(mission.difference_amount)) {
  1163. _this.已复盘有差异列.push(mission);
  1164. mission.mark = '已复盘有差异';
  1165. return;
  1166. }
  1167. _this.已复盘无差异列.push(mission);
  1168. mission.mark = '已复盘无差异';
  1169. return;
  1170. case '是':
  1171. if (parseInt(mission.difference_amount)) {
  1172. _this.未复盘有差异列.push(mission);
  1173. mission.mark = '未复盘有差异';
  1174. return;
  1175. }
  1176. _this.无差异列.push(mission);
  1177. mission.mark = '无差异';
  1178. return;
  1179. case '确认差异':
  1180. _this.确认差异列.push(mission);
  1181. mission.mark = '确认差异';
  1182. return;
  1183. case '否':
  1184. _this.未盘列.push(mission);
  1185. mission.mark = '未盘';
  1186. return;
  1187. case '跳过':
  1188. _this.跳过列.push(mission);
  1189. mission.mark = '跳过';
  1190. return;
  1191. }
  1192. });
  1193. _this.已复盘有差异列 = _this.按库位排序_且合并SKU一起(_this.已复盘有差异列);
  1194. _this.未复盘有差异列 = _this.按库位排序_且合并SKU一起(_this.未复盘有差异列);
  1195. _this.已复盘无差异列 = _this.按库位排序_且合并SKU一起(_this.已复盘无差异列);
  1196. _this.无差异列 = _this.按库位排序_且合并SKU一起(_this.无差异列);
  1197. _this.未盘列 = _this.按库位排序_且合并SKU一起(_this.未盘列);
  1198. if (_this.未盘列.length>0&&!_this.分割位置id) _this.分割位置id = _this.未盘列[0].id;
  1199. _this.分割位置id = _this.更新分割位置(_this.未盘分隔列2, _this.分割位置id);
  1200. _this.未盘分隔列 = _this.分隔_基于分割位置(_this.未盘列, _this.分割位置id);
  1201. _this.未盘分隔列1 = _this.按库位排序_且合并SKU一起(_this.未盘分隔列[0]);
  1202. _this.未盘分隔列2 = _this.按库位排序_且合并SKU一起(_this.未盘分隔列[1]);
  1203. _this.确认差异列 = _this.按库位排序_且合并SKU一起(_this.确认差异列);
  1204. _this.跳过列 = _this.按库位排序_且合并SKU一起(_this.跳过列);
  1205. _this.inventoryMissions = [];
  1206. _this.重推入(_this.inventoryMissions, _this.已复盘有差异列);
  1207. _this.重推入(_this.inventoryMissions, _this.未复盘有差异列);
  1208. _this.重推入(_this.inventoryMissions, _this.未盘分隔列2);
  1209. _this.重推入(_this.inventoryMissions, _this.未盘分隔列1);
  1210. _this.重推入(_this.inventoryMissions, _this.确认差异列);
  1211. _this.重推入(_this.inventoryMissions, _this.已复盘无差异列);
  1212. _this.重推入(_this.inventoryMissions, _this.无差异列);
  1213. _this.重推入(_this.inventoryMissions, _this.跳过列);
  1214. },
  1215. 更新分割位置(上次分割列, 旧分割位置id) {
  1216. if (!上次分割列) return 旧分割位置id;
  1217. let is不更新 = false;
  1218. 上次分割列.some(function (行) {
  1219. if (行.id === 旧分割位置id && 行.mark === '未盘') {
  1220. is不更新 = true;
  1221. return true;
  1222. }
  1223. });
  1224. if (is不更新) return 旧分割位置id;
  1225. let 新分割位置id = 旧分割位置id;
  1226. 上次分割列.some(function (行) {
  1227. if (行.mark !== '未盘') return false;
  1228. 新分割位置id = 行.id;
  1229. return true;
  1230. });
  1231. return 新分割位置id;
  1232. },
  1233. 重推入(目标数组, 推入数组) {
  1234. 推入数组.forEach(function (元素) {
  1235. 目标数组.push(元素);
  1236. })
  1237. },
  1238. 按库位排序_且合并SKU一起(inventoryMissions) {
  1239. let 结果列 = [];
  1240. let 已出现字典列 = [];
  1241. inventoryMissions.sort(function (a, b) {
  1242. if (a.location > b.location) return 1;
  1243. if (a.location < b.location) return -1;
  1244. return 0;
  1245. });
  1246. function 迭代查重转移(目标列, 进度下标) {
  1247. if (!进度下标) {
  1248. 进度下标 = 0;
  1249. }
  1250. for (; 进度下标 < 目标列.length; 进度下标++) {
  1251. let 目标 = 目标列[进度下标];
  1252. if (已出现字典列[目标.commodity.barcode] === true) {
  1253. 目标列.splice(进度下标, 1)
  1254. let 最后一次重复下标 = -1;//为了给相同条码依次排序设定
  1255. 结果列.some(function (结果, i) {
  1256. if (结果.commodity.barcode === 目标.commodity.barcode) {
  1257. 最后一次重复下标 = i;
  1258. if (最后一次重复下标 === 结果列.length - 1) {
  1259. 结果列.splice(最后一次重复下标 + 1, 0, 目标);
  1260. return true;
  1261. }
  1262. } else if (最后一次重复下标 > -1) {
  1263. 结果列.splice(最后一次重复下标 + 1, 0, 目标);
  1264. return true;
  1265. }
  1266. return false;
  1267. })
  1268. 迭代查重转移(目标列, 进度下标);
  1269. return;
  1270. }
  1271. 已出现字典列[目标.commodity.barcode] = true;
  1272. 结果列.push(目标);
  1273. }
  1274. }
  1275. 迭代查重转移(inventoryMissions)
  1276. return 结果列;
  1277. },
  1278. 选中盘点起始位置(id,location) {
  1279. this.分割位置id = id;
  1280. this.重排序并标记全列表类型();
  1281. tempTip.setDuration(2000);
  1282. tempTip.showSuccess('已将库位:' + location + '的盘点记录设置为起始盘点记录');
  1283. },
  1284. 分隔_基于分割位置(未盘列,分割位置id) { // return [arr1,arr2]
  1285. let 分割位置=null;
  1286. 未盘列.forEach(function(行,下标){
  1287. if(行.id===分割位置id){
  1288. 分割位置=下标;
  1289. }
  1290. });
  1291. let 未盘列1=未盘列.slice(0,分割位置);
  1292. let 未盘列2=未盘列.slice(分割位置,未盘列.length);
  1293. return [未盘列1,未盘列2];
  1294. },
  1295. 删除盘点记录(inventoryAccountMissionId, inventoryAccountId, name) {
  1296. let _this = this;
  1297. if (!confirm('确定要删除商品为:“' + name + '”的盘点记录吗?')) {
  1298. return
  1299. }
  1300. ;
  1301. let url = '{{url('inventory/删除盘点记录')}}';
  1302. axios.post(url, {
  1303. inventoryAccountMissionId: inventoryAccountMissionId,
  1304. inventoryAccountId: inventoryAccountId
  1305. }).then(
  1306. function (response) {
  1307. if (!response.data.success) {
  1308. tempTip.setDuration(2000);
  1309. tempTip.show('盘点单号:' + inventoryAccountMissionId + '删除失败!' + response.data.data);
  1310. } else {
  1311. _this.inventoryMissions.every(function (inventoryAccountMission, i) {
  1312. if (response.data.data > 0 && inventoryAccountMission.id === inventoryAccountMissionId) {
  1313. _this.inventoryMissions.splice(i, 1);
  1314. return false;
  1315. }
  1316. return true
  1317. });
  1318. tempTip.setDuration(2000);
  1319. tempTip.showSuccess('盘点记录:' + inventoryAccountMissionId + '删除成功!');
  1320. }
  1321. }).catch(function (err) {
  1322. tempTip.setDuration(3000);
  1323. tempTip.show('删除失败,网络链接错误!' + err);
  1324. });
  1325. },
  1326. 跳过盘点记录(inventoryAccountMissionId, inventoryAccountId, name) {
  1327. let _this = this;
  1328. if (!confirm('确定要跳过商品为:“' + name + '”的盘点记录吗?')) {return ;}
  1329. let url = '{{url('inventory/跳过盘点记录')}}';
  1330. axios.post(url, {
  1331. inventoryAccountMissionId: inventoryAccountMissionId,
  1332. inventoryAccountId: inventoryAccountId
  1333. }).then(
  1334. function (response) {
  1335. if (!response.data.success) {
  1336. tempTip.setDuration(3000);
  1337. tempTip.show('盘点单号:' + inventoryAccountMissionId + '跳过盘点失败!' + response.data.data);
  1338. } else {
  1339. _this.inventoryMissions.every(function (inventoryAccountMission) {
  1340. if (inventoryAccountMission.id === inventoryAccountMissionId) {
  1341. inventoryAccountMission.checked = response.data.inventoryAccountMission.checked;
  1342. return false;
  1343. }
  1344. return true
  1345. });
  1346. }
  1347. _this.重排序并显示();
  1348. tempTip.setDuration(3000);
  1349. tempTip.showSuccess('盘点记录:' + inventoryAccountMissionId + '跳过盘点成功!');
  1350. }).catch(function (err) {
  1351. tempTip.setDuration(3000);
  1352. tempTip.show('跳过盘点记录失败,网络链接错误!' + err);
  1353. });
  1354. },
  1355. 确认盘点差异(inventoryAccountMissionId, inventoryAccountId, name) {
  1356. let _this = this;
  1357. if (!confirm('确定提交商品为:“' + name + '”的盘点差异吗?')) {return ;}
  1358. let url = '{{url('inventory/确认盘点差异')}}';
  1359. axios.post(url, {
  1360. inventoryAccountMissionId: inventoryAccountMissionId,
  1361. inventoryAccountId: inventoryAccountId
  1362. }).then(
  1363. function (response) {
  1364. if (!response.data.success) {
  1365. tempTip.setDuration(3000);
  1366. tempTip.show('盘点单号:' + inventoryAccountMissionId + '提交盘点差异失败!' + response.data.data);
  1367. } else {
  1368. _this.inventoryMissions.every(function (inventoryAccountMission) {
  1369. if (inventoryAccountMission.id === inventoryAccountMissionId) {
  1370. inventoryAccountMission.checked = response.data.inventoryAccountMission.checked;
  1371. return false;
  1372. }
  1373. return true
  1374. });
  1375. }
  1376. _this.重排序并显示();
  1377. tempTip.setDuration(3000);
  1378. tempTip.showSuccess('盘点记录:' + inventoryAccountMissionId + '提交盘点差异成功!');
  1379. }).catch(function (err) {
  1380. tempTip.setDuration(3000);
  1381. tempTip.show('提交盘点差异记录失败,网络链接错误!' + err);
  1382. });
  1383. },
  1384. 批量跳过或确认差异(){
  1385. let _this = this;
  1386. if (!confirm('确定对勾选内容进行批量操作吗?')) {return ;}
  1387. let url = '{{url('inventory/批量跳过或确认差异')}}';
  1388. axios.post(url, {checkData: _this.checkData}).then(
  1389. function (response) {
  1390. if (!response.data.success) {
  1391. tempTip.setDuration(3000);
  1392. tempTip.show('批量操作失败!' + response.data.data);
  1393. } else {
  1394. response.data.inventoryAccountMissions.forEach(function (mission) {
  1395. _this.库位索引_记录[mission.location].forEach(function(missionInIndex){
  1396. if(parseInt(missionInIndex.id)===parseInt(mission.id)){
  1397. missionInIndex.checked=mission.checked;
  1398. }
  1399. });
  1400. });
  1401. }
  1402. _this.重排序并显示();
  1403. _this.清空checkbox();
  1404. tempTip.setDuration(3000);
  1405. tempTip.showSuccess('批量操作成功!');
  1406. }).catch(function (err) {
  1407. tempTip.setDuration(3000);
  1408. tempTip.show('批量操作失败,网络链接错误!' + err);
  1409. });
  1410. },
  1411. 重排序并显示(){
  1412. let _this=this;
  1413. _this.显示记录列=[];
  1414. _this.重排序并标记全列表类型(_this.inventoryMissions);
  1415. _this.加载下方数据并置空上方数据();
  1416. },
  1417. 完结盘点任务(id, owner_name, type) {
  1418. if (!confirm('确定完结货主为:“' + owner_name + '”的“' + type + '”任务吗?')) {
  1419. return;
  1420. }
  1421. let url = '{{url('inventory/完结盘点任务')}}/' + id;
  1422. axios.get(url).then(function (response) {
  1423. if (!response.data.success) {
  1424. tempTip.setDuration(3000);
  1425. tempTip.show('修改完结状态失败!');
  1426. } else {
  1427. if (response.data.data.id === id) {
  1428. tempTip.setDuration(3000);
  1429. tempTip.showSuccess('货主为:“' + owner_name + '”的“' + type + '”任务完结成功');
  1430. window.setTimeout(function () {
  1431. window.location.href = '{{url('inventory/stockInventory/mission')}}';
  1432. }, 1000);
  1433. }
  1434. }
  1435. }).catch(function (err) {
  1436. tempTip.setDuration(3000);
  1437. tempTip.show('修改完结状态失败! ' + err);
  1438. })
  1439. },
  1440. 增加系统之外的盘点记录(location, barcode, count, inventoryId, owner_code, param) {
  1441. let _this = this;
  1442. let url = '{{url('inventory/增加系统之外的盘点记录')}}';
  1443. axios.post(url, {location:location,barcode:barcode,count:count,inventoryId:inventoryId,owner_code:owner_code,param:param}).then(
  1444. function (response) {
  1445. if (!response.data.success) {
  1446. tempTip.setDuration(3000);
  1447. tempTip.show('增加系统之外的盘点记录失败!');
  1448. } else {
  1449. let inventoryAccountMission=response.data.inventoryAccountMission;
  1450. inventoryAccountMission.commodity_barcodes = response.data.inventoryAccountMission.commodity.barcodes;
  1451. inventoryAccountMission.commodity_name = response.data.inventoryAccountMission.commodity.name;
  1452. inventoryAccountMission.stockInventoryPersons = response.data.stockInventoryPersons;
  1453. inventoryAccountMission.produced_at = '';
  1454. inventoryAccountMission.valid_at = '';
  1455. _this.inventoryMissions.push(inventoryAccountMission);
  1456. inventoryAccountMission.commodity_barcodes.forEach(function(barcode){
  1457. if(!Array.isArray(_this.条码索引_记录[barcode.code])) _this.条码索引_记录[barcode.code]=[];
  1458. _this.条码索引_记录[barcode.code].push(inventoryAccountMission);
  1459. });
  1460. if(!Array.isArray(_this.库位索引_记录[location])) _this.库位索引_记录[location]=[];
  1461. _this.库位索引_记录[location].push(inventoryAccountMission);
  1462. _this.重排序并显示();
  1463. _this.清空inputs();
  1464. tempTip.setDuration(3000);
  1465. tempTip.showSuccess('增加系统之外的盘点记录成功!');
  1466. }
  1467. }
  1468. ).catch(function (err) {
  1469. tempTip.setDuration(3000);
  1470. tempTip.show('增加系统之外的盘点记录失败,网络链接错误!' + err);
  1471. });
  1472. },
  1473. 将相邻同样条目总数匹配的标记_供样式使用(inventoryMissions) {
  1474. for (let i = 0; i < inventoryMissions.length; i++) {
  1475. let 相同条码组 = [];
  1476. function 抽出紧邻相同条码(起始下标) {
  1477. let 下标B = 起始下标 + 1;
  1478. if (下标B >= inventoryMissions.length) return;
  1479. if (inventoryMissions[起始下标].commodity.barcode === inventoryMissions[下标B].commodity.barcode) {
  1480. if (相同条码组.length <= 1 || 相同条码组[相同条码组.length - 1].id !== inventoryMissions[起始下标].id) {
  1481. 相同条码组.push(inventoryMissions[起始下标]);
  1482. }
  1483. 相同条码组.push(inventoryMissions[下标B]);
  1484. return 抽出紧邻相同条码(下标B);
  1485. }
  1486. return 下标B;
  1487. }
  1488. i = 抽出紧邻相同条码(i);
  1489. let 库存总数 = 0;
  1490. let 实盘总数 = 0;
  1491. 相同条码组.forEach(function (目标) {
  1492. 库存总数 += 目标.stored_amount;
  1493. 实盘总数 += 目标.verified_amount;
  1494. })
  1495. if (库存总数 === 实盘总数)
  1496. 相同条码组.forEach(function (目标) {
  1497. 目标.hasLinkingGroup = true;
  1498. })
  1499. }
  1500. ;
  1501. },
  1502. 清理标记(mission) {
  1503. mission.hasLinkingGroup = false;
  1504. },
  1505. 盘点(id, location, barcode, inventoryId, count) {
  1506. let _this = this;
  1507. let url = '{{url('inventory/stockInventory')}}';
  1508. axios.post(url, {id:id,location:location,barcode:barcode,count:count,inventoryId:inventoryId})
  1509. .then(function (response) {
  1510. if (!response.data.success) {
  1511. tempTip.setDuration(2000);
  1512. tempTip.show('盘点失败!' + ' ' + response.data.data);
  1513. return;
  1514. }
  1515. if (_this.inventory.id === response.data.inventory.id) {
  1516. _this.inventory.processed = response.data.inventory.processed;
  1517. _this.inventory.surplus = response.data.inventory.surplus;
  1518. _this.inventory.check_surplus = response.data.inventory.check_surplus;
  1519. }
  1520. _this.inventoryMissions.every(function (inventoryMission, i) {
  1521. if (parseInt(inventoryMission.id) === parseInt(response.data.inventoryMission.id)) {
  1522. inventoryMission.checked = response.data.inventoryMission.checked;
  1523. inventoryMission.verified_amount = response.data.inventoryMission.verified_amount;
  1524. inventoryMission.difference_amount = response.data.inventoryMission.difference_amount;
  1525. inventoryMission.re_checked_amount = response.data.inventoryMission.re_checked_amount;
  1526. inventoryMission.stockInventoryPersons = response.data.stockInventoryPersons;
  1527. _this.inventoryMissions.splice(i, 1)
  1528. _this.inventoryMissions.unshift(inventoryMission);
  1529. return false;
  1530. }
  1531. return true;
  1532. });
  1533. _this.重排序并显示();
  1534. if (response.data.inventoryMission.difference_amount!==0)_this.初盘有盘点差异_确认是否重盘();
  1535. if (response.data.inventoryMission.difference_amount===0){
  1536. _this.清空inputs();
  1537. tempTip.setDuration(3000);
  1538. tempTip.showSuccess('盘点成功!');
  1539. _this.放置焦点光标至正确位置();
  1540. }
  1541. }).catch(function (err) {
  1542. tempTip.setDuration(2000);
  1543. tempTip.show('盘点失败!' + '网络错误' + err);
  1544. })
  1545. },
  1546. 初盘有盘点差异_确认是否重盘(){
  1547. let _this=this;
  1548. tempTip.confirm('<p class="text-danger">'+"当前盘点数量存在差异,是否重盘当前盘点记录?"+'</p>',function () {
  1549. _this.放置焦点光标至正确位置();
  1550. _this.提交库位和条码();
  1551. },
  1552. function () {
  1553. _this.清空inputs();
  1554. _this.放置焦点光标至正确位置();
  1555. tempTip.setDuration(3000);
  1556. tempTip.showSuccess('盘点成功!');
  1557. },'是','否')
  1558. },
  1559. 清空inputs(){
  1560. $locationInput.val('');
  1561. $barcodeInput.val('');
  1562. $amountInput.val('');
  1563. for(let key in this.inputs()){
  1564. this.inputs()[key]='';
  1565. }
  1566. },
  1567. 清空checkbox(){
  1568. this.checkData=[];
  1569. },
  1570. 不覆盖() {
  1571. let _this = this;
  1572. _this.清空指定盘点记录列();
  1573. _this.清空inputs();
  1574. },
  1575. 覆盖(){
  1576. let _this=this;
  1577. let location=_this.inputs().location.trim();
  1578. let barcode=_this.inputs().barcode.trim();
  1579. let inventoryId=_this.inventory.id;
  1580. let count=_this.inputs().amount.trim();
  1581. let id=_this.selectingId;
  1582. _this.清空指定盘点记录列();
  1583. this.盘点(id, location, barcode, inventoryId, count);
  1584. },
  1585. 盘点选中任务(e){
  1586. let _this=this;
  1587. let id = $(e.target).attr('data_id');
  1588. let inventoryId=_this.inventory.id;
  1589. let count=_this.inputs().amount.trim();
  1590. let produced_at=_this.inputs().produced_at.trim();
  1591. let valid_at=_this.inputs().valid_at.trim();
  1592. let batch_number=_this.inputs().batch_number.trim();
  1593. let url = '{{url('inventory/盘点选中任务')}}';
  1594. axios.post(url, {id:id,count:count,inventoryId:inventoryId,produced_at:produced_at,valid_at:valid_at,batch_number:batch_number}).then(function (response) {
  1595. if (!response.data.success) {
  1596. tempTip.setDuration(2000);
  1597. tempTip.show('盘点失败!' + ' ' + response.data.data);
  1598. return;
  1599. }else {
  1600. if (_this.inventory.id === response.data.inventory.id) {
  1601. _this.inventory.processed = response.data.inventory.processed;
  1602. _this.inventory.surplus = response.data.inventory.surplus;
  1603. _this.inventory.check_surplus = response.data.inventory.check_surplus;
  1604. }
  1605. if (response.data.inventoryMission.length >1) {
  1606. response.data.inventoryMission.forEach(function (mission) {
  1607. let isToEdit=false;
  1608. let commodity_barcodes=mission.commodity_barcodes;
  1609. _this.库位索引_记录[_this.inputs().location.trim()].every(function (inventoryMission){
  1610. if (parseInt(inventoryMission.id) === parseInt(mission.id)){
  1611. isToEdit=true;
  1612. inventoryMission.checked = mission.checked;
  1613. inventoryMission.verified_amount = mission.verified_amount;
  1614. inventoryMission.difference_amount =mission.difference_amount;
  1615. inventoryMission.re_checked_amount = mission.re_checked_amount;
  1616. inventoryMission.stockInventoryPersons = response.data.stockInventoryPersons;
  1617. return false;
  1618. }
  1619. return true;
  1620. })
  1621. if (!isToEdit){
  1622. mission.commodity_barcodes= commodity_barcodes;
  1623. mission.stockInventoryPersons=response.data.stockInventoryPersons;
  1624. _this.inventoryMissions.push(mission);
  1625. }
  1626. });
  1627. }else {
  1628. _this.库位索引_记录[_this.inputs().location.trim()].every(function (inventoryMission,i) {
  1629. if (parseInt(inventoryMission.id) === parseInt(response.data.inventoryMission.id)){
  1630. inventoryMission.checked = response.data.inventoryMission.checked;
  1631. inventoryMission.verified_amount = response.data.inventoryMission.verified_amount;
  1632. inventoryMission.difference_amount = response.data.inventoryMission.difference_amount;
  1633. inventoryMission.re_checked_amount = response.data.inventoryMission.re_checked_amount;
  1634. inventoryMission.stockInventoryPersons = response.data.stockInventoryPersons;
  1635. _this.inventoryMissions.splice(i, 1);
  1636. _this.inventoryMissions.unshift(inventoryMission);
  1637. return false;
  1638. }
  1639. return true;
  1640. })
  1641. }
  1642. _this.重排序并显示();
  1643. _this.清空inputs();
  1644. _this.清空指定盘点记录列();
  1645. tempTip.setDuration(3000);
  1646. tempTip.showSuccess('盘点成功!');
  1647. }
  1648. }).catch(function (err) {
  1649. tempTip.setDuration(2000);
  1650. tempTip.show('盘点失败!' + '网络错误' + err);
  1651. })
  1652. },
  1653. inventoryAccountMissionExport(checkAllSign) {
  1654. let url = '{{url('inventory/stockInventory/inventoryAccountMission/export')}}';
  1655. let token = '{{ csrf_token() }}';
  1656. let allData = [];
  1657. if (checkAllSign) {
  1658. allData = JSON.stringify(this.inventoryMissions);
  1659. let allData1 = JSON.parse(allData);
  1660. allData1.forEach(function (inventoryMission) {
  1661. if (inventoryMission.stock_persons.length > 0) inventoryMission.stock_person = inventoryMission.stock_persons[inventoryMission.stock_persons.length - 1].name;
  1662. if (inventoryMission.stock_persons.length<1) inventoryMission.stock_person='';
  1663. delete inventoryMission.commodity_barcodes;
  1664. delete inventoryMission.stock_persons;
  1665. delete inventoryMission.stockInventoryPersons;
  1666. delete inventoryMission.commodity;
  1667. });
  1668. let data = JSON.stringify(allData1);
  1669. excelExport(false,data,url,this.sum,token);
  1670. } else {
  1671. this.checkData.forEach(function (inventoryMission) {
  1672. if (inventoryMission.stock_persons.length > 0) inventoryMission.stock_person = inventoryMission.stock_persons[inventoryMission.stock_persons.length - 1].name;
  1673. if (inventoryMission.stock_persons.length <1) inventoryMission.stock_person='';
  1674. delete inventoryMission.commodity_barcodes;
  1675. delete inventoryMission.stock_persons;
  1676. delete inventoryMission.stockInventoryPersons;
  1677. delete inventoryMission.commodity;
  1678. });
  1679. let data = JSON.stringify(this.checkData);
  1680. excelExport(checkAllSign,data,url,this.sum,token);
  1681. }
  1682. },
  1683. stockInventoryByLocation(){
  1684. let _this=this;
  1685. let inventoryId=_this.inventory.id;
  1686. let difference=[];
  1687. let trPc = $("#blueTablePc tr:gt(1)").get();
  1688. let tr = $("#blueTable tr:gt(0)").get();
  1689. $(trPc).each(function(item,key){
  1690. input = $(key).find('.blueAmountPc');
  1691. let obj=new Object();
  1692. obj.id=input.attr('data_id');
  1693. obj.stored_amount=input.attr('stored_amount');
  1694. obj.amount=input.val();
  1695. if (input.val()) _this.库位盘点记录.push(obj);
  1696. });
  1697. $(tr).each(function(item,key){
  1698. input = $(key).find('.blueAmount');
  1699. let obj=new Object();
  1700. obj.id=input.attr('data_id');
  1701. obj.stored_amount=input.attr('stored_amount');
  1702. obj.amount=input.val();
  1703. if (input.val()) _this.库位盘点记录.push(obj);
  1704. });
  1705. let url = '{{url('inventory/stockInventory/batchStockByLocation')}}';
  1706. axios.post(url,{mission:_this.库位盘点记录,inventoryId:inventoryId}).then(function(response){
  1707. if (!response.data.success) {
  1708. tempTip.setDuration(2000);
  1709. tempTip.show('盘点失败!' + ' ' + response.data.msg);
  1710. return;
  1711. }else {
  1712. if (_this.inventory.id === response.data.inventory.id) {
  1713. _this.inventory.processed = response.data.inventory.processed;
  1714. _this.inventory.surplus = response.data.inventory.surplus;
  1715. _this.inventory.check_surplus = response.data.inventory.check_surplus;
  1716. }
  1717. response.data.inventoryMission.forEach(function (mission) {
  1718. if(mission.difference_amount>0) difference.push(mission.commodity.barcodes[0].code);
  1719. _this.inventoryMissions.every(function (inventoryMission,i){
  1720. if (parseInt(inventoryMission.id) === parseInt(mission.id)){
  1721. inventoryMission.checked = mission.checked;
  1722. inventoryMission.verified_amount = mission.verified_amount;
  1723. inventoryMission.difference_amount =mission.difference_amount;
  1724. inventoryMission.re_checked_amount = mission.re_checked_amount;
  1725. inventoryMission.stockInventoryPersons = response.data.stockInventoryPersons;
  1726. _this.inventoryMissions.splice(i, 1);
  1727. _this.inventoryMissions.unshift(inventoryMission);
  1728. return false;
  1729. }
  1730. return true;
  1731. })
  1732. });
  1733. _this.重排序并显示();
  1734. _this.清空inputs();
  1735. _this.清空指定盘点记录列();
  1736. tempTip.setDuration(5000);
  1737. if (difference.length>0){
  1738. tempTip.show('给库位下:条码为'+difference+'存在差异,如需重盘请针对该条码重新盘点!');
  1739. difference=[];
  1740. }else {
  1741. tempTip.showSuccess('盘点成功!');
  1742. }
  1743. }
  1744. }).catch(function (err) {
  1745. tempTip.setDuration(2000);
  1746. tempTip.show('盘点失败!' + '网络错误' + err);
  1747. })
  1748. },
  1749. 新增盘点记录(){
  1750. let _this=this;
  1751. _this.addInventoryMission=true;
  1752. _this.清空指定盘点记录列();
  1753. },
  1754. 收起新增(){
  1755. let _this=this;
  1756. _this.addInventoryMission=false;
  1757. _this.清空指定盘点记录列();
  1758. },
  1759. 盲收(){
  1760. let _this=this;
  1761. _this.blindReceive=true;
  1762. _this.scanListening();
  1763. },
  1764. 正常盘点(){
  1765. let _this=this;
  1766. _this.blindReceive=false;
  1767. $(document).off('keypress');
  1768. },
  1769. changeToManualInputAmount:function(){
  1770. this.status.amountDisable=false;
  1771. this.isManualInputtingAmount=true;
  1772. $('#amountLabel').text('输入数量:');
  1773. },
  1774. changeToScanInputAmount:function(){
  1775. this.status.amountDisable=true;
  1776. this.isManualInputtingAmount=false;
  1777. $('#amountLabel').text('自动扫入数量:');
  1778. },
  1779. changeToManualInputBarcode:function(){
  1780. this.status.barcodeDisable=false;
  1781. this.isManualInputtingBarcode=true;
  1782. $('#barcode').attr('placeholder','手工输入条码');
  1783. },
  1784. changeToScanInputBarcode:function(){
  1785. let data = this;
  1786. this.isManualInputtingBarcode=false;
  1787. this.inputting.barcode='';
  1788. let $barcode = $('#barcode');
  1789. this.status.barcodeDisable=false;
  1790. setTimeout(function () {
  1791. $barcode.focus();
  1792. data.status.barcodeDisable=true;
  1793. },20);
  1794. $barcode.attr('placeholder','扫入条码');
  1795. },
  1796. oninputEnter:function(e){
  1797. if (e.key === 'Enter') {
  1798. this.focusDocument();
  1799. }
  1800. },
  1801. focusDocument: function () {
  1802. this.focusing = 'document';
  1803. this.showCommitButton();
  1804. },
  1805. focusOutDocument: function () {
  1806. this.focusing = '';
  1807. this.autoFillBin();
  1808. },
  1809. scanListening: function () {
  1810. let data = this;
  1811. $(document).on('keypress', function (e) {
  1812. if(data.focusing!=='document'){return}
  1813. if(data.isManualInputtingBarcode){return}
  1814. if (e.keyCode !== 13) {
  1815. if(data.status.scanEndInputted){
  1816. data.lastScannedBarcode=data.inputting.barcode;
  1817. data.inputting.barcode='';
  1818. data.status.scanEndInputted=false;
  1819. }
  1820. data.inputting.barcode += String.fromCharCode(e.keyCode);
  1821. } else {
  1822. if(data.inputting.barcode.length<=1){
  1823. window.tempTip.setDuration(4500);
  1824. window.tempTip.show('未扫入条码,请检查扫码枪设置,尝试调至“直接键盘输出”模式');
  1825. return;
  1826. }
  1827. data.status.scanEndInputted = true;
  1828. data.showCommitButton();
  1829. data.autoFillBin();
  1830. switch(data.inputMode){
  1831. case 'increasing': data.commitGoodsOnIncreasingMode();break;
  1832. case 'multiIncreasing': data.commitGoodsOnMultiIncreasingMode();break;
  1833. }
  1834. }
  1835. });
  1836. },
  1837. commitGoodsOnIncreasingMode: function () {
  1838. let data = this;
  1839. function doIt(){
  1840. let repeatedBarcode=data.repeatedIncreasingBarcodeFromSaved();
  1841. function increase(){
  1842. data.inputting.bin=repeatedBarcode.bin;
  1843. repeatedBarcode.amount++;
  1844. data.inputting.amount=repeatedBarcode.amount;
  1845. window.tempTip.setDuration(500);
  1846. window.tempTip.showSuccess(repeatedBarcode.amount);
  1847. data.focusDocument();
  1848. data.audioDing();
  1849. }
  1850. if(!repeatedBarcode){
  1851. data.focusOutDocument();
  1852. data.alertVibrate();
  1853. window.tempTip.setInputType('number');
  1854. data.inputting.amount=1;
  1855. data.goodses.unshift(JSON.parse(JSON.stringify(data.inputting)));
  1856. data.status.binDisable=true;
  1857. window.tempTip.setDuration(500);
  1858. window.tempTip.showSuccess('保存成功');
  1859. data.focusDocument();
  1860. data.audioDing();
  1861. }else{
  1862. increase();
  1863. }
  1864. }
  1865. if(data.lastScannedBarcode!==data.inputting.barcode && data.lastScannedBarcode){
  1866. data.audioWarning_otherBarcode();
  1867. data.focusOutDocument();
  1868. window.tempTip.confirm('扫到其它条码,是否切换至新条码并记录?',doIt,function () {
  1869. data.inputting.barcode=data.lastScannedBarcode;
  1870. data.focusDocument();
  1871. })
  1872. }else{
  1873. doIt()
  1874. }
  1875. },
  1876. commitGoodsOnMultiIncreasingMode: function () {
  1877. let data = this;
  1878. let repeatedBarcode=this.repeatedIncreasingBarcodeFromSaved();
  1879. function increase(){
  1880. data.inputting.bin=repeatedBarcode.bin;
  1881. repeatedBarcode.amount++;
  1882. data.inputting.amount=repeatedBarcode.amount;
  1883. window.tempTip.setDuration(500);
  1884. window.tempTip.showSuccess(repeatedBarcode.amount);
  1885. data.focusDocument();
  1886. data.audioDing();
  1887. }
  1888. if(!repeatedBarcode){
  1889. data.focusOutDocument();
  1890. data.alertVibrate();
  1891. window.tempTip.setInputType('number');
  1892. data.inputting.amount=1;
  1893. data.goodses.unshift(JSON.parse(JSON.stringify(data.inputting)));
  1894. data.status.binDisable=true;
  1895. window.tempTip.setDuration(500);
  1896. window.tempTip.showSuccess('保存成功');
  1897. data.focusDocument();
  1898. data.audioDing();
  1899. }else{
  1900. increase();
  1901. }
  1902. },
  1903. audioWarning_otherBarcode: function () {
  1904. let audio = document.getElementById('soundWarning');
  1905. audio.currentTime = 0;//重新播放
  1906. if(audio.paused){
  1907. audio.play();// 播放
  1908. }
  1909. this.alertVibrate();
  1910. },
  1911. audioDing: function () {
  1912. let audio = document.getElementById('soundDing');
  1913. audio.currentTime = 0;//重新播放
  1914. audio.play();// 播放
  1915. function startVibrate(duration) {
  1916. if (navigator.vibrate) {
  1917. navigator.vibrate(duration);
  1918. } else if (navigator.webkitVibrate) {
  1919. navigator.webkitVibrate(duration);
  1920. }
  1921. }
  1922. startVibrate(500);
  1923. },
  1924. alertVibrate: function () {
  1925. function startVibrate(duration) {
  1926. if (navigator.vibrate) {
  1927. navigator.vibrate(duration);
  1928. } else if (navigator.webkitVibrate) {
  1929. navigator.webkitVibrate(duration);
  1930. }
  1931. }
  1932. let vibrateInterval = setInterval(function() {
  1933. startVibrate(150);
  1934. }, 50);
  1935. setTimeout(function() {
  1936. clearInterval(vibrateInterval)
  1937. }, 2000);
  1938. },
  1939. autoFillBin: function () {
  1940. let data = this;
  1941. let isNotRepeatingBarcode=this.goodses.every(function(goods){
  1942. if(goods.barcode===data.inputting.barcode){
  1943. data.inputting.bin=goods.bin;
  1944. data.status.binDisable=true;
  1945. return false;
  1946. }
  1947. return true;
  1948. });
  1949. if(isNotRepeatingBarcode){
  1950. data.status.binDisable=false;
  1951. }
  1952. },
  1953. repeatedIncreasingBarcodeFromSaved: function () {
  1954. let data = this;
  1955. let repeatedGoods=null;
  1956. data.goodses.every(function(goods){
  1957. if(goods.barcode===data.inputting.barcode && goods.fromIncreasing){
  1958. repeatedGoods=goods;
  1959. return false;
  1960. }
  1961. return true;
  1962. });
  1963. return repeatedGoods;
  1964. },
  1965. commitGoods: function () {
  1966. let data = this;
  1967. window.tempTip.setDuration(3500);
  1968. if(!data.inputting.barcode){window.tempTip.show('请扫入条码');return;}
  1969. else if(!data.inputting.amount){window.tempTip.show('请输入数量');return;}
  1970. //else if(!data.inputting.bin){window.tempTip.show('请输入隔口号');return;}
  1971. data.recordOrPlusGoods();
  1972. window.tempTip.setDuration(1500);
  1973. window.tempTip.showSuccess('成功提交:' + data.inputting.barcode);
  1974. data.cleanInputs();
  1975. data.audioDing();
  1976. },
  1977. cleanInputs: function () {
  1978. this.changeToScanInputBarcode();
  1979. this.inputting.barcode='';
  1980. this.inputting.amount='';
  1981. this.inputting.bin='';
  1982. this.inputting.produce_date='';
  1983. this.inputting.valid_date='';
  1984. this.inputting.batch_number='';
  1985. this.commitButtonVisible=false;
  1986. this.status.binDisable=false;
  1987. this.lastScannedBarcode='';
  1988. },
  1989. recordOrPlusGoods: function () {
  1990. let data = this;
  1991. if(this.inputMode==='regular'){
  1992. data.goodses.unshift(JSON.parse(JSON.stringify(data.inputting)));
  1993. return;
  1994. }
  1995. let isNotRepeating=data.goodses.every(function(goods){
  1996. if(goods.barcode===data.inputting.barcode){
  1997. goods.amount=parseInt(goods.amount)+parseInt(data.inputting.amount);
  1998. return false;
  1999. }
  2000. return true;
  2001. });
  2002. if(isNotRepeating){
  2003. data.goodses.unshift(JSON.parse(JSON.stringify(data.inputting)));
  2004. }
  2005. },
  2006. removeGoods: function ($e,barcode) {
  2007. if(!confirm('确定要删除条码为'+barcode+'的记录吗'))return;
  2008. let data = this;
  2009. data.goodses.every(function(goods,i){
  2010. if(goods.barcode===barcode){
  2011. data.goodses.splice(i,1)
  2012. return false;
  2013. }
  2014. return true;
  2015. })
  2016. },
  2017. showCommitButton: function () {
  2018. let data = this;
  2019. if(data.inputting.barcode && data.inputting.amount /*&& data.inputting.bin*/){
  2020. data.commitButtonVisible=true;
  2021. }else{
  2022. if (this.inputMode==='regular' && this.status.barcodeDisable && !this.inputting.amount && this.inputting.barcode){
  2023. this.focusing = '';
  2024. document.getElementById('amount').focus();
  2025. }
  2026. }
  2027. },
  2028. submitStockInventory: function () {
  2029. let data = this;
  2030. data.focusOutDocument();
  2031. if(data.goodses.length===0){
  2032. window.tempTip.show('请先录入数据再提交盘点');return;
  2033. }
  2034. if(!data.location){
  2035. window.tempTip.setDuration(1500);
  2036. window.tempTip.show('库位为必填项');
  2037. return;
  2038. }
  2039. window.tempTip.confirm('请检查表格,确定全部完成。提交后数据将全部清空,不能后退',
  2040. function () {
  2041. let url='{{url("inventory/stockInventory/baseOnBlindReceive")}}';
  2042. axios.post(url,{'location':data.location,'goodses':data.goodses,'inventoryId':data.inventory.id,'owner_code':data.inventory.owner.code})
  2043. .then(function(response){
  2044. if(response.data.success){
  2045. data.goodses=[];
  2046. data.cleanInputs();
  2047. window.tempTip.cancelWaitingTip();
  2048. if (data.inventory.id === response.data.inventory.id) {
  2049. data.inventory.processed = response.data.inventory.processed;
  2050. data.inventory.surplus = response.data.inventory.surplus;
  2051. data.inventory.check_surplus = response.data.inventory.check_surplus;
  2052. }
  2053. if (response.data.inventoryMissions.length >0) {
  2054. response.data.inventoryMissions.forEach(function (mission) {
  2055. let isToEdit=false;
  2056. data.inventoryMissions.every(function (inventoryMission){
  2057. if (parseInt(inventoryMission.id) === parseInt(mission.id)){
  2058. isToEdit=true;
  2059. inventoryMission.checked = mission.checked;
  2060. inventoryMission.verified_amount = mission.verified_amount;
  2061. inventoryMission.difference_amount =mission.difference_amount;
  2062. inventoryMission.re_checked_amount = mission.re_checked_amount;
  2063. inventoryMission.stockInventoryPersons = response.data.stockInventoryPersons;
  2064. return false;
  2065. }
  2066. return true;
  2067. })
  2068. if (!isToEdit){
  2069. mission.commodity_barcodes = mission.commodity.barcodes;
  2070. mission.stockInventoryPersons=response.data.stockInventoryPersons;
  2071. data.inventoryMissions.push(mission);
  2072. }
  2073. });
  2074. }
  2075. data.重排序并标记全列表类型(data.inventoryMissions);
  2076. window.tempTip.setDuration(1500);
  2077. window.tempTip.showSuccess('盲收盘点成功,可返回盘点页面查看');
  2078. data.location='';
  2079. data.focusDocument();
  2080. }else{
  2081. window.tempTip.setDuration(1500);
  2082. window.tempTip.show('盲收盘点失败:'+response.data.fail_info);
  2083. data.focusDocument();
  2084. data.alertVibrate()
  2085. }
  2086. })
  2087. .catch(function (err) {
  2088. window.tempTip.setDuration(3500);
  2089. window.tempTip.show('网络或系统错误,请将以下信息提交给开发者:'+err);
  2090. data.alertVibrate();
  2091. });
  2092. },function () {
  2093. data.focusDocument();
  2094. })
  2095. }
  2096. },
  2097. computed: {
  2098. borderByMode: function () {
  2099. return {
  2100. // 'border-info':this.inputMode==='regular',
  2101. 'border-success':this.inputMode==='increasing',
  2102. 'border-danger':this.inputMode==='multiIncreasing'
  2103. }
  2104. }
  2105. }
  2106. // 单条排序并着色(inventoryMission){
  2107. // let _this=this;
  2108. // let 所在临时分类列=[];
  2109. // switch(inventoryMission.mark){
  2110. // case '已复盘有差异':所在临时分类列=_this.已复盘有差异列;break;
  2111. // case '已复盘无差异':所在临时分类列=_this.已复盘无差异列;break;
  2112. // case '未复盘有差异':所在临时分类列=_this.未复盘有差异列;break;
  2113. // case '无差异':所在临时分类列=_this.无差异列;break;
  2114. // case '未盘':所在临时分类列=_this.未盘列;break;
  2115. // }
  2116. // },
  2117. });
  2118. </script>
  2119. @endsection