add.vue 134 KB

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