operator.data.ts 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  1. import { h } from 'vue';
  2. import { BasicColumn } from '/@/components/Table';
  3. import { render } from '/@/utils/common/renderUtils';
  4. const renderNum = (num, weight, backArr?: boolean, tag = 'div') => {
  5. let arr = [h(tag, { style: { color: '#0085ff' } }, num)];
  6. if (weight) {
  7. arr.push(h(tag, {}, (tag === 'span' ? '/' : '') + parseInt(weight).toFixed(2)));
  8. }
  9. if (backArr === true) {
  10. return arr;
  11. }
  12. return h('div', {}, arr);
  13. };
  14. export const renderStrandCell = (options) => {
  15. const { num, lengthJsonStr, clickCb, record, strandNo } = options;
  16. try {
  17. if (lengthJsonStr) {
  18. const lengthJson = JSON.parse(lengthJsonStr);
  19. const lengthKeys = Object.keys(lengthJson);
  20. if (lengthKeys.length) {
  21. return h('div', { style: { textAlign: 'left', padding: '20px 0 0' } }, [
  22. h('div', { style: { color: '#f50', position: 'absolute', top: '0px' } }, num),
  23. ...lengthKeys.map((key) => {
  24. return h('div', {}, [
  25. h(
  26. 'span',
  27. {
  28. style: { cursor: 'pointer' },
  29. onClick() {
  30. clickCb && clickCb({ record, size: key, strandNo });
  31. },
  32. },
  33. Number(key) / 1000 + ': '
  34. ),
  35. h('span', { style: { color: '#0085ff' } }, lengthJson[key]),
  36. ]);
  37. }),
  38. ]);
  39. }
  40. return num;
  41. }
  42. } catch (error) {}
  43. return num;
  44. };
  45. // 列表数据
  46. export const getColumns = ({ clickCb, openCompensateModal, heatNoClick }): BasicColumn[] => {
  47. return [
  48. {
  49. title: '#',
  50. align: 'center',
  51. dataIndex: 'columnIndex',
  52. ellipsis: false,
  53. width: 36,
  54. fixed: 'left',
  55. },
  56. {
  57. title: '炉号',
  58. align: 'center',
  59. dataIndex: 'heatNo',
  60. width: 90,
  61. fixed: 'left',
  62. customRender(opt) {
  63. return h('div', { style: { cursor: 'pointer' }, onClick: () => heatNoClick && heatNoClick(opt.record) }, [
  64. h('div', { style: { color: '#6bd000', position: 'absolute', top: '0px' } }, render.renderDict(opt.record.shiftGroup, 'lg_bz')),
  65. h('span', {}, opt.record.heatNo),
  66. ]);
  67. },
  68. },
  69. {
  70. title: '牌号',
  71. align: 'center',
  72. width: 80,
  73. dataIndex: 'brandNum',
  74. customRender(opt) {
  75. return render.renderDict(opt.record.brandNum, 'billet_spec');
  76. },
  77. },
  78. {
  79. title: '1流',
  80. width: 90,
  81. align: 'center',
  82. dataIndex: 'oneStrandNo',
  83. customRender(opt) {
  84. return renderStrandCell({ num: opt.record.oneStrandNo, lengthJsonStr: opt.record.oneLength, clickCb, record: opt.record, strandNo: 1 });
  85. },
  86. },
  87. {
  88. title: '2流',
  89. width: 90,
  90. align: 'center',
  91. dataIndex: 'twoStrandNo',
  92. customRender(opt) {
  93. return renderStrandCell({ num: opt.record.twoStrandNo, lengthJsonStr: opt.record.twoLength, clickCb, record: opt.record, strandNo: 2 });
  94. },
  95. },
  96. {
  97. title: '3流',
  98. width: 90,
  99. align: 'center',
  100. dataIndex: 'threeStrandNo',
  101. customRender(opt) {
  102. return renderStrandCell({ num: opt.record.threeStrandNo, lengthJsonStr: opt.record.threeLength, clickCb, record: opt.record, strandNo: 3 });
  103. },
  104. },
  105. {
  106. title: '4流',
  107. width: 90,
  108. align: 'center',
  109. dataIndex: 'fourStrandNo',
  110. customRender(opt) {
  111. return renderStrandCell({ num: opt.record.fourStrandNo, lengthJsonStr: opt.record.fourLength, clickCb, record: opt.record, strandNo: 4 });
  112. },
  113. },
  114. {
  115. title: '5流',
  116. width: 90,
  117. align: 'center',
  118. dataIndex: 'fiveStrandNo',
  119. customRender(opt) {
  120. return renderStrandCell({ num: opt.record.fiveStrandNo, lengthJsonStr: opt.record.fiveLength, clickCb, record: opt.record, strandNo: 5 });
  121. },
  122. },
  123. {
  124. title: '6流',
  125. width: 90,
  126. align: 'center',
  127. dataIndex: 'sixStrandNo',
  128. customRender(opt) {
  129. return renderStrandCell({ num: opt.record.sixStrandNo, lengthJsonStr: opt.record.sixLength, clickCb, record: opt.record, strandNo: 6 });
  130. },
  131. },
  132. {
  133. title: '7流',
  134. width: 90,
  135. align: 'center',
  136. dataIndex: 'sevenStrandNo',
  137. customRender(opt) {
  138. return renderStrandCell({ num: opt.record.sevenStrandNo, lengthJsonStr: opt.record.sevenLength, clickCb, record: opt.record, strandNo: 7 });
  139. },
  140. },
  141. {
  142. title: '8流',
  143. width: 90,
  144. align: 'center',
  145. dataIndex: 'eightStrandNo',
  146. customRender(opt) {
  147. return renderStrandCell({ num: opt.record.eightStrandNo, lengthJsonStr: opt.record.eightLength, clickCb, record: opt.record, strandNo: 8 });
  148. },
  149. },
  150. {
  151. title: '棒一',
  152. align: 'center',
  153. width: 75,
  154. dataIndex: 'directRolling',
  155. customRender({ record }) {
  156. const { hotSend, directRolling } = record;
  157. try {
  158. if (hotSend) {
  159. const obj = JSON.parse(hotSend);
  160. // return obj.hotSendTotalCount + ' / ' + obj.hotSendTotalWeight.toFixed(2);
  161. return renderNum(obj.hotSendTotalCount, obj.hotSendTotalWeight);
  162. }
  163. if (directRolling) {
  164. const obj = JSON.parse(directRolling);
  165. // return obj.directRollingTotalCount + ' / ' + obj.directRollingTotalWeight.toFixed(2);
  166. return renderNum(obj.directRollingTotalCount, obj.directRollingTotalWeight);
  167. }
  168. } catch (error) {}
  169. return '';
  170. },
  171. },
  172. {
  173. title: '热装',
  174. align: 'center',
  175. width: 75,
  176. dataIndex: 'hotCharge',
  177. customRender({ record }) {
  178. const { hotCharge } = record;
  179. try {
  180. if (hotCharge) {
  181. const obj = JSON.parse(hotCharge);
  182. // return obj.hotChargeTotalCount + ' / ' + obj.hotChargeTotalWeight.toFixed(2);
  183. return renderNum(obj.hotChargeTotalCount, obj.hotChargeTotalWeight);
  184. }
  185. } catch (error) {}
  186. return '';
  187. },
  188. },
  189. {
  190. title: '堆垛',
  191. align: 'center',
  192. width: 75,
  193. dataIndex: 'stacking',
  194. customRender({ record }) {
  195. const { stacking } = record;
  196. try {
  197. if (stacking) {
  198. const obj = JSON.parse(stacking);
  199. // return obj.stackingTotalCount + ' / ' + obj.stackingTotalWeight.toFixed(2);
  200. return renderNum(obj.stackingTotalCount, obj.stackingTotalWeight);
  201. }
  202. } catch (error) {}
  203. return '';
  204. },
  205. },
  206. {
  207. title: '定尺',
  208. align: 'center',
  209. width: 100,
  210. dataIndex: 'length',
  211. customRender({ record }) {
  212. const { length } = record;
  213. try {
  214. if (length) {
  215. const obj = JSON.parse(length);
  216. let lengthCC: any[] = [];
  217. Object.keys(obj).forEach((key) => {
  218. // lengthCC.push(h('div', {}, key + ' : ' + obj[key].lengthTotalCount + ' / ' + obj[key].lengthTotalWeight.toFixed(2)));
  219. const lengthStlArr = renderNum(obj[key].lengthTotalCount, null, true, 'span') as any[];
  220. lengthCC.push(h('div', {}, [h('span', {}, Number(key) / 1000 + ': '), ...lengthStlArr]));
  221. });
  222. return h('div', { style: { fontSize: '12px', textAlign: 'left' } }, lengthCC);
  223. }
  224. } catch (error) {}
  225. return '';
  226. },
  227. },
  228. {
  229. title: '总计',
  230. align: 'center',
  231. width: 75,
  232. dataIndex: 'totalInfo',
  233. customRender({ record }) {
  234. try {
  235. const { totalInfo, hotCharge, stacking, hotSend, directRolling } = record;
  236. if (totalInfo) {
  237. const obj = JSON.parse(totalInfo);
  238. // return obj.totalCount + ' / ' + obj.totalWeight;
  239. let quXiaongGen = 0;
  240. // 热装
  241. if (hotCharge) {
  242. const hotChargeObj = JSON.parse(hotCharge);
  243. quXiaongGen = quXiaongGen + (hotChargeObj.hotChargeTotalCount || 0);
  244. }
  245. // 堆垛
  246. if (stacking) {
  247. const stackingObj = JSON.parse(stacking);
  248. quXiaongGen = quXiaongGen + (stackingObj.stackingTotalCount || 0);
  249. }
  250. // 棒一或者高线
  251. if (directRolling) {
  252. const directRollingObj = JSON.parse(directRolling);
  253. quXiaongGen = quXiaongGen + (directRollingObj.directRollingTotalCount || 0);
  254. }
  255. if (hotSend) {
  256. const hotSendObj = JSON.parse(hotSend);
  257. quXiaongGen = quXiaongGen + (hotSendObj.hotSendTotalCount || 0);
  258. }
  259. return h(
  260. 'div',
  261. {
  262. style: { cursor: 'pointer' },
  263. onClick: () => {
  264. if (!record.heatNo) return;
  265. openCompensateModal && openCompensateModal(record);
  266. },
  267. },
  268. // renderNum(
  269. // h('span', {}, [h('span', {}, obj.totalCount), h('span', { style: { color: '#999' } }, '/' + (obj.totalCount - quXiaongGen))]),
  270. // obj.totalWeight
  271. // )
  272. renderNum(
  273. h('span', {}, [h('span', {}, obj.totalCount)]),
  274. obj.totalWeight
  275. )
  276. );
  277. }
  278. } catch (error) {}
  279. return '';
  280. },
  281. customHeaderCell: (columns) => {
  282. return {
  283. style: {
  284. cursor: 'pointer',
  285. },
  286. onClick: () => {
  287. console.log('columns', columns);
  288. openCompensateModal && openCompensateModal(columns);
  289. },
  290. };
  291. },
  292. },
  293. ];
  294. };