add.vue 92 KB

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