add.vue 90 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650
  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="8">
  13. <el-form-item label="入库单号" prop="bizNum">
  14. <el-input :value="formData.bizNum" disabled /></el-form-item
  15. ></el-col> -->
  16. <!-- <el-col :span="8">
  17. <el-form-item label="仓库" prop="warehouseId">
  18. <el-select
  19. filterable
  20. v-model="formData.warehouseId"
  21. clearable
  22. :disabled="
  23. !!(warehousingMaterialList && warehousingMaterialList.length)
  24. "
  25. >
  26. <el-option
  27. v-for="(item, index) in warehouseList"
  28. :key="index"
  29. :label="item.name"
  30. :value="item.id"
  31. @click.native="warehouse = item"
  32. ></el-option>
  33. </el-select>
  34. </el-form-item>
  35. </el-col> -->
  36. <el-col :span="8">
  37. <el-form-item label="物品类型" prop="extInfo.assetType">
  38. <!-- <DictSelection
  39. dictName="类型用途"
  40. :disabled="
  41. !!(warehousingMaterialList && warehousingMaterialList.length)
  42. "
  43. clearable
  44. v-model="formData.extInfo.assetType"
  45. @itemChange="handleChange"
  46. /> -->
  47. <!-- <el-select
  48. :disabled="
  49. !!(warehousingMaterialList && warehousingMaterialList.length)
  50. "
  51. clearable
  52. v-model="formData.extInfo.assetType"
  53. @change="handleChanges"
  54. >
  55. <el-option
  56. v-for="(item, index) in codeList"
  57. :key="index"
  58. :label="item.dictValue"
  59. :value="item.dictCode"
  60. ></el-option>
  61. </el-select> -->
  62. <selectTree
  63. ref="tree"
  64. class="form-ipt"
  65. size="medium"
  66. style="width: 100%"
  67. clearable
  68. :options="codeList"
  69. :props="{
  70. value: 'id',
  71. label: 'name',
  72. children: 'children'
  73. }"
  74. @getValue="codeListValue"
  75. :isAll="false"
  76. />
  77. </el-form-item>
  78. </el-col>
  79. <el-col :span="8">
  80. <el-form-item label="入库类型" prop="bizType">
  81. <el-select
  82. @change="onClear"
  83. filterable
  84. placeholder="请选择"
  85. v-model="formData.bizType"
  86. clearable
  87. :disabled="
  88. !!(warehousingMaterialList && warehousingMaterialList.length)
  89. "
  90. >
  91. <el-option
  92. v-for="item in sceneState"
  93. :key="item.code"
  94. :value="item.code + ''"
  95. :label="item.label"
  96. ></el-option>
  97. </el-select> </el-form-item
  98. ></el-col>
  99. <el-col :span="8">
  100. <el-form-item
  101. v-if="formData.bizType == 2"
  102. label="采购收货单"
  103. prop="documentSource"
  104. >
  105. <el-input
  106. placeholder="请输入"
  107. v-model="formData.extInfo.documentSource"
  108. @click.native="handlePicker()"
  109. >
  110. <el-button
  111. slot="append"
  112. icon="el-icon-circle-close"
  113. @click.stop="onClear"
  114. ></el-button>
  115. </el-input>
  116. </el-form-item>
  117. <el-form-item
  118. v-if="formData.bizType == 1"
  119. label="生产工单"
  120. prop="documentSource"
  121. >
  122. <el-input
  123. placeholder="请输入"
  124. clearable
  125. v-model="formData.extInfo.documentSource"
  126. /></el-form-item>
  127. <el-form-item
  128. v-if="
  129. formData.bizType != 1 &&
  130. formData.bizType != 2 &&
  131. formData.bizType != 3
  132. "
  133. label="销售订单"
  134. prop="documentSource"
  135. >
  136. <el-input
  137. placeholder="请输入"
  138. clearable
  139. v-model="formData.extInfo.documentSource"
  140. /></el-form-item>
  141. <el-form-item
  142. v-if="formData.bizType == 3"
  143. label="出库单"
  144. prop="documentSource"
  145. >
  146. <el-input
  147. placeholder="请输入"
  148. clearable
  149. v-model="formData.extInfo.documentSource"
  150. /></el-form-item>
  151. </el-col>
  152. <el-col :span="8">
  153. <el-form-item label="权属部门" prop="deptName">
  154. <el-input
  155. placeholder="权属部门"
  156. disabled
  157. v-model="formData.extInfo.deptName"
  158. clearable
  159. />
  160. </el-form-item>
  161. </el-col>
  162. <el-col :span="8">
  163. <el-form-item label="入库登记人">
  164. <el-input
  165. placeholder="登记人"
  166. disabled
  167. v-model="formData.extInfo.createUserName"
  168. clearable /></el-form-item
  169. ></el-col>
  170. <!-- <el-col :span="8">
  171. <el-form-item label="入库时间" prop="outInTime">
  172. <el-date-picker
  173. v-model="formData.outInTime"
  174. clearable
  175. type="datetime"
  176. value-format="yyyy-MM-dd HH:mm:ss"
  177. placeholder="选择日期"
  178. >
  179. </el-date-picker></el-form-item
  180. ></el-col> -->
  181. <el-col :span="8" v-if="formData.bizType == 2">
  182. <el-form-item label="供应商" prop="supplierName">
  183. <!-- <DictSelection
  184. dictName="经销商列表"
  185. clearable
  186. v-model="formData.extInfo.supplierId"
  187. @itemChange="ChangeSupplier"
  188. /> -->
  189. <el-input
  190. placeholder="请输入"
  191. clearable
  192. v-model="formData.extInfo.supplierName"
  193. />
  194. </el-form-item>
  195. </el-col>
  196. <!-- <el-col :span="8" v-if="formData.bizType == 2">
  197. <el-form-item label="物料代号" prop="supplierCode">
  198. <el-input
  199. placeholder="请输入"
  200. v-model="formData.supplierCode"
  201. clearable /></el-form-item
  202. ></el-col> -->
  203. <!-- <el-col :span="8" v-if="formData.bizType == 2">
  204. <el-form-item label="客户" prop="clientName">
  205. <el-input
  206. placeholder="请输入"
  207. clearable
  208. v-model="formData.clientName"
  209. />
  210. </el-form-item>
  211. </el-col> -->
  212. <!-- <el-col :span="8" v-if="formData.bizType == 2">
  213. <el-form-item label="客户代号" prop="clientCode">
  214. <el-input
  215. placeholder="请输入"
  216. v-model="formData.clientCode"
  217. clearable /></el-form-item
  218. ></el-col> -->
  219. <!-- <el-col :span="8">
  220. <el-form-item label="送货人" prop="fromUser">
  221. <el-input
  222. placeholder="请输入"
  223. v-model="formData.fromUser"
  224. clearable /></el-form-item
  225. ></el-col> -->
  226. <el-col :span="8">
  227. <el-form-item label="送货人" prop="fromUser">
  228. <el-input
  229. placeholder="请输入"
  230. v-model="formData.fromUser"
  231. clearable
  232. />
  233. <!-- <el-select
  234. v-model="formData.fromUser"
  235. filterable
  236. placeholder="请选择送货人"
  237. >
  238. <el-option
  239. v-for="item in contactList"
  240. :key="item.id"
  241. :label="item.linkName"
  242. :value="item.id"
  243. @click.native="
  244. () => (formData.extInfo.deliveryPhone = item.mobilePhone)
  245. "
  246. >
  247. </el-option>
  248. </el-select> -->
  249. </el-form-item></el-col
  250. >
  251. <el-col :span="8">
  252. <el-form-item label="送货人联系方式" prop="deliveryPhone">
  253. <el-input
  254. placeholder="请输入"
  255. v-model="formData.extInfo.deliveryPhone"
  256. clearable /></el-form-item
  257. ></el-col>
  258. <!-- <el-col :span="8">
  259. <el-form-item label="紧急状态" prop="urgent">
  260. <el-select
  261. filterable
  262. placeholder="请选择"
  263. v-model="formData.extInfo.urgent"
  264. clearable
  265. >
  266. <el-option
  267. v-for="item in emergencyState"
  268. :key="item.code"
  269. :value="item.code"
  270. :label="item.label"
  271. ></el-option>
  272. </el-select> </el-form-item
  273. ></el-col> -->
  274. <!-- <el-col :span="8">
  275. <el-form-item label="审核人部门" prop="verifyDeptName">
  276. <selectTree
  277. ref="tree"
  278. class="form-ipt"
  279. size="medium"
  280. style="width: 100%"
  281. clearable
  282. :options="treeList"
  283. :props="{
  284. value: 'code',
  285. label: 'name',
  286. children: 'children'
  287. }"
  288. @getValue="auditorDeptClick"
  289. />
  290. </el-form-item>
  291. </el-col>
  292. <el-col :span="8">
  293. <el-form-item label="审核人" prop="verifyId">
  294. <el-select
  295. filterable
  296. class="form-ipt"
  297. style="width: 100%"
  298. v-model="formData.verifyId"
  299. placeholder="请选择"
  300. >
  301. <el-option
  302. v-for="item in staffList"
  303. :key="item.id"
  304. :label="item.name"
  305. :value="item.id"
  306. @click.native="changeVerfy(item)"
  307. >
  308. </el-option>
  309. </el-select>
  310. </el-form-item>
  311. </el-col> -->
  312. <!-- <el-col :span="24">
  313. <el-form-item label="附件" prop="contentImage">
  314. <selectUpload @getImgs="upload" :initData="uploadList" />
  315. </el-form-item>
  316. </el-col> -->
  317. <el-col :span="24">
  318. <el-form-item label="备注" prop="remark">
  319. <el-input
  320. v-model="formData.remark"
  321. clearable
  322. type="textarea"
  323. placeholder="请详细说明"
  324. :rows="4"
  325. ></el-input>
  326. </el-form-item>
  327. </el-col>
  328. </el-row>
  329. </el-form>
  330. <div class="material">
  331. <header-title title="产品信息">
  332. <el-button type="primary" @click="addStock">添加</el-button>
  333. </header-title>
  334. <div class="mt10 form-table">
  335. <el-form
  336. ref="warehousingMaterialListRef"
  337. :model="{ warehousingMaterialList: warehousingMaterialList }"
  338. :show-message="false"
  339. >
  340. <el-button
  341. v-if="warehousingMaterialList.length != 0"
  342. type="success"
  343. plain
  344. style="margin-bottom: 20px; float: right; margin-right: 20px"
  345. size="mini"
  346. @click="listSaveArrs"
  347. >批量保存</el-button
  348. >
  349. <el-table
  350. v-if="isWeight"
  351. :header-cell-style="rowClass"
  352. :max-height="300"
  353. ref="warehousingMaterialListTable"
  354. :key="formData.extInfo.assetType"
  355. :data="warehousingMaterialList"
  356. tooltip-effect="dark"
  357. style="width: 100%"
  358. stripe
  359. >
  360. <el-table-column
  361. label="序号"
  362. type="index"
  363. width="50"
  364. align="center"
  365. >
  366. </el-table-column>
  367. <el-table-column
  368. label="编码"
  369. prop="assetCode"
  370. align="center"
  371. width="130"
  372. :show-overflow-tooltip="true"
  373. ></el-table-column>
  374. <el-table-column
  375. label="名称"
  376. align="center"
  377. width="200"
  378. prop="assetName"
  379. :show-overflow-tooltip="true"
  380. ></el-table-column>
  381. <!-- <el-table-column
  382. label="客户编码"
  383. align="center"
  384. width="150"
  385. prop="customCode"
  386. v-if="formData.bizType == 1"
  387. >
  388. <template slot-scope="{ row, $index }">
  389. <template v-if="row.isSave">
  390. {{ row.customCode }}
  391. </template>
  392. <el-form-item
  393. v-else
  394. :prop="`warehousingMaterialList.${$index}.customCode`"
  395. required
  396. >
  397. <el-input v-model="row.customCode"> </el-input>
  398. </el-form-item>
  399. </template>
  400. </el-table-column>
  401. <el-table-column
  402. label="供应商编码"
  403. align="center"
  404. width="150"
  405. prop="customCode"
  406. v-if="formData.bizType == 2"
  407. >
  408. <template slot-scope="{ row, $index }">
  409. <template v-if="row.isSave">
  410. {{ row.supplierCode }}
  411. </template>
  412. <el-form-item
  413. v-else
  414. :prop="`warehousingMaterialList.${$index}.supplierCode`"
  415. required
  416. >
  417. <el-input v-model="row.supplierCode"> </el-input>
  418. </el-form-item>
  419. </template>
  420. </el-table-column> -->
  421. <el-table-column
  422. v-for="(item, index) in tableHeader"
  423. :key="index"
  424. align="center"
  425. :label="item.label"
  426. :width="item.width"
  427. :prop="item.prop"
  428. :show-overflow-tooltip="true"
  429. >
  430. <template slot-scope="{ row }">
  431. <template v-if="item.formatter">{{
  432. item.formatter(row)
  433. }}</template>
  434. <template v-else>{{ row[item.prop] }}</template>
  435. </template>
  436. </el-table-column>
  437. <el-table-column label="批号" width="100" prop="assetName">
  438. <template slot-scope="{ row, $index }">
  439. <template v-if="row.isSave">
  440. {{ row.manualBatchNo }}
  441. </template>
  442. <el-form-item v-else>
  443. <el-input v-model="row.manualBatchNo"> </el-input>
  444. </el-form-item>
  445. </template>
  446. </el-table-column>
  447. <el-table-column
  448. label="批次号"
  449. prop="batchNo"
  450. width="70"
  451. align="center"
  452. >
  453. <template slot-scope="{ row, $index }">
  454. <template v-if="row.isSave">
  455. {{ row.batchNo }}
  456. </template>
  457. <el-form-item
  458. v-else
  459. :prop="`warehousingMaterialList.${$index}.batchNo`"
  460. required
  461. >
  462. <!-- <el-input v-model="row.batchNo"></el-input> -->
  463. {{ row.batchNo }}
  464. </el-form-item>
  465. </template>
  466. </el-table-column>
  467. <el-table-column
  468. label="最小包装单元"
  469. align="center"
  470. prop="minPackingCount"
  471. width="100"
  472. >
  473. <el-table-column label="" prop="minPackingCount" width="100">
  474. <template slot-scope="{ row, $index }">
  475. <template v-if="row.isSave">
  476. {{ row.minPackingCount }}
  477. </template>
  478. <el-form-item
  479. v-else
  480. :prop="`warehousingMaterialList.${$index}.minPackingCount`"
  481. required
  482. >
  483. <el-input
  484. type="number"
  485. v-model="row.minPackingCount"
  486. @input="minPackingCountChange(row, $event)"
  487. >
  488. </el-input>
  489. </el-form-item>
  490. </template>
  491. </el-table-column>
  492. <el-table-column label="" prop="minPackingCount">
  493. <template slot-scope="{ row, $index }">
  494. {{ handleRowUnit(row) }} /{{ row.minPackUnit }}
  495. </template>
  496. </el-table-column>
  497. </el-table-column>
  498. <el-table-column
  499. label="包装数量"
  500. prop="outInNum"
  501. width="150"
  502. align="center"
  503. >
  504. <template slot-scope="{ row, $index }">
  505. <template v-if="row.isSave || formData.bizType == 5">
  506. {{ row.outInNum }} {{ row.minPackUnit }}
  507. </template>
  508. <el-form-item
  509. v-else
  510. :prop="`warehousingMaterialList.${$index}.outInNum`"
  511. required
  512. >
  513. <el-input
  514. v-model="row.outInNum"
  515. @input="packNum(row, $event)"
  516. >
  517. <template slot="append">
  518. {{ row.minPackUnit ? row.minPackUnit : '/' }}
  519. </template>
  520. </el-input>
  521. </el-form-item>
  522. </template>
  523. </el-table-column>
  524. <el-table-column label="计量数量" prop="counts">
  525. <template slot-scope="{ row, $index }">
  526. {{ $math.format(row.minPackingCount * row.outInNum, 14) }}
  527. </template>
  528. </el-table-column>
  529. <el-table-column
  530. label="计量单位"
  531. prop="batchNo"
  532. width="100"
  533. align="center"
  534. >
  535. <!-- v-if="formData.extInfo.assetType == 1" -->
  536. <template slot-scope="{ row, $index }">
  537. <template>
  538. {{ row.measuringUnit }}
  539. </template>
  540. </template>
  541. </el-table-column>
  542. <!-- <el-table-column
  543. label="计量单位"
  544. prop="batchNo"
  545. width="100"
  546. align="center"
  547. v-if="formData.extInfo.assetType == 4"
  548. >
  549. <template slot-scope="{ row, $index }">
  550. <template>
  551. {{ row.measuringUnit }}
  552. </template>
  553. </template>
  554. </el-table-column> -->
  555. <!-- <el-table-column
  556. label="数量"
  557. prop="batchNo"
  558. width="150"
  559. align="center"
  560. v-if="formData.extInfo.assetType == 1"
  561. >
  562. <template slot-scope="{ row, $index }">
  563. <template> {{ row.outInNum }} </template>
  564. </template>
  565. </el-table-column>
  566. <el-table-column
  567. label="数量"
  568. prop="batchNo"
  569. width="150"
  570. align="center"
  571. v-if="formData.extInfo.assetType == 4"
  572. >
  573. <template slot-scope="{ row, $index }">
  574. <template>
  575. {{ row.minPackingCount * row.outInNum }}
  576. </template>
  577. </template>
  578. </el-table-column> -->
  579. <el-table-column
  580. label="重量"
  581. align="center"
  582. prop="contentImage"
  583. :show-overflow-tooltip="true"
  584. >
  585. <!-- v-if="formData.extInfo.assetType == 1" -->
  586. <template slot-scope="{ row, $index }">
  587. {{ row.weight }}
  588. <template slot="append">
  589. {{ handleRowUnit(row) }}
  590. <!-- {{
  591. { yuan: '元', wanyuan: '万元' }[row.univalenceUnit]
  592. }} -->
  593. </template>
  594. </template>
  595. </el-table-column>
  596. <!-- <el-table-column
  597. label="重量"
  598. align="center"
  599. prop="contentImage"
  600. :show-overflow-tooltip="true"
  601. v-if="formData.extInfo.assetType == 4"
  602. >
  603. <template slot-scope="{ row, $index }">
  604. {{
  605. deviceWeight(
  606. row.roughWeight,
  607. row.minPackingCount * row.outInNum
  608. )
  609. }}
  610. <template slot="append"> -->
  611. <!-- {{ handleRowUnit(row) }} -->
  612. <!-- {{
  613. { yuan: '元', wanyuan: '万元' }[row.univalenceUnit]
  614. }} -->
  615. <!-- </template>
  616. </template>
  617. </el-table-column> -->
  618. <el-table-column
  619. label="重量单位"
  620. align="center"
  621. prop="contentImage"
  622. :show-overflow-tooltip="true"
  623. >
  624. <template slot-scope="{ row, $index }">
  625. {{ row.weightUnit }}
  626. <template slot="append"> </template>
  627. </template>
  628. </el-table-column>
  629. <el-table-column
  630. label="单价"
  631. prop="univalence"
  632. width="150"
  633. align="center"
  634. >
  635. <template slot-scope="{ row, $index }">
  636. <!-- <template v-if="row.isSave || formData.bizType == 5">
  637. <template v-if="row.univalence || row.univalence === 0">
  638. {{ row.univalence
  639. }}{{
  640. { yuan: '元', wanyuan: '万元' }[row.univalenceUnit]
  641. }}
  642. </template>
  643. </template> -->
  644. <!-- v-else -->
  645. <el-form-item
  646. :prop="`warehousingMaterialList.${$index}.univalence`"
  647. >
  648. <el-input
  649. v-model="row.univalence"
  650. placeholder="非必填"
  651. @input="
  652. (value) =>
  653. (row.univalence = value.replace(/[^0-9.]+/g, ''))
  654. "
  655. >
  656. <template slot="append">
  657. 元/{{ handleRowUnit(row) }}
  658. <!-- {{
  659. { yuan: '元', wanyuan: '万元' }[row.univalenceUnit]
  660. }} -->
  661. </template>
  662. </el-input>
  663. </el-form-item>
  664. </template>
  665. </el-table-column>
  666. <el-table-column
  667. label="金额"
  668. align="center"
  669. prop="contentImage"
  670. :show-overflow-tooltip="true"
  671. >
  672. <template slot-scope="{ row, $index }">
  673. {{
  674. calcSumTotal(
  675. row.outInNum,
  676. row.minPackingCount,
  677. row.univalence,
  678. row
  679. )
  680. }}
  681. </template>
  682. </el-table-column>
  683. <el-table-column
  684. label="货位"
  685. prop="warehouseName"
  686. :show-overflow-tooltip="true"
  687. width="250"
  688. required
  689. >
  690. <template slot-scope="{ row, $index }">
  691. <el-form-item
  692. :prop="`warehousingMaterialList.${$index}.houseList`"
  693. :required="true"
  694. >
  695. <div @click="handleWareHouse(row, $index)">
  696. <div
  697. style="color: #ff4949"
  698. v-if="row.houseList.length == 0"
  699. >
  700. ---(必填)
  701. </div>
  702. <div v-else>
  703. <div
  704. class="fontOmitted"
  705. v-for="(item, index) in row.houseList"
  706. :key="index"
  707. >
  708. {{ item.warehouseName }}- {{ item.areaName }}-
  709. {{ item.shelfCode }}- {{ item.cargoSpaceCode
  710. }}<span style="color: #ff4949" v-if="item.num">
  711. - {{ item.num }}(数)</span
  712. >
  713. <br />
  714. </div>
  715. </div>
  716. </div>
  717. </el-form-item>
  718. </template>
  719. </el-table-column>
  720. <el-table-column
  721. label="质检单"
  722. v-if="formData.extInfo.assetType === 3"
  723. prop="contentImage"
  724. :show-overflow-tooltip="true"
  725. >
  726. <template slot-scope="{ row, $index }">
  727. <upload @on-success="(data) => (row.contentImage = [data])"
  728. ><template slot="placeholder">上传</template></upload
  729. >
  730. </template>
  731. </el-table-column>
  732. <el-table-column
  733. label="操作"
  734. width="200"
  735. fixed="right"
  736. align="center"
  737. >
  738. <template slot="header" slot-scope="scope"> 操作 </template>
  739. <template slot-scope="{ row, $index }">
  740. <el-button
  741. type="text"
  742. v-show="!row.isSave"
  743. @click="listSave(row, $index)"
  744. >保存</el-button
  745. >
  746. <el-button
  747. type="text"
  748. v-show="row.isSave"
  749. @click="listEdit(row, $index)"
  750. >编辑</el-button
  751. >
  752. <el-button
  753. type="text"
  754. v-if="formData.bizType == 5"
  755. v-show="!row.isSave"
  756. @click="chooseAssets(row, $index)"
  757. >选择资产编号</el-button
  758. >
  759. <el-button type="text" @click="listDel(row, $index)"
  760. >删除</el-button
  761. >
  762. </template>
  763. </el-table-column>
  764. </el-table>
  765. </el-form>
  766. </div>
  767. <div class="mt20">
  768. <header-title :title="`包装明细`">
  769. <div class="switch_right">
  770. <span v-if="materialCodeReqList.length != 0">
  771. 分拆<el-switch
  772. v-model="isSplit"
  773. active-color="#13ce66"
  774. inactive-color="#ff4949"
  775. @change="handleIsDetail"
  776. style="margin-left: 10px"
  777. >
  778. </el-switch>
  779. </span>
  780. <el-button
  781. style="margin-left: 20px"
  782. type="text"
  783. @click="dateSetting"
  784. v-if="!isSplit && formData.bizType != 5"
  785. >批量设置{{
  786. curDateType === 'manufactureTime' ? '生产日期' : '采购日期'
  787. }}</el-button
  788. >
  789. </div>
  790. </header-title>
  791. <el-button
  792. v-if="materialCodeReqList.length != 0"
  793. type="success"
  794. plain
  795. style="margin-bottom: 20px; float: right; margin-right: 20px"
  796. size="mini"
  797. @click="wrapListSave"
  798. >批量保存</el-button
  799. >
  800. <el-table
  801. v-if="showMaterialTable"
  802. ref="materialCodeReqListTable"
  803. :data="materialCodeReqList"
  804. tooltip-effect="dark"
  805. :key="formData.bizType"
  806. :header-cell-style="rowClass"
  807. style="width: 100%"
  808. stripe
  809. :max-height="300"
  810. @selection-change="handleSelectionChange"
  811. >
  812. <el-table-column
  813. v-if="formData.bizType != 5"
  814. type="selection"
  815. align="center"
  816. width="50"
  817. fixed="left"
  818. >
  819. </el-table-column>
  820. <el-table-column label="序号" type="index" width="50">
  821. </el-table-column>
  822. <el-table-column
  823. label="编码"
  824. prop="assetCode"
  825. width="130"
  826. :show-overflow-tooltip="true"
  827. ></el-table-column>
  828. <el-table-column
  829. label="名称"
  830. prop="assetName"
  831. width="150"
  832. :show-overflow-tooltip="true"
  833. ></el-table-column>
  834. <el-table-column
  835. label="批号"
  836. prop="manualBatchNo"
  837. width="100"
  838. ></el-table-column>
  839. <el-table-column
  840. label="批次号"
  841. prop="batchNo"
  842. width="70"
  843. ></el-table-column>
  844. <el-table-column
  845. :label="`包装编码`"
  846. prop="onlyCode"
  847. width="200"
  848. :show-overflow-tooltip="true"
  849. ></el-table-column>
  850. <el-table-column
  851. label="包装数量"
  852. prop="packingCount"
  853. width="80"
  854. ></el-table-column>
  855. <el-table-column
  856. label="包装单位"
  857. prop="packingUnit"
  858. ></el-table-column>
  859. <el-table-column
  860. label="计量数量"
  861. prop="minPackingCount"
  862. ></el-table-column>
  863. <el-table-column
  864. label="计量单位"
  865. prop="measuringUnit"
  866. ></el-table-column>
  867. <el-table-column label="物料代号" prop="materielCode" width="130">
  868. <template slot-scope="{ row }">
  869. <el-input
  870. v-if="!row.isPack"
  871. v-model="row.materielCode"
  872. ></el-input>
  873. <span v-else>{{ row.materielCode }}</span>
  874. </template>
  875. </el-table-column>
  876. <el-table-column label="客户代号" prop="clientCode">
  877. <template slot-scope="{ row }">
  878. <el-input
  879. v-if="!row.isPack"
  880. v-model="row.clientCode"
  881. ></el-input>
  882. <span v-else> {{ row.clientCode }}</span>
  883. </template>
  884. </el-table-column>
  885. <el-table-column label="刻码" prop="engrave">
  886. <template slot-scope="{ row }">
  887. <el-input v-if="!row.isPack" v-model="row.engrave"></el-input>
  888. <span v-else>{{ row.engrave }}</span>
  889. </template>
  890. </el-table-column>
  891. <el-table-column label="重量" prop="weight" width="100">
  892. <template slot-scope="{ row }">
  893. <el-input
  894. v-if="!row.isPack && row.measuringUnit != row.weightUtil"
  895. v-model="row.weight"
  896. @input="weightInput($event, row)"
  897. ></el-input>
  898. <span v-else>{{ row.weight }}</span>
  899. </template>
  900. </el-table-column>
  901. <el-table-column label="重量单位" prop="weightUtil">
  902. <template slot-scope="{ row }">
  903. {{ row.weightUtil }}
  904. </template>
  905. </el-table-column>
  906. <el-table-column label="质检结果" prop="result" width="120">
  907. <template slot-scope="{ row }">
  908. <DictSelection
  909. v-if="!row.isPack"
  910. @updateVal="changeWrapStatus($event, row)"
  911. dictName="质检结果"
  912. clearable
  913. v-model="row.result"
  914. />
  915. <span v-else>{{ qualityResults[row.result] }}</span>
  916. </template>
  917. </el-table-column>
  918. <el-table-column label="质检状态" prop="status" width="120">
  919. <template slot-scope="{ row }">
  920. <!-- <DictSelection
  921. dictName="质检状态"
  922. clearable
  923. v-model="row.status"
  924. ></DictSelection> -->
  925. <span>{{ qualityStatus[row.status] }}</span>
  926. </template>
  927. </el-table-column>
  928. <el-table-column
  929. v-if="formData.bizType != 5"
  930. label="生产日期"
  931. prop=""
  932. width="220"
  933. >
  934. <template slot="header" slot-scope="scope">
  935. <el-select :disabled="isSplit" filterable v-model="curDateType">
  936. <el-option
  937. value="manufactureTime"
  938. label="生产日期"
  939. ></el-option>
  940. <el-option
  941. value="procurementTime"
  942. label="采购日期"
  943. ></el-option>
  944. </el-select>
  945. </template>
  946. <template slot-scope="{ row }">
  947. <template v-if="formData.bizType == 5">
  948. {{ row[curDateType] }}
  949. </template>
  950. <el-date-picker
  951. v-else
  952. :disabled="row.isPack"
  953. size="small"
  954. v-model="row[curDateType]"
  955. type="datetime"
  956. value-format="yyyy-MM-dd HH:mm:ss"
  957. placeholder="选择日期"
  958. >
  959. </el-date-picker>
  960. </template>
  961. </el-table-column>
  962. <template v-else>
  963. <el-table-column
  964. label="生产日期"
  965. prop="manufactureTime"
  966. width="200"
  967. ></el-table-column>
  968. <el-table-column
  969. label="采购日期"
  970. prop="procurementTime"
  971. width="200"
  972. ></el-table-column>
  973. </template>
  974. <el-table-column
  975. v-if="!isSplit"
  976. label="操作"
  977. width="80"
  978. fixed="right"
  979. >
  980. <template slot-scope="{ row }">
  981. <el-button type="text" @click="packCout(row)">
  982. {{ !row.isPack ? '保存' : '编辑' }}
  983. </el-button>
  984. </template>
  985. </el-table-column>
  986. </el-table>
  987. <!-- </el-tab-pane>
  988. </el-tabs> -->
  989. </div>
  990. <div class="mt20" v-if="isSplit">
  991. <header-title :title="`物料明细`"> </header-title>
  992. <el-button
  993. v-if="resultArray.length != 0"
  994. type="success"
  995. plain
  996. style="margin-bottom: 20px; float: right; margin-right: 20px"
  997. size="mini"
  998. @click="materialListSave"
  999. >批量保存</el-button
  1000. >
  1001. <el-table
  1002. ref="resultArrayTable"
  1003. :data="resultArray"
  1004. tooltip-effect="dark"
  1005. :key="formData.bizType"
  1006. :header-cell-style="rowClass"
  1007. style="width: 100%"
  1008. stripe
  1009. :max-height="300"
  1010. @selection-change="handleSelectionChange"
  1011. >
  1012. <el-table-column label="序号" type="index" width="50">
  1013. </el-table-column>
  1014. <el-table-column
  1015. label="编码"
  1016. width="150"
  1017. prop="assetCode"
  1018. :show-overflow-tooltip="true"
  1019. ></el-table-column>
  1020. <el-table-column
  1021. label="名称"
  1022. prop="assetName"
  1023. width="200"
  1024. :show-overflow-tooltip="true"
  1025. ></el-table-column>
  1026. <el-table-column
  1027. label="批号"
  1028. prop="manualBatchNo"
  1029. width="100"
  1030. ></el-table-column>
  1031. <el-table-column
  1032. label="批次号"
  1033. prop="batchNo"
  1034. width="80"
  1035. ></el-table-column>
  1036. <el-table-column
  1037. label="物料编码"
  1038. prop="no"
  1039. width="200"
  1040. :show-overflow-tooltip="true"
  1041. ></el-table-column>
  1042. <el-table-column
  1043. label="计量数量"
  1044. prop="minPackingCount"
  1045. width="90"
  1046. ></el-table-column>
  1047. <el-table-column
  1048. width="80"
  1049. label="计量单位"
  1050. prop="measuringUnit"
  1051. ></el-table-column>
  1052. <el-table-column label="物料代号" prop="materielCode" width="130">
  1053. <template slot-scope="{ row }">
  1054. <el-input
  1055. v-if="!row.isPack"
  1056. v-model="row.materielCode"
  1057. ></el-input>
  1058. <span v-else>{{ row.materielCode }}</span>
  1059. </template>
  1060. </el-table-column>
  1061. <el-table-column label="客户代号" prop="clientCode">
  1062. <template slot-scope="{ row }">
  1063. <el-input
  1064. v-if="!row.isPack"
  1065. v-model="row.clientCode"
  1066. ></el-input>
  1067. <span v-else>{{ row.clientCode }}</span>
  1068. </template>
  1069. </el-table-column>
  1070. <el-table-column label="刻码" prop="engrave">
  1071. <template slot-scope="{ row }">
  1072. <el-input v-if="!row.isPack" v-model="row.engrave"></el-input>
  1073. <span v-else>{{ row.engrave }}</span>
  1074. </template>
  1075. </el-table-column>
  1076. <el-table-column label="重量" prop="weight" width="100">
  1077. <template slot-scope="{ row }">
  1078. <el-input
  1079. v-if="!row.isPack && row.measuringUnit != row.weightUnit"
  1080. v-model="row.weight"
  1081. ></el-input>
  1082. <span v-else>{{ row.weight }}</span>
  1083. </template>
  1084. </el-table-column>
  1085. <el-table-column
  1086. label="重量单位"
  1087. prop="weightUnit"
  1088. width="100"
  1089. ></el-table-column>
  1090. <el-table-column label="质检结果" prop="result" width="120">
  1091. <template slot-scope="{ row }">
  1092. <DictSelection
  1093. v-if="!row.isPack"
  1094. @updateVal="changeWrapStatus($event, row)"
  1095. dictName="质检结果"
  1096. clearable
  1097. v-model="row.result"
  1098. />
  1099. <span v-else>{{ qualityResults[row.result] }}</span>
  1100. </template>
  1101. </el-table-column>
  1102. <el-table-column label="质检状态" prop="status" width="120">
  1103. <template slot-scope="{ row }">
  1104. <span>{{ qualityStatus[row.status] }}</span>
  1105. </template>
  1106. </el-table-column>
  1107. <el-table-column label="操作" width="80" fixed="right">
  1108. <template slot-scope="{ row }">
  1109. <el-button type="text" @click="materialBtn(row)">
  1110. {{ !row.isPack ? '保存' : '编辑' }}
  1111. </el-button>
  1112. </template>
  1113. </el-table-column>
  1114. </el-table>
  1115. </div>
  1116. </div>
  1117. <div class="center mt20">
  1118. <el-button type="primary" @click="handleSave" :loading="saveLoading"
  1119. >保存</el-button
  1120. >
  1121. <el-button @click="$router.go(-1)">返回</el-button>
  1122. </div>
  1123. </el-card>
  1124. <selectType
  1125. :visibleDialog.sync="visibleDialog"
  1126. :title="title"
  1127. :tableHeader="tableHeader"
  1128. :bizScene="formData.bizType"
  1129. :type="[selectEquiType]"
  1130. :loadTree.sync="loadTree"
  1131. @selectTableData="addProduct"
  1132. />
  1133. <WareHouseDailog
  1134. ref="wareHouseDailogRef"
  1135. @houseData="houseData"
  1136. ></WareHouseDailog>
  1137. <ReturnSelect
  1138. ref="returnSelectRef"
  1139. :tableHeader="tableHeader"
  1140. :curDateType="curDateType"
  1141. ></ReturnSelect>
  1142. <el-dialog :visible.sync="dateVisible" title="选择日期" width="400px">
  1143. <el-date-picker
  1144. size="small"
  1145. v-model="batchTime"
  1146. type="datetime"
  1147. style="width: 320px"
  1148. value-format="yyyy-MM-dd HH:mm:ss"
  1149. placeholder="选择日期"
  1150. >
  1151. </el-date-picker>
  1152. <div style="text-align: right; margin-top: 20px">
  1153. <el-button @click="dateVisible = false">取消</el-button>
  1154. <el-button type="primary" @click="dateConfirm" :disabled="!batchTime"
  1155. >确认</el-button
  1156. >
  1157. </div>
  1158. </el-dialog>
  1159. <!-- 销售订单 -->
  1160. <picker ref="pickerRef" @success="pickerSuccess" />
  1161. </div>
  1162. </template>
  1163. <script>
  1164. import { add, bignumber } from 'mathjs';
  1165. import picker from './components/picker.vue';
  1166. import outin from '@/api/warehouseManagement/outin';
  1167. import {
  1168. getTreeByPid,
  1169. getTreeByGroup,
  1170. getProductList
  1171. } from '@/api/classifyManage';
  1172. import warehouseDefinition from '@/api/warehouseManagement/warehouseDefinition';
  1173. import selectUpload from '@/components/selectUpload';
  1174. import upload from '@/components/uploadImg';
  1175. import {
  1176. warehousingType,
  1177. sceneState,
  1178. emergencyState,
  1179. materialType
  1180. } from '@/utils/dict/index';
  1181. // import { getInfo, warehousingAdd, getAssetNum } from '@/api/stockManagement';
  1182. import selectTree from '@/components/selectTree';
  1183. import selectType from '../components/selectType.vue';
  1184. import WareHouseDailog from '../components/WareHouseDailog.vue';
  1185. import ReturnSelect from './components/ReturnSelect.vue';
  1186. // import supplier from '@/api/main/supplier';
  1187. // import org from '@/api/main/org';
  1188. // import user from '@/api/main/user';
  1189. import { tableHeader } from '../common';
  1190. import { getCode } from '@/api/codeManagement/index.js';
  1191. import { number } from 'echarts/core';
  1192. import { purchaseorderGetById, contactlink, oneId } from '@/api/mes';
  1193. export default {
  1194. components: {
  1195. selectUpload,
  1196. selectTree,
  1197. selectType,
  1198. WareHouseDailog,
  1199. upload,
  1200. ReturnSelect,
  1201. picker
  1202. },
  1203. data() {
  1204. return {
  1205. showMaterialTable: true, // 缓存包装明细列表
  1206. isSplit: false, // 是否拆分到物料明细
  1207. qualityStatus: {
  1208. 0: '未检',
  1209. 1: '已检',
  1210. 2: '部分检'
  1211. }, // 质检状态 0未检 1已检
  1212. qualityResults: {
  1213. 0: '合格',
  1214. 1: '不合格',
  1215. 3: '让步接收'
  1216. }, // 质检结果 0合格 1不合格 3让步接收
  1217. isWeight: true,
  1218. resultArray: [],
  1219. contactList: [],
  1220. pickerRow: {},
  1221. fromUserList: [],
  1222. codeList: [],
  1223. materialType,
  1224. warehousingType,
  1225. sceneState,
  1226. emergencyState,
  1227. saveLoading: false,
  1228. visibleDialog: false,
  1229. curDateType: 'manufactureTime',
  1230. materialCodeReqListSelected: [],
  1231. // warehouseList: [], //仓库数组
  1232. // warehouse: {},
  1233. title: '',
  1234. tableData2: [],
  1235. uploadList: [],
  1236. supplierList: [],
  1237. warehousingMaterialList: [],
  1238. activeName: 'a',
  1239. loadTree: true,
  1240. selectEquiType: '',
  1241. batchTime: '',
  1242. dateVisible: false,
  1243. treeList: [],
  1244. staffList: [],
  1245. formData: {
  1246. extInfo: {
  1247. assetType: '', //物品类型
  1248. deptCode: '', //部门code
  1249. deptName: '', //部门名称
  1250. verifyDeptCode: '', //审核部门编码
  1251. verifyDeptName: '', //审核部门名称
  1252. deliveryName: '', //送货人名称
  1253. deliveryPhone: '', //送货人电话
  1254. documentSource: '', //销售订单
  1255. urgent: '', //紧急状态
  1256. supplierId: '', //供应商ID
  1257. supplierName: '', //供应商名称
  1258. createUserName: '', //创建人名字
  1259. contentImage: [] //图片数组
  1260. },
  1261. fromUser: '', //送货人
  1262. bizType: '', //物品类型
  1263. verifyId: '', //审核人Id
  1264. verifyName: '', //审核人名称
  1265. createUserId: '',
  1266. remark: ''
  1267. },
  1268. rules: {
  1269. 'extInfo.assetType': {
  1270. required: true,
  1271. message: '请选择物品类型',
  1272. trigger: 'change'
  1273. },
  1274. bizType: {
  1275. required: true,
  1276. message: '请选择入库场景',
  1277. trigger: 'change'
  1278. }
  1279. }
  1280. };
  1281. },
  1282. computed: {
  1283. // 条码信息
  1284. materialCodeReqList() {
  1285. return this.warehousingMaterialList
  1286. .map((i) => i.warehouseLedgerDetails || [])
  1287. .flat();
  1288. },
  1289. tableHeader() {
  1290. return tableHeader(this.selectEquiType);
  1291. }
  1292. },
  1293. created() {
  1294. if (this.$route.query.id) {
  1295. // this._getInfo()
  1296. } else {
  1297. let obj = localStorage.getItem('orgInfo')
  1298. ? JSON.parse(localStorage.getItem('orgInfo'))
  1299. : {};
  1300. this.formData.createUserName = obj.name;
  1301. this.formData.extInfo.deptName = obj.dept?.name;
  1302. this.formData.deptCode = obj.dept?.code;
  1303. }
  1304. this.initData();
  1305. },
  1306. methods: {
  1307. // 包装维度最小包装单元改变——>总重量
  1308. minPackingCountChange(row, value) {
  1309. if (value >= 0) {
  1310. row.minPackingCount = value;
  1311. } else {
  1312. row.minPackingCount = 0;
  1313. }
  1314. // row.minPackingCount = value.replace(/^(0+)|[^\d]+/g, '');
  1315. if (row.outInNum >= 0 && value >= 0) {
  1316. this.packNum(row, row.outInNum);
  1317. }
  1318. },
  1319. // 选择质检结果改变质检状态
  1320. changeWrapStatus(resultValue, row) {
  1321. switch (resultValue) {
  1322. case '':
  1323. // 清空质检状态
  1324. row.status = '0';
  1325. break;
  1326. default:
  1327. // 默认已检质检状态
  1328. row.status = '1';
  1329. break;
  1330. }
  1331. },
  1332. // 包装批量保存
  1333. wrapListSave() {
  1334. // 批量修改包装明细
  1335. this.isWeight = false;
  1336. this.bulkEditingWrap();
  1337. this.$nextTick(() => {
  1338. this.isWeight = true;
  1339. });
  1340. },
  1341. // 物料批量保存
  1342. materialListSave() {
  1343. this.resultArray.forEach((item) => {
  1344. if (!item.isPack) {
  1345. this.materialBtn(item);
  1346. }
  1347. });
  1348. },
  1349. weightInput(value, row) {
  1350. const newValue = value.replace(/[^\d.]/g, ''); // 保留数字和小数点
  1351. const decimalCount = (newValue.match(/\./g) || []).length; // 计算小数点的个数
  1352. if (decimalCount > 1) {
  1353. // 如果小数点个数大于1,移除多余的小数点
  1354. const lastIndex = newValue.lastIndexOf('.');
  1355. row.weight =
  1356. newValue.slice(0, lastIndex) + newValue.slice(lastIndex + 1);
  1357. } else if (decimalCount === 1) {
  1358. // 如果小数点个数等于1,允许小数点的输入
  1359. row.weight = newValue;
  1360. } else {
  1361. row.weight = newValue === '' ? 0 : parseFloat(newValue); // 如果输入为空,则设为0
  1362. }
  1363. },
  1364. handleIsDetail(event) {
  1365. this.isSplit = event;
  1366. const list = this.materialCodeReqList;
  1367. if (event) {
  1368. let resultArray = [];
  1369. list.forEach((item) => {
  1370. // 包装维度改成已保存状态
  1371. item.isPack = true;
  1372. // 拆分物料维度并生成列表
  1373. for (let i = 1; i <= Number(item.minPackingCount); i++) {
  1374. console.log(item.weight);
  1375. console.log(item.minPackingCount);
  1376. resultArray.push({
  1377. onlyCode: item.onlyCode,
  1378. no: item.onlyCode + i.toString().padStart(4, '0'),
  1379. assetCode: item.assetCode,
  1380. assetName: item.assetName,
  1381. manualBatchNo: item.manualBatchNo,
  1382. batchNo: item.batchNo,
  1383. minPackingCount: 1,
  1384. measuringUnit: item.measuringUnit,
  1385. materielCode: item.materielCode,
  1386. clientCode: item.clientCode,
  1387. weight: this.$math.format(
  1388. item.weight / Number(item.minPackingCount),
  1389. 14
  1390. ),
  1391. initWeight: this.$math.format(
  1392. item.weight / Number(item.minPackingCount),
  1393. 14
  1394. ),
  1395. weightUnit: item.weightUnit,
  1396. engrave: item.engrave,
  1397. result: item.result,
  1398. status: item.status,
  1399. isPack: false
  1400. });
  1401. }
  1402. });
  1403. this.resultArray = resultArray;
  1404. // 批量修改包装明细
  1405. this.isWeight = false;
  1406. this.bulkEditingWrap();
  1407. this.$nextTick(() => {
  1408. this.isWeight = true;
  1409. });
  1410. } else {
  1411. // 包装维度改成编辑状态
  1412. list.forEach((item) => {
  1413. item.isPack = false;
  1414. });
  1415. // 清空物料维度列表
  1416. this.resultArray = [];
  1417. }
  1418. },
  1419. //包装明细保存
  1420. packCout(row) {
  1421. //true保存==》反之
  1422. if (!row.isPack) {
  1423. row.isPack = true;
  1424. const code = row.assetCode;
  1425. const batchNo = row.batchNo;
  1426. //做防护,防止weight字符串类型
  1427. this.materialCodeReqList.forEach((ele) => {
  1428. ele.weight = Number(ele.weight);
  1429. });
  1430. // const count = this.materialCodeReqList.reduce(
  1431. // (acc, curr) => acc + curr.weight,
  1432. // 0
  1433. // );
  1434. // 修改产品信息重量(包装维度累计)
  1435. this.isWeight = false;
  1436. this.warehousingMaterialList.forEach((item) => {
  1437. if (item.assetCode == code && item.batchNo == batchNo) {
  1438. let arr = [];
  1439. for (const key in this.materialCodeReqList) {
  1440. if (
  1441. this.materialCodeReqList[key].assetCode == item.assetCode &&
  1442. this.materialCodeReqList[key].batchNo == item.batchNo
  1443. ) {
  1444. arr.push({ ...this.materialCodeReqList[key] });
  1445. }
  1446. }
  1447. const count = arr.reduce((acc, curr) => {
  1448. if (curr.isPack) {
  1449. this.$set(curr, 'initWeight', +curr.weight);
  1450. return Number(this.$math.format(+acc + +curr.weight, 14));
  1451. } else {
  1452. return Number(this.$math.format(+acc + +curr.initWeight, 14));
  1453. }
  1454. }, 0);
  1455. this.$set(item, 'weight', count);
  1456. }
  1457. });
  1458. this.$nextTick(() => {
  1459. this.isWeight = true;
  1460. });
  1461. } else {
  1462. row.isPack = false;
  1463. }
  1464. // setTimeout(() => {
  1465. // }, 100);
  1466. },
  1467. // 批量修改包装明细
  1468. bulkEditingWrap() {
  1469. // 批量修改包装明细列表状态(已保存)
  1470. this.materialCodeReqList.forEach((item) => {
  1471. item.isPack = true;
  1472. });
  1473. // 改变产品明细重量
  1474. this.warehousingMaterialList.forEach((outItem) => {
  1475. let arr = [];
  1476. this.materialCodeReqList.forEach((inneritem) => {
  1477. if (
  1478. inneritem.assetCode == outItem.assetCode &&
  1479. inneritem.batchNo == outItem.batchNo
  1480. ) {
  1481. arr.push(inneritem);
  1482. }
  1483. });
  1484. const count = arr.reduce((acc, curr) => {
  1485. if (curr.isPack) {
  1486. this.$set(curr, 'initWeight', +curr.weight);
  1487. return Number(this.$math.format(+acc + +curr.weight, 14));
  1488. } else {
  1489. return Number(this.$math.format(+acc + +curr.initWeight, 14));
  1490. }
  1491. }, 0);
  1492. this.$set(outItem, 'weight', count);
  1493. });
  1494. },
  1495. // 批量修改物料明细
  1496. bulkEditingMaterial() {
  1497. // 批量修改物料明细列表状态(已保存)
  1498. this.resultArray.forEach((item) => {
  1499. item.isPack = true;
  1500. });
  1501. // 改变包装明细重量
  1502. this.materialCodeReqList.forEach((outItem) => {
  1503. let arr = [];
  1504. this.resultArray.forEach((inneritem) => {
  1505. if (
  1506. inneritem.assetCode == outItem.assetCode &&
  1507. inneritem.batchNo == outItem.batchNo
  1508. ) {
  1509. arr.push(inneritem);
  1510. }
  1511. });
  1512. const count = arr.reduce((acc, curr) => {
  1513. if (curr.isPack) {
  1514. this.$set(curr, 'initWeight', +curr.weight);
  1515. return Number(this.$math.format(+acc + +curr.weight, 14));
  1516. } else {
  1517. return Number(this.$math.format(+acc + +curr.initWeight, 14));
  1518. }
  1519. }, 0);
  1520. this.$set(outItem, 'weight', count);
  1521. });
  1522. },
  1523. // 物料明细保存
  1524. materialBtn(row) {
  1525. console.log(row);
  1526. console.log(this.resultArray);
  1527. console.log(this.materialCodeReqList);
  1528. // true保存 false编辑
  1529. if (!row.isPack) {
  1530. row.isPack = true;
  1531. // 物料维度修改质检改变包装维度质检(结果和状态)
  1532. this.materialCodeReqList.forEach((outItem) => {
  1533. let arr = [];
  1534. this.resultArray.forEach((inneritem) => {
  1535. if (inneritem.onlyCode == outItem.onlyCode) {
  1536. arr.push(inneritem);
  1537. }
  1538. });
  1539. console.log(arr);
  1540. // 首先判断是未填/合格不合格
  1541. let boolen = arr.every((item) => {
  1542. return item.result === '' || item.result === undefined;
  1543. });
  1544. // 判断只要物料全部质检结果(未填)——>包装质检结果(未填) 状态(未检)
  1545. if (boolen) {
  1546. this.$set(outItem, 'result', '');
  1547. this.$set(outItem, 'status', '0');
  1548. } else {
  1549. // 判断只要物料有一个质检结果(不合格)——>包装质检结果(不合格) 状态(已检)
  1550. let boolen = arr.some((item) => {
  1551. return item.result === '1';
  1552. });
  1553. if (boolen) {
  1554. this.$set(outItem, 'result', '1');
  1555. this.$set(outItem, 'status', '1');
  1556. } else {
  1557. // 判断只要物料有一个质检结果(让步接收)——>包装质检结果(让步接收) 状态(已检)
  1558. let boolen = arr.some((item) => {
  1559. return item.result === '3';
  1560. });
  1561. if (boolen) {
  1562. // 让步接收 已检
  1563. this.$set(outItem, 'result', '3');
  1564. this.$set(outItem, 'status', '1');
  1565. } else {
  1566. // 判断只要物料有全部质检结果(合格)——>包装质检结果(合格) 状态(已检)
  1567. let boolen = arr.every((item) => {
  1568. return item.result === '0';
  1569. });
  1570. if (boolen) {
  1571. // 合格 已检
  1572. this.$set(outItem, 'result', '0');
  1573. this.$set(outItem, 'status', '1');
  1574. } else {
  1575. // 合格 部分检
  1576. this.$set(outItem, 'result', '0');
  1577. this.$set(outItem, 'status', '2');
  1578. }
  1579. }
  1580. }
  1581. }
  1582. // this.$set(outItem, 'result', boolen ? '1' : '0');
  1583. });
  1584. // 物料维度修改重量改变包装维度重量
  1585. let onlyCode = row.onlyCode;
  1586. this.materialCodeReqList.forEach((item) => {
  1587. if (item.onlyCode === onlyCode) {
  1588. let arr = [];
  1589. for (const key in this.resultArray) {
  1590. if (this.resultArray[key].onlyCode == item.onlyCode) {
  1591. arr.push(this.resultArray[key]);
  1592. }
  1593. }
  1594. const count = arr.reduce((acc, curr) => {
  1595. if (curr.isPack) {
  1596. this.$set(curr, 'initWeight', +curr.weight);
  1597. return Number(this.$math.format(+acc + +curr.weight, 14));
  1598. } else {
  1599. return Number(this.$math.format(+acc + +curr.initWeight, 14));
  1600. }
  1601. }, 0);
  1602. this.$set(item, 'weight', count);
  1603. }
  1604. });
  1605. // 包装维度修改重量改变产品信息
  1606. this.isWeight = false;
  1607. // 批量修改包装明细
  1608. this.bulkEditingWrap();
  1609. this.$nextTick(() => {
  1610. this.isWeight = true;
  1611. });
  1612. } else {
  1613. row.isPack = false;
  1614. }
  1615. },
  1616. packNum(row, value) {
  1617. const total = {
  1618. packingCount: Number(
  1619. row.minPackingCount > 0 ? row.minPackingCount : 0
  1620. ),
  1621. outInNum: Number(row.outInNum > 0 ? row.outInNum : 0)
  1622. };
  1623. if (row.measuringUnit == row.weightUnit) {
  1624. row.weight = Number(
  1625. this.$math.format(
  1626. total.packingCount * 1 * total.outInNum.toFixed(2),
  1627. 14
  1628. )
  1629. );
  1630. } else {
  1631. const totals = Number(
  1632. this.$math.format(total.packingCount * total.outInNum, 14)
  1633. );
  1634. row.weight = Number(
  1635. this.$math.format(
  1636. totals * (row.netWeight > 0 ? row.netWeight.toFixed(2) : 0),
  1637. 14
  1638. )
  1639. );
  1640. }
  1641. return (row.outInNum = value.replace(/^(0+)|[^\d]+/g, ''));
  1642. },
  1643. async searchContact(id) {
  1644. const data = await contactlink({ contactId: id });
  1645. this.contactList = data.data;
  1646. },
  1647. async pickerSuccess(row) {
  1648. this.pickerRow = row;
  1649. this.formData.extInfo.documentSource = row.orderNo;
  1650. this.formData.clientName = row.partaName;
  1651. this.formData.clientCode = row.partaId;
  1652. this.formData.extInfo.supplierName = row.partbName;
  1653. this.formData.extInfo.supplierId = row.partbId;
  1654. await this.searchContact(row.partbId);
  1655. const data = await oneId(row.id);
  1656. if (this.warehousingMaterialList.length == 0) {
  1657. console.log('data===', data);
  1658. let list = data.data.productList.map((item) => {
  1659. return {
  1660. ...item,
  1661. assetName: item.productName,
  1662. assetCode: item.productCode,
  1663. categoryId: item.productCategoryId,
  1664. minPackUnit: item.packingUnit
  1665. };
  1666. });
  1667. this.onSelectTableData(await this.serachMainCode(list));
  1668. }
  1669. },
  1670. async serachMainCode(arr) {
  1671. let newArr = [];
  1672. // 使用 Promise.all 来等待所有异步操作完成
  1673. await Promise.all(
  1674. arr.map(async (item) => {
  1675. const data = await getProductList({
  1676. pageNum: 1,
  1677. size: 10,
  1678. categoryLevelId: item.categoryLevelPathIdParent,
  1679. code: item.assetCode
  1680. });
  1681. newArr.push(data.list); // 将结果存储到 newArr 中
  1682. })
  1683. );
  1684. let re = [];
  1685. for (const item of newArr) {
  1686. for (const it of item) {
  1687. re.push(it);
  1688. }
  1689. }
  1690. return re.map((item) => {
  1691. return {
  1692. ...item,
  1693. minPackUnit: item.packingUnit,
  1694. assetCode: item.code,
  1695. assetName: item.name
  1696. };
  1697. });
  1698. },
  1699. onClear() {
  1700. this.formData.extInfo.documentSource = '';
  1701. this.pickerRow = {};
  1702. this.formData.clientName = '';
  1703. this.formData.clientCode = '';
  1704. this.formData.extInfo.supplierName = '';
  1705. this.formData.extInfo.supplierId = '';
  1706. this.$forceUpdate();
  1707. },
  1708. handlePicker() {
  1709. this.$refs.pickerRef.open();
  1710. },
  1711. codeListValue(val) {
  1712. this.formData.extInfo.assetType = val.id;
  1713. this.$forceUpdate();
  1714. this.title = val?.name;
  1715. this.selectEquiType = val?.id;
  1716. },
  1717. //计算生产设备重量
  1718. deviceWeight(row, num) {
  1719. if (row) {
  1720. return Number(row * num);
  1721. } else {
  1722. return row;
  1723. }
  1724. },
  1725. //计算金额
  1726. calcSumTotal(PackingCount, outInNum, univalence) {
  1727. //最小包装单元,包装数量,单价
  1728. const total = {
  1729. PackingCount: Number(PackingCount > 0 ? PackingCount : 0),
  1730. outInNum: Number(outInNum > 0 ? outInNum : 0),
  1731. univalence: Number(univalence > 0 ? univalence : 0)
  1732. };
  1733. return Number(
  1734. this.$math.format(
  1735. total.PackingCount * total.outInNum * total.univalence,
  1736. 14
  1737. )
  1738. );
  1739. },
  1740. handleRowUnit(row) {
  1741. return row.measuringUnit;
  1742. // if (this.formData.extInfo.assetType == 1) {
  1743. // return row.weightUnit;
  1744. // } else if (this.formData.extInfo.assetType == 4) {
  1745. // return row.measuringUnit;
  1746. // } else {
  1747. // return row.measuringUnit;
  1748. // }
  1749. },
  1750. changeVerfy(it) {
  1751. this.formData.verifyName = it.name;
  1752. },
  1753. //选择供应啥的操作
  1754. ChangeSupplier(data) {
  1755. this.formData.extInfo.supplierName = data.dictValue;
  1756. },
  1757. ChangeSuppliers(data) {
  1758. this.formData.clientName = data.dictValue;
  1759. },
  1760. rowClass({ row, column, rowIndex, columnIndex }) {
  1761. if (rowIndex === 1) {
  1762. return {
  1763. display: 'none',
  1764. background: '#EEEEEE',
  1765. border: 'none'
  1766. };
  1767. }
  1768. return { background: '#EEEEEE', border: 'none' };
  1769. },
  1770. calcSum(a, b, c, row) {
  1771. if (
  1772. (Number.isNaN(+a) && a !== '') ||
  1773. (Number.isNaN(+b) && b !== '') ||
  1774. (Number.isNaN(+c) && c !== '')
  1775. ) {
  1776. return '';
  1777. }
  1778. return a * b * c + { yuan: '元', wanyuan: '万元' }[row.univalenceUnit];
  1779. // return a * b * c;
  1780. },
  1781. // 部门 点击事件
  1782. async auditorDeptClick(data) {
  1783. this.formData.extInfo.verifyDeptCode = data?.id;
  1784. this.formData.extInfo.verifyDeptName = data?.name;
  1785. this.formData.verifyId = '';
  1786. this.formData.verifyName = '';
  1787. this.$refs.formName.validateField('verifyDeptName');
  1788. if (data) {
  1789. this.getStaffList(data);
  1790. }
  1791. },
  1792. async getStaffList(data) {
  1793. let res = await warehouseDefinition.getUserPage({
  1794. groupId: data.id,
  1795. size: 9999,
  1796. page: 1
  1797. });
  1798. this.staffList = res.list;
  1799. },
  1800. // 详情接口
  1801. // async _getInfo () {
  1802. // const res = await getInfo({ id: this.$route.query.id })
  1803. // if (res?.success) {
  1804. // this.warehousingMaterialList = res.data.warehouseLedgerInfos.map(i => {
  1805. // i.isSave = true
  1806. // return i
  1807. // })
  1808. // this.formData = res.data.outInWarehouse
  1809. // this.uploadList = this.formData.contentImage
  1810. // }
  1811. // },
  1812. chooseAssets(row, index) {
  1813. this.$refs.returnSelectRef.open(row, (res) => {
  1814. row.outInNum = res.length;
  1815. this.$set(
  1816. row,
  1817. 'selfWarehouseLedgerDetails',
  1818. res.map((i) => {
  1819. delete i.updateTime;
  1820. delete i.createTime;
  1821. return i;
  1822. })
  1823. );
  1824. });
  1825. },
  1826. // 仓库编辑
  1827. handleWareHouse(row, idx) {
  1828. this.$refs.wareHouseDailogRef.open(row, idx);
  1829. },
  1830. // 入库操作
  1831. listEdit(row) {
  1832. this.$set(row, 'isSave', false);
  1833. row.selfWarehouseLedgerDetails = row.warehouseLedgerDetails;
  1834. row.warehouseLedgerDetails = [];
  1835. // 重置重量
  1836. this.packNum(row, row.outInNum);
  1837. // 清空物料明细防止数据错乱
  1838. if (this.isSplit && this.resultArray?.length > 0) {
  1839. this.handleIsDetail(false);
  1840. }
  1841. },
  1842. listSave(row, index) {
  1843. if (this.isSplit && this.resultArray?.length > 0) {
  1844. this.handleIsDetail(false);
  1845. }
  1846. const fileds = [
  1847. // `warehousingMaterialList.${index}.cargoSpaceCode`,
  1848. `warehousingMaterialList.${index}.batchNo`,
  1849. `warehousingMaterialList.${index}.houseList`
  1850. ];
  1851. if (this.formData.bizType == 1) {
  1852. // fileds.push(...[`warehousingMaterialList.${index}.customCode`]);
  1853. } else if (this.formData.bizType == 2) {
  1854. // fileds.push(...[`warehousingMaterialList.${index}.supplierCode`]);
  1855. }
  1856. if (this.formData.bizType != 5) {
  1857. fileds.push(
  1858. ...[
  1859. `warehousingMaterialList.${index}.outInNum`,
  1860. `warehousingMaterialList.${index}.minPackingCount`
  1861. ]
  1862. );
  1863. } else if (
  1864. this.warehousingMaterialList.some(
  1865. (i) => !i.selfWarehouseLedgerDetails?.length
  1866. )
  1867. ) {
  1868. this.$message.error('请选择资产编号!');
  1869. return;
  1870. }
  1871. Promise.all(
  1872. fileds.map(
  1873. (item) =>
  1874. new Promise(async (resolve, rej) => {
  1875. this.$refs.warehousingMaterialListRef.validateField(
  1876. item,
  1877. (err) => {
  1878. if (err) {
  1879. rej(err);
  1880. } else {
  1881. resolve();
  1882. }
  1883. }
  1884. );
  1885. })
  1886. )
  1887. )
  1888. .then((res) => {
  1889. this.$set(row, 'isSave', true);
  1890. if (this.formData.bizType != 5) {
  1891. this.createMaterialCode(row);
  1892. } else {
  1893. // 退还
  1894. this.createMaterialCodeReturn(row);
  1895. }
  1896. })
  1897. .catch((err) => {
  1898. this.$message.error('请填入必填项!');
  1899. });
  1900. },
  1901. listSaveArrs() {
  1902. // 已经拆分(还原到未拆封编辑状态)
  1903. if (this.isSplit && this.resultArray.length > 0) {
  1904. this.handleIsDetail(false);
  1905. }
  1906. const rows = this.warehousingMaterialList;
  1907. const indexes = Array.from(
  1908. { length: this.warehousingMaterialList.length },
  1909. (_, index) => index
  1910. );
  1911. let showMessage = true;
  1912. rows.forEach((row, i) => {
  1913. const index = indexes[i];
  1914. const fileds = [
  1915. // `warehousingMaterialList.${index}.cargoSpaceCode`,
  1916. `warehousingMaterialList.${index}.batchNo`,
  1917. `warehousingMaterialList.${index}.houseList`
  1918. ];
  1919. if (this.formData.bizType == 1) {
  1920. // fileds.push(...[`warehousingMaterialList.${index}.customCode`]);
  1921. } else if (this.formData.bizType == 2) {
  1922. // fileds.push(...[`warehousingMaterialList.${index}.supplierCode`]);
  1923. }
  1924. if (this.formData.bizType != 5) {
  1925. fileds.push(
  1926. ...[
  1927. `warehousingMaterialList.${index}.outInNum`,
  1928. `warehousingMaterialList.${index}.minPackingCount`
  1929. ]
  1930. );
  1931. } else if (
  1932. this.warehousingMaterialList.some(
  1933. (i) => !i.selfWarehouseLedgerDetails?.length
  1934. )
  1935. ) {
  1936. this.$message.error('请选择资产编号!');
  1937. return;
  1938. }
  1939. Promise.all(
  1940. fileds.map(
  1941. (item) =>
  1942. new Promise(async (resolve, rej) => {
  1943. this.$refs.warehousingMaterialListRef.validateField(
  1944. item,
  1945. (err) => {
  1946. if (err) {
  1947. rej(err);
  1948. } else {
  1949. resolve();
  1950. }
  1951. }
  1952. );
  1953. })
  1954. )
  1955. )
  1956. .then((res) => {
  1957. this.$set(row, 'isSave', true);
  1958. if (this.formData.bizType != 5) {
  1959. this.createMaterialCode(row);
  1960. } else {
  1961. // 退还
  1962. this.createMaterialCodeReturn(row);
  1963. }
  1964. })
  1965. .catch((err) => {
  1966. if (showMessage) {
  1967. showMessage = false;
  1968. this.$message.error('请填入必填项!');
  1969. }
  1970. });
  1971. });
  1972. },
  1973. // listSaveArrs() {
  1974. // console.log(this.warehousingMaterialList);
  1975. // },
  1976. // 批量设置生产日期
  1977. handleSelectionChange(val) {
  1978. this.materialCodeReqListSelected = val;
  1979. },
  1980. dateSetting() {
  1981. if (!this.materialCodeReqListSelected.length) {
  1982. return this.$message.error(`请选择${this.title}明细!`);
  1983. }
  1984. this.dateVisible = true;
  1985. },
  1986. dateConfirm() {
  1987. this.materialCodeReqListSelected.forEach((item) => {
  1988. this.$set(item, this.curDateType, this.batchTime);
  1989. });
  1990. this.dateVisible = false;
  1991. },
  1992. //入库明细删除
  1993. listDel(row, index) {
  1994. this.warehousingMaterialList.splice(index, 1);
  1995. if (this.isSplit && this.resultArray?.length > 0) {
  1996. this.handleIsDetail(false);
  1997. }
  1998. },
  1999. // 入库明细生成条码信息
  2000. async createMaterialCode(row) {
  2001. // 添加相同物品、批次号重新更新明细 原料编码
  2002. const list = this.warehousingMaterialList.filter(
  2003. (i) =>
  2004. i.assetCode === row.assetCode &&
  2005. i.batchNo === row.batchNo &&
  2006. i.isSave
  2007. );
  2008. const num = list.reduce((num, pre) => {
  2009. num += row.isUnpack
  2010. ? Number(this.$math.format(pre.outInNum * pre.minPackingCount, 14))
  2011. : pre.outInNum - 0;
  2012. return num;
  2013. }, 0);
  2014. const nums = list.reduce((num, pre) => {
  2015. num += Number(
  2016. this.$math.format(pre.outInNum * pre.minPackingCount, 14)
  2017. );
  2018. return num;
  2019. }, 0);
  2020. const res = await outin.getAssetNum({
  2021. assetCode: row.assetCode,
  2022. batchNum: row.batchNo,
  2023. num: num
  2024. });
  2025. // row.measuringUnit == 'PCS' ? nums :
  2026. list.forEach((item) => {
  2027. if (item.warehouseLedgerDetails?.length) {
  2028. item.warehouseLedgerDetails.forEach((i) => {
  2029. i.onlyCode = res.shift().onlyCode;
  2030. });
  2031. } else {
  2032. this.$set(
  2033. item,
  2034. 'warehouseLedgerDetails',
  2035. Array.from(
  2036. new Array(
  2037. item.isUnpack
  2038. ? Number(
  2039. this.$math.format(
  2040. item.outInNum * item.minPackingCount,
  2041. 14
  2042. )
  2043. )
  2044. : // : item.measuringUnit == 'PCS'
  2045. // ? +item.outInNum * parseInt(item.minPackingCount)
  2046. +item.outInNum
  2047. ),
  2048. (val, idx) => {
  2049. return {
  2050. ...item,
  2051. onlyCode: res.shift().onlyCode,
  2052. bizStatus: 1,
  2053. contentImage: []
  2054. };
  2055. }
  2056. )
  2057. );
  2058. }
  2059. });
  2060. // 添加相同物品,重复批次号 重新更新明细 包装编码
  2061. const batchList = this.warehousingMaterialList.filter(
  2062. (i) => i.batchNo === row.batchNo && i.isSave
  2063. );
  2064. if (batchList.length) {
  2065. const num = batchList.reduce((num, pre) => {
  2066. num += +pre.outInNum;
  2067. return num;
  2068. }, 0);
  2069. const res1 = await outin.getAssetNum({
  2070. batchNum: row.batchNo,
  2071. num
  2072. });
  2073. if (res1) {
  2074. batchList.forEach((item) => {
  2075. let num = res1.shift()?.num;
  2076. let minPackingCount = item.minPackingCount;
  2077. if (item.warehouseLedgerDetails?.length) {
  2078. item.warehouseLedgerDetails.forEach((i, index) => {
  2079. this.$set(i, 'num', num);
  2080. console.log('i---', i);
  2081. console.log('row---', row);
  2082. if (row.code == i.code) {
  2083. if (item.measuringUnit == item.weightUnit) {
  2084. this.$set(i, 'weight', item.minPackingCount);
  2085. this.$set(i, 'initWeight', item.minPackingCount);
  2086. } else {
  2087. this.$set(
  2088. i,
  2089. 'weight',
  2090. Number(
  2091. this.$math.format(
  2092. 1 * item.minPackingCount * item.netWeight,
  2093. 14
  2094. )
  2095. )
  2096. );
  2097. this.$set(
  2098. i,
  2099. 'initWeight',
  2100. Number(
  2101. this.$math.format(
  2102. 1 * item.minPackingCount * item.netWeight,
  2103. 14
  2104. )
  2105. )
  2106. );
  2107. }
  2108. }
  2109. this.$set(i, 'weightUtil', item.weightUnit);
  2110. this.$set(i, 'packingCount', 1);
  2111. this.$set(i, 'packingUnit ', item.packingUnit);
  2112. this.$set(i, 'minPackingCount ', item.minPackingCount);
  2113. this.$set(i, 'measuringUnit', item.measuringUnit);
  2114. this.$set(i, 'isPack', false);
  2115. if (this.formData.extInfo.assetType == 1) {
  2116. this.$set(i, 'status', '0');
  2117. } else {
  2118. this.$set(i, 'result', '0');
  2119. this.$set(i, 'status', '1');
  2120. }
  2121. if (!item.isUnpack) {
  2122. if (index < item.warehouseLedgerDetails.length - 1) {
  2123. num = res1.shift()?.num;
  2124. }
  2125. } else {
  2126. // 拆包的包装编码一致
  2127. minPackingCount--;
  2128. if (
  2129. minPackingCount === 0 &&
  2130. index < item.warehouseLedgerDetails.length - 1
  2131. ) {
  2132. minPackingCount = item.minPackingCount;
  2133. num = res1.shift()?.num;
  2134. }
  2135. }
  2136. });
  2137. }
  2138. });
  2139. }
  2140. }
  2141. },
  2142. // 入库明细生成条码信息 退还
  2143. async createMaterialCodeReturn(row) {
  2144. // 添加相同物品重新更新明细 原料编码
  2145. const list = this.warehousingMaterialList.filter(
  2146. (i) => i.batchNo === row.batchNo && i.isSave
  2147. );
  2148. // 退还
  2149. const res = await getAssetNum({
  2150. batchNo: row.batchNo,
  2151. num: list.reduce((num, pre) => {
  2152. num += pre.selfWarehouseLedgerDetails.length;
  2153. return num;
  2154. }, 0)
  2155. });
  2156. if (res?.success) {
  2157. list.forEach((item) => {
  2158. let num = res.data.shift().num;
  2159. let minPackingCount = item.minPackingCount;
  2160. if (item.warehouseLedgerDetails?.length) {
  2161. item.warehouseLedgerDetails.forEach((i, index) => {
  2162. Object.assign(i, {
  2163. num,
  2164. manualBatchNo: item.manualBatchNo,
  2165. batchNo: item.batchNo,
  2166. cargoSpaceCode: item.cargoSpaceCode, //货位编码
  2167. cargoSpaceId: item.cargoSpaceId, //货位id
  2168. shelfId: item.shelfId, //货架id
  2169. shelfCode: item.shelfCode, //货架名称
  2170. areaId: item.areaId, //库区id
  2171. areaName: item.areaName, //库区名称
  2172. warehouseId: item.warehouseId, //仓库id
  2173. warehouseName: item.warehouseName //仓库名称
  2174. });
  2175. if (!item.isUnpack) {
  2176. // 拆包的包装编码一致
  2177. if (index < item.warehouseLedgerDetails.length - 1) {
  2178. num = res.data.shift()?.num;
  2179. }
  2180. } else {
  2181. minPackingCount--;
  2182. if (
  2183. minPackingCount === 0 &&
  2184. index < item.warehouseLedgerDetails.length - 1
  2185. ) {
  2186. minPackingCount = item.minPackingCount;
  2187. num = res1.data.shift()?.num;
  2188. }
  2189. }
  2190. });
  2191. } else {
  2192. this.$set(
  2193. item,
  2194. 'warehouseLedgerDetails',
  2195. item.selfWarehouseLedgerDetails.map((val, idx) => {
  2196. let obj = {
  2197. ...val,
  2198. bizStatus: 1,
  2199. minPackingCount: item.minPackingCount,
  2200. batchNo: item.batchNo,
  2201. cargoSpaceCode: item.cargoSpaceCode, //货位编码
  2202. cargoSpaceId: item.cargoSpaceId, //货位id
  2203. shelfId: item.shelfId, //货架id
  2204. shelfCode: item.shelfCode, //货架名称
  2205. areaId: item.areaId, //库区id
  2206. areaName: item.areaName, //库区名称
  2207. warehouseId: item.warehouseId, //仓库id
  2208. warehouseName: item.warehouseName, //仓库名称
  2209. materialId: item.materialId,
  2210. num
  2211. };
  2212. if (!item.isUnpack) {
  2213. // 拆包的包装编码一致
  2214. if (idx < item.warehouseLedgerDetails.length - 1) {
  2215. num = res.data.shift()?.num;
  2216. }
  2217. } else {
  2218. minPackingCount--;
  2219. if (
  2220. minPackingCount === 0 &&
  2221. idx < item.warehouseLedgerDetails.length - 1
  2222. ) {
  2223. minPackingCount = item.minPackingCount;
  2224. num = res1.data.shift()?.num;
  2225. }
  2226. }
  2227. return obj;
  2228. })
  2229. );
  2230. }
  2231. });
  2232. }
  2233. },
  2234. handleSave() {
  2235. this.$refs.formName.validate(async (valid) => {
  2236. if (valid) {
  2237. if (!this.warehousingMaterialList?.length) {
  2238. return this.$message.error('请添加入库明细!');
  2239. } else if (
  2240. this.warehousingMaterialList.some((item) => !item.isSave)
  2241. ) {
  2242. return this.$message.error('请保存入库明细!');
  2243. }
  2244. // 默认全部保存
  2245. if (this.resultArray?.length > 0) {
  2246. // 物料批量保存
  2247. this.materialListSave();
  2248. } else {
  2249. // 包装批量保存
  2250. this.wrapListSave();
  2251. }
  2252. this.formatWarehouseMaterialList();
  2253. let arr = this.warehousingMaterialList.map((item) => {
  2254. return {
  2255. netWeight: item.netWeight > 0 ? item.netWeight : 0,
  2256. num: item.num > 0 ? item.num : 0,
  2257. manualBatchNo: item.manualBatchNo,
  2258. batchNo: item.batchNo,
  2259. categoryId:
  2260. this.formData.bizType == 2
  2261. ? item.categoryId
  2262. ? item.categoryId
  2263. : item.id
  2264. : item.id,
  2265. count:
  2266. item.outInNum > 0 && item.minPackingCount > 0
  2267. ? this.$math.format(
  2268. parseInt(item.outInNum) *
  2269. parseInt(item.minPackingCount),
  2270. 14
  2271. )
  2272. : 0,
  2273. minPackingCount:
  2274. item.minPackingCount > 0 ? item.minPackingCount : 0,
  2275. packingCount: item.outInNum > 0 ? item.outInNum : 0,
  2276. price: item.univalence > 0 ? item.univalence : 0,
  2277. outInDetailRecordAddPOList: item.warehouseLedgerDetails,
  2278. position: `${item.warehouseName}-${item.areaName}-${item.shelfCode}-${item.cargoSpaceCode}`,
  2279. remark: '',
  2280. pathIds: `${item.warehouseId},${item.areaId},${item.shelfId},${item.cargoSpaceId}`,
  2281. pathName: `${item.warehouseName},${item.areaName},${item.shelfCode},${item.cargoSpaceCode}`,
  2282. totalMoney:
  2283. item.outInNum > 0 &&
  2284. item.minPackingCount > 0 &&
  2285. item.univalence > 0
  2286. ? this.$math.format(
  2287. item.outInNum * item.minPackingCount * item.univalence,
  2288. 14
  2289. )
  2290. : 0,
  2291. weightUnit: item.weightUnit,
  2292. customCode: item.customCode,
  2293. supplierCode: item.supplierCode,
  2294. weight: item.weight > 0 ? item.weight : 0
  2295. };
  2296. });
  2297. arr.forEach((item) => {
  2298. if (item.outInDetailRecordAddPOList.length > 0) {
  2299. let list = item.outInDetailRecordAddPOList.map((it) => {
  2300. return this.formatOutInDetailRecordAddPO(it, item);
  2301. });
  2302. item.outInDetailRecordAddPOList = list;
  2303. }
  2304. });
  2305. let obj = { ...this.formData, type: 1 };
  2306. obj.sourceBizNo = this.formData.extInfo.documentSource;
  2307. obj.outInDetailAddPOList = arr;
  2308. console.log('=====>', obj);
  2309. this.saveLoading = true;
  2310. try {
  2311. const res = await outin.save(obj);
  2312. if (res.code == 0) {
  2313. await outin.outApproves({ outInId: res.data[0] });
  2314. this.$message.success('保存成功!');
  2315. }
  2316. } catch (error) {
  2317. console.error('保存失败:', error);
  2318. }
  2319. this.saveLoading = false;
  2320. this.$router.push('/warehouseManagement/stockManagement');
  2321. }
  2322. });
  2323. },
  2324. formatWarehouseMaterialList() {
  2325. for (let key in this.warehousingMaterialList) {
  2326. for (let k in this.warehousingMaterialList[key].houseList) {
  2327. let house = this.warehousingMaterialList[key].houseList[k];
  2328. this.warehousingMaterialList[key].warehouseName =
  2329. house.warehouseName;
  2330. this.warehousingMaterialList[key].areaName = house.areaName;
  2331. this.warehousingMaterialList[key].shelfCode = house.shelfCode;
  2332. this.warehousingMaterialList[key].cargoSpaceCode =
  2333. house.cargoSpaceCode;
  2334. this.warehousingMaterialList[key].warehouseId = house.warehouseId;
  2335. this.warehousingMaterialList[key].areaId = house.areaId;
  2336. this.warehousingMaterialList[key].shelfId = house.shelfId;
  2337. this.warehousingMaterialList[key].cargoSpaceId = house.cargoSpaceId;
  2338. this.warehousingMaterialList[key].num = house.num;
  2339. }
  2340. }
  2341. },
  2342. formatOutInDetailRecordAddPO(it, item) {
  2343. return {
  2344. code: it.onlyCode,
  2345. dateType: this.curDateType === 'manufactureTime' ? 2 : 1,
  2346. dateValue: it[this.curDateType],
  2347. minUnit: it.minPackingCount,
  2348. minPackingCount: it.minPackingCount,
  2349. minPositionId: it.cargoSpaceId,
  2350. name: it.assetName,
  2351. pathIds: item.pathIds,
  2352. unit: it.unit,
  2353. packageNo: it.num,
  2354. clientCode: it.clientCode,
  2355. materielCode: it.materielCode,
  2356. weight: it.weight,
  2357. weightUtil: it.weightUtil,
  2358. engrave: it.engrave,
  2359. materialDetails: this.materialDetails(it.onlyCode),
  2360. packingCount: it.packingCount,
  2361. status: it.status,
  2362. result: it.result
  2363. };
  2364. },
  2365. materialDetails(onlyCode) {
  2366. return this.resultArray.filter((item) => item.onlyCode === onlyCode);
  2367. },
  2368. async getOrderCode() {
  2369. const data = await getCode('in_warehouse');
  2370. return data;
  2371. },
  2372. // 添加物品明细
  2373. addProduct(val) {
  2374. // 已经拆分(还原到未拆封编辑状态)
  2375. if (this.isSplit && this.resultArray.length > 0) {
  2376. this.handleIsDetail(false);
  2377. }
  2378. this.onSelectTableData(val);
  2379. },
  2380. //添加明细
  2381. async onSelectTableData(val) {
  2382. const res = await getCode('lot_number_code');
  2383. this.warehousingMaterialList.push(
  2384. ...val.map((next) => {
  2385. next.batchNo = res;
  2386. let cur = {};
  2387. next.realInventoryAmount = next.realInventoryAmount || 0;
  2388. cur = {
  2389. ...next,
  2390. cargoSpaceCode: '', //货位编码
  2391. cargoSpaceId: '', //货位id
  2392. shelfId: '', //货架id
  2393. shelfCode: '', //货架名称
  2394. areaId: '', //库区id
  2395. areaName: '', //库区名称
  2396. warehouseId: '', //仓库id
  2397. warehouseName: '', //仓库名称
  2398. assetType: this.formData.extInfo.assetType,
  2399. expirationDate: '',
  2400. outInNum: '',
  2401. minPackingCount: '',
  2402. bizStatus: 1,
  2403. contentImage: [],
  2404. warehouseLedgerDetails: [],
  2405. houseList: []
  2406. };
  2407. return cur;
  2408. })
  2409. );
  2410. },
  2411. async initData() {
  2412. const { data } = await getTreeByGroup({ type: 2 });
  2413. this.codeList = data;
  2414. // .map((item) => {
  2415. // return { dictCode: item.id, dictValue: item.name };
  2416. // });
  2417. const res = await warehouseDefinition.tree();
  2418. this.treeList = this.$util.toTreeData({
  2419. data: res,
  2420. idField: 'id',
  2421. parentIdField: 'parentId'
  2422. });
  2423. // const res111 = await warehouseDefinition.list();
  2424. // this.warehouseList = res111.list;
  2425. let res22 = await warehouseDefinition.getUserPage({
  2426. size: -1,
  2427. page: 1
  2428. });
  2429. this.fromUserList = res22.list;
  2430. const info = JSON.parse(localStorage.getItem('info'));
  2431. let obj = res.find(
  2432. (item) => item.id === info.deptId[info.deptId.length - 1]
  2433. );
  2434. if (!obj) return;
  2435. this.formData.extInfo.deptCode = obj.id;
  2436. this.formData.extInfo.deptName = obj.name;
  2437. this.formData.extInfo.createUserName = info.name;
  2438. this.formData.createUserId = info.id;
  2439. // this.treeList = res;
  2440. // this.formData.extInfo.deptCode =
  2441. // this.getTreeList().then((res) => {
  2442. // if (res?.success) {
  2443. // this.treeList = res.data;
  2444. // }
  2445. // });
  2446. // this.getSupplier().then((res) => {
  2447. // if (res?.success) {
  2448. // this.supplierList = res.data.items;
  2449. // }
  2450. // });
  2451. // this.getStaffList();
  2452. },
  2453. addStock() {
  2454. // this.$refs.wareHouseDailogRef.open({});
  2455. // return;
  2456. if (!this.title) return this.$message.error('请选择入库产品类型');
  2457. if (!this.formData.bizType)
  2458. return this.$message.error('请选择入库场景');
  2459. this.visibleDialog = true;
  2460. },
  2461. handleChange(data) {
  2462. this.title = data?.dictValue;
  2463. this.selectEquiType = data?.dictCode;
  2464. },
  2465. handleChanges(code) {
  2466. const data = this.codeList.find((item) => item.dictCode == code);
  2467. this.title = data?.dictValue;
  2468. this.selectEquiType = data?.dictCode;
  2469. },
  2470. getSupplier() {
  2471. return new Promise((resolve, reject) => {
  2472. supplier.list({ page: 1, size: 999 }).then((res) => {
  2473. if (res.success) {
  2474. resolve(res);
  2475. }
  2476. });
  2477. });
  2478. },
  2479. getTreeList() {
  2480. return new Promise((resolve, reject) => {
  2481. org.tree().then((res) => {
  2482. if (res.success) {
  2483. resolve(res);
  2484. }
  2485. });
  2486. });
  2487. },
  2488. upload(data) {
  2489. this.formData.contentImage = data;
  2490. this.$refs.formName.validateField('contentImage');
  2491. },
  2492. houseData(argum, idx) {
  2493. this.$set(this.warehousingMaterialList[idx], 'houseList', argum);
  2494. }
  2495. },
  2496. watch: {
  2497. // 解决右侧悬浮操作栏不对称问题
  2498. warehousingMaterialList: {
  2499. handler() {
  2500. this.$nextTick(() => {
  2501. this.$refs.warehousingMaterialListTable?.doLayout();
  2502. });
  2503. },
  2504. deep: true
  2505. },
  2506. // 解决右侧悬浮操作栏不对称问题
  2507. materialCodeReqList: {
  2508. handler() {
  2509. this.$nextTick(() => {
  2510. this.$refs.materialCodeReqListTable?.doLayout();
  2511. });
  2512. },
  2513. deep: true
  2514. },
  2515. // 解决右侧悬浮操作栏不对称问题
  2516. resultArray: {
  2517. handler() {
  2518. this.$nextTick(() => {
  2519. this.$refs.resultArrayTable?.doLayout();
  2520. });
  2521. },
  2522. deep: true
  2523. }
  2524. }
  2525. };
  2526. </script>
  2527. <style lang="scss" scoped>
  2528. ::v-deep .el-row {
  2529. display: flex;
  2530. flex-wrap: wrap;
  2531. }
  2532. ::v-deep.form-table {
  2533. .el-form-item {
  2534. margin-bottom: 0;
  2535. }
  2536. .el-input__inner {
  2537. padding: 0 10px;
  2538. }
  2539. ::-webkit-scrollbar {
  2540. width: 8px;
  2541. height: 8px;
  2542. background-color: transparent;
  2543. }
  2544. }
  2545. .p20 {
  2546. padding: 20px;
  2547. }
  2548. .el-select,
  2549. .el-date-editor {
  2550. width: 100%;
  2551. }
  2552. .el-form-item {
  2553. margin-bottom: 22px;
  2554. }
  2555. .material {
  2556. margin-top: 20px;
  2557. .flex {
  2558. display: flex;
  2559. justify-content: space-between;
  2560. font-size: 14px;
  2561. align-items: center;
  2562. .red {
  2563. color: #ff4949;
  2564. }
  2565. }
  2566. }
  2567. .mt10 {
  2568. margin-top: 10px;
  2569. }
  2570. .mt20 {
  2571. margin-top: 20px;
  2572. }
  2573. .center {
  2574. text-align: center;
  2575. }
  2576. .switch_left li {
  2577. border-right: 1px solid rgba(222, 222, 222, 1);
  2578. border-left: 1px solid rgba(222, 222, 222, 1);
  2579. }
  2580. .fontOmitted {
  2581. text-overflow: ellipsis;
  2582. overflow: hidden;
  2583. word-break: break-all;
  2584. white-space: nowrap;
  2585. }
  2586. .table-fixed {
  2587. .el-table__fixed-right {
  2588. height: 100% !important;
  2589. }
  2590. .el-table__fixed-left {
  2591. height: 100% !important;
  2592. }
  2593. .el-table__fixed {
  2594. height: 100% !important;
  2595. }
  2596. }
  2597. </style>