add.vue 64 KB

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