add.vue 57 KB

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