add.vue 55 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661
  1. <template>
  2. <div class="ele-body">
  3. <el-card shadow="never">
  4. <header-title title="基本信息"></header-title>
  5. <el-form
  6. :model="formData"
  7. ref="formName"
  8. label-width="110px"
  9. :rules="rules"
  10. >
  11. <el-row :gutter="20">
  12. <!-- <el-col :span="8">
  13. <el-form-item label="入库单号" prop="bizNum">
  14. <el-input :value="formData.bizNum" disabled /></el-form-item
  15. ></el-col> -->
  16. <!-- <el-col :span="8">
  17. <el-form-item label="仓库" prop="warehouseId">
  18. <el-select
  19. filterable
  20. v-model="formData.warehouseId"
  21. clearable
  22. :disabled="
  23. !!(warehousingMaterialList && warehousingMaterialList.length)
  24. "
  25. >
  26. <el-option
  27. v-for="(item, index) in warehouseList"
  28. :key="index"
  29. :label="item.name"
  30. :value="item.id"
  31. @click.native="warehouse = item"
  32. ></el-option>
  33. </el-select>
  34. </el-form-item>
  35. </el-col> -->
  36. <el-col :span="8">
  37. <el-form-item label="物品类型" prop="extInfo.assetType">
  38. <!-- <DictSelection
  39. dictName="类型用途"
  40. :disabled="
  41. !!(warehousingMaterialList && warehousingMaterialList.length)
  42. "
  43. clearable
  44. v-model="formData.extInfo.assetType"
  45. @itemChange="handleChange"
  46. /> -->
  47. <!-- <el-select
  48. :disabled="
  49. !!(warehousingMaterialList && warehousingMaterialList.length)
  50. "
  51. clearable
  52. v-model="formData.extInfo.assetType"
  53. @change="handleChanges"
  54. >
  55. <el-option
  56. v-for="(item, index) in codeList"
  57. :key="index"
  58. :label="item.dictValue"
  59. :value="item.dictCode"
  60. ></el-option>
  61. </el-select> -->
  62. <selectTree
  63. ref="tree"
  64. class="form-ipt"
  65. size="medium"
  66. style="width: 100%"
  67. clearable
  68. :options="codeList"
  69. :props="{
  70. value: 'id',
  71. label: 'name',
  72. children: 'children'
  73. }"
  74. @getValue="codeListValue"
  75. :isAll="false"
  76. />
  77. </el-form-item>
  78. </el-col>
  79. <el-col :span="8">
  80. <el-form-item label="入库类型" prop="bizType">
  81. <el-select
  82. filterable
  83. placeholder="请选择"
  84. v-model="formData.bizType"
  85. clearable
  86. :disabled="
  87. !!(warehousingMaterialList && warehousingMaterialList.length)
  88. "
  89. >
  90. <el-option
  91. v-for="item in sceneState"
  92. :key="item.code"
  93. :value="item.code + ''"
  94. :label="item.label"
  95. ></el-option>
  96. </el-select> </el-form-item
  97. ></el-col>
  98. <el-col :span="8">
  99. <el-form-item
  100. v-if="formData.bizType == 2"
  101. label="采购订单"
  102. prop="documentSource"
  103. >
  104. <el-input
  105. placeholder="请输入"
  106. clearable
  107. v-model="formData.extInfo.documentSource"
  108. /></el-form-item>
  109. <el-form-item
  110. v-if="formData.bizType == 1"
  111. label="生产订单"
  112. prop="documentSource"
  113. >
  114. <el-input
  115. placeholder="请输入"
  116. clearable
  117. v-model="formData.extInfo.documentSource"
  118. /></el-form-item>
  119. <el-form-item
  120. v-if="formData.bizType != 1 && formData.bizType != 2"
  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-col>
  130. <el-col :span="8">
  131. <el-form-item label="权属部门" prop="deptName">
  132. <el-input
  133. placeholder="权属部门"
  134. disabled
  135. v-model="formData.extInfo.deptName"
  136. clearable
  137. />
  138. </el-form-item>
  139. </el-col>
  140. <el-col :span="8">
  141. <el-form-item label="入库登记人">
  142. <el-input
  143. placeholder="登记人"
  144. disabled
  145. v-model="formData.extInfo.createUserName"
  146. clearable /></el-form-item
  147. ></el-col>
  148. <!-- <el-col :span="8">
  149. <el-form-item label="入库时间" prop="outInTime">
  150. <el-date-picker
  151. v-model="formData.outInTime"
  152. clearable
  153. type="datetime"
  154. value-format="yyyy-MM-dd HH:mm:ss"
  155. placeholder="选择日期"
  156. >
  157. </el-date-picker></el-form-item
  158. ></el-col> -->
  159. <el-col :span="8">
  160. <el-form-item label="供应商" prop="supplierId">
  161. <DictSelection
  162. dictName="经销商列表"
  163. clearable
  164. v-model="formData.extInfo.supplierId"
  165. @itemChange="ChangeSupplier"
  166. />
  167. </el-form-item>
  168. </el-col>
  169. <el-col :span="8">
  170. <el-form-item label="供应商代号" prop="supplierCode">
  171. <el-input
  172. placeholder="请输入"
  173. v-model="formData.supplierCode"
  174. clearable /></el-form-item
  175. ></el-col>
  176. <el-col :span="8" v-if="formData.bizType == 2">
  177. <el-form-item label="客户" prop="clientName">
  178. <DictSelection
  179. dictName="经销商列表"
  180. clearable
  181. v-model="formData.extInfo.clientName"
  182. @itemChange="ChangeSuppliers"
  183. />
  184. </el-form-item>
  185. </el-col>
  186. <el-col :span="8" v-if="formData.bizType == 2">
  187. <el-form-item label="客户代号" prop="clientCode">
  188. <el-input
  189. placeholder="请输入"
  190. v-model="formData.clientCode"
  191. clearable /></el-form-item
  192. ></el-col>
  193. <el-col :span="8">
  194. <el-form-item label="送货人" prop="fromUser">
  195. <el-input
  196. placeholder="请输入"
  197. v-model="formData.fromUser"
  198. clearable /></el-form-item
  199. ></el-col>
  200. <el-col :span="8">
  201. <el-form-item label="送货人联系方式" prop="deliveryPhone">
  202. <el-input
  203. placeholder="请输入"
  204. v-model="formData.extInfo.deliveryPhone"
  205. clearable /></el-form-item
  206. ></el-col>
  207. <el-col :span="8">
  208. <el-form-item label="紧急状态" prop="urgent">
  209. <el-select
  210. filterable
  211. placeholder="请选择"
  212. v-model="formData.extInfo.urgent"
  213. clearable
  214. >
  215. <el-option
  216. v-for="item in emergencyState"
  217. :key="item.code"
  218. :value="item.code"
  219. :label="item.label"
  220. ></el-option>
  221. </el-select> </el-form-item
  222. ></el-col>
  223. <el-col :span="8">
  224. <el-form-item label="审核人部门" prop="verifyDeptName">
  225. <selectTree
  226. ref="tree"
  227. class="form-ipt"
  228. size="medium"
  229. style="width: 100%"
  230. clearable
  231. :options="treeList"
  232. :props="{
  233. value: 'code',
  234. label: 'name',
  235. children: 'children'
  236. }"
  237. @getValue="auditorDeptClick"
  238. />
  239. </el-form-item>
  240. </el-col>
  241. <el-col :span="8">
  242. <el-form-item label="审核人" prop="verifyId">
  243. <el-select
  244. filterable
  245. class="form-ipt"
  246. style="width: 100%"
  247. v-model="formData.verifyId"
  248. placeholder="请选择"
  249. >
  250. <el-option
  251. v-for="item in staffList"
  252. :key="item.id"
  253. :label="item.name"
  254. :value="item.id"
  255. @click.native="changeVerfy(item)"
  256. >
  257. </el-option>
  258. </el-select>
  259. </el-form-item>
  260. </el-col>
  261. <!-- <el-col :span="24">
  262. <el-form-item label="附件" prop="contentImage">
  263. <selectUpload @getImgs="upload" :initData="uploadList" />
  264. </el-form-item>
  265. </el-col> -->
  266. <el-col :span="24">
  267. <el-form-item label="备注" prop="remark">
  268. <el-input
  269. v-model="formData.remark"
  270. clearable
  271. type="textarea"
  272. placeholder="请详细说明"
  273. :rows="4"
  274. ></el-input>
  275. </el-form-item>
  276. </el-col>
  277. </el-row>
  278. </el-form>
  279. <div class="material">
  280. <header-title title="入库信息">
  281. <el-button type="primary" @click="addStock">添加</el-button>
  282. </header-title>
  283. <div class="mt10 form-table">
  284. <el-form
  285. ref="warehousingMaterialListRef"
  286. :model="{ warehousingMaterialList: warehousingMaterialList }"
  287. :show-message="false"
  288. >
  289. <el-table
  290. :header-cell-style="rowClass"
  291. ref="multipleTable"
  292. :key="formData.extInfo.assetType"
  293. :data="warehousingMaterialList"
  294. tooltip-effect="dark"
  295. style="width: 100%"
  296. stripe
  297. >
  298. <el-table-column
  299. label="序号"
  300. type="index"
  301. width="50"
  302. align="center"
  303. >
  304. </el-table-column>
  305. <el-table-column
  306. label="物品编码"
  307. prop="assetCode"
  308. align="center"
  309. width="150"
  310. ></el-table-column>
  311. <el-table-column
  312. label="名称"
  313. align="center"
  314. width="150"
  315. prop="assetName"
  316. ></el-table-column>
  317. <!-- <el-table-column
  318. label="客户编码"
  319. align="center"
  320. width="150"
  321. prop="customCode"
  322. v-if="formData.bizType == 1"
  323. >
  324. <template slot-scope="{ row, $index }">
  325. <template v-if="row.isSave">
  326. {{ row.customCode }}
  327. </template>
  328. <el-form-item
  329. v-else
  330. :prop="`warehousingMaterialList.${$index}.customCode`"
  331. required
  332. >
  333. <el-input v-model="row.customCode"> </el-input>
  334. </el-form-item>
  335. </template>
  336. </el-table-column>
  337. <el-table-column
  338. label="供应商编码"
  339. align="center"
  340. width="150"
  341. prop="customCode"
  342. v-if="formData.bizType == 2"
  343. >
  344. <template slot-scope="{ row, $index }">
  345. <template v-if="row.isSave">
  346. {{ row.supplierCode }}
  347. </template>
  348. <el-form-item
  349. v-else
  350. :prop="`warehousingMaterialList.${$index}.supplierCode`"
  351. required
  352. >
  353. <el-input v-model="row.supplierCode"> </el-input>
  354. </el-form-item>
  355. </template>
  356. </el-table-column> -->
  357. <el-table-column
  358. v-for="(item, index) in tableHeader"
  359. :key="index"
  360. align="center"
  361. :label="item.label"
  362. width="150"
  363. :prop="item.prop"
  364. >
  365. <template slot-scope="{ row }">
  366. <template v-if="item.formatter">{{
  367. item.formatter(row)
  368. }}</template>
  369. <template v-else>{{ row[item.prop] }}</template>
  370. </template>
  371. </el-table-column>
  372. <el-table-column
  373. label="批次号"
  374. prop="batchNo"
  375. width="150"
  376. align="center"
  377. >
  378. <template slot-scope="{ row, $index }">
  379. <template v-if="row.isSave">
  380. {{ row.batchNo }}
  381. </template>
  382. <el-form-item
  383. v-else
  384. :prop="`warehousingMaterialList.${$index}.batchNo`"
  385. required
  386. >
  387. <!-- <el-input v-model="row.batchNo"></el-input> -->
  388. {{ row.batchNo }}
  389. </el-form-item>
  390. </template>
  391. </el-table-column>
  392. <el-table-column
  393. label="最小包装单元"
  394. align="center"
  395. prop="minPackingCount"
  396. width="100"
  397. >
  398. <el-table-column label="" prop="minPackingCount" width="100">
  399. <template slot-scope="{ row, $index }">
  400. <template v-if="row.isSave">
  401. {{ row.minPackingCount }}
  402. </template>
  403. <el-form-item
  404. v-else
  405. :prop="`warehousingMaterialList.${$index}.minPackingCount`"
  406. required
  407. >
  408. <el-input
  409. v-model="row.minPackingCount"
  410. @input="
  411. (value) =>
  412. (row.minPackingCount = value.replace(
  413. /^(0+)|[^\d]+/g,
  414. ''
  415. ))
  416. "
  417. >
  418. </el-input>
  419. </el-form-item>
  420. </template>
  421. </el-table-column>
  422. <el-table-column label="" prop="minPackingCount">
  423. <template slot-scope="{ row, $index }">
  424. {{ handleRowUnit(row) }} /{{ row.minPackUnit }}
  425. </template>
  426. </el-table-column>
  427. </el-table-column>
  428. <el-table-column
  429. label="包装数量"
  430. prop="outInNum"
  431. width="150"
  432. align="center"
  433. >
  434. <template slot-scope="{ row, $index }">
  435. <template v-if="row.isSave || formData.bizType == 5">
  436. {{ row.outInNum }} {{ row.minPackUnit }}
  437. </template>
  438. <el-form-item
  439. v-else
  440. :prop="`warehousingMaterialList.${$index}.outInNum`"
  441. required
  442. >
  443. <el-input
  444. v-model="row.outInNum"
  445. @input="
  446. (value) =>
  447. (row.outInNum = value.replace(/^(0+)|[^\d]+/g, ''))
  448. "
  449. >
  450. <template slot="append">
  451. {{ row.minPackUnit ? row.minPackUnit : '/' }}
  452. </template>
  453. </el-input>
  454. </el-form-item>
  455. </template>
  456. </el-table-column>
  457. <el-table-column
  458. label="单价"
  459. prop="univalence"
  460. width="150"
  461. align="center"
  462. >
  463. <template slot-scope="{ row, $index }">
  464. <!-- <template v-if="row.isSave || formData.bizType == 5">
  465. <template v-if="row.univalence || row.univalence === 0">
  466. {{ row.univalence
  467. }}{{
  468. { yuan: '元', wanyuan: '万元' }[row.univalenceUnit]
  469. }}
  470. </template>
  471. </template> -->
  472. <!-- v-else -->
  473. <el-form-item
  474. :prop="`warehousingMaterialList.${$index}.univalence`"
  475. >
  476. <el-input
  477. v-model="row.univalence"
  478. placeholder="非必填"
  479. @input="
  480. (value) =>
  481. (row.univalence = value.replace(/[^0-9.]+/g, ''))
  482. "
  483. >
  484. <template slot="append">
  485. 元/{{ handleRowUnit(row) }}
  486. <!-- {{
  487. { yuan: '元', wanyuan: '万元' }[row.univalenceUnit]
  488. }} -->
  489. </template>
  490. </el-input>
  491. </el-form-item>
  492. </template>
  493. </el-table-column>
  494. <el-table-column
  495. label="金额"
  496. align="center"
  497. prop="contentImage"
  498. :show-overflow-tooltip="true"
  499. >
  500. <template slot-scope="{ row, $index }">
  501. {{
  502. calcSumTotal(
  503. row.outInNum,
  504. row.minPackingCount,
  505. row.univalence,
  506. row
  507. )
  508. }}
  509. </template>
  510. </el-table-column>
  511. <el-table-column
  512. label="数量"
  513. prop="batchNo"
  514. width="150"
  515. align="center"
  516. v-if="formData.extInfo.assetType == 1"
  517. >
  518. <template slot-scope="{ row, $index }">
  519. <template> {{ row.outInNum }} </template>
  520. </template>
  521. </el-table-column>
  522. <el-table-column
  523. label="数量"
  524. prop="batchNo"
  525. width="150"
  526. align="center"
  527. v-if="formData.extInfo.assetType == 4"
  528. >
  529. <template slot-scope="{ row, $index }">
  530. <template>
  531. {{ row.minPackingCount * row.outInNum }}
  532. </template>
  533. </template>
  534. </el-table-column>
  535. <el-table-column
  536. label="计量单位"
  537. prop="batchNo"
  538. width="150"
  539. align="center"
  540. v-if="formData.extInfo.assetType == 1"
  541. >
  542. <template slot-scope="{ row, $index }">
  543. <template>
  544. {{ row.minPackUnit }}
  545. </template>
  546. </template>
  547. </el-table-column>
  548. <el-table-column
  549. label="计量单位"
  550. prop="batchNo"
  551. width="150"
  552. align="center"
  553. v-if="formData.extInfo.assetType == 4"
  554. >
  555. <template slot-scope="{ row, $index }">
  556. <template>
  557. {{ row.measuringUnit }}
  558. </template>
  559. </template>
  560. </el-table-column>
  561. <el-table-column
  562. label="重量"
  563. align="center"
  564. prop="contentImage"
  565. :show-overflow-tooltip="true"
  566. v-if="formData.extInfo.assetType == 1"
  567. >
  568. <template slot-scope="{ row, $index }">
  569. {{ weightTotal(row.outInNum, row.minPackingCount) }}
  570. <template slot="append">
  571. {{ handleRowUnit(row) }}
  572. <!-- {{
  573. { yuan: '元', wanyuan: '万元' }[row.univalenceUnit]
  574. }} -->
  575. </template>
  576. </template>
  577. </el-table-column>
  578. <el-table-column
  579. label="重量"
  580. align="center"
  581. prop="contentImage"
  582. :show-overflow-tooltip="true"
  583. v-if="formData.extInfo.assetType == 4"
  584. >
  585. <template slot-scope="{ row, $index }">
  586. {{
  587. deviceWeight(
  588. row.roughWeight,
  589. row.minPackingCount * row.outInNum
  590. )
  591. }}
  592. <template slot="append">
  593. {{ handleRowUnit(row) }}
  594. <!-- {{
  595. { yuan: '元', wanyuan: '万元' }[row.univalenceUnit]
  596. }} -->
  597. </template>
  598. </template>
  599. </el-table-column>
  600. <el-table-column
  601. label="重量单位"
  602. align="center"
  603. prop="contentImage"
  604. :show-overflow-tooltip="true"
  605. >
  606. <template slot-scope="{ row, $index }">
  607. {{ row.weightUnit }}
  608. <template slot="append"> </template>
  609. </template>
  610. </el-table-column>
  611. <el-table-column
  612. label="货位"
  613. prop="warehouseName"
  614. :show-overflow-tooltip="true"
  615. width="250"
  616. required
  617. >
  618. <template slot-scope="{ row, $index }">
  619. <el-form-item
  620. :prop="`warehousingMaterialList.${$index}.houseList`"
  621. :required="true"
  622. >
  623. <div @click="handleWareHouse(row, $index)">
  624. <div
  625. style="color: #ff4949"
  626. v-if="row.houseList.length == 0"
  627. >
  628. ---(必填)
  629. </div>
  630. <div v-else>
  631. <div
  632. v-for="(item, index) in row.houseList"
  633. :key="index"
  634. >
  635. {{ item.warehouseName }}- {{ item.areaName }}-
  636. {{ item.shelfCode }}- {{ item.cargoSpaceCode
  637. }}<span style="color: #ff4949" v-if="item.num">
  638. - {{ item.num }}(数)</span
  639. >
  640. <br />
  641. </div>
  642. </div>
  643. </div>
  644. </el-form-item>
  645. </template>
  646. </el-table-column>
  647. <el-table-column
  648. label="质检单"
  649. v-if="formData.extInfo.assetType === 3"
  650. prop="contentImage"
  651. :show-overflow-tooltip="true"
  652. >
  653. <template slot-scope="{ row, $index }">
  654. <upload @on-success="(data) => (row.contentImage = [data])"
  655. ><template slot="placeholder">上传</template></upload
  656. >
  657. </template>
  658. </el-table-column>
  659. <el-table-column
  660. label="操作"
  661. width="200"
  662. fixed="right"
  663. align="center"
  664. >
  665. <template slot-scope="{ row, $index }">
  666. <el-button
  667. type="text"
  668. v-show="!row.isSave"
  669. @click="listSave(row, $index)"
  670. >保存</el-button
  671. >
  672. <el-button
  673. type="text"
  674. v-show="row.isSave"
  675. @click="listEdit(row, $index)"
  676. >编辑</el-button
  677. >
  678. <el-button
  679. type="text"
  680. v-if="formData.bizType == 5"
  681. v-show="!row.isSave"
  682. @click="chooseAssets(row, $index)"
  683. >选择资产编号</el-button
  684. >
  685. <el-button type="text" @click="listDel(row, $index)"
  686. >删除</el-button
  687. >
  688. </template>
  689. </el-table-column>
  690. </el-table>
  691. </el-form>
  692. </div>
  693. <div class="mt20">
  694. <header-title :title="`${title}明细`">
  695. <div class="switch_right">
  696. <el-button
  697. type="text"
  698. @click="dateSetting"
  699. v-if="formData.bizType != 5"
  700. >批量设置{{
  701. curDateType === 'manufactureTime' ? '生产日期' : '采购日期'
  702. }}</el-button
  703. >
  704. </div>
  705. </header-title>
  706. <el-table
  707. ref="multipleTable"
  708. :data="materialCodeReqList"
  709. tooltip-effect="dark"
  710. :key="formData.bizType"
  711. :header-cell-style="rowClass"
  712. style="width: 100%"
  713. stripe
  714. height="300px"
  715. @selection-change="handleSelectionChange"
  716. >
  717. <el-table-column
  718. label=""
  719. type="selection"
  720. align="center"
  721. width="50"
  722. v-if="formData.bizType != 5"
  723. >
  724. </el-table-column>
  725. <el-table-column label="序号" type="index" width="50">
  726. </el-table-column>
  727. <el-table-column
  728. :label="`${title}编码`"
  729. prop="onlyCode"
  730. ></el-table-column>
  731. <el-table-column label="包装编码" prop="num"></el-table-column>
  732. <el-table-column label="批次号" prop="batchNo"></el-table-column>
  733. <el-table-column
  734. label="物品编码"
  735. prop="assetCode"
  736. ></el-table-column>
  737. <el-table-column label="名称" prop="assetName"></el-table-column>
  738. <el-table-column label="最小包装单元" prop="modelType">
  739. <el-table-column label="" prop="minPackingCount" width="100">
  740. <template slot-scope="{ row, $index }">
  741. {{ row.minPackingCount }}
  742. </template>
  743. </el-table-column>
  744. <el-table-column label="" prop="minPackingCount">
  745. <template slot-scope="{ row, $index }">
  746. {{ handleRowUnit(row) }} /{{ row.minPackUnit }}
  747. </template>
  748. </el-table-column>
  749. </el-table-column>
  750. <el-table-column
  751. v-if="formData.bizType != 5"
  752. label="生产日期"
  753. prop=""
  754. width="220"
  755. >
  756. <template slot="header" slot-scope="scope">
  757. <el-select filterable v-model="curDateType">
  758. <el-option
  759. value="manufactureTime"
  760. label="生产日期"
  761. ></el-option>
  762. <el-option
  763. value="procurementTime"
  764. label="采购日期"
  765. ></el-option>
  766. </el-select>
  767. </template>
  768. <template slot-scope="{ row }">
  769. <template v-if="formData.bizType == 5">
  770. {{ row[curDateType] }}
  771. </template>
  772. <el-date-picker
  773. v-else
  774. size="small"
  775. v-model="row[curDateType]"
  776. type="datetime"
  777. value-format="yyyy-MM-dd HH:mm:ss"
  778. placeholder="选择日期"
  779. >
  780. </el-date-picker>
  781. </template>
  782. </el-table-column>
  783. <template v-else>
  784. <el-table-column
  785. label="生产日期"
  786. prop="manufactureTime"
  787. width="200"
  788. ></el-table-column>
  789. <el-table-column
  790. label="采购日期"
  791. prop="procurementTime"
  792. width="200"
  793. ></el-table-column>
  794. </template>
  795. </el-table>
  796. <!-- </el-tab-pane>
  797. </el-tabs> -->
  798. </div>
  799. </div>
  800. <div class="center mt20">
  801. <el-button type="primary" @click="handleSave" :loading="saveLoading"
  802. >保存</el-button
  803. >
  804. <el-button @click="$router.go(-1)">返回</el-button>
  805. </div>
  806. </el-card>
  807. <selectType
  808. :visibleDialog.sync="visibleDialog"
  809. :title="title"
  810. :tableHeader="tableHeader"
  811. :bizScene="formData.bizType"
  812. :type="[selectEquiType]"
  813. :loadTree.sync="loadTree"
  814. @selectTableData="onSelectTableData"
  815. />
  816. <WareHouseDailog
  817. ref="wareHouseDailogRef"
  818. @houseData="houseData"
  819. ></WareHouseDailog>
  820. <ReturnSelect
  821. ref="returnSelectRef"
  822. :tableHeader="tableHeader"
  823. :curDateType="curDateType"
  824. ></ReturnSelect>
  825. <el-dialog :visible.sync="dateVisible" title="选择日期" width="400px">
  826. <el-date-picker
  827. size="small"
  828. v-model="batchTime"
  829. type="datetime"
  830. style="width: 320px"
  831. value-format="yyyy-MM-dd HH:mm:ss"
  832. placeholder="选择日期"
  833. >
  834. </el-date-picker>
  835. <div style="text-align: right; margin-top: 20px">
  836. <el-button @click="dateVisible = false">取消</el-button>
  837. <el-button type="primary" @click="dateConfirm" :disabled="!batchTime"
  838. >确认</el-button
  839. >
  840. </div>
  841. </el-dialog>
  842. </div>
  843. </template>
  844. <script>
  845. import outin from '@/api/warehouseManagement/outin';
  846. import { getTreeByPid, getTreeByGroup } from '@/api/classifyManage';
  847. import warehouseDefinition from '@/api/warehouseManagement/warehouseDefinition';
  848. import selectUpload from '@/components/selectUpload';
  849. import upload from '@/components/uploadImg';
  850. import {
  851. warehousingType,
  852. sceneState,
  853. emergencyState,
  854. materialType
  855. } from '@/utils/dict/index';
  856. // import { getInfo, warehousingAdd, getAssetNum } from '@/api/stockManagement';
  857. import selectTree from '@/components/selectTree';
  858. import selectType from '../components/selectType.vue';
  859. import WareHouseDailog from '../components/WareHouseDailog.vue';
  860. import ReturnSelect from './components/ReturnSelect.vue';
  861. // import supplier from '@/api/main/supplier';
  862. // import org from '@/api/main/org';
  863. // import user from '@/api/main/user';
  864. import { tableHeader } from '../common';
  865. import { getCode } from '@/api/codeManagement/index.js';
  866. import { number } from 'echarts/core';
  867. export default {
  868. components: {
  869. selectUpload,
  870. selectTree,
  871. selectType,
  872. WareHouseDailog,
  873. upload,
  874. ReturnSelect
  875. },
  876. data() {
  877. return {
  878. codeList: [],
  879. materialType,
  880. warehousingType,
  881. sceneState,
  882. emergencyState,
  883. saveLoading: false,
  884. visibleDialog: false,
  885. curDateType: 'manufactureTime',
  886. materialCodeReqListSelected: [],
  887. // warehouseList: [], //仓库数组
  888. // warehouse: {},
  889. title: '',
  890. tableData2: [],
  891. uploadList: [],
  892. supplierList: [],
  893. warehousingMaterialList: [],
  894. activeName: 'a',
  895. loadTree: true,
  896. selectEquiType: '',
  897. batchTime: '',
  898. dateVisible: false,
  899. treeList: [],
  900. staffList: [],
  901. formData: {
  902. extInfo: {
  903. assetType: '', //物品类型
  904. deptCode: '', //部门code
  905. deptName: '', //部门名称
  906. verifyDeptCode: '', //审核部门编码
  907. verifyDeptName: '', //审核部门名称
  908. deliveryName: '', //送货人名称
  909. deliveryPhone: '', //送货人电话
  910. documentSource: '', //销售订单
  911. urgent: '', //紧急状态
  912. supplierId: '', //供应商ID
  913. supplierName: '', //供应商名称
  914. createUserName: '', //创建人名字
  915. contentImage: [] //图片数组
  916. },
  917. fromUser: '', //送货人
  918. bizType: '', //物品类型
  919. verifyId: '', //审核人Id
  920. verifyName: '', //审核人名称
  921. createUserId: '',
  922. remark: ''
  923. },
  924. rules: {
  925. 'extInfo.assetType': {
  926. required: true,
  927. message: '请选择物品类型',
  928. trigger: 'change'
  929. },
  930. bizType: {
  931. required: true,
  932. message: '请选择入库场景',
  933. trigger: 'change'
  934. }
  935. }
  936. };
  937. },
  938. computed: {
  939. // 条码信息
  940. materialCodeReqList() {
  941. return this.warehousingMaterialList
  942. .map((i) => i.warehouseLedgerDetails || [])
  943. .flat();
  944. },
  945. tableHeader() {
  946. return tableHeader(this.selectEquiType);
  947. }
  948. },
  949. created() {
  950. if (this.$route.query.id) {
  951. // this._getInfo()
  952. } else {
  953. let obj = localStorage.getItem('orgInfo')
  954. ? JSON.parse(localStorage.getItem('orgInfo'))
  955. : {};
  956. this.formData.createUserName = obj.name;
  957. this.formData.extInfo.deptName = obj.dept?.name;
  958. this.formData.deptCode = obj.dept?.code;
  959. }
  960. this.initData();
  961. },
  962. methods: {
  963. codeListValue(val) {
  964. console.log(val);
  965. this.formData.extInfo.assetType = val.id;
  966. this.$forceUpdate();
  967. this.title = val?.name;
  968. this.selectEquiType = val?.id;
  969. console.log(this.title);
  970. },
  971. //计算生产设备重量
  972. deviceWeight(row, num) {
  973. if (row) {
  974. return Number(row * num);
  975. } else {
  976. return row;
  977. }
  978. },
  979. //计算重量
  980. weightTotal(PackingCount, outInNum) {
  981. const total = {
  982. PackingCount: Number(PackingCount),
  983. outInNum: Number(outInNum)
  984. };
  985. return total.PackingCount * total.outInNum;
  986. },
  987. //计算金额
  988. calcSumTotal(PackingCount, outInNum, univalence) {
  989. //最小包装单元,包装数量,单价
  990. const total = {
  991. PackingCount: Number(PackingCount),
  992. outInNum: Number(outInNum),
  993. univalence: Number(univalence)
  994. };
  995. return total.PackingCount * total.outInNum * total.univalence;
  996. },
  997. handleRowUnit(row) {
  998. console.log('===sss', this.formData);
  999. if (this.formData.extInfo.assetType == 1) {
  1000. console.log(row);
  1001. return row.weightUnit;
  1002. } else if (this.formData.extInfo.assetType == 4) {
  1003. return row.measuringUnit;
  1004. }
  1005. },
  1006. changeVerfy(it) {
  1007. this.formData.verifyName = it.name;
  1008. console.log(this.formData.verifyName);
  1009. },
  1010. //选择供应啥的操作
  1011. ChangeSupplier(data) {
  1012. this.formData.extInfo.supplierName = data.dictValue;
  1013. },
  1014. ChangeSuppliers(data) {
  1015. this.formData.extInfo.clientName = data.dictValue;
  1016. },
  1017. rowClass({ row, column, rowIndex, columnIndex }) {
  1018. if (rowIndex === 1) {
  1019. return {
  1020. display: 'none',
  1021. background: '#EEEEEE',
  1022. border: 'none'
  1023. };
  1024. }
  1025. return { background: '#EEEEEE', border: 'none' };
  1026. },
  1027. calcSum(a, b, c, row) {
  1028. console.log(a, b, c);
  1029. if (
  1030. (Number.isNaN(+a) && a !== '') ||
  1031. (Number.isNaN(+b) && b !== '') ||
  1032. (Number.isNaN(+c) && c !== '')
  1033. ) {
  1034. return '';
  1035. }
  1036. console.log(row);
  1037. return a * b * c + { yuan: '元', wanyuan: '万元' }[row.univalenceUnit];
  1038. // return a * b * c;
  1039. },
  1040. // 部门 点击事件
  1041. async auditorDeptClick(data) {
  1042. console.log(data);
  1043. this.formData.extInfo.verifyDeptCode = data?.id;
  1044. this.formData.extInfo.verifyDeptName = data?.name;
  1045. this.formData.verifyId = '';
  1046. this.formData.verifyName = '';
  1047. this.$refs.formName.validateField('verifyDeptName');
  1048. if (data) {
  1049. this.getStaffList(data);
  1050. }
  1051. },
  1052. async getStaffList(data) {
  1053. let res = await warehouseDefinition.getUserPage({
  1054. groupId: data.id,
  1055. size: 9999,
  1056. page: 1
  1057. });
  1058. this.staffList = res.list;
  1059. },
  1060. // 详情接口
  1061. // async _getInfo () {
  1062. // const res = await getInfo({ id: this.$route.query.id })
  1063. // if (res?.success) {
  1064. // this.warehousingMaterialList = res.data.warehouseLedgerInfos.map(i => {
  1065. // i.isSave = true
  1066. // return i
  1067. // })
  1068. // this.formData = res.data.outInWarehouse
  1069. // this.uploadList = this.formData.contentImage
  1070. // }
  1071. // },
  1072. chooseAssets(row, index) {
  1073. this.$refs.returnSelectRef.open(row, (res) => {
  1074. row.outInNum = res.length;
  1075. this.$set(
  1076. row,
  1077. 'selfWarehouseLedgerDetails',
  1078. res.map((i) => {
  1079. delete i.updateTime;
  1080. delete i.createTime;
  1081. return i;
  1082. })
  1083. );
  1084. });
  1085. },
  1086. // 仓库编辑
  1087. handleWareHouse(row, idx) {
  1088. this.$refs.wareHouseDailogRef.open(row, idx);
  1089. },
  1090. // 入库操作
  1091. listEdit(row) {
  1092. this.$set(row, 'isSave', false);
  1093. row.selfWarehouseLedgerDetails = row.warehouseLedgerDetails;
  1094. row.warehouseLedgerDetails = [];
  1095. },
  1096. listSave(row, index) {
  1097. console.log(this.formData);
  1098. const fileds = [
  1099. // `warehousingMaterialList.${index}.cargoSpaceCode`,
  1100. `warehousingMaterialList.${index}.batchNo`,
  1101. `warehousingMaterialList.${index}.houseList`
  1102. ];
  1103. if (this.formData.bizType == 1) {
  1104. // fileds.push(...[`warehousingMaterialList.${index}.customCode`]);
  1105. } else if (this.formData.bizType == 2) {
  1106. // fileds.push(...[`warehousingMaterialList.${index}.supplierCode`]);
  1107. }
  1108. if (this.formData.bizType != 5) {
  1109. fileds.push(
  1110. ...[
  1111. `warehousingMaterialList.${index}.outInNum`,
  1112. `warehousingMaterialList.${index}.minPackingCount`
  1113. ]
  1114. );
  1115. } else if (
  1116. this.warehousingMaterialList.some(
  1117. (i) => !i.selfWarehouseLedgerDetails?.length
  1118. )
  1119. ) {
  1120. this.$message.error('请选择资产编号!');
  1121. return;
  1122. }
  1123. console.log(fileds);
  1124. Promise.all(
  1125. fileds.map(
  1126. (item) =>
  1127. new Promise(async (resolve, rej) => {
  1128. console.log('item', item);
  1129. this.$refs.warehousingMaterialListRef.validateField(
  1130. item,
  1131. (err) => {
  1132. if (err) {
  1133. rej(err);
  1134. } else {
  1135. resolve();
  1136. }
  1137. }
  1138. );
  1139. })
  1140. )
  1141. )
  1142. .then((res) => {
  1143. console.log(11111111);
  1144. this.$set(row, 'isSave', true);
  1145. if (this.formData.bizScene != 5) {
  1146. this.createMaterialCode(row);
  1147. } else {
  1148. // 退还
  1149. this.createMaterialCodeReturn(row);
  1150. }
  1151. })
  1152. .catch((err) => {
  1153. this.$message.error('请填入必填项!');
  1154. });
  1155. console.log(2);
  1156. },
  1157. // 批量设置生产日期
  1158. handleSelectionChange(val) {
  1159. this.materialCodeReqListSelected = val;
  1160. },
  1161. dateSetting() {
  1162. if (!this.materialCodeReqListSelected.length) {
  1163. return this.$message.error(`请选择${this.title}明细!`);
  1164. }
  1165. this.dateVisible = true;
  1166. },
  1167. dateConfirm() {
  1168. this.materialCodeReqListSelected.forEach((item) => {
  1169. this.$set(item, this.curDateType, this.batchTime);
  1170. });
  1171. this.dateVisible = false;
  1172. },
  1173. //入库明细删除
  1174. listDel(row, index) {
  1175. this.warehousingMaterialList.splice(index, 1);
  1176. },
  1177. // 入库明细生成条码信息
  1178. async createMaterialCode(row) {
  1179. // 添加相同物品、批次号重新更新明细 原料编码
  1180. const list = this.warehousingMaterialList.filter(
  1181. (i) =>
  1182. i.assetCode === row.assetCode &&
  1183. i.batchNo === row.batchNo &&
  1184. i.isSave
  1185. );
  1186. const num = list.reduce((num, pre) => {
  1187. num += row.isUnpack
  1188. ? pre.outInNum * pre.minPackingCount
  1189. : pre.outInNum - 0;
  1190. return num;
  1191. }, 0);
  1192. const res = await outin.getAssetNum({
  1193. assetCode: row.assetCode,
  1194. batchNum: row.batchNo,
  1195. num
  1196. });
  1197. list.forEach((item) => {
  1198. if (item.warehouseLedgerDetails?.length) {
  1199. item.warehouseLedgerDetails.forEach((i) => {
  1200. i.onlyCode = res.shift().onlyCode;
  1201. });
  1202. } else {
  1203. this.$set(
  1204. item,
  1205. 'warehouseLedgerDetails',
  1206. Array.from(
  1207. new Array(
  1208. item.isUnpack
  1209. ? item.outInNum * item.minPackingCount
  1210. : +item.outInNum
  1211. ),
  1212. (val, idx) => {
  1213. return {
  1214. ...item,
  1215. onlyCode: res.shift().onlyCode,
  1216. bizStatus: 1,
  1217. contentImage: []
  1218. };
  1219. }
  1220. )
  1221. );
  1222. }
  1223. });
  1224. // 添加相同物品,重复批次号 重新更新明细 包装编码
  1225. const batchList = this.warehousingMaterialList.filter(
  1226. (i) => i.batchNo === row.batchNo && i.isSave
  1227. );
  1228. if (batchList.length) {
  1229. const num = batchList.reduce((num, pre) => {
  1230. num += +pre.outInNum;
  1231. return num;
  1232. }, 0);
  1233. const res1 = await outin.getAssetNum({
  1234. batchNum: row.batchNo,
  1235. num
  1236. });
  1237. if (res1) {
  1238. batchList.forEach((item) => {
  1239. let num = res1.shift()?.num;
  1240. let minPackingCount = item.minPackingCount;
  1241. if (item.warehouseLedgerDetails?.length) {
  1242. item.warehouseLedgerDetails.forEach((i, index) => {
  1243. this.$set(i, 'num', num);
  1244. if (!item.isUnpack) {
  1245. if (index < item.warehouseLedgerDetails.length - 1) {
  1246. num = res1.shift()?.num;
  1247. }
  1248. } else {
  1249. // 拆包的包装编码一致
  1250. minPackingCount--;
  1251. if (
  1252. minPackingCount === 0 &&
  1253. index < item.warehouseLedgerDetails.length - 1
  1254. ) {
  1255. minPackingCount = item.minPackingCount;
  1256. num = res1.shift()?.num;
  1257. }
  1258. }
  1259. });
  1260. }
  1261. });
  1262. }
  1263. }
  1264. },
  1265. // 入库明细生成条码信息 退还
  1266. async createMaterialCodeReturn(row) {
  1267. // 添加相同物品重新更新明细 原料编码
  1268. const list = this.warehousingMaterialList.filter(
  1269. (i) => i.batchNo === row.batchNo && i.isSave
  1270. );
  1271. // 退还
  1272. const res = await getAssetNum({
  1273. batchNo: row.batchNo,
  1274. num: list.reduce((num, pre) => {
  1275. num += pre.selfWarehouseLedgerDetails.length;
  1276. return num;
  1277. }, 0)
  1278. });
  1279. if (res?.success) {
  1280. list.forEach((item) => {
  1281. let num = res.data.shift().num;
  1282. let minPackingCount = item.minPackingCount;
  1283. if (item.warehouseLedgerDetails?.length) {
  1284. item.warehouseLedgerDetails.forEach((i, index) => {
  1285. Object.assign(i, {
  1286. num,
  1287. batchNo: item.batchNo,
  1288. cargoSpaceCode: item.cargoSpaceCode, //货位编码
  1289. cargoSpaceId: item.cargoSpaceId, //货位id
  1290. shelfId: item.shelfId, //货架id
  1291. shelfCode: item.shelfCode, //货架名称
  1292. areaId: item.areaId, //库区id
  1293. areaName: item.areaName, //库区名称
  1294. warehouseId: item.warehouseId, //仓库id
  1295. warehouseName: item.warehouseName //仓库名称
  1296. });
  1297. if (!item.isUnpack) {
  1298. // 拆包的包装编码一致
  1299. if (index < item.warehouseLedgerDetails.length - 1) {
  1300. num = res.data.shift()?.num;
  1301. }
  1302. } else {
  1303. minPackingCount--;
  1304. if (
  1305. minPackingCount === 0 &&
  1306. index < item.warehouseLedgerDetails.length - 1
  1307. ) {
  1308. minPackingCount = item.minPackingCount;
  1309. num = res1.data.shift()?.num;
  1310. }
  1311. }
  1312. });
  1313. } else {
  1314. this.$set(
  1315. item,
  1316. 'warehouseLedgerDetails',
  1317. item.selfWarehouseLedgerDetails.map((val, idx) => {
  1318. let obj = {
  1319. ...val,
  1320. bizStatus: 1,
  1321. minPackingCount: item.minPackingCount,
  1322. batchNo: item.batchNo,
  1323. cargoSpaceCode: item.cargoSpaceCode, //货位编码
  1324. cargoSpaceId: item.cargoSpaceId, //货位id
  1325. shelfId: item.shelfId, //货架id
  1326. shelfCode: item.shelfCode, //货架名称
  1327. areaId: item.areaId, //库区id
  1328. areaName: item.areaName, //库区名称
  1329. warehouseId: item.warehouseId, //仓库id
  1330. warehouseName: item.warehouseName, //仓库名称
  1331. materialId: item.materialId,
  1332. num
  1333. };
  1334. if (!item.isUnpack) {
  1335. // 拆包的包装编码一致
  1336. if (idx < item.warehouseLedgerDetails.length - 1) {
  1337. num = res.data.shift()?.num;
  1338. }
  1339. } else {
  1340. minPackingCount--;
  1341. if (
  1342. minPackingCount === 0 &&
  1343. idx < item.warehouseLedgerDetails.length - 1
  1344. ) {
  1345. minPackingCount = item.minPackingCount;
  1346. num = res1.data.shift()?.num;
  1347. }
  1348. }
  1349. return obj;
  1350. })
  1351. );
  1352. }
  1353. });
  1354. }
  1355. },
  1356. handleSave() {
  1357. this.$refs.formName.validate(async (valid) => {
  1358. if (valid) {
  1359. if (!this.warehousingMaterialList?.length) {
  1360. return this.$message.error('请添加入库明细!');
  1361. } else if (
  1362. this.warehousingMaterialList.some((item) => !item.isSave)
  1363. ) {
  1364. return this.$message.error('请保存入库明细!');
  1365. }
  1366. const params = {
  1367. outInWarehouse: { ...this.formData, type: 1 },
  1368. warehouseLedgerInfos: this.warehousingMaterialList
  1369. };
  1370. console.log('第一层', this.warehousingMaterialList);
  1371. for (let key in this.warehousingMaterialList) {
  1372. for (let k in this.warehousingMaterialList[key].houseList) {
  1373. this.warehousingMaterialList[key].warehouseName =
  1374. this.warehousingMaterialList[key].houseList[k].warehouseName;
  1375. this.warehousingMaterialList[key].areaName =
  1376. this.warehousingMaterialList[key].houseList[k].areaName;
  1377. this.warehousingMaterialList[key].shelfCode =
  1378. this.warehousingMaterialList[key].houseList[k].shelfCode;
  1379. this.warehousingMaterialList[key].cargoSpaceCode =
  1380. this.warehousingMaterialList[key].houseList[k].cargoSpaceCode;
  1381. this.warehousingMaterialList[key].warehouseId =
  1382. this.warehousingMaterialList[key].houseList[k].warehouseId;
  1383. this.warehousingMaterialList[key].areaId =
  1384. this.warehousingMaterialList[key].houseList[k].areaId;
  1385. this.warehousingMaterialList[key].shelfId =
  1386. this.warehousingMaterialList[key].houseList[k].shelfId;
  1387. this.warehousingMaterialList[key].cargoSpaceId =
  1388. this.warehousingMaterialList[key].houseList[k].cargoSpaceId;
  1389. }
  1390. }
  1391. let arr = this.warehousingMaterialList.map((item) => {
  1392. return {
  1393. batchNo: item.batchNo,
  1394. categoryId: item.id,
  1395. count: item.outInNum,
  1396. minPackingCount: item.minPackingCount,
  1397. packingCount: item.outInNum,
  1398. price: item.univalence,
  1399. outInDetailRecordAddPOList: item.warehouseLedgerDetails,
  1400. position: `${item.warehouseName}-${item.areaName}-${item.shelfCode}-${item.cargoSpaceCode}`,
  1401. // pathIds: item.categoryLevelPathId.toString(),
  1402. remark: '',
  1403. pathIds: `${item.warehouseId},${item.areaId},${item.shelfId},${item.cargoSpaceId}`,
  1404. pathName: `${item.warehouseName},${item.areaName},${item.shelfCode},${item.cargoSpaceCode}`,
  1405. totalMoney:
  1406. item.outInNum * item.minPackingCount * item.univalence,
  1407. weightUnit: item.weightUnit,
  1408. customCode: item.customCode,
  1409. supplierCode: item.supplierCode
  1410. };
  1411. });
  1412. arr.forEach((item) => {
  1413. if (item.outInDetailRecordAddPOList.length > 0) {
  1414. let list = item.outInDetailRecordAddPOList.map((it) => {
  1415. return {
  1416. code: it.onlyCode,
  1417. dateType: this.curDateType === 'manufactureTime' ? 2 : 1,
  1418. dateValue: it[this.curDateType],
  1419. minUnit: it.minPackingCount,
  1420. minPositionId: it.cargoSpaceId,
  1421. name: it.assetName,
  1422. pathIds: item.pathIds,
  1423. unit: it.unit,
  1424. packageNo: it.num
  1425. };
  1426. });
  1427. item.outInDetailRecordAddPOList = list;
  1428. }
  1429. });
  1430. let obj = { ...this.formData, type: 1 };
  1431. obj.outInDetailAddPOList = arr;
  1432. console.log('====>>', obj);
  1433. this.saveLoading = true;
  1434. try {
  1435. const res = await outin.save(obj);
  1436. if (res.code == 0) {
  1437. this.$message.success('保存成功!');
  1438. }
  1439. } catch (error) {}
  1440. this.saveLoading = false;
  1441. this.$router.push('/warehouseManagement/stockManagement');
  1442. }
  1443. });
  1444. },
  1445. async getOrderCode() {
  1446. const data = await getCode('in_warehouse');
  1447. return data;
  1448. },
  1449. //添加明细
  1450. async onSelectTableData(val) {
  1451. const res = await getCode('lot_number_code');
  1452. this.warehousingMaterialList.push(
  1453. ...val.map((next) => {
  1454. next.batchNo = res;
  1455. let cur = {};
  1456. next.realInventoryAmount = next.realInventoryAmount || 0;
  1457. cur = {
  1458. ...next,
  1459. cargoSpaceCode: '', //货位编码
  1460. cargoSpaceId: '', //货位id
  1461. shelfId: '', //货架id
  1462. shelfCode: '', //货架名称
  1463. areaId: '', //库区id
  1464. areaName: '', //库区名称
  1465. warehouseId: '', //仓库id
  1466. warehouseName: '', //仓库名称
  1467. assetType: this.formData.extInfo.assetType,
  1468. expirationDate: '',
  1469. outInNum: '',
  1470. minPackingCount: '',
  1471. bizStatus: 1,
  1472. contentImage: [],
  1473. warehouseLedgerDetails: [],
  1474. houseList: []
  1475. };
  1476. return cur;
  1477. })
  1478. );
  1479. console.log('sasasa===', this.warehousingMaterialList);
  1480. },
  1481. async initData() {
  1482. const { data } = await getTreeByGroup({ type: 1 });
  1483. this.codeList = data;
  1484. // .map((item) => {
  1485. // return { dictCode: item.id, dictValue: item.name };
  1486. // });
  1487. const res = await warehouseDefinition.tree();
  1488. this.treeList = this.$util.toTreeData({
  1489. data: res,
  1490. idField: 'id',
  1491. parentIdField: 'parentId'
  1492. });
  1493. // const res111 = await warehouseDefinition.list();
  1494. // this.warehouseList = res111.list;
  1495. const info = JSON.parse(localStorage.getItem('info'));
  1496. let obj = res.find((item) => item.id === info.deptId);
  1497. if (!obj) return;
  1498. this.formData.extInfo.deptName = obj.name;
  1499. this.formData.extInfo.createUserName = info.name;
  1500. this.formData.createUserId = info.id;
  1501. // this.treeList = res;
  1502. // this.formData.extInfo.deptCode =
  1503. // this.getTreeList().then((res) => {
  1504. // if (res?.success) {
  1505. // this.treeList = res.data;
  1506. // }
  1507. // });
  1508. // this.getSupplier().then((res) => {
  1509. // if (res?.success) {
  1510. // this.supplierList = res.data.items;
  1511. // }
  1512. // });
  1513. // this.getStaffList();
  1514. },
  1515. addStock() {
  1516. // this.$refs.wareHouseDailogRef.open({});
  1517. // return;
  1518. if (!this.title) return this.$message.error('请选择入库产品类型');
  1519. if (!this.formData.bizType)
  1520. return this.$message.error('请选择入库场景');
  1521. this.visibleDialog = true;
  1522. },
  1523. handleChange(data) {
  1524. this.title = data?.dictValue;
  1525. this.selectEquiType = data?.dictCode;
  1526. },
  1527. handleChanges(code) {
  1528. const data = this.codeList.find((item) => item.dictCode == code);
  1529. this.title = data?.dictValue;
  1530. this.selectEquiType = data?.dictCode;
  1531. },
  1532. getSupplier() {
  1533. return new Promise((resolve, reject) => {
  1534. supplier.list({ page: 1, size: 999 }).then((res) => {
  1535. if (res.success) {
  1536. resolve(res);
  1537. }
  1538. });
  1539. });
  1540. },
  1541. getTreeList() {
  1542. return new Promise((resolve, reject) => {
  1543. org.tree().then((res) => {
  1544. if (res.success) {
  1545. resolve(res);
  1546. }
  1547. });
  1548. });
  1549. },
  1550. upload(data) {
  1551. this.formData.contentImage = data;
  1552. this.$refs.formName.validateField('contentImage');
  1553. },
  1554. houseData(argum, idx) {
  1555. this.$set(this.warehousingMaterialList[idx], 'houseList', argum);
  1556. }
  1557. }
  1558. };
  1559. </script>
  1560. <style lang="scss" scoped>
  1561. ::v-deep.form-table {
  1562. .el-form-item {
  1563. margin-bottom: 0;
  1564. }
  1565. .el-input__inner {
  1566. padding: 0 10px;
  1567. }
  1568. ::-webkit-scrollbar {
  1569. width: 8px;
  1570. height: 8px;
  1571. background-color: transparent;
  1572. }
  1573. }
  1574. .p20 {
  1575. padding: 20px;
  1576. }
  1577. .el-select,
  1578. .el-date-editor {
  1579. width: 100%;
  1580. }
  1581. .el-form-item {
  1582. margin-bottom: 22px;
  1583. }
  1584. .material {
  1585. margin-top: 20px;
  1586. .flex {
  1587. display: flex;
  1588. justify-content: space-between;
  1589. font-size: 14px;
  1590. align-items: center;
  1591. .red {
  1592. color: #ff4949;
  1593. }
  1594. }
  1595. }
  1596. .mt10 {
  1597. margin-top: 10px;
  1598. }
  1599. .mt20 {
  1600. margin-top: 20px;
  1601. }
  1602. .center {
  1603. text-align: center;
  1604. }
  1605. .switch_left li {
  1606. border-right: 1px solid rgba(222, 222, 222, 1);
  1607. border-left: 1px solid rgba(222, 222, 222, 1);
  1608. }
  1609. </style>