add.vue 63 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835
  1. <template>
  2. <div id="inventoryAllocate">
  3. <el-card class="box-card">
  4. <header-title title="基本信息"></header-title>
  5. <el-form label-width="65px" label-position="left" class="ele-form-search">
  6. <el-row :gutter="15">
  7. <el-col :span="8" class="col_height">
  8. <el-form-item label="调拨编码:" prop="code">
  9. <template>
  10. <el-input :disabled="true" v-model="params.code"></el-input>
  11. </template>
  12. </el-form-item>
  13. </el-col>
  14. <el-col :span="8" class="col_height">
  15. <el-form-item label="调拨类型:" prop="warehouseId">
  16. <template>
  17. <el-select
  18. :disabled="isEdit"
  19. @change="allocateChange"
  20. style="width: 100%"
  21. v-model="allocateId"
  22. placeholder="请选择"
  23. >
  24. <el-option
  25. v-for="item in allocationType"
  26. :label="item.label"
  27. :value="item.code"
  28. :key="item.code"
  29. >
  30. </el-option>
  31. </el-select>
  32. </template>
  33. </el-form-item>
  34. </el-col>
  35. <el-col :span="8" class="col_height">
  36. <el-form-item label="调拨名称:" prop="name">
  37. <template>
  38. <el-input
  39. :disabled="isEdit"
  40. v-model="params.name"
  41. placeholder="请输入内容"
  42. ></el-input>
  43. </template>
  44. </el-form-item>
  45. </el-col>
  46. </el-row>
  47. </el-form>
  48. <div class="productBox">
  49. <div class="productsList">
  50. <header-title title="调出明细"></header-title>
  51. <el-form
  52. label-position="left"
  53. class="ele-form-search"
  54. @submit.native.prevent
  55. >
  56. <el-row :gutter="10">
  57. <el-col :span="12">
  58. <el-form-item
  59. label-width="65px"
  60. label="所属工厂:"
  61. prop="factoryId"
  62. >
  63. <el-select
  64. :disabled="isEdit"
  65. style="width: 100%"
  66. @change="factoryChange"
  67. v-model="factoryId"
  68. placeholder="请选择工厂"
  69. >
  70. <el-option
  71. v-for="item in factoryList"
  72. :key="item.id"
  73. :label="item.name"
  74. :value="item.id"
  75. ></el-option>
  76. </el-select>
  77. </el-form-item>
  78. </el-col>
  79. <el-col :span="12">
  80. <el-form-item
  81. label-width="65px"
  82. label="调出仓库:"
  83. prop="outWarehouseId"
  84. >
  85. <template>
  86. <el-select
  87. :disabled="isEdit"
  88. style="width: 100%"
  89. @change="outWarehouseChange"
  90. v-model="params.outWarehouseId"
  91. placeholder="请选择"
  92. >
  93. <el-option
  94. v-for="item in outTreeList"
  95. :disabled="item.hiden"
  96. :label="item.name"
  97. :value="item.id"
  98. :key="item.name"
  99. >
  100. </el-option>
  101. </el-select>
  102. </template>
  103. </el-form-item>
  104. </el-col>
  105. <el-col :span="8">
  106. <el-form-item
  107. label-width="65px"
  108. label="调出库区:"
  109. prop="outCargoAreaId"
  110. >
  111. <template>
  112. <el-select
  113. @change="outCargoAreaChange"
  114. style="width: 100%"
  115. v-model="params.outCargoAreaId"
  116. placeholder="请选择"
  117. >
  118. <el-option
  119. v-for="item in outCargoAreaList"
  120. :label="item.name"
  121. :value="item.id"
  122. :key="item.name"
  123. >
  124. </el-option>
  125. </el-select>
  126. </template>
  127. </el-form-item>
  128. </el-col>
  129. <el-col :span="8">
  130. <el-form-item
  131. label-width="65px"
  132. label="调出货架:"
  133. prop="outShelvesId"
  134. >
  135. <template>
  136. <el-select
  137. style="width: 100%"
  138. @change="outShelvesChange"
  139. v-model="params.outShelvesId"
  140. placeholder="请选择"
  141. >
  142. <el-option
  143. v-for="item in outShelvesList"
  144. :label="item.name"
  145. :value="item.id"
  146. :key="item.name"
  147. >
  148. </el-option>
  149. </el-select>
  150. </template>
  151. </el-form-item>
  152. </el-col>
  153. <el-col :span="8">
  154. <el-form-item
  155. label-width="65px"
  156. label="调出货位:"
  157. prop="outFreightId"
  158. >
  159. <template>
  160. <el-select
  161. style="width: 100%"
  162. @change="outFreightIdChange"
  163. v-model="params.outFreightId"
  164. placeholder="请选择"
  165. >
  166. <el-option
  167. v-for="item in outFreightList"
  168. :label="item.name"
  169. :value="item.id"
  170. :key="item.name"
  171. >
  172. </el-option>
  173. </el-select>
  174. </template>
  175. </el-form-item>
  176. </el-col>
  177. </el-row>
  178. <el-row :gutter="15">
  179. <el-col :span="9">
  180. <el-form-item
  181. label="列表维度:"
  182. label-width="65px"
  183. prop="dimension"
  184. >
  185. <template>
  186. <el-select
  187. clearable
  188. @change="handledime"
  189. v-model="dimension"
  190. placeholder="请选择"
  191. >
  192. <el-option label="物品维度" value="1"> </el-option>
  193. <el-option label="批次维度" value="2"> </el-option>
  194. <el-option label="包装维度" value="3"> </el-option>
  195. </el-select>
  196. </template>
  197. </el-form-item>
  198. </el-col>
  199. <el-col :span="7">
  200. <el-input
  201. placeholder="请输入名称/编码/批次号/型号/规格/客户代号/刻码"
  202. v-model="query.keyWord"
  203. class="input-with-select"
  204. @keyup.enter.native="querySearch"
  205. >
  206. </el-input>
  207. </el-col>
  208. <el-col :span="8">
  209. <div
  210. style="
  211. display: flex;
  212. justify-content: flex-end;
  213. margin-bottom: 10px;
  214. "
  215. >
  216. <el-button
  217. slot="append"
  218. icon="el-icon-search"
  219. type="primary"
  220. @click="querySearch"
  221. >搜索</el-button
  222. >
  223. <el-button
  224. @click="queryReset"
  225. icon="el-icon-refresh-left"
  226. size="small"
  227. type="primary"
  228. >重置</el-button
  229. >
  230. <el-button type="primary" @click="merge">调出</el-button>
  231. </div>
  232. </el-col>
  233. </el-row>
  234. </el-form>
  235. <!-- 数据表格 -->
  236. <ele-pro-table
  237. ref="table"
  238. :columns="columns"
  239. height="calc(100vh-300px)"
  240. :pageSize="20"
  241. :datasource="datasource"
  242. cache-key="wms-inventoryAllocation-add-table-left"
  243. :selection.sync="selection"
  244. row-key="id"
  245. :initLoad="false"
  246. @done="onDone"
  247. >
  248. </ele-pro-table>
  249. </div>
  250. <div class="allocateDetails">
  251. <header-title :title="`调入明细`"></header-title>
  252. <el-form
  253. label-position="left"
  254. class="ele-form-search"
  255. @submit.native.prevent
  256. >
  257. <el-row :gutter="15">
  258. <el-col :span="12">
  259. <el-form-item
  260. label-width="65px"
  261. label="调入工厂:"
  262. prop="targetFactoriesId"
  263. >
  264. <el-select
  265. :disabled="allocateId == 1 || isEdit"
  266. style="width: 100%"
  267. @change="targetFactoryChange"
  268. v-model="params.targetFactoriesId"
  269. placeholder="请选择工厂"
  270. >
  271. <el-option
  272. v-for="item in factoryList"
  273. :key="item.id"
  274. :label="item.name"
  275. :value="item.id"
  276. ></el-option>
  277. </el-select>
  278. </el-form-item>
  279. </el-col>
  280. <el-col :span="12">
  281. <el-form-item
  282. label-width="65px"
  283. label="调入仓库:"
  284. prop="inWarehouseId"
  285. >
  286. <template>
  287. <el-select
  288. :disabled="allocateId == 1 || isEdit"
  289. @change="inWarehouseChange"
  290. style="width: 100%"
  291. v-model="params.inWarehouseId"
  292. placeholder="请选择"
  293. >
  294. <el-option
  295. v-for="item in inTreeList"
  296. :disabled="item.hiden"
  297. :label="item.name"
  298. :value="item.id"
  299. :key="item.name"
  300. >
  301. </el-option>
  302. </el-select>
  303. </template>
  304. </el-form-item>
  305. </el-col>
  306. <el-col :span="12">
  307. <el-form-item
  308. label-width="65px"
  309. label="调入库区:"
  310. prop="inCargoAreaId"
  311. >
  312. <template>
  313. <el-select
  314. @change="inCargoAreaChange"
  315. style="width: 100%"
  316. v-model="params.inCargoAreaId"
  317. placeholder="请选择"
  318. >
  319. <el-option
  320. v-for="item in inCargoAreaList"
  321. :label="item.name"
  322. :value="item.id"
  323. :key="item.name"
  324. >
  325. </el-option>
  326. </el-select>
  327. </template>
  328. </el-form-item>
  329. </el-col>
  330. <el-col :span="12">
  331. <el-form-item
  332. label-width="65px"
  333. label="调入货架:"
  334. prop="inShelvesId"
  335. >
  336. <template>
  337. <el-select
  338. style="width: 100%"
  339. @change="inShelvesChange"
  340. v-model="params.inShelvesId"
  341. placeholder="请选择"
  342. >
  343. <el-option
  344. v-for="item in inShelvesList"
  345. :label="item.name"
  346. :value="item.id"
  347. :key="item.name"
  348. >
  349. </el-option>
  350. </el-select>
  351. </template>
  352. </el-form-item>
  353. </el-col>
  354. <el-col :span="12">
  355. <el-form-item
  356. label-width="65px"
  357. label="调入货位:"
  358. prop="inFreightId"
  359. >
  360. <template>
  361. <el-select
  362. style="width: 100%"
  363. @change="inFreightIdChange"
  364. v-model="params.inFreightId"
  365. placeholder="请选择"
  366. >
  367. <el-option
  368. v-for="item in inFreightList"
  369. :label="item.name"
  370. :value="item.id"
  371. :key="item.name"
  372. >
  373. </el-option>
  374. </el-select>
  375. </template>
  376. </el-form-item>
  377. </el-col>
  378. </el-row>
  379. </el-form>
  380. <ele-pro-table
  381. ref="detailTable"
  382. :columns="columnsRight"
  383. height="calc(100vh-300px)"
  384. :datasource="tableData"
  385. cache-key="wms-inventoryAllocation-add-table-right"
  386. :initLoad="false"
  387. :need-page="false"
  388. >
  389. <template v-slot:quantity="{ row }">
  390. <el-input-number
  391. v-model="row.quantity"
  392. controls-position="right"
  393. :min="0"
  394. :max="row.measureQuantity"
  395. :precision="2"
  396. style="width: 100%"
  397. ></el-input-number>
  398. </template>
  399. <template v-slot:action="scoped">
  400. <el-button
  401. @click="deleted(scoped.row, scoped.$index)"
  402. type="text"
  403. size="small"
  404. >删除</el-button
  405. >
  406. </template>
  407. </ele-pro-table>
  408. <div class="submit_item">
  409. <el-button type="primary" @click="submit(0)">保存</el-button
  410. ><el-button type="primary" @click="config">提交</el-button></div
  411. >
  412. </div>
  413. </div>
  414. </el-card>
  415. </div>
  416. </template>
  417. <script>
  418. import storageApi from '@/api/warehouseManagement/index.js';
  419. import { getCode } from '@/api/codeManagement/index.js';
  420. import { allocationType } from '@/utils/dict/warehouse';
  421. import { getWarehouseList } from '@/api/classifyManage/itemInformation';
  422. import warehouseDefinition from '@/api/warehouseManagement/warehouseDefinition';
  423. export default {
  424. data() {
  425. return {
  426. query: {},
  427. allocationType,
  428. outTreeList: [],
  429. inTreeList: [],
  430. selectionIds: [],
  431. selection: [],
  432. tableData: [],
  433. productList: [],
  434. allocateId: 2,
  435. currentPullAreaId: '',
  436. currentPullAreaName: '',
  437. currentTuneAreaId: '',
  438. currentTuneAreaName: '',
  439. pullLibrary: [], // 调出库
  440. tuneLibrary: [], // 调入库
  441. outWarehouseList: [],
  442. inWarehouseList: [],
  443. dimension: '2',
  444. // 搜索验证状态
  445. searchState: { hasError: false },
  446. params: {
  447. code: '',
  448. name: '',
  449. outWarehouseId: '', // 调出仓库
  450. outWarehouseName: '',
  451. outCargoAreaId: '', // 调出库区
  452. outCargoAreaName: '',
  453. outShelvesId: '', // 调出货架
  454. outShelvesName: '',
  455. outFreightId: '', // 调出货位
  456. outFreightName: '',
  457. targetFactoriesId: '', // 调入工厂
  458. inWarehouseId: '', // 调入仓库
  459. inWarehouseName: '',
  460. inCargoAreaId: '', // 调入库区
  461. inCargoAreaName: '',
  462. inShelvesId: '', // 调入货架
  463. inShelvesName: '',
  464. inFreightId: '', // 调入货位
  465. inFreightName: ''
  466. },
  467. outCargoAreaList: [], // 调出库区列表
  468. outShelvesList: [], // 调出货架列表
  469. outFreightList: [], // 调出货位列表
  470. inCargoAreaList: [], // 调入库区列表
  471. inShelvesList: [], // 调入货架列表
  472. inFreightList: [], // 调入货位列表
  473. treeLoading: false,
  474. currentObj: {},
  475. factoryList: [],
  476. isEdit: false,
  477. factoryId: '', // 工厂ID
  478. transferOrderId: '', // 调拨单ID
  479. page: 1,
  480. size: 20,
  481. total: 0,
  482. };
  483. },
  484. computed: {
  485. // 表格列配置
  486. columns() {
  487. return [
  488. {
  489. columnKey: 'index',
  490. label: '序号',
  491. type: 'index',
  492. width: 55,
  493. align: 'center',
  494. showOverflowTooltip: true,
  495. fixed: 'left'
  496. },
  497. {
  498. width: 45,
  499. type: 'selection',
  500. columnKey: 'selection',
  501. align: 'center',
  502. fixed: 'left'
  503. },
  504. {
  505. prop: 'categoryCode',
  506. label: '物品编码',
  507. align: 'center',
  508. showOverflowTooltip: true,
  509. minWidth: 120
  510. },
  511. {
  512. prop: 'categoryName',
  513. label: '物品名称',
  514. align: 'center',
  515. showOverflowTooltip: true,
  516. minWidth: 180
  517. },
  518. {
  519. prop: 'warehouseName',
  520. label: '仓库',
  521. align: 'center',
  522. showOverflowTooltip: true,
  523. minWidth: 110,
  524. },
  525. {
  526. prop: 'areaName',
  527. label: '库区',
  528. align: 'center',
  529. showOverflowTooltip: true,
  530. minWidth: 110
  531. },
  532. {
  533. prop: 'goodsShelfName',
  534. label: '货架',
  535. align: 'center',
  536. showOverflowTooltip: true,
  537. minWidth: 110
  538. },
  539. {
  540. prop: 'goodsAllocationName',
  541. label: '货位',
  542. align: 'center',
  543. showOverflowTooltip: true,
  544. minWidth: 110
  545. },
  546. {
  547. prop: 'brandNum',
  548. label: '牌号',
  549. align: 'center',
  550. showOverflowTooltip: true,
  551. minWidth: 110
  552. },
  553. {
  554. prop: 'categoryModel',
  555. label: '型号',
  556. align: 'center',
  557. showOverflowTooltip: true,
  558. minWidth: 110
  559. },
  560. {
  561. prop: 'specification',
  562. label: '规格',
  563. align: 'center',
  564. minWidth: 130,
  565. showOverflowTooltip: true,
  566. },
  567. ...(this.dimension != '1' ? [{
  568. prop: 'batchNo',
  569. label: '批次号',
  570. align: 'center',
  571. minWidth: 130,
  572. showOverflowTooltip: true,
  573. }] : []),
  574. ...(this.dimension == '3' ? [
  575. {
  576. prop: 'packageNo',
  577. label: '包装编码',
  578. align: 'center',
  579. minWidth: 130,
  580. showOverflowTooltip: true,
  581. },
  582. {
  583. prop: 'packingQuantity',
  584. label: '包装数量',
  585. align: 'center',
  586. showOverflowTooltip: true,
  587. },
  588. {
  589. prop: 'packingUnit',
  590. label: '包装单位',
  591. align: 'center',
  592. showOverflowTooltip: true,
  593. }
  594. ] : []),
  595. {
  596. prop: 'measureQuantity',
  597. label: '计量数量',
  598. align: 'center',
  599. showOverflowTooltip: true,
  600. },
  601. {
  602. prop: 'measureUnit',
  603. label: '计量单位',
  604. align: 'center',
  605. showOverflowTooltip: true,
  606. },
  607. {
  608. prop: 'weight',
  609. label: '重量',
  610. align: 'center',
  611. showOverflowTooltip: true,
  612. },
  613. {
  614. prop: 'weightUnit',
  615. label: '重量单位',
  616. align: 'center',
  617. showOverflowTooltip: true,
  618. },
  619. {
  620. prop: 'productionDate',
  621. label: '生产日期',
  622. align: 'center',
  623. minWidth: 130,
  624. showOverflowTooltip: true,
  625. },
  626. {
  627. prop: 'purchaseDate',
  628. label: '采购日期',
  629. align: 'center',
  630. showOverflowTooltip: true,
  631. },
  632. {
  633. prop: 'barcodes',
  634. label: '发货条码',
  635. align: 'center',
  636. showOverflowTooltip: true,
  637. },
  638. {
  639. prop: 'clientCode',
  640. label: '客户代号',
  641. align: 'center',
  642. showOverflowTooltip: true,
  643. },
  644. {
  645. prop: 'engrave',
  646. label: '刻码',
  647. align: 'center',
  648. showOverflowTooltip: true,
  649. },
  650. {
  651. prop: 'materielDesignation',
  652. label: '物料代号',
  653. align: 'center',
  654. showOverflowTooltip: true,
  655. }
  656. ]
  657. },
  658. columnsRight() {
  659. return [
  660. {
  661. columnKey: 'index',
  662. label: '序号',
  663. type: 'index',
  664. width: 55,
  665. align: 'center',
  666. showOverflowTooltip: true,
  667. fixed: 'left'
  668. },
  669. {
  670. prop: 'categoryCode',
  671. label: '物品编码',
  672. align: 'center',
  673. showOverflowTooltip: true,
  674. minWidth: 120
  675. },
  676. {
  677. prop: 'categoryName',
  678. label: '物品名称',
  679. align: 'center',
  680. showOverflowTooltip: true,
  681. minWidth: 180
  682. },
  683. {
  684. prop: 'outWarehouseArea',
  685. label: '调出区域',
  686. align: 'center',
  687. showOverflowTooltip: true,
  688. minWidth: 200
  689. },
  690. {
  691. prop: 'inWarehouseArea',
  692. label: '调入区域',
  693. align: 'center',
  694. showOverflowTooltip: true,
  695. minWidth: 200
  696. },
  697. {
  698. prop: 'brandNum',
  699. label: '牌号',
  700. align: 'center',
  701. showOverflowTooltip: true,
  702. minWidth: 110
  703. },
  704. {
  705. prop: 'categoryModel',
  706. label: '型号',
  707. align: 'center',
  708. showOverflowTooltip: true,
  709. minWidth: 110
  710. },
  711. {
  712. prop: 'specification',
  713. label: '规格',
  714. align: 'center',
  715. minWidth: 130,
  716. showOverflowTooltip: true,
  717. },
  718. // {
  719. // prop: 'batchNo',
  720. // label: '批次号',
  721. // align: 'center',
  722. // showOverflowTooltip: true,
  723. // minWidth: 110
  724. // },
  725. ...(this.dimension != '1' ? [{
  726. prop: 'batchNo',
  727. label: '批次号',
  728. align: 'center',
  729. minWidth: 130,
  730. showOverflowTooltip: true,
  731. }] : []),
  732. this.dimension == 3 ? {
  733. prop: 'packageNo',
  734. label: '包装编码',
  735. align: 'center',
  736. minWidth: 130,
  737. showOverflowTooltip: true,
  738. } : '',
  739. this.dimension == 3 ? {
  740. prop: 'packingQuantity',
  741. label: '包装数量',
  742. align: 'center',
  743. showOverflowTooltip: true,
  744. }:'',
  745. this.dimension == 3 ? {
  746. prop: 'packingUnit',
  747. label: '包装单位',
  748. align: 'center',
  749. showOverflowTooltip: true,
  750. } : '',
  751. {
  752. prop: 'measureQuantity',
  753. label: '计量数量',
  754. align: 'center',
  755. showOverflowTooltip: true,
  756. },
  757. {
  758. prop: 'quantity',
  759. label: '调拨数量',
  760. align: 'center',
  761. minWidth: 130,
  762. slot: 'quantity',
  763. showOverflowTooltip: true,
  764. // render: (h, { row, column, index }) => {
  765. // return h('el-input-number', {
  766. // props: {
  767. // value: row.quantity,
  768. // min: 0,
  769. // max: row.measureQuantity,
  770. // precision: 2
  771. // },
  772. // on: {
  773. // input: (val) => {
  774. // this.$set(row, 'quantity', val);
  775. // }
  776. // },
  777. // style: {
  778. // width: '100%'
  779. // }
  780. // });
  781. // }
  782. },
  783. {
  784. prop: 'measureUnit',
  785. label: '计量单位',
  786. align: 'center',
  787. showOverflowTooltip: true,
  788. },
  789. // {
  790. // prop: 'weight',
  791. // label: '重量',
  792. // align: 'center',
  793. // showOverflowTooltip: true,
  794. // },
  795. // {
  796. // prop: 'weightUnit',
  797. // label: '重量单位',
  798. // align: 'center',
  799. // showOverflowTooltip: true,
  800. // },
  801. {
  802. label: '操作',
  803. align: 'center',
  804. fixed: 'right',
  805. width: 100,
  806. slot: 'action'
  807. }
  808. ].filter(Boolean);
  809. },
  810. userInfo() {
  811. console.log('this.$store.state.user.info------', this.$store.state.user.info);
  812. return this.$store.state.user.info
  813. }
  814. },
  815. async created() {
  816. // this.getTreeData();
  817. await this.getFactoryList();
  818. if (this.$route.query.isEdit) {
  819. console.log('this.$route.query.isEdit------', this.$route.query.isEdit);
  820. this.isEdit = true;
  821. this.getEditInfo();
  822. } else {
  823. const code = await getCode('transfer_no');
  824. const name = await getCode('inventory_allocation_name');
  825. this.params.name = name;
  826. this.params.code = code;
  827. if(this.factoryList.find(item => item.id == this.userInfo.factoryId)?.id) {
  828. this.factoryId = this.userInfo.factoryId;
  829. this.params.targetFactoriesId = this.factoryId
  830. // if(this.allocateId == 1) {
  831. // this.params.targetFactoriesId = this.factoryId
  832. // }
  833. this.getTreeData(this.factoryId)
  834. }
  835. }
  836. },
  837. watch: {
  838. productList() {
  839. this.doLayout();
  840. this.$refs.table.setSelectedRowKeys(this.selectionIds);
  841. }
  842. },
  843. methods: {
  844. /* 表格数据源 */
  845. async datasource({ page, limit, where }) {
  846. // return storageApi.getAllotApplyPage({
  847. // pageNum: page,
  848. // size: limit,
  849. // ...where
  850. // });
  851. let params = {
  852. ...this.query,
  853. warehouseId: this.params.outWarehouseId,
  854. warehouseAreaId: this.params.outCargoAreaId,
  855. warehouseAreaGoodsId: this.params.outShelvesId,
  856. warehouseAreaGoodsShelvesId: this.params.outFreightId
  857. };
  858. const data = await storageApi[
  859. this.dimension == 1 ? 'getProductList' : this.dimension == 2 ? 'getBatchList' : 'getPackingList'
  860. ]({
  861. ...params,
  862. pageNum: page,
  863. size: limit
  864. });
  865. return data;
  866. },
  867. onDone(res) {
  868. console.log('res:', res);
  869. this.$nextTick(() => {
  870. // 回显选中的数据的复选框
  871. console.log('data------data', this.selectionIds);
  872. this.$refs.table.setSelectedRowKeys(this.selectionIds);
  873. });
  874. },
  875. /* 刷新表格 */
  876. reload(where) {
  877. this.$refs.table.reload({ page: 1, where });
  878. },
  879. doLayout() {
  880. let that = this;
  881. this.$nextTick(() => {
  882. console.log('操作了!!');
  883. // console.log('that.$refs.table------', that.$refs.table);
  884. that.$refs.table.doLayout();
  885. });
  886. },
  887. async getEditInfo() {
  888. const dataList = await storageApi.getAllotDetailList({
  889. applyId: this.$route.query.id
  890. });
  891. const baseInfo = await storageApi.getAllotDetail(this.$route.query.id);
  892. // 初始化基础数据
  893. this.factoryId = baseInfo.factoriesId;
  894. this.allocateId = baseInfo.type;
  895. this.transferOrderId = baseInfo.id;
  896. await this.getTreeData(); // 初始仓库
  897. this.params = {
  898. code: baseInfo.allotCode,
  899. name: baseInfo.name,
  900. outWarehouseId: baseInfo.sourceWarehouseId, // 调出仓库
  901. outWarehouseName: baseInfo.sourceWarehouse,
  902. outCargoAreaId: '', // 调出库区
  903. outCargoAreaName: '',
  904. outShelvesId: '', // 调出货架
  905. outShelvesName: '',
  906. outFreightId: '', // 调出货位
  907. outFreightName: '',
  908. targetFactoriesId: baseInfo.targetFactoriesId, // 调入工厂
  909. inWarehouseId: baseInfo.targetWarehouseId, // 调入仓库
  910. inWarehouseName: baseInfo.targetWarehouse,
  911. inCargoAreaId: '', // 调入库区
  912. inCargoAreaName: '',
  913. inShelvesId: '', // 调入货架
  914. inShelvesName: '',
  915. inFreightId: '', // 调入货位
  916. inFreightName: ''
  917. };
  918. console.log('baseInfo------', baseInfo);
  919. // 兼容旧数据
  920. if (baseInfo.inventoryDimension == 0) {
  921. if (dataList?.length) {
  922. if (dataList[0].packageNo) {
  923. this.dimension = '2';
  924. }else{
  925. this.dimension = '2';
  926. }
  927. }
  928. } else {
  929. this.dimension = baseInfo.inventoryDimension + '';
  930. }
  931. if (this.allocateId == 1) {
  932. // 库内调拨
  933. await this.outWarehouseChange(baseInfo.sourceWarehouseId); // 加载调出库区
  934. } else {
  935. // 库外调拨
  936. await this.outWarehouseChange(baseInfo.sourceWarehouseId); // 加载调出库区
  937. this.inWarehouseChange(baseInfo.targetWarehouseId); // 加载调入库区
  938. }
  939. // 处理右边显示数据
  940. this.selectionIds = dataList.map((item) => item.outInDetailRecordId);
  941. console.log('this.selectionIds------', this.selectionIds);
  942. console.log('this.productList------', this.productList);
  943. // this.selection = this.productList.filter((item) => {
  944. // return this.selectionIds.includes(item.id);
  945. // });
  946. this.selection = dataList;
  947. // this.selection.forEach((item) => {
  948. // this.$refs.table.toggleRowSelection(item);
  949. // });
  950. this.$refs.table.setSelectedRowKeys(this.selectionIds);
  951. console.log('this.selection------', this.selection);
  952. this.tableData = this.selection.map((item, index) => {
  953. // let filterObj = dataList.filter(
  954. // (ite) => ite.outInDetailRecordId == item.id
  955. // )[0];
  956. // console.log('filterObj---', filterObj);
  957. return {
  958. ...item,
  959. // quantity: filterObj.measureQuantity,
  960. // warehouseId: filterObj.warehouseId,
  961. // warehouseName: filterObj.warehouseName,
  962. // areaId: filterObj.areaId,
  963. // areaName: filterObj.areaName,
  964. // goodsAllocationId: filterObj.goodsAllocationId,
  965. // goodsAllocationName: filterObj.goodsAllocationName,
  966. // goodsShelfId: filterObj.goodsShelfId,
  967. // goodsShelfName: filterObj.goodsShelfName,
  968. // targetAreaId: filterObj.targetAreaId,
  969. // targetAreaName: filterObj.targetAreaName,
  970. // targetGoodsAllocationId: filterObj.targetGoodsAllocationId,
  971. // targetGoodsAllocationName: filterObj.targetGoodsAllocationName,
  972. // targetGoodsShelfId: filterObj.targetGoodsShelfId,
  973. // targetGoodsShelfName: filterObj.targetGoodsShelfName,
  974. // targetWarehouseId: filterObj.targetWarehouseId,
  975. // targetWarehouseName: filterObj.targetWarehouseName,
  976. outWarehouseArea:
  977. item.warehouseName +
  978. (item.areaName ? '-' + item.areaName : '') +
  979. (item.goodsShelfName ? '-' + item.goodsShelfName : '') +
  980. (item.goodsAllocationName
  981. ? '-' + item.goodsAllocationName
  982. : ''),
  983. inWarehouseArea:
  984. item.targetWarehouseName +
  985. (item.targetAreaName ? '-' + item.targetAreaName : '') +
  986. (item.targetGoodsShelfName
  987. ? '-' + item.targetGoodsShelfName
  988. : '') +
  989. (item.targetGoodsAllocationName
  990. ? '-' + item.targetGoodsAllocationName
  991. : '')
  992. };
  993. });
  994. console.log('this.tableData--------!!!!!', this.tableData);
  995. console.log(dataList);
  996. console.log(baseInfo);
  997. },
  998. factoryChange() {
  999. // this.params.inWarehouseName = this.params.outWarehouseName;
  1000. this.params.targetFactoriesId = this.factoryId;
  1001. console.log('this.params------', this.params);
  1002. this.reset();
  1003. this.getTreeData();
  1004. },
  1005. targetFactoryChange() {
  1006. // this.reset();
  1007. // this.getTreeData();
  1008. },
  1009. search() {
  1010. return new Promise((resolve, reject) => {
  1011. // 重置错误标志
  1012. this.searchState.hasError = false;
  1013. if(!this.params.targetFactoriesId){
  1014. this.searchState.hasError = true;
  1015. const errorMsg = '调入工厂不能为空';
  1016. this.$message.error(errorMsg);
  1017. return reject(new Error(errorMsg));
  1018. }
  1019. if(!this.params.inWarehouseId){
  1020. this.searchState.hasError = true;
  1021. const errorMsg = '调入仓库不能为空';
  1022. this.$message.error(errorMsg);
  1023. return reject(new Error(errorMsg));
  1024. }
  1025. // 检查是否存在quantity小于等于0或无效的项
  1026. if(this.tableData.some((item) => !item.quantity || item.quantity <= 0)) {
  1027. this.searchState.hasError = true;
  1028. const errorMsg = '调拨数量不能为0';
  1029. this.$message.error(errorMsg);
  1030. return reject(new Error(errorMsg));
  1031. }
  1032. if (this.allocateId == 1) {
  1033. // 库内调拨
  1034. if (this.params.inFreightId && this.params.outFreightId) {
  1035. if (this.params.inFreightId === this.params.outFreightId) {
  1036. this.productList = [];
  1037. this.searchState.hasError = true;
  1038. const errorMsg = '调入货位不能与调出货位相同';
  1039. this.$message.error(errorMsg);
  1040. return reject(new Error(errorMsg));
  1041. }
  1042. } else if (!this.params.inFreightId && !this.params.outFreightId) {
  1043. if (this.params.inShelvesId && this.params.outShelvesId) {
  1044. if (this.params.inShelvesId === this.params.outShelvesId) {
  1045. this.productList = [];
  1046. this.searchState.hasError = true;
  1047. const errorMsg = '调入货架不能与调出货架相同';
  1048. this.$message.error(errorMsg);
  1049. return reject(new Error(errorMsg));
  1050. }
  1051. } else if (!this.params.inShelvesId && !this.params.outShelvesId) {
  1052. if (this.params.inCargoAreaId && this.params.outCargoAreaId) {
  1053. if (this.params.inCargoAreaId === this.params.outCargoAreaId) {
  1054. this.productList = [];
  1055. this.searchState.hasError = true;
  1056. const errorMsg = '调入库区不能与调出库区相同';
  1057. this.$message.error(errorMsg);
  1058. return reject(new Error(errorMsg));
  1059. }
  1060. } else if (
  1061. !this.params.inCargoAreaId &&
  1062. !this.params.outCargoAreaId
  1063. ) {
  1064. this.productList = [];
  1065. this.searchState.hasError = true;
  1066. const errorMsg = '调入库区与调出库区不能为空';
  1067. this.$message.error(errorMsg);
  1068. return reject(new Error(errorMsg));
  1069. } else {
  1070. this.productList = [];
  1071. this.searchState.hasError = true;
  1072. const errorMsg = '调入库区与调出库区必须同时填写';
  1073. this.$message.error(errorMsg);
  1074. return reject(new Error(errorMsg));
  1075. }
  1076. } else {
  1077. this.productList = [];
  1078. this.searchState.hasError = true;
  1079. const errorMsg = '调入货架与调出货架必须同时填写';
  1080. this.$message.error(errorMsg);
  1081. return reject(new Error(errorMsg));
  1082. }
  1083. } else {
  1084. this.productList = [];
  1085. this.searchState.hasError = true;
  1086. const errorMsg = '调入货位与调出货位必须同时填写';
  1087. this.$message.error(errorMsg);
  1088. return reject(new Error(errorMsg));
  1089. }
  1090. // 验证通过,获取产品列表
  1091. this.getProductList();
  1092. resolve();
  1093. } else {
  1094. // 库外调拨
  1095. resolve();
  1096. // if (!this.params.inFreightId && !this.params.outFreightId) {
  1097. // if (!this.params.inShelvesId && !this.params.outShelvesId) {
  1098. // if (!this.params.inCargoAreaId && !this.params.outCargoAreaId) {
  1099. // this.productList = [];
  1100. // this.searchState.hasError = true;
  1101. // const errorMsg = '调入库区与调出库区不能为空';
  1102. // this.$message.error(errorMsg);
  1103. // return reject(new Error(errorMsg));
  1104. // } else if (
  1105. // this.params.inCargoAreaId &&
  1106. // this.params.outCargoAreaId
  1107. // ) {
  1108. // this.getProductList();
  1109. // this.reload();
  1110. // resolve();
  1111. // } else {
  1112. // this.productList = [];
  1113. // this.searchState.hasError = true;
  1114. // const errorMsg = '调入库区与调出库区必须同时填写';
  1115. // this.$message.error(errorMsg);
  1116. // return reject(new Error(errorMsg));
  1117. // }
  1118. // } else if (this.params.inShelvesId && this.params.outShelvesId) {
  1119. // this.getProductList();
  1120. // this.reload();
  1121. // resolve();
  1122. // } else {
  1123. // this.productList = [];
  1124. // this.searchState.hasError = true;
  1125. // const errorMsg = '调入货架与调出货架必须同时填写';
  1126. // this.$message.error(errorMsg);
  1127. // return reject(new Error(errorMsg));
  1128. // }
  1129. // } else if (this.params.inFreightId && this.params.outFreightId) {
  1130. // this.getProductList();
  1131. // this.reload();
  1132. // resolve();
  1133. // } else {
  1134. // this.productList = [];
  1135. // this.searchState.hasError = true;
  1136. // const errorMsg = '调入货位与调出货位必须同时填写';
  1137. // this.$message.error(errorMsg);
  1138. // return reject(new Error(errorMsg));
  1139. // }
  1140. }
  1141. });
  1142. },
  1143. reset() {
  1144. this.params = {
  1145. ...this.params,
  1146. outWarehouseId: '', // 调出仓库
  1147. outWarehouseName: '',
  1148. outCargoAreaId: '', // 调出库区
  1149. outCargoAreaName: '',
  1150. outShelvesId: '', // 调出货架
  1151. outShelvesName: '',
  1152. outFreightId: '', // 调出货位
  1153. outFreightName: '',
  1154. inWarehouseId: '', // 调入仓库
  1155. inWarehouseName: '',
  1156. inCargoAreaId: '', // 调入库区
  1157. inCargoAreaName: '',
  1158. inShelvesId: '', // 调入货架
  1159. inShelvesName: '',
  1160. inFreightId: '', // 调入货位
  1161. inFreightName: ''
  1162. };
  1163. this.total = 0;
  1164. this.productList = [];
  1165. this.selection = [];
  1166. this.selectionIds = [];
  1167. this.outCargoAreaList = []; // 调出库区列表
  1168. this.inCargoAreaList = []; // 调入库区列表
  1169. this.outShelvesList = []; // 调出货架列表
  1170. this.inShelvesList = []; // 调入货架列表
  1171. this.outFreightList = []; // 调出货位列表
  1172. this.inFreightList = []; // 调入货位列表
  1173. },
  1174. queryReset() {
  1175. this.query = {};
  1176. this.page = 1;
  1177. this.getProductList();
  1178. this.reload();
  1179. },
  1180. querySearch() {
  1181. this.page = 1;
  1182. this.getProductList();
  1183. this.reload();
  1184. },
  1185. //获取工厂列表
  1186. async getFactoryList() {
  1187. const res = await warehouseDefinition.getFactoryarea({
  1188. pageNum: 1,
  1189. size: 9999,
  1190. type: 1
  1191. });
  1192. this.factoryList = res.list;
  1193. },
  1194. async outWarehouseChange(val) {
  1195. console.log('val------', val);
  1196. this.outCargoAreaList = this.outTreeList.filter(
  1197. (item) => item.id == val
  1198. )[0]?.children;
  1199. this.params.outWarehouseName = this.outTreeList.filter(
  1200. (item) => item.id == val
  1201. )[0]?.name;
  1202. this.productList = [];
  1203. this.tableData = [];
  1204. this.selection = [];
  1205. this.selectionIds = [];
  1206. this.params.outCargoAreaId = ''; // 调出库区
  1207. this.params.outCargoAreaName = '';
  1208. this.params.outShelvesId = ''; // 调出货架
  1209. this.params.outShelvesName = '';
  1210. this.params.outFreightId = ''; // 调出货位
  1211. this.params.outFreightName = '';
  1212. this.outShelvesList = []; // 调出货架列表
  1213. this.outFreightList = []; // 调出货位列表
  1214. if (this.allocateId == 2) {
  1215. // 过滤调入库区
  1216. this.inTreeList = this.inTreeList.map((item) => {
  1217. if (item.id === val) {
  1218. return {
  1219. ...item,
  1220. hiden: true
  1221. };
  1222. } else {
  1223. return {
  1224. ...item,
  1225. hiden: false
  1226. };
  1227. }
  1228. });
  1229. } else {
  1230. console.log(11111)
  1231. this.inCargoAreaList = this.outCargoAreaList;
  1232. this.params.inWarehouseName = this.params.outWarehouseName;
  1233. this.params.inWarehouseId = this.params.outWarehouseId;
  1234. this.params.inCargoAreaId = ''; // 调出库区
  1235. this.params.inCargoAreaName = '';
  1236. this.params.inShelvesId = ''; // 调出货架
  1237. this.params.inShelvesName = '';
  1238. this.params.inFreightId = ''; // 调出货位
  1239. this.params.inFreightName = '';
  1240. this.inShelvesList = []; // 调入货架列表
  1241. this.inFreightList = []; // 调入货位列表
  1242. }
  1243. console.log('this.params------~~~', this.params);
  1244. await this.getProductList();
  1245. await this.reload();
  1246. },
  1247. outCargoAreaChange(val) {
  1248. this.outShelvesList = this.outCargoAreaList.filter(
  1249. (item) => item.id == val
  1250. )[0].children;
  1251. this.params.outCargoAreaName = this.outCargoAreaList.filter(
  1252. (item) => item.id == val
  1253. )[0].name;
  1254. this.productList = [];
  1255. this.params.outShelvesId = ''; // 调出货架
  1256. this.params.outShelvesName = '';
  1257. this.params.outFreightId = ''; // 调出货位
  1258. this.params.outFreightName = '';
  1259. this.outFreightList = []; // 调出货位列表
  1260. this.getProductList();
  1261. this.reload();
  1262. },
  1263. outShelvesChange(val) {
  1264. this.outFreightList = this.outShelvesList.filter(
  1265. (item) => item.id == val
  1266. )[0].children;
  1267. this.params.outShelvesName = this.outShelvesList.filter(
  1268. (item) => item.id == val
  1269. )[0].name;
  1270. this.productList = [];
  1271. this.params.outFreightId = ''; // 调出货位
  1272. this.params.outFreightName = '';
  1273. this.getProductList();
  1274. this.reload();
  1275. },
  1276. outFreightIdChange(val) {
  1277. this.params.outFreightName = this.outFreightList.filter(
  1278. (item) => item.id == val
  1279. )[0].name;
  1280. this.getProductList();
  1281. this.reload();
  1282. },
  1283. inWarehouseChange(val) {
  1284. this.inCargoAreaList = this.inTreeList.filter(
  1285. (item) => item.id == val
  1286. )[0]?.children;
  1287. this.params.inWarehouseName = this.inTreeList.filter(
  1288. (item) => item.id == val
  1289. )[0]?.name;
  1290. // this.productList = [];
  1291. // this.tableData = [];
  1292. // this.selection = [];
  1293. // this.selectionIds = [];
  1294. this.params.inCargoAreaId = ''; // 调出库区
  1295. this.params.inCargoAreaName = '';
  1296. this.params.inShelvesId = ''; // 调出货架
  1297. this.params.inShelvesName = '';
  1298. this.params.inFreightId = ''; // 调出货位
  1299. this.params.inFreightName = '';
  1300. this.inShelvesList = []; // 调入货架列表
  1301. this.inFreightList = []; // 调入货位列表
  1302. if (this.allocateId == 2) {
  1303. // 过滤调出库区(库外调拨)
  1304. this.outTreeList = this.outTreeList.map((item) => {
  1305. if (item.id === val) {
  1306. return {
  1307. ...item,
  1308. hiden: true
  1309. };
  1310. } else {
  1311. return {
  1312. ...item,
  1313. hiden: false
  1314. };
  1315. }
  1316. });
  1317. console.log(this.outTreeList);
  1318. }
  1319. },
  1320. inCargoAreaChange(val) {
  1321. this.inShelvesList = this.inCargoAreaList.filter(
  1322. (item) => item.id == val
  1323. )[0].children;
  1324. this.params.inCargoAreaName = this.inCargoAreaList.filter(
  1325. (item) => item.id == val
  1326. )[0].name;
  1327. // this.productList = [];
  1328. this.params.inShelvesId = ''; // 调出货架
  1329. this.params.inShelvesName = '';
  1330. this.params.inFreightId = ''; // 调出货位
  1331. this.params.inFreightName = '';
  1332. this.inFreightList = []; // 调入货位列表
  1333. },
  1334. inShelvesChange(val) {
  1335. this.inFreightList = this.inShelvesList.filter(
  1336. (item) => item.id == val
  1337. )[0].children;
  1338. this.params.inShelvesName = this.inShelvesList.filter(
  1339. (item) => item.id == val
  1340. )[0].name;
  1341. // this.productList = [];
  1342. this.params.inFreightId = ''; // 调出货位
  1343. this.params.inFreightName = '';
  1344. },
  1345. inFreightIdChange(val) {
  1346. this.params.inFreightName = this.inFreightList.filter(
  1347. (item) => item.id == val
  1348. )[0].name;
  1349. },
  1350. // 调出区域改变
  1351. outChange(val) {
  1352. console.log(this.$refs.outTree.getNodeByValue(val));
  1353. let obj = this.$refs.outTree.getNodeByValue(val);
  1354. this.currentObj = obj;
  1355. this.getProductList();
  1356. this.reload();
  1357. },
  1358. // 调入区域改变
  1359. inChange(val) {
  1360. let obj = this.$refs.outTree.getNodeByValue(val);
  1361. },
  1362. handledime() {
  1363. this.getProductList();
  1364. this.reload();
  1365. this.selection=[]
  1366. this.selectionIds = []
  1367. this.$refs.table.clearSelection()
  1368. this.tableData=[]
  1369. },
  1370. async getProductList() {
  1371. let params = {
  1372. ...this.query,
  1373. warehouseId: this.params.outWarehouseId,
  1374. warehouseAreaId: this.params.outCargoAreaId,
  1375. warehouseAreaGoodsId: this.params.outShelvesId,
  1376. warehouseAreaGoodsShelvesId: this.params.outFreightId
  1377. };
  1378. const data = await storageApi[
  1379. this.dimension == 1 ? 'getProductList' : this.dimension == 2 ? 'getBatchList' : 'getPackingList'
  1380. ]({
  1381. ...params,
  1382. pageNum: this.page,
  1383. size: this.size
  1384. });
  1385. this.total = data.count;
  1386. this.productList = data.list;
  1387. },
  1388. async getTreeData() {
  1389. try {
  1390. this.treeLoading = true;
  1391. let res = await storageApi.getWarehouseTrees({
  1392. factoriesId: this.factoryId
  1393. });
  1394. this.treeLoading = false;
  1395. if (res?.code === '0') {
  1396. this.outTreeList = res.data;
  1397. this.inTreeList = res.data;
  1398. }
  1399. } catch (error) {
  1400. console.log(error);
  1401. }
  1402. this.treeLoading = false;
  1403. },
  1404. deleted(row, index) {
  1405. console.log('deleted~~~', row.id, index);
  1406. this.tableData.splice(index, 1);
  1407. this.selectionIds = this.selectionIds.filter((item) => item != row.outInDetailRecordId);
  1408. this.selection = this.selection.filter((item) => item.id != row.id);
  1409. this.$refs.table.setSelectedRowKeys(this.selectionIds);
  1410. this.$forceUpdate()
  1411. },
  1412. config() {
  1413. if (this.allocateId == 1) {
  1414. // 库内
  1415. this.submit(2);
  1416. } else {
  1417. // 库外
  1418. this.submit(1);
  1419. }
  1420. },
  1421. submit(status) {
  1422. if (!this.params.name) {
  1423. return this.$message.error('名称不能为空!');
  1424. }
  1425. // 提交前通过search方法校验数据
  1426. this.search().then(() => {
  1427. // 验证通过后检查表格数据
  1428. if (this.tableData.length > 0) {
  1429. let params = {
  1430. categoryCode: this.tableData
  1431. .map((item) => item.categoryCode)
  1432. .join(','),
  1433. categoryName: this.tableData
  1434. .map((item) => item.categoryName)
  1435. .join(','),
  1436. allotApplyAddPOBuilders: this.tableData.map((item) => {
  1437. return {
  1438. quantity: item.quantity,
  1439. categoryId: item.categoryId,
  1440. warehouseId: item.warehouseId,
  1441. warehouseName: item.warehouseName,
  1442. areaId: item.areaId,
  1443. areaName: item.areaName,
  1444. goodsAllocationId: item.goodsAllocationId,
  1445. goodsAllocationName: item.goodsAllocationName,
  1446. goodsShelfId: item.goodsShelfId,
  1447. goodsShelfName: item.goodsShelfName,
  1448. outInDetailRecordId: item.outInDetailRecordId,
  1449. targetAreaId: item.targetAreaId,
  1450. targetAreaName: item.targetAreaName,
  1451. targetGoodsAllocationId: item.targetGoodsAllocationId,
  1452. targetGoodsAllocationName: item.targetGoodsAllocationName,
  1453. targetGoodsShelfId: item.targetGoodsShelfId,
  1454. targetGoodsShelfName: item.targetGoodsShelfName,
  1455. targetWarehouseId: item.targetWarehouseId || this.params.inWarehouseId,
  1456. targetWarehouseName: item.targetWarehouseName || this.params.inWarehouseName,
  1457. targetFactoriesId: this.params.targetFactoriesId,
  1458. };
  1459. }),
  1460. allotCode: this.params.code,
  1461. name: this.params.name,
  1462. id: this.transferOrderId,
  1463. sourceWarehouse: this.params.outWarehouseName,
  1464. sourceWarehouseId: this.params.outWarehouseId,
  1465. targetWarehouse: this.params.inWarehouseName,
  1466. targetWarehouseId: this.params.inWarehouseId,
  1467. status: status,
  1468. type: this.allocateId,
  1469. inventoryDimension: this.dimension,
  1470. targetFactoriesId: this.params.targetFactoriesId,
  1471. };
  1472. console.log('params------------', params);
  1473. storageApi.allotApplySave(params).then(() => {
  1474. this.$message.success('保存成功');
  1475. this.$router.go(-1);
  1476. });
  1477. } else {
  1478. this.$message.error('请调入相关数据');
  1479. }
  1480. }).catch((error) => {
  1481. // 验证失败,不提交数据
  1482. console.error('数据验证失败:', error);
  1483. });
  1484. },
  1485. checkSelectable(row) {
  1486. return !this.selectionIds.includes(row.id);
  1487. },
  1488. allocateChange(val) {
  1489. this.allocateId = val;
  1490. this.params = {
  1491. ...this.params,
  1492. outWarehouseId: '', // 调出仓库
  1493. outWarehouseName: '',
  1494. outCargoAreaId: '', // 调出库区
  1495. outCargoAreaName: '',
  1496. outShelvesId: '', // 调出货架
  1497. outShelvesName: '',
  1498. outFreightId: '', // 调出货位
  1499. outFreightName: '',
  1500. inWarehouseId: '', // 调入仓库
  1501. inWarehouseName: '',
  1502. inCargoAreaId: '', // 调入库区
  1503. inCargoAreaName: '',
  1504. inShelvesId: '', // 调入货架
  1505. inShelvesName: '',
  1506. inFreightId: '', // 调入货位
  1507. inFreightName: ''
  1508. };
  1509. this.total = 0;
  1510. this.productList = [];
  1511. this.outShelvesList = [];
  1512. this.outCargoAreaList = [];
  1513. this.outFreightList = [];
  1514. this.inShelvesList = [];
  1515. this.inCargoAreaList = [];
  1516. this.inFreightList = [];
  1517. this.selectionIds = [];
  1518. this.selection = [];
  1519. this.tableData = [];
  1520. this.$refs.table.clearSelection();
  1521. this.getTreeData();
  1522. // this.params = {
  1523. // outWarehouseId: '',
  1524. // outWarehouseName: '',
  1525. // inWarehouseId: '',
  1526. // inWarehouseName: ''
  1527. // };
  1528. // this.currentPullAreaId = '';
  1529. // this.currentPullAreaName = '';
  1530. // this.currentTuneAreaId = '';
  1531. // this.currentTuneAreaName = '';
  1532. // this.pullLibrary = [];
  1533. // this.tuneLibrary = [];
  1534. // this.productList = [];
  1535. // this.tableData = [];
  1536. // this.productList = [];
  1537. // this.getWarehouseOptions();
  1538. },
  1539. pullClick(id, name) {
  1540. if (this.currentPullAreaId == id) {
  1541. return false;
  1542. } else {
  1543. console.log('-------------');
  1544. this.currentPullAreaId = id;
  1545. this.currentPullAreaName = name;
  1546. this.currentTuneAreaId = '';
  1547. this.currentTuneAreaName = '';
  1548. }
  1549. storageApi
  1550. .getPackingList({
  1551. warehouseAreaId: id,
  1552. pageNum: 1,
  1553. size: 9999
  1554. })
  1555. .then(({ list }) => {
  1556. this.productList = list;
  1557. });
  1558. },
  1559. tuneClick(id, name, boolen) {
  1560. if (!this.currentPullAreaId) {
  1561. return this.$message.error('请先选择调出库');
  1562. }
  1563. if (boolen) {
  1564. return false;
  1565. }
  1566. this.currentTuneAreaId = id;
  1567. this.currentTuneAreaName = name;
  1568. },
  1569. selecctedRow(val) {
  1570. this.selection = val;
  1571. },
  1572. async getWarehouseOptions() {
  1573. const { data } = await storageApi.getWarehouseTrees();
  1574. this.outWarehouseList = data;
  1575. this.inWarehouseList = data;
  1576. },
  1577. async merge() {
  1578. if (!this.params.outWarehouseId) {
  1579. return this.$message.error('请先选择调出仓库');
  1580. }
  1581. if (!this.params.inWarehouseId) {
  1582. return this.$message.error('请先选择调入仓库');
  1583. }
  1584. if (this.selection.length > 0) {
  1585. console.log(this.selection);
  1586. console.log(this.selectionIds);
  1587. let boolen = this.selection.every((item) =>
  1588. this.selectionIds.includes(item.id)
  1589. );
  1590. console.log('boolen~~~~', boolen);
  1591. if (this.selection.length > 0 && !boolen) {
  1592. this.selection = this.selection.filter(
  1593. (item) => !this.selectionIds.includes(item.id)
  1594. );
  1595. // // 判断货位
  1596. // if (this.params.inFreightId) {
  1597. // let isBoolen = this.selection.some(
  1598. // (item) => item.goodsAllocationId == this.params.inFreightId
  1599. // );
  1600. // if (isBoolen) {
  1601. // return this.$message.error('所选物品货位与调入货位重复!');
  1602. // }
  1603. // }
  1604. // // 判断货架
  1605. // if (!this.params.inFreightId && this.params.inShelvesId) {
  1606. // let isBoolen = this.selection.some(
  1607. // (item) => item.goodsShelfId == this.params.inShelvesId
  1608. // );
  1609. // if (isBoolen) {
  1610. // return this.$message.error('所选物品货架与调入货架重复!');
  1611. // }
  1612. // }
  1613. // // 判断库区
  1614. // if (!this.params.inCargoAreaId) {
  1615. // return this.$message.error('调入库区不能为空');
  1616. // } else if (
  1617. // !this.params.inFreightId &&
  1618. // !this.params.inShelvesId &&
  1619. // this.params.inCargoAreaId
  1620. // ) {
  1621. // let isBoolen = this.selection.some(
  1622. // (item) => item.areaId == this.params.inCargoAreaId
  1623. // );
  1624. // if (isBoolen) {
  1625. // return this.$message.error('所选物品库区与调入库区重复');
  1626. // }
  1627. // }
  1628. if (!this.params.inFreightId && !this.params.inShelvesId) {
  1629. // 只有调入库区
  1630. for (let i = 0; i < this.selection.length; i++) {
  1631. console.log(this.selection[i].areaId);
  1632. console.log(this.params.inCargoAreaId);
  1633. if (this.selection[i].areaId == this.params.inCargoAreaId) {
  1634. return this.$message.error('所选物品库区与调入库区重复');
  1635. }
  1636. }
  1637. } else if (this.params.inShelvesId && !this.params.inFreightId) {
  1638. // 只有调入库区/货架
  1639. for (let i = 0; i < this.selection.length; i++) {
  1640. if (this.selection[i].areaId == this.params.inCargoAreaId) {
  1641. // 库区相同
  1642. if (
  1643. this.selection[i].goodsShelfId == this.params.inShelvesId
  1644. ) {
  1645. // 货架相同
  1646. return this.$message.error(
  1647. '所选物品库区/货架与调入库区/货架重复'
  1648. );
  1649. } else {
  1650. // 货架不同直接录入
  1651. }
  1652. } else {
  1653. // 库区不同直接录入
  1654. }
  1655. }
  1656. } else if (this.params.inShelvesId && this.params.inFreightId) {
  1657. // 只有调入库区/货架/货位
  1658. for (let i = 0; i < this.selection.length; i++) {
  1659. if (this.selection[i].areaId == this.params.inCargoAreaId) {
  1660. // 库区相同
  1661. if (
  1662. this.selection[i].goodsShelfId == this.params.inShelvesId
  1663. ) {
  1664. // 货架相同
  1665. if (
  1666. this.selection[i].goodsAllocationId ==
  1667. this.params.inFreightId
  1668. ) {
  1669. // 货位相同
  1670. return this.$message.error(
  1671. '所选物品库区/货架/货位与调入库区/货架/货位重复'
  1672. );
  1673. } else {
  1674. // 货位不同直接录入
  1675. }
  1676. } else {
  1677. // 货架不同直接录入
  1678. }
  1679. } else {
  1680. // 库区不同直接录入
  1681. }
  1682. }
  1683. } else {
  1684. return this.$message.error('调入库区不能为空');
  1685. }
  1686. this.selectionIds = this.selectionIds.concat(
  1687. this.selection.map((item) => item.id)
  1688. );
  1689. console.log('this.selection---------', this.selection);
  1690. console.log('this.selectionIds---', this.selectionIds);
  1691. this.tableData = this.tableData.concat(
  1692. this.selection.map((item) => {
  1693. console.log('this.params---------', this.params);
  1694. return {
  1695. ...item,
  1696. outInDetailRecordId: item.id,
  1697. quantity: item.quantity || item.measureQuantity,
  1698. categoryId: item.categoryId,
  1699. warehouseId: this.params.outWarehouseId,
  1700. warehouseName: this.params.outWarehouseName,
  1701. areaId: this.params.outCargoAreaId,
  1702. areaName: this.params.outCargoAreaName,
  1703. goodsAllocationId: this.params.outFreightId,
  1704. goodsAllocationName: this.params.outFreightName,
  1705. goodsShelfId: this.params.outShelvesId,
  1706. goodsShelfName: this.params.outShelvesName,
  1707. targetAreaId: this.params.inCargoAreaId,
  1708. targetAreaName: this.params.inCargoAreaName,
  1709. targetGoodsAllocationId: this.params.inFreightId,
  1710. targetGoodsAllocationName: this.params.inFreightName,
  1711. targetGoodsShelfId: this.params.inShelvesId,
  1712. targetGoodsShelfName: this.params.inShelvesName,
  1713. targetWarehouseId: this.params.inWarehouseId,
  1714. targetWarehouseName: this.params.inWarehouseName,
  1715. targetFactoriesId: this.params.targetFactoriesId,
  1716. outWarehouseArea:
  1717. this.params.outWarehouseName +
  1718. (this.params.outCargoAreaName
  1719. ? '-' + this.params.outCargoAreaName
  1720. : '') +
  1721. (this.params.outShelvesName
  1722. ? '-' + this.params.outShelvesName
  1723. : '') +
  1724. (this.params.outFreightName
  1725. ? '-' + this.params.outFreightName
  1726. : ''),
  1727. inWarehouseArea:
  1728. this.params.inWarehouseName +
  1729. (this.params.inCargoAreaName
  1730. ? '-' + this.params.inCargoAreaName
  1731. : '') +
  1732. (this.params.inShelvesName
  1733. ? '-' + this.params.inShelvesName
  1734. : '') +
  1735. (this.params.inFreightName
  1736. ? '-' + this.params.inFreightName
  1737. : '')
  1738. };
  1739. })
  1740. );
  1741. console.log('this.tableData---------', this.tableData);
  1742. } else {
  1743. this.$message.error('请选择正确的行');
  1744. }
  1745. } else {
  1746. this.$message.error('请选择调出物品信息');
  1747. }
  1748. }
  1749. }
  1750. };
  1751. </script>
  1752. <style lang="scss" scoped>
  1753. #inventoryAllocate {
  1754. height: 100%;
  1755. .el-form-item {
  1756. margin-bottom: 5px !important;
  1757. }
  1758. .submit_item {
  1759. display: flex;
  1760. justify-content: flex-end;
  1761. align-items: center;
  1762. margin-top: 8px;
  1763. height: 40px;
  1764. }
  1765. :deep(.el-form-item__label) {
  1766. padding-right: 5px !important;
  1767. }
  1768. :deep(.el-card) {
  1769. height: 100%;
  1770. .el-card__body {
  1771. height: 100%;
  1772. box-sizing: border-box;
  1773. overflow: hidden;
  1774. display: flex;
  1775. flex-direction: column;
  1776. }
  1777. }
  1778. .col_height {
  1779. height: 45px !important;
  1780. }
  1781. .productBox {
  1782. display: flex;
  1783. flex: 1;
  1784. > div {
  1785. flex: 1;
  1786. overflow: hidden;
  1787. }
  1788. }
  1789. .selectBox {
  1790. padding: 20px;
  1791. }
  1792. .box-card {
  1793. margin: 20px;
  1794. }
  1795. .productsList {
  1796. margin-right: 10px;
  1797. display: flex;
  1798. flex-direction: column;
  1799. :deep(.el-table) {
  1800. flex: 1;
  1801. display: flex;
  1802. flex-direction: column;
  1803. .el-table__body-wrapper {
  1804. flex: 1;
  1805. }
  1806. }
  1807. }
  1808. .allocateDetails {
  1809. display: flex;
  1810. flex-direction: column;
  1811. :deep(.el-table) {
  1812. flex: 1;
  1813. display: flex;
  1814. flex-direction: column;
  1815. .el-table__body-wrapper {
  1816. flex: 1;
  1817. }
  1818. }
  1819. }
  1820. }
  1821. </style>