add.vue 119 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045
  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="180" 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 > 999999) {
  795. this.$set(this.productList[index], 'packingQuantity', 999999);
  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. let num = 0;
  842. for (; startIndex < endIndex; endIndex--) {
  843. // total =
  844. num = this.$math.format(
  845. row.packingSpecificationOption[endIndex].packageCell * total,
  846. 14
  847. );
  848. }
  849. console.log(num, 'numnumnum')
  850. total = Number(num);
  851. console.log(total, '333')
  852. }
  853. // 判断单位和计量单位是否为不拆物料层规格
  854. let packingBoolen = !!this.getDict('不拆物料层规格', row.packingUnit)
  855. .dictValue;
  856. let measureBoolen = !!this.getDict('不拆物料层规格', row.measureUnit)
  857. .dictValue;
  858. console.log(packingBoolen, 'packingBoolen')
  859. console.log(measureBoolen, 'measureBoolen')
  860. if (packingBoolen && measureBoolen && row.packingUnit != 'L') {
  861. console.log(total, '55555')
  862. this.$set(this.productList[index], 'weight', total);
  863. if (row.packingUnit == row.measureUnit) {
  864. this.$set(this.productList[index], 'measureQuantity', row.packingQuantity)
  865. }
  866. } else {
  867. console.log(row, 'row')
  868. if (row.measureType != 1) {
  869. if (row.packingUnit == 'KG') {
  870. if (row.packingUnit == row.measureUnit) {
  871. this.$set(this.productList[index], 'weight', row.measureQuantity)
  872. } else {
  873. const weight = total * Number(row.singleWeight);
  874. this.$set(this.productList[index], 'weight', weight)
  875. }
  876. console.log(total, '66')
  877. } else {
  878. const weight = row.measureQuantity * Number(row.singleWeight);
  879. this.$set(this.productList[index], 'weight', weight)
  880. console.log(total, '77')
  881. }
  882. } else {
  883. const weight = total * Number(row.singleWeight);
  884. this.$set(this.productList[index], 'weight', weight)
  885. console.log(total, '8')
  886. }
  887. }
  888. this.$set(this.productList[index], 'measureQuantity', total)
  889. }
  890. },
  891. //出入库申请列表操作直接入库
  892. getProduct() {
  893. let aaa = [this.$route.query.inId];
  894. console.log(aaa, '出入库申请入库操作直接入库');
  895. storageApi.getApplystoragedetails(aaa).then(async (res) => {
  896. if (this.$route.query.type == 2) {
  897. // 出库
  898. let data = await storageApi.getHierarchyFifo({
  899. type: 1,
  900. builders: res.map((item) => {
  901. return {
  902. categoryId: item.categoryId,
  903. num: item.measureQuantity
  904. };
  905. })
  906. });
  907. if (data?.length > 0) {
  908. this.outboundRequisitionSelection(data, 1, {
  909. sourceBizNo: this.$route.query.code,
  910. bizType: this.$route.query.sourceType,
  911. assetType: Array.from(
  912. new Set(res.map((item) => item.rootCategoryLevelId))
  913. ).join(',')
  914. });
  915. } else {
  916. this.$message.warning('该出库申请单无库存');
  917. }
  918. } else {
  919. // 入库
  920. const batchNo = await getCode('lot_number_code');
  921. console.log(res, '入库');
  922. let data = res.map((item, index) => {
  923. return {
  924. ...item,
  925. index,
  926. batchNo,
  927. id: '',
  928. warehouseIds: [item.warehouseId],
  929. warehouseNames: [item.warehouseName]
  930. };
  931. });
  932. this.outboundRequisitionSelection(data, 1, {
  933. sourceBizNo: this.$route.query.code,
  934. bizType: this.$route.query.sourceType,
  935. assetType: Array.from(
  936. new Set(res.map((item) => item.rootCategoryLevelId))
  937. ).join(',')
  938. });
  939. }
  940. });
  941. },
  942. async outboundRequisitionSelection(data, dimension, query) {
  943. console.log('data-----------', data);
  944. console.log('query-----------', query);
  945. console.log(this.formData.bizType, 'bbbbbtype')
  946. if (this.formData.bizType != 10) {
  947. this.formData.sourceBizNo = query.sourceBizNo;
  948. this.formData.bizType = query.bizType;
  949. this.formData.extInfo.assetType = query.assetType.split(',');
  950. const batchNo = await getCode('lot_number_code');
  951. // 获取包装规格
  952. let packingSpecification =
  953. await storageApi.getCategoryPackageDisposition({
  954. categoryIds: data.map((item) => item.categoryId)
  955. });
  956. this.packingSpecificationOption = data.map((item) => {
  957. return packingSpecification
  958. .filter((ite) => item.categoryId == ite.categoryId)
  959. .sort((a, b) => a.sort - b.sort);
  960. });
  961. console.log(
  962. 'this.packingSpecificationOption------------------------------------------包装组',
  963. this.packingSpecificationOption
  964. );
  965. console.log(data, 'datadatadatadatadata');
  966. data.map((productItem, productIndex) => {
  967. // 显示规格
  968. let packingSpecificationLabel = this.packingSpecificationOption[
  969. productIndex
  970. ]
  971. .map((item) => {
  972. if (item.sort > 0) {
  973. return `${item.packageCell}${item.packageUnit}/${item.conversionUnit}`;
  974. }
  975. })
  976. .filter((item) => !!item);
  977. // let r= {
  978. // ...productItem,
  979. console.log(productItem, 'productItem')
  980. productItem.weight = productItem.weight ? Number(productItem.weight) : 0;
  981. // productItem.singleWeight = 0;
  982. productItem.measureUnit = productItem.measuringUnit; // 计量单位
  983. productItem.index = this.productList.length + productIndex;
  984. productItem.isSave =
  985. productItem.outInDetailRecordRequestList?.length > 0
  986. ? true
  987. : false;
  988. productItem.netWeight =
  989. productItem.netWeight > 0 ? productItem.netWeight : 0;
  990. productItem.materielCode = productItem.materielCode;
  991. productItem.categoryModel = productItem.modelType; // 物品型号
  992. productItem.specification = productItem.specification; // 规格
  993. productItem.batchNo = batchNo; // 批次号
  994. productItem.warehouseIds = [productItem.warehouseId]; // 仓库Id
  995. productItem.warehouseNames = [productItem.warehouseName]; // 仓库名称
  996. productItem.packingSpecificationOption =
  997. this.packingSpecificationOption[productIndex]; // 包装规格选项
  998. productItem.packingSpecificationLabel = packingSpecificationLabel; // 包装规格显示
  999. productItem.outInDetailRecordRequestList =
  1000. productItem.outInDetailRecordRequestList?.length > 0
  1001. ? productItem.outInDetailRecordRequestList.map(
  1002. (packingItem, packingIndex) => {
  1003. return {
  1004. ...packingItem,
  1005. index:
  1006. this.productList.length +
  1007. productIndex +
  1008. '-' +
  1009. packingIndex, // 包装索引
  1010. batchNo: batchNo, // 批次号
  1011. parentIndex: this.productList.length + productIndex, // 物品索引
  1012. categoryName: productItem.categoryName,
  1013. categoryCode: productItem.categoryCode,
  1014. materialDetailList:
  1015. packingItem.materialDetailList.map(
  1016. (materialItem, materialIndex) => {
  1017. return {
  1018. ...materialItem,
  1019. index:
  1020. this.productList.length +
  1021. productIndex +
  1022. '-' +
  1023. packingIndex +
  1024. '——' +
  1025. materialIndex, // 包装索引
  1026. parentIndex:
  1027. this.productList.length +
  1028. productIndex +
  1029. '-' +
  1030. packingIndex, // 物品索引
  1031. batchNo: batchNo, // 批次号
  1032. categoryName: productItem.categoryName,
  1033. categoryCode: productItem.categoryCode
  1034. };
  1035. }
  1036. )
  1037. };
  1038. }
  1039. )
  1040. : [];
  1041. });
  1042. // this.productList = data;
  1043. this.productList = data.map((item) => {
  1044. if (item.weight === null || item.weight === undefined) {
  1045. item.weight = 0;
  1046. }
  1047. if (this.formData.bizType == 4) {
  1048. item.packingUnit = '箱'
  1049. } else {
  1050. item.packingUnit = ''
  1051. }
  1052. return item;
  1053. });
  1054. console.log(this.productList, 'productList')
  1055. // this.productList.map((v) => {
  1056. // v.weight = isNaN(v.weight);
  1057. // });
  1058. // 获取包装维度数据
  1059. const arr = [];
  1060. for (const key in this.productList) {
  1061. for (const k in this.productList[key]
  1062. .outInDetailRecordRequestList) {
  1063. arr.push({
  1064. ...this.productList[key].outInDetailRecordRequestList[k]
  1065. });
  1066. }
  1067. }
  1068. this.packingList = arr;
  1069. // 获取物料维度数据
  1070. let iArr = [];
  1071. arr.forEach((item) => {
  1072. item.materialDetailList.forEach((ele) => {
  1073. iArr.push({ ...ele });
  1074. });
  1075. });
  1076. this.materialList = iArr;
  1077. } else {
  1078. this.selWWData = query;
  1079. this.$set(this.formData, 'sourceBizNo', query.sourceBizNo);
  1080. }
  1081. },
  1082. // 获取动态表头
  1083. getFieldModel() {
  1084. storageApi.fieldModel({ fieldModel: 't_main_category' }).then((res) => {
  1085. let newRes = res.map((m) => {
  1086. return {
  1087. prop: 'extField.' + m.prop,
  1088. label: m.label,
  1089. align: 'center',
  1090. showOverflowTooltip: true
  1091. };
  1092. }).filter(item => item.label !== '包装规格');
  1093. console.log(newRes, 'newRes');
  1094. this.newColumns = [...newRes];
  1095. });
  1096. },
  1097. // 初始化当前用户信息
  1098. async initUserInfo() {
  1099. const res = await warehouseDefinition.tree();
  1100. let info = JSON.parse(localStorage.getItem('info'));
  1101. console.log(info, 'infoinfoinfo')
  1102. let obj = res.find(
  1103. (item) => item.id === info.deptIds[info.deptIds.length - 1]
  1104. );
  1105. // if (!obj) return;
  1106. if (obj) {
  1107. console.log(obj, 'objobjobjobjobjobjobjobjobjobjobjobjobjobjobjobjobj')
  1108. this.formData.extInfo.deptCode = obj?.id;
  1109. this.formData.extInfo.deptName = obj?.name;
  1110. } else {
  1111. this.formData.extInfo.deptName = info.deptName ? info.deptName : info.groupName ? info.groupName : '';
  1112. }
  1113. this.formData.extInfo.createUserName = info.name;
  1114. this.formData.createUserId = info.userId;
  1115. },
  1116. // 获取当前时间函数
  1117. getNowDate() {
  1118. let date = new Date(),
  1119. obj = {
  1120. year: date.getFullYear(), //获取完整的年份(4位)
  1121. month: date.getMonth() + 1, //获取当前月份(0-11,0代表1月)
  1122. strDate: date.getDate(), // 获取当前日(1-31)
  1123. hour: date.getHours(), //获取当前小时(0 ~ 23)
  1124. minute: date.getMinutes(), //获取当前分钟(0 ~ 59)
  1125. second: date.getSeconds() //获取当前秒数(0 ~ 59)
  1126. };
  1127. Object.keys(obj).forEach((key) => {
  1128. if (obj[key] < 10) obj[key] = `0${obj[key]}`;
  1129. });
  1130. return obj;
  1131. },
  1132. // 赋值入库时间
  1133. getNowFormatDate() {
  1134. let obj = this.getNowDate();
  1135. this.formData.storageTime = `${obj.year}-${obj.month}-${obj.strDate} ${obj.hour}:${obj.minute}:${obj.second}`;
  1136. },
  1137. // 获取物品列表
  1138. async getListItems() {
  1139. const res2 = await warehouseDefinition.getTreeByGroup({ type: 2 });
  1140. this.goodsLists = res2;
  1141. },
  1142. // 打开单据来源弹窗
  1143. openDocumentSourceDialog() {
  1144. console.log('打开单据来源弹窗');
  1145. this.$refs.outboundRequisitionDialogRef.open();
  1146. },
  1147. // 清除单据来源
  1148. clearSourceBizNo() {
  1149. this.formData.sourceBizNo = '';
  1150. },
  1151. // 返回
  1152. back() {
  1153. this.$router.go(-1);
  1154. },
  1155. // 添加产品
  1156. addProduct() {
  1157. if (this.formData.extInfo.assetType.length <= 0) {
  1158. return this.$message.error('请选择物品类型');
  1159. }
  1160. if (!this.formData.bizType) {
  1161. return this.$message.error('请选择入库类型');
  1162. }
  1163. this.visibleDialog = true;
  1164. },
  1165. // 键盘移动
  1166. moveFocus(event, index, key, type, row) {
  1167. let keyfield = [];
  1168. let listLength = 0;
  1169. switch (type) {
  1170. case '产品':
  1171. listLength = this.productList.length;
  1172. keyfield = ['batchNo', 'packingQuantity', 'unitPrice', 'purpose'];
  1173. break;
  1174. case '包装':
  1175. listLength = this.showPackingList.length;
  1176. if (row.measureUnit != row.weightUnit) {
  1177. keyfield = [
  1178. 'packing_materielDesignation',
  1179. 'packing_clientCode',
  1180. 'packing_engrave',
  1181. 'packing_weight'
  1182. ];
  1183. } else {
  1184. keyfield = [
  1185. 'packing_materielDesignation',
  1186. 'packing_clientCode',
  1187. 'packing_engrave'
  1188. ];
  1189. }
  1190. break;
  1191. case '物料':
  1192. listLength = this.showMaterialList.length;
  1193. if (row.measureUnit != row.weightUnit) {
  1194. keyfield = [
  1195. 'material_materielDesignation',
  1196. 'material_clientCode',
  1197. 'material_engrave',
  1198. 'material_weight'
  1199. ];
  1200. } else {
  1201. keyfield = [
  1202. 'material_materielDesignation',
  1203. 'material_clientCode',
  1204. 'material_engrave'
  1205. ];
  1206. }
  1207. break;
  1208. }
  1209. if (event.keyCode === 13) {
  1210. // 回车
  1211. if (
  1212. index === listLength - 1 &&
  1213. key === keyfield[keyfield.length - 1]
  1214. ) {
  1215. // 最后一行最后一个
  1216. return;
  1217. }
  1218. this.$refs[key + index].blur();
  1219. if (key === keyfield[keyfield.length - 1]) {
  1220. // 当前行最后一个,跳转下一行第一个
  1221. if (this.$refs[keyfield[0] + (index + 1)].value == 0) {
  1222. this.$refs[keyfield[0] + (index + 1)].value = '';
  1223. }
  1224. this.$refs[keyfield[0] + (index + 1)].focus();
  1225. } else {
  1226. // 跳转下一个
  1227. const nextkeyindex = keyfield.findIndex((k) => k === key) + 1;
  1228. this.$nextTick(() => {
  1229. if (this.$refs[keyfield[nextkeyindex] + index].value == 0) {
  1230. this.$refs[keyfield[nextkeyindex] + index].value = '';
  1231. }
  1232. this.$refs[keyfield[nextkeyindex] + index].focus();
  1233. });
  1234. }
  1235. }
  1236. // 向上 =38
  1237. if (event.keyCode === 38) {
  1238. console.log('向上');
  1239. if (index === 0) {
  1240. // 第一行
  1241. console.log('第一行无法向上');
  1242. return;
  1243. }
  1244. this.$refs[key + index].blur();
  1245. this.$nextTick(() => {
  1246. if (this.$refs[key + (index - 1)].value == 0) {
  1247. this.$refs[key + (index - 1)].value = '';
  1248. }
  1249. this.$refs[key + (index - 1)].focus();
  1250. });
  1251. }
  1252. // 下 = 40
  1253. if (event.keyCode === 40) {
  1254. console.log('向下');
  1255. if (index === listLength - 1) {
  1256. // 最后一行
  1257. console.log('最后一行无法向下');
  1258. return;
  1259. }
  1260. this.$refs[key + index].blur();
  1261. this.$nextTick(() => {
  1262. if (this.$refs[key + (index + 1)].value == 0) {
  1263. this.$refs[key + (index + 1)].value = '';
  1264. }
  1265. this.$refs[key + (index + 1)].focus();
  1266. });
  1267. }
  1268. // 左 = 37
  1269. if (event.keyCode === 37) {
  1270. console.log('向左');
  1271. if (index === 0 && key === keyfield[0]) {
  1272. // 第一行第一个
  1273. console.log('第一行第一个无法向左');
  1274. return;
  1275. }
  1276. this.$refs[key + index].blur();
  1277. if (key === keyfield[0]) {
  1278. if (
  1279. this.$refs[keyfield[keyfield.length - 1] + (index - 1)].value == 0
  1280. ) {
  1281. this.$refs[keyfield[keyfield.length - 1] + (index - 1)].value =
  1282. '';
  1283. }
  1284. // 当前行第一个,跳转上一行最后一个
  1285. this.$refs[keyfield[keyfield.length - 1] + (index - 1)].focus();
  1286. } else {
  1287. // 跳转上一个
  1288. const prevkeyindex = keyfield.findIndex((k) => k === key) - 1;
  1289. this.$nextTick(() => {
  1290. if (this.$refs[keyfield[prevkeyindex] + index].value == 0) {
  1291. this.$refs[keyfield[prevkeyindex] + index].value = '';
  1292. }
  1293. this.$refs[keyfield[prevkeyindex] + index].focus();
  1294. });
  1295. }
  1296. }
  1297. // 右 = 39
  1298. if (event.keyCode === 39) {
  1299. console.log('向右');
  1300. if (
  1301. index === listLength - 1 &&
  1302. key === keyfield[keyfield.length - 1]
  1303. ) {
  1304. // 最后一行最后一个
  1305. console.log('最后一行最后一个无法向左');
  1306. return;
  1307. }
  1308. console.log(this.$refs);
  1309. this.$refs[key + index].blur();
  1310. if (key === keyfield[keyfield.length - 1]) {
  1311. // 当前行最后一个,跳转下一行第一个
  1312. if (this.$refs[keyfield[0] + (index + 1)].value == 0) {
  1313. this.$refs[keyfield[0] + (index + 1)].value = '';
  1314. }
  1315. this.$refs[keyfield[0] + (index + 1)].focus();
  1316. } else {
  1317. // 跳转下一个
  1318. const nextkeyindex = keyfield.findIndex((k) => k === key) + 1;
  1319. this.$nextTick(() => {
  1320. if (this.$refs[keyfield[nextkeyindex] + index].value == 0) {
  1321. this.$refs[keyfield[nextkeyindex] + index].value = '';
  1322. }
  1323. this.$refs[keyfield[nextkeyindex] + index].focus();
  1324. });
  1325. }
  1326. }
  1327. },
  1328. handleAvatarSuccess() {
  1329. this.$refs.fileUploadBtn.clearFiles(); //上传成功之后清除历史记录**加粗样式**
  1330. },
  1331. async onChange(file) {
  1332. console.log(XLSX);
  1333. this.warehousingMaterialList = [];
  1334. this.resultArray = [];
  1335. const loading = this.$loading({
  1336. lock: true,
  1337. text: '加载中...'
  1338. });
  1339. /**
  1340. * 1. 使用原生api去读取好的文件
  1341. * */
  1342. // console.log("原始上传的文件", file);
  1343. // 读取文件不是立马能够读取到的,所以是异步的,使用Promise
  1344. let dataBinary = await new Promise((resolve) => {
  1345. // Web API构造函数FileReader,可实例化对象,去调用其身上方法,去读取解析文件信息
  1346. let reader = new FileReader(); // https://developer.mozilla.org/zh-CN/docs/Web/API/FileReader
  1347. // console.log("实例化对象有各种方法", reader);
  1348. reader.readAsBinaryString(file.raw); // 读取raw的File文件
  1349. reader.onload = (ev) => {
  1350. // console.log("文件解析流程进度事件", ev);
  1351. resolve(ev.target.result); // 将解析好的结果扔出去,以供使用
  1352. };
  1353. });
  1354. // console.log("读取出的流文件", dataBinary);
  1355. /**
  1356. * 2. 使用xlsx插件去解析已经读取好的二进制excel流文件
  1357. * */
  1358. let workBook = XLSX.read(dataBinary, {
  1359. type: 'binary',
  1360. cellDates: true
  1361. });
  1362. // excel中有很多的sheet,这里取了第一个sheet:workBook.SheetNames[0]
  1363. let firstWorkSheet = workBook.Sheets[workBook.SheetNames[0]];
  1364. // 分为第一行的数据,和第一行下方的数据
  1365. // const header = this.getHeaderRow(firstWorkSheet);
  1366. // console.log('读取的excel表头数据(第一行)', header);
  1367. const xlsxData = XLSX.utils.sheet_to_json(firstWorkSheet);
  1368. console.log('读取所有excel数据', xlsxData);
  1369. // let modelTypeList = xlsxData.map((item) => {
  1370. // return item['型号'];
  1371. // });
  1372. // let nameList = xlsxData.map((item) => {
  1373. // return item['物品名称'];
  1374. // });
  1375. let codeList = xlsxData.map((item) => {
  1376. return item['sap物料码'];
  1377. });
  1378. let functionType = {};
  1379. xlsxData.map((item) => {
  1380. functionType[item['sap物料码']] = item['采购原因'];
  1381. });
  1382. this.formData.extInfo.assetType = ['6']; //备品备件
  1383. this.formData.bizType = '2'; // 采购入库
  1384. outin
  1385. .getListByNameOrModeType({
  1386. // modelTypeList,
  1387. // nameList,
  1388. codeList,
  1389. categoryLevelId: '6'
  1390. })
  1391. .then(async (data) => {
  1392. console.log('查询到的备件数据', data);
  1393. const batchNo = await getCode('lot_number_code');
  1394. // 添加包装数量和最小包装单元
  1395. this.productList = data.map((item, index) => {
  1396. console.log(xlsxData);
  1397. let filterArray = xlsxData.filter(
  1398. (xlsxItem) => xlsxItem['sap物料码'] == item.code
  1399. );
  1400. console.log(filterArray);
  1401. return {
  1402. index: this.productList.length + index,
  1403. categoryId: item.id, // 物品id
  1404. categoryName: item.name, // 物品名称
  1405. categoryCode: item.code, // 物品编码
  1406. categoryModel: item.modelType, // 物品型号
  1407. specification: item.specification, // 规格
  1408. brandNum: item.brandNum, // 牌号
  1409. batchNo: batchNo, // 批次号
  1410. minPackingQuantity: 1, // 最小包装单元数量
  1411. packingQuantity: filterArray[0]['数量'], // 包装数量
  1412. packingUnit: item.packingUnit, // 单位
  1413. measureQuantity: 0, // 计量数量
  1414. measureUnit: item.measuringUnit, // 计量单位
  1415. netWeight: item.netWeight > -1 ? item.netWeight : 0, // 净重
  1416. weight: 0, // 重量
  1417. weightUnit: item.weightUnit, // 重量单位
  1418. totalMoney: '', // 总价
  1419. unitPrice: item.unitPrice, // 单价
  1420. purpose: functionType[item.code], // 用途
  1421. isUnpack: item.isUnpack // 是否允许拆包
  1422. };
  1423. });
  1424. console.log(this.productList);
  1425. this.handleAvatarSuccess();
  1426. loading.close();
  1427. })
  1428. .catch(() => {
  1429. loading.close();
  1430. });
  1431. },
  1432. // 入库
  1433. storage() {
  1434. let boolen = this.productList.every((item) => item.isSave);
  1435. if (!boolen) {
  1436. this.$message.warning('请先保存所有产品信息');
  1437. return;
  1438. }
  1439. // 处理包装数据
  1440. this.packingList = this.packingList.map((packingItem) => {
  1441. return {
  1442. ...packingItem,
  1443. materialDetailList: this.materialList.filter(
  1444. (item) => item.parentIndex === packingItem.index
  1445. ),
  1446. taskId: this.selWWData?.taskId,
  1447. workOrderId: this.selWWData?.workOrderId
  1448. };
  1449. });
  1450. // 处理产品数据
  1451. this.productList = this.productList.map((productItem) => {
  1452. return {
  1453. ...productItem,
  1454. outInDetailRecordRequestList: this.packingList.filter(
  1455. (item) => item.parentIndex === productItem.index
  1456. )
  1457. };
  1458. });
  1459. this.formData.outInDetailList = this.productList;
  1460. let obj = deepClone(this.formData);
  1461. // 处理物品类型assetType
  1462. obj.extInfo.assetType = obj.extInfo.assetType.join(',');
  1463. // 处理仓库id
  1464. let warehouseId = [];
  1465. let warehouseName = [];
  1466. let warehouseIds = this.productList
  1467. .map((item) => item.warehouseIds)
  1468. .flat();
  1469. let warehouseNames = this.productList
  1470. .map((item) => item.warehouseNames)
  1471. .flat();
  1472. warehouseIds.forEach((item, index) => {
  1473. if (!warehouseId.includes(item)) {
  1474. warehouseId.push(item);
  1475. warehouseName.push(warehouseNames[index]);
  1476. }
  1477. });
  1478. obj.warehouseIds = warehouseId;
  1479. obj.warehouseNames = warehouseName;
  1480. console.log('入库数据', obj);
  1481. // 是否需要审核(0审核 1跳过审核)
  1482. if (obj.bizType == '12') {
  1483. obj.isSkip = 1;
  1484. } else {
  1485. obj.isSkip = 0;
  1486. }
  1487. // obj.isSkip = 1;
  1488. this.saveLoading = true;
  1489. console.log(obj, 'objobjobjobjobjobj');
  1490. storageApi
  1491. .storage(obj)
  1492. .then(async (res) => {
  1493. console.log('入库成功', res);
  1494. if (res.code == 0) {
  1495. try {
  1496. // 委外入库(非采购)
  1497. if (obj.bizType == '12') {
  1498. await storageApi.qualityInspectionTwo({
  1499. outInId: res.data[0]
  1500. });
  1501. } else {
  1502. await storageApi.submitTwo({ outInId: res.data[0] });
  1503. }
  1504. this.$message.success('入库成功');
  1505. this.saveLoading = false;
  1506. this.$router.push('/warehouseManagement/stockManagement');
  1507. } catch (error) {
  1508. this.saveLoading = false;
  1509. console.log('提交流程失败', error);
  1510. }
  1511. }
  1512. })
  1513. .catch((err) => {
  1514. console.log('入库失败', err);
  1515. this.saveLoading = false;
  1516. });
  1517. },
  1518. pickingHandleScroll() {
  1519. // console.log('---------pickingHandleScroll------------');
  1520. // console.log(this.packingList);
  1521. // console.log(this.showPackingList);
  1522. // console.log(this.pageSize);
  1523. if (this.showPackingList.length < this.packingList.length) {
  1524. if (this.packingList.length > this.pageSize) {
  1525. this.pickingPageNum += 1;
  1526. }
  1527. this.pickingFetchData();
  1528. }
  1529. },
  1530. pickingFetchData() {
  1531. const start = (this.pickingPageNum - 1) * this.pageSize;
  1532. const end = start + this.pageSize;
  1533. console.log(start);
  1534. console.log(end);
  1535. this.showPackingList = this.showPackingList.concat(
  1536. this.packingList.slice(start, end)
  1537. );
  1538. },
  1539. materielHandleScroll() {
  1540. console.log('---------materielHandleScroll------------');
  1541. if (this.showMaterialList.length < this.materialList.length) {
  1542. if (this.materialList.length > this.pageSize) {
  1543. this.materielPageNum += 1;
  1544. }
  1545. this.materielFetchData();
  1546. }
  1547. },
  1548. materielFetchData() {
  1549. const start = (this.materielPageNum - 1) * this.pageSize;
  1550. const end = start + this.pageSize;
  1551. this.showMaterialList = this.showMaterialList.concat(
  1552. this.materialList.slice(start, end)
  1553. );
  1554. console.log(this.showMaterialList);
  1555. },
  1556. // 日期选择
  1557. dateConfirm() {
  1558. this.packingListSelected.forEach((item) => {
  1559. this.$set(item, this.curDateType, this.batchTime);
  1560. });
  1561. this.batchTime = '';
  1562. this.dateVisible = false;
  1563. },
  1564. // 包装重量修改
  1565. packingWeightCahnge(value, row) {
  1566. // 修改物品重量
  1567. let filterPackingList = this.packingList.filter((item) => {
  1568. return item.parentIndex === row.parentIndex;
  1569. });
  1570. let productIndex = this.productList.findIndex((item) => {
  1571. return item.index === row.parentIndex;
  1572. });
  1573. let totalWeight = filterPackingList.reduce(
  1574. (accumulator, currentValue) => {
  1575. return this.$math.format(+accumulator + +currentValue.weight, 14);
  1576. },
  1577. 0
  1578. );
  1579. this.$set(this.productList[productIndex], 'weight', totalWeight);
  1580. this.$set(
  1581. this.productList[productIndex],
  1582. 'singleWeight',
  1583. totalWeight / this.productList[productIndex].measureQuantity
  1584. );
  1585. // 修改拆分物料
  1586. this.materialList.map((item, index) => {
  1587. if (item.parentIndex === row.index) {
  1588. console.log(value / row.measureQuantity);
  1589. this.$set(
  1590. this.materialList[index],
  1591. 'weight',
  1592. this.$math.format(value / row.measureQuantity, 14) >= 0
  1593. ? this.$math.format(value / row.measureQuantity, 14)
  1594. : 0
  1595. );
  1596. }
  1597. });
  1598. },
  1599. // 物料重量修改
  1600. materialWeightCahnge(row) {
  1601. // 修改包装重量
  1602. let filterMaterialList = this.materialList.filter((item) => {
  1603. return item.parentIndex === row.parentIndex;
  1604. });
  1605. let packingIndex = this.packingList.findIndex((item) => {
  1606. return item.index === row.parentIndex;
  1607. });
  1608. let totalMaterialWeight = filterMaterialList.reduce(
  1609. (accumulator, currentValue) => {
  1610. return this.$math.format(+accumulator + +currentValue.weight, 14);
  1611. },
  1612. 0
  1613. );
  1614. this.$set(
  1615. this.packingList[packingIndex],
  1616. 'weight',
  1617. totalMaterialWeight
  1618. );
  1619. // 修改物品重量
  1620. let filterPackingList = this.packingList.filter((item) => {
  1621. return (
  1622. item.parentIndex === this.packingList[packingIndex].parentIndex
  1623. );
  1624. });
  1625. let productIndex = this.productList.findIndex((item) => {
  1626. return item.index === this.packingList[packingIndex].parentIndex;
  1627. });
  1628. let totalWeight = filterPackingList.reduce(
  1629. (accumulator, currentValue) => {
  1630. return this.$math.format(+accumulator + +currentValue.weight, 14);
  1631. },
  1632. 0
  1633. );
  1634. this.$set(this.productList[productIndex], 'weight', totalWeight);
  1635. },
  1636. // 包装质检结果修改
  1637. packingResultCahnge(value, row) {
  1638. // 修改物料质检结果( 1合格 2不合格)
  1639. this.materialList.map((item, index) => {
  1640. if (item.parentIndex === row.index) {
  1641. this.$set(this.materialList[index], 'result', value);
  1642. }
  1643. });
  1644. },
  1645. // 物料质量结果修改
  1646. materialResultCahnge(value, row) {
  1647. // 修改包装质检结果
  1648. let filterMaterialList = this.materialList.filter((item) => {
  1649. return item.parentIndex == row.parentIndex;
  1650. });
  1651. let packingIndex = this.packingList.findIndex((item) => {
  1652. return item.index == row.parentIndex;
  1653. });
  1654. let boolen = filterMaterialList.every((item) => {
  1655. return item.result == 1;
  1656. });
  1657. this.$set(this.packingList[packingIndex], 'result', boolen ? 1 : 2);
  1658. },
  1659. // 重量限制
  1660. weightInput(value, row, type) {
  1661. const newValue = value.replace(/[^\d.]/g, ''); // 保留数字和小数点
  1662. const decimalCount = (newValue.match(/\./g) || []).length; // 计算小数点的个数
  1663. if (row.weight < 0) {
  1664. row.weight = 0;
  1665. } else if (row.weight > 9999) {
  1666. row.weight = 9999;
  1667. } else {
  1668. if (decimalCount > 1) {
  1669. // 如果小数点个数大于1,移除多余的小数点
  1670. const lastIndex = newValue.lastIndexOf('.');
  1671. row.weight =
  1672. newValue.slice(0, lastIndex) + newValue.slice(lastIndex + 1);
  1673. } else if (decimalCount === 1) {
  1674. // 如果小数点个数等于1,允许小数点的输入
  1675. row.weight = newValue;
  1676. } else {
  1677. row.weight = newValue === '' ? 0 : parseFloat(newValue); // 如果输入为空,则设为0
  1678. }
  1679. }
  1680. if (type === '包装') {
  1681. this.packingWeightCahnge(value, row);
  1682. } else {
  1683. this.materialWeightCahnge(row);
  1684. }
  1685. },
  1686. //计算金额
  1687. calcSumTotal(measureQuantity, unitPrice, row) {
  1688. //最小包装单元,包装数量,单价
  1689. console.log(measureQuantity, unitPrice, ';;;;;;;;;;')
  1690. const total = {
  1691. measureQuantity: Number(measureQuantity > 0 ? measureQuantity : 0),
  1692. unitPrice: Number(unitPrice > 0 ? unitPrice : 0)
  1693. };
  1694. let number = Number(
  1695. this.$math.format(total.measureQuantity * total.unitPrice, 14)
  1696. );
  1697. row.totalMoney = number;
  1698. console.log(number, 'number')
  1699. return number;
  1700. },
  1701. // 包装维度最小包装单元改变——>总重量
  1702. minPackingQuantityChange(row, value, index) {
  1703. console.log(value);
  1704. if (row.measureUnit !== 'KG') {
  1705. if (value.replace(/^(0+)|[^\d]+/g, '') > 9999) {
  1706. this.$set(this.productList[index], 'minPackingQuantity', 9999);
  1707. } else {
  1708. this.$set(
  1709. this.productList[index],
  1710. 'minPackingQuantity',
  1711. value.replace(/^(0+)|[^\d]+/g, '')
  1712. );
  1713. }
  1714. } else {
  1715. if (value < 1) {
  1716. this.$set(this.productList[index], 'minPackingQuantity', 1);
  1717. } else if (value > 9999) {
  1718. this.$set(this.productList[index], 'minPackingQuantity', 9999);
  1719. }
  1720. }
  1721. if (row.packingQuantity >= 0 && value >= 0) {
  1722. this.packNum(row, row.packingQuantity, index);
  1723. }
  1724. },
  1725. // 包装数量过滤处理改变——>总重量
  1726. packNum(row, value, index) {
  1727. const total = {
  1728. minPackingQuantity: Number(
  1729. row.minPackingQuantity > 0
  1730. ? row.minPackingQuantity > 9999
  1731. ? 9999
  1732. : row.minPackingQuantity
  1733. : 0
  1734. ),
  1735. packingQuantity: Number(
  1736. row.packingQuantity > 0
  1737. ? row.packingQuantity > 9999
  1738. ? 9999
  1739. : row.packingQuantity
  1740. : 0
  1741. )
  1742. };
  1743. const totals = Number(
  1744. this.$math.format(
  1745. total.minPackingQuantity * total.packingQuantity,
  1746. 14
  1747. )
  1748. );
  1749. if (row.measureUnit == row.weightUnit) {
  1750. row.weight = Number(
  1751. this.$math.format(
  1752. total.minPackingQuantity *
  1753. 1 *
  1754. Number(total.packingQuantity).toFixed(2),
  1755. 14
  1756. )
  1757. );
  1758. } else {
  1759. row.weight = Number(
  1760. this.$math.format(
  1761. totals *
  1762. (row.netWeight > 0 ? Number(row.netWeight).toFixed(2) : 0),
  1763. 14
  1764. )
  1765. );
  1766. }
  1767. this.$set(this.productList[index], 'measureQuantity', totals);
  1768. // 清空仓库
  1769. this.$set(this.productList[index], 'warehouseId', '');
  1770. this.$set(this.productList[index], 'warehouseName', '');
  1771. if (value.replace(/^(0+)|[^\d]+/g, '') > 9999) {
  1772. this.$set(this.productList[index], 'packingQuantity', 9999);
  1773. } else {
  1774. this.$set(
  1775. this.productList[index],
  1776. 'packingQuantity',
  1777. value.replace(/^(0+)|[^\d]+/g, '')
  1778. );
  1779. }
  1780. // return (row.packingQuantity = value.replace(/^(0+)|[^\d]+/g, ''));
  1781. },
  1782. // 表格样式
  1783. rowClass({ row, column, rowIndex, columnIndex }) {
  1784. if (rowIndex === 1) {
  1785. return {
  1786. display: 'none',
  1787. background: '#EEEEEE'
  1788. };
  1789. }
  1790. return { background: '#0000' };
  1791. },
  1792. getNewSpecificationOption(packingSpecificationOption) {
  1793. return packingSpecificationOption.map(arr => {
  1794. return arr.reduce((acc, current) => {
  1795. const conversionUnit = current.conversionUnit;
  1796. if (!acc.some(item => item.conversionUnit === conversionUnit)) {
  1797. acc.push(current);
  1798. }
  1799. return acc;
  1800. }, []);
  1801. });
  1802. },
  1803. async addGoods(data) {
  1804. if (data.length === 0) return this.$message.warning('请选择产品信息')
  1805. console.log(data, 'datadatadatadatadatadatadata111')
  1806. // 获取批次号
  1807. const batchNo = await getCode('lot_number_code');
  1808. // 获取供应商
  1809. const supplierList = await storageApi.contactQueryByCategoryIdsAPI({
  1810. categoryIds: data.map((item) => item.id)
  1811. });
  1812. console.log(supplierList, '供应商列表');
  1813. // 获取包装规格
  1814. let packingSpecification =
  1815. await storageApi.getCategoryPackageDisposition({
  1816. categoryIds: data.map((item) => item.id)
  1817. });
  1818. console.log(packingSpecification, 'packingSpecification')
  1819. this.packingSpecificationOption = data.map((item) => {
  1820. return packingSpecification
  1821. .filter((ite) => item.id == ite.categoryId)
  1822. .sort((a, b) => a.sort - b.sort);
  1823. });
  1824. console.log('yeyyeyey----------------', data);
  1825. const newSpecificationOption = this.getNewSpecificationOption(this.packingSpecificationOption)
  1826. let productList = data.map((item, index) => {
  1827. // 显示规格
  1828. let packingSpecificationLabel = this.packingSpecificationOption[index]
  1829. .map((item) => {
  1830. if (item.sort > 0) {
  1831. return `${item.packageCell}${item.packageUnit}/${item.conversionUnit}`;
  1832. }
  1833. })
  1834. .filter((item) => !!item);
  1835. return {
  1836. index:
  1837. this.productList.length - 1 > -1
  1838. ? this.productList[this.productList.length - 1].index +
  1839. index +
  1840. 1
  1841. : this.productList.length + index,
  1842. // extField: {
  1843. // packingSpecification: item.extField.packingSpecification
  1844. // }, // 包装规格
  1845. categoryId: item.id, // 物品id
  1846. categoryName: item.name, // 物品名称
  1847. categoryCode: item.code, // 物品编码
  1848. categoryModel: item.modelType, // 物品型号
  1849. specification: item.specification, // 规格
  1850. brandNum: item.brandNum, // 牌号
  1851. batchNo: batchNo, // 批次号
  1852. supplierListOptions: supplierList[item.id], // 供应商列表
  1853. supplierId: '', // 供应商id
  1854. supplierName: '', // 供应商名称
  1855. supplierCode: '',
  1856. measureType: item.measureType, // 计量类型
  1857. approvalNumber: item.approvalNumber, // 批准文号
  1858. packingSpecification: item.packingSpecification, // 包装规格
  1859. packingSpecificationOption: newSpecificationOption[index], // 包装规格选项
  1860. packingSpecificationLabel: packingSpecificationLabel, // 包装规格显示
  1861. minPackingQuantity: '', // 最小包装单元数量
  1862. packingQuantity: '', // 包装数量
  1863. packingUnit: '', // 单位
  1864. measureQuantity: 0, // 计量数量
  1865. measureUnit: item.measuringUnit, // 计量单位
  1866. netWeight: item.netWeight > -1 ? item.netWeight : 0, // 净重
  1867. weight: 0, // 重量
  1868. singleWeight: item.netWeight, //单重 进来获取净重
  1869. weightUnit: item.weightUnit, // 重量单位
  1870. totalMoney: '', // 总价
  1871. unitPrice: item.unitPrice, // 单价
  1872. purpose: '', // 用途
  1873. isUnpack: item.isUnpack, // 是否允许拆包
  1874. categoryLevelPathIdParent: item.categoryLevelPathIdParent
  1875. };
  1876. });
  1877. this.productList = this.productList.concat(productList);
  1878. console.log('this.productList--------', this.productList);
  1879. },
  1880. // 物品保存验证表单(批量)
  1881. validateForm() {
  1882. return new Promise(async (resolve, reject) => {
  1883. let list = this.productList.map(async (row, index) => {
  1884. let fileds = [
  1885. `productList.${index}.batchNo`,
  1886. `productList.${index}.packingQuantity`,
  1887. `productList.${index}.packingUnit`,
  1888. `productList.${index}.warehouseId`
  1889. ];
  1890. console.log(fileds);
  1891. if (row.isSave) {
  1892. return Promise.resolve(true);
  1893. } else {
  1894. return await Promise.all(
  1895. fileds.map(
  1896. (item) =>
  1897. new Promise(async (res, rej) => {
  1898. this.$refs.productListRef.validateField(item, (err) => {
  1899. if (err) {
  1900. rej(err);
  1901. } else {
  1902. res(true);
  1903. }
  1904. });
  1905. })
  1906. )
  1907. );
  1908. }
  1909. });
  1910. console.log(list);
  1911. Promise.all(list)
  1912. .then(() => {
  1913. console.log('保存成功!');
  1914. resolve();
  1915. })
  1916. .catch((err) => {
  1917. console.log('保存失败!');
  1918. this.$message.error('请填入必填项!');
  1919. reject(err);
  1920. });
  1921. });
  1922. },
  1923. // 产品批量保存
  1924. // async listSaveArrs() {
  1925. // this.validateForm()
  1926. // .then(async () => {
  1927. // // 批量获取包装编码并处理
  1928. // let packingCodePrams = this.productList.map((row) => {
  1929. // // 判断单位和计量单位是否为不拆物料层规格
  1930. // let packingBoolen = !!this.getDict(
  1931. // '不拆物料层规格',
  1932. // row.packingUnit
  1933. // ).dictValue;
  1934. // let measureBoolen = !!this.getDict(
  1935. // '不拆物料层规格',
  1936. // row.measureUnit
  1937. // ).dictValue;
  1938. // let num = 0;
  1939. // if (packingBoolen) {
  1940. // let filterArr = row.packingSpecificationOption.filter(
  1941. // (item) => {
  1942. // return (
  1943. // item.packageUnit == row.packingUnit &&
  1944. // item.packageUnit != item.conversionUnit
  1945. // );
  1946. // }
  1947. // );
  1948. // num = Math.ceil(row.packingQuantity / filterArr[0].packageCell);
  1949. // }
  1950. // if (row.isSave) {
  1951. // return {};
  1952. // } else {
  1953. // console.log(packingBoolen, 'packingBoolen怕怕怕怕怕怕怕')
  1954. // // 处理单位为KG类的情况
  1955. // if (packingBoolen) {
  1956. // return {
  1957. // assetCode: row.categoryCode + row.index,
  1958. // batchNum: row.batchNo,
  1959. // num
  1960. // };
  1961. // } else {
  1962. // if (row.isUnpack) {
  1963. // if (measureBoolen) {
  1964. // // 处理单位不为KG类,计量单位为KG类的情况
  1965. // let num = row.packingQuantity;
  1966. // let splitIndex = row.packingSpecificationOption.findIndex(
  1967. // (item) =>
  1968. // item.conversionUnit == row.packingUnit &&
  1969. // item.packageUnit != item.conversionUnit
  1970. // );
  1971. // for (; splitIndex > 1; splitIndex--) {
  1972. // num = this.$math.format(
  1973. // num *
  1974. // row.packingSpecificationOption[splitIndex]
  1975. // .packageCell,
  1976. // 14
  1977. // );
  1978. // }
  1979. // return {
  1980. // assetCode: row.categoryCode + row.index,
  1981. // batchNum: row.batchNo,
  1982. // num
  1983. // };
  1984. // } else {
  1985. // console.log('拆包情况------:', row.measureQuantity, row.packingSpecificationOption[1]?.packageCell);
  1986. // // 处理拆包到最小包装单元数量的情况
  1987. // let num = Math.ceil(
  1988. // row.measureQuantity / row.packingSpecificationOption[1]?.packageCell
  1989. // );
  1990. // return {
  1991. // assetCode: row.categoryCode + row.index,
  1992. // batchNum: row.batchNo,
  1993. // num: num
  1994. // };
  1995. // }
  1996. // } else {
  1997. // return {
  1998. // assetCode: row.categoryCode + row.index,
  1999. // batchNum: row.batchNo,
  2000. // num: row.packingQuantity
  2001. // };
  2002. // }
  2003. // }
  2004. // }
  2005. // });
  2006. // let filterPackingCodePrams = packingCodePrams.filter(
  2007. // (item) => item.assetCode
  2008. // );
  2009. // let { data } = await storageApi.getAssetNum(filterPackingCodePrams);
  2010. // console.log('data-----11111111111111111---', data);
  2011. // let packingCodeList = [];
  2012. // packingCodePrams.forEach((item, index) => {
  2013. // packingCodeList[index] = data.filter(
  2014. // (ite) => ite.assetCode == item.assetCode
  2015. // );
  2016. // });
  2017. // // 批量生成包装
  2018. // this.productList.map((row, index) => {
  2019. // if (!row.isSave) {
  2020. // this.generateWrappers(row, index, packingCodeList[index]);
  2021. // this.$set(this.productList[index], 'isSave', true);
  2022. // console.log('this.productList[index]----', this.productList[index]);
  2023. // console.log('row----', row);
  2024. // this.$set(
  2025. // this.productList[index],
  2026. // 'warehouseId',
  2027. // row.warehouseId
  2028. // );
  2029. // this.$set(
  2030. // this.productList[index],
  2031. // 'warehouseName',
  2032. // row.warehouseName
  2033. // );
  2034. // this.$set(
  2035. // this.productList[index],
  2036. // 'warehouseIds',
  2037. // [row.warehouseId]
  2038. // );
  2039. // this.$set(
  2040. // this.productList[index],
  2041. // 'warehouseNames',
  2042. // [row.warehouseName]
  2043. // );
  2044. // }
  2045. // });
  2046. // // 加载虚拟列表数据(分页)
  2047. // // this.pickingFetchData();
  2048. // // this.materielFetchData();
  2049. // })
  2050. // .catch((err) => {
  2051. // console.log(err);
  2052. // });
  2053. // },
  2054. // 物品保存验证表单(单独)
  2055. validateFormIndividually(index) {
  2056. return new Promise(async (resolve) => {
  2057. console.log(index);
  2058. let fileds = [
  2059. `productList.${index}.batchNo`,
  2060. `productList.${index}.packingQuantity`,
  2061. `productList.${index}.packingUnit`,
  2062. `productList.${index}.warehouseId`
  2063. ];
  2064. Promise.all(
  2065. fileds.map(
  2066. (item) =>
  2067. new Promise(async (res, rej) => {
  2068. this.$refs.productListRef.validateField(item, (err) => {
  2069. if (err) {
  2070. rej(err);
  2071. } else {
  2072. res(true);
  2073. }
  2074. });
  2075. })
  2076. )
  2077. )
  2078. .then(() => {
  2079. resolve();
  2080. })
  2081. .catch(() => {
  2082. this.$message.error('请填入必填项!');
  2083. });
  2084. });
  2085. },
  2086. // 产品编辑
  2087. listEdit(row) {
  2088. console.log(row);
  2089. this.$set(row, 'isSave', false);
  2090. this.deletePackingAndMaterial(row);
  2091. },
  2092. // 根据产品信息删除包装和物料
  2093. deletePackingAndMaterial(row) {
  2094. console.log('row--------', row);
  2095. console.log('packingList------', this.packingList);
  2096. // 删除包装(去掉不相同的包装)
  2097. this.packingList = this.packingList.filter(
  2098. (item) => item.parentIndex !== row.index
  2099. );
  2100. this.showPackingList = this.showPackingList.filter(
  2101. (item) => item.parentIndex !== row.index
  2102. );
  2103. this.pickingPageNum = Math.ceil(
  2104. this.showPackingList.length / this.pageSize
  2105. );
  2106. console.log('包装当前页数');
  2107. console.log(this.pickingPageNum);
  2108. // 删除物料(获取相同物料)
  2109. let packingIndexs = this.packingList.map((item) => item.index);
  2110. this.materialList = this.materialList.filter((item) =>
  2111. packingIndexs.includes(item.parentIndex)
  2112. );
  2113. this.showMaterialList = this.showMaterialList.filter((item) =>
  2114. packingIndexs.includes(item.parentIndex)
  2115. );
  2116. this.materielPageNum = Math.ceil(
  2117. this.showMaterialList.length / this.pageSize
  2118. );
  2119. console.log('物料当前页数');
  2120. console.log(this.showMaterialList.length);
  2121. console.log(this.pageSize);
  2122. console.log(this.materielPageNum);
  2123. },
  2124. // 新增批量保存方法
  2125. async batchSave() {
  2126. try {
  2127. // 验证所有未保存的表单
  2128. await this.validateForm()
  2129. // 遍历所有产品进行保存
  2130. for (let i = 0; i < this.productList.length; i++) {
  2131. const row = this.productList[i]
  2132. if (!row.isSave) {
  2133. // 执行单个保存逻辑
  2134. await this.listSave(row, i)
  2135. }
  2136. }
  2137. } catch (error) {
  2138. this.$message.error('批量保存失败,请检查必填项')
  2139. }
  2140. },
  2141. //产品保存操作
  2142. async listSave(row, index) {
  2143. console.log('row22222222', row);
  2144. return new Promise(async (resolve, reject) => {
  2145. try {
  2146. await this.validateFormIndividually(index)
  2147. // 判断单位和计量单位是否为不拆物料层规格
  2148. let packingBoolen = !!this.getDict('不拆物料层规格', row.packingUnit)
  2149. .dictValue;
  2150. let measureBoolen = !!this.getDict('不拆物料层规格', row.measureUnit)
  2151. .dictValue;
  2152. console.log('packingBoolen---------', packingBoolen);
  2153. console.log('measureBoolen---------', measureBoolen);
  2154. let packingNum = 0;
  2155. // 处理单位为KG类的情况
  2156. if (packingBoolen) {
  2157. if (!row.isUnpack && row.packingUnit == '立方') {
  2158. packingNum = 1;
  2159. } else {
  2160. let filterArr = row.packingSpecificationOption.filter((item) => {
  2161. return (
  2162. item.packageUnit == row.packingUnit &&
  2163. item.packageUnit != item.conversionUnit
  2164. );
  2165. });
  2166. packingNum = Math.ceil(
  2167. row.packingQuantity / filterArr[0].packageCell
  2168. );
  2169. }
  2170. }
  2171. // 处理单位不为KG类,计量单位为KG类的情况
  2172. let measureNum = row.packingQuantity;
  2173. let num = 0;
  2174. if (measureBoolen) {
  2175. let splitIndex = row.packingSpecificationOption.findIndex(
  2176. (item) =>
  2177. item.conversionUnit == row.packingUnit &&
  2178. item.packageUnit != item.conversionUnit
  2179. );
  2180. for (; splitIndex > 1; splitIndex--) {
  2181. measureNum = this.$math.format(
  2182. measureNum *
  2183. row.packingSpecificationOption[splitIndex].packageCell,
  2184. 14
  2185. );
  2186. }
  2187. } else {
  2188. num = Math.ceil(
  2189. row.measureQuantity / row.packingSpecificationOption[1]?.packageCell
  2190. );
  2191. }
  2192. console.log(packingNum, measureNum, num, '加油加油加油')
  2193. if (row.packingSpecificationLabel?.length < 1) {
  2194. this.$message.error('请到主数据维护包装组信息!')
  2195. return;
  2196. }
  2197. // 不拆包
  2198. if (!row.isUnpack) {
  2199. if (row.packingUnit != row.measureUnit) {
  2200. let pNum = row.packingQuantity;
  2201. const { data } = await storageApi.getAssetNum([
  2202. {
  2203. assetCode: row.categoryCode + row.index,
  2204. batchNum: row.batchNo,
  2205. num: pNum,
  2206. }
  2207. ]);
  2208. this.generateWrappers(row, index, data)
  2209. } else {
  2210. let pNum = 0;
  2211. const { data } = await storageApi.getAssetNum([
  2212. {
  2213. assetCode: row.categoryCode + row.index,
  2214. batchNum: row.batchNo,
  2215. num: pNum,
  2216. }
  2217. ]);
  2218. }
  2219. } else {
  2220. //拆包
  2221. const { data } = await storageApi.getAssetNum([
  2222. {
  2223. assetCode: row.categoryCode + row.index,
  2224. batchNum: row.batchNo,
  2225. num: packingBoolen ? packingNum : measureBoolen ? measureNum : num,
  2226. }
  2227. ]);
  2228. this.generateWrappers(row, index, data);
  2229. }
  2230. this.$set(this.productList[index], 'isSave', true)
  2231. this.$set(this.productList[index], 'warehouseId', row.warehouseId);
  2232. this.$set(
  2233. this.productList[index],
  2234. 'warehouseName',
  2235. row.warehouseName
  2236. );
  2237. this.$set(this.productList[index], 'warehouseIds', row.warehouseId);
  2238. this.$set(
  2239. this.productList[index],
  2240. 'warehouseNames',
  2241. row.warehouseName
  2242. );
  2243. resolve()
  2244. } catch (error) {
  2245. reject(error)
  2246. }
  2247. })
  2248. },
  2249. // 生成包装
  2250. generateWrappers(row, productIndex, packingCodeList) {
  2251. console.log(packingCodeList, 'packingCodeListROW', row.measureType)
  2252. //计量类型不是数量
  2253. if (!row.isUnpack && row.measureType != 1) {
  2254. // 计量单位=包装单位,则不生成包装层数据
  2255. if (row.measureUnit == row.packingUnit) {
  2256. // 直接生成物品层数据
  2257. this.productList[productIndex].measureQuantity = row.measureQuantity;
  2258. this.productList[productIndex].weight = row.weight;
  2259. return;
  2260. }
  2261. }
  2262. console.log('包装数据--------', row);
  2263. // console.log('包装规格----', row.packingSpecificationOption);
  2264. console.log('计量单位----', row.measureUnit);
  2265. let packingList = [];
  2266. let obj = this.getNowDate();
  2267. let productionDate = '';
  2268. let purchaseDate = '';
  2269. if (this.formData.bizType == '1') {
  2270. // 生产入库
  2271. productionDate = `${obj.year}-${obj.month}-${obj.strDate} ${obj.hour}:${obj.minute}:${obj.second}`;
  2272. this.curDateType = 'productionDate';
  2273. } else if (this.formData.bizType == '2') {
  2274. // 采购入库
  2275. purchaseDate = `${obj.year}-${obj.month}-${obj.strDate} ${obj.hour}:${obj.minute}:${obj.second}`;
  2276. this.curDateType = 'purchaseDate';
  2277. }
  2278. // 判断单位和计量单位是否为不拆物料层规格
  2279. let packingBoolen = !!this.getDict('不拆物料层规格', row.packingUnit)
  2280. .dictValue;
  2281. let measureBoolen = !!this.getDict('不拆物料层规格', row.measureUnit)
  2282. .dictValue;
  2283. let num = row.packingQuantity;
  2284. let filterArr = [];
  2285. // 处理单位为KG类的情况
  2286. if (packingBoolen) {
  2287. console.log(packingBoolen, 'packingBoolenpackingBoolenpackingBoolenpackingBoolenpackingBoolenpackingBoolen')
  2288. if (!row.isUnpack && row.packingUnit == '立方') {
  2289. num = 1;
  2290. } else {
  2291. filterArr = row.packingSpecificationOption.filter((item) => {
  2292. return (
  2293. item.packageUnit == row.packingUnit &&
  2294. item.packageUnit != item.conversionUnit
  2295. );
  2296. });
  2297. num = Math.ceil(row.packingQuantity / filterArr[0]?.packageCell);
  2298. }
  2299. } else {
  2300. if (measureBoolen) {
  2301. // 处理单位不为KG类,计量单位为KG类的情况
  2302. let splitIndex = row.packingSpecificationOption.findIndex(
  2303. (item) =>
  2304. item.conversionUnit == row.packingUnit &&
  2305. item.packageUnit != item.conversionUnit
  2306. );
  2307. for (; splitIndex > 1; splitIndex--) {
  2308. num = this.$math.format(
  2309. num * row.packingSpecificationOption[splitIndex].packageCell,
  2310. 14
  2311. );
  2312. }
  2313. } else {
  2314. num = Math.ceil(
  2315. row.measureQuantity / row.packingSpecificationOption[1]?.packageCell
  2316. );
  2317. filterArr = row.packingSpecificationOption.filter((item) => {
  2318. return (
  2319. item.packageUnit == row.packingUnit &&
  2320. item.packageUnit != item.conversionUnit
  2321. );
  2322. });
  2323. }
  2324. }
  2325. console.log('num-----------', num);
  2326. if (!row.isUnpack) {
  2327. let packingUnit = !row.isUnpack ? row.packingUnit : row.packingSpecificationOption[1].conversionUnit;
  2328. let packingQuantity = row.packingQuantity / packingCodeList.length;
  2329. let measureUnit = row.measureUnit;
  2330. let measureQuantity = row.measureQuantity / row.packingQuantity;
  2331. for (let index = 0; index < packingCodeList.length; index++) {
  2332. let item = {
  2333. index: row.index + '-' + index, // 包装索引
  2334. warehouseId: row.warehouseId, // 仓库id
  2335. warehouseName: row.warehouseName, // 仓库名称
  2336. categoryName: row.categoryName, // 产品名称
  2337. categoryCode: row.categoryCode, // 产品编码
  2338. categoryModel: row.categoryModel, // 物品型号
  2339. specification: row.specification, // 规格
  2340. supplierCode: row.supplierCode, // 供应商编码
  2341. brandNum: row.brandNum, // 牌号
  2342. parentIndex: row.index, // 产品索引
  2343. batchNo: row.batchNo, // 批次号
  2344. packageNo: packingCodeList[index]?.onlyCode, // 包装编码
  2345. packingQuantity: packingQuantity, // 包装数量
  2346. packingUnit: packingUnit,
  2347. measureQuantity: measureQuantity, // 计量数量
  2348. measureUnit: measureUnit, // 计量单位
  2349. weight: 0, // 重量
  2350. packingSpecificationOption: row.packingSpecificationOption, // 包装规格
  2351. weightUnit: row.weightUnit, // 重量单位
  2352. netWeight: row.netWeight, // 净重
  2353. barcodes: '', // 发货条码
  2354. clientCode: row.extInfo ? row.extInfo.clientCode : '', // 客户代号
  2355. materielDesignation: row.extInfo ? row.extInfo.materielCode : '', // 物料代号
  2356. supplierName: row.supplierName, // 供应商名称
  2357. supplierCode: row.supplierCode, // 供应商代号
  2358. engrave: '', // 刻码
  2359. isUnpack: row.isUnpack, // 是否允许拆包
  2360. productionDate: productionDate, // 生产日期
  2361. purchaseDate: purchaseDate, // 采购时间
  2362. result: 1, // 结果(1合格 2不合格)
  2363. status: 2 // 状态(0=未质检 1待检 2已检)
  2364. };
  2365. let outBoolen = !!this.getDict('不拆物料层规格', item.measureUnit)
  2366. .dictValue;
  2367. if (outBoolen) {
  2368. // 计量单位为KG类,直接替换
  2369. item.weight = item.measureQuantity ? Number(item.measureQuantity) : 0;
  2370. } else {
  2371. console.log('计量单位为不为KG类======================');
  2372. // 计量单位为不为KG类,重新统计计算
  2373. let inBoolen = !!this.getDict(
  2374. '不拆物料层规格',
  2375. item.packingSpecificationOption[0].packageUnit
  2376. ).dictValue;
  2377. let startIndex = item.packingSpecificationOption.findIndex(
  2378. (ite) => {
  2379. return (
  2380. item.measureUnit == ite.packingUnit &&
  2381. ite.packingUnit != ite.conversionUnit
  2382. );
  2383. }
  2384. );
  2385. let endIndex = item.packingSpecificationOption.findIndex(
  2386. (ite) => item.packingUnit == ite.conversionUnit
  2387. );
  2388. if (measureBoolen) {
  2389. let total = item.packingQuantity ? Number(item.packingQuantity) : 0;
  2390. for (; startIndex < endIndex; endIndex--) {
  2391. total = this.$math.format(
  2392. item.packingSpecificationOption[endIndex].packageCell * total,
  2393. 14
  2394. );
  2395. }
  2396. if (inBoolen) {
  2397. // 第二层为KG类
  2398. item.weight = total ? Number(total) : 0;
  2399. } else {
  2400. // 第二层不为KG类
  2401. item.weight = this.$math.format(total * item.netWeight, 14);
  2402. }
  2403. } else if (!measureBoolen) {
  2404. if (inBoolen) {
  2405. // 第二层为KG类
  2406. item.weight = item.measureQuantity ? Number(item.measureQuantity) : 0;
  2407. } else {
  2408. // 第二层不为KG类
  2409. if (row.singleWeight && item.measureQuantity) {
  2410. item.weight = Number(item.measureQuantity) * Number(row.singleWeight);
  2411. } else {
  2412. item.weight = 0;
  2413. }
  2414. }
  2415. }
  2416. }
  2417. packingList.push(item);
  2418. }
  2419. } else {
  2420. console.log('拆包处理', row);
  2421. for (let index = 0; index < num; index++) {
  2422. let measureQuantity = 1;
  2423. let packingQuantity = 1;
  2424. let packingUnit = row.packingUnit;
  2425. // 处理单位为KG类,计算每桶KG值
  2426. if (packingBoolen) {
  2427. if (!row.isUnpack && row.packingUnit == '立方') {
  2428. let result = row.packingQuantity / row.packingSpecificationOption[1].packageCell;
  2429. packingQuantity = Math.ceil(result * 100) / 100;
  2430. console.log(packingQuantity, '包装数oppppp量')
  2431. measureQuantity = row.measureQuantity
  2432. console.log(measureQuantity, '计量数oppppp量')
  2433. packingUnit = row.packingUnit;
  2434. } else {
  2435. measureQuantity =
  2436. Number(row.packingQuantity) >
  2437. this.$math.format(filterArr[0].packageCell * (index + 1), 14)
  2438. ? filterArr[0].packageCell
  2439. : Number(row.packingQuantity) -
  2440. this.$math.format(filterArr[0].packageCell * index, 14);
  2441. }
  2442. } else {
  2443. if (row.isUnpack == 1) {
  2444. console.log('1 拆--------', measureBoolen)
  2445. if (measureBoolen) {
  2446. // 处理单位不为KG类,计量单位为KG类的情况
  2447. let splitIndex = row.packingSpecificationOption.findIndex(
  2448. (item) =>
  2449. item.conversionUnit == row.packingUnit &&
  2450. item.packageUnit != item.conversionUnit
  2451. );
  2452. for (; splitIndex > 0; splitIndex--) {
  2453. measureQuantity = this.$math.format(
  2454. measureQuantity *
  2455. row.packingSpecificationOption[splitIndex].packageCell,
  2456. 14
  2457. );
  2458. }
  2459. console.log('2 拆--------', measureQuantity)
  2460. } else {
  2461. measureQuantity = row.packingSpecificationOption[1]?.packageCell;
  2462. console.log('3 拆--------', measureQuantity)
  2463. }
  2464. } else {
  2465. console.log('4 拆--------')
  2466. if (row.packingQuantity) {
  2467. measureQuantity = row.measureQuantity / row.packingQuantity;
  2468. }
  2469. }
  2470. console.log(measureQuantity, 'measureQuantity')
  2471. }
  2472. console.log(filterArr[0], 'filterArr[0]')
  2473. let item = {
  2474. index: row.index + '-' + index, // 包装索引
  2475. warehouseId: row.warehouseId, // 仓库id
  2476. warehouseName: row.warehouseName, // 仓库名称
  2477. categoryName: row.categoryName, // 产品名称
  2478. categoryCode: row.categoryCode, // 产品编码
  2479. categoryModel: row.categoryModel, // 物品型号
  2480. specification: row.specification, // 规格
  2481. supplierCode: row.supplierCode, // 供应商编码
  2482. brandNum: row.brandNum, // 牌号
  2483. parentIndex: row.index, // 产品索引
  2484. batchNo: row.batchNo, // 批次号
  2485. packageNo: packingCodeList[index]?.onlyCode, // 包装编码
  2486. packingQuantity: packingQuantity, // 包装数量
  2487. measureQuantity: row.isUnpack
  2488. ? packingBoolen
  2489. ? measureQuantity
  2490. : measureBoolen
  2491. ? row.packingSpecificationOption[1]
  2492. ? row.packingSpecificationOption[1].packageCell
  2493. : row.packingSpecificationOption[0].packageCell
  2494. : measureQuantity
  2495. : measureQuantity, // 计量数量
  2496. measureUnit: row.isUnpack
  2497. ? measureBoolen
  2498. ? row.packingSpecificationOption[1]
  2499. ? row.packingSpecificationOption[1].packageUnit
  2500. : row.packingSpecificationOption[0].packageUnit
  2501. : row.measureUnit
  2502. : row.measureUnit, // 计量单位
  2503. weight: 0, // 重量
  2504. packingSpecificationOption: row.packingSpecificationOption, // 包装规格
  2505. weightUnit: row.weightUnit, // 重量单位
  2506. netWeight: row.netWeight, // 净重
  2507. barcodes: '', // 发货条码
  2508. clientCode: row.extInfo ? row.extInfo.clientCode : '', // 客户代号
  2509. materielDesignation: row.extInfo ? row.extInfo.materielCode : '', // 物料代号
  2510. supplierName: row.supplierName, // 供应商名称
  2511. supplierCode: row.supplierCode, // 供应商代号
  2512. engrave: '', // 刻码
  2513. isUnpack: row.isUnpack, // 是否允许拆包
  2514. productionDate: productionDate, // 生产日期
  2515. purchaseDate: purchaseDate, // 采购时间
  2516. result: 1, // 结果(1合格 2不合格)
  2517. status: 2 // 状态(0=未质检 1待检 2已检)
  2518. };
  2519. /**
  2520. * packingUnit: row.isUnpack ? packingBoolen ? filterArr[0].conversionUnit : measureBoolen ? row.packingSpecificationOption[2] ? row.packingSpecificationOption[2].conversionUnit
  2521. * : row.packingSpecificationOption[1].conversionUnit: row.measureUnit: packingBoolen ? filterArr[0].conversionUnit : row.packingUnit,
  2522. */
  2523. if (row.isUnpack) {
  2524. // 第二层条件: packingBoolen
  2525. if (packingBoolen) {
  2526. // 空值保护: 确保 filterArr[0] 存在
  2527. item.packingUnit = filterArr?.[0]?.conversionUnit;
  2528. } else {
  2529. // 第三层条件: measureBoolen
  2530. if (measureBoolen) {
  2531. // 处理 packingSpecificationOption 的索引
  2532. const option = row.packingSpecificationOption?.[1] || row.packingSpecificationOption?.[0];
  2533. item.packingUnit = option?.conversionUnit;
  2534. } else {
  2535. item.packingUnit = row.packingSpecificationOption?.[1].conversionUnit;
  2536. }
  2537. }
  2538. } else {
  2539. // 第二层条件: packingBoolen (isUnpack 为 false 时的分支)
  2540. if (packingBoolen) {
  2541. item.packingUnit = filterArr?.[0]?.conversionUnit;
  2542. } else {
  2543. item.packingUnit = row.packingUnit;
  2544. }
  2545. }
  2546. let outBoolen = !!this.getDict('不拆物料层规格', item.measureUnit)
  2547. .dictValue;
  2548. if (outBoolen) {
  2549. // 计量单位为KG类,直接替换
  2550. item.weight = item.measureQuantity ? Number(item.measureQuantity) : 0;
  2551. } else {
  2552. console.log('计量单位为不为KG类======================');
  2553. // 计量单位为不为KG类,重新统计计算
  2554. let inBoolen = !!this.getDict(
  2555. '不拆物料层规格',
  2556. item.packingSpecificationOption[0].packageUnit
  2557. ).dictValue;
  2558. let startIndex = item.packingSpecificationOption.findIndex(
  2559. (ite) => {
  2560. return (
  2561. item.measureUnit == ite.packingUnit &&
  2562. ite.packingUnit != ite.conversionUnit
  2563. );
  2564. }
  2565. );
  2566. let endIndex = item.packingSpecificationOption.findIndex(
  2567. (ite) => item.packingUnit == ite.conversionUnit
  2568. );
  2569. if (measureBoolen) {
  2570. let total = item.packingQuantity ? Number(item.packingQuantity) : 0;
  2571. for (; startIndex < endIndex; endIndex--) {
  2572. total = this.$math.format(
  2573. item.packingSpecificationOption[endIndex].packageCell * total,
  2574. 14
  2575. );
  2576. }
  2577. if (inBoolen) {
  2578. // 第二层为KG类
  2579. item.weight = total ? Number(total) : 0;
  2580. } else {
  2581. // 第二层不为KG类
  2582. item.weight = this.$math.format(total * item.netWeight, 14);
  2583. }
  2584. } else if (!measureBoolen) {
  2585. if (inBoolen) {
  2586. // 第二层为KG类
  2587. item.weight = item.measureQuantity ? Number(item.measureQuantity) : 0;
  2588. } else {
  2589. // 第二层不为KG类
  2590. if (row.singleWeight && item.measureQuantity) {
  2591. item.weight = Number(item.measureQuantity) * Number(row.singleWeight);
  2592. } else {
  2593. item.weight = 0;
  2594. }
  2595. }
  2596. }
  2597. }
  2598. packingList.push(item);
  2599. }
  2600. const existingIndex = this.packingList.findIndex(p =>
  2601. p.parentIndex === row.index
  2602. );
  2603. if (existingIndex > -1) {
  2604. this.packingList.splice(existingIndex, 1); // 移除旧数据
  2605. }
  2606. }
  2607. console.log(productIndex, 'productIndex')
  2608. // 单独点击保存并插入对应位置(包装)
  2609. if (productIndex == 0) {
  2610. this.packingList.splice(productIndex, 0, ...packingList);
  2611. } else {
  2612. let packingIndex = this.packingList.findLastIndex(
  2613. (item) =>
  2614. item.parentIndex == this.productList[productIndex - 1].index
  2615. );
  2616. this.packingList.splice(packingIndex + 1, 0, ...packingList);
  2617. }
  2618. const lastIndex = this.packingList.length - 1
  2619. let remainder = row.measureQuantity % row.packingSpecificationOption[1]?.packageCell
  2620. console.log(remainder, 'remainder')
  2621. if (remainder > 0) {
  2622. this.$set(this.packingList[lastIndex], 'measureQuantity', remainder)
  2623. }
  2624. },
  2625. //入库明细删除
  2626. listDel(row, index) {
  2627. this.productList.splice(index, 1);
  2628. this.deletePackingAndMaterial(row);
  2629. },
  2630. // 打开仓库弹框
  2631. handleWareHouse(row, idx, type) {
  2632. console.log(row, 'row')
  2633. if (row.packingSpecificationLabel?.length < 1) {
  2634. this.$message.error('请到主数据维护包装组信息!')
  2635. return;
  2636. }
  2637. if (row.isSave) {
  2638. return false;
  2639. }
  2640. let packingBoolen = !!this.getDict('不拆物料层规格', row.packingUnit)
  2641. .dictValue;
  2642. let measureBoolen = !!this.getDict('不拆物料层规格', row.measureUnit)
  2643. .dictValue;
  2644. console.log(packingBoolen, 'packingBoolen')
  2645. console.log(measureBoolen, 'measureBoolen')
  2646. //行内选择仓库
  2647. if (idx > -1 && type != 'batch') {
  2648. if (row.packingQuantity > 0) {
  2649. //不拆
  2650. if (!row.isUnpack) {
  2651. //计量和包装单位相同
  2652. if (row.measureUnit == row.packingUnit) {
  2653. let pNum = 0;
  2654. let mNum = row.measureQuantity
  2655. this.$refs.wareHouseDailogRef.open(
  2656. pNum,
  2657. mNum,
  2658. idx,
  2659. row.warehouseId,
  2660. row.warehouseName + '',
  2661. row.categoryLevelPathIdParent
  2662. );
  2663. } else {
  2664. let pNum = row.packingQuantity;
  2665. let mNum = row.measureQuantity
  2666. this.$refs.wareHouseDailogRef.open(
  2667. pNum,
  2668. mNum,
  2669. idx,
  2670. row.warehouseId,
  2671. row.warehouseName + '',
  2672. row.categoryLevelPathIdParent
  2673. );
  2674. }
  2675. } else {
  2676. if (packingBoolen) {
  2677. console.log(packingBoolen, 'packingBoolen', row.packageUnit, row.isUnpack);
  2678. let filterArr = row.packingSpecificationOption.filter((item) => {
  2679. return (
  2680. item.packageUnit == row.packingUnit &&
  2681. item.packageUnit != item.conversionUnit
  2682. );
  2683. });
  2684. let num = Math.ceil(
  2685. row.packingQuantity / filterArr[0].packageCell
  2686. );
  2687. this.$refs.wareHouseDailogRef.open(
  2688. num,
  2689. row.measureQuantity,
  2690. idx,
  2691. row.warehouseId,
  2692. row.warehouseName + '',
  2693. row.categoryLevelPathIdParent
  2694. );
  2695. } else {
  2696. console.log(measureBoolen, 'measureBoolen');
  2697. let num = row.packingQuantity;
  2698. if (measureBoolen) {
  2699. let splitIndex = row.packingSpecificationOption.findIndex(
  2700. (item) =>
  2701. item.conversionUnit == row.packingUnit &&
  2702. item.packageUnit != item.conversionUnit
  2703. );
  2704. for (; splitIndex > 1; splitIndex--) {
  2705. num = this.$math.format(
  2706. num *
  2707. row.packingSpecificationOption[splitIndex].packageCell,
  2708. 14
  2709. );
  2710. }
  2711. this.$refs.wareHouseDailogRef.open(
  2712. num,
  2713. row.measureQuantity,
  2714. idx,
  2715. row.warehouseId,
  2716. row.warehouseName + '',
  2717. row.categoryLevelPathIdParent
  2718. );
  2719. } else {
  2720. if (row.measureType != 1 && row.measureUnit == row.packingUnit) {
  2721. let pNum = 0;
  2722. let mNum = row.measureQuantity
  2723. this.$refs.wareHouseDailogRef.open(
  2724. pNum,
  2725. mNum,
  2726. idx,
  2727. row.warehouseId,
  2728. row.warehouseName + '',
  2729. row.categoryLevelPathIdParent
  2730. );
  2731. } else {
  2732. let num = Math.ceil(
  2733. row.measureQuantity / row.packingSpecificationOption[1]?.packageCell
  2734. );
  2735. console.log(num, 'num')
  2736. this.$refs.wareHouseDailogRef.open(
  2737. num,
  2738. row.measureQuantity,
  2739. idx,
  2740. row.warehouseId,
  2741. row.warehouseName + '',
  2742. row.categoryLevelPathIdParent);
  2743. }
  2744. }
  2745. }
  2746. }
  2747. } else {
  2748. this.$message.error('请先填写包装数量!');
  2749. }
  2750. } else {
  2751. //批量
  2752. console.log(row, `row`)
  2753. console.log(idx, `idx`)
  2754. console.log(type, 'type')
  2755. // 批量设置
  2756. if (row.some(item => !item.packingQuantity)) {
  2757. this.$message.error('请先填写所有行的包装数量!');
  2758. return;
  2759. }
  2760. for (let i = 0; i < row.length; i++) {
  2761. //测量单位等于包装单位
  2762. if (row[i].measureType != 1 && row[i].measureUnit === row[i].packingUnit) {
  2763. row[i].packingQuantity2 = 0;
  2764. console.log(row[i].packingQuantity2)
  2765. } else {
  2766. row[i].packingQuantity2 = Math.ceil(
  2767. row[i].measureQuantity / row[i].packingSpecificationOption[1]?.packageCell
  2768. );
  2769. console.log(row[i].packingQuantity2, '单位不一样')
  2770. }
  2771. }
  2772. console.log(row, 'rowrowrowrowrowrow我看看')
  2773. const pNum = row.reduce((sum, item) => {
  2774. if (item.packingQuantity2 !== undefined && item.packingQuantity2 !== null) {
  2775. return sum + Number(item.packingQuantity2);
  2776. }
  2777. return sum;
  2778. }, 0);
  2779. const mNum = row.reduce((sum, item) => {
  2780. if (item.measureQuantity !== undefined && item.measureQuantity !== null) {
  2781. return sum + Number(item.measureQuantity);
  2782. }
  2783. return sum;
  2784. }, 0);
  2785. console.log(pNum, 'pppp')
  2786. console.log(mNum, 'mmmmm')
  2787. this.$refs.wareHouseDailogRef.open(
  2788. pNum,
  2789. mNum
  2790. );
  2791. }
  2792. },
  2793. wareHouseSelection(argum, idx) {
  2794. console.log(argum, 'argumargumargumargumargumargum');
  2795. // 方便包装遍历获取仓库id和名称
  2796. let warehouseIds = [];
  2797. let warehouseNames = [];
  2798. argum.forEach((item) => {
  2799. console.log(item, 'itemitem')
  2800. for (let index = 0; index < item.packingQuantity; index++) {
  2801. warehouseIds.push(item.warehouseId);
  2802. warehouseNames.push(item.warehouseName);
  2803. }
  2804. });
  2805. console.log(idx, this.productList, 'idxidxidxidx')
  2806. if (idx > -1) {
  2807. this.$set(
  2808. this.productList[idx],
  2809. 'warehouseId',
  2810. argum.map((item) => item.warehouseId).join(',')
  2811. );
  2812. this.$set(
  2813. this.productList[idx],
  2814. 'warehouseName',
  2815. argum.map((item) => item.warehouseName).join(',')
  2816. );
  2817. this.$set(this.productList[idx], 'warehouseIds', warehouseIds);
  2818. this.$set(this.productList[idx], 'warehouseNames', warehouseNames);
  2819. console.log(this.productList, 'productList')
  2820. } else {
  2821. this.productList.map((item, index) => {
  2822. this.$set(
  2823. this.productList[index],
  2824. 'warehouseId',
  2825. argum.map((item) => item.warehouseId).join(',')
  2826. );
  2827. this.$set(
  2828. this.productList[index],
  2829. 'warehouseName',
  2830. argum.map((item) => item.warehouseName).join(',')
  2831. );
  2832. this.$set(this.productList[index], 'warehouseIds', warehouseIds);
  2833. this.$set(
  2834. this.productList[index],
  2835. 'warehouseNames',
  2836. warehouseNames
  2837. );
  2838. });
  2839. }
  2840. this.$forceUpdate();
  2841. },
  2842. // 生成物料
  2843. generateMaterial(row) {
  2844. let materialList = [];
  2845. for (let index = 0; index < row.measureQuantity; index++) {
  2846. materialList.push({
  2847. materialCode: row.packageNo + index.toString().padStart(4, '0'), // 物料编码
  2848. index: row.index + '——' + index, // 包装索引
  2849. warehouseId: row.warehouseId, // 仓库id
  2850. warehouseName: row.warehouseName, // 仓库名称
  2851. categoryName: row.categoryName, // 产品名称
  2852. categoryCode: row.categoryCode, // 产品编码
  2853. parentIndex: row.index, // 产品索引
  2854. batchNo: row.batchNo, // 批次号
  2855. packageNo: row.packageNo, // 包装编码
  2856. measureQuantity: 1, // 计量数量
  2857. measureUnit: row.measureUnit, // 计量单位
  2858. weight: Number(
  2859. this.$math.format(row.weight / row.packingQuantity, 14)
  2860. ), // 重量
  2861. weightUnit: row.weightUnit, // 重量单位
  2862. barcodes: '', // 发货条码
  2863. clientCode: '', // 客户代号
  2864. materielDesignation: '', // 物料代号
  2865. engrave: '', // 刻码
  2866. result: 1, // 结果(1合格 2不合格)
  2867. status: 2 // 状态(0=未质检 1待检 2已检)
  2868. });
  2869. }
  2870. return materialList;
  2871. },
  2872. // 设置时间
  2873. dateSetting() {
  2874. if (!this.packingListSelected.length) {
  2875. return this.$message.error(`请选择${this.title}明细!`);
  2876. }
  2877. this.dateVisible = true;
  2878. },
  2879. // 选择包装列表
  2880. handleSelectionChange(val) {
  2881. this.packingListSelected = val;
  2882. },
  2883. // 选择质检结果改变质检状态
  2884. changeWrapStatus(resultValue, row, type) {
  2885. console.log(resultValue);
  2886. switch (resultValue) {
  2887. case 0:
  2888. // 清空质检状态
  2889. row.status = 0;
  2890. break;
  2891. default:
  2892. // 默认已检质检状态
  2893. row.status = 2;
  2894. break;
  2895. }
  2896. if (type === '包装') {
  2897. this.packingResultCahnge(resultValue, row);
  2898. } else {
  2899. this.materialResultCahnge(resultValue, row);
  2900. }
  2901. }
  2902. }
  2903. };
  2904. </script>
  2905. <style lang="scss" scoped>
  2906. .inbound_details {
  2907. margin-top: 10px;
  2908. .el-form-item {
  2909. margin-bottom: 0 !important;
  2910. }
  2911. }
  2912. .el-form-item {
  2913. margin-bottom: 5px;
  2914. }
  2915. .right_control {
  2916. display: flex;
  2917. >button {
  2918. margin-left: 5px;
  2919. }
  2920. }
  2921. .storage_btn {
  2922. margin-top: 20px;
  2923. display: flex;
  2924. align-content: center;
  2925. justify-content: center;
  2926. }
  2927. .el-date-editor.el-input,
  2928. .el-date-editor.el-input__inner {
  2929. width: 100% !important;
  2930. }
  2931. .red_color {
  2932. color: red;
  2933. }
  2934. .wareHouse_style {
  2935. text-overflow: ellipsis;
  2936. overflow: hidden;
  2937. word-break: break-all;
  2938. white-space: nowrap;
  2939. }
  2940. </style>