changePosition.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. <template>
  2. <basic-modal
  3. v-bind="$attrs"
  4. @register="registerModal"
  5. destroyOnClose
  6. :title="modalTitle"
  7. :height="900"
  8. width="1400px"
  9. ok-text="保存"
  10. @ok="handleSubmit"
  11. :ok-button-props="{ disabled: !curLayerSelectedAddress }"
  12. @cancel="handleCancel"
  13. >
  14. <div class="stacking-modal">
  15. <a-spin :spinning="isSpinning">
  16. <div class="selected-divider">
  17. <a-segmented v-model:value="activeKey" :options="stackingList" />
  18. <a-row class="selected-divider-row" :gutter="[30, 20]">
  19. <a-col :span="8" v-for="item in getSelectedData" class="p-stack-col">
  20. <div class="weizhi">{{ item.address }}</div>
  21. <a-row
  22. justify="start"
  23. class="stacking-list-row"
  24. :class="{ 'selected-row': curLayerSelectedAddress === item.id }"
  25. @click="handleStackClick(item)"
  26. >
  27. <a-col class="stack-col" :class="{ 'hemp-texture': !!item.steelBillet[0] }" :span="6">{{ item.steelBillet[0] || '' }}</a-col>
  28. <a-col class="stack-col" :class="{ 'hemp-texture': !!item.steelBillet[1] }" :span="6">{{ item.steelBillet[1] || '' }}</a-col>
  29. <a-col class="stack-col" :class="{ 'hemp-texture': !!item.steelBillet[2] }" :span="6">{{ item.steelBillet[2] || '' }}</a-col>
  30. <a-col class="stack-col" :class="{ 'hemp-texture': !!item.steelBillet[3] }" :span="6">{{ item.steelBillet[3] || '' }}</a-col>
  31. </a-row>
  32. </a-col>
  33. </a-row>
  34. <div class="single-billet-wrap selected-divider-row" v-if="singleBillet == '1'">
  35. <a-row justify="start" class="single-billet-row stacking-list-row">
  36. <a-col class="stack-col hemp-texture" v-for="item in singleSelectBillers" :span="6">
  37. {{ item.billetNo || '' }}
  38. </a-col>
  39. </a-row>
  40. </div>
  41. </div>
  42. </a-spin>
  43. </div>
  44. </basic-modal>
  45. </template>
  46. <script lang="ts" setup>
  47. import { computed, ref } from 'vue';
  48. import { BasicModal, useModalInner } from '/@/components/Modal';
  49. import { getStackInfo, stackLocationChange } from '/@/views/billet/hotDelivery/hotDelivery.api';
  50. import ASegmented from 'ant-design-vue/es/segmented/src/segmented';
  51. import { useMessage } from '/@/hooks/web/useMessage';
  52. const { createMessage } = useMessage();
  53. // Emits声明
  54. const emit = defineEmits(['register', 'success']);
  55. const modalTitle = ref('');
  56. const record = ref<Record<string, any>>({});
  57. // 当前铸机线信息
  58. const activeKey = ref('1');
  59. const stackingList = ref<any[]>([]);
  60. const stackingInfoList = ref<Record<string, any>>({});
  61. // 定尺
  62. // 获取堆垛容器加载
  63. const isSpinning = ref(false);
  64. // 是否是单支钢坯进行棒线操作
  65. const singleBillet = ref('4');
  66. const singleSelectBillers = ref<any[]>([]);
  67. //表单赋值
  68. const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
  69. try {
  70. const { basicInfo } = data;
  71. record.value = basicInfo;
  72. modalTitle.value = `${basicInfo.layer}层${basicInfo.address}位置 - 更换位置`;
  73. // 获取当前堆垛信息
  74. getStackInfoList();
  75. } catch (error) {
  76. console.log(error);
  77. }
  78. });
  79. // 获取当前堆垛信息
  80. const getStackInfoList = async () => {
  81. isSpinning.value = true;
  82. const stackingInfo = await getStackInfo({ typeConfigId: record.value.typeConfigId });
  83. let layerObj = {};
  84. if (stackingInfo.length) {
  85. stackingInfo.forEach((item) => {
  86. if (!layerObj[item.layer]) layerObj[item.layer] = [];
  87. layerObj[item.layer].push({ ...item, steelBillet: item.billetNos ? item.billetNos.split(',') : [] });
  88. });
  89. }
  90. stackingInfoList.value = layerObj;
  91. stackingList.value = Object.keys(layerObj)
  92. .sort((a, b) => Number(a) - Number(b))
  93. .map((item) => ({ label: `第${item}层`, value: item }));
  94. const canShowLayer = stackingList.value.filter((item) => layerObj[item.value].some((item) => !!item.billetNos));
  95. if (canShowLayer.length) {
  96. activeKey.value = canShowLayer[canShowLayer.length - 1].value;
  97. }
  98. isSpinning.value = false;
  99. };
  100. // 返回选中的表格数据
  101. const getSelectedData = computed(() => {
  102. const key = activeKey.value;
  103. const newData = stackingInfoList.value[key] ? stackingInfoList.value[key].sort((a, b) => Number(b.address) - Number(a.address)) : [];
  104. return newData;
  105. });
  106. // 选中当前层的位置
  107. const curLayerSelectedAddress = ref<string | number>('');
  108. const handleStackClick = (item) => {
  109. if (item.steelBillet.length || item.billetNos) return;
  110. curLayerSelectedAddress.value = curLayerSelectedAddress.value === item.id ? '' : item.id;
  111. };
  112. const handleCancel = () => {
  113. curLayerSelectedAddress.value = '';
  114. closeModal();
  115. };
  116. //表单提交事件
  117. async function handleSubmit() {
  118. try {
  119. if (!curLayerSelectedAddress.value) {
  120. createMessage.warning('请选择位置');
  121. return;
  122. }
  123. const params = {
  124. stackId: record.value.id,
  125. locationChangeId: curLayerSelectedAddress.value,
  126. };
  127. setModalProps({ confirmLoading: true });
  128. //提交表单
  129. await stackLocationChange(params);
  130. //关闭弹窗
  131. handleCancel();
  132. } catch (e) {
  133. console.log(e);
  134. } finally {
  135. setModalProps({ confirmLoading: false });
  136. //刷新列表
  137. emit('success');
  138. }
  139. }
  140. </script>
  141. <style lang="less" scoped>
  142. @import '/@/views/billet/hotDelivery/components/metal.less';
  143. .stacking-modal {
  144. position: relative;
  145. .group-zhishu {
  146. margin-bottom: 20px;
  147. margin-left: 20px;
  148. }
  149. .single-billet-wrap {
  150. position: absolute;
  151. top: -30px;
  152. left: 0;
  153. right: 0;
  154. bottom: 0;
  155. z-index: 10;
  156. background: rgba(51, 51, 51, 0.45);
  157. display: flex;
  158. justify-content: center;
  159. align-items: center;
  160. .single-billet-row {
  161. width: 30%;
  162. height: 80px;
  163. background: rgba(255, 255, 255, 0.8);
  164. padding: 20px;
  165. .delete {
  166. position: absolute;
  167. right: 2px;
  168. top: -10px;
  169. color: red;
  170. cursor: pointer;
  171. }
  172. }
  173. }
  174. }
  175. </style>