storage.vue 123 KB

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