add.vue 133 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720
  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. };
  1043. },
  1044. computed: {
  1045. ...mapGetters(['dict', 'getDict']),
  1046. clientEnvironmentId() {
  1047. return this.$store.state.user.info.clientEnvironmentId;
  1048. },
  1049. columns() {
  1050. return [
  1051. {
  1052. label: '序号',
  1053. type: 'index',
  1054. width: 50,
  1055. align: 'center'
  1056. },
  1057. {
  1058. label: '产品编码',
  1059. prop: 'categoryCode',
  1060. width: 130,
  1061. showOverflowTooltip: true,
  1062. align: 'center'
  1063. },
  1064. {
  1065. showOverflowTooltip: true,
  1066. label: '产品名称',
  1067. prop: 'categoryName',
  1068. width: 200,
  1069. align: 'center'
  1070. },
  1071. {
  1072. label: '型号',
  1073. showOverflowTooltip: true,
  1074. prop: 'categoryModel',
  1075. width: 100,
  1076. align: 'center'
  1077. },
  1078. {
  1079. label: '规格',
  1080. prop: 'specification',
  1081. showOverflowTooltip: true,
  1082. width: 100,
  1083. align: 'center'
  1084. },
  1085. {
  1086. label: '牌号',
  1087. prop: 'brandNum',
  1088. showOverflowTooltip: true,
  1089. width: 100,
  1090. align: 'center'
  1091. },
  1092. ...this.newColumns.map((item) => {
  1093. return {
  1094. label: item.label,
  1095. prop: item.prop,
  1096. showOverflowTooltip: true,
  1097. width: 100,
  1098. align: 'center'
  1099. };
  1100. }),
  1101. {
  1102. label: '批次号',
  1103. showOverflowTooltip: true,
  1104. prop: 'batchNo',
  1105. width: 200,
  1106. slot: 'batchNo',
  1107. align: 'center',
  1108. headerSlot: 'headerBatchNo'
  1109. },
  1110. {
  1111. label: '数量',
  1112. showOverflowTooltip: true,
  1113. prop: 'quantity',
  1114. slot: 'quantity',
  1115. width: 180,
  1116. align: 'center',
  1117. headerSlot: 'headerPackingQuantity'
  1118. },
  1119. {
  1120. label: '单位',
  1121. showOverflowTooltip: true,
  1122. prop: 'unit',
  1123. slot: 'unit',
  1124. width: 100,
  1125. align: 'center'
  1126. },
  1127. {
  1128. label: '包装数量',
  1129. showOverflowTooltip: true,
  1130. prop: 'packingQuantity',
  1131. slot: 'packingQuantity',
  1132. width: 180,
  1133. align: 'center'
  1134. },
  1135. {
  1136. label: '包装单位',
  1137. showOverflowTooltip: true,
  1138. prop: 'packingUnit',
  1139. slot: 'packingUnit',
  1140. width: 100,
  1141. align: 'center'
  1142. },
  1143. {
  1144. label: '包装规格',
  1145. showOverflowTooltip: true,
  1146. prop: 'packingSpecificationLabel',
  1147. slot: 'packingSpecificationLabel',
  1148. width: 300,
  1149. align: 'center'
  1150. },
  1151. {
  1152. label: '允许拆包',
  1153. prop: 'isUnpack',
  1154. width: 80,
  1155. formatter: (_row, _column, cellValue) => {
  1156. return cellValue ? '是' : '否';
  1157. },
  1158. align: 'center'
  1159. },
  1160. {
  1161. label: '计量数量',
  1162. prop: 'measureQuantity',
  1163. width: 100,
  1164. align: 'center'
  1165. },
  1166. {
  1167. label: '计量单位',
  1168. prop: 'measureUnit',
  1169. width: 100,
  1170. align: 'center'
  1171. },
  1172. {
  1173. label: '单重',
  1174. prop: 'singleWeight',
  1175. slot: 'singleWeight',
  1176. showOverflowTooltip: true,
  1177. width: 180,
  1178. align: 'center'
  1179. },
  1180. {
  1181. label: '总重',
  1182. prop: 'weight',
  1183. slot: 'weight',
  1184. showOverflowTooltip: true,
  1185. width: 150,
  1186. align: 'center'
  1187. },
  1188. {
  1189. label: '重量单位',
  1190. prop: 'weightUnit',
  1191. showOverflowTooltip: true,
  1192. width: 100,
  1193. align: 'center'
  1194. },
  1195. this.isPrice == 1
  1196. ? {
  1197. label: '单价',
  1198. slot: 'price',
  1199. prop: 'price',
  1200. showOverflowTooltip: true,
  1201. width: 150,
  1202. align: 'center'
  1203. }
  1204. : {
  1205. label: '单价',
  1206. prop: 'price',
  1207. width: 1
  1208. },
  1209. this.isPrice == 1
  1210. ? {
  1211. label: '金额',
  1212. slot: 'totalMoney',
  1213. prop: 'totalMoney',
  1214. showOverflowTooltip: true,
  1215. width: 100,
  1216. align: 'center'
  1217. }
  1218. : {
  1219. label: '金额',
  1220. prop: 'totalMoney',
  1221. width: 1
  1222. },
  1223. {
  1224. label: '供应商',
  1225. slot: 'supplierId',
  1226. prop: 'supplierId',
  1227. showOverflowTooltip: true,
  1228. width: 200,
  1229. align: 'center'
  1230. },
  1231. {
  1232. label: '供应商代号',
  1233. slot: 'supplierCode',
  1234. showOverflowTooltip: true,
  1235. width: 100,
  1236. align: 'center'
  1237. },
  1238. {
  1239. label: '仓库',
  1240. prop: 'warehouseName',
  1241. slot: 'warehouseName',
  1242. showOverflowTooltip: true,
  1243. width: 300,
  1244. align: 'center'
  1245. },
  1246. {
  1247. minWidth: 300,
  1248. prop: 'modelKey',
  1249. showOverflowTooltip: true,
  1250. label: '机型',
  1251. slot: 'modelKey',
  1252. align: 'center'
  1253. },
  1254. {
  1255. minWidth: 300,
  1256. prop: 'colorKey',
  1257. showOverflowTooltip: true,
  1258. label: '颜色',
  1259. slot: 'colorKey',
  1260. align: 'center'
  1261. },
  1262. {
  1263. label: '采购原因',
  1264. prop: 'purpose',
  1265. slot: 'purpose',
  1266. showOverflowTooltip: true,
  1267. width: 200,
  1268. align: 'center'
  1269. },
  1270. {
  1271. label: '生产日期',
  1272. prop: 'detailProductionDate',
  1273. slot: 'detailProductionDate',
  1274. showOverflowTooltip: true,
  1275. width: 220,
  1276. align: 'center'
  1277. },
  1278. {
  1279. label: '采购日期',
  1280. prop: 'detailPurchaseDate',
  1281. slot: 'detailPurchaseDate',
  1282. showOverflowTooltip: true,
  1283. width: 220,
  1284. align: 'center'
  1285. },
  1286. {
  1287. label: '失效日期',
  1288. prop: 'detailExpireDate',
  1289. slot: 'detailExpireDate',
  1290. showOverflowTooltip: true,
  1291. width: 220,
  1292. align: 'center'
  1293. },
  1294. {
  1295. columnKey: 'action',
  1296. label: '操作',
  1297. width: 250,
  1298. align: 'center',
  1299. resizable: false,
  1300. slot: 'action',
  1301. showOverflowTooltip: true,
  1302. fixed: 'right'
  1303. }
  1304. ];
  1305. }
  1306. },
  1307. watch: {
  1308. packingList: {
  1309. handler(newVal) {
  1310. console.log('包装列表', newVal);
  1311. console.log('当前包装列表加载页数', this.pickingPageNum);
  1312. this.showPackingList = newVal.slice(
  1313. 0,
  1314. this.pageSize * (this.pickingPageNum > 0 ? this.pickingPageNum : 1)
  1315. );
  1316. this.pickingPageNum = Math.ceil(
  1317. this.showPackingList.length / this.pageSize
  1318. );
  1319. },
  1320. deep: true
  1321. },
  1322. materialList: {
  1323. handler(newVal) {
  1324. console.log('物料列表', newVal);
  1325. console.log('当前物料列表加载页数', this.materielPageNum);
  1326. this.showMaterialList = newVal.slice(
  1327. 0,
  1328. this.pageSize *
  1329. (this.materielPageNum > 0 ? this.materielPageNum : 1)
  1330. );
  1331. },
  1332. deep: true
  1333. },
  1334. '$route.query': {
  1335. handler(newQuery, oldQuery) {
  1336. if (newQuery?.detailId) {
  1337. this.viewInit();
  1338. }
  1339. },
  1340. deep: true // 确保对象内部的属性变化也能被监听到
  1341. }
  1342. },
  1343. created() {
  1344. //仓库出入库是否显示金额(0:不显示 1:显示)
  1345. parameterGetByCode({
  1346. code: 'wms_price'
  1347. }).then((res) => {
  1348. this.isPrice = res.value;
  1349. });
  1350. if (this.$route.query.name == 'inboundRequests') {
  1351. this.getProduct();
  1352. }
  1353. this.requestDict('不拆物料层规格');
  1354. this.getFieldModel();
  1355. this.getListItems();
  1356. this.initUserInfo();
  1357. this.getNowFormatDate();
  1358. if (this.$route.query.id && !this.$route.query.name) {
  1359. storageApi
  1360. .getApplystorageDetailById(this.$route.query.id)
  1361. .then(async (data) => {
  1362. this.formData.extInfo.assetType = [data.rootCategoryLevelId];
  1363. this.formData.bizType = String(data.type);
  1364. this.formData.sourceBizNo = data.code;
  1365. this.formData.id = data.id;
  1366. this.formData.bizNo = data.bizNo;
  1367. const batchNo = await getCode('lot_number_code');
  1368. this.productList = data.detailList.map((item, index) => {
  1369. return {
  1370. index: this.productList.length + index,
  1371. categoryId: item.categoryId, // 物品id
  1372. categoryName: item.categoryName, // 物品名称
  1373. categoryCode: item.categoryCode, // 物品编码
  1374. categoryModel: item.modelType, // 物品型号
  1375. specification: item.specification, // 规格
  1376. brandNum: item.brandNum, // 牌号
  1377. batchNo: item.batchNo || batchNo, // 批次号
  1378. minPackingQuantity: item.quantity, // 最小包装单元数量
  1379. packingQuantity: 1, // 包装数量
  1380. packingUnit: item.packingUnit, // 单位
  1381. measureQuantity: 0, // 计量数量
  1382. measureUnit: item.measuringUnit, // 计量单位
  1383. netWeight: item.netWeight > -1 ? item.netWeight : 0, // 净重
  1384. weight: item?.packingWeight || 0, // 重量
  1385. weightUnit: item.weightUnit, // 重量单位
  1386. totalMoney: '', // 总价
  1387. unitPrice: item.unitPrice, // 单价
  1388. purpose: item.purpose, // 用途
  1389. isUnpack: item.isUnpack, // 是否允许拆包
  1390. warehouseId: item.warehouseId, // 仓库Id
  1391. warehouseName: item.warehouseName, // 仓库名称
  1392. warehouseIds: [item.warehouseId],
  1393. warehouseNames: [item.warehouseName]
  1394. // 编辑时单位选择消失bug
  1395. };
  1396. });
  1397. // this.$nextTick(() => {
  1398. // this.listSaveArrs();
  1399. // });
  1400. });
  1401. }
  1402. if (this.$route.query.detailId) {
  1403. this.viewInit();
  1404. }
  1405. },
  1406. methods: {
  1407. ...mapActions('dict', ['requestDict']),
  1408. changeCount(number) {
  1409. return new BigNumber(number).toString();
  1410. },
  1411. viewInit() {
  1412. const _this = this;
  1413. // 编辑时选单位没有选项bug
  1414. let packingSpecification;
  1415. storageApi
  1416. .getInboundDetailsById(this.$route.query.detailId)
  1417. .then(async (data) => {
  1418. this.formData.extInfo.assetType = data.extInfo.assetType.split(',');
  1419. this.formData.bizType = String(data.bizType);
  1420. this.formData.sourceBizNo = data.code;
  1421. this.formData.id = data.id;
  1422. this.formData.bizNo = data.bizNo;
  1423. const batchNo = await getCode('lot_number_code');
  1424. packingSpecification =
  1425. await storageApi.getCategoryPackageDisposition({
  1426. categoryIds: data.outInDetailList.map((item) => item.categoryId)
  1427. });
  1428. console.log(packingSpecification);
  1429. this.packingSpecificationOption = data.outInDetailList.map(
  1430. (item) => {
  1431. return packingSpecification
  1432. .filter((ite) => item.categoryId == ite.categoryId)
  1433. .sort((a, b) => a.sort - b.sort);
  1434. }
  1435. );
  1436. const newSpecificationOption = this.packingSpecificationOption;
  1437. this.productList = data.outInDetailList.map(
  1438. (productItem, productIndex) => {
  1439. return {
  1440. ...productItem,
  1441. index: this.productList.length + productIndex,
  1442. isSave: true,
  1443. // 编辑时没有单位选项
  1444. packingSpecificationOption:
  1445. newSpecificationOption[productIndex],
  1446. //
  1447. packingSpecificationLabel:
  1448. productItem.extField?.packingSpecification?.split(','),
  1449. batchNo: productItem.batchNo || batchNo, // 批次号
  1450. warehouseIds: [productItem.warehouseId], // 仓库Id
  1451. warehouseNames: [productItem.warehouseName], // 仓库名称
  1452. outInDetailRecordRequestList:
  1453. productItem.outInDetailRecordRequestList?.length > 0
  1454. ? productItem.outInDetailRecordRequestList.map(
  1455. (packingItem, packingIndex) => {
  1456. return {
  1457. ...packingItem,
  1458. index:
  1459. this.productList.length +
  1460. productIndex +
  1461. '-' +
  1462. packingIndex, // 包装索引
  1463. batchNo: productItem.batchNo || batchNo, // 批次号
  1464. parentIndex:
  1465. this.productList.length + productIndex, // 物品索引
  1466. categoryName: productItem.categoryName,
  1467. categoryCode: productItem.categoryCode,
  1468. materialDetailList:
  1469. packingItem.materialDetailList.map(
  1470. (materialItem, materialIndex) => {
  1471. return {
  1472. ...materialItem,
  1473. index:
  1474. this.productList.length +
  1475. productIndex +
  1476. '-' +
  1477. packingIndex +
  1478. '——' +
  1479. materialIndex, // 包装索引
  1480. parentIndex:
  1481. this.productList.length +
  1482. productIndex +
  1483. '-' +
  1484. packingIndex, // 物品索引
  1485. batchNo: batchNo, // 批次号
  1486. categoryName: productItem.categoryName,
  1487. categoryCode: productItem.categoryCode
  1488. };
  1489. }
  1490. )
  1491. };
  1492. }
  1493. )
  1494. : []
  1495. };
  1496. }
  1497. );
  1498. console.log('this.productList-----------', this.productList);
  1499. // 获取包装维度数据
  1500. const arr = [];
  1501. for (const key in this.productList) {
  1502. for (const k in this.productList[key]
  1503. .outInDetailRecordRequestList) {
  1504. arr.push({
  1505. ...this.productList[key].outInDetailRecordRequestList[k]
  1506. });
  1507. }
  1508. }
  1509. this.packingList = arr;
  1510. // 获取物料维度数据
  1511. let iArr = [];
  1512. arr.forEach((item) => {
  1513. item.materialDetailList.forEach((ele) => {
  1514. iArr.push({ ...ele });
  1515. });
  1516. });
  1517. this.materialList = iArr;
  1518. });
  1519. },
  1520. selectSupplier(val, row) {
  1521. row.supplierId = val;
  1522. row.supplierName = row.supplierListOptions.filter(
  1523. (item) => item.id == val
  1524. )[0].name;
  1525. row.supplierCode = row.supplierListOptions.filter(
  1526. (item) => item.id == val
  1527. )[0].serialNo;
  1528. },
  1529. inputSingleWeight(row, index) {
  1530. console.log(row, 'row1');
  1531. if (row.singleWeight < 0) {
  1532. this.$set(this.productList[index], 'singleWeight', 1);
  1533. }
  1534. if (row.measureUnit == row.weightUnit) {
  1535. row.weight = row.singleWeight * row.quantity;
  1536. row.measureQuantity = row.weight;
  1537. } else {
  1538. row.weight = row.singleWeight * row.measureQuantity;
  1539. }
  1540. //重量
  1541. // if (row.measureType == '2') {
  1542. // if (row.packingUnit == 'KG') {
  1543. // const weight =
  1544. // Number(row.measureQuantity) * Number(row.singleWeight);
  1545. // this.$set(this.productList[index], 'weight', weight);
  1546. // } else {
  1547. // this.$set(this.productList[index], 'weight', measureQuantity);
  1548. // }
  1549. // }
  1550. console.log(row, 'row2');
  1551. },
  1552. inputAllweight(row, index) {
  1553. if (row.weight < 0) {
  1554. this.$set(this.productList[index], 'weight', 1);
  1555. }
  1556. if (row.measureUnit == row.weightUnit) {
  1557. row.measureQuantity = row.weight;
  1558. row.singleWeight =
  1559. Math.trunc((row.measureQuantity / row.quantity) * 10000) / 10000;
  1560. } else {
  1561. row.singleWeight = row.measureQuantity
  1562. ? row.weight / row.measureQuantity
  1563. : 0;
  1564. }
  1565. // const singleWeight = Number(row.weight) / Number(row.measureQuantity);
  1566. // this.$set(this.productList[index], 'singleWeight', singleWeight);
  1567. },
  1568. // 仓库选择
  1569. // wareHouseSelection(val, index) {
  1570. // console.log('仓库选择', val);
  1571. // let arr = this.productList[index].outInDetail
  1572. // },
  1573. // 计算最小单元数量
  1574. // 小数处理,最大3位
  1575. format3(str) {
  1576. let value = str;
  1577. value = value.toString().replace(/[^0-9.]/g, '');
  1578. const parts = value.split('.');
  1579. if (parts.length > 2) {
  1580. value = parts[0] + '.' + parts.slice(1).join('');
  1581. }
  1582. if (parts.length === 2) {
  1583. value = parts[0] + '.' + parts[1].slice(0, 3);
  1584. }
  1585. console.log(value);
  1586. return value;
  1587. },
  1588. async computeNum(row, index, isClear) {
  1589. row.quantity = this.format3(row.quantity);
  1590. // console.log(row.packingSpecificationOption);
  1591. // console.log(row.packingUnit);
  1592. let data = row.packingSpecificationOption.find(
  1593. (item) => item.id == row.unitId
  1594. );
  1595. row.unit = data.conversionUnit;
  1596. // 清空仓库(包装数量输入)
  1597. if (isClear) {
  1598. if (row.quantity < 0) {
  1599. this.$set(this.productList[index], 'quantity', 1);
  1600. }
  1601. }
  1602. //如果有包装数量和包装单位
  1603. if (row.quantity && row.unit) {
  1604. //获取仓库
  1605. const res = await warehouseDefinition.list({
  1606. inventoryType: row?.categoryLevelPathIdParent
  1607. });
  1608. // 只有一个仓库自动显示出来
  1609. if (res.length == 1) {
  1610. // let name = res[0]?.factoryName + '-' + res[0]?.name;
  1611. let name = res[0]?.name;
  1612. console.log('仓库-----------------------------', res);
  1613. this.$set(this.productList[index], 'warehouseId', res[0].id);
  1614. this.$set(this.productList[index], 'warehouseName', name);
  1615. let table1 = [];
  1616. table1.push({
  1617. measureQuantity: row.measureQuantity,
  1618. packingQuantity: row.quantity,
  1619. warehouseName: name,
  1620. warehouseId: res[0].id
  1621. });
  1622. this.wareHouseSelection(table1, index);
  1623. } else {
  1624. this.$set(this.productList[index], 'warehouseId', '');
  1625. this.$set(this.productList[index], 'warehouseName', '');
  1626. }
  1627. // -----------------------------------------------------------------
  1628. // let startIndex = row.packingSpecificationOption.findIndex((ite) => {
  1629. // return (
  1630. // data.id == ite.id &&
  1631. // ite.packingUnit != ite.conversionUnit
  1632. // );
  1633. // });
  1634. let endIndex = row.packingSpecificationOption.findIndex(
  1635. (ite) => data.id == ite.id
  1636. );
  1637. console.log(endIndex, 'endIndex');
  1638. let total = Number(row.quantity);
  1639. for (; 0 < endIndex; endIndex--) {
  1640. total = this.$math.format(
  1641. row.packingSpecificationOption[endIndex].packageCell * total,
  1642. 14
  1643. );
  1644. }
  1645. //计量数量
  1646. row.measureQuantity = this.changeCount(total);
  1647. // --------------------------------------------------------------------
  1648. //计量单位不是数量时,配置了单重的重量计算
  1649. // row.measureType != 1 &&
  1650. let weight = 0;
  1651. if (row.measureUnit == row.weightUnit) {
  1652. weight = row.measureQuantity;
  1653. //包装单位与重量单位相等时,单重重量为0
  1654. if (row.unit == row.weightUnit) {
  1655. row.singleWeight = 0;
  1656. } else {
  1657. row.singleWeight =
  1658. Math.trunc((row.measureQuantity / row.quantity) * 10000) /
  1659. 10000;
  1660. }
  1661. } else if (row.singleWeight) {
  1662. weight = row.measureQuantity * Number(row.singleWeight);
  1663. }
  1664. this.$set(this.productList[index], 'weight', weight);
  1665. this.$set(
  1666. this.productList[index],
  1667. 'packingQuantity',
  1668. this.setPNum(row)
  1669. );
  1670. }
  1671. },
  1672. //出入库申请列表操作直接入库
  1673. getProduct() {
  1674. let aaa = [this.$route.query.inId];
  1675. console.log(aaa, '出入库申请入库操作直接入库');
  1676. storageApi.getApplystoragedetails(aaa).then(async (res) => {
  1677. if (this.$route.query.type == 2) {
  1678. // 出库
  1679. let data = await storageApi.getHierarchyFifo({
  1680. type: 1,
  1681. builders: res.map((item) => {
  1682. return {
  1683. categoryId: item.categoryId,
  1684. num: item.measureQuantity
  1685. };
  1686. })
  1687. });
  1688. if (data?.length > 0) {
  1689. this.outboundRequisitionSelection(data, 1, {
  1690. sourceBizNo: this.$route.query.code,
  1691. bizType: this.$route.query.sourceType,
  1692. assetType: Array.from(
  1693. new Set(res.map((item) => item.rootCategoryLevelId))
  1694. ).join(',')
  1695. });
  1696. } else {
  1697. this.$message.warning('该出库申请单无库存');
  1698. }
  1699. } else {
  1700. // 入库
  1701. const batchNo = await getCode('lot_number_code');
  1702. console.log(res, '入库');
  1703. let data = res.map((item, index) => {
  1704. delete item.extInfo;
  1705. return {
  1706. ...item,
  1707. index,
  1708. batchNo,
  1709. id: '',
  1710. warehouseIds: [item.warehouseId],
  1711. warehouseNames: [item.warehouseName]
  1712. };
  1713. });
  1714. this.outboundRequisitionSelection(data, 1, {
  1715. sourceBizNo: this.$route.query.code,
  1716. bizType: this.$route.query.sourceType,
  1717. assetType: Array.from(
  1718. new Set(res.map((item) => item.rootCategoryLevelId))
  1719. ).join(',')
  1720. });
  1721. }
  1722. });
  1723. },
  1724. async outboundRequisitionSelection(data, dimension, query) {
  1725. console.log('data-----------', data);
  1726. console.log('query-----------', query);
  1727. console.log(this.formData.bizType, 'bbbbbtype');
  1728. if (this.formData.bizType != 10) {
  1729. this.formData.sourceBizNo = query.sourceBizNo;
  1730. this.formData.bizType = query.bizType;
  1731. this.formData.extInfo.assetType = query.assetType.split(',');
  1732. const batchNo = await getCode('lot_number_code');
  1733. // 获取包装规格
  1734. let packingSpecification =
  1735. await storageApi.getCategoryPackageDisposition({
  1736. categoryIds: data.map((item) => item.categoryId)
  1737. });
  1738. // 获取供应商
  1739. const supplierList = await storageApi.contactQueryByCategoryIdsAPI({
  1740. categoryIds: data.map((item) => item.categoryId)
  1741. });
  1742. this.packingSpecificationOption = data.map((item) => {
  1743. return packingSpecification
  1744. .filter((ite) => item.categoryId == ite.categoryId)
  1745. .sort((a, b) => a.sort - b.sort);
  1746. });
  1747. console.log(
  1748. 'this.packingSpecificationOption------------------------------------------包装组',
  1749. this.packingSpecificationOption
  1750. );
  1751. console.log(data, 'datadatadatadatadata');
  1752. data.map((productItem, productIndex) => {
  1753. // 显示规格
  1754. let packingSpecificationLabel = this.packingSpecificationOption[
  1755. productIndex
  1756. ]
  1757. .map((item) => {
  1758. if (item.sort > 0) {
  1759. return `${item.packageCell}${item.packageUnit}/${item.conversionUnit}`;
  1760. }
  1761. })
  1762. .filter((item) => !!item);
  1763. // let r= {
  1764. // ...productItem,
  1765. console.log(productItem, 'productItem');
  1766. productItem.weight = productItem.weight
  1767. ? Number(productItem.weight)
  1768. : 0;
  1769. // productItem.singleWeight = 0;
  1770. productItem.measureUnit = productItem.measuringUnit; // 计量单位
  1771. productItem.index = this.productList.length + productIndex;
  1772. productItem.isSave =
  1773. productItem.outInDetailRecordRequestList?.length > 0
  1774. ? true
  1775. : false;
  1776. productItem.netWeight =
  1777. productItem.netWeight > 0 ? productItem.netWeight : 0;
  1778. productItem.materielCode = productItem.materielCode;
  1779. productItem.categoryModel = productItem.modelType; // 物品型号
  1780. productItem.specification = productItem.specification; // 规格
  1781. productItem.engrave = productItem.engrave; // 刻码
  1782. productItem.materielDesignation = productItem.materielDesignation; //物料代号
  1783. productItem.clientCode = productItem.clientCode; // 客户代号
  1784. productItem.batchNo = productItem.batchNo || batchNo; // 批次号
  1785. productItem.warehouseIds = [productItem.warehouseId]; // 仓库Id
  1786. productItem.warehouseNames = [productItem.warehouseName]; // 仓库名称
  1787. productItem.packingSpecificationOption =
  1788. this.packingSpecificationOption[productIndex]; // 包装规格选项
  1789. productItem.packingSpecificationLabel = packingSpecificationLabel; // 包装规格显示
  1790. productItem.outInDetailRecordRequestList =
  1791. productItem.outInDetailRecordRequestList?.length > 0
  1792. ? productItem.outInDetailRecordRequestList.map(
  1793. (packingItem, packingIndex) => {
  1794. return {
  1795. ...packingItem,
  1796. index:
  1797. this.productList.length +
  1798. productIndex +
  1799. '-' +
  1800. packingIndex, // 包装索引
  1801. batchNo: productItem.batchNo || batchNo, // 批次号
  1802. parentIndex: this.productList.length + productIndex, // 物品索引
  1803. categoryName: productItem.categoryName,
  1804. categoryCode: productItem.categoryCode,
  1805. materialDetailList: packingItem.materialDetailList.map(
  1806. (materialItem, materialIndex) => {
  1807. return {
  1808. ...materialItem,
  1809. index:
  1810. this.productList.length +
  1811. productIndex +
  1812. '-' +
  1813. packingIndex +
  1814. '——' +
  1815. materialIndex, // 包装索引
  1816. parentIndex:
  1817. this.productList.length +
  1818. productIndex +
  1819. '-' +
  1820. packingIndex, // 物品索引
  1821. batchNo: batchNo, // 批次号
  1822. categoryName: productItem.categoryName,
  1823. categoryCode: productItem.categoryCode
  1824. };
  1825. }
  1826. )
  1827. };
  1828. }
  1829. )
  1830. : [];
  1831. });
  1832. // this.productList = data;
  1833. this.productList = data.map((item) => {
  1834. if (item.weight === null || item.weight === undefined) {
  1835. item.weight = 0;
  1836. }
  1837. (item.supplierListOptions = supplierList[item.categoryId]), // 供应商列表
  1838. (item.packingUnit = item.measuringUnit); // 单位
  1839. item.packingUnitId = item.packingSpecificationOption.find(
  1840. (v) => v.conversionUnit == item.measuringUnit
  1841. )?.id; // 单位
  1842. // if (this.formData.bizType == 4) {
  1843. // item.packingUnit = '箱';
  1844. // } else {
  1845. // item.packingUnit = '';
  1846. // }
  1847. return item;
  1848. });
  1849. console.log(this.productList, 'productList');
  1850. this.$nextTick(() => {
  1851. this.batchSave();
  1852. });
  1853. // this.productList.map((v) => {
  1854. // v.weight = isNaN(v.weight);
  1855. // });
  1856. // 获取包装维度数据
  1857. // const arr = [];
  1858. // for (const key in this.productList) {
  1859. // for (const k in this.productList[key]
  1860. // .outInDetailRecordRequestList) {
  1861. // arr.push({
  1862. // ...this.productList[key].outInDetailRecordRequestList[k]
  1863. // });
  1864. // }
  1865. // }
  1866. // 获取物料维度数据
  1867. // let iArr = [];
  1868. // arr.forEach((item) => {
  1869. // item.materialDetailList.forEach((ele) => {
  1870. // iArr.push({ ...ele });
  1871. // });
  1872. // });
  1873. // this.materialList = iArr;
  1874. } else {
  1875. this.selWWData = query;
  1876. this.$set(this.formData, 'sourceBizNo', query.sourceBizNo);
  1877. }
  1878. },
  1879. // 获取动态表头
  1880. getFieldModel() {
  1881. storageApi.fieldModel({ fieldModel: 't_main_category' }).then((res) => {
  1882. let newRes = res
  1883. .map((m) => {
  1884. return {
  1885. prop: 'extField.' + m.prop,
  1886. label: m.label,
  1887. align: 'center',
  1888. showOverflowTooltip: true
  1889. };
  1890. })
  1891. .filter((item) => item.label !== '包装规格');
  1892. console.log(newRes, 'newRes');
  1893. this.newColumns = [...newRes];
  1894. });
  1895. },
  1896. // 初始化当前用户信息
  1897. async initUserInfo() {
  1898. const res = await warehouseDefinition.tree();
  1899. let info = JSON.parse(localStorage.getItem('info'));
  1900. console.log(info, 'infoinfoinfo');
  1901. let obj = res.find(
  1902. (item) => item.id === info.deptIds[info.deptIds.length - 1]
  1903. );
  1904. // if (!obj) return;
  1905. if (obj) {
  1906. console.log(
  1907. obj,
  1908. 'objobjobjobjobjobjobjobjobjobjobjobjobjobjobjobjobj'
  1909. );
  1910. this.formData.extInfo.deptCode = obj?.id;
  1911. this.formData.extInfo.deptName = obj?.name;
  1912. } else {
  1913. this.formData.extInfo.deptName = info.deptName
  1914. ? info.deptName
  1915. : info.groupName
  1916. ? info.groupName
  1917. : '';
  1918. }
  1919. this.formData.extInfo.createUserName = info.name;
  1920. this.formData.createUserId = info.userId;
  1921. },
  1922. // 获取当前时间函数
  1923. getNowDate() {
  1924. let date = new Date(),
  1925. obj = {
  1926. year: date.getFullYear(), //获取完整的年份(4位)
  1927. month: date.getMonth() + 1, //获取当前月份(0-11,0代表1月)
  1928. strDate: date.getDate(), // 获取当前日(1-31)
  1929. hour: date.getHours(), //获取当前小时(0 ~ 23)
  1930. minute: date.getMinutes(), //获取当前分钟(0 ~ 59)
  1931. second: date.getSeconds() //获取当前秒数(0 ~ 59)
  1932. };
  1933. Object.keys(obj).forEach((key) => {
  1934. if (obj[key] < 10) obj[key] = `0${obj[key]}`;
  1935. });
  1936. return obj;
  1937. },
  1938. // 赋值入库时间
  1939. getNowFormatDate() {
  1940. let obj = this.getNowDate();
  1941. this.formData.storageTime = `${obj.year}-${obj.month}-${obj.strDate} ${obj.hour}:${obj.minute}:${obj.second}`;
  1942. },
  1943. // 获取物品列表
  1944. async getListItems() {
  1945. const res2 = await warehouseDefinition.getTreeByGroup({ type: 2 });
  1946. this.goodsLists = res2;
  1947. },
  1948. // 打开单据来源弹窗
  1949. openDocumentSourceDialog() {
  1950. console.log('打开单据来源弹窗');
  1951. this.$refs.outboundRequisitionDialogRef.open();
  1952. },
  1953. // 清除单据来源
  1954. clearSourceBizNo() {
  1955. this.$set(this.formData, 'sourceBizNo', '');
  1956. this.productList = [];
  1957. this.packingList = [];
  1958. },
  1959. // 返回
  1960. back() {
  1961. this.$router.go(-1);
  1962. },
  1963. // 添加产品
  1964. addProduct() {
  1965. this.$refs.formName.validate((valid) => {
  1966. if (valid) {
  1967. this.visibleDialog = true;
  1968. } else {
  1969. console.log('error submit!!');
  1970. return false;
  1971. }
  1972. });
  1973. // if (this.formData.extInfo.assetType.length <= 0) {
  1974. // return this.$message.error('请选择物品类型');
  1975. // }
  1976. // if (!this.formData.bizType) {
  1977. // return this.$message.error('请选择入库类型');
  1978. // }
  1979. },
  1980. contactDialogSuccess(data) {
  1981. this.$set(this.formData, 'clientName', data.name);
  1982. this.$set(this.formData, 'clientCode', data.code);
  1983. },
  1984. // 键盘移动
  1985. moveFocus(event, index, key, type, row) {
  1986. let keyfield = [];
  1987. let listLength = 0;
  1988. switch (type) {
  1989. case '产品':
  1990. listLength = this.productList.length;
  1991. keyfield = ['batchNo', 'quantity', 'unitPrice', 'purpose'];
  1992. break;
  1993. case '包装':
  1994. listLength = this.showPackingList.length;
  1995. if (row.measureUnit != row.weightUnit) {
  1996. keyfield = [
  1997. 'packing_materielDesignation',
  1998. 'packing_clientCode',
  1999. 'packing_engrave',
  2000. 'packing_weight'
  2001. ];
  2002. } else {
  2003. keyfield = [
  2004. 'packing_materielDesignation',
  2005. 'packing_clientCode',
  2006. 'packing_engrave'
  2007. ];
  2008. }
  2009. break;
  2010. case '物料':
  2011. listLength = this.showMaterialList.length;
  2012. if (row.measureUnit != row.weightUnit) {
  2013. keyfield = [
  2014. 'material_materielDesignation',
  2015. 'material_clientCode',
  2016. 'material_engrave',
  2017. 'material_weight'
  2018. ];
  2019. } else {
  2020. keyfield = [
  2021. 'material_materielDesignation',
  2022. 'material_clientCode',
  2023. 'material_engrave'
  2024. ];
  2025. }
  2026. break;
  2027. }
  2028. if (event.keyCode === 13) {
  2029. // 回车
  2030. if (
  2031. index === listLength - 1 &&
  2032. key === keyfield[keyfield.length - 1]
  2033. ) {
  2034. // 最后一行最后一个
  2035. return;
  2036. }
  2037. this.$refs[key + index].blur();
  2038. if (key === keyfield[keyfield.length - 1]) {
  2039. // 当前行最后一个,跳转下一行第一个
  2040. if (this.$refs[keyfield[0] + (index + 1)].value == 0) {
  2041. this.$refs[keyfield[0] + (index + 1)].value = '';
  2042. }
  2043. this.$refs[keyfield[0] + (index + 1)].focus();
  2044. } else {
  2045. // 跳转下一个
  2046. const nextkeyindex = keyfield.findIndex((k) => k === key) + 1;
  2047. this.$nextTick(() => {
  2048. if (this.$refs[keyfield[nextkeyindex] + index].value == 0) {
  2049. this.$refs[keyfield[nextkeyindex] + index].value = '';
  2050. }
  2051. this.$refs[keyfield[nextkeyindex] + index].focus();
  2052. });
  2053. }
  2054. }
  2055. // 向上 =38
  2056. if (event.keyCode === 38) {
  2057. console.log('向上');
  2058. if (index === 0) {
  2059. // 第一行
  2060. console.log('第一行无法向上');
  2061. return;
  2062. }
  2063. this.$refs[key + index].blur();
  2064. this.$nextTick(() => {
  2065. if (this.$refs[key + (index - 1)].value == 0) {
  2066. this.$refs[key + (index - 1)].value = '';
  2067. }
  2068. this.$refs[key + (index - 1)].focus();
  2069. });
  2070. }
  2071. // 下 = 40
  2072. if (event.keyCode === 40) {
  2073. console.log('向下');
  2074. if (index === listLength - 1) {
  2075. // 最后一行
  2076. console.log('最后一行无法向下');
  2077. return;
  2078. }
  2079. this.$refs[key + index].blur();
  2080. this.$nextTick(() => {
  2081. if (this.$refs[key + (index + 1)].value == 0) {
  2082. this.$refs[key + (index + 1)].value = '';
  2083. }
  2084. this.$refs[key + (index + 1)].focus();
  2085. });
  2086. }
  2087. // 左 = 37
  2088. if (event.keyCode === 37) {
  2089. console.log('向左');
  2090. if (index === 0 && key === keyfield[0]) {
  2091. // 第一行第一个
  2092. console.log('第一行第一个无法向左');
  2093. return;
  2094. }
  2095. this.$refs[key + index].blur();
  2096. if (key === keyfield[0]) {
  2097. if (
  2098. this.$refs[keyfield[keyfield.length - 1] + (index - 1)].value == 0
  2099. ) {
  2100. this.$refs[keyfield[keyfield.length - 1] + (index - 1)].value =
  2101. '';
  2102. }
  2103. // 当前行第一个,跳转上一行最后一个
  2104. this.$refs[keyfield[keyfield.length - 1] + (index - 1)].focus();
  2105. } else {
  2106. // 跳转上一个
  2107. const prevkeyindex = keyfield.findIndex((k) => k === key) - 1;
  2108. this.$nextTick(() => {
  2109. if (this.$refs[keyfield[prevkeyindex] + index].value == 0) {
  2110. this.$refs[keyfield[prevkeyindex] + index].value = '';
  2111. }
  2112. this.$refs[keyfield[prevkeyindex] + index].focus();
  2113. });
  2114. }
  2115. }
  2116. // 右 = 39
  2117. if (event.keyCode === 39) {
  2118. console.log('向右');
  2119. if (
  2120. index === listLength - 1 &&
  2121. key === keyfield[keyfield.length - 1]
  2122. ) {
  2123. // 最后一行最后一个
  2124. console.log('最后一行最后一个无法向左');
  2125. return;
  2126. }
  2127. console.log(this.$refs);
  2128. this.$refs[key + index].blur();
  2129. if (key === keyfield[keyfield.length - 1]) {
  2130. // 当前行最后一个,跳转下一行第一个
  2131. if (this.$refs[keyfield[0] + (index + 1)].value == 0) {
  2132. this.$refs[keyfield[0] + (index + 1)].value = '';
  2133. }
  2134. this.$refs[keyfield[0] + (index + 1)].focus();
  2135. } else {
  2136. // 跳转下一个
  2137. const nextkeyindex = keyfield.findIndex((k) => k === key) + 1;
  2138. this.$nextTick(() => {
  2139. if (this.$refs[keyfield[nextkeyindex] + index].value == 0) {
  2140. this.$refs[keyfield[nextkeyindex] + index].value = '';
  2141. }
  2142. this.$refs[keyfield[nextkeyindex] + index].focus();
  2143. });
  2144. }
  2145. }
  2146. },
  2147. handleAvatarSuccess() {
  2148. this.$refs.fileUploadBtn.clearFiles(); //上传成功之后清除历史记录**加粗样式**
  2149. },
  2150. async onChange(file) {
  2151. console.log(XLSX);
  2152. this.warehousingMaterialList = [];
  2153. this.resultArray = [];
  2154. const loading = this.$loading({
  2155. lock: true,
  2156. text: '加载中...'
  2157. });
  2158. /**
  2159. * 1. 使用原生api去读取好的文件
  2160. * */
  2161. // console.log("原始上传的文件", file);
  2162. // 读取文件不是立马能够读取到的,所以是异步的,使用Promise
  2163. let dataBinary = await new Promise((resolve) => {
  2164. // Web API构造函数FileReader,可实例化对象,去调用其身上方法,去读取解析文件信息
  2165. let reader = new FileReader(); // https://developer.mozilla.org/zh-CN/docs/Web/API/FileReader
  2166. // console.log("实例化对象有各种方法", reader);
  2167. reader.readAsBinaryString(file.raw); // 读取raw的File文件
  2168. reader.onload = (ev) => {
  2169. // console.log("文件解析流程进度事件", ev);
  2170. resolve(ev.target.result); // 将解析好的结果扔出去,以供使用
  2171. };
  2172. });
  2173. // console.log("读取出的流文件", dataBinary);
  2174. /**
  2175. * 2. 使用xlsx插件去解析已经读取好的二进制excel流文件
  2176. * */
  2177. let workBook = XLSX.read(dataBinary, {
  2178. type: 'binary',
  2179. cellDates: true
  2180. });
  2181. // excel中有很多的sheet,这里取了第一个sheet:workBook.SheetNames[0]
  2182. let firstWorkSheet = workBook.Sheets[workBook.SheetNames[0]];
  2183. // 分为第一行的数据,和第一行下方的数据
  2184. // const header = this.getHeaderRow(firstWorkSheet);
  2185. // console.log('读取的excel表头数据(第一行)', header);
  2186. const xlsxData = XLSX.utils.sheet_to_json(firstWorkSheet);
  2187. console.log('读取所有excel数据', xlsxData);
  2188. // let modelTypeList = xlsxData.map((item) => {
  2189. // return item['型号'];
  2190. // });
  2191. // let nameList = xlsxData.map((item) => {
  2192. // return item['物品名称'];
  2193. // });
  2194. let codeList = xlsxData.map((item) => {
  2195. return item['sap物料码'];
  2196. });
  2197. let functionType = {};
  2198. xlsxData.map((item) => {
  2199. functionType[item['sap物料码']] = item['采购原因'];
  2200. });
  2201. this.formData.extInfo.assetType = ['6']; //备品备件
  2202. this.formData.bizType = '2'; // 采购入库
  2203. outin
  2204. .getListByNameOrModeType({
  2205. // modelTypeList,
  2206. // nameList,
  2207. codeList,
  2208. categoryLevelId: '6'
  2209. })
  2210. .then(async (data) => {
  2211. console.log('查询到的备件数据', data);
  2212. const batchNo = await getCode('lot_number_code');
  2213. // 添加包装数量和最小包装单元
  2214. this.productList = data.map((item, index) => {
  2215. console.log(xlsxData);
  2216. let filterArray = xlsxData.filter(
  2217. (xlsxItem) => xlsxItem['sap物料码'] == item.code
  2218. );
  2219. console.log(filterArray);
  2220. return {
  2221. index: this.productList.length + index,
  2222. categoryId: item.id, // 物品id
  2223. categoryName: item.name, // 物品名称
  2224. categoryCode: item.code, // 物品编码
  2225. categoryModel: item.modelType, // 物品型号
  2226. specification: item.specification, // 规格
  2227. brandNum: item.brandNum, // 牌号
  2228. batchNo: item.batchNo || batchNo, // 批次号
  2229. minPackingQuantity: 1, // 最小包装单元数量
  2230. packingQuantity: filterArray[0]['数量'], // 包装数量
  2231. packingUnit: item.packingUnit, // 单位
  2232. measureQuantity: 0, // 计量数量
  2233. measureUnit: item.measuringUnit, // 计量单位
  2234. netWeight: item.netWeight > -1 ? item.netWeight : 0, // 净重
  2235. weight: 0, // 重量
  2236. weightUnit: item.weightUnit, // 重量单位
  2237. totalMoney: '', // 总价
  2238. unitPrice: item.unitPrice, // 单价
  2239. purpose: functionType[item.code], // 用途
  2240. isUnpack: item.isUnpack // 是否允许拆包
  2241. };
  2242. });
  2243. console.log(this.productList);
  2244. this.handleAvatarSuccess();
  2245. loading.close();
  2246. })
  2247. .catch(() => {
  2248. loading.close();
  2249. });
  2250. },
  2251. // 入库
  2252. handleStorage(type) {
  2253. this.$refs.formName.validate(async (valid) => {
  2254. if (valid) {
  2255. if (!this.productList.length) {
  2256. return this.$message.warning('请至少添加一条产品');
  2257. }
  2258. let boolen = this.productList.every((item) => item.isSave);
  2259. console.log(boolen);
  2260. if (!boolen) {
  2261. this.$message.warning('请先保存所有产品信息');
  2262. return;
  2263. }
  2264. // 处理包装数据
  2265. this.packingList = this.packingList.map((packingItem) => {
  2266. if (packingItem.modelKey) {
  2267. packingItem.modelKey = packingItem.modelKey;
  2268. }
  2269. if (packingItem.colorKey) {
  2270. packingItem.colorKey = packingItem.colorKey;
  2271. }
  2272. return {
  2273. ...packingItem,
  2274. materialDetailList: this.materialList.filter(
  2275. (item) => item.parentIndex === packingItem.index
  2276. ),
  2277. taskId: this.selWWData?.taskId,
  2278. workOrderId: this.selWWData?.workOrderId
  2279. };
  2280. });
  2281. // 处理产品数据
  2282. this.productList = this.productList.map((productItem) => {
  2283. if (productItem.modelKey) {
  2284. productItem.modelKey = productItem.modelKey;
  2285. }
  2286. if (productItem.colorKey) {
  2287. productItem.colorKey = productItem.colorKey;
  2288. }
  2289. return {
  2290. ...productItem,
  2291. outInDetailRecordRequestList: this.packingList.filter(
  2292. (item) => item.parentIndex === productItem.index
  2293. )
  2294. };
  2295. });
  2296. this.formData.outInDetailList = this.productList;
  2297. let obj = deepClone(this.formData);
  2298. // 处理物品类型assetType
  2299. obj.extInfo.assetType = obj.extInfo.assetType.join(',');
  2300. // 处理仓库id
  2301. let warehouseId = [];
  2302. let warehouseName = [];
  2303. let warehouseIds = this.productList
  2304. .map((item) => item.warehouseIds)
  2305. .flat();
  2306. let warehouseNames = this.productList
  2307. .map((item) => item.warehouseNames)
  2308. .flat();
  2309. warehouseIds.forEach((item, index) => {
  2310. if (!warehouseId.includes(item)) {
  2311. warehouseId.push(item);
  2312. warehouseName.push(warehouseNames[index]);
  2313. }
  2314. });
  2315. obj.warehouseIds = warehouseId;
  2316. obj.warehouseNames = warehouseName;
  2317. console.log('入库数据', obj);
  2318. // 是否需要审核(0审核 1跳过审核)
  2319. if (obj.bizType == '12') {
  2320. obj.isSkip = 1;
  2321. } else {
  2322. obj.isSkip = 0;
  2323. }
  2324. // obj.isSkip = 1;
  2325. this.saveLoading = true;
  2326. console.log(obj, 'objobjobjobjobjobj');
  2327. // if(){}
  2328. if (!(await this.isVerifyRepeatIsStock())) {
  2329. this.saveLoading = false;
  2330. return;
  2331. }
  2332. let api = obj.id ? storageApi.update : storageApi.storage;
  2333. api(obj)
  2334. .then(async (res) => {
  2335. console.log('入库成功', res);
  2336. console.log('入库成功', obj.id);
  2337. if (res.code == 0) {
  2338. try {
  2339. if (type != 'save') {
  2340. if (obj.bizType == '12') {
  2341. await storageApi.qualityInspectionTwo({
  2342. outInIds: res.data
  2343. });
  2344. } else {
  2345. await storageApi.submitTwo({ outInIds: res.data });
  2346. }
  2347. this.$message.success('入库成功');
  2348. } else {
  2349. this.$message.success('操作成功');
  2350. }
  2351. // 委外入库(非采购)
  2352. this.saveLoading = false;
  2353. // this.$router.push('/warehouseManagement/stockManagement');
  2354. this.back();
  2355. } catch (error) {
  2356. this.saveLoading = false;
  2357. // this.$router.push('/warehouseManagement/stockManagement');
  2358. this.back();
  2359. console.log('提交流程失败', error);
  2360. }
  2361. }
  2362. })
  2363. .catch((err) => {
  2364. console.log('入库失败', err);
  2365. this.saveLoading = false;
  2366. });
  2367. } else {
  2368. return;
  2369. }
  2370. });
  2371. },
  2372. async isVerifyRepeatIsStock() {
  2373. const isVerifyData = await storageApi.isVerifyRepeatIsStock({
  2374. categoryCodes: this.productList.map((item) => item.categoryCode),
  2375. batchNos: this.productList.map((item) => item.batchNo)
  2376. });
  2377. return new Promise((resolve, reject) => {
  2378. if (isVerifyData?.length) {
  2379. this.$confirm(
  2380. `当前批次:${isVerifyData[0].batchNo},物品${isVerifyData
  2381. .map((item) => item.categoryName)
  2382. .join(',')}已有入库记录,是否继续入库!`,
  2383. {
  2384. confirmButtonText: '是',
  2385. cancelButtonText: '否'
  2386. }
  2387. )
  2388. .then(() => {
  2389. resolve(true);
  2390. })
  2391. .catch(() => {
  2392. resolve(false);
  2393. });
  2394. } else {
  2395. resolve(true);
  2396. }
  2397. });
  2398. },
  2399. pickingHandleScroll() {
  2400. // console.log('---------pickingHandleScroll------------');
  2401. // console.log(this.packingList);
  2402. // console.log(this.showPackingList);
  2403. // console.log(this.pageSize);
  2404. if (this.showPackingList.length < this.packingList.length) {
  2405. if (this.packingList.length > this.pageSize) {
  2406. this.pickingPageNum += 1;
  2407. }
  2408. this.pickingFetchData();
  2409. }
  2410. },
  2411. pickingFetchData() {
  2412. const start = (this.pickingPageNum - 1) * this.pageSize;
  2413. const end = start + this.pageSize;
  2414. console.log(start);
  2415. console.log(end);
  2416. this.showPackingList = this.showPackingList.concat(
  2417. this.packingList.slice(start, end)
  2418. );
  2419. },
  2420. materielHandleScroll() {
  2421. console.log('---------materielHandleScroll------------');
  2422. if (this.showMaterialList.length < this.materialList.length) {
  2423. if (this.materialList.length > this.pageSize) {
  2424. this.materielPageNum += 1;
  2425. }
  2426. this.materielFetchData();
  2427. }
  2428. },
  2429. materielFetchData() {
  2430. const start = (this.materielPageNum - 1) * this.pageSize;
  2431. const end = start + this.pageSize;
  2432. this.showMaterialList = this.showMaterialList.concat(
  2433. this.materialList.slice(start, end)
  2434. );
  2435. console.log(this.showMaterialList);
  2436. },
  2437. // 日期选择
  2438. dateConfirm() {
  2439. this.packingListSelected.forEach((item) => {
  2440. this.$set(item, this.curDateType, this.batchTime);
  2441. });
  2442. this.batchTime = '';
  2443. this.dateVisible = false;
  2444. },
  2445. // 包装重量修改
  2446. packingWeightCahnge(value, row) {
  2447. // 修改物品重量
  2448. let filterPackingList = this.packingList.filter((item) => {
  2449. return item.parentIndex === row.parentIndex;
  2450. });
  2451. let productIndex = this.productList.findIndex((item) => {
  2452. return item.index === row.parentIndex;
  2453. });
  2454. let totalWeight = filterPackingList.reduce(
  2455. (accumulator, currentValue) => {
  2456. return this.$math.format(+accumulator + +currentValue.weight, 14);
  2457. },
  2458. 0
  2459. );
  2460. this.$set(this.productList[productIndex], 'weight', totalWeight);
  2461. this.$set(
  2462. this.productList[productIndex],
  2463. 'singleWeight',
  2464. totalWeight / this.productList[productIndex].measureQuantity
  2465. );
  2466. // 修改拆分物料
  2467. this.materialList.map((item, index) => {
  2468. if (item.parentIndex === row.index) {
  2469. console.log(value / row.measureQuantity);
  2470. this.$set(
  2471. this.materialList[index],
  2472. 'weight',
  2473. this.$math.format(value / row.measureQuantity, 14) >= 0
  2474. ? this.$math.format(value / row.measureQuantity, 14)
  2475. : 0
  2476. );
  2477. }
  2478. });
  2479. },
  2480. // 物料重量修改
  2481. materialWeightCahnge(row) {
  2482. // 修改包装重量
  2483. let filterMaterialList = this.materialList.filter((item) => {
  2484. return item.parentIndex === row.parentIndex;
  2485. });
  2486. let packingIndex = this.packingList.findIndex((item) => {
  2487. return item.index === row.parentIndex;
  2488. });
  2489. let totalMaterialWeight = filterMaterialList.reduce(
  2490. (accumulator, currentValue) => {
  2491. return this.$math.format(+accumulator + +currentValue.weight, 14);
  2492. },
  2493. 0
  2494. );
  2495. this.$set(
  2496. this.packingList[packingIndex],
  2497. 'weight',
  2498. totalMaterialWeight
  2499. );
  2500. // 修改物品重量
  2501. let filterPackingList = this.packingList.filter((item) => {
  2502. return (
  2503. item.parentIndex === this.packingList[packingIndex].parentIndex
  2504. );
  2505. });
  2506. let productIndex = this.productList.findIndex((item) => {
  2507. return item.index === this.packingList[packingIndex].parentIndex;
  2508. });
  2509. let totalWeight = filterPackingList.reduce(
  2510. (accumulator, currentValue) => {
  2511. return this.$math.format(+accumulator + +currentValue.weight, 14);
  2512. },
  2513. 0
  2514. );
  2515. this.$set(this.productList[productIndex], 'weight', totalWeight);
  2516. },
  2517. // 包装质检结果修改
  2518. packingResultCahnge(value, row) {
  2519. // 修改物料质检结果( 1合格 2不合格)
  2520. this.materialList.map((item, index) => {
  2521. if (item.parentIndex === row.index) {
  2522. this.$set(this.materialList[index], 'result', value);
  2523. }
  2524. });
  2525. },
  2526. // 物料质量结果修改
  2527. materialResultCahnge(value, row) {
  2528. // 修改包装质检结果
  2529. let filterMaterialList = this.materialList.filter((item) => {
  2530. return item.parentIndex == row.parentIndex;
  2531. });
  2532. let packingIndex = this.packingList.findIndex((item) => {
  2533. return item.index == row.parentIndex;
  2534. });
  2535. let boolen = filterMaterialList.every((item) => {
  2536. return item.result == 1;
  2537. });
  2538. this.$set(this.packingList[packingIndex], 'result', boolen ? 1 : 2);
  2539. },
  2540. // 重量限制
  2541. weightInput(value, row, type) {
  2542. const newValue = value.replace(/[^\d.]/g, ''); // 保留数字和小数点
  2543. const decimalCount = (newValue.match(/\./g) || []).length; // 计算小数点的个数
  2544. if (row.weight < 0) {
  2545. row.weight = 0;
  2546. } else if (row.weight > 9999) {
  2547. row.weight = 9999;
  2548. } else {
  2549. if (decimalCount > 1) {
  2550. // 如果小数点个数大于1,移除多余的小数点
  2551. const lastIndex = newValue.lastIndexOf('.');
  2552. row.weight =
  2553. newValue.slice(0, lastIndex) + newValue.slice(lastIndex + 1);
  2554. } else if (decimalCount === 1) {
  2555. // 如果小数点个数等于1,允许小数点的输入
  2556. row.weight = newValue;
  2557. } else {
  2558. row.weight = newValue === '' ? 0 : parseFloat(newValue); // 如果输入为空,则设为0
  2559. }
  2560. }
  2561. if (type === '包装') {
  2562. this.packingWeightCahnge(value, row);
  2563. } else {
  2564. this.materialWeightCahnge(row);
  2565. }
  2566. },
  2567. //计算金额
  2568. calcSumTotal(measureQuantity, unitPrice, row) {
  2569. //最小包装单元,包装数量,单价
  2570. const total = {
  2571. measureQuantity: Number(measureQuantity > 0 ? measureQuantity : 0),
  2572. unitPrice: Number(unitPrice > 0 ? unitPrice : 0)
  2573. };
  2574. let number = Number(
  2575. this.$math.format(total.measureQuantity * total.unitPrice, 14)
  2576. );
  2577. row.totalMoney = number;
  2578. return number;
  2579. },
  2580. // 表格样式
  2581. rowClass({ row, column, rowIndex, columnIndex }) {
  2582. if (rowIndex === 1) {
  2583. return {
  2584. display: 'none',
  2585. background: '#EEEEEE'
  2586. };
  2587. }
  2588. return { background: '#0000' };
  2589. },
  2590. getNewSpecificationOption(packingSpecificationOption) {
  2591. return packingSpecificationOption.map((arr) => {
  2592. return arr.reduce((acc, current) => {
  2593. const conversionUnit = current.conversionUnit;
  2594. if (!acc.some((item) => item.conversionUnit === conversionUnit)) {
  2595. acc.push(current);
  2596. }
  2597. return acc;
  2598. }, []);
  2599. });
  2600. },
  2601. async addGoods(data) {
  2602. if (data.length === 0) return this.$message.warning('请选择产品信息');
  2603. console.log(data, 'datadatadatadatadatadatadata111');
  2604. // 获取批次号
  2605. const batchNo = await getCode('lot_number_code');
  2606. // 获取供应商
  2607. const supplierList = await storageApi.contactQueryByCategoryIdsAPI({
  2608. categoryIds: data.map((item) => item.id)
  2609. });
  2610. console.log(supplierList, '供应商列表');
  2611. // 获取包装规格
  2612. let packingSpecification =
  2613. await storageApi.getCategoryPackageDisposition({
  2614. categoryIds: data.map((item) => item.id)
  2615. });
  2616. console.log(packingSpecification, '--packingSpecification');
  2617. this.packingSpecificationOption = data.map((item) => {
  2618. return packingSpecification
  2619. .filter((ite) => item.id == ite.categoryId)
  2620. .sort((a, b) => a.sort - b.sort);
  2621. });
  2622. console.log('yeyyeyey----------------', data);
  2623. const newSpecificationOption = this.packingSpecificationOption;
  2624. let productList = data.map((item, index) => {
  2625. // 显示规格
  2626. let packingSpecificationLabel = this.packingSpecificationOption[index]
  2627. .map((item) => {
  2628. if (item.sort > 0) {
  2629. return `${item.packageCell}${item.packageUnit}/${item.conversionUnit}`;
  2630. }
  2631. })
  2632. .filter((item) => !!item);
  2633. return {
  2634. index:
  2635. this.productList.length - 1 > -1
  2636. ? this.productList[this.productList.length - 1].index +
  2637. index +
  2638. 1
  2639. : this.productList.length + index,
  2640. // extField: {
  2641. // packingSpecification: item.extField.packingSpecification
  2642. // }, // 包装规格
  2643. categoryId: item.id, // 物品id
  2644. categoryName: item.name, // 物品名称
  2645. categoryCode: item.code, // 物品编码
  2646. categoryModel: item.modelType, // 物品型号
  2647. specification: item.specification, // 规格
  2648. modelKey: item.modelKey ? item.modelKey : '', // 机型
  2649. colorKey: item.colorKey ? item.colorKey : '', // 颜色
  2650. color: item.color,
  2651. brandNum: item.brandNum, // 牌号
  2652. batchNo: item.batchNo || batchNo, // 批次号
  2653. supplierListOptions: supplierList[item.id], // 供应商列表
  2654. supplierId: '', // 供应商id
  2655. supplierName: '', // 供应商名称
  2656. supplierCode: '',
  2657. measureType: item.measureType, // 计量类型
  2658. approvalNumber: item.approvalNumber, // 批准文号
  2659. packingSpecification: item.packingSpecification, // 包装规格
  2660. packingSpecificationOption: newSpecificationOption[index], // 包装规格选项
  2661. packingSpecificationLabel: packingSpecificationLabel, // 包装规格显示
  2662. minPackingQuantity: '', // 最小包装单元数量
  2663. packingQuantity: '', // 包装数量
  2664. packingUnit: item.packingUnit, // 包装数量
  2665. unit: item.measuringUnit, // 单位
  2666. unitId: newSpecificationOption[index].find(
  2667. (v) => v.conversionUnit == item.measuringUnit
  2668. )?.id, // 单位
  2669. measureQuantity: 0, // 计量数量
  2670. measureUnit: item.measuringUnit, // 计量单位
  2671. netWeight: item.netWeight > -1 ? item.netWeight : 0, // 净重
  2672. weight: 0, // 重量
  2673. singleWeight: item.netWeight, //单重 进来获取净重
  2674. weightUnit: item.weightUnit, // 重量单位
  2675. totalMoney: '', // 总价
  2676. unitPrice: item.unitPrice, // 单价
  2677. purpose: '', // 用途
  2678. isUnpack: item.isUnpack, // 是否允许拆包
  2679. categoryLevelPathIdParent: item.categoryLevelPathIdParent
  2680. };
  2681. });
  2682. this.productList = this.productList.concat(productList);
  2683. console.log('this.productList--------', this.productList);
  2684. },
  2685. // 物品保存验证表单(批量)
  2686. validateForm() {
  2687. return new Promise(async (resolve, reject) => {
  2688. let list = this.productList.map(async (row, index) => {
  2689. let fileds = [
  2690. `productList.${index}.batchNo`,
  2691. `productList.${index}.quantity`,
  2692. `productList.${index}.unit`,
  2693. `productList.${index}.warehouseId`
  2694. ];
  2695. console.log(fileds);
  2696. if (row.isSave) {
  2697. return Promise.resolve(true);
  2698. } else {
  2699. return await Promise.all(
  2700. fileds.map(
  2701. (item) =>
  2702. new Promise(async (res, rej) => {
  2703. this.$refs.productListRef.validateField(item, (err) => {
  2704. if (err) {
  2705. rej(err);
  2706. } else {
  2707. res(true);
  2708. }
  2709. });
  2710. })
  2711. )
  2712. );
  2713. }
  2714. });
  2715. Promise.all(list)
  2716. .then(() => {
  2717. console.log('保存成功!');
  2718. resolve();
  2719. })
  2720. .catch((err) => {
  2721. console.log('保存失败!');
  2722. this.$message.error('请填入必填项!');
  2723. reject(err);
  2724. });
  2725. });
  2726. },
  2727. // 物品保存验证表单(单独)
  2728. validateFormIndividually(index) {
  2729. return new Promise(async (resolve) => {
  2730. console.log(index);
  2731. let fileds = [
  2732. `productList.${index}.batchNo`,
  2733. `productList.${index}.quantity`,
  2734. `productList.${index}.unit`,
  2735. `productList.${index}.warehouseId`
  2736. ];
  2737. Promise.all(
  2738. fileds.map(
  2739. (item) =>
  2740. new Promise(async (res, rej) => {
  2741. this.$refs.productListRef.validateField(item, (err) => {
  2742. if (err) {
  2743. rej(err);
  2744. } else {
  2745. res(true);
  2746. }
  2747. });
  2748. })
  2749. )
  2750. )
  2751. .then(() => {
  2752. resolve();
  2753. })
  2754. .catch(() => {
  2755. this.$message.error('请填入必填项!');
  2756. });
  2757. });
  2758. },
  2759. // 产品编辑
  2760. listEdit(row) {
  2761. console.log(row);
  2762. this.$set(row, 'isSave', false);
  2763. this.deletePackingAndMaterial(row);
  2764. },
  2765. // 根据产品信息删除包装和物料
  2766. deletePackingAndMaterial(row) {
  2767. console.log('row--------', row);
  2768. console.log('packingList------', this.packingList);
  2769. // 删除包装(去掉不相同的包装)
  2770. this.packingList = this.packingList.filter(
  2771. (item) => item.parentIndex !== row.index
  2772. );
  2773. this.showPackingList = this.showPackingList.filter(
  2774. (item) => item.parentIndex !== row.index
  2775. );
  2776. this.pickingPageNum = Math.ceil(
  2777. this.showPackingList.length / this.pageSize
  2778. );
  2779. console.log('包装当前页数');
  2780. console.log(this.pickingPageNum);
  2781. // 删除物料(获取相同物料)
  2782. let packingIndexs = this.packingList.map((item) => item.index);
  2783. this.materialList = this.materialList.filter((item) =>
  2784. packingIndexs.includes(item.parentIndex)
  2785. );
  2786. this.showMaterialList = this.showMaterialList.filter((item) =>
  2787. packingIndexs.includes(item.parentIndex)
  2788. );
  2789. this.materielPageNum = Math.ceil(
  2790. this.showMaterialList.length / this.pageSize
  2791. );
  2792. console.log('物料当前页数');
  2793. console.log(this.showMaterialList.length);
  2794. console.log(this.pageSize);
  2795. console.log(this.materielPageNum);
  2796. },
  2797. // 新增批量保存方法
  2798. async batchSave() {
  2799. try {
  2800. // 验证所有未保存的表单
  2801. await this.validateForm();
  2802. // 遍历所有产品进行保存
  2803. for (let i = 0; i < this.productList.length; i++) {
  2804. const row = this.productList[i];
  2805. if (!row.isSave) {
  2806. // 执行单个保存逻辑
  2807. await this.listSave(row, i);
  2808. }
  2809. }
  2810. } catch (error) {
  2811. this.$message.error('批量保存失败,请检查必填项');
  2812. }
  2813. },
  2814. setPNum(row) {
  2815. let pNum = 0;
  2816. if (row.unitId) {
  2817. let splitIndex = row.packingSpecificationOption.findIndex(
  2818. (item) => item.id == row.unitId
  2819. );
  2820. if (splitIndex == 0) {
  2821. pNum = Math.ceil(
  2822. row.measureQuantity /
  2823. row.packingSpecificationOption[1]?.packageCell
  2824. );
  2825. }
  2826. if (splitIndex == 1) {
  2827. pNum = row.quantity;
  2828. }
  2829. for (; splitIndex > 1; splitIndex--) {
  2830. pNum = Math.ceil(
  2831. row.quantity *
  2832. row.packingSpecificationOption[splitIndex].packageCell
  2833. );
  2834. }
  2835. } else {
  2836. pNum = Math.ceil(
  2837. row.measureQuantity / row.packingSpecificationOption[1]?.packageCell
  2838. );
  2839. }
  2840. return pNum;
  2841. },
  2842. //产品保存操作
  2843. async listSave(row, index) {
  2844. console.log(row, ';ddd');
  2845. return new Promise(async (resolve, reject) => {
  2846. try {
  2847. await this.validateFormIndividually(index);
  2848. if (row.packingSpecificationLabel?.length < 1) {
  2849. this.$message.error('请到主数据维护包装组信息!');
  2850. return;
  2851. }
  2852. // 不拆包
  2853. if (!row.isUnpack) {
  2854. if (row.packingUnit != row.measureUnit) {
  2855. let pNum = row.quantity;
  2856. let splitIndex = row.packingSpecificationOption.findIndex(
  2857. (item) =>
  2858. item.conversionUnit == row.unit &&
  2859. item.unit != item.conversionUnit
  2860. );
  2861. for (; splitIndex > 1; splitIndex--) {
  2862. pNum = this.$math.format(
  2863. pNum *
  2864. row.packingSpecificationOption[splitIndex].packageCell,
  2865. 14
  2866. );
  2867. }
  2868. console.log(pNum, 'pNum12');
  2869. const { data } = await storageApi.getAssetNum([
  2870. {
  2871. assetCode: row.categoryCode + row.index,
  2872. batchNum: row.batchNo,
  2873. num: Math.ceil(pNum)
  2874. }
  2875. ]);
  2876. // this.generateWrappers(row, index, data)
  2877. } else {
  2878. let pNum = 0;
  2879. const { data } = await storageApi.getAssetNum([
  2880. {
  2881. assetCode: row.categoryCode + row.index,
  2882. batchNum: row.batchNo,
  2883. num: Math.ceil(pNum)
  2884. }
  2885. ]);
  2886. }
  2887. } else {
  2888. let pNum = this.setPNum(row);
  2889. // row.packingQuantity;
  2890. // console.log(row.packingQuantity,'row.packingQuantity')
  2891. // return
  2892. //拆包
  2893. const { data } = await storageApi.getAssetNum([
  2894. {
  2895. assetCode: row.categoryCode + row.index,
  2896. batchNum: row.batchNo,
  2897. num: Math.ceil(pNum)
  2898. }
  2899. ]);
  2900. console.log(data, 'data');
  2901. this.generateWrappers(row, index, data);
  2902. this.$set(
  2903. this.productList[index],
  2904. 'packingQuantity',
  2905. data.length
  2906. );
  2907. }
  2908. this.$set(this.productList[index], 'isSave', true);
  2909. // this.$set(this.productList[index], 'isSave', data.length);
  2910. this.$set(this.productList[index], 'warehouseId', row.warehouseId);
  2911. this.$set(
  2912. this.productList[index],
  2913. 'warehouseName',
  2914. row.warehouseName
  2915. );
  2916. this.$set(this.productList[index], 'warehouseIds', [
  2917. row.warehouseId
  2918. ]);
  2919. this.$set(this.productList[index], 'warehouseNames', [
  2920. row.warehouseName
  2921. ]);
  2922. resolve();
  2923. } catch (error) {
  2924. reject(error);
  2925. }
  2926. });
  2927. },
  2928. // 生成包装
  2929. generateWrappers(row, productIndex, packingCodeList) {
  2930. console.log(packingCodeList, 'packingCodeListROW', row.measureType);
  2931. //计量类型不是数量
  2932. if (!row.isUnpack && row.measureType != 1) {
  2933. // 计量单位=包装单位,则不生成包装层数据
  2934. if (row.measureUnit == row.unit) {
  2935. // 直接生成物品层数据
  2936. this.productList[productIndex].measureQuantity =
  2937. row.measureQuantity;
  2938. this.productList[productIndex].weight = row.weight;
  2939. return;
  2940. }
  2941. }
  2942. console.log('包装数据--------', row);
  2943. // console.log('包装规格----', row.packingSpecificationOption);
  2944. console.log('计量单位----', row.measureUnit);
  2945. let packingList = [];
  2946. let obj = this.getNowDate();
  2947. let productionDate = row.detailProductionDate || '';
  2948. let purchaseDate = row.detailPurchaseDate || '';
  2949. let expireDate = row.detailExpireDate || '';
  2950. if (this.formData.bizType == '1') {
  2951. // 生产入库
  2952. productionDate = `${obj.year}-${obj.month}-${obj.strDate} ${obj.hour}:${obj.minute}:${obj.second}`;
  2953. // this.curDateType = 'productionDate';
  2954. } else if (this.formData.bizType == '2') {
  2955. // 采购入库
  2956. purchaseDate = `${obj.year}-${obj.month}-${obj.strDate} ${obj.hour}:${obj.minute}:${obj.second}`;
  2957. // this.curDateType = 'purchaseDate';
  2958. }
  2959. // 判断单位和计量单位是否为不拆物料层规格
  2960. let packingBoolen = !!this.getDict('不拆物料层规格', row.unit)
  2961. .dictValue;
  2962. let measureBoolen = !!this.getDict('不拆物料层规格', row.measureUnit)
  2963. .dictValue;
  2964. let num = row.packingQuantity;
  2965. let filterArr = [];
  2966. // 处理单位为KG类的情况
  2967. if (packingBoolen) {
  2968. console.log(
  2969. packingBoolen,
  2970. 'packingBoolenpackingBoolenpackingBoolenpackingBoolenpackingBoolenpackingBoolen'
  2971. );
  2972. if (!row.isUnpack && row.unit == '立方') {
  2973. num = 1;
  2974. } else {
  2975. filterArr = row.packingSpecificationOption.filter((item) => {
  2976. return (
  2977. item.packageUnit == row.unit &&
  2978. item.packageUnit != item.conversionUnit
  2979. );
  2980. });
  2981. num = Math.ceil(row.packingQuantity / filterArr[0]?.packageCell);
  2982. }
  2983. } else {
  2984. if (measureBoolen) {
  2985. // 处理单位不为KG类,计量单位为KG类的情况
  2986. let splitIndex = row.packingSpecificationOption.findIndex(
  2987. (item) =>
  2988. item.conversionUnit == row.unit &&
  2989. item.packageUnit != item.conversionUnit
  2990. );
  2991. for (; splitIndex > 1; splitIndex--) {
  2992. num = this.$math.format(
  2993. num * row.packingSpecificationOption[splitIndex].packageCell,
  2994. 14
  2995. );
  2996. }
  2997. } else {
  2998. if (row.packingSpecificationOption[1]?.packageCell) {
  2999. num = Math.ceil(
  3000. row.measureQuantity /
  3001. row.packingSpecificationOption[1]?.packageCell
  3002. );
  3003. filterArr = row.packingSpecificationOption.filter((item) => {
  3004. return (
  3005. item.packageUnit == row.unit &&
  3006. item.packageUnit != item.conversionUnit
  3007. );
  3008. });
  3009. }
  3010. }
  3011. }
  3012. console.log('num-----------', num);
  3013. if (!row.isUnpack) {
  3014. console.log(row.packingSpecificationOption[1]);
  3015. // let packingUnit = !row.isUnpack ? row.packingUnit : row.packingSpecificationOption[1].conversionUnit;
  3016. // let packingQuantity = row.packingQuantity / packingCodeList.length;
  3017. let unit = row.packingSpecificationOption[1]?.conversionUnit;
  3018. let startIndex = row.packingSpecificationOption.findIndex((ite) => {
  3019. return (
  3020. row.measuringUnit == ite.unit && ite.unit != ite.conversionUnit
  3021. );
  3022. });
  3023. let endIndex = row.packingSpecificationOption.findIndex(
  3024. (ite) => row.unit == ite.conversionUnit
  3025. );
  3026. let total = Number(row.quantity);
  3027. for (; startIndex < endIndex; endIndex--) {
  3028. total = this.$math.format(
  3029. row.packingSpecificationOption[endIndex].packageCell * total,
  3030. 14
  3031. );
  3032. }
  3033. console.log('total-----------', total);
  3034. let packingQuantity = row.measureQuantity / total;
  3035. let measureUnit = row.measureUnit;
  3036. let measureQuantity = row.measureQuantity / packingCodeList.length;
  3037. for (let index = 0; index < packingCodeList.length; index++) {
  3038. let item = {
  3039. index: row.index + '-' + index, // 包装索引
  3040. warehouseId: row.warehouseId, // 仓库id
  3041. warehouseName: row.warehouseName, // 仓库名称
  3042. categoryName: row.categoryName, // 产品名称
  3043. categoryCode: row.categoryCode, // 产品编码
  3044. categoryModel: row.categoryModel, // 物品型号
  3045. specification: row.specification, // 规格
  3046. supplierCode: row.supplierCode, // 供应商编码
  3047. brandNum: row.brandNum, // 牌号
  3048. parentIndex: row.index, // 产品索引
  3049. batchNo: row.batchNo, // 批次号
  3050. packageNo: packingCodeList[index]?.onlyCode, // 包装编码
  3051. packingQuantity: packingQuantity, // 包装数量
  3052. packingUnit: packingUnit, //包装单位
  3053. measureQuantity: measureQuantity, // 计量数量
  3054. measureUnit: measureUnit, // 计量单位
  3055. modelKey: row.modelKey, // 机型
  3056. colorKey: row.colorKey, //颜色
  3057. measureType: row.measureType,
  3058. measureUnit: measureUnit, // 计量单位
  3059. weight: 0, // 重量
  3060. packingSpecificationOption: row.packingSpecificationOption, // 包装规格
  3061. weightUnit: row.weightUnit, // 重量单位
  3062. netWeight: row.netWeight, // 净重
  3063. barcodes: '', // 发货条码
  3064. clientCode: row.extInfo ? row.extInfo.clientCode : '', // 客户代号
  3065. materielDesignation:
  3066. row.materielDesignation ||
  3067. (row.extInfo ? row.extInfo.materielCode : ''), // 物料代号
  3068. supplierName: row.supplierName, // 供应商名称
  3069. supplierCode: row.supplierCode, // 供应商代号
  3070. engrave: '', // 刻码
  3071. isUnpack: row.isUnpack, // 是否允许拆包
  3072. productionDate: productionDate, // 生产日期
  3073. purchaseDate: purchaseDate, // 采购时间
  3074. result: 1, // 结果(1合格 2不合格)
  3075. status: 2 // 状态(0=未质检 1待检 2已检)
  3076. };
  3077. let outBoolen = !!this.getDict('不拆物料层规格', item.measureUnit)
  3078. .dictValue;
  3079. if (outBoolen) {
  3080. // 计量单位为KG类,直接替换
  3081. item.weight = item.measureQuantity
  3082. ? Number(item.measureQuantity)
  3083. : 0;
  3084. } else {
  3085. console.log('计量单位为不为KG类======================');
  3086. // 计量单位为不为KG类,重新统计计算
  3087. let inBoolen = !!this.getDict(
  3088. '不拆物料层规格',
  3089. item.packingSpecificationOption[0].packageUnit
  3090. ).dictValue;
  3091. let startIndex = item.packingSpecificationOption.findIndex(
  3092. (ite) => {
  3093. return (
  3094. item.measureUnit == ite.packingUnit &&
  3095. ite.packingUnit != ite.conversionUnit
  3096. );
  3097. }
  3098. );
  3099. let endIndex = item.packingSpecificationOption.findIndex(
  3100. (ite) => item.packingUnit == ite.conversionUnit
  3101. );
  3102. if (measureBoolen) {
  3103. let total = item.packingQuantity
  3104. ? Number(item.packingQuantity)
  3105. : 0;
  3106. for (; startIndex < endIndex; endIndex--) {
  3107. total = this.$math.format(
  3108. item.packingSpecificationOption[endIndex].packageCell *
  3109. total,
  3110. 14
  3111. );
  3112. }
  3113. if (inBoolen) {
  3114. // 第二层为KG类
  3115. item.weight = total ? Number(total) : 0;
  3116. } else {
  3117. // 第二层不为KG类
  3118. item.weight = this.$math.format(total * item.netWeight, 14);
  3119. }
  3120. } else if (!measureBoolen) {
  3121. if (inBoolen) {
  3122. // 第二层为KG类
  3123. item.weight = item.measureQuantity
  3124. ? Number(item.measureQuantity)
  3125. : 0;
  3126. } else {
  3127. // 第二层不为KG类
  3128. if (row.singleWeight && item.measureQuantity) {
  3129. item.weight =
  3130. Number(item.measureQuantity) * Number(row.singleWeight);
  3131. } else {
  3132. item.weight = 0;
  3133. }
  3134. }
  3135. }
  3136. }
  3137. packingList.push(item);
  3138. }
  3139. } else {
  3140. for (let index = 0; index < packingCodeList.length; index++) {
  3141. let measureQuantity = 1;
  3142. let packingQuantity = 1;
  3143. // let packingUnit = row.unit;
  3144. // 处理单位为KG类,计算每桶KG值
  3145. if (packingBoolen) {
  3146. measureQuantity =
  3147. Number(row.quantity) >
  3148. this.$math.format(filterArr[0].packageCell * (index + 1), 14)
  3149. ? filterArr[0].packageCell
  3150. : Number(row.quantity) -
  3151. this.$math.format(filterArr[0].packageCell * index, 14);
  3152. } else {
  3153. //计量单位等于重量单位并且有总重 计量数量=总重/包装数
  3154. if (row.weightUnit == row.measureUnit && row.weight) {
  3155. measureQuantity =
  3156. Math.trunc((row.weight / packingCodeList.length) * 10000) /
  3157. 10000;
  3158. } else {
  3159. measureQuantity = row.packingSpecificationOption[1].packageCell;
  3160. }
  3161. }
  3162. console.log(
  3163. 'meadasdassureQuantity',
  3164. row.weight / row.packingQuantity
  3165. );
  3166. let item = {
  3167. index: row.index + '-' + index, // 包装索引
  3168. warehouseId: row.warehouseId, // 仓库id
  3169. warehouseName: row.warehouseName, // 仓库名称
  3170. categoryName: row.categoryName, // 产品名称
  3171. categoryCode: row.categoryCode, // 产品编码
  3172. categoryModel: row.categoryModel, // 物品型号
  3173. specification: row.specification, // 规格
  3174. supplierCode: row.supplierCode, // 供应商编码
  3175. brandNum: row.brandNum, // 牌号
  3176. parentIndex: row.index, // 产品索引
  3177. modelKey: row.modelKey, // 机型
  3178. colorKey: row.colorKey, //颜色
  3179. batchNo: row.batchNo, // 批次号
  3180. packageNo: packingCodeList[index]?.onlyCode, // 包装编码
  3181. packingQuantity: packingQuantity, // 包装数量
  3182. measureQuantity: measureQuantity, // 计量数量
  3183. measureUnit: row.isUnpack
  3184. ? measureBoolen
  3185. ? row.packingSpecificationOption[1]
  3186. ? row.packingSpecificationOption[1].packageUnit
  3187. : row.packingSpecificationOption[0].packageUnit
  3188. : row.measureUnit
  3189. : row.measureUnit, // 计量单位
  3190. weight: row.weight / row.packingQuantity,
  3191. packingSpecificationOption: row.packingSpecificationOption, // 包装规格
  3192. weightUnit: row.weightUnit, // 重量单位
  3193. netWeight: row.netWeight, // 净重
  3194. barcodes: '', // 发货条码
  3195. clientCode:
  3196. row.clientCode || (row.extInfo ? row.extInfo.clientCode : ''), // 客户代号
  3197. materielDesignation:
  3198. row.materielDesignation ||
  3199. (row.extInfo ? row.extInfo.materielCode : ''), // 物料代号
  3200. supplierName: row.supplierName, // 供应商名称
  3201. supplierCode: row.supplierCode, // 供应商代号
  3202. engrave: row.engrave, // 刻码
  3203. isUnpack: row.isUnpack, // 是否允许拆包
  3204. productionDate: productionDate, // 生产日期
  3205. purchaseDate: purchaseDate, // 采购时间
  3206. expireDate: expireDate,
  3207. result: 1, // 结果(1合格 2不合格)
  3208. status: 2 // 状态(0=未质检 1待检 2已检)
  3209. };
  3210. console.log(
  3211. row.packingSpecificationOption[1],
  3212. 'row.packingSpecificationOption[1]'
  3213. );
  3214. if (row.isUnpack) {
  3215. // 第二层条件: packingBoolen
  3216. item.packingUnit =
  3217. row.packingSpecificationOption[1].conversionUnit;
  3218. }
  3219. if (row.weightUnit == row.measureUnit) {
  3220. item.weight = item.measureQuantity
  3221. ? Number(item.measureQuantity)
  3222. : 0;
  3223. } else {
  3224. //单位不相等 物品层总重除包装层计量
  3225. item.weight = this.$math.format(
  3226. (row.singleWeight || 0) * item.measureQuantity,
  3227. 14
  3228. );
  3229. // console.log('计量单位为不为KG类======================');
  3230. // // 计量单位为不为KG类,重新统计计算
  3231. // let inBoolen = !!this.getDict(
  3232. // '不拆物料层规格',
  3233. // item.packingSpecificationOption[0].packageUnit
  3234. // ).dictValue;
  3235. // let startIndex = item.packingSpecificationOption.findIndex(
  3236. // (ite) => {
  3237. // return (
  3238. // item.measureUnit == ite.packingUnit &&
  3239. // ite.packingUnit != ite.conversionUnit
  3240. // );
  3241. // }
  3242. // );
  3243. // let endIndex = item.packingSpecificationOption.findIndex(
  3244. // (ite) => item.packingUnit == ite.conversionUnit
  3245. // );
  3246. // if (measureBoolen) {
  3247. // let total = item.packingQuantity
  3248. // ? Number(item.packingQuantity)
  3249. // : 0;
  3250. // for (; startIndex < endIndex; endIndex--) {
  3251. // total = this.$math.format(
  3252. // item.packingSpecificationOption[endIndex].packageCell *
  3253. // total,
  3254. // 14
  3255. // );
  3256. // }
  3257. // if (inBoolen) {
  3258. // // 第二层为KG类
  3259. // item.weight = total ? Number(total) : 0;
  3260. // } else {
  3261. // // 第二层不为KG类
  3262. // item.weight = this.$math.format(total * item.netWeight, 14);
  3263. // }
  3264. // } else if (!measureBoolen) {
  3265. // if (inBoolen) {
  3266. // // 第二层为KG类
  3267. // item.weight = item.measureQuantity
  3268. // ? Number(item.measureQuantity)
  3269. // : 0;
  3270. // } else {
  3271. // // 第二层不为KG类
  3272. // if (row.singleWeight && item.measureQuantity) {
  3273. // item.weight =
  3274. // Number(item.measureQuantity) * Number(row.singleWeight);
  3275. // } else {
  3276. // item.weight = item.weight || 0;
  3277. // }
  3278. // }
  3279. // }
  3280. }
  3281. packingList.push(item);
  3282. }
  3283. const existingIndex = this.packingList.findIndex(
  3284. (p) => p.parentIndex === row.index
  3285. );
  3286. if (existingIndex > -1) {
  3287. this.packingList.splice(existingIndex, 1); // 移除旧数据
  3288. }
  3289. }
  3290. console.log(productIndex, 'productIndex');
  3291. // 单独点击保存并插入对应位置(包装)
  3292. if (productIndex == 0) {
  3293. this.packingList.splice(productIndex, 0, ...packingList);
  3294. } else {
  3295. let packingIndex = this.packingList.findLastIndex(
  3296. (item) =>
  3297. item.parentIndex == this.productList[productIndex - 1].index
  3298. );
  3299. this.packingList.splice(packingIndex + 1, 0, ...packingList);
  3300. }
  3301. const lastIndex = this.packingList.length - 1;
  3302. let remainder = 0;
  3303. if (row.weightUnit != row.measureUnit) {
  3304. remainder =
  3305. row.measureQuantity %
  3306. row.packingSpecificationOption[1]?.packageCell;
  3307. }
  3308. console.log(remainder, 'remainder');
  3309. if (remainder > 0) {
  3310. let onlyCode = packingCodeList[packingCodeList.length - 1]?.onlyCode;
  3311. let index = this.packingList.findIndex(
  3312. (packingItem) => packingItem.packageNo == onlyCode
  3313. );
  3314. this.$set(this.packingList[index], 'measureQuantity', remainder);
  3315. if (row.singleWeight) {
  3316. this.$set(
  3317. this.packingList[index],
  3318. 'weight',
  3319. row.singleWeight * remainder
  3320. );
  3321. }
  3322. }
  3323. },
  3324. //入库明细删除
  3325. listDel(row, index) {
  3326. this.productList.splice(index, 1);
  3327. this.deletePackingAndMaterial(row);
  3328. },
  3329. // 打开仓库弹框
  3330. handleWareHouse(row, idx, type) {
  3331. console.log(row, 'row');
  3332. console.log(idx, 'idx');
  3333. console.log(type, 'type');
  3334. if (row.packingSpecificationLabel?.length < 1) {
  3335. this.$message.error('请到主数据维护包装组信息!');
  3336. return;
  3337. }
  3338. if (row.isSave) {
  3339. return false;
  3340. }
  3341. //单个
  3342. if (idx > -1 && type != 'batch') {
  3343. if (row.quantity > 0) {
  3344. if (!row.isUnpack) {
  3345. console.log('不拆');
  3346. //计量和包装单位相同
  3347. if (row.measureUnit == row.unit) {
  3348. let pNum = 0;
  3349. let mNum = row.measureQuantity;
  3350. this.$refs.wareHouseDailogRef.open({
  3351. packingQuantity: pNum,
  3352. measureQuantity: mNum,
  3353. idx,
  3354. warehouseId: row.warehouseId,
  3355. warehouseName: row.warehouseName + '',
  3356. categoryType: row.categoryLevelPathIdParent
  3357. });
  3358. } else {
  3359. if (row.packingSpecificationOption[1]?.packageCell) {
  3360. let num = row.quantity;
  3361. let splitIndex = row.packingSpecificationOption.findIndex(
  3362. (item) =>
  3363. item.conversionUnit == row.unit &&
  3364. item.packageUnit != item.conversionUnit
  3365. );
  3366. for (; splitIndex > 1; splitIndex--) {
  3367. num = this.$math.format(
  3368. num *
  3369. row.packingSpecificationOption[splitIndex].packageCell,
  3370. 14
  3371. );
  3372. }
  3373. this.$refs.wareHouseDailogRef.open({
  3374. packingQuantity: num,
  3375. measureQuantity: row.measureQuantity,
  3376. idx,
  3377. warehouseId: row.warehouseId,
  3378. warehouseName: row.warehouseName + '',
  3379. categoryType: row.categoryLevelPathIdParent
  3380. });
  3381. } else {
  3382. this.$refs.wareHouseDailogRef.open({
  3383. packingQuantity: num,
  3384. measureQuantity: row.measureQuantity,
  3385. idx,
  3386. warehouseId: row.warehouseId,
  3387. warehouseName: row.warehouseName + '',
  3388. categoryType: row.categoryLevelPathIdParent
  3389. });
  3390. }
  3391. }
  3392. } else {
  3393. console.log('拆');
  3394. // let filterArr = row.packingSpecificationOption.filter((item) => {
  3395. // return (
  3396. // item.packageUnit == row.packingUnit &&
  3397. // item.packageUnit != item.conversionUnit
  3398. // );
  3399. // });
  3400. let num = Math.ceil(
  3401. row.measureQuantity /
  3402. row.packingSpecificationOption[1]?.packageCell
  3403. );
  3404. console.log(num);
  3405. this.$refs.wareHouseDailogRef.open({
  3406. packingQuantity: num,
  3407. measureQuantity: row.measureQuantity,
  3408. idx,
  3409. warehouseId: row.warehouseId,
  3410. warehouseName: row.warehouseName + '',
  3411. categoryType: row.categoryLevelPathIdParent
  3412. });
  3413. }
  3414. } else {
  3415. this.$message.error('请先填写包装数量!');
  3416. }
  3417. } else {
  3418. //批量
  3419. console.log(row, `row`);
  3420. console.log(idx, `idx`);
  3421. console.log(type, 'type');
  3422. // 验证所有选中行是否填写了包装数量
  3423. if (row.some((item) => !item.quantity)) {
  3424. this.$message.error('请先填写所有行的包装数量!');
  3425. return;
  3426. }
  3427. // 计算总需求数量
  3428. let totalPacking = row.reduce((sum, item) => {
  3429. return sum + Number(this.calculateRequiredWarehouseNum(item));
  3430. }, 0);
  3431. const mNum = row.reduce((sum, item) => {
  3432. if (
  3433. item.measureQuantity !== undefined &&
  3434. item.measureQuantity !== null
  3435. ) {
  3436. return sum + Number(item.measureQuantity);
  3437. }
  3438. return sum;
  3439. }, 0);
  3440. // 打开仓库选择弹窗
  3441. this.$refs.wareHouseDailogRef.open({
  3442. packingQuantity: totalPacking,
  3443. measureQuantity: mNum,
  3444. batch: this.formData.extInfo.assetType
  3445. });
  3446. // this.$refs.wareHouseDailogRef.open(totalPacking, mNum);
  3447. }
  3448. },
  3449. calculateRequiredWarehouseNum(row) {
  3450. if (!row.isUnpack && row.measureUnit !== row.packingUnit) {
  3451. let splitIndex = row.packingSpecificationOption.findIndex(
  3452. (item) => item.conversionUnit === row.packingUnit
  3453. );
  3454. let num = row.packingQuantity;
  3455. for (; splitIndex > 1; splitIndex--) {
  3456. num = Math.ceil(
  3457. num * row.packingSpecificationOption[splitIndex].packageCell
  3458. );
  3459. }
  3460. return num;
  3461. }
  3462. console.log(row.packingQuantity, 'row.calculateRequiredWarehouseNum');
  3463. return row.packingQuantity;
  3464. },
  3465. wareHouseSelection(argum, idx) {
  3466. console.log(argum, 'argumargumargumargumargumargum', idx);
  3467. // 方便包装遍历获取仓库id和名称
  3468. let warehouseIds = [];
  3469. let warehouseNames = [];
  3470. argum.forEach((item) => {
  3471. console.log(item, 'itemitem');
  3472. for (let index = 0; index < item.packingQuantity; index++) {
  3473. warehouseIds.push(item.warehouseId);
  3474. warehouseNames.push(item.warehouseName);
  3475. }
  3476. });
  3477. console.log(idx, 'idxidxidxidx', this.productList, 'this.productList');
  3478. if (idx > -1) {
  3479. this.$set(
  3480. this.productList[idx],
  3481. 'warehouseId',
  3482. argum.map((item) => item.warehouseId).join(',')
  3483. );
  3484. this.$set(
  3485. this.productList[idx],
  3486. 'warehouseName',
  3487. argum.map((item) => item.warehouseName).join(',')
  3488. );
  3489. this.$set(this.productList[idx], 'warehouseIds', warehouseIds);
  3490. this.$set(this.productList[idx], 'warehouseNames', warehouseNames);
  3491. console.log(this.productList, 'productList');
  3492. } else {
  3493. this.productList.map((item, index) => {
  3494. this.$set(
  3495. this.productList[index],
  3496. 'warehouseId',
  3497. argum.map((item) => item.warehouseId).join(',')
  3498. );
  3499. this.$set(
  3500. this.productList[index],
  3501. 'warehouseName',
  3502. argum.map((item) => item.warehouseName).join(',')
  3503. );
  3504. this.$set(this.productList[index], 'warehouseIds', warehouseIds);
  3505. this.$set(
  3506. this.productList[index],
  3507. 'warehouseNames',
  3508. warehouseNames
  3509. );
  3510. });
  3511. }
  3512. this.$forceUpdate();
  3513. },
  3514. // 生成物料
  3515. generateMaterial(row) {
  3516. let materialList = [];
  3517. for (let index = 0; index < row.measureQuantity; index++) {
  3518. materialList.push({
  3519. materialCode: row.packageNo + index.toString().padStart(4, '0'), // 物料编码
  3520. index: row.index + '——' + index, // 包装索引
  3521. warehouseId: row.warehouseId, // 仓库id
  3522. warehouseName: row.warehouseName, // 仓库名称
  3523. categoryName: row.categoryName, // 产品名称
  3524. categoryCode: row.categoryCode, // 产品编码
  3525. parentIndex: row.index, // 产品索引
  3526. batchNo: row.batchNo, // 批次号
  3527. packageNo: row.packageNo, // 包装编码
  3528. measureQuantity: 1, // 计量数量
  3529. measureUnit: row.measureUnit, // 计量单位
  3530. weight: Number(
  3531. this.$math.format(row.weight / row.packingQuantity, 14)
  3532. ), // 重量
  3533. weightUnit: row.weightUnit, // 重量单位
  3534. barcodes: '', // 发货条码
  3535. clientCode: '', // 客户代号
  3536. materielDesignation: '', // 物料代号
  3537. engrave: '', // 刻码
  3538. result: 1, // 结果(1合格 2不合格)
  3539. status: 2 // 状态(0=未质检 1待检 2已检)
  3540. });
  3541. }
  3542. return materialList;
  3543. },
  3544. // 设置时间
  3545. dateSetting(curDateType) {
  3546. if (!this.packingListSelected.length) {
  3547. return this.$message.error(`请选择${this.title}明细!`);
  3548. }
  3549. this.curDateType = curDateType;
  3550. this.dateVisible = true;
  3551. },
  3552. // 选择包装列表
  3553. handleSelectionChange(val) {
  3554. this.packingListSelected = val;
  3555. },
  3556. // 选择质检结果改变质检状态
  3557. changeWrapStatus(resultValue, row, type) {
  3558. console.log(resultValue);
  3559. switch (resultValue) {
  3560. case 0:
  3561. // 清空质检状态
  3562. row.status = 0;
  3563. break;
  3564. default:
  3565. // 默认已检质检状态
  3566. row.status = 2;
  3567. break;
  3568. }
  3569. if (type === '包装') {
  3570. this.packingResultCahnge(resultValue, row);
  3571. } else {
  3572. this.materialResultCahnge(resultValue, row);
  3573. }
  3574. }
  3575. }
  3576. };
  3577. </script>
  3578. <style lang="scss" scoped>
  3579. .inbound_details {
  3580. margin-top: 10px;
  3581. .el-form-item {
  3582. margin-bottom: 0 !important;
  3583. }
  3584. }
  3585. .el-form-item {
  3586. margin-bottom: 5px;
  3587. }
  3588. .right_control {
  3589. display: flex;
  3590. > button {
  3591. margin-left: 5px;
  3592. }
  3593. }
  3594. .storage_btn {
  3595. margin-top: 20px;
  3596. display: flex;
  3597. align-content: center;
  3598. justify-content: center;
  3599. }
  3600. .el-date-editor.el-input,
  3601. .el-date-editor.el-input__inner {
  3602. width: 100% !important;
  3603. }
  3604. .red_color {
  3605. color: red;
  3606. }
  3607. .wareHouse_style {
  3608. text-overflow: ellipsis;
  3609. overflow: hidden;
  3610. word-break: break-all;
  3611. white-space: nowrap;
  3612. }
  3613. :deep(.el-col) {
  3614. margin-bottom: 12px;
  3615. }
  3616. </style>