AdjustPositions.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430
  1. <template>
  2. <Navbar :title="'货位调整'" :is-go-back="false" />
  3. <div>
  4. <a-form :colon="false">
  5. <a-row :gutter="[8, 0]" justify="space-start">
  6. <a-col>
  7. <a-form-item label="调整前货位" :label-col="{ style: 'width: 80px' }" class="horizontal-form-item">
  8. <a-select
  9. v-model:value="positionBeforeId" placeholder="请选择调整前货位" class="w-full"
  10. @change="handlePositionBeforeChange"
  11. >
  12. <a-select-option v-for="item in positionBefores" :key="item.positionId" :value="item.positionId">
  13. {{ item.positionNo }}
  14. </a-select-option>
  15. </a-select>
  16. </a-form-item>
  17. </a-col>
  18. <a-col>
  19. <a-form-item label="调整后货位" :label-col="{ style: 'width: 80px' }" class="horizontal-form-item">
  20. <a-select v-model:value="positionAfterId" placeholder="请选择调整后货位" class="w-full">
  21. <a-select-option v-for="item in positionAfters" :key="item.positionId" :value="item.positionId">
  22. {{ item.positionNo }}
  23. </a-select-option>
  24. </a-select>
  25. </a-form-item>
  26. </a-col>
  27. <a-col>
  28. <a-form-item label="搜索内容" :label-col="{ style: 'width: 80px' }" class="horizontal-form-item">
  29. <a-input
  30. v-model:value="queryMessage" placeholder="请输入工具的中文名称或SKU或序列号" class="w-full"
  31. @press-enter="handleSearch"
  32. />
  33. </a-form-item>
  34. </a-col>
  35. <a-col>
  36. <a-form-item label="工具类型" :label-col="{ style: 'width: 80px' }" class="horizontal-form-item">
  37. <a-select v-model:value="selectType" class="w-full" @change="changeSelectType">
  38. <a-select-option value="1">RFID管理</a-select-option>
  39. <a-select-option value="2">非RFID管理</a-select-option>
  40. </a-select>
  41. </a-form-item>
  42. </a-col>
  43. <a-col>
  44. <a-form-item>
  45. <a-space>
  46. <a-button type="primary" @click="handleSearch">查询</a-button>
  47. <a-button type="primary" @click="submitBefore">确认调整</a-button>
  48. </a-space>
  49. </a-form-item>
  50. </a-col>
  51. </a-row>
  52. </a-form>
  53. <a-table
  54. :columns="columns" :data-source="selectType === '2' ? currentStockDtos : inventoryInstanceDatas"
  55. :pagination="pagination" :loading="loading" row-key="id" @change="handleTableChange"
  56. >
  57. <template #bodyCell="{ column, record }">
  58. <template v-if="column.key === 'image'">
  59. <img
  60. :src="Common.getThumbnailImageSrc(className, record.imageName)" class="image"
  61. @click="$refs.imagePreview.preview(className, record.imageName)"
  62. />
  63. </template>
  64. <template v-if="column.key === 'adjustQuantity' && selectType === '2'">
  65. <a-input-number v-model="record.adjustQuantity" :min="0" @change="checkBoxChange(record)" />
  66. </template>
  67. </template>
  68. </a-table>
  69. <a-modal v-model:visible="modal" title="调整确认" :footer="null">
  70. <p>您确认要进行货位调整吗?</p>
  71. <div class="modal-footer">
  72. <a-button @click="closeModal">取消</a-button>
  73. <a-button type="primary" @click="handleSubmit">确认</a-button>
  74. </div>
  75. </a-modal>
  76. <Loading v-if="loading" />
  77. <ImagePreview ref="imagePreview" />
  78. </div>
  79. </template>
  80. <script>
  81. import Common from '../common/Common.js';
  82. import CurrentStockResource from '../api/wms/CurrentStockResource.js';
  83. import AdjustPositionResource from '../api/wms/AdjustPositionResource.js';
  84. import InventoryInstanceResource from '../api/common/InventoryInstanceResource.js';
  85. export default {
  86. data() {
  87. return {
  88. formLayout: {
  89. labelCol: { span: 8 },
  90. wrapperCol: { span: 16 },
  91. },
  92. checked: false,
  93. positionBefores: [],
  94. positionBeforeId: null,
  95. positionAfterId: null,
  96. positionAfters: [],
  97. queryMessage: '',
  98. currentStockDtos: [],
  99. inventoryInstanceDatas: [],
  100. pagination: {
  101. total: 0,
  102. pageSize: Common.pageSize,
  103. current: 1,
  104. },
  105. className: 'com.leanwo.prodog.model.common.Inventory',
  106. selectType: '1',
  107. loading: false,
  108. modal: false,
  109. columns: [
  110. {
  111. title: '序号',
  112. key: 'index',
  113. render: (text, record, index) => index + 1,
  114. },
  115. {
  116. title: '图片',
  117. key: 'image',
  118. },
  119. {
  120. title: '中文名称',
  121. dataIndex: 'inventoryName',
  122. key: 'inventoryName',
  123. },
  124. {
  125. title: 'SKU',
  126. dataIndex: 'inventoryCode',
  127. key: 'inventoryCode',
  128. },
  129. {
  130. title: '序列号',
  131. dataIndex: 'no',
  132. key: 'no',
  133. },
  134. {
  135. title: '库存数量',
  136. dataIndex: 'stockQuantity',
  137. key: 'stockQuantity',
  138. },
  139. {
  140. title: '调整数量',
  141. key: 'adjustQuantity',
  142. },
  143. ],
  144. };
  145. },
  146. mounted() {
  147. this.loadSelectPositionBefore();
  148. this.loadSelectPositionAfter();
  149. },
  150. methods: {
  151. handleTableChange(pagination) {
  152. this.pagination.current = pagination.current;
  153. this.pagination.pageSize = pagination.pageSize;
  154. this.handleSearch();
  155. },
  156. filterOption(input, option) {
  157. return option.children.toLowerCase().indexOf(input.toLowerCase()) >= 0;
  158. },
  159. handlePositionBeforeChange() {
  160. this.handleSearch();
  161. },
  162. handleSearch() {
  163. if (this.selectType === '1') {
  164. this.queryInventoryInstance();
  165. } else {
  166. this.queryInventory();
  167. }
  168. },
  169. changeSelectType() {
  170. this.handleSearch();
  171. },
  172. checkBoxChange(item) {
  173. if (!item.adjustQuantity || item.adjustQuantity === 0) {
  174. item.checked = false;
  175. } else {
  176. item.checked = true;
  177. }
  178. },
  179. closeModal() {
  180. this.modal = false;
  181. },
  182. submitBefore() {
  183. if (!this.positionBeforeId || !this.positionAfterId) {
  184. Notify.error('错误', '调整前货位与调整后货位不允许为空', false);
  185. return;
  186. }
  187. if (this.positionBeforeId === this.positionAfterId) {
  188. Notify.error('错误', '调整前货位与调整后货位不能相同', false);
  189. return;
  190. }
  191. const data =
  192. this.selectType === '2' ? this.currentStockDtos : this.inventoryInstanceDatas;
  193. let checkCount = 0;
  194. let falseData = true;
  195. data.forEach(item => {
  196. if (item.checked) {
  197. checkCount++;
  198. if (this.selectType === '2' && (!item.adjustQuantity || item.adjustQuantity <= 0)) {
  199. falseData = false;
  200. }
  201. }
  202. });
  203. if (!falseData) {
  204. Notify.error('错误', '调整数量必须大于0', false);
  205. return;
  206. }
  207. if (checkCount > 0) {
  208. this.modal = true;
  209. } else {
  210. Notify.error('错误', '请选择最少一条数据进行提交', false);
  211. }
  212. },
  213. handleSubmit() {
  214. this.modal = false;
  215. if (this.selectType === '2') {
  216. this.submit1();
  217. } else {
  218. this.submit2();
  219. }
  220. },
  221. submit1() {
  222. const currentStockDtoBs = this.currentStockDtos.filter(item => item.checked);
  223. this.loading = true;
  224. $.ajax({
  225. url: Common.getApiURL('AdjustPositionResource/saveAdjustPosition'),
  226. type: 'post',
  227. data: {
  228. currentStockDtoBs: JSON.stringify(currentStockDtoBs),
  229. positionBeforeId: this.positionBeforeId,
  230. positionAfterId: this.positionAfterId,
  231. },
  232. beforeSend: request => Common.addTokenToRequest(request),
  233. success: successData => {
  234. this.loading = false;
  235. if (successData.errorCode === 0) {
  236. if (successData.data) {
  237. Notify.success('成功', '操作成功', false);
  238. this.queryInventory();
  239. }
  240. }
  241. },
  242. error: errorData => {
  243. this.loading = false;
  244. Common.processException(errorData);
  245. },
  246. });
  247. },
  248. submit2() {
  249. const inventoryInstanceDtos = this.inventoryInstanceDatas.filter(item => item.checked);
  250. this.loading = true;
  251. $.ajax({
  252. url: Common.getApiURL('AdjustPositionResource/saveAdjustPosition2'),
  253. type: 'post',
  254. data: {
  255. inventoryInstanceDtos: JSON.stringify(inventoryInstanceDtos),
  256. positionBeforeId: this.positionBeforeId,
  257. positionAfterId: this.positionAfterId,
  258. },
  259. beforeSend: request => Common.addTokenToRequest(request),
  260. success: successData => {
  261. this.loading = false;
  262. if (successData.errorCode === 0) {
  263. if (successData.data) {
  264. Notify.success('成功', '操作成功', false);
  265. this.queryInventoryInstance();
  266. }
  267. }
  268. },
  269. error: errorData => {
  270. this.loading = false;
  271. Common.processException(errorData);
  272. },
  273. });
  274. },
  275. queryInventory() {
  276. this.loading = true;
  277. const queryMessage = $.trim(this.queryMessage);
  278. const start = (this.pagination.current - 1) * this.pagination.pageSize;
  279. const length = this.pagination.pageSize;
  280. $.ajax({
  281. url: Common.getApiURL('CurrentStockResource/queryCurrentStockByPosition'),
  282. type: 'get',
  283. data: {
  284. positionBeforeId: this.positionBeforeId,
  285. queryMessage,
  286. start,
  287. length,
  288. },
  289. beforeSend: request => Common.addTokenToRequest(request),
  290. success: successData => {
  291. this.loading = false;
  292. if (successData.errorCode === 0) {
  293. if (successData.datas) {
  294. this.currentStockDtos = successData.datas.map(item => ({
  295. ...item,
  296. checked: false,
  297. }));
  298. this.pagination.total = successData.total;
  299. }
  300. }
  301. },
  302. error: errorData => {
  303. this.loading = false;
  304. Common.processException(errorData);
  305. },
  306. });
  307. },
  308. queryInventoryInstance() {
  309. this.loading = true;
  310. const queryMessage = $.trim(this.queryMessage);
  311. const start = (this.pagination.current - 1) * this.pagination.pageSize;
  312. const length = this.pagination.pageSize;
  313. $.ajax({
  314. url: Common.getApiURL('InventoryInstanceResource/queryByPosition'),
  315. type: 'get',
  316. data: {
  317. positionBeforeId: this.positionBeforeId,
  318. queryMessage,
  319. start,
  320. length,
  321. },
  322. beforeSend: request => Common.addTokenToRequest(request),
  323. success: successData => {
  324. this.loading = false;
  325. if (successData.errorCode === 0) {
  326. if (successData.datas) {
  327. this.inventoryInstanceDatas = successData.datas.map(item => ({
  328. ...item,
  329. checked: false,
  330. }));
  331. this.pagination.total = successData.total;
  332. }
  333. }
  334. },
  335. error: errorData => {
  336. this.loading = false;
  337. Common.processException(errorData);
  338. },
  339. });
  340. },
  341. loadSelectPositionBefore() {
  342. this.loading = true;
  343. $.ajax({
  344. url: Common.getApiURL('positionResource/queryByCondition'),
  345. type: 'get',
  346. beforeSend: request => Common.addTokenToRequest(request),
  347. success: data => {
  348. this.loading = false;
  349. if (data.errorCode === 0) {
  350. this.positionBefores = data.datas.map(item => ({
  351. positionId: item.positionId,
  352. positionNo: item.positionNo,
  353. }));
  354. }
  355. },
  356. error: errorData => {
  357. this.loading = false;
  358. Common.processException(errorData);
  359. },
  360. });
  361. },
  362. loadSelectPositionAfter() {
  363. this.loading = true;
  364. $.ajax({
  365. url: Common.getApiURL('positionResource/queryByCondition'),
  366. type: 'get',
  367. beforeSend: request => Common.addTokenToRequest(request),
  368. success: data => {
  369. this.loading = false;
  370. if (data.errorCode === 0) {
  371. this.positionAfters = data.datas.map(item => ({
  372. positionId: item.positionId,
  373. positionNo: item.positionNo,
  374. }));
  375. }
  376. },
  377. error: errorData => {
  378. this.loading = false;
  379. Common.processException(errorData);
  380. },
  381. });
  382. },
  383. },
  384. };
  385. </script>
  386. <style scoped>
  387. .adjust-positions-container {
  388. padding: 24px;
  389. }
  390. .search-form {
  391. margin-bottom: 24px;
  392. }
  393. .image {
  394. width: 40px;
  395. height: 40px;
  396. }
  397. .modal-footer {
  398. display: flex;
  399. justify-content: flex-end;
  400. margin-top: 24px;
  401. }
  402. .horizontal-form-item {
  403. display: flex;
  404. align-items: center;
  405. gap: 8px;
  406. }
  407. .w-full {
  408. width: 160px;
  409. }
  410. :deep(.ant-form-item) {
  411. margin-bottom: 10px !important;
  412. }
  413. :deep(.ant-form-item-label > label) {
  414. font-size: 14px !important;
  415. font-weight: 600 !important;
  416. }
  417. </style>