add.vue 65 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889
  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="cacheKeyUrl"
  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. cacheKeyUrl: 'wms-inventoryAllocation-add-table-left',
  427. query: {},
  428. allocationType,
  429. outTreeList: [],
  430. inTreeList: [],
  431. selectionIds: [],
  432. selection: [],
  433. tableData: [],
  434. productList: [],
  435. allocateId: 2,
  436. currentPullAreaId: '',
  437. currentPullAreaName: '',
  438. currentTuneAreaId: '',
  439. currentTuneAreaName: '',
  440. pullLibrary: [], // 调出库
  441. tuneLibrary: [], // 调入库
  442. outWarehouseList: [],
  443. inWarehouseList: [],
  444. dimension: '2',
  445. // 搜索验证状态
  446. searchState: { hasError: false },
  447. params: {
  448. code: '',
  449. name: '',
  450. outWarehouseId: '', // 调出仓库
  451. outWarehouseName: '',
  452. outCargoAreaId: '', // 调出库区
  453. outCargoAreaName: '',
  454. outShelvesId: '', // 调出货架
  455. outShelvesName: '',
  456. outFreightId: '', // 调出货位
  457. outFreightName: '',
  458. targetFactoriesId: '', // 调入工厂
  459. inWarehouseId: '', // 调入仓库
  460. inWarehouseName: '',
  461. inCargoAreaId: '', // 调入库区
  462. inCargoAreaName: '',
  463. inShelvesId: '', // 调入货架
  464. inShelvesName: '',
  465. inFreightId: '', // 调入货位
  466. inFreightName: ''
  467. },
  468. outCargoAreaList: [], // 调出库区列表
  469. outShelvesList: [], // 调出货架列表
  470. outFreightList: [], // 调出货位列表
  471. inCargoAreaList: [], // 调入库区列表
  472. inShelvesList: [], // 调入货架列表
  473. inFreightList: [], // 调入货位列表
  474. treeLoading: false,
  475. currentObj: {},
  476. factoryList: [],
  477. isEdit: false,
  478. factoryId: '', // 工厂ID
  479. transferOrderId: '', // 调拨单ID
  480. page: 1,
  481. size: 20,
  482. total: 0,
  483. };
  484. },
  485. computed: {
  486. // 表格列配置
  487. columns() {
  488. return [
  489. {
  490. columnKey: 'index',
  491. label: '序号',
  492. type: 'index',
  493. width: 55,
  494. align: 'center',
  495. showOverflowTooltip: true,
  496. fixed: 'left'
  497. },
  498. {
  499. width: 45,
  500. type: 'selection',
  501. columnKey: 'selection',
  502. align: 'center',
  503. fixed: 'left'
  504. },
  505. {
  506. prop: 'categoryCode',
  507. label: '物品编码',
  508. align: 'center',
  509. showOverflowTooltip: true,
  510. minWidth: 120
  511. },
  512. {
  513. prop: 'categoryName',
  514. label: '物品名称',
  515. align: 'center',
  516. showOverflowTooltip: true,
  517. minWidth: 180
  518. },
  519. {
  520. prop: 'warehouseName',
  521. label: '仓库',
  522. align: 'center',
  523. showOverflowTooltip: true,
  524. minWidth: 110,
  525. },
  526. {
  527. prop: 'areaName',
  528. label: '库区',
  529. align: 'center',
  530. showOverflowTooltip: true,
  531. minWidth: 110
  532. },
  533. {
  534. prop: 'goodsShelfName',
  535. label: '货架',
  536. align: 'center',
  537. showOverflowTooltip: true,
  538. minWidth: 110
  539. },
  540. {
  541. prop: 'goodsAllocationName',
  542. label: '货位',
  543. align: 'center',
  544. showOverflowTooltip: true,
  545. minWidth: 110
  546. },
  547. {
  548. prop: 'measureQuantity',
  549. label: '计量数量',
  550. align: 'center',
  551. showOverflowTooltip: true,
  552. },
  553. {
  554. prop: 'measureUnit',
  555. label: '计量单位',
  556. align: 'center',
  557. showOverflowTooltip: true,
  558. },
  559. {
  560. prop: 'lockQuantity',
  561. label: '锁定数量',
  562. align: 'center',
  563. showOverflowTooltip: true,
  564. },
  565. {
  566. prop: 'brandNum',
  567. label: '牌号',
  568. align: 'center',
  569. showOverflowTooltip: true,
  570. minWidth: 110
  571. },
  572. {
  573. prop: 'categoryModel',
  574. label: '型号',
  575. align: 'center',
  576. showOverflowTooltip: true,
  577. minWidth: 110
  578. },
  579. {
  580. prop: 'specification',
  581. label: '规格',
  582. align: 'center',
  583. minWidth: 130,
  584. showOverflowTooltip: true,
  585. },
  586. {
  587. prop: 'colorKey',
  588. label: '颜色',
  589. align: 'center',
  590. minWidth: 130,
  591. showOverflowTooltip: true,
  592. },
  593. ...(this.dimension != '1' ? [{
  594. prop: 'batchNo',
  595. label: '批次号',
  596. align: 'center',
  597. minWidth: 130,
  598. showOverflowTooltip: true,
  599. }] : []),
  600. ...(this.dimension == '3' ? [
  601. {
  602. prop: 'packageNo',
  603. label: '包装编码',
  604. align: 'center',
  605. minWidth: 130,
  606. showOverflowTooltip: true,
  607. },
  608. {
  609. prop: 'packingQuantity',
  610. label: '包装数量',
  611. align: 'center',
  612. showOverflowTooltip: true,
  613. },
  614. {
  615. prop: 'packingUnit',
  616. label: '包装单位',
  617. align: 'center',
  618. showOverflowTooltip: true,
  619. }
  620. ] : []),
  621. {
  622. prop: 'weight',
  623. label: '重量',
  624. align: 'center',
  625. showOverflowTooltip: true,
  626. },
  627. {
  628. prop: 'weightUnit',
  629. label: '重量单位',
  630. align: 'center',
  631. showOverflowTooltip: true,
  632. },
  633. {
  634. prop: 'productionDate',
  635. label: '生产日期',
  636. align: 'center',
  637. minWidth: 130,
  638. showOverflowTooltip: true,
  639. },
  640. {
  641. prop: 'purchaseDate',
  642. label: '采购日期',
  643. align: 'center',
  644. showOverflowTooltip: true,
  645. },
  646. {
  647. prop: 'barcodes',
  648. label: '发货条码',
  649. align: 'center',
  650. showOverflowTooltip: true,
  651. },
  652. {
  653. prop: 'clientCode',
  654. label: '客户代号',
  655. align: 'center',
  656. showOverflowTooltip: true,
  657. },
  658. {
  659. prop: 'engrave',
  660. label: '刻码',
  661. align: 'center',
  662. showOverflowTooltip: true,
  663. },
  664. {
  665. prop: 'materielDesignation',
  666. label: '物料代号',
  667. align: 'center',
  668. showOverflowTooltip: true,
  669. },
  670. {
  671. prop: 'saleOrderNos',
  672. label: '销售订单号',
  673. align: 'center',
  674. minWidth: 150,
  675. showOverflowTooltip: true,
  676. formatter(row) {
  677. return row.saleOrderInfo?.saleOrderNos || '';
  678. }
  679. },
  680. {
  681. prop: 'customerNames',
  682. label: '客户',
  683. align: 'center',
  684. showOverflowTooltip: true,
  685. minWidth: 150,
  686. formatter(row) {
  687. return row.saleOrderInfo?.customerNames || '';
  688. }
  689. }
  690. ]
  691. },
  692. columnsRight() {
  693. return [
  694. {
  695. columnKey: 'index',
  696. label: '序号',
  697. type: 'index',
  698. width: 55,
  699. align: 'center',
  700. showOverflowTooltip: true,
  701. fixed: 'left'
  702. },
  703. {
  704. prop: 'categoryCode',
  705. label: '物品编码',
  706. align: 'center',
  707. showOverflowTooltip: true,
  708. minWidth: 120
  709. },
  710. {
  711. prop: 'categoryName',
  712. label: '物品名称',
  713. align: 'center',
  714. showOverflowTooltip: true,
  715. minWidth: 180
  716. },
  717. {
  718. prop: 'outWarehouseArea',
  719. label: '调出区域',
  720. align: 'center',
  721. showOverflowTooltip: true,
  722. minWidth: 200
  723. },
  724. {
  725. prop: 'inWarehouseArea',
  726. label: '调入区域',
  727. align: 'center',
  728. showOverflowTooltip: true,
  729. minWidth: 200
  730. },
  731. {
  732. prop: 'brandNum',
  733. label: '牌号',
  734. align: 'center',
  735. showOverflowTooltip: true,
  736. minWidth: 110
  737. },
  738. {
  739. prop: 'categoryModel',
  740. label: '型号',
  741. align: 'center',
  742. showOverflowTooltip: true,
  743. minWidth: 110
  744. },
  745. {
  746. prop: 'specification',
  747. label: '规格',
  748. align: 'center',
  749. minWidth: 130,
  750. showOverflowTooltip: true,
  751. },
  752. {
  753. prop: 'colorKey',
  754. label: '颜色',
  755. align: 'center',
  756. minWidth: 130,
  757. showOverflowTooltip: true,
  758. },
  759. // {
  760. // prop: 'batchNo',
  761. // label: '批次号',
  762. // align: 'center',
  763. // showOverflowTooltip: true,
  764. // minWidth: 110
  765. // },
  766. ...(this.dimension != '1' ? [{
  767. prop: 'batchNo',
  768. label: '批次号',
  769. align: 'center',
  770. minWidth: 130,
  771. showOverflowTooltip: true,
  772. }] : []),
  773. this.dimension == 3 ? {
  774. prop: 'packageNo',
  775. label: '包装编码',
  776. align: 'center',
  777. minWidth: 130,
  778. showOverflowTooltip: true,
  779. } : '',
  780. this.dimension == 3 ? {
  781. prop: 'packingQuantity',
  782. label: '包装数量',
  783. align: 'center',
  784. showOverflowTooltip: true,
  785. }:'',
  786. this.dimension == 3 ? {
  787. prop: 'packingUnit',
  788. label: '包装单位',
  789. align: 'center',
  790. showOverflowTooltip: true,
  791. } : '',
  792. {
  793. prop: 'measureQuantity',
  794. label: '计量数量',
  795. align: 'center',
  796. showOverflowTooltip: true,
  797. },
  798. {
  799. prop: 'quantity',
  800. label: '调拨数量',
  801. align: 'center',
  802. minWidth: 130,
  803. slot: 'quantity',
  804. showOverflowTooltip: true,
  805. // render: (h, { row, column, index }) => {
  806. // return h('el-input-number', {
  807. // props: {
  808. // value: row.quantity,
  809. // min: 0,
  810. // max: row.measureQuantity,
  811. // precision: 2
  812. // },
  813. // on: {
  814. // input: (val) => {
  815. // this.$set(row, 'quantity', val);
  816. // }
  817. // },
  818. // style: {
  819. // width: '100%'
  820. // }
  821. // });
  822. // }
  823. },
  824. {
  825. prop: 'measureUnit',
  826. label: '计量单位',
  827. align: 'center',
  828. showOverflowTooltip: true,
  829. },
  830. // {
  831. // prop: 'weight',
  832. // label: '重量',
  833. // align: 'center',
  834. // showOverflowTooltip: true,
  835. // },
  836. // {
  837. // prop: 'weightUnit',
  838. // label: '重量单位',
  839. // align: 'center',
  840. // showOverflowTooltip: true,
  841. // },
  842. {
  843. label: '操作',
  844. align: 'center',
  845. fixed: 'right',
  846. width: 100,
  847. slot: 'action'
  848. }
  849. ].filter(Boolean);
  850. },
  851. userInfo() {
  852. console.log('this.$store.state.user.info------', this.$store.state.user.info);
  853. return this.$store.state.user.info
  854. }
  855. },
  856. async created() {
  857. // this.getTreeData();
  858. await this.getFactoryList();
  859. if (this.$route.query.isEdit) {
  860. console.log('this.$route.query.isEdit------', this.$route.query.isEdit);
  861. this.isEdit = true;
  862. this.getEditInfo();
  863. } else {
  864. const code = await getCode('transfer_no');
  865. const name = await getCode('inventory_allocation_name');
  866. this.params.name = name;
  867. this.params.code = code;
  868. if(this.factoryList.find(item => item.id == this.userInfo.factoryId)?.id) {
  869. this.factoryId = this.userInfo.factoryId;
  870. this.params.targetFactoriesId = this.factoryId
  871. // if(this.allocateId == 1) {
  872. // this.params.targetFactoriesId = this.factoryId
  873. // }
  874. this.getTreeData(this.factoryId)
  875. }
  876. }
  877. },
  878. watch: {
  879. productList() {
  880. this.doLayout();
  881. this.$refs.table.setSelectedRowKeys(this.selectionIds);
  882. }
  883. },
  884. methods: {
  885. /* 表格数据源 */
  886. async datasource({ page, limit, where }) {
  887. // return storageApi.getAllotApplyPage({
  888. // pageNum: page,
  889. // size: limit,
  890. // ...where
  891. // });
  892. let params = {
  893. ...this.query,
  894. warehouseId: this.params.outWarehouseId,
  895. warehouseAreaId: this.params.outCargoAreaId,
  896. warehouseAreaGoodsId: this.params.outShelvesId,
  897. warehouseAreaGoodsShelvesId: this.params.outFreightId
  898. };
  899. const data = await storageApi[
  900. this.dimension == 1 ? 'getProductList' : this.dimension == 2 ? 'getBatchList' : 'getPackingList'
  901. ]({
  902. ...params,
  903. pageNum: page,
  904. size: limit
  905. });
  906. return data;
  907. },
  908. onDone(res) {
  909. console.log('res:', res);
  910. this.$nextTick(() => {
  911. // 回显选中的数据的复选框
  912. console.log('data------data', this.selectionIds);
  913. this.$refs.table.setSelectedRowKeys(this.selectionIds);
  914. });
  915. },
  916. /* 刷新表格 */
  917. reload(where) {
  918. this.$refs.table.reload({ page: 1, where });
  919. },
  920. doLayout() {
  921. let that = this;
  922. this.$nextTick(() => {
  923. console.log('操作了!!');
  924. // console.log('that.$refs.table------', that.$refs.table);
  925. that.$refs.table.doLayout();
  926. });
  927. },
  928. async getEditInfo() {
  929. const dataList = await storageApi.getAllotDetailList({
  930. applyId: this.$route.query.id
  931. });
  932. const baseInfo = await storageApi.getAllotDetail(this.$route.query.id);
  933. // 初始化基础数据
  934. this.factoryId = baseInfo.factoriesId;
  935. this.allocateId = baseInfo.type;
  936. this.transferOrderId = baseInfo.id;
  937. await this.getTreeData(); // 初始仓库
  938. this.params = {
  939. code: baseInfo.allotCode,
  940. name: baseInfo.name,
  941. outWarehouseId: baseInfo.sourceWarehouseId, // 调出仓库
  942. outWarehouseName: baseInfo.sourceWarehouse,
  943. outCargoAreaId: '', // 调出库区
  944. outCargoAreaName: '',
  945. outShelvesId: '', // 调出货架
  946. outShelvesName: '',
  947. outFreightId: '', // 调出货位
  948. outFreightName: '',
  949. targetFactoriesId: baseInfo.targetFactoriesId, // 调入工厂
  950. inWarehouseId: baseInfo.targetWarehouseId, // 调入仓库
  951. inWarehouseName: baseInfo.targetWarehouse,
  952. inCargoAreaId: '', // 调入库区
  953. inCargoAreaName: '',
  954. inShelvesId: '', // 调入货架
  955. inShelvesName: '',
  956. inFreightId: '', // 调入货位
  957. inFreightName: ''
  958. };
  959. console.log('baseInfo------', baseInfo);
  960. // 兼容旧数据
  961. if (baseInfo.inventoryDimension == 0) {
  962. if (dataList?.length) {
  963. if (dataList[0].packageNo) {
  964. this.dimension = '2';
  965. }else{
  966. this.dimension = '2';
  967. }
  968. }
  969. } else {
  970. this.dimension = baseInfo.inventoryDimension + '';
  971. }
  972. if (this.allocateId == 1) {
  973. // 库内调拨
  974. await this.outWarehouseChange(baseInfo.sourceWarehouseId); // 加载调出库区
  975. } else {
  976. // 库外调拨
  977. await this.outWarehouseChange(baseInfo.sourceWarehouseId); // 加载调出库区
  978. this.inWarehouseChange(baseInfo.targetWarehouseId); // 加载调入库区
  979. }
  980. // 处理右边显示数据
  981. this.selectionIds = dataList.map((item) => item.outInDetailRecordId);
  982. console.log('this.selectionIds------', this.selectionIds);
  983. console.log('this.productList------', this.productList);
  984. // this.selection = this.productList.filter((item) => {
  985. // return this.selectionIds.includes(item.id);
  986. // });
  987. this.selection = dataList;
  988. // this.selection.forEach((item) => {
  989. // this.$refs.table.toggleRowSelection(item);
  990. // });
  991. this.$refs.table.setSelectedRowKeys(this.selectionIds);
  992. console.log('this.selection------', this.selection);
  993. this.tableData = this.selection.map((item, index) => {
  994. // let filterObj = dataList.filter(
  995. // (ite) => ite.outInDetailRecordId == item.id
  996. // )[0];
  997. // console.log('filterObj---', filterObj);
  998. return {
  999. ...item,
  1000. // quantity: filterObj.measureQuantity,
  1001. // warehouseId: filterObj.warehouseId,
  1002. // warehouseName: filterObj.warehouseName,
  1003. // areaId: filterObj.areaId,
  1004. // areaName: filterObj.areaName,
  1005. // goodsAllocationId: filterObj.goodsAllocationId,
  1006. // goodsAllocationName: filterObj.goodsAllocationName,
  1007. // goodsShelfId: filterObj.goodsShelfId,
  1008. // goodsShelfName: filterObj.goodsShelfName,
  1009. // targetAreaId: filterObj.targetAreaId,
  1010. // targetAreaName: filterObj.targetAreaName,
  1011. // targetGoodsAllocationId: filterObj.targetGoodsAllocationId,
  1012. // targetGoodsAllocationName: filterObj.targetGoodsAllocationName,
  1013. // targetGoodsShelfId: filterObj.targetGoodsShelfId,
  1014. // targetGoodsShelfName: filterObj.targetGoodsShelfName,
  1015. // targetWarehouseId: filterObj.targetWarehouseId,
  1016. // targetWarehouseName: filterObj.targetWarehouseName,
  1017. outWarehouseArea:
  1018. item.warehouseName +
  1019. (item.areaName ? '-' + item.areaName : '') +
  1020. (item.goodsShelfName ? '-' + item.goodsShelfName : '') +
  1021. (item.goodsAllocationName
  1022. ? '-' + item.goodsAllocationName
  1023. : ''),
  1024. inWarehouseArea:
  1025. item.targetWarehouseName +
  1026. (item.targetAreaName ? '-' + item.targetAreaName : '') +
  1027. (item.targetGoodsShelfName
  1028. ? '-' + item.targetGoodsShelfName
  1029. : '') +
  1030. (item.targetGoodsAllocationName
  1031. ? '-' + item.targetGoodsAllocationName
  1032. : '')
  1033. };
  1034. });
  1035. console.log('this.tableData--------!!!!!', this.tableData);
  1036. console.log(dataList);
  1037. console.log(baseInfo);
  1038. },
  1039. factoryChange() {
  1040. // this.params.inWarehouseName = this.params.outWarehouseName;
  1041. this.params.targetFactoriesId = this.factoryId;
  1042. console.log('this.params------', this.params);
  1043. this.reset();
  1044. this.getTreeData();
  1045. },
  1046. targetFactoryChange() {
  1047. // this.reset();
  1048. // this.getTreeData();
  1049. },
  1050. search() {
  1051. return new Promise((resolve, reject) => {
  1052. // 重置错误标志
  1053. this.searchState.hasError = false;
  1054. if(!this.params.targetFactoriesId){
  1055. this.searchState.hasError = true;
  1056. const errorMsg = '调入工厂不能为空';
  1057. this.$message.error(errorMsg);
  1058. return reject(new Error(errorMsg));
  1059. }
  1060. if(!this.params.inWarehouseId){
  1061. this.searchState.hasError = true;
  1062. const errorMsg = '调入仓库不能为空';
  1063. this.$message.error(errorMsg);
  1064. return reject(new Error(errorMsg));
  1065. }
  1066. // 检查是否存在quantity小于等于0或无效的项
  1067. if(this.tableData.some((item) => !item.quantity || item.quantity <= 0)) {
  1068. this.searchState.hasError = true;
  1069. const errorMsg = '调拨数量不能为0';
  1070. this.$message.error(errorMsg);
  1071. return reject(new Error(errorMsg));
  1072. }
  1073. if (this.allocateId == 1) {
  1074. // 库内调拨
  1075. if (this.params.inFreightId && this.params.outFreightId) {
  1076. if (this.params.inFreightId === this.params.outFreightId) {
  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 if (!this.params.inFreightId && !this.params.outFreightId) {
  1084. if (this.params.inShelvesId && this.params.outShelvesId) {
  1085. if (this.params.inShelvesId === this.params.outShelvesId) {
  1086. this.productList = [];
  1087. this.searchState.hasError = true;
  1088. const errorMsg = '调入货架不能与调出货架相同';
  1089. this.$message.error(errorMsg);
  1090. return reject(new Error(errorMsg));
  1091. }
  1092. } else if (!this.params.inShelvesId && !this.params.outShelvesId) {
  1093. if (this.params.inCargoAreaId && this.params.outCargoAreaId) {
  1094. if (this.params.inCargoAreaId === this.params.outCargoAreaId) {
  1095. this.productList = [];
  1096. this.searchState.hasError = true;
  1097. const errorMsg = '调入库区不能与调出库区相同';
  1098. this.$message.error(errorMsg);
  1099. return reject(new Error(errorMsg));
  1100. }
  1101. } else if (
  1102. !this.params.inCargoAreaId &&
  1103. !this.params.outCargoAreaId
  1104. ) {
  1105. this.productList = [];
  1106. this.searchState.hasError = true;
  1107. const errorMsg = '调入库区与调出库区不能为空';
  1108. this.$message.error(errorMsg);
  1109. return reject(new Error(errorMsg));
  1110. } else {
  1111. this.productList = [];
  1112. this.searchState.hasError = true;
  1113. const errorMsg = '调入库区与调出库区必须同时填写';
  1114. this.$message.error(errorMsg);
  1115. return reject(new Error(errorMsg));
  1116. }
  1117. } else {
  1118. this.productList = [];
  1119. this.searchState.hasError = true;
  1120. const errorMsg = '调入货架与调出货架必须同时填写';
  1121. this.$message.error(errorMsg);
  1122. return reject(new Error(errorMsg));
  1123. }
  1124. } else {
  1125. this.productList = [];
  1126. this.searchState.hasError = true;
  1127. const errorMsg = '调入货位与调出货位必须同时填写';
  1128. this.$message.error(errorMsg);
  1129. return reject(new Error(errorMsg));
  1130. }
  1131. // 验证通过,获取产品列表
  1132. this.getProductList();
  1133. resolve();
  1134. } else {
  1135. // 库外调拨
  1136. resolve();
  1137. // if (!this.params.inFreightId && !this.params.outFreightId) {
  1138. // if (!this.params.inShelvesId && !this.params.outShelvesId) {
  1139. // if (!this.params.inCargoAreaId && !this.params.outCargoAreaId) {
  1140. // this.productList = [];
  1141. // this.searchState.hasError = true;
  1142. // const errorMsg = '调入库区与调出库区不能为空';
  1143. // this.$message.error(errorMsg);
  1144. // return reject(new Error(errorMsg));
  1145. // } else if (
  1146. // this.params.inCargoAreaId &&
  1147. // this.params.outCargoAreaId
  1148. // ) {
  1149. // this.getProductList();
  1150. // this.reload();
  1151. // resolve();
  1152. // } else {
  1153. // this.productList = [];
  1154. // this.searchState.hasError = true;
  1155. // const errorMsg = '调入库区与调出库区必须同时填写';
  1156. // this.$message.error(errorMsg);
  1157. // return reject(new Error(errorMsg));
  1158. // }
  1159. // } else if (this.params.inShelvesId && this.params.outShelvesId) {
  1160. // this.getProductList();
  1161. // this.reload();
  1162. // resolve();
  1163. // } else {
  1164. // this.productList = [];
  1165. // this.searchState.hasError = true;
  1166. // const errorMsg = '调入货架与调出货架必须同时填写';
  1167. // this.$message.error(errorMsg);
  1168. // return reject(new Error(errorMsg));
  1169. // }
  1170. // } else if (this.params.inFreightId && this.params.outFreightId) {
  1171. // this.getProductList();
  1172. // this.reload();
  1173. // resolve();
  1174. // } else {
  1175. // this.productList = [];
  1176. // this.searchState.hasError = true;
  1177. // const errorMsg = '调入货位与调出货位必须同时填写';
  1178. // this.$message.error(errorMsg);
  1179. // return reject(new Error(errorMsg));
  1180. // }
  1181. }
  1182. });
  1183. },
  1184. reset() {
  1185. this.params = {
  1186. ...this.params,
  1187. outWarehouseId: '', // 调出仓库
  1188. outWarehouseName: '',
  1189. outCargoAreaId: '', // 调出库区
  1190. outCargoAreaName: '',
  1191. outShelvesId: '', // 调出货架
  1192. outShelvesName: '',
  1193. outFreightId: '', // 调出货位
  1194. outFreightName: '',
  1195. inWarehouseId: '', // 调入仓库
  1196. inWarehouseName: '',
  1197. inCargoAreaId: '', // 调入库区
  1198. inCargoAreaName: '',
  1199. inShelvesId: '', // 调入货架
  1200. inShelvesName: '',
  1201. inFreightId: '', // 调入货位
  1202. inFreightName: ''
  1203. };
  1204. this.total = 0;
  1205. this.productList = [];
  1206. this.selection = [];
  1207. this.selectionIds = [];
  1208. this.outCargoAreaList = []; // 调出库区列表
  1209. this.inCargoAreaList = []; // 调入库区列表
  1210. this.outShelvesList = []; // 调出货架列表
  1211. this.inShelvesList = []; // 调入货架列表
  1212. this.outFreightList = []; // 调出货位列表
  1213. this.inFreightList = []; // 调入货位列表
  1214. },
  1215. queryReset() {
  1216. this.query = {};
  1217. this.page = 1;
  1218. this.getProductList();
  1219. this.reload();
  1220. },
  1221. querySearch() {
  1222. this.page = 1;
  1223. this.getProductList();
  1224. this.reload();
  1225. },
  1226. //获取工厂列表
  1227. async getFactoryList() {
  1228. const res = await warehouseDefinition.getFactoryarea({
  1229. pageNum: 1,
  1230. size: 9999,
  1231. type: 1
  1232. });
  1233. this.factoryList = res.list;
  1234. },
  1235. async outWarehouseChange(val) {
  1236. console.log('val------', val);
  1237. this.outCargoAreaList = this.outTreeList.filter(
  1238. (item) => item.id == val
  1239. )[0]?.children;
  1240. this.params.outWarehouseName = this.outTreeList.filter(
  1241. (item) => item.id == val
  1242. )[0]?.name;
  1243. this.productList = [];
  1244. this.tableData = [];
  1245. this.selection = [];
  1246. this.selectionIds = [];
  1247. this.params.outCargoAreaId = ''; // 调出库区
  1248. this.params.outCargoAreaName = '';
  1249. this.params.outShelvesId = ''; // 调出货架
  1250. this.params.outShelvesName = '';
  1251. this.params.outFreightId = ''; // 调出货位
  1252. this.params.outFreightName = '';
  1253. this.outShelvesList = []; // 调出货架列表
  1254. this.outFreightList = []; // 调出货位列表
  1255. if (this.allocateId == 2) {
  1256. // 过滤调入库区
  1257. this.inTreeList = this.inTreeList.map((item) => {
  1258. if (item.id === val) {
  1259. return {
  1260. ...item,
  1261. hiden: true
  1262. };
  1263. } else {
  1264. return {
  1265. ...item,
  1266. hiden: false
  1267. };
  1268. }
  1269. });
  1270. } else {
  1271. console.log(11111)
  1272. this.inCargoAreaList = this.outCargoAreaList;
  1273. this.params.inWarehouseName = this.params.outWarehouseName;
  1274. this.params.inWarehouseId = this.params.outWarehouseId;
  1275. this.params.inCargoAreaId = ''; // 调出库区
  1276. this.params.inCargoAreaName = '';
  1277. this.params.inShelvesId = ''; // 调出货架
  1278. this.params.inShelvesName = '';
  1279. this.params.inFreightId = ''; // 调出货位
  1280. this.params.inFreightName = '';
  1281. this.inShelvesList = []; // 调入货架列表
  1282. this.inFreightList = []; // 调入货位列表
  1283. }
  1284. console.log('this.params------~~~', this.params);
  1285. await this.getProductList();
  1286. await this.reload();
  1287. },
  1288. outCargoAreaChange(val) {
  1289. this.outShelvesList = this.outCargoAreaList.filter(
  1290. (item) => item.id == val
  1291. )[0].children;
  1292. this.params.outCargoAreaName = this.outCargoAreaList.filter(
  1293. (item) => item.id == val
  1294. )[0].name;
  1295. this.productList = [];
  1296. this.params.outShelvesId = ''; // 调出货架
  1297. this.params.outShelvesName = '';
  1298. this.params.outFreightId = ''; // 调出货位
  1299. this.params.outFreightName = '';
  1300. this.outFreightList = []; // 调出货位列表
  1301. this.getProductList();
  1302. this.reload();
  1303. },
  1304. outShelvesChange(val) {
  1305. this.outFreightList = this.outShelvesList.filter(
  1306. (item) => item.id == val
  1307. )[0].children;
  1308. this.params.outShelvesName = this.outShelvesList.filter(
  1309. (item) => item.id == val
  1310. )[0].name;
  1311. this.productList = [];
  1312. this.params.outFreightId = ''; // 调出货位
  1313. this.params.outFreightName = '';
  1314. this.getProductList();
  1315. this.reload();
  1316. },
  1317. outFreightIdChange(val) {
  1318. this.params.outFreightName = this.outFreightList.filter(
  1319. (item) => item.id == val
  1320. )[0].name;
  1321. this.getProductList();
  1322. this.reload();
  1323. },
  1324. inWarehouseChange(val) {
  1325. this.inCargoAreaList = this.inTreeList.filter(
  1326. (item) => item.id == val
  1327. )[0]?.children;
  1328. this.params.inWarehouseName = this.inTreeList.filter(
  1329. (item) => item.id == val
  1330. )[0]?.name;
  1331. // this.productList = [];
  1332. // this.tableData = [];
  1333. // this.selection = [];
  1334. // this.selectionIds = [];
  1335. this.params.inCargoAreaId = ''; // 调出库区
  1336. this.params.inCargoAreaName = '';
  1337. this.params.inShelvesId = ''; // 调出货架
  1338. this.params.inShelvesName = '';
  1339. this.params.inFreightId = ''; // 调出货位
  1340. this.params.inFreightName = '';
  1341. this.inShelvesList = []; // 调入货架列表
  1342. this.inFreightList = []; // 调入货位列表
  1343. if (this.allocateId == 2) {
  1344. // 过滤调出库区(库外调拨)
  1345. this.outTreeList = this.outTreeList.map((item) => {
  1346. if (item.id === val) {
  1347. return {
  1348. ...item,
  1349. hiden: true
  1350. };
  1351. } else {
  1352. return {
  1353. ...item,
  1354. hiden: false
  1355. };
  1356. }
  1357. });
  1358. console.log(this.outTreeList);
  1359. }
  1360. },
  1361. inCargoAreaChange(val) {
  1362. this.inShelvesList = this.inCargoAreaList.filter(
  1363. (item) => item.id == val
  1364. )[0].children;
  1365. this.params.inCargoAreaName = this.inCargoAreaList.filter(
  1366. (item) => item.id == val
  1367. )[0].name;
  1368. // this.productList = [];
  1369. this.params.inShelvesId = ''; // 调出货架
  1370. this.params.inShelvesName = '';
  1371. this.params.inFreightId = ''; // 调出货位
  1372. this.params.inFreightName = '';
  1373. this.inFreightList = []; // 调入货位列表
  1374. },
  1375. inShelvesChange(val) {
  1376. this.inFreightList = this.inShelvesList.filter(
  1377. (item) => item.id == val
  1378. )[0].children;
  1379. this.params.inShelvesName = this.inShelvesList.filter(
  1380. (item) => item.id == val
  1381. )[0].name;
  1382. // this.productList = [];
  1383. this.params.inFreightId = ''; // 调出货位
  1384. this.params.inFreightName = '';
  1385. },
  1386. inFreightIdChange(val) {
  1387. this.params.inFreightName = this.inFreightList.filter(
  1388. (item) => item.id == val
  1389. )[0].name;
  1390. },
  1391. // 调出区域改变
  1392. outChange(val) {
  1393. console.log(this.$refs.outTree.getNodeByValue(val));
  1394. let obj = this.$refs.outTree.getNodeByValue(val);
  1395. this.currentObj = obj;
  1396. this.getProductList();
  1397. this.reload();
  1398. },
  1399. // 调入区域改变
  1400. inChange(val) {
  1401. let obj = this.$refs.outTree.getNodeByValue(val);
  1402. },
  1403. handledime() {
  1404. this.getProductList();
  1405. this.reload();
  1406. this.selection=[]
  1407. this.selectionIds = []
  1408. this.$refs.table.clearSelection()
  1409. this.tableData=[]
  1410. },
  1411. async getProductList() {
  1412. let params = {
  1413. ...this.query,
  1414. warehouseId: this.params.outWarehouseId,
  1415. warehouseAreaId: this.params.outCargoAreaId,
  1416. warehouseAreaGoodsId: this.params.outShelvesId,
  1417. warehouseAreaGoodsShelvesId: this.params.outFreightId
  1418. };
  1419. const data = await storageApi[
  1420. this.dimension == 1 ? 'getProductList' : this.dimension == 2 ? 'getBatchList' : 'getPackingList'
  1421. ]({
  1422. ...params,
  1423. pageNum: this.page,
  1424. size: this.size
  1425. });
  1426. this.total = data.count;
  1427. this.productList = data.list;
  1428. },
  1429. async getTreeData() {
  1430. try {
  1431. this.treeLoading = true;
  1432. let res = await storageApi.getWarehouseTrees({
  1433. factoriesId: this.factoryId
  1434. });
  1435. this.treeLoading = false;
  1436. if (res?.code === '0') {
  1437. this.outTreeList = res.data;
  1438. this.inTreeList = res.data;
  1439. }
  1440. } catch (error) {
  1441. console.log(error);
  1442. }
  1443. this.treeLoading = false;
  1444. },
  1445. deleted(row, index) {
  1446. console.log('deleted~~~', row.id, index);
  1447. this.tableData.splice(index, 1);
  1448. this.selectionIds = this.selectionIds.filter((item) => item != row.outInDetailRecordId);
  1449. this.selection = this.selection.filter((item) => item.id != row.id);
  1450. this.$refs.table.setSelectedRowKeys(this.selectionIds);
  1451. this.$forceUpdate()
  1452. },
  1453. config() {
  1454. if (this.allocateId == 1) {
  1455. // 库内
  1456. this.submit(2);
  1457. } else {
  1458. // 库外
  1459. this.submit(1);
  1460. }
  1461. },
  1462. submit(status) {
  1463. if (!this.params.name) {
  1464. return this.$message.error('名称不能为空!');
  1465. }
  1466. // 提交前通过search方法校验数据
  1467. this.search().then(() => {
  1468. // 验证通过后检查表格数据
  1469. if (this.tableData.length > 0) {
  1470. let params = {
  1471. categoryCode: this.tableData
  1472. .map((item) => item.categoryCode)
  1473. .join(','),
  1474. categoryName: this.tableData
  1475. .map((item) => item.categoryName)
  1476. .join(','),
  1477. allotApplyAddPOBuilders: this.tableData.map((item) => {
  1478. return {
  1479. colorKey: item.colorKey,
  1480. quantity: item.quantity,
  1481. categoryId: item.categoryId,
  1482. warehouseId: item.warehouseId,
  1483. warehouseName: item.warehouseName,
  1484. areaId: item.areaId,
  1485. areaName: item.areaName,
  1486. goodsAllocationId: item.goodsAllocationId,
  1487. goodsAllocationName: item.goodsAllocationName,
  1488. goodsShelfId: item.goodsShelfId,
  1489. goodsShelfName: item.goodsShelfName,
  1490. outInDetailRecordId: item.outInDetailRecordId,
  1491. targetAreaId: item.targetAreaId,
  1492. targetAreaName: item.targetAreaName,
  1493. targetGoodsAllocationId: item.targetGoodsAllocationId,
  1494. targetGoodsAllocationName: item.targetGoodsAllocationName,
  1495. targetGoodsShelfId: item.targetGoodsShelfId,
  1496. targetGoodsShelfName: item.targetGoodsShelfName,
  1497. targetWarehouseId: item.targetWarehouseId || this.params.inWarehouseId,
  1498. targetWarehouseName: item.targetWarehouseName || this.params.inWarehouseName,
  1499. targetFactoriesId: this.params.targetFactoriesId,
  1500. saleOrderNos: item.saleOrderNos || '',
  1501. customerNames: item.customerNames || '',
  1502. };
  1503. }),
  1504. allotCode: this.params.code,
  1505. name: this.params.name,
  1506. id: this.transferOrderId,
  1507. sourceWarehouse: this.params.outWarehouseName,
  1508. sourceWarehouseId: this.params.outWarehouseId,
  1509. targetWarehouse: this.params.inWarehouseName,
  1510. targetWarehouseId: this.params.inWarehouseId,
  1511. status: status,
  1512. type: this.allocateId,
  1513. inventoryDimension: this.dimension,
  1514. targetFactoriesId: this.params.targetFactoriesId,
  1515. };
  1516. console.log('params------------', params);
  1517. console.log('params.allotApplyAddPOBuilders------------', params);
  1518. const customerNames = params.allotApplyAddPOBuilders.map((item) => item.customerNames);
  1519. const saleOrderNos = params.allotApplyAddPOBuilders.map((item) => item.saleOrderNos);
  1520. if (new Set(customerNames).size !== 1, new Set(saleOrderNos).size !== 1) {
  1521. return this.$message.error('不同客户,不同销售订单的产品不允许调拨');
  1522. }
  1523. storageApi.allotApplySave(params).then(() => {
  1524. this.$message.success('保存成功');
  1525. this.$router.go(-1);
  1526. });
  1527. } else {
  1528. this.$message.error('请调入相关数据');
  1529. }
  1530. }).catch((error) => {
  1531. // 验证失败,不提交数据
  1532. console.error('数据验证失败:', error);
  1533. });
  1534. },
  1535. checkSelectable(row) {
  1536. return !this.selectionIds.includes(row.id);
  1537. },
  1538. allocateChange(val) {
  1539. this.allocateId = val;
  1540. this.params = {
  1541. ...this.params,
  1542. outWarehouseId: '', // 调出仓库
  1543. outWarehouseName: '',
  1544. outCargoAreaId: '', // 调出库区
  1545. outCargoAreaName: '',
  1546. outShelvesId: '', // 调出货架
  1547. outShelvesName: '',
  1548. outFreightId: '', // 调出货位
  1549. outFreightName: '',
  1550. inWarehouseId: '', // 调入仓库
  1551. inWarehouseName: '',
  1552. inCargoAreaId: '', // 调入库区
  1553. inCargoAreaName: '',
  1554. inShelvesId: '', // 调入货架
  1555. inShelvesName: '',
  1556. inFreightId: '', // 调入货位
  1557. inFreightName: ''
  1558. };
  1559. this.total = 0;
  1560. this.productList = [];
  1561. this.outShelvesList = [];
  1562. this.outCargoAreaList = [];
  1563. this.outFreightList = [];
  1564. this.inShelvesList = [];
  1565. this.inCargoAreaList = [];
  1566. this.inFreightList = [];
  1567. this.selectionIds = [];
  1568. this.selection = [];
  1569. this.tableData = [];
  1570. this.$refs.table.clearSelection();
  1571. this.getTreeData();
  1572. // this.params = {
  1573. // outWarehouseId: '',
  1574. // outWarehouseName: '',
  1575. // inWarehouseId: '',
  1576. // inWarehouseName: ''
  1577. // };
  1578. // this.currentPullAreaId = '';
  1579. // this.currentPullAreaName = '';
  1580. // this.currentTuneAreaId = '';
  1581. // this.currentTuneAreaName = '';
  1582. // this.pullLibrary = [];
  1583. // this.tuneLibrary = [];
  1584. // this.productList = [];
  1585. // this.tableData = [];
  1586. // this.productList = [];
  1587. // this.getWarehouseOptions();
  1588. },
  1589. pullClick(id, name) {
  1590. if (this.currentPullAreaId == id) {
  1591. return false;
  1592. } else {
  1593. console.log('-------------');
  1594. this.currentPullAreaId = id;
  1595. this.currentPullAreaName = name;
  1596. this.currentTuneAreaId = '';
  1597. this.currentTuneAreaName = '';
  1598. }
  1599. storageApi
  1600. .getPackingList({
  1601. warehouseAreaId: id,
  1602. pageNum: 1,
  1603. size: 9999
  1604. })
  1605. .then(({ list }) => {
  1606. this.productList = list;
  1607. });
  1608. },
  1609. tuneClick(id, name, boolen) {
  1610. if (!this.currentPullAreaId) {
  1611. return this.$message.error('请先选择调出库');
  1612. }
  1613. if (boolen) {
  1614. return false;
  1615. }
  1616. this.currentTuneAreaId = id;
  1617. this.currentTuneAreaName = name;
  1618. },
  1619. selecctedRow(val) {
  1620. this.selection = val;
  1621. },
  1622. async getWarehouseOptions() {
  1623. const { data } = await storageApi.getWarehouseTrees();
  1624. this.outWarehouseList = data;
  1625. this.inWarehouseList = data;
  1626. },
  1627. async merge() {
  1628. if (!this.params.outWarehouseId) {
  1629. return this.$message.error('请先选择调出仓库');
  1630. }
  1631. if (!this.params.inWarehouseId) {
  1632. return this.$message.error('请先选择调入仓库');
  1633. }
  1634. if (this.selection.length > 0) {
  1635. console.log(this.selection);
  1636. console.log(this.selectionIds);
  1637. let boolen = this.selection.every((item) =>
  1638. this.selectionIds.includes(item.id)
  1639. );
  1640. console.log('boolen~~~~', boolen);
  1641. if (this.selection.length > 0 && !boolen) {
  1642. this.selection = this.selection.filter(
  1643. (item) => !this.selectionIds.includes(item.id)
  1644. );
  1645. // // 判断货位
  1646. // if (this.params.inFreightId) {
  1647. // let isBoolen = this.selection.some(
  1648. // (item) => item.goodsAllocationId == this.params.inFreightId
  1649. // );
  1650. // if (isBoolen) {
  1651. // return this.$message.error('所选物品货位与调入货位重复!');
  1652. // }
  1653. // }
  1654. // // 判断货架
  1655. // if (!this.params.inFreightId && this.params.inShelvesId) {
  1656. // let isBoolen = this.selection.some(
  1657. // (item) => item.goodsShelfId == this.params.inShelvesId
  1658. // );
  1659. // if (isBoolen) {
  1660. // return this.$message.error('所选物品货架与调入货架重复!');
  1661. // }
  1662. // }
  1663. // // 判断库区
  1664. // if (!this.params.inCargoAreaId) {
  1665. // return this.$message.error('调入库区不能为空');
  1666. // } else if (
  1667. // !this.params.inFreightId &&
  1668. // !this.params.inShelvesId &&
  1669. // this.params.inCargoAreaId
  1670. // ) {
  1671. // let isBoolen = this.selection.some(
  1672. // (item) => item.areaId == this.params.inCargoAreaId
  1673. // );
  1674. // if (isBoolen) {
  1675. // return this.$message.error('所选物品库区与调入库区重复');
  1676. // }
  1677. // }
  1678. if (!this.params.inFreightId && !this.params.inShelvesId) {
  1679. // 只有调入库区
  1680. for (let i = 0; i < this.selection.length; i++) {
  1681. console.log(this.selection[i].areaId);
  1682. console.log(this.params.inCargoAreaId);
  1683. if (this.selection[i].areaId == this.params.inCargoAreaId) {
  1684. return this.$message.error('所选物品库区与调入库区重复');
  1685. }
  1686. }
  1687. } else if (this.params.inShelvesId && !this.params.inFreightId) {
  1688. // 只有调入库区/货架
  1689. for (let i = 0; i < this.selection.length; i++) {
  1690. if (this.selection[i].areaId == this.params.inCargoAreaId) {
  1691. // 库区相同
  1692. if (
  1693. this.selection[i].goodsShelfId == this.params.inShelvesId
  1694. ) {
  1695. // 货架相同
  1696. return this.$message.error(
  1697. '所选物品库区/货架与调入库区/货架重复'
  1698. );
  1699. } else {
  1700. // 货架不同直接录入
  1701. }
  1702. } else {
  1703. // 库区不同直接录入
  1704. }
  1705. }
  1706. } else if (this.params.inShelvesId && this.params.inFreightId) {
  1707. // 只有调入库区/货架/货位
  1708. for (let i = 0; i < this.selection.length; i++) {
  1709. if (this.selection[i].areaId == this.params.inCargoAreaId) {
  1710. // 库区相同
  1711. if (
  1712. this.selection[i].goodsShelfId == this.params.inShelvesId
  1713. ) {
  1714. // 货架相同
  1715. if (
  1716. this.selection[i].goodsAllocationId ==
  1717. this.params.inFreightId
  1718. ) {
  1719. // 货位相同
  1720. return this.$message.error(
  1721. '所选物品库区/货架/货位与调入库区/货架/货位重复'
  1722. );
  1723. } else {
  1724. // 货位不同直接录入
  1725. }
  1726. } else {
  1727. // 货架不同直接录入
  1728. }
  1729. } else {
  1730. // 库区不同直接录入
  1731. }
  1732. }
  1733. } else {
  1734. return this.$message.error('调入库区不能为空');
  1735. }
  1736. this.selectionIds = this.selectionIds.concat(
  1737. this.selection.map((item) => item.id)
  1738. );
  1739. console.log('this.selection---------', this.selection);
  1740. console.log('this.selectionIds---', this.selectionIds);
  1741. this.tableData = this.tableData.concat(
  1742. this.selection.map((item) => {
  1743. console.log('this.params---------', this.params);
  1744. return {
  1745. ...item,
  1746. saleOrderNos: item.saleOrderInfo?.saleOrderNos || '',
  1747. customerNames: item.saleOrderInfo?.customerNames || '',
  1748. outInDetailRecordId: item.id,
  1749. quantity: item.quantity || item.measureQuantity,
  1750. categoryId: item.categoryId,
  1751. warehouseId: this.params.outWarehouseId,
  1752. warehouseName: this.params.outWarehouseName,
  1753. areaId: this.params.outCargoAreaId,
  1754. areaName: this.params.outCargoAreaName,
  1755. goodsAllocationId: this.params.outFreightId,
  1756. goodsAllocationName: this.params.outFreightName,
  1757. goodsShelfId: this.params.outShelvesId,
  1758. goodsShelfName: this.params.outShelvesName,
  1759. targetAreaId: this.params.inCargoAreaId,
  1760. targetAreaName: this.params.inCargoAreaName,
  1761. targetGoodsAllocationId: this.params.inFreightId,
  1762. targetGoodsAllocationName: this.params.inFreightName,
  1763. targetGoodsShelfId: this.params.inShelvesId,
  1764. targetGoodsShelfName: this.params.inShelvesName,
  1765. targetWarehouseId: this.params.inWarehouseId,
  1766. targetWarehouseName: this.params.inWarehouseName,
  1767. targetFactoriesId: this.params.targetFactoriesId,
  1768. outWarehouseArea:
  1769. this.params.outWarehouseName +
  1770. (this.params.outCargoAreaName
  1771. ? '-' + this.params.outCargoAreaName
  1772. : '') +
  1773. (this.params.outShelvesName
  1774. ? '-' + this.params.outShelvesName
  1775. : '') +
  1776. (this.params.outFreightName
  1777. ? '-' + this.params.outFreightName
  1778. : ''),
  1779. inWarehouseArea:
  1780. this.params.inWarehouseName +
  1781. (this.params.inCargoAreaName
  1782. ? '-' + this.params.inCargoAreaName
  1783. : '') +
  1784. (this.params.inShelvesName
  1785. ? '-' + this.params.inShelvesName
  1786. : '') +
  1787. (this.params.inFreightName
  1788. ? '-' + this.params.inFreightName
  1789. : '')
  1790. };
  1791. })
  1792. );
  1793. console.log('this.tableData---------', this.tableData);
  1794. } else {
  1795. this.$message.error('请选择正确的行');
  1796. }
  1797. } else {
  1798. this.$message.error('请选择调出物品信息');
  1799. }
  1800. }
  1801. }
  1802. };
  1803. </script>
  1804. <style lang="scss" scoped>
  1805. #inventoryAllocate {
  1806. height: 100%;
  1807. .el-form-item {
  1808. margin-bottom: 5px !important;
  1809. }
  1810. .submit_item {
  1811. display: flex;
  1812. justify-content: flex-end;
  1813. align-items: center;
  1814. margin-top: 8px;
  1815. height: 40px;
  1816. }
  1817. :deep(.el-form-item__label) {
  1818. padding-right: 5px !important;
  1819. }
  1820. :deep(.el-card) {
  1821. height: 100%;
  1822. .el-card__body {
  1823. height: 100%;
  1824. box-sizing: border-box;
  1825. overflow: hidden;
  1826. display: flex;
  1827. flex-direction: column;
  1828. }
  1829. }
  1830. .col_height {
  1831. height: 45px !important;
  1832. }
  1833. .productBox {
  1834. display: flex;
  1835. flex: 1;
  1836. > div {
  1837. flex: 1;
  1838. overflow: hidden;
  1839. }
  1840. }
  1841. .selectBox {
  1842. padding: 20px;
  1843. }
  1844. .box-card {
  1845. margin: 20px;
  1846. }
  1847. .productsList {
  1848. margin-right: 10px;
  1849. display: flex;
  1850. flex-direction: column;
  1851. :deep(.el-table) {
  1852. flex: 1;
  1853. display: flex;
  1854. flex-direction: column;
  1855. .el-table__body-wrapper {
  1856. flex: 1;
  1857. }
  1858. }
  1859. }
  1860. .allocateDetails {
  1861. display: flex;
  1862. flex-direction: column;
  1863. :deep(.el-table) {
  1864. flex: 1;
  1865. display: flex;
  1866. flex-direction: column;
  1867. .el-table__body-wrapper {
  1868. flex: 1;
  1869. }
  1870. }
  1871. }
  1872. }
  1873. </style>