WareHouseAllocationDailog.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. <template>
  2. <el-dialog
  3. :visible.sync="visible"
  4. title="选择货位"
  5. @before-close="cancel"
  6. width="874px"
  7. >
  8. <el-form :model="formData" label-width="100px">
  9. <el-row>
  10. <el-col :span="8">
  11. <el-form-item label="选择仓库">
  12. {{ formData.warehouse.name }}
  13. </el-form-item></el-col
  14. >
  15. <el-col :span="8">
  16. <el-form-item label="选择库区">
  17. <el-select filterable v-model="area">
  18. <el-option
  19. v-for="(item, index) in areaList"
  20. :key="index"
  21. :label="item.areaCode"
  22. :value="item.areaId"
  23. @click.native="() => (formData.area = item)"
  24. ></el-option>
  25. </el-select> </el-form-item
  26. ></el-col>
  27. <el-col :span="8">
  28. <el-form-item label="选择货架">
  29. <el-select filterable v-model="shelves">
  30. <el-option
  31. v-for="(item, index) in shelvesList"
  32. :key="index"
  33. :label="item.goodsshelvesCode"
  34. :value="item.goodsshelvesId"
  35. @click.native="() => (formData.shelves = item)"
  36. ></el-option>
  37. </el-select> </el-form-item
  38. ></el-col>
  39. </el-row>
  40. </el-form>
  41. <div class="status-legend">
  42. <div
  43. v-for="(item, index) in warehouseDefinition_locationStatus"
  44. :key="index"
  45. >
  46. <span :style="{ 'background-color': item.color }"></span
  47. >{{ item.label }}
  48. </div>
  49. </div>
  50. <div class="content-box">
  51. <div
  52. v-for="p in locationList"
  53. :key="p.id"
  54. class="box"
  55. @click="handleSelect(p)"
  56. :style="{
  57. 'background-color': getStatus(p.allocationStatus).color,
  58. cursor: [1, 2].includes(p.allocationStatus)
  59. ? 'pointer'
  60. : 'not-allowed'
  61. }"
  62. >
  63. {{ p.goodsAllocationCode }}
  64. </div>
  65. <div class="placeholder-box"></div>
  66. <div class="placeholder-box"></div>
  67. <div class="placeholder-box"></div>
  68. <div class="placeholder-box"></div>
  69. </div>
  70. <template slot="footer">
  71. <el-button @click="cancel">关闭</el-button>
  72. </template>
  73. <CargoSpaceInfoDialog
  74. ref="CargoSpaceInfoRef"
  75. :assetsList="assetsList"
  76. :prAssetsList="prAssetsList"
  77. @success="cargoSpaceInfoConfirm"
  78. />
  79. </el-dialog>
  80. </template>
  81. <script>
  82. // import { getWarehouseChildren } from '@/api/stockManagement/outgoingManagement'
  83. import { warehouseDefinition_locationStatus } from '@/utils/dict/warehouseDefinition';
  84. import CargoSpaceInfoDialog from './CargoSpaceInfoDialog.vue';
  85. import { useDict } from '@/utils/dict/index';
  86. import { deepClone } from '@/utils/index';
  87. export default {
  88. components: {
  89. CargoSpaceInfoDialog
  90. },
  91. props: {
  92. warehouseObj: {
  93. type: Object,
  94. default: () => ({})
  95. }
  96. },
  97. data() {
  98. return {
  99. warehouseDefinition_locationStatus,
  100. visible: false,
  101. value: '',
  102. row: {},
  103. formData: {
  104. warehouse: {
  105. id: '',
  106. name: ''
  107. },
  108. area: {
  109. areaId: '',
  110. areaName: ''
  111. },
  112. shelves: {
  113. goodsshelvesId: '',
  114. goodsshelvesCode: ''
  115. }
  116. },
  117. warehouse: '',
  118. area: '',
  119. shelves: '',
  120. warehouseList: [],
  121. inOrOut: '', //调入调出
  122. assetsList: [], //调出已选
  123. prAssetsList: [] //预调出已选
  124. };
  125. },
  126. computed: {
  127. areaList() {
  128. this.area = '';
  129. this.shelves = '';
  130. return (
  131. this.warehouseList.find((i) => i.id === this.formData.warehouse.id)
  132. ?.wareHouseArea || []
  133. );
  134. },
  135. shelvesList() {
  136. this.shelves = '';
  137. return (
  138. this.areaList.find((i) => i.areaId === this.area)
  139. ?.wareHouseGoodsshelves || []
  140. );
  141. },
  142. locationList() {
  143. return (
  144. this.shelvesList.find((i) => i.goodsshelvesId === this.shelves)
  145. ?.wareHouseGoodsAllocation || []
  146. );
  147. }
  148. },
  149. created() {
  150. this._getWarehouseChildren();
  151. },
  152. methods: {
  153. getStatus: useDict(warehouseDefinition_locationStatus),
  154. open(type, warehouse) {
  155. this.inOrOut = type;
  156. this.formData.warehouse = warehouse;
  157. this.visible = true;
  158. },
  159. // 选中货位
  160. handleSelect(p) {
  161. if (![1, 2].includes(p.allocationStatus)) {
  162. return;
  163. }
  164. const { warehouse, area, shelves } = this.formData;
  165. const data = {
  166. warehouseId: warehouse.id,
  167. warehouseName: warehouse.name,
  168. areaId: area.areaId,
  169. areaName: area.areaName,
  170. shelfId: shelves.goodsshelvesId,
  171. shelfCode: shelves.goodsshelvesCode,
  172. cargoSpaceId: p.goodsAllocationId,
  173. cargoSpaceCode: p.goodsAllocationCode
  174. };
  175. if (this.inOrOut === 'output') {
  176. this.$refs.CargoSpaceInfoRef.open(data);
  177. } else {
  178. this.$emit('inputSuccess', data);
  179. this.cancel();
  180. }
  181. },
  182. // 选中货位上资产
  183. cargoSpaceInfoConfirm(list) {
  184. this.$emit('outputSuccess', list);
  185. this.cancel();
  186. },
  187. async _getWarehouseChildren() {
  188. const res = await getWarehouseChildren();
  189. if (res?.success) {
  190. this.warehouseList = res.data;
  191. }
  192. },
  193. cancel() {
  194. this.row = {};
  195. this.area = '';
  196. this.shelves = '';
  197. this.visible = false;
  198. }
  199. }
  200. };
  201. </script>
  202. <style lang="scss" scoped>
  203. .status-legend {
  204. display: flex;
  205. align-items: center;
  206. justify-content: center;
  207. margin: 12px 0;
  208. div {
  209. margin: 0 12px;
  210. }
  211. span {
  212. display: inline-block;
  213. width: 13px;
  214. height: 13px;
  215. margin: 0 4px;
  216. }
  217. }
  218. .content-box {
  219. display: flex;
  220. justify-content: space-between;
  221. flex-wrap: wrap;
  222. max-height: 40vh;
  223. overflow: auto;
  224. .box {
  225. cursor: pointer;
  226. width: 134px;
  227. height: 64px;
  228. background-clip: content-box;
  229. margin-bottom: 4px;
  230. line-height: 64px;
  231. text-align: center;
  232. }
  233. .placeholder-box {
  234. width: 134px;
  235. }
  236. }
  237. </style>