procurementWarehousing.vue 108 KB

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