headTop.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403
  1. <template>
  2. <a-row class="head-top">
  3. <a-col :span="3" class="head-no bg flex items-center justify-center"
  4. ><a-badge status="processing" /> 浇铸炉号:{{ info.billetHotsendChangeShift.heatNo }}
  5. </a-col>
  6. <a-col :span="1" class="amount-no bg flex items-center justify-center">
  7. <a-statistic title="支数" :value="info.currentCastingFurnaceAmount || 0" />
  8. </a-col>
  9. <a-col :span="2" class="amount-no bg flex items-center justify-center">
  10. <a-statistic title="重量/t" :value="info.currentCastingFurnace ? info.currentCastingFurnace.toFixed(3) : 0" />
  11. </a-col>
  12. <a-col :span="1" class="flex items-center justify-center">
  13. <a-button type="primary" class="change-heat" @click="switchHeatNo" :loading="changeHeatLoading">换炉</a-button>
  14. </a-col>
  15. <a-col :span="1" class="current-shift flex items-center justify-center">当班统计:</a-col>
  16. <a-col :span="1" class="flex items-center justify-center">
  17. <a-statistic title="总支数" :value="info.billetHotsendChangeShift.shiftSum" />
  18. </a-col>
  19. <a-col :span="2" class="flex items-center justify-center">
  20. <a-statistic title="总重量/t" :value="info.billetHotsendChangeShift.shiftProduct ? info.billetHotsendChangeShift.shiftProduct.toFixed(3) : 0" />
  21. </a-col>
  22. <a-col :span="3" class="flex flex-col" v-for="item of typeList">
  23. <div class="type-item">
  24. <span class="type-title" :style="{ color: item.titleColor }">{{ item.title }}:</span> {{ item.amount }} 支 / {{ item.weight }} t
  25. </div>
  26. <div class="type-item" v-for="ele of item.dtlList">
  27. <div class="type-item-dtl">
  28. <span class="type-title">{{ ele.size }}:</span> {{ ele.nums }} 支 / {{ ele.weight }} t
  29. </div>
  30. </div>
  31. </a-col>
  32. <a-col :span="2" class="paihao flex items-center justify-center">当前牌号:<component :is="renderDictTag(info.brandNum, 'billet_spec')" /></a-col>
  33. <a-col :span="2" class="current-shift flex items-center justify-center">
  34. <a-button type="primary" danger @click="openPaihaoModal = true">切换牌号</a-button>
  35. </a-col>
  36. </a-row>
  37. <a-modal
  38. v-model:open="openPaihaoModal"
  39. title="切换牌号"
  40. centered
  41. width="400px"
  42. ok-text="确认"
  43. :okButtonProps="{ loading: okLoading }"
  44. cancel-text="取消"
  45. @ok="switchSteelOne"
  46. @cancel="
  47. () => {
  48. openPaihaoModal = false;
  49. newBrandNum = '';
  50. }
  51. "
  52. >
  53. <div class="flex justify-center items-center" style="margin: 20px 0">
  54. <div>选择牌号:</div>
  55. <JSearchSelect type="list" style="width: 277px" v-model:value="newBrandNum" dict="billet_spec" placeholder="请选择" allowClear />
  56. </div>
  57. </a-modal>
  58. <!-- 切换炉号确认 -->
  59. <changeHeatModal @register="registerChangeHeatModal" @ok="() => {}" />
  60. </template>
  61. <script setup lang="ts">
  62. import { ref, onMounted, onUnmounted } from 'vue';
  63. import AStatistic from 'ant-design-vue/lib/statistic/Statistic';
  64. import { getOnDutyInfo, getTeamShift, getSteelPileBaseInfo, groupBy } from '../../Dashboard/dashboard.api';
  65. import { useTimeoutFn } from '/@/hooks/core/useTimeout';
  66. import { switchSteel, returnFurnaceChange } from '../operator.api';
  67. import { useMessage } from '/@/hooks/web/useMessage';
  68. import JSearchSelect from '/@/components/Form/src/jeecg/components/JSearchSelect.vue';
  69. import { render } from '/@/utils/common/renderUtils';
  70. import changeHeatModal from './changeHeatModal.vue';
  71. import { useModal } from '/@/components/Modal';
  72. const { createMessage } = useMessage();
  73. // 注册打印modal
  74. const [registerChangeHeatModal, { openModal: openChangeHeatModal }] = useModal();
  75. const emits = defineEmits(['shiftChange', 'lengthChange']);
  76. const props = defineProps({
  77. ccmNo: {
  78. type: String,
  79. default: '5',
  80. },
  81. });
  82. const info = ref<any>({
  83. brandNum: '',
  84. billetHotsendChangeShift: {
  85. heatNo: '',
  86. shiftGroup: '',
  87. shift: '',
  88. wasteAmount: 0,
  89. shiftProduct: 0,
  90. shiftSum: 0,
  91. wasteBlankOutput: 0,
  92. },
  93. currentCastingFurnaceAmount: null,
  94. currentCastingFurnace: null,
  95. });
  96. // typeList
  97. const typeList = ref<any>([
  98. { title: '棒一', titleColor: '#f50', amount: 0, weight: 0, dtlList: [] },
  99. { title: '热装', titleColor: '#f50', amount: 0, weight: 0, dtlList: [] },
  100. { title: '堆垛', titleColor: '#b8ceff', amount: 0, weight: 0, dtlList: [] },
  101. ]);
  102. // 渲染字典标签
  103. const renderDictTag = (value: string, dictCode: string) => {
  104. return render.renderDict(value, dictCode);
  105. };
  106. // 获取班组班别
  107. const getShiftInfo = () => {
  108. emits('shiftChange', getTeamShift(info.value.billetHotsendChangeShift.shift, info.value.billetHotsendChangeShift.shiftGroup), {
  109. shift: info.value.billetHotsendChangeShift.shift,
  110. shiftGroup: info.value.billetHotsendChangeShift.shiftGroup,
  111. });
  112. };
  113. // 获取当前班次信息
  114. const getInfo = async () => {
  115. try {
  116. const infoRes = await getOnDutyInfo({ ccmNo: props.ccmNo });
  117. if (infoRes) {
  118. info.value = infoRes;
  119. try {
  120. let standObj = {};
  121. (JSON.parse(infoRes.standNoSize) || []).forEach((item) => {
  122. standObj[item.strandNo] = item.length;
  123. });
  124. emits('lengthChange', JSON.stringify(standObj));
  125. } catch (error) {
  126. console.log(error);
  127. }
  128. }
  129. // 获取明细
  130. const dtlRes = await getSteelPileBaseInfo({ ccmNo: props.ccmNo });
  131. // 按照目的地分组
  132. if (dtlRes) {
  133. const destinationArr = dtlRes.reduce((acc, cur) => {
  134. acc[cur.belongTable] = acc[cur.belongTable] || [];
  135. acc[cur.belongTable].push(cur);
  136. return acc;
  137. }, {});
  138. // roll_club_one 棒一
  139. // roll_club_two 棒二
  140. // roll_club_three 棒三
  141. // roll_out_shipp 上若
  142. // roll_height 高线
  143. // stacking_and_loading_vehicles 堆垛
  144. let hotsendData: any = [],
  145. hotSendSum = 0,
  146. hotSendTotalWeight = 0,
  147. hotchargeData: any = [],
  148. hotChargeSum = 0,
  149. hotChargeTotalWeight = 0,
  150. stackingData: any = [],
  151. stackingSum = 0,
  152. stackingTotalWeight = 0;
  153. // 计算棒一
  154. if (destinationArr['roll_club_one']) {
  155. hotsendData = Object.values(groupBy(destinationArr['roll_club_one'] || [], 'length')).map((one: any) => {
  156. hotSendSum += one.nums;
  157. hotSendTotalWeight += one.weight;
  158. return {
  159. ...one,
  160. weight: one.weight.toFixed(3),
  161. size: one.size / 1000,
  162. };
  163. });
  164. }
  165. // 计算热装
  166. if (destinationArr['roll_club_two'] || destinationArr['roll_club_three'] || destinationArr['roll_out_shipp']) {
  167. const concatArr = [
  168. ...(destinationArr['roll_club_two'] || []),
  169. ...(destinationArr['roll_club_three'] || []),
  170. ...(destinationArr['roll_out_shipp'] || []),
  171. ];
  172. hotchargeData = Object.values(groupBy(concatArr, 'length')).map((one: any) => {
  173. hotChargeSum += one.nums;
  174. hotChargeTotalWeight += one.weight;
  175. return {
  176. ...one,
  177. weight: one.weight.toFixed(3),
  178. size: one.size / 1000,
  179. };
  180. });
  181. }
  182. // 计算堆垛
  183. if (destinationArr['stacking_and_loading_vehicles']) {
  184. stackingData = Object.values(groupBy(destinationArr['stacking_and_loading_vehicles'] || [], 'length')).map((one: any) => {
  185. stackingSum += one.nums;
  186. stackingTotalWeight += one.weight;
  187. return {
  188. ...one,
  189. weight: one.weight.toFixed(3),
  190. size: one.size / 1000,
  191. };
  192. });
  193. }
  194. typeList.value = [
  195. {
  196. title: '棒一',
  197. titleColor: '#f50',
  198. amount: hotSendSum || 0,
  199. weight: hotSendTotalWeight ? hotSendTotalWeight.toFixed(3) : 0,
  200. dtlList: hotsendData,
  201. },
  202. {
  203. title: '热装',
  204. titleColor: '#f50',
  205. amount: hotChargeSum || 0,
  206. weight: hotChargeTotalWeight ? hotChargeTotalWeight.toFixed(3) : 0,
  207. dtlList: hotchargeData,
  208. },
  209. {
  210. title: '堆垛',
  211. titleColor: '#b8ceff',
  212. amount: stackingSum || 0,
  213. weight: stackingTotalWeight ? stackingTotalWeight.toFixed(3) : 0,
  214. dtlList: stackingData,
  215. },
  216. ];
  217. getShiftInfo();
  218. }
  219. } catch (error) {
  220. } finally {
  221. start();
  222. }
  223. };
  224. const { start, stop } = useTimeoutFn(getInfo, 5000);
  225. // 换炉
  226. const changeHeatLoading = ref(false);
  227. const switchHeatNo = async () => {
  228. try {
  229. if (!info.value.billetHotsendChangeShift.heatNo) return;
  230. changeHeatLoading.value = true;
  231. const heatInfo = await returnFurnaceChange({
  232. heatNo: Number(info.value.billetHotsendChangeShift.heatNo) + 1,
  233. });
  234. if (heatInfo) {
  235. openChangeHeatModal(true, {
  236. record: { ...heatInfo, ccmNo: heatInfo.ccmNo || props.ccmNo },
  237. });
  238. }
  239. changeHeatLoading.value = false;
  240. } catch (error) {
  241. changeHeatLoading.value = false;
  242. }
  243. };
  244. // 切换牌号
  245. const openPaihaoModal = ref(false);
  246. const newBrandNum = ref('');
  247. const okLoading = ref(false);
  248. const switchSteelOne = async () => {
  249. try {
  250. if (newBrandNum.value == '') {
  251. createMessage.error('请选择牌号');
  252. return;
  253. }
  254. okLoading.value = true;
  255. await switchSteel({
  256. ccmNo: props.ccmNo,
  257. brandNum: newBrandNum.value,
  258. });
  259. getInfo();
  260. openPaihaoModal.value = false;
  261. newBrandNum.value = '';
  262. okLoading.value = false;
  263. } catch (error) {
  264. okLoading.value = false;
  265. }
  266. };
  267. onMounted(() => {
  268. getInfo();
  269. });
  270. onUnmounted(() => {
  271. stop();
  272. });
  273. defineExpose({
  274. reload: () => {
  275. stop();
  276. getInfo();
  277. },
  278. });
  279. </script>
  280. <style lang="less" scoped>
  281. .head-top {
  282. height: 130px;
  283. font-size: 16px;
  284. color: var(--op-text-color-fff);
  285. border: 1px solid var(--op-border-color);
  286. border-radius: 6px;
  287. background-color: #01396c;
  288. overflow: hidden;
  289. .ant-col {
  290. height: 130px;
  291. border-right: 1px solid var(--op-border-color);
  292. overflow: hidden auto;
  293. padding: 10px;
  294. font-size: 16px;
  295. &:last-child {
  296. border-right: none;
  297. }
  298. }
  299. .head-no {
  300. height: 130px;
  301. font-size: 24px;
  302. font-family: 'Kingsoft_Cloud_Font';
  303. }
  304. .bg {
  305. background: #0085ff;
  306. }
  307. .ant-statistic {
  308. :deep(.ant-statistic-title),
  309. :deep(.ant-statistic-content-value-int),
  310. :deep(.ant-statistic-content-value-decimal) {
  311. color: var(--op-text-color-fff);
  312. text-align: center;
  313. font-size: 16px;
  314. }
  315. :deep(.ant-statistic-content-value-int),
  316. :deep(.ant-statistic-content-value-decimal) {
  317. font-size: 30px;
  318. }
  319. :deep(.ant-statistic-content) {
  320. text-align: center;
  321. }
  322. }
  323. .ant-btn {
  324. height: 80px;
  325. font-size: 18px;
  326. padding: 4px 10px;
  327. }
  328. .paihao {
  329. color: #f50;
  330. font-size: 16px;
  331. }
  332. .type-item {
  333. font-size: 16px;
  334. }
  335. .type-title {
  336. display: inline-block;
  337. width: 50px;
  338. }
  339. .change-heat.is-disabled {
  340. background: #d9d9d9;
  341. color: #8a8a8a;
  342. }
  343. .ant-badge {
  344. width: 12px;
  345. height: 12px;
  346. line-height: 12px;
  347. margin-right: 8px;
  348. margin-top: -7px;
  349. :deep(.ant-badge-status-dot) {
  350. width: 12px;
  351. height: 12px;
  352. color: #00fb6f;
  353. background-color: #00fb6f;
  354. }
  355. }
  356. @keyframes antStatusProcessing {
  357. 0% {
  358. transform: scale(0.8);
  359. opacity: 0.8;
  360. }
  361. 100% {
  362. transform: scale(2.4);
  363. opacity: 0.2;
  364. }
  365. }
  366. }
  367. </style>