procurementWarehousing.vue 109 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146
  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. if (this.$refs[keyfield[0] + (index + 1)].value == 0) {
  1356. this.$refs[keyfield[0] + (index + 1)].value = '';
  1357. }
  1358. this.$refs[keyfield[0] + (index + 1)].focus();
  1359. } else {
  1360. // 跳转下一个
  1361. const nextkeyindex = keyfield.findIndex((k) => k === key) + 1;
  1362. this.$nextTick(() => {
  1363. if (this.$refs[keyfield[nextkeyindex] + index].value == 0) {
  1364. this.$refs[keyfield[nextkeyindex] + index].value = '';
  1365. }
  1366. this.$refs[keyfield[nextkeyindex] + index].focus();
  1367. });
  1368. }
  1369. }
  1370. // 向上 =38
  1371. if (event.keyCode === 38) {
  1372. console.log('向上');
  1373. if (index === 0) {
  1374. // 第一行
  1375. console.log('第一行无法向上');
  1376. return;
  1377. }
  1378. this.$refs[key + index].blur();
  1379. this.$nextTick(() => {
  1380. if (this.$refs[key + (index - 1)].value == 0) {
  1381. this.$refs[key + (index - 1)].value = '';
  1382. }
  1383. this.$refs[key + (index - 1)].focus();
  1384. });
  1385. }
  1386. // 下 = 40
  1387. if (event.keyCode === 40) {
  1388. console.log('向下');
  1389. if (index === listLength - 1) {
  1390. // 最后一行
  1391. console.log('最后一行无法向下');
  1392. return;
  1393. }
  1394. this.$refs[key + index].blur();
  1395. this.$nextTick(() => {
  1396. if (this.$refs[key + (index + 1)].value == 0) {
  1397. this.$refs[key + (index + 1)].value = '';
  1398. }
  1399. this.$refs[key + (index + 1)].focus();
  1400. });
  1401. }
  1402. // 左 = 37
  1403. if (event.keyCode === 37) {
  1404. console.log('向左');
  1405. if (index === 0 && key === keyfield[0]) {
  1406. // 第一行第一个
  1407. console.log('第一行第一个无法向左');
  1408. return;
  1409. }
  1410. this.$refs[key + index].blur();
  1411. if (key === keyfield[0]) {
  1412. if (
  1413. this.$refs[keyfield[keyfield.length - 1] + (index - 1)].value == 0
  1414. ) {
  1415. this.$refs[keyfield[keyfield.length - 1] + (index - 1)].value =
  1416. '';
  1417. }
  1418. // 当前行第一个,跳转上一行最后一个
  1419. this.$refs[keyfield[keyfield.length - 1] + (index - 1)].focus();
  1420. } else {
  1421. // 跳转上一个
  1422. const prevkeyindex = keyfield.findIndex((k) => k === key) - 1;
  1423. this.$nextTick(() => {
  1424. if (this.$refs[keyfield[prevkeyindex] + index].value == 0) {
  1425. this.$refs[keyfield[prevkeyindex] + index].value = '';
  1426. }
  1427. this.$refs[keyfield[prevkeyindex] + index].focus();
  1428. });
  1429. }
  1430. }
  1431. // 右 = 39
  1432. if (event.keyCode === 39) {
  1433. console.log('向右');
  1434. if (
  1435. index === listLength - 1 &&
  1436. key === keyfield[keyfield.length - 1]
  1437. ) {
  1438. // 最后一行最后一个
  1439. console.log('最后一行最后一个无法向左');
  1440. return;
  1441. }
  1442. this.$refs[key + index].blur();
  1443. if (key === keyfield[keyfield.length - 1]) {
  1444. // 当前行最后一个,跳转下一行第一个
  1445. if (this.$refs[keyfield[0] + (index + 1)].value == 0) {
  1446. this.$refs[keyfield[0] + (index + 1)].value = '';
  1447. }
  1448. this.$refs[keyfield[0] + (index + 1)].focus();
  1449. } else {
  1450. // 跳转下一个
  1451. const nextkeyindex = keyfield.findIndex((k) => k === key) + 1;
  1452. this.$nextTick(() => {
  1453. if (this.$refs[keyfield[nextkeyindex] + index].value == 0) {
  1454. this.$refs[keyfield[nextkeyindex] + index].value = '';
  1455. }
  1456. this.$refs[keyfield[nextkeyindex] + index].focus();
  1457. });
  1458. }
  1459. }
  1460. },
  1461. //获取回执附件
  1462. getQualityFile() {
  1463. return { qualityFile: this.qualityFile, id: this.formData.id };
  1464. },
  1465. //获取质检状态(全部已检)
  1466. getStatus() {
  1467. if (this.resultArray.length > 0) {
  1468. let metailAllChecked = this.materialCodeReqListOrStorage.every(
  1469. (item) => item.status == 1
  1470. );
  1471. let resultAllChecked = this.resultArray.every(
  1472. (item) => item.status == 1
  1473. );
  1474. if (metailAllChecked && resultAllChecked) {
  1475. if (this.taskDefinitionKey === 'qualityInspection') {
  1476. // 物料批量保存
  1477. return this.materialListSave()
  1478. .then(() => {
  1479. return true;
  1480. })
  1481. .catch(() => {
  1482. return false;
  1483. });
  1484. } else {
  1485. return true;
  1486. }
  1487. } else {
  1488. return false;
  1489. }
  1490. } else {
  1491. let boolen = this.materialCodeReqListOrStorage.every(
  1492. (item) => item.status == 1
  1493. );
  1494. if (boolen) {
  1495. if (this.taskDefinitionKey === 'qualityInspection') {
  1496. // 包装批量保存
  1497. return this.wrapListSave()
  1498. .then(() => {
  1499. return true;
  1500. })
  1501. .catch(() => {
  1502. return false;
  1503. });
  1504. } else {
  1505. return true;
  1506. }
  1507. } else {
  1508. return false;
  1509. }
  1510. }
  1511. },
  1512. getSceneState: useDictLabel(sceneState),
  1513. // 物料批量保存
  1514. materialListSave() {
  1515. return new Promise((resolve, reject) => {
  1516. let boolen = this.resultArray.every((item) => item.status == 1);
  1517. console.log(boolen);
  1518. if (boolen) {
  1519. console.log(this.resultArray);
  1520. this.resultArray.forEach((item, index) => {
  1521. if (!item.isPack) {
  1522. console.log(item);
  1523. this.materialBtn(item, index, true);
  1524. }
  1525. });
  1526. // 更新数据
  1527. this.initFormData()
  1528. .then(() => {
  1529. this.resultArray.forEach((item) => {
  1530. if (!item.isPack) {
  1531. item.isPack = true;
  1532. }
  1533. // 生产性采购审核
  1534. this.$nextTick(() => {
  1535. if (this.taskDefinitionKey === 'qualityInspection') {
  1536. this.isWrapTable = false;
  1537. this.isMaterialTable = false;
  1538. this.$nextTick(() => {
  1539. this.isWrapTable = true;
  1540. this.isMaterialTable = true;
  1541. });
  1542. }
  1543. });
  1544. resolve();
  1545. });
  1546. })
  1547. .catch(() => {
  1548. reject();
  1549. });
  1550. } else {
  1551. this.$message.error('请选择质检结果');
  1552. }
  1553. });
  1554. },
  1555. // 格式化数据并更新(用于质检员批量质检)
  1556. initFormData() {
  1557. return new Promise(async (resolve, reject) => {
  1558. console.log(this.warehousingMaterialList);
  1559. console.log(this.materialCodeReqListOrStorage);
  1560. console.log(this.resultArray);
  1561. this.warehousingMaterialList.forEach((goodsItem) => {
  1562. goodsItem.outInDetailRecordUpdatePOList =
  1563. this.materialCodeReqListOrStorage.filter(
  1564. (wrapItem) =>
  1565. goodsItem.assetCode == wrapItem.assetCode &&
  1566. goodsItem.batchNo == wrapItem.batchNo
  1567. );
  1568. });
  1569. this.warehousingMaterialList.forEach((goodsItem) => {
  1570. goodsItem.outInDetailRecordUpdatePOList.forEach((wrapItem) => {
  1571. wrapItem.materialDetails = this.resultArray.filter(
  1572. (metialItem) => metialItem.onlyCode == wrapItem.code
  1573. );
  1574. });
  1575. });
  1576. console.log(this.warehousingMaterialList);
  1577. const res = await outin.updateOutIn(this.warehousingMaterialList);
  1578. console.log(res);
  1579. if (res.code == 0) {
  1580. this.$message.success('保存成功');
  1581. resolve();
  1582. } else {
  1583. this.$message.success('保存失败');
  1584. reject();
  1585. }
  1586. });
  1587. },
  1588. async initData() {
  1589. const batchNo = await getCode('lot_number_code'); // 生成批次号编码
  1590. // 根据编码获取物品类别信息详情
  1591. this.formData.sourceBizNo = this.infoData.receiveNo; // 来源单号
  1592. this.formData.extInfo.assetType = this.infoData.categoryLevelTopId; // 入库物品类型
  1593. this.formData.bizType = '2'; // 入库场景(销售入库)
  1594. this.formData.type = '1'; // 出入库类型 2出库 1入库
  1595. this.formData.extInfo.deptName = this.user.info.deptName; // 权属部门
  1596. this.formData.extInfo.deptCode = this.user.info.deptIds[0]; // 权属部门id
  1597. this.formData.extInfo.createUserName = this.user.info.name; // 入库登记人
  1598. this.formData.extInfo.supplierName = this.infoData.supplierName; // 供应商
  1599. this.formData.extInfo.contentImage = []; // 内容图片地址URL
  1600. this.formData.extInfo.deliveryPhone = ''; // 送货人联系方式
  1601. this.formData.fromUser = ''; // 送货人
  1602. this.formData.bizStatus = 1; // ??未知参数
  1603. this.formData.warehouseLedgerDetails = []; // ??未知参数
  1604. this.formData.remark = ''; // 备注
  1605. // this.formData.extInfo.documentSource = this.infoData.receiveNo // 销售订单
  1606. // this.formData.createTime = '' // 入库时间
  1607. // this.formData.verifyStatus = '' // 状态
  1608. // this.formData.verifyName = '' // 审核人
  1609. // this.formData.clientName = '' // 客户
  1610. // 添加物品明细
  1611. if (this.infoData.productList?.length > 0) {
  1612. this.infoData.productList.forEach(async (item) => {
  1613. let goodsInfo = await getByCode(item.productCode);
  1614. console.log(goodsInfo);
  1615. let obj = {};
  1616. obj.assetCode = item.productCode; // 编码
  1617. obj.assetName = item.productName; // 名称
  1618. obj.modelType = item.modelType; // 型号
  1619. obj.specification = item.specification; // 规格
  1620. obj.categoryId = goodsInfo.id; // 类别id
  1621. obj.brandNum = item.productBrand; // 牌号
  1622. obj.manualBatchNo = item.manualBatchNo;
  1623. obj.batchNo = batchNo; // 批次号
  1624. obj.minPackingCount = ''; // 最小包装单元
  1625. obj.measuringUnit = item.measuringUnit; // 包装单位
  1626. obj.minPackUnit = goodsInfo.packingUnit; // 最小包装单位
  1627. obj.outInNum = ''; // 包装数量
  1628. obj.weight = ''; // 重量
  1629. obj.weightUnit = goodsInfo.weightUnit; // 重量单位
  1630. obj.univalence = item.singlePrice; // 单价
  1631. obj.netWeight = goodsInfo.netWeight; // 净重
  1632. obj.warehouseId = ''; // 仓库id
  1633. obj.houseList = []; // 仓库信息(用户显示)
  1634. this.warehousingMaterialList.push(obj);
  1635. });
  1636. }
  1637. },
  1638. // 获取入库产品类型列表
  1639. async getAssetTypeList() {
  1640. const { data } = await allCategoryLevel();
  1641. this.codeList = data.map((item) => {
  1642. return { dictCode: item.id, dictValue: item.name };
  1643. });
  1644. },
  1645. // 获取入库产品类型
  1646. handleAssetType(r) {
  1647. const code = this.codeList.find((item) => item.dictCode == r);
  1648. return code?.dictValue;
  1649. },
  1650. getAuditStatus: useDictLabel(auditStatus),
  1651. // 包装维度最小包装单元改变——>总重量
  1652. minPackingCountChange(row, value) {
  1653. if (value >= 0) {
  1654. row.minPackingCount = value;
  1655. } else {
  1656. row.minPackingCount = 0;
  1657. }
  1658. // row.minPackingCount = value.replace(/^(0+)|[^\d]+/g, '');
  1659. if (row.outInNum > 0 && value > 0) {
  1660. this.packNum(row, row.outInNum);
  1661. }
  1662. },
  1663. // 选择质检结果改变质检状态
  1664. changeWrapStatus(resultValue, row) {
  1665. switch (resultValue) {
  1666. case '':
  1667. // 清空质检状态
  1668. row.status = '0';
  1669. break;
  1670. default:
  1671. // 默认已检质检状态
  1672. row.status = '1';
  1673. break;
  1674. }
  1675. },
  1676. cancel() {
  1677. this.$emit('cancel');
  1678. },
  1679. weightInput(value, row) {
  1680. const newValue = value.replace(/[^\d.]/g, ''); // 保留数字和小数点
  1681. const decimalCount = (newValue.match(/\./g) || []).length; // 计算小数点的个数
  1682. if (decimalCount > 1) {
  1683. // 如果小数点个数大于1,移除多余的小数点
  1684. const lastIndex = newValue.lastIndexOf('.');
  1685. row.weight =
  1686. newValue.slice(0, lastIndex) + newValue.slice(lastIndex + 1);
  1687. } else if (decimalCount === 1) {
  1688. // 如果小数点个数等于1,允许小数点的输入
  1689. row.weight = newValue;
  1690. } else {
  1691. row.weight = newValue === '' ? 0 : parseFloat(newValue); // 如果输入为空,则设为0
  1692. }
  1693. },
  1694. // 包装批量保存
  1695. wrapListSave() {
  1696. return new Promise((resolve, reject) => {
  1697. let materialCodeReqList = [];
  1698. // 生产性入库没入库用materialCodeReqList字段
  1699. if (
  1700. this.taskDefinitionKey === 'qualityInspection' &&
  1701. this.isStorage
  1702. ) {
  1703. materialCodeReqList = this.materialCodeReqListOrStorage;
  1704. } else {
  1705. materialCodeReqList = this.materialCodeReqList;
  1706. }
  1707. let boolen = materialCodeReqList.every((item) => item.status == 1);
  1708. if (boolen) {
  1709. // 批量修改包装明细
  1710. this.bulkEditingWrap(true);
  1711. this.$nextTick(() => {
  1712. // 更新数据
  1713. this.initFormData()
  1714. .then(() => {
  1715. // 批量修改包装明细列表状态(已保存)
  1716. this.materialCodeReqListOrStorage.forEach((item) => {
  1717. if (!item.isPack) {
  1718. item.isPack = true;
  1719. }
  1720. });
  1721. this.$nextTick(() => {
  1722. this.isWeight = false;
  1723. this.isWrapTable = false;
  1724. this.$nextTick(() => {
  1725. this.isWeight = true;
  1726. this.isWrapTable = true;
  1727. });
  1728. });
  1729. resolve();
  1730. })
  1731. .catch(() => {
  1732. reject();
  1733. });
  1734. });
  1735. } else {
  1736. this.$message.error('请选择质检结果');
  1737. }
  1738. });
  1739. },
  1740. handleIsDetail(event) {
  1741. this.isSplit = event;
  1742. const list = this.materialCodeReqList;
  1743. if (event) {
  1744. let resultArray = [];
  1745. list.forEach((item) => {
  1746. // 包装维度改成已保存状态
  1747. item.isPack = true;
  1748. // 拆分物料维度并生成列表
  1749. for (let i = 1; i <= Number(item.minPackingCount); i++) {
  1750. resultArray.push({
  1751. onlyCode: item.onlyCode,
  1752. no: item.onlyCode + i.toString().padStart(4, '0'),
  1753. assetCode: item.assetCode,
  1754. assetName: item.assetName,
  1755. manualBatchNo: item.manualBatchNo,
  1756. batchNo: item.batchNo,
  1757. minPackingCount: 1,
  1758. measuringUnit: item.measuringUnit,
  1759. materielCode: item.materielCode,
  1760. clientCode: item.clientCode,
  1761. weight: this.$math.format(
  1762. item.weight / Number(item.minPackingCount),
  1763. 14
  1764. ),
  1765. initWeight: this.$math.format(
  1766. item.weight / Number(item.minPackingCount),
  1767. 14
  1768. ),
  1769. weightUnit: item.weightUnit,
  1770. engrave: item.engrave,
  1771. result: item.result,
  1772. status: item.status,
  1773. isPack: false
  1774. });
  1775. }
  1776. });
  1777. this.resultArray = resultArray;
  1778. console.log(this.materialCodeReqList);
  1779. console.log(this.resultArray);
  1780. // 批量修改包装明细
  1781. this.isWeight = false;
  1782. this.bulkEditingWrap();
  1783. this.$nextTick(() => {
  1784. this.isWeight = true;
  1785. });
  1786. } else {
  1787. // 包装维度改成编辑状态
  1788. list.forEach((item) => {
  1789. item.isPack = false;
  1790. });
  1791. // 清空物料维度列表
  1792. this.resultArray = [];
  1793. }
  1794. },
  1795. //包装明细保存
  1796. packCout(row) {
  1797. // 生产性质检必须已检才能通过
  1798. if (
  1799. this.taskDefinitionKey === 'qualityInspection' &&
  1800. row.status != '1'
  1801. ) {
  1802. this.$message.error('请选择质检结果');
  1803. return false;
  1804. }
  1805. //true保存==》反之
  1806. if (!row.isPack) {
  1807. const code = row.assetCode;
  1808. const batchNo = row.batchNo;
  1809. //做防护,防止weight字符串类型
  1810. this.materialCodeReqList.forEach((ele) => {
  1811. ele.weight = Number(ele.weight);
  1812. });
  1813. // const count = this.materialCodeReqList.reduce(
  1814. // (acc, curr) => acc + curr.weight,
  1815. // 0
  1816. // );
  1817. let materialCodeReqList = [];
  1818. // 生产性入库没入库用materialCodeReqList字段
  1819. if (
  1820. this.taskDefinitionKey === 'qualityInspection' &&
  1821. this.isStorage
  1822. ) {
  1823. materialCodeReqList = this.materialCodeReqListOrStorage;
  1824. } else {
  1825. materialCodeReqList = this.materialCodeReqList;
  1826. }
  1827. // 修改产品信息重量(包装维度累计)
  1828. this.isWeight = false;
  1829. row.isPack = true;
  1830. this.warehousingMaterialList.forEach((item) => {
  1831. if (item.assetCode == code && item.batchNo == batchNo) {
  1832. let arr = [];
  1833. for (const key in materialCodeReqList) {
  1834. if (
  1835. materialCodeReqList[key].assetCode == item.assetCode &&
  1836. materialCodeReqList[key].batchNo == item.batchNo
  1837. ) {
  1838. arr.push({ ...materialCodeReqList[key] });
  1839. }
  1840. }
  1841. const count = arr.reduce((acc, curr) => {
  1842. if (curr.isPack) {
  1843. this.$set(curr, 'initWeight', +curr.weight);
  1844. return Number(this.$math.format(+acc + +curr.weight, 14));
  1845. } else {
  1846. return Number(this.$math.format(+acc + +curr.initWeight, 14));
  1847. }
  1848. }, 0);
  1849. this.$set(item, 'weight', count);
  1850. }
  1851. });
  1852. row.isPack = false;
  1853. this.$nextTick(() => {
  1854. // 生产性包装保存
  1855. if (
  1856. this.taskDefinitionKey === 'qualityInspection' &&
  1857. this.isStorage
  1858. ) {
  1859. this.initFormData().then(() => {
  1860. row.isPack = true;
  1861. // 生产性采购审核
  1862. if (this.taskDefinitionKey === 'qualityInspection') {
  1863. this.isWrapTable = false;
  1864. this.$nextTick(() => {
  1865. this.isWrapTable = true;
  1866. });
  1867. }
  1868. });
  1869. }
  1870. this.isWeight = true;
  1871. });
  1872. } else {
  1873. // 生产性
  1874. if (this.taskDefinitionKey === 'qualityInspection') {
  1875. this.isWrapTable = false;
  1876. row.isPack = false;
  1877. this.$nextTick(() => {
  1878. this.isWrapTable = true;
  1879. });
  1880. } else {
  1881. row.isPack = false;
  1882. }
  1883. }
  1884. // setTimeout(() => {
  1885. // }, 100);
  1886. },
  1887. // 批量修改包装明细
  1888. bulkEditingWrap(changeEditStatus) {
  1889. let materialCodeReqList = [];
  1890. // 生产性入库没入库用materialCodeReqList字段
  1891. if (this.taskDefinitionKey === 'qualityInspection' && this.isStorage) {
  1892. materialCodeReqList = this.materialCodeReqListOrStorage;
  1893. } else {
  1894. materialCodeReqList = this.materialCodeReqList;
  1895. }
  1896. if (!changeEditStatus) {
  1897. // 批量修改包装明细列表状态(已保存)
  1898. materialCodeReqList.forEach((item) => {
  1899. item.isPack = true;
  1900. });
  1901. }
  1902. console.log(materialCodeReqList);
  1903. // 改变产品明细重量
  1904. this.warehousingMaterialList.forEach((outItem) => {
  1905. let arr = [];
  1906. materialCodeReqList.forEach((inneritem) => {
  1907. if (
  1908. inneritem.assetCode == outItem.assetCode &&
  1909. inneritem.batchNo == outItem.batchNo
  1910. ) {
  1911. arr.push(inneritem);
  1912. }
  1913. });
  1914. const count = arr.reduce((acc, curr) => {
  1915. if (curr.isPack) {
  1916. this.$set(curr, 'initWeight', +curr.weight);
  1917. return Number(this.$math.format(+acc + +curr.weight, 14));
  1918. } else {
  1919. return Number(this.$math.format(+acc + +curr.initWeight, 14));
  1920. }
  1921. }, 0);
  1922. this.$set(outItem, 'weight', count);
  1923. });
  1924. },
  1925. // 批量修改物料明细
  1926. bulkEditingMaterial() {
  1927. let materialCodeReqList = [];
  1928. // 生产性入库没入库用materialCodeReqList字段
  1929. if (this.taskDefinitionKey === 'qualityInspection' && this.isStorage) {
  1930. materialCodeReqList = this.materialCodeReqListOrStorage;
  1931. } else {
  1932. materialCodeReqList = this.materialCodeReqList;
  1933. }
  1934. // 批量修改物料明细列表状态(已保存)
  1935. this.resultArray.forEach((item) => {
  1936. item.isPack = true;
  1937. });
  1938. // 改变包装明细重量
  1939. materialCodeReqList.forEach((outItem) => {
  1940. let arr = [];
  1941. this.resultArray.forEach((inneritem) => {
  1942. if (
  1943. inneritem.assetCode == outItem.assetCode &&
  1944. inneritem.batchNo == outItem.batchNo
  1945. ) {
  1946. arr.push(inneritem);
  1947. }
  1948. });
  1949. const count = arr.reduce((acc, curr) => {
  1950. if (curr.isPack) {
  1951. this.$set(curr, 'initWeight', +curr.weight);
  1952. return Number(this.$math.format(+acc + +curr.weight, 14));
  1953. } else {
  1954. return Number(this.$math.format(+acc + +curr.initWeight, 14));
  1955. }
  1956. }, 0);
  1957. this.$set(outItem, 'weight', count);
  1958. });
  1959. },
  1960. // 物料明细保存(单独保存)
  1961. materialBtn(row, index, isLonely) {
  1962. console.log(row);
  1963. console.log(index);
  1964. console.log(this.resultArray);
  1965. console.log(this.materialCodeReqList);
  1966. // 是否单点
  1967. if (!isLonely) {
  1968. // 生产性质检必须已检才能通过
  1969. if (
  1970. this.taskDefinitionKey === 'qualityInspection' &&
  1971. row.status != '1'
  1972. ) {
  1973. this.$message.error('请选择质检结果');
  1974. return false;
  1975. }
  1976. }
  1977. let materialCodeReqList = [];
  1978. let code = 'onlyCode';
  1979. // 生产性入库没入库用materialCodeReqList字段
  1980. if (this.taskDefinitionKey === 'qualityInspection' && this.isStorage) {
  1981. materialCodeReqList = this.materialCodeReqListOrStorage;
  1982. code = 'code';
  1983. } else {
  1984. materialCodeReqList = this.materialCodeReqList;
  1985. code = 'onlyCode';
  1986. }
  1987. // true保存 false编辑
  1988. if (!row.isPack) {
  1989. // 物料维度修改质检改变包装维度质检(结果和状态)
  1990. this.materialCodeReqListOrStorage.forEach((outItem) => {
  1991. let arr = [];
  1992. this.resultArray.forEach((inneritem) => {
  1993. if (inneritem.onlyCode == outItem[code]) {
  1994. arr.push(inneritem);
  1995. }
  1996. });
  1997. console.log(arr);
  1998. // 首先判断是未填/合格不合格
  1999. let boolen = arr.every((item) => {
  2000. return (
  2001. item.result === '' ||
  2002. item.result === undefined ||
  2003. item.result === null
  2004. );
  2005. });
  2006. // 判断只要物料全部质检结果(未填)——>包装质检结果(未填) 状态(未检)
  2007. if (boolen) {
  2008. this.$set(outItem, 'result', '');
  2009. this.$set(outItem, 'status', '0');
  2010. } else {
  2011. // 判断只要物料有一个质检结果(不合格)——>包装质检结果(不合格) 状态(已检)
  2012. let boolen = arr.some((item) => {
  2013. return item.result === '1';
  2014. });
  2015. if (boolen) {
  2016. this.$set(outItem, 'result', '1');
  2017. this.$set(outItem, 'status', '1');
  2018. } else {
  2019. // 判断只要物料有一个质检结果(让步接收)——>包装质检结果(让步接收) 状态(已检)
  2020. let boolen = arr.some((item) => {
  2021. return item.result === '3';
  2022. });
  2023. if (boolen) {
  2024. // 让步接收 已检
  2025. this.$set(outItem, 'result', '3');
  2026. this.$set(outItem, 'status', '1');
  2027. } else {
  2028. // 判断只要物料有全部质检结果(合格)——>包装质检结果(合格) 状态(已检)
  2029. let boolen = arr.every((item) => {
  2030. return item.result === '0';
  2031. });
  2032. if (boolen) {
  2033. // 合格 已检
  2034. this.$set(outItem, 'result', '0');
  2035. this.$set(outItem, 'status', '1');
  2036. } else {
  2037. // 合格 部分检
  2038. this.$set(outItem, 'result', '0');
  2039. this.$set(outItem, 'status', '2');
  2040. }
  2041. }
  2042. }
  2043. }
  2044. // this.$set(outItem, 'result', boolen ? '1' : '0');
  2045. });
  2046. // 物料维度修改重量改变包装维度重量
  2047. let onlyCode = row.onlyCode;
  2048. let warpRow = {};
  2049. // 解决接口未调用成功状态不改变
  2050. row.isPack = true;
  2051. this.materialCodeReqListOrStorage.forEach((item) => {
  2052. if (item[code] === onlyCode) {
  2053. warpRow = item; // 保存当前修改包装
  2054. let arr = [];
  2055. for (const key in this.resultArray) {
  2056. if (this.resultArray[key].onlyCode == item[code]) {
  2057. arr.push(this.resultArray[key]);
  2058. }
  2059. }
  2060. const count = arr.reduce((acc, curr) => {
  2061. // 注意跟入库不一样这里取反(入库先修改状态再计算重量)
  2062. console.log(curr);
  2063. if (curr.isPack) {
  2064. this.$set(curr, 'initWeight', +curr.weight);
  2065. return Number(this.$math.format(+acc + +curr.weight, 14));
  2066. } else {
  2067. return Number(this.$math.format(+acc + +curr.initWeight, 14));
  2068. }
  2069. }, 0);
  2070. this.$set(item, 'weight', count);
  2071. }
  2072. });
  2073. // 包装维度修改重量改变产品信息
  2074. this.isWeight = false;
  2075. // 批量修改包装明细
  2076. this.bulkEditingWrap();
  2077. // 解决接口未调用成功状态不改变
  2078. row.isPack = false;
  2079. this.$nextTick(() => {
  2080. if (!isLonely) {
  2081. // 更新数据
  2082. this.initFormData().then(() => {
  2083. row.isPack = true;
  2084. // 生产性采购审核
  2085. if (this.taskDefinitionKey === 'qualityInspection') {
  2086. this.isWrapTable = false;
  2087. this.isMaterialTable = false;
  2088. this.$nextTick(() => {
  2089. this.isWrapTable = true;
  2090. this.isMaterialTable = true;
  2091. });
  2092. }
  2093. });
  2094. }
  2095. this.isWeight = true;
  2096. });
  2097. } else {
  2098. // 生产性采购审核
  2099. if (this.taskDefinitionKey === 'qualityInspection') {
  2100. this.isMaterialTable = false;
  2101. this.isWrapTable = false;
  2102. row.isPack = false;
  2103. this.$nextTick(() => {
  2104. this.isWrapTable = true;
  2105. this.isMaterialTable = true;
  2106. });
  2107. } else {
  2108. row.isPack = false;
  2109. }
  2110. }
  2111. },
  2112. packNum(row, value) {
  2113. const total = {
  2114. packingCount: Number(
  2115. row.minPackingCount > 0 ? row.minPackingCount : 0
  2116. ),
  2117. outInNum: Number(row.outInNum > 0 ? row.outInNum : 0)
  2118. };
  2119. if (row.measuringUnit == row.weightUnit) {
  2120. row.weight = Number(
  2121. this.$math.format(
  2122. total.packingCount * 1 * total.outInNum.toFixed(2),
  2123. 14
  2124. )
  2125. );
  2126. } else {
  2127. const totals = Number(
  2128. this.$math.format(total.packingCount * total.outInNum, 14)
  2129. );
  2130. row.weight = Number(
  2131. this.$math.format(
  2132. totals * (row.netWeight > 0 ? row.netWeight.toFixed(2) : 0),
  2133. 14
  2134. )
  2135. );
  2136. }
  2137. return (row.outInNum = value.replace(/^(0+)|[^\d]+/g, ''));
  2138. },
  2139. async searchContact(id) {
  2140. const data = await contactlink({ contactId: id });
  2141. this.contactList = data.data;
  2142. },
  2143. async pickerSuccess(row) {
  2144. this.formData.bizType = '2';
  2145. this.codeListValue(row.categoryLevelTopId);
  2146. this.isTask = true;
  2147. this.pickerRow = row;
  2148. this.formData.extInfo.documentSource = row.orderNo;
  2149. this.formData.sourceBizNo = row.receiveNo;
  2150. this.formData.fromId = row.id;
  2151. this.formData.clientName = row.partaName;
  2152. this.formData.clientCode = row.partaId;
  2153. this.formData.extInfo.supplierName = row.supplierName;
  2154. this.formData.extInfo.supplierId = row.supplierId;
  2155. // await this.searchContact(row.partbId);
  2156. const data = await getReceiveSaleOrderrecordDetail(row.id);
  2157. if (this.warehousingMaterialList.length == 0) {
  2158. let list = data.productList.map((item) => {
  2159. return {
  2160. ...item,
  2161. assetName: item.productName,
  2162. assetCode: item.productCode,
  2163. categoryId: item.productCategoryId,
  2164. minPackUnit: item.packingUnit
  2165. };
  2166. });
  2167. this.onSelectTableData(await this.serachMainCode(list));
  2168. }
  2169. },
  2170. async serachMainCode(arr) {
  2171. let newArr = [];
  2172. // 使用 Promise.all 来等待所有异步操作完成
  2173. await Promise.all(
  2174. arr.map(async (item) => {
  2175. const data = await getProductList({
  2176. pageNum: 1,
  2177. size: 10,
  2178. categoryLevelId: item.categoryLevelPathIdParent,
  2179. codeEq: item.assetCode
  2180. });
  2181. newArr.push(data.list); // 将结果存储到 newArr 中
  2182. })
  2183. );
  2184. let re = [];
  2185. for (const item of newArr) {
  2186. for (const it of item) {
  2187. re.push(it);
  2188. }
  2189. }
  2190. return re.map((item) => {
  2191. return {
  2192. ...item,
  2193. minPackUnit: item.packingUnit,
  2194. assetCode: item.code,
  2195. assetName: item.name
  2196. };
  2197. });
  2198. },
  2199. onClear() {
  2200. this.formData.extInfo.documentSource = '';
  2201. this.pickerRow = {};
  2202. this.formData.clientName = '';
  2203. this.formData.clientCode = '';
  2204. this.formData.extInfo.supplierName = '';
  2205. this.formData.extInfo.supplierId = '';
  2206. this.$forceUpdate();
  2207. },
  2208. handlePicker() {
  2209. this.$refs.pickerRef.open();
  2210. },
  2211. codeListValue(val) {
  2212. this.formData.extInfo.assetType = val.id || val;
  2213. this.$forceUpdate();
  2214. this.title = val?.name;
  2215. this.selectEquiType = val?.id || val;
  2216. },
  2217. //计算生产设备重量
  2218. deviceWeight(row, num) {
  2219. if (row) {
  2220. return Number(row * num);
  2221. } else {
  2222. return row;
  2223. }
  2224. },
  2225. //计算金额
  2226. calcSumTotal(PackingCount, outInNum, univalence) {
  2227. //最小包装单元,包装数量,单价
  2228. const total = {
  2229. PackingCount: Number(PackingCount),
  2230. outInNum: Number(outInNum),
  2231. univalence: Number(univalence == undefined ? 0 : univalence)
  2232. };
  2233. return total.PackingCount * total.outInNum * total.univalence;
  2234. },
  2235. handleRowUnit(row) {
  2236. return row.measuringUnit;
  2237. // if (this.formData.extInfo.assetType == 1) {
  2238. // return row.weightUnit;
  2239. // } else if (this.formData.extInfo.assetType == 4) {
  2240. // return row.measuringUnit;
  2241. // } else {
  2242. // return row.measuringUnit;
  2243. // }
  2244. },
  2245. changeVerfy(it) {
  2246. this.formData.verifyName = it.name;
  2247. },
  2248. //选择供应啥的操作
  2249. ChangeSupplier(data) {
  2250. this.formData.extInfo.supplierName = data.dictValue;
  2251. },
  2252. ChangeSuppliers(data) {
  2253. this.formData.clientName = data.dictValue;
  2254. },
  2255. rowClass({ row, column, rowIndex, columnIndex }) {
  2256. if (rowIndex === 1) {
  2257. return {
  2258. display: 'none',
  2259. background: '#EEEEEE',
  2260. border: 'none'
  2261. };
  2262. }
  2263. return { background: '#EEEEEE', border: 'none' };
  2264. },
  2265. calcSum(a, b, c, row) {
  2266. if (
  2267. (Number.isNaN(+a) && a !== '') ||
  2268. (Number.isNaN(+b) && b !== '') ||
  2269. (Number.isNaN(+c) && c !== '')
  2270. ) {
  2271. return '';
  2272. }
  2273. return a * b * c + { yuan: '元', wanyuan: '万元' }[row.univalenceUnit];
  2274. // return a * b * c;
  2275. },
  2276. // 部门 点击事件
  2277. async auditorDeptClick(data) {
  2278. this.formData.extInfo.verifyDeptCode = data?.id;
  2279. this.formData.extInfo.verifyDeptName = data?.name;
  2280. this.formData.verifyId = '';
  2281. this.formData.verifyName = '';
  2282. this.$refs.formName.validateField('verifyDeptName');
  2283. if (data) {
  2284. this.getStaffList(data);
  2285. }
  2286. },
  2287. async getStaffList(data) {
  2288. let res = await warehouseDefinition.getUserPage({
  2289. groupId: data.id,
  2290. size: 9999,
  2291. page: 1
  2292. });
  2293. this.staffList = res.list;
  2294. },
  2295. // 详情接口
  2296. // async _getInfo () {
  2297. // const res = await getInfo({ id: this.$route.query.id })
  2298. // if (res?.success) {
  2299. // this.warehousingMaterialList = res.data.warehouseLedgerInfos.map(i => {
  2300. // i.isSave = true
  2301. // return i
  2302. // })
  2303. // this.formData = res.data.outInWarehouse
  2304. // this.uploadList = this.formData.contentImage
  2305. // }
  2306. // },
  2307. chooseAssets(row, index) {
  2308. this.$refs.returnSelectRef.open(row, (res) => {
  2309. row.outInNum = res.length;
  2310. this.$set(
  2311. row,
  2312. 'selfWarehouseLedgerDetails',
  2313. res.map((i) => {
  2314. delete i.updateTime;
  2315. delete i.createTime;
  2316. return i;
  2317. })
  2318. );
  2319. });
  2320. },
  2321. // 仓库编辑
  2322. handleWareHouse(row, idx) {
  2323. this.$refs.wareHouseDailogRef.open(row, idx);
  2324. },
  2325. // 入库操作
  2326. listEdit(row) {
  2327. this.$set(row, 'isSave', false);
  2328. row.selfWarehouseLedgerDetails = row.warehouseLedgerDetails;
  2329. row.warehouseLedgerDetails = [];
  2330. // 清空物料明细防止数据错乱
  2331. this.resultArray = [];
  2332. this.isDetail = false;
  2333. },
  2334. listSave(row, index) {
  2335. const fileds = [
  2336. // `warehousingMaterialList.${index}.cargoSpaceCode`,
  2337. `warehousingMaterialList.${index}.batchNo`,
  2338. `warehousingMaterialList.${index}.houseList`
  2339. ];
  2340. if (this.formData.bizType == 1) {
  2341. // fileds.push(...[`warehousingMaterialList.${index}.customCode`]);
  2342. } else if (this.formData.bizType == 2) {
  2343. // fileds.push(...[`warehousingMaterialList.${index}.supplierCode`]);
  2344. }
  2345. if (this.formData.bizType != 5) {
  2346. fileds.push(
  2347. ...[
  2348. `warehousingMaterialList.${index}.outInNum`,
  2349. `warehousingMaterialList.${index}.minPackingCount`
  2350. ]
  2351. );
  2352. } else if (
  2353. this.warehousingMaterialList.some(
  2354. (i) => !i.selfWarehouseLedgerDetails?.length
  2355. )
  2356. ) {
  2357. this.$message.error('请选择资产编号!');
  2358. return;
  2359. }
  2360. Promise.all(
  2361. fileds.map(
  2362. (item) =>
  2363. new Promise(async (resolve, rej) => {
  2364. this.$refs.warehousingMaterialListRef.validateField(
  2365. item,
  2366. (err) => {
  2367. if (err) {
  2368. rej(err);
  2369. } else {
  2370. resolve();
  2371. }
  2372. }
  2373. );
  2374. })
  2375. )
  2376. )
  2377. .then((res) => {
  2378. this.$set(row, 'isSave', true);
  2379. if (this.formData.bizType != 5) {
  2380. this.createMaterialCode(row);
  2381. } else {
  2382. // 退还
  2383. this.createMaterialCodeReturn(row);
  2384. }
  2385. })
  2386. .catch((err) => {
  2387. this.$message.error('请填入必填项!');
  2388. });
  2389. },
  2390. listSaveArrs() {
  2391. const rows = this.warehousingMaterialList;
  2392. const indexes = Array.from(
  2393. { length: this.warehousingMaterialList.length },
  2394. (_, index) => index
  2395. );
  2396. console.log(indexes);
  2397. rows.forEach((row, i) => {
  2398. const index = indexes[i];
  2399. const fileds = [
  2400. `warehousingMaterialList.${index}.batchNo`,
  2401. `warehousingMaterialList.${index}.houseList`
  2402. ];
  2403. if (this.formData.bizType != 5) {
  2404. fileds.push(
  2405. ...[
  2406. `warehousingMaterialList.${index}.outInNum`,
  2407. `warehousingMaterialList.${index}.minPackingCount`
  2408. ]
  2409. );
  2410. } else if (
  2411. this.warehousingMaterialList.some(
  2412. (i) => !i.selfWarehouseLedgerDetails?.length
  2413. )
  2414. ) {
  2415. this.$message.error('请选择资产编号!');
  2416. return;
  2417. }
  2418. // 解决重复弹框
  2419. let showDioalog = false;
  2420. Promise.all(
  2421. fileds.map(
  2422. (item) =>
  2423. new Promise(async (resolve, rej) => {
  2424. this.$refs.warehousingMaterialListRef.validateField(
  2425. item,
  2426. (err) => {
  2427. if (err) {
  2428. rej(err);
  2429. } else {
  2430. resolve();
  2431. }
  2432. }
  2433. );
  2434. })
  2435. )
  2436. )
  2437. .then((res) => {
  2438. this.$set(row, 'isSave', true);
  2439. if (this.formData.bizType != 5) {
  2440. this.createMaterialCode(row);
  2441. } else {
  2442. // 退还
  2443. this.createMaterialCodeReturn(row);
  2444. }
  2445. })
  2446. .catch((err) => {
  2447. // this.$message.error('请填入必填项!');
  2448. if (!showDioalog) {
  2449. this.$message.error('请填入必填项!');
  2450. showDioalog = true;
  2451. }
  2452. });
  2453. });
  2454. },
  2455. // listSaveArrs() {
  2456. // console.log(this.warehousingMaterialList);
  2457. // },
  2458. // 批量设置生产日期
  2459. handleSelectionChange(val) {
  2460. this.materialCodeReqListSelected = val;
  2461. },
  2462. dateSetting() {
  2463. if (!this.materialCodeReqListSelected.length) {
  2464. return this.$message.error(`请选择${this.title}明细!`);
  2465. }
  2466. this.dateVisible = true;
  2467. },
  2468. dateConfirm() {
  2469. this.materialCodeReqListSelected.forEach((item) => {
  2470. this.$set(item, this.curDateType, this.batchTime);
  2471. });
  2472. this.dateVisible = false;
  2473. },
  2474. //入库明细删除
  2475. listDel(row, index) {
  2476. this.warehousingMaterialList.splice(index, 1);
  2477. this.resultArray = [];
  2478. this.isDetail = false;
  2479. },
  2480. // 入库明细生成条码信息
  2481. async createMaterialCode(row) {
  2482. console.log(row);
  2483. // 添加相同物品、批次号重新更新明细 原料编码
  2484. const list = this.warehousingMaterialList.filter(
  2485. (i) =>
  2486. i.assetCode === row.assetCode &&
  2487. i.batchNo === row.batchNo &&
  2488. i.isSave
  2489. );
  2490. const num = list.reduce((num, pre) => {
  2491. num += row.isUnpack
  2492. ? pre.outInNum * pre.minPackingCount
  2493. : pre.outInNum - 0;
  2494. return num;
  2495. }, 0);
  2496. const nums = list.reduce((num, pre) => {
  2497. num += pre.outInNum * pre.minPackingCount;
  2498. return num;
  2499. }, 0);
  2500. const res = await outin.getAssetNum({
  2501. assetCode: row.assetCode,
  2502. batchNum: row.batchNo,
  2503. num: num
  2504. });
  2505. // row.measuringUnit == 'PCS' ? nums :
  2506. list.forEach((item) => {
  2507. if (item.warehouseLedgerDetails?.length) {
  2508. item.warehouseLedgerDetails.forEach((i) => {
  2509. i.onlyCode = res.shift().onlyCode;
  2510. });
  2511. } else {
  2512. this.$set(
  2513. item,
  2514. 'warehouseLedgerDetails',
  2515. Array.from(
  2516. new Array(
  2517. item.isUnpack
  2518. ? item.outInNum * item.minPackingCount
  2519. : // : item.measuringUnit == 'PCS'
  2520. // ? +item.outInNum * parseInt(item.minPackingCount)
  2521. +item.outInNum
  2522. ),
  2523. (val, idx) => {
  2524. return {
  2525. ...item,
  2526. onlyCode: res.shift().onlyCode,
  2527. bizStatus: 1,
  2528. contentImage: []
  2529. };
  2530. }
  2531. )
  2532. );
  2533. }
  2534. });
  2535. // 添加相同物品,重复批次号 重新更新明细 包装编码
  2536. const batchList = this.warehousingMaterialList.filter(
  2537. (i) => i.batchNo === row.batchNo && i.isSave
  2538. );
  2539. if (batchList.length) {
  2540. const num = batchList.reduce((num, pre) => {
  2541. num += +pre.outInNum;
  2542. return num;
  2543. }, 0);
  2544. const res1 = await outin.getAssetNum({
  2545. batchNum: row.batchNo,
  2546. num
  2547. });
  2548. if (res1) {
  2549. batchList.forEach((item) => {
  2550. let num = res1.shift()?.num;
  2551. let minPackingCount = item.minPackingCount;
  2552. if (item.warehouseLedgerDetails?.length) {
  2553. item.warehouseLedgerDetails.forEach((i, index) => {
  2554. this.$set(i, 'num', num);
  2555. if (row.code == i.code) {
  2556. if (item.measuringUnit == item.weightUnit) {
  2557. this.$set(i, 'weight', item.minPackingCount);
  2558. this.$set(i, 'initWeight', item.minPackingCount);
  2559. } else {
  2560. this.$set(
  2561. i,
  2562. 'weight',
  2563. Number(
  2564. this.$math.format(
  2565. 1 * item.minPackingCount * item.netWeight,
  2566. 14
  2567. )
  2568. )
  2569. );
  2570. this.$set(
  2571. i,
  2572. 'initWeight',
  2573. Number(
  2574. this.$math.format(
  2575. 1 * item.minPackingCount * item.netWeight,
  2576. 14
  2577. )
  2578. )
  2579. );
  2580. }
  2581. }
  2582. this.$set(i, 'weightUtil', item.weightUnit);
  2583. this.$set(i, 'packingCount', 1);
  2584. this.$set(i, 'packingUnit ', item.packingUnit);
  2585. this.$set(i, 'minPackingCount ', item.minPackingCount);
  2586. this.$set(i, 'measuringUnit', item.measuringUnit);
  2587. this.$set(i, 'isPack', false);
  2588. if (this.formData.extInfo.assetType == 1) {
  2589. this.$set(i, 'status', '0');
  2590. } else {
  2591. this.$set(i, 'result', '0');
  2592. this.$set(i, 'status', '1');
  2593. }
  2594. if (!item.isUnpack) {
  2595. if (index < item.warehouseLedgerDetails.length - 1) {
  2596. num = res1.shift()?.num;
  2597. }
  2598. } else {
  2599. // 拆包的包装编码一致
  2600. minPackingCount--;
  2601. if (
  2602. minPackingCount === 0 &&
  2603. index < item.warehouseLedgerDetails.length - 1
  2604. ) {
  2605. minPackingCount = item.minPackingCount;
  2606. num = res1.shift()?.num;
  2607. }
  2608. }
  2609. });
  2610. }
  2611. });
  2612. }
  2613. }
  2614. },
  2615. // 入库明细生成条码信息 退还
  2616. async createMaterialCodeReturn(row) {
  2617. // 添加相同物品重新更新明细 原料编码
  2618. const list = this.warehousingMaterialList.filter(
  2619. (i) => i.batchNo === row.batchNo && i.isSave
  2620. );
  2621. // 退还
  2622. const res = await getAssetNum({
  2623. batchNo: row.batchNo,
  2624. num: list.reduce((num, pre) => {
  2625. num += pre.selfWarehouseLedgerDetails.length;
  2626. return num;
  2627. }, 0)
  2628. });
  2629. if (res?.success) {
  2630. list.forEach((item) => {
  2631. let num = res.data.shift().num;
  2632. let minPackingCount = item.minPackingCount;
  2633. if (item.warehouseLedgerDetails?.length) {
  2634. item.warehouseLedgerDetails.forEach((i, index) => {
  2635. Object.assign(i, {
  2636. num,
  2637. manualBatchNo: item.manualBatchNo,
  2638. batchNo: item.batchNo,
  2639. cargoSpaceCode: item.cargoSpaceCode, //货位编码
  2640. cargoSpaceId: item.cargoSpaceId, //货位id
  2641. shelfId: item.shelfId, //货架id
  2642. shelfCode: item.shelfCode, //货架名称
  2643. areaId: item.areaId, //库区id
  2644. areaName: item.areaName, //库区名称
  2645. warehouseId: item.warehouseId, //仓库id
  2646. warehouseName: item.warehouseName //仓库名称
  2647. });
  2648. if (!item.isUnpack) {
  2649. // 拆包的包装编码一致
  2650. if (index < item.warehouseLedgerDetails.length - 1) {
  2651. num = res.data.shift()?.num;
  2652. }
  2653. } else {
  2654. minPackingCount--;
  2655. if (
  2656. minPackingCount === 0 &&
  2657. index < item.warehouseLedgerDetails.length - 1
  2658. ) {
  2659. minPackingCount = item.minPackingCount;
  2660. num = res1.data.shift()?.num;
  2661. }
  2662. }
  2663. });
  2664. } else {
  2665. this.$set(
  2666. item,
  2667. 'warehouseLedgerDetails',
  2668. item.selfWarehouseLedgerDetails.map((val, idx) => {
  2669. let obj = {
  2670. ...val,
  2671. bizStatus: 1,
  2672. minPackingCount: item.minPackingCount,
  2673. manualBatchNo: item.manualBatchNo,
  2674. batchNo: item.batchNo,
  2675. cargoSpaceCode: item.cargoSpaceCode, //货位编码
  2676. cargoSpaceId: item.cargoSpaceId, //货位id
  2677. shelfId: item.shelfId, //货架id
  2678. shelfCode: item.shelfCode, //货架名称
  2679. areaId: item.areaId, //库区id
  2680. areaName: item.areaName, //库区名称
  2681. warehouseId: item.warehouseId, //仓库id
  2682. warehouseName: item.warehouseName, //仓库名称
  2683. materialId: item.materialId,
  2684. num
  2685. };
  2686. if (!item.isUnpack) {
  2687. // 拆包的包装编码一致
  2688. if (idx < item.warehouseLedgerDetails.length - 1) {
  2689. num = res.data.shift()?.num;
  2690. }
  2691. } else {
  2692. minPackingCount--;
  2693. if (
  2694. minPackingCount === 0 &&
  2695. idx < item.warehouseLedgerDetails.length - 1
  2696. ) {
  2697. minPackingCount = item.minPackingCount;
  2698. num = res1.data.shift()?.num;
  2699. }
  2700. }
  2701. return obj;
  2702. })
  2703. );
  2704. }
  2705. });
  2706. }
  2707. },
  2708. async handleSave(data) {
  2709. // this.$refs.formName.validate(async (valid) => {
  2710. // if (valid) {
  2711. // if (!this.warehousingMaterialList?.length) {
  2712. // return this.$message.error('请添加入库明细!');
  2713. // } else if (
  2714. // this.warehousingMaterialList.some((item) => !item.isSave)
  2715. // ) {
  2716. // return this.$message.error('请保存入库明细!');
  2717. // }
  2718. console.log(this.warehousingMaterialList.length);
  2719. console.log(this.materialCodeReqList.length);
  2720. if (
  2721. this.warehousingMaterialList?.length <= 0 ||
  2722. this.materialCodeReqList?.length <= 0
  2723. ) {
  2724. this.$message.error('请添加产品信息和包装明细');
  2725. return false;
  2726. }
  2727. // // 默认全部保存(需要后台修改)
  2728. // if (this.resultArray?.length > 0) {
  2729. // // 物料批量保存
  2730. // this.materialListSave();
  2731. // } else {
  2732. // // 包装批量保存
  2733. // this.wrapListSave();
  2734. // }
  2735. this.formatWarehouseMaterialList();
  2736. let arr = this.warehousingMaterialList.map((item) => {
  2737. console.log(item, 'item');
  2738. return {
  2739. netWeight: item.netWeight > 0 ? item.netWeight : 0,
  2740. num: item.num > 0 ? item.num : 0,
  2741. manualBatchNo: item.manualBatchNo,
  2742. batchNo: item.batchNo,
  2743. categoryId:
  2744. this.formData.bizType == 2
  2745. ? item.categoryId
  2746. ? item.categoryId
  2747. : item.id
  2748. : item.id,
  2749. count:
  2750. item.outInNum > 0 && item.minPackingCount > 0
  2751. ? this.$math.format(
  2752. parseInt(item.outInNum) * parseInt(item.minPackingCount),
  2753. 14
  2754. )
  2755. : 0,
  2756. minPackingCount:
  2757. item.minPackingCount > 0 ? item.minPackingCount : 0,
  2758. packingCount: item.outInNum > 0 ? item.outInNum : 0,
  2759. price: item.univalence > 0 ? item.univalence : 0,
  2760. outInDetailRecordAddPOList: item.warehouseLedgerDetails,
  2761. position: `${item.warehouseName}-${item.areaName}-${item.shelfCode}-${item.cargoSpaceCode}`,
  2762. remark: '',
  2763. pathIds: `${item.warehouseId},${item.areaId},${item.shelfId},${item.cargoSpaceId}`,
  2764. pathName: `${item.warehouseName},${item.areaName},${item.shelfCode},${item.cargoSpaceCode}`,
  2765. totalMoney:
  2766. item.outInNum > 0 &&
  2767. item.minPackingCount > 0 &&
  2768. item.univalence > 0
  2769. ? this.$math.format(
  2770. item.outInNum * item.minPackingCount * item.univalence,
  2771. 14
  2772. )
  2773. : 0,
  2774. weightUnit: item.weightUnit,
  2775. customCode: item.customCode,
  2776. supplierCode: item.supplierCode,
  2777. weight: item.weight > 0 ? item.weight : 0
  2778. };
  2779. });
  2780. arr.forEach((item) => {
  2781. if (item.outInDetailRecordAddPOList.length > 0) {
  2782. let list = item.outInDetailRecordAddPOList.map((it) => {
  2783. return this.formatOutInDetailRecordAddPO(it, item);
  2784. });
  2785. item.outInDetailRecordAddPOList = list;
  2786. }
  2787. });
  2788. let obj = { ...this.formData, type: 1 };
  2789. obj.outInDetailAddPOList = arr;
  2790. this.saveLoading = true;
  2791. // 入库来源storageSource 0-正常 1-外部
  2792. obj.storageSource = 1;
  2793. try {
  2794. const res = await outin.updateOutIn(obj);
  2795. if (res.code == 0) {
  2796. this.isConfig = true;
  2797. this.$message.success('保存成功!');
  2798. } else {
  2799. this.isConfig = false;
  2800. this.$message.success('保存失败!');
  2801. }
  2802. // if (res.code == 0) {
  2803. // approveTaskWithVariables(data).then((res) => {
  2804. // console.log(res);
  2805. // if (res.data.code == 0) {
  2806. // this.$message.success('保存成功!');
  2807. // this.$emit('success');
  2808. // }
  2809. // });
  2810. // await outin.outApproves({ outInId: res.data });
  2811. // this.$message.success('保存成功!');
  2812. // this.$emit('success');
  2813. // }
  2814. } catch (error) {
  2815. console.error('保存失败:', error);
  2816. }
  2817. this.saveLoading = false;
  2818. // this.$router.push('/warehouseManagement/stockManagement');
  2819. // }
  2820. // });
  2821. },
  2822. formatWarehouseMaterialList() {
  2823. for (let key in this.warehousingMaterialList) {
  2824. for (let k in this.warehousingMaterialList[key].houseList) {
  2825. let house = this.warehousingMaterialList[key].houseList[k];
  2826. this.warehousingMaterialList[key].warehouseName =
  2827. house.warehouseName;
  2828. this.warehousingMaterialList[key].areaName = house.areaName;
  2829. this.warehousingMaterialList[key].shelfCode = house.shelfCode;
  2830. this.warehousingMaterialList[key].cargoSpaceCode =
  2831. house.cargoSpaceCode;
  2832. this.warehousingMaterialList[key].warehouseId = house.warehouseId;
  2833. this.warehousingMaterialList[key].areaId = house.areaId;
  2834. this.warehousingMaterialList[key].shelfId = house.shelfId;
  2835. this.warehousingMaterialList[key].cargoSpaceId = house.cargoSpaceId;
  2836. this.warehousingMaterialList[key].num = house.num;
  2837. }
  2838. }
  2839. },
  2840. formatOutInDetailRecordAddPO(it, item) {
  2841. return {
  2842. code: it.onlyCode,
  2843. dateType: this.curDateType === 'manufactureTime' ? 2 : 1,
  2844. dateValue: it[this.curDateType],
  2845. minUnit: it.minPackingCount,
  2846. minPositionId: it.cargoSpaceId,
  2847. name: it.assetName,
  2848. pathIds: item.pathIds,
  2849. minPackingCount: it.minPackingCount,
  2850. unit: it.unit,
  2851. packageNo: it.num,
  2852. clientCode: it.clientCode,
  2853. materielCode: it.materielCode,
  2854. weight: it.weight,
  2855. weightUtil: it.weightUtil,
  2856. engrave: it.engrave,
  2857. materialDetails: this.materialDetails(it.onlyCode),
  2858. packingCount: it.packingCount,
  2859. status: it.status,
  2860. result: it.result
  2861. };
  2862. },
  2863. materialDetails(onlyCode) {
  2864. return this.resultArray.filter((item) => item.onlyCode === onlyCode);
  2865. },
  2866. async getOrderCode() {
  2867. const data = await getCode('in_warehouse');
  2868. return data;
  2869. },
  2870. //添加明细
  2871. async onSelectTableData(val) {
  2872. console.log('===ssa', val);
  2873. const res = await getCode('lot_number_code');
  2874. this.warehousingMaterialList.push(
  2875. ...val.map((next) => {
  2876. next.batchNo = res;
  2877. let cur = {};
  2878. next.realInventoryAmount = next.realInventoryAmount || 0;
  2879. cur = {
  2880. ...next,
  2881. cargoSpaceCode: '', //货位编码
  2882. cargoSpaceId: '', //货位id
  2883. shelfId: '', //货架id
  2884. shelfCode: '', //货架名称
  2885. areaId: '', //库区id
  2886. areaName: '', //库区名称
  2887. warehouseId: '', //仓库id
  2888. warehouseName: '', //仓库名称
  2889. assetType: this.formData.extInfo.assetType,
  2890. expirationDate: '',
  2891. outInNum: '',
  2892. minPackingCount: '',
  2893. bizStatus: 1,
  2894. contentImage: [],
  2895. warehouseLedgerDetails: [],
  2896. houseList: []
  2897. };
  2898. return cur;
  2899. })
  2900. );
  2901. },
  2902. // async initData() {
  2903. // const { data } = await getTreeByGroup({ type: 1 });
  2904. // this.codeList = data;
  2905. // // .map((item) => {
  2906. // // return { dictCode: item.id, dictValue: item.name };
  2907. // // });
  2908. // const res = await warehouseDefinition.tree();
  2909. // this.treeList = this.$util.toTreeData({
  2910. // data: res,
  2911. // idField: 'id',
  2912. // parentIdField: 'parentId'
  2913. // });
  2914. // // const res111 = await warehouseDefinition.list();
  2915. // // this.warehouseList = res111.list;
  2916. // let res22 = await warehouseDefinition.getUserPage({
  2917. // size: -1,
  2918. // page: 1
  2919. // });
  2920. // this.fromUserList = res22.list;
  2921. // const info = await getLoginUser();
  2922. // // const info = JSON.parse(localStorage.getItem('info'));
  2923. // let obj = res.find(
  2924. // (item) => item.id === info.deptIds[info.deptIds.length - 1]
  2925. // );
  2926. // if (!obj) return;
  2927. // this.formData.extInfo.deptCode = obj.id;
  2928. // this.formData.extInfo.deptName = obj.name;
  2929. // this.formData.extInfo.createUserName = info.name;
  2930. // this.formData.createUserId = info.id;
  2931. // // this.treeList = res;
  2932. // // this.formData.extInfo.deptCode =
  2933. // // this.getTreeList().then((res) => {
  2934. // // if (res?.success) {
  2935. // // this.treeList = res.data;
  2936. // // }
  2937. // // });
  2938. // // this.getSupplier().then((res) => {
  2939. // // if (res?.success) {
  2940. // // this.supplierList = res.data.items;
  2941. // // }
  2942. // // });
  2943. // // this.getStaffList();
  2944. // },
  2945. addStock() {
  2946. // this.$refs.wareHouseDailogRef.open({});
  2947. // return;
  2948. if (!this.title) return this.$message.error('请选择入库产品类型');
  2949. if (!this.formData.bizType)
  2950. return this.$message.error('请选择入库场景');
  2951. this.visibleDialog = true;
  2952. },
  2953. handleChange(data) {
  2954. this.title = data?.dictValue;
  2955. this.selectEquiType = data?.dictCode;
  2956. },
  2957. handleChanges(code) {
  2958. const data = this.codeList.find((item) => item.dictCode == code);
  2959. this.title = data?.dictValue;
  2960. this.selectEquiType = data?.dictCode;
  2961. },
  2962. getSupplier() {
  2963. return new Promise((resolve, reject) => {
  2964. supplier.list({ page: 1, size: 999 }).then((res) => {
  2965. if (res.success) {
  2966. resolve(res);
  2967. }
  2968. });
  2969. });
  2970. },
  2971. getTreeList() {
  2972. return new Promise((resolve, reject) => {
  2973. org.tree().then((res) => {
  2974. if (res.success) {
  2975. resolve(res);
  2976. }
  2977. });
  2978. });
  2979. },
  2980. upload(data) {
  2981. this.formData.contentImage = data;
  2982. this.$refs.formName.validateField('contentImage');
  2983. },
  2984. houseData(argum, idx) {
  2985. this.$set(this.warehousingMaterialList[idx], 'houseList', argum);
  2986. }
  2987. },
  2988. watch: {
  2989. // 解决右侧悬浮操作栏不对称问题
  2990. warehousingMaterialList: {
  2991. handler() {
  2992. this.$nextTick(() => {
  2993. this.$refs.warehousingMaterialListTable?.doLayout();
  2994. });
  2995. },
  2996. deep: true
  2997. },
  2998. // 解决右侧悬浮操作栏不对称问题
  2999. materialCodeReqList: {
  3000. handler() {
  3001. this.$nextTick(() => {
  3002. this.$refs.materialCodeReqListTable?.doLayout();
  3003. });
  3004. },
  3005. deep: true
  3006. },
  3007. // 解决右侧悬浮操作栏不对称问题
  3008. resultArray: {
  3009. handler() {
  3010. this.$nextTick(() => {
  3011. this.$refs.resultArrayTable?.doLayout();
  3012. });
  3013. },
  3014. deep: true
  3015. }
  3016. }
  3017. };
  3018. </script>
  3019. <style lang="scss" scoped>
  3020. ::v-deep.form-table {
  3021. .el-form-item {
  3022. margin-bottom: 0;
  3023. }
  3024. .el-input__inner {
  3025. padding: 0 10px;
  3026. }
  3027. ::-webkit-scrollbar {
  3028. width: 8px;
  3029. height: 8px;
  3030. background-color: transparent;
  3031. }
  3032. }
  3033. .p20 {
  3034. padding: 20px;
  3035. }
  3036. .el-select,
  3037. .el-date-editor {
  3038. width: 100%;
  3039. }
  3040. .el-form-item {
  3041. margin-bottom: 22px;
  3042. }
  3043. ::v-deep .material {
  3044. .title {
  3045. width: 100%;
  3046. }
  3047. margin-top: 20px;
  3048. .flex {
  3049. display: flex;
  3050. justify-content: space-between;
  3051. font-size: 14px;
  3052. align-items: center;
  3053. .red {
  3054. color: #ff4949;
  3055. }
  3056. }
  3057. }
  3058. .mt10 {
  3059. margin-top: 10px;
  3060. }
  3061. .mt20 {
  3062. margin-top: 20px;
  3063. }
  3064. .center {
  3065. text-align: center;
  3066. }
  3067. .switch_left li {
  3068. border-right: 1px solid rgba(222, 222, 222, 1);
  3069. border-left: 1px solid rgba(222, 222, 222, 1);
  3070. }
  3071. .fontOmitted {
  3072. text-overflow: ellipsis;
  3073. overflow: hidden;
  3074. word-break: break-all;
  3075. white-space: nowrap;
  3076. }
  3077. .table-fixed {
  3078. .el-table__fixed-right {
  3079. height: 100% !important;
  3080. }
  3081. .el-table__fixed-left {
  3082. height: 100% !important;
  3083. }
  3084. .el-table__fixed {
  3085. height: 100% !important;
  3086. }
  3087. }
  3088. </style>