storage.vue 124 KB

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