storage_2.vue 85 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349
  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. },
  949. data() {
  950. return {
  951. newColumns: [], // 动态表头
  952. sceneState,
  953. saveLoading: false,
  954. dateVisible: false,
  955. loadTree: true,
  956. visibleDialog: false,
  957. title: '选择产品',
  958. goodsLists: [],
  959. formData: {
  960. bizType: '',
  961. storageTime: '',
  962. extInfo: {
  963. assetType: []
  964. }
  965. },
  966. rules: {
  967. 'extInfo.assetType': {
  968. required: true,
  969. message: '请选择物品类型',
  970. trigger: 'blur'
  971. },
  972. bizType: {
  973. required: true,
  974. message: '请选择入库场景',
  975. trigger: 'change'
  976. }
  977. },
  978. qualityResultsOptions, // 质检结果选项
  979. qualityStatus, // 质检状态 0未检 1已检
  980. qualityResults, // 质检结果 0无 1合格 2不合格
  981. productList: [], // 产品列表
  982. packingList: [], // 包装列表
  983. showPackingList: [], // 包装列表(虚拟列表)
  984. materialList: [], // 物料列表
  985. showMaterialList: [], // 物料列表(虚拟列表)
  986. curDateType: 'productionDate',
  987. packingListSelected: [], // 包装选择列表
  988. isWrapTable: true, // 解决表格不刷新问题(包装)
  989. currentPackingQuantity: '', // 当前包装数量
  990. batchTime: '', // 生产日期、采购日期
  991. pageSize: 20, // 物料和包装列表条数
  992. pickingPageNum: 1, // 包装虚拟分页页数
  993. materielPageNum: 1 // 物料虚拟分页页数
  994. };
  995. },
  996. computed: {
  997. clientEnvironmentId() {
  998. return this.$store.state.user.info.clientEnvironmentId;
  999. }
  1000. },
  1001. watch: {
  1002. packingList: {
  1003. handler(newVal) {
  1004. console.log('包装列表', newVal);
  1005. console.log('当前包装列表加载页数', this.pickingPageNum);
  1006. this.showPackingList = newVal.slice(
  1007. 0,
  1008. this.pageSize * (this.pickingPageNum > 0 ? this.pickingPageNum : 1)
  1009. );
  1010. },
  1011. deep: true
  1012. },
  1013. materialList: {
  1014. handler(newVal) {
  1015. console.log('物料列表', newVal);
  1016. console.log('当前物料列表加载页数', this.materielPageNum);
  1017. this.showMaterialList = newVal.slice(
  1018. 0,
  1019. this.pageSize *
  1020. (this.materielPageNum > 0 ? this.materielPageNum : 1)
  1021. );
  1022. },
  1023. deep: true
  1024. }
  1025. },
  1026. created() {
  1027. this.getFieldModel();
  1028. this.getListItems();
  1029. this.initFormData();
  1030. this.getNowFormatDate();
  1031. },
  1032. methods: {
  1033. changeCount(number) {
  1034. return new BigNumber(number).toString();
  1035. },
  1036. selectSupplier(val, row) {
  1037. row.supplierId = val;
  1038. row.supplierName = row.supplierListOptions.filter(
  1039. (item) => item.id == val
  1040. )[0].name;
  1041. },
  1042. // 获取动态表头
  1043. getFieldModel() {
  1044. storageApi.fieldModel({ fieldModel: 't_main_category' }).then((res) => {
  1045. let newRes = res.map((m) => {
  1046. return {
  1047. prop: 'extField.' + m.prop,
  1048. label: m.label,
  1049. align: 'center',
  1050. showOverflowTooltip: true
  1051. };
  1052. });
  1053. this.newColumns = [...newRes];
  1054. });
  1055. },
  1056. // 初始化信息
  1057. async initFormData() {
  1058. this.formData.type = 1;
  1059. this.formData.bizType = this.bizType;
  1060. this.formData.extInfo.assetType = Array.from(
  1061. new Set(this.form.categoryLevelTopId.split(','))
  1062. );
  1063. this.formData.sourceBizNo = this.sourceBizNo;
  1064. // 入库登记人
  1065. this.formData.extInfo.createUserName = this.$store.state.user.info.name;
  1066. this.formData.createUserId = this.$store.state.user.info.userId;
  1067. if (this.saleProductList?.length > 0) {
  1068. // 物品列表 this.saleProductList
  1069. let codeList = this.saleProductList.map((item) => {
  1070. return item.productCode;
  1071. });
  1072. storageApi.getListByNameOrModeType({ codeList }).then(async (res) => {
  1073. // 获取批次号
  1074. const batchNo = await getCode('lot_number_code');
  1075. // 获取供应商
  1076. const supplierList = await storageApi.contactQueryByCategoryIdsAPI({
  1077. categoryIds: res.map((item) => item.id)
  1078. });
  1079. this.productList = res.map((item, index) => {
  1080. let filtersItem = this.saleProductList.filter(
  1081. (detailItem) => detailItem.productCode == item.code
  1082. )[0];
  1083. console.log('filtersItem---------', filtersItem);
  1084. let warehouseId = filtersItem.warehouseId;
  1085. let warehouseName = filtersItem.warehouseName;
  1086. let measureQuantity = filtersItem.totalCount || 0;
  1087. let packingQuantity = filtersItem.totalCount || 0;
  1088. let packingUnit = filtersItem.measuringUnit || '';
  1089. let price = filtersItem.singlePrice || 0;
  1090. let weight = filtersItem.sendTotalWeight || 0;
  1091. // 获取相同仓库
  1092. let warehouseIds = [];
  1093. let warehouseNames = [];
  1094. for (let i = 0; i < filtersItem.totalCount; i++) {
  1095. warehouseIds.push(filtersItem.warehouseId);
  1096. warehouseNames.push(filtersItem.warehouseName);
  1097. }
  1098. return {
  1099. index: this.productList.length + index,
  1100. categoryId: item.id, // 物品id
  1101. categoryName: item.name, // 物品名称
  1102. categoryCode: item.code, // 物品编码
  1103. categoryModel: item.modelType, // 物品型号
  1104. specification: item.specification, // 规格
  1105. brandNum: item.brandNum, // 牌号
  1106. batchNo: batchNo, // 批次号
  1107. supplierListOptions: supplierList[item.id], // 供应商列表
  1108. supplierId: '', // 供应商id
  1109. supplierName: '', // 供应商名称
  1110. approvalNumber: item.approvalNumber, // 批准文号
  1111. packingSpecification: item.packingSpecification, // 包装规格
  1112. minPackingQuantity: packingQuantity, // 最小包装单元数量
  1113. packingQuantity: 1, // 包装数量
  1114. packingUnit: packingUnit, // 包装单位
  1115. measureQuantity: measureQuantity, // 计量数量
  1116. measureUnit: item.measuringUnit, // 计量单位
  1117. netWeight: item.netWeight > -1 ? item.netWeight : 0, // 净重
  1118. weight: weight, // 重量
  1119. weightUnit: item.weightUnit, // 重量单位
  1120. totalMoney: '', // 总价
  1121. price: item.price || price, // 单价
  1122. purpose: '', // 用途
  1123. isUnpack: item.isUnpack, // 是否允许拆包
  1124. warehouseId, // 仓库id
  1125. warehouseName, // 仓库名称
  1126. warehouseIds,
  1127. warehouseNames
  1128. };
  1129. });
  1130. this.$nextTick(() => {
  1131. this.listSaveArrs();
  1132. });
  1133. });
  1134. }
  1135. if (this.detailList?.length > 0) {
  1136. // 包装列表 this.detailList
  1137. // 获取主数据物品详情
  1138. // let { category } = await getDetails(this.form.categoryId);
  1139. // console.log(category);
  1140. console.log('this.form------------', this.form);
  1141. // let codeList = this.detailList.map((item) => {
  1142. // return item.productCode || item.categoryCode;
  1143. // });
  1144. // console.log('codeList-----------', codeList);
  1145. storageApi
  1146. .getListByNameOrModeType({ codeList: [this.form.categoryCode] })
  1147. .then(async (res) => {
  1148. console.log(res);
  1149. // 获取批次号
  1150. const batchNo = await getCode('lot_number_code');
  1151. // 获取供应商
  1152. const supplierList =
  1153. await storageApi.contactQueryByCategoryIdsAPI({
  1154. categoryIds: res.map((item) => item.id)
  1155. });
  1156. // 获取相同仓库
  1157. let warehouseIds = [];
  1158. let warehouseNames = [];
  1159. for (let index = 0; index < this.form.totalCount; index++) {
  1160. warehouseIds.push(this.form.warehouseId);
  1161. warehouseNames.push(this.form.warehouseName);
  1162. }
  1163. // 通过包装生成对应产品(只有一个产品不同规格)
  1164. let specification = this.detailList.map((item) => item.quantity);
  1165. let filterSpecification = Array.from(new Set(specification));
  1166. this.productList = filterSpecification.map(
  1167. (minPackingQuantity, index) => {
  1168. // 换算重量
  1169. let weight = 0;
  1170. if (
  1171. this.form.weightUnit.toUpperCase() ==
  1172. res[0].weightUnit.toUpperCase()
  1173. ) {
  1174. weight = this.form.totalWeight;
  1175. } else {
  1176. switch (res[0].weightUnit.toUpperCase()) {
  1177. case 'KG':
  1178. if (this.form.totalWeight > -1) {
  1179. weight = this.$math.format(
  1180. this.form.totalWeight / 1000,
  1181. 14
  1182. );
  1183. } else {
  1184. weight = 0;
  1185. }
  1186. break;
  1187. case 'G':
  1188. if (this.form.totalWeight > -1) {
  1189. weight = this.$math.format(
  1190. this.form.totalWeight * 1000,
  1191. 14
  1192. );
  1193. } else {
  1194. weight = 0;
  1195. }
  1196. break;
  1197. }
  1198. }
  1199. let packingQuantity = this.detailList.filter(
  1200. (item) => item.quantity == minPackingQuantity
  1201. ).length;
  1202. let measureQuantity = this.$math.format(
  1203. packingQuantity * minPackingQuantity,
  1204. 14
  1205. );
  1206. return {
  1207. index: this.productList.length + index,
  1208. isSave: true,
  1209. categoryId: res[0].id, // 物品id
  1210. categoryName: res[0].name, // 物品名称
  1211. categoryCode: res[0].code, // 物品编码
  1212. categoryModel: res[0].modelType, // 物品型号
  1213. specification: res[0].specification, // 规格
  1214. brandNum: res[0].brandNum, // 牌号
  1215. batchNo: batchNo, // 批次号
  1216. supplierListOptions: supplierList[res[0].id], // 供应商列表
  1217. supplierId: '', // 供应商id
  1218. supplierName: '', // 供应商名称
  1219. approvalNumber: res[0].approvalNumber, // 批准文号
  1220. packingSpecification: res[0].packingSpecification, // 包装规格
  1221. minPackingQuantity: minPackingQuantity, // 最小包装单元数量
  1222. packingQuantity: packingQuantity, // 包装数量
  1223. packingUnit: res[0].packingUnit, // 包装单位
  1224. measureQuantity: measureQuantity, // 计量数量
  1225. measureUnit: res[0].measuringUnit, // 计量单位
  1226. netWeight: res[0].netWeight > -1 ? res[0].netWeight : 0, // 净重
  1227. weight: weight, // 重量
  1228. weightUnit: res[0].weightUnit, // 重量单位
  1229. totalMoney: '', // 总价
  1230. price: res[0].price, // 单价
  1231. purpose: '', // 用途
  1232. isUnpack: res[0].isUnpack, // 是否允许拆包
  1233. warehouseId: this.form.warehouseId, // 仓库id
  1234. warehouseName: this.form.warehouseName, // 仓库名称
  1235. warehouseIds,
  1236. warehouseNames
  1237. };
  1238. }
  1239. );
  1240. console.log(this.productList);
  1241. // 生成包装编码
  1242. let params = this.productList.map((item, index) => {
  1243. return {
  1244. assetCode: this.productList[index].categoryCode + index,
  1245. batchNum: this.productList[index].batchNo,
  1246. num: item.packingQuantity
  1247. };
  1248. });
  1249. const { data } = await storageApi.getAssetNum(params);
  1250. let packingCodeList = data;
  1251. console.log('包装编码-------------------------', packingCodeList);
  1252. // 生产包装
  1253. this.packingList = this.detailList.map((item, index) => {
  1254. // 换算重量
  1255. let weight = 0;
  1256. if (
  1257. this.productList[0].weightUnit.toUpperCase() ==
  1258. item.weightUnit.toUpperCase()
  1259. ) {
  1260. weight = this.form.totalWeight;
  1261. } else {
  1262. switch (this.productList[0].weightUnit.toUpperCase()) {
  1263. case 'KG':
  1264. if (item.weightUnit > -1) {
  1265. weight = this.$math.format(item.weightUnit / 1000, 14);
  1266. } else {
  1267. weight = 0;
  1268. }
  1269. break;
  1270. case 'G':
  1271. if (item.weightUnit > -1) {
  1272. weight = this.$math.format(item.weightUnit * 1000, 14);
  1273. } else {
  1274. weight = 0;
  1275. }
  1276. break;
  1277. }
  1278. }
  1279. // 代入时间
  1280. let obj = this.getNowDate();
  1281. let productionDate = '';
  1282. let purchaseDate = '';
  1283. if (this.formData.bizType == '1') {
  1284. // 生产入库
  1285. productionDate = `${obj.year}-${obj.month}-${obj.strDate} ${obj.hour}:${obj.minute}:${obj.second}`;
  1286. this.curDateType = 'productionDate';
  1287. } else if (this.formData.bizType == '2') {
  1288. // 采购入库
  1289. purchaseDate = `${obj.year}-${obj.month}-${obj.strDate} ${obj.hour}:${obj.minute}:${obj.second}`;
  1290. this.curDateType = 'purchaseDate';
  1291. }
  1292. let filterProduct = this.productList.filter(
  1293. (ite) => ite.minPackingQuantity == item.quantity
  1294. )[0];
  1295. return {
  1296. index: filterProduct.index + '-' + index, // 包装索引
  1297. warehouseId: filterProduct.warehouseIds[index], // 仓库id
  1298. warehouseName: filterProduct.warehouseNames[index], // 仓库名称
  1299. categoryName: filterProduct.categoryName, // 产品名称
  1300. categoryCode: filterProduct.categoryCode, // 产品编码
  1301. categoryModel: filterProduct.categoryModel, // 物品型号
  1302. specification: filterProduct.specification, // 规格
  1303. brandNum: filterProduct.brandNum, // 牌号
  1304. parentIndex: filterProduct.index, // 产品索引
  1305. batchNo: filterProduct.batchNo, // 批次号
  1306. packageNo: packingCodeList[index].onlyCode, // 包装编码
  1307. packingQuantity: 1, // 包装数量
  1308. packingUnit: item.packingUnit, // 包装单位
  1309. measureQuantity: item.quantity, // 计量数量
  1310. measureUnit: item.measuringUnit, // 计量单位
  1311. weight: weight, // 重量
  1312. weightUnit: filterProduct.weightUnit, // 重量单位
  1313. packingSpecificationOption:
  1314. filterProduct.packingSpecificationOption, // 包装规格
  1315. netWeight: filterProduct.netWeight, // 净重
  1316. barcodes: item.sendCode, // 发货条码
  1317. clientCode: item.clientCode, // 客户代号
  1318. materielDesignation: '', // 物料代号
  1319. engrave: item.engrave, // 刻码
  1320. isUnpack: filterProduct.isUnpack, // 是否允许拆包
  1321. productionDate: productionDate, // 生产日期
  1322. purchaseDate: purchaseDate, // 采购时间
  1323. result: 1, // 结果(1合格 2不合格)
  1324. status: 1 // 状态(0=未质检 1已质检)
  1325. };
  1326. });
  1327. console.log('this.packingList--------', this.packingList);
  1328. });
  1329. }
  1330. },
  1331. // 获取当前时间函数
  1332. getNowDate() {
  1333. let date = new Date(),
  1334. obj = {
  1335. year: date.getFullYear(), //获取完整的年份(4位)
  1336. month: date.getMonth() + 1, //获取当前月份(0-11,0代表1月)
  1337. strDate: date.getDate(), // 获取当前日(1-31)
  1338. hour: date.getHours(), //获取当前小时(0 ~ 23)
  1339. minute: date.getMinutes(), //获取当前分钟(0 ~ 59)
  1340. second: date.getSeconds() //获取当前秒数(0 ~ 59)
  1341. };
  1342. Object.keys(obj).forEach((key) => {
  1343. if (obj[key] < 10) obj[key] = `0${obj[key]}`;
  1344. });
  1345. return obj;
  1346. },
  1347. // 赋值入库时间
  1348. getNowFormatDate() {
  1349. let obj = this.getNowDate();
  1350. this.formData.storageTime = `${obj.year}-${obj.month}-${obj.strDate} ${obj.hour}:${obj.minute}:${obj.second}`;
  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.extInfo.documentSource = '';
  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 = [
  1383. 'batchNo',
  1384. 'minPackingQuantity',
  1385. 'packingQuantity',
  1386. 'price',
  1387. 'purpose'
  1388. ];
  1389. break;
  1390. case '包装':
  1391. listLength = this.showPackingList.length;
  1392. if (row.measureUnit != row.weightUnit) {
  1393. keyfield = [
  1394. 'packing_materielDesignation',
  1395. 'packing_clientCode',
  1396. 'packing_engrave',
  1397. 'packing_weight'
  1398. ];
  1399. } else {
  1400. keyfield = [
  1401. 'packing_materielDesignation',
  1402. 'packing_clientCode',
  1403. 'packing_engrave'
  1404. ];
  1405. }
  1406. break;
  1407. case '物料':
  1408. listLength = this.showMaterialList.length;
  1409. if (row.measureUnit != row.weightUnit) {
  1410. keyfield = [
  1411. 'material_materielDesignation',
  1412. 'material_clientCode',
  1413. 'material_engrave',
  1414. 'material_weight'
  1415. ];
  1416. } else {
  1417. keyfield = [
  1418. 'material_materielDesignation',
  1419. 'material_clientCode',
  1420. 'material_engrave'
  1421. ];
  1422. }
  1423. break;
  1424. }
  1425. if (event.keyCode === 13) {
  1426. // 回车
  1427. if (
  1428. index === listLength - 1 &&
  1429. key === keyfield[keyfield.length - 1]
  1430. ) {
  1431. // 最后一行最后一个
  1432. return;
  1433. }
  1434. this.$refs[key + index].blur();
  1435. if (key === keyfield[keyfield.length - 1]) {
  1436. // 当前行最后一个,跳转下一行第一个
  1437. if (this.$refs[keyfield[0] + (index + 1)].value == 0) {
  1438. this.$refs[keyfield[0] + (index + 1)].value = '';
  1439. }
  1440. this.$refs[keyfield[0] + (index + 1)].focus();
  1441. } else {
  1442. // 跳转下一个
  1443. const nextkeyindex = keyfield.findIndex((k) => k === key) + 1;
  1444. this.$nextTick(() => {
  1445. if (this.$refs[keyfield[nextkeyindex] + index].value == 0) {
  1446. this.$refs[keyfield[nextkeyindex] + index].value = '';
  1447. }
  1448. this.$refs[keyfield[nextkeyindex] + index].focus();
  1449. });
  1450. }
  1451. }
  1452. // 向上 =38
  1453. if (event.keyCode === 38) {
  1454. console.log('向上');
  1455. if (index === 0) {
  1456. // 第一行
  1457. console.log('第一行无法向上');
  1458. return;
  1459. }
  1460. this.$refs[key + index].blur();
  1461. this.$nextTick(() => {
  1462. if (this.$refs[key + (index - 1)].value == 0) {
  1463. this.$refs[key + (index - 1)].value = '';
  1464. }
  1465. this.$refs[key + (index - 1)].focus();
  1466. });
  1467. }
  1468. // 下 = 40
  1469. if (event.keyCode === 40) {
  1470. console.log('向下');
  1471. if (index === listLength - 1) {
  1472. // 最后一行
  1473. console.log('最后一行无法向下');
  1474. return;
  1475. }
  1476. this.$refs[key + index].blur();
  1477. this.$nextTick(() => {
  1478. if (this.$refs[key + (index + 1)].value == 0) {
  1479. this.$refs[key + (index + 1)].value = '';
  1480. }
  1481. this.$refs[key + (index + 1)].focus();
  1482. });
  1483. }
  1484. // 左 = 37
  1485. if (event.keyCode === 37) {
  1486. console.log('向左');
  1487. if (index === 0 && key === keyfield[0]) {
  1488. // 第一行第一个
  1489. console.log('第一行第一个无法向左');
  1490. return;
  1491. }
  1492. this.$refs[key + index].blur();
  1493. if (key === keyfield[0]) {
  1494. if (
  1495. this.$refs[keyfield[keyfield.length - 1] + (index - 1)].value == 0
  1496. ) {
  1497. this.$refs[keyfield[keyfield.length - 1] + (index - 1)].value =
  1498. '';
  1499. }
  1500. // 当前行第一个,跳转上一行最后一个
  1501. this.$refs[keyfield[keyfield.length - 1] + (index - 1)].focus();
  1502. } else {
  1503. // 跳转上一个
  1504. const prevkeyindex = keyfield.findIndex((k) => k === key) - 1;
  1505. this.$nextTick(() => {
  1506. if (this.$refs[keyfield[prevkeyindex] + index].value == 0) {
  1507. this.$refs[keyfield[prevkeyindex] + index].value = '';
  1508. }
  1509. this.$refs[keyfield[prevkeyindex] + index].focus();
  1510. });
  1511. }
  1512. }
  1513. // 右 = 39
  1514. if (event.keyCode === 39) {
  1515. console.log('向右');
  1516. if (
  1517. index === listLength - 1 &&
  1518. key === keyfield[keyfield.length - 1]
  1519. ) {
  1520. // 最后一行最后一个
  1521. console.log('最后一行最后一个无法向左');
  1522. return;
  1523. }
  1524. console.log(this.$refs);
  1525. this.$refs[key + index].blur();
  1526. if (key === keyfield[keyfield.length - 1]) {
  1527. // 当前行最后一个,跳转下一行第一个
  1528. if (this.$refs[keyfield[0] + (index + 1)].value == 0) {
  1529. this.$refs[keyfield[0] + (index + 1)].value = '';
  1530. }
  1531. this.$refs[keyfield[0] + (index + 1)].focus();
  1532. } else {
  1533. // 跳转下一个
  1534. const nextkeyindex = keyfield.findIndex((k) => k === key) + 1;
  1535. this.$nextTick(() => {
  1536. if (this.$refs[keyfield[nextkeyindex] + index].value == 0) {
  1537. this.$refs[keyfield[nextkeyindex] + index].value = '';
  1538. }
  1539. this.$refs[keyfield[nextkeyindex] + index].focus();
  1540. });
  1541. }
  1542. }
  1543. },
  1544. // 入库
  1545. getReturnStorage() {
  1546. return new Promise((resolve) => {
  1547. let boolen = this.productList.every((item) => item.isSave);
  1548. if (!boolen) {
  1549. this.$message.warning('请先保存所有产品信息');
  1550. return;
  1551. }
  1552. // 处理包装数据
  1553. this.packingList = this.packingList.map((packingItem) => {
  1554. return {
  1555. ...packingItem,
  1556. materialDetailList: this.materialList.filter(
  1557. (item) => item.parentIndex === packingItem.index
  1558. )
  1559. };
  1560. });
  1561. // 处理产品数据
  1562. this.productList = this.productList.map((productItem) => {
  1563. return {
  1564. ...productItem,
  1565. outInDetailRecordRequestList: this.packingList.filter(
  1566. (item) => item.parentIndex === productItem.index
  1567. )
  1568. };
  1569. });
  1570. this.formData.outInDetailList = this.productList;
  1571. let obj = deepClone(this.formData);
  1572. // 处理物品类型assetType
  1573. obj.extInfo.assetType = obj.extInfo.assetType.join(',');
  1574. // 处理仓库id
  1575. let warehouseId = [];
  1576. let warehouseName = [];
  1577. let warehouseIds = this.productList
  1578. .map((item) => item.warehouseIds)
  1579. .flat();
  1580. let warehouseNames = this.productList
  1581. .map((item) => item.warehouseNames)
  1582. .flat();
  1583. warehouseIds.forEach((item, index) => {
  1584. if (!warehouseId.includes(item)) {
  1585. warehouseId.push(item);
  1586. warehouseName.push(warehouseNames[index]);
  1587. }
  1588. });
  1589. obj.warehouseIds = warehouseId;
  1590. obj.warehouseNames = warehouseName;
  1591. resolve(obj);
  1592. });
  1593. },
  1594. pickingHandleScroll() {
  1595. console.log('---------pickingHandleScroll------------');
  1596. if (this.showPackingList.length < this.packingList.length) {
  1597. if (this.packingList.length > this.pageSize) {
  1598. this.pickingPageNum += 1;
  1599. }
  1600. this.pickingFetchData();
  1601. }
  1602. },
  1603. pickingFetchData() {
  1604. const start = (this.pickingPageNum - 1) * this.pageSize;
  1605. const end = start + this.pageSize;
  1606. this.showPackingList = this.showPackingList.concat(
  1607. this.packingList.slice(start, end)
  1608. );
  1609. },
  1610. materielHandleScroll() {
  1611. console.log('---------materielHandleScroll------------');
  1612. if (this.showMaterialList.length < this.materialList.length) {
  1613. if (this.materialList.length > this.pageSize) {
  1614. this.materielPageNum += 1;
  1615. }
  1616. this.materielFetchData();
  1617. }
  1618. },
  1619. materielFetchData() {
  1620. const start = (this.materielPageNum - 1) * this.pageSize;
  1621. const end = start + this.pageSize;
  1622. this.showMaterialList = this.showMaterialList.concat(
  1623. this.materialList.slice(start, end)
  1624. );
  1625. console.log(this.showMaterialList);
  1626. },
  1627. // 日期选择
  1628. dateConfirm() {
  1629. this.packingListSelected.forEach((item) => {
  1630. this.$set(item, this.curDateType, this.batchTime);
  1631. });
  1632. this.batchTime = '';
  1633. this.dateVisible = false;
  1634. },
  1635. // 包装重量修改
  1636. packingWeightCahnge(value, row) {
  1637. // 修改物品重量
  1638. let filterPackingList = this.packingList.filter((item) => {
  1639. return item.parentIndex === row.parentIndex;
  1640. });
  1641. let productIndex = this.productList.findIndex((item) => {
  1642. return item.index === row.parentIndex;
  1643. });
  1644. let totalWeight = filterPackingList.reduce(
  1645. (accumulator, currentValue) => {
  1646. return this.$math.format(+accumulator + +currentValue.weight, 14);
  1647. },
  1648. 0
  1649. );
  1650. this.$set(this.productList[productIndex], 'weight', totalWeight);
  1651. // 修改拆分物料
  1652. this.materialList.map((item, index) => {
  1653. if (item.parentIndex === row.index) {
  1654. console.log(value / row.measureQuantity);
  1655. this.$set(
  1656. this.materialList[index],
  1657. 'weight',
  1658. this.$math.format(value / row.measureQuantity, 14) >= 0
  1659. ? this.$math.format(value / row.measureQuantity, 14)
  1660. : 0
  1661. );
  1662. }
  1663. });
  1664. },
  1665. // 物料重量修改
  1666. materialWeightCahnge(row) {
  1667. // 修改包装重量
  1668. let filterMaterialList = this.materialList.filter((item) => {
  1669. return item.parentIndex === row.parentIndex;
  1670. });
  1671. let packingIndex = this.packingList.findIndex((item) => {
  1672. return item.index === row.parentIndex;
  1673. });
  1674. let totalMaterialWeight = filterMaterialList.reduce(
  1675. (accumulator, currentValue) => {
  1676. return this.$math.format(+accumulator + +currentValue.weight, 14);
  1677. },
  1678. 0
  1679. );
  1680. this.$set(
  1681. this.packingList[packingIndex],
  1682. 'weight',
  1683. totalMaterialWeight
  1684. );
  1685. // 修改物品重量
  1686. let filterPackingList = this.packingList.filter((item) => {
  1687. return (
  1688. item.parentIndex === this.packingList[packingIndex].parentIndex
  1689. );
  1690. });
  1691. let productIndex = this.productList.findIndex((item) => {
  1692. return item.index === this.packingList[packingIndex].parentIndex;
  1693. });
  1694. let totalWeight = filterPackingList.reduce(
  1695. (accumulator, currentValue) => {
  1696. return this.$math.format(+accumulator + +currentValue.weight, 14);
  1697. },
  1698. 0
  1699. );
  1700. this.$set(this.productList[productIndex], 'weight', totalWeight);
  1701. },
  1702. // 包装质检结果修改
  1703. packingResultCahnge(value, row) {
  1704. // 修改物料质检结果( 1合格 2不合格)
  1705. this.materialList.map((item, index) => {
  1706. if (item.parentIndex === row.index) {
  1707. this.$set(this.materialList[index], 'result', value);
  1708. }
  1709. });
  1710. },
  1711. // 物料质量结果修改
  1712. materialResultCahnge(value, row) {
  1713. // 修改包装质检结果
  1714. let filterMaterialList = this.materialList.filter((item) => {
  1715. return item.parentIndex == row.parentIndex;
  1716. });
  1717. let packingIndex = this.packingList.findIndex((item) => {
  1718. return item.index == row.parentIndex;
  1719. });
  1720. let boolen = filterMaterialList.every((item) => {
  1721. return item.result == 1;
  1722. });
  1723. this.$set(this.packingList[packingIndex], 'result', boolen ? 1 : 2);
  1724. },
  1725. // 重量限制
  1726. weightInput(value, row, type) {
  1727. const newValue = value.replace(/[^\d.]/g, ''); // 保留数字和小数点
  1728. const decimalCount = (newValue.match(/\./g) || []).length; // 计算小数点的个数
  1729. if (row.weight < 0) {
  1730. row.weight = 0;
  1731. } else if (row.weight > 999999) {
  1732. row.weight = 999999;
  1733. } else {
  1734. if (decimalCount > 1) {
  1735. // 如果小数点个数大于1,移除多余的小数点
  1736. const lastIndex = newValue.lastIndexOf('.');
  1737. row.weight =
  1738. newValue.slice(0, lastIndex) + newValue.slice(lastIndex + 1);
  1739. } else if (decimalCount === 1) {
  1740. // 如果小数点个数等于1,允许小数点的输入
  1741. row.weight = newValue;
  1742. } else {
  1743. row.weight = newValue === '' ? 0 : parseFloat(newValue); // 如果输入为空,则设为0
  1744. }
  1745. }
  1746. if (type === '包装') {
  1747. this.packingWeightCahnge(value, row);
  1748. } else {
  1749. this.materialWeightCahnge(row);
  1750. }
  1751. },
  1752. //计算金额
  1753. calcSumTotal(packingQuantity, minPackingQuantity, price, row) {
  1754. //最小包装单元,包装数量,单价
  1755. const total = {
  1756. packingQuantity: Number(packingQuantity > 0 ? packingQuantity : 0),
  1757. minPackingQuantity: Number(
  1758. minPackingQuantity > 0 ? minPackingQuantity : 0
  1759. ),
  1760. price: Number(price > 0 ? price : 0)
  1761. };
  1762. let number = Number(
  1763. this.$math.format(
  1764. total.packingQuantity * total.minPackingQuantity * total.price,
  1765. 14
  1766. )
  1767. );
  1768. row.totalMoney = number;
  1769. return number;
  1770. },
  1771. // 包装维度最小包装单元改变——>总重量
  1772. minPackingQuantityChange(row, value, index) {
  1773. console.log(value);
  1774. // if (row.measureUnit !== 'KG') {
  1775. // if (value.replace(/^(0+)|[^\d]+/g, '') > 999999) {
  1776. // this.$set(this.productList[index], 'minPackingQuantity', 999999);
  1777. // } else {
  1778. // this.$set(
  1779. // this.productList[index],
  1780. // 'minPackingQuantity',
  1781. // value.replace(/^(0+)|[^\d]+/g, '')
  1782. // );
  1783. // }
  1784. // } else {
  1785. // if (value < 0) {
  1786. // this.$set(this.productList[index], 'minPackingQuantity', 1);
  1787. // } else if (value > 999999) {
  1788. // this.$set(this.productList[index], 'minPackingQuantity', 999999);
  1789. // }
  1790. // }
  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. if (row.packingQuantity >= 0 && value >= 0) {
  1797. this.packNum(row, row.packingQuantity, index);
  1798. }
  1799. },
  1800. // 包装数量过滤处理改变——>总重量
  1801. packNum(row, value, index) {
  1802. const total = {
  1803. minPackingQuantity: Number(
  1804. row.minPackingQuantity > 0
  1805. ? row.minPackingQuantity > 999999
  1806. ? 999999
  1807. : row.minPackingQuantity
  1808. : 0
  1809. ),
  1810. packingQuantity: Number(
  1811. row.packingQuantity > 0
  1812. ? row.packingQuantity > 999999
  1813. ? 999999
  1814. : row.packingQuantity
  1815. : 0
  1816. )
  1817. };
  1818. const totals = Number(
  1819. this.$math.format(
  1820. total.minPackingQuantity * total.packingQuantity,
  1821. 14
  1822. )
  1823. );
  1824. if (row.measureUnit == row.weightUnit) {
  1825. row.weight = Number(
  1826. this.$math.format(
  1827. total.minPackingQuantity *
  1828. 1 *
  1829. Number(total.packingQuantity).toFixed(2),
  1830. 14
  1831. )
  1832. );
  1833. } else {
  1834. row.weight = Number(
  1835. this.$math.format(
  1836. totals *
  1837. (row.netWeight > 0 ? Number(row.netWeight).toFixed(2) : 0),
  1838. 14
  1839. )
  1840. );
  1841. }
  1842. this.$set(this.productList[index], 'measureQuantity', totals);
  1843. // 清空仓库
  1844. this.$set(this.productList[index], 'warehouseId', '');
  1845. this.$set(this.productList[index], 'warehouseName', '');
  1846. if (value.replace(/^(0+)|[^\d]+/g, '') > 999999) {
  1847. this.$set(this.productList[index], 'packingQuantity', 999999);
  1848. } else {
  1849. this.$set(
  1850. this.productList[index],
  1851. 'packingQuantity',
  1852. value.replace(/^(0+)|[^\d]+/g, '')
  1853. );
  1854. }
  1855. // return (row.packingQuantity = value.replace(/^(0+)|[^\d]+/g, ''));
  1856. },
  1857. // 表格样式
  1858. rowClass({ row, column, rowIndex, columnIndex }) {
  1859. if (rowIndex === 1) {
  1860. return {
  1861. display: 'none',
  1862. background: '#EEEEEE'
  1863. };
  1864. }
  1865. return { background: '#0000' };
  1866. },
  1867. // 添加物品明细
  1868. async addGoods(data) {
  1869. const batchNo = await getCode('lot_number_code');
  1870. const supplierList = await storageApi.contactQueryByCategoryIdsAPI({
  1871. categoryIds: data.map((item) => item.id)
  1872. });
  1873. let productList = data.map((item, index) => {
  1874. return {
  1875. index: this.productList.length + index,
  1876. categoryId: item.id, // 物品id
  1877. categoryName: item.name, // 物品名称
  1878. categoryCode: item.code, // 物品编码
  1879. categoryModel: item.listSavemodelType, // 物品型号
  1880. specification: item.specification, // 规格
  1881. brandNum: item.brandNum, // 牌号
  1882. batchNo: batchNo, // 批次号
  1883. supplierListOptions: supplierList[item.id], // 供应商列表
  1884. supplierId: '', // 供应商id
  1885. supplierName: '', // 供应商名称
  1886. approvalNumber: item.approvalNumber, // 批准文号
  1887. packingSpecification: item.packingSpecification, // 包装规格
  1888. minPackingQuantity: '', // 最小包装单元数量
  1889. packingQuantity: '', // 包装数量
  1890. packingUnit: item.packingUnit, // 包装单位
  1891. measureQuantity: 0, // 计量数量
  1892. measureUnit: item.measuringUnit, // 计量单位
  1893. netWeight: item.netWeight > -1 ? item.netWeight : 0, // 净重
  1894. weight: 0, // 重量
  1895. weightUnit: item.weightUnit, // 重量单位
  1896. totalMoney: '', // 总价
  1897. price: item.price, // 单价
  1898. purpose: '', // 用途
  1899. isUnpack: item.isUnpack // 是否允许拆包
  1900. };
  1901. });
  1902. this.productList = this.productList.concat(productList);
  1903. },
  1904. // 物品保存验证表单(批量)
  1905. validateForm() {
  1906. return new Promise(async (resolve, reject) => {
  1907. let list = this.productList.map(async (row, index) => {
  1908. let fileds = [
  1909. `productList.${index}.batchNo`,
  1910. `productList.${index}.minPackingQuantity`,
  1911. `productList.${index}.packingQuantity`,
  1912. `productList.${index}.warehouseId`
  1913. ];
  1914. console.log(fileds);
  1915. if (row.isSave) {
  1916. return Promise.resolve(true);
  1917. } else {
  1918. return await Promise.all(
  1919. fileds.map(
  1920. (item) =>
  1921. new Promise(async (res, rej) => {
  1922. this.$refs.productListRef.validateField(item, (err) => {
  1923. if (err) {
  1924. rej(err);
  1925. } else {
  1926. res(true);
  1927. }
  1928. });
  1929. })
  1930. )
  1931. );
  1932. }
  1933. });
  1934. console.log(list);
  1935. Promise.all(list)
  1936. .then(() => {
  1937. console.log('保存成功!');
  1938. resolve();
  1939. })
  1940. .catch((err) => {
  1941. console.log('保存失败!');
  1942. this.$message.error('请填入必填项!');
  1943. reject(err);
  1944. });
  1945. });
  1946. },
  1947. // 产品批量保存
  1948. async listSaveArrs() {
  1949. this.validateForm()
  1950. .then(async () => {
  1951. // 批量获取包装编码并处理
  1952. let packingCodePrams = this.productList.map((row) => {
  1953. if (row.isSave) {
  1954. return {};
  1955. } else {
  1956. return {
  1957. assetCode: row.categoryCode + row.index,
  1958. batchNum: row.batchNo,
  1959. num: row.packingQuantity
  1960. };
  1961. }
  1962. });
  1963. let filterPackingCodePrams = packingCodePrams.filter(
  1964. (item) => item.assetCode
  1965. );
  1966. let { data } = await storageApi.getAssetNum(filterPackingCodePrams);
  1967. let packingCodeList = [];
  1968. packingCodePrams.forEach((item, index) => {
  1969. packingCodeList[index] = data.filter(
  1970. (ite) => ite.assetCode == item.assetCode
  1971. );
  1972. });
  1973. // 批量生成包装
  1974. this.productList.map((row, index) => {
  1975. if (!row.isSave) {
  1976. this.generateWrappers(row, index, packingCodeList[index]);
  1977. this.$set(this.productList[index], 'isSave', true);
  1978. }
  1979. });
  1980. // 加载虚拟列表数据(分页)
  1981. // this.pickingFetchData();
  1982. // this.materielFetchData();
  1983. })
  1984. .catch((err) => {
  1985. console.log(err);
  1986. });
  1987. },
  1988. // 物品保存验证表单(单独)
  1989. validateFormIndividually(index) {
  1990. return new Promise(async (resolve) => {
  1991. console.log(index);
  1992. let fileds = [
  1993. `productList.${index}.batchNo`,
  1994. `productList.${index}.minPackingQuantity`,
  1995. `productList.${index}.packingQuantity`,
  1996. `productList.${index}.warehouseId`
  1997. ];
  1998. Promise.all(
  1999. fileds.map(
  2000. (item) =>
  2001. new Promise(async (res, rej) => {
  2002. this.$refs.productListRef.validateField(item, (err) => {
  2003. if (err) {
  2004. rej(err);
  2005. } else {
  2006. res(true);
  2007. }
  2008. });
  2009. })
  2010. )
  2011. )
  2012. .then(() => {
  2013. resolve();
  2014. })
  2015. .catch(() => {
  2016. this.$message.error('请填入必填项!');
  2017. });
  2018. });
  2019. },
  2020. // 产品编辑
  2021. listEdit(row) {
  2022. console.log(row);
  2023. this.$set(row, 'isSave', false);
  2024. // 重新计算重量
  2025. const totals = Number(
  2026. this.$math.format(row.minPackingQuantity * row.packingQuantity, 14)
  2027. );
  2028. if (row.measureUnit == row.weightUnit) {
  2029. row.weight = Number(
  2030. this.$math.format(
  2031. row.minPackingQuantity *
  2032. 1 *
  2033. Number(row.packingQuantity).toFixed(2),
  2034. 14
  2035. )
  2036. );
  2037. } else {
  2038. row.weight = Number(
  2039. this.$math.format(
  2040. totals *
  2041. (row.netWeight > 0 ? Number(row.netWeight).toFixed(2) : 0),
  2042. 14
  2043. )
  2044. );
  2045. }
  2046. console.log(row);
  2047. this.deletePackingAndMaterial(row);
  2048. },
  2049. // 根据产品信息删除包装和物料
  2050. deletePackingAndMaterial(row) {
  2051. // 删除包装(去掉不相同的包装)
  2052. this.packingList = this.packingList.filter(
  2053. (item) => item.parentIndex !== row.index
  2054. );
  2055. this.showPackingList = this.showPackingList.filter(
  2056. (item) => item.parentIndex !== row.index
  2057. );
  2058. this.pickingPageNum = Math.ceil(
  2059. this.showPackingList.length / this.pageSize
  2060. );
  2061. console.log('包装当前页数');
  2062. console.log(this.pickingPageNum);
  2063. // 删除物料(获取相同物料)
  2064. let packingIndexs = this.packingList.map((item) => item.index);
  2065. this.materialList = this.materialList.filter((item) =>
  2066. packingIndexs.includes(item.parentIndex)
  2067. );
  2068. this.showMaterialList = this.showMaterialList.filter((item) =>
  2069. packingIndexs.includes(item.parentIndex)
  2070. );
  2071. this.materielPageNum = Math.ceil(
  2072. this.showMaterialList.length / this.pageSize
  2073. );
  2074. console.log('物料当前页数');
  2075. console.log(this.showMaterialList.length);
  2076. console.log(this.pageSize);
  2077. console.log(this.materielPageNum);
  2078. },
  2079. // 产品保存操作
  2080. listSave(row, index) {
  2081. this.validateFormIndividually(index).then(async () => {
  2082. console.log('保存成功');
  2083. // 获取包装编码列表
  2084. const { data } = await storageApi.getAssetNum([
  2085. {
  2086. assetCode: row.categoryCode + row.index,
  2087. batchNum: row.batchNo,
  2088. num: row.packingQuantity
  2089. }
  2090. ]);
  2091. this.generateWrappers(row, index, data);
  2092. this.$set(this.productList[index], 'isSave', true);
  2093. // 加载虚拟列表数据(分页)
  2094. // this.pickingFetchData();
  2095. // this.materielFetchData();
  2096. });
  2097. },
  2098. //入库明细删除
  2099. listDel(row, index) {
  2100. this.productList.splice(index, 1);
  2101. this.deletePackingAndMaterial(row);
  2102. },
  2103. // 打开仓库弹框
  2104. handleWareHouse(row, idx) {
  2105. if (row.packingQuantity > 0) {
  2106. this.$refs.wareHouseDailogRef.open(row.packingQuantity, idx);
  2107. } else {
  2108. this.$message.error('请先填写包装数量!');
  2109. }
  2110. },
  2111. wareHouseSelection(argum, idx) {
  2112. console.log(argum);
  2113. console.log(idx);
  2114. this.$set(
  2115. this.productList[idx],
  2116. 'warehouseId',
  2117. argum.map((item) => item.warehouseId).join(',')
  2118. );
  2119. this.$set(
  2120. this.productList[idx],
  2121. 'warehouseName',
  2122. argum.map((item) => item.warehouseName).join(',')
  2123. );
  2124. // 方便包装遍历获取仓库id和名称
  2125. let warehouseIds = [];
  2126. let warehouseNames = [];
  2127. argum.forEach((item) => {
  2128. for (let index = 0; index < item.packingQuantity; index++) {
  2129. warehouseIds.push(item.warehouseId);
  2130. warehouseNames.push(item.warehouseName);
  2131. }
  2132. });
  2133. console.log(warehouseIds);
  2134. console.log(warehouseNames);
  2135. this.$set(this.productList[idx], 'warehouseIds', warehouseIds);
  2136. this.$set(this.productList[idx], 'warehouseNames', warehouseNames);
  2137. console.log(this.productList);
  2138. this.$forceUpdate();
  2139. },
  2140. // 生成包装
  2141. generateWrappers(row, productIndex, packingCodeList) {
  2142. let packingList = [];
  2143. let obj = this.getNowDate();
  2144. let productionDate = '';
  2145. let purchaseDate = '';
  2146. if (this.formData.bizType == '1') {
  2147. // 生产入库
  2148. productionDate = `${obj.year}-${obj.month}-${obj.strDate} ${obj.hour}:${obj.minute}:${obj.second}`;
  2149. this.curDateType = 'productionDate';
  2150. } else if (this.formData.bizType == '2') {
  2151. // 采购入库
  2152. purchaseDate = `${obj.year}-${obj.month}-${obj.strDate} ${obj.hour}:${obj.minute}:${obj.second}`;
  2153. this.curDateType = 'purchaseDate';
  2154. }
  2155. for (let index = 0; index < row.packingQuantity; index++) {
  2156. let item = {
  2157. index: row.index + '-' + index, // 包装索引
  2158. warehouseId: row.warehouseIds[index], // 仓库id
  2159. warehouseName: row.warehouseNames[index], // 仓库名称
  2160. categoryName: row.categoryName, // 产品名称
  2161. categoryCode: row.categoryCode, // 产品编码
  2162. categoryModel: row.categoryModel, // 物品型号
  2163. specification: row.specification, // 规格
  2164. brandNum: row.brandNum, // 牌号
  2165. parentIndex: row.index, // 产品索引
  2166. batchNo: row.batchNo, // 批次号
  2167. packageNo: packingCodeList[index].onlyCode, // 包装编码
  2168. packingQuantity: 1, // 包装数量
  2169. packingUnit: row.packingUnit, // 包装单位
  2170. measureQuantity: row.minPackingQuantity, // 计量数量
  2171. measureUnit: row.measureUnit, // 计量单位
  2172. weight: Number(
  2173. this.$math.format(row.weight / row.packingQuantity, 14)
  2174. ), // 重量
  2175. weightUnit: row.weightUnit, // 重量单位
  2176. barcodes: '', // 发货条码
  2177. clientCode: '', // 客户代号
  2178. materielDesignation: '', // 物料代号
  2179. engrave: '', // 刻码
  2180. isUnpack: row.isUnpack, // 是否允许拆包
  2181. productionDate: productionDate, // 生产日期
  2182. purchaseDate: purchaseDate, // 采购时间
  2183. result: this.formData.bizType == 2 && this.form.isQmsCheck ? 0 : 1, // 结果(0无 1合格 2不合格) 是否质检isQmsCheck(0否 1是) bizType(2采购入库)
  2184. status: this.formData.bizType == 2 && this.form.isQmsCheck ? 0 : 2 // 状态(0未质检 1待检 2已质检)
  2185. };
  2186. packingList.push(item);
  2187. }
  2188. // 单独点击保存并插入对应位置(包装)
  2189. // if (productIndex > -1) {
  2190. if (productIndex == 0) {
  2191. this.packingList.splice(productIndex, 0, ...packingList);
  2192. } else {
  2193. let packingIndex = this.packingList.findLastIndex(
  2194. (item) => item.parentIndex === productIndex - 1
  2195. );
  2196. this.packingList.splice(packingIndex + 1, 0, ...packingList);
  2197. }
  2198. // } else {
  2199. // // 批量点击生成包装
  2200. // this.packingList = this.packingList.concat(packingList);
  2201. // }
  2202. // 单独点击保存并插入对应位置(物料)
  2203. let materialList = packingList
  2204. .map((item) => {
  2205. if (item.isUnpack) {
  2206. return this.generateMaterial(item);
  2207. } else {
  2208. return [];
  2209. }
  2210. })
  2211. .flat();
  2212. console.log(materialList);
  2213. if (materialList.length > 0) {
  2214. // if (productIndex > -1) {
  2215. if (productIndex == 0) {
  2216. this.materialList.splice(0, 0, ...materialList);
  2217. } else {
  2218. let preLastPackingIndex = this.packingList.findLastIndex((ite) => {
  2219. return ite.parentIndex <= productIndex - 1 && ite.isUnpack;
  2220. });
  2221. // console.log('preLastPackingIndex-------', preLastPackingIndex);
  2222. // console.log(this.packingList);
  2223. // console.log(this.packingList[preLastPackingIndex]);
  2224. // console.log(this.materialList);
  2225. // console.log(this.packingList[preLastPackingIndex].index);
  2226. let preLastMaterialIndex = this.materialList.findLastIndex(
  2227. (ite) => {
  2228. return (
  2229. ite.parentIndex == this.packingList[preLastPackingIndex].index
  2230. );
  2231. }
  2232. );
  2233. // console.log('preLastMaterialIndex-------', preLastMaterialIndex);
  2234. this.materialList.splice(
  2235. preLastMaterialIndex + 1,
  2236. 0,
  2237. ...materialList
  2238. );
  2239. }
  2240. // } else {
  2241. // this.materialList = this.materialList.concat(materialList);
  2242. // }
  2243. console.log(this.materialList);
  2244. }
  2245. },
  2246. // 生成物料
  2247. generateMaterial(row) {
  2248. let materialList = [];
  2249. for (let index = 0; index < row.measureQuantity; index++) {
  2250. materialList.push({
  2251. materialCode: row.packageNo + index.toString().padStart(4, '0'), // 物料编码
  2252. index: row.index + '——' + index, // 包装索引
  2253. warehouseId: row.warehouseId, // 仓库id
  2254. warehouseName: row.warehouseName, // 仓库名称
  2255. categoryName: row.categoryName, // 产品名称
  2256. categoryCode: row.categoryCode, // 产品编码
  2257. parentIndex: row.index, // 产品索引
  2258. batchNo: row.batchNo, // 批次号
  2259. packageNo: row.packageNo, // 包装编码
  2260. measureQuantity: 1, // 计量数量
  2261. measureUnit: row.measureUnit, // 计量单位
  2262. weight: Number(
  2263. this.$math.format(row.weight / row.packingQuantity, 14)
  2264. ), // 重量
  2265. weightUnit: row.weightUnit, // 重量单位
  2266. barcodes: '', // 发货条码
  2267. clientCode: '', // 客户代号
  2268. materielDesignation: '', // 物料代号
  2269. engrave: '', // 刻码
  2270. result: this.formData.bizType == 2 && this.form.isQmsCheck ? 0 : 1, // 结果(0无 1合格 2不合格) 是否质检isQmsCheck(0否 1是) bizType(2采购入库)
  2271. status: this.formData.bizType == 2 && this.form.isQmsCheck ? 0 : 2 // 状态(0未质检 1待检 2已质检)
  2272. });
  2273. }
  2274. return materialList;
  2275. },
  2276. // 设置时间
  2277. dateSetting() {
  2278. if (!this.packingListSelected.length) {
  2279. return this.$message.error(`请选择${this.title}明细!`);
  2280. }
  2281. this.dateVisible = true;
  2282. },
  2283. // 选择包装列表
  2284. handleSelectionChange(val) {
  2285. this.packingListSelected = val;
  2286. },
  2287. // 选择质检结果改变质检状态
  2288. changeWrapStatus(resultValue, row, type) {
  2289. console.log(resultValue);
  2290. switch (resultValue) {
  2291. case 0:
  2292. // 清空质检状态
  2293. row.status = 0;
  2294. break;
  2295. default:
  2296. // 默认已检质检状态
  2297. row.status = 2;
  2298. break;
  2299. }
  2300. if (type === '包装') {
  2301. this.packingResultCahnge(resultValue, row);
  2302. } else {
  2303. this.materialResultCahnge(resultValue, row);
  2304. }
  2305. }
  2306. }
  2307. };
  2308. </script>
  2309. <style lang="scss" scoped>
  2310. .inbound_details {
  2311. margin-top: 10px;
  2312. .el-form-item {
  2313. margin-bottom: 0 !important;
  2314. }
  2315. }
  2316. .storage_btn {
  2317. margin-top: 20px;
  2318. display: flex;
  2319. align-content: center;
  2320. justify-content: center;
  2321. }
  2322. .el-date-editor.el-input,
  2323. .el-date-editor.el-input__inner {
  2324. width: 200px !important;
  2325. }
  2326. .red_color {
  2327. color: red;
  2328. }
  2329. .wareHouse_style {
  2330. text-overflow: ellipsis;
  2331. overflow: hidden;
  2332. word-break: break-all;
  2333. white-space: nowrap;
  2334. }
  2335. </style>