add.vue 86 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534
  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. :value="formData.extInfo.assetType"
  68. clearable
  69. :options="codeList"
  70. :props="{
  71. value: 'id',
  72. label: 'name',
  73. children: 'children'
  74. }"
  75. @getValue="codeListValue"
  76. :isAll="false"
  77. />
  78. </el-form-item>
  79. </el-col>
  80. <el-col :span="8">
  81. <el-form-item label="入库类型" prop="bizType">
  82. <el-select
  83. @change="onClear"
  84. filterable
  85. placeholder="请选择"
  86. v-model="formData.bizType"
  87. clearable
  88. :disabled="
  89. !!(warehousingMaterialList && warehousingMaterialList.length)
  90. "
  91. >
  92. <el-option
  93. v-for="item in sceneState"
  94. :key="item.code"
  95. :value="item.code + ''"
  96. :label="item.label"
  97. ></el-option>
  98. </el-select> </el-form-item
  99. ></el-col>
  100. <el-col :span="8">
  101. <el-form-item
  102. v-if="formData.bizType == 2"
  103. label="采购收货单"
  104. prop="documentSource"
  105. >
  106. <el-input
  107. placeholder="请输入"
  108. v-model="formData.extInfo.documentSource"
  109. @click.native="handlePicker()"
  110. :disabled="isTask"
  111. >
  112. <el-button
  113. slot="append"
  114. icon="el-icon-circle-close"
  115. @click.stop="onClear"
  116. ></el-button>
  117. </el-input>
  118. </el-form-item>
  119. <el-form-item
  120. v-if="formData.bizType == 1"
  121. label="生产工单"
  122. prop="documentSource"
  123. >
  124. <el-input
  125. placeholder="请输入"
  126. clearable
  127. v-model="formData.extInfo.documentSource"
  128. /></el-form-item>
  129. <el-form-item
  130. v-if="
  131. formData.bizType != 1 &&
  132. formData.bizType != 2 &&
  133. formData.bizType != 3
  134. "
  135. label="销售订单"
  136. prop="documentSource"
  137. >
  138. <el-input
  139. placeholder="请输入"
  140. clearable
  141. v-model="formData.extInfo.documentSource"
  142. /></el-form-item>
  143. <el-form-item
  144. v-if="formData.bizType == 3"
  145. label="出库单"
  146. prop="documentSource"
  147. >
  148. <el-input
  149. placeholder="请输入"
  150. clearable
  151. v-model="formData.extInfo.documentSource"
  152. /></el-form-item>
  153. </el-col>
  154. <el-col :span="8">
  155. <el-form-item label="权属部门" prop="deptName">
  156. <el-input
  157. placeholder="权属部门"
  158. disabled
  159. v-model="formData.extInfo.deptName"
  160. clearable
  161. />
  162. </el-form-item>
  163. </el-col>
  164. <el-col :span="8">
  165. <el-form-item label="入库登记人">
  166. <el-input
  167. placeholder="登记人"
  168. disabled
  169. v-model="formData.extInfo.createUserName"
  170. clearable /></el-form-item
  171. ></el-col>
  172. <!-- <el-col :span="8">
  173. <el-form-item label="入库时间" prop="outInTime">
  174. <el-date-picker
  175. v-model="formData.outInTime"
  176. clearable
  177. type="datetime"
  178. value-format="yyyy-MM-dd HH:mm:ss"
  179. placeholder="选择日期"
  180. >
  181. </el-date-picker></el-form-item
  182. ></el-col> -->
  183. <el-col :span="8" v-if="formData.bizType == 2">
  184. <el-form-item label="供应商" prop="supplierName">
  185. <!-- <DictSelection
  186. dictName="经销商列表"
  187. clearable
  188. v-model="formData.extInfo.supplierId"
  189. @itemChange="ChangeSupplier"
  190. /> -->
  191. <el-input
  192. placeholder="请输入"
  193. clearable
  194. v-model="formData.extInfo.supplierName"
  195. />
  196. </el-form-item>
  197. </el-col>
  198. <!-- <el-col :span="8" v-if="formData.bizType == 2">
  199. <el-form-item label="物料代号" prop="supplierCode">
  200. <el-input
  201. placeholder="请输入"
  202. v-model="formData.supplierCode"
  203. clearable /></el-form-item
  204. ></el-col> -->
  205. <!-- <el-col :span="8" v-if="formData.bizType == 2">
  206. <el-form-item label="客户" prop="clientName">
  207. <el-input
  208. placeholder="请输入"
  209. clearable
  210. v-model="formData.clientName"
  211. />
  212. </el-form-item>
  213. </el-col> -->
  214. <!-- <el-col :span="8" v-if="formData.bizType == 2">
  215. <el-form-item label="客户代号" prop="clientCode">
  216. <el-input
  217. placeholder="请输入"
  218. v-model="formData.clientCode"
  219. clearable /></el-form-item
  220. ></el-col> -->
  221. <!-- <el-col :span="8">
  222. <el-form-item label="送货人" prop="fromUser">
  223. <el-input
  224. placeholder="请输入"
  225. v-model="formData.fromUser"
  226. clearable /></el-form-item
  227. ></el-col> -->
  228. <el-col :span="8">
  229. <el-form-item label="送货人" prop="fromUser">
  230. <el-input
  231. placeholder="请输入"
  232. v-model="formData.fromUser"
  233. clearable
  234. />
  235. <!-- <el-select
  236. v-model="formData.fromUser"
  237. filterable
  238. placeholder="请选择送货人"
  239. >
  240. <el-option
  241. v-for="item in contactList"
  242. :key="item.id"
  243. :label="item.linkName"
  244. :value="item.id"
  245. @click.native="
  246. () => (formData.extInfo.deliveryPhone = item.mobilePhone)
  247. "
  248. >
  249. </el-option>
  250. </el-select> -->
  251. </el-form-item></el-col
  252. >
  253. <el-col :span="8">
  254. <el-form-item label="送货人联系方式" prop="deliveryPhone">
  255. <el-input
  256. placeholder="请输入"
  257. v-model="formData.extInfo.deliveryPhone"
  258. clearable /></el-form-item
  259. ></el-col>
  260. <!-- <el-col :span="8">
  261. <el-form-item label="紧急状态" prop="urgent">
  262. <el-select
  263. filterable
  264. placeholder="请选择"
  265. v-model="formData.extInfo.urgent"
  266. clearable
  267. >
  268. <el-option
  269. v-for="item in emergencyState"
  270. :key="item.code"
  271. :value="item.code"
  272. :label="item.label"
  273. ></el-option>
  274. </el-select> </el-form-item
  275. ></el-col> -->
  276. <!-- <el-col :span="8">
  277. <el-form-item label="审核人部门" prop="verifyDeptName">
  278. <selectTree
  279. ref="tree"
  280. class="form-ipt"
  281. size="medium"
  282. style="width: 100%"
  283. clearable
  284. :options="treeList"
  285. :props="{
  286. value: 'code',
  287. label: 'name',
  288. children: 'children'
  289. }"
  290. @getValue="auditorDeptClick"
  291. />
  292. </el-form-item>
  293. </el-col>
  294. <el-col :span="8">
  295. <el-form-item label="审核人" prop="verifyId">
  296. <el-select
  297. filterable
  298. class="form-ipt"
  299. style="width: 100%"
  300. v-model="formData.verifyId"
  301. placeholder="请选择"
  302. >
  303. <el-option
  304. v-for="item in staffList"
  305. :key="item.id"
  306. :label="item.name"
  307. :value="item.id"
  308. @click.native="changeVerfy(item)"
  309. >
  310. </el-option>
  311. </el-select>
  312. </el-form-item>
  313. </el-col> -->
  314. <!-- <el-col :span="24">
  315. <el-form-item label="附件" prop="contentImage">
  316. <selectUpload @getImgs="upload" :initData="uploadList" />
  317. </el-form-item>
  318. </el-col> -->
  319. <el-col :span="24">
  320. <el-form-item label="备注" prop="remark">
  321. <el-input
  322. v-model="formData.remark"
  323. clearable
  324. type="textarea"
  325. placeholder="请详细说明"
  326. :rows="4"
  327. ></el-input>
  328. </el-form-item>
  329. </el-col>
  330. </el-row>
  331. </el-form>
  332. <div class="material">
  333. <header-title title="产品信息">
  334. <el-button type="primary" @click="addStock" v-if="!isTask"
  335. >添加</el-button
  336. >
  337. </header-title>
  338. <div class="mt10 form-table">
  339. <el-form
  340. ref="warehousingMaterialListRef"
  341. :model="{ warehousingMaterialList: warehousingMaterialList }"
  342. :show-message="false"
  343. >
  344. <el-button
  345. v-if="warehousingMaterialList.length != 0"
  346. type="success"
  347. plain
  348. style="margin-bottom: 20px; float: right; margin-right: 20px"
  349. size="mini"
  350. @click="listSaveArrs"
  351. >批量保存</el-button
  352. >
  353. <el-table
  354. v-if="isWeight"
  355. :header-cell-style="rowClass"
  356. ref="warehousingMaterialListTable"
  357. :key="formData.extInfo.assetType"
  358. :data="warehousingMaterialList"
  359. tooltip-effect="dark"
  360. style="width: 100%"
  361. stripe
  362. >
  363. <el-table-column
  364. label="序号"
  365. type="index"
  366. width="50"
  367. align="center"
  368. >
  369. </el-table-column>
  370. <el-table-column
  371. label="编码"
  372. prop="assetCode"
  373. align="center"
  374. width="130"
  375. ></el-table-column>
  376. <el-table-column
  377. label="名称"
  378. align="center"
  379. width="200"
  380. prop="assetName"
  381. ></el-table-column>
  382. <!-- <el-table-column
  383. label="客户编码"
  384. align="center"
  385. width="150"
  386. prop="customCode"
  387. v-if="formData.bizType == 1"
  388. >
  389. <template slot-scope="{ row, $index }">
  390. <template v-if="row.isSave">
  391. {{ row.customCode }}
  392. </template>
  393. <el-form-item
  394. v-else
  395. :prop="`warehousingMaterialList.${$index}.customCode`"
  396. required
  397. >
  398. <el-input v-model="row.customCode"> </el-input>
  399. </el-form-item>
  400. </template>
  401. </el-table-column>
  402. <el-table-column
  403. label="供应商编码"
  404. align="center"
  405. width="150"
  406. prop="customCode"
  407. v-if="formData.bizType == 2"
  408. >
  409. <template slot-scope="{ row, $index }">
  410. <template v-if="row.isSave">
  411. {{ row.supplierCode }}
  412. </template>
  413. <el-form-item
  414. v-else
  415. :prop="`warehousingMaterialList.${$index}.supplierCode`"
  416. required
  417. >
  418. <el-input v-model="row.supplierCode"> </el-input>
  419. </el-form-item>
  420. </template>
  421. </el-table-column> -->
  422. <el-table-column
  423. v-for="(item, index) in tableHeader"
  424. :key="index"
  425. align="center"
  426. :label="item.label"
  427. width="150"
  428. :prop="item.prop"
  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
  749. type="text"
  750. @click="listDel(row, $index)"
  751. v-if="!isTask"
  752. >删除</el-button
  753. >
  754. </template>
  755. </el-table-column>
  756. </el-table>
  757. </el-form>
  758. </div>
  759. <div class="mt20">
  760. <header-title :title="`包装明细`">
  761. <div class="switch_right">
  762. <span v-if="materialCodeReqList.length != 0">
  763. 分拆<el-switch
  764. v-model="isDetail"
  765. active-color="#13ce66"
  766. inactive-color="#ff4949"
  767. @change="handleIsDetail"
  768. style="margin-left: 10px"
  769. >
  770. </el-switch>
  771. </span>
  772. <el-button
  773. style="margin-left: 20px"
  774. type="text"
  775. @click="dateSetting"
  776. v-if="formData.bizType != 5"
  777. >批量设置{{
  778. curDateType === 'manufactureTime' ? '生产日期' : '采购日期'
  779. }}</el-button
  780. >
  781. </div>
  782. </header-title>
  783. <el-button
  784. v-if="materialCodeReqList.length != 0"
  785. type="success"
  786. plain
  787. style="margin-bottom: 20px; float: right; margin-right: 20px"
  788. size="mini"
  789. @click="wrapListSave"
  790. >批量保存</el-button
  791. >
  792. <el-table
  793. ref="materialCodeReqListTable"
  794. :data="materialCodeReqList"
  795. tooltip-effect="dark"
  796. :key="formData.bizType"
  797. :header-cell-style="rowClass"
  798. style="width: 100%"
  799. stripe
  800. height="300px"
  801. @selection-change="handleSelectionChange"
  802. >
  803. <el-table-column
  804. label=""
  805. type="selection"
  806. align="center"
  807. width="50"
  808. v-if="formData.bizType != 5"
  809. >
  810. </el-table-column>
  811. <el-table-column label="序号" type="index" width="50">
  812. </el-table-column>
  813. <el-table-column
  814. label="编码"
  815. prop="assetCode"
  816. width="130"
  817. :show-overflow-tooltip="true"
  818. ></el-table-column>
  819. <el-table-column
  820. label="名称"
  821. prop="assetName"
  822. width="150"
  823. :show-overflow-tooltip="true"
  824. ></el-table-column>
  825. <el-table-column
  826. label="批次号"
  827. prop="batchNo"
  828. width="70"
  829. ></el-table-column>
  830. <el-table-column
  831. :label="`包装编码`"
  832. prop="onlyCode"
  833. width="130"
  834. :show-overflow-tooltip="true"
  835. ></el-table-column>
  836. <el-table-column
  837. label="包装数量"
  838. prop="packingCount"
  839. width="80"
  840. ></el-table-column>
  841. <el-table-column
  842. label="包装单位"
  843. prop="packingUnit"
  844. ></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">
  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="isDetail">
  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="80"
  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">
  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="onSelectTableData"
  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. isDetail: false,
  1188. contactList: [],
  1189. pickerRow: {},
  1190. fromUserList: [],
  1191. codeList: [],
  1192. materialType,
  1193. warehousingType,
  1194. sceneState,
  1195. emergencyState,
  1196. saveLoading: false,
  1197. visibleDialog: false,
  1198. curDateType: 'manufactureTime',
  1199. materialCodeReqListSelected: [],
  1200. // warehouseList: [], //仓库数组
  1201. // warehouse: {},
  1202. title: '',
  1203. tableData2: [],
  1204. uploadList: [],
  1205. supplierList: [],
  1206. warehousingMaterialList: [],
  1207. activeName: 'a',
  1208. loadTree: true,
  1209. selectEquiType: '',
  1210. batchTime: '',
  1211. dateVisible: false,
  1212. treeList: [],
  1213. staffList: [],
  1214. formData: {
  1215. extInfo: {
  1216. assetType: '', //物品类型
  1217. deptCode: '', //部门code
  1218. deptName: '', //部门名称
  1219. verifyDeptCode: '', //审核部门编码
  1220. verifyDeptName: '', //审核部门名称
  1221. deliveryName: '', //送货人名称
  1222. deliveryPhone: '', //送货人电话
  1223. documentSource: '', //销售订单
  1224. urgent: '', //紧急状态
  1225. supplierId: '', //供应商ID
  1226. supplierName: '', //供应商名称
  1227. createUserName: '', //创建人名字
  1228. contentImage: [] //图片数组
  1229. },
  1230. fromUser: '', //送货人
  1231. bizType: '', //物品类型
  1232. verifyId: '', //审核人Id
  1233. verifyName: '', //审核人名称
  1234. createUserId: '',
  1235. remark: ''
  1236. },
  1237. rules: {
  1238. 'extInfo.assetType': {
  1239. required: true,
  1240. message: '请选择物品类型',
  1241. trigger: 'change'
  1242. },
  1243. bizType: {
  1244. required: true,
  1245. message: '请选择入库场景',
  1246. trigger: 'change'
  1247. }
  1248. }
  1249. };
  1250. },
  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. row.minPackingCount = value.replace(/^(0+)|[^\d]+/g, '');
  1279. if (row.outInNum >= 0 && value >= 0) {
  1280. this.packNum(row, row.outInNum);
  1281. }
  1282. },
  1283. // 选择质检结果改变质检状态
  1284. changeWrapStatus(resultValue, row) {
  1285. switch (resultValue) {
  1286. case '':
  1287. // 清空质检状态
  1288. row.status = '0';
  1289. break;
  1290. default:
  1291. // 默认已检质检状态
  1292. row.status = '1';
  1293. break;
  1294. }
  1295. },
  1296. cancel() {
  1297. this.$emit('cancel');
  1298. },
  1299. weightInput(value, row) {
  1300. const newValue = value.replace(/[^\d.]/g, ''); // 保留数字和小数点
  1301. const decimalCount = (newValue.match(/\./g) || []).length; // 计算小数点的个数
  1302. if (decimalCount > 1) {
  1303. // 如果小数点个数大于1,移除多余的小数点
  1304. const lastIndex = newValue.lastIndexOf('.');
  1305. row.weight =
  1306. newValue.slice(0, lastIndex) + newValue.slice(lastIndex + 1);
  1307. } else if (decimalCount === 1) {
  1308. // 如果小数点个数等于1,允许小数点的输入
  1309. row.weight = newValue;
  1310. } else {
  1311. row.weight = newValue === '' ? 0 : parseFloat(newValue); // 如果输入为空,则设为0
  1312. }
  1313. },
  1314. handleIsDetail(event) {
  1315. this.isSplit = event;
  1316. const list = this.materialCodeReqList;
  1317. if (event) {
  1318. let resultArray = [];
  1319. list.forEach((item) => {
  1320. // 包装维度改成已保存状态
  1321. item.isPack = true;
  1322. // 拆分物料维度并生成列表
  1323. for (let i = 1; i <= Number(item.minPackingCount); i++) {
  1324. resultArray.push({
  1325. onlyCode: item.onlyCode,
  1326. no: item.onlyCode + i.toString().padStart(4, '0'),
  1327. assetCode: item.assetCode,
  1328. assetName: item.assetName,
  1329. batchNo: item.batchNo,
  1330. minPackingCount: 1,
  1331. measuringUnit: item.measuringUnit,
  1332. materielCode: item.materielCode,
  1333. clientCode: item.clientCode,
  1334. weight: item.weight / Number(item.minPackingCount),
  1335. weightUnit: item.weightUnit,
  1336. engrave: item.engrave,
  1337. result: item.result,
  1338. status: item.status,
  1339. isPack: false
  1340. });
  1341. }
  1342. });
  1343. this.resultArray = resultArray;
  1344. // 批量修改包装明细
  1345. this.isWeight = false;
  1346. this.bulkEditingWrap();
  1347. this.$nextTick(() => {
  1348. this.isWeight = true;
  1349. });
  1350. } else {
  1351. // 包装维度改成编辑状态
  1352. list.forEach((item) => {
  1353. item.isPack = false;
  1354. });
  1355. // 清空物料维度列表
  1356. this.resultArray = [];
  1357. }
  1358. },
  1359. //包装明细保存
  1360. packCout(row) {
  1361. //true保存==》反之
  1362. if (!row.isPack) {
  1363. row.isPack = true;
  1364. const code = row.assetCode;
  1365. const batchNo = row.batchNo;
  1366. //做防护,防止weight字符串类型
  1367. this.materialCodeReqList.forEach((ele) => {
  1368. ele.weight = Number(ele.weight);
  1369. });
  1370. // const count = this.materialCodeReqList.reduce(
  1371. // (acc, curr) => acc + curr.weight,
  1372. // 0
  1373. // );
  1374. // 修改产品信息重量(包装维度累计)
  1375. this.isWeight = false;
  1376. this.warehousingMaterialList.forEach((item) => {
  1377. if (item.assetCode == code && item.batchNo == batchNo) {
  1378. let arr = [];
  1379. for (const key in this.materialCodeReqList) {
  1380. if (
  1381. this.materialCodeReqList[key].assetCode == item.assetCode &&
  1382. this.materialCodeReqList[key].batchNo == item.batchNo
  1383. ) {
  1384. arr.push({ ...this.materialCodeReqList[key] });
  1385. }
  1386. }
  1387. const count = arr.reduce(
  1388. (acc, curr) =>
  1389. Number(this.$math.format(+acc + +curr.weight, 14)),
  1390. 0
  1391. );
  1392. this.$set(item, 'weight', count);
  1393. }
  1394. });
  1395. this.$nextTick(() => {
  1396. this.isWeight = true;
  1397. });
  1398. } else {
  1399. row.isPack = false;
  1400. }
  1401. // setTimeout(() => {
  1402. // }, 100);
  1403. },
  1404. // 批量修改包装明细
  1405. bulkEditingWrap() {
  1406. // 批量修改包装明细列表状态(已保存)
  1407. this.materialCodeReqList.forEach((item) => {
  1408. item.isPack = true;
  1409. });
  1410. // 改变产品明细重量
  1411. this.warehousingMaterialList.forEach((outItem) => {
  1412. let arr = [];
  1413. this.materialCodeReqList.forEach((inneritem) => {
  1414. if (
  1415. inneritem.assetCode == outItem.assetCode &&
  1416. inneritem.batchNo == outItem.batchNo
  1417. ) {
  1418. arr.push(inneritem);
  1419. }
  1420. });
  1421. const count = arr.reduce(
  1422. (acc, curr) => Number(this.$math.format(+acc + +curr.weight, 14)),
  1423. 0
  1424. );
  1425. this.$set(outItem, 'weight', count);
  1426. });
  1427. },
  1428. // 批量修改物料明细
  1429. bulkEditingMaterial() {
  1430. // 批量修改物料明细列表状态(已保存)
  1431. this.resultArray.forEach((item) => {
  1432. item.isPack = true;
  1433. });
  1434. // 改变包装明细重量
  1435. this.materialCodeReqList.forEach((outItem) => {
  1436. let arr = [];
  1437. this.resultArray.forEach((inneritem) => {
  1438. if (
  1439. inneritem.assetCode == outItem.assetCode &&
  1440. inneritem.batchNo == outItem.batchNo
  1441. ) {
  1442. arr.push(inneritem);
  1443. }
  1444. });
  1445. const count = arr.reduce(
  1446. (acc, curr) => Number(this.$math.format(+acc + +curr.weight, 14)),
  1447. 0
  1448. );
  1449. this.$set(outItem, 'weight', count);
  1450. });
  1451. },
  1452. // 物料明细保存
  1453. materialBtn(row) {
  1454. console.log(row);
  1455. console.log(this.resultArray);
  1456. console.log(this.materialCodeReqList);
  1457. // true保存 false编辑
  1458. if (!row.isPack) {
  1459. row.isPack = true;
  1460. // 物料维度修改质检改变包装维度质检(结果和状态)
  1461. this.materialCodeReqList.forEach((outItem) => {
  1462. let arr = [];
  1463. this.resultArray.forEach((inneritem) => {
  1464. if (inneritem.onlyCode == outItem.onlyCode) {
  1465. arr.push(inneritem);
  1466. }
  1467. });
  1468. console.log(arr);
  1469. // 首先判断是未填/合格不合格
  1470. let boolen = arr.every((item) => {
  1471. return item.result === '' || item.result === undefined;
  1472. });
  1473. // 判断只要物料全部质检结果(未填)——>包装质检结果(未填) 状态(未检)
  1474. if (boolen) {
  1475. this.$set(outItem, 'result', '');
  1476. this.$set(outItem, 'status', '0');
  1477. } else {
  1478. // 判断只要物料有一个质检结果(不合格)——>包装质检结果(不合格) 状态(已检)
  1479. let boolen = arr.some((item) => {
  1480. return item.result === '1';
  1481. });
  1482. if (boolen) {
  1483. this.$set(outItem, 'result', '1');
  1484. this.$set(outItem, 'status', '1');
  1485. } else {
  1486. // 判断只要物料有一个质检结果(让步接收)——>包装质检结果(让步接收) 状态(已检)
  1487. let boolen = arr.some((item) => {
  1488. return item.result === '3';
  1489. });
  1490. if (boolen) {
  1491. // 让步接收 已检
  1492. this.$set(outItem, 'result', '3');
  1493. this.$set(outItem, 'status', '1');
  1494. } else {
  1495. // 判断只要物料有全部质检结果(合格)——>包装质检结果(合格) 状态(已检)
  1496. let boolen = arr.every((item) => {
  1497. return item.result === '0';
  1498. });
  1499. if (boolen) {
  1500. // 合格 已检
  1501. this.$set(outItem, 'result', '0');
  1502. this.$set(outItem, 'status', '1');
  1503. } else {
  1504. // 合格 部分检
  1505. this.$set(outItem, 'result', '0');
  1506. this.$set(outItem, 'status', '2');
  1507. }
  1508. }
  1509. }
  1510. }
  1511. // this.$set(outItem, 'result', boolen ? '1' : '0');
  1512. });
  1513. // 物料维度修改重量改变包装维度重量
  1514. let onlyCode = row.onlyCode;
  1515. this.materialCodeReqList.forEach((item) => {
  1516. if (item.onlyCode === onlyCode) {
  1517. let arr = [];
  1518. for (const key in this.resultArray) {
  1519. if (this.resultArray[key].onlyCode == item.onlyCode) {
  1520. arr.push({ ...this.resultArray[key] });
  1521. }
  1522. }
  1523. const count = arr.reduce(
  1524. (acc, curr) =>
  1525. Number(this.$math.format(+acc + +curr.weight, 14)),
  1526. 0
  1527. );
  1528. this.$set(item, 'weight', count);
  1529. }
  1530. });
  1531. // 包装维度修改重量改变产品信息
  1532. this.isWeight = false;
  1533. // 批量修改包装明细
  1534. this.bulkEditingWrap();
  1535. this.$nextTick(() => {
  1536. this.isWeight = true;
  1537. });
  1538. } else {
  1539. row.isPack = false;
  1540. }
  1541. },
  1542. packNum(row, value) {
  1543. const total = {
  1544. packingCount: Number(row.minPackingCount),
  1545. outInNum: Number(row.outInNum)
  1546. };
  1547. if (row.measuringUnit == row.weightUnit) {
  1548. row.weight = Number(
  1549. this.$math.format(
  1550. total.packingCount * 1 * total.outInNum.toFixed(2),
  1551. 14
  1552. )
  1553. );
  1554. } else {
  1555. const totals = Number(
  1556. this.$math.format(total.packingCount * total.outInNum, 14)
  1557. );
  1558. row.weight = Number(
  1559. this.$math.format(totals * row.netWeight.toFixed(2), 14)
  1560. );
  1561. }
  1562. return (row.outInNum = value.replace(/^(0+)|[^\d]+/g, ''));
  1563. },
  1564. async searchContact(id) {
  1565. const data = await contactlink({ contactId: id });
  1566. this.contactList = data.data;
  1567. },
  1568. async pickerSuccess(row) {
  1569. this.formData.bizType = '2';
  1570. this.codeListValue(row.categoryLevelTopId);
  1571. this.isTask = true;
  1572. this.pickerRow = row;
  1573. this.formData.extInfo.documentSource = row.orderNo;
  1574. this.formData.sourceBizNo = row.receiveNo;
  1575. this.formData.fromId = row.id;
  1576. this.formData.clientName = row.partaName;
  1577. this.formData.clientCode = row.partaId;
  1578. this.formData.extInfo.supplierName = row.supplierName;
  1579. this.formData.extInfo.supplierId = row.supplierId;
  1580. // await this.searchContact(row.partbId);
  1581. const data = await getReceiveSaleOrderrecordDetail(row.id);
  1582. if (this.warehousingMaterialList.length == 0) {
  1583. let list = data.productList.map((item) => {
  1584. return {
  1585. ...item,
  1586. assetName: item.productName,
  1587. assetCode: item.productCode,
  1588. categoryId: item.productCategoryId,
  1589. minPackUnit: item.packingUnit
  1590. };
  1591. });
  1592. this.onSelectTableData(await this.serachMainCode(list));
  1593. }
  1594. },
  1595. async serachMainCode(arr) {
  1596. let newArr = [];
  1597. // 使用 Promise.all 来等待所有异步操作完成
  1598. await Promise.all(
  1599. arr.map(async (item) => {
  1600. const data = await getProductList({
  1601. pageNum: 1,
  1602. size: 10,
  1603. categoryLevelId: item.categoryLevelPathIdParent,
  1604. code: item.assetCode
  1605. });
  1606. newArr.push(data.list); // 将结果存储到 newArr 中
  1607. })
  1608. );
  1609. let re = [];
  1610. for (const item of newArr) {
  1611. for (const it of item) {
  1612. re.push(it);
  1613. }
  1614. }
  1615. return re.map((item) => {
  1616. return {
  1617. ...item,
  1618. minPackUnit: item.packingUnit,
  1619. assetCode: item.code,
  1620. assetName: item.name
  1621. };
  1622. });
  1623. },
  1624. onClear() {
  1625. this.formData.extInfo.documentSource = '';
  1626. this.pickerRow = {};
  1627. this.formData.clientName = '';
  1628. this.formData.clientCode = '';
  1629. this.formData.extInfo.supplierName = '';
  1630. this.formData.extInfo.supplierId = '';
  1631. this.$forceUpdate();
  1632. },
  1633. handlePicker() {
  1634. this.$refs.pickerRef.open();
  1635. },
  1636. codeListValue(val) {
  1637. this.formData.extInfo.assetType = val.id || val;
  1638. this.$forceUpdate();
  1639. this.title = val?.name;
  1640. this.selectEquiType = val?.id || val;
  1641. },
  1642. //计算生产设备重量
  1643. deviceWeight(row, num) {
  1644. if (row) {
  1645. return Number(row * num);
  1646. } else {
  1647. return row;
  1648. }
  1649. },
  1650. //计算金额
  1651. calcSumTotal(PackingCount, outInNum, univalence) {
  1652. //最小包装单元,包装数量,单价
  1653. const total = {
  1654. PackingCount: Number(PackingCount),
  1655. outInNum: Number(outInNum),
  1656. univalence: Number(univalence == undefined ? 0 : univalence)
  1657. };
  1658. return total.PackingCount * total.outInNum * total.univalence;
  1659. },
  1660. handleRowUnit(row) {
  1661. return row.measuringUnit;
  1662. // if (this.formData.extInfo.assetType == 1) {
  1663. // return row.weightUnit;
  1664. // } else if (this.formData.extInfo.assetType == 4) {
  1665. // return row.measuringUnit;
  1666. // } else {
  1667. // return row.measuringUnit;
  1668. // }
  1669. },
  1670. changeVerfy(it) {
  1671. this.formData.verifyName = it.name;
  1672. },
  1673. //选择供应啥的操作
  1674. ChangeSupplier(data) {
  1675. this.formData.extInfo.supplierName = data.dictValue;
  1676. },
  1677. ChangeSuppliers(data) {
  1678. this.formData.clientName = data.dictValue;
  1679. },
  1680. rowClass({ row, column, rowIndex, columnIndex }) {
  1681. if (rowIndex === 1) {
  1682. return {
  1683. display: 'none',
  1684. background: '#EEEEEE',
  1685. border: 'none'
  1686. };
  1687. }
  1688. return { background: '#EEEEEE', border: 'none' };
  1689. },
  1690. calcSum(a, b, c, row) {
  1691. if (
  1692. (Number.isNaN(+a) && a !== '') ||
  1693. (Number.isNaN(+b) && b !== '') ||
  1694. (Number.isNaN(+c) && c !== '')
  1695. ) {
  1696. return '';
  1697. }
  1698. return a * b * c + { yuan: '元', wanyuan: '万元' }[row.univalenceUnit];
  1699. // return a * b * c;
  1700. },
  1701. // 部门 点击事件
  1702. async auditorDeptClick(data) {
  1703. this.formData.extInfo.verifyDeptCode = data?.id;
  1704. this.formData.extInfo.verifyDeptName = data?.name;
  1705. this.formData.verifyId = '';
  1706. this.formData.verifyName = '';
  1707. this.$refs.formName.validateField('verifyDeptName');
  1708. if (data) {
  1709. this.getStaffList(data);
  1710. }
  1711. },
  1712. async getStaffList(data) {
  1713. let res = await warehouseDefinition.getUserPage({
  1714. groupId: data.id,
  1715. size: 9999,
  1716. page: 1
  1717. });
  1718. this.staffList = res.list;
  1719. },
  1720. // 详情接口
  1721. // async _getInfo () {
  1722. // const res = await getInfo({ id: this.$route.query.id })
  1723. // if (res?.success) {
  1724. // this.warehousingMaterialList = res.data.warehouseLedgerInfos.map(i => {
  1725. // i.isSave = true
  1726. // return i
  1727. // })
  1728. // this.formData = res.data.outInWarehouse
  1729. // this.uploadList = this.formData.contentImage
  1730. // }
  1731. // },
  1732. chooseAssets(row, index) {
  1733. this.$refs.returnSelectRef.open(row, (res) => {
  1734. row.outInNum = res.length;
  1735. this.$set(
  1736. row,
  1737. 'selfWarehouseLedgerDetails',
  1738. res.map((i) => {
  1739. delete i.updateTime;
  1740. delete i.createTime;
  1741. return i;
  1742. })
  1743. );
  1744. });
  1745. },
  1746. // 仓库编辑
  1747. handleWareHouse(row, idx) {
  1748. this.$refs.wareHouseDailogRef.open(row, idx);
  1749. },
  1750. // 入库操作
  1751. listEdit(row) {
  1752. this.$set(row, 'isSave', false);
  1753. row.selfWarehouseLedgerDetails = row.warehouseLedgerDetails;
  1754. row.warehouseLedgerDetails = [];
  1755. // 清空物料明细防止数据错乱
  1756. this.resultArray = [];
  1757. this.isDetail = false;
  1758. },
  1759. listSave(row, index) {
  1760. const fileds = [
  1761. // `warehousingMaterialList.${index}.cargoSpaceCode`,
  1762. `warehousingMaterialList.${index}.batchNo`,
  1763. `warehousingMaterialList.${index}.houseList`
  1764. ];
  1765. if (this.formData.bizType == 1) {
  1766. // fileds.push(...[`warehousingMaterialList.${index}.customCode`]);
  1767. } else if (this.formData.bizType == 2) {
  1768. // fileds.push(...[`warehousingMaterialList.${index}.supplierCode`]);
  1769. }
  1770. if (this.formData.bizType != 5) {
  1771. fileds.push(
  1772. ...[
  1773. `warehousingMaterialList.${index}.outInNum`,
  1774. `warehousingMaterialList.${index}.minPackingCount`
  1775. ]
  1776. );
  1777. } else if (
  1778. this.warehousingMaterialList.some(
  1779. (i) => !i.selfWarehouseLedgerDetails?.length
  1780. )
  1781. ) {
  1782. this.$message.error('请选择资产编号!');
  1783. return;
  1784. }
  1785. Promise.all(
  1786. fileds.map(
  1787. (item) =>
  1788. new Promise(async (resolve, rej) => {
  1789. this.$refs.warehousingMaterialListRef.validateField(
  1790. item,
  1791. (err) => {
  1792. if (err) {
  1793. rej(err);
  1794. } else {
  1795. resolve();
  1796. }
  1797. }
  1798. );
  1799. })
  1800. )
  1801. )
  1802. .then((res) => {
  1803. this.$set(row, 'isSave', true);
  1804. if (this.formData.bizType != 5) {
  1805. this.createMaterialCode(row);
  1806. } else {
  1807. // 退还
  1808. this.createMaterialCodeReturn(row);
  1809. }
  1810. })
  1811. .catch((err) => {
  1812. this.$message.error('请填入必填项!');
  1813. });
  1814. },
  1815. listSaveArrs() {
  1816. const rows = this.warehousingMaterialList;
  1817. const indexes = Array.from(
  1818. { length: this.warehousingMaterialList.length },
  1819. (_, index) => index
  1820. );
  1821. rows.forEach((row, i) => {
  1822. const index = indexes[i];
  1823. const fileds = [
  1824. // `warehousingMaterialList.${index}.cargoSpaceCode`,
  1825. `warehousingMaterialList.${index}.batchNo`,
  1826. `warehousingMaterialList.${index}.houseList`
  1827. ];
  1828. if (this.formData.bizType == 1) {
  1829. // fileds.push(...[`warehousingMaterialList.${index}.customCode`]);
  1830. } else if (this.formData.bizType == 2) {
  1831. // fileds.push(...[`warehousingMaterialList.${index}.supplierCode`]);
  1832. }
  1833. if (this.formData.bizType != 5) {
  1834. fileds.push(
  1835. ...[
  1836. `warehousingMaterialList.${index}.outInNum`,
  1837. `warehousingMaterialList.${index}.minPackingCount`
  1838. ]
  1839. );
  1840. } else if (
  1841. this.warehousingMaterialList.some(
  1842. (i) => !i.selfWarehouseLedgerDetails?.length
  1843. )
  1844. ) {
  1845. this.$message.error('请选择资产编号!');
  1846. return;
  1847. }
  1848. Promise.all(
  1849. fileds.map(
  1850. (item) =>
  1851. new Promise(async (resolve, rej) => {
  1852. this.$refs.warehousingMaterialListRef.validateField(
  1853. item,
  1854. (err) => {
  1855. if (err) {
  1856. rej(err);
  1857. } else {
  1858. resolve();
  1859. }
  1860. }
  1861. );
  1862. })
  1863. )
  1864. )
  1865. .then((res) => {
  1866. this.$set(row, 'isSave', true);
  1867. if (this.formData.bizType != 5) {
  1868. this.createMaterialCode(row);
  1869. } else {
  1870. // 退还
  1871. this.createMaterialCodeReturn(row);
  1872. }
  1873. })
  1874. .catch((err) => {
  1875. // this.$message.error('请填入必填项!');
  1876. });
  1877. });
  1878. },
  1879. // listSaveArrs() {
  1880. // console.log(this.warehousingMaterialList);
  1881. // },
  1882. // 批量设置生产日期
  1883. handleSelectionChange(val) {
  1884. this.materialCodeReqListSelected = val;
  1885. },
  1886. dateSetting() {
  1887. if (!this.materialCodeReqListSelected.length) {
  1888. return this.$message.error(`请选择${this.title}明细!`);
  1889. }
  1890. this.dateVisible = true;
  1891. },
  1892. dateConfirm() {
  1893. this.materialCodeReqListSelected.forEach((item) => {
  1894. this.$set(item, this.curDateType, this.batchTime);
  1895. });
  1896. this.dateVisible = false;
  1897. },
  1898. //入库明细删除
  1899. listDel(row, index) {
  1900. this.warehousingMaterialList.splice(index, 1);
  1901. this.resultArray = [];
  1902. this.isDetail = false;
  1903. },
  1904. // 入库明细生成条码信息
  1905. async createMaterialCode(row) {
  1906. // 添加相同物品、批次号重新更新明细 原料编码
  1907. const list = this.warehousingMaterialList.filter(
  1908. (i) =>
  1909. i.assetCode === row.assetCode &&
  1910. i.batchNo === row.batchNo &&
  1911. i.isSave
  1912. );
  1913. const num = list.reduce((num, pre) => {
  1914. num += row.isUnpack
  1915. ? pre.outInNum * pre.minPackingCount
  1916. : pre.outInNum - 0;
  1917. return num;
  1918. }, 0);
  1919. const nums = list.reduce((num, pre) => {
  1920. num += pre.outInNum * pre.minPackingCount;
  1921. return num;
  1922. }, 0);
  1923. const res = await outin.getAssetNum({
  1924. assetCode: row.assetCode,
  1925. batchNum: row.batchNo,
  1926. num: num
  1927. });
  1928. // row.measuringUnit == 'PCS' ? nums :
  1929. list.forEach((item) => {
  1930. if (item.warehouseLedgerDetails?.length) {
  1931. item.warehouseLedgerDetails.forEach((i) => {
  1932. i.onlyCode = res.shift().onlyCode;
  1933. });
  1934. } else {
  1935. this.$set(
  1936. item,
  1937. 'warehouseLedgerDetails',
  1938. Array.from(
  1939. new Array(
  1940. item.isUnpack
  1941. ? item.outInNum * item.minPackingCount
  1942. : // : item.measuringUnit == 'PCS'
  1943. // ? +item.outInNum * parseInt(item.minPackingCount)
  1944. +item.outInNum
  1945. ),
  1946. (val, idx) => {
  1947. return {
  1948. ...item,
  1949. onlyCode: res.shift().onlyCode,
  1950. bizStatus: 1,
  1951. contentImage: []
  1952. };
  1953. }
  1954. )
  1955. );
  1956. }
  1957. });
  1958. // 添加相同物品,重复批次号 重新更新明细 包装编码
  1959. const batchList = this.warehousingMaterialList.filter(
  1960. (i) => i.batchNo === row.batchNo && i.isSave
  1961. );
  1962. if (batchList.length) {
  1963. const num = batchList.reduce((num, pre) => {
  1964. num += +pre.outInNum;
  1965. return num;
  1966. }, 0);
  1967. const res1 = await outin.getAssetNum({
  1968. batchNum: row.batchNo,
  1969. num
  1970. });
  1971. if (res1) {
  1972. batchList.forEach((item) => {
  1973. let num = res1.shift()?.num;
  1974. let minPackingCount = item.minPackingCount;
  1975. if (item.warehouseLedgerDetails?.length) {
  1976. item.warehouseLedgerDetails.forEach((i, index) => {
  1977. this.$set(i, 'num', num);
  1978. if (item.measuringUnit == item.weightUnit) {
  1979. this.$set(i, 'weight', item.minPackingCount);
  1980. } else {
  1981. this.$set(
  1982. i,
  1983. 'weight',
  1984. typeof 1 * item.minPackingCount * item.netWeight ===
  1985. number
  1986. ? 1
  1987. : 1 * item.minPackingCount * item.netWeight
  1988. );
  1989. }
  1990. this.$set(i, 'weightUtil', item.weightUnit);
  1991. this.$set(i, 'packingCount', 1);
  1992. this.$set(i, 'packingUnit ', item.packingUnit);
  1993. this.$set(i, 'minPackingCount ', item.minPackingCount);
  1994. this.$set(i, 'measuringUnit', item.measuringUnit);
  1995. this.$set(i, 'isPack', false);
  1996. if (this.formData.extInfo.assetType == 1) {
  1997. this.$set(i, 'status', '0');
  1998. } else {
  1999. this.$set(i, 'result', '0');
  2000. this.$set(i, 'status', '1');
  2001. }
  2002. if (!item.isUnpack) {
  2003. if (index < item.warehouseLedgerDetails.length - 1) {
  2004. num = res1.shift()?.num;
  2005. }
  2006. } else {
  2007. // 拆包的包装编码一致
  2008. minPackingCount--;
  2009. if (
  2010. minPackingCount === 0 &&
  2011. index < item.warehouseLedgerDetails.length - 1
  2012. ) {
  2013. minPackingCount = item.minPackingCount;
  2014. num = res1.shift()?.num;
  2015. }
  2016. }
  2017. });
  2018. }
  2019. });
  2020. }
  2021. }
  2022. },
  2023. // 入库明细生成条码信息 退还
  2024. async createMaterialCodeReturn(row) {
  2025. // 添加相同物品重新更新明细 原料编码
  2026. const list = this.warehousingMaterialList.filter(
  2027. (i) => i.batchNo === row.batchNo && i.isSave
  2028. );
  2029. // 退还
  2030. const res = await getAssetNum({
  2031. batchNo: row.batchNo,
  2032. num: list.reduce((num, pre) => {
  2033. num += pre.selfWarehouseLedgerDetails.length;
  2034. return num;
  2035. }, 0)
  2036. });
  2037. if (res?.success) {
  2038. list.forEach((item) => {
  2039. let num = res.data.shift().num;
  2040. let minPackingCount = item.minPackingCount;
  2041. if (item.warehouseLedgerDetails?.length) {
  2042. item.warehouseLedgerDetails.forEach((i, index) => {
  2043. Object.assign(i, {
  2044. num,
  2045. batchNo: item.batchNo,
  2046. cargoSpaceCode: item.cargoSpaceCode, //货位编码
  2047. cargoSpaceId: item.cargoSpaceId, //货位id
  2048. shelfId: item.shelfId, //货架id
  2049. shelfCode: item.shelfCode, //货架名称
  2050. areaId: item.areaId, //库区id
  2051. areaName: item.areaName, //库区名称
  2052. warehouseId: item.warehouseId, //仓库id
  2053. warehouseName: item.warehouseName //仓库名称
  2054. });
  2055. if (!item.isUnpack) {
  2056. // 拆包的包装编码一致
  2057. if (index < item.warehouseLedgerDetails.length - 1) {
  2058. num = res.data.shift()?.num;
  2059. }
  2060. } else {
  2061. minPackingCount--;
  2062. if (
  2063. minPackingCount === 0 &&
  2064. index < item.warehouseLedgerDetails.length - 1
  2065. ) {
  2066. minPackingCount = item.minPackingCount;
  2067. num = res1.data.shift()?.num;
  2068. }
  2069. }
  2070. });
  2071. } else {
  2072. this.$set(
  2073. item,
  2074. 'warehouseLedgerDetails',
  2075. item.selfWarehouseLedgerDetails.map((val, idx) => {
  2076. let obj = {
  2077. ...val,
  2078. bizStatus: 1,
  2079. minPackingCount: item.minPackingCount,
  2080. batchNo: item.batchNo,
  2081. cargoSpaceCode: item.cargoSpaceCode, //货位编码
  2082. cargoSpaceId: item.cargoSpaceId, //货位id
  2083. shelfId: item.shelfId, //货架id
  2084. shelfCode: item.shelfCode, //货架名称
  2085. areaId: item.areaId, //库区id
  2086. areaName: item.areaName, //库区名称
  2087. warehouseId: item.warehouseId, //仓库id
  2088. warehouseName: item.warehouseName, //仓库名称
  2089. materialId: item.materialId,
  2090. num
  2091. };
  2092. if (!item.isUnpack) {
  2093. // 拆包的包装编码一致
  2094. if (idx < item.warehouseLedgerDetails.length - 1) {
  2095. num = res.data.shift()?.num;
  2096. }
  2097. } else {
  2098. minPackingCount--;
  2099. if (
  2100. minPackingCount === 0 &&
  2101. idx < item.warehouseLedgerDetails.length - 1
  2102. ) {
  2103. minPackingCount = item.minPackingCount;
  2104. num = res1.data.shift()?.num;
  2105. }
  2106. }
  2107. return obj;
  2108. })
  2109. );
  2110. }
  2111. });
  2112. }
  2113. },
  2114. // 包装批量保存
  2115. wrapListSave() {
  2116. // 批量修改包装明细
  2117. this.isWeight = false;
  2118. this.bulkEditingWrap();
  2119. this.$nextTick(() => {
  2120. this.isWeight = true;
  2121. });
  2122. },
  2123. // 物料批量保存
  2124. materialListSave() {
  2125. this.resultArray.forEach((item) => {
  2126. if (!item.isPack) {
  2127. this.materialBtn(item);
  2128. }
  2129. });
  2130. },
  2131. handleSave(data) {
  2132. this.$refs.formName.validate(async (valid) => {
  2133. if (valid) {
  2134. if (!this.warehousingMaterialList?.length) {
  2135. return this.$message.error('请添加入库明细!');
  2136. } else if (
  2137. this.warehousingMaterialList.some((item) => !item.isSave)
  2138. ) {
  2139. return this.$message.error('请保存入库明细!');
  2140. }
  2141. // 默认全部保存
  2142. if (this.resultArray?.length > 0) {
  2143. // 物料批量保存
  2144. this.materialListSave();
  2145. } else {
  2146. // 包装批量保存
  2147. this.wrapListSave();
  2148. }
  2149. this.formatWarehouseMaterialList();
  2150. let arr = this.warehousingMaterialList.map((item) => {
  2151. console.log(item, 'item');
  2152. return {
  2153. netWeight: item.netWeight,
  2154. num: item.num,
  2155. batchNo: item.batchNo,
  2156. code: item.productCode,
  2157. categoryId:
  2158. this.formData.bizType == 2
  2159. ? item.categoryId
  2160. ? item.categoryId
  2161. : item.id
  2162. : item.id,
  2163. count: parseInt(item.outInNum) * parseInt(item.minPackingCount),
  2164. minPackingCount: item.minPackingCount,
  2165. packingCount: item.outInNum,
  2166. price: item.univalence,
  2167. outInDetailRecordAddPOList: item.warehouseLedgerDetails,
  2168. position: `${item.warehouseName}-${item.areaName}-${item.shelfCode}-${item.cargoSpaceCode}`,
  2169. remark: '',
  2170. pathIds: `${item.warehouseId},${item.areaId},${item.shelfId},${item.cargoSpaceId}`,
  2171. pathName: `${item.warehouseName},${item.areaName},${item.shelfCode},${item.cargoSpaceCode}`,
  2172. totalMoney:
  2173. item.outInNum * item.minPackingCount * item.univalence,
  2174. weightUnit: item.weightUnit,
  2175. customCode: item.customCode,
  2176. supplierCode: item.supplierCode,
  2177. weight: item.weight
  2178. };
  2179. });
  2180. arr.forEach((item) => {
  2181. if (item.outInDetailRecordAddPOList.length > 0) {
  2182. let list = item.outInDetailRecordAddPOList.map((it) => {
  2183. return this.formatOutInDetailRecordAddPO(it, item);
  2184. });
  2185. item.outInDetailRecordAddPOList = list;
  2186. }
  2187. });
  2188. let obj = { ...this.formData, type: 1 };
  2189. obj.outInDetailAddPOList = arr;
  2190. this.saveLoading = true;
  2191. // 入库来源storageSource 0-正常 1-外部
  2192. obj.storageSource = 1;
  2193. try {
  2194. const res = await outin.save(obj);
  2195. if (res.code == 0) {
  2196. approveTaskWithVariables(data).then((res) => {
  2197. console.log(res);
  2198. if (res.data.code == 0) {
  2199. this.$message.success('保存成功!');
  2200. this.$emit('success');
  2201. }
  2202. });
  2203. // await outin.outApproves({ outInId: res.data });
  2204. // this.$message.success('保存成功!');
  2205. // this.$emit('success');
  2206. }
  2207. } catch (error) {
  2208. console.error('保存失败:', error);
  2209. }
  2210. this.saveLoading = false;
  2211. // this.$router.push('/warehouseManagement/stockManagement');
  2212. }
  2213. });
  2214. },
  2215. formatWarehouseMaterialList() {
  2216. for (let key in this.warehousingMaterialList) {
  2217. for (let k in this.warehousingMaterialList[key].houseList) {
  2218. let house = this.warehousingMaterialList[key].houseList[k];
  2219. this.warehousingMaterialList[key].warehouseName =
  2220. house.warehouseName;
  2221. this.warehousingMaterialList[key].areaName = house.areaName;
  2222. this.warehousingMaterialList[key].shelfCode = house.shelfCode;
  2223. this.warehousingMaterialList[key].cargoSpaceCode =
  2224. house.cargoSpaceCode;
  2225. this.warehousingMaterialList[key].warehouseId = house.warehouseId;
  2226. this.warehousingMaterialList[key].areaId = house.areaId;
  2227. this.warehousingMaterialList[key].shelfId = house.shelfId;
  2228. this.warehousingMaterialList[key].cargoSpaceId = house.cargoSpaceId;
  2229. this.warehousingMaterialList[key].num = house.num;
  2230. }
  2231. }
  2232. },
  2233. formatOutInDetailRecordAddPO(it, item) {
  2234. return {
  2235. code: it.onlyCode,
  2236. dateType: this.curDateType === 'manufactureTime' ? 2 : 1,
  2237. dateValue: it[this.curDateType],
  2238. minUnit: it.minPackingCount,
  2239. minPositionId: it.cargoSpaceId,
  2240. minPackingCount: it.minPackingCount,
  2241. name: it.assetName,
  2242. pathIds: item.pathIds,
  2243. unit: it.unit,
  2244. packageNo: it.num,
  2245. clientCode: it.clientCode,
  2246. materielCode: it.materielCode,
  2247. weight: it.weight,
  2248. weightUtil: it.weightUtil,
  2249. engrave: it.engrave,
  2250. materialDetails: this.materialDetails(it.onlyCode),
  2251. packingCount: it.packingCount,
  2252. status: it.status,
  2253. result: it.result
  2254. };
  2255. },
  2256. materialDetails(onlyCode) {
  2257. return this.resultArray.filter((item) => item.onlyCode === onlyCode);
  2258. },
  2259. async getOrderCode() {
  2260. const data = await getCode('in_warehouse');
  2261. return data;
  2262. },
  2263. //添加明细
  2264. async onSelectTableData(val) {
  2265. console.log('===ssa', val);
  2266. const res = await getCode('lot_number_code');
  2267. this.warehousingMaterialList.push(
  2268. ...val.map((next) => {
  2269. next.batchNo = res;
  2270. let cur = {};
  2271. next.realInventoryAmount = next.realInventoryAmount || 0;
  2272. cur = {
  2273. ...next,
  2274. cargoSpaceCode: '', //货位编码
  2275. cargoSpaceId: '', //货位id
  2276. shelfId: '', //货架id
  2277. shelfCode: '', //货架名称
  2278. areaId: '', //库区id
  2279. areaName: '', //库区名称
  2280. warehouseId: '', //仓库id
  2281. warehouseName: '', //仓库名称
  2282. assetType: this.formData.extInfo.assetType,
  2283. expirationDate: '',
  2284. outInNum: '',
  2285. minPackingCount: '',
  2286. bizStatus: 1,
  2287. contentImage: [],
  2288. warehouseLedgerDetails: [],
  2289. houseList: []
  2290. };
  2291. return cur;
  2292. })
  2293. );
  2294. },
  2295. async initData() {
  2296. const { data } = await getTreeByGroup({ type: 1 });
  2297. this.codeList = data;
  2298. // .map((item) => {
  2299. // return { dictCode: item.id, dictValue: item.name };
  2300. // });
  2301. const res = await warehouseDefinition.tree();
  2302. this.treeList = this.$util.toTreeData({
  2303. data: res,
  2304. idField: 'id',
  2305. parentIdField: 'parentId'
  2306. });
  2307. // const res111 = await warehouseDefinition.list();
  2308. // this.warehouseList = res111.list;
  2309. let res22 = await warehouseDefinition.getUserPage({
  2310. size: -1,
  2311. page: 1
  2312. });
  2313. this.fromUserList = res22.list;
  2314. const info = await getLoginUser();
  2315. // const info = JSON.parse(localStorage.getItem('info'));
  2316. let obj = res.find(
  2317. (item) => item.id === info.deptId[info.deptId.length - 1]
  2318. );
  2319. if (!obj) return;
  2320. this.formData.extInfo.deptCode = obj.id;
  2321. this.formData.extInfo.deptName = obj.name;
  2322. this.formData.extInfo.createUserName = info.name;
  2323. this.formData.createUserId = info.id;
  2324. // this.treeList = res;
  2325. // this.formData.extInfo.deptCode =
  2326. // this.getTreeList().then((res) => {
  2327. // if (res?.success) {
  2328. // this.treeList = res.data;
  2329. // }
  2330. // });
  2331. // this.getSupplier().then((res) => {
  2332. // if (res?.success) {
  2333. // this.supplierList = res.data.items;
  2334. // }
  2335. // });
  2336. // this.getStaffList();
  2337. },
  2338. addStock() {
  2339. // this.$refs.wareHouseDailogRef.open({});
  2340. // return;
  2341. if (!this.title) return this.$message.error('请选择入库产品类型');
  2342. if (!this.formData.bizType)
  2343. return this.$message.error('请选择入库场景');
  2344. this.visibleDialog = true;
  2345. },
  2346. handleChange(data) {
  2347. this.title = data?.dictValue;
  2348. this.selectEquiType = data?.dictCode;
  2349. },
  2350. handleChanges(code) {
  2351. const data = this.codeList.find((item) => item.dictCode == code);
  2352. this.title = data?.dictValue;
  2353. this.selectEquiType = data?.dictCode;
  2354. },
  2355. getSupplier() {
  2356. return new Promise((resolve, reject) => {
  2357. supplier.list({ page: 1, size: 999 }).then((res) => {
  2358. if (res.success) {
  2359. resolve(res);
  2360. }
  2361. });
  2362. });
  2363. },
  2364. getTreeList() {
  2365. return new Promise((resolve, reject) => {
  2366. org.tree().then((res) => {
  2367. if (res.success) {
  2368. resolve(res);
  2369. }
  2370. });
  2371. });
  2372. },
  2373. upload(data) {
  2374. this.formData.contentImage = data;
  2375. this.$refs.formName.validateField('contentImage');
  2376. },
  2377. houseData(argum, idx) {
  2378. this.$set(this.warehousingMaterialList[idx], 'houseList', argum);
  2379. }
  2380. },
  2381. watch: {
  2382. // 解决右侧悬浮操作栏不对称问题
  2383. warehousingMaterialList: {
  2384. handler() {
  2385. this.$nextTick(() => {
  2386. this.$refs.warehousingMaterialListTable.doLayout();
  2387. });
  2388. },
  2389. deep: true
  2390. },
  2391. // 解决右侧悬浮操作栏不对称问题
  2392. materialCodeReqList: {
  2393. handler() {
  2394. this.$nextTick(() => {
  2395. this.$refs.materialCodeReqListTable.doLayout();
  2396. });
  2397. },
  2398. deep: true
  2399. },
  2400. // 解决右侧悬浮操作栏不对称问题
  2401. resultArray: {
  2402. handler() {
  2403. this.$nextTick(() => {
  2404. this.$refs.resultArrayTable.doLayout();
  2405. });
  2406. },
  2407. deep: true
  2408. }
  2409. }
  2410. };
  2411. </script>
  2412. <style lang="scss" scoped>
  2413. ::v-deep.form-table {
  2414. .el-form-item {
  2415. margin-bottom: 0;
  2416. }
  2417. .el-input__inner {
  2418. padding: 0 10px;
  2419. }
  2420. ::-webkit-scrollbar {
  2421. width: 8px;
  2422. height: 8px;
  2423. background-color: transparent;
  2424. }
  2425. }
  2426. .p20 {
  2427. padding: 20px;
  2428. }
  2429. .el-select,
  2430. .el-date-editor {
  2431. width: 100%;
  2432. }
  2433. .el-form-item {
  2434. margin-bottom: 22px;
  2435. }
  2436. .material {
  2437. margin-top: 20px;
  2438. .flex {
  2439. display: flex;
  2440. justify-content: space-between;
  2441. font-size: 14px;
  2442. align-items: center;
  2443. .red {
  2444. color: #ff4949;
  2445. }
  2446. }
  2447. }
  2448. .mt10 {
  2449. margin-top: 10px;
  2450. }
  2451. .mt20 {
  2452. margin-top: 20px;
  2453. }
  2454. .center {
  2455. text-align: center;
  2456. }
  2457. .switch_left li {
  2458. border-right: 1px solid rgba(222, 222, 222, 1);
  2459. border-left: 1px solid rgba(222, 222, 222, 1);
  2460. }
  2461. .fontOmitted {
  2462. text-overflow: ellipsis;
  2463. overflow: hidden;
  2464. word-break: break-all;
  2465. white-space: nowrap;
  2466. }
  2467. .table-fixed {
  2468. .el-table__fixed-right {
  2469. height: 100% !important;
  2470. }
  2471. .el-table__fixed-left {
  2472. height: 100% !important;
  2473. }
  2474. .el-table__fixed {
  2475. height: 100% !important;
  2476. }
  2477. }
  2478. </style>