add.vue 70 KB

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