storage.vue 115 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134
  1. <template>
  2. <div class="ele-body">
  3. <el-card shadow="never">
  4. <header-title title="基本信息"> </header-title>
  5. <el-form
  6. :model="formData"
  7. ref="formName"
  8. label-width="110px"
  9. :rules="rules"
  10. >
  11. <el-row :gutter="20">
  12. <el-col :span="6">
  13. <el-form-item label="物品类型" prop="extInfo.assetType">
  14. <el-select
  15. style="width: 100%"
  16. disabled
  17. multiple
  18. v-model="formData.extInfo.assetType"
  19. placeholder="请选择"
  20. >
  21. <el-option
  22. v-for="item in goodsLists"
  23. :key="item.id"
  24. :label="item.name"
  25. :value="item.id"
  26. >
  27. </el-option>
  28. </el-select>
  29. </el-form-item>
  30. </el-col>
  31. <el-col :span="6">
  32. <el-form-item label="入库类型" prop="bizType">
  33. <el-select
  34. style="width: 100%"
  35. disabled
  36. filterable
  37. placeholder="请选择"
  38. v-model="formData.bizType"
  39. clearable
  40. >
  41. <el-option
  42. v-for="item in sceneState"
  43. :key="item.code"
  44. :value="item.code"
  45. :label="item.label"
  46. ></el-option>
  47. </el-select> </el-form-item
  48. ></el-col>
  49. <el-col :span="6">
  50. <el-form-item label="单据来源" prop="documentSource">
  51. <el-input
  52. placeholder="请选择"
  53. disabled
  54. v-model="formData.sourceBizNo"
  55. @click.native="openDocumentSourceDialog"
  56. >
  57. </el-input>
  58. </el-form-item>
  59. </el-col>
  60. <!-- <el-col :span="6">
  61. <el-form-item label="权属部门" prop="deptName">
  62. <el-input
  63. placeholder="权属部门"
  64. disabled
  65. v-model="formData.extInfo.deptName"
  66. clearable
  67. />
  68. </el-form-item>
  69. </el-col> -->
  70. <el-col :span="6">
  71. <el-form-item label="入库时间">
  72. <el-date-picker
  73. v-model="formData.storageTime"
  74. type="datetime"
  75. value-format="yyyy-MM-dd HH:mm:ss"
  76. placeholder="选择日期时间"
  77. >
  78. </el-date-picker></el-form-item
  79. ></el-col>
  80. <el-col :span="6">
  81. <el-form-item label="入库登记人">
  82. <el-input
  83. placeholder="登记人"
  84. disabled
  85. v-model="formData.extInfo.createUserName"
  86. clearable /></el-form-item
  87. ></el-col>
  88. <!-- <el-col :span="6" v-if="formData.bizType == 2">
  89. <el-form-item label="供应商" prop="supplierName">
  90. <el-input
  91. placeholder="请输入"
  92. clearable
  93. v-model="formData.extInfo.supplierName"
  94. />
  95. </el-form-item>
  96. </el-col> -->
  97. <el-col :span="6">
  98. <el-form-item label="送货人" prop="fromUser">
  99. <el-input
  100. placeholder="请输入"
  101. v-model="formData.fromUser"
  102. clearable
  103. /> </el-form-item
  104. ></el-col>
  105. <el-col :span="6">
  106. <el-form-item label="送货人联系方式" prop="deliveryPhone">
  107. <el-input
  108. placeholder="请输入"
  109. v-model="formData.extInfo.deliveryPhone"
  110. clearable /></el-form-item
  111. ></el-col>
  112. <el-col :span="6">
  113. <el-form-item label="备注" prop="remark">
  114. <el-input
  115. v-model="formData.remark"
  116. clearable
  117. type="textarea"
  118. placeholder="请详细说明"
  119. :rows="1"
  120. ></el-input>
  121. </el-form-item>
  122. </el-col>
  123. </el-row>
  124. </el-form>
  125. <div class="inbound_details">
  126. <header-title title="产品信息">
  127. <el-button type="primary" @click="addProduct">添加</el-button>
  128. </header-title>
  129. <div class="form_table">
  130. <el-form
  131. ref="productListRef"
  132. :model="{ productList: productList }"
  133. :show-message="false"
  134. >
  135. <el-button
  136. v-if="productList.length != 0"
  137. type="success"
  138. plain
  139. style="margin-bottom: 20px; float: right; margin-right: 20px"
  140. size="mini"
  141. @click="listSaveArrs"
  142. >批量保存</el-button
  143. >
  144. <el-button
  145. v-if="productList.length != 0 && this.packingList.length == 0"
  146. type="success"
  147. plain
  148. style="margin-bottom: 20px; float: right; margin-right: 20px"
  149. size="mini"
  150. @click="handleWareHouse(productList[0])"
  151. >批量选择仓库</el-button
  152. >
  153. <el-table
  154. :header-cell-style="rowClass"
  155. :max-height="300"
  156. border
  157. ref="productListTable"
  158. :data="productList"
  159. tooltip-effect="dark"
  160. >
  161. <el-table-column
  162. label="序号"
  163. type="index"
  164. width="50"
  165. align="center"
  166. >
  167. </el-table-column>
  168. <el-table-column
  169. label="编码"
  170. prop="categoryCode"
  171. align="center"
  172. width="130"
  173. :show-overflow-tooltip="true"
  174. ></el-table-column>
  175. <el-table-column
  176. label="名称"
  177. align="center"
  178. width="200"
  179. prop="categoryName"
  180. :show-overflow-tooltip="true"
  181. ></el-table-column>
  182. <el-table-column
  183. label="型号"
  184. align="center"
  185. width="100"
  186. prop="categoryModel"
  187. :show-overflow-tooltip="true"
  188. ></el-table-column>
  189. <el-table-column
  190. label="规格"
  191. align="center"
  192. width="100"
  193. prop="specification"
  194. :show-overflow-tooltip="true"
  195. ></el-table-column>
  196. <el-table-column
  197. label="牌号"
  198. align="center"
  199. width="100"
  200. prop="brandNum"
  201. :show-overflow-tooltip="true"
  202. ></el-table-column>
  203. <el-table-column
  204. v-for="(item, index) in newColumns"
  205. :label="item.label"
  206. :align="item.align"
  207. :prop="item.prop"
  208. :show-overflow-tooltip="item.showOverflowTooltip"
  209. ></el-table-column>
  210. <el-table-column
  211. label="批次号"
  212. align="center"
  213. width="100"
  214. prop="batchNo"
  215. >
  216. <template slot-scope="{ row, $index }">
  217. <template v-if="row.isSave">
  218. {{ row.batchNo }}
  219. </template>
  220. <el-form-item
  221. v-else
  222. :prop="`productList.${$index}.batchNo`"
  223. required
  224. >
  225. <el-input
  226. :ref="'batchNo' + $index"
  227. @keyup.native="
  228. moveFocus($event, $index, 'batchNo', '产品', row)
  229. "
  230. v-model.number="row.batchNo"
  231. >
  232. </el-input>
  233. </el-form-item>
  234. </template>
  235. </el-table-column>
  236. <el-table-column
  237. label="数量"
  238. align="center"
  239. width="100"
  240. prop="packingQuantity"
  241. >
  242. <template slot-scope="{ row, $index }">
  243. <template v-if="row.isSave">
  244. {{ row.packingQuantity }}
  245. </template>
  246. <el-form-item
  247. v-else
  248. :prop="`productList.${$index}.packingQuantity`"
  249. required
  250. >
  251. <el-input
  252. :ref="'packingQuantity' + $index"
  253. type="number"
  254. @keyup.native="
  255. moveFocus(
  256. $event,
  257. $index,
  258. 'packingQuantity',
  259. '产品',
  260. row
  261. )
  262. "
  263. v-model="row.packingQuantity"
  264. @input="computeNum(row, $index, true)"
  265. >
  266. </el-input>
  267. </el-form-item>
  268. </template>
  269. </el-table-column>
  270. <el-table-column
  271. label="单位"
  272. align="center"
  273. prop="packingUnit"
  274. width="100"
  275. >
  276. <template slot-scope="{ row, $index }">
  277. <template v-if="row.isSave">
  278. {{ row.packingUnit }}
  279. </template>
  280. <el-form-item
  281. v-else
  282. :prop="`productList.${$index}.packingUnit`"
  283. required
  284. >
  285. <el-select
  286. v-model="row.packingUnit"
  287. placeholder="请选择"
  288. @change="computeNum(row, $index)"
  289. >
  290. <el-option
  291. v-for="item in row.packingSpecificationOption"
  292. :label="`${item.conversionUnit}`"
  293. :value="item.conversionUnit"
  294. :key="item.id"
  295. >
  296. </el-option>
  297. </el-select>
  298. </el-form-item>
  299. </template>
  300. </el-table-column>
  301. <el-table-column
  302. label="包装规格"
  303. align="center"
  304. prop="packingSpecificationLabel"
  305. width="300"
  306. :show-overflow-tooltip="true"
  307. >
  308. <template slot-scope="{ row, $index }">
  309. <el-tag v-for="item in row.packingSpecificationLabel">{{
  310. item
  311. }}</el-tag>
  312. </template>
  313. </el-table-column>
  314. <el-table-column label="允许拆包" prop="isUnpack">
  315. <template slot-scope="{ row, $index }">
  316. {{ row.isUnpack == 1 ? '是' : '否' }}
  317. </template>
  318. </el-table-column>
  319. <el-table-column
  320. label="计量数量"
  321. align="center"
  322. prop="measureQuantity"
  323. :show-overflow-tooltip="true"
  324. ></el-table-column>
  325. <el-table-column
  326. label="计量单位"
  327. align="center"
  328. prop="measureUnit"
  329. :show-overflow-tooltip="true"
  330. ></el-table-column>
  331. <el-table-column
  332. label="单重"
  333. align="center"
  334. prop="singleWeight"
  335. :show-overflow-tooltip="true"
  336. width="120"
  337. >
  338. <template slot-scope="{ row, $index }">
  339. <template v-if="row.isSave">
  340. {{ row.singleWeight }}
  341. </template>
  342. <el-input-number
  343. v-else
  344. v-model="row.singleWeight"
  345. placeholder="请输入"
  346. :precision="2"
  347. :min="0"
  348. controls-position="right"
  349. @input="inputsingleWeight(row, $index)"
  350. :controls="false"
  351. style="width: 100%"
  352. ></el-input-number>
  353. <template slot="append">
  354. {{ row.measureUnit }}
  355. </template>
  356. </template>
  357. </el-table-column>
  358. <el-table-column
  359. label="计价方式"
  360. align="center"
  361. prop="pricingWay"
  362. :show-overflow-tooltip="true"
  363. width="120"
  364. >
  365. <template slot-scope="{ row, $index }">
  366. <span v-if="row.pricingWay == 1">数量</span>
  367. <span v-if="row.pricingWay == 2">重量</span>
  368. </template>
  369. </el-table-column>
  370. <el-table-column
  371. label="总重"
  372. align="center"
  373. prop="weight"
  374. width="120"
  375. :show-overflow-tooltip="true"
  376. >
  377. <template slot-scope="{ row, $index }">
  378. <template v-if="row.isSave">
  379. {{ row.weight }}
  380. </template>
  381. <el-input
  382. v-else
  383. v-model="row.weight"
  384. placeholder="请输入"
  385. type="number"
  386. @input="inputWeight(row, $index)"
  387. ></el-input>
  388. <template slot="append">
  389. {{ row.measureUnit }}
  390. </template>
  391. </template>
  392. </el-table-column>
  393. <el-table-column
  394. label="重量单位"
  395. align="center"
  396. prop="weightUnit"
  397. :show-overflow-tooltip="true"
  398. >
  399. <template slot-scope="{ row, $index }">
  400. {{ row.weightUnit }}
  401. <template slot="append"> </template>
  402. </template>
  403. </el-table-column>
  404. <el-table-column
  405. label="单价"
  406. prop="unitPrice"
  407. width="200"
  408. align="center"
  409. >
  410. <template slot-scope="{ row, $index }">
  411. <template v-if="row.isSave">
  412. <span>{{ row.unitPrice }}</span>
  413. <span v-if="row.unitPrice">/元</span>
  414. </template>
  415. <el-form-item v-else>
  416. <el-input
  417. type="number"
  418. :ref="'unitPrice' + $index"
  419. @keyup.native="
  420. moveFocus($event, $index, 'unitPrice', '产品', row)
  421. "
  422. v-model.number="row.unitPrice"
  423. placeholder="非必填"
  424. @input="
  425. (value) =>
  426. (row.unitPrice = value.replace(/[^0-9.]+/g, ''))
  427. "
  428. >
  429. <template slot="append">
  430. <span v-if="row.unitPrice">/元</span>
  431. </template>
  432. </el-input>
  433. </el-form-item>
  434. </template>
  435. </el-table-column>
  436. <el-table-column
  437. label="金额"
  438. align="center"
  439. prop="totalMoney"
  440. :show-overflow-tooltip="true"
  441. >
  442. <template slot-scope="{ row, $index }">
  443. {{
  444. changeCount(
  445. calcSumTotal(row.measureQuantity, row.unitPrice, row)
  446. )
  447. }}
  448. </template>
  449. </el-table-column>
  450. <el-table-column
  451. label="供应商"
  452. align="center"
  453. prop="supplierId"
  454. width="200"
  455. :show-overflow-tooltip="true"
  456. >
  457. <template slot-scope="{ row, $index }">
  458. <template v-if="row.isSave">
  459. {{ row.supplierName }}
  460. </template>
  461. <el-select
  462. v-else
  463. @change="selectSupplier($event, row)"
  464. v-model="row.supplierId"
  465. placeholder="请选择"
  466. :clearable="true"
  467. >
  468. <el-option
  469. v-for="item in row.supplierListOptions"
  470. :label="item.name"
  471. :value="item.id"
  472. :key="item.id"
  473. >
  474. </el-option>
  475. </el-select>
  476. </template>
  477. </el-table-column>
  478. <el-table-column
  479. label="供应商代号"
  480. align="center"
  481. prop="supplierCode"
  482. width="120"
  483. :show-overflow-tooltip="true"
  484. >
  485. <template slot-scope="{ row, $index }">
  486. <template v-if="bizType == 2">{{
  487. row.supplierMark
  488. }}</template>
  489. <template v-if="bizType != 2">{{
  490. row.supplierCode
  491. }}</template>
  492. </template>
  493. </el-table-column>
  494. <el-table-column
  495. v-if="bizType == 2"
  496. label="产地"
  497. align="center"
  498. prop="provenance "
  499. :show-overflow-tooltip="true"
  500. width="120"
  501. >
  502. </el-table-column>
  503. <el-table-column
  504. label="仓库"
  505. align="center"
  506. prop="warehouseName"
  507. :show-overflow-tooltip="true"
  508. width="300"
  509. >
  510. <template slot-scope="{ row, $index }">
  511. <el-form-item
  512. :prop="`productList.${$index}.warehouseId`"
  513. required
  514. >
  515. <div
  516. :class="
  517. row.warehouseName
  518. ? 'wareHouse_style'
  519. : 'wareHouse_style red_color'
  520. "
  521. @click="handleWareHouse(row, $index)"
  522. >
  523. <span>
  524. {{
  525. row.warehouseName ? row.warehouseName : '请选择仓库'
  526. }}
  527. </span>
  528. </div>
  529. </el-form-item>
  530. </template>
  531. </el-table-column>
  532. <el-table-column
  533. label="采购原因"
  534. align="center"
  535. width="200"
  536. prop="purpose"
  537. :show-overflow-tooltip="true"
  538. >
  539. <template slot-scope="{ row, $index }">
  540. <template v-if="row.isSave">
  541. {{ row.purpose }}
  542. </template>
  543. <el-input
  544. v-else
  545. :ref="'purpose' + $index"
  546. @keyup.native="
  547. moveFocus($event, $index, 'purpose', '产品', row)
  548. "
  549. v-model="row.purpose"
  550. >
  551. </el-input>
  552. </template>
  553. </el-table-column>
  554. <el-table-column
  555. label="操作"
  556. width="200"
  557. fixed="right"
  558. align="center"
  559. >
  560. <template slot="header" slot-scope="scope"> 操作 </template>
  561. <template slot-scope="{ row, $index }">
  562. <el-button
  563. type="text"
  564. v-show="!row.isSave"
  565. @click="listSave(row, $index)"
  566. >保存</el-button
  567. >
  568. <el-button
  569. type="text"
  570. v-show="row.isSave"
  571. @click="listEdit(row, $index)"
  572. >编辑</el-button
  573. >
  574. <el-button type="text" @click="listDel(row, $index)"
  575. >删除</el-button
  576. >
  577. </template>
  578. </el-table-column>
  579. </el-table>
  580. </el-form>
  581. </div>
  582. </div>
  583. <div v-if="showPackingList.length > 0" class="inbound_details">
  584. <header-title :title="`包装明细`">
  585. <div class="switch_right">
  586. <el-button
  587. style="margin-left: 20px"
  588. type="text"
  589. @click="dateSetting"
  590. >批量设置{{
  591. curDateType === 'productionDate' ? '生产日期' : '采购日期'
  592. }}</el-button
  593. >
  594. </div>
  595. </header-title>
  596. <el-table
  597. v-if="isWrapTable"
  598. ref="packingListTable"
  599. :data="showPackingList"
  600. tooltip-effect="dark"
  601. :key="formData.bizType"
  602. :header-cell-style="rowClass"
  603. style="width: 100%"
  604. border
  605. stripe
  606. :max-height="300"
  607. v-el-table-infinite-scroll="pickingHandleScroll"
  608. @selection-change="handleSelectionChange"
  609. >
  610. <el-table-column type="selection" align="center" width="50">
  611. </el-table-column>
  612. <el-table-column label="序号" type="index" width="50">
  613. </el-table-column>
  614. <el-table-column
  615. label="编码"
  616. prop="categoryCode"
  617. width="130"
  618. :show-overflow-tooltip="true"
  619. ></el-table-column>
  620. <el-table-column
  621. label="名称"
  622. prop="categoryName"
  623. width="150"
  624. :show-overflow-tooltip="true"
  625. ></el-table-column>
  626. <el-table-column
  627. label="批次号"
  628. prop="batchNo"
  629. width="70"
  630. ></el-table-column>
  631. <el-table-column
  632. :label="`包装编码`"
  633. prop="packageNo"
  634. width="200"
  635. :show-overflow-tooltip="true"
  636. ></el-table-column>
  637. <el-table-column
  638. label="包装数量"
  639. prop="packingQuantity"
  640. width="80"
  641. ></el-table-column>
  642. <el-table-column label="单位" prop="packingUnit"></el-table-column>
  643. <el-table-column
  644. label="计量数量"
  645. prop="measureQuantity"
  646. :show-overflow-tooltip="true"
  647. ></el-table-column>
  648. <el-table-column
  649. label="计量单位"
  650. prop="measureUnit"
  651. ></el-table-column>
  652. <!-- <el-table-column label="允许拆包" prop="isUnpack">
  653. <template slot-scope="{ row, $index }">
  654. {{ row.isUnpack ? '是' : '否' }}
  655. </template>
  656. </el-table-column> -->
  657. <el-table-column
  658. label="仓库"
  659. :show-overflow-tooltip="true"
  660. prop="warehouseName"
  661. width="200"
  662. ></el-table-column>
  663. <el-table-column
  664. label="物料代号"
  665. prop="materielDesignation"
  666. width="130"
  667. >
  668. <template slot-scope="{ row, $index }">
  669. <el-input
  670. v-if="!row.isPack"
  671. :ref="'packing_materielDesignation' + $index"
  672. @keyup.native="
  673. moveFocus(
  674. $event,
  675. $index,
  676. 'packing_materielDesignation',
  677. '包装',
  678. row
  679. )
  680. "
  681. v-model="row.materielDesignation"
  682. ></el-input>
  683. <span v-else>{{ row.materielDesignation }}</span>
  684. </template>
  685. </el-table-column>
  686. <el-table-column label="客户代号" prop="clientCode">
  687. <template slot-scope="{ row, $index }" v-if="bizType != 2">
  688. <el-input
  689. v-if="!row.isPack"
  690. :ref="'packing_clientCode' + $index"
  691. @keyup.native="
  692. moveFocus($event, $index, 'packing_clientCode', '包装', row)
  693. "
  694. v-model="row.clientCode"
  695. ></el-input>
  696. <span v-else> {{ row.clientCode }}</span>
  697. </template>
  698. <template slot-scope="{ row, $index }" v-if="bizType == 2">
  699. <el-input
  700. v-if="!row.isPack"
  701. :ref="'packing_clientCode' + $index"
  702. @keyup.native="
  703. moveFocus($event, $index, 'packing_clientCode', '包装', row)
  704. "
  705. v-model="row.customerMark"
  706. ></el-input>
  707. <span v-else> {{ row.customerMark }}</span>
  708. </template>
  709. </el-table-column>
  710. <el-table-column label="刻码" prop="engrave" width="140">
  711. <template slot-scope="{ row, $index }">
  712. <el-input
  713. v-if="!row.isPack"
  714. :ref="'packing_engrave' + $index"
  715. @keyup.native="
  716. moveFocus($event, $index, 'packing_engrave', '包装', row)
  717. "
  718. v-model="row.engrave"
  719. ></el-input>
  720. <span v-else>{{ row.engrave }}</span>
  721. </template>
  722. </el-table-column>
  723. <el-table-column label="重量" prop="weight" width="100">
  724. <template slot-scope="{ row, $index }">
  725. <el-input
  726. v-if="!row.isPack && row.measureUnit != row.weightUnit"
  727. :ref="'packing_weight' + $index"
  728. @keyup.native="
  729. moveFocus($event, $index, 'packing_weight', '包装', row)
  730. "
  731. v-model.number="row.weight"
  732. @input="weightInput($event, row, '包装')"
  733. ></el-input>
  734. <span v-else>{{ row.weight }}</span>
  735. </template>
  736. </el-table-column>
  737. <el-table-column label="重量单位" prop="weightUnit">
  738. <template slot-scope="{ row }">
  739. {{ row.weightUnit }}
  740. </template>
  741. </el-table-column>
  742. <el-table-column
  743. v-if="form.isQmsCheck == 0"
  744. label="质检结果"
  745. prop="result"
  746. width="120"
  747. >
  748. <template slot-scope="{ row }">
  749. <el-select
  750. v-if="!row.isPack"
  751. @change="changeWrapStatus($event, row, '包装')"
  752. v-model="row.result"
  753. placeholder="请选择"
  754. >
  755. <el-option
  756. v-for="item in qualityResultsOptions"
  757. :label="item.label"
  758. :value="item.value"
  759. :key="item.value"
  760. >
  761. </el-option>
  762. </el-select>
  763. <span v-else>{{ qualityResults[row.result] }}</span>
  764. </template>
  765. </el-table-column>
  766. <el-table-column label="质检状态" prop="status" width="120">
  767. <template slot-scope="{ row }">
  768. <span>{{ qualityStatus[row.status] }}</span>
  769. </template>
  770. </el-table-column>
  771. <el-table-column label="生产日期" prop="" width="220">
  772. <template slot="header" slot-scope="scope">
  773. <el-select filterable v-model="curDateType">
  774. <el-option value="productionDate" label="生产日期"></el-option>
  775. <el-option value="purchaseDate" label="采购日期"></el-option>
  776. </el-select>
  777. </template>
  778. <template slot-scope="{ row }">
  779. <template v-if="formData.bizType == 5">
  780. {{ row[curDateType] }}
  781. </template>
  782. <el-date-picker
  783. v-else
  784. :disabled="row.isPack"
  785. size="small"
  786. v-model="row[curDateType]"
  787. type="datetime"
  788. value-format="yyyy-MM-dd HH:mm:ss"
  789. placeholder="选择日期"
  790. >
  791. </el-date-picker>
  792. </template>
  793. </el-table-column>
  794. <!-- <el-table-column label="操作" width="120" fixed="right">
  795. <template slot-scope="{ row, $index }">
  796. <el-button type="text" @click="wrapDelete(row, $index)">
  797. 删除
  798. </el-button>
  799. </template>
  800. </el-table-column> -->
  801. </el-table>
  802. </div>
  803. <div v-if="showMaterialList.length > 0" class="inbound_details">
  804. <header-title :title="`物料明细`"></header-title>
  805. <el-table
  806. ref="materialListTable"
  807. :data="showMaterialList"
  808. tooltip-effect="dark"
  809. :key="formData.bizType"
  810. :header-cell-style="rowClass"
  811. style="width: 100%"
  812. border
  813. stripe
  814. :max-height="300"
  815. v-el-table-infinite-scroll="materielHandleScroll"
  816. >
  817. <el-table-column label="序号" type="index" width="50">
  818. </el-table-column>
  819. <el-table-column
  820. label="编码"
  821. prop="categoryCode"
  822. width="130"
  823. :show-overflow-tooltip="true"
  824. ></el-table-column>
  825. <el-table-column
  826. label="名称"
  827. prop="categoryName"
  828. width="150"
  829. :show-overflow-tooltip="true"
  830. ></el-table-column>
  831. <el-table-column
  832. label="批次号"
  833. prop="batchNo"
  834. width="70"
  835. ></el-table-column>
  836. <el-table-column
  837. label="物料编码"
  838. prop="materialCode"
  839. width="200"
  840. :show-overflow-tooltip="true"
  841. ></el-table-column>
  842. <el-table-column
  843. label="计量数量"
  844. prop="measureQuantity"
  845. width="90"
  846. :show-overflow-tooltip="true"
  847. ></el-table-column>
  848. <el-table-column
  849. width="80"
  850. label="计量单位"
  851. prop="measureUnit"
  852. ></el-table-column>
  853. <el-table-column
  854. label="物料代号"
  855. prop="materielDesignation"
  856. width="130"
  857. >
  858. <template slot-scope="{ row, $index }">
  859. <el-input
  860. v-if="!row.isPack"
  861. :ref="'material_materielDesignation' + $index"
  862. @keyup.native="
  863. moveFocus(
  864. $event,
  865. $index,
  866. 'material_materielDesignation',
  867. '物料',
  868. row
  869. )
  870. "
  871. v-model="row.materielDesignation"
  872. ></el-input>
  873. <span v-else>{{ row.materielDesignation }}</span>
  874. </template>
  875. </el-table-column>
  876. <el-table-column label="客户代号" prop="clientCode">
  877. <template slot-scope="{ row, $index }" v-if="bizType != 2">
  878. <el-input
  879. v-if="!row.isPack"
  880. :ref="'material_clientCode' + $index"
  881. @keyup.native="
  882. moveFocus($event, $index, 'material_clientCode', '物料', row)
  883. "
  884. v-model="row.clientCode"
  885. ></el-input>
  886. <span v-else>{{ row.clientCode }}</span>
  887. </template>
  888. <template slot-scope="{ row, $index }" v-if="bizType == 2">
  889. <el-input
  890. v-if="!row.isPack"
  891. :ref="'packing_clientCode' + $index"
  892. @keyup.native="
  893. moveFocus($event, $index, 'packing_clientCode', '物料', row)
  894. "
  895. v-model="row.customerMark"
  896. ></el-input>
  897. <span v-else> {{ row.customerMark }}</span>
  898. </template>
  899. </el-table-column>
  900. <el-table-column label="刻码" prop="engrave" width="140">
  901. <template slot-scope="{ row, $index }">
  902. <el-input
  903. v-if="!row.isPack"
  904. :ref="'material_engrave' + $index"
  905. @keyup.native="
  906. moveFocus($event, $index, 'material_engrave', '物料', row)
  907. "
  908. v-model="row.engrave"
  909. ></el-input>
  910. <span v-else>{{ row.engrave }}</span>
  911. </template>
  912. </el-table-column>
  913. <el-table-column label="重量" prop="weight" width="100">
  914. <template slot-scope="{ row, $index }">
  915. <el-input
  916. v-if="!row.isPack && row.measureUnit != row.weightUnit"
  917. :ref="'material_weight' + $index"
  918. @keyup.native="
  919. moveFocus($event, $index, 'material_weight', '物料', row)
  920. "
  921. @input="weightInput($event, row, '物料')"
  922. v-model.number="row.weight"
  923. ></el-input>
  924. <span v-else>{{ row.weight }}</span>
  925. </template>
  926. </el-table-column>
  927. <el-table-column
  928. label="重量单位"
  929. prop="weightUnit"
  930. width="100"
  931. ></el-table-column>
  932. <el-table-column label="质检结果" prop="result" width="120">
  933. <template slot-scope="{ row }">
  934. <el-select
  935. v-if="!row.isPack"
  936. @change="changeWrapStatus($event, row, '物料')"
  937. v-model="row.result"
  938. placeholder="请选择"
  939. >
  940. <el-option
  941. v-for="item in qualityResultsOptions"
  942. :label="item.label"
  943. :value="item.value"
  944. :key="item.value"
  945. >
  946. </el-option>
  947. </el-select>
  948. <span v-else>{{ qualityResults[row.result] }}</span>
  949. </template>
  950. </el-table-column>
  951. <el-table-column label="质检状态" prop="status" width="120">
  952. <template slot-scope="{ row }">
  953. <span>{{ qualityStatus[row.status] }}</span>
  954. </template>
  955. </el-table-column>
  956. <!-- <el-table-column label="操作" width="120" fixed="right">
  957. <template slot-scope="{ row, $index }">
  958. <el-button type="text" @click="materialDelete(row, $index)">
  959. 删除
  960. </el-button>
  961. </template>
  962. </el-table-column> -->
  963. </el-table>
  964. </div>
  965. </el-card>
  966. <!-- 产品选择弹框 -->
  967. <selectType
  968. :visibleDialog.sync="visibleDialog"
  969. :title="title"
  970. :treeIds="formData.extInfo.assetType"
  971. :loadTree.sync="loadTree"
  972. @selectTableData="addGoods"
  973. />
  974. <!-- 仓库选择弹框 -->
  975. <WarehousingDialog
  976. ref="wareHouseDailogRef"
  977. @selection="wareHouseSelection"
  978. ></WarehousingDialog>
  979. <!-- 生产日期、采购日期弹框 -->
  980. <el-dialog :visible.sync="dateVisible" title="选择日期" width="400px">
  981. <el-date-picker
  982. size="small"
  983. v-model="batchTime"
  984. type="datetime"
  985. style="width: 320px"
  986. value-format="yyyy-MM-dd HH:mm:ss"
  987. placeholder="选择日期"
  988. >
  989. </el-date-picker>
  990. <div style="text-align: right; margin-top: 20px">
  991. <el-button @click="dateVisible = false">取消</el-button>
  992. <el-button type="primary" @click="dateConfirm" :disabled="!batchTime"
  993. >确认</el-button
  994. >
  995. </div>
  996. </el-dialog>
  997. </div>
  998. </template>
  999. <script>
  1000. import elTableInfiniteScroll from 'el-table-infinite-scroll';
  1001. import storageApi from '@/api/warehouseManagement/index.js';
  1002. import WarehousingDialog from './components/WarehousingDialog.vue';
  1003. import { getCode } from '@/api/codeManagement/index.js';
  1004. import selectType from './components/selectType_new.vue';
  1005. import {
  1006. sceneState,
  1007. qualityResultsOptions,
  1008. qualityResults,
  1009. qualityStatus
  1010. } from '@/utils/dict/index';
  1011. import { getTreeByGroup } from '@/api/classifyManage';
  1012. import { deepClone } from '@/utils';
  1013. import { getDetails } from '@/api/classifyManage/itemInformation';
  1014. import { mapActions, mapGetters } from 'vuex';
  1015. import BigNumber from 'bignumber.js';
  1016. export default {
  1017. components: {
  1018. selectType,
  1019. WarehousingDialog
  1020. },
  1021. // 虚拟列表滚动方法
  1022. directives: {
  1023. 'el-table-infinite-scroll': elTableInfiniteScroll
  1024. },
  1025. props: {
  1026. form: { type: Object, default: () => {} },
  1027. bizType: { type: Number, default: 1 },
  1028. sourceBizNo: { type: String, default: '' },
  1029. detailList: { type: Array, default: () => [] },
  1030. saleProductList: { type: Array, default: () => [] },
  1031. detailProductList: { type: Array, default: () => [] },
  1032. isMoreProduct: { type: Boolean, default: false } //多产品包装明细
  1033. },
  1034. data() {
  1035. return {
  1036. newColumns: [], // 动态表头
  1037. sceneState,
  1038. saveLoading: false,
  1039. dateVisible: false,
  1040. loadTree: true,
  1041. visibleDialog: false,
  1042. title: '选择产品',
  1043. goodsLists: [],
  1044. formData: {
  1045. bizType: '',
  1046. storageTime: '',
  1047. extInfo: {
  1048. assetType: []
  1049. }
  1050. },
  1051. rules: {
  1052. 'extInfo.assetType': {
  1053. required: true,
  1054. message: '请选择物品类型',
  1055. trigger: 'blur'
  1056. },
  1057. bizType: {
  1058. required: true,
  1059. message: '请选择入库场景',
  1060. trigger: 'change'
  1061. }
  1062. },
  1063. qualityResultsOptions, // 质检结果选项
  1064. qualityStatus, // 质检状态 0未检 1已检
  1065. qualityResults, // 质检结果 0无 1合格 2不合格
  1066. productList: [], // 产品列表
  1067. packingList: [], // 包装列表
  1068. showPackingList: [], // 包装列表(虚拟列表)
  1069. materialList: [], // 物料列表
  1070. showMaterialList: [], // 物料列表(虚拟列表)
  1071. curDateType: 'productionDate',
  1072. packingListSelected: [], // 包装选择列表
  1073. isWrapTable: true, // 解决表格不刷新问题(包装)
  1074. currentPackingQuantity: '', // 当前包装数量
  1075. batchTime: '', // 生产日期、采购日期
  1076. pageSize: 20, // 物料和包装列表条数
  1077. pickingPageNum: 1, // 包装虚拟分页页数
  1078. materielPageNum: 1 // 物料虚拟分页页数
  1079. };
  1080. },
  1081. computed: {
  1082. ...mapGetters(['dict', 'getDict']),
  1083. clientEnvironmentId() {
  1084. return this.$store.state.user.info.clientEnvironmentId;
  1085. }
  1086. },
  1087. watch: {
  1088. packingList: {
  1089. handler(newVal) {
  1090. this.showPackingList = newVal.slice(
  1091. 0,
  1092. this.pageSize * (this.pickingPageNum > 0 ? this.pickingPageNum : 1)
  1093. );
  1094. this.showPackingList.forEach((obj) => {
  1095. obj.workOrderId = this.detailProductList[0]?.workOrderId;
  1096. obj.taskId = this.detailProductList[0]?.taskId;
  1097. obj.outsourceBatchNo = this.detailProductList[0]?.batchNo;
  1098. obj.outsourceCode = this.detailProductList[0]?.sourceCode;
  1099. obj.taskId = this.detailList[0]?.taskId;
  1100. obj.workOrderId = this.detailList[0]?.workOrderId;
  1101. });
  1102. this.pickingPageNum = Math.ceil(
  1103. this.showPackingList.length / this.pageSize
  1104. );
  1105. },
  1106. deep: true
  1107. },
  1108. materialList: {
  1109. handler(newVal) {
  1110. this.showMaterialList = newVal.slice(
  1111. 0,
  1112. this.pageSize *
  1113. (this.materielPageNum > 0 ? this.materielPageNum : 1)
  1114. );
  1115. },
  1116. deep: true
  1117. },
  1118. detailList: {
  1119. handler(newVal) {
  1120. if (newVal.length) {
  1121. this.initFormData();
  1122. }
  1123. },
  1124. deep: true
  1125. }
  1126. },
  1127. async created() {
  1128. await this.requestDict('不拆物料层规格');
  1129. await this.getFieldModel();
  1130. await this.getListItems();
  1131. await this.initFormData();
  1132. await this.getNowFormatDate();
  1133. },
  1134. methods: {
  1135. ...mapActions('dict', ['requestDict']),
  1136. changeCount(number) {
  1137. return new BigNumber(number).toString();
  1138. },
  1139. selectSupplier(val, row) {
  1140. row.supplierId = val;
  1141. row.supplierName = row.supplierListOptions.filter(
  1142. (item) => item.id == val
  1143. )[0]?.name;
  1144. row.supplierCode = row.supplierListOptions.filter(
  1145. (item) => item.id == val
  1146. )[0].serialNo;
  1147. },
  1148. inputsingleWeight(row, index) {
  1149. row.weight = row.singleWeight * row.measureQuantity;
  1150. },
  1151. inputWeight(row, index) {
  1152. row.singleWeight = row.measureQuantity
  1153. ? row.weight / row.measureQuantity
  1154. : 0;
  1155. },
  1156. // 计算最小单元数量
  1157. computeNum(row, index, isClear) {
  1158. // 清空仓库(包装数量输入)
  1159. if (isClear) {
  1160. this.$set(this.productList[index], 'warehouseId', '');
  1161. this.$set(this.productList[index], 'warehouseName', '');
  1162. if (row.packingQuantity < 0) {
  1163. this.$set(this.productList[index], 'packingQuantity', 1);
  1164. } else if (row.packingQuantity > 9999) {
  1165. this.$set(this.productList[index], 'packingQuantity', 9999);
  1166. }
  1167. // else {
  1168. // this.$set(
  1169. // this.productList[index],
  1170. // 'packingQuantity',
  1171. // row.packingQuantity.replace(/[^\d\.{2,}]/g, '')
  1172. // );
  1173. // }
  1174. }
  1175. if (row.packingQuantity && row.packingUnit) {
  1176. let startIndex = row.packingSpecificationOption.findIndex((ite) => {
  1177. return (
  1178. row.measuringUnit == ite.packingUnit &&
  1179. ite.packingUnit != ite.conversionUnit
  1180. );
  1181. });
  1182. let endIndex = row.packingSpecificationOption.findIndex(
  1183. (ite) => row.packingUnit == ite.conversionUnit
  1184. );
  1185. let total = row.packingQuantity;
  1186. for (; startIndex < endIndex; endIndex--) {
  1187. total = this.$math.format(
  1188. row.packingSpecificationOption[endIndex].packageCell * total,
  1189. 14
  1190. );
  1191. }
  1192. if (row.measuringUnit != 'KG') {
  1193. row.weight = row.singleWeight * row.measureQuantity;
  1194. }
  1195. row.measureQuantity = this.changeCount(total);
  1196. // 判断单位和计量单位是否为不拆物料层规格
  1197. let packingBoolen = !!this.getDict('不拆物料层规格', row.packingUnit)
  1198. .dictValue;
  1199. let measureBoolen = !!this.getDict('不拆物料层规格', row.measureUnit)
  1200. .dictValue;
  1201. if (packingBoolen || measureBoolen) {
  1202. row.weight = total;
  1203. } else {
  1204. row.weight = this.$math.format(total * row.netWeight, 14);
  1205. }
  1206. }
  1207. },
  1208. // 获取动态表头
  1209. getFieldModel() {
  1210. storageApi.fieldModel({ fieldModel: 't_main_category' }).then((res) => {
  1211. let newRes = res.map((m) => {
  1212. return {
  1213. prop: 'extField.' + m.prop,
  1214. label: m.label,
  1215. align: 'center',
  1216. showOverflowTooltip: true
  1217. };
  1218. });
  1219. this.newColumns = [...newRes];
  1220. });
  1221. },
  1222. // 初始化信息
  1223. async initFormData() {
  1224. this.formData.type = 1;
  1225. this.formData.bizType = this.bizType;
  1226. if (
  1227. this.form != null &&
  1228. Object.keys(this.form).length > 0 &&
  1229. this.form.categoryLevelTopId != ''
  1230. ) {
  1231. this.formData.extInfo.assetType = Array.from(
  1232. new Set(this.form?.categoryLevelTopId?.split(','))
  1233. );
  1234. } else {
  1235. this.$message.warning('未获取到物品类型!');
  1236. }
  1237. console.log('this.detailList---------', this.detailList);
  1238. if (this.sourceBizNo != null && this.sourceBizNo != '') {
  1239. this.formData.sourceBizNo = this.sourceBizNo;
  1240. } else {
  1241. this.$message.warning('未获取到单据来源!');
  1242. }
  1243. // 入库登记人
  1244. this.formData.extInfo.createUserName = this.$store.state.user.info.name;
  1245. this.formData.extInfo.deliveryPhone = this.$store.state.user.info.phone;
  1246. this.formData.createUserId = this.$store.state.user.info.userId;
  1247. this.formData.extInfo.deptName = this.$store.state.user.info.deptName;
  1248. // this.formData.extInfo.supplierName = this.form.supplierName;
  1249. // this.formData.extInfo.supplierId = this.form.supplierId;
  1250. console.log('this.saleProductList---------', this.saleProductList);
  1251. if (this.saleProductList?.length > 0) {
  1252. // 物品列表
  1253. let codeList = this.saleProductList.map((item) => {
  1254. return item.productCode;
  1255. });
  1256. storageApi.getListByNameOrModeType({ codeList }).then(async (res) => {
  1257. console.log('res---------', res);
  1258. if (res.length <= 0) {
  1259. this.$message.warning('未获取到物品信息!');
  1260. return;
  1261. }
  1262. // 获取批次号
  1263. const batchNo = await getCode('lot_number_code');
  1264. // 获取供应商
  1265. const supplierList = await storageApi.contactQueryByCategoryIdsAPI({
  1266. categoryIds: res.map((item) => item.id)
  1267. });
  1268. // 获取包装规格
  1269. let packingSpecification =
  1270. await storageApi.getCategoryPackageDisposition({
  1271. categoryIds: res.map((item) => item.id)
  1272. });
  1273. this.packingSpecificationOption = res.map((item) => {
  1274. return packingSpecification
  1275. .filter((ite) => item.id == ite.categoryId)
  1276. .sort((a, b) => a.sort - b.sort);
  1277. });
  1278. this.productList = res.map((item, index) => {
  1279. let filtersItem = this.saleProductList.filter(
  1280. (detailItem) => detailItem.productCode == item.code
  1281. )[0];
  1282. // 显示规格
  1283. let packingSpecificationLabel = this.packingSpecificationOption[
  1284. index
  1285. ]
  1286. .map((item) => {
  1287. if (item.sort > 0) {
  1288. return `${item.packageCell}${item.packageUnit}/${item.conversionUnit}`;
  1289. }
  1290. })
  1291. .filter((item) => !!item);
  1292. let warehouseId = filtersItem.warehouseId;
  1293. let warehouseName = filtersItem.warehouseName;
  1294. let measureQuantity = filtersItem.totalCount || 0;
  1295. let packingQuantity = filtersItem.totalCount || 0;
  1296. let packingUnit = filtersItem.measuringUnit || '';
  1297. let unitPrice = filtersItem.singlePrice || 0;
  1298. let pricingWay = filtersItem.pricingWay || '';
  1299. // 计价方式是重量
  1300. let singleWeight =
  1301. this.detailProductList[0]?.pricingWay == 2
  1302. ? this.detailProductList[0]?.singleWeight
  1303. : filtersItem.singleWeight || 0;
  1304. let weight =
  1305. this.detailProductList[0]?.pricingWay == 2
  1306. ? this.detailProductList[0]?.singleWeight *
  1307. filtersItem.measureQuantity
  1308. : filtersItem.sendTotalWeight || 0;
  1309. // 获取相同仓库
  1310. let warehouseIds = [];
  1311. let warehouseNames = [];
  1312. for (let i = 0; i < filtersItem.totalCount; i++) {
  1313. warehouseIds.push(filtersItem.warehouseId);
  1314. warehouseNames.push(filtersItem.warehouseName);
  1315. }
  1316. let totalMoney = filtersItem.totalPrice || 0;
  1317. return {
  1318. index: this.productList.length + index,
  1319. categoryId: item.id, // 物品id
  1320. categoryName: item.name, // 物品名称
  1321. categoryCode: item.code, // 物品编码
  1322. categoryModel: item.modelType, // 物品型号
  1323. specification: item.specification, // 规格
  1324. brandNum: item.brandNum, // 牌号
  1325. batchNo: this.saleProductList[index]?.batchNo || batchNo, // 批次号
  1326. supplierListOptions: supplierList[item.id], // 供应商列表
  1327. supplierId: this.form.supplierId, // 供应商id
  1328. supplierCode: this.form.supplierCode, // 供应商代号
  1329. supplierName: this.form.supplierName, // 供应商名称
  1330. approvalNumber: item.approvalNumber, // 批准文号
  1331. packingSpecification: item.packingSpecification, // 包装规格
  1332. packingSpecificationOption:
  1333. this.packingSpecificationOption[index], // 包装规格选项
  1334. packingSpecificationLabel: packingSpecificationLabel, // 包装规格显示
  1335. // minPackingQuantity: minPackingQuantity, // 最小包装单元数量
  1336. packingQuantity: packingQuantity, // 包装数量
  1337. packingUnit: packingUnit, // 单位
  1338. measureQuantity: measureQuantity, // 计量数量
  1339. measureUnit: item.measuringUnit, // 计量单位
  1340. netWeight: item.netWeight > -1 ? item.netWeight : 0, // 净重
  1341. singleWeight: singleWeight, // 单重重量
  1342. weight: weight, // 总重量
  1343. weightUnit: item.weightUnit, // 重量单位
  1344. totalMoney: totalMoney, // 总价
  1345. unitPrice: item.unitPrice || unitPrice, // 单价
  1346. pricingWay: pricingWay, //计价方式
  1347. purpose: '', // 用途
  1348. isUnpack: item.isUnpack, // 是否允许拆包
  1349. warehouseId, // 仓库id
  1350. warehouseName, // 仓库名称
  1351. warehouseIds,
  1352. warehouseNames
  1353. };
  1354. });
  1355. this.$nextTick(() => {
  1356. this.listSaveArrs();
  1357. });
  1358. });
  1359. }
  1360. if (this.detailList?.length > 0) {
  1361. // 包装列表 this.detailList
  1362. // 获取主数据物品详情
  1363. // let { category } = await getDetails(this.form.categoryId);
  1364. let codeList = this.detailList.map((item) => {
  1365. return item.productCode || item.categoryCode;
  1366. });
  1367. storageApi.getListByNameOrModeType({ codeList }).then(async (res) => {
  1368. // 获取批次号
  1369. const batchNo = await getCode('lot_number_code');
  1370. // 获取供应商
  1371. const supplierList = await storageApi.contactQueryByCategoryIdsAPI({
  1372. categoryIds: res.map((item) => item.id)
  1373. });
  1374. // 获取包装规格
  1375. let packingSpecification =
  1376. await storageApi.getCategoryPackageDisposition({
  1377. categoryIds: res.map((item) => item.id)
  1378. });
  1379. this.packingSpecificationOption = res.map((item) => {
  1380. return packingSpecification
  1381. .filter((ite) => item.id == ite.categoryId)
  1382. .sort((a, b) => a.sort - b.sort);
  1383. });
  1384. // 获取相同仓库
  1385. let warehouseIds = [];
  1386. let warehouseNames = [];
  1387. for (let index = 0; index < this.form.totalCount; index++) {
  1388. warehouseIds.push(this.form.warehouseId);
  1389. warehouseNames.push(this.form.warehouseName);
  1390. }
  1391. if (this.isMoreProduct) {
  1392. this.formData.extInfo.assetType = [];
  1393. res.map((item) => {
  1394. this.formData.extInfo.assetType.push(
  1395. item.categoryLevelPathIdParent
  1396. );
  1397. });
  1398. this.formData.extInfo.assetType = Array.from(
  1399. new Set(...this.formData.extInfo.assetType)
  1400. );
  1401. }
  1402. // 生成产品列表
  1403. this.productList = res.map((item, index) => {
  1404. // 显示规格
  1405. let packingSpecificationLabel = this.packingSpecificationOption[
  1406. index
  1407. ]
  1408. .map((item) => {
  1409. if (item.sort > 0) {
  1410. return `${item.packageCell}${item.packageUnit}/${item.conversionUnit}`;
  1411. }
  1412. })
  1413. .filter((item) => !!item);
  1414. // 换算重量
  1415. let weight = 0;
  1416. if (
  1417. this.form?.weightUnit?.toUpperCase() ==
  1418. item?.weightUnit.toUpperCase()
  1419. ) {
  1420. weight = this.form.totalWeight;
  1421. } else {
  1422. switch (item.weightUnit.toUpperCase()) {
  1423. case 'KG':
  1424. if (this.form.totalWeight > -1) {
  1425. weight = this.$math.format(
  1426. this.form.totalWeight / 1000,
  1427. 14
  1428. );
  1429. } else {
  1430. weight = 0;
  1431. }
  1432. break;
  1433. case 'G':
  1434. if (this.form.totalWeight > -1) {
  1435. weight = this.$math.format(
  1436. this.form.totalWeight * 1000,
  1437. 14
  1438. );
  1439. } else {
  1440. weight = 0;
  1441. }
  1442. break;
  1443. case 'L':
  1444. if (this.form.totalWeight > -1) {
  1445. weight = this.$math.format(
  1446. this.form.totalWeight * 1000,
  1447. 14
  1448. );
  1449. } else {
  1450. weight = 0;
  1451. }
  1452. break;
  1453. case 'l':
  1454. if (this.form.totalWeight > -1) {
  1455. weight = this.$math.format(
  1456. this.form.totalWeight * 1000,
  1457. 14
  1458. );
  1459. } else {
  1460. weight = 0;
  1461. }
  1462. break;
  1463. case 'ML':
  1464. if (this.form.totalWeight > -1) {
  1465. weight = this.$math.format(
  1466. this.form.totalWeight * 1000,
  1467. 14
  1468. );
  1469. } else {
  1470. weight = 0;
  1471. }
  1472. break;
  1473. case 'ml':
  1474. if (this.form.totalWeight > -1) {
  1475. weight = this.$math.format(
  1476. this.form.totalWeight * 1000,
  1477. 14
  1478. );
  1479. } else {
  1480. weight = 0;
  1481. }
  1482. break;
  1483. }
  1484. }
  1485. let singleWeight = item.singleWeight || 0; // 单重重量
  1486. return {
  1487. index: this.productList.length + index,
  1488. isSave: true,
  1489. categoryId: item.id, // 物品id
  1490. categoryName: item.name, // 物品名称
  1491. categoryCode: item.code, // 物品编码
  1492. categoryModel: item.modelType, // 物品型号
  1493. specification: item.specification, // 规格
  1494. brandNum: item.brandNum, // 牌号
  1495. batchNo: batchNo, // 批次号
  1496. supplierListOptions: supplierList[item.id], // 供应商列表
  1497. supplierId: '', // 供应商id
  1498. supplierCode: '',
  1499. supplierName: '', // 供应商名称
  1500. approvalNumber: item.approvalNumber, // 批准文号
  1501. packingSpecification: item.packingSpecification, // 包装规格
  1502. packingSpecificationOption:
  1503. this.packingSpecificationOption[index], // 包装规格选项
  1504. packingSpecificationLabel: packingSpecificationLabel, // 包装规格显示
  1505. // minPackingQuantity: 1, // 最小包装单元数量
  1506. packingQuantity: this.isMoreProduct
  1507. ? this.detailList.filter(
  1508. (val) => val.productCode == item.code
  1509. ).length
  1510. : this.detailList.length || this.form.detailList.length, // 包装数量
  1511. packingUnit: item.packingUnit, // 单位
  1512. measureQuantity: this.isMoreProduct
  1513. ? this.getMeasureQuantity(item.code)
  1514. : this.form.totalCount, // 计量数量
  1515. measureUnit: item.measuringUnit, // 计量单位
  1516. netWeight: item.netWeight > -1 ? item.netWeight : 0, // 净重
  1517. weight: weight, // 重量
  1518. singleWeight: singleWeight,
  1519. weightUnit: item.weightUnit, // 重量单位
  1520. totalMoney: item.totalPrice, // 总价
  1521. unitPrice: item.unitPrice, // 单价
  1522. purpose: '', // 用途
  1523. isUnpack: item.isUnpack, // 是否允许拆包
  1524. warehouseId: this.isMoreProduct
  1525. ? this.detailList.find((val) => val.productCode == item.code)
  1526. ?.warehouseId
  1527. : this.form.warehouseId, // 仓库id
  1528. warehouseName: this.isMoreProduct
  1529. ? this.detailList.find((val) => val.productCode == item.code)
  1530. ?.warehouseName
  1531. : this.form.warehouseName, // 仓库名称
  1532. warehouseIds: this.isMoreProduct
  1533. ? this.detailList
  1534. .filter((val) => val.productCode == item.code)
  1535. .map((item) => item.warehouseId)
  1536. : warehouseIds,
  1537. warehouseNames: this.isMoreProduct
  1538. ? this.detailList
  1539. .filter((val) => val.productCode == item.code)
  1540. .map((item) => item.warehouseName)
  1541. : warehouseNames
  1542. };
  1543. });
  1544. let getAssetNumPr = this.isMoreProduct
  1545. ? this.detailList.map((val) => {
  1546. return {
  1547. assetCode: val.productCode,
  1548. batchNum: val.productBrand,
  1549. num: 1
  1550. };
  1551. })
  1552. : [
  1553. {
  1554. assetCode:
  1555. this.productList[0].categoryCode +
  1556. this.productList[0].index,
  1557. batchNum: this.productList[0].batchNo,
  1558. num: this.detailList.length
  1559. }
  1560. ];
  1561. // 生成包装编码
  1562. const { data } = await storageApi.getAssetNum(getAssetNumPr);
  1563. let packingCodeList = data;
  1564. // 生产包装
  1565. this.packingList = this.detailList.map((item, index) => {
  1566. // 换算重量
  1567. let weight = 0;
  1568. if (
  1569. this.productList[0].weightUnit.toUpperCase() ==
  1570. item.weightUnit.toUpperCase()
  1571. ) {
  1572. weight = this.form.totalWeight;
  1573. } else {
  1574. switch (this.productList[0].weightUnit.toUpperCase()) {
  1575. case 'KG':
  1576. if (item.weightUnit > -1) {
  1577. weight = this.$math.format(item.weightUnit / 1000, 14);
  1578. } else {
  1579. weight = 0;
  1580. }
  1581. break;
  1582. case 'G':
  1583. if (item.weightUnit > -1) {
  1584. weight = this.$math.format(item.weightUnit * 1000, 14);
  1585. } else {
  1586. weight = 0;
  1587. }
  1588. break;
  1589. case 'L':
  1590. if (item.weightUnit > -1) {
  1591. weight = this.$math.format(item.weightUnit / 1000, 14);
  1592. } else {
  1593. weight = 0;
  1594. }
  1595. break;
  1596. case 'l':
  1597. if (item.weightUnit > -1) {
  1598. weight = this.$math.format(item.weightUnit / 1000, 14);
  1599. } else {
  1600. weight = 0;
  1601. }
  1602. break;
  1603. case 'ML':
  1604. if (item.weightUnit > -1) {
  1605. weight = this.$math.format(item.weightUnit / 1000, 14);
  1606. } else {
  1607. weight = 0;
  1608. }
  1609. break;
  1610. case 'ml':
  1611. if (item.weightUnit > -1) {
  1612. weight = this.$math.format(item.weightUnit / 1000, 14);
  1613. } else {
  1614. weight = 0;
  1615. }
  1616. break;
  1617. }
  1618. }
  1619. // 代入时间
  1620. let obj = this.getNowDate();
  1621. let productionDate = '';
  1622. let purchaseDate = '';
  1623. if (this.formData.bizType == '1') {
  1624. // 生产入库
  1625. productionDate = `${obj.year}-${obj.month}-${obj.strDate} ${obj.hour}:${obj.minute}:${obj.second}`;
  1626. this.curDateType = 'productionDate';
  1627. } else if (this.formData.bizType == '2') {
  1628. // 采购入库
  1629. purchaseDate = `${obj.year}-${obj.month}-${obj.strDate} ${obj.hour}:${obj.minute}:${obj.second}`;
  1630. this.curDateType = 'purchaseDate';
  1631. }
  1632. return {
  1633. index: this.isMoreProduct
  1634. ? this.productList.find(
  1635. (val) => val.categoryCode == item.productCode
  1636. ).index +
  1637. '-' +
  1638. index
  1639. : this.productList[0].index + '-' + index, // 包装索引
  1640. warehouseId:
  1641. item.warehouseId || this.productList[0].warehouseIds[index], // 仓库id
  1642. warehouseName:
  1643. item.warehouseName ||
  1644. this.productList[0].warehouseNames[index], // 仓库名称
  1645. categoryName:
  1646. item.productName || this.productList[0].categoryName, // 产品名称
  1647. categoryCode:
  1648. item.productCode || this.productList[0].categoryCode, // 产品编码
  1649. categoryModel:
  1650. item.modelType || this.productList[0].categoryModel, // 物品型号
  1651. specification:
  1652. item.specification || this.productList[0].specification, // 规格
  1653. brandNum: item.productBrand || this.productList[0].brandNum, // 牌号
  1654. parentIndex: this.isMoreProduct
  1655. ? this.productList.find(
  1656. (val) => val.categoryCode == item.productCode
  1657. ).index
  1658. : this.productList[0].index, // 产品索引
  1659. batchNo: item.batchNo || this.productList[0].batchNo, // 批次号
  1660. packageNo: packingCodeList[index]?.onlyCode, // 包装编码
  1661. packingQuantity: 1, // 包装数量
  1662. packingUnit: item.packingUnit, // 单位
  1663. measureQuantity: item.quantity, // 计量数量
  1664. measureUnit: item.measuringUnit, // 计量单位
  1665. weight: item.packingWeight, // 重量
  1666. singleWeight: item.singleWeight,
  1667. pricingWay: item.pricingWay,
  1668. weightUnit: item.weightUnit || this.productList[0].weightUnit, // 重量单位
  1669. packingSpecificationOption: this.isMoreProduct
  1670. ? this.productList.find(
  1671. (val) => val.categoryCode == item.productCode
  1672. )?.packingSpecificationOption
  1673. : this.productList[0].packingSpecificationOption, // 包装规格
  1674. netWeight: this.productList[0].netWeight, // 净重
  1675. barcodes: item.barcodes || item.sendCode, // 发货条码
  1676. clientCode: item.clientCode || item.extInfo?.clientCode, // 客户代号
  1677. materielDesignation:
  1678. item.materielDesignation || item.extInfo?.materielCode, // 物料代号
  1679. engrave: item.engrave || item.extInfo?.engrave, // 刻码
  1680. isUnpack: this.productList[0].isUnpack, // 是否允许拆包
  1681. productionDate: productionDate, // 生产日期
  1682. purchaseDate: purchaseDate, // 采购时间
  1683. result: 1, // 结果(1合格 2不合格)
  1684. status: 2 // 状态(0=未质检 1待检 2已检)
  1685. };
  1686. });
  1687. });
  1688. }
  1689. },
  1690. //获取计量数量
  1691. getMeasureQuantity(code) {
  1692. let measureQuantity = 0;
  1693. this.detailList.forEach((item) => {
  1694. if (code == item.productCode) {
  1695. measureQuantity += item.quantity;
  1696. }
  1697. });
  1698. return measureQuantity;
  1699. },
  1700. //多产品明细数据转换
  1701. async getDetailsVal(code, productBrand) {
  1702. const { data } = await storageApi.getAssetNum([
  1703. {
  1704. assetCode: code,
  1705. batchNum: 1,
  1706. num: 1
  1707. }
  1708. ]);
  1709. return data[0].onlyCode;
  1710. },
  1711. // 获取当前时间函数
  1712. getNowDate() {
  1713. let date = new Date(),
  1714. obj = {
  1715. month: date.getMonth() + 1, //获取当前月份(0-11,0代表1月)
  1716. strDate: date.getDate(), // 获取当前日(1-31)
  1717. hour: date.getHours(), //获取当前小时(0 ~ 23)
  1718. minute: date.getMinutes(), //获取当前分钟(0 ~ 59)
  1719. second: date.getSeconds() //获取当前秒数(0 ~ 59)
  1720. };
  1721. Object.keys(obj).forEach((key) => {
  1722. if (obj[key] < 10) obj[key] = `0${obj[key]}`;
  1723. });
  1724. return obj;
  1725. },
  1726. // 赋值入库时间
  1727. getNowFormatDate() {
  1728. if (this.bizType == '2') {
  1729. let time = '00:00:00';
  1730. this.formData.storageTime = this.form.receiveDate + ' ' + time;
  1731. } else {
  1732. let obj = this.getNowDate();
  1733. this.formData.storageTime = `${obj.year}-${obj.month}-${obj.strDate} ${obj.hour}:${obj.minute}:${obj.second}`;
  1734. }
  1735. },
  1736. // 获取物品列表
  1737. async getListItems() {
  1738. const { data } = await getTreeByGroup({ type: 2 });
  1739. this.goodsLists = data;
  1740. },
  1741. // 打开单据来源弹窗
  1742. openDocumentSourceDialog() {
  1743. console.log('打开单据来源弹窗');
  1744. },
  1745. // 清除单据来源
  1746. clearDocumentSource() {
  1747. this.formData.sourceBizNo = '';
  1748. },
  1749. // 添加产品
  1750. addProduct() {
  1751. if (this.formData.extInfo.assetType.length <= 0) {
  1752. return this.$message.error('请选择物品类型');
  1753. }
  1754. if (!this.formData.bizType) {
  1755. return this.$message.error('请选择入库类型');
  1756. }
  1757. this.visibleDialog = true;
  1758. },
  1759. // 键盘移动
  1760. moveFocus(event, index, key, type, row) {
  1761. let keyfield = [];
  1762. let listLength = 0;
  1763. switch (type) {
  1764. case '产品':
  1765. listLength = this.productList.length;
  1766. keyfield = ['batchNo', 'packingQuantity', 'unitPrice', 'purpose'];
  1767. break;
  1768. case '包装':
  1769. listLength = this.showPackingList.length;
  1770. if (row.measureUnit != row.weightUnit) {
  1771. keyfield = [
  1772. 'packing_materielDesignation',
  1773. 'packing_clientCode',
  1774. 'packing_engrave',
  1775. 'packing_weight'
  1776. ];
  1777. } else {
  1778. keyfield = [
  1779. 'packing_materielDesignation',
  1780. 'packing_clientCode',
  1781. 'packing_engrave'
  1782. ];
  1783. }
  1784. break;
  1785. case '物料':
  1786. listLength = this.showMaterialList.length;
  1787. if (row.measureUnit != row.weightUnit) {
  1788. keyfield = [
  1789. 'material_materielDesignation',
  1790. 'material_clientCode',
  1791. 'material_engrave',
  1792. 'material_weight'
  1793. ];
  1794. } else {
  1795. keyfield = [
  1796. 'material_materielDesignation',
  1797. 'material_clientCode',
  1798. 'material_engrave'
  1799. ];
  1800. }
  1801. break;
  1802. }
  1803. if (event.keyCode === 13) {
  1804. // 回车
  1805. if (
  1806. index === listLength - 1 &&
  1807. key === keyfield[keyfield.length - 1]
  1808. ) {
  1809. // 最后一行最后一个
  1810. return;
  1811. }
  1812. this.$refs[key + index].blur();
  1813. if (key === keyfield[keyfield.length - 1]) {
  1814. // 当前行最后一个,跳转下一行第一个
  1815. if (this.$refs[keyfield[0] + (index + 1)].value == 0) {
  1816. this.$refs[keyfield[0] + (index + 1)].value = '';
  1817. }
  1818. this.$refs[keyfield[0] + (index + 1)].focus();
  1819. } else {
  1820. // 跳转下一个
  1821. const nextkeyindex = keyfield.findIndex((k) => k === key) + 1;
  1822. this.$nextTick(() => {
  1823. if (this.$refs[keyfield[nextkeyindex] + index].value == 0) {
  1824. this.$refs[keyfield[nextkeyindex] + index].value = '';
  1825. }
  1826. this.$refs[keyfield[nextkeyindex] + index].focus();
  1827. });
  1828. }
  1829. }
  1830. // 向上 =38
  1831. if (event.keyCode === 38) {
  1832. if (index === 0) {
  1833. // 第一行
  1834. return;
  1835. }
  1836. this.$refs[key + index].blur();
  1837. this.$nextTick(() => {
  1838. if (this.$refs[key + (index - 1)].value == 0) {
  1839. this.$refs[key + (index - 1)].value = '';
  1840. }
  1841. this.$refs[key + (index - 1)].focus();
  1842. });
  1843. }
  1844. // 下 = 40
  1845. if (event.keyCode === 40) {
  1846. if (index === listLength - 1) {
  1847. // 最后一行
  1848. return;
  1849. }
  1850. this.$refs[key + index].blur();
  1851. this.$nextTick(() => {
  1852. if (this.$refs[key + (index + 1)].value == 0) {
  1853. this.$refs[key + (index + 1)].value = '';
  1854. }
  1855. this.$refs[key + (index + 1)].focus();
  1856. });
  1857. }
  1858. // 左 = 37
  1859. if (event.keyCode === 37) {
  1860. console.log('向左');
  1861. if (index === 0 && key === keyfield[0]) {
  1862. // 第一行第一个
  1863. console.log('第一行第一个无法向左');
  1864. return;
  1865. }
  1866. this.$refs[key + index].blur();
  1867. if (key === keyfield[0]) {
  1868. if (
  1869. this.$refs[keyfield[keyfield.length - 1] + (index - 1)].value == 0
  1870. ) {
  1871. this.$refs[keyfield[keyfield.length - 1] + (index - 1)].value =
  1872. '';
  1873. }
  1874. // 当前行第一个,跳转上一行最后一个
  1875. this.$refs[keyfield[keyfield.length - 1] + (index - 1)].focus();
  1876. } else {
  1877. // 跳转上一个
  1878. const prevkeyindex = keyfield.findIndex((k) => k === key) - 1;
  1879. this.$nextTick(() => {
  1880. if (this.$refs[keyfield[prevkeyindex] + index].value == 0) {
  1881. this.$refs[keyfield[prevkeyindex] + index].value = '';
  1882. }
  1883. this.$refs[keyfield[prevkeyindex] + index].focus();
  1884. });
  1885. }
  1886. }
  1887. // 右 = 39
  1888. if (event.keyCode === 39) {
  1889. if (
  1890. index === listLength - 1 &&
  1891. key === keyfield[keyfield.length - 1]
  1892. ) {
  1893. // 最后一行最后一个
  1894. return;
  1895. }
  1896. this.$refs[key + index].blur();
  1897. if (key === keyfield[keyfield.length - 1]) {
  1898. // 当前行最后一个,跳转下一行第一个
  1899. if (this.$refs[keyfield[0] + (index + 1)].value == 0) {
  1900. this.$refs[keyfield[0] + (index + 1)].value = '';
  1901. }
  1902. this.$refs[keyfield[0] + (index + 1)].focus();
  1903. } else {
  1904. // 跳转下一个
  1905. const nextkeyindex = keyfield.findIndex((k) => k === key) + 1;
  1906. this.$nextTick(() => {
  1907. if (this.$refs[keyfield[nextkeyindex] + index].value == 0) {
  1908. this.$refs[keyfield[nextkeyindex] + index].value = '';
  1909. }
  1910. this.$refs[keyfield[nextkeyindex] + index].focus();
  1911. });
  1912. }
  1913. }
  1914. },
  1915. // 入库
  1916. getReturnStorage() {
  1917. return new Promise((resolve) => {
  1918. if (this.productList.length <= 0) {
  1919. this.$message.error('请先添加产品信息');
  1920. return;
  1921. }
  1922. let boolen = this.productList.every((item) => item.isSave);
  1923. if (!boolen) {
  1924. this.$message.error('请先保存所有产品信息');
  1925. return;
  1926. }
  1927. // 处理包装数据
  1928. let _packingList = [];
  1929. _packingList = this.packingList.map((packingItem) => {
  1930. let _taskId = null;
  1931. let _workOrderId = null;
  1932. if ([1].includes(this.bizType)) {
  1933. _workOrderId = this.detailList[0]?.workOrderId;
  1934. _taskId = this.detailList[0]?.taskId;
  1935. } else {
  1936. _workOrderId = this.detailProductList[0]?.workOrderId;
  1937. _taskId = this.detailProductList[0]?.taskId;
  1938. }
  1939. // workOrderId: this.detailProductList[0]?.workOrderId,
  1940. // taskId: this.detailProductList[0]?.taskId,
  1941. // taskId: this.detailList[0]?.taskId,
  1942. // workOrderId: this.detailList[0]?.workOrderId,
  1943. return {
  1944. ...packingItem,
  1945. workOrderId: _workOrderId,
  1946. taskId: _taskId,
  1947. outsourceBatchNo: this.detailProductList[0]?.batchNo,
  1948. outsourceCode: this.detailProductList[0]?.sourceCode,
  1949. materialDetailList: this.materialList.filter(
  1950. (item) => item.parentIndex === packingItem.index
  1951. )
  1952. };
  1953. });
  1954. // 处理产品数据
  1955. this.productList = this.productList.map((productItem) => {
  1956. return {
  1957. ...productItem,
  1958. outInDetailRecordRequestList: _packingList.filter(
  1959. (item) => item.parentIndex === productItem.index
  1960. )
  1961. };
  1962. });
  1963. this.formData.outInDetailList = this.productList;
  1964. let obj = deepClone(this.formData);
  1965. // 处理物品类型assetType
  1966. obj.extInfo.assetType = obj.extInfo.assetType.join(',');
  1967. obj.extInfo.documentSource = this.formData.sourceBizNo;
  1968. obj.extInfo.deptName = this.formData.extInfo.deptName;
  1969. obj.extInfo.supplierName = this.form.supplierName;
  1970. obj.extInfo.deliveryPhone = this.formData.extInfo.deliveryPhone;
  1971. // 处理仓库id
  1972. let warehouseId = [];
  1973. let warehouseName = [];
  1974. let warehouseIds = this.productList
  1975. .map((item) => item.warehouseIds)
  1976. .flat();
  1977. let warehouseNames = this.productList
  1978. .map((item) => item.warehouseNames)
  1979. .flat();
  1980. warehouseIds.forEach((item, index) => {
  1981. if (!warehouseId.includes(item)) {
  1982. warehouseId.push(item);
  1983. warehouseName.push(warehouseNames[index]);
  1984. }
  1985. });
  1986. obj.warehouseIds = warehouseId;
  1987. obj.warehouseNames = warehouseName;
  1988. obj._packingList = _packingList;
  1989. setTimeout(() => {
  1990. resolve(obj);
  1991. }, 1000);
  1992. });
  1993. },
  1994. pickingHandleScroll() {
  1995. if (this.showPackingList.length < this.packingList.length) {
  1996. if (this.packingList.length > this.pageSize) {
  1997. this.pickingPageNum += 1;
  1998. }
  1999. this.pickingFetchData();
  2000. }
  2001. },
  2002. pickingFetchData() {
  2003. const start = (this.pickingPageNum - 1) * this.pageSize;
  2004. const end = start + this.pageSize;
  2005. this.showPackingList = this.showPackingList.concat(
  2006. this.packingList.slice(start, end)
  2007. );
  2008. },
  2009. materielHandleScroll() {
  2010. if (this.showMaterialList.length < this.materialList.length) {
  2011. if (this.materialList.length > this.pageSize) {
  2012. this.materielPageNum += 1;
  2013. }
  2014. this.materielFetchData();
  2015. }
  2016. },
  2017. materielFetchData() {
  2018. const start = (this.materielPageNum - 1) * this.pageSize;
  2019. const end = start + this.pageSize;
  2020. this.showMaterialList = this.showMaterialList.concat(
  2021. this.materialList.slice(start, end)
  2022. );
  2023. },
  2024. // 日期选择
  2025. dateConfirm() {
  2026. this.packingListSelected.forEach((item) => {
  2027. this.$set(item, this.curDateType, this.batchTime);
  2028. });
  2029. this.batchTime = '';
  2030. this.dateVisible = false;
  2031. },
  2032. // 包装重量修改
  2033. packingWeightCahnge(value, row) {
  2034. // 修改物品重量
  2035. let filterPackingList = this.packingList.filter((item) => {
  2036. return item.parentIndex === row.parentIndex;
  2037. });
  2038. let productIndex = this.productList.findIndex((item) => {
  2039. return item.index === row.parentIndex;
  2040. });
  2041. let totalWeight = filterPackingList.reduce(
  2042. (accumulator, currentValue) => {
  2043. return this.$math.format(+accumulator + +currentValue.weight, 14);
  2044. },
  2045. 0
  2046. );
  2047. this.$set(this.productList[productIndex], 'weight', totalWeight);
  2048. this.$set(
  2049. this.productList[productIndex],
  2050. 'singleWeight',
  2051. totalWeight / this.productList[productIndex].measureQuantity
  2052. );
  2053. // 修改拆分物料
  2054. this.materialList.map((item, index) => {
  2055. if (item.parentIndex === row.index) {
  2056. this.$set(
  2057. this.materialList[index],
  2058. 'weight',
  2059. this.$math.format(value / row.measureQuantity, 14) >= 0
  2060. ? this.$math.format(value / row.measureQuantity, 14)
  2061. : 0
  2062. );
  2063. }
  2064. });
  2065. },
  2066. // 物料重量修改
  2067. materialWeightCahnge(row) {
  2068. // 修改包装重量
  2069. let filterMaterialList = this.materialList.filter((item) => {
  2070. return item.parentIndex === row.parentIndex;
  2071. });
  2072. let packingIndex = this.packingList.findIndex((item) => {
  2073. return item.index === row.parentIndex;
  2074. });
  2075. let totalMaterialWeight = filterMaterialList.reduce(
  2076. (accumulator, currentValue) => {
  2077. return this.$math.format(+accumulator + +currentValue.weight, 14);
  2078. },
  2079. 0
  2080. );
  2081. this.$set(
  2082. this.packingList[packingIndex],
  2083. 'weight',
  2084. totalMaterialWeight
  2085. );
  2086. // 修改物品重量
  2087. let filterPackingList = this.packingList.filter((item) => {
  2088. return (
  2089. item.parentIndex === this.packingList[packingIndex].parentIndex
  2090. );
  2091. });
  2092. let productIndex = this.productList.findIndex((item) => {
  2093. return item.index === this.packingList[packingIndex].parentIndex;
  2094. });
  2095. let totalWeight = filterPackingList.reduce(
  2096. (accumulator, currentValue) => {
  2097. return this.$math.format(+accumulator + +currentValue.weight, 14);
  2098. },
  2099. 0
  2100. );
  2101. this.$set(this.productList[productIndex], 'weight', totalWeight);
  2102. },
  2103. // 包装质检结果修改
  2104. packingResultCahnge(value, row) {
  2105. // 修改物料质检结果(0无 1合格 2不合格 3让步接收)
  2106. this.materialList.map((item, index) => {
  2107. if (item.parentIndex === row.index) {
  2108. this.$set(this.materialList[index], 'result', value);
  2109. this.$set(this.materialList[index], 'status', 2);
  2110. }
  2111. });
  2112. },
  2113. // 物料质量结果修改
  2114. materialResultCahnge(value, row) {
  2115. // 修改包装质检结果
  2116. let filterMaterialList = this.materialList.filter((item) => {
  2117. return item.parentIndex == row.parentIndex;
  2118. });
  2119. let packingIndex = this.packingList.findIndex((item) => {
  2120. return item.index == row.parentIndex;
  2121. });
  2122. let boolen = filterMaterialList.every((item) => {
  2123. return item.result == 1;
  2124. });
  2125. this.$set(this.packingList[packingIndex], 'result', boolen ? 1 : 2);
  2126. this.$set(this.packingList[packingIndex], 'status', 2);
  2127. },
  2128. // 重量限制
  2129. weightInput(value, row, type) {
  2130. const newValue = value.replace(/[^\d.]/g, ''); // 保留数字和小数点
  2131. const decimalCount = (newValue.match(/\./g) || []).length; // 计算小数点的个数
  2132. if (row.weight < 0) {
  2133. row.weight = 0;
  2134. } else if (row.weight > 9999) {
  2135. row.weight = 9999;
  2136. } else {
  2137. if (decimalCount > 1) {
  2138. // 如果小数点个数大于1,移除多余的小数点
  2139. const lastIndex = newValue.lastIndexOf('.');
  2140. row.weight =
  2141. newValue.slice(0, lastIndex) + newValue.slice(lastIndex + 1);
  2142. } else if (decimalCount === 1) {
  2143. // 如果小数点个数等于1,允许小数点的输入
  2144. row.weight = newValue;
  2145. } else {
  2146. row.weight = newValue === '' ? 0 : parseFloat(newValue); // 如果输入为空,则设为0
  2147. }
  2148. }
  2149. if (type === '包装') {
  2150. this.packingWeightCahnge(value, row);
  2151. } else {
  2152. this.materialWeightCahnge(row);
  2153. }
  2154. },
  2155. //计算金额
  2156. calcSumTotal(measureQuantity, unitPrice, row) {
  2157. //最小包装单元,包装数量,单价
  2158. if (this.bizType != 2) {
  2159. const total = {
  2160. measureQuantity: Number(measureQuantity > 0 ? measureQuantity : 0),
  2161. unitPrice: Number(unitPrice > 0 ? unitPrice : 0)
  2162. };
  2163. let number = Number(
  2164. this.$math.format(total.measureQuantity * total.unitPrice, 14)
  2165. );
  2166. row.totalMoney = number;
  2167. return number;
  2168. } else {
  2169. return row.totalMoney;
  2170. }
  2171. },
  2172. // 包装维度最小包装单元改变——>总重量
  2173. minPackingQuantityChange(row, value, index) {
  2174. if (row.measureUnit !== 'KG') {
  2175. if (value.replace(/^(0+)|[^\d]+/g, '') > 9999) {
  2176. this.$set(this.productList[index], 'minPackingQuantity', 9999);
  2177. } else {
  2178. this.$set(
  2179. this.productList[index],
  2180. 'minPackingQuantity',
  2181. value.replace(/^(0+)|[^\d]+/g, '')
  2182. );
  2183. }
  2184. } else {
  2185. if (value < 1) {
  2186. this.$set(this.productList[index], 'minPackingQuantity', 1);
  2187. } else if (value > 9999) {
  2188. this.$set(this.productList[index], 'minPackingQuantity', 9999);
  2189. }
  2190. }
  2191. if (row.packingQuantity >= 0 && value >= 0) {
  2192. this.packNum(row, row.packingQuantity, index);
  2193. }
  2194. },
  2195. // 包装数量过滤处理改变——>总重量
  2196. packNum(row, value, index) {
  2197. const total = {
  2198. minPackingQuantity: Number(
  2199. row.minPackingQuantity > 0
  2200. ? row.minPackingQuantity > 9999
  2201. ? 9999
  2202. : row.minPackingQuantity
  2203. : 0
  2204. ),
  2205. packingQuantity: Number(
  2206. row.packingQuantity > 0
  2207. ? row.packingQuantity > 9999
  2208. ? 9999
  2209. : row.packingQuantity
  2210. : 0
  2211. )
  2212. };
  2213. const totals = Number(
  2214. this.$math.format(
  2215. total.minPackingQuantity * total.packingQuantity,
  2216. 14
  2217. )
  2218. );
  2219. if (row.measureUnit == row.weightUnit) {
  2220. row.weight = Number(
  2221. this.$math.format(
  2222. total.minPackingQuantity *
  2223. 1 *
  2224. Number(total.packingQuantity).toFixed(2),
  2225. 14
  2226. )
  2227. );
  2228. } else {
  2229. row.weight = Number(
  2230. this.$math.format(
  2231. totals *
  2232. (row.netWeight > 0 ? Number(row.netWeight).toFixed(2) : 0),
  2233. 14
  2234. )
  2235. );
  2236. }
  2237. this.$set(this.productList[index], 'measureQuantity', totals);
  2238. // 清空仓库
  2239. this.$set(this.productList[index], 'warehouseId', '');
  2240. this.$set(this.productList[index], 'warehouseName', '');
  2241. if (value.replace(/^(0+)|[^\d]+/g, '') > 9999) {
  2242. this.$set(this.productList[index], 'packingQuantity', 9999);
  2243. } else {
  2244. this.$set(
  2245. this.productList[index],
  2246. 'packingQuantity',
  2247. value.replace(/^(0+)|[^\d]+/g, '')
  2248. );
  2249. }
  2250. // return (row.packingQuantity = value.replace(/^(0+)|[^\d]+/g, ''));
  2251. },
  2252. // 表格样式
  2253. rowClass({ row, column, rowIndex, columnIndex }) {
  2254. if (rowIndex === 1) {
  2255. return {
  2256. display: 'none',
  2257. background: '#EEEEEE'
  2258. };
  2259. }
  2260. return { background: '#0000' };
  2261. },
  2262. // 添加物品明细
  2263. async addGoods(data) {
  2264. // 获取批次号
  2265. const batchNo = await getCode('lot_number_code');
  2266. // 获取供应商
  2267. const supplierList = await storageApi.contactQueryByCategoryIdsAPI({
  2268. categoryIds: data.map((item) => item.id)
  2269. });
  2270. // 获取包装规格
  2271. let packingSpecification =
  2272. await storageApi.getCategoryPackageDisposition({
  2273. categoryIds: data.map((item) => item.id)
  2274. });
  2275. this.packingSpecificationOption = data.map((item) => {
  2276. return packingSpecification
  2277. .filter((ite) => item.id == ite.categoryId)
  2278. .sort((a, b) => a.sort - b.sort);
  2279. });
  2280. let productList = data.map((item, index) => {
  2281. // 显示规格
  2282. let packingSpecificationLabel = this.packingSpecificationOption[index]
  2283. .map((item) => {
  2284. if (item.sort > 0) {
  2285. return `${item.packageCell}${item.packageUnit}/${item.conversionUnit}`;
  2286. }
  2287. })
  2288. .filter((item) => !!item);
  2289. return {
  2290. index:
  2291. this.productList.length - 1 > -1
  2292. ? this.productList[this.productList.length - 1].index +
  2293. index +
  2294. 1
  2295. : this.productList.length + index,
  2296. categoryId: item.id, // 物品id
  2297. categoryName: item.name, // 物品名称
  2298. categoryCode: item.code, // 物品编码
  2299. categoryModel: item.modelType, // 物品型号
  2300. specification: item.specification, // 规格
  2301. brandNum: item.brandNum, // 牌号
  2302. batchNo: batchNo, // 批次号
  2303. supplierListOptions: supplierList[item.id], // 供应商列表
  2304. supplierId: '', // 供应商id
  2305. supplierCode: '',
  2306. supplierName: '', // 供应商名称
  2307. approvalNumber: item.approvalNumber, // 批准文号
  2308. packingSpecification: item.packingSpecification, // 包装规格
  2309. packingSpecificationOption: this.packingSpecificationOption[index], // 包装规格选项
  2310. packingSpecificationLabel: packingSpecificationLabel, // 包装规格显示
  2311. minPackingQuantity: '', // 最小包装单元数量
  2312. packingQuantity: '', // 包装数量
  2313. packingUnit: '', // 单位
  2314. measureQuantity: 0, // 计量数量
  2315. measureUnit: item.measuringUnit, // 计量单位
  2316. netWeight: item.netWeight > -1 ? item.netWeight : 0, // 净重
  2317. weight: 0, // 重量
  2318. singleWeight: item.measuringUnit != 'KG' ? item.netWeight : 0, // 单重
  2319. pricingWay: item.pricingWay,
  2320. weightUnit: item.weightUnit, // 重量单位
  2321. totalMoney: item.totalPrice, // 总价
  2322. unitPrice: item.unitPrice, // 单价
  2323. purpose: '', // 用途
  2324. isUnpack: item.isUnpack // 是否允许拆包
  2325. };
  2326. });
  2327. this.productList = this.productList.concat(productList);
  2328. console.log('this.productList--------', this.productList);
  2329. },
  2330. // 物品保存验证表单(批量)
  2331. validateForm() {
  2332. return new Promise(async (resolve, reject) => {
  2333. let list = this.productList.map(async (row, index) => {
  2334. let fileds = [
  2335. `productList.${index}.batchNo`,
  2336. `productList.${index}.packingQuantity`,
  2337. `productList.${index}.packingUnit`,
  2338. `productList.${index}.warehouseId`
  2339. ];
  2340. if (row.isSave) {
  2341. return Promise.resolve(true);
  2342. } else {
  2343. return await Promise.all(
  2344. fileds.map(
  2345. (item) =>
  2346. new Promise(async (res, rej) => {
  2347. this.$refs.productListRef.validateField(item, (err) => {
  2348. if (err) {
  2349. rej(err);
  2350. } else {
  2351. res(true);
  2352. }
  2353. });
  2354. })
  2355. )
  2356. );
  2357. }
  2358. });
  2359. Promise.all(list)
  2360. .then(() => {
  2361. console.log('保存成功!');
  2362. resolve();
  2363. })
  2364. .catch((err) => {
  2365. console.log('保存失败!');
  2366. this.$message.error('请填入必填项!');
  2367. reject(err);
  2368. });
  2369. });
  2370. },
  2371. // 产品批量保存
  2372. async listSaveArrs() {
  2373. this.validateForm()
  2374. .then(async () => {
  2375. // 批量获取包装编码并处理
  2376. let packingCodePrams = this.productList.map((row) => {
  2377. // 判断单位和计量单位是否为不拆物料层规格
  2378. let packingBoolen = !!this.getDict(
  2379. '不拆物料层规格',
  2380. row.packingUnit
  2381. ).dictValue;
  2382. let measureBoolen = !!this.getDict(
  2383. '不拆物料层规格',
  2384. row.measureUnit
  2385. ).dictValue;
  2386. let num = 0;
  2387. if (packingBoolen) {
  2388. let filterArr = row.packingSpecificationOption.filter(
  2389. (item) => {
  2390. return (
  2391. item.packageUnit == row.packingUnit &&
  2392. item.packageUnit != item.conversionUnit
  2393. );
  2394. }
  2395. );
  2396. num = Math.ceil(row.packingQuantity / filterArr[0].packageCell);
  2397. }
  2398. if (row.isSave) {
  2399. return {};
  2400. } else {
  2401. // 处理单位为KG类的情况
  2402. if (packingBoolen) {
  2403. return {
  2404. assetCode: row.categoryCode + row.index,
  2405. batchNum: row.batchNo,
  2406. num
  2407. };
  2408. } else {
  2409. if (row.isUnpack == 1) {
  2410. if (measureBoolen) {
  2411. // 处理单位不为KG类,计量单位为KG类的情况
  2412. let num = row.packingQuantity;
  2413. let splitIndex = row.packingSpecificationOption.findIndex(
  2414. (item) =>
  2415. item.conversionUnit == row.packingUnit &&
  2416. item.packageUnit != item.conversionUnit
  2417. );
  2418. for (; splitIndex > 1; splitIndex--) {
  2419. num = this.$math.format(
  2420. num *
  2421. row.packingSpecificationOption[splitIndex]
  2422. .packageCell,
  2423. 14
  2424. );
  2425. }
  2426. return {
  2427. assetCode: row.categoryCode + row.index,
  2428. batchNum: row.batchNo,
  2429. num
  2430. };
  2431. } else {
  2432. // 处理拆包到最小包装单元数量的情况
  2433. return {
  2434. assetCode: row.categoryCode + row.index,
  2435. batchNum: row.batchNo,
  2436. num: row.measureQuantity
  2437. };
  2438. }
  2439. } else {
  2440. return {
  2441. assetCode: row.categoryCode + row.index,
  2442. batchNum: row.batchNo,
  2443. num: row.packingQuantity
  2444. };
  2445. }
  2446. }
  2447. }
  2448. });
  2449. let filterPackingCodePrams = packingCodePrams.filter(
  2450. (item) => item.assetCode
  2451. );
  2452. let { data } = await storageApi.getAssetNum(filterPackingCodePrams);
  2453. let packingCodeList = [];
  2454. packingCodePrams.forEach((item, index) => {
  2455. packingCodeList[index] = data.filter(
  2456. (ite) => ite.assetCode == item.assetCode
  2457. );
  2458. });
  2459. // 批量生成包装
  2460. this.productList.map((row, index) => {
  2461. if (!row.isSave) {
  2462. this.generateWrappers(row, index, packingCodeList[index]);
  2463. this.$set(this.productList[index], 'isSave', true);
  2464. }
  2465. });
  2466. // 加载虚拟列表数据(分页)
  2467. // this.pickingFetchData();
  2468. // this.materielFetchData();
  2469. })
  2470. .catch((err) => {
  2471. console.log(err);
  2472. });
  2473. },
  2474. // 物品保存验证表单(单独)
  2475. validateFormIndividually(index) {
  2476. return new Promise(async (resolve) => {
  2477. let fileds = [
  2478. `productList.${index}.batchNo`,
  2479. `productList.${index}.packingQuantity`,
  2480. `productList.${index}.packingUnit`,
  2481. `productList.${index}.warehouseId`
  2482. ];
  2483. Promise.all(
  2484. fileds.map(
  2485. (item) =>
  2486. new Promise(async (res, rej) => {
  2487. this.$refs.productListRef.validateField(item, (err) => {
  2488. if (err) {
  2489. rej(err);
  2490. } else {
  2491. res(true);
  2492. }
  2493. });
  2494. })
  2495. )
  2496. )
  2497. .then(() => {
  2498. resolve();
  2499. })
  2500. .catch(() => {
  2501. this.$message.error('请填入必填项!');
  2502. });
  2503. });
  2504. },
  2505. // 产品编辑
  2506. listEdit(row) {
  2507. this.$set(row, 'isSave', false);
  2508. // // 重新计算重量
  2509. // const totals = Number(
  2510. // this.$math.format(row.minPackingQuantity * row.packingQuantity, 14)
  2511. // );
  2512. // if (row.measureUnit == row.weightUnit) {
  2513. // row.weight = Number(
  2514. // this.$math.format(
  2515. // row.minPackingQuantity *
  2516. // 1 *
  2517. // Number(row.packingQuantity).toFixed(2),
  2518. // 14
  2519. // )
  2520. // );
  2521. // } else {
  2522. // row.weight = Number(
  2523. // this.$math.format(
  2524. // totals *
  2525. // (row.netWeight > 0 ? Number(row.netWeight).toFixed(2) : 0),
  2526. // 14
  2527. // )
  2528. // );
  2529. // }
  2530. this.deletePackingAndMaterial(row);
  2531. },
  2532. // 根据产品信息删除包装和物料
  2533. deletePackingAndMaterial(row) {
  2534. // 删除包装(去掉不相同的包装)
  2535. this.packingList = this.packingList.filter(
  2536. (item) => item.parentIndex !== row.index
  2537. );
  2538. this.showPackingList = this.showPackingList.filter(
  2539. (item) => item.parentIndex !== row.index
  2540. );
  2541. this.pickingPageNum = Math.ceil(
  2542. this.showPackingList.length / this.pageSize
  2543. );
  2544. // 删除物料(获取相同物料)
  2545. let packingIndexs = this.packingList.map((item) => item.index);
  2546. this.materialList = this.materialList.filter((item) =>
  2547. packingIndexs.includes(item.parentIndex)
  2548. );
  2549. this.showMaterialList = this.showMaterialList.filter((item) =>
  2550. packingIndexs.includes(item.parentIndex)
  2551. );
  2552. this.materielPageNum = Math.ceil(
  2553. this.showMaterialList.length / this.pageSize
  2554. );
  2555. },
  2556. // 产品保存操作
  2557. listSave(row, index) {
  2558. this.validateFormIndividually(index).then(async () => {
  2559. // 判断单位和计量单位是否为不拆物料层规格
  2560. let packingBoolen = !!this.getDict('不拆物料层规格', row.packingUnit)
  2561. .dictValue;
  2562. let measureBoolen = !!this.getDict('不拆物料层规格', row.measureUnit)
  2563. .dictValue;
  2564. let packingNum = 0;
  2565. // 处理单位为KG类的情况
  2566. if (packingBoolen) {
  2567. let filterArr = row.packingSpecificationOption.filter((item) => {
  2568. return (
  2569. item.packageUnit == row.packingUnit &&
  2570. item.packageUnit != item.conversionUnit
  2571. );
  2572. });
  2573. packingNum = Math.ceil(
  2574. row.packingQuantity / filterArr[0].packageCell
  2575. );
  2576. }
  2577. // 处理单位不为KG类,计量单位为KG类的情况
  2578. let measureNum = row.packingQuantity;
  2579. if (measureBoolen) {
  2580. let splitIndex = row.packingSpecificationOption.findIndex(
  2581. (item) =>
  2582. item.conversionUnit == row.packingUnit &&
  2583. item.packageUnit != item.conversionUnit
  2584. );
  2585. for (; splitIndex > 1; splitIndex--) {
  2586. measureNum = this.$math.format(
  2587. measureNum *
  2588. row.packingSpecificationOption[splitIndex].packageCell,
  2589. 14
  2590. );
  2591. }
  2592. }
  2593. // 获取包装编码列表
  2594. const { data } = await storageApi.getAssetNum([
  2595. {
  2596. assetCode: row.categoryCode + row.index,
  2597. batchNum: row.batchNo,
  2598. num: packingBoolen
  2599. ? Math.floor(packingNum)
  2600. : Math.floor(row.isUnpack)
  2601. ? measureBoolen
  2602. ? Math.floor(measureNum)
  2603. : Math.floor(row.measureQuantity)
  2604. : Math.floor(row.packingQuantity)
  2605. }
  2606. ]);
  2607. this.generateWrappers(row, index, data);
  2608. this.$set(this.productList[index], 'isSave', true);
  2609. // 加载虚拟列表数据(分页)
  2610. // this.pickingFetchData();
  2611. // this.materielFetchData();
  2612. });
  2613. },
  2614. //入库明细删除
  2615. listDel(row, index) {
  2616. this.productList.splice(index, 1);
  2617. this.deletePackingAndMaterial(row);
  2618. },
  2619. // 打开仓库弹框
  2620. handleWareHouse(row, idx) {
  2621. if (row.isSave) {
  2622. return false;
  2623. }
  2624. let packingBoolen = !!this.getDict('不拆物料层规格', row.packingUnit)
  2625. .dictValue;
  2626. let measureBoolen = !!this.getDict('不拆物料层规格', row.measureUnit)
  2627. .dictValue;
  2628. if (idx > -1) {
  2629. if (row.packingQuantity > 0) {
  2630. if (packingBoolen) {
  2631. let filterArr = row.packingSpecificationOption.filter((item) => {
  2632. return (
  2633. item.packageUnit == row.packingUnit &&
  2634. item.packageUnit != item.conversionUnit
  2635. );
  2636. });
  2637. let num = Math.ceil(
  2638. row.packingQuantity / filterArr[0].packageCell
  2639. );
  2640. this.$refs.wareHouseDailogRef.open(num, idx);
  2641. } else {
  2642. let num = row.packingQuantity;
  2643. if (measureBoolen) {
  2644. let splitIndex = row.packingSpecificationOption.findIndex(
  2645. (item) =>
  2646. item.conversionUnit == row.packingUnit &&
  2647. item.packageUnit != item.conversionUnit
  2648. );
  2649. for (; splitIndex > 1; splitIndex--) {
  2650. num = this.$math.format(
  2651. num *
  2652. row.packingSpecificationOption[splitIndex].packageCell,
  2653. 14
  2654. );
  2655. }
  2656. }
  2657. this.$refs.wareHouseDailogRef.open(
  2658. row.isUnpack
  2659. ? measureBoolen
  2660. ? num
  2661. : row.measureQuantity
  2662. : row.packingQuantity,
  2663. idx
  2664. );
  2665. }
  2666. } else {
  2667. this.$message.error('请先填写包装数量!');
  2668. }
  2669. } else {
  2670. // 批量设置
  2671. let boolen = this.productList.every(
  2672. (item) =>
  2673. item.packingQuantity == this.productList[0].packingQuantity
  2674. );
  2675. if (boolen) {
  2676. if (row.packingQuantity > 0) {
  2677. if (packingBoolen) {
  2678. let filterArr = row.packingSpecificationOption.filter(
  2679. (item) => {
  2680. return (
  2681. item.packingUnit == row.packingUnit &&
  2682. item.packingUnit != item.conversionUnit
  2683. );
  2684. }
  2685. );
  2686. let num = Math.ceil(
  2687. row.packingQuantity / filterArr[0].packageCell
  2688. );
  2689. this.$refs.wareHouseDailogRef.open(num, idx);
  2690. } else {
  2691. this.$refs.wareHouseDailogRef.open(
  2692. row.isUnpack
  2693. ? measureBoolen
  2694. ? row.packingQuantity
  2695. : row.measureQuantity
  2696. : row.packingQuantity,
  2697. idx
  2698. );
  2699. }
  2700. } else {
  2701. this.$message.error('请先填写包装数量!');
  2702. }
  2703. } else {
  2704. this.$message.error('请保证产品包装数量一致!');
  2705. }
  2706. }
  2707. },
  2708. wareHouseSelection(argum, idx) {
  2709. // 方便包装遍历获取仓库id和名称
  2710. let warehouseIds = [];
  2711. let warehouseNames = [];
  2712. argum.forEach((item) => {
  2713. for (let index = 0; index < item.packingQuantity; index++) {
  2714. warehouseIds.push(item.warehouseId);
  2715. warehouseNames.push(item.warehouseName);
  2716. }
  2717. });
  2718. if (idx > -1) {
  2719. this.$set(
  2720. this.productList[idx],
  2721. 'warehouseId',
  2722. argum.map((item) => item.warehouseId).join(',')
  2723. );
  2724. this.$set(
  2725. this.productList[idx],
  2726. 'warehouseName',
  2727. argum.map((item) => item.warehouseName).join(',')
  2728. );
  2729. this.$set(this.productList[idx], 'warehouseIds', warehouseIds);
  2730. this.$set(this.productList[idx], 'warehouseNames', warehouseNames);
  2731. } else {
  2732. this.productList.map((item, index) => {
  2733. this.$set(
  2734. this.productList[index],
  2735. 'warehouseId',
  2736. argum.map((item) => item.warehouseId).join(',')
  2737. );
  2738. this.$set(
  2739. this.productList[index],
  2740. 'warehouseName',
  2741. argum.map((item) => item.warehouseName).join(',')
  2742. );
  2743. this.$set(this.productList[index], 'warehouseIds', warehouseIds);
  2744. this.$set(
  2745. this.productList[index],
  2746. 'warehouseNames',
  2747. warehouseNames
  2748. );
  2749. });
  2750. }
  2751. this.$forceUpdate();
  2752. },
  2753. // 生成包装
  2754. generateWrappers(row, productIndex, packingCodeList) {
  2755. let packingList = [];
  2756. let obj = this.getNowDate();
  2757. let productionDate = '';
  2758. let purchaseDate = '';
  2759. if (this.formData.bizType == '1') {
  2760. // 生产入库
  2761. productionDate = `${obj.year}-${obj.month}-${obj.strDate} ${obj.hour}:${obj.minute}:${obj.second}`;
  2762. this.curDateType = 'productionDate';
  2763. } else if (this.formData.bizType == '2') {
  2764. // 采购入库
  2765. // purchaseDate = `${obj.year}-${obj.month}-${obj.strDate} ${obj.hour}:${obj.minute}:${obj.second}`;
  2766. purchaseDate = this.formData.storageTime;
  2767. this.curDateType = 'purchaseDate';
  2768. }
  2769. // 判断单位和计量单位是否为不拆物料层规格
  2770. let packingBoolen = !!this.getDict('不拆物料层规格', row.packingUnit)
  2771. .dictValue;
  2772. let measureBoolen = !!this.getDict('不拆物料层规格', row.measureUnit)
  2773. .dictValue;
  2774. let num = row.packingQuantity;
  2775. let filterArr = [];
  2776. // 处理单位为KG类的情况
  2777. if (packingBoolen) {
  2778. filterArr = row.packingSpecificationOption.filter((item) => {
  2779. return (
  2780. item.packageUnit == row.packingUnit &&
  2781. item.packageUnit != item.conversionUnit
  2782. );
  2783. });
  2784. num = Math.ceil(row.packingQuantity / filterArr[0].packageCell);
  2785. } else {
  2786. if (row.isUnpack == 1) {
  2787. if (measureBoolen) {
  2788. // 处理单位不为KG类,计量单位为KG类的情况
  2789. let splitIndex = row.packingSpecificationOption.findIndex(
  2790. (item) =>
  2791. item.conversionUnit == row.packingUnit &&
  2792. item.packageUnit != item.conversionUnit
  2793. );
  2794. for (; splitIndex > 1; splitIndex--) {
  2795. num = this.$math.format(
  2796. num * row.packingSpecificationOption[splitIndex].packageCell,
  2797. 14
  2798. );
  2799. }
  2800. } else {
  2801. let splitIndex = row.packingSpecificationOption.findIndex(
  2802. (item) =>
  2803. item.conversionUnit == row.packingUnit &&
  2804. item.packageUnit != item.conversionUnit
  2805. );
  2806. for (; splitIndex > 0; splitIndex--) {
  2807. num = this.$math.format(
  2808. num * row.packingSpecificationOption[splitIndex].packageCell,
  2809. 14
  2810. );
  2811. }
  2812. }
  2813. } else {
  2814. // num = row.packingQuantity;
  2815. num = this.productList.length;
  2816. }
  2817. }
  2818. for (let index = 0; index < num; index++) {
  2819. let measureQuantity = 1;
  2820. // 处理单位为KG类,计算每桶KG值
  2821. if (packingBoolen) {
  2822. measureQuantity =
  2823. Number(row.packingQuantity) >
  2824. this.$math.format(filterArr[0].packageCell * (index + 1), 14)
  2825. ? filterArr[0].packageCell
  2826. : Number(row.packingQuantity) -
  2827. this.$math.format(filterArr[0].packageCell * index, 14);
  2828. } else {
  2829. if (row.isUnpack == 1) {
  2830. if (measureBoolen) {
  2831. // 处理单位不为KG类,计量单位为KG类的情况
  2832. let splitIndex = row.packingSpecificationOption.findIndex(
  2833. (item) =>
  2834. item.conversionUnit == row.packingUnit &&
  2835. item.packageUnit != item.conversionUnit
  2836. );
  2837. for (; splitIndex > 0; splitIndex--) {
  2838. measureQuantity = this.$math.format(
  2839. measureQuantity *
  2840. row.packingSpecificationOption[splitIndex].packageCell,
  2841. 14
  2842. );
  2843. }
  2844. } else {
  2845. let splitIndex = row.packingSpecificationOption.findIndex(
  2846. (item) =>
  2847. item.conversionUnit == row.packingUnit &&
  2848. item.packageUnit != item.conversionUnit
  2849. );
  2850. for (; splitIndex > 0; splitIndex--) {
  2851. measureQuantity = this.$math.format(
  2852. measureQuantity *
  2853. row.packingSpecificationOption[splitIndex].packageCell,
  2854. 14
  2855. );
  2856. }
  2857. }
  2858. } else {
  2859. measureQuantity = row.measureQuantity;
  2860. }
  2861. }
  2862. let item = {
  2863. index: row.index + '-' + index, // 包装索引
  2864. warehouseId: row.warehouseIds[index], // 仓库id
  2865. warehouseName: row.warehouseNames[index], // 仓库名称
  2866. categoryName: row.categoryName, // 产品名称
  2867. categoryCode: row.categoryCode, // 产品编码
  2868. categoryModel: row.categoryModel, // 物品型号
  2869. specification: row.specification, // 规格
  2870. brandNum: row.brandNum, // 牌号
  2871. parentIndex: row.index, // 产品索引
  2872. batchNo: row.batchNo, // 批次号
  2873. packageNo: packingCodeList[index]?.onlyCode, // 包装编码
  2874. packingQuantity: 1, // 包装数量
  2875. packingUnit:
  2876. row.isUnpack == 1
  2877. ? packingBoolen
  2878. ? filterArr[0].conversionUnit
  2879. : measureBoolen
  2880. ? row.packingSpecificationOption[1]
  2881. ? row.packingSpecificationOption[1].conversionUnit
  2882. : row.packingSpecificationOption[0].conversionUnit
  2883. : row.measureUnit
  2884. : packingBoolen
  2885. ? filterArr[0].conversionUnit
  2886. : row.packingUnit,
  2887. measureQuantity:
  2888. row.isUnpack == 1
  2889. ? packingBoolen
  2890. ? measureQuantity
  2891. : measureBoolen
  2892. ? row.packingSpecificationOption[1]
  2893. ? row.packingSpecificationOption[1].packageCell
  2894. : row.packingSpecificationOption[0].packageCell
  2895. : measureQuantity
  2896. : measureQuantity, // 计量数量
  2897. measureUnit:
  2898. row.isUnpack == 1
  2899. ? measureBoolen
  2900. ? row.packingSpecificationOption[1]
  2901. ? row.packingSpecificationOption[1].packageUnit
  2902. : row.packingSpecificationOption[0].packageUnit
  2903. : row.measureUnit
  2904. : row.measureUnit, // 计量单位
  2905. weight: 0, // 重量
  2906. singleWeight: 0, // 单重
  2907. packingSpecificationOption: row.packingSpecificationOption, // 包装规格
  2908. weightUnit: row.weightUnit, // 重量单位
  2909. netWeight: row.netWeight, // 净重
  2910. barcodes: '', // 发货条码
  2911. clientCode: '', // 客户代号
  2912. materielDesignation: '', // 物料代号
  2913. engrave: '', // 刻码
  2914. isUnpack: row.isUnpack, // 是否允许拆包
  2915. productionDate: productionDate, // 生产日期
  2916. purchaseDate: purchaseDate, // 采购时间
  2917. result: this.formData.bizType == 2 && this.form.isQmsCheck ? 0 : 1, // 结果(0无 1合格 2不合格) 是否质检isQmsCheck(0否 1是) bizType(2采购入库)
  2918. status: this.formData.bizType == 2 && this.form.isQmsCheck ? 0 : 2 // 状态(0未质检 1待检 2已质检)
  2919. };
  2920. let outBoolen = !!this.getDict('不拆物料层规格', item.measureUnit)
  2921. .dictValue;
  2922. if (outBoolen) {
  2923. // 计量单位为KG类,直接替换
  2924. item.weight = item.measureQuantity;
  2925. } else {
  2926. // 计量单位为不为KG类,重新统计计算
  2927. let inBoolen = !!this.getDict(
  2928. '不拆物料层规格',
  2929. item.packingSpecificationOption[0].packageUnit
  2930. ).dictValue;
  2931. let startIndex = item.packingSpecificationOption.findIndex(
  2932. (ite) => {
  2933. return (
  2934. item.measureUnit == ite.packingUnit &&
  2935. ite.packingUnit != ite.conversionUnit
  2936. );
  2937. }
  2938. );
  2939. let endIndex = item.packingSpecificationOption.findIndex(
  2940. (ite) => item.packingUnit == ite.conversionUnit
  2941. );
  2942. if (measureBoolen) {
  2943. let total = item.packingQuantity;
  2944. for (; startIndex < endIndex; endIndex--) {
  2945. total = this.$math.format(
  2946. item.packingSpecificationOption[endIndex].packageCell * total,
  2947. 14
  2948. );
  2949. }
  2950. if (inBoolen) {
  2951. // 第二层为KG类
  2952. item.weight = total;
  2953. } else {
  2954. // 第二层不为KG类
  2955. item.weight = this.$math.format(total * item.netWeight, 14);
  2956. }
  2957. } else if (!measureBoolen) {
  2958. if (inBoolen) {
  2959. // 第二层为KG类
  2960. item.weight = item.measureQuantity;
  2961. } else {
  2962. // 第二层不为KG类
  2963. item.weight = item.measureQuantity * row.singleWeight;
  2964. }
  2965. }
  2966. }
  2967. packingList.push(item);
  2968. }
  2969. // 单独点击保存并插入对应位置(包装)
  2970. if (productIndex == 0) {
  2971. this.packingList.splice(productIndex, 0, ...packingList);
  2972. } else {
  2973. let packingIndex = this.packingList.findLastIndex(
  2974. (item) =>
  2975. item.parentIndex == this.productList[productIndex - 1].index
  2976. );
  2977. this.packingList.splice(packingIndex + 1, 0, ...packingList);
  2978. }
  2979. // 单独点击保存并插入对应位置(物料)
  2980. // let materialList = packingList
  2981. // .map((item) => {
  2982. // if (item.isUnpack) {
  2983. // return this.generateMaterial(item);
  2984. // } else {
  2985. // return [];
  2986. // }
  2987. // })
  2988. // .flat();
  2989. // console.log(materialList);
  2990. // if (materialList.length > 0) {
  2991. // if (productIndex == 0) {
  2992. // this.materialList.splice(0, 0, ...materialList);
  2993. // } else {
  2994. // let preLastPackingIndex = this.packingList.findLastIndex((ite) => {
  2995. // return ite.parentIndex <= productIndex - 1 && ite.isUnpack;
  2996. // });
  2997. // let preLastMaterialIndex = this.materialList.findLastIndex(
  2998. // (ite) => {
  2999. // return (
  3000. // ite.parentIndex == this.packingList[preLastPackingIndex].index
  3001. // );
  3002. // }
  3003. // );
  3004. // this.materialList.splice(
  3005. // preLastMaterialIndex + 1,
  3006. // 0,
  3007. // ...materialList
  3008. // );
  3009. // }
  3010. // }
  3011. },
  3012. // 生成物料
  3013. generateMaterial(row) {
  3014. let materialList = [];
  3015. for (let index = 0; index < row.measureQuantity; index++) {
  3016. materialList.push({
  3017. materialCode: row.packageNo + index.toString().padStart(4, '0'), // 物料编码
  3018. index: row.index + '——' + index, // 包装索引
  3019. warehouseId: row.warehouseId, // 仓库id
  3020. warehouseName: row.warehouseName, // 仓库名称
  3021. categoryName: row.categoryName, // 产品名称
  3022. categoryCode: row.categoryCode, // 产品编码
  3023. parentIndex: row.index, // 产品索引
  3024. batchNo: row.batchNo, // 批次号
  3025. packageNo: row.packageNo, // 包装编码
  3026. measureQuantity: 1, // 计量数量
  3027. measureUnit: row.measureUnit, // 计量单位
  3028. weight: Number(
  3029. this.$math.format(row.weight / row.packingQuantity, 14)
  3030. ), // 重量
  3031. weightUnit: row.weightUnit, // 重量单位
  3032. barcodes: '', // 发货条码
  3033. clientCode: '', // 客户代号
  3034. materielDesignation: '', // 物料代号
  3035. engrave: '', // 刻码
  3036. result: 1, // 结果(1合格 2不合格 3让步接收)
  3037. status: 2 // 状态(0=未质检 1待检 2已检)
  3038. });
  3039. }
  3040. return materialList;
  3041. },
  3042. // 设置时间
  3043. dateSetting() {
  3044. if (!this.packingListSelected.length) {
  3045. return this.$message.error(`请选择${this.title}明细!`);
  3046. }
  3047. this.dateVisible = true;
  3048. },
  3049. // 选择包装列表
  3050. handleSelectionChange(val) {
  3051. this.packingListSelected = val;
  3052. },
  3053. // 选择质检结果改变质检状态
  3054. changeWrapStatus(resultValue, row, type) {
  3055. switch (resultValue) {
  3056. case 0:
  3057. // 清空质检状态
  3058. row.status = 0;
  3059. break;
  3060. default:
  3061. // 默认已检质检状态
  3062. row.status = 2;
  3063. break;
  3064. }
  3065. if (type === '包装') {
  3066. this.packingResultCahnge(resultValue, row);
  3067. } else {
  3068. this.materialResultCahnge(resultValue, row);
  3069. }
  3070. }
  3071. }
  3072. };
  3073. </script>
  3074. <style lang="scss" scoped>
  3075. .inbound_details {
  3076. margin-top: 10px;
  3077. .el-form-item {
  3078. margin-bottom: 0 !important;
  3079. }
  3080. }
  3081. .right_control {
  3082. display: flex;
  3083. > button {
  3084. margin-left: 20px;
  3085. }
  3086. }
  3087. .storage_btn {
  3088. margin-top: 20px;
  3089. display: flex;
  3090. align-content: center;
  3091. justify-content: center;
  3092. }
  3093. .el-date-editor.el-input,
  3094. .el-date-editor.el-input__inner {
  3095. width: 100% !important;
  3096. }
  3097. .red_color {
  3098. color: red;
  3099. }
  3100. .wareHouse_style {
  3101. text-overflow: ellipsis;
  3102. overflow: hidden;
  3103. word-break: break-all;
  3104. white-space: nowrap;
  3105. }
  3106. </style>