heatList.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334
  1. <template>
  2. <div class="cc-heatList">
  3. <div class="tips-title flex">
  4. <div class="left-tip">当班浇铸炉次</div>
  5. <div class="flex-1">支数(根) / 重量(t)</div>
  6. </div>
  7. <!--引用表格-->
  8. <BasicTable @register="registerTable">
  9. <!--操作栏-->
  10. <template #action="{ record }">
  11. <TableAction class="flex flex-col" style="gap: 4px" :actions="getTableAction(record)" />
  12. </template>
  13. <!--字段回显插槽-->
  14. <!-- <template v-slot:bodyCell="{ column, record, index, text }"> </template> -->
  15. </BasicTable>
  16. </div>
  17. </template>
  18. <script lang="ts" name="billetLiftingBill" setup>
  19. import { BasicTable, TableAction, ActionItem } from '/@/components/Table';
  20. import { useListPage } from '/@/hooks/system/useListPage';
  21. import { columns } from '../operator.data';
  22. import { queryHeatsActualsByCcmNo, addHotCharge, stackingUpAdd } from '../operator.api';
  23. import { onMounted, onUnmounted } from 'vue';
  24. import { mapTableTotalSummary } from '/@/utils/common/compUtils';
  25. import { useTimeoutFn } from '/@/hooks/core/useTimeout';
  26. import { useMessage } from '/@/hooks/web/useMessage';
  27. const { createMessage } = useMessage();
  28. const props = defineProps({
  29. ccmNo: {
  30. type: String,
  31. default: '5',
  32. },
  33. carRef: {
  34. type: Object,
  35. default: () => {
  36. return {};
  37. },
  38. },
  39. });
  40. //注册table数据
  41. const { tableContext } = useListPage({
  42. tableProps: {
  43. api: queryHeatsActualsByCcmNo,
  44. beforeFetch: (params) => {
  45. return Object.assign(params, { ccmNo: props.ccmNo });
  46. },
  47. afterFetch: (data) => {
  48. const length = data.length;
  49. return data.map((item, index) => {
  50. return {
  51. ...item,
  52. columnIndex: length - index,
  53. };
  54. });
  55. },
  56. columns,
  57. showIndexColumn: false,
  58. canResize: true,
  59. striped: true,
  60. showTableSetting: false,
  61. pagination: false,
  62. actionColumn: {
  63. width: 60,
  64. title: '操作',
  65. fixed: 'right',
  66. },
  67. showActionColumn: true,
  68. showSummary: true,
  69. summaryFunc: onSummary,
  70. },
  71. });
  72. /**
  73. * 计算合计
  74. * @param tableData
  75. */
  76. function onSummary(tableData: Recordable[]) {
  77. // 可用工具方法自动计算合计
  78. const totals = mapTableTotalSummary(tableData, [
  79. 'oneStrandNo',
  80. 'twoStrandNo',
  81. 'threeStrandNo',
  82. 'fourStrandNo',
  83. 'fiveStrandNo',
  84. 'sixStrandNo',
  85. 'sevenStrandNo',
  86. 'eightStrandNo',
  87. ]);
  88. // 直轧,热装,堆垛,总计
  89. let directRollingTotalCount = 0,
  90. directRollingTotalWeight = 0,
  91. hotChargeTotalCount = 0,
  92. hotChargeTotalWeight = 0,
  93. stackingTotalCount = 0,
  94. stackingTotalWeight = 0,
  95. totalCount = 0,
  96. totalWeight = 0;
  97. try {
  98. tableData.forEach((item) => {
  99. const { hotSend, directRolling, hotCharge, stacking, totalInfo } = item;
  100. // 直轧
  101. if (hotSend) {
  102. const obj = JSON.parse(hotSend);
  103. directRollingTotalCount += Number(obj.hotSendTotalCount);
  104. directRollingTotalWeight += parseFloat(obj.hotSendTotalWeight);
  105. }
  106. if (directRolling) {
  107. const obj = JSON.parse(directRolling);
  108. directRollingTotalCount += Number(obj.directRollingTotalCount);
  109. directRollingTotalWeight += parseFloat(obj.directRollingTotalWeight);
  110. }
  111. // 热装
  112. if (hotCharge) {
  113. const obj = JSON.parse(hotCharge);
  114. hotChargeTotalCount += Number(obj.hotChargeTotalCount);
  115. hotChargeTotalWeight += parseFloat(obj.hotChargeTotalWeight);
  116. }
  117. // 堆垛
  118. if (stacking) {
  119. const obj = JSON.parse(stacking);
  120. stackingTotalCount += Number(obj.stackingTotalCount);
  121. stackingTotalWeight += parseFloat(obj.stackingTotalWeight);
  122. }
  123. // 总计
  124. if (totalInfo) {
  125. const obj = JSON.parse(totalInfo);
  126. totalCount += Number(obj.totalCount);
  127. totalWeight += parseFloat(obj.totalWeight);
  128. }
  129. });
  130. } catch (error) {}
  131. return [
  132. {
  133. ...totals,
  134. directRolling: JSON.stringify({ directRollingTotalCount, directRollingTotalWeight: directRollingTotalWeight }),
  135. hotCharge: JSON.stringify({ hotChargeTotalCount, hotChargeTotalWeight: hotChargeTotalWeight }),
  136. stacking: JSON.stringify({ stackingTotalCount, stackingTotalWeight: stackingTotalWeight }),
  137. totalInfo: JSON.stringify({ totalCount, totalWeight: totalWeight }),
  138. columnIndex: '合',
  139. },
  140. ];
  141. }
  142. const [registerTable, { reload, setLoading }] = tableContext;
  143. const { start, stop } = useTimeoutFn(() => {
  144. reload();
  145. start();
  146. }, 10000);
  147. onMounted(() => {
  148. start();
  149. });
  150. onUnmounted(() => {
  151. stop();
  152. });
  153. // 热装
  154. const hotCharge = async (record) => {
  155. try {
  156. const valiDesRes = props.carRef && props.carRef.valirDest ? props.carRef.valirDest() : true;
  157. if (!valiDesRes) {
  158. return;
  159. }
  160. const chargeInfo = props.carRef && props.carRef.getCurrentCar ? props.carRef.getCurrentCar() : {};
  161. if (!chargeInfo.id) {
  162. createMessage.error('获取车辆信息失败,请刷新页面重试~');
  163. return;
  164. }
  165. const params = {
  166. ccmNo: props.ccmNo,
  167. heatNo: record.heatNo,
  168. storageId: chargeInfo.id,
  169. };
  170. setLoading(true);
  171. await addHotCharge(params);
  172. stop();
  173. reload();
  174. props.carRef.refreshCarList && props.carRef.refreshCarList();
  175. } catch (error) {
  176. } finally {
  177. setLoading(false);
  178. }
  179. };
  180. // 起垛
  181. const doStack = async (record) => {
  182. try {
  183. const selectStackList = props.carRef && props.carRef.getSelectedStack ? props.carRef.getSelectedStack() : [];
  184. const emptyAddress = selectStackList.filter((item) => !item.billetNos);
  185. if (emptyAddress.length === 0) {
  186. createMessage.error('请选择起垛位置!');
  187. return;
  188. }
  189. // 堆垛信息
  190. const stackInfo = props.carRef && props.carRef.getStackInfo ? props.carRef.getStackInfo() : {};
  191. if (!stackInfo.id) {
  192. createMessage.error('获取堆垛信息失败,请刷新页面重试~');
  193. return;
  194. }
  195. let layerObj = {},
  196. sortedStackList: any[] = [];
  197. emptyAddress.forEach((item) => {
  198. if (!layerObj[item.layer]) layerObj[item.layer] = [];
  199. layerObj[item.layer].push(item);
  200. });
  201. // 根据层数和位置排序
  202. Object.keys(layerObj)
  203. .sort((a, b) => Number(a) - Number(b))
  204. .forEach((item) => {
  205. layerObj[item].sort((j, k) => Number(j.address) - Number(k.address)).forEach((item) => sortedStackList.push(item));
  206. });
  207. const params = {
  208. ccmNo: props.ccmNo,
  209. heatNo: record.heatNo,
  210. billetHotsendTypeConfigId: stackInfo.id,
  211. stackingAndLoadingVehiclesIds: sortedStackList.map((item) => item.id),
  212. };
  213. setLoading(true);
  214. await stackingUpAdd(params);
  215. stop();
  216. reload();
  217. props.carRef.refreshCarList && props.carRef.refreshCarList();
  218. } catch (error) {
  219. } finally {
  220. setLoading(false);
  221. }
  222. };
  223. /**
  224. * 操作栏
  225. */
  226. function getTableAction(record): ActionItem[] | undefined {
  227. if (!record.operateStatus) return undefined;
  228. const chargeInfo = props.carRef && props.carRef.getCurrentCar ? props.carRef.getCurrentCar() : {};
  229. return [
  230. {
  231. label: '热装',
  232. color: 'error',
  233. disabled: !chargeInfo.id || !!chargeInfo.outTime,
  234. type: 'primary',
  235. onClick: () => {
  236. hotCharge(record);
  237. },
  238. },
  239. {
  240. label: '起垛',
  241. color: 'warning',
  242. type: 'primary',
  243. onClick: () => {
  244. doStack(record);
  245. },
  246. },
  247. ];
  248. }
  249. </script>
  250. <style scoped lang="less">
  251. .cc-heatList {
  252. .tips-title {
  253. color: #fff;
  254. font-size: 18px;
  255. text-align: center;
  256. border: 1px solid #fff;
  257. margin-bottom: 4px;
  258. .left-tip {
  259. width: 227px;
  260. border-right: 1px solid #fff;
  261. }
  262. }
  263. .jeecg-basic-table {
  264. padding: 0;
  265. }
  266. :deep(.ant-table) {
  267. .ant-table-thead > tr > th {
  268. font-size: 16px;
  269. font-weight: 800;
  270. color: #fff;
  271. }
  272. .ant-table-thead > tr > th:nth-child(4),
  273. .ant-table-thead > tr > th:nth-child(5),
  274. .ant-table-thead > tr > th:nth-child(6),
  275. .ant-table-thead > tr > th:nth-child(7),
  276. .ant-table-thead > tr > th:nth-child(8),
  277. .ant-table-thead > tr > th:nth-child(9),
  278. .ant-table-thead > tr > th:nth-child(10),
  279. .ant-table-thead > tr > th:nth-child(11) {
  280. color: #f50;
  281. padding: 0;
  282. }
  283. .ant-table-tbody {
  284. font-size: 15px;
  285. font-family: 'Kingsoft_Cloud_Font';
  286. & > tr > td:nth-child(6),
  287. & > tr > td:nth-child(7),
  288. & > tr > td:nth-child(8),
  289. & > tr > td:nth-child(9),
  290. & > tr > td:nth-child(10),
  291. & > tr > td:nth-child(11) {
  292. padding: 0 8px;
  293. position: relative;
  294. }
  295. }
  296. .ant-table-footer {
  297. padding: 0;
  298. }
  299. }
  300. }
  301. </style>