add.vue 92 KB

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