add0429.vue 85 KB

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