add.vue 137 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819
  1. <template>
  2. <div class="ele-body">
  3. <el-card shadow="never">
  4. <header-title title="基本信息">
  5. <div class="right_control">
  6. <el-upload
  7. ref="fileUploadBtn"
  8. action="#"
  9. :auto-upload="false"
  10. :on-change="onChange"
  11. :limit="1"
  12. :show-file-list="false"
  13. accept=".xls,.xlsx"
  14. >
  15. <el-button type="primary">备品备件导入excel</el-button>
  16. </el-upload>
  17. <el-button type="primary" @click="back">返回</el-button>
  18. </div>
  19. </header-title>
  20. <el-form
  21. :model="formData"
  22. ref="formName"
  23. label-width="110px"
  24. :rules="rules"
  25. >
  26. <el-row :gutter="24">
  27. <el-col :span="6">
  28. <el-form-item label="物品类型" prop="extInfo.assetType">
  29. <el-select
  30. style="width: 100%"
  31. multiple
  32. v-model="formData.extInfo.assetType"
  33. placeholder="请选择"
  34. >
  35. <el-option
  36. v-for="item in goodsLists"
  37. :key="item.id"
  38. :label="item.name"
  39. :value="item.id"
  40. >
  41. </el-option>
  42. </el-select>
  43. </el-form-item>
  44. </el-col>
  45. <el-col :span="6">
  46. <el-form-item label="入库类型" prop="bizType">
  47. <el-select
  48. style="width: 100%"
  49. filterable
  50. placeholder="请选择"
  51. v-model="formData.bizType"
  52. clearable
  53. >
  54. <el-option
  55. v-for="item in sceneState"
  56. :key="item.code"
  57. :value="item.code + ''"
  58. :label="item.label"
  59. ></el-option>
  60. </el-select> </el-form-item
  61. ></el-col>
  62. <el-col :span="6">
  63. <el-form-item label="客户名称" prop="">
  64. <el-input
  65. placeholder="请选择"
  66. v-model="formData.clientName"
  67. style="width: calc(100% - 80px)"
  68. >
  69. </el-input>
  70. <openContactDialog
  71. style="margin-left: 3px"
  72. @changeParent="contactDialogSuccess"
  73. ></openContactDialog>
  74. </el-form-item>
  75. </el-col>
  76. <el-col :span="6">
  77. <el-form-item label="单据来源" prop="sourceBizNo">
  78. <el-input
  79. placeholder="请选择"
  80. v-model="formData.sourceBizNo"
  81. @focus="openDocumentSourceDialog"
  82. >
  83. <template #append>
  84. <el-button
  85. @click="clearSourceBizNo"
  86. slot="append"
  87. icon="el-icon-circle-close"
  88. ></el-button>
  89. </template>
  90. </el-input>
  91. </el-form-item>
  92. </el-col>
  93. <el-col :span="6">
  94. <el-form-item label="入库时间">
  95. <el-date-picker
  96. v-model="formData.storageTime"
  97. type="datetime"
  98. value-format="yyyy-MM-dd HH:mm:ss"
  99. placeholder="选择日期时间"
  100. >
  101. </el-date-picker></el-form-item
  102. ></el-col>
  103. <el-col :span="6">
  104. <el-form-item label="入库登记人">
  105. <el-input
  106. placeholder="登记人"
  107. disabled
  108. v-model="formData.extInfo.createUserName"
  109. clearable /></el-form-item
  110. ></el-col>
  111. <el-col :span="6" v-if="formData.bizType == 2">
  112. <el-form-item label="供应商" prop="supplierName">
  113. <el-input
  114. placeholder="请输入"
  115. clearable
  116. v-model="formData.extInfo.supplierName"
  117. />
  118. </el-form-item>
  119. </el-col>
  120. <el-col :span="6">
  121. <el-form-item label="送货人" prop="fromUser">
  122. <el-input
  123. placeholder="请输入"
  124. v-model="formData.fromUser"
  125. clearable
  126. /> </el-form-item
  127. ></el-col>
  128. <el-col :span="6">
  129. <el-form-item label="送货人联系方式" prop="deliveryPhone">
  130. <el-input
  131. placeholder="请输入"
  132. v-model="formData.extInfo.deliveryPhone"
  133. clearable /></el-form-item
  134. ></el-col>
  135. <el-col :span="6">
  136. <el-form-item label="备注" prop="remark">
  137. <el-input
  138. v-model="formData.remark"
  139. placeholder="请详细说明"
  140. ></el-input>
  141. </el-form-item>
  142. </el-col>
  143. </el-row>
  144. </el-form>
  145. <div class="inbound_details">
  146. <header-title title="产品信息">
  147. <el-button type="primary" @click="addProduct">添加</el-button>
  148. </header-title>
  149. <div class="form_table">
  150. <el-form
  151. ref="productListRef"
  152. :model="{ productList: productList }"
  153. :show-message="false"
  154. >
  155. <ele-pro-table
  156. ref="table"
  157. :columns="columns"
  158. :datasource="productList"
  159. :needPage="false"
  160. @columns-change="handleColumnChange"
  161. :cache-key="cacheKeyUrl"
  162. >
  163. <template v-slot:toolbar>
  164. <el-button
  165. v-if="productList.length != 0"
  166. type="success"
  167. plain
  168. style="float: right; margin-right: 20px"
  169. size="mini"
  170. @click="dateSetting('detailExpireDate', 'productList')"
  171. >批量设置失效日期</el-button
  172. >
  173. <el-button
  174. v-if="productList.length != 0"
  175. type="success"
  176. plain
  177. style="float: right; margin-right: 20px"
  178. size="mini"
  179. @click="dateSetting('detailPurchaseDate', 'productList')"
  180. >批量设置采购日期</el-button
  181. >
  182. <el-button
  183. v-if="productList.length != 0"
  184. type="success"
  185. plain
  186. style="float: right; margin-right: 20px"
  187. size="mini"
  188. @click="dateSetting('detailProductionDate', 'productList')"
  189. >批量设置生产日期</el-button
  190. >
  191. <el-button
  192. v-if="productList.length != 0"
  193. type="success"
  194. plain
  195. style="float: right; margin-right: 20px"
  196. size="mini"
  197. @click="batchSave"
  198. >批量保存</el-button
  199. >
  200. <el-button
  201. v-if="productList.length != 0"
  202. type="success"
  203. plain
  204. style="float: right; margin-right: 20px"
  205. size="mini"
  206. @click="handleWareHouse(productList, '', 'batch')"
  207. >批量选择仓库</el-button
  208. >
  209. </template>
  210. <template v-slot:headerBatchNo="{ column }">
  211. <span class="is-required">{{ column.label }}</span>
  212. </template>
  213. <template v-slot:batchNo="{ row, $index }">
  214. <template v-if="row.isSave">
  215. {{ row.batchNo }}
  216. </template>
  217. <el-form-item
  218. v-else
  219. :prop="`productList.${$index}.batchNo`"
  220. required
  221. >
  222. <el-input
  223. :ref="'batchNo' + $index"
  224. @keyup.native="
  225. moveFocus($event, $index, 'batchNo', '产品', row)
  226. "
  227. v-model="row.batchNo"
  228. >
  229. </el-input>
  230. </el-form-item>
  231. </template>
  232. <template v-slot:quantity="{ row, $index }">
  233. <template v-if="row.isSave">
  234. {{ row.quantity }}
  235. </template>
  236. <el-form-item
  237. v-else
  238. :prop="`productList.${$index}.quantity`"
  239. required
  240. >
  241. <el-input
  242. :ref="'quantity' + $index"
  243. type="number"
  244. placeholder="请输入"
  245. @keyup.native="
  246. moveFocus($event, $index, 'quantity', '产品', row)
  247. "
  248. v-model="row.quantity"
  249. @input="computeNum(row, $index, true)"
  250. :disabled="row.isSave"
  251. >
  252. </el-input>
  253. </el-form-item>
  254. </template>
  255. <template v-slot:unit="{ row, $index }">
  256. <template v-if="row.isSave">
  257. {{ row.unit }}
  258. </template>
  259. <el-form-item
  260. v-else
  261. :prop="`productList.${$index}.unit`"
  262. required
  263. >
  264. <el-select
  265. :disabled="row.isSave"
  266. v-model="row.unitId"
  267. placeholder="请选择"
  268. @change="computeNum(row, $index)"
  269. >
  270. <el-option
  271. v-for="item in row.packingSpecificationOption"
  272. :label="`${item.conversionUnit}`"
  273. :value="item.id"
  274. :key="item.id"
  275. >
  276. </el-option>
  277. </el-select>
  278. </el-form-item>
  279. </template>
  280. <template v-slot:packingSpecificationLabel="{ row, $index }">
  281. <el-tag v-for="item in row.packingSpecificationLabel">{{
  282. item
  283. }}</el-tag>
  284. </template>
  285. <template v-slot:singleWeight="{ row, $index }">
  286. <el-input
  287. :disabled="row.isSave || row.weightUnit == row.unit"
  288. v-model="row.singleWeight"
  289. placeholder="请输入"
  290. :min="0"
  291. style="width: 100%"
  292. @input="inputSingleWeight(row, $index)"
  293. >
  294. <template slot="append">
  295. {{ row.weightUnit }}
  296. </template>
  297. </el-input>
  298. </template>
  299. <template v-slot:weight="{ row, $index }">
  300. <el-input
  301. :disabled="row.isSave || row.weightUnit == row.unit"
  302. v-model="row.weight"
  303. placeholder="请输入"
  304. @input="inputAllweight(row, $index)"
  305. >
  306. </el-input>
  307. </template>
  308. <template v-slot:unitPrice="{ row, $index }">
  309. <template v-if="row.isSave">
  310. {{ row.unitPrice ? row.unitPrice + '/元' : '' }}
  311. </template>
  312. <el-form-item v-else>
  313. <el-input
  314. type="number"
  315. :ref="'unitPrice' + $index"
  316. @keyup.native="
  317. moveFocus($event, $index, 'unitPrice', '产品', row)
  318. "
  319. v-model.number="row.unitPrice"
  320. placeholder="非必填"
  321. @input="
  322. (value) =>
  323. (row.unitPrice = value.replace(/[^0-9.]+/g, ''))
  324. "
  325. >
  326. <template slot="append">
  327. 元/{{ row.measureUnit }}
  328. </template>
  329. </el-input>
  330. </el-form-item>
  331. </template>
  332. <template v-slot:totalMoney="{ row, $index }">
  333. {{
  334. changeCount(
  335. calcSumTotal(row.measureQuantity, row.unitPrice, row)
  336. )
  337. }}
  338. </template>
  339. <template v-slot:supplierId="{ row, $index }">
  340. <template v-if="row.isSave">
  341. {{ row.supplierName }}
  342. </template>
  343. <el-select
  344. v-else
  345. @change="selectSupplier($event, row)"
  346. v-model="row.supplierId"
  347. placeholder="请选择"
  348. >
  349. <el-option
  350. v-for="item in row.supplierListOptions"
  351. :label="item.name"
  352. :value="item.id"
  353. :key="item.id"
  354. >
  355. </el-option>
  356. </el-select>
  357. </template>
  358. <template v-slot:warehouseName="{ row, $index }">
  359. <el-form-item
  360. :prop="`productList.${$index}.warehouseId`"
  361. required
  362. >
  363. <div
  364. :class="
  365. row.warehouseName
  366. ? 'wareHouse_style'
  367. : 'wareHouse_style red_color'
  368. "
  369. @click="handleWareHouse(row, $index)"
  370. >
  371. <span>
  372. {{ row.warehouseName ? row.warehouseName : '请选择仓库' }}
  373. </span>
  374. </div>
  375. </el-form-item>
  376. </template>
  377. <template v-slot:purpose="{ row, $index }">
  378. <template v-if="row.isSave">
  379. {{ row.purpose }}
  380. </template>
  381. <el-input
  382. v-else
  383. :ref="'purpose' + $index"
  384. @keyup.native="
  385. moveFocus($event, $index, 'purpose', '产品', row)
  386. "
  387. v-model="row.purpose"
  388. >
  389. </el-input>
  390. </template>
  391. <template v-slot:modelKey="{ row, $index }">
  392. <el-form-item>
  393. <DictSelection
  394. dictName="物品机型"
  395. clearable
  396. v-model="row.modelKey"
  397. :isOne="$index === 0"
  398. filterable
  399. allow-create
  400. default-first-option
  401. >
  402. </DictSelection>
  403. </el-form-item>
  404. </template>
  405. <template v-slot:colorKey="{ row, $index }">
  406. <el-form-item>
  407. <DictSelection
  408. dictName="物品颜色"
  409. clearable
  410. v-model="row.colorKey"
  411. :isOne="$index === 0"
  412. filterable
  413. allow-create
  414. default-first-option
  415. >
  416. </DictSelection>
  417. </el-form-item>
  418. </template>
  419. <template v-slot:reelSpecification="{ row, $index }">
  420. <el-form-item>
  421. <el-input
  422. :ref="'reelSpecification' + $index"
  423. v-model="row.reelSpecification"
  424. >
  425. </el-input>
  426. </el-form-item>
  427. </template>
  428. <template v-slot:detailProductionDate="{ row, $index }">
  429. <template v-if="row.isSave">
  430. {{ row.detailProductionDate }}
  431. </template>
  432. <el-date-picker
  433. v-else
  434. :disabled="row.isPack"
  435. size="small"
  436. v-model="row.detailProductionDate"
  437. type="datetime"
  438. value-format="yyyy-MM-dd HH:mm:ss"
  439. placeholder="选择日期"
  440. >
  441. </el-date-picker>
  442. </template>
  443. <template v-slot:detailPurchaseDate="{ row, $index }">
  444. <template v-if="row.isSave">
  445. {{ row.detailPurchaseDate }}
  446. </template>
  447. <el-date-picker
  448. v-else
  449. :disabled="row.isPack"
  450. size="small"
  451. v-model="row.detailPurchaseDate"
  452. type="datetime"
  453. value-format="yyyy-MM-dd HH:mm:ss"
  454. placeholder="选择日期"
  455. >
  456. </el-date-picker>
  457. </template>
  458. <template v-slot:detailExpireDate="{ row, $index }">
  459. <template v-if="row.isSave">
  460. {{ row.detailExpireDate }}
  461. </template>
  462. <el-date-picker
  463. v-else
  464. :disabled="row.isPack"
  465. size="small"
  466. v-model="row.detailExpireDate"
  467. type="datetime"
  468. value-format="yyyy-MM-dd HH:mm:ss"
  469. placeholder="选择日期"
  470. >
  471. </el-date-picker>
  472. </template>
  473. <template v-slot:action="{ row, $index }">
  474. <el-button
  475. type="text"
  476. v-show="!row.isSave"
  477. @click="listSave(row, $index)"
  478. >保存</el-button
  479. >
  480. <el-button
  481. type="text"
  482. v-show="row.isSave"
  483. @click="listEdit(row, $index)"
  484. >编辑</el-button
  485. >
  486. <el-button type="text" @click="listDel(row, $index)"
  487. >删除</el-button
  488. >
  489. </template>
  490. </ele-pro-table>
  491. </el-form>
  492. </div>
  493. </div>
  494. <div v-if="showPackingList.length > 0" class="inbound_details">
  495. <header-title :title="`包装明细`">
  496. <div class="switch_right">
  497. <el-button
  498. style="margin-left: 20px"
  499. type="text"
  500. @click="dateSetting('productionDate')"
  501. >批量设置生产日期</el-button
  502. >
  503. <el-button
  504. style="margin-left: 20px"
  505. type="text"
  506. @click="dateSetting('purchaseDate')"
  507. >批量设置采购日期</el-button
  508. >
  509. <el-button
  510. style="margin-left: 20px"
  511. type="text"
  512. @click="dateSetting('expireDate')"
  513. >批量设置失效日期</el-button
  514. >
  515. </div>
  516. </header-title>
  517. <el-table
  518. v-if="isWrapTable"
  519. ref="packingListTable"
  520. :data="showPackingList"
  521. tooltip-effect="dark"
  522. :key="formData.bizType"
  523. :header-cell-style="rowClass"
  524. style="width: 100%"
  525. border
  526. stripe
  527. :max-height="300"
  528. v-el-table-infinite-scroll="pickingHandleScroll"
  529. @selection-change="handleSelectionChange"
  530. >
  531. <el-table-column type="selection" align="center" width="50">
  532. </el-table-column>
  533. <el-table-column label="序号" type="index" width="50">
  534. </el-table-column>
  535. <el-table-column
  536. label="批次号"
  537. prop="batchNo"
  538. width="150"
  539. :show-overflow-tooltip="true"
  540. ></el-table-column>
  541. <el-table-column
  542. label="包装编码"
  543. prop="packageNo"
  544. width="130"
  545. :show-overflow-tooltip="true"
  546. ></el-table-column>
  547. <el-table-column
  548. label="名称"
  549. prop="categoryName"
  550. width="120"
  551. :show-overflow-tooltip="true"
  552. ></el-table-column>
  553. <el-table-column
  554. label="编码"
  555. prop="categoryCode"
  556. width="120"
  557. :show-overflow-tooltip="true"
  558. ></el-table-column>
  559. <el-table-column
  560. label="型号"
  561. prop="categoryModel"
  562. width="80"
  563. :show-overflow-tooltip="true"
  564. ></el-table-column>
  565. <el-table-column
  566. label="规格"
  567. prop="specification"
  568. width="80"
  569. :show-overflow-tooltip="true"
  570. ></el-table-column>
  571. <el-table-column
  572. label="牌号"
  573. prop="brandNum"
  574. width="80"
  575. :show-overflow-tooltip="true"
  576. ></el-table-column>
  577. <el-table-column
  578. label="包装数量"
  579. prop="packingQuantity"
  580. width="80"
  581. ></el-table-column>
  582. <el-table-column
  583. label="包装单位"
  584. prop="packingUnit"
  585. ></el-table-column>
  586. <el-table-column
  587. label="计量数量"
  588. prop="measureQuantity"
  589. :show-overflow-tooltip="true"
  590. ></el-table-column>
  591. <el-table-column
  592. label="计量单位"
  593. prop="measureUnit"
  594. ></el-table-column>
  595. <el-table-column
  596. label="仓库"
  597. :show-overflow-tooltip="true"
  598. prop="warehouseName"
  599. width="200"
  600. ></el-table-column>
  601. <el-table-column
  602. label="供应商"
  603. align="center"
  604. prop="supplierName"
  605. width="200"
  606. :show-overflow-tooltip="true"
  607. >
  608. </el-table-column>
  609. <el-table-column label="供应商代号" prop="supplierCode" width="130">
  610. </el-table-column>
  611. <el-table-column
  612. label="物料代号"
  613. prop="materielDesignation"
  614. width="130"
  615. >
  616. <template slot-scope="{ row, $index }">
  617. <el-input
  618. v-if="!row.isPack"
  619. :ref="'packing_materielDesignation' + $index"
  620. @keyup.native="
  621. moveFocus(
  622. $event,
  623. $index,
  624. 'packing_materielDesignation',
  625. '包装',
  626. row
  627. )
  628. "
  629. v-model="row.materielDesignation"
  630. ></el-input>
  631. <span v-else>{{ row.materielDesignation }}</span>
  632. </template>
  633. </el-table-column>
  634. <el-table-column label="客户代号" prop="clientCode">
  635. <template slot-scope="{ row, $index }">
  636. <el-input v-model="row.clientCode"></el-input>
  637. </template>
  638. </el-table-column>
  639. <el-table-column label="刻码" prop="engrave" width="140">
  640. <template slot-scope="{ row, $index }">
  641. <el-input
  642. v-if="!row.isPack"
  643. :ref="'packing_engrave' + $index"
  644. @keyup.native="
  645. moveFocus($event, $index, 'packing_engrave', '包装', row)
  646. "
  647. v-model="row.engrave"
  648. ></el-input>
  649. <span v-else>{{ row.engrave }}</span>
  650. </template>
  651. </el-table-column>
  652. <el-table-column label="重量" prop="weight" width="100">
  653. <template slot-scope="{ row, $index }">
  654. <el-input
  655. v-if="!row.isPack && row.measureUnit != row.weightUnit"
  656. :ref="'packing_weight' + $index"
  657. @keyup.native="
  658. moveFocus($event, $index, 'packing_weight', '包装', row)
  659. "
  660. v-model.number="row.weight"
  661. @input="weightInput($event, row, '包装')"
  662. ></el-input>
  663. <span v-else>{{ row.weight }}</span>
  664. </template>
  665. </el-table-column>
  666. <el-table-column label="重量单位" prop="weightUnit">
  667. <template slot-scope="{ row }">
  668. {{ row.weightUnit }}
  669. </template>
  670. </el-table-column>
  671. <el-table-column label="机型" prop="modelKey" width="300">
  672. <template slot-scope="{ row }">
  673. <DictSelection
  674. dictName="物品机型"
  675. clearable
  676. v-model="row.modelKey"
  677. :isOne="false"
  678. filterable
  679. allow-create
  680. default-first-option
  681. >
  682. </DictSelection>
  683. </template>
  684. </el-table-column>
  685. <el-table-column label="颜色" prop="colorKey" width="300">
  686. <template slot-scope="{ row }">
  687. <DictSelection
  688. dictName="物品颜色"
  689. clearable
  690. v-model="row.colorKey"
  691. :isOne="false"
  692. filterable
  693. allow-create
  694. default-first-option
  695. >
  696. </DictSelection>
  697. </template>
  698. </el-table-column>
  699. <el-table-column label="质检结果" prop="result" width="120">
  700. <template slot-scope="{ row }">
  701. <el-select
  702. v-if="!row.isPack"
  703. @change="changeWrapStatus($event, row, '包装')"
  704. v-model="row.result"
  705. placeholder="请选择"
  706. >
  707. <el-option
  708. v-for="item in qualityResultsOptions"
  709. :label="item.label"
  710. :value="item.value"
  711. :key="item.value"
  712. >
  713. </el-option>
  714. </el-select>
  715. <span v-else>{{ qualityResults[row.result] }}</span>
  716. </template>
  717. </el-table-column>
  718. <el-table-column label="质检状态" prop="status" width="120">
  719. <template slot-scope="{ row }">
  720. <span>{{ qualityStatus[row.status] }}</span>
  721. </template>
  722. </el-table-column>
  723. <template v-if="formData.bizType == 5">
  724. <el-table-column
  725. label="生产日期"
  726. prop="productionDate"
  727. width="220"
  728. ></el-table-column>
  729. <el-table-column
  730. label="采购日期"
  731. prop="purchaseDate"
  732. width="220"
  733. ></el-table-column>
  734. </template>
  735. <template v-else>
  736. <el-table-column label="生产日期" prop="productionDate" width="220">
  737. <template slot-scope="{ row, $index }">
  738. <el-date-picker
  739. :disabled="row.isPack"
  740. size="small"
  741. v-model="row.productionDate"
  742. type="datetime"
  743. value-format="yyyy-MM-dd HH:mm:ss"
  744. placeholder="选择日期"
  745. >
  746. </el-date-picker
  747. ></template>
  748. </el-table-column>
  749. <el-table-column label="采购日期" prop="purchaseDate" width="220">
  750. <template slot-scope="{ row, $index }">
  751. <el-date-picker
  752. :disabled="row.isPack"
  753. size="small"
  754. v-model="row.purchaseDate"
  755. type="datetime"
  756. value-format="yyyy-MM-dd HH:mm:ss"
  757. placeholder="选择日期"
  758. >
  759. </el-date-picker
  760. ></template>
  761. </el-table-column>
  762. <el-table-column label="失效日期" prop="expireDate" width="220">
  763. <template slot-scope="{ row, $index }">
  764. <el-date-picker
  765. :disabled="row.isPack"
  766. size="small"
  767. v-model="row.expireDate"
  768. type="datetime"
  769. value-format="yyyy-MM-dd HH:mm:ss"
  770. placeholder="选择日期"
  771. >
  772. </el-date-picker
  773. ></template>
  774. </el-table-column>
  775. </template>
  776. <!-- <el-table-column label="操作" width="120" fixed="right">
  777. <template slot-scope="{ row, $index }">
  778. <el-button type="text" @click="wrapDelete(row, $index)">
  779. 删除
  780. </el-button>
  781. </template>
  782. </el-table-column> -->
  783. </el-table>
  784. </div>
  785. <div v-if="showMaterialList.length > 0" class="inbound_details">
  786. <header-title :title="`物料明细`"></header-title>
  787. <el-table
  788. ref="materialListTable"
  789. :data="showMaterialList"
  790. tooltip-effect="dark"
  791. :key="formData.bizType"
  792. :header-cell-style="rowClass"
  793. style="width: 100%"
  794. border
  795. stripe
  796. :max-height="300"
  797. v-el-table-infinite-scroll="materielHandleScroll"
  798. >
  799. <el-table-column label="序号" type="index" width="50">
  800. </el-table-column>
  801. <el-table-column
  802. label="编码"
  803. prop="categoryCode"
  804. width="130"
  805. :show-overflow-tooltip="true"
  806. ></el-table-column>
  807. <el-table-column
  808. label="名称"
  809. prop="categoryName"
  810. width="150"
  811. :show-overflow-tooltip="true"
  812. ></el-table-column>
  813. <el-table-column
  814. label="批次号"
  815. prop="batchNo"
  816. width="150"
  817. ></el-table-column>
  818. <el-table-column
  819. label="物料编码"
  820. prop="materialCode"
  821. width="200"
  822. :show-overflow-tooltip="true"
  823. ></el-table-column>
  824. <el-table-column
  825. label="计量数量"
  826. prop="measureQuantity"
  827. width="90"
  828. :show-overflow-tooltip="true"
  829. ></el-table-column>
  830. <el-table-column
  831. width="80"
  832. label="计量单位"
  833. prop="measureUnit"
  834. ></el-table-column>
  835. <el-table-column
  836. label="物料代号"
  837. prop="materielDesignation"
  838. width="130"
  839. >
  840. <template slot-scope="{ row, $index }">
  841. <el-input
  842. v-if="!row.isPack"
  843. :ref="'material_materielDesignation' + $index"
  844. @keyup.native="
  845. moveFocus(
  846. $event,
  847. $index,
  848. 'material_materielDesignation',
  849. '物料',
  850. row
  851. )
  852. "
  853. v-model="row.materielDesignation"
  854. ></el-input>
  855. <span v-else>{{ row.materielDesignation }}</span>
  856. </template>
  857. </el-table-column>
  858. <el-table-column label="客户代号" prop="clientCode">
  859. <template slot-scope="{ row, $index }">
  860. <el-input
  861. v-if="!row.isPack"
  862. :ref="'material_clientCode' + $index"
  863. @keyup.native="
  864. moveFocus($event, $index, 'material_clientCode', '物料', row)
  865. "
  866. v-model="row.extInfo.clientCode"
  867. ></el-input>
  868. <span v-else>{{ row.extInfo.clientCode }}</span>
  869. </template>
  870. </el-table-column>
  871. <el-table-column label="刻码" prop="engrave" width="140">
  872. <template slot-scope="{ row, $index }">
  873. <el-input
  874. v-if="!row.isPack"
  875. :ref="'material_engrave' + $index"
  876. @keyup.native="
  877. moveFocus($event, $index, 'material_engrave', '物料', row)
  878. "
  879. v-model="row.engrave"
  880. ></el-input>
  881. <span v-else>{{ row.engrave }}</span>
  882. </template>
  883. </el-table-column>
  884. <el-table-column label="重量" prop="weight" width="100">
  885. <template slot-scope="{ row, $index }">
  886. <el-input
  887. v-if="!row.isPack && row.measureUnit != row.weightUnit"
  888. :ref="'material_weight' + $index"
  889. @keyup.native="
  890. moveFocus($event, $index, 'material_weight', '物料', row)
  891. "
  892. @input="weightInput($event, row, '物料')"
  893. v-model.number="row.weight"
  894. ></el-input>
  895. <span v-else>{{ row.weight }}</span>
  896. </template>
  897. </el-table-column>
  898. <el-table-column
  899. label="重量单位"
  900. prop="weightUnit"
  901. width="100"
  902. ></el-table-column>
  903. <el-table-column label="质检结果" prop="result" width="120">
  904. <template slot-scope="{ row }">
  905. <el-select
  906. v-if="!row.isPack"
  907. @change="changeWrapStatus($event, row, '物料')"
  908. v-model="row.result"
  909. placeholder="请选择"
  910. >
  911. <el-option
  912. v-for="item in qualityResultsOptions"
  913. :label="item.label"
  914. :value="item.value"
  915. :key="item.value"
  916. >
  917. </el-option>
  918. </el-select>
  919. <span v-else>{{ qualityResults[row.result] }}</span>
  920. </template>
  921. </el-table-column>
  922. <el-table-column label="质检状态" prop="status" width="120">
  923. <template slot-scope="{ row }">
  924. <span>{{ qualityStatus[row.status] }}</span>
  925. </template>
  926. </el-table-column>
  927. <!-- <el-table-column label="操作" width="120" fixed="right">
  928. <template slot-scope="{ row, $index }">
  929. <el-button type="text" @click="materialDelete(row, $index)">
  930. 删除
  931. </el-button>
  932. </template>
  933. </el-table-column> -->
  934. </el-table>
  935. </div>
  936. <div class="storage_btn">
  937. <el-button
  938. type="primary"
  939. :loading="saveLoading"
  940. @click="handleStorage('save')"
  941. >保存</el-button
  942. >
  943. <el-button
  944. type="primary"
  945. :loading="saveLoading"
  946. @click="handleStorage('Storage')"
  947. >入库</el-button
  948. >
  949. </div>
  950. </el-card>
  951. <!-- 产品选择弹框 -->
  952. <selectType
  953. :visibleDialog.sync="visibleDialog"
  954. :title="title"
  955. :bizScene="formData.bizType"
  956. :treeIds="formData.extInfo.assetType"
  957. :loadTree.sync="loadTree"
  958. @selectTableData="addGoods"
  959. :cacheKeyUrl="'wms-warehouseManagement-stockManagement-add'"
  960. />
  961. <!-- 仓库选择弹框 -->
  962. <WarehousingDialog
  963. ref="wareHouseDailogRef"
  964. @selection="wareHouseSelection"
  965. ></WarehousingDialog>
  966. <!-- 生产日期、采购日期弹框 -->
  967. <el-dialog :visible.sync="dateVisible" title="选择日期" width="400px">
  968. <el-date-picker
  969. size="small"
  970. v-model="batchTime"
  971. type="datetime"
  972. style="width: 320px"
  973. value-format="yyyy-MM-dd HH:mm:ss"
  974. placeholder="选择日期"
  975. >
  976. </el-date-picker>
  977. <div style="text-align: right; margin-top: 20px">
  978. <el-button @click="dateVisible = false">取消</el-button>
  979. <el-button type="primary" @click="dateConfirm" :disabled="!batchTime"
  980. >确认</el-button
  981. >
  982. </div>
  983. </el-dialog>
  984. <outboundRequisitionDialog
  985. ref="outboundRequisitionDialogRef"
  986. @detailData="outboundRequisitionSelection"
  987. type="1"
  988. :bizType="formData.bizType"
  989. />
  990. </div>
  991. </template>
  992. <script>
  993. import XLSX from 'xlsx';
  994. import { mapActions, mapGetters } from 'vuex';
  995. import outboundRequisitionDialog from '../components/outboundRequisitionDialog.vue';
  996. import openContactDialog from '@/components/contactDialog/openContactDialog.vue';
  997. import elTableInfiniteScroll from 'el-table-infinite-scroll';
  998. import storageApi from '@/api/warehouseManagement/index.js';
  999. import WarehousingDialog from '../components/WarehousingDialog.vue';
  1000. import { getCode } from '@/api/codeManagement/index.js';
  1001. import selectType from './components/selectType';
  1002. import warehouseDefinition from '@/api/warehouseManagement/warehouseDefinition';
  1003. import {
  1004. sceneState,
  1005. qualityResultsOptions,
  1006. qualityResults,
  1007. qualityStatus
  1008. } from '@/utils/dict/index';
  1009. import { getTreeByGroup } from '@/api/classifyManage';
  1010. import outin from '@/api/warehouseManagement/outin';
  1011. import { deepClone } from '@/utils';
  1012. import BigNumber from 'bignumber.js';
  1013. import { isBoolean } from 'mathjs';
  1014. import { parameterGetByCode } from '@/api/sys/index.js';
  1015. import tabMixins from '@/mixins/tableColumnsMixin';
  1016. import { color } from 'echarts';
  1017. export default {
  1018. mixins: [tabMixins],
  1019. name: 'stockManagementAdd',
  1020. components: {
  1021. selectType,
  1022. WarehousingDialog,
  1023. outboundRequisitionDialog,
  1024. openContactDialog
  1025. },
  1026. // 虚拟列表滚动方法
  1027. directives: {
  1028. 'el-table-infinite-scroll': elTableInfiniteScroll
  1029. },
  1030. data() {
  1031. return {
  1032. newDynamicColumns: [], // 动态表头
  1033. sceneState,
  1034. saveLoading: false,
  1035. dateVisible: false,
  1036. loadTree: true,
  1037. visibleDialog: false,
  1038. title: '选择产品',
  1039. goodsLists: [],
  1040. cacheKeyUrl: 'wms-stockManagement-add-goods',
  1041. formData: {
  1042. bizType: '',
  1043. storageTime: '',
  1044. extInfo: {
  1045. assetType: []
  1046. }
  1047. },
  1048. rules: {
  1049. 'extInfo.assetType': {
  1050. required: true,
  1051. message: '请选择物品类型',
  1052. trigger: ['change', 'blur']
  1053. },
  1054. bizType: {
  1055. required: true,
  1056. message: '请选择入库场景',
  1057. trigger: 'change'
  1058. }
  1059. },
  1060. qualityResultsOptions, // 质检结果下拉选项 0无 1合格 2不合格
  1061. qualityStatus, // 质检状态 0未检 1已检
  1062. qualityResults, // 质检结果 0无 1合格 2不合格
  1063. productList: [], // 产品列表
  1064. packingList: [], // 包装列表
  1065. showPackingList: [], // 包装列表(虚拟列表)
  1066. materialList: [], // 物料列表
  1067. showMaterialList: [], // 物料列表(虚拟列表)
  1068. curDateType: 'productionDate',
  1069. packingListSelected: [], // 包装选择列表
  1070. isWrapTable: true, // 解决表格不刷新问题(包装)
  1071. currentPackingQuantity: '', // 当前包装数量
  1072. batchTime: '', // 生产日期、采购日期
  1073. pageSize: 20, // 物料和包装列表条数
  1074. pickingPageNum: 1, // 包装虚拟分页页数
  1075. materielPageNum: 1, // 物料虚拟分页页数
  1076. packingSpecificationOption: [], // 包装规格下拉
  1077. isPrice: 1,
  1078. columnsVersion: 1
  1079. };
  1080. },
  1081. computed: {
  1082. ...mapGetters(['dict', 'getDict']),
  1083. clientEnvironmentId() {
  1084. return this.$store.state.user.info.clientEnvironmentId;
  1085. },
  1086. columns() {
  1087. // 当columnsVersion变化时会重新计算
  1088. const version = this.columnsVersion;
  1089. return [
  1090. {
  1091. label: '序号',
  1092. type: 'index',
  1093. width: 50,
  1094. align: 'center'
  1095. },
  1096. {
  1097. label: '产品编码',
  1098. prop: 'categoryCode',
  1099. width: 130,
  1100. showOverflowTooltip: true,
  1101. align: 'center'
  1102. },
  1103. {
  1104. showOverflowTooltip: true,
  1105. label: '产品名称',
  1106. prop: 'categoryName',
  1107. width: 200,
  1108. align: 'center'
  1109. },
  1110. {
  1111. label: '型号',
  1112. showOverflowTooltip: true,
  1113. prop: 'categoryModel',
  1114. width: 100,
  1115. align: 'center'
  1116. },
  1117. {
  1118. label: '规格',
  1119. prop: 'specification',
  1120. showOverflowTooltip: true,
  1121. width: 100,
  1122. align: 'center'
  1123. },
  1124. {
  1125. label: '牌号',
  1126. prop: 'brandNum',
  1127. showOverflowTooltip: true,
  1128. width: 100,
  1129. align: 'center'
  1130. },
  1131. ...this.newDynamicColumns.map((item) => {
  1132. return {
  1133. label: item.label,
  1134. prop: item.prop,
  1135. showOverflowTooltip: true,
  1136. width: 100,
  1137. align: 'center'
  1138. };
  1139. }),
  1140. {
  1141. label: '批次号',
  1142. showOverflowTooltip: true,
  1143. prop: 'batchNo',
  1144. width: 200,
  1145. slot: 'batchNo',
  1146. align: 'center',
  1147. headerSlot: 'headerBatchNo'
  1148. },
  1149. {
  1150. label: '系统内部批次号',
  1151. showOverflowTooltip: true,
  1152. prop: 'systemBatchNo',
  1153. minWidth: 180,
  1154. align: 'center',
  1155. formatter: (row) => row.systemBatchNo || '-'
  1156. },
  1157. {
  1158. label: '数量',
  1159. showOverflowTooltip: true,
  1160. prop: 'quantity',
  1161. slot: 'quantity',
  1162. width: 180,
  1163. align: 'center',
  1164. headerSlot: 'headerPackingQuantity'
  1165. },
  1166. {
  1167. label: '单位',
  1168. showOverflowTooltip: true,
  1169. prop: 'unit',
  1170. slot: 'unit',
  1171. width: 100,
  1172. align: 'center',
  1173. headerSlot: 'headerUnit'
  1174. },
  1175. {
  1176. label: '包装数量',
  1177. showOverflowTooltip: true,
  1178. prop: 'packingQuantity',
  1179. slot: 'packingQuantity',
  1180. width: 180,
  1181. align: 'center'
  1182. },
  1183. {
  1184. label: '包装单位',
  1185. showOverflowTooltip: true,
  1186. prop: 'packingUnit',
  1187. slot: 'packingUnit',
  1188. width: 100,
  1189. align: 'center'
  1190. },
  1191. {
  1192. label: '包装规格',
  1193. showOverflowTooltip: true,
  1194. prop: 'packingSpecificationLabel',
  1195. slot: 'packingSpecificationLabel',
  1196. width: 300,
  1197. align: 'center'
  1198. },
  1199. {
  1200. label: '允许拆包',
  1201. prop: 'isUnpack',
  1202. width: 80,
  1203. formatter: (_row, _column, cellValue) => {
  1204. return cellValue ? '是' : '否';
  1205. },
  1206. align: 'center'
  1207. },
  1208. {
  1209. label: '计量数量',
  1210. prop: 'measureQuantity',
  1211. width: 100,
  1212. align: 'center'
  1213. },
  1214. {
  1215. label: '计量单位',
  1216. prop: 'measureUnit',
  1217. width: 100,
  1218. align: 'center'
  1219. },
  1220. {
  1221. label: '单重',
  1222. prop: 'singleWeight',
  1223. slot: 'singleWeight',
  1224. showOverflowTooltip: true,
  1225. width: 180,
  1226. align: 'center'
  1227. },
  1228. {
  1229. label: '总重',
  1230. prop: 'weight',
  1231. slot: 'weight',
  1232. showOverflowTooltip: true,
  1233. width: 150,
  1234. align: 'center'
  1235. },
  1236. {
  1237. label: '重量单位',
  1238. prop: 'weightUnit',
  1239. showOverflowTooltip: true,
  1240. width: 100,
  1241. align: 'center'
  1242. },
  1243. this.isPrice == 1
  1244. ? {
  1245. label: '单价',
  1246. slot: 'price',
  1247. prop: 'price',
  1248. showOverflowTooltip: true,
  1249. width: 150,
  1250. align: 'center'
  1251. }
  1252. : {
  1253. label: '单价',
  1254. prop: 'price',
  1255. width: 1
  1256. },
  1257. this.isPrice == 1
  1258. ? {
  1259. label: '金额',
  1260. slot: 'totalMoney',
  1261. prop: 'totalMoney',
  1262. showOverflowTooltip: true,
  1263. width: 100,
  1264. align: 'center'
  1265. }
  1266. : {
  1267. label: '金额',
  1268. prop: 'totalMoney',
  1269. width: 1
  1270. },
  1271. {
  1272. label: '供应商',
  1273. slot: 'supplierId',
  1274. prop: 'supplierId',
  1275. showOverflowTooltip: true,
  1276. width: 200,
  1277. align: 'center'
  1278. },
  1279. {
  1280. label: '供应商代号',
  1281. slot: 'supplierCode',
  1282. prop: 'supplierCode',
  1283. showOverflowTooltip: true,
  1284. width: 100,
  1285. align: 'center'
  1286. },
  1287. {
  1288. label: '仓库',
  1289. prop: 'warehouseName',
  1290. slot: 'warehouseName',
  1291. showOverflowTooltip: true,
  1292. width: 300,
  1293. align: 'center',
  1294. headerSlot: 'headerWarehouseName'
  1295. },
  1296. {
  1297. minWidth: 200,
  1298. prop: 'modelKey',
  1299. showOverflowTooltip: true,
  1300. label: '机型',
  1301. slot: 'modelKey',
  1302. align: 'center'
  1303. },
  1304. {
  1305. minWidth: 200,
  1306. prop: 'colorKey',
  1307. showOverflowTooltip: true,
  1308. label: '颜色',
  1309. slot: 'colorKey',
  1310. align: 'center'
  1311. },
  1312. {
  1313. minWidth: 200,
  1314. prop: 'reelSpecification',
  1315. showOverflowTooltip: true,
  1316. label: '盘具',
  1317. slot: 'reelSpecification',
  1318. align: 'center'
  1319. },
  1320. {
  1321. label: '采购原因',
  1322. prop: 'purpose',
  1323. slot: 'purpose',
  1324. showOverflowTooltip: true,
  1325. width: 200,
  1326. align: 'center'
  1327. },
  1328. {
  1329. label: '生产日期',
  1330. prop: 'detailProductionDate',
  1331. slot: 'detailProductionDate',
  1332. showOverflowTooltip: true,
  1333. width: 220,
  1334. align: 'center'
  1335. },
  1336. {
  1337. label: '采购日期',
  1338. prop: 'detailPurchaseDate',
  1339. slot: 'detailPurchaseDate',
  1340. showOverflowTooltip: true,
  1341. width: 220,
  1342. align: 'center'
  1343. },
  1344. {
  1345. label: '失效日期',
  1346. prop: 'detailExpireDate',
  1347. slot: 'detailExpireDate',
  1348. showOverflowTooltip: true,
  1349. width: 220,
  1350. align: 'center'
  1351. },
  1352. {
  1353. columnKey: 'action',
  1354. label: '操作',
  1355. width: 250,
  1356. align: 'center',
  1357. resizable: false,
  1358. slot: 'action',
  1359. showOverflowTooltip: true,
  1360. fixed: 'right'
  1361. }
  1362. ];
  1363. }
  1364. },
  1365. watch: {
  1366. packingList: {
  1367. handler(newVal) {
  1368. console.log('包装列表', newVal);
  1369. console.log('当前包装列表加载页数', this.pickingPageNum);
  1370. this.showPackingList = newVal.slice(
  1371. 0,
  1372. this.pageSize * (this.pickingPageNum > 0 ? this.pickingPageNum : 1)
  1373. );
  1374. this.pickingPageNum = Math.ceil(
  1375. this.showPackingList.length / this.pageSize
  1376. );
  1377. },
  1378. deep: true
  1379. },
  1380. materialList: {
  1381. handler(newVal) {
  1382. console.log('物料列表', newVal);
  1383. console.log('当前物料列表加载页数', this.materielPageNum);
  1384. this.showMaterialList = newVal.slice(
  1385. 0,
  1386. this.pageSize *
  1387. (this.materielPageNum > 0 ? this.materielPageNum : 1)
  1388. );
  1389. },
  1390. deep: true
  1391. },
  1392. '$route.query': {
  1393. handler(newQuery, oldQuery) {
  1394. if (newQuery?.detailId) {
  1395. this.viewInit();
  1396. }
  1397. },
  1398. deep: true // 确保对象内部的属性变化也能被监听到
  1399. }
  1400. },
  1401. created() {
  1402. //仓库出入库是否显示金额(0:不显示 1:显示)
  1403. parameterGetByCode({
  1404. code: 'wms_price'
  1405. }).then((res) => {
  1406. this.isPrice = res.value;
  1407. });
  1408. if (this.$route.query.name == 'inboundRequests') {
  1409. this.getProduct();
  1410. }
  1411. this.requestDict('不拆物料层规格');
  1412. this.getFieldModel();
  1413. this.getListItems();
  1414. this.initUserInfo();
  1415. this.getNowFormatDate();
  1416. if (this.$route.query.id && !this.$route.query.name) {
  1417. storageApi
  1418. .getApplystorageDetailById(this.$route.query.id)
  1419. .then(async (data) => {
  1420. this.formData.extInfo.assetType = [data.rootCategoryLevelId];
  1421. this.formData.bizType = String(data.type);
  1422. this.formData.sourceBizNo = data.code;
  1423. this.formData.id = data.id;
  1424. this.formData.bizNo = data.bizNo;
  1425. const batchNo = await getCode('lot_number_code');
  1426. this.productList = data.detailList.map((item, index) => {
  1427. return {
  1428. index: this.productList.length + index,
  1429. categoryId: item.categoryId, // 物品id
  1430. categoryName: item.categoryName, // 物品名称
  1431. categoryCode: item.categoryCode, // 物品编码
  1432. categoryModel: item.modelType, // 物品型号
  1433. specification: item.specification, // 规格
  1434. brandNum: item.brandNum, // 牌号
  1435. batchNo: item.batchNo || batchNo, // 批次号
  1436. systemBatchNo: item.systemBatchNo || '', // 系统内部批次号
  1437. minPackingQuantity: item.quantity, // 最小包装单元数量
  1438. packingQuantity: 1, // 包装数量
  1439. packingUnit: item.packingUnit, // 单位
  1440. measureQuantity: 0, // 计量数量
  1441. measureUnit: item.measuringUnit, // 计量单位
  1442. netWeight: item.netWeight > -1 ? item.netWeight : 0, // 净重
  1443. weight: item?.packingWeight || 0, // 重量
  1444. weightUnit: item.weightUnit, // 重量单位
  1445. totalMoney: '', // 总价
  1446. unitPrice: item.unitPrice, // 单价
  1447. purpose: item.purpose, // 用途
  1448. isUnpack: item.isUnpack, // 是否允许拆包
  1449. warehouseId: item.warehouseId, // 仓库Id
  1450. warehouseName: item.warehouseName, // 仓库名称
  1451. warehouseIds: [item.warehouseId],
  1452. warehouseNames: [item.warehouseName]
  1453. // 编辑时单位选择消失bug
  1454. };
  1455. });
  1456. // this.$nextTick(() => {
  1457. // this.listSaveArrs();
  1458. // });
  1459. });
  1460. }
  1461. if (this.$route.query.detailId) {
  1462. this.viewInit();
  1463. }
  1464. },
  1465. methods: {
  1466. ...mapActions('dict', ['requestDict']),
  1467. changeCount(number) {
  1468. return new BigNumber(number).toString();
  1469. },
  1470. viewInit() {
  1471. const _this = this;
  1472. // 编辑时选单位没有选项bug
  1473. let packingSpecification;
  1474. storageApi
  1475. .getInboundDetailsById(this.$route.query.detailId)
  1476. .then(async (data) => {
  1477. this.formData.extInfo.assetType = data.extInfo.assetType.split(',');
  1478. this.formData.bizType = String(data.bizType);
  1479. this.formData.sourceBizNo = data.code;
  1480. this.formData.id = data.id;
  1481. this.formData.bizNo = data.bizNo;
  1482. const batchNo = await getCode('lot_number_code');
  1483. packingSpecification =
  1484. await storageApi.getCategoryPackageDisposition({
  1485. categoryIds: data.outInDetailList.map((item) => item.categoryId)
  1486. });
  1487. console.log(packingSpecification);
  1488. this.packingSpecificationOption = data.outInDetailList.map(
  1489. (item) => {
  1490. return packingSpecification
  1491. .filter((ite) => item.categoryId == ite.categoryId)
  1492. .sort((a, b) => a.sort - b.sort);
  1493. }
  1494. );
  1495. const newSpecificationOption = this.packingSpecificationOption;
  1496. this.productList = data.outInDetailList.map(
  1497. (productItem, productIndex) => {
  1498. return {
  1499. ...productItem,
  1500. index: this.productList.length + productIndex,
  1501. isSave: true,
  1502. // 编辑时没有单位选项
  1503. packingSpecificationOption:
  1504. newSpecificationOption[productIndex],
  1505. //
  1506. packingSpecificationLabel:
  1507. productItem.extField?.packingSpecification?.split(','),
  1508. batchNo: productItem.batchNo || batchNo, // 批次号
  1509. systemBatchNo: productItem.systemBatchNo || '', // 系统内部批次号
  1510. warehouseIds: [productItem.warehouseId], // 仓库Id
  1511. warehouseNames: [productItem.warehouseName], // 仓库名称
  1512. outInDetailRecordRequestList:
  1513. productItem.outInDetailRecordRequestList?.length > 0
  1514. ? productItem.outInDetailRecordRequestList.map(
  1515. (packingItem, packingIndex) => {
  1516. return {
  1517. ...packingItem,
  1518. index:
  1519. this.productList.length +
  1520. productIndex +
  1521. '-' +
  1522. packingIndex, // 包装索引
  1523. batchNo: productItem.batchNo || batchNo, // 批次号
  1524. systemBatchNo: productItem.systemBatchNo || '', // 系统内部批次号
  1525. parentIndex:
  1526. this.productList.length + productIndex, // 物品索引
  1527. categoryName: productItem.categoryName,
  1528. categoryCode: productItem.categoryCode,
  1529. reelSpecification: productItem.reelSpecification,
  1530. materialDetailList:
  1531. packingItem.materialDetailList.map(
  1532. (materialItem, materialIndex) => {
  1533. return {
  1534. ...materialItem,
  1535. index:
  1536. this.productList.length +
  1537. productIndex +
  1538. '-' +
  1539. packingIndex +
  1540. '——' +
  1541. materialIndex, // 包装索引
  1542. parentIndex:
  1543. this.productList.length +
  1544. productIndex +
  1545. '-' +
  1546. packingIndex, // 物品索引
  1547. batchNo: batchNo, // 批次号
  1548. categoryName: productItem.categoryName,
  1549. categoryCode: productItem.categoryCode
  1550. };
  1551. }
  1552. )
  1553. };
  1554. }
  1555. )
  1556. : []
  1557. };
  1558. }
  1559. );
  1560. console.log('this.productList-----------', this.productList);
  1561. // 获取包装维度数据
  1562. const arr = [];
  1563. for (const key in this.productList) {
  1564. for (const k in this.productList[key]
  1565. .outInDetailRecordRequestList) {
  1566. arr.push({
  1567. ...this.productList[key].outInDetailRecordRequestList[k]
  1568. });
  1569. }
  1570. }
  1571. this.packingList = arr;
  1572. // 获取物料维度数据
  1573. let iArr = [];
  1574. arr.forEach((item) => {
  1575. item.materialDetailList.forEach((ele) => {
  1576. iArr.push({ ...ele });
  1577. });
  1578. });
  1579. this.materialList = iArr;
  1580. });
  1581. },
  1582. selectSupplier(val, row) {
  1583. row.supplierId = val;
  1584. row.supplierName = row.supplierListOptions.filter(
  1585. (item) => item.id == val
  1586. )[0].name;
  1587. row.supplierCode = row.supplierListOptions.filter(
  1588. (item) => item.id == val
  1589. )[0].serialNo;
  1590. },
  1591. inputSingleWeight(row, index) {
  1592. console.log(row, 'row1');
  1593. if (row.singleWeight < 0) {
  1594. this.$set(this.productList[index], 'singleWeight', 1);
  1595. }
  1596. if (row.measureUnit == row.weightUnit) {
  1597. row.weight = row.singleWeight * row.quantity;
  1598. row.measureQuantity = row.weight;
  1599. } else {
  1600. row.weight = row.singleWeight * row.measureQuantity;
  1601. }
  1602. //重量
  1603. // if (row.measureType == '2') {
  1604. // if (row.packingUnit == 'KG') {
  1605. // const weight =
  1606. // Number(row.measureQuantity) * Number(row.singleWeight);
  1607. // this.$set(this.productList[index], 'weight', weight);
  1608. // } else {
  1609. // this.$set(this.productList[index], 'weight', measureQuantity);
  1610. // }
  1611. // }
  1612. console.log(row, 'row2');
  1613. },
  1614. inputAllweight(row, index) {
  1615. if (row.weight < 0) {
  1616. this.$set(this.productList[index], 'weight', 1);
  1617. }
  1618. if (row.measureUnit == row.weightUnit) {
  1619. row.measureQuantity = row.weight;
  1620. row.singleWeight =
  1621. Math.trunc((row.measureQuantity / row.quantity) * 10000) / 10000;
  1622. } else {
  1623. row.singleWeight = row.measureQuantity
  1624. ? row.weight / row.measureQuantity
  1625. : 0;
  1626. }
  1627. // const singleWeight = Number(row.weight) / Number(row.measureQuantity);
  1628. // this.$set(this.productList[index], 'singleWeight', singleWeight);
  1629. },
  1630. // 仓库选择
  1631. // wareHouseSelection(val, index) {
  1632. // console.log('仓库选择', val);
  1633. // let arr = this.productList[index].outInDetail
  1634. // },
  1635. // 计算最小单元数量
  1636. // 小数处理,最大3位
  1637. format3(str) {
  1638. let value = str;
  1639. value = value.toString().replace(/[^0-9.]/g, '');
  1640. const parts = value.split('.');
  1641. if (parts.length > 2) {
  1642. value = parts[0] + '.' + parts.slice(1).join('');
  1643. }
  1644. if (parts.length === 2) {
  1645. value = parts[0] + '.' + parts[1].slice(0, 3);
  1646. }
  1647. console.log(value);
  1648. return value;
  1649. },
  1650. async computeNum(row, index, isClear) {
  1651. row.quantity = this.format3(row.quantity);
  1652. // console.log(row.packingSpecificationOption);
  1653. // console.log(row.packingUnit);
  1654. let data = row.packingSpecificationOption.find(
  1655. (item) => item.id == row.unitId
  1656. );
  1657. row.unit = data.conversionUnit;
  1658. // 清空仓库(包装数量输入)
  1659. if (isClear) {
  1660. if (row.quantity < 0) {
  1661. this.$set(this.productList[index], 'quantity', 1);
  1662. }
  1663. }
  1664. //如果有包装数量和包装单位
  1665. if (row.quantity && row.unit) {
  1666. //获取仓库
  1667. const res = await warehouseDefinition.list({
  1668. inventoryType: row?.categoryLevelPathIdParent
  1669. });
  1670. // 只有一个仓库自动显示出来
  1671. if (res.length == 1) {
  1672. // let name = res[0]?.factoryName + '-' + res[0]?.name;
  1673. let name = res[0]?.name;
  1674. console.log('仓库-----------------------------', res);
  1675. this.$set(this.productList[index], 'warehouseId', res[0].id);
  1676. this.$set(this.productList[index], 'warehouseName', name);
  1677. let table1 = [];
  1678. table1.push({
  1679. measureQuantity: row.measureQuantity,
  1680. packingQuantity: row.quantity,
  1681. warehouseName: name,
  1682. warehouseId: res[0].id
  1683. });
  1684. this.wareHouseSelection(table1, index);
  1685. } else {
  1686. this.$set(this.productList[index], 'warehouseId', '');
  1687. this.$set(this.productList[index], 'warehouseName', '');
  1688. }
  1689. // -----------------------------------------------------------------
  1690. // let startIndex = row.packingSpecificationOption.findIndex((ite) => {
  1691. // return (
  1692. // data.id == ite.id &&
  1693. // ite.packingUnit != ite.conversionUnit
  1694. // );
  1695. // });
  1696. let endIndex = row.packingSpecificationOption.findIndex(
  1697. (ite) => data.id == ite.id
  1698. );
  1699. console.log(endIndex, 'endIndex');
  1700. let total = Number(row.quantity);
  1701. for (; 0 < endIndex; endIndex--) {
  1702. total = this.$math.format(
  1703. row.packingSpecificationOption[endIndex].packageCell * total,
  1704. 14
  1705. );
  1706. }
  1707. //计量数量
  1708. row.measureQuantity = this.changeCount(total);
  1709. // --------------------------------------------------------------------
  1710. //计量单位不是数量时,配置了单重的重量计算
  1711. // row.measureType != 1 &&
  1712. let weight = 0;
  1713. if (row.measureUnit == row.weightUnit) {
  1714. weight = row.measureQuantity;
  1715. //包装单位与重量单位相等时,单重重量为0
  1716. if (row.unit == row.weightUnit) {
  1717. row.singleWeight = 0;
  1718. } else {
  1719. row.singleWeight =
  1720. Math.trunc((row.measureQuantity / row.quantity) * 10000) /
  1721. 10000;
  1722. }
  1723. } else if (row.singleWeight) {
  1724. weight = row.measureQuantity * Number(row.singleWeight);
  1725. }
  1726. this.$set(this.productList[index], 'weight', weight);
  1727. this.$set(
  1728. this.productList[index],
  1729. 'packingQuantity',
  1730. this.setPNum(row)
  1731. );
  1732. }
  1733. },
  1734. //出入库申请列表操作直接入库
  1735. getProduct() {
  1736. let aaa = [this.$route.query.inId];
  1737. console.log(aaa, '出入库申请入库操作直接入库');
  1738. storageApi.getApplystoragedetails(aaa).then(async (res) => {
  1739. if (this.$route.query.type == 2) {
  1740. // 出库
  1741. let data = await storageApi.getHierarchyFifo({
  1742. type: 1,
  1743. builders: res.map((item) => {
  1744. return {
  1745. categoryId: item.categoryId,
  1746. batchNo: item.batchNo,
  1747. systemBatchNo: item.systemBatchNo || '',
  1748. num: item.measureQuantity
  1749. };
  1750. })
  1751. });
  1752. if (data?.length > 0) {
  1753. this.outboundRequisitionSelection(data, 1, {
  1754. sourceBizNo: this.$route.query.code,
  1755. bizType: this.$route.query.sourceType,
  1756. assetType: Array.from(
  1757. new Set(res.map((item) => item.rootCategoryLevelId))
  1758. ).join(',')
  1759. });
  1760. } else {
  1761. this.$message.warning('该出库申请单无库存');
  1762. }
  1763. } else {
  1764. // 入库
  1765. const batchNo = await getCode('lot_number_code');
  1766. console.log(res, '入库');
  1767. let data = res.map((item, index) => {
  1768. delete item.extInfo;
  1769. return {
  1770. ...item,
  1771. index,
  1772. batchNo,
  1773. id: '',
  1774. warehouseIds: [item.warehouseId],
  1775. warehouseNames: [item.warehouseName]
  1776. };
  1777. });
  1778. this.outboundRequisitionSelection(data, 1, {
  1779. sourceBizNo: this.$route.query.code,
  1780. bizType: this.$route.query.sourceType,
  1781. assetType: Array.from(
  1782. new Set(res.map((item) => item.rootCategoryLevelId))
  1783. ).join(',')
  1784. });
  1785. }
  1786. });
  1787. },
  1788. async outboundRequisitionSelection(data, dimension, query) {
  1789. console.log('data-----------', data);
  1790. console.log('query-----------', query);
  1791. console.log(this.formData.bizType, 'bbbbbtype');
  1792. if (this.formData.bizType != 10) {
  1793. this.formData.sourceBizNo = query.sourceBizNo;
  1794. this.formData.bizType = query.bizType;
  1795. this.formData.extInfo.assetType = query.assetType.split(',');
  1796. const batchNo = await getCode('lot_number_code');
  1797. // 获取包装规格
  1798. let packingSpecification =
  1799. await storageApi.getCategoryPackageDisposition({
  1800. categoryIds: data.map((item) => item.categoryId)
  1801. });
  1802. // 获取供应商
  1803. const supplierList = await storageApi.contactQueryByCategoryIdsAPI({
  1804. categoryIds: data.map((item) => item.categoryId)
  1805. });
  1806. this.packingSpecificationOption = data.map((item) => {
  1807. return packingSpecification
  1808. .filter((ite) => item.categoryId == ite.categoryId)
  1809. .sort((a, b) => a.sort - b.sort);
  1810. });
  1811. console.log(
  1812. 'this.packingSpecificationOption------------------------------------------包装组',
  1813. this.packingSpecificationOption
  1814. );
  1815. console.log(data, 'datadatadatadatadata');
  1816. data.map((productItem, productIndex) => {
  1817. // 显示规格
  1818. let packingSpecificationLabel = this.packingSpecificationOption[
  1819. productIndex
  1820. ]
  1821. .map((item) => {
  1822. if (item.sort > 0) {
  1823. return `${item.packageCell}${item.packageUnit}/${item.conversionUnit}`;
  1824. }
  1825. })
  1826. .filter((item) => !!item);
  1827. // let r= {
  1828. // ...productItem,
  1829. console.log(productItem, 'productItem');
  1830. productItem.weight = productItem.weight
  1831. ? Number(productItem.weight)
  1832. : 0;
  1833. // productItem.singleWeight = 0;
  1834. productItem.measureUnit = productItem.measuringUnit; // 计量单位
  1835. productItem.index = this.productList.length + productIndex;
  1836. productItem.isSave =
  1837. productItem.outInDetailRecordRequestList?.length > 0
  1838. ? true
  1839. : false;
  1840. productItem.netWeight =
  1841. productItem.netWeight > 0 ? productItem.netWeight : 0;
  1842. productItem.materielCode = productItem.materielCode;
  1843. productItem.categoryModel = productItem.modelType; // 物品型号
  1844. productItem.specification = productItem.specification; // 规格
  1845. productItem.engrave = productItem.engrave; // 刻码
  1846. productItem.materielDesignation = productItem.materielDesignation; //物料代号
  1847. productItem.clientCode = productItem.clientCode; // 客户代号
  1848. productItem.batchNo = productItem.batchNo || batchNo; // 批次号
  1849. productItem.warehouseIds = [productItem.warehouseId]; // 仓库Id
  1850. productItem.warehouseNames = [productItem.warehouseName]; // 仓库名称
  1851. productItem.packingSpecificationOption =
  1852. this.packingSpecificationOption[productIndex]; // 包装规格选项
  1853. productItem.packingSpecificationLabel = packingSpecificationLabel; // 包装规格显示
  1854. productItem.outInDetailRecordRequestList =
  1855. productItem.outInDetailRecordRequestList?.length > 0
  1856. ? productItem.outInDetailRecordRequestList.map(
  1857. (packingItem, packingIndex) => {
  1858. return {
  1859. ...packingItem,
  1860. index:
  1861. this.productList.length +
  1862. productIndex +
  1863. '-' +
  1864. packingIndex, // 包装索引
  1865. batchNo: productItem.batchNo || batchNo, // 批次号
  1866. systemBatchNo: productItem.systemBatchNo || '', // 系统内部批次号
  1867. parentIndex: this.productList.length + productIndex, // 物品索引
  1868. categoryName: productItem.categoryName,
  1869. categoryCode: productItem.categoryCode,
  1870. materialDetailList: packingItem.materialDetailList.map(
  1871. (materialItem, materialIndex) => {
  1872. return {
  1873. ...materialItem,
  1874. index:
  1875. this.productList.length +
  1876. productIndex +
  1877. '-' +
  1878. packingIndex +
  1879. '——' +
  1880. materialIndex, // 包装索引
  1881. parentIndex:
  1882. this.productList.length +
  1883. productIndex +
  1884. '-' +
  1885. packingIndex, // 物品索引
  1886. batchNo: batchNo, // 批次号
  1887. categoryName: productItem.categoryName,
  1888. categoryCode: productItem.categoryCode
  1889. };
  1890. }
  1891. )
  1892. };
  1893. }
  1894. )
  1895. : [];
  1896. });
  1897. // this.productList = data;
  1898. this.productList = data.map((item) => {
  1899. if (item.weight === null || item.weight === undefined) {
  1900. item.weight = 0;
  1901. }
  1902. (item.supplierListOptions = supplierList[item.categoryId]), // 供应商列表
  1903. (item.packingUnit = item.measuringUnit); // 单位
  1904. item.packingUnitId = item.packingSpecificationOption.find(
  1905. (v) => v.conversionUnit == item.measuringUnit
  1906. )?.id; // 单位
  1907. // if (this.formData.bizType == 4) {
  1908. // item.packingUnit = '箱';
  1909. // } else {
  1910. // item.packingUnit = '';
  1911. // }
  1912. return item;
  1913. });
  1914. console.log(this.productList, 'productList');
  1915. this.$nextTick(() => {
  1916. this.batchSave();
  1917. });
  1918. // this.productList.map((v) => {
  1919. // v.weight = isNaN(v.weight);
  1920. // });
  1921. // 获取包装维度数据
  1922. // const arr = [];
  1923. // for (const key in this.productList) {
  1924. // for (const k in this.productList[key]
  1925. // .outInDetailRecordRequestList) {
  1926. // arr.push({
  1927. // ...this.productList[key].outInDetailRecordRequestList[k]
  1928. // });
  1929. // }
  1930. // }
  1931. // 获取物料维度数据
  1932. // let iArr = [];
  1933. // arr.forEach((item) => {
  1934. // item.materialDetailList.forEach((ele) => {
  1935. // iArr.push({ ...ele });
  1936. // });
  1937. // });
  1938. // this.materialList = iArr;
  1939. } else {
  1940. this.selWWData = query;
  1941. this.$set(this.formData, 'sourceBizNo', query.sourceBizNo);
  1942. }
  1943. },
  1944. // 获取动态表头
  1945. getFieldModel() {
  1946. storageApi.fieldModel({ fieldModel: 't_main_category' }).then((res) => {
  1947. let newRes = res
  1948. .map((m) => {
  1949. return {
  1950. prop: 'extField.' + m.prop,
  1951. label: m.label,
  1952. align: 'center',
  1953. showOverflowTooltip: true
  1954. };
  1955. })
  1956. .filter((item) => item.label !== '包装规格');
  1957. console.log(newRes, 'newRes');
  1958. this.newDynamicColumns = [...newRes];
  1959. });
  1960. },
  1961. // 初始化当前用户信息
  1962. async initUserInfo() {
  1963. const res = await warehouseDefinition.tree();
  1964. let info = JSON.parse(localStorage.getItem('info'));
  1965. console.log(info, 'infoinfoinfo');
  1966. let obj = res.find(
  1967. (item) => item.id === info.deptIds[info.deptIds.length - 1]
  1968. );
  1969. // if (!obj) return;
  1970. if (obj) {
  1971. console.log(
  1972. obj,
  1973. 'objobjobjobjobjobjobjobjobjobjobjobjobjobjobjobjobj'
  1974. );
  1975. this.formData.extInfo.deptCode = obj?.id;
  1976. this.formData.extInfo.deptName = obj?.name;
  1977. } else {
  1978. this.formData.extInfo.deptName = info.deptName
  1979. ? info.deptName
  1980. : info.groupName
  1981. ? info.groupName
  1982. : '';
  1983. }
  1984. this.formData.extInfo.createUserName = info.name;
  1985. this.formData.createUserId = info.userId;
  1986. },
  1987. // 获取当前时间函数
  1988. getNowDate() {
  1989. let date = new Date(),
  1990. obj = {
  1991. year: date.getFullYear(), //获取完整的年份(4位)
  1992. month: date.getMonth() + 1, //获取当前月份(0-11,0代表1月)
  1993. strDate: date.getDate(), // 获取当前日(1-31)
  1994. hour: date.getHours(), //获取当前小时(0 ~ 23)
  1995. minute: date.getMinutes(), //获取当前分钟(0 ~ 59)
  1996. second: date.getSeconds() //获取当前秒数(0 ~ 59)
  1997. };
  1998. Object.keys(obj).forEach((key) => {
  1999. if (obj[key] < 10) obj[key] = `0${obj[key]}`;
  2000. });
  2001. return obj;
  2002. },
  2003. // 赋值入库时间
  2004. getNowFormatDate() {
  2005. let obj = this.getNowDate();
  2006. this.formData.storageTime = `${obj.year}-${obj.month}-${obj.strDate} ${obj.hour}:${obj.minute}:${obj.second}`;
  2007. },
  2008. // 获取物品列表
  2009. async getListItems() {
  2010. const res2 = await warehouseDefinition.getTreeByGroup({ type: 2 });
  2011. this.goodsLists = res2;
  2012. },
  2013. // 打开单据来源弹窗
  2014. openDocumentSourceDialog() {
  2015. console.log('打开单据来源弹窗');
  2016. this.$refs.outboundRequisitionDialogRef.open();
  2017. },
  2018. // 清除单据来源
  2019. clearSourceBizNo() {
  2020. this.$set(this.formData, 'sourceBizNo', '');
  2021. this.productList = [];
  2022. this.packingList = [];
  2023. },
  2024. // 返回
  2025. back() {
  2026. this.$router.go(-1);
  2027. },
  2028. // 添加产品
  2029. addProduct() {
  2030. this.$refs.formName.validate((valid) => {
  2031. if (valid) {
  2032. this.visibleDialog = true;
  2033. } else {
  2034. console.log('error submit!!');
  2035. return false;
  2036. }
  2037. });
  2038. // if (this.formData.extInfo.assetType.length <= 0) {
  2039. // return this.$message.error('请选择物品类型');
  2040. // }
  2041. // if (!this.formData.bizType) {
  2042. // return this.$message.error('请选择入库类型');
  2043. // }
  2044. },
  2045. contactDialogSuccess(data) {
  2046. this.$set(this.formData, 'clientName', data.name);
  2047. this.$set(this.formData, 'clientCode', data.code);
  2048. },
  2049. // 键盘移动
  2050. moveFocus(event, index, key, type, row) {
  2051. let keyfield = [];
  2052. let listLength = 0;
  2053. switch (type) {
  2054. case '产品':
  2055. listLength = this.productList.length;
  2056. keyfield = ['batchNo', 'quantity', 'unitPrice', 'purpose'];
  2057. break;
  2058. case '包装':
  2059. listLength = this.showPackingList.length;
  2060. if (row.measureUnit != row.weightUnit) {
  2061. keyfield = [
  2062. 'packing_materielDesignation',
  2063. 'packing_clientCode',
  2064. 'packing_engrave',
  2065. 'packing_weight'
  2066. ];
  2067. } else {
  2068. keyfield = [
  2069. 'packing_materielDesignation',
  2070. 'packing_clientCode',
  2071. 'packing_engrave'
  2072. ];
  2073. }
  2074. break;
  2075. case '物料':
  2076. listLength = this.showMaterialList.length;
  2077. if (row.measureUnit != row.weightUnit) {
  2078. keyfield = [
  2079. 'material_materielDesignation',
  2080. 'material_clientCode',
  2081. 'material_engrave',
  2082. 'material_weight'
  2083. ];
  2084. } else {
  2085. keyfield = [
  2086. 'material_materielDesignation',
  2087. 'material_clientCode',
  2088. 'material_engrave'
  2089. ];
  2090. }
  2091. break;
  2092. }
  2093. if (event.keyCode === 13) {
  2094. // 回车
  2095. if (
  2096. index === listLength - 1 &&
  2097. key === keyfield[keyfield.length - 1]
  2098. ) {
  2099. // 最后一行最后一个
  2100. return;
  2101. }
  2102. this.$refs[key + index].blur();
  2103. if (key === keyfield[keyfield.length - 1]) {
  2104. // 当前行最后一个,跳转下一行第一个
  2105. if (this.$refs[keyfield[0] + (index + 1)].value == 0) {
  2106. this.$refs[keyfield[0] + (index + 1)].value = '';
  2107. }
  2108. this.$refs[keyfield[0] + (index + 1)].focus();
  2109. } else {
  2110. // 跳转下一个
  2111. const nextkeyindex = keyfield.findIndex((k) => k === key) + 1;
  2112. this.$nextTick(() => {
  2113. if (this.$refs[keyfield[nextkeyindex] + index].value == 0) {
  2114. this.$refs[keyfield[nextkeyindex] + index].value = '';
  2115. }
  2116. this.$refs[keyfield[nextkeyindex] + index].focus();
  2117. });
  2118. }
  2119. }
  2120. // 向上 =38
  2121. if (event.keyCode === 38) {
  2122. console.log('向上');
  2123. if (index === 0) {
  2124. // 第一行
  2125. console.log('第一行无法向上');
  2126. return;
  2127. }
  2128. this.$refs[key + index].blur();
  2129. this.$nextTick(() => {
  2130. if (this.$refs[key + (index - 1)].value == 0) {
  2131. this.$refs[key + (index - 1)].value = '';
  2132. }
  2133. this.$refs[key + (index - 1)].focus();
  2134. });
  2135. }
  2136. // 下 = 40
  2137. if (event.keyCode === 40) {
  2138. console.log('向下');
  2139. if (index === listLength - 1) {
  2140. // 最后一行
  2141. console.log('最后一行无法向下');
  2142. return;
  2143. }
  2144. this.$refs[key + index].blur();
  2145. this.$nextTick(() => {
  2146. if (this.$refs[key + (index + 1)].value == 0) {
  2147. this.$refs[key + (index + 1)].value = '';
  2148. }
  2149. this.$refs[key + (index + 1)].focus();
  2150. });
  2151. }
  2152. // 左 = 37
  2153. if (event.keyCode === 37) {
  2154. console.log('向左');
  2155. if (index === 0 && key === keyfield[0]) {
  2156. // 第一行第一个
  2157. console.log('第一行第一个无法向左');
  2158. return;
  2159. }
  2160. this.$refs[key + index].blur();
  2161. if (key === keyfield[0]) {
  2162. if (
  2163. this.$refs[keyfield[keyfield.length - 1] + (index - 1)].value == 0
  2164. ) {
  2165. this.$refs[keyfield[keyfield.length - 1] + (index - 1)].value =
  2166. '';
  2167. }
  2168. // 当前行第一个,跳转上一行最后一个
  2169. this.$refs[keyfield[keyfield.length - 1] + (index - 1)].focus();
  2170. } else {
  2171. // 跳转上一个
  2172. const prevkeyindex = keyfield.findIndex((k) => k === key) - 1;
  2173. this.$nextTick(() => {
  2174. if (this.$refs[keyfield[prevkeyindex] + index].value == 0) {
  2175. this.$refs[keyfield[prevkeyindex] + index].value = '';
  2176. }
  2177. this.$refs[keyfield[prevkeyindex] + index].focus();
  2178. });
  2179. }
  2180. }
  2181. // 右 = 39
  2182. if (event.keyCode === 39) {
  2183. console.log('向右');
  2184. if (
  2185. index === listLength - 1 &&
  2186. key === keyfield[keyfield.length - 1]
  2187. ) {
  2188. // 最后一行最后一个
  2189. console.log('最后一行最后一个无法向左');
  2190. return;
  2191. }
  2192. console.log(this.$refs);
  2193. this.$refs[key + index].blur();
  2194. if (key === keyfield[keyfield.length - 1]) {
  2195. // 当前行最后一个,跳转下一行第一个
  2196. if (this.$refs[keyfield[0] + (index + 1)].value == 0) {
  2197. this.$refs[keyfield[0] + (index + 1)].value = '';
  2198. }
  2199. this.$refs[keyfield[0] + (index + 1)].focus();
  2200. } else {
  2201. // 跳转下一个
  2202. const nextkeyindex = keyfield.findIndex((k) => k === key) + 1;
  2203. this.$nextTick(() => {
  2204. if (this.$refs[keyfield[nextkeyindex] + index].value == 0) {
  2205. this.$refs[keyfield[nextkeyindex] + index].value = '';
  2206. }
  2207. this.$refs[keyfield[nextkeyindex] + index].focus();
  2208. });
  2209. }
  2210. }
  2211. },
  2212. handleAvatarSuccess() {
  2213. this.$refs.fileUploadBtn.clearFiles(); //上传成功之后清除历史记录**加粗样式**
  2214. },
  2215. async onChange(file) {
  2216. console.log(XLSX);
  2217. this.warehousingMaterialList = [];
  2218. this.resultArray = [];
  2219. const loading = this.$loading({
  2220. lock: true,
  2221. text: '加载中...'
  2222. });
  2223. /**
  2224. * 1. 使用原生api去读取好的文件
  2225. * */
  2226. // console.log("原始上传的文件", file);
  2227. // 读取文件不是立马能够读取到的,所以是异步的,使用Promise
  2228. let dataBinary = await new Promise((resolve) => {
  2229. // Web API构造函数FileReader,可实例化对象,去调用其身上方法,去读取解析文件信息
  2230. let reader = new FileReader(); // https://developer.mozilla.org/zh-CN/docs/Web/API/FileReader
  2231. // console.log("实例化对象有各种方法", reader);
  2232. reader.readAsBinaryString(file.raw); // 读取raw的File文件
  2233. reader.onload = (ev) => {
  2234. // console.log("文件解析流程进度事件", ev);
  2235. resolve(ev.target.result); // 将解析好的结果扔出去,以供使用
  2236. };
  2237. });
  2238. // console.log("读取出的流文件", dataBinary);
  2239. /**
  2240. * 2. 使用xlsx插件去解析已经读取好的二进制excel流文件
  2241. * */
  2242. let workBook = XLSX.read(dataBinary, {
  2243. type: 'binary',
  2244. cellDates: true
  2245. });
  2246. // excel中有很多的sheet,这里取了第一个sheet:workBook.SheetNames[0]
  2247. let firstWorkSheet = workBook.Sheets[workBook.SheetNames[0]];
  2248. // 分为第一行的数据,和第一行下方的数据
  2249. // const header = this.getHeaderRow(firstWorkSheet);
  2250. // console.log('读取的excel表头数据(第一行)', header);
  2251. const xlsxData = XLSX.utils.sheet_to_json(firstWorkSheet);
  2252. console.log('读取所有excel数据', xlsxData);
  2253. // let modelTypeList = xlsxData.map((item) => {
  2254. // return item['型号'];
  2255. // });
  2256. // let nameList = xlsxData.map((item) => {
  2257. // return item['物品名称'];
  2258. // });
  2259. let codeList = xlsxData.map((item) => {
  2260. return item['sap物料码'];
  2261. });
  2262. let functionType = {};
  2263. xlsxData.map((item) => {
  2264. functionType[item['sap物料码']] = item['采购原因'];
  2265. });
  2266. this.formData.extInfo.assetType = ['6']; //备品备件
  2267. this.formData.bizType = '2'; // 采购入库
  2268. outin
  2269. .getListByNameOrModeType({
  2270. // modelTypeList,
  2271. // nameList,
  2272. codeList,
  2273. categoryLevelId: '6'
  2274. })
  2275. .then(async (data) => {
  2276. console.log('查询到的备件数据', data);
  2277. const batchNo = await getCode('lot_number_code');
  2278. // 添加包装数量和最小包装单元
  2279. this.productList = data.map((item, index) => {
  2280. console.log(xlsxData);
  2281. let filterArray = xlsxData.filter(
  2282. (xlsxItem) => xlsxItem['sap物料码'] == item.code
  2283. );
  2284. console.log(filterArray);
  2285. return {
  2286. index: this.productList.length + index,
  2287. categoryId: item.id, // 物品id
  2288. categoryName: item.name, // 物品名称
  2289. categoryCode: item.code, // 物品编码
  2290. categoryModel: item.modelType, // 物品型号
  2291. specification: item.specification, // 规格
  2292. brandNum: item.brandNum, // 牌号
  2293. batchNo: item.batchNo || batchNo, // 批次号
  2294. systemBatchNo: item.systemBatchNo || '', // 系统内部批次号
  2295. minPackingQuantity: 1, // 最小包装单元数量
  2296. packingQuantity: filterArray[0]['数量'], // 包装数量
  2297. packingUnit: item.packingUnit, // 单位
  2298. measureQuantity: 0, // 计量数量
  2299. measureUnit: item.measuringUnit, // 计量单位
  2300. netWeight: item.netWeight > -1 ? item.netWeight : 0, // 净重
  2301. weight: 0, // 重量
  2302. weightUnit: item.weightUnit, // 重量单位
  2303. totalMoney: '', // 总价
  2304. unitPrice: item.unitPrice, // 单价
  2305. purpose: functionType[item.code], // 用途
  2306. isUnpack: item.isUnpack // 是否允许拆包
  2307. };
  2308. });
  2309. console.log(this.productList);
  2310. this.handleAvatarSuccess();
  2311. loading.close();
  2312. })
  2313. .catch(() => {
  2314. loading.close();
  2315. });
  2316. },
  2317. // 入库
  2318. handleStorage(type) {
  2319. this.$refs.formName.validate(async (valid) => {
  2320. if (valid) {
  2321. if (!this.productList.length) {
  2322. return this.$message.warning('请至少添加一条产品');
  2323. }
  2324. let boolen = this.productList.every((item) => item.isSave);
  2325. let is = false;
  2326. this.productList.forEach((v, i) => {
  2327. this.productList.forEach((v2, j) => {
  2328. if (
  2329. v.categoryCode == v2.categoryCode &&
  2330. v.taskId == v2.taskId &&
  2331. v.batchNo == v2.batchNo &&
  2332. v.colorKey == v2.colorKey &&
  2333. v.modelKey == v2.modelKey &&
  2334. v.provenance?.toString() == v2.provenance?.toString() &&
  2335. v.level == v2.level &&
  2336. i != j
  2337. ) {
  2338. is = true;
  2339. }
  2340. });
  2341. });
  2342. if (is) {
  2343. this.$message.error('同产品,工序、批次号、颜色、机型、产地、等级不能完全一致!');
  2344. return;
  2345. }
  2346. if (!boolen) {
  2347. this.$message.warning('请先保存所有产品信息');
  2348. return;
  2349. }
  2350. // 处理包装数据
  2351. this.packingList = this.packingList.map((packingItem) => {
  2352. if (packingItem.modelKey) {
  2353. packingItem.modelKey = packingItem.modelKey;
  2354. }
  2355. if (packingItem.colorKey) {
  2356. packingItem.colorKey = packingItem.colorKey;
  2357. }
  2358. return {
  2359. ...packingItem,
  2360. materialDetailList: this.materialList.filter(
  2361. (item) => item.parentIndex === packingItem.index
  2362. ),
  2363. taskId: this.selWWData?.taskId,
  2364. workOrderId: this.selWWData?.workOrderId
  2365. };
  2366. });
  2367. // 处理产品数据
  2368. this.productList = this.productList.map((productItem) => {
  2369. if (productItem.modelKey) {
  2370. productItem.modelKey = productItem.modelKey;
  2371. }
  2372. if (productItem.colorKey) {
  2373. productItem.colorKey = productItem.colorKey;
  2374. }
  2375. return {
  2376. ...productItem,
  2377. outInDetailRecordRequestList: this.packingList.filter(
  2378. (item) => item.parentIndex === productItem.index
  2379. )
  2380. };
  2381. });
  2382. this.formData.outInDetailList = this.productList;
  2383. let obj = deepClone(this.formData);
  2384. // 处理物品类型assetType
  2385. obj.extInfo.assetType = obj.extInfo.assetType.join(',');
  2386. // 处理仓库id
  2387. let warehouseId = [];
  2388. let warehouseName = [];
  2389. let warehouseIds = this.productList
  2390. .map((item) => item.warehouseIds)
  2391. .flat();
  2392. let warehouseNames = this.productList
  2393. .map((item) => item.warehouseNames)
  2394. .flat();
  2395. warehouseIds.forEach((item, index) => {
  2396. if (!warehouseId.includes(item)) {
  2397. warehouseId.push(item);
  2398. warehouseName.push(warehouseNames[index]);
  2399. }
  2400. });
  2401. obj.warehouseIds = warehouseId;
  2402. obj.warehouseNames = warehouseName;
  2403. console.log('入库数据', obj);
  2404. // 是否需要审核(0审核 1跳过审核)
  2405. if (obj.bizType == '12') {
  2406. obj.isSkip = 1;
  2407. } else {
  2408. obj.isSkip = 0;
  2409. }
  2410. // obj.isSkip = 1;
  2411. this.saveLoading = true;
  2412. console.log(obj, 'objobjobjobjobjobj');
  2413. // if(){}
  2414. if (!(await this.isVerifyRepeatIsStock())) {
  2415. this.saveLoading = false;
  2416. return;
  2417. }
  2418. let api = obj.id ? storageApi.update : storageApi.storage;
  2419. api(obj)
  2420. .then(async (res) => {
  2421. console.log('入库成功', res);
  2422. console.log('入库成功', obj.id);
  2423. if (res.code == 0) {
  2424. try {
  2425. if (type != 'save') {
  2426. if (obj.bizType == '12') {
  2427. await storageApi.qualityInspectionTwo({
  2428. outInIds: res.data
  2429. });
  2430. } else {
  2431. await storageApi.submitTwo({ outInIds: res.data });
  2432. }
  2433. this.$message.success('入库成功');
  2434. } else {
  2435. this.$message.success('操作成功');
  2436. }
  2437. // 委外入库(非采购)
  2438. this.saveLoading = false;
  2439. // this.$router.push('/warehouseManagement/stockManagement');
  2440. this.back();
  2441. } catch (error) {
  2442. this.saveLoading = false;
  2443. // this.$router.push('/warehouseManagement/stockManagement');
  2444. this.back();
  2445. console.log('提交流程失败', error);
  2446. }
  2447. }
  2448. })
  2449. .catch((err) => {
  2450. console.log('入库失败', err);
  2451. this.saveLoading = false;
  2452. });
  2453. } else {
  2454. return;
  2455. }
  2456. });
  2457. },
  2458. async isVerifyRepeatIsStock() {
  2459. const isVerifyData = await storageApi.isVerifyRepeatIsStock({
  2460. categoryCodes: this.productList.map((item) => item.categoryCode),
  2461. batchNos: this.productList.map((item) => item.batchNo)
  2462. });
  2463. return new Promise((resolve, reject) => {
  2464. if (isVerifyData?.length) {
  2465. this.$confirm(
  2466. `当前批次:${isVerifyData[0].batchNo},物品${isVerifyData
  2467. .map((item) => item.categoryName)
  2468. .join(',')}已有入库记录,是否继续入库!`,
  2469. {
  2470. confirmButtonText: '是',
  2471. cancelButtonText: '否'
  2472. }
  2473. )
  2474. .then(() => {
  2475. resolve(true);
  2476. })
  2477. .catch(() => {
  2478. resolve(false);
  2479. });
  2480. } else {
  2481. resolve(true);
  2482. }
  2483. });
  2484. },
  2485. pickingHandleScroll() {
  2486. // console.log('---------pickingHandleScroll------------');
  2487. // console.log(this.packingList);
  2488. // console.log(this.showPackingList);
  2489. // console.log(this.pageSize);
  2490. if (this.showPackingList.length < this.packingList.length) {
  2491. if (this.packingList.length > this.pageSize) {
  2492. this.pickingPageNum += 1;
  2493. }
  2494. this.pickingFetchData();
  2495. }
  2496. },
  2497. pickingFetchData() {
  2498. const start = (this.pickingPageNum - 1) * this.pageSize;
  2499. const end = start + this.pageSize;
  2500. console.log(start);
  2501. console.log(end);
  2502. this.showPackingList = this.showPackingList.concat(
  2503. this.packingList.slice(start, end)
  2504. );
  2505. },
  2506. materielHandleScroll() {
  2507. console.log('---------materielHandleScroll------------');
  2508. if (this.showMaterialList.length < this.materialList.length) {
  2509. if (this.materialList.length > this.pageSize) {
  2510. this.materielPageNum += 1;
  2511. }
  2512. this.materielFetchData();
  2513. }
  2514. },
  2515. materielFetchData() {
  2516. const start = (this.materielPageNum - 1) * this.pageSize;
  2517. const end = start + this.pageSize;
  2518. this.showMaterialList = this.showMaterialList.concat(
  2519. this.materialList.slice(start, end)
  2520. );
  2521. console.log(this.showMaterialList);
  2522. },
  2523. // 日期选择
  2524. dateConfirm() {
  2525. if(this.listType == 'productList') {
  2526. this.productList.forEach((item) => {
  2527. this.$set(item, this.curDateType, this.batchTime);
  2528. });
  2529. } else {
  2530. this.packingListSelected.forEach((item) => {
  2531. this.$set(item, this.curDateType, this.batchTime);
  2532. });
  2533. }
  2534. this.batchTime = '';
  2535. this.dateVisible = false;
  2536. },
  2537. // 包装重量修改
  2538. packingWeightCahnge(value, row) {
  2539. // 修改物品重量
  2540. let filterPackingList = this.packingList.filter((item) => {
  2541. return item.parentIndex === row.parentIndex;
  2542. });
  2543. let productIndex = this.productList.findIndex((item) => {
  2544. return item.index === row.parentIndex;
  2545. });
  2546. let totalWeight = filterPackingList.reduce(
  2547. (accumulator, currentValue) => {
  2548. return this.$math.format(+accumulator + +currentValue.weight, 14);
  2549. },
  2550. 0
  2551. );
  2552. this.$set(this.productList[productIndex], 'weight', totalWeight);
  2553. this.$set(
  2554. this.productList[productIndex],
  2555. 'singleWeight',
  2556. totalWeight / this.productList[productIndex].measureQuantity
  2557. );
  2558. // 修改拆分物料
  2559. this.materialList.map((item, index) => {
  2560. if (item.parentIndex === row.index) {
  2561. console.log(value / row.measureQuantity);
  2562. this.$set(
  2563. this.materialList[index],
  2564. 'weight',
  2565. this.$math.format(value / row.measureQuantity, 14) >= 0
  2566. ? this.$math.format(value / row.measureQuantity, 14)
  2567. : 0
  2568. );
  2569. }
  2570. });
  2571. },
  2572. // 物料重量修改
  2573. materialWeightCahnge(row) {
  2574. // 修改包装重量
  2575. let filterMaterialList = this.materialList.filter((item) => {
  2576. return item.parentIndex === row.parentIndex;
  2577. });
  2578. let packingIndex = this.packingList.findIndex((item) => {
  2579. return item.index === row.parentIndex;
  2580. });
  2581. let totalMaterialWeight = filterMaterialList.reduce(
  2582. (accumulator, currentValue) => {
  2583. return this.$math.format(+accumulator + +currentValue.weight, 14);
  2584. },
  2585. 0
  2586. );
  2587. this.$set(
  2588. this.packingList[packingIndex],
  2589. 'weight',
  2590. totalMaterialWeight
  2591. );
  2592. // 修改物品重量
  2593. let filterPackingList = this.packingList.filter((item) => {
  2594. return (
  2595. item.parentIndex === this.packingList[packingIndex].parentIndex
  2596. );
  2597. });
  2598. let productIndex = this.productList.findIndex((item) => {
  2599. return item.index === this.packingList[packingIndex].parentIndex;
  2600. });
  2601. let totalWeight = filterPackingList.reduce(
  2602. (accumulator, currentValue) => {
  2603. return this.$math.format(+accumulator + +currentValue.weight, 14);
  2604. },
  2605. 0
  2606. );
  2607. this.$set(this.productList[productIndex], 'weight', totalWeight);
  2608. },
  2609. // 包装质检结果修改
  2610. packingResultCahnge(value, row) {
  2611. // 修改物料质检结果( 1合格 2不合格)
  2612. this.materialList.map((item, index) => {
  2613. if (item.parentIndex === row.index) {
  2614. this.$set(this.materialList[index], 'result', value);
  2615. }
  2616. });
  2617. },
  2618. // 物料质量结果修改
  2619. materialResultCahnge(value, row) {
  2620. // 修改包装质检结果
  2621. let filterMaterialList = this.materialList.filter((item) => {
  2622. return item.parentIndex == row.parentIndex;
  2623. });
  2624. let packingIndex = this.packingList.findIndex((item) => {
  2625. return item.index == row.parentIndex;
  2626. });
  2627. let boolen = filterMaterialList.every((item) => {
  2628. return item.result == 1;
  2629. });
  2630. this.$set(this.packingList[packingIndex], 'result', boolen ? 1 : 2);
  2631. },
  2632. // 重量限制
  2633. weightInput(value, row, type) {
  2634. const newValue = value.replace(/[^\d.]/g, ''); // 保留数字和小数点
  2635. const decimalCount = (newValue.match(/\./g) || []).length; // 计算小数点的个数
  2636. if (row.weight < 0) {
  2637. row.weight = 0;
  2638. } else if (row.weight > 9999) {
  2639. row.weight = 9999;
  2640. } else {
  2641. if (decimalCount > 1) {
  2642. // 如果小数点个数大于1,移除多余的小数点
  2643. const lastIndex = newValue.lastIndexOf('.');
  2644. row.weight =
  2645. newValue.slice(0, lastIndex) + newValue.slice(lastIndex + 1);
  2646. } else if (decimalCount === 1) {
  2647. // 如果小数点个数等于1,允许小数点的输入
  2648. row.weight = newValue;
  2649. } else {
  2650. row.weight = newValue === '' ? 0 : parseFloat(newValue); // 如果输入为空,则设为0
  2651. }
  2652. }
  2653. if (type === '包装') {
  2654. this.packingWeightCahnge(value, row);
  2655. } else {
  2656. this.materialWeightCahnge(row);
  2657. }
  2658. },
  2659. //计算金额
  2660. calcSumTotal(measureQuantity, unitPrice, row) {
  2661. //最小包装单元,包装数量,单价
  2662. const total = {
  2663. measureQuantity: Number(measureQuantity > 0 ? measureQuantity : 0),
  2664. unitPrice: Number(unitPrice > 0 ? unitPrice : 0)
  2665. };
  2666. let number = Number(
  2667. this.$math.format(total.measureQuantity * total.unitPrice, 14)
  2668. );
  2669. row.totalMoney = number;
  2670. return number;
  2671. },
  2672. // 表格样式
  2673. rowClass({ row, column, rowIndex, columnIndex }) {
  2674. if (rowIndex === 1) {
  2675. return {
  2676. display: 'none',
  2677. background: '#EEEEEE'
  2678. };
  2679. }
  2680. return { background: '#0000' };
  2681. },
  2682. getNewSpecificationOption(packingSpecificationOption) {
  2683. return packingSpecificationOption.map((arr) => {
  2684. return arr.reduce((acc, current) => {
  2685. const conversionUnit = current.conversionUnit;
  2686. if (!acc.some((item) => item.conversionUnit === conversionUnit)) {
  2687. acc.push(current);
  2688. }
  2689. return acc;
  2690. }, []);
  2691. });
  2692. },
  2693. async addGoods(data) {
  2694. if (data.length === 0) return this.$message.warning('请选择产品信息');
  2695. console.log(data, 'datadatadatadatadatadatadata111');
  2696. // 获取批次号
  2697. const batchNo = await getCode('lot_number_code');
  2698. // 获取供应商
  2699. const supplierList = await storageApi.contactQueryByCategoryIdsAPI({
  2700. categoryIds: data.map((item) => item.id)
  2701. });
  2702. console.log(supplierList, '供应商列表');
  2703. // 获取包装规格
  2704. let packingSpecification =
  2705. await storageApi.getCategoryPackageDisposition({
  2706. categoryIds: data.map((item) => item.id)
  2707. });
  2708. console.log(packingSpecification, '--packingSpecification');
  2709. this.packingSpecificationOption = data.map((item) => {
  2710. return packingSpecification
  2711. .filter((ite) => item.id == ite.categoryId)
  2712. .sort((a, b) => a.sort - b.sort);
  2713. });
  2714. console.log('yeyyeyey----------------', data);
  2715. const newSpecificationOption = this.packingSpecificationOption;
  2716. let productList = data.map((item, index) => {
  2717. // 显示规格
  2718. let packingSpecificationLabel = this.packingSpecificationOption[index]
  2719. .map((item) => {
  2720. if (item.sort > 0) {
  2721. return `${item.packageCell}${item.packageUnit}/${item.conversionUnit}`;
  2722. }
  2723. })
  2724. .filter((item) => !!item);
  2725. return {
  2726. index:
  2727. this.productList.length - 1 > -1
  2728. ? this.productList[this.productList.length - 1].index +
  2729. index +
  2730. 1
  2731. : this.productList.length + index,
  2732. // extField: {
  2733. // packingSpecification: item.extField.packingSpecification
  2734. // }, // 包装规格
  2735. categoryId: item.id, // 物品id
  2736. categoryName: item.name, // 物品名称
  2737. categoryCode: item.code, // 物品编码
  2738. categoryModel: item.modelType, // 物品型号
  2739. specification: item.specification, // 规格
  2740. modelKey: item.modelKey ? item.modelKey?.split(',')?.[0] || '' : '', // 机型
  2741. colorKey: item.colorKey ? item.colorKey?.split(',')?.[0] || '' : '', // 颜色
  2742. color: item.color,
  2743. brandNum: item.brandNum, // 牌号
  2744. batchNo: item.batchNo || batchNo, // 批次号
  2745. systemBatchNo: item.systemBatchNo || '', // 系统内部批次号
  2746. supplierListOptions: supplierList[item.id], // 供应商列表
  2747. supplierId: '', // 供应商id
  2748. supplierName: '', // 供应商名称
  2749. supplierCode: '',
  2750. measureType: item.measureType, // 计量类型
  2751. approvalNumber: item.approvalNumber, // 批准文号
  2752. packingSpecification: item.packingSpecification, // 包装规格
  2753. packingSpecificationOption: newSpecificationOption[index], // 包装规格选项
  2754. packingSpecificationLabel: packingSpecificationLabel, // 包装规格显示
  2755. minPackingQuantity: '', // 最小包装单元数量
  2756. packingQuantity: '', // 包装数量
  2757. packingUnit: item.packingUnit, // 包装数量
  2758. unit: item.measuringUnit, // 单位
  2759. unitId: newSpecificationOption[index].find(
  2760. (v) => v.conversionUnit == item.measuringUnit
  2761. )?.id, // 单位
  2762. measureQuantity: 0, // 计量数量
  2763. measureUnit: item.measuringUnit, // 计量单位
  2764. netWeight: item.netWeight > -1 ? item.netWeight : 0, // 净重
  2765. weight: 0, // 重量
  2766. singleWeight: item.netWeight, //单重 进来获取净重
  2767. weightUnit: item.weightUnit, // 重量单位
  2768. totalMoney: '', // 总价
  2769. unitPrice: item.unitPrice, // 单价
  2770. purpose: '', // 用途
  2771. isUnpack: item.isUnpack, // 是否允许拆包
  2772. categoryLevelPathIdParent: item.categoryLevelPathIdParent,
  2773. extField: item.extField,
  2774. };
  2775. });
  2776. this.productList = this.productList.concat(productList);
  2777. console.log('this.productList--------', this.productList);
  2778. },
  2779. // 物品保存验证表单(批量)
  2780. validateForm() {
  2781. return new Promise(async (resolve, reject) => {
  2782. let list = this.productList.map(async (row, index) => {
  2783. let fileds = [
  2784. `productList.${index}.batchNo`,
  2785. `productList.${index}.quantity`,
  2786. `productList.${index}.unit`,
  2787. `productList.${index}.warehouseId`
  2788. ];
  2789. console.log(fileds);
  2790. if (row.isSave) {
  2791. return Promise.resolve(true);
  2792. } else {
  2793. return await Promise.all(
  2794. fileds.map(
  2795. (item) =>
  2796. new Promise(async (res, rej) => {
  2797. this.$refs.productListRef.validateField(item, (err) => {
  2798. if (err) {
  2799. rej(err);
  2800. } else {
  2801. res(true);
  2802. }
  2803. });
  2804. })
  2805. )
  2806. );
  2807. }
  2808. });
  2809. Promise.all(list)
  2810. .then(() => {
  2811. console.log('保存成功!');
  2812. resolve();
  2813. })
  2814. .catch((err) => {
  2815. console.log('保存失败!');
  2816. this.$message.error('请填入必填项!');
  2817. reject(err);
  2818. });
  2819. });
  2820. },
  2821. // 物品保存验证表单(单独)
  2822. validateFormIndividually(index) {
  2823. return new Promise(async (resolve) => {
  2824. console.log(index);
  2825. let fileds = [
  2826. `productList.${index}.batchNo`,
  2827. `productList.${index}.quantity`,
  2828. `productList.${index}.unit`,
  2829. `productList.${index}.warehouseId`
  2830. ];
  2831. Promise.all(
  2832. fileds.map(
  2833. (item) =>
  2834. new Promise(async (res, rej) => {
  2835. this.$refs.productListRef.validateField(item, (err) => {
  2836. if (err) {
  2837. rej(err);
  2838. } else {
  2839. res(true);
  2840. }
  2841. });
  2842. })
  2843. )
  2844. )
  2845. .then(() => {
  2846. resolve();
  2847. })
  2848. .catch(() => {
  2849. this.$message.error('请填入必填项!');
  2850. });
  2851. });
  2852. },
  2853. // 产品编辑
  2854. listEdit(row) {
  2855. console.log(row);
  2856. this.$set(row, 'isSave', false);
  2857. this.deletePackingAndMaterial(row);
  2858. },
  2859. // 根据产品信息删除包装和物料
  2860. deletePackingAndMaterial(row) {
  2861. console.log('row--------', row);
  2862. console.log('packingList------', this.packingList);
  2863. // 删除包装(去掉不相同的包装)
  2864. this.packingList = this.packingList.filter(
  2865. (item) => item.parentIndex !== row.index
  2866. );
  2867. this.showPackingList = this.showPackingList.filter(
  2868. (item) => item.parentIndex !== row.index
  2869. );
  2870. this.pickingPageNum = Math.ceil(
  2871. this.showPackingList.length / this.pageSize
  2872. );
  2873. console.log('包装当前页数');
  2874. console.log(this.pickingPageNum);
  2875. // 删除物料(获取相同物料)
  2876. let packingIndexs = this.packingList.map((item) => item.index);
  2877. this.materialList = this.materialList.filter((item) =>
  2878. packingIndexs.includes(item.parentIndex)
  2879. );
  2880. this.showMaterialList = this.showMaterialList.filter((item) =>
  2881. packingIndexs.includes(item.parentIndex)
  2882. );
  2883. this.materielPageNum = Math.ceil(
  2884. this.showMaterialList.length / this.pageSize
  2885. );
  2886. console.log('物料当前页数');
  2887. console.log(this.showMaterialList.length);
  2888. console.log(this.pageSize);
  2889. console.log(this.materielPageNum);
  2890. },
  2891. // 新增批量保存方法
  2892. async batchSave() {
  2893. try {
  2894. // 验证所有未保存的表单
  2895. await this.validateForm();
  2896. // 遍历所有产品进行保存
  2897. for (let i = 0; i < this.productList.length; i++) {
  2898. const row = this.productList[i];
  2899. if (!row.isSave) {
  2900. // 执行单个保存逻辑
  2901. await this.listSave(row, i);
  2902. }
  2903. }
  2904. } catch (error) {
  2905. this.$message.error('批量保存失败,请检查必填项');
  2906. }
  2907. },
  2908. setPNum(row) {
  2909. let pNum = 0;
  2910. if (row.unitId) {
  2911. let splitIndex = row.packingSpecificationOption.findIndex(
  2912. (item) => item.id == row.unitId
  2913. );
  2914. if (splitIndex == 0) {
  2915. pNum = Math.ceil(
  2916. row.measureQuantity /
  2917. row.packingSpecificationOption[1]?.packageCell
  2918. );
  2919. }
  2920. if (splitIndex == 1) {
  2921. pNum = row.quantity;
  2922. }
  2923. for (; splitIndex > 1; splitIndex--) {
  2924. pNum = Math.ceil(
  2925. row.quantity *
  2926. row.packingSpecificationOption[splitIndex].packageCell
  2927. );
  2928. }
  2929. } else {
  2930. pNum = Math.ceil(
  2931. row.measureQuantity / row.packingSpecificationOption[1]?.packageCell
  2932. );
  2933. }
  2934. return pNum;
  2935. },
  2936. //产品保存操作
  2937. async listSave(row, index) {
  2938. console.log(row, ';ddd');
  2939. return new Promise(async (resolve, reject) => {
  2940. try {
  2941. await this.validateFormIndividually(index);
  2942. if (row.packingSpecificationLabel?.length < 1) {
  2943. this.$message.error('请到主数据维护包装组信息!');
  2944. return;
  2945. }
  2946. // 不拆包
  2947. if (!row.isUnpack) {
  2948. if (row.packingUnit != row.measureUnit) {
  2949. let pNum = row.quantity;
  2950. let splitIndex = row.packingSpecificationOption.findIndex(
  2951. (item) =>
  2952. item.conversionUnit == row.unit &&
  2953. item.unit != item.conversionUnit
  2954. );
  2955. for (; splitIndex > 1; splitIndex--) {
  2956. pNum = this.$math.format(
  2957. pNum *
  2958. row.packingSpecificationOption[splitIndex].packageCell,
  2959. 14
  2960. );
  2961. }
  2962. console.log(pNum, 'pNum12');
  2963. const { data } = await storageApi.getAssetNum([
  2964. {
  2965. assetCode: row.categoryCode + row.index,
  2966. batchNum: row.batchNo,
  2967. num: Math.ceil(pNum)
  2968. }
  2969. ]);
  2970. // this.generateWrappers(row, index, data)
  2971. } else {
  2972. let pNum = 0;
  2973. const { data } = await storageApi.getAssetNum([
  2974. {
  2975. assetCode: row.categoryCode + row.index,
  2976. batchNum: row.batchNo,
  2977. num: Math.ceil(pNum)
  2978. }
  2979. ]);
  2980. }
  2981. } else {
  2982. let pNum = this.setPNum(row);
  2983. // row.packingQuantity;
  2984. // console.log(row.packingQuantity,'row.packingQuantity')
  2985. // return
  2986. //拆包
  2987. const { data } = await storageApi.getAssetNum([
  2988. {
  2989. assetCode: row.categoryCode + row.index,
  2990. batchNum: row.batchNo,
  2991. num: Math.ceil(pNum)
  2992. }
  2993. ]);
  2994. console.log(data, 'data');
  2995. this.generateWrappers(row, index, data);
  2996. this.$set(
  2997. this.productList[index],
  2998. 'packingQuantity',
  2999. data.length
  3000. );
  3001. }
  3002. this.$set(this.productList[index], 'isSave', true);
  3003. // this.$set(this.productList[index], 'isSave', data.length);
  3004. this.$set(this.productList[index], 'warehouseId', row.warehouseId);
  3005. this.$set(
  3006. this.productList[index],
  3007. 'warehouseName',
  3008. row.warehouseName
  3009. );
  3010. this.$set(this.productList[index], 'warehouseIds', [
  3011. row.warehouseId
  3012. ]);
  3013. this.$set(this.productList[index], 'warehouseNames', [
  3014. row.warehouseName
  3015. ]);
  3016. resolve();
  3017. } catch (error) {
  3018. reject(error);
  3019. }
  3020. });
  3021. },
  3022. // 生成包装
  3023. generateWrappers(row, productIndex, packingCodeList) {
  3024. console.log(packingCodeList, 'packingCodeListROW', row.measureType);
  3025. //计量类型不是数量
  3026. if (!row.isUnpack && row.measureType != 1) {
  3027. // 计量单位=包装单位,则不生成包装层数据
  3028. if (row.measureUnit == row.unit) {
  3029. // 直接生成物品层数据
  3030. this.productList[productIndex].measureQuantity =
  3031. row.measureQuantity;
  3032. this.productList[productIndex].weight = row.weight;
  3033. return;
  3034. }
  3035. }
  3036. console.log('包装数据--------', row);
  3037. // console.log('包装规格----', row.packingSpecificationOption);
  3038. console.log('计量单位----', row.measureUnit);
  3039. let packingList = [];
  3040. let obj = this.getNowDate();
  3041. let productionDate = row.detailProductionDate || '';
  3042. let purchaseDate = row.detailPurchaseDate || '';
  3043. let expireDate = row.detailExpireDate || '';
  3044. if (this.formData.bizType == '1') {
  3045. // 生产入库
  3046. productionDate = `${obj.year}-${obj.month}-${obj.strDate} ${obj.hour}:${obj.minute}:${obj.second}`;
  3047. // this.curDateType = 'productionDate';
  3048. } else if (this.formData.bizType == '2') {
  3049. // 采购入库
  3050. purchaseDate = `${obj.year}-${obj.month}-${obj.strDate} ${obj.hour}:${obj.minute}:${obj.second}`;
  3051. // this.curDateType = 'purchaseDate';
  3052. }
  3053. // 判断单位和计量单位是否为不拆物料层规格
  3054. let packingBoolen = !!this.getDict('不拆物料层规格', row.unit)
  3055. .dictValue;
  3056. let measureBoolen = !!this.getDict('不拆物料层规格', row.measureUnit)
  3057. .dictValue;
  3058. let num = row.packingQuantity;
  3059. let filterArr = [];
  3060. // 处理单位为KG类的情况
  3061. if (packingBoolen) {
  3062. console.log(
  3063. packingBoolen,
  3064. 'packingBoolenpackingBoolenpackingBoolenpackingBoolenpackingBoolenpackingBoolen'
  3065. );
  3066. if (!row.isUnpack && row.unit == '立方') {
  3067. num = 1;
  3068. } else {
  3069. filterArr = row.packingSpecificationOption.filter((item) => {
  3070. return (
  3071. item.packageUnit == row.unit &&
  3072. item.packageUnit != item.conversionUnit
  3073. );
  3074. });
  3075. num = Math.ceil(row.packingQuantity / filterArr[0]?.packageCell);
  3076. }
  3077. } else {
  3078. if (measureBoolen) {
  3079. // 处理单位不为KG类,计量单位为KG类的情况
  3080. let splitIndex = row.packingSpecificationOption.findIndex(
  3081. (item) =>
  3082. item.conversionUnit == row.unit &&
  3083. item.packageUnit != item.conversionUnit
  3084. );
  3085. for (; splitIndex > 1; splitIndex--) {
  3086. num = this.$math.format(
  3087. num * row.packingSpecificationOption[splitIndex].packageCell,
  3088. 14
  3089. );
  3090. }
  3091. } else {
  3092. if (row.packingSpecificationOption[1]?.packageCell) {
  3093. num = Math.ceil(
  3094. row.measureQuantity /
  3095. row.packingSpecificationOption[1]?.packageCell
  3096. );
  3097. filterArr = row.packingSpecificationOption.filter((item) => {
  3098. return (
  3099. item.packageUnit == row.unit &&
  3100. item.packageUnit != item.conversionUnit
  3101. );
  3102. });
  3103. }
  3104. }
  3105. }
  3106. console.log('num-----------', num);
  3107. if (!row.isUnpack) {
  3108. console.log(row.packingSpecificationOption[1]);
  3109. // let packingUnit = !row.isUnpack ? row.packingUnit : row.packingSpecificationOption[1].conversionUnit;
  3110. // let packingQuantity = row.packingQuantity / packingCodeList.length;
  3111. let unit = row.packingSpecificationOption[1]?.conversionUnit;
  3112. let startIndex = row.packingSpecificationOption.findIndex((ite) => {
  3113. return (
  3114. row.measuringUnit == ite.unit && ite.unit != ite.conversionUnit
  3115. );
  3116. });
  3117. let endIndex = row.packingSpecificationOption.findIndex(
  3118. (ite) => row.unit == ite.conversionUnit
  3119. );
  3120. let total = Number(row.quantity);
  3121. for (; startIndex < endIndex; endIndex--) {
  3122. total = this.$math.format(
  3123. row.packingSpecificationOption[endIndex].packageCell * total,
  3124. 14
  3125. );
  3126. }
  3127. console.log('total-----------', total);
  3128. let packingQuantity = row.measureQuantity / total;
  3129. let measureUnit = row.measureUnit;
  3130. let measureQuantity = row.measureQuantity / packingCodeList.length;
  3131. for (let index = 0; index < packingCodeList.length; index++) {
  3132. let item = {
  3133. index: row.index + '-' + index, // 包装索引
  3134. warehouseId: row.warehouseId, // 仓库id
  3135. warehouseName: row.warehouseName, // 仓库名称
  3136. categoryName: row.categoryName, // 产品名称
  3137. categoryCode: row.categoryCode, // 产品编码
  3138. categoryModel: row.categoryModel, // 物品型号
  3139. specification: row.specification, // 规格
  3140. supplierCode: row.supplierCode, // 供应商编码
  3141. brandNum: row.brandNum, // 牌号
  3142. parentIndex: row.index, // 产品索引
  3143. batchNo: row.batchNo, // 批次号
  3144. systemBatchNo: row.systemBatchNo, // 系统内部批次号
  3145. packageNo: packingCodeList[index]?.onlyCode, // 包装编码
  3146. packingQuantity: packingQuantity, // 包装数量
  3147. packingUnit: packingUnit, //包装单位
  3148. measureQuantity: measureQuantity, // 计量数量
  3149. measureUnit: measureUnit, // 计量单位
  3150. modelKey: row.modelKey, // 机型
  3151. colorKey: row.colorKey, //颜色
  3152. measureType: row.measureType,
  3153. measureUnit: measureUnit, // 计量单位
  3154. weight: 0, // 重量
  3155. packingSpecificationOption: row.packingSpecificationOption, // 包装规格
  3156. weightUnit: row.weightUnit, // 重量单位
  3157. netWeight: row.netWeight, // 净重
  3158. barcodes: '', // 发货条码
  3159. clientCode: row.extInfo ? row.extInfo.clientCode : '', // 客户代号
  3160. materielDesignation:
  3161. row.materielDesignation ||
  3162. (row.extInfo ? row.extInfo.materielCode : ''), // 物料代号
  3163. supplierName: row.supplierName, // 供应商名称
  3164. supplierCode: row.supplierCode, // 供应商代号
  3165. engrave: '', // 刻码
  3166. isUnpack: row.isUnpack, // 是否允许拆包
  3167. productionDate: productionDate, // 生产日期
  3168. purchaseDate: purchaseDate, // 采购时间
  3169. result: 1, // 结果(1合格 2不合格)
  3170. status: 2 // 状态(0=未质检 1待检 2已检)
  3171. };
  3172. let outBoolen = !!this.getDict('不拆物料层规格', item.measureUnit)
  3173. .dictValue;
  3174. if (outBoolen) {
  3175. // 计量单位为KG类,直接替换
  3176. item.weight = item.measureQuantity
  3177. ? Number(item.measureQuantity)
  3178. : 0;
  3179. } else {
  3180. console.log('计量单位为不为KG类======================');
  3181. // 计量单位为不为KG类,重新统计计算
  3182. let inBoolen = !!this.getDict(
  3183. '不拆物料层规格',
  3184. item.packingSpecificationOption[0].packageUnit
  3185. ).dictValue;
  3186. let startIndex = item.packingSpecificationOption.findIndex(
  3187. (ite) => {
  3188. return (
  3189. item.measureUnit == ite.packingUnit &&
  3190. ite.packingUnit != ite.conversionUnit
  3191. );
  3192. }
  3193. );
  3194. let endIndex = item.packingSpecificationOption.findIndex(
  3195. (ite) => item.packingUnit == ite.conversionUnit
  3196. );
  3197. if (measureBoolen) {
  3198. let total = item.packingQuantity
  3199. ? Number(item.packingQuantity)
  3200. : 0;
  3201. for (; startIndex < endIndex; endIndex--) {
  3202. total = this.$math.format(
  3203. item.packingSpecificationOption[endIndex].packageCell *
  3204. total,
  3205. 14
  3206. );
  3207. }
  3208. if (inBoolen) {
  3209. // 第二层为KG类
  3210. item.weight = total ? Number(total) : 0;
  3211. } else {
  3212. // 第二层不为KG类
  3213. item.weight = this.$math.format(total * item.netWeight, 14);
  3214. }
  3215. } else if (!measureBoolen) {
  3216. if (inBoolen) {
  3217. // 第二层为KG类
  3218. item.weight = item.measureQuantity
  3219. ? Number(item.measureQuantity)
  3220. : 0;
  3221. } else {
  3222. // 第二层不为KG类
  3223. if (row.singleWeight && item.measureQuantity) {
  3224. item.weight =
  3225. Number(item.measureQuantity) * Number(row.singleWeight);
  3226. } else {
  3227. item.weight = 0;
  3228. }
  3229. }
  3230. }
  3231. }
  3232. packingList.push(item);
  3233. }
  3234. } else {
  3235. for (let index = 0; index < packingCodeList.length; index++) {
  3236. let measureQuantity = 1;
  3237. let packingQuantity = 1;
  3238. // let packingUnit = row.unit;
  3239. // 处理单位为KG类,计算每桶KG值
  3240. if (packingBoolen) {
  3241. measureQuantity =
  3242. Number(row.quantity) >
  3243. this.$math.format(filterArr[0].packageCell * (index + 1), 14)
  3244. ? filterArr[0].packageCell
  3245. : Number(row.quantity) -
  3246. this.$math.format(filterArr[0].packageCell * index, 14);
  3247. } else {
  3248. //计量单位等于重量单位并且有总重 计量数量=总重/包装数
  3249. if (row.weightUnit == row.measureUnit && row.weight) {
  3250. measureQuantity =
  3251. Math.trunc((row.weight / packingCodeList.length) * 10000) /
  3252. 10000;
  3253. } else {
  3254. measureQuantity = row.packingSpecificationOption[1].packageCell;
  3255. }
  3256. }
  3257. console.log(
  3258. 'meadasdassureQuantity',
  3259. row.weight / row.packingQuantity
  3260. );
  3261. let item = {
  3262. index: row.index + '-' + index, // 包装索引
  3263. warehouseId: row.warehouseId, // 仓库id
  3264. warehouseName: row.warehouseName, // 仓库名称
  3265. categoryName: row.categoryName, // 产品名称
  3266. categoryCode: row.categoryCode, // 产品编码
  3267. categoryModel: row.categoryModel, // 物品型号
  3268. specification: row.specification, // 规格
  3269. supplierCode: row.supplierCode, // 供应商编码
  3270. brandNum: row.brandNum, // 牌号
  3271. parentIndex: row.index, // 产品索引
  3272. modelKey: row.modelKey, // 机型
  3273. colorKey: row.colorKey, //颜色
  3274. batchNo: row.batchNo, // 批次号
  3275. systemBatchNo: row.systemBatchNo, // 系统内部批次号
  3276. packageNo: packingCodeList[index]?.onlyCode, // 包装编码
  3277. packingQuantity: packingQuantity, // 包装数量
  3278. measureQuantity: measureQuantity, // 计量数量
  3279. measureUnit: row.isUnpack
  3280. ? measureBoolen
  3281. ? row.packingSpecificationOption[1]
  3282. ? row.packingSpecificationOption[1].packageUnit
  3283. : row.packingSpecificationOption[0].packageUnit
  3284. : row.measureUnit
  3285. : row.measureUnit, // 计量单位
  3286. weight: row.weight / row.packingQuantity,
  3287. packingSpecificationOption: row.packingSpecificationOption, // 包装规格
  3288. weightUnit: row.weightUnit, // 重量单位
  3289. netWeight: row.netWeight, // 净重
  3290. barcodes: '', // 发货条码
  3291. clientCode:
  3292. row.clientCode || (row.extInfo ? row.extInfo.clientCode : ''), // 客户代号
  3293. materielDesignation:
  3294. row.materielDesignation ||
  3295. (row.extInfo ? row.extInfo.materielCode : ''), // 物料代号
  3296. supplierName: row.supplierName, // 供应商名称
  3297. supplierCode: row.supplierCode, // 供应商代号
  3298. engrave: row.engrave, // 刻码
  3299. isUnpack: row.isUnpack, // 是否允许拆包
  3300. productionDate: productionDate, // 生产日期
  3301. purchaseDate: purchaseDate, // 采购时间
  3302. expireDate: expireDate,
  3303. result: 1, // 结果(1合格 2不合格)
  3304. status: 2 // 状态(0=未质检 1待检 2已检)
  3305. };
  3306. console.log(
  3307. row.packingSpecificationOption[1],
  3308. 'row.packingSpecificationOption[1]'
  3309. );
  3310. if (row.isUnpack) {
  3311. // 第二层条件: packingBoolen
  3312. item.packingUnit =
  3313. row.packingSpecificationOption[1].conversionUnit;
  3314. }
  3315. if (row.weightUnit == row.measureUnit) {
  3316. item.weight = item.measureQuantity
  3317. ? Number(item.measureQuantity)
  3318. : 0;
  3319. } else {
  3320. //单位不相等 物品层总重除包装层计量
  3321. item.weight = this.$math.format(
  3322. (row.singleWeight || 0) * item.measureQuantity,
  3323. 14
  3324. );
  3325. // console.log('计量单位为不为KG类======================');
  3326. // // 计量单位为不为KG类,重新统计计算
  3327. // let inBoolen = !!this.getDict(
  3328. // '不拆物料层规格',
  3329. // item.packingSpecificationOption[0].packageUnit
  3330. // ).dictValue;
  3331. // let startIndex = item.packingSpecificationOption.findIndex(
  3332. // (ite) => {
  3333. // return (
  3334. // item.measureUnit == ite.packingUnit &&
  3335. // ite.packingUnit != ite.conversionUnit
  3336. // );
  3337. // }
  3338. // );
  3339. // let endIndex = item.packingSpecificationOption.findIndex(
  3340. // (ite) => item.packingUnit == ite.conversionUnit
  3341. // );
  3342. // if (measureBoolen) {
  3343. // let total = item.packingQuantity
  3344. // ? Number(item.packingQuantity)
  3345. // : 0;
  3346. // for (; startIndex < endIndex; endIndex--) {
  3347. // total = this.$math.format(
  3348. // item.packingSpecificationOption[endIndex].packageCell *
  3349. // total,
  3350. // 14
  3351. // );
  3352. // }
  3353. // if (inBoolen) {
  3354. // // 第二层为KG类
  3355. // item.weight = total ? Number(total) : 0;
  3356. // } else {
  3357. // // 第二层不为KG类
  3358. // item.weight = this.$math.format(total * item.netWeight, 14);
  3359. // }
  3360. // } else if (!measureBoolen) {
  3361. // if (inBoolen) {
  3362. // // 第二层为KG类
  3363. // item.weight = item.measureQuantity
  3364. // ? Number(item.measureQuantity)
  3365. // : 0;
  3366. // } else {
  3367. // // 第二层不为KG类
  3368. // if (row.singleWeight && item.measureQuantity) {
  3369. // item.weight =
  3370. // Number(item.measureQuantity) * Number(row.singleWeight);
  3371. // } else {
  3372. // item.weight = item.weight || 0;
  3373. // }
  3374. // }
  3375. // }
  3376. }
  3377. packingList.push(item);
  3378. }
  3379. const existingIndex = this.packingList.findIndex(
  3380. (p) => p.parentIndex === row.index
  3381. );
  3382. if (existingIndex > -1) {
  3383. this.packingList.splice(existingIndex, 1); // 移除旧数据
  3384. }
  3385. }
  3386. console.log(productIndex, 'productIndex');
  3387. // 单独点击保存并插入对应位置(包装)
  3388. if (productIndex == 0) {
  3389. this.packingList.splice(productIndex, 0, ...packingList);
  3390. } else {
  3391. let packingIndex = this.packingList.findLastIndex(
  3392. (item) =>
  3393. item.parentIndex == this.productList[productIndex - 1].index
  3394. );
  3395. this.packingList.splice(packingIndex + 1, 0, ...packingList);
  3396. }
  3397. const lastIndex = this.packingList.length - 1;
  3398. let remainder = 0;
  3399. if (row.weightUnit != row.measureUnit) {
  3400. remainder =
  3401. row.measureQuantity %
  3402. row.packingSpecificationOption[1]?.packageCell;
  3403. }
  3404. console.log(remainder, 'remainder');
  3405. if (remainder > 0) {
  3406. let onlyCode = packingCodeList[packingCodeList.length - 1]?.onlyCode;
  3407. let index = this.packingList.findIndex(
  3408. (packingItem) => packingItem.packageNo == onlyCode
  3409. );
  3410. this.$set(this.packingList[index], 'measureQuantity', remainder);
  3411. if (row.singleWeight) {
  3412. this.$set(
  3413. this.packingList[index],
  3414. 'weight',
  3415. row.singleWeight * remainder
  3416. );
  3417. }
  3418. }
  3419. },
  3420. //入库明细删除
  3421. listDel(row, index) {
  3422. this.productList.splice(index, 1);
  3423. this.deletePackingAndMaterial(row);
  3424. },
  3425. // 打开仓库弹框
  3426. handleWareHouse(row, idx, type) {
  3427. console.log(row, 'row');
  3428. console.log(idx, 'idx');
  3429. console.log(type, 'type');
  3430. if (row.packingSpecificationLabel?.length < 1) {
  3431. this.$message.error('请到主数据维护包装组信息!');
  3432. return;
  3433. }
  3434. if (row.isSave) {
  3435. return false;
  3436. }
  3437. //单个
  3438. if (idx > -1 && type != 'batch') {
  3439. if (row.quantity > 0) {
  3440. if (!row.isUnpack) {
  3441. console.log('不拆');
  3442. //计量和包装单位相同
  3443. if (row.measureUnit == row.unit) {
  3444. let pNum = 0;
  3445. let mNum = row.measureQuantity;
  3446. this.$refs.wareHouseDailogRef.open({
  3447. packingQuantity: pNum,
  3448. measureQuantity: mNum,
  3449. idx,
  3450. warehouseId: row.warehouseId,
  3451. warehouseName: row.warehouseName + '',
  3452. categoryType: row.categoryLevelPathIdParent
  3453. });
  3454. } else {
  3455. if (row.packingSpecificationOption[1]?.packageCell) {
  3456. let num = row.quantity;
  3457. let splitIndex = row.packingSpecificationOption.findIndex(
  3458. (item) =>
  3459. item.conversionUnit == row.unit &&
  3460. item.packageUnit != item.conversionUnit
  3461. );
  3462. for (; splitIndex > 1; splitIndex--) {
  3463. num = this.$math.format(
  3464. num *
  3465. row.packingSpecificationOption[splitIndex].packageCell,
  3466. 14
  3467. );
  3468. }
  3469. this.$refs.wareHouseDailogRef.open({
  3470. packingQuantity: num,
  3471. measureQuantity: row.measureQuantity,
  3472. idx,
  3473. warehouseId: row.warehouseId,
  3474. warehouseName: row.warehouseName + '',
  3475. categoryType: row.categoryLevelPathIdParent
  3476. });
  3477. } else {
  3478. this.$refs.wareHouseDailogRef.open({
  3479. packingQuantity: num,
  3480. measureQuantity: row.measureQuantity,
  3481. idx,
  3482. warehouseId: row.warehouseId,
  3483. warehouseName: row.warehouseName + '',
  3484. categoryType: row.categoryLevelPathIdParent
  3485. });
  3486. }
  3487. }
  3488. } else {
  3489. console.log('拆');
  3490. // let filterArr = row.packingSpecificationOption.filter((item) => {
  3491. // return (
  3492. // item.packageUnit == row.packingUnit &&
  3493. // item.packageUnit != item.conversionUnit
  3494. // );
  3495. // });
  3496. let num = Math.ceil(
  3497. row.measureQuantity /
  3498. row.packingSpecificationOption[1]?.packageCell
  3499. );
  3500. console.log(num);
  3501. this.$refs.wareHouseDailogRef.open({
  3502. packingQuantity: num,
  3503. measureQuantity: row.measureQuantity,
  3504. idx,
  3505. warehouseId: row.warehouseId,
  3506. warehouseName: row.warehouseName + '',
  3507. categoryType: row.categoryLevelPathIdParent
  3508. });
  3509. }
  3510. } else {
  3511. this.$message.error('请先填写包装数量!');
  3512. }
  3513. } else {
  3514. //批量
  3515. console.log(row, `row`);
  3516. console.log(idx, `idx`);
  3517. console.log(type, 'type');
  3518. // 验证所有选中行是否填写了包装数量
  3519. if (row.some((item) => !item.quantity)) {
  3520. this.$message.error('请先填写所有行的包装数量!');
  3521. return;
  3522. }
  3523. // 计算总需求数量
  3524. let totalPacking = row.reduce((sum, item) => {
  3525. return sum + Number(this.calculateRequiredWarehouseNum(item));
  3526. }, 0);
  3527. const mNum = row.reduce((sum, item) => {
  3528. if (
  3529. item.measureQuantity !== undefined &&
  3530. item.measureQuantity !== null
  3531. ) {
  3532. return sum + Number(item.measureQuantity);
  3533. }
  3534. return sum;
  3535. }, 0);
  3536. // 打开仓库选择弹窗
  3537. this.$refs.wareHouseDailogRef.open({
  3538. packingQuantity: totalPacking,
  3539. measureQuantity: mNum,
  3540. batch: this.formData.extInfo.assetType
  3541. });
  3542. // this.$refs.wareHouseDailogRef.open(totalPacking, mNum);
  3543. }
  3544. },
  3545. calculateRequiredWarehouseNum(row) {
  3546. if (!row.isUnpack && row.measureUnit !== row.packingUnit) {
  3547. let splitIndex = row.packingSpecificationOption.findIndex(
  3548. (item) => item.conversionUnit === row.packingUnit
  3549. );
  3550. let num = row.packingQuantity;
  3551. for (; splitIndex > 1; splitIndex--) {
  3552. num = Math.ceil(
  3553. num * row.packingSpecificationOption[splitIndex].packageCell
  3554. );
  3555. }
  3556. return num;
  3557. }
  3558. console.log(row.packingQuantity, 'row.calculateRequiredWarehouseNum');
  3559. return row.packingQuantity;
  3560. },
  3561. wareHouseSelection(argum, idx) {
  3562. console.log(argum, 'argumargumargumargumargumargum', idx);
  3563. // 方便包装遍历获取仓库id和名称
  3564. let warehouseIds = [];
  3565. let warehouseNames = [];
  3566. argum.forEach((item) => {
  3567. console.log(item, 'itemitem');
  3568. for (let index = 0; index < item.packingQuantity; index++) {
  3569. warehouseIds.push(item.warehouseId);
  3570. warehouseNames.push(item.warehouseName);
  3571. }
  3572. });
  3573. console.log(idx, 'idxidxidxidx', this.productList, 'this.productList');
  3574. if (idx > -1) {
  3575. this.$set(
  3576. this.productList[idx],
  3577. 'warehouseId',
  3578. argum.map((item) => item.warehouseId).join(',')
  3579. );
  3580. this.$set(
  3581. this.productList[idx],
  3582. 'warehouseName',
  3583. argum.map((item) => item.warehouseName).join(',')
  3584. );
  3585. this.$set(this.productList[idx], 'warehouseIds', warehouseIds);
  3586. this.$set(this.productList[idx], 'warehouseNames', warehouseNames);
  3587. console.log(this.productList, 'productList');
  3588. } else {
  3589. this.productList.map((item, index) => {
  3590. this.$set(
  3591. this.productList[index],
  3592. 'warehouseId',
  3593. argum.map((item) => item.warehouseId).join(',')
  3594. );
  3595. this.$set(
  3596. this.productList[index],
  3597. 'warehouseName',
  3598. argum.map((item) => item.warehouseName).join(',')
  3599. );
  3600. this.$set(this.productList[index], 'warehouseIds', warehouseIds);
  3601. this.$set(
  3602. this.productList[index],
  3603. 'warehouseNames',
  3604. warehouseNames
  3605. );
  3606. });
  3607. }
  3608. this.$forceUpdate();
  3609. },
  3610. // 生成物料
  3611. generateMaterial(row) {
  3612. let materialList = [];
  3613. for (let index = 0; index < row.measureQuantity; index++) {
  3614. materialList.push({
  3615. materialCode: row.packageNo + index.toString().padStart(4, '0'), // 物料编码
  3616. index: row.index + '——' + index, // 包装索引
  3617. warehouseId: row.warehouseId, // 仓库id
  3618. warehouseName: row.warehouseName, // 仓库名称
  3619. categoryName: row.categoryName, // 产品名称
  3620. categoryCode: row.categoryCode, // 产品编码
  3621. parentIndex: row.index, // 产品索引
  3622. batchNo: row.batchNo, // 批次号
  3623. systemBatchNo: row.systemBatchNo, // 系统内部批次号
  3624. packageNo: row.packageNo, // 包装编码
  3625. measureQuantity: 1, // 计量数量
  3626. measureUnit: row.measureUnit, // 计量单位
  3627. weight: Number(
  3628. this.$math.format(row.weight / row.packingQuantity, 14)
  3629. ), // 重量
  3630. weightUnit: row.weightUnit, // 重量单位
  3631. barcodes: '', // 发货条码
  3632. clientCode: '', // 客户代号
  3633. materielDesignation: '', // 物料代号
  3634. engrave: '', // 刻码
  3635. result: 1, // 结果(1合格 2不合格)
  3636. status: 2 // 状态(0=未质检 1待检 2已检)
  3637. });
  3638. }
  3639. return materialList;
  3640. },
  3641. // 设置时间
  3642. dateSetting(curDateType, listType) {
  3643. if (!this.packingListSelected.length && !listType) {
  3644. return this.$message.error(`请选择${this.title}明细!`);
  3645. }
  3646. this.curDateType = curDateType;
  3647. this.listType = listType;
  3648. this.dateVisible = true;
  3649. },
  3650. // 选择包装列表
  3651. handleSelectionChange(val) {
  3652. this.packingListSelected = val;
  3653. },
  3654. // 选择质检结果改变质检状态
  3655. changeWrapStatus(resultValue, row, type) {
  3656. console.log(resultValue);
  3657. switch (resultValue) {
  3658. case 0:
  3659. // 清空质检状态
  3660. row.status = 0;
  3661. break;
  3662. default:
  3663. // 默认已检质检状态
  3664. row.status = 2;
  3665. break;
  3666. }
  3667. if (type === '包装') {
  3668. this.packingResultCahnge(resultValue, row);
  3669. } else {
  3670. this.materialResultCahnge(resultValue, row);
  3671. }
  3672. }
  3673. }
  3674. };
  3675. </script>
  3676. <style lang="scss" scoped>
  3677. .inbound_details {
  3678. margin-top: 10px;
  3679. .el-form-item {
  3680. margin-bottom: 0 !important;
  3681. }
  3682. }
  3683. .el-form-item {
  3684. margin-bottom: 5px;
  3685. }
  3686. .right_control {
  3687. display: flex;
  3688. > button {
  3689. margin-left: 5px;
  3690. }
  3691. }
  3692. .storage_btn {
  3693. margin-top: 20px;
  3694. display: flex;
  3695. align-content: center;
  3696. justify-content: center;
  3697. }
  3698. .el-date-editor.el-input,
  3699. .el-date-editor.el-input__inner {
  3700. width: 100% !important;
  3701. }
  3702. .red_color {
  3703. color: red;
  3704. }
  3705. .wareHouse_style {
  3706. text-overflow: ellipsis;
  3707. overflow: hidden;
  3708. word-break: break-all;
  3709. white-space: nowrap;
  3710. }
  3711. :deep(.el-col) {
  3712. margin-bottom: 12px;
  3713. }
  3714. </style>