add.vue 118 KB

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