storage_2.vue 86 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376
  1. <template>
  2. <div class="ele-body">
  3. <el-card shadow="never">
  4. <header-title title="基本信息"> </header-title>
  5. <el-form
  6. :model="formData"
  7. ref="formName"
  8. label-width="110px"
  9. :rules="rules"
  10. >
  11. <el-row :gutter="20">
  12. <el-col :span="6">
  13. <el-form-item label="物品类型" prop="extInfo.assetType">
  14. <el-select
  15. style="width: 100%"
  16. multiple
  17. v-model="formData.extInfo.assetType"
  18. placeholder="请选择"
  19. >
  20. <el-option
  21. v-for="item in goodsLists"
  22. :key="item.id"
  23. :label="item.name"
  24. :value="item.id"
  25. >
  26. </el-option>
  27. </el-select>
  28. </el-form-item>
  29. </el-col>
  30. <el-col :span="6">
  31. <el-form-item label="入库类型" prop="bizType">
  32. <el-select
  33. style="width: 100%"
  34. filterable
  35. placeholder="请选择"
  36. v-model="formData.bizType"
  37. clearable
  38. >
  39. <el-option
  40. v-for="item in sceneState"
  41. :key="item.code"
  42. :value="item.code"
  43. :label="item.label"
  44. ></el-option>
  45. </el-select> </el-form-item
  46. ></el-col>
  47. <el-col :span="6">
  48. <el-form-item label="单据来源" prop="documentSource">
  49. <el-input
  50. placeholder="请选择"
  51. v-model="formData.sourceBizNo"
  52. @click.native="openDocumentSourceDialog"
  53. >
  54. <el-button
  55. @click="clearDocumentSource"
  56. slot="append"
  57. icon="el-icon-circle-close"
  58. ></el-button>
  59. </el-input>
  60. </el-form-item>
  61. </el-col>
  62. <!-- <el-col :span="6">
  63. <el-form-item label="权属部门" prop="deptName">
  64. <el-input
  65. placeholder="权属部门"
  66. disabled
  67. v-model="formData.extInfo.deptName"
  68. clearable
  69. />
  70. </el-form-item>
  71. </el-col> -->
  72. <el-col :span="6">
  73. <el-form-item label="入库时间">
  74. <el-date-picker
  75. v-model="formData.storageTime"
  76. type="datetime"
  77. value-format="yyyy-MM-dd HH:mm:ss"
  78. placeholder="选择日期时间"
  79. >
  80. </el-date-picker></el-form-item
  81. ></el-col>
  82. <el-col :span="6">
  83. <el-form-item label="入库登记人">
  84. <el-input
  85. placeholder="登记人"
  86. disabled
  87. v-model="formData.extInfo.createUserName"
  88. clearable /></el-form-item
  89. ></el-col>
  90. <!-- <el-col :span="6" v-if="formData.bizType == 2">
  91. <el-form-item label="供应商" prop="supplierName">
  92. <el-input
  93. placeholder="请输入"
  94. clearable
  95. v-model="formData.extInfo.supplierName"
  96. />
  97. </el-form-item>
  98. </el-col> -->
  99. <el-col :span="6">
  100. <el-form-item label="送货人" prop="fromUser">
  101. <el-input
  102. placeholder="请输入"
  103. v-model="formData.fromUser"
  104. clearable
  105. /> </el-form-item
  106. ></el-col>
  107. <el-col :span="6">
  108. <el-form-item label="送货人联系方式" prop="deliveryPhone">
  109. <el-input
  110. placeholder="请输入"
  111. v-model="formData.extInfo.deliveryPhone"
  112. clearable /></el-form-item
  113. ></el-col>
  114. <el-col :span="6">
  115. <el-form-item label="备注" prop="remark">
  116. <el-input
  117. v-model="formData.remark"
  118. clearable
  119. type="textarea"
  120. placeholder="请详细说明"
  121. :rows="1"
  122. ></el-input>
  123. </el-form-item>
  124. </el-col>
  125. </el-row>
  126. </el-form>
  127. <div class="inbound_details">
  128. <header-title title="产品信息">
  129. <el-button type="primary" @click="addProduct">添加</el-button>
  130. </header-title>
  131. <div class="form_table">
  132. <el-form
  133. ref="productListRef"
  134. :model="{ productList: productList }"
  135. :show-message="false"
  136. >
  137. <el-button
  138. v-if="productList.length != 0"
  139. type="success"
  140. plain
  141. style="margin-bottom: 20px; float: right; margin-right: 20px"
  142. size="mini"
  143. @click="listSaveArrs"
  144. >批量保存</el-button
  145. >
  146. <el-table
  147. :header-cell-style="rowClass"
  148. :max-height="300"
  149. border
  150. ref="productListTable"
  151. :data="productList"
  152. tooltip-effect="dark"
  153. >
  154. <el-table-column
  155. label="序号"
  156. type="index"
  157. width="50"
  158. align="center"
  159. >
  160. </el-table-column>
  161. <el-table-column
  162. label="编码"
  163. prop="categoryCode"
  164. align="center"
  165. width="130"
  166. :show-overflow-tooltip="true"
  167. ></el-table-column>
  168. <el-table-column
  169. label="名称"
  170. align="center"
  171. width="200"
  172. prop="categoryName"
  173. :show-overflow-tooltip="true"
  174. ></el-table-column>
  175. <el-table-column
  176. label="型号"
  177. align="center"
  178. width="100"
  179. prop="categoryModel"
  180. :show-overflow-tooltip="true"
  181. ></el-table-column>
  182. <el-table-column
  183. label="规格"
  184. align="center"
  185. width="100"
  186. prop="specification"
  187. :show-overflow-tooltip="true"
  188. ></el-table-column>
  189. <el-table-column
  190. label="牌号"
  191. align="center"
  192. width="100"
  193. prop="brandNum"
  194. :show-overflow-tooltip="true"
  195. ></el-table-column>
  196. <el-table-column
  197. v-for="(item, index) in newColumns"
  198. :label="item.label"
  199. :align="item.align"
  200. :prop="item.prop"
  201. :show-overflow-tooltip="item.showOverflowTooltip"
  202. ></el-table-column>
  203. <el-table-column
  204. label="批次号"
  205. align="center"
  206. width="100"
  207. prop="batchNo"
  208. >
  209. <template slot-scope="{ row, $index }">
  210. <template v-if="row.isSave">
  211. {{ row.batchNo }}
  212. </template>
  213. <el-form-item
  214. v-else
  215. :prop="`productList.${$index}.batchNo`"
  216. required
  217. >
  218. <el-input
  219. :ref="'batchNo' + $index"
  220. @keyup.native="
  221. moveFocus($event, $index, 'batchNo', '产品', row)
  222. "
  223. v-model.number="row.batchNo"
  224. >
  225. </el-input>
  226. </el-form-item>
  227. </template>
  228. </el-table-column>
  229. <el-table-column
  230. label="最小包装单元"
  231. align="center"
  232. prop="minPackingQuantity"
  233. width="200"
  234. >
  235. <template slot-scope="{ row, $index }">
  236. <template v-if="row.isSave">
  237. {{ row.minPackingQuantity }}
  238. </template>
  239. <el-form-item
  240. v-else
  241. :prop="`productList.${$index}.minPackingQuantity`"
  242. required
  243. >
  244. <el-input
  245. type="number"
  246. :ref="'minPackingQuantity' + $index"
  247. @keyup.native="
  248. moveFocus(
  249. $event,
  250. $index,
  251. 'minPackingQuantity',
  252. '产品',
  253. row
  254. )
  255. "
  256. v-model="row.minPackingQuantity"
  257. @input="minPackingQuantityChange(row, $event, $index)"
  258. >
  259. <template slot="append">
  260. {{ row.measureUnit }} /{{ row.packingUnit }}
  261. </template>
  262. </el-input>
  263. </el-form-item>
  264. </template>
  265. </el-table-column>
  266. <el-table-column
  267. label="包装数量"
  268. prop="packingQuantity"
  269. width="150"
  270. align="center"
  271. >
  272. <template slot-scope="{ row, $index }">
  273. <template v-if="row.isSave">
  274. {{ row.packingQuantity }} {{ row.packingUnit }}
  275. </template>
  276. <el-form-item
  277. v-else
  278. :prop="`productList.${$index}.packingQuantity`"
  279. required
  280. >
  281. <el-input
  282. :ref="'packingQuantity' + $index"
  283. @keyup.native="
  284. moveFocus(
  285. $event,
  286. $index,
  287. 'packingQuantity',
  288. '产品',
  289. row
  290. )
  291. "
  292. v-model.number="row.packingQuantity"
  293. @input="packNum(row, $event, $index)"
  294. >
  295. <template slot="append">
  296. {{ row.packingUnit ? row.packingUnit : '/' }}
  297. </template>
  298. </el-input>
  299. </el-form-item>
  300. </template>
  301. </el-table-column>
  302. <el-table-column
  303. label="计量数量"
  304. prop="measureQuantity"
  305. :show-overflow-tooltip="true"
  306. >
  307. <template slot-scope="{ row, $index }">
  308. {{
  309. changeCount(
  310. $math.format(
  311. row.minPackingQuantity * row.packingQuantity,
  312. 14
  313. )
  314. )
  315. }}
  316. </template>
  317. </el-table-column>
  318. <el-table-column
  319. label="计量单位"
  320. prop="measureUnit"
  321. width="100"
  322. align="center"
  323. >
  324. <template slot-scope="{ row, $index }">
  325. <template>
  326. {{ row.measureUnit }}
  327. </template>
  328. </template>
  329. </el-table-column>
  330. <el-table-column
  331. label="重量"
  332. align="center"
  333. prop="weight"
  334. :show-overflow-tooltip="true"
  335. >
  336. <template slot-scope="{ row, $index }">
  337. {{ row.weight }}
  338. <template slot="append">
  339. {{ row.measureUnit }}
  340. </template>
  341. </template>
  342. </el-table-column>
  343. <el-table-column
  344. label="重量单位"
  345. align="center"
  346. prop="weightUnit"
  347. :show-overflow-tooltip="true"
  348. >
  349. <template slot-scope="{ row, $index }">
  350. {{ row.weightUnit }}
  351. <template slot="append"> </template>
  352. </template>
  353. </el-table-column>
  354. <el-table-column
  355. label="单价"
  356. prop="price"
  357. width="200"
  358. align="center"
  359. >
  360. <template slot-scope="{ row, $index }">
  361. <template v-if="row.isSave">
  362. {{ row.price }}元/{{ row.measureUnit }}
  363. </template>
  364. <el-form-item v-else>
  365. <el-input
  366. type="number"
  367. :ref="'price' + $index"
  368. @keyup.native="
  369. moveFocus($event, $index, 'price', '产品', row)
  370. "
  371. v-model.number="row.price"
  372. placeholder="非必填"
  373. @input="
  374. (value) => (row.price = value.replace(/[^0-9.]+/g, ''))
  375. "
  376. >
  377. <template slot="append">
  378. 元/{{ row.measureUnit }}
  379. </template>
  380. </el-input>
  381. </el-form-item>
  382. </template>
  383. </el-table-column>
  384. <el-table-column
  385. label="金额"
  386. align="center"
  387. prop="contentImage"
  388. :show-overflow-tooltip="true"
  389. >
  390. <template slot-scope="{ row, $index }">
  391. {{
  392. changeCount(
  393. calcSumTotal(
  394. row.packingQuantity,
  395. row.minPackingQuantity,
  396. row.price,
  397. row
  398. )
  399. )
  400. }}
  401. </template>
  402. </el-table-column>
  403. <el-table-column
  404. label="供应商"
  405. align="center"
  406. prop="supplierId"
  407. width="200"
  408. :show-overflow-tooltip="true"
  409. >
  410. <template slot-scope="{ row, $index }">
  411. <el-select
  412. @change="selectSupplier($event, row)"
  413. v-model="row.supplierId"
  414. placeholder="请选择"
  415. >
  416. <el-option
  417. v-for="item in row.supplierListOptions"
  418. :label="item.name"
  419. :value="item.id"
  420. :key="item.id"
  421. >
  422. </el-option>
  423. </el-select>
  424. </template>
  425. </el-table-column>
  426. <el-table-column
  427. label="仓库"
  428. align="center"
  429. prop="warehouseName"
  430. :show-overflow-tooltip="true"
  431. width="300"
  432. >
  433. <template slot-scope="{ row, $index }">
  434. <el-form-item
  435. :prop="`productList.${$index}.warehouseId`"
  436. required
  437. >
  438. <div
  439. :class="
  440. row.warehouseName
  441. ? 'wareHouse_style'
  442. : 'wareHouse_style red_color'
  443. "
  444. @click="handleWareHouse(row, $index)"
  445. >
  446. <span>
  447. {{
  448. row.warehouseName ? row.warehouseName : '请选择仓库'
  449. }}
  450. </span>
  451. </div>
  452. </el-form-item>
  453. </template>
  454. </el-table-column>
  455. <el-table-column
  456. label="采购原因"
  457. align="center"
  458. width="200"
  459. prop="purpose"
  460. :show-overflow-tooltip="true"
  461. >
  462. <template slot-scope="{ row, $index }">
  463. <template v-if="row.isSave">
  464. {{ row.purpose }}
  465. </template>
  466. <el-input
  467. v-else
  468. :ref="'purpose' + $index"
  469. @keyup.native="
  470. moveFocus($event, $index, 'purpose', '产品', row)
  471. "
  472. v-model="row.purpose"
  473. >
  474. </el-input>
  475. </template>
  476. </el-table-column>
  477. <el-table-column
  478. label="操作"
  479. width="200"
  480. fixed="right"
  481. align="center"
  482. >
  483. <template slot="header" slot-scope="scope"> 操作 </template>
  484. <template slot-scope="{ row, $index }">
  485. <el-button
  486. type="text"
  487. v-show="!row.isSave"
  488. @click="listSave(row, $index)"
  489. >保存</el-button
  490. >
  491. <el-button
  492. type="text"
  493. v-show="row.isSave"
  494. @click="listEdit(row, $index)"
  495. >编辑</el-button
  496. >
  497. <el-button type="text" @click="listDel(row, $index)"
  498. >删除</el-button
  499. >
  500. </template>
  501. </el-table-column>
  502. </el-table>
  503. </el-form>
  504. </div>
  505. </div>
  506. <div v-if="showPackingList.length > 0" class="inbound_details">
  507. <header-title :title="`包装明细`">
  508. <div class="switch_right">
  509. <el-button
  510. style="margin-left: 20px"
  511. type="text"
  512. @click="dateSetting"
  513. >批量设置{{
  514. curDateType === 'productionDate' ? '生产日期' : '采购日期'
  515. }}</el-button
  516. >
  517. </div>
  518. </header-title>
  519. <el-table
  520. v-if="isWrapTable"
  521. ref="packingListTable"
  522. :data="showPackingList"
  523. tooltip-effect="dark"
  524. :key="formData.bizType"
  525. :header-cell-style="rowClass"
  526. border
  527. style="width: 100%"
  528. stripe
  529. :max-height="300"
  530. v-el-table-infinite-scroll="pickingHandleScroll"
  531. @selection-change="handleSelectionChange"
  532. >
  533. <el-table-column
  534. fixed="left"
  535. type="selection"
  536. align="center"
  537. width="50"
  538. >
  539. </el-table-column>
  540. <el-table-column label="序号" type="index" width="50">
  541. </el-table-column>
  542. <el-table-column
  543. label="编码"
  544. prop="categoryCode"
  545. width="130"
  546. :show-overflow-tooltip="true"
  547. ></el-table-column>
  548. <el-table-column
  549. label="名称"
  550. prop="categoryName"
  551. width="150"
  552. :show-overflow-tooltip="true"
  553. ></el-table-column>
  554. <el-table-column
  555. label="批次号"
  556. prop="batchNo"
  557. width="70"
  558. ></el-table-column>
  559. <el-table-column
  560. :label="`包装编码`"
  561. prop="packageNo"
  562. width="200"
  563. :show-overflow-tooltip="true"
  564. ></el-table-column>
  565. <el-table-column
  566. label="包装数量"
  567. prop="packingQuantity"
  568. width="80"
  569. ></el-table-column>
  570. <el-table-column
  571. label="包装单位"
  572. prop="packingUnit"
  573. ></el-table-column>
  574. <el-table-column
  575. label="计量数量"
  576. prop="measureQuantity"
  577. :show-overflow-tooltip="true"
  578. ></el-table-column>
  579. <el-table-column
  580. label="计量单位"
  581. prop="measureUnit"
  582. ></el-table-column>
  583. <el-table-column label="允许拆包" prop="isUnpack">
  584. <template slot-scope="{ row, $index }">
  585. {{ row.isUnpack ? '是' : '否' }}
  586. </template>
  587. </el-table-column>
  588. <el-table-column
  589. label="仓库"
  590. :show-overflow-tooltip="true"
  591. prop="warehouseName"
  592. width="200"
  593. ></el-table-column>
  594. <el-table-column
  595. label="物料代号"
  596. prop="materielDesignation"
  597. width="130"
  598. >
  599. <template slot-scope="{ row, $index }">
  600. <el-input
  601. v-if="!row.isPack"
  602. :ref="'packing_materielDesignation' + $index"
  603. @keyup.native="
  604. moveFocus(
  605. $event,
  606. $index,
  607. 'packing_materielDesignation',
  608. '包装',
  609. row
  610. )
  611. "
  612. v-model="row.materielDesignation"
  613. ></el-input>
  614. <span v-else>{{ row.materielDesignation }}</span>
  615. </template>
  616. </el-table-column>
  617. <el-table-column label="客户代号" prop="clientCode">
  618. <template slot-scope="{ row, $index }">
  619. <el-input
  620. v-if="!row.isPack"
  621. :ref="'packing_clientCode' + $index"
  622. @keyup.native="
  623. moveFocus($event, $index, 'packing_clientCode', '包装', row)
  624. "
  625. v-model="row.clientCode"
  626. ></el-input>
  627. <span v-else> {{ row.clientCode }}</span>
  628. </template>
  629. </el-table-column>
  630. <el-table-column label="刻码" prop="engrave" width="140">
  631. <template slot-scope="{ row, $index }">
  632. <el-input
  633. v-if="!row.isPack"
  634. :ref="'packing_engrave' + $index"
  635. @keyup.native="
  636. moveFocus($event, $index, 'packing_engrave', '包装', row)
  637. "
  638. v-model="row.engrave"
  639. ></el-input>
  640. <span v-else>{{ row.engrave }}</span>
  641. </template>
  642. </el-table-column>
  643. <el-table-column label="重量" prop="weight" width="100">
  644. <template slot-scope="{ row, $index }">
  645. <el-input
  646. v-if="!row.isPack && row.measureUnit != row.weightUnit"
  647. :ref="'packing_weight' + $index"
  648. @keyup.native="
  649. moveFocus($event, $index, 'packing_weight', '包装', row)
  650. "
  651. v-model.number="row.weight"
  652. @input="weightInput($event, row, '包装')"
  653. ></el-input>
  654. <span v-else>{{ row.weight }}</span>
  655. </template>
  656. </el-table-column>
  657. <el-table-column label="重量单位" prop="weightUnit">
  658. <template slot-scope="{ row }">
  659. {{ row.weightUnit }}
  660. </template>
  661. </el-table-column>
  662. <el-table-column
  663. v-if="!Number(form.isQmsCheck)"
  664. label="质检结果"
  665. prop="result"
  666. width="120"
  667. >
  668. <template slot-scope="{ row }">
  669. <el-select
  670. v-if="!row.isPack"
  671. @change="changeWrapStatus($event, row, '包装')"
  672. v-model="row.result"
  673. placeholder="请选择"
  674. >
  675. <el-option
  676. v-for="item in qualityResultsOptions"
  677. :label="item.label"
  678. :value="item.value"
  679. :key="item.value"
  680. >
  681. </el-option>
  682. </el-select>
  683. <span v-else>{{ qualityResults[row.result] }}</span>
  684. </template>
  685. </el-table-column>
  686. <el-table-column label="质检状态" prop="status" width="120">
  687. <template slot-scope="{ row }">
  688. <span>{{ qualityStatus[row.status] }}</span>
  689. </template>
  690. </el-table-column>
  691. <el-table-column label="生产日期" prop="" width="220">
  692. <template slot="header" slot-scope="scope">
  693. <el-select filterable v-model="curDateType">
  694. <el-option value="productionDate" label="生产日期"></el-option>
  695. <el-option value="purchaseDate" label="采购日期"></el-option>
  696. </el-select>
  697. </template>
  698. <template slot-scope="{ row }">
  699. <template v-if="formData.bizType == 5">
  700. {{ row[curDateType] }}
  701. </template>
  702. <el-date-picker
  703. v-else
  704. :disabled="row.isPack"
  705. size="small"
  706. v-model="row[curDateType]"
  707. type="datetime"
  708. value-format="yyyy-MM-dd HH:mm:ss"
  709. placeholder="选择日期"
  710. >
  711. </el-date-picker>
  712. </template>
  713. </el-table-column>
  714. <!-- <el-table-column label="操作" width="120" fixed="right">
  715. <template slot-scope="{ row, $index }">
  716. <el-button type="text" @click="wrapDelete(row, $index)">
  717. 删除
  718. </el-button>
  719. </template>
  720. </el-table-column> -->
  721. </el-table>
  722. </div>
  723. <div v-if="showMaterialList.length > 0" class="inbound_details">
  724. <header-title :title="`物料明细`"></header-title>
  725. <el-table
  726. ref="materialListTable"
  727. :data="showMaterialList"
  728. tooltip-effect="dark"
  729. :key="formData.bizType"
  730. :header-cell-style="rowClass"
  731. border
  732. style="width: 100%"
  733. stripe
  734. :max-height="300"
  735. v-el-table-infinite-scroll="materielHandleScroll"
  736. >
  737. <el-table-column label="序号" type="index" width="50">
  738. </el-table-column>
  739. <el-table-column
  740. label="编码"
  741. prop="categoryCode"
  742. width="130"
  743. :show-overflow-tooltip="true"
  744. ></el-table-column>
  745. <el-table-column
  746. label="名称"
  747. prop="categoryName"
  748. width="150"
  749. :show-overflow-tooltip="true"
  750. ></el-table-column>
  751. <el-table-column
  752. label="批次号"
  753. prop="batchNo"
  754. width="70"
  755. ></el-table-column>
  756. <el-table-column
  757. label="物料编码"
  758. prop="materialCode"
  759. width="200"
  760. :show-overflow-tooltip="true"
  761. ></el-table-column>
  762. <el-table-column
  763. label="计量数量"
  764. prop="measureQuantity"
  765. width="90"
  766. :show-overflow-tooltip="true"
  767. ></el-table-column>
  768. <el-table-column
  769. width="80"
  770. label="计量单位"
  771. prop="measureUnit"
  772. ></el-table-column>
  773. <el-table-column
  774. label="物料代号"
  775. prop="materielDesignation"
  776. width="130"
  777. >
  778. <template slot-scope="{ row, $index }">
  779. <el-input
  780. v-if="!row.isPack"
  781. :ref="'material_materielDesignation' + $index"
  782. @keyup.native="
  783. moveFocus(
  784. $event,
  785. $index,
  786. 'material_materielDesignation',
  787. '物料',
  788. row
  789. )
  790. "
  791. v-model="row.materielDesignation"
  792. ></el-input>
  793. <span v-else>{{ row.materielDesignation }}</span>
  794. </template>
  795. </el-table-column>
  796. <el-table-column label="客户代号" prop="clientCode">
  797. <template slot-scope="{ row, $index }">
  798. <el-input
  799. v-if="!row.isPack"
  800. :ref="'material_clientCode' + $index"
  801. @keyup.native="
  802. moveFocus($event, $index, 'material_clientCode', '物料', row)
  803. "
  804. v-model="row.clientCode"
  805. ></el-input>
  806. <span v-else>{{ row.clientCode }}</span>
  807. </template>
  808. </el-table-column>
  809. <el-table-column label="刻码" prop="engrave" width="140">
  810. <template slot-scope="{ row, $index }">
  811. <el-input
  812. v-if="!row.isPack"
  813. :ref="'material_engrave' + $index"
  814. @keyup.native="
  815. moveFocus($event, $index, 'material_engrave', '物料', row)
  816. "
  817. v-model="row.engrave"
  818. ></el-input>
  819. <span v-else>{{ row.engrave }}</span>
  820. </template>
  821. </el-table-column>
  822. <el-table-column label="重量" prop="weight" width="100">
  823. <template slot-scope="{ row, $index }">
  824. <el-input
  825. v-if="!row.isPack && row.measureUnit != row.weightUnit"
  826. :ref="'material_weight' + $index"
  827. @keyup.native="
  828. moveFocus($event, $index, 'material_weight', '物料', row)
  829. "
  830. @input="weightInput($event, row, '物料')"
  831. v-model.number="row.weight"
  832. ></el-input>
  833. <span v-else>{{ row.weight }}</span>
  834. </template>
  835. </el-table-column>
  836. <el-table-column
  837. label="重量单位"
  838. prop="weightUnit"
  839. width="100"
  840. ></el-table-column>
  841. <el-table-column
  842. v-if="!Number(form.isQmsCheck)"
  843. label="质检结果"
  844. prop="result"
  845. width="120"
  846. >
  847. <template slot-scope="{ row }">
  848. <el-select
  849. v-if="!row.isPack"
  850. @change="changeWrapStatus($event, row, '物料')"
  851. v-model="row.result"
  852. placeholder="请选择"
  853. >
  854. <el-option
  855. v-for="item in qualityResultsOptions"
  856. :label="item.label"
  857. :value="item.value"
  858. :key="item.value"
  859. >
  860. </el-option>
  861. </el-select>
  862. <span v-else>{{ qualityResults[row.result] }}</span>
  863. </template>
  864. </el-table-column>
  865. <el-table-column label="质检状态" prop="status" width="120">
  866. <template slot-scope="{ row }">
  867. <span>{{ qualityStatus[row.status] }}</span>
  868. </template>
  869. </el-table-column>
  870. <!-- <el-table-column label="操作" width="120" fixed="right">
  871. <template slot-scope="{ row, $index }">
  872. <el-button type="text" @click="materialDelete(row, $index)">
  873. 删除
  874. </el-button>
  875. </template>
  876. </el-table-column> -->
  877. </el-table>
  878. <!-- <div v-if="showPackingList.length > 0" class="storage_btn">
  879. <el-button type="primary" :loading="saveLoading" @click="storage"
  880. >入库</el-button
  881. >
  882. </div> -->
  883. </div>
  884. </el-card>
  885. <!-- 产品选择弹框 -->
  886. <selectType
  887. :visibleDialog.sync="visibleDialog"
  888. :title="title"
  889. :treeIds="formData.extInfo.assetType"
  890. :loadTree.sync="loadTree"
  891. @selectTableData="addGoods"
  892. />
  893. <!-- 仓库选择弹框 -->
  894. <WarehousingDialog
  895. ref="wareHouseDailogRef"
  896. @selection="wareHouseSelection"
  897. ></WarehousingDialog>
  898. <!-- 生产日期、采购日期弹框 -->
  899. <el-dialog :visible.sync="dateVisible" title="选择日期" width="400px">
  900. <el-date-picker
  901. size="small"
  902. v-model="batchTime"
  903. type="datetime"
  904. style="width: 320px"
  905. value-format="yyyy-MM-dd HH:mm:ss"
  906. placeholder="选择日期"
  907. >
  908. </el-date-picker>
  909. <div style="text-align: right; margin-top: 20px">
  910. <el-button @click="dateVisible = false">取消</el-button>
  911. <el-button type="primary" @click="dateConfirm" :disabled="!batchTime"
  912. >确认</el-button
  913. >
  914. </div>
  915. </el-dialog>
  916. </div>
  917. </template>
  918. <script>
  919. import elTableInfiniteScroll from 'el-table-infinite-scroll';
  920. import storageApi from '@/api/warehouseManagement/index.js';
  921. import WarehousingDialog from './components/WarehousingDialog.vue';
  922. import { getCode } from '@/api/codeManagement/index.js';
  923. import selectType from './components/selectType_new.vue';
  924. import {
  925. sceneState,
  926. qualityResultsOptions,
  927. qualityResults,
  928. qualityStatus
  929. } from '@/utils/dict/index';
  930. import { getTreeByGroup } from '@/api/classifyManage';
  931. import { deepClone } from '@/utils';
  932. import BigNumber from 'bignumber.js';
  933. export default {
  934. components: {
  935. selectType,
  936. WarehousingDialog
  937. },
  938. // 虚拟列表滚动方法
  939. directives: {
  940. 'el-table-infinite-scroll': elTableInfiniteScroll
  941. },
  942. props: {
  943. form: { type: Object, default: () => {} },
  944. bizType: { type: Number, default: 1 },
  945. sourceBizNo: { type: String, default: '' },
  946. detailList: { type: Array, default: () => [] },
  947. saleProductList: { type: Array, default: () => [] },
  948. detailProductList: { type: Array, default: () => [] }
  949. },
  950. data() {
  951. return {
  952. newColumns: [], // 动态表头
  953. sceneState,
  954. saveLoading: false,
  955. dateVisible: false,
  956. loadTree: true,
  957. visibleDialog: false,
  958. title: '选择产品',
  959. goodsLists: [],
  960. formData: {
  961. bizType: '',
  962. storageTime: '',
  963. extInfo: {
  964. assetType: []
  965. }
  966. },
  967. rules: {
  968. 'extInfo.assetType': {
  969. required: true,
  970. message: '请选择物品类型',
  971. trigger: 'blur'
  972. },
  973. bizType: {
  974. required: true,
  975. message: '请选择入库场景',
  976. trigger: 'change'
  977. }
  978. },
  979. qualityResultsOptions, // 质检结果选项
  980. qualityStatus, // 质检状态 0未检 1已检
  981. qualityResults, // 质检结果 0无 1合格 2不合格
  982. productList: [], // 产品列表
  983. packingList: [], // 包装列表
  984. showPackingList: [], // 包装列表(虚拟列表)
  985. materialList: [], // 物料列表
  986. showMaterialList: [], // 物料列表(虚拟列表)
  987. curDateType: 'productionDate',
  988. packingListSelected: [], // 包装选择列表
  989. isWrapTable: true, // 解决表格不刷新问题(包装)
  990. currentPackingQuantity: '', // 当前包装数量
  991. batchTime: '', // 生产日期、采购日期
  992. pageSize: 20, // 物料和包装列表条数
  993. pickingPageNum: 1, // 包装虚拟分页页数
  994. materielPageNum: 1 // 物料虚拟分页页数
  995. };
  996. },
  997. computed: {
  998. clientEnvironmentId() {
  999. return this.$store.state.user.info.clientEnvironmentId;
  1000. }
  1001. },
  1002. watch: {
  1003. packingList: {
  1004. handler(newVal) {
  1005. console.log('包装列表', newVal);
  1006. this.showPackingList = newVal.slice(
  1007. 0,
  1008. this.pageSize * (this.pickingPageNum > 0 ? this.pickingPageNum : 1)
  1009. );
  1010. this.showPackingList.forEach((obj) => {
  1011. obj.workOrderId = this.detailProductList[0].workOrderId;
  1012. obj.taskId = this.detailProductList[0].taskId;
  1013. });
  1014. },
  1015. deep: true
  1016. },
  1017. materialList: {
  1018. handler(newVal) {
  1019. console.log('物料列表', newVal);
  1020. console.log('当前物料列表加载页数', this.materielPageNum);
  1021. this.showMaterialList = newVal.slice(
  1022. 0,
  1023. this.pageSize *
  1024. (this.materielPageNum > 0 ? this.materielPageNum : 1)
  1025. );
  1026. },
  1027. deep: true
  1028. }
  1029. },
  1030. created() {
  1031. this.getFieldModel();
  1032. this.getListItems();
  1033. this.initFormData();
  1034. this.getNowFormatDate();
  1035. },
  1036. methods: {
  1037. changeCount(number) {
  1038. return new BigNumber(number).toString();
  1039. },
  1040. selectSupplier(val, row) {
  1041. row.supplierId = val;
  1042. row.supplierName = row.supplierListOptions.filter(
  1043. (item) => item.id == val
  1044. )[0].name;
  1045. },
  1046. // 获取动态表头
  1047. getFieldModel() {
  1048. storageApi.fieldModel({ fieldModel: 't_main_category' }).then((res) => {
  1049. let newRes = res.map((m) => {
  1050. return {
  1051. prop: 'extField.' + m.prop,
  1052. label: m.label,
  1053. align: 'center',
  1054. showOverflowTooltip: true
  1055. };
  1056. });
  1057. this.newColumns = [...newRes];
  1058. });
  1059. },
  1060. // 初始化信息
  1061. async initFormData() {
  1062. this.formData.type = 1;
  1063. this.formData.bizType = this.bizType;
  1064. this.formData.extInfo.assetType = Array.from(
  1065. new Set(this.form.categoryLevelTopId.split(','))
  1066. );
  1067. this.formData.sourceBizNo = this.sourceBizNo;
  1068. // 入库登记人
  1069. this.formData.extInfo.createUserName = this.$store.state.user.info.name;
  1070. this.formData.createUserId = this.$store.state.user.info.userId;
  1071. if (this.saleProductList?.length > 0) {
  1072. // 物品列表 this.saleProductList
  1073. let codeList = this.saleProductList.map((item) => {
  1074. return item.productCode;
  1075. });
  1076. storageApi.getListByNameOrModeType({ codeList }).then(async (res) => {
  1077. // 获取批次号
  1078. const batchNo = await getCode('lot_number_code');
  1079. // 获取供应商
  1080. const supplierList = await storageApi.contactQueryByCategoryIdsAPI({
  1081. categoryIds: res.map((item) => item.id)
  1082. });
  1083. this.productList = res.map((item, index) => {
  1084. let filtersItem = this.saleProductList.filter(
  1085. (detailItem) => detailItem.productCode == item.code
  1086. )[0];
  1087. console.log('filtersItem---------', filtersItem);
  1088. let warehouseId = filtersItem.warehouseId;
  1089. let warehouseName = filtersItem.warehouseName;
  1090. let measureQuantity = filtersItem.totalCount || 0;
  1091. let packingQuantity = filtersItem.totalCount || 0;
  1092. let packingUnit = filtersItem.measuringUnit || '';
  1093. let price = filtersItem.singlePrice || 0;
  1094. let weight = filtersItem.sendTotalWeight || 0;
  1095. // 获取相同仓库
  1096. let warehouseIds = [];
  1097. let warehouseNames = [];
  1098. for (let i = 0; i < filtersItem.totalCount; i++) {
  1099. warehouseIds.push(filtersItem.warehouseId);
  1100. warehouseNames.push(filtersItem.warehouseName);
  1101. }
  1102. return {
  1103. index: this.productList.length + index,
  1104. categoryId: item.id, // 物品id
  1105. categoryName: item.name, // 物品名称
  1106. categoryCode: item.code, // 物品编码
  1107. categoryModel: item.modelType, // 物品型号
  1108. specification: item.specification, // 规格
  1109. brandNum: item.brandNum, // 牌号
  1110. batchNo: batchNo, // 批次号
  1111. supplierListOptions: supplierList[item.id], // 供应商列表
  1112. supplierId: '', // 供应商id
  1113. supplierName: '', // 供应商名称
  1114. approvalNumber: item.approvalNumber, // 批准文号
  1115. packingSpecification: item.packingSpecification, // 包装规格
  1116. minPackingQuantity: packingQuantity, // 最小包装单元数量
  1117. packingQuantity: 1, // 包装数量
  1118. packingUnit: packingUnit, // 包装单位
  1119. measureQuantity: measureQuantity, // 计量数量
  1120. measureUnit: item.measuringUnit, // 计量单位
  1121. netWeight: item.netWeight > -1 ? item.netWeight : 0, // 净重
  1122. weight: weight, // 重量
  1123. weightUnit: item.weightUnit, // 重量单位
  1124. totalMoney: '', // 总价
  1125. price: item.price || price, // 单价
  1126. purpose: '', // 用途
  1127. isUnpack: item.isUnpack, // 是否允许拆包
  1128. warehouseId, // 仓库id
  1129. warehouseName, // 仓库名称
  1130. warehouseIds,
  1131. warehouseNames
  1132. };
  1133. });
  1134. this.$nextTick(() => {
  1135. this.listSaveArrs();
  1136. });
  1137. });
  1138. }
  1139. if (this.detailList?.length > 0) {
  1140. // 包装列表 this.detailList
  1141. // 获取主数据物品详情
  1142. // let { category } = await getDetails(this.form.categoryId);
  1143. // console.log(category);
  1144. console.log('this.form------------', this.form);
  1145. // let codeList = this.detailList.map((item) => {
  1146. // return item.productCode || item.categoryCode;
  1147. // });
  1148. // console.log('codeList-----------', codeList);
  1149. storageApi
  1150. .getListByNameOrModeType({ codeList: [this.form.categoryCode] })
  1151. .then(async (res) => {
  1152. console.log(res);
  1153. // 获取批次号
  1154. const batchNo = await getCode('lot_number_code');
  1155. // 获取供应商
  1156. const supplierList =
  1157. await storageApi.contactQueryByCategoryIdsAPI({
  1158. categoryIds: res.map((item) => item.id)
  1159. });
  1160. // 获取相同仓库
  1161. let warehouseIds = [];
  1162. let warehouseNames = [];
  1163. for (let index = 0; index < this.form.totalCount; index++) {
  1164. warehouseIds.push(this.form.warehouseId);
  1165. warehouseNames.push(this.form.warehouseName);
  1166. }
  1167. // 通过包装生成对应产品(只有一个产品不同规格)
  1168. let specification = this.detailList.map((item) => item.quantity);
  1169. let filterSpecification = Array.from(new Set(specification));
  1170. this.productList = filterSpecification.map(
  1171. (minPackingQuantity, index) => {
  1172. // 换算重量
  1173. let weight = 0;
  1174. if (
  1175. this.form.weightUnit.toUpperCase() ==
  1176. res[0].weightUnit.toUpperCase()
  1177. ) {
  1178. weight = this.form.totalWeight;
  1179. } else {
  1180. switch (res[0].weightUnit.toUpperCase()) {
  1181. case 'KG':
  1182. if (this.form.totalWeight > -1) {
  1183. weight = this.$math.format(
  1184. this.form.totalWeight / 1000,
  1185. 14
  1186. );
  1187. } else {
  1188. weight = 0;
  1189. }
  1190. break;
  1191. case 'G':
  1192. if (this.form.totalWeight > -1) {
  1193. weight = this.$math.format(
  1194. this.form.totalWeight * 1000,
  1195. 14
  1196. );
  1197. } else {
  1198. weight = 0;
  1199. }
  1200. break;
  1201. }
  1202. }
  1203. let packingQuantity = this.detailList.filter(
  1204. (item) => item.quantity == minPackingQuantity
  1205. ).length;
  1206. let measureQuantity = this.$math.format(
  1207. packingQuantity * minPackingQuantity,
  1208. 14
  1209. );
  1210. return {
  1211. index: this.productList.length + index,
  1212. isSave: true,
  1213. categoryId: res[0].id, // 物品id
  1214. categoryName: res[0].name, // 物品名称
  1215. categoryCode: res[0].code, // 物品编码
  1216. categoryModel: res[0].modelType, // 物品型号
  1217. specification: res[0].specification, // 规格
  1218. brandNum: res[0].brandNum, // 牌号
  1219. batchNo: batchNo, // 批次号
  1220. supplierListOptions: supplierList[res[0].id], // 供应商列表
  1221. supplierId: '', // 供应商id
  1222. supplierName: '', // 供应商名称
  1223. approvalNumber: res[0].approvalNumber, // 批准文号
  1224. packingSpecification: res[0].packingSpecification, // 包装规格
  1225. minPackingQuantity: minPackingQuantity, // 最小包装单元数量
  1226. packingQuantity: packingQuantity, // 包装数量
  1227. packingUnit: res[0].packingUnit, // 包装单位
  1228. measureQuantity: measureQuantity, // 计量数量
  1229. measureUnit: res[0].measuringUnit, // 计量单位
  1230. netWeight: res[0].netWeight > -1 ? res[0].netWeight : 0, // 净重
  1231. weight: weight, // 重量
  1232. weightUnit: res[0].weightUnit, // 重量单位
  1233. totalMoney: '', // 总价
  1234. price: res[0].price, // 单价
  1235. purpose: '', // 用途
  1236. isUnpack: res[0].isUnpack, // 是否允许拆包
  1237. warehouseId: this.form.warehouseId, // 仓库id
  1238. warehouseName: this.form.warehouseName, // 仓库名称
  1239. warehouseIds,
  1240. warehouseNames
  1241. };
  1242. }
  1243. );
  1244. console.log(this.productList);
  1245. // 生成包装编码
  1246. let params = this.productList.map((item, index) => {
  1247. return {
  1248. assetCode: this.productList[index].categoryCode + index,
  1249. batchNum: this.productList[index].batchNo,
  1250. num: item.packingQuantity
  1251. };
  1252. });
  1253. const { data } = await storageApi.getAssetNum(params);
  1254. let packingCodeList = data;
  1255. console.log('包装编码-------------------------', packingCodeList);
  1256. // 生产包装
  1257. this.packingList = this.detailList.map((item, index) => {
  1258. // 换算重量
  1259. let weight = 0;
  1260. if (
  1261. this.productList[0].weightUnit.toUpperCase() ==
  1262. item.weightUnit.toUpperCase()
  1263. ) {
  1264. weight = this.form.totalWeight;
  1265. } else {
  1266. switch (this.productList[0].weightUnit.toUpperCase()) {
  1267. case 'KG':
  1268. if (item.weightUnit > -1) {
  1269. weight = this.$math.format(item.weightUnit / 1000, 14);
  1270. } else {
  1271. weight = 0;
  1272. }
  1273. break;
  1274. case 'G':
  1275. if (item.weightUnit > -1) {
  1276. weight = this.$math.format(item.weightUnit * 1000, 14);
  1277. } else {
  1278. weight = 0;
  1279. }
  1280. break;
  1281. }
  1282. }
  1283. // 代入时间
  1284. let obj = this.getNowDate();
  1285. let productionDate = '';
  1286. let purchaseDate = '';
  1287. if (this.formData.bizType == '1') {
  1288. // 生产入库
  1289. productionDate = `${obj.year}-${obj.month}-${obj.strDate} ${obj.hour}:${obj.minute}:${obj.second}`;
  1290. this.curDateType = 'productionDate';
  1291. } else if (this.formData.bizType == '2') {
  1292. // 采购入库
  1293. purchaseDate = `${obj.year}-${obj.month}-${obj.strDate} ${obj.hour}:${obj.minute}:${obj.second}`;
  1294. this.curDateType = 'purchaseDate';
  1295. }
  1296. let filterProduct = this.productList.filter(
  1297. (ite) => ite.minPackingQuantity == item.quantity
  1298. )[0];
  1299. return {
  1300. index: filterProduct.index + '-' + index, // 包装索引
  1301. warehouseId: filterProduct.warehouseIds[index], // 仓库id
  1302. warehouseName: filterProduct.warehouseNames[index], // 仓库名称
  1303. categoryName: filterProduct.categoryName, // 产品名称
  1304. categoryCode: filterProduct.categoryCode, // 产品编码
  1305. categoryModel: filterProduct.categoryModel, // 物品型号
  1306. specification: filterProduct.specification, // 规格
  1307. brandNum: filterProduct.brandNum, // 牌号
  1308. parentIndex: filterProduct.index, // 产品索引
  1309. batchNo: filterProduct.batchNo, // 批次号
  1310. packageNo: packingCodeList[index].onlyCode, // 包装编码
  1311. packingQuantity: 1, // 包装数量
  1312. packingUnit: item.packingUnit, // 包装单位
  1313. measureQuantity: item.quantity, // 计量数量
  1314. measureUnit: item.measuringUnit, // 计量单位
  1315. weight: weight, // 重量
  1316. weightUnit: filterProduct.weightUnit, // 重量单位
  1317. packingSpecificationOption:
  1318. filterProduct.packingSpecificationOption, // 包装规格
  1319. netWeight: filterProduct.netWeight, // 净重
  1320. barcodes: item.sendCode, // 发货条码
  1321. clientCode: item.clientCode, // 客户代号
  1322. materielDesignation: '', // 物料代号
  1323. engrave: item.engrave, // 刻码
  1324. isUnpack: filterProduct.isUnpack, // 是否允许拆包
  1325. productionDate: productionDate, // 生产日期
  1326. purchaseDate: purchaseDate, // 采购时间
  1327. result: 1, // 结果(1合格 2不合格)
  1328. status: 2 // 状态(0=未质检 1待检 2已检)
  1329. };
  1330. });
  1331. console.log('this.packingList--------', this.packingList);
  1332. });
  1333. }
  1334. },
  1335. // 获取当前时间函数
  1336. getNowDate() {
  1337. let date = new Date(),
  1338. obj = {
  1339. year: date.getFullYear(), //获取完整的年份(4位)
  1340. month: date.getMonth() + 1, //获取当前月份(0-11,0代表1月)
  1341. strDate: date.getDate(), // 获取当前日(1-31)
  1342. hour: date.getHours(), //获取当前小时(0 ~ 23)
  1343. minute: date.getMinutes(), //获取当前分钟(0 ~ 59)
  1344. second: date.getSeconds() //获取当前秒数(0 ~ 59)
  1345. };
  1346. Object.keys(obj).forEach((key) => {
  1347. if (obj[key] < 10) obj[key] = `0${obj[key]}`;
  1348. });
  1349. return obj;
  1350. },
  1351. // 赋值入库时间
  1352. getNowFormatDate() {
  1353. let obj = this.getNowDate();
  1354. this.formData.storageTime = `${obj.year}-${obj.month}-${obj.strDate} ${obj.hour}:${obj.minute}:${obj.second}`;
  1355. },
  1356. // 获取物品列表
  1357. async getListItems() {
  1358. const { data } = await getTreeByGroup({ type: 2 });
  1359. this.goodsLists = data;
  1360. },
  1361. // 打开单据来源弹窗
  1362. openDocumentSourceDialog() {
  1363. console.log('打开单据来源弹窗');
  1364. },
  1365. // 清除单据来源
  1366. clearDocumentSource() {
  1367. this.formData.extInfo.documentSource = '';
  1368. },
  1369. // 添加产品
  1370. addProduct() {
  1371. if (this.formData.extInfo.assetType.length <= 0) {
  1372. return this.$message.error('请选择物品类型');
  1373. }
  1374. if (!this.formData.bizType) {
  1375. return this.$message.error('请选择入库类型');
  1376. }
  1377. this.visibleDialog = true;
  1378. },
  1379. // 键盘移动
  1380. moveFocus(event, index, key, type, row) {
  1381. let keyfield = [];
  1382. let listLength = 0;
  1383. switch (type) {
  1384. case '产品':
  1385. listLength = this.productList.length;
  1386. keyfield = [
  1387. 'batchNo',
  1388. 'minPackingQuantity',
  1389. 'packingQuantity',
  1390. 'price',
  1391. 'purpose'
  1392. ];
  1393. break;
  1394. case '包装':
  1395. listLength = this.showPackingList.length;
  1396. if (row.measureUnit != row.weightUnit) {
  1397. keyfield = [
  1398. 'packing_materielDesignation',
  1399. 'packing_clientCode',
  1400. 'packing_engrave',
  1401. 'packing_weight'
  1402. ];
  1403. } else {
  1404. keyfield = [
  1405. 'packing_materielDesignation',
  1406. 'packing_clientCode',
  1407. 'packing_engrave'
  1408. ];
  1409. }
  1410. break;
  1411. case '物料':
  1412. listLength = this.showMaterialList.length;
  1413. if (row.measureUnit != row.weightUnit) {
  1414. keyfield = [
  1415. 'material_materielDesignation',
  1416. 'material_clientCode',
  1417. 'material_engrave',
  1418. 'material_weight'
  1419. ];
  1420. } else {
  1421. keyfield = [
  1422. 'material_materielDesignation',
  1423. 'material_clientCode',
  1424. 'material_engrave'
  1425. ];
  1426. }
  1427. break;
  1428. }
  1429. if (event.keyCode === 13) {
  1430. // 回车
  1431. if (
  1432. index === listLength - 1 &&
  1433. key === keyfield[keyfield.length - 1]
  1434. ) {
  1435. // 最后一行最后一个
  1436. return;
  1437. }
  1438. this.$refs[key + index].blur();
  1439. if (key === keyfield[keyfield.length - 1]) {
  1440. // 当前行最后一个,跳转下一行第一个
  1441. if (this.$refs[keyfield[0] + (index + 1)].value == 0) {
  1442. this.$refs[keyfield[0] + (index + 1)].value = '';
  1443. }
  1444. this.$refs[keyfield[0] + (index + 1)].focus();
  1445. } else {
  1446. // 跳转下一个
  1447. const nextkeyindex = keyfield.findIndex((k) => k === key) + 1;
  1448. this.$nextTick(() => {
  1449. if (this.$refs[keyfield[nextkeyindex] + index].value == 0) {
  1450. this.$refs[keyfield[nextkeyindex] + index].value = '';
  1451. }
  1452. this.$refs[keyfield[nextkeyindex] + index].focus();
  1453. });
  1454. }
  1455. }
  1456. // 向上 =38
  1457. if (event.keyCode === 38) {
  1458. console.log('向上');
  1459. if (index === 0) {
  1460. // 第一行
  1461. console.log('第一行无法向上');
  1462. return;
  1463. }
  1464. this.$refs[key + index].blur();
  1465. this.$nextTick(() => {
  1466. if (this.$refs[key + (index - 1)].value == 0) {
  1467. this.$refs[key + (index - 1)].value = '';
  1468. }
  1469. this.$refs[key + (index - 1)].focus();
  1470. });
  1471. }
  1472. // 下 = 40
  1473. if (event.keyCode === 40) {
  1474. console.log('向下');
  1475. if (index === listLength - 1) {
  1476. // 最后一行
  1477. console.log('最后一行无法向下');
  1478. return;
  1479. }
  1480. this.$refs[key + index].blur();
  1481. this.$nextTick(() => {
  1482. if (this.$refs[key + (index + 1)].value == 0) {
  1483. this.$refs[key + (index + 1)].value = '';
  1484. }
  1485. this.$refs[key + (index + 1)].focus();
  1486. });
  1487. }
  1488. // 左 = 37
  1489. if (event.keyCode === 37) {
  1490. console.log('向左');
  1491. if (index === 0 && key === keyfield[0]) {
  1492. // 第一行第一个
  1493. console.log('第一行第一个无法向左');
  1494. return;
  1495. }
  1496. this.$refs[key + index].blur();
  1497. if (key === keyfield[0]) {
  1498. if (
  1499. this.$refs[keyfield[keyfield.length - 1] + (index - 1)].value == 0
  1500. ) {
  1501. this.$refs[keyfield[keyfield.length - 1] + (index - 1)].value =
  1502. '';
  1503. }
  1504. // 当前行第一个,跳转上一行最后一个
  1505. this.$refs[keyfield[keyfield.length - 1] + (index - 1)].focus();
  1506. } else {
  1507. // 跳转上一个
  1508. const prevkeyindex = keyfield.findIndex((k) => k === key) - 1;
  1509. this.$nextTick(() => {
  1510. if (this.$refs[keyfield[prevkeyindex] + index].value == 0) {
  1511. this.$refs[keyfield[prevkeyindex] + index].value = '';
  1512. }
  1513. this.$refs[keyfield[prevkeyindex] + index].focus();
  1514. });
  1515. }
  1516. }
  1517. // 右 = 39
  1518. if (event.keyCode === 39) {
  1519. console.log('向右');
  1520. if (
  1521. index === listLength - 1 &&
  1522. key === keyfield[keyfield.length - 1]
  1523. ) {
  1524. // 最后一行最后一个
  1525. console.log('最后一行最后一个无法向左');
  1526. return;
  1527. }
  1528. console.log(this.$refs);
  1529. this.$refs[key + index].blur();
  1530. if (key === keyfield[keyfield.length - 1]) {
  1531. // 当前行最后一个,跳转下一行第一个
  1532. if (this.$refs[keyfield[0] + (index + 1)].value == 0) {
  1533. this.$refs[keyfield[0] + (index + 1)].value = '';
  1534. }
  1535. this.$refs[keyfield[0] + (index + 1)].focus();
  1536. } else {
  1537. // 跳转下一个
  1538. const nextkeyindex = keyfield.findIndex((k) => k === key) + 1;
  1539. this.$nextTick(() => {
  1540. if (this.$refs[keyfield[nextkeyindex] + index].value == 0) {
  1541. this.$refs[keyfield[nextkeyindex] + index].value = '';
  1542. }
  1543. this.$refs[keyfield[nextkeyindex] + index].focus();
  1544. });
  1545. }
  1546. }
  1547. },
  1548. // 入库
  1549. getReturnStorage() {
  1550. return new Promise((resolve) => {
  1551. let boolen = this.productList.every((item) => item.isSave);
  1552. if (!boolen) {
  1553. this.$message.warning('请先保存所有产品信息');
  1554. return;
  1555. }
  1556. // 处理包装数据
  1557. this.packingList = this.packingList.map((packingItem) => {
  1558. return {
  1559. ...packingItem,
  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: this.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. // 处理仓库id
  1579. let warehouseId = [];
  1580. let warehouseName = [];
  1581. let warehouseIds = this.productList
  1582. .map((item) => item.warehouseIds)
  1583. .flat();
  1584. let warehouseNames = this.productList
  1585. .map((item) => item.warehouseNames)
  1586. .flat();
  1587. warehouseIds.forEach((item, index) => {
  1588. if (!warehouseId.includes(item)) {
  1589. warehouseId.push(item);
  1590. warehouseName.push(warehouseNames[index]);
  1591. }
  1592. });
  1593. obj.warehouseIds = warehouseId;
  1594. obj.warehouseNames = warehouseName;
  1595. resolve(obj);
  1596. });
  1597. },
  1598. pickingHandleScroll() {
  1599. console.log('---------pickingHandleScroll------------');
  1600. if (this.showPackingList.length < this.packingList.length) {
  1601. if (this.packingList.length > this.pageSize) {
  1602. this.pickingPageNum += 1;
  1603. }
  1604. this.pickingFetchData();
  1605. }
  1606. },
  1607. pickingFetchData() {
  1608. const start = (this.pickingPageNum - 1) * this.pageSize;
  1609. const end = start + this.pageSize;
  1610. this.showPackingList = this.showPackingList.concat(
  1611. this.packingList.slice(start, end)
  1612. );
  1613. },
  1614. materielHandleScroll() {
  1615. console.log('---------materielHandleScroll------------');
  1616. if (this.showMaterialList.length < this.materialList.length) {
  1617. if (this.materialList.length > this.pageSize) {
  1618. this.materielPageNum += 1;
  1619. }
  1620. this.materielFetchData();
  1621. }
  1622. },
  1623. materielFetchData() {
  1624. const start = (this.materielPageNum - 1) * this.pageSize;
  1625. const end = start + this.pageSize;
  1626. this.showMaterialList = this.showMaterialList.concat(
  1627. this.materialList.slice(start, end)
  1628. );
  1629. console.log(this.showMaterialList);
  1630. },
  1631. // 日期选择
  1632. dateConfirm() {
  1633. this.packingListSelected.forEach((item) => {
  1634. this.$set(item, this.curDateType, this.batchTime);
  1635. });
  1636. this.batchTime = '';
  1637. this.dateVisible = false;
  1638. },
  1639. // 包装重量修改
  1640. packingWeightCahnge(value, row) {
  1641. // 修改物品重量
  1642. let filterPackingList = this.packingList.filter((item) => {
  1643. return item.parentIndex === row.parentIndex;
  1644. });
  1645. let productIndex = this.productList.findIndex((item) => {
  1646. return item.index === row.parentIndex;
  1647. });
  1648. let totalWeight = filterPackingList.reduce(
  1649. (accumulator, currentValue) => {
  1650. return this.$math.format(+accumulator + +currentValue.weight, 14);
  1651. },
  1652. 0
  1653. );
  1654. this.$set(this.productList[productIndex], 'weight', totalWeight);
  1655. // 修改拆分物料
  1656. this.materialList.map((item, index) => {
  1657. if (item.parentIndex === row.index) {
  1658. console.log(value / row.measureQuantity);
  1659. this.$set(
  1660. this.materialList[index],
  1661. 'weight',
  1662. this.$math.format(value / row.measureQuantity, 14) >= 0
  1663. ? this.$math.format(value / row.measureQuantity, 14)
  1664. : 0
  1665. );
  1666. }
  1667. });
  1668. },
  1669. // 物料重量修改
  1670. materialWeightCahnge(row) {
  1671. // 修改包装重量
  1672. let filterMaterialList = this.materialList.filter((item) => {
  1673. return item.parentIndex === row.parentIndex;
  1674. });
  1675. let packingIndex = this.packingList.findIndex((item) => {
  1676. return item.index === row.parentIndex;
  1677. });
  1678. let totalMaterialWeight = filterMaterialList.reduce(
  1679. (accumulator, currentValue) => {
  1680. return this.$math.format(+accumulator + +currentValue.weight, 14);
  1681. },
  1682. 0
  1683. );
  1684. this.$set(
  1685. this.packingList[packingIndex],
  1686. 'weight',
  1687. totalMaterialWeight
  1688. );
  1689. // 修改物品重量
  1690. let filterPackingList = this.packingList.filter((item) => {
  1691. return (
  1692. item.parentIndex === this.packingList[packingIndex].parentIndex
  1693. );
  1694. });
  1695. let productIndex = this.productList.findIndex((item) => {
  1696. return item.index === this.packingList[packingIndex].parentIndex;
  1697. });
  1698. let totalWeight = filterPackingList.reduce(
  1699. (accumulator, currentValue) => {
  1700. return this.$math.format(+accumulator + +currentValue.weight, 14);
  1701. },
  1702. 0
  1703. );
  1704. this.$set(this.productList[productIndex], 'weight', totalWeight);
  1705. },
  1706. // 包装质检结果修改
  1707. packingResultCahnge(value, row) {
  1708. // 修改物料质检结果( 1合格 2不合格)
  1709. this.materialList.map((item, index) => {
  1710. if (item.parentIndex === row.index) {
  1711. this.$set(this.materialList[index], 'result', value);
  1712. this.$set(this.materialList[index], 'status', 2);
  1713. }
  1714. });
  1715. },
  1716. // 物料质量结果修改
  1717. materialResultCahnge(value, row) {
  1718. // 修改包装质检结果
  1719. let filterMaterialList = this.materialList.filter((item) => {
  1720. return item.parentIndex == row.parentIndex;
  1721. });
  1722. let packingIndex = this.packingList.findIndex((item) => {
  1723. return item.index == row.parentIndex;
  1724. });
  1725. let boolen = filterMaterialList.every((item) => {
  1726. return item.result == 1;
  1727. });
  1728. this.$set(this.packingList[packingIndex], 'result', boolen ? 1 : 2);
  1729. this.$set(this.packingList[packingIndex], 'status', 2);
  1730. },
  1731. // 重量限制
  1732. weightInput(value, row, type) {
  1733. const newValue = value.replace(/[^\d.]/g, ''); // 保留数字和小数点
  1734. const decimalCount = (newValue.match(/\./g) || []).length; // 计算小数点的个数
  1735. if (row.weight < 0) {
  1736. row.weight = 0;
  1737. } else if (row.weight > 999999) {
  1738. row.weight = 999999;
  1739. } else {
  1740. if (decimalCount > 1) {
  1741. // 如果小数点个数大于1,移除多余的小数点
  1742. const lastIndex = newValue.lastIndexOf('.');
  1743. row.weight =
  1744. newValue.slice(0, lastIndex) + newValue.slice(lastIndex + 1);
  1745. } else if (decimalCount === 1) {
  1746. // 如果小数点个数等于1,允许小数点的输入
  1747. row.weight = newValue;
  1748. } else {
  1749. row.weight = newValue === '' ? 0 : parseFloat(newValue); // 如果输入为空,则设为0
  1750. }
  1751. }
  1752. if (type === '包装') {
  1753. this.packingWeightCahnge(value, row);
  1754. } else {
  1755. this.materialWeightCahnge(row);
  1756. }
  1757. },
  1758. //计算金额
  1759. calcSumTotal(packingQuantity, minPackingQuantity, price, row) {
  1760. //最小包装单元,包装数量,单价
  1761. const total = {
  1762. packingQuantity: Number(packingQuantity > 0 ? packingQuantity : 0),
  1763. minPackingQuantity: Number(
  1764. minPackingQuantity > 0 ? minPackingQuantity : 0
  1765. ),
  1766. price: Number(price > 0 ? price : 0)
  1767. };
  1768. let number = Number(
  1769. this.$math.format(
  1770. total.packingQuantity * total.minPackingQuantity * total.price,
  1771. 14
  1772. )
  1773. );
  1774. row.totalMoney = number;
  1775. return number;
  1776. },
  1777. // 包装维度最小包装单元改变——>总重量
  1778. minPackingQuantityChange(row, value, index) {
  1779. console.log(value);
  1780. // if (row.measureUnit !== 'KG') {
  1781. // if (value.replace(/^(0+)|[^\d]+/g, '') > 999999) {
  1782. // this.$set(this.productList[index], 'minPackingQuantity', 999999);
  1783. // } else {
  1784. // this.$set(
  1785. // this.productList[index],
  1786. // 'minPackingQuantity',
  1787. // value.replace(/^(0+)|[^\d]+/g, '')
  1788. // );
  1789. // }
  1790. // } else {
  1791. // if (value < 0) {
  1792. // this.$set(this.productList[index], 'minPackingQuantity', 1);
  1793. // } else if (value > 999999) {
  1794. // this.$set(this.productList[index], 'minPackingQuantity', 999999);
  1795. // }
  1796. // }
  1797. if (value < 0) {
  1798. this.$set(this.productList[index], 'minPackingQuantity', 1);
  1799. } else if (value > 999999) {
  1800. this.$set(this.productList[index], 'minPackingQuantity', 999999);
  1801. }
  1802. if (row.packingQuantity >= 0 && value >= 0) {
  1803. this.packNum(row, row.packingQuantity, index);
  1804. }
  1805. },
  1806. // 包装数量过滤处理改变——>总重量
  1807. packNum(row, value, index) {
  1808. const total = {
  1809. minPackingQuantity: Number(
  1810. row.minPackingQuantity > 0
  1811. ? row.minPackingQuantity > 999999
  1812. ? 999999
  1813. : row.minPackingQuantity
  1814. : 0
  1815. ),
  1816. packingQuantity: Number(
  1817. row.packingQuantity > 0
  1818. ? row.packingQuantity > 999999
  1819. ? 999999
  1820. : row.packingQuantity
  1821. : 0
  1822. )
  1823. };
  1824. const totals = Number(
  1825. this.$math.format(
  1826. total.minPackingQuantity * total.packingQuantity,
  1827. 14
  1828. )
  1829. );
  1830. if (row.measureUnit == row.weightUnit) {
  1831. row.weight = Number(
  1832. this.$math.format(
  1833. total.minPackingQuantity *
  1834. 1 *
  1835. Number(total.packingQuantity).toFixed(2),
  1836. 14
  1837. )
  1838. );
  1839. } else {
  1840. row.weight = Number(
  1841. this.$math.format(
  1842. totals *
  1843. (row.netWeight > 0 ? Number(row.netWeight).toFixed(2) : 0),
  1844. 14
  1845. )
  1846. );
  1847. }
  1848. this.$set(this.productList[index], 'measureQuantity', totals);
  1849. // 清空仓库
  1850. this.$set(this.productList[index], 'warehouseId', '');
  1851. this.$set(this.productList[index], 'warehouseName', '');
  1852. if (value.replace(/^(0+)|[^\d]+/g, '') > 999999) {
  1853. this.$set(this.productList[index], 'packingQuantity', 999999);
  1854. } else {
  1855. this.$set(
  1856. this.productList[index],
  1857. 'packingQuantity',
  1858. value.replace(/^(0+)|[^\d]+/g, '')
  1859. );
  1860. }
  1861. // return (row.packingQuantity = value.replace(/^(0+)|[^\d]+/g, ''));
  1862. },
  1863. // 表格样式
  1864. rowClass({ row, column, rowIndex, columnIndex }) {
  1865. if (rowIndex === 1) {
  1866. return {
  1867. display: 'none',
  1868. background: '#EEEEEE'
  1869. };
  1870. }
  1871. return { background: '#0000' };
  1872. },
  1873. // 添加物品明细
  1874. async addGoods(data) {
  1875. const batchNo = await getCode('lot_number_code');
  1876. const supplierList = await storageApi.contactQueryByCategoryIdsAPI({
  1877. categoryIds: data.map((item) => item.id)
  1878. });
  1879. let productList = data.map((item, index) => {
  1880. return {
  1881. index: this.productList.length + index,
  1882. categoryId: item.id, // 物品id
  1883. categoryName: item.name, // 物品名称
  1884. categoryCode: item.code, // 物品编码
  1885. categoryModel: item.listSavemodelType, // 物品型号
  1886. specification: item.specification, // 规格
  1887. brandNum: item.brandNum, // 牌号
  1888. batchNo: batchNo, // 批次号
  1889. supplierListOptions: supplierList[item.id], // 供应商列表
  1890. supplierId: '', // 供应商id
  1891. supplierName: '', // 供应商名称
  1892. approvalNumber: item.approvalNumber, // 批准文号
  1893. packingSpecification: item.packingSpecification, // 包装规格
  1894. minPackingQuantity: '', // 最小包装单元数量
  1895. packingQuantity: '', // 包装数量
  1896. packingUnit: item.packingUnit, // 包装单位
  1897. measureQuantity: 0, // 计量数量
  1898. measureUnit: item.measuringUnit, // 计量单位
  1899. netWeight: item.netWeight > -1 ? item.netWeight : 0, // 净重
  1900. weight: 0, // 重量
  1901. weightUnit: item.weightUnit, // 重量单位
  1902. totalMoney: '', // 总价
  1903. price: item.price, // 单价
  1904. purpose: '', // 用途
  1905. isUnpack: item.isUnpack // 是否允许拆包
  1906. };
  1907. });
  1908. this.productList = this.productList.concat(productList);
  1909. },
  1910. // 物品保存验证表单(批量)
  1911. validateForm() {
  1912. return new Promise(async (resolve, reject) => {
  1913. let list = this.productList.map(async (row, index) => {
  1914. let fileds = [
  1915. `productList.${index}.batchNo`,
  1916. `productList.${index}.minPackingQuantity`,
  1917. `productList.${index}.packingQuantity`,
  1918. `productList.${index}.warehouseId`
  1919. ];
  1920. console.log(fileds);
  1921. if (row.isSave) {
  1922. return Promise.resolve(true);
  1923. } else {
  1924. return await Promise.all(
  1925. fileds.map(
  1926. (item) =>
  1927. new Promise(async (res, rej) => {
  1928. this.$refs.productListRef.validateField(item, (err) => {
  1929. if (err) {
  1930. rej(err);
  1931. } else {
  1932. res(true);
  1933. }
  1934. });
  1935. })
  1936. )
  1937. );
  1938. }
  1939. });
  1940. console.log(list);
  1941. Promise.all(list)
  1942. .then(() => {
  1943. console.log('保存成功!');
  1944. resolve();
  1945. })
  1946. .catch((err) => {
  1947. console.log('保存失败!');
  1948. this.$message.error('请填入必填项!');
  1949. reject(err);
  1950. });
  1951. });
  1952. },
  1953. // 产品批量保存
  1954. async listSaveArrs() {
  1955. this.validateForm()
  1956. .then(async () => {
  1957. // 批量获取包装编码并处理
  1958. let packingCodePrams = this.productList.map((row) => {
  1959. if (row.isSave) {
  1960. return {};
  1961. } else {
  1962. return {
  1963. assetCode: row.categoryCode + row.index,
  1964. batchNum: row.batchNo,
  1965. num: row.packingQuantity
  1966. };
  1967. }
  1968. });
  1969. let filterPackingCodePrams = packingCodePrams.filter(
  1970. (item) => item.assetCode
  1971. );
  1972. let { data } = await storageApi.getAssetNum(filterPackingCodePrams);
  1973. let packingCodeList = [];
  1974. packingCodePrams.forEach((item, index) => {
  1975. packingCodeList[index] = data.filter(
  1976. (ite) => ite.assetCode == item.assetCode
  1977. );
  1978. });
  1979. // 批量生成包装
  1980. this.productList.map((row, index) => {
  1981. if (!row.isSave) {
  1982. this.generateWrappers(row, index, packingCodeList[index]);
  1983. this.$set(this.productList[index], 'isSave', true);
  1984. }
  1985. });
  1986. // 加载虚拟列表数据(分页)
  1987. // this.pickingFetchData();
  1988. // this.materielFetchData();
  1989. })
  1990. .catch((err) => {
  1991. console.log(err);
  1992. });
  1993. },
  1994. // 物品保存验证表单(单独)
  1995. validateFormIndividually(index) {
  1996. return new Promise(async (resolve) => {
  1997. console.log(index);
  1998. let fileds = [
  1999. `productList.${index}.batchNo`,
  2000. `productList.${index}.minPackingQuantity`,
  2001. `productList.${index}.packingQuantity`,
  2002. `productList.${index}.warehouseId`
  2003. ];
  2004. Promise.all(
  2005. fileds.map(
  2006. (item) =>
  2007. new Promise(async (res, rej) => {
  2008. this.$refs.productListRef.validateField(item, (err) => {
  2009. if (err) {
  2010. rej(err);
  2011. } else {
  2012. res(true);
  2013. }
  2014. });
  2015. })
  2016. )
  2017. )
  2018. .then(() => {
  2019. resolve();
  2020. })
  2021. .catch(() => {
  2022. this.$message.error('请填入必填项!');
  2023. });
  2024. });
  2025. },
  2026. // 产品编辑
  2027. listEdit(row) {
  2028. console.log(row);
  2029. this.$set(row, 'isSave', false);
  2030. // 重新计算重量
  2031. const totals = Number(
  2032. this.$math.format(row.minPackingQuantity * row.packingQuantity, 14)
  2033. );
  2034. if (row.measureUnit == row.weightUnit) {
  2035. row.weight = Number(
  2036. this.$math.format(
  2037. row.minPackingQuantity *
  2038. 1 *
  2039. Number(row.packingQuantity).toFixed(2),
  2040. 14
  2041. )
  2042. );
  2043. } else {
  2044. row.weight = Number(
  2045. this.$math.format(
  2046. totals *
  2047. (row.netWeight > 0 ? Number(row.netWeight).toFixed(2) : 0),
  2048. 14
  2049. )
  2050. );
  2051. }
  2052. console.log(row);
  2053. this.deletePackingAndMaterial(row);
  2054. },
  2055. // 根据产品信息删除包装和物料
  2056. deletePackingAndMaterial(row) {
  2057. // 删除包装(去掉不相同的包装)
  2058. this.packingList = this.packingList.filter(
  2059. (item) => item.parentIndex !== row.index
  2060. );
  2061. this.showPackingList = this.showPackingList.filter(
  2062. (item) => item.parentIndex !== row.index
  2063. );
  2064. this.pickingPageNum = Math.ceil(
  2065. this.showPackingList.length / this.pageSize
  2066. );
  2067. console.log('包装当前页数');
  2068. console.log(this.pickingPageNum);
  2069. // 删除物料(获取相同物料)
  2070. let packingIndexs = this.packingList.map((item) => item.index);
  2071. this.materialList = this.materialList.filter((item) =>
  2072. packingIndexs.includes(item.parentIndex)
  2073. );
  2074. this.showMaterialList = this.showMaterialList.filter((item) =>
  2075. packingIndexs.includes(item.parentIndex)
  2076. );
  2077. this.materielPageNum = Math.ceil(
  2078. this.showMaterialList.length / this.pageSize
  2079. );
  2080. console.log('物料当前页数');
  2081. console.log(this.showMaterialList.length);
  2082. console.log(this.pageSize);
  2083. console.log(this.materielPageNum);
  2084. },
  2085. // 产品保存操作
  2086. listSave(row, index) {
  2087. this.validateFormIndividually(index).then(async () => {
  2088. console.log('保存成功');
  2089. // 获取包装编码列表
  2090. const { data } = await storageApi.getAssetNum([
  2091. {
  2092. assetCode: row.categoryCode + row.index,
  2093. batchNum: row.batchNo,
  2094. num: row.packingQuantity
  2095. }
  2096. ]);
  2097. this.generateWrappers(row, index, data);
  2098. this.$set(this.productList[index], 'isSave', true);
  2099. // 加载虚拟列表数据(分页)
  2100. // this.pickingFetchData();
  2101. // this.materielFetchData();
  2102. });
  2103. },
  2104. //入库明细删除
  2105. listDel(row, index) {
  2106. this.productList.splice(index, 1);
  2107. this.deletePackingAndMaterial(row);
  2108. },
  2109. // 打开仓库弹框
  2110. handleWareHouse(row, idx) {
  2111. if (row.packingQuantity > 0) {
  2112. this.$refs.wareHouseDailogRef.open(row.packingQuantity, idx);
  2113. } else {
  2114. this.$message.error('请先填写包装数量!');
  2115. }
  2116. },
  2117. wareHouseSelection(argum, idx) {
  2118. console.log(argum);
  2119. console.log(idx);
  2120. this.$set(
  2121. this.productList[idx],
  2122. 'warehouseId',
  2123. argum.map((item) => item.warehouseId).join(',')
  2124. );
  2125. this.$set(
  2126. this.productList[idx],
  2127. 'warehouseName',
  2128. argum.map((item) => item.warehouseName).join(',')
  2129. );
  2130. // 方便包装遍历获取仓库id和名称
  2131. let warehouseIds = [];
  2132. let warehouseNames = [];
  2133. argum.forEach((item) => {
  2134. for (let index = 0; index < item.packingQuantity; index++) {
  2135. warehouseIds.push(item.warehouseId);
  2136. warehouseNames.push(item.warehouseName);
  2137. }
  2138. });
  2139. console.log(warehouseIds);
  2140. console.log(warehouseNames);
  2141. this.$set(this.productList[idx], 'warehouseIds', warehouseIds);
  2142. this.$set(this.productList[idx], 'warehouseNames', warehouseNames);
  2143. console.log(this.productList);
  2144. this.$forceUpdate();
  2145. },
  2146. // 生成包装
  2147. generateWrappers(row, productIndex, packingCodeList) {
  2148. let packingList = [];
  2149. let obj = this.getNowDate();
  2150. let productionDate = '';
  2151. let purchaseDate = '';
  2152. if (this.formData.bizType == '1') {
  2153. // 生产入库
  2154. productionDate = `${obj.year}-${obj.month}-${obj.strDate} ${obj.hour}:${obj.minute}:${obj.second}`;
  2155. this.curDateType = 'productionDate';
  2156. } else if (this.formData.bizType == '2') {
  2157. // 采购入库
  2158. purchaseDate = `${obj.year}-${obj.month}-${obj.strDate} ${obj.hour}:${obj.minute}:${obj.second}`;
  2159. this.curDateType = 'purchaseDate';
  2160. }
  2161. for (let index = 0; index < row.packingQuantity; index++) {
  2162. let item = {
  2163. index: row.index + '-' + index, // 包装索引
  2164. warehouseId: row.warehouseIds[index], // 仓库id
  2165. warehouseName: row.warehouseNames[index], // 仓库名称
  2166. categoryName: row.categoryName, // 产品名称
  2167. categoryCode: row.categoryCode, // 产品编码
  2168. categoryModel: row.categoryModel, // 物品型号
  2169. specification: row.specification, // 规格
  2170. brandNum: row.brandNum, // 牌号
  2171. parentIndex: row.index, // 产品索引
  2172. batchNo: row.batchNo, // 批次号
  2173. packageNo: packingCodeList[index].onlyCode, // 包装编码
  2174. packingQuantity: 1, // 包装数量
  2175. packingUnit: row.packingUnit, // 包装单位
  2176. measureQuantity: row.minPackingQuantity, // 计量数量
  2177. measureUnit: row.measureUnit, // 计量单位
  2178. weight: Number(
  2179. this.$math.format(row.weight / row.packingQuantity, 14)
  2180. ), // 重量
  2181. weightUnit: row.weightUnit, // 重量单位
  2182. barcodes: '', // 发货条码
  2183. clientCode: '', // 客户代号
  2184. materielDesignation: '', // 物料代号
  2185. engrave: '', // 刻码
  2186. isUnpack: row.isUnpack, // 是否允许拆包
  2187. productionDate: productionDate, // 生产日期
  2188. purchaseDate: purchaseDate, // 采购时间
  2189. result:
  2190. this.clientEnvironmentId == 3
  2191. ? 1
  2192. : this.formData.bizType == 2 && this.form.isQmsCheck
  2193. ? 0
  2194. : 1, // 结果(0无 1合格 2不合格) 是否质检isQmsCheck(0否 1是) bizType(2采购入库)
  2195. status:
  2196. this.clientEnvironmentId == 3
  2197. ? 2
  2198. : this.formData.bizType == 2 && this.form.isQmsCheck
  2199. ? 0
  2200. : 2 // 状态(0未质检 1待检 2已质检)
  2201. };
  2202. packingList.push(item);
  2203. }
  2204. // 单独点击保存并插入对应位置(包装)
  2205. // if (productIndex > -1) {
  2206. if (productIndex == 0) {
  2207. this.packingList.splice(productIndex, 0, ...packingList);
  2208. } else {
  2209. let packingIndex = this.packingList.findLastIndex(
  2210. (item) => item.parentIndex === productIndex - 1
  2211. );
  2212. this.packingList.splice(packingIndex + 1, 0, ...packingList);
  2213. }
  2214. // } else {
  2215. // // 批量点击生成包装
  2216. // this.packingList = this.packingList.concat(packingList);
  2217. // }
  2218. // 单独点击保存并插入对应位置(物料)
  2219. let materialList = packingList
  2220. .map((item) => {
  2221. if (item.isUnpack) {
  2222. return this.generateMaterial(item);
  2223. } else {
  2224. return [];
  2225. }
  2226. })
  2227. .flat();
  2228. console.log(materialList);
  2229. if (materialList.length > 0) {
  2230. // if (productIndex > -1) {
  2231. if (productIndex == 0) {
  2232. this.materialList.splice(0, 0, ...materialList);
  2233. } else {
  2234. let preLastPackingIndex = this.packingList.findLastIndex((ite) => {
  2235. return ite.parentIndex <= productIndex - 1 && ite.isUnpack;
  2236. });
  2237. // console.log('preLastPackingIndex-------', preLastPackingIndex);
  2238. // console.log(this.packingList);
  2239. // console.log(this.packingList[preLastPackingIndex]);
  2240. // console.log(this.materialList);
  2241. // console.log(this.packingList[preLastPackingIndex].index);
  2242. let preLastMaterialIndex = this.materialList.findLastIndex(
  2243. (ite) => {
  2244. return (
  2245. ite.parentIndex == this.packingList[preLastPackingIndex].index
  2246. );
  2247. }
  2248. );
  2249. // console.log('preLastMaterialIndex-------', preLastMaterialIndex);
  2250. this.materialList.splice(
  2251. preLastMaterialIndex + 1,
  2252. 0,
  2253. ...materialList
  2254. );
  2255. }
  2256. // } else {
  2257. // this.materialList = this.materialList.concat(materialList);
  2258. // }
  2259. console.log(this.materialList);
  2260. }
  2261. },
  2262. // 生成物料
  2263. generateMaterial(row) {
  2264. let materialList = [];
  2265. for (let index = 0; index < row.measureQuantity; index++) {
  2266. materialList.push({
  2267. materialCode: row.packageNo + index.toString().padStart(4, '0'), // 物料编码
  2268. index: row.index + '——' + index, // 包装索引
  2269. warehouseId: row.warehouseId, // 仓库id
  2270. warehouseName: row.warehouseName, // 仓库名称
  2271. categoryName: row.categoryName, // 产品名称
  2272. categoryCode: row.categoryCode, // 产品编码
  2273. parentIndex: row.index, // 产品索引
  2274. batchNo: row.batchNo, // 批次号
  2275. packageNo: row.packageNo, // 包装编码
  2276. measureQuantity: 1, // 计量数量
  2277. measureUnit: row.measureUnit, // 计量单位
  2278. weight: Number(
  2279. this.$math.format(row.weight / row.packingQuantity, 14)
  2280. ), // 重量
  2281. weightUnit: row.weightUnit, // 重量单位
  2282. barcodes: '', // 发货条码
  2283. clientCode: '', // 客户代号
  2284. materielDesignation: '', // 物料代号
  2285. engrave: '', // 刻码
  2286. result:
  2287. this.clientEnvironmentId == 3
  2288. ? 1
  2289. : this.formData.bizType == 2 && this.form.isQmsCheck
  2290. ? 0
  2291. : 1, // 结果(0无 1合格 2不合格) 是否质检isQmsCheck(0否 1是) bizType(2采购入库)
  2292. status:
  2293. this.clientEnvironmentId == 3
  2294. ? 2
  2295. : this.formData.bizType == 2 && this.form.isQmsCheck
  2296. ? 0
  2297. : 2 // 状态(0未质检 1待检 2已质检)
  2298. });
  2299. }
  2300. return materialList;
  2301. },
  2302. // 设置时间
  2303. dateSetting() {
  2304. if (!this.packingListSelected.length) {
  2305. return this.$message.error(`请选择${this.title}明细!`);
  2306. }
  2307. this.dateVisible = true;
  2308. },
  2309. // 选择包装列表
  2310. handleSelectionChange(val) {
  2311. this.packingListSelected = val;
  2312. },
  2313. // 选择质检结果改变质检状态
  2314. changeWrapStatus(resultValue, row, type) {
  2315. console.log(resultValue);
  2316. switch (resultValue) {
  2317. case 0:
  2318. // 清空质检状态
  2319. row.status = 0;
  2320. break;
  2321. default:
  2322. // 默认已检质检状态
  2323. row.status = 2;
  2324. break;
  2325. }
  2326. if (type === '包装') {
  2327. this.packingResultCahnge(resultValue, row);
  2328. } else {
  2329. this.materialResultCahnge(resultValue, row);
  2330. }
  2331. }
  2332. }
  2333. };
  2334. </script>
  2335. <style lang="scss" scoped>
  2336. .inbound_details {
  2337. margin-top: 10px;
  2338. .el-form-item {
  2339. margin-bottom: 0 !important;
  2340. }
  2341. }
  2342. .storage_btn {
  2343. margin-top: 20px;
  2344. display: flex;
  2345. align-content: center;
  2346. justify-content: center;
  2347. }
  2348. .el-date-editor.el-input,
  2349. .el-date-editor.el-input__inner {
  2350. width: 200px !important;
  2351. }
  2352. .red_color {
  2353. color: red;
  2354. }
  2355. .wareHouse_style {
  2356. text-overflow: ellipsis;
  2357. overflow: hidden;
  2358. word-break: break-all;
  2359. white-space: nowrap;
  2360. }
  2361. </style>