Commit d631f64ffd58d871c5f4eba9810336d0969445c3
1 parent
e2a4aa75
新增页面
Showing
118 changed files
with
82996 additions
and
20 deletions
Too many changes to show.
To preserve performance only 29 of 118 files are displayed.
.umirc.ts
| ... | ... | @@ -9,11 +9,40 @@ export default defineConfig({ |
| 9 | 9 | component: '@/routes/indexPage', |
| 10 | 10 | routes: [ |
| 11 | 11 | { path: '/indexPage/CommonList' }, |
| 12 | + { path: '/indexPage/CommonListA' }, | |
| 12 | 13 | { path: '/indexPage/CommonNewBill' }, |
| 13 | 14 | { path: '/indexPage/CommonBill' }, |
| 14 | 15 | { path: '/indexPage/CommonListEdit' }, |
| 15 | 16 | { path: '/indexPage/CommonClassify' }, |
| 16 | - { path: '/indexPage/eleknifemould'} | |
| 17 | + { path: '/indexPage/eleknifemould'}, | |
| 18 | + { path: '/indexPage/elecustomer'}, | |
| 19 | + { path: '/indexPage/CommonListTab'}, | |
| 20 | + { path: '/indexPage/commonColumnList'}, | |
| 21 | + { path: '/indexPage/commonListTree'}, | |
| 22 | + { path: '/indexPage/commonListLeft'}, | |
| 23 | + { path: '/indexPage/commonGatte'}, | |
| 24 | + { path: '/indexPage/materialRequirementsPlanning'}, | |
| 25 | + { path: '/indexPage/eleteststand'}, | |
| 26 | + { path: '/indexPage/eleemployee'}, | |
| 27 | + { path: '/indexPage/elematerials'}, | |
| 28 | + { path: '/indexPage/eleproduct'}, | |
| 29 | + { path: '/indexPage/syssystemsettings'}, | |
| 30 | + { path: '/indexPage/elesupply'}, | |
| 31 | + { path: '/indexPage/eleprocess'}, | |
| 32 | + { path: '/indexPage/elecheckmodel'}, | |
| 33 | + { path: '/indexPage/sischeckphase'}, | |
| 34 | + { path: '/indexPage/sftlogininfo'}, | |
| 35 | + { path: '/indexPage/siscommonstyle'}, | |
| 36 | + { path: '/indexPage/sisproductclassify'}, | |
| 37 | + { path: '/indexPage/commonCheckBill'}, | |
| 38 | + { path: '/indexPage/workOrderNew'}, | |
| 39 | + { path: '/indexPage/workOrderPack'}, | |
| 40 | + { path: '/indexPage/workOrderPackTableTree'}, | |
| 41 | + { path: '/indexPage/workOrderResearchTableTree'}, | |
| 42 | + { path: '/indexPage/processCard'}, | |
| 43 | + { path: '/indexPage/processCardPack'}, | |
| 44 | + { path: '/indexPage/processCardPackTableTree'}, | |
| 45 | + { path: '/indexPage/processCardPackTableTreeNew'}, | |
| 17 | 46 | ], |
| 18 | 47 | }, |
| 19 | 48 | ], | ... | ... |
package.json
| ... | ... | @@ -11,22 +11,27 @@ |
| 11 | 11 | "dependencies": { |
| 12 | 12 | "@ant-design/compatible": "^1.1.2", |
| 13 | 13 | "@ant-design/icons": "^5.6.1", |
| 14 | + "@antv/g2": "^5.2.12", | |
| 14 | 15 | "@js-preview/docx": "^1.6.4", |
| 15 | 16 | "@js-preview/excel": "^1.7.14", |
| 16 | 17 | "antd": "^5.24.3", |
| 17 | 18 | "antd-mobile": "2.3.4", |
| 18 | 19 | "antd-v4": "npm:antd@4.24.16", |
| 19 | 20 | "braft-editor": "^2.3.9", |
| 21 | + "dhtmlx-gantt": "^9.0.6", | |
| 20 | 22 | "immutability-helper": "^3.1.1", |
| 21 | 23 | "lodash": "^4.17.21", |
| 24 | + "lodash-decorators": "^6.0.1", | |
| 22 | 25 | "moment": "^2.30.1", |
| 23 | 26 | "react-dnd": "^14.0.5", |
| 24 | 27 | "react-dnd-html5-backend": "^14.1.0", |
| 28 | + "react-flow-renderer": "^10.3.17", | |
| 25 | 29 | "react-grid-layout": "^1.5.1", |
| 26 | 30 | "react-highlight-words": "^0.21.0", |
| 27 | 31 | "react-pdf": "^9.2.1", |
| 28 | 32 | "react-resizable": "^3.0.5", |
| 29 | 33 | "react-sortable-hoc": "^2.0.0", |
| 34 | + "react-to-print": "^3.0.5", | |
| 30 | 35 | "umi": "^4.4.6" |
| 31 | 36 | }, |
| 32 | 37 | "devDependencies": { | ... | ... |
src/components/Charts/Bar/index.js
0 → 100644
| 1 | +import React, { PureComponent } from 'react'; | |
| 2 | +import { Chart } from '@antv/g2'; | |
| 3 | +import Debounce from 'lodash-decorators/debounce'; | |
| 4 | +import Bind from 'lodash-decorators/bind'; | |
| 5 | +import equal from '../equal'; | |
| 6 | + | |
| 7 | +class Bar extends PureComponent { | |
| 8 | + componentDidMount() { | |
| 9 | + this.renderChart(this.props.data); | |
| 10 | + window.addEventListener('resize', this.resize); | |
| 11 | + } | |
| 12 | + | |
| 13 | + componentWillReceiveProps(nextProps) { | |
| 14 | + if (!equal(this.props, nextProps)) { | |
| 15 | + this.renderChart(nextProps.data); | |
| 16 | + } | |
| 17 | + } | |
| 18 | + | |
| 19 | + componentWillUnmount() { | |
| 20 | + window.removeEventListener('resize', this.resize); | |
| 21 | + if (this.chart) { | |
| 22 | + this.chart.destroy(); | |
| 23 | + } | |
| 24 | + this.resize.cancel(); | |
| 25 | + } | |
| 26 | + | |
| 27 | + @Bind() | |
| 28 | + @Debounce(200) | |
| 29 | + resize() { | |
| 30 | + if (!this.node) { | |
| 31 | + return; | |
| 32 | + } | |
| 33 | + this.renderChart([]); | |
| 34 | + } | |
| 35 | + | |
| 36 | + handleRef = (n) => { | |
| 37 | + this.node = n; | |
| 38 | + }; | |
| 39 | + | |
| 40 | + renderChart(data) { | |
| 41 | + if (this.node.offsetWidth === 0) { | |
| 42 | + return; | |
| 43 | + } | |
| 44 | + const { | |
| 45 | + xUnit = '', yUnit = '', height, style, | |
| 46 | + } = this.props; | |
| 47 | + const textMyStyle = {}; | |
| 48 | + if (style !== undefined) { | |
| 49 | + if (style.color !== undefined) { | |
| 50 | + textMyStyle.fill = style.color; | |
| 51 | + } | |
| 52 | + } | |
| 53 | + if (!data || (data && data.length < 1)) return; | |
| 54 | + // clean | |
| 55 | + if (this.chart) { | |
| 56 | + this.chart.destroy(); | |
| 57 | + } | |
| 58 | + this.node.innerHTML = ''; | |
| 59 | + const chart = new Chart({ | |
| 60 | + container: this.node, | |
| 61 | + autoFit: true, /* 图标自适应 */ | |
| 62 | + height, | |
| 63 | + padding: 'auto', | |
| 64 | + }); | |
| 65 | + chart.axis('x', { | |
| 66 | + label: { | |
| 67 | + formatter: (val) => { | |
| 68 | + return `${val}${xUnit}`; | |
| 69 | + }, | |
| 70 | + textStyle: textMyStyle, | |
| 71 | + }, | |
| 72 | + }); | |
| 73 | + chart.axis('y', { | |
| 74 | + label: { | |
| 75 | + formatter: (val) => { | |
| 76 | + return `${val}${yUnit}`; | |
| 77 | + }, | |
| 78 | + textStyle: textMyStyle, | |
| 79 | + }, | |
| 80 | + }); | |
| 81 | + chart.data(data); | |
| 82 | + chart.tooltip({ | |
| 83 | + showTitle: false, | |
| 84 | + }); | |
| 85 | + chart.coord().transpose(); | |
| 86 | + chart.interval().position('y*x').tooltip('y*x', (name, value) => { | |
| 87 | + return { | |
| 88 | + name: `${name}${xUnit}`, | |
| 89 | + value: `${value}${yUnit}`, | |
| 90 | + }; | |
| 91 | + }); | |
| 92 | + chart.render(); | |
| 93 | + this.chart = chart; | |
| 94 | + } | |
| 95 | + | |
| 96 | + render() { | |
| 97 | + return ( | |
| 98 | + <div ref={this.handleRef} /> | |
| 99 | + ); | |
| 100 | + } | |
| 101 | +} | |
| 102 | + | |
| 103 | +export default Bar; | ... | ... |
src/components/Charts/BrokenLine/index.js
0 → 100644
| 1 | +/* eslint-disable no-undef */ | |
| 2 | +import React, { PureComponent } from 'react'; | |
| 3 | +import { Chart } from '@antv/g2'; | |
| 4 | +import Debounce from 'lodash-decorators/debounce'; | |
| 5 | +import Bind from 'lodash-decorators/bind'; | |
| 6 | +import equal from '../equal'; | |
| 7 | + | |
| 8 | +class BrokenLine extends PureComponent { | |
| 9 | + componentDidMount() { | |
| 10 | + this.renderChart(this.props.data); | |
| 11 | + window.addEventListener('resize', this.resize); | |
| 12 | + } | |
| 13 | + | |
| 14 | + componentWillReceiveProps(nextProps) { | |
| 15 | + if (!equal(this.props, nextProps)) { | |
| 16 | + this.renderChart(nextProps.data); | |
| 17 | + } | |
| 18 | + } | |
| 19 | + | |
| 20 | + componentWillUnmount() { | |
| 21 | + window.removeEventListener('resize', this.resize); | |
| 22 | + if (this.chart) { | |
| 23 | + this.chart.destroy(); | |
| 24 | + } | |
| 25 | + this.resize.cancel(); | |
| 26 | + } | |
| 27 | + | |
| 28 | + @Bind() | |
| 29 | + @Debounce(200) | |
| 30 | + resize() { | |
| 31 | + if (!this.node) { | |
| 32 | + return; | |
| 33 | + } | |
| 34 | + this.renderChart([]); | |
| 35 | + } | |
| 36 | + | |
| 37 | + handleRef = (n) => { | |
| 38 | + this.node = n; | |
| 39 | + }; | |
| 40 | + | |
| 41 | + renderChart(data) { | |
| 42 | + if (this.node.offsetWidth === 0) { | |
| 43 | + return; | |
| 44 | + } | |
| 45 | + const { | |
| 46 | + xUnit = '', yUnit = '', height, style, | |
| 47 | + } = this.props; | |
| 48 | + const textMyStyle = {}; | |
| 49 | + if (style !== undefined) { | |
| 50 | + if (style.color !== undefined) { | |
| 51 | + textMyStyle.fill = style.color; | |
| 52 | + } | |
| 53 | + } | |
| 54 | + if (!data || (data && data.length < 1)) return; | |
| 55 | + if (this.chart) { | |
| 56 | + this.chart.destroy(); | |
| 57 | + } | |
| 58 | + this.node.innerHTML = ''; | |
| 59 | + const chart = new Chart({ | |
| 60 | + container: this.node, | |
| 61 | + autoFit: true, /* 图标自适应 */ | |
| 62 | + height, | |
| 63 | + padding: 'auto', | |
| 64 | + }); | |
| 65 | + chart.axis('x', { | |
| 66 | + label: { | |
| 67 | + formatter: (val) => { | |
| 68 | + return `${val}${xUnit}`; | |
| 69 | + }, | |
| 70 | + textStyle: textMyStyle, | |
| 71 | + }, | |
| 72 | + }); | |
| 73 | + chart.axis('y', { | |
| 74 | + label: { | |
| 75 | + formatter: (val) => { | |
| 76 | + return `${val}${yUnit}`; | |
| 77 | + }, | |
| 78 | + textStyle: textMyStyle, | |
| 79 | + }, | |
| 80 | + }); | |
| 81 | + chart.option('slider', { | |
| 82 | + start: 0.9, | |
| 83 | + end: 1, | |
| 84 | + trendCfg: { | |
| 85 | + isArea: false, | |
| 86 | + }, | |
| 87 | + }); | |
| 88 | + chart.data(data); | |
| 89 | + chart.tooltip({ | |
| 90 | + showCrosshairs: true, | |
| 91 | + shared: true, | |
| 92 | + }); | |
| 93 | + chart.line().position('x*y').color('type').tooltip('x*y*type', (name, value, type) => { | |
| 94 | + return { | |
| 95 | + title: `${name}${xUnit}`, | |
| 96 | + name: type, | |
| 97 | + value: `${value}${yUnit}`, | |
| 98 | + }; | |
| 99 | + }); | |
| 100 | + chart | |
| 101 | + .point() | |
| 102 | + .position('x*y') | |
| 103 | + .color('type') | |
| 104 | + .size(4) | |
| 105 | + .shape('circle') | |
| 106 | + .style({ stroke: '#fff', lineWidth: 1 }); | |
| 107 | + chart.render(); | |
| 108 | + this.chart = chart; | |
| 109 | + } | |
| 110 | + | |
| 111 | + render() { | |
| 112 | + const { height } = this.props; | |
| 113 | + return ( | |
| 114 | + <div style={{ height }}> | |
| 115 | + <div ref={this.handleRef} /> | |
| 116 | + </div> | |
| 117 | + ); | |
| 118 | + } | |
| 119 | +} | |
| 120 | + | |
| 121 | +export default BrokenLine; | ... | ... |
src/components/Charts/ColorBlock/index.js
0 → 100644
| 1 | +/* eslint-disable no-undef */ | |
| 2 | +import React, { PureComponent } from 'react'; | |
| 3 | + | |
| 4 | +// import G2 from '@antv/g2/build/g2'; | |
| 5 | +import { Chart } from '@antv/g2'; | |
| 6 | +import Debounce from 'lodash-decorators/debounce'; | |
| 7 | +import Bind from 'lodash-decorators/bind'; | |
| 8 | +import equal from '../equal'; | |
| 9 | + | |
| 10 | +class ColorBlock extends PureComponent { | |
| 11 | + componentDidMount() { | |
| 12 | + this.renderChart(this.props.data); | |
| 13 | + window.addEventListener('resize', this.resize); | |
| 14 | + } | |
| 15 | + | |
| 16 | + componentWillReceiveProps(nextProps) { | |
| 17 | + if (!equal(this.props, nextProps)) { | |
| 18 | + this.renderChart(nextProps.data); | |
| 19 | + } | |
| 20 | + } | |
| 21 | + | |
| 22 | + componentWillUnmount() { | |
| 23 | + window.removeEventListener('resize', this.resize); | |
| 24 | + if (this.chart) { | |
| 25 | + this.chart.destroy(); | |
| 26 | + } | |
| 27 | + this.resize.cancel(); | |
| 28 | + } | |
| 29 | + | |
| 30 | + @Bind() | |
| 31 | + @Debounce(200) | |
| 32 | + resize() { | |
| 33 | + if (!this.node) { | |
| 34 | + return; | |
| 35 | + } | |
| 36 | + this.renderChart([]); | |
| 37 | + } | |
| 38 | + | |
| 39 | + handleRef = (n) => { | |
| 40 | + this.node = n; | |
| 41 | + }; | |
| 42 | + | |
| 43 | + renderChart(data) { | |
| 44 | + if (this.node.offsetWidth === 0) { | |
| 45 | + return; | |
| 46 | + } | |
| 47 | + if (this.chart) { | |
| 48 | + this.chart.destroy(); | |
| 49 | + } | |
| 50 | + | |
| 51 | + this.node.innerHTML = ''; | |
| 52 | + const { day, sMachines, height } = this.props; | |
| 53 | + | |
| 54 | + const source = data.map((arr) => { | |
| 55 | + return { | |
| 56 | + xValue: arr[0], | |
| 57 | + yValue: arr[1], | |
| 58 | + value: arr[2], | |
| 59 | + }; | |
| 60 | + }); | |
| 61 | + | |
| 62 | + const chart = new Chart({ | |
| 63 | + container: this.node, | |
| 64 | + autoFit: true, | |
| 65 | + height, | |
| 66 | + }); | |
| 67 | + | |
| 68 | + chart.data(source); | |
| 69 | + | |
| 70 | + chart.scale('xValue', { | |
| 71 | + type: 'cat', | |
| 72 | + values: day, | |
| 73 | + }); | |
| 74 | + chart.scale('yValue', { | |
| 75 | + type: 'cat', | |
| 76 | + values: sMachines, | |
| 77 | + }); | |
| 78 | + chart.scale('value', { | |
| 79 | + nice: true, | |
| 80 | + }); | |
| 81 | + | |
| 82 | + chart.axis('xValue', { | |
| 83 | + tickLine: null, | |
| 84 | + grid: { | |
| 85 | + alignTick: false, | |
| 86 | + line: { | |
| 87 | + style: { | |
| 88 | + lineWidth: 1, | |
| 89 | + lineDash: null, | |
| 90 | + stroke: '#f0f0f0', | |
| 91 | + }, | |
| 92 | + }, | |
| 93 | + }, | |
| 94 | + }); | |
| 95 | + | |
| 96 | + chart.axis('yValue', { | |
| 97 | + title: null, | |
| 98 | + grid: { | |
| 99 | + alignTick: false, | |
| 100 | + line: { | |
| 101 | + style: { | |
| 102 | + lineWidth: 1, | |
| 103 | + lineDash: null, | |
| 104 | + stroke: '#f0f0f0', | |
| 105 | + }, | |
| 106 | + }, | |
| 107 | + }, | |
| 108 | + }); | |
| 109 | + | |
| 110 | + chart.tooltip({ | |
| 111 | + showMarkers: false, | |
| 112 | + }); | |
| 113 | + | |
| 114 | + chart | |
| 115 | + .polygon() | |
| 116 | + .position('xValue*yValue') | |
| 117 | + .color('value', '#f6ffed-#389e0d-#135200') | |
| 118 | + .label('value', { | |
| 119 | + offset: -2, | |
| 120 | + style: { | |
| 121 | + fill: '#fff', | |
| 122 | + shadowBlur: 2, | |
| 123 | + shadowColor: 'rgba(0, 0, 0, .45)', | |
| 124 | + }, | |
| 125 | + }) | |
| 126 | + .style({ | |
| 127 | + lineWidth: 1, | |
| 128 | + stroke: '#fff', | |
| 129 | + }); | |
| 130 | + | |
| 131 | + chart.interaction('element-active'); | |
| 132 | + | |
| 133 | + chart.render(); | |
| 134 | + this.chart = chart; | |
| 135 | + } | |
| 136 | + | |
| 137 | + render() { | |
| 138 | + const { height } = this.props; | |
| 139 | + return ( | |
| 140 | + <div style={{ height }}> | |
| 141 | + <div ref={this.handleRef} /> | |
| 142 | + </div> | |
| 143 | + ); | |
| 144 | + } | |
| 145 | +} | |
| 146 | + | |
| 147 | +export default ColorBlock; | ... | ... |
src/components/Charts/Columnar/index.js
0 → 100644
| 1 | +/* eslint-disable no-undef */ | |
| 2 | +import React, { PureComponent } from 'react'; | |
| 3 | +import { Chart } from '@antv/g2'; | |
| 4 | +import Debounce from 'lodash-decorators/debounce'; | |
| 5 | +import Bind from 'lodash-decorators/bind'; | |
| 6 | +import equal from '../equal'; | |
| 7 | + | |
| 8 | +class Columnar extends PureComponent { | |
| 9 | + componentDidMount() { | |
| 10 | + this.renderChart(this.props.data); | |
| 11 | + window.addEventListener('resize', this.resize); | |
| 12 | + } | |
| 13 | + | |
| 14 | + componentWillReceiveProps(nextProps) { | |
| 15 | + if (!equal(this.props, nextProps)) { | |
| 16 | + this.renderChart(nextProps.data); | |
| 17 | + } | |
| 18 | + } | |
| 19 | + | |
| 20 | + componentWillUnmount() { | |
| 21 | + window.removeEventListener('resize', this.resize); | |
| 22 | + if (this.chart) { | |
| 23 | + this.chart.destroy(); | |
| 24 | + } | |
| 25 | + this.resize.cancel(); | |
| 26 | + } | |
| 27 | + | |
| 28 | + @Bind() | |
| 29 | + @Debounce(200) | |
| 30 | + resize() { | |
| 31 | + if (!this.node) { | |
| 32 | + return; | |
| 33 | + } | |
| 34 | + this.renderChart([]); | |
| 35 | + } | |
| 36 | + | |
| 37 | + handleRef = (n) => { | |
| 38 | + this.node = n; | |
| 39 | + }; | |
| 40 | + | |
| 41 | + renderChart(data) { | |
| 42 | + const { | |
| 43 | + xUnit = '', yUnit = '', height, style, | |
| 44 | + } = this.props; | |
| 45 | + const textMyStyle = {}; | |
| 46 | + if (style !== undefined) { | |
| 47 | + if (style.color !== undefined) { | |
| 48 | + textMyStyle.fill = style.color; | |
| 49 | + } | |
| 50 | + } | |
| 51 | + if (!data || (data && data.length < 1)) return; | |
| 52 | + // clean | |
| 53 | + if (this.chart) { | |
| 54 | + this.chart.destroy(); | |
| 55 | + } | |
| 56 | + this.node.innerHTML = ''; | |
| 57 | + const chart = new Chart({ | |
| 58 | + container: this.node, | |
| 59 | + autoFit: true, /* 图标自适应 */ | |
| 60 | + height, | |
| 61 | + padding: 'auto', | |
| 62 | + }); | |
| 63 | + chart.axis('x', { | |
| 64 | + label: { | |
| 65 | + formatter: (val) => { | |
| 66 | + return `${val}${xUnit}`; | |
| 67 | + }, | |
| 68 | + textStyle: textMyStyle, | |
| 69 | + }, | |
| 70 | + }); | |
| 71 | + chart.axis('y', { | |
| 72 | + label: { | |
| 73 | + formatter: (val) => { | |
| 74 | + return `${val}${yUnit}`; | |
| 75 | + }, | |
| 76 | + textStyle: textMyStyle, | |
| 77 | + }, | |
| 78 | + }); | |
| 79 | + chart.data(data); | |
| 80 | + chart.tooltip({ | |
| 81 | + showTitle: false, | |
| 82 | + }); | |
| 83 | + chart.interval().position('x*y').tooltip('x*y', (name, value) => { | |
| 84 | + return { | |
| 85 | + name: `${name}${xUnit}`, | |
| 86 | + value: `${value}${yUnit}`, | |
| 87 | + }; | |
| 88 | + }); | |
| 89 | + chart.render(); | |
| 90 | + this.chart = chart; | |
| 91 | + } | |
| 92 | + | |
| 93 | + render() { | |
| 94 | + const { height } = this.props; | |
| 95 | + return ( | |
| 96 | + <div style={{ height }}> | |
| 97 | + <div ref={this.handleRef} /> | |
| 98 | + </div> | |
| 99 | + ); | |
| 100 | + } | |
| 101 | +} | |
| 102 | + | |
| 103 | +export default Columnar; | ... | ... |
src/components/Charts/ColumnarGroup/index.js
0 → 100644
| 1 | +/* eslint-disable no-undef */ | |
| 2 | +import React, { PureComponent } from 'react'; | |
| 3 | +import { Chart } from '@antv/g2'; | |
| 4 | +import Debounce from 'lodash-decorators/debounce'; | |
| 5 | +import Bind from 'lodash-decorators/bind'; | |
| 6 | +import equal from '../equal'; | |
| 7 | + | |
| 8 | +class ColumnarGroup extends PureComponent { | |
| 9 | + componentDidMount() { | |
| 10 | + this.renderChart(this.props.data); | |
| 11 | + window.addEventListener('resize', this.resize); | |
| 12 | + } | |
| 13 | + | |
| 14 | + componentWillReceiveProps(nextProps) { | |
| 15 | + if (!equal(this.props, nextProps)) { | |
| 16 | + this.renderChart(nextProps.data); | |
| 17 | + } | |
| 18 | + } | |
| 19 | + | |
| 20 | + componentWillUnmount() { | |
| 21 | + window.removeEventListener('resize', this.resize); | |
| 22 | + if (this.chart) { | |
| 23 | + this.chart.destroy(); | |
| 24 | + } | |
| 25 | + this.resize.cancel(); | |
| 26 | + } | |
| 27 | + | |
| 28 | + @Bind() | |
| 29 | + @Debounce(200) | |
| 30 | + resize() { | |
| 31 | + if (!this.node) { | |
| 32 | + return; | |
| 33 | + } | |
| 34 | + this.renderChart([]); | |
| 35 | + } | |
| 36 | + | |
| 37 | + handleRef = (n) => { | |
| 38 | + this.node = n; | |
| 39 | + }; | |
| 40 | + | |
| 41 | + renderChart(data) { | |
| 42 | + const { xUnit = '', yUnit = '', height } = this.props; | |
| 43 | + if (!data || (data && data.length < 1)) return; | |
| 44 | + // clean | |
| 45 | + if (this.chart) { | |
| 46 | + this.chart.destroy(); | |
| 47 | + } | |
| 48 | + this.node.innerHTML = ''; | |
| 49 | + const chart = new Chart({ | |
| 50 | + container: this.node, | |
| 51 | + autoFit: true, /* 图标自适应s */ | |
| 52 | + height, | |
| 53 | + padding: 'auto', | |
| 54 | + }); | |
| 55 | + chart.axis('x', { | |
| 56 | + label: { | |
| 57 | + formatter: (val) => { | |
| 58 | + return `${val}${xUnit}`; | |
| 59 | + }, | |
| 60 | + }, | |
| 61 | + }); | |
| 62 | + chart.axis('y', { | |
| 63 | + label: { | |
| 64 | + formatter: (val) => { | |
| 65 | + return `${val}${yUnit}`; | |
| 66 | + }, | |
| 67 | + }, | |
| 68 | + }); | |
| 69 | + chart.data(data); | |
| 70 | + chart | |
| 71 | + .interval() | |
| 72 | + .position('x*y') | |
| 73 | + .color('type') | |
| 74 | + .adjust([{ | |
| 75 | + type: 'dodge', | |
| 76 | + marginRatio: 1 / 32, | |
| 77 | + }]) | |
| 78 | + .tooltip('x*y*type', (name, value, type) => { | |
| 79 | + return { | |
| 80 | + title: `${name}${xUnit}`, | |
| 81 | + name: type, | |
| 82 | + value: `${value}${yUnit}`, | |
| 83 | + }; | |
| 84 | + }); | |
| 85 | + chart.render(); | |
| 86 | + this.chart = chart; | |
| 87 | + } | |
| 88 | + | |
| 89 | + render() { | |
| 90 | + return ( | |
| 91 | + <div ref={this.handleRef} /> | |
| 92 | + ); | |
| 93 | + } | |
| 94 | +} | |
| 95 | + | |
| 96 | +export default ColumnarGroup; | ... | ... |
src/components/Charts/ColumnarStack/index.js
0 → 100644
| 1 | +import React, { PureComponent } from 'react'; | |
| 2 | +import { Chart } from '@antv/g2'; | |
| 3 | +import DataSet from '@antv/data-set'; | |
| 4 | +import Debounce from 'lodash-decorators/debounce'; | |
| 5 | +import Bind from 'lodash-decorators/bind'; | |
| 6 | +import equal from '../equal'; | |
| 7 | + | |
| 8 | +class ColumnarStack extends PureComponent { | |
| 9 | + componentDidMount() { | |
| 10 | + this.renderChart(this.props.data); | |
| 11 | + window.addEventListener('resize', this.resize); | |
| 12 | + } | |
| 13 | + | |
| 14 | + componentWillReceiveProps(nextProps) { | |
| 15 | + if (!equal(this.props, nextProps)) { | |
| 16 | + this.renderChart(nextProps.data); | |
| 17 | + } | |
| 18 | + } | |
| 19 | + | |
| 20 | + componentWillUnmount() { | |
| 21 | + window.removeEventListener('resize', this.resize); | |
| 22 | + if (this.chart) { | |
| 23 | + this.chart.destroy(); | |
| 24 | + } | |
| 25 | + this.resize.cancel(); | |
| 26 | + } | |
| 27 | + | |
| 28 | + @Bind() | |
| 29 | + @Debounce(200) | |
| 30 | + resize() { | |
| 31 | + if (!this.node) { | |
| 32 | + return; | |
| 33 | + } | |
| 34 | + this.renderChart([]); | |
| 35 | + } | |
| 36 | + | |
| 37 | + handleRef = (n) => { | |
| 38 | + this.node = n; | |
| 39 | + }; | |
| 40 | + | |
| 41 | + renderChart(data) { | |
| 42 | + const { xUnit = '', yUnit = '', height } = this.props; | |
| 43 | + if (!data || (data && data.length < 1)) return; | |
| 44 | + // clean | |
| 45 | + if (this.chart) { | |
| 46 | + this.chart.destroy(); | |
| 47 | + } | |
| 48 | + this.node.innerHTML = ''; | |
| 49 | + const chart = new Chart({ | |
| 50 | + container: this.node, | |
| 51 | + autoFit: true, /* 图标自适应 */ | |
| 52 | + height, | |
| 53 | + padding: 'auto', | |
| 54 | + }); | |
| 55 | + // 计算每个柱子的占比 | |
| 56 | + const ds = new DataSet(); | |
| 57 | + const dv = ds.createView().source(data).transform({ | |
| 58 | + type: 'percent', | |
| 59 | + field: 'y', // 统计销量 | |
| 60 | + dimension: 'type', // 每年的占比 | |
| 61 | + groupBy: ['x'], // 以不同产品类别为分组 | |
| 62 | + as: 'percent', | |
| 63 | + }); | |
| 64 | + chart.data(dv.rows, { | |
| 65 | + percent: { | |
| 66 | + min: 0, | |
| 67 | + formatter: (val) => { | |
| 68 | + return `${(val * 100).toFixed(2)}${yUnit}`; | |
| 69 | + }, | |
| 70 | + }, | |
| 71 | + }); | |
| 72 | + chart.axis('x', { | |
| 73 | + label: { | |
| 74 | + formatter: (val) => { | |
| 75 | + return `${val}${xUnit}`; | |
| 76 | + }, | |
| 77 | + }, | |
| 78 | + }); | |
| 79 | + chart.interval().adjust('stack').position('x*percent').color('type') | |
| 80 | + .tooltip('x*y*type', (name, value, type) => { | |
| 81 | + return { | |
| 82 | + title: `${name}${xUnit}`, | |
| 83 | + name: type, | |
| 84 | + value: `${value}`, | |
| 85 | + }; | |
| 86 | + }); | |
| 87 | + chart.render(); | |
| 88 | + this.chart = chart; | |
| 89 | + } | |
| 90 | + | |
| 91 | + render() { | |
| 92 | + return ( | |
| 93 | + <div ref={this.handleRef} /> | |
| 94 | + ); | |
| 95 | + } | |
| 96 | +} | |
| 97 | + | |
| 98 | +export default ColumnarStack; | ... | ... |
src/components/Charts/EqualColumnarStack/index.js
0 → 100644
| 1 | +import React, { PureComponent } from 'react'; | |
| 2 | +import { Chart } from '@antv/g2'; | |
| 3 | +import DataSet from '@antv/data-set'; | |
| 4 | +import Debounce from 'lodash-decorators/debounce'; | |
| 5 | +import Bind from 'lodash-decorators/bind'; | |
| 6 | +import equal from '../equal'; | |
| 7 | + | |
| 8 | +class EqualColumnarStack extends PureComponent { | |
| 9 | + componentDidMount() { | |
| 10 | + this.renderChart(this.props); | |
| 11 | + window.addEventListener('resize', this.resize); | |
| 12 | + } | |
| 13 | + | |
| 14 | + componentWillReceiveProps(nextProps) { | |
| 15 | + if (!equal(this.props, nextProps)) { | |
| 16 | + this.renderChart(nextProps); | |
| 17 | + } | |
| 18 | + } | |
| 19 | + | |
| 20 | + componentWillUnmount() { | |
| 21 | + window.removeEventListener('resize', this.resize); | |
| 22 | + if (this.chart) { | |
| 23 | + this.chart.destroy(); | |
| 24 | + } | |
| 25 | + this.resize.cancel(); | |
| 26 | + } | |
| 27 | + | |
| 28 | + @Bind() | |
| 29 | + @Debounce(200) | |
| 30 | + resize() { | |
| 31 | + if (!this.node) { | |
| 32 | + return; | |
| 33 | + } | |
| 34 | + this.renderChart(this.props); | |
| 35 | + } | |
| 36 | + | |
| 37 | + handleRef = (n) => { | |
| 38 | + this.node = n; | |
| 39 | + }; | |
| 40 | + | |
| 41 | + renderChart(props) { | |
| 42 | + const { | |
| 43 | + fields, yName: value, xName: currkey, onChartClick, chartName, height, | |
| 44 | + } = props; | |
| 45 | + const ds = new DataSet(); | |
| 46 | + const dv = ds.createView().source(props.data); | |
| 47 | + dv.transform({ | |
| 48 | + type: 'fold', | |
| 49 | + fields, | |
| 50 | + key: currkey, | |
| 51 | + value, | |
| 52 | + }); | |
| 53 | + if (this.chart) { | |
| 54 | + this.chart.destroy(); | |
| 55 | + } | |
| 56 | + this.node.innerHTML = ''; | |
| 57 | + const chart = new Chart({ | |
| 58 | + container: this.node, | |
| 59 | + autoFit: true, | |
| 60 | + height, | |
| 61 | + }); | |
| 62 | + chart.data(dv.rows); | |
| 63 | + chart.axis(currkey, { | |
| 64 | + label: { | |
| 65 | + autoHide: false, // 关闭label默认的自动隐藏 | |
| 66 | + autoEllipsis: false, // 关闭lable自动省略 | |
| 67 | + autoRotate: true, // 关闭默认的label超长自动旋转 默认时右下45度旋转 | |
| 68 | + formatter: (val) => { | |
| 69 | + return `${val}`; | |
| 70 | + }, | |
| 71 | + }, | |
| 72 | + }); | |
| 73 | + chart.interval().adjust('stack') | |
| 74 | + .position(`${currkey}*${value}`) | |
| 75 | + .color('name'); | |
| 76 | + /* .active(true) | |
| 77 | + .tooltip(false); */ | |
| 78 | + chart.on('interval:dblclick', (ev) => { | |
| 79 | + const cdata = ev.data; | |
| 80 | + if (cdata) { | |
| 81 | + const { data } = cdata; | |
| 82 | + onChartClick(chartName, data); | |
| 83 | + } | |
| 84 | + }); | |
| 85 | + chart.render(); | |
| 86 | + this.chart = chart; | |
| 87 | + } | |
| 88 | + render() { | |
| 89 | + return ( | |
| 90 | + <div ref={this.handleRef} /> | |
| 91 | + ); | |
| 92 | + } | |
| 93 | +} | |
| 94 | + | |
| 95 | +export default EqualColumnarStack; | ... | ... |
src/components/Charts/Gantt/Gantt.css
0 → 100644
src/components/Charts/Gantt/MessageArea/Message.js
0 → 100644
| 1 | +import React, { Component } from 'react'; | |
| 2 | + | |
| 3 | +class MessageArea extends Component { | |
| 4 | + render() { | |
| 5 | + const messages = this.props.messages.map(({ message }) => { | |
| 6 | + return <li key={Math.random()}>{message}</li>; | |
| 7 | + }); | |
| 8 | + | |
| 9 | + return ( | |
| 10 | + <div className="message-area"> | |
| 11 | + <h3>Messages:</h3> | |
| 12 | + <ul> | |
| 13 | + {messages} | |
| 14 | + </ul> | |
| 15 | + </div> | |
| 16 | + ); | |
| 17 | + } | |
| 18 | +} | |
| 19 | + | |
| 20 | +MessageArea.defaultProps = { | |
| 21 | + messages: [], | |
| 22 | +}; | |
| 23 | + | |
| 24 | +export default MessageArea; | ... | ... |
src/components/Charts/Gantt/MessageArea/MessageArea.css
0 → 100644
| 1 | +.message-area { | |
| 2 | + background: #ebebeb; | |
| 3 | + height: 200px; | |
| 4 | + overflow: auto; | |
| 5 | + padding: 10px; | |
| 6 | + box-sizing:border-box; | |
| 7 | +} | |
| 8 | + | |
| 9 | +.message-area ul{ | |
| 10 | + margin: 0; | |
| 11 | + padding: 0; | |
| 12 | + list-style: none; | |
| 13 | +} | |
| 14 | + | |
| 15 | +.message-area li:before { | |
| 16 | + content: "\003e"; | |
| 17 | + padding-right: 10px; | |
| 18 | +} | ... | ... |
src/components/Charts/Gantt/MessageArea/index.js
0 → 100644
src/components/Charts/Gantt/index.js
0 → 100644
| 1 | +import React, { Component } from 'react'; | |
| 2 | +import { gantt } from 'dhtmlx-gantt'; | |
| 3 | +import { DoubleRightOutlined } from '@ant-design/icons'; | |
| 4 | +import 'dhtmlx-gantt/codebase/dhtmlxgantt.css'; | |
| 5 | +import './Gantt.css'; | |
| 6 | + | |
| 7 | +/* eslint-disable */ | |
| 8 | +class Gantt extends Component { | |
| 9 | + | |
| 10 | + state = { expanded: true }; | |
| 11 | + tableHeight = 60; | |
| 12 | + | |
| 13 | + componentDidMount() { | |
| 14 | + gantt.plugins({ | |
| 15 | + tooltip: true, // 鼠标划过任务是否显示明细 | |
| 16 | + // auto_scheduling: true,//根据任务之间的关系自动安排任务 | |
| 17 | + // multiselect: true, //为任务激活多任务选择 | |
| 18 | + }); | |
| 19 | + gantt.config.xml_date = '%Y-%m-%d %H:%i'; /* 时间格式 年月日 时分 */ | |
| 20 | + gantt.config.reorder_grid_columns = true; /* 左侧列可拖动 */ | |
| 21 | + gantt.config.grid_elastic_columns = true; | |
| 22 | + gantt.config.drag_mode = { ignore: 'ignore'}; | |
| 23 | + gantt.config.scale_height = this.tableHeight; | |
| 24 | + gantt.i18n.setLocale('cn'); | |
| 25 | + // gantt.config.readonly = true;// 只读模式的甘特图 | |
| 26 | + const { tasks } = this.props; | |
| 27 | + this.setTemplate(); | |
| 28 | + gantt.init(this.ganttContainer); | |
| 29 | + this.initGanttDataProcessor(); | |
| 30 | + gantt.parse(tasks); | |
| 31 | + } | |
| 32 | + | |
| 33 | + | |
| 34 | + shouldComponentUpdate(nextProps, nextState) { | |
| 35 | + // const { tasks } = nextProps; | |
| 36 | + // return tasks !== undefined; | |
| 37 | + return this.props.zoom !== nextProps.zoom || this.state.expanded !== nextState.expanded; | |
| 38 | + } | |
| 39 | + componentDidUpdate() { | |
| 40 | + gantt.clearAll(); | |
| 41 | + const { tasks } = this.props; | |
| 42 | + this.setTemplate(); | |
| 43 | + gantt.init(this.ganttContainer); | |
| 44 | + this.initGanttDataProcessor(); | |
| 45 | + gantt.parse(tasks); | |
| 46 | + } | |
| 47 | + componentWillUnmount() { | |
| 48 | + if (this.dataProcessor) { | |
| 49 | + this.dataProcessor.destructor(); | |
| 50 | + this.dataProcessor = null; | |
| 51 | + } | |
| 52 | + } | |
| 53 | + setZoom = (value) => { | |
| 54 | + const scale = value.scale !== undefined ? value.scale : 'Minutes'; | |
| 55 | + const step = value.step !== undefined ? value.step : 10; | |
| 56 | + switch (scale) { | |
| 57 | + case 'Minutes': | |
| 58 | + gantt.config.duration_unit = 'minute'; | |
| 59 | + gantt.config.scale_unit = 'day'; | |
| 60 | + gantt.config.date_scale = '%Y-%m-%d'; | |
| 61 | + gantt.setWorkTime({ hours: ['00:30-03:30'] }); | |
| 62 | + gantt.config.scale_height = 60; | |
| 63 | + gantt.config.min_column_width = 40; | |
| 64 | + gantt.config.subscales = [ | |
| 65 | + { unit: 'minute', step, date: '%H:%i' }, | |
| 66 | + ]; | |
| 67 | + break; | |
| 68 | + case 'Hours': | |
| 69 | + gantt.config.scale_unit = 'day'; | |
| 70 | + gantt.config.date_scale = '%M %d'; | |
| 71 | + | |
| 72 | + gantt.config.scale_height = 60; | |
| 73 | + gantt.config.min_column_width = 30; | |
| 74 | + gantt.config.subscales = [ | |
| 75 | + { unit: 'hour', step, date: '%H' }, | |
| 76 | + ]; | |
| 77 | + break; | |
| 78 | + case 'Days': | |
| 79 | + gantt.config.min_column_width = 70; | |
| 80 | + gantt.config.scale_unit = 'week'; | |
| 81 | + gantt.config.date_scale = '%Y-%m-%d'; | |
| 82 | + gantt.config.subscales = [ | |
| 83 | + { unit: 'day', step, date: '%M %d' }, | |
| 84 | + ]; | |
| 85 | + gantt.config.scale_height = 60; | |
| 86 | + break; | |
| 87 | + case 'Months': | |
| 88 | + gantt.config.min_column_width = 70; | |
| 89 | + gantt.config.scale_unit = 'month'; | |
| 90 | + gantt.config.date_scale = '%F'; | |
| 91 | + gantt.config.scale_height = 60; | |
| 92 | + gantt.config.subscales = [ | |
| 93 | + { unit: 'week', step, date: '#%W' }, | |
| 94 | + ]; | |
| 95 | + break; | |
| 96 | + default: | |
| 97 | + break; | |
| 98 | + } | |
| 99 | + } | |
| 100 | + initGanttDataProcessor =() => { | |
| 101 | + // eslint-disable-next-line prefer-destructuring | |
| 102 | + const onDataUpdated = this.props.onDataUpdated; | |
| 103 | + if (this.dataProcessor) { | |
| 104 | + this.dataProcessor.destructor(); | |
| 105 | + this.dataProcessor = null; | |
| 106 | + } | |
| 107 | + this.dataProcessor = gantt.createDataProcessor((type, action, item, id) => { | |
| 108 | + return new Promise((resolve) => { | |
| 109 | + if (onDataUpdated) { | |
| 110 | + onDataUpdated(type, action, item, id); | |
| 111 | + } | |
| 112 | + | |
| 113 | + // if onDataUpdated changes returns a permanent id of the created item, you can return it from here so dhtmlxGantt could apply it | |
| 114 | + // resolve({id: databaseId}); | |
| 115 | + return resolve(); | |
| 116 | + }); | |
| 117 | + }); | |
| 118 | + } | |
| 119 | + | |
| 120 | + setTemplate = () => { | |
| 121 | + const { tasks } = this.props; | |
| 122 | + if (Array.isArray(tasks?.columns)) { | |
| 123 | + gantt.config.columns = tasks?.columns; | |
| 124 | + } | |
| 125 | + gantt.config.show_grid = this.state.expanded; | |
| 126 | + gantt.templates.tooltip_text = function (start, end, task) { | |
| 127 | + return ( | |
| 128 | + '<b>标题:</b> ' + | |
| 129 | + task.text + | |
| 130 | + '<br/><span>开始:</span> ' + | |
| 131 | + gantt.templates.tooltip_date_format(start) + | |
| 132 | + '<br/><span>结束:</span> ' + | |
| 133 | + gantt.templates.tooltip_date_format(end) + | |
| 134 | + '<br/><span>进度:</span> ' + | |
| 135 | + Math.round(task.progress * 100) + | |
| 136 | + '%' | |
| 137 | + ); | |
| 138 | + }; | |
| 139 | + } | |
| 140 | + | |
| 141 | + render() { | |
| 142 | + const { zoom } = this.props; | |
| 143 | + this.setZoom(zoom); | |
| 144 | + return ( | |
| 145 | + <div style={{ position: 'relative', height: '100%' }}> | |
| 146 | + <DoubleRightOutlined | |
| 147 | + style={{ | |
| 148 | + position: 'absolute', | |
| 149 | + zIndex: 1, | |
| 150 | + top: this.state.expanded ? this.tableHeight / 2 : this.tableHeight / 4, | |
| 151 | + transform: 'translate(50%, -50%)', | |
| 152 | + opacity: 0.5, | |
| 153 | + }} | |
| 154 | + rotate={this.state.expanded ? 180 : 0} | |
| 155 | + onClick={() => { | |
| 156 | + this.setState({ expanded: !this.state.expanded }); | |
| 157 | + }} | |
| 158 | + /> | |
| 159 | + <div | |
| 160 | + ref={(input) => { this.ganttContainer = input; }} | |
| 161 | + style={{ width: '100%', height: '100%' }} | |
| 162 | + /> | |
| 163 | + </div> | |
| 164 | + ); | |
| 165 | + } | |
| 166 | +} | |
| 167 | +export default Gantt; | ... | ... |
src/components/Charts/Gauge/index.js
0 → 100644
| 1 | +import React, { PureComponent } from 'react'; | |
| 2 | +import G2 from '@antv/g2'; | |
| 3 | +import Bind from 'lodash-decorators/bind'; | |
| 4 | +import Debounce from 'lodash-decorators/debounce'; | |
| 5 | +import equal from '../equal'; | |
| 6 | + | |
| 7 | +const { Shape } = G2; | |
| 8 | + | |
| 9 | +const primaryColor = '#2F9CFF'; | |
| 10 | +const backgroundColor = '#F0F2F5'; | |
| 11 | + | |
| 12 | +/* eslint no-underscore-dangle: 0 */ | |
| 13 | +class Gauge extends PureComponent { | |
| 14 | + componentDidMount() { | |
| 15 | + setTimeout(() => { | |
| 16 | + this.renderChart(); | |
| 17 | + }, 10); | |
| 18 | + window.addEventListener('resize', this.resize); | |
| 19 | + } | |
| 20 | + | |
| 21 | + componentWillReceiveProps(nextProps) { | |
| 22 | + if (!equal(this.props, nextProps)) { | |
| 23 | + setTimeout(() => { | |
| 24 | + this.renderChart(nextProps); | |
| 25 | + }, 10); | |
| 26 | + } | |
| 27 | + } | |
| 28 | + | |
| 29 | + componentWillUnmount() { | |
| 30 | + window.removeEventListener('resize', this.resize); | |
| 31 | + // if (this.chart) { | |
| 32 | + // console.log('data', this.chart); | |
| 33 | + // this.chart.destroy(); | |
| 34 | + // } | |
| 35 | + this.resize.cancel(); | |
| 36 | + } | |
| 37 | + | |
| 38 | + @Bind() | |
| 39 | + @Debounce(200) | |
| 40 | + resize() { | |
| 41 | + if (!this.node) { | |
| 42 | + return; | |
| 43 | + } | |
| 44 | + this.renderChart([]); | |
| 45 | + } | |
| 46 | + | |
| 47 | + handleRef = (n) => { | |
| 48 | + this.node = n; | |
| 49 | + }; | |
| 50 | + | |
| 51 | + initChart(nextProps) { | |
| 52 | + const { xUnit, color = primaryColor } = nextProps || this.props; | |
| 53 | + | |
| 54 | + Shape.registShape('point', 'dashBoard', { | |
| 55 | + drawShape(cfg, group) { | |
| 56 | + const originPoint = cfg.points[0]; | |
| 57 | + const point = this.parsePoint({ x: originPoint.x, y: 0.4 }); | |
| 58 | + | |
| 59 | + const center = this.parsePoint({ | |
| 60 | + x: 0, | |
| 61 | + y: 0, | |
| 62 | + }); | |
| 63 | + | |
| 64 | + const shape = group.addShape('polygon', { | |
| 65 | + attrs: { | |
| 66 | + points: [ | |
| 67 | + [center.x, center.y], | |
| 68 | + [point.x + 8, point.y], | |
| 69 | + [point.x + 8, point.y - 2], | |
| 70 | + [center.x, center.y - 2], | |
| 71 | + ], | |
| 72 | + radius: 2, | |
| 73 | + lineWidth: 2, | |
| 74 | + arrow: false, | |
| 75 | + fill: color, | |
| 76 | + }, | |
| 77 | + }); | |
| 78 | + | |
| 79 | + group.addShape('Marker', { | |
| 80 | + attrs: { | |
| 81 | + symbol: 'circle', | |
| 82 | + lineWidth: 2, | |
| 83 | + fill: color, | |
| 84 | + radius: 8, | |
| 85 | + x: center.x, | |
| 86 | + y: center.y, | |
| 87 | + }, | |
| 88 | + }); | |
| 89 | + group.addShape('Marker', { | |
| 90 | + attrs: { | |
| 91 | + symbol: 'circle', | |
| 92 | + lineWidth: 2, | |
| 93 | + fill: '#fff', | |
| 94 | + radius: 5, | |
| 95 | + x: center.x, | |
| 96 | + y: center.y, | |
| 97 | + }, | |
| 98 | + }); | |
| 99 | + | |
| 100 | + const { origin } = cfg; | |
| 101 | + group.addShape('text', { | |
| 102 | + attrs: { | |
| 103 | + x: center.x, | |
| 104 | + y: center.y + 80, | |
| 105 | + text: `${origin._origin.value}%`, | |
| 106 | + textAlign: 'center', | |
| 107 | + fontSize: 24, | |
| 108 | + fill: 'rgba(0, 0, 0, 0.85)', | |
| 109 | + }, | |
| 110 | + }); | |
| 111 | + group.addShape('text', { | |
| 112 | + attrs: { | |
| 113 | + x: center.x, | |
| 114 | + y: center.y + 45, | |
| 115 | + text: xUnit, | |
| 116 | + textAlign: 'center', | |
| 117 | + fontSize: 14, | |
| 118 | + fill: 'rgba(0, 0, 0, 0.43)', | |
| 119 | + }, | |
| 120 | + }); | |
| 121 | + | |
| 122 | + return shape; | |
| 123 | + }, | |
| 124 | + }); | |
| 125 | + } | |
| 126 | + | |
| 127 | + renderChart(nextProps) { | |
| 128 | + if (this.node.offsetWidth === 0) { | |
| 129 | + return; | |
| 130 | + } | |
| 131 | + const { | |
| 132 | + height, color = primaryColor, bgColor = backgroundColor, xUnit, | |
| 133 | + } = nextProps || this.props; | |
| 134 | + const data = [{ name: xUnit, value: this.props.data }]; | |
| 135 | + | |
| 136 | + if (this.chart) { | |
| 137 | + this.chart.clear(); | |
| 138 | + } | |
| 139 | + if (this.chart) { | |
| 140 | + this.chart.destroy(); | |
| 141 | + } | |
| 142 | + if (this.node) { | |
| 143 | + this.node.innerHTML = ''; | |
| 144 | + } | |
| 145 | + | |
| 146 | + this.initChart(nextProps); | |
| 147 | + const chart = new G2.Chart({ | |
| 148 | + container: this.node, | |
| 149 | + forceFit: true, | |
| 150 | + height, | |
| 151 | + animate: false, | |
| 152 | + plotCfg: { | |
| 153 | + margin: [10, 10, 30, 10], | |
| 154 | + }, | |
| 155 | + }); | |
| 156 | + | |
| 157 | + chart.source(data); | |
| 158 | + | |
| 159 | + chart.tooltip(false); | |
| 160 | + | |
| 161 | + chart.coord('gauge', { | |
| 162 | + startAngle: -1.2 * Math.PI, | |
| 163 | + endAngle: 0.20 * Math.PI, | |
| 164 | + }); | |
| 165 | + chart.col('value', { | |
| 166 | + type: 'linear', | |
| 167 | + nice: true, | |
| 168 | + min: 0, | |
| 169 | + max: 100, | |
| 170 | + tickCount: 6, | |
| 171 | + }); | |
| 172 | + chart.axis('value', { | |
| 173 | + subTick: false, | |
| 174 | + tickLine: { | |
| 175 | + stroke: color, | |
| 176 | + lineWidth: 2, | |
| 177 | + value: -14, | |
| 178 | + }, | |
| 179 | + labelOffset: -12, | |
| 180 | + formatter: (val) => { | |
| 181 | + switch (parseInt(val, 10)) { | |
| 182 | + case 20: | |
| 183 | + return '差'; | |
| 184 | + case 40: | |
| 185 | + return '中'; | |
| 186 | + case 60: | |
| 187 | + return '良'; | |
| 188 | + case 80: | |
| 189 | + return '优'; | |
| 190 | + default: | |
| 191 | + return ''; | |
| 192 | + } | |
| 193 | + }, | |
| 194 | + }); | |
| 195 | + chart.point().position('value').shape('dashBoard'); | |
| 196 | + draw(data); | |
| 197 | + | |
| 198 | + /* eslint no-shadow: 0 */ | |
| 199 | + function draw(data) { | |
| 200 | + const val = data[0].value; | |
| 201 | + const lineWidth = 12; | |
| 202 | + chart.guide().clear(); | |
| 203 | + | |
| 204 | + chart.guide().arc(() => { | |
| 205 | + return [0, 0.95]; | |
| 206 | + }, () => { | |
| 207 | + return [val, 0.95]; | |
| 208 | + }, { | |
| 209 | + stroke: color, | |
| 210 | + lineWidth, | |
| 211 | + }); | |
| 212 | + | |
| 213 | + chart.guide().arc(() => { | |
| 214 | + return [val, 0.95]; | |
| 215 | + }, (arg) => { | |
| 216 | + return [arg.max, 0.95]; | |
| 217 | + }, { | |
| 218 | + stroke: bgColor, | |
| 219 | + lineWidth, | |
| 220 | + }); | |
| 221 | + | |
| 222 | + chart.changeData(data); | |
| 223 | + } | |
| 224 | + | |
| 225 | + this.chart = chart; | |
| 226 | + } | |
| 227 | + | |
| 228 | + render() { | |
| 229 | + return ( | |
| 230 | + <div ref={this.handleRef} /> | |
| 231 | + ); | |
| 232 | + } | |
| 233 | +} | |
| 234 | + | |
| 235 | +export default Gauge; | ... | ... |
src/components/Charts/Pie/index.js
0 → 100644
| 1 | +/* eslint-disable no-undef, jsx-a11y/no-noninteractive-element-interactions */ | |
| 2 | +import React, { Component } from 'react'; | |
| 3 | +import G2 from '@antv/g2'; | |
| 4 | +import { Divider } from 'antd'; | |
| 5 | +import classNames from 'classnames'; | |
| 6 | +import ReactFitText from 'react-fittext'; | |
| 7 | +import Debounce from 'lodash-decorators/debounce'; | |
| 8 | +import Bind from 'lodash-decorators/bind'; | |
| 9 | +import equal from '../equal'; | |
| 10 | +import styles from './index.less'; | |
| 11 | +import Charts from '../index.js'; | |
| 12 | + | |
| 13 | +/* eslint react/no-danger:0 */ | |
| 14 | +class Pie extends Component { | |
| 15 | + constructor(props) { | |
| 16 | + super(props); | |
| 17 | + this.state = { | |
| 18 | + legendData: [], | |
| 19 | + legendBlock: true, | |
| 20 | + }; | |
| 21 | + } | |
| 22 | + | |
| 23 | + componentDidMount() { | |
| 24 | + this.renderChart(); | |
| 25 | + this.resize(); | |
| 26 | + window.addEventListener('resize', this.resize); | |
| 27 | + } | |
| 28 | + | |
| 29 | + componentWillReceiveProps(nextProps) { | |
| 30 | + if (!equal(this.props, nextProps)) { | |
| 31 | + this.renderChart(nextProps.data); | |
| 32 | + } | |
| 33 | + } | |
| 34 | + | |
| 35 | + componentWillUnmount() { | |
| 36 | + window.removeEventListener('resize', this.resize); | |
| 37 | + if (this.chart) { | |
| 38 | + this.chart.destroy(); | |
| 39 | + } | |
| 40 | + this.resize.cancel(); | |
| 41 | + } | |
| 42 | + | |
| 43 | + @Bind() | |
| 44 | + @Debounce(300) | |
| 45 | + resize() { | |
| 46 | + const { hasLegend } = this.props; | |
| 47 | + if (!hasLegend || !this.root) { | |
| 48 | + window.removeEventListener('resize', this.resize); | |
| 49 | + return; | |
| 50 | + } | |
| 51 | + if (this.root.parentNode.clientWidth <= 380) { | |
| 52 | + if (!this.state.legendBlock) { | |
| 53 | + this.setState({ | |
| 54 | + legendBlock: true, | |
| 55 | + }, () => { | |
| 56 | + this.renderChart(); | |
| 57 | + }); | |
| 58 | + } | |
| 59 | + } else if (this.state.legendBlock) { | |
| 60 | + this.setState({ | |
| 61 | + legendBlock: false, | |
| 62 | + }, () => { | |
| 63 | + this.renderChart(); | |
| 64 | + }); | |
| 65 | + } | |
| 66 | + } | |
| 67 | + | |
| 68 | + handleRef = (n) => { | |
| 69 | + this.node = n; | |
| 70 | + }; | |
| 71 | + | |
| 72 | + handleRoot = (n) => { | |
| 73 | + this.root = n; | |
| 74 | + }; | |
| 75 | + | |
| 76 | + handleLegendClick = (item, i) => { | |
| 77 | + const newItem = item; | |
| 78 | + newItem.checked = !newItem.checked; | |
| 79 | + | |
| 80 | + const { legendData } = this.state; | |
| 81 | + legendData[i] = newItem; | |
| 82 | + | |
| 83 | + if (this.chart) { | |
| 84 | + const filterItem = legendData.filter(l => l.checked).map(l => l.x); | |
| 85 | + this.chart.filter('x', filterItem); | |
| 86 | + this.chart.repaint(); | |
| 87 | + } | |
| 88 | + | |
| 89 | + this.setState({ | |
| 90 | + legendData, | |
| 91 | + }); | |
| 92 | + }; | |
| 93 | + | |
| 94 | + renderChart(d) { | |
| 95 | + if (this.node.offsetWidth === 0) { | |
| 96 | + return; | |
| 97 | + } | |
| 98 | + let data = d || this.props.data; | |
| 99 | + | |
| 100 | + const { | |
| 101 | + height = 0, | |
| 102 | + hasLegend, | |
| 103 | + fit = true, | |
| 104 | + margin = [12, 0, 12, 0], percent, color, | |
| 105 | + inner = 0.75, | |
| 106 | + animate = true, | |
| 107 | + colors, | |
| 108 | + lineWidth = 0, | |
| 109 | + } = this.props; | |
| 110 | + | |
| 111 | + const defaultColors = colors; | |
| 112 | + | |
| 113 | + let selected = this.props.selected || true; | |
| 114 | + let tooltip = this.props.tooltips || true; | |
| 115 | + | |
| 116 | + let formatColor; | |
| 117 | + if (percent) { | |
| 118 | + selected = false; | |
| 119 | + tooltip = false; | |
| 120 | + formatColor = (value) => { | |
| 121 | + if (value === '占比') { | |
| 122 | + return color || 'rgba(24, 144, 255, 0.85)'; | |
| 123 | + } else { | |
| 124 | + return '#F0F2F5'; | |
| 125 | + } | |
| 126 | + }; | |
| 127 | + | |
| 128 | + /* eslint no-param-reassign: */ | |
| 129 | + data = [ | |
| 130 | + { | |
| 131 | + x: '占比', | |
| 132 | + y: parseFloat(percent), | |
| 133 | + }, | |
| 134 | + { | |
| 135 | + x: '反比', | |
| 136 | + y: 100 - parseFloat(percent), | |
| 137 | + }, | |
| 138 | + ]; | |
| 139 | + } | |
| 140 | + | |
| 141 | + if (!data || (data && data.length < 1)) { | |
| 142 | + return; | |
| 143 | + } | |
| 144 | + | |
| 145 | + // clean | |
| 146 | + this.node.innerHTML = ''; | |
| 147 | + | |
| 148 | + const { Stat } = G2; | |
| 149 | + | |
| 150 | + const chart = new G2.Chart({ | |
| 151 | + container: this.node, | |
| 152 | + forceFit: fit, | |
| 153 | + height, | |
| 154 | + plotCfg: { | |
| 155 | + margin, | |
| 156 | + }, | |
| 157 | + animate, | |
| 158 | + }); | |
| 159 | + | |
| 160 | + if (!tooltip) { | |
| 161 | + chart.tooltip(false); | |
| 162 | + } else { | |
| 163 | + chart.tooltip({ | |
| 164 | + title: null, | |
| 165 | + }); | |
| 166 | + } | |
| 167 | + | |
| 168 | + chart.axis(false); | |
| 169 | + chart.legend(false); | |
| 170 | + chart.source(data, { | |
| 171 | + x: { | |
| 172 | + type: 'cat', | |
| 173 | + range: [0, 1], | |
| 174 | + }, | |
| 175 | + y: { | |
| 176 | + min: 0, | |
| 177 | + }, | |
| 178 | + }); | |
| 179 | + | |
| 180 | + chart.coord('theta', { | |
| 181 | + inner, | |
| 182 | + }); | |
| 183 | + // chart.changeSize(180, 216);// 设置图标的高度 | |
| 184 | + chart | |
| 185 | + .intervalStack() | |
| 186 | + .position(Stat.summary.percent('y')) | |
| 187 | + .style({ lineWidth, stroke: '#fff' }) | |
| 188 | + .color('x', percent ? formatColor : defaultColors) | |
| 189 | + .selected(selected); | |
| 190 | + | |
| 191 | + chart.render(); | |
| 192 | + | |
| 193 | + this.chart = chart; | |
| 194 | + | |
| 195 | + let legendData = []; | |
| 196 | + if (hasLegend) { | |
| 197 | + const geom = chart.getGeoms()[0]; // 获取所有的图形 | |
| 198 | + const items = geom.getData(); // 获取图形对应的数据 | |
| 199 | + legendData = items.map((item) => { | |
| 200 | + /* eslint no-underscore-dangle:0 */ | |
| 201 | + const origin = item._origin; | |
| 202 | + origin.color = item.color; | |
| 203 | + origin.checked = true; | |
| 204 | + return origin; | |
| 205 | + }); | |
| 206 | + } | |
| 207 | + | |
| 208 | + this.setState({ | |
| 209 | + legendData, | |
| 210 | + }); | |
| 211 | + } | |
| 212 | + | |
| 213 | + render() { | |
| 214 | + const { | |
| 215 | + valueFormat, subTitle, hasLegend, className, style, data = [], | |
| 216 | + } = this.props; | |
| 217 | + let { projectName } = this.props; /* 项目名称 */ | |
| 218 | + projectName = projectName === undefined || projectName === null ? '' : projectName; | |
| 219 | + const { yuan } = Charts; | |
| 220 | + // const total = hasLegend ? yuan(data.reduce((pre, now) => now.y + pre, 0)) : this.props.total; | |
| 221 | + const total = hasLegend ? data.reduce((pre, now) => now.y + pre, 0).toFixed(2) : this.props.total; /* 保留两位小数 */ | |
| 222 | + const { legendData, legendBlock } = this.state; | |
| 223 | + const pieClassName = classNames(styles.pie, className, { | |
| 224 | + [styles.hasLegend]: !!hasLegend, | |
| 225 | + [styles.legendBlock]: legendBlock, | |
| 226 | + }); | |
| 227 | + return ( | |
| 228 | + <div ref={this.handleRoot} className={pieClassName} style={style}> | |
| 229 | + <ReactFitText maxFontSize={25}> | |
| 230 | + <div className={styles.chart}> | |
| 231 | + <div ref={this.handleRef} style={{ fontSize: 0 }} /> | |
| 232 | + { | |
| 233 | + (subTitle || total) && ( | |
| 234 | + <div className={styles.total}> | |
| 235 | + {subTitle && <h4 className="pie-sub-title">{subTitle}</h4>} | |
| 236 | + { | |
| 237 | + // eslint-disable-next-line | |
| 238 | + total && <div className="pie-stat" dangerouslySetInnerHTML={{ __html: total }} /> | |
| 239 | + } | |
| 240 | + </div> | |
| 241 | + ) | |
| 242 | + } | |
| 243 | + </div> | |
| 244 | + </ReactFitText> | |
| 245 | + | |
| 246 | + { | |
| 247 | + hasLegend && ( | |
| 248 | + <ul | |
| 249 | + className={styles.legend} | |
| 250 | + // className={location.pathname.indexOf('commonAuto') > -1 ? styles.legendBigScreen : styles.legend} | |
| 251 | + style={location.pathname.indexOf('indexMobile') > -1 ? { width: '48%' } : { width: '48%' }} | |
| 252 | + > | |
| 253 | + { | |
| 254 | + legendData.map((item, i) => ( | |
| 255 | + <li key={item.x} onClick={() => this.handleLegendClick(item, i)}> | |
| 256 | + <span className={styles.dot} style={{ backgroundColor: !item.checked ? '#aaa' : item.color }} /> | |
| 257 | + <span className={`${styles.legendTitle} ${projectName} ${location.pathname.indexOf('indexMobile') > -1 ? styles.spanStyle : ''}`}>{item.x}</span> | |
| 258 | + <Divider type="vertical" /> | |
| 259 | + {location.pathname.indexOf('indexMobile') > -1 ? '' : '' | |
| 260 | + // <span className={`${styles.percent} ${projectName}`}>{`${(item['..percent'] * 100).toFixed(2)}%`}</span> | |
| 261 | + } | |
| 262 | + <span | |
| 263 | + className={`${styles.value} ${projectName}`} | |
| 264 | + dangerouslySetInnerHTML={{ | |
| 265 | + __html: valueFormat ? yuan(item.y) : item.y, | |
| 266 | + }} | |
| 267 | + /> | |
| 268 | + </li> | |
| 269 | + )) | |
| 270 | + } | |
| 271 | + </ul> | |
| 272 | + ) | |
| 273 | + } | |
| 274 | + </div> | |
| 275 | + ); | |
| 276 | + } | |
| 277 | +} | |
| 278 | + | |
| 279 | +export default Pie; | ... | ... |
src/components/Charts/Pie/index.less
0 → 100644
| 1 | +@import "~antd-v4/lib/style/themes/default.less"; | |
| 2 | + | |
| 3 | +.pie { | |
| 4 | + position: relative; | |
| 5 | + .chart { | |
| 6 | + position: relative; | |
| 7 | + } | |
| 8 | + &.hasLegend .chart { | |
| 9 | + width: ~"calc(47%)"!important; | |
| 10 | + } | |
| 11 | + .legend { | |
| 12 | + position: absolute!important; | |
| 13 | + right: 0; | |
| 14 | + min-width: 48%; | |
| 15 | + top: 50%; | |
| 16 | + transform: translateY(-50%)!important; | |
| 17 | + margin: 0 0 0 10px; | |
| 18 | + list-style: none; | |
| 19 | + padding: 0; | |
| 20 | + li { | |
| 21 | + width: 100%; | |
| 22 | + cursor: pointer; | |
| 23 | + margin-bottom: 0; | |
| 24 | + height: 16px; | |
| 25 | + line-height: 16px; | |
| 26 | + &:last-child { | |
| 27 | + margin-bottom: 0; | |
| 28 | + } | |
| 29 | + } | |
| 30 | + } | |
| 31 | + | |
| 32 | + .legendBigScreen { /* 大屏纵向排列 */ | |
| 33 | + position: relative!important; | |
| 34 | + right: 0; | |
| 35 | + min-width: 48%; | |
| 36 | + top: 50%; | |
| 37 | + transform: translateY(-50%)!important; | |
| 38 | + margin: 0; | |
| 39 | + list-style: none; | |
| 40 | + padding: 0; | |
| 41 | + li { | |
| 42 | + width: 100%; | |
| 43 | + cursor: pointer; | |
| 44 | + margin-bottom: 0; | |
| 45 | + height: 22px; | |
| 46 | + line-height: 22px; | |
| 47 | + &:last-child { | |
| 48 | + margin-bottom: 0; | |
| 49 | + } | |
| 50 | + } | |
| 51 | + } | |
| 52 | + .dot { | |
| 53 | + border-radius: 8px; | |
| 54 | + display: inline-block; | |
| 55 | + margin-right: 8px; | |
| 56 | + position: relative; | |
| 57 | + top: -1px; | |
| 58 | + height: 8px; | |
| 59 | + width: 8px; | |
| 60 | + } | |
| 61 | + .line { | |
| 62 | + background-color: @border-color-split; | |
| 63 | + display: inline-block; | |
| 64 | + margin-right: 8px; | |
| 65 | + width: 1px; | |
| 66 | + height: 16px; | |
| 67 | + } | |
| 68 | + .legendTitle { | |
| 69 | + color: @text-color; | |
| 70 | + } | |
| 71 | + .spanStyle{ | |
| 72 | + width: 50%; | |
| 73 | + display: inline-block; | |
| 74 | + overflow: hidden; | |
| 75 | + text-overflow: ellipsis; | |
| 76 | + white-space: nowrap; | |
| 77 | + } | |
| 78 | + .percent { | |
| 79 | + color: @text-color-secondary; | |
| 80 | + } | |
| 81 | + .value { | |
| 82 | + position: absolute; | |
| 83 | + right: 0; | |
| 84 | + } | |
| 85 | + .title { | |
| 86 | + margin-bottom: 8px; | |
| 87 | + } | |
| 88 | + .total { | |
| 89 | + position: absolute; | |
| 90 | + left: 50%; | |
| 91 | + top: 50%; | |
| 92 | + text-align: center; | |
| 93 | + height: 62px; | |
| 94 | + transform: translate(-50%, -50%); | |
| 95 | + & > div { | |
| 96 | + font-size: 24px; | |
| 97 | + } | |
| 98 | + & > h4 { | |
| 99 | + color: @text-color-secondary; | |
| 100 | + font-size: 14px; | |
| 101 | + line-height: 22px; | |
| 102 | + height: 22px; | |
| 103 | + margin-bottom: 8px; | |
| 104 | + font-weight: normal; | |
| 105 | + } | |
| 106 | + & > p { | |
| 107 | + color: @heading-color; | |
| 108 | + display: block; | |
| 109 | + font-size: 1.2em; | |
| 110 | + height: 32px; | |
| 111 | + line-height: 32px; | |
| 112 | + white-space: nowrap; | |
| 113 | + } | |
| 114 | + } | |
| 115 | +} | |
| 116 | + | |
| 117 | +.legendBlock { | |
| 118 | + &.hasLegend .chart { | |
| 119 | + width: 100%; | |
| 120 | + margin: 0 0 32px 0; | |
| 121 | + } | |
| 122 | + .legend { | |
| 123 | + position: relative; | |
| 124 | + transform: none; | |
| 125 | + } | |
| 126 | +} | ... | ... |
src/components/Charts/PieGroup/index.js
0 → 100644
| 1 | +import React, { Component } from 'react'; | |
| 2 | +import { Row, Col } from 'antd'; | |
| 3 | +import { getTheme } from '@antv/g2'; | |
| 4 | +import Pie from '../Pie'; | |
| 5 | + | |
| 6 | +class PieGroup extends Component { | |
| 7 | + render() { | |
| 8 | + const { data, height } = this.props; | |
| 9 | + const column = 24 / data.length; | |
| 10 | + const { colors10: colors } = getTheme(); | |
| 11 | + return ( | |
| 12 | + <Row gutter={4}> | |
| 13 | + { | |
| 14 | + data.map((child, i) => { | |
| 15 | + const { sId } = child; | |
| 16 | + child.height = height; | |
| 17 | + child.color = colors[i]; | |
| 18 | + return ( | |
| 19 | + <Col span={column} key={sId}> | |
| 20 | + <Pie {...child} /> | |
| 21 | + </Col> | |
| 22 | + ); | |
| 23 | + }) | |
| 24 | + } | |
| 25 | + </Row> | |
| 26 | + ); | |
| 27 | + } | |
| 28 | +} | |
| 29 | + | |
| 30 | +export default PieGroup; | |
| 31 | + | ... | ... |
src/components/Charts/TimeLineGroup/index.js
0 → 100644
| 1 | +/* eslint-disable object-curly-newline */ | |
| 2 | +import React, { Component } from 'react'; | |
| 3 | +import { Row, Col, Tabs } from 'antd'; | |
| 4 | +import TimeLineChart from '../TimelineChart'; | |
| 5 | +import NumberInfo from '../../NumberInfo'; | |
| 6 | +import Pie from '../Pie'; | |
| 7 | +import styles from '../index.less'; | |
| 8 | +import * as utils from '../../../utils/utils'; | |
| 9 | + | |
| 10 | +const { TabPane } = Tabs; | |
| 11 | + | |
| 12 | +class TimeLineGroup extends Component { | |
| 13 | + constructor(props) { | |
| 14 | + super(props); | |
| 15 | + this.state = { | |
| 16 | + offlineCard: styles.offlineCard, | |
| 17 | + tabGroup: styles.tabGroup, | |
| 18 | + currentTabKey: utils.isNotEmptyArr(props.data) ? props.data[0].x : '', | |
| 19 | + }; | |
| 20 | + } | |
| 21 | + | |
| 22 | + handleTabChange = (key) => { | |
| 23 | + this.setState({ | |
| 24 | + currentTabKey: key, | |
| 25 | + }); | |
| 26 | + }; | |
| 27 | + | |
| 28 | + render() { | |
| 29 | + const { offlineCard, currentTabKey, tabGroup } = this.state; | |
| 30 | + const { data, titleMap, subTitle, yUnit } = this.props; | |
| 31 | + const TabGroup = ({ tabData, currentTabKey: currentKey }) => ( | |
| 32 | + <Row gutter={8} className={tabGroup}> | |
| 33 | + <Col span={12}> | |
| 34 | + <NumberInfo | |
| 35 | + title={tabData.x} | |
| 36 | + subTitle={subTitle} | |
| 37 | + gap={2} | |
| 38 | + total={`${tabData.y * 100}%`} | |
| 39 | + theme={(currentKey !== tabData.x) && 'light'} | |
| 40 | + /> | |
| 41 | + </Col> | |
| 42 | + <Col span={12} style={{ paddingTop: 36 }}> | |
| 43 | + <Pie | |
| 44 | + animate={false} | |
| 45 | + color={(currentKey !== tabData.x) && '#BDE4FF'} | |
| 46 | + inner={0.55} | |
| 47 | + tooltip={false} | |
| 48 | + margin={[8, 0, 0, 0]} | |
| 49 | + percent={tabData.y * 100} | |
| 50 | + height={46} | |
| 51 | + /> | |
| 52 | + </Col> | |
| 53 | + </Row> | |
| 54 | + ); | |
| 55 | + return ( | |
| 56 | + <Tabs | |
| 57 | + className={offlineCard} | |
| 58 | + activeKey={currentTabKey} | |
| 59 | + onChange={this.handleTabChange} | |
| 60 | + > | |
| 61 | + { | |
| 62 | + data.map(item => ( | |
| 63 | + <TabPane | |
| 64 | + tab={<TabGroup tabData={item} currentTabKey={currentTabKey} />} | |
| 65 | + key={item.x} | |
| 66 | + > | |
| 67 | + <TimeLineChart | |
| 68 | + data={item.child} | |
| 69 | + titleMap={titleMap} | |
| 70 | + yUnit={yUnit} | |
| 71 | + height={this.props.height} | |
| 72 | + /> | |
| 73 | + </TabPane>)) | |
| 74 | + } | |
| 75 | + </Tabs> | |
| 76 | + ); | |
| 77 | + } | |
| 78 | +} | |
| 79 | + | |
| 80 | +export default TimeLineGroup; | |
| 81 | + | ... | ... |
src/components/Charts/TimelineChart/index.js
0 → 100644
| 1 | +import React, { Component } from 'react'; | |
| 2 | +import G2 from 'g2'; | |
| 3 | +import Slider from 'g2-plugin-slider'; | |
| 4 | +import styles from './index.less'; | |
| 5 | + | |
| 6 | +class TimelineChart extends Component { | |
| 7 | + componentDidMount() { | |
| 8 | + this.renderChart(this.props.data); | |
| 9 | + } | |
| 10 | + | |
| 11 | + componentWillReceiveProps(nextProps) { | |
| 12 | + if (nextProps.data !== this.props.data) { | |
| 13 | + this.renderChart(nextProps.data); | |
| 14 | + } | |
| 15 | + } | |
| 16 | + | |
| 17 | + componentWillUnmount() { | |
| 18 | + if (this.chart) { | |
| 19 | + this.chart.destroy(); | |
| 20 | + } | |
| 21 | + if (this.slider) { | |
| 22 | + this.slider.destroy(); | |
| 23 | + } | |
| 24 | + } | |
| 25 | + | |
| 26 | + sliderId = `timeline-chart-slider-${Math.random() * 1000}`; | |
| 27 | + handleRef = (n) => { | |
| 28 | + this.node = n; | |
| 29 | + }; | |
| 30 | + | |
| 31 | + renderChart(data) { | |
| 32 | + const { | |
| 33 | + height = 400, margin = [60, 20, 40, 70], titleMap, borderWidth = 2, yUnit = '', | |
| 34 | + } = this.props; | |
| 35 | + if (!data || (data && data.length < 1)) { | |
| 36 | + return; | |
| 37 | + } | |
| 38 | + | |
| 39 | + // clean | |
| 40 | + if (this.sliderId) { | |
| 41 | + // eslint-disable-next-line no-undef | |
| 42 | + document.getElementById(this.sliderId).innerHTML = ''; | |
| 43 | + } | |
| 44 | + if (this.chart) { | |
| 45 | + this.chart.destroy(); | |
| 46 | + } | |
| 47 | + if (this.slider) { | |
| 48 | + this.slider.destroy(); | |
| 49 | + } | |
| 50 | + this.node.innerHTML = ''; | |
| 51 | + const chart = new G2.Chart({ | |
| 52 | + container: this.node, | |
| 53 | + forceFit: true, | |
| 54 | + height, | |
| 55 | + plotCfg: { | |
| 56 | + margin, | |
| 57 | + }, | |
| 58 | + }); | |
| 59 | + | |
| 60 | + chart.axis('x', { | |
| 61 | + title: false, | |
| 62 | + }); | |
| 63 | + chart.axis('y1', { | |
| 64 | + title: false, | |
| 65 | + }); | |
| 66 | + chart.axis('y2', false); | |
| 67 | + | |
| 68 | + chart.legend({ | |
| 69 | + mode: false, | |
| 70 | + position: 'top', | |
| 71 | + marker: 'square', | |
| 72 | + }); | |
| 73 | + | |
| 74 | + let max; | |
| 75 | + if (data[0] && data[0].y1 && data[0].y2) { | |
| 76 | + max = Math.max( | |
| 77 | + data.sort((a, b) => b.y1 - a.y1)[0].y1, | |
| 78 | + data.sort((a, b) => b.y2 - a.y2)[0].y2, | |
| 79 | + ); | |
| 80 | + } | |
| 81 | + | |
| 82 | + chart.source(data, { | |
| 83 | + x: { | |
| 84 | + type: 'timeCat', | |
| 85 | + tickCount: 20, | |
| 86 | + mask: 'mm-dd', | |
| 87 | + range: [0, 1], | |
| 88 | + }, | |
| 89 | + y1: { | |
| 90 | + alias: titleMap.y1, | |
| 91 | + max, | |
| 92 | + min: 0, | |
| 93 | + formatter: (val) => { | |
| 94 | + return `${val}${yUnit}`; | |
| 95 | + }, | |
| 96 | + }, | |
| 97 | + y2: { | |
| 98 | + alias: titleMap.y2, | |
| 99 | + max, | |
| 100 | + min: 0, | |
| 101 | + formatter: (val) => { | |
| 102 | + return `${val}${yUnit}`; | |
| 103 | + }, | |
| 104 | + }, | |
| 105 | + }); | |
| 106 | + | |
| 107 | + chart.line().position('x*y1').color('#1890FF').size(borderWidth); | |
| 108 | + chart.line().position('x*y2').color('#2FC25B').size(borderWidth); | |
| 109 | + | |
| 110 | + this.chart = chart; | |
| 111 | + | |
| 112 | + /* eslint new-cap:0 */ | |
| 113 | + const slider = new Slider({ | |
| 114 | + domId: this.sliderId, | |
| 115 | + height: 26, | |
| 116 | + xDim: 'x', | |
| 117 | + yDim: 'y1', | |
| 118 | + charts: [chart], | |
| 119 | + }); | |
| 120 | + slider.render(); | |
| 121 | + | |
| 122 | + this.slider = slider; | |
| 123 | + } | |
| 124 | + | |
| 125 | + render() { | |
| 126 | + const { height, title } = this.props; | |
| 127 | + return ( | |
| 128 | + <div className={styles.timelineChart} style={{ height: height + 28 }}> | |
| 129 | + <div> | |
| 130 | + { title && <h4>{title}</h4>} | |
| 131 | + <div ref={this.handleRef} /> | |
| 132 | + <div id={this.sliderId} /> | |
| 133 | + </div> | |
| 134 | + </div> | |
| 135 | + ); | |
| 136 | + } | |
| 137 | +} | |
| 138 | + | |
| 139 | +export default TimelineChart; | ... | ... |
src/components/Charts/TimelineChart/index.less
0 → 100644
src/components/Charts/WaterWave/index.js
0 → 100644
| 1 | +/* eslint-disable object-curly-newline,no-return-assign */ | |
| 2 | +import React, { PureComponent } from 'react'; | |
| 3 | +import styles from './index.less'; | |
| 4 | + | |
| 5 | +class WaterWave extends PureComponent { | |
| 6 | + constructor(props) { | |
| 7 | + super(props); | |
| 8 | + this.state = { | |
| 9 | + radio: 1, | |
| 10 | + waterWave: styles.waterWave, | |
| 11 | + waterWaveCanvasWrapper: styles.waterWaveCanvasWrapper, | |
| 12 | + text: styles.text, | |
| 13 | + }; | |
| 14 | + } | |
| 15 | + | |
| 16 | + componentDidMount() { | |
| 17 | + this.renderChart(); | |
| 18 | + this.resize(); | |
| 19 | + window.addEventListener('resize', this.resize); | |
| 20 | + } | |
| 21 | + | |
| 22 | + componentWillUnmount() { | |
| 23 | + cancelAnimationFrame(this.timer); | |
| 24 | + if (this.node) { | |
| 25 | + this.node.innerHTML = ''; | |
| 26 | + } | |
| 27 | + window.removeEventListener('resize', this.resize); | |
| 28 | + } | |
| 29 | + | |
| 30 | + resize = () => { | |
| 31 | + const { height } = this.props; | |
| 32 | + const { offsetWidth } = this.root.parentNode; | |
| 33 | + this.setState({ | |
| 34 | + radio: offsetWidth < height ? offsetWidth / height : 1, | |
| 35 | + }); | |
| 36 | + }; | |
| 37 | + | |
| 38 | + renderChart() { | |
| 39 | + const { color = '#1890FF' } = this.props; | |
| 40 | + const data = (this.props.data / 100); | |
| 41 | + // const self = this; | |
| 42 | + | |
| 43 | + if (!this.node || !data) { | |
| 44 | + return; | |
| 45 | + } | |
| 46 | + if (this.timer) { | |
| 47 | + cancelAnimationFrame(this.timer); | |
| 48 | + if (this.node) { | |
| 49 | + this.node.innerHTML = ''; | |
| 50 | + } | |
| 51 | + } | |
| 52 | + | |
| 53 | + const canvas = this.node; | |
| 54 | + const ctx = canvas.getContext('2d'); | |
| 55 | + | |
| 56 | + const canvasWidth = canvas.width; | |
| 57 | + const canvasHeight = canvas.height; | |
| 58 | + const radius = canvasWidth / 2; | |
| 59 | + const lineWidth = 2; | |
| 60 | + const cR = radius - (lineWidth); | |
| 61 | + | |
| 62 | + ctx.beginPath(); | |
| 63 | + ctx.lineWidth = lineWidth * 2; | |
| 64 | + | |
| 65 | + const axisLength = canvasWidth - (lineWidth); | |
| 66 | + const unit = axisLength / 8; | |
| 67 | + const range = 0.2; // 振幅 | |
| 68 | + let currRange = range; | |
| 69 | + const xOffset = lineWidth; | |
| 70 | + let sp = 0; // 周期偏移量 | |
| 71 | + let currData = 0; | |
| 72 | + const waveupsp = 0.005; // 水波上涨速度 | |
| 73 | + | |
| 74 | + let arcStack = []; | |
| 75 | + const bR = radius - (lineWidth); | |
| 76 | + const circleOffset = -(Math.PI / 2); | |
| 77 | + let circleLock = true; | |
| 78 | + | |
| 79 | + for (let i = circleOffset; i < circleOffset + (2 * Math.PI); i += 1 / (8 * Math.PI)) { | |
| 80 | + arcStack.push([ | |
| 81 | + radius + (bR * Math.cos(i)), | |
| 82 | + radius + (bR * Math.sin(i)), | |
| 83 | + ]); | |
| 84 | + } | |
| 85 | + | |
| 86 | + const cStartPoint = arcStack.shift(); | |
| 87 | + ctx.strokeStyle = color; | |
| 88 | + ctx.moveTo(cStartPoint[0], cStartPoint[1]); | |
| 89 | + | |
| 90 | + function drawSin() { | |
| 91 | + ctx.beginPath(); | |
| 92 | + ctx.save(); | |
| 93 | + | |
| 94 | + const sinStack = []; | |
| 95 | + for (let i = xOffset; i <= xOffset + axisLength; i += Math.ceil(20 / axisLength)) { | |
| 96 | + const x = sp + ((xOffset + i) / unit); | |
| 97 | + const y = Math.sin(x) * currRange; | |
| 98 | + const dx = i; | |
| 99 | + const dy = ((2 * cR * (1 - currData)) + (radius - cR)) - (unit * y); | |
| 100 | + ctx.lineTo(dx, dy); | |
| 101 | + sinStack.push([dx, dy]); | |
| 102 | + } | |
| 103 | + | |
| 104 | + const startPoint = sinStack.shift(); | |
| 105 | + | |
| 106 | + ctx.lineTo(xOffset + axisLength, canvasHeight); | |
| 107 | + ctx.lineTo(xOffset, canvasHeight); | |
| 108 | + ctx.lineTo(startPoint[0], startPoint[1]); | |
| 109 | + | |
| 110 | + const gradient = ctx.createLinearGradient(0, 0, 0, canvasHeight); | |
| 111 | + gradient.addColorStop(0, '#ffffff'); | |
| 112 | + gradient.addColorStop(1, '#1890FF'); | |
| 113 | + ctx.fillStyle = gradient; | |
| 114 | + ctx.fill(); | |
| 115 | + ctx.restore(); | |
| 116 | + } | |
| 117 | + | |
| 118 | + function render1() { | |
| 119 | + ctx.clearRect(0, 0, canvasWidth, canvasHeight); | |
| 120 | + if (circleLock) { | |
| 121 | + if (arcStack.length) { | |
| 122 | + const temp = arcStack.shift(); | |
| 123 | + ctx.lineTo(temp[0], temp[1]); | |
| 124 | + ctx.stroke(); | |
| 125 | + } else { | |
| 126 | + circleLock = false; | |
| 127 | + ctx.lineTo(cStartPoint[0], cStartPoint[1]); | |
| 128 | + ctx.stroke(); | |
| 129 | + arcStack = null; | |
| 130 | + | |
| 131 | + ctx.globalCompositeOperation = 'destination-over'; | |
| 132 | + ctx.beginPath(); | |
| 133 | + ctx.lineWidth = lineWidth; | |
| 134 | + ctx.arc(radius, radius, bR, 0, 2 * Math.PI, 1); | |
| 135 | + | |
| 136 | + ctx.beginPath(); | |
| 137 | + ctx.save(); | |
| 138 | + ctx.arc(radius, radius, radius - (3 * lineWidth), 0, 2 * Math.PI, 1); | |
| 139 | + | |
| 140 | + ctx.restore(); | |
| 141 | + ctx.clip(); | |
| 142 | + ctx.fillStyle = '#1890FF'; | |
| 143 | + } | |
| 144 | + } else { | |
| 145 | + if (data >= 0.85) { | |
| 146 | + if (currRange > range / 4) { | |
| 147 | + const t = range * 0.01; | |
| 148 | + currRange -= t; | |
| 149 | + } | |
| 150 | + } else if (data <= 0.1) { | |
| 151 | + if (currRange < range * 1.5) { | |
| 152 | + const t = range * 0.01; | |
| 153 | + currRange += t; | |
| 154 | + } | |
| 155 | + } else { | |
| 156 | + if (currRange <= range) { | |
| 157 | + const t = range * 0.01; | |
| 158 | + currRange += t; | |
| 159 | + } | |
| 160 | + if (currRange >= range) { | |
| 161 | + const t = range * 0.01; | |
| 162 | + currRange -= t; | |
| 163 | + } | |
| 164 | + } | |
| 165 | + if ((data - currData) > 0) { | |
| 166 | + currData += waveupsp; | |
| 167 | + } | |
| 168 | + if ((data - currData) < 0) { | |
| 169 | + currData -= waveupsp; | |
| 170 | + } | |
| 171 | + | |
| 172 | + sp += 0.07; | |
| 173 | + drawSin(); | |
| 174 | + } | |
| 175 | + // self.timer = requestAnimationFrame(render1); //此句直接导致死循环 | |
| 176 | + } | |
| 177 | + | |
| 178 | + render1(); | |
| 179 | + } | |
| 180 | + | |
| 181 | + render() { | |
| 182 | + const { radio, waterWave, waterWaveCanvasWrapper, text } = this.state; | |
| 183 | + const { data, xUnit, height } = this.props; | |
| 184 | + return ( | |
| 185 | + <div className={waterWave} ref={n => (this.root = n)} style={{ transform: `scale(${radio})` }}> | |
| 186 | + <div style={{ width: height - 24, height: height - 24, overflow: 'hidden', margin: '0 auto' }}> | |
| 187 | + <canvas | |
| 188 | + className={waterWaveCanvasWrapper} | |
| 189 | + ref={n => (this.node = n)} | |
| 190 | + width={(height - 24) * 2} | |
| 191 | + height={(height - 24) * 2} | |
| 192 | + /> | |
| 193 | + </div> | |
| 194 | + <div className={text}> | |
| 195 | + { | |
| 196 | + xUnit && <span>{xUnit}</span> | |
| 197 | + } | |
| 198 | + <h4>{data}%</h4> | |
| 199 | + </div> | |
| 200 | + </div> | |
| 201 | + ); | |
| 202 | + } | |
| 203 | +} | |
| 204 | + | |
| 205 | +export default WaterWave; | ... | ... |
src/components/Charts/WaterWave/index.less
0 → 100644
| 1 | +@import "~antd-v4/lib/style/themes/default.less"; | |
| 2 | + | |
| 3 | +.waterWave { | |
| 4 | + display: block; | |
| 5 | + position: relative; | |
| 6 | + transform-origin: left; | |
| 7 | + padding: 12px 0; | |
| 8 | + .text { | |
| 9 | + position: absolute; | |
| 10 | + left: 0; | |
| 11 | + top: 20%; | |
| 12 | + text-align: center; | |
| 13 | + width: 100%; | |
| 14 | + span { | |
| 15 | + color: @text-color-secondary; | |
| 16 | + font-size: 14px; | |
| 17 | + line-height: 22px; | |
| 18 | + } | |
| 19 | + h4 { | |
| 20 | + color: @heading-color; | |
| 21 | + line-height: 32px; | |
| 22 | + font-size: 24px; | |
| 23 | + } | |
| 24 | + } | |
| 25 | + .waterWaveCanvasWrapper { | |
| 26 | + transform: scale(.5); | |
| 27 | + transform-origin: 0 0; | |
| 28 | + } | |
| 29 | +} | ... | ... |
src/components/Charts/equal.js
0 → 100644
| 1 | +/* eslint eqeqeq: 0 */ | |
| 2 | + | |
| 3 | +function equal(old, target) { | |
| 4 | + let r = true; | |
| 5 | + for (const prop in old) { | |
| 6 | + if (typeof old[prop] === 'function' && typeof target[prop] === 'function') { | |
| 7 | + if (old[prop].toString() != target[prop].toString()) { | |
| 8 | + r = false; | |
| 9 | + } | |
| 10 | + } else if (old[prop] != target[prop]) { | |
| 11 | + r = false; | |
| 12 | + } | |
| 13 | + } | |
| 14 | + return r; | |
| 15 | +} | |
| 16 | + | |
| 17 | +export default equal; | ... | ... |
src/components/Charts/index.js
0 → 100644
| 1 | +import numeral from 'numeral'; | |
| 2 | +import Bar from './Bar'; | |
| 3 | +import Columnar from './Columnar'; | |
| 4 | +import ColumnarGroup from './ColumnarGroup'; | |
| 5 | +import BrokenLine from './BrokenLine'; | |
| 6 | +import WaterWave from './WaterWave'; | |
| 7 | +import Gauge from './Gauge'; | |
| 8 | +import ColumnarStack from './ColumnarStack'; | |
| 9 | +import PieGroup from './PieGroup'; | |
| 10 | +import Pie from './Pie'; | |
| 11 | +import TimeLineChart from './TimelineChart'; | |
| 12 | +import TimeLineGroup from './TimeLineGroup'; | |
| 13 | +import EqualColumnarStack from './EqualColumnarStack'; | |
| 14 | +import ColorBlock from './ColorBlock'; | |
| 15 | +/* update by zz 20201227 */ | |
| 16 | +// const yuan = val => `¥ ${numeral(val).format('0,0')}`; | |
| 17 | +const yuan = val => `${numeral(val).format('0,0')}`; | |
| 18 | +export default { | |
| 19 | + yuan, | |
| 20 | + Bar, | |
| 21 | + Columnar, | |
| 22 | + ColumnarGroup, | |
| 23 | + BrokenLine, | |
| 24 | + WaterWave, | |
| 25 | + Gauge, | |
| 26 | + ColumnarStack, | |
| 27 | + PieGroup, | |
| 28 | + Pie, | |
| 29 | + TimeLineChart, | |
| 30 | + TimeLineGroup, | |
| 31 | + EqualColumnarStack, | |
| 32 | + ColorBlock, | |
| 33 | +}; | ... | ... |
src/components/Charts/index.less
0 → 100644
| 1 | +@import "~antd-v4/lib/style/themes/default.less"; | |
| 2 | +.char { | |
| 3 | + margin: 24px; | |
| 4 | +} | |
| 5 | + | |
| 6 | +.commonChar { | |
| 7 | + // padding-top: 10px; | |
| 8 | + padding-bottom: 10px; | |
| 9 | + background: #888; | |
| 10 | + :global{ | |
| 11 | + .ant-col-18{ | |
| 12 | + padding-right: 24px; | |
| 13 | + } | |
| 14 | + .ant-card-body{ | |
| 15 | + overflow: hidden; | |
| 16 | + } | |
| 17 | + } | |
| 18 | + .commonCharContainer { | |
| 19 | + margin-bottom: 24px; | |
| 20 | + overflow: hidden; | |
| 21 | + canvas + div { | |
| 22 | + display: none; | |
| 23 | + } | |
| 24 | + :global { | |
| 25 | + .ant-card-extra { | |
| 26 | + padding: 12px 24px!important; | |
| 27 | + } | |
| 28 | + } | |
| 29 | + .commonRollChar{ | |
| 30 | + .xly-list > .ant-layout{ | |
| 31 | + margin: 0 !important; | |
| 32 | + } | |
| 33 | + } | |
| 34 | + } | |
| 35 | +} | |
| 36 | + | |
| 37 | +.commonCharPage{ | |
| 38 | + padding: 105px 20px 0 20px; | |
| 39 | + background: #888; | |
| 40 | +} | |
| 41 | + | |
| 42 | +.offlineCard { | |
| 43 | + :global { | |
| 44 | + .ant-tabs-ink-bar { | |
| 45 | + bottom: auto; | |
| 46 | + } | |
| 47 | + .ant-tabs-bar { | |
| 48 | + border-bottom: none; | |
| 49 | + } | |
| 50 | + .ant-tabs-nav-container-scrolling { | |
| 51 | + padding-left: 40px; | |
| 52 | + padding-right: 40px; | |
| 53 | + } | |
| 54 | + .ant-tabs-tab-prev-icon:before { | |
| 55 | + position: relative; | |
| 56 | + left: 6px; | |
| 57 | + } | |
| 58 | + .ant-tabs-tab-next-icon:before { | |
| 59 | + position: relative; | |
| 60 | + right: 6px; | |
| 61 | + } | |
| 62 | + .ant-tabs-tab-active h4 { | |
| 63 | + color: @primary-color; | |
| 64 | + } | |
| 65 | + } | |
| 66 | + .tabGroup { | |
| 67 | + width: 138px; | |
| 68 | + margin: 8px 0!important; | |
| 69 | + } | |
| 70 | +} | |
| 71 | + | |
| 72 | + | ... | ... |
src/components/Common/CommonCheckBill/index.css
0 → 100644
| 1 | +.pdfContainer { | |
| 2 | + width: 100%; | |
| 3 | + height: 300px; | |
| 4 | +} | |
| 5 | +/* 处理分隔符间距 */ | |
| 6 | +:global { | |
| 7 | + /* 主表分隔符间距 */ | |
| 8 | +} | |
| 9 | +:global .commonCheckBillContainer .ant-divider-horizontal.ant-divider-with-text { | |
| 10 | + margin: 5px 0 10px 0!important; | |
| 11 | +} | |
| 12 | +:global .commonCheckBillContainer .flexArea .ant-divider-horizontal.ant-divider-with-text { | |
| 13 | + margin: -8px 0 !important; | |
| 14 | +} | ... | ... |
src/components/Common/CommonCheckBill/index.js
0 → 100644
| 1 | +/* eslint-disable prefer-destructuring */ | |
| 2 | +import React, { Component } from 'react'; | |
| 3 | +import { UploadOutlined } from '@ant-design/icons'; | |
| 4 | +import { Form } from '@ant-design/compatible'; | |
| 5 | +import '@ant-design/compatible/assets/index.css'; | |
| 6 | +import { | |
| 7 | + Row, | |
| 8 | + Col, | |
| 9 | + Checkbox, | |
| 10 | + Layout, | |
| 11 | + Spin, | |
| 12 | + Avatar, | |
| 13 | + Button, | |
| 14 | + Table, | |
| 15 | + Upload, | |
| 16 | + Input, | |
| 17 | + Divider, | |
| 18 | + Collapse, | |
| 19 | +} from 'antd'; | |
| 20 | +import { message } from '@/utils/common/message'; | |
| 21 | +import CommonSales from '@/components/Common/CommonCheckBillEvent';/* 继承销售模块业务功能 */ | |
| 22 | +import * as commonFunc from '@/components/Common/commonFunc';/* 通用单据方法 */ /* 通用单据方法 */ | |
| 23 | +import Toolbar from '@/components/Common/ToolBar/ToolBarNew'; | |
| 24 | +import StaticEditTable from '@/components/Common/CommonTable';/* 可编辑表格 */ | |
| 25 | +import styles from '@/index.less'; | |
| 26 | +import CommonView from '@/components/Common/CommonView'; | |
| 27 | +import CommonViewFlex from '@/components/Common/CommonViewFlex'; | |
| 28 | +import CommonViewTable from '@/components/Common/CommonViewTable'; | |
| 29 | +import CommonBase from '@/components/Common/CommonBase';/* 获取配置及数据 */ | |
| 30 | +import * as commonBusiness from '@/components/Common/commonBusiness';/* 单据业务功能 */ | |
| 31 | +import commonConfig from '@/utils/config'; | |
| 32 | +import * as commonUtils from '@/utils/utils';/* 通用方法 */ | |
| 33 | +import * as commonServices from '@/services/services';/* 服务类 */ | |
| 34 | +import CommonListSelect from '@/components/Common/CommonListSelect'; | |
| 35 | +import CommonListSelectTree from '@/components/Common/CommonListSelectTree'; | |
| 36 | +import AddIcon from '@/assets/add.svg'; | |
| 37 | +import DisableAddIcon from '@/assets/disableadd.svg'; | |
| 38 | +import CopyIcon from '@/assets/copy.svg'; | |
| 39 | +import CopyAllIcon from '@/assets/copyall.svg'; | |
| 40 | +import DisableCopyIcon from '@/assets/disablecopy.svg'; | |
| 41 | +import DisableCopyAllIcon from '@/assets/disablecopyall.svg'; | |
| 42 | +import DelIcon from '@/assets/delete.svg'; | |
| 43 | +import DisableDelIcon from '@/assets/disabledelete.svg';/* 获取配置及数据 */ | |
| 44 | +import MaterialRemarkIcon from '@/assets/materialremark.svg'; | |
| 45 | +import DisMaRemarklIcon from '@/assets/disablematerialremark.svg'; | |
| 46 | +import ProcessIcon from '@/assets/process.svg'; | |
| 47 | +import DisableProcessIcon from '@/assets/disableprocess.svg'; | |
| 48 | +import MateriallIcon from '@/assets/material.svg'; | |
| 49 | +import DisableMateriallIcon from '@/assets/disablematerial.svg'; | |
| 50 | +// import SlaveMemo from './SlaveMemo'; | |
| 51 | +import AntdDraggableModal from '@/components/Common/AntdDraggableModal'; | |
| 52 | +import StaticEditTree from '@/components/Common/Tree/StaticTree'; | |
| 53 | +import AddChildIcon from '@/assets/addChild.svg'; | |
| 54 | +import DisableAddChildIcon from '@/assets/disableaddChild.svg'; | |
| 55 | +import ContextMenuModal from '@/components/Common/ContextMenuModal'; | |
| 56 | +import PrintPdf from '@/components/PrintPdf/PrintPdf'; | |
| 57 | +import customStyles from './index.less'; | |
| 58 | + | |
| 59 | +const width = '18px'; | |
| 60 | +const height = '18px'; | |
| 61 | +const setAdd = { | |
| 62 | + title: '增加', | |
| 63 | + width: { width }, | |
| 64 | + height: { height }, | |
| 65 | + img: <img src={AddIcon} alt="添加" width={width} height={height} />, | |
| 66 | + disableimg: <img src={DisableAddIcon} alt="删除" width={width} height={height} />, | |
| 67 | +}; | |
| 68 | +const setAddChild = { | |
| 69 | + title: '增加', | |
| 70 | + width: { width }, | |
| 71 | + height: { height }, | |
| 72 | + img: <img src={AddChildIcon} alt="添加" width={width} height={height} />, | |
| 73 | + disableimg: <img src={DisableAddChildIcon} alt="添加" width={width} height={height} />, | |
| 74 | +}; | |
| 75 | +const setCopy = { | |
| 76 | + title: '复制', | |
| 77 | + width: { width }, | |
| 78 | + height: { height }, | |
| 79 | + img: <img src={CopyIcon} alt="复制" width="20px" height="20px" />, | |
| 80 | + disableimg: <img src={DisableCopyIcon} alt="复制" width="20px" height="20px" />, | |
| 81 | +}; | |
| 82 | +const setCopyAll = { | |
| 83 | + title: '复制部件', | |
| 84 | + width: { width }, | |
| 85 | + height: { height }, | |
| 86 | + img: <img src={CopyAllIcon} alt="复制部件" width="16px" height="16px" />, | |
| 87 | + disableimg: <img src={DisableCopyAllIcon} alt="复制部件" width="16px" height="16px" />, | |
| 88 | +}; | |
| 89 | +const setDelete = { | |
| 90 | + title: '删除', | |
| 91 | + width: { width }, | |
| 92 | + height: { height }, | |
| 93 | + img: <img src={DelIcon} alt="删除" width={width} height={height} />, | |
| 94 | + disableimg: <img src={DisableDelIcon} alt="删除" width={width} height={height} />, | |
| 95 | +}; | |
| 96 | +const setProcess = { | |
| 97 | + title: '工序', | |
| 98 | + width: { width }, | |
| 99 | + height: { height }, | |
| 100 | + img: <img src={ProcessIcon} alt="选择工序" width="16px" height="16px" />, | |
| 101 | + disableimg: <img src={DisableProcessIcon} alt="删除" width="16px" height="16px" />, | |
| 102 | +}; | |
| 103 | +const setMaterial = { | |
| 104 | + title: '材料', | |
| 105 | + width: { width }, | |
| 106 | + height: { height }, | |
| 107 | + img: <img src={MateriallIcon} alt="选择材料" width="22px" height="22px" />, | |
| 108 | + disableimg: <img src={DisableMateriallIcon} alt="选择材料" width="22px" height="22px" />, | |
| 109 | +}; | |
| 110 | + | |
| 111 | + | |
| 112 | +const { Header, Content, Sider } = Layout; | |
| 113 | +const { Panel } = Collapse; | |
| 114 | +class CommonBill extends Component { | |
| 115 | + constructor(props) { | |
| 116 | + super(props); | |
| 117 | + this.state = { | |
| 118 | + }; | |
| 119 | + } | |
| 120 | + | |
| 121 | + /** 行选择 */ | |
| 122 | + onRowClick = (name, record) => { | |
| 123 | + if (name === 'control') { | |
| 124 | + this.props.onTableSelectRowChange(name, [record.sId]); | |
| 125 | + } | |
| 126 | + }; | |
| 127 | + | |
| 128 | + onChange = (checkedValues) => { | |
| 129 | + this.props.onSaveState({ | |
| 130 | + dataPersonArray: checkedValues, | |
| 131 | + }); | |
| 132 | + }; | |
| 133 | + getMenuStatus = (menu) => { | |
| 134 | + if (menu.sControlName === 'BtnImport') { | |
| 135 | + return !this.props.enabled; | |
| 136 | + } | |
| 137 | + }; | |
| 138 | + /** 上传后执行函数 */ | |
| 139 | + handleUploadChangeFile = async (info) => { | |
| 140 | + const { file } = info; | |
| 141 | + const { | |
| 142 | + masterData, sModelsId, app, token, sModelsType, slaveConfig, slaveData, | |
| 143 | + } = this.props; | |
| 144 | + if (file.response) { | |
| 145 | + if (file.response.code === 1) { | |
| 146 | + /* 数据查询成功 */ | |
| 147 | + const errorInfo = file.response.dataset.rows[0].nocanbeInsert; | |
| 148 | + if (commonUtils.isNotEmptyObject(errorInfo)) { | |
| 149 | + message.error(errorInfo[0].sReason); | |
| 150 | + return; | |
| 151 | + } | |
| 152 | + /* 把之前存放的数据删除 */ | |
| 153 | + const slaveDelData = []; | |
| 154 | + if (commonUtils.isNotEmptyArr(slaveData)) { | |
| 155 | + slaveData.forEach((item) => { | |
| 156 | + if (commonUtils.isEmptyObject(item.handleType)) { | |
| 157 | + item.handleType = 'del'; | |
| 158 | + slaveDelData.push(item); | |
| 159 | + } | |
| 160 | + }); | |
| 161 | + } | |
| 162 | + const returnData = file.response.dataset.rows[0].canbeInsert; | |
| 163 | + let iCount = 0; | |
| 164 | + let productIdDropDown; | |
| 165 | + if (productIdDropDown === undefined && commonUtils.isNotEmptyArr(returnData)) { /* 无论导入多少条数据 都只调用1次接口,获取产品下拉数据集 */ | |
| 166 | + const iIndex = slaveConfig.gdsconfigformslave.findIndex(item => item.sName === 'sProductName'); | |
| 167 | + if (iIndex > -1) { | |
| 168 | + const sqlDropDownData = await this.props.getSqlDropDownData(sModelsId, 'slave', slaveConfig.gdsconfigformslave[iIndex], returnData[0]); | |
| 169 | + productIdDropDown = sqlDropDownData.dropDownData; | |
| 170 | + } | |
| 171 | + } | |
| 172 | + await returnData.forEach(async (tableDataRow) => { | |
| 173 | + tableDataRow.handleType = 'add'; | |
| 174 | + tableDataRow.sId = commonUtils.createSid(); | |
| 175 | + tableDataRow.sParentId = masterData.sId; | |
| 176 | + tableDataRow.key = tableDataRow.sId; | |
| 177 | + /* 若导入模板没有序号,则序号从1自增 */ | |
| 178 | + if (commonUtils.isEmptyObject(tableDataRow.iOrder)) { | |
| 179 | + iCount += 1; | |
| 180 | + tableDataRow.iOrder = iCount; | |
| 181 | + } | |
| 182 | + for (const child of Object.keys(tableDataRow)) { | |
| 183 | + const index = child.indexOf('_sRealValue_'); | |
| 184 | + if (index > -1) { | |
| 185 | + const property = child.substring(0, child.length - 12); | |
| 186 | + tableDataRow[property] = tableDataRow[child]; | |
| 187 | + } | |
| 188 | + } | |
| 189 | + if (productIdDropDown !== undefined) { | |
| 190 | + const iProductIdIndex = productIdDropDown.findIndex(item => item.sId === tableDataRow.sProductId); | |
| 191 | + if (iProductIdIndex === -1 && commonUtils.isNotEmptyObject(sModelsType) && sModelsType.includes('sales/salesOrder')) { /* 只有销售模块生成新产品 盘点 ,期间 不生成新的产品 */ | |
| 192 | + tableDataRow.sProductId = tableDataRow.sProductName; | |
| 193 | + tableDataRow.sProductInfo = JSON.stringify({ | |
| 194 | + sProductId: tableDataRow.sProductName, | |
| 195 | + sProductName: tableDataRow.sProductName, | |
| 196 | + sProductStyle: tableDataRow.sProductStyle, | |
| 197 | + sProductUnit: tableDataRow.sProductUnit, | |
| 198 | + sProductNo: tableDataRow.sProductNo, | |
| 199 | + sCustomerProductNo: tableDataRow.sCustomerProductNo, | |
| 200 | + sProductClassifyId: tableDataRow.sProductClassifyId, | |
| 201 | + sProductClassifyName: tableDataRow.sProductClassifyName, | |
| 202 | + }); | |
| 203 | + } | |
| 204 | + } | |
| 205 | + if (!tableDataRow.dNProductPrice) { | |
| 206 | + tableDataRow.dNProductPrice = tableDataRow.dProductForeignPrice; | |
| 207 | + } | |
| 208 | + const models = sModelsType.includes('sales/') || sModelsType.includes('manufacture/') || sModelsType.includes('quotation/') || sModelsType.includes('productStock/') ? 'Product' : 'Materials'; | |
| 209 | + if (sModelsType.includes('purchase/') || sModelsType.includes('quotation/') || sModelsType.includes('manufacture/') || sModelsType.includes('materialsStock/') || sModelsType.includes('outside/')) { | |
| 210 | + tableDataRow = await this.props.onMaterialsChange(tableDataRow, sModelsId, masterData, {}, 'dAuxiliaryQty', app, token, models); | |
| 211 | + tableDataRow = commonBusiness.getCalculateAllMoney(app, models, 'dAuxiliaryQty', masterData, tableDataRow); | |
| 212 | + } else { | |
| 213 | + tableDataRow = commonBusiness.getCalculateAllMoney(app, models, 'dProductQty', masterData, tableDataRow); | |
| 214 | + } | |
| 215 | + }); | |
| 216 | + this.props.onSaveState({ slaveData: returnData, slaveDelData }); | |
| 217 | + } else { /* 失败s */ | |
| 218 | + this.props.getServiceError(file.response); | |
| 219 | + } | |
| 220 | + } | |
| 221 | + }; | |
| 222 | + handleUploadPropsSales = () => { | |
| 223 | + const { masterData, sModelsType } = this.props; | |
| 224 | + if (commonUtils.isNotEmptyObject(masterData)) { | |
| 225 | + const sCustomerId = commonUtils.isEmptyStr(masterData.sCustomerId) ? undefined : masterData.sCustomerId; | |
| 226 | + let existCustomerId = false; | |
| 227 | + if (sModelsType.includes('sales/') && commonUtils.isNotEmptyStr(sCustomerId)) { | |
| 228 | + existCustomerId = true; | |
| 229 | + } else if (!sModelsType.includes('sales/')) { | |
| 230 | + existCustomerId = true; | |
| 231 | + } | |
| 232 | + return { | |
| 233 | + disabled: !this.props.enabled || !existCustomerId, /* 是否可用 */ | |
| 234 | + style: { display: commonUtils.convertBooleanToDisplayBlock(true) }, /* 是否显示 */ | |
| 235 | + }; | |
| 236 | + } | |
| 237 | + }; | |
| 238 | + | |
| 239 | + /** 上传后执行函数 */ | |
| 240 | + handleBeforeUpload = () => { | |
| 241 | + // const isLt10M = file.size / 1024 / 1024 < 10; | |
| 242 | + // if (!isLt10M) { | |
| 243 | + // message.error(commonFunc.showMessage(this.props.app.commonConst, 'picMax'));/* 图片大小需小于10MB! */ | |
| 244 | + // } | |
| 245 | + }; | |
| 246 | + /** 图片上传后执行函数 */ | |
| 247 | + handleUploadChange = (info, name) => { | |
| 248 | + const { file } = info; | |
| 249 | + if (file.response && file.response.code === 1) { | |
| 250 | + const sPicturePath = file.response.dataset.rows[0].savePathStr; | |
| 251 | + const spicture = sPicturePath; | |
| 252 | + const uploadInfo = { | |
| 253 | + sPicturePath, | |
| 254 | + sFileName: file.name, | |
| 255 | + }; | |
| 256 | + const { [`${name}Column`]: tableColumn, masterData, [`${name}Data`]: tableData } = this.props; | |
| 257 | + if (commonUtils.isNotEmptyArr(tableData) && commonUtils.isEmpty(tableData[tableData.length - 1].sPicturePath)) { | |
| 258 | + tableData[tableData.length - 1].sPicturePath = uploadInfo.sPicturePath; | |
| 259 | + tableData[tableData.length - 1].spicture = spicture; | |
| 260 | + tableData[tableData.length - 1] = { | |
| 261 | + ...tableData[tableData.length - 1], | |
| 262 | + sPicturePath: uploadInfo.sPicturePath, | |
| 263 | + sFileName: uploadInfo.sFileName, | |
| 264 | + spicture, | |
| 265 | + handleType: commonUtils.isEmpty(tableData[tableData.length - 1].handleType) ? 'update' : tableData[tableData.length - 1].handleType, | |
| 266 | + }; | |
| 267 | + } else { | |
| 268 | + const tableDataRow = this.props.onDataRowAdd(name, true); | |
| 269 | + tableColumn.forEach((slaveChild) => { | |
| 270 | + const ckey = slaveChild.dataIndex; | |
| 271 | + if (ckey === 'sProductNo' || ckey === 'sProductName') { | |
| 272 | + tableDataRow[ckey] = masterData[ckey] !== undefined ? masterData[ckey] : ''; | |
| 273 | + } else if (ckey === 'iOrder') { | |
| 274 | + tableDataRow[ckey] = ''; | |
| 275 | + } else if (file.response && file.response.code === 1) { | |
| 276 | + if (uploadInfo[ckey] !== undefined) { | |
| 277 | + tableDataRow[ckey] = uploadInfo[ckey]; | |
| 278 | + } | |
| 279 | + } | |
| 280 | + }); | |
| 281 | + tableData.push(tableDataRow); | |
| 282 | + } | |
| 283 | + this.props.onSaveState({ [`${name}Data`]: tableData, enabled: true }); | |
| 284 | + } else if (file.response && file.response.code === -1) { | |
| 285 | + message.error(file.response.msg); | |
| 286 | + } | |
| 287 | + }; | |
| 288 | + handleOk = async (flag, tmpCheck, isWait) => { | |
| 289 | + const { | |
| 290 | + sModelsId, masterData, app, checkConditions, sCheckModelId, checkPersonData, currentId, masterConfig, slaveConfig, checkConfig, sCheckRemark, | |
| 291 | + } = this.props; | |
| 292 | + const { currentPane } = app; | |
| 293 | + const bCkxTmpCheck = app.systemData.filter(item => item.sName === 'CkxTmpCheck')[0].sValue; | |
| 294 | + if (bCkxTmpCheck === '1') { | |
| 295 | + const returnData = await this.props.onDataAudit(flag, tmpCheck, isWait); | |
| 296 | + if (returnData.code === 1) { | |
| 297 | + if (returnData.dataset.rows[0].dataSet.outData[0].sCode === 1) { | |
| 298 | + this.props.onGetData(masterConfig, slaveConfig, checkConfig); | |
| 299 | + message.success(returnData.msg); | |
| 300 | + } else { | |
| 301 | + message.error(returnData.dataset.rows[0].dataSet.outData[0].sReturn); | |
| 302 | + } | |
| 303 | + } else { /* 失败 */ | |
| 304 | + this.props.getServiceError(returnData); | |
| 305 | + } | |
| 306 | + } else { | |
| 307 | + const dataPersonArray = commonUtils.isEmptyObject(this.props.dataPersonArray) ? [] : this.props.dataPersonArray; | |
| 308 | + if (commonUtils.isEmptyObject(dataPersonArray)) { | |
| 309 | + checkPersonData.forEach((item) => { | |
| 310 | + dataPersonArray.push(item.sUserId); | |
| 311 | + }); | |
| 312 | + } | |
| 313 | + const dataPersonString = dataPersonArray.join(','); | |
| 314 | + const url = `${commonConfig.server_host}business/getProData?sModelsId=${sModelsId}`; | |
| 315 | + const value = { | |
| 316 | + sProName: 'Sp_System_AutoSendCheckMsg', | |
| 317 | + paramsMap: { | |
| 318 | + sFormGuid: sModelsId, | |
| 319 | + sBillKey: currentPane.sProcName, | |
| 320 | + sTbName: masterConfig.sTbName, | |
| 321 | + sGuid: masterData.sId, | |
| 322 | + sBillNo: masterData.sBillNo, | |
| 323 | + sCheckCondition: checkConditions, | |
| 324 | + sMemo: sCheckRemark, | |
| 325 | + sCheckModelGuid: sCheckModelId, | |
| 326 | + sCheckPerson: dataPersonString, | |
| 327 | + }, | |
| 328 | + }; | |
| 329 | + | |
| 330 | + const returnData = (await commonServices.postValueService(app.token, value, url)).data; | |
| 331 | + if (returnData.code === 1) { | |
| 332 | + const noCheckMsg = commonFunc.showMessage(app.commonConst, 'NoCheckMsg'); /* 您有消息待审核 */ | |
| 333 | + if (returnData.dataset.rows[0].dataSet.outData[0].sCode === 1) { | |
| 334 | + this.props.handleSendSocketMessage('examine', 'showImg', currentId, dataPersonString, noCheckMsg, null); | |
| 335 | + const urlCanCheckBill = `${commonConfig.server_host}checkModel/getCanCheckBill?sModelsId=${sModelsId}`; | |
| 336 | + const valueCanCheckBill = { sCheckModelId, checkPersonData, sBillId: masterData.sId }; | |
| 337 | + const returnCanCheckBill = (await commonServices.postValueService(app.token, valueCanCheckBill, urlCanCheckBill)).data; | |
| 338 | + if (returnCanCheckBill.code === 1) { | |
| 339 | + if (returnCanCheckBill.dataset.rows[0].iCount === 1) { | |
| 340 | + this.props.onDataAudit(1, 1); | |
| 341 | + this.props.onSaveState({ | |
| 342 | + visible: false, | |
| 343 | + }); | |
| 344 | + return; | |
| 345 | + } | |
| 346 | + } else { /* 失败 */ | |
| 347 | + this.props.getServiceError(returnCanCheckBill); | |
| 348 | + } | |
| 349 | + this.props.handleSendSocketMessage('reflush', 'showImg', currentId, dataPersonString, noCheckMsg, null); | |
| 350 | + message.success(returnData.msg); | |
| 351 | + } else { | |
| 352 | + message.error(returnData.dataset.rows[0].dataSet.outData[0].sReturn); | |
| 353 | + } | |
| 354 | + } else { /* 失败 */ | |
| 355 | + this.props.getServiceError(returnData); | |
| 356 | + } | |
| 357 | + } | |
| 358 | + this.props.onSaveState({ | |
| 359 | + visible: false, | |
| 360 | + }); | |
| 361 | + }; | |
| 362 | + handleCancel = () => { | |
| 363 | + this.props.onSaveState({ | |
| 364 | + visible: false, | |
| 365 | + }); | |
| 366 | + }; | |
| 367 | + handleTableModal = async () => { | |
| 368 | + const { | |
| 369 | + sModelsId, controlData, masterData, slaveData, controlConfig, slaveSelectedRowKeys, enabled, slaveConfig, sModelsType, | |
| 370 | + } = this.props; | |
| 371 | + const addState = {}; | |
| 372 | + let treeState = {}; | |
| 373 | + if (this.props.sModelsType.includes('sales/salesOrder')) { | |
| 374 | + const iSlaveIndex = slaveData.findIndex(item => item.sId === slaveSelectedRowKeys[0]); | |
| 375 | + const iIndex = controlData.findIndex(item => item.sSlaveId === slaveSelectedRowKeys[0]); | |
| 376 | + if (iIndex === -1 && iSlaveIndex > -1 && enabled) { | |
| 377 | + const allTableData = {}; | |
| 378 | + allTableData.master = masterData; | |
| 379 | + allTableData.slaveData = slaveData; | |
| 380 | + let dropdownProductClassifyId; | |
| 381 | + const iIndex = slaveConfig.gdsconfigformslave.findIndex(item => item.sName === 'sProductClassifyId'); | |
| 382 | + if (iIndex > -1) { | |
| 383 | + const sqlDropDownData = await this.props.getSqlDropDownData(sModelsId, 'slave', slaveConfig.gdsconfigformslave[iIndex]); | |
| 384 | + dropdownProductClassifyId = sqlDropDownData.dropDownData; | |
| 385 | + } | |
| 386 | + if (commonUtils.isEmptyArr(dropdownProductClassifyId)) { | |
| 387 | + const iIndex = slaveConfig.gdsconfigformslave.findIndex(item => item.sName === 'sProductClassifyName'); | |
| 388 | + if (iIndex > -1) { | |
| 389 | + const sqlDropDownData = await this.props.getSqlDropDownData(sModelsId, 'slave', slaveConfig.gdsconfigformslave[iIndex]); | |
| 390 | + dropdownProductClassifyId = sqlDropDownData.dropDownData; | |
| 391 | + } | |
| 392 | + } | |
| 393 | + if (commonUtils.isNotEmptyArr(dropdownProductClassifyId)) { | |
| 394 | + const iProductClassifyIdIndex = dropdownProductClassifyId.findIndex(item => item.sId === slaveData[iSlaveIndex].sProductClassifyId); | |
| 395 | + if (commonUtils.isNotEmptyObject(dropdownProductClassifyId[iProductClassifyIdIndex])) { | |
| 396 | + const sAllPartsName = dropdownProductClassifyId[iProductClassifyIdIndex].sAllPartsName; | |
| 397 | + if (commonUtils.isNotEmptyStr(sAllPartsName)) { | |
| 398 | + const sAssignFieldObj = sAllPartsName.split(','); | |
| 399 | + for (const child of sAssignFieldObj) { | |
| 400 | + const tableDataRowAdd = commonFunc.getDefaultData(controlConfig, allTableData); | |
| 401 | + tableDataRowAdd.handleType = 'add'; | |
| 402 | + tableDataRowAdd.sId = commonUtils.createSid(); | |
| 403 | + tableDataRowAdd.sParentId = masterData && masterData.sId ? masterData.sId : null; | |
| 404 | + tableDataRowAdd.sSlaveId = slaveSelectedRowKeys[0]; | |
| 405 | + tableDataRowAdd.key = tableDataRowAdd.sId; | |
| 406 | + tableDataRowAdd.bDefault = false; | |
| 407 | + tableDataRowAdd.iOrder = 0; | |
| 408 | + tableDataRowAdd.sPartsName = child; | |
| 409 | + tableDataRowAdd.dPartsQty = commonUtils.isNull(slaveData[iSlaveIndex].dProductQty, 0) + commonUtils.isNull(slaveData[iSlaveIndex].dGiveQty, 0) + commonUtils.isNull(slaveData[iSlaveIndex].dStockupQty, 0); | |
| 410 | + tableDataRowAdd.sAllId = tableDataRowAdd.sId; | |
| 411 | + tableDataRowAdd.sControlParentId = ''; | |
| 412 | + controlData.push(tableDataRowAdd); | |
| 413 | + } | |
| 414 | + } | |
| 415 | + } | |
| 416 | + } | |
| 417 | + addState.controlData = controlData; | |
| 418 | + } | |
| 419 | + | |
| 420 | + if (controlData !== undefined) { | |
| 421 | + const iControlIndex = controlData.findIndex(item => item.sSlaveId === slaveSelectedRowKeys[0]); | |
| 422 | + if (iControlIndex > -1) { | |
| 423 | + addState.controlSelectedRowKeys = [controlData[iControlIndex].sId]; | |
| 424 | + } | |
| 425 | + } | |
| 426 | + if (sModelsType === 'sales/salesOrderPack') { | |
| 427 | + const sSlaveId = slaveSelectedRowKeys[0]; | |
| 428 | + if (commonUtils.isNotEmptyObject(sSlaveId)) { | |
| 429 | + treeState = this.props.onGetControlTreeData(controlData, true, sSlaveId); | |
| 430 | + } | |
| 431 | + } | |
| 432 | + } | |
| 433 | + | |
| 434 | + this.props.onSaveState({ | |
| 435 | + visibleModal: true, | |
| 436 | + ...addState, | |
| 437 | + ...treeState, | |
| 438 | + }); | |
| 439 | + }; | |
| 440 | + handleTableChooseProcess = () => { | |
| 441 | + const { processConfig } = this.props; | |
| 442 | + const iIndex = processConfig.gdsconfigformslave.findIndex(item => item.sControlName === 'BtnChooseProcess'); | |
| 443 | + | |
| 444 | + if (iIndex > -1) { | |
| 445 | + this.props.onBtnChoose('process', 'BtnChooseProcess', processConfig.gdsconfigformslave[iIndex]); | |
| 446 | + } | |
| 447 | + }; | |
| 448 | + handleCancelModal = (modelVisible) => { | |
| 449 | + this.props.onSaveState({ | |
| 450 | + [modelVisible]: false, | |
| 451 | + }); | |
| 452 | + }; | |
| 453 | + handleOkModal = async () => { | |
| 454 | + const { | |
| 455 | + controlData, materialsData, processData, slaveData, slaveSelectedRowKeys, | |
| 456 | + } = this.props; | |
| 457 | + const ctData = controlData.filter(item => item.handleType !== 'del' && item.sSlaveId === slaveSelectedRowKeys[0]); | |
| 458 | + const mtData = materialsData.filter(item => item.handleType !== 'del' && item.sSlaveId === slaveSelectedRowKeys[0]); | |
| 459 | + const pData = processData.filter(item => item.handleType !== 'del' && item.sSlaveId === slaveSelectedRowKeys[0] && item.sType !== '3'); | |
| 460 | + const p3Data = processData.filter(item => item.handleType !== 'del' && item.sSlaveId === slaveSelectedRowKeys[0] && item.sType === '3'); /* 成品工序 */ | |
| 461 | + if (commonUtils.isNotEmptyArr(ctData)) { | |
| 462 | + let mDetail = ''; | |
| 463 | + let pDetail = ''; | |
| 464 | + const slaveIndex = slaveData.findIndex(item => item.sId === slaveSelectedRowKeys[0]); | |
| 465 | + await ctData.forEach((controlItem, n) => { | |
| 466 | + if (commonUtils.isNotEmptyObject(controlItem.sPartsName)) { | |
| 467 | + const qz = n === 0 ? '' : ' '; | |
| 468 | + if (commonUtils.isNotEmptyObject(controlItem.sPartsName)) { | |
| 469 | + const yDetail = `${mDetail}${qz}#${controlItem.sPartsName}:`; | |
| 470 | + const gDetail = `${pDetail}${qz}#${controlItem.sPartsName}:`; | |
| 471 | + let imDetail = ''; | |
| 472 | + let ipDetail = ''; | |
| 473 | + const materials = mtData.filter(materialsItem => (materialsItem.sControlId === controlItem.sId)); | |
| 474 | + // let materialsIdDropDown; | |
| 475 | + // const materialsIndex = materialsConfig.gdsconfigformslave.findIndex(item => item.sName === 'sMaterialsName'); | |
| 476 | + // if (materialsIndex > -1) { | |
| 477 | + // const sqlDropDownData = await this.props.getSqlDropDownData(sModelsId, 'materials', materialsConfig.gdsconfigformslave[materialsIndex]); | |
| 478 | + // materialsIdDropDown = sqlDropDownData.dropDownData; | |
| 479 | + // } | |
| 480 | + materials.forEach((mItem, i) => { | |
| 481 | + const fh = i === 0 ? '' : ','; | |
| 482 | + imDetail = `${imDetail}${fh} ${mItem.sMaterialsName}`; | |
| 483 | + }); | |
| 484 | + // processPropsType | |
| 485 | + const process = pData.filter(processItem => (processItem.sControlId === controlItem.sId)); | |
| 486 | + // let processIdDropDown; | |
| 487 | + // const processIndex = processConfig.gdsconfigformslave.findIndex(item => item.sName === 'sProcessName'); | |
| 488 | + // if (processIndex > -1) { | |
| 489 | + // const sqlDropDownData = await this.props.getSqlDropDownData(sModelsId, 'process', processConfig.gdsconfigformslave[processIndex]); | |
| 490 | + // processIdDropDown = sqlDropDownData.dropDownData; | |
| 491 | + // } | |
| 492 | + // const processIdDropDown = commonUtils.getStoreDropDownData(sModelsId, 'process', 'sProcessName'); | |
| 493 | + process.forEach((pItem, i) => { | |
| 494 | + const fh = i === 0 ? '' : ','; | |
| 495 | + ipDetail = `${ipDetail}${fh} ${pItem.sProcessName}`; | |
| 496 | + }); | |
| 497 | + if (commonUtils.isNotEmptyObject(imDetail)) { | |
| 498 | + mDetail = `${yDetail}${imDetail}`; | |
| 499 | + } | |
| 500 | + if (commonUtils.isNotEmptyObject(ipDetail)) { | |
| 501 | + pDetail = `${gDetail}${ipDetail}`; | |
| 502 | + } | |
| 503 | + } | |
| 504 | + } | |
| 505 | + }); | |
| 506 | + /* 成品工序 */ | |
| 507 | + let ip3Detail = ''; | |
| 508 | + if (commonUtils.isNotEmptyArr(p3Data)) { | |
| 509 | + p3Data.forEach((pItem, i) => { | |
| 510 | + const fh = i === 0 ? '' : ','; | |
| 511 | + ip3Detail = `${ip3Detail}${fh} ${pItem.sProcessName}`; | |
| 512 | + }); | |
| 513 | + } | |
| 514 | + if (commonUtils.isNotEmptyObject(ip3Detail)) { | |
| 515 | + if (commonUtils.isNotEmptyObject(pDetail)) { | |
| 516 | + pDetail = `${pDetail},${ip3Detail}`; | |
| 517 | + } else { | |
| 518 | + pDetail = ip3Detail; | |
| 519 | + } | |
| 520 | + } | |
| 521 | + slaveData[slaveIndex].sMaterialsMemo = mDetail; | |
| 522 | + slaveData[slaveIndex].sProcessMemo = pDetail; | |
| 523 | + slaveData[slaveIndex].handleType = commonUtils.isEmpty(slaveData[slaveIndex].handleType) ? 'update' : slaveData[slaveIndex].handleType; | |
| 524 | + } else if (commonUtils.isNotEmptyArr(controlData) && commonUtils.isEmptyArr(ctData)) { | |
| 525 | + const sSlaveId = controlData[0].sSlaveId; | |
| 526 | + const slaveIndex = slaveData.findIndex(item => item.sId === sSlaveId); | |
| 527 | + slaveData[slaveIndex].sMaterialsMemo = ''; | |
| 528 | + slaveData[slaveIndex].sProcessMemo = ''; | |
| 529 | + slaveData[slaveIndex].handleType = commonUtils.isEmpty(slaveData[slaveIndex].handleType) ? 'update' : slaveData[slaveIndex].handleType; | |
| 530 | + } | |
| 531 | + this.props.onSaveState({ | |
| 532 | + visibleModal: false, | |
| 533 | + controlData, | |
| 534 | + materialsData, | |
| 535 | + processData, | |
| 536 | + slaveData, | |
| 537 | + }); | |
| 538 | + }; | |
| 539 | + /** 控制选择控制表时,显示部件工序与成品工序 */ | |
| 540 | + handleFilterSlaveData = (name, dataIndex, value, record) => { | |
| 541 | + return (commonUtils.isNotEmptyStr(record.sSlaveId) && record.sSlaveId.toString().toLowerCase().includes(value.toLowerCase())); | |
| 542 | + }; | |
| 543 | + /** 控制选择控制表时,显示部件工序与成品工序 */ | |
| 544 | + handleFilterData = (name, dataIndex, value, record) => { | |
| 545 | + const { slaveSelectedRowKeys } = this.props; | |
| 546 | + if (name === 'process') { | |
| 547 | + return (commonUtils.isNotEmptyStr(record.sType) && record.sType === '3' && | |
| 548 | + commonUtils.isNotEmptyStr(record.sSlaveId) && record.sSlaveId.toString().toLowerCase().includes(slaveSelectedRowKeys.toString().toLowerCase())) || | |
| 549 | + (commonUtils.isNotEmptyStr(record.sControlId) && record.sControlId.toString().toLowerCase().includes(value.toLowerCase()) && | |
| 550 | + commonUtils.isNotEmptyStr(record.sSlaveId) && record.sSlaveId.toString().toLowerCase().includes(slaveSelectedRowKeys.toString().toLowerCase())); | |
| 551 | + } else { | |
| 552 | + return (commonUtils.isNotEmptyStr(record.sType) && record.sType === '2' && | |
| 553 | + commonUtils.isNotEmptyStr(record.sSlaveId) && record.sSlaveId.toString().toLowerCase().includes(slaveSelectedRowKeys.toString().toLowerCase())) || | |
| 554 | + (commonUtils.isNotEmptyStr(record.sControlId) && record.sControlId.toString().toLowerCase().includes(value.toLowerCase()) && | |
| 555 | + commonUtils.isNotEmptyStr(record.sSlaveId) && record.sSlaveId.toString().toLowerCase().includes(slaveSelectedRowKeys.toString().toLowerCase())); | |
| 556 | + } | |
| 557 | + // (commonUtils.isNotEmptyStr(record.sControlId) && record.sControlId.toString().toLowerCase().includes(value.toLowerCase())); | |
| 558 | + }; | |
| 559 | + /* 控制表过滤材料表 工序表数据 */ | |
| 560 | + handleGetFilterData = (name) => { | |
| 561 | + const { [`${name}Data`]: data, controlSelectedRowKeys, slaveSelectedRowKeys } = this.props; | |
| 562 | + if (data !== undefined) { | |
| 563 | + const newArr = data.filter((item) => { | |
| 564 | + if (name === 'control') { | |
| 565 | + return (commonUtils.isNotEmptyStr(item.sSlaveId) && item.sSlaveId.toString().toLowerCase().includes(slaveSelectedRowKeys.toString())); | |
| 566 | + } else { | |
| 567 | + return (commonUtils.isNotEmptyStr(item.sControlId) && item.sControlId.toString().toLowerCase().includes(controlSelectedRowKeys.toString()) && | |
| 568 | + commonUtils.isNotEmptyStr(item.sSlaveId) && item.sSlaveId.toString().toLowerCase().includes(slaveSelectedRowKeys.toString())); | |
| 569 | + } | |
| 570 | + }); | |
| 571 | + return newArr.length; | |
| 572 | + } | |
| 573 | + }; | |
| 574 | + /* 包装工单过滤行 */ /** 控制选择控制表时,显示部件工序与成品工序 */ | |
| 575 | + handleFilterDataPack = (name, dataIndex, value, record) => { | |
| 576 | + if (name === 'process') { | |
| 577 | + return (commonUtils.isNotEmptyStr(record.sType) && record.sType === '3') || | |
| 578 | + (commonUtils.isNotEmptyStr(record.sControlId) && record.sControlId.toString().toLowerCase().includes(value.toLowerCase())); | |
| 579 | + } else { | |
| 580 | + return (commonUtils.isNotEmptyStr(record.sType) && record.sType === '2') || | |
| 581 | + (commonUtils.isNotEmptyStr(record.sControlId) && record.sControlId.toString().toLowerCase().includes(value.toLowerCase())); | |
| 582 | + } | |
| 583 | + }; | |
| 584 | + /* 控制表过滤材料表 工序表数据 */ | |
| 585 | + handleGetFilterDataPack = (name) => { | |
| 586 | + const { [`${name}Data`]: data, controlSelectedRowKeys } = this.props; | |
| 587 | + if (data !== undefined && commonUtils.isNotEmptyArr(controlSelectedRowKeys)) { | |
| 588 | + const newArr = data.filter((item) => { | |
| 589 | + return (commonUtils.isNotEmptyStr(item.sControlId) && item.sControlId.toString().toLowerCase().includes(controlSelectedRowKeys.toString())); | |
| 590 | + }); | |
| 591 | + return newArr.length; | |
| 592 | + } | |
| 593 | + }; | |
| 594 | + /** 添加表格空行 */ | |
| 595 | + handleTableAdd = async (name, flag, bchild) => { | |
| 596 | + /* 外置处理业务 */ | |
| 597 | + const { | |
| 598 | + sModelsId, sModelsType, gdsformconst, slaveData, controlData, controlSelectedRowKeys, [`${name}Data`]: tableData, slaveSelectedRowKeys, slaveConfig, | |
| 599 | + } = this.props; | |
| 600 | + let tableDataRow = {}; | |
| 601 | + if (name === 'control') { | |
| 602 | + const { | |
| 603 | + [`${name}SelectedRowKeys`]: treeSelectedKeys, | |
| 604 | + } = this.props; | |
| 605 | + if ((bchild === 'childNode' || bchild === 'sameNode') && (commonUtils.isEmptyArr(treeSelectedKeys) || commonUtils.isEmptyArr(controlSelectedRowKeys))) { | |
| 606 | + message.warn('请选择部件!'); // 请选择部件 | |
| 607 | + return; | |
| 608 | + } | |
| 609 | + tableDataRow = this.props.onDataRowAdd(name, true); | |
| 610 | + if (commonUtils.isEmptyObject(tableDataRow)) { | |
| 611 | + return; | |
| 612 | + } | |
| 613 | + let dPartsQty = 0; | |
| 614 | + if (commonUtils.isNotEmptyArr(slaveData)) { | |
| 615 | + slaveData.forEach((item) => { | |
| 616 | + dPartsQty += commonUtils.isNull(item.dProductQty, 0) + commonUtils.isNull(item.dGiveQty, 0) + commonUtils.isNull(item.dStockupQty, 0); | |
| 617 | + }); | |
| 618 | + let productIdDropDown; | |
| 619 | + const slaveIndex = slaveConfig.gdsconfigformslave.findIndex(item => item.sName === 'sProductName'); | |
| 620 | + if (slaveIndex > -1) { | |
| 621 | + const sqlDropDownData = await this.props.getSqlDropDownData(sModelsId, 'slave', slaveConfig.gdsconfigformslave[slaveIndex]); | |
| 622 | + productIdDropDown = sqlDropDownData.dropDownData; | |
| 623 | + } | |
| 624 | + if (productIdDropDown) { | |
| 625 | + const iProductIdIndex = productIdDropDown.findIndex(item => item.sId === slaveData[0].sProductId); | |
| 626 | + if (iProductIdIndex > -1) { | |
| 627 | + tableDataRow.sPartsName = productIdDropDown[iProductIdIndex].sProductName; | |
| 628 | + } | |
| 629 | + } | |
| 630 | + } | |
| 631 | + const iSlaveIndex = slaveData.findIndex(item => item.sId === slaveSelectedRowKeys[0]); | |
| 632 | + if (iSlaveIndex > -1) { | |
| 633 | + if (sModelsType.includes('sales/salesOrder')) { | |
| 634 | + if (!commonUtils.isEmpty(slaveData[iSlaveIndex].dProductQty)) { | |
| 635 | + tableDataRow.dPartsQty = commonUtils.isNull(slaveData[iSlaveIndex].dProductQty, 0) + commonUtils.isNull(slaveData[iSlaveIndex].dGiveQty, 0); | |
| 636 | + } | |
| 637 | + } else { | |
| 638 | + tableDataRow.dPartsQty = dPartsQty; | |
| 639 | + } | |
| 640 | + tableDataRow.sSlaveId = slaveData[iSlaveIndex].sId; | |
| 641 | + } | |
| 642 | + /* 树形部件节点增加同级部件、增加子级部件 */ | |
| 643 | + if (sModelsType === 'sales/salesOrderPack') { | |
| 644 | + if (bchild === 'sameNode') { /* 添加同级 */ | |
| 645 | + const iIndex = controlData.findIndex(item => item.sId === treeSelectedKeys[0]); | |
| 646 | + /* 找到同级子元素的sControlParentId */ | |
| 647 | + if (iIndex > -1) { | |
| 648 | + tableDataRow.sControlParentId = controlData[iIndex].sControlParentId; | |
| 649 | + /* 找到同级父级sAllId */ | |
| 650 | + const pId = controlData[iIndex].sControlParentId; | |
| 651 | + const sControlParentId = controlData.findIndex(item => item.sId === pId); | |
| 652 | + if (sControlParentId > -1) { | |
| 653 | + const sAllId = controlData[sControlParentId].sAllId; | |
| 654 | + if (commonUtils.isEmptyObject(sAllId)) { | |
| 655 | + message.warn('部件数据生成错误![sAllId为空]'); | |
| 656 | + return; | |
| 657 | + } | |
| 658 | + tableDataRow.sAllId = `${controlData[sControlParentId].sAllId},${tableDataRow.sId}`; | |
| 659 | + } else { | |
| 660 | + tableDataRow.sAllId = tableDataRow.sId; | |
| 661 | + } | |
| 662 | + } | |
| 663 | + } | |
| 664 | + if (bchild === 'childNode') { /* 添加子级 */ | |
| 665 | + tableDataRow.sControlParentId = treeSelectedKeys[0]; | |
| 666 | + const iIndex = controlData.findIndex(item => item.sId === treeSelectedKeys[0]); | |
| 667 | + if (iIndex > -1) { | |
| 668 | + const sAllId = controlData[iIndex].sAllId; | |
| 669 | + if (commonUtils.isEmptyObject(sAllId)) { | |
| 670 | + message.warn('子部件数据生成错误![sAllId为空]'); // 获取父节点的sAllId | |
| 671 | + return; | |
| 672 | + } | |
| 673 | + tableDataRow.sAllId = `${controlData[iIndex].sAllId},${tableDataRow.sId}`; | |
| 674 | + } | |
| 675 | + } | |
| 676 | + } | |
| 677 | + tableData.push(tableDataRow); | |
| 678 | + let treeState = []; | |
| 679 | + if (sModelsType === 'sales/salesOrderPack') { | |
| 680 | + treeState = this.props.onGetControlTreeData(tableData, true, tableDataRow.sSlaveId); | |
| 681 | + } | |
| 682 | + this.props.onSaveState({ [`${name}Data`]: tableData, [`${name}SelectedRowKeys`]: [tableDataRow.sId], ...treeState }); | |
| 683 | + } else if (name === 'materials' || name === 'process') { | |
| 684 | + tableDataRow = this.props.onDataRowAdd(name, true); | |
| 685 | + if (commonUtils.isEmptyArr(controlSelectedRowKeys)) { | |
| 686 | + const msg = commonFunc.showMessage(gdsformconst, 'pleaseChooseParts'); | |
| 687 | + message.warn(msg === '' ? '请选择部件' : msg); // 请选择部件 | |
| 688 | + return; | |
| 689 | + } | |
| 690 | + const iIndex = controlData.findIndex(item => item.sId === controlSelectedRowKeys[0]); | |
| 691 | + const iSlaveIndex = slaveData.findIndex(item => item.sId === slaveSelectedRowKeys[0]); | |
| 692 | + if (iIndex > -1 && iSlaveIndex > -1) { | |
| 693 | + if (commonUtils.isEmpty(controlData[iIndex].sPartsName) === '') { | |
| 694 | + message.warn(commonFunc.showMessage(gdsformconst, 'partsNameNotNull')); // 部件名称不能为空 | |
| 695 | + return; | |
| 696 | + } | |
| 697 | + tableDataRow.sSlaveId = slaveData[iSlaveIndex].sId; | |
| 698 | + tableDataRow.sControlId = controlData[iIndex].sId; | |
| 699 | + tableDataRow.sPartsName = controlData[iIndex].sPartsName; | |
| 700 | + } | |
| 701 | + tableData.push(tableDataRow); | |
| 702 | + this.props.onSaveState({ [`${name}Data`]: tableData, [`${name}SelectedRowKeys`]: [tableDataRow.sId] }); | |
| 703 | + } else { | |
| 704 | + this.props.onDataRowAdd(name, flag); | |
| 705 | + } | |
| 706 | + }; | |
| 707 | + /** 删除表格数据 */ | |
| 708 | + otherTableDel = (name, tableSelectedRowKeys) => { | |
| 709 | + const tableData = this.props[`${name}Data`]; | |
| 710 | + let tableDelData = this.props[`${name}DelData`]; | |
| 711 | + tableDelData = commonUtils.isEmptyArr(tableDelData) ? [] : tableDelData; | |
| 712 | + for (const sId of tableSelectedRowKeys) { | |
| 713 | + /* 看看删除集合和从表中是否都存在该条数据 */ | |
| 714 | + let tableDataIndex = tableData.findIndex(item => item.sControlId === sId); | |
| 715 | + while (tableDataIndex > -1) { | |
| 716 | + /* 删除从表中的数据并存入删除集合中 */ | |
| 717 | + const slaveDataFilter = tableData[tableDataIndex]; | |
| 718 | + tableData.splice(tableDataIndex, 1); | |
| 719 | + slaveDataFilter.handleType = 'del'; | |
| 720 | + tableDelData.push(slaveDataFilter); | |
| 721 | + tableDataIndex = tableData.findIndex(item => item.sControlId === sId); | |
| 722 | + } | |
| 723 | + } | |
| 724 | + return { [`${name}Data`]: tableData, [`${name}DelData`]: tableDelData, [`${name}SelectedRowKeys`]: [] }; | |
| 725 | + }; | |
| 726 | + /** 删除表格数据 */ | |
| 727 | + handleTableDel = (name, isWait, tableSelectedRowKeys, isTree) => { | |
| 728 | + if (name === 'control') { | |
| 729 | + // const tableSelectedRowKeys = this.props[`${name}SelectedRowKeys`]; /* 删除时,选中行取删除参数传过来的 */ | |
| 730 | + const { | |
| 731 | + controlData, treeSelectedKeys, [`${name}SelectedRowKeys`]: tableSelectedRowKeys, sModelsType, slaveSelectedRowKeys, slaveData, | |
| 732 | + } = this.props; | |
| 733 | + if (isTree) { | |
| 734 | + /* 删除该节点及所有子节点 */ | |
| 735 | + const controlChildData = controlData.filter(item => commonUtils.isNotEmptyObject(item.sAllId) && item.sAllId.indexOf(treeSelectedKeys[0]) > -1 && item.sId !== treeSelectedKeys[0]); | |
| 736 | + if (commonUtils.isNotEmptyArr(controlData)) { | |
| 737 | + controlChildData.forEach((itemNew) => { | |
| 738 | + tableSelectedRowKeys.push(itemNew.sId); | |
| 739 | + }); | |
| 740 | + } | |
| 741 | + } | |
| 742 | + if (commonUtils.isNotEmptyArr(tableSelectedRowKeys)) { | |
| 743 | + const materialsReturnData = this.otherTableDel('materials', tableSelectedRowKeys); | |
| 744 | + const processReturnData = this.otherTableDel('process', tableSelectedRowKeys); | |
| 745 | + const controlReturnData = this.props.onDataRowDel(name, isWait, tableSelectedRowKeys); | |
| 746 | + let treeState = []; | |
| 747 | + if (sModelsType === 'sales/salesOrderPack') { | |
| 748 | + const iSlaveIndex = slaveData.findIndex(item => item.sId === slaveSelectedRowKeys[0]); | |
| 749 | + if (iSlaveIndex > -1) { | |
| 750 | + const sSlaveId = slaveData[iSlaveIndex].sId; | |
| 751 | + treeState = this.props.onGetControlTreeData(controlReturnData.controlData, true, sSlaveId); | |
| 752 | + } | |
| 753 | + } | |
| 754 | + this.props.onSaveState({ | |
| 755 | + ...materialsReturnData, | |
| 756 | + ...processReturnData, | |
| 757 | + ...controlReturnData, | |
| 758 | + ...treeState, | |
| 759 | + }); | |
| 760 | + return true; | |
| 761 | + } else { | |
| 762 | + message.warn('请选择要删除的部件!'); | |
| 763 | + return false; | |
| 764 | + } | |
| 765 | + } else { | |
| 766 | + return this.props.onDataRowDel(name, isWait, tableSelectedRowKeys); | |
| 767 | + } | |
| 768 | + }; | |
| 769 | + /** 销售订单删除从表数据时也删除控制材料工序表数据 */ | |
| 770 | + handleSlaveTableDel = (name, isWait, tableSelectedRowKeys) => { | |
| 771 | + const { | |
| 772 | + sModelsType, controlData, processData, materialsData, | |
| 773 | + } = this.props; | |
| 774 | + if (sModelsType === 'sales/salesOrder' && name === 'slave') { | |
| 775 | + const controlDataDel = controlData.filter(item => item.sSlaveId === tableSelectedRowKeys[0]); | |
| 776 | + const controlDataSelectedRowKeys = []; | |
| 777 | + if (!commonUtils.isEmpty(controlDataDel)) { | |
| 778 | + for (const item of controlDataDel) { | |
| 779 | + const materialsDataSelectedRowKey = item.sId; | |
| 780 | + controlDataSelectedRowKeys.push(materialsDataSelectedRowKey); | |
| 781 | + } | |
| 782 | + if (commonUtils.isNotEmptyArr(controlDataSelectedRowKeys)) { | |
| 783 | + this.props.onDataRowDel('control', isWait, controlDataSelectedRowKeys, true); | |
| 784 | + } | |
| 785 | + const materialsDataDel = materialsData.filter(item => item.sSlaveId === tableSelectedRowKeys[0]); | |
| 786 | + const materialsDataSelectedRowKeys = []; | |
| 787 | + if (!commonUtils.isEmpty(materialsDataDel)) { | |
| 788 | + for (const item of materialsDataDel) { | |
| 789 | + const materialsDataSelectedRowKey = item.sId; | |
| 790 | + materialsDataSelectedRowKeys.push(materialsDataSelectedRowKey); | |
| 791 | + } | |
| 792 | + } | |
| 793 | + if (commonUtils.isNotEmptyArr(materialsDataSelectedRowKeys)) { | |
| 794 | + this.props.onDataRowDel('materials', isWait, materialsDataSelectedRowKeys, true); | |
| 795 | + } | |
| 796 | + const processDataDel = processData.filter(item => item.sSlaveId === tableSelectedRowKeys[0]); | |
| 797 | + const processDataSelectedRowKeys = []; | |
| 798 | + if (!commonUtils.isEmpty(processDataDel)) { | |
| 799 | + for (const item of processDataDel) { | |
| 800 | + const processDataSelectedRowKey = item.sId; | |
| 801 | + processDataSelectedRowKeys.push(processDataSelectedRowKey); | |
| 802 | + } | |
| 803 | + } | |
| 804 | + if (commonUtils.isNotEmptyArr(processDataSelectedRowKeys)) { | |
| 805 | + this.props.onDataRowDel('process', isWait, processDataSelectedRowKeys, true); | |
| 806 | + } | |
| 807 | + } | |
| 808 | + } | |
| 809 | + return this.props.onDataRowDel(name, isWait, tableSelectedRowKeys); | |
| 810 | + }; | |
| 811 | + handleSelect = async (name, selectConfig, selectData) => { | |
| 812 | + const { | |
| 813 | + [`${name}Data`]: tableData, [`${name}Config`]: tableConfig, masterData, masterConfig, controlSelectedRowKeys, sModelsId, token, app, tableName, sModelsType, | |
| 814 | + } = this.props; | |
| 815 | + const tableSelectedRowKeys = []; | |
| 816 | + if (sModelsType !== '' && sModelsType.includes('sales/') && name === 'productProcessInfo') { /* 销售订单调用工艺卡 */ | |
| 817 | + const { | |
| 818 | + controlConfig, materialsConfig, processConfig, slaveSelectedRowKeys, slaveData, | |
| 819 | + } = this.props; | |
| 820 | + const iIndex = slaveData.findIndex(item => slaveSelectedRowKeys.includes(item.sId)); | |
| 821 | + if (iIndex > -1 && commonUtils.isNotEmptyArr(selectData)) { | |
| 822 | + const tableDataRow = slaveData[iIndex]; /* 从表选中行 */ | |
| 823 | + let { controlData, materialsData, processData } = this.props; | |
| 824 | + const sId = tableDataRow.sId; | |
| 825 | + const bCkxCopyFromTechnology = '1'; // app.systemData.filter(item => item.sName === 'CkxCopyFromTechnology')[0].sValue; | |
| 826 | + if (bCkxCopyFromTechnology === '1' && tableDataRow.sProductId !== tableDataRow.sProductName) { | |
| 827 | + const controlSelectedData = controlData.filter(item => item.sSlaveId === sId); | |
| 828 | + if (commonUtils.isNotEmptyObject(controlSelectedData)) { | |
| 829 | + const controlSelectedRowKeys = []; | |
| 830 | + controlSelectedData.forEach((item) => { | |
| 831 | + controlSelectedRowKeys.push(item.sId); | |
| 832 | + }); | |
| 833 | + const materialsReturnData = this.otherTableDel('materials', controlSelectedRowKeys); | |
| 834 | + const processReturnData = this.otherTableDel('process', controlSelectedRowKeys); | |
| 835 | + const controlReturnData = this.props.onDataRowDel('control', true, controlSelectedRowKeys); | |
| 836 | + controlData = controlReturnData.controlData; | |
| 837 | + materialsData = materialsReturnData.materialsData; | |
| 838 | + processData = processReturnData.processData; | |
| 839 | + this.props.onSaveState({ | |
| 840 | + ...materialsReturnData, | |
| 841 | + ...processReturnData, | |
| 842 | + ...controlReturnData, | |
| 843 | + }); | |
| 844 | + } | |
| 845 | + const sCustomerId = selectData[0].sCustomerId; | |
| 846 | + const sProductId = selectData[0].sProductId; | |
| 847 | + const sProductIdArray = []; | |
| 848 | + sProductIdArray.push(sProductId); | |
| 849 | + const sProductIds = sProductIdArray.toString(); | |
| 850 | + const condition = { | |
| 851 | + sCustomerId, sProductIds, | |
| 852 | + }; | |
| 853 | + const dataUrl = `${commonConfig.server_host}salesorder/getProcessCardDataByCustomIdProductId/?sModelsId=${sModelsId}`; | |
| 854 | + const dataReturn = (await commonServices.postValueService(token, condition, dataUrl)).data; | |
| 855 | + const config = this.props.masterConfig.gdsconfigformslave.filter(item => item.sControlName.includes('BtnCopyFrom.productProcessInfo')); | |
| 856 | + if (dataReturn.code === 1) { | |
| 857 | + const returnData = dataReturn.dataset.rows[0]; | |
| 858 | + const copyToControlConfig = config.filter(item => item.sControlName.toLowerCase().includes('.control')); | |
| 859 | + const copyToMaterialsConfig = config.filter(item => item.sControlName.toLowerCase().includes('.materials')); | |
| 860 | + const copyToProcessConfig = config.filter(item => item.sControlName.toLowerCase().includes('.process')); | |
| 861 | + const controlAssignField = commonUtils.isNotEmptyArr(copyToControlConfig) ? copyToControlConfig[0].sAssignField : ''; | |
| 862 | + const materialsAssignField = commonUtils.isNotEmptyArr(copyToMaterialsConfig) ? copyToMaterialsConfig[0].sAssignField : ''; | |
| 863 | + const processAssignField = commonUtils.isNotEmptyArr(copyToProcessConfig) ? copyToProcessConfig[0].sAssignField : ''; | |
| 864 | + const newCopyTo = {}; | |
| 865 | + newCopyTo.master = masterData; | |
| 866 | + newCopyTo.slave = commonUtils.isEmptyArr(tableData) ? {} : tableData; | |
| 867 | + if (commonUtils.isNotEmptyArr(returnData.controlData)) { | |
| 868 | + const treeCopyNodes = new Map(); | |
| 869 | + // eslint-disable-next-line no-loop-func | |
| 870 | + returnData.controlData.forEach((controlItem) => { | |
| 871 | + newCopyTo.control = controlItem; | |
| 872 | + let controlRow = commonFunc.getDefaultData(controlConfig, newCopyTo); // 取默认值 | |
| 873 | + controlRow = { ...controlRow, ...commonFunc.getAssignFieldValue(controlAssignField, controlItem, newCopyTo) }; // 取赋值字段 | |
| 874 | + controlRow.handleType = 'add'; | |
| 875 | + controlRow.sId = commonUtils.createSid(); | |
| 876 | + controlRow.sSlaveId = tableDataRow.sId; | |
| 877 | + controlRow.sParentId = masterData.sId; | |
| 878 | + if (sModelsType === 'sales/salesOrderPack') { /* 树形 */ | |
| 879 | + /* CopyTo时sAllId,sControlParentId 设置 */ | |
| 880 | + const sAllOldId = controlItem.sAllId; | |
| 881 | + let arr = []; | |
| 882 | + if (commonUtils.isNotEmptyObject(sAllOldId)) { | |
| 883 | + arr = sAllOldId.split(','); | |
| 884 | + } | |
| 885 | + const newId = controlRow.sId; | |
| 886 | + let sOldParentId = ''; | |
| 887 | + let sNewParentAllId = ''; | |
| 888 | + if (arr.length < 2) { /* 根节点复制 */ | |
| 889 | + controlRow.sAllId = newId; | |
| 890 | + sOldParentId = newId; | |
| 891 | + sNewParentAllId = newId; | |
| 892 | + } else { | |
| 893 | + sOldParentId = arr[arr.length - 2]; | |
| 894 | + if (treeCopyNodes.has(sOldParentId)) { | |
| 895 | + sNewParentAllId = treeCopyNodes.get(sOldParentId); | |
| 896 | + } else { | |
| 897 | + const obj = arr[arr.length - 1]; | |
| 898 | + sNewParentAllId = sAllOldId.replace((`,${obj}`), ''); | |
| 899 | + } | |
| 900 | + const sNewArr = sNewParentAllId.split(','); | |
| 901 | + controlRow.sControlParentId = sNewArr[sNewArr.length - 1]; | |
| 902 | + sNewParentAllId = `${sNewParentAllId},${newId}`; | |
| 903 | + controlRow.sAllId = sNewParentAllId; | |
| 904 | + } | |
| 905 | + treeCopyNodes.set(controlItem.sId, sNewParentAllId); | |
| 906 | + } | |
| 907 | + controlData.push(controlRow); | |
| 908 | + | |
| 909 | + if (commonUtils.isNotEmptyArr(returnData.materialsData)) { | |
| 910 | + returnData.materialsData.filter(item => item.sControlId === controlItem.sId) | |
| 911 | + .forEach((materialsItem) => { | |
| 912 | + newCopyTo.materials = materialsItem; | |
| 913 | + let materialsRow = commonFunc.getDefaultData(materialsConfig, newCopyTo); // 取默认值 | |
| 914 | + materialsRow = { ...materialsRow, ...commonFunc.getAssignFieldValue(materialsAssignField, materialsItem, newCopyTo) }; // 取赋值字段 | |
| 915 | + materialsRow.handleType = 'add'; | |
| 916 | + materialsRow.sId = commonUtils.createSid(); | |
| 917 | + materialsRow.sSlaveId = tableDataRow.sId; | |
| 918 | + materialsRow.sParentId = masterData.sId; | |
| 919 | + materialsRow.sControlId = controlRow.sId; | |
| 920 | + materialsRow.sPartsName = controlRow.sPartsName; | |
| 921 | + | |
| 922 | + materialsData.push(materialsRow); | |
| 923 | + }); | |
| 924 | + } | |
| 925 | + | |
| 926 | + if (commonUtils.isNotEmptyArr(returnData.processData)) { | |
| 927 | + returnData.processData.filter(item => item.sControlId === controlItem.sId) | |
| 928 | + .forEach((processItem) => { | |
| 929 | + newCopyTo.process = processItem; | |
| 930 | + let processRow = commonFunc.getDefaultData(processConfig, newCopyTo); // 取默认值 | |
| 931 | + processRow = { ...processRow, ...commonFunc.getAssignFieldValue(processAssignField, processItem, newCopyTo) }; // 取赋值字段 | |
| 932 | + processRow.handleType = 'add'; | |
| 933 | + processRow.sId = commonUtils.createSid(); | |
| 934 | + processRow.sSlaveId = tableDataRow.sId; | |
| 935 | + processRow.sParentId = masterData.sId; | |
| 936 | + processRow.sControlId = controlRow.sId; | |
| 937 | + processRow.sPartsName = controlRow.sPartsName; | |
| 938 | + processData.push(processRow); | |
| 939 | + }); | |
| 940 | + } | |
| 941 | + }); | |
| 942 | + } | |
| 943 | + if (commonUtils.isNotEmptyArr(returnData.materialsData)) { | |
| 944 | + // eslint-disable-next-line no-loop-func | |
| 945 | + returnData.materialsData.filter(item => item.sType === '2') | |
| 946 | + .forEach((materialsItem) => { | |
| 947 | + newCopyTo.materials = materialsItem; | |
| 948 | + let materialsRow = commonFunc.getDefaultData(materialsConfig, newCopyTo); // 取默认值 | |
| 949 | + materialsRow = { ...materialsRow, ...commonFunc.getAssignFieldValue(materialsAssignField, materialsItem, newCopyTo) }; // 取赋值字段 | |
| 950 | + materialsRow.handleType = 'add'; | |
| 951 | + materialsRow.sId = commonUtils.createSid(); | |
| 952 | + materialsRow.sSlaveId = tableDataRow.sId; | |
| 953 | + materialsRow.sParentId = masterData.sId; | |
| 954 | + materialsData.push(materialsRow); | |
| 955 | + }); | |
| 956 | + } | |
| 957 | + if (commonUtils.isNotEmptyArr(returnData.processData)) { | |
| 958 | + // eslint-disable-next-line no-loop-func | |
| 959 | + returnData.processData.filter(item => item.sType === '3') | |
| 960 | + .forEach((processItem) => { | |
| 961 | + newCopyTo.process = processItem; | |
| 962 | + let processRow = commonFunc.getDefaultData(processConfig, newCopyTo); // 取默认值 | |
| 963 | + processRow = { ...processRow, ...commonFunc.getAssignFieldValue(processAssignField, processItem, newCopyTo) }; // 取赋值字段 | |
| 964 | + processRow.handleType = 'add'; | |
| 965 | + processRow.sId = commonUtils.createSid(); | |
| 966 | + processRow.sSlaveId = tableDataRow.sId; | |
| 967 | + processRow.sParentId = masterData.sId; | |
| 968 | + processData.push(processRow); | |
| 969 | + }); | |
| 970 | + } | |
| 971 | + /* 包装订单 生成树形 */ | |
| 972 | + let treeState = {}; | |
| 973 | + if (sModelsType === 'sales/salesOrderPack') { | |
| 974 | + treeState = this.props.onGetControlTreeData(controlData, true); | |
| 975 | + } | |
| 976 | + this.props.onSaveState({ | |
| 977 | + controlData, | |
| 978 | + materialsData, | |
| 979 | + processData, | |
| 980 | + ...treeState, | |
| 981 | + }); | |
| 982 | + } | |
| 983 | + } | |
| 984 | + } | |
| 985 | + } else if (name === 'productProcessInfoAbandon') { /* 暂未使用的调用工艺卡功能 */ | |
| 986 | + if (commonUtils.isNotEmptyArr(selectData)) { | |
| 987 | + let slaveData = []; | |
| 988 | + let controlData = []; | |
| 989 | + let materialsData = []; | |
| 990 | + let processData = []; | |
| 991 | + let sConfigMasterIdSlave = ''; | |
| 992 | + let sConfigMasterIdControl = ''; | |
| 993 | + let sConfigMasterIdMaterials = ''; | |
| 994 | + let sConfigMasterIdProcess = ''; | |
| 995 | + const selectRowData = selectData[0]; | |
| 996 | + const sConfigIdString = masterConfig.gdsconfigformslave.filter(item => item.sName === 'sConfigId')[0].showDropDown; | |
| 997 | + if (commonUtils.isNotEmptyStr(sConfigIdString)) { | |
| 998 | + const sConfigId = JSON.parse(sConfigIdString); | |
| 999 | + sConfigMasterIdSlave = sConfigId.sConfigMasterIdSlave; | |
| 1000 | + sConfigMasterIdControl = sConfigId.sConfigMasterIdControl; | |
| 1001 | + sConfigMasterIdMaterials = sConfigId.sConfigMasterIdMaterials; | |
| 1002 | + sConfigMasterIdProcess = sConfigId.sConfigMasterIdProcess; | |
| 1003 | + } | |
| 1004 | + if (commonUtils.isEmptyStr(sConfigMasterIdSlave)) { | |
| 1005 | + message.warning(commonFunc.showMessage(app.commonConst, 'slaveParameterErro')); | |
| 1006 | + } | |
| 1007 | + if (commonUtils.isEmptyStr(sConfigMasterIdControl)) { | |
| 1008 | + message.warning(commonFunc.showMessage(app.commonConst, 'controlParameterErro')); | |
| 1009 | + } | |
| 1010 | + if (commonUtils.isEmptyStr(sConfigMasterIdMaterials)) { | |
| 1011 | + message.warning(commonFunc.showMessage(app.commonConst, 'materialsParameterErro')); | |
| 1012 | + } | |
| 1013 | + if (commonUtils.isEmptyStr(sConfigMasterIdProcess)) { | |
| 1014 | + message.warning(commonFunc.showMessage(app.commonConst, 'processParameterErro')); | |
| 1015 | + } | |
| 1016 | + const slaveUrl = `${commonConfig.server_host}business/getBusinessDataByFormcustomId/${sConfigMasterIdSlave}?sModelsId=${sModelsId}`; | |
| 1017 | + const value = { sSqlCondition: { sParentId: selectRowData.sId } }; | |
| 1018 | + const slaveReturnData = (await commonServices.postValueService(token, value, slaveUrl)).data; | |
| 1019 | + if (slaveReturnData.code === 1) { | |
| 1020 | + slaveData = slaveReturnData.dataset.rows[0].dataSet; | |
| 1021 | + slaveData.forEach((item) => { | |
| 1022 | + item.handleType = 'add'; | |
| 1023 | + item.sId = commonUtils.createSid(); | |
| 1024 | + item.sParentId = masterData.sId; | |
| 1025 | + }); | |
| 1026 | + } else { | |
| 1027 | + this.props.getServiceError(slaveReturnData); | |
| 1028 | + } | |
| 1029 | + | |
| 1030 | + const controlUrl = `${commonConfig.server_host}business/getBusinessDataByFormcustomId/${sConfigMasterIdControl}?sModelsId=${sModelsId}`; | |
| 1031 | + const controlReturnData = (await commonServices.postValueService(token, value, controlUrl)).data; | |
| 1032 | + if (controlReturnData.code === 1) { | |
| 1033 | + controlData = controlReturnData.dataset.rows[0].dataSet; | |
| 1034 | + controlData.forEach((item) => { | |
| 1035 | + item.handleType = 'add'; | |
| 1036 | + item.sId = commonUtils.createSid(); | |
| 1037 | + item.sParentId = masterData.sId; | |
| 1038 | + }); | |
| 1039 | + } else { | |
| 1040 | + this.props.getServiceError(controlReturnData); | |
| 1041 | + } | |
| 1042 | + const materialsUrl = `${commonConfig.server_host}business/getBusinessDataByFormcustomId/${sConfigMasterIdMaterials}?sModelsId=${sModelsId}`; | |
| 1043 | + const materialsReturnData = (await commonServices.postValueService(token, value, materialsUrl)).data; | |
| 1044 | + if (materialsReturnData.code === 1) { | |
| 1045 | + materialsData = materialsReturnData.dataset.rows[0].dataSet; | |
| 1046 | + materialsData.forEach((item) => { | |
| 1047 | + item.handleType = 'add'; | |
| 1048 | + item.sId = commonUtils.createSid(); | |
| 1049 | + item.sParentId = masterData.sId; | |
| 1050 | + }); | |
| 1051 | + } else { | |
| 1052 | + this.props.getServiceError(materialsReturnData); | |
| 1053 | + } | |
| 1054 | + const processUrl = `${commonConfig.server_host}business/getBusinessDataByFormcustomId/${sConfigMasterIdProcess}?sModelsId=${sModelsId}`; | |
| 1055 | + const processReturnData = (await commonServices.postValueService(token, value, processUrl)).data; | |
| 1056 | + if (processReturnData.code === 1) { | |
| 1057 | + processData = processReturnData.dataset.rows[0].dataSet; | |
| 1058 | + processData.forEach((item) => { | |
| 1059 | + item.handleType = 'add'; | |
| 1060 | + item.sId = commonUtils.createSid(); | |
| 1061 | + item.sParentId = masterData.sId; | |
| 1062 | + }); | |
| 1063 | + } else { | |
| 1064 | + this.props.getServiceError(processReturnData); | |
| 1065 | + } | |
| 1066 | + this.props.onSaveState({ | |
| 1067 | + processData, materialsData, controlData, slaveData, [`${name}ChooseVisible`]: false, [`${name}SelectedRowKeys`]: tableSelectedRowKeys, | |
| 1068 | + }); | |
| 1069 | + } | |
| 1070 | + } else if (tableName === 'slave' && selectConfig.sControlName === 'BtnChooseMaterials') { | |
| 1071 | + this.props.onSelect('slave', selectConfig, selectData); | |
| 1072 | + } else if (sModelsType.includes('cashier/') && selectConfig.sControlName === 'BtnImportFormData') { | |
| 1073 | + const { slaveData } = this.props; | |
| 1074 | + let tableDataNew = []; | |
| 1075 | + if (commonUtils.isNotEmptyArr(slaveData)) { | |
| 1076 | + tableDataNew = slaveData; | |
| 1077 | + tableDataNew.forEach((item, index) => { | |
| 1078 | + const handleType = item.handleType; | |
| 1079 | + if (commonUtils.isEmptyObject(handleType) || handleType === 'update') { | |
| 1080 | + tableDataNew[index] = { ...item, handleType: 'del' }; | |
| 1081 | + } | |
| 1082 | + }); | |
| 1083 | + } | |
| 1084 | + if (commonUtils.isNotEmptyArr(selectData)) { | |
| 1085 | + selectData.forEach((item) => { | |
| 1086 | + let tableDataRow = {}; // 取默认值 | |
| 1087 | + tableDataRow = { ...tableDataRow, ...commonFunc.getAssignFieldValue(selectConfig.sAssignField, item) }; // 取赋值字段 | |
| 1088 | + tableDataRow.handleType = 'add'; | |
| 1089 | + tableDataRow.sId = commonUtils.createSid(); | |
| 1090 | + tableDataRow.sParentId = masterData.sId; | |
| 1091 | + tableDataNew.push(tableDataRow); | |
| 1092 | + }); | |
| 1093 | + this.props.onSaveState({ slaveData: tableDataNew, importFormDataVisible: false }); | |
| 1094 | + } | |
| 1095 | + } else { | |
| 1096 | + const { controlData, slaveData, slaveSelectedRowKeys } = this.props; | |
| 1097 | + const iIndex = commonUtils.isNotEmptyArr(controlSelectedRowKeys) ? controlData.findIndex(item => item.sId === controlSelectedRowKeys[0]) : -1; | |
| 1098 | + if (commonUtils.isNotEmptyArr(selectData)) { | |
| 1099 | + selectData.forEach((item) => { | |
| 1100 | + const newCopyTo = {}; | |
| 1101 | + newCopyTo.master = masterData; | |
| 1102 | + if (iIndex > -1) { | |
| 1103 | + newCopyTo.control = controlData[iIndex]; | |
| 1104 | + } | |
| 1105 | + let tableDataRow = commonFunc.getDefaultData(tableConfig, newCopyTo); // 取默认值 | |
| 1106 | + tableDataRow = { ...tableDataRow, ...commonFunc.getAssignFieldValue(selectConfig.sAssignField, item, newCopyTo) }; // 取赋值字段 | |
| 1107 | + tableDataRow.handleType = 'add'; | |
| 1108 | + tableDataRow.sId = commonUtils.createSid(); | |
| 1109 | + tableDataRow.sParentId = masterData.sId; | |
| 1110 | + if (this.props.sModelsType.includes('sales/salesOrder')) { | |
| 1111 | + const iSlaveIndex = commonUtils.isNotEmptyArr(slaveSelectedRowKeys) ? slaveData.findIndex(item => item.sId === slaveSelectedRowKeys[0]) : -1; | |
| 1112 | + if (iSlaveIndex > -1) { | |
| 1113 | + tableDataRow.sSlaveId = slaveData[iSlaveIndex].sId; | |
| 1114 | + } | |
| 1115 | + } | |
| 1116 | + if (iIndex > -1 && tableDataRow.sType !== '3') { | |
| 1117 | + tableDataRow.sControlId = controlData[iIndex].sId; | |
| 1118 | + tableDataRow.sPartsName = controlData[iIndex].sPartsName; | |
| 1119 | + tableData.push(tableDataRow); | |
| 1120 | + } else if (tableDataRow.sType === '3') { | |
| 1121 | + tableData.push(tableDataRow); | |
| 1122 | + } | |
| 1123 | + tableSelectedRowKeys.push(tableDataRow.sId); | |
| 1124 | + }); | |
| 1125 | + } | |
| 1126 | + const tableDataNew = this.sortData(controlData, tableData); | |
| 1127 | + this.props.onSaveState({ [`${name}Data`]: tableDataNew, [`${name}ChooseVisible`]: false, [`${name}SelectedRowKeys`]: tableSelectedRowKeys }); | |
| 1128 | + } | |
| 1129 | + }; | |
| 1130 | + | |
| 1131 | + /** 树节点选中 */ | |
| 1132 | + handleTreeSelect = (name, checkedKeys, e) => { | |
| 1133 | + let { controlSelectedRowKeys } = this.props; | |
| 1134 | + controlSelectedRowKeys = checkedKeys; /* 把树形选中节点赋值给表格部件选中节点 */ | |
| 1135 | + this.props.onTreeSelect(name, checkedKeys, e); | |
| 1136 | + this.props.onSaveState({ | |
| 1137 | + controlSelectedRowKeys, | |
| 1138 | + }); | |
| 1139 | + }; | |
| 1140 | + | |
| 1141 | + sortData = (tableData, processData) => { | |
| 1142 | + processData.sort((g1, g2) => { | |
| 1143 | + const iIndex1 = tableData.findIndex(item => item.sId === g1.sControlId) === -1 ? 999 : tableData.findIndex(item => item.sId === g1.sControlId); | |
| 1144 | + let sPartOrder1 = `0000${iIndex1}`; | |
| 1145 | + sPartOrder1 = sPartOrder1.substring(sPartOrder1.length - 3); | |
| 1146 | + let sOrder1 = `000${g1.iOrder}`; | |
| 1147 | + sOrder1 = sOrder1.substring(sOrder1.length - 3); | |
| 1148 | + | |
| 1149 | + const iIndex2 = tableData.findIndex(item => item.sId === g2.sControlId) === -1 ? 999 : tableData.findIndex(item => item.sId === g2.sControlId); | |
| 1150 | + let sPartOrder2 = `0000${iIndex2}`; | |
| 1151 | + sPartOrder2 = sPartOrder2.substring(sPartOrder2.length - 3); | |
| 1152 | + let sOrder2 = `000${g2.iOrder}`; | |
| 1153 | + sOrder2 = sOrder2.substring(sOrder2.length - 3); | |
| 1154 | + return parseInt(sPartOrder1 + g1.sType + sOrder1, 10) - parseInt(sPartOrder2 + g2.sType + sOrder2, 10); | |
| 1155 | + }); | |
| 1156 | + return processData; | |
| 1157 | + }; | |
| 1158 | + handleGetDataOk = () => { | |
| 1159 | + this.props.onDataImport('zero'); | |
| 1160 | + } | |
| 1161 | + handleGetDataCancel = () => { | |
| 1162 | + this.props.onDataImport('all'); | |
| 1163 | + } | |
| 1164 | + colseGetDataVisible = () => { | |
| 1165 | + this.props.onSaveState({ isGetDataVisible: false }); | |
| 1166 | + } | |
| 1167 | + | |
| 1168 | + /* 审核备注文本框改变事件 */ | |
| 1169 | + textChange= (e, record) => { | |
| 1170 | + const sCheckRemark = commonUtils.isNotEmptyObject(record) && commonUtils.isNotEmptyObject(e.target.value) ? e.target.value : ''; | |
| 1171 | + this.props.onSaveState({ sCheckRemark });/* 审核备注 */ | |
| 1172 | + } | |
| 1173 | + // ----------------------------数据修改回带end ---------------------------- // | |
| 1174 | + | |
| 1175 | + render() { | |
| 1176 | + const { | |
| 1177 | + pageLoading, masterConfig, visible, checkConditions, checkPersonData, visibleModal, processChooseVisible, materialsChooseVisible, app, sTabId, sModelsType, enabled, slaveSelectedRowKeys, | |
| 1178 | + } = this.props; | |
| 1179 | + const checkCondition = commonFunc.showMessage(app.commonConst, 'checkCondition');/* 审核条件 */ | |
| 1180 | + const checkSmemo = commonFunc.showMessage(app.commonConst, 'checkSmemo');/* 备注 */ | |
| 1181 | + const columns = [{ | |
| 1182 | + title: checkCondition, | |
| 1183 | + dataIndex: 'condition', | |
| 1184 | + key: 'condition', | |
| 1185 | + }, { | |
| 1186 | + title: checkSmemo, | |
| 1187 | + dataIndex: 'sMemo', | |
| 1188 | + key: 'sMemo', | |
| 1189 | + render: (text, record) => { | |
| 1190 | + return ( | |
| 1191 | + <Form> | |
| 1192 | + <Input onChange={(e) => { this.textChange(e, record); }} /> | |
| 1193 | + </Form> | |
| 1194 | + ); | |
| 1195 | + }, | |
| 1196 | + }]; | |
| 1197 | + let chooseProcessConfig; | |
| 1198 | + let onChooseProcessIndex; | |
| 1199 | + /* 获取toolbar 选择工序 */ | |
| 1200 | + if (commonUtils.isNotEmptyObject(masterConfig)) { | |
| 1201 | + onChooseProcessIndex = masterConfig.gdsconfigformslave.findIndex(item => item.sControlName === 'BtnChooseProcess'); | |
| 1202 | + if (onChooseProcessIndex > -1) { | |
| 1203 | + chooseProcessConfig = this.props.masterConfig.gdsconfigformslave[onChooseProcessIndex]; | |
| 1204 | + } | |
| 1205 | + } | |
| 1206 | + /* 获取toolbar 选择材料 */ | |
| 1207 | + let chooseMaterialsConfig; | |
| 1208 | + const modalWidth = '1132'; | |
| 1209 | + const fixedAutoHeight = sModelsType === 'sales/salesOrderPack' ? 120 : 66; | |
| 1210 | + if (commonUtils.isNotEmptyObject(masterConfig)) { | |
| 1211 | + const iIndex = masterConfig.gdsconfigformslave.findIndex(item => item.sControlName === 'BtnChooseMaterials'); | |
| 1212 | + if (iIndex > -1) { | |
| 1213 | + chooseMaterialsConfig = masterConfig.gdsconfigformslave[iIndex]; | |
| 1214 | + } | |
| 1215 | + } | |
| 1216 | + /* 若销售订单从表选中行被工单或其他调用 则材料与工艺只能查看不能操作s */ | |
| 1217 | + let bUsed = enabled; | |
| 1218 | + if (sModelsType.includes('sales/salesOrder') && enabled && commonUtils.isNotEmptyArr(slaveSelectedRowKeys)) { | |
| 1219 | + const { slaveData } = this.props; | |
| 1220 | + const iSlaveDataIndex = slaveData.findIndex(item => slaveSelectedRowKeys.includes(item.sId)); | |
| 1221 | + if (iSlaveDataIndex > -1) { | |
| 1222 | + const sWorkOrderUsed = slaveData[iSlaveDataIndex].sWorkOrderUsed; | |
| 1223 | + if (commonUtils.isNotEmptyObject(sWorkOrderUsed)) { | |
| 1224 | + bUsed = false; | |
| 1225 | + } | |
| 1226 | + } | |
| 1227 | + } | |
| 1228 | + | |
| 1229 | + const controlPropsType = { | |
| 1230 | + ...commonBusiness.getTableTypes('control', this.props), | |
| 1231 | + tableProps: { | |
| 1232 | + CalLastWidth: modalWidth, AutoTableHeight: fixedAutoHeight, setCopyAll, setProcess, setMaterial, chooseProcessConfigRow: chooseProcessConfig, chooseMaterialsConfigRow: chooseMaterialsConfig, onRow: (record) => { return { onClick: () => { this.onRowClick('control', record); } }; }, | |
| 1233 | + }, | |
| 1234 | + filteredValue: this.props.slaveSelectedRowKeys, | |
| 1235 | + onFilterData: this.handleFilterSlaveData, | |
| 1236 | + OnGetFilterData: this.handleGetFilterData, | |
| 1237 | + onAddRow: this.handleTableAdd, | |
| 1238 | + onDelRow: this.handleTableDel, | |
| 1239 | + onKeyDown: this.props.onKeyDown, | |
| 1240 | + enabled: bUsed, | |
| 1241 | + }; | |
| 1242 | + const name = 'controlTree'; | |
| 1243 | + const treeProps = { | |
| 1244 | + ...commonBusiness.getTreeTypes('tree', this.props), | |
| 1245 | + isSearch: false, | |
| 1246 | + checkable: false, | |
| 1247 | + disabled: false, | |
| 1248 | + checkedAll: false, | |
| 1249 | + unChecked: false, | |
| 1250 | + [`${name}Column`]: this.props[`${name}Column`], | |
| 1251 | + [`${name}Config`]: this.props[`${name}Config`], | |
| 1252 | + [`${name}Data`]: this.props[`${name}Data`], | |
| 1253 | + getFloatNum: this.props.getFloatNum, | |
| 1254 | + getSqlDropDownData: this.props.getSqlDropDownData, | |
| 1255 | + getSqlCondition: this.props.getSqlCondition, | |
| 1256 | + handleSqlDropDownNewRecord: this.props.handleSqlDropDownNewRecord, | |
| 1257 | + getDateFormat: this.props.getDateFormat, | |
| 1258 | + onDoubleClick: this.props.onDoubleClick, | |
| 1259 | + onSelect: this.handleTreeSelect, | |
| 1260 | + expandedKeys: this.props.expandedKeys, | |
| 1261 | + showLine: true, | |
| 1262 | + }; | |
| 1263 | + const materialsPropsType = { | |
| 1264 | + ...commonBusiness.getTableTypes('materials', this.props), | |
| 1265 | + tableProps: { CalLastWidth: modalWidth, AutoTableHeight: fixedAutoHeight }, | |
| 1266 | + filteredValue: this.props.controlSelectedRowKeys, | |
| 1267 | + onFilterData: this.handleFilterData, | |
| 1268 | + OnGetFilterData: this.handleGetFilterData, | |
| 1269 | + onAddRow: this.handleTableAdd, | |
| 1270 | + onKeyDown: this.props.onKeyDown, | |
| 1271 | + enabled: bUsed, | |
| 1272 | + }; | |
| 1273 | + const processPropsType = { | |
| 1274 | + ...commonBusiness.getTableTypes('process', this.props), | |
| 1275 | + tableProps: { CalLastWidth: modalWidth, AutoTableHeight: 132 }, | |
| 1276 | + filteredValue: this.props.controlSelectedRowKeys, | |
| 1277 | + onFilterData: this.handleFilterData, | |
| 1278 | + OnGetFilterData: this.handleGetFilterData, | |
| 1279 | + onAddRow: this.handleTableAdd, | |
| 1280 | + onChooseProcessRow: this.handleTableChooseProcess, | |
| 1281 | + onKeyDown: this.props.onKeyDown, | |
| 1282 | + enabled: bUsed, | |
| 1283 | + }; | |
| 1284 | + let searchProcessType = {}; | |
| 1285 | + // let chooseProcessConfig = {}; | |
| 1286 | + if (commonUtils.isNotEmptyObject(this.props.processChooseData)) { | |
| 1287 | + // const iIndex = this.props.processConfig.gdsconfigformslave.findIndex(item => item.sControlName === 'BtnChooseProcess'); | |
| 1288 | + // if (iIndex > -1) { | |
| 1289 | + // chooseProcessConfig = this.props.processConfig.gdsconfigformslave[iIndex]; | |
| 1290 | + // } | |
| 1291 | + | |
| 1292 | + searchProcessType = { | |
| 1293 | + app: { | |
| 1294 | + ...this.props.app, | |
| 1295 | + currentPane: { | |
| 1296 | + name: 'process', | |
| 1297 | + config: chooseProcessConfig, | |
| 1298 | + conditonValues: this.props.getSqlCondition(chooseProcessConfig), | |
| 1299 | + title: this.props.processChooseData.sMenuName, | |
| 1300 | + route: this.props.processChooseData.sName, | |
| 1301 | + formId: this.props.processChooseData.sId, | |
| 1302 | + key: this.props.sModelsId + this.props.processChooseData.sId, | |
| 1303 | + sModelsType: this.props.processChooseData.sModelType, | |
| 1304 | + select: this.handleSelect, | |
| 1305 | + selectCancel: this.props.onSelectCancel, | |
| 1306 | + }, | |
| 1307 | + }, | |
| 1308 | + dispatch: this.props.dispatch, | |
| 1309 | + content: this.props.content, | |
| 1310 | + id: new Date().getTime().toString(), | |
| 1311 | + realizeHeight: this.props.realizeHeight, /* 拖动偏移高度 */ | |
| 1312 | + }; | |
| 1313 | + } | |
| 1314 | + | |
| 1315 | + | |
| 1316 | + let searchMaterialsType = {}; | |
| 1317 | + // let chooseMaterialsConfig = {}; | |
| 1318 | + if (commonUtils.isNotEmptyObject(this.props.materialsChooseData) && this.props.tableName !== 'slave') { | |
| 1319 | + // const iIndex = this.props.materialsConfig.gdsconfigformslave.findIndex(item => item.sControlName === 'BtnChooseMaterials'); | |
| 1320 | + // if (iIndex > -1) { | |
| 1321 | + // chooseMaterialsConfig = this.props.materialsConfig.gdsconfigformslave[iIndex]; | |
| 1322 | + // } | |
| 1323 | + | |
| 1324 | + searchMaterialsType = { | |
| 1325 | + app: { | |
| 1326 | + ...this.props.app, | |
| 1327 | + currentPane: { | |
| 1328 | + name: 'materials', | |
| 1329 | + config: chooseMaterialsConfig, | |
| 1330 | + conditonValues: this.props.getSqlCondition(chooseMaterialsConfig), | |
| 1331 | + title: this.props.materialsChooseData.sMenuName, | |
| 1332 | + route: this.props.materialsChooseData.sName, | |
| 1333 | + formId: this.props.materialsChooseData.sId, | |
| 1334 | + key: this.props.sModelsId + this.props.materialsChooseData.sId, | |
| 1335 | + sModelsType: this.props.materialsChooseData.sModelsType, | |
| 1336 | + select: this.handleSelect, | |
| 1337 | + selectCancel: this.props.onSelectCancel, | |
| 1338 | + }, | |
| 1339 | + }, | |
| 1340 | + dispatch: this.props.dispatch, | |
| 1341 | + content: this.props.content, | |
| 1342 | + id: new Date().getTime().toString(), | |
| 1343 | + realizeHeight: this.props.realizeHeight, | |
| 1344 | + }; | |
| 1345 | + } | |
| 1346 | + const pane = app.panes.filter(paneTmp => paneTmp.key === sTabId)[0]; | |
| 1347 | + const setMaterailRemark = commonFunc.showMessage(app.commonConst, 'setMaterailRemark');/* 选择材料与工艺 */ | |
| 1348 | + const setProcessTitle = commonFunc.showMessage(app.commonConst, 'setProcess');/* 选择工序标题 */ | |
| 1349 | + const setMaterialTitle = commonFunc.showMessage(app.commonConst, 'setMaterial');/* 选择材料标题 */ | |
| 1350 | + const btnSure = commonFunc.showMessage(app.commonConst, 'btnSure');/* 确认 */ | |
| 1351 | + const check = commonFunc.showMessage(app.commonConst, 'check');/* 审核 */ | |
| 1352 | + const BtnClose = commonFunc.showMessage(app.commonConst, 'BtnClose');/* 关闭 */ | |
| 1353 | + const checkPerson = commonFunc.showMessage(app.commonConst, 'checkPerson');/* 审核人 */ | |
| 1354 | + // eslint-disable-next-line jsx-a11y/anchor-is-valid | |
| 1355 | + const operateAdd = <a title="添加同级" alt="" onClick={this.props.enabled ? this.handleTableAdd.bind(this, 'control', false, 'sameNode') : null}>{this.props.enabled ? setAdd.img : setAdd.disableimg} </a>; | |
| 1356 | + // eslint-disable-next-line jsx-a11y/anchor-is-valid | |
| 1357 | + const operateAddChild = <a title="添加子级" onClick={this.props.enabled ? this.handleTableAdd.bind(this, 'control', false, 'childNode') : null}>{this.props.enabled ? setAddChild.img : setAddChild.disableimg }</a>; | |
| 1358 | + // eslint-disable-next-line jsx-a11y/anchor-is-valid | |
| 1359 | + const operateCopy = <a title="复制" onClick={this.props.enabled ? this.props.onDataRowCopy.bind(this, 'control', false, true) : null}>{this.props.enabled ? setCopy.img : setCopy.disableimg}</a>; | |
| 1360 | + // eslint-disable-next-line jsx-a11y/anchor-is-valid | |
| 1361 | + const operateUpdate = <a title="复制全部" onClick={this.props.enabled ? this.props.onDataRowCopyAll.bind(this, 'control', false, true) : null}>{this.props.enabled ? setCopyAll.img : setCopyAll.disableimg }</a>; | |
| 1362 | + // eslint-disable-next-line jsx-a11y/anchor-is-valid | |
| 1363 | + const operateDel = <a title="删除" onClick={this.props.enabled ? this.handleTableDel.bind(this, 'control', true, '', true) : null}>{this.props.enabled ? setDelete.img : setDelete.disableimg}</a>; | |
| 1364 | + return ( | |
| 1365 | + <div> | |
| 1366 | + <Spin spinning={pageLoading}> | |
| 1367 | + <div> | |
| 1368 | + <BillComponent | |
| 1369 | + {...this.props} | |
| 1370 | + {...this.state} | |
| 1371 | + onUploadChangeFile={this.handleUploadChangeFile} /* xls文件导入 */ | |
| 1372 | + onUploadChange={this.handleUploadChange} /* 表格图片上传 */ | |
| 1373 | + onBeforeUpload={this.handleBeforeUpload} | |
| 1374 | + onGetDataCancel={this.handleGetDataCancel} | |
| 1375 | + onGetDataOk={this.handleGetDataOk} | |
| 1376 | + colseGetDataVisible={this.colseGetDataVisible} | |
| 1377 | + getMenuStatus={this.getMenuStatus} | |
| 1378 | + onUploadPropsSales={this.handleUploadPropsSales} | |
| 1379 | + onDataRowModal={this.handleTableModal} | |
| 1380 | + onDataRowDel={this.handleSlaveTableDel} | |
| 1381 | + onDoubleClick={this.onDoubleClick} | |
| 1382 | + onSelectTree={this.handleTreeSelect} | |
| 1383 | + handleCancelModal={this.handleCancelModal} | |
| 1384 | + setMaterialTitle={setMaterialTitle} | |
| 1385 | + onSelect={this.handleSelect} | |
| 1386 | + /> | |
| 1387 | + { | |
| 1388 | + visible ? | |
| 1389 | + <AntdDraggableModal | |
| 1390 | + title={check} | |
| 1391 | + visible={visible} | |
| 1392 | + onCancel={this.handleCancel} | |
| 1393 | + onSaveState={this.props.onSaveState} | |
| 1394 | + footer={[ | |
| 1395 | + <Button key="back" onClick={this.handleCancel}>{BtnClose}</Button>, | |
| 1396 | + <Button key="submit" type="primary" onClick={this.handleOk.bind(this, 1, 1, true)}> | |
| 1397 | + {btnSure} | |
| 1398 | + </Button>, | |
| 1399 | + ]} | |
| 1400 | + > | |
| 1401 | + <Table columns={columns} dataSource={checkConditions} bordered pagination={false} className={styles.checkTable} /> | |
| 1402 | + <div style={{ float: 'left', width: '15%' }}>{checkPerson}</div> | |
| 1403 | + <div style={{ float: 'left', width: '60%' }}> | |
| 1404 | + <Checkbox.Group style={{ width: '100%' }} onChange={this.onChange}> | |
| 1405 | + <Row> | |
| 1406 | + { commonUtils.isNotEmptyObject(checkPersonData) ? | |
| 1407 | + checkPersonData.map((item) => { | |
| 1408 | + return ( | |
| 1409 | + <Col span={8}> | |
| 1410 | + <Checkbox value={item.sUserId}>{item.sUserName}</Checkbox> | |
| 1411 | + </Col> | |
| 1412 | + ); | |
| 1413 | + }) | |
| 1414 | + : '' | |
| 1415 | + } | |
| 1416 | + </Row> | |
| 1417 | + </Checkbox.Group> | |
| 1418 | + </div> | |
| 1419 | + </AntdDraggableModal> | |
| 1420 | + : '' | |
| 1421 | + } | |
| 1422 | + { | |
| 1423 | + visibleModal ? | |
| 1424 | + <AntdDraggableModal | |
| 1425 | + title={setMaterailRemark} | |
| 1426 | + width="1200" | |
| 1427 | + bodyStyle={{ paddingBottom: 0, zIndex: 1000 }} | |
| 1428 | + visible={pane.notCurrentPane ? false : visibleModal} | |
| 1429 | + onCancel={this.handleCancelModal.bind(this, 'visibleModal')} | |
| 1430 | + onSaveState={this.props.onSaveState} | |
| 1431 | + forbidResize | |
| 1432 | + footer={[ | |
| 1433 | + <Button key="back" onClick={this.handleCancelModal.bind(this, 'visibleModal')}>{BtnClose}</Button>, | |
| 1434 | + <Button key="submit" type="primary" onClick={this.handleOkModal.bind(this)}> | |
| 1435 | + {btnSure} | |
| 1436 | + </Button>, | |
| 1437 | + ]} | |
| 1438 | + > | |
| 1439 | + { | |
| 1440 | + (pane.notCurrentPane ? false : processChooseVisible) ? | |
| 1441 | + <AntdDraggableModal | |
| 1442 | + width={1100} | |
| 1443 | + className="MProcess" | |
| 1444 | + bodyStyle={{ paddingBottom: 0, maxHeight: 520, zIndex: 2000 }} | |
| 1445 | + title={commonUtils.isEmptyObject(searchProcessType) ? setProcessTitle : searchProcessType.app.currentPane.title} | |
| 1446 | + onCancel={this.handleCancelModal.bind(this, 'processChooseVisible')} | |
| 1447 | + visible={pane.notCurrentPane ? false : processChooseVisible} | |
| 1448 | + onSaveState={this.props.onSaveState} | |
| 1449 | + footer={null} | |
| 1450 | + > | |
| 1451 | + <CommonListSelectTree {...searchProcessType} /> | |
| 1452 | + </AntdDraggableModal> | |
| 1453 | + : '' | |
| 1454 | + } | |
| 1455 | + { | |
| 1456 | + (pane.notCurrentPane ? false : materialsChooseVisible) ? | |
| 1457 | + <AntdDraggableModal | |
| 1458 | + bodyStyle={{ paddingBottom: 0, maxHeight: 520, zIndex: 2000 }} | |
| 1459 | + className="MProcess" | |
| 1460 | + width={1100} | |
| 1461 | + title={commonUtils.isEmptyObject(searchMaterialsType) ? setMaterialTitle : searchMaterialsType.app.currentPane.title} | |
| 1462 | + onCancel={this.handleCancelModal.bind(this, 'materialsChooseVisible')} | |
| 1463 | + visible={pane.notCurrentPane ? false : materialsChooseVisible} | |
| 1464 | + onSaveState={this.props.onSaveState} | |
| 1465 | + footer={null} | |
| 1466 | + > | |
| 1467 | + <CommonListSelect {...searchMaterialsType} /> | |
| 1468 | + </AntdDraggableModal> | |
| 1469 | + : '' | |
| 1470 | + } | |
| 1471 | + <div id="ModalMaterialRemark" > | |
| 1472 | + { | |
| 1473 | + sModelsType === 'sales/salesOrderPack' ? | |
| 1474 | + <div style={{ | |
| 1475 | + marginTop: 0, height: '180px', overflowY: 'hidden', overflowX: 'hidden', | |
| 1476 | +}} | |
| 1477 | + > | |
| 1478 | + <div className="xly-bill-pack"> | |
| 1479 | + <Sider className="controlhandcover"> | |
| 1480 | + <div className="xly-control"> | |
| 1481 | + <div style={{ backgroundColor: '#f5f5f5', height: '30px', lineHeight: '30px' }}> | |
| 1482 | + <span style={{ | |
| 1483 | + fontSize: '12px', color: 'rgba(0, 0, 0, 0.85)', fontWeight: '600', paddingLeft: '8px', | |
| 1484 | +}} | |
| 1485 | + >部件信息 | |
| 1486 | + </span> | |
| 1487 | + </div> | |
| 1488 | + <div className="xly-control-tree"><StaticEditTree {...treeProps} /></div> | |
| 1489 | + <div className="xly-control-operate" > | |
| 1490 | + <span>{operateAdd}</span> | |
| 1491 | + <span>{operateAddChild}</span> | |
| 1492 | + <span>{operateCopy}</span> | |
| 1493 | + <span>{operateUpdate}</span> | |
| 1494 | + <span>{operateDel}</span> | |
| 1495 | + </div> | |
| 1496 | + </div> | |
| 1497 | + </Sider> | |
| 1498 | + <div style={{ overflowX: 'auto', overflowY: 'hidden' }}> | |
| 1499 | + <StaticEditTable {...controlPropsType} footer="hidden" setOpterationColumn="Y" /> | |
| 1500 | + </div> | |
| 1501 | + </div> | |
| 1502 | + </div> : | |
| 1503 | + <div style={{ marginTop: 0, overflowY: 'hidden' }} > | |
| 1504 | + <StaticEditTable {...controlPropsType} footer="hidden" setOpterationColumn="Y" /> | |
| 1505 | + </div> | |
| 1506 | + } | |
| 1507 | + <div style={{ marginTop: 0, overflowY: 'hidden' }}> | |
| 1508 | + <StaticEditTable {...materialsPropsType} footer="hidden" setOpterationColumn="Y" /> | |
| 1509 | + </div> | |
| 1510 | + <div style={{ marginTop: 0, overflowY: 'hidden' }} id="chooseProcessModal"> | |
| 1511 | + <StaticEditTable {...processPropsType} footer="hidden" setOpterationColumn="Y" /> | |
| 1512 | + </div> | |
| 1513 | + </div> | |
| 1514 | + </AntdDraggableModal> | |
| 1515 | + : ''} | |
| 1516 | + </div> | |
| 1517 | + </Spin> | |
| 1518 | + </div> | |
| 1519 | + ); | |
| 1520 | + } | |
| 1521 | +} | |
| 1522 | + | |
| 1523 | +const BillComponent = Form.create({ | |
| 1524 | + mapPropsToFields(props) { | |
| 1525 | + const { masterData, masterConfig } = props; | |
| 1526 | + const obj = commonFunc.mapPropsToFields(masterData, Form, masterConfig); | |
| 1527 | + return obj; | |
| 1528 | + }, | |
| 1529 | +})((props) => { | |
| 1530 | + const { | |
| 1531 | + form, | |
| 1532 | + onReturnForm, | |
| 1533 | + slaveData, | |
| 1534 | + slavePagination, | |
| 1535 | + onlyMaster, | |
| 1536 | + sModelsId, | |
| 1537 | + app, | |
| 1538 | + masterConfig, | |
| 1539 | + slaveConfig, | |
| 1540 | + isSmall, | |
| 1541 | + isGetDataVisible, | |
| 1542 | + onGetDataCancel, | |
| 1543 | + onGetDataOk, | |
| 1544 | + colseGetDataVisible, | |
| 1545 | + sModelsType, | |
| 1546 | + masterData, | |
| 1547 | + previewUrl, | |
| 1548 | + slaveSelectedRowKeys, | |
| 1549 | + } = props; | |
| 1550 | + /* 回带表单 */ | |
| 1551 | + onReturnForm(form); | |
| 1552 | + const pagination = { | |
| 1553 | + pageSize: commonConfig.pageSize, | |
| 1554 | + total: commonUtils.isEmptyArr(slaveData) ? 0 : slaveData.length, | |
| 1555 | + current: commonUtils.isEmptyObject(slavePagination) ? 1 : slavePagination.current, | |
| 1556 | + ...slavePagination, | |
| 1557 | + // showQuickJumper: true, | |
| 1558 | + hideOnSinglePage: true, | |
| 1559 | + size: isSmall ? 'small' : 'large', | |
| 1560 | + pageSizeOptions: commonConfig.pageSizeOptions, | |
| 1561 | + showSizeChanger: !isSmall, | |
| 1562 | + showQuickJumper: !isSmall, | |
| 1563 | + }; | |
| 1564 | + const templateProps = props.formData.filter(item => item.sGrd === 'importTemplate')[0]; | |
| 1565 | + let setMaterialRemark = { | |
| 1566 | + title: '材料与工艺', | |
| 1567 | + width: { width }, | |
| 1568 | + height: { height }, | |
| 1569 | + img: <img src={MaterialRemarkIcon} alt="材料与工艺" width={width} height={height} />, | |
| 1570 | + disableimg: <img src={DisMaRemarklIcon} alt="材料与工艺不可用" width={width} height={height} />, | |
| 1571 | + }; | |
| 1572 | + /* 获取toolbar 选择材料 */ | |
| 1573 | + let searchMaterialsType = {}; | |
| 1574 | + let chooseMaterialsConfig = {}; | |
| 1575 | + if (commonUtils.isNotEmptyObject(slaveConfig)) { | |
| 1576 | + const iIndex = slaveConfig.gdsconfigformslave.findIndex(item => item.sControlName === 'BtnChooseMaterials'); | |
| 1577 | + if (iIndex > -1) { | |
| 1578 | + chooseMaterialsConfig = slaveConfig.gdsconfigformslave[iIndex]; | |
| 1579 | + } | |
| 1580 | + } | |
| 1581 | + if (commonUtils.isNotEmptyObject(props.materialsChooseData)) { | |
| 1582 | + searchMaterialsType = { | |
| 1583 | + app: { | |
| 1584 | + ...props.app, | |
| 1585 | + currentPane: { | |
| 1586 | + name: 'materials', | |
| 1587 | + config: chooseMaterialsConfig, | |
| 1588 | + conditonValues: props.getSqlCondition(chooseMaterialsConfig), | |
| 1589 | + title: props.materialsChooseData.sMenuName, | |
| 1590 | + route: props.materialsChooseData.sName, | |
| 1591 | + formId: props.materialsChooseData.sId, | |
| 1592 | + key: sModelsId + props.materialsChooseData.sId, | |
| 1593 | + sModelsType: props.materialsChooseData.sModelType, | |
| 1594 | + select: props.onSelect, | |
| 1595 | + selectCancel: props.onSelectCancel, | |
| 1596 | + }, | |
| 1597 | + }, | |
| 1598 | + dispatch: props.dispatch, | |
| 1599 | + content: props.content, | |
| 1600 | + id: new Date().getTime().toString(), | |
| 1601 | + realizeHeight: props.realizeHeight, /* 拖动偏移高度 */ | |
| 1602 | + }; | |
| 1603 | + } | |
| 1604 | + | |
| 1605 | + /* 调用产品工艺卡 */ | |
| 1606 | + let productProcessInfoType = {}; | |
| 1607 | + let productProcessInfoConfig = {}; | |
| 1608 | + let processCardSearchResult = commonFunc.showMessage(app.commonConst, 'processCardSearchResult');/* 复制从工艺卡查询结果 */ | |
| 1609 | + if (commonUtils.isNotEmptyObject(props.productProcessInfoChooseData)) { | |
| 1610 | + const productProcessInfoCopyFromKey = props.productProcessInfoCopyFromKey; | |
| 1611 | + const iIndex = props.masterConfig.gdsconfigformslave.findIndex(item => item.sControlName === productProcessInfoCopyFromKey); | |
| 1612 | + if (iIndex > -1) { | |
| 1613 | + productProcessInfoConfig = props.masterConfig.gdsconfigformslave[iIndex]; | |
| 1614 | + processCardSearchResult = commonUtils.isNotEmptyObject(productProcessInfoConfig) && commonUtils.isNotEmptyObject(productProcessInfoConfig.sActiveName) ? productProcessInfoConfig.sActiveName : processCardSearchResult; | |
| 1615 | + } | |
| 1616 | + productProcessInfoType = { | |
| 1617 | + app: { | |
| 1618 | + ...props.app, | |
| 1619 | + currentPane: { | |
| 1620 | + name: 'productProcessInfo', | |
| 1621 | + config: productProcessInfoConfig, | |
| 1622 | + conditonValues: props.getSqlCondition(productProcessInfoConfig), | |
| 1623 | + title: props.productProcessInfoChooseData.sMenuName, | |
| 1624 | + route: props.productProcessInfoChooseData.sName, | |
| 1625 | + formId: props.productProcessInfoChooseData.sId, | |
| 1626 | + key: sModelsId + props.productProcessInfoChooseData.sId, | |
| 1627 | + sModelsType: props.productProcessInfoChooseData.sModelType, | |
| 1628 | + select: props.onSelect, | |
| 1629 | + selectCancel: props.onSelectCancel, | |
| 1630 | + }, | |
| 1631 | + }, | |
| 1632 | + dispatch: props.dispatch, | |
| 1633 | + content: props.content, | |
| 1634 | + id: new Date().getTime().toString(), | |
| 1635 | + }; | |
| 1636 | + } | |
| 1637 | + | |
| 1638 | + | |
| 1639 | + /* 导入收付款未清数据 */ | |
| 1640 | + let importPopupProps = {}; | |
| 1641 | + let importPopupTitle = '导入未清数据'; | |
| 1642 | + if (commonUtils.isNotEmptyObject(props)) { | |
| 1643 | + let importPopupConfig = {}; | |
| 1644 | + const { | |
| 1645 | + masterConfig, sModelsId, | |
| 1646 | + } = props; | |
| 1647 | + if (commonUtils.isNotEmptyObject(masterConfig)) { | |
| 1648 | + const iIndex = masterConfig.gdsconfigformslave.findIndex(item => item.sControlName === 'BtnImportFormData' && item.bVisible); | |
| 1649 | + if (iIndex > -1) { | |
| 1650 | + importPopupConfig = masterConfig.gdsconfigformslave[iIndex]; | |
| 1651 | + importPopupTitle = commonUtils.isNotEmptyObject(importPopupConfig) && commonUtils.isNotEmptyObject(importPopupConfig.sActiveName) ? importPopupConfig.sActiveName : importPopupTitle; | |
| 1652 | + importPopupProps = { | |
| 1653 | + app: { | |
| 1654 | + ...props.app, | |
| 1655 | + currentPane: { | |
| 1656 | + name: 'commonPopup', | |
| 1657 | + config: importPopupConfig, | |
| 1658 | + conditonValues: {}, | |
| 1659 | + title: importPopupTitle, | |
| 1660 | + route: '/indexPage/commonList', | |
| 1661 | + formRoute: '/indexPage/commonList', | |
| 1662 | + formId: importPopupConfig.sActiveId, | |
| 1663 | + key: sModelsId + importPopupConfig.sId, | |
| 1664 | + sModelsType: 'search/importFormData', | |
| 1665 | + select: props.onSelect, | |
| 1666 | + selectCancel: props.handleCancelModal.bind(this, 'importFormDataVisible'), | |
| 1667 | + bFilterProName: props.bFilterProName, /* 存储过程查询ID */ | |
| 1668 | + bFilterProValue: props.bFilterProValue, /* 存储过程查询VALUE */ | |
| 1669 | + }, | |
| 1670 | + }, | |
| 1671 | + dispatch: props.dispatch, | |
| 1672 | + content: props.content, | |
| 1673 | + id: new Date().getTime().toString(), | |
| 1674 | + realizeHeight: props.realizeHeight, /* 拖动偏移高度 */ | |
| 1675 | + }; | |
| 1676 | + } | |
| 1677 | + } | |
| 1678 | + } | |
| 1679 | + | |
| 1680 | + // const saleOrder = commonFunc.showMessage(app.commonConst, 'saleOrder');/* 销售订单 s*/ | |
| 1681 | + setMaterialRemark = props.sModelsType !== undefined && props.sModelsType.includes('sales/salesOrder') ? setMaterialRemark : null; | |
| 1682 | + const slaveTableProps = { | |
| 1683 | + ...commonBusiness.getTableTypes('slave', props), | |
| 1684 | + tableProps: { | |
| 1685 | + setAdd, setCopy, setCopyAll, setDelete, setMaterialRemark, setMaterial, chooseMaterialsConfigRow: chooseMaterialsConfig, pagination, onChange: props.onTitleChange, | |
| 1686 | + }, | |
| 1687 | + templateProps, | |
| 1688 | + onKeyDown: props.onKeyDown, | |
| 1689 | + onContextMenu: props.onContextMenu, | |
| 1690 | + masterData: props.masterData, // 为通用弹窗提供主表数据(孟总需求:产品新增需要带上客户信息) | |
| 1691 | + }; | |
| 1692 | + | |
| 1693 | + | |
| 1694 | + const controlPropsType = { | |
| 1695 | + ...commonBusiness.getTableTypes('control', props), | |
| 1696 | + tableProps: { | |
| 1697 | + setAdd, setCopy, setCopyAll, setDelete, setMaterialRemark, setMaterial, chooseMaterialsConfigRow: chooseMaterialsConfig, pagination, onChange: props.onTitleChange, | |
| 1698 | + }, | |
| 1699 | + templateProps, | |
| 1700 | + onKeyDown: props.onKeyDown, | |
| 1701 | + onContextMenu: props.onContextMenu, | |
| 1702 | + masterData: props.masterData, // 为通用弹窗提供主表数据(孟总需求:产品新增需要带上客户信息) | |
| 1703 | + }; | |
| 1704 | + | |
| 1705 | + | |
| 1706 | + const materialsPropsType = { | |
| 1707 | + ...commonBusiness.getTableTypes('materials', props), | |
| 1708 | + tableProps: { | |
| 1709 | + setAdd, setCopy, setCopyAll, setDelete, setMaterialRemark, setMaterial, chooseMaterialsConfigRow: chooseMaterialsConfig, pagination, onChange: props.onTitleChange, | |
| 1710 | + }, | |
| 1711 | + templateProps, | |
| 1712 | + onKeyDown: props.onKeyDown, | |
| 1713 | + onContextMenu: props.onContextMenu, | |
| 1714 | + masterData: props.masterData, // 为通用弹窗提供主表数据(孟总需求:产品新增需要带上客户信息) | |
| 1715 | + }; | |
| 1716 | + | |
| 1717 | + | |
| 1718 | + const processPropsType = { | |
| 1719 | + ...commonBusiness.getTableTypes('process', props), | |
| 1720 | + tableProps: { | |
| 1721 | + setAdd, setCopy, setCopyAll, setDelete, setMaterialRemark, setMaterial, chooseMaterialsConfigRow: chooseMaterialsConfig, pagination, onChange: props.onTitleChange, | |
| 1722 | + }, | |
| 1723 | + templateProps, | |
| 1724 | + onKeyDown: props.onKeyDown, | |
| 1725 | + onContextMenu: props.onContextMenu, | |
| 1726 | + masterData: props.masterData, // 为通用弹窗提供主表数据(孟总需求:产品新增需要带上客户信息) | |
| 1727 | + }; | |
| 1728 | + | |
| 1729 | + const packPropsType = { | |
| 1730 | + ...commonBusiness.getTableTypes('pack', props), | |
| 1731 | + tableProps: { | |
| 1732 | + setAdd, setCopy, setCopyAll, setDelete, setMaterialRemark, setMaterial, chooseMaterialsConfigRow: chooseMaterialsConfig, pagination, onChange: props.onTitleChange, | |
| 1733 | + }, | |
| 1734 | + onKeyDown: props.onKeyDown, | |
| 1735 | + onContextMenu: props.onContextMenu, | |
| 1736 | + masterData: props.masterData, // 为通用弹窗提供主表数据(孟总需求:产品新增需要带上客户信息) | |
| 1737 | + }; | |
| 1738 | + | |
| 1739 | + let gdsconfigformmasterId = ''; | |
| 1740 | + if (templateProps !== undefined) { | |
| 1741 | + gdsconfigformmasterId = templateProps.sId; | |
| 1742 | + } | |
| 1743 | + | |
| 1744 | + const sNotEmpty = 'sParentId,sProductId'; | |
| 1745 | + let uploadUrl = `${commonConfig.server_host}import/checkExcel?sModelsId=${sModelsId}&gdsconfigformmasterId=${gdsconfigformmasterId}&sNotEmpty=${sNotEmpty}&token=${app.token}`; | |
| 1746 | + /* 送货单需要传客户id */ | |
| 1747 | + if (commonUtils.isNotEmptyObject(sModelsType) && sModelsType === 'sales/salesSgoods' && commonUtils.isNotEmptyObject(masterData)) { | |
| 1748 | + const sCustomerId = masterData.sCustomerId; | |
| 1749 | + if (commonUtils.isNotEmptyObject(sCustomerId)) { | |
| 1750 | + uploadUrl = `${commonConfig.server_host}import/checkExcel?sModelsId=${sModelsId}&gdsconfigformmasterId=${gdsconfigformmasterId}&sNotEmpty=${sNotEmpty}&sCustomerId=${sCustomerId}&token=${app.token}`; | |
| 1751 | + } | |
| 1752 | + } | |
| 1753 | + const outProps = { | |
| 1754 | + action: uploadUrl, | |
| 1755 | + onChange: props.onUploadChangeFile, /* 文件上传 */ | |
| 1756 | + accept: 'xls/*', | |
| 1757 | + showUploadList: false, | |
| 1758 | + beforeUpload: () => { | |
| 1759 | + /* 查看时不可上传 */ | |
| 1760 | + if (!props.enabled) return false; | |
| 1761 | + }, | |
| 1762 | + }; | |
| 1763 | + const uploadPropsSales = props.onUploadPropsSales(); | |
| 1764 | + const isGetData = commonFunc.showMessage(app.commonConst, 'isGetData');/* 确认获取库存为零的数据吗 */ | |
| 1765 | + const isFilterGetDataZero = commonFunc.showMessage(app.commonConst, 'isFilterGetDataZero'); | |
| 1766 | + const isAllGetData = commonFunc.showMessage(app.commonConst, 'isAllGetData'); | |
| 1767 | + // const CheckInfo = commonFunc.showMessage(app.commonConst, 'CheckInfo');/* 审批信息 */ | |
| 1768 | + const BtnimportData = commonFunc.showMessage(app.commonConst, 'importData');/* 导入数据 */ | |
| 1769 | + const ImportData = commonUtils.isNotEmptyObject(masterConfig) ? masterConfig.gdsconfigformslave.filter(item => item.sControlName.includes('ImportData') && item.bVisible) : '';/* 后台是否配置导入 */ | |
| 1770 | + | |
| 1771 | + /* 取 masterConfig中有多少个分割符配置 */ | |
| 1772 | + const masterShowConfig = commonUtils.isNotEmptyObject(masterConfig) ? masterConfig.gdsconfigformslave.filter(item => item.bVisible && item.sName !== '') : []; | |
| 1773 | + const diliverConfigTypeArr = []; /* 有分隔符的配置 */ | |
| 1774 | + masterShowConfig.forEach((child) => { | |
| 1775 | + if (child.sControlName.indexOf('_') > -1) { | |
| 1776 | + const tableType = child.sControlName.split('_')[1]; | |
| 1777 | + const isIndex = diliverConfigTypeArr.findIndex(item => item === tableType); | |
| 1778 | + if (isIndex === -1) { | |
| 1779 | + diliverConfigTypeArr.push(tableType); | |
| 1780 | + } | |
| 1781 | + } | |
| 1782 | + }); | |
| 1783 | + /* ----从表设置------- */ | |
| 1784 | + /* 取区域间隔符 */ | |
| 1785 | + // eslint-disable-next-line no-unused-vars | |
| 1786 | + const areaShowConfig = commonUtils.isNotEmptyObject(masterConfig) ? masterConfig.gdsconfigformslave.filter(item => item.bVisible && item.sControlName !== '' && item.sControlName.toLowerCase().indexOf('dividerarea') > -1) : []; | |
| 1787 | + | |
| 1788 | + // eslint-disable-next-line no-unused-vars | |
| 1789 | + let listConfig = {}; /* 从表区域 列表显示设置 */ | |
| 1790 | + if (commonUtils.isNotEmptyObject(slaveConfig)) { | |
| 1791 | + listConfig = commonUtils.isNotEmptyObject(slaveConfig) ? slaveConfig.gdsconfigformslave.filter(item => item.bVisible && item.sName !== '' && (item.iTag !== 2 && item.iTag !== 3)) : []; | |
| 1792 | + } | |
| 1793 | + | |
| 1794 | + /* commonView显示区域 */ | |
| 1795 | + const ableConfigs = commonUtils.isNotEmptyObject(slaveConfig) ? slaveConfig.gdsconfigformslave.filter(item => item.sName !== '' && item.bControl && item.sControlName.indexOf('Btn') === -1) : []; | |
| 1796 | + /* 选中行 */ | |
| 1797 | + let showAll = true; /* 只显示表格 */ | |
| 1798 | + let bShowLeft = true; /* 表格显示在左侧 */ | |
| 1799 | + let iColValueView = 12; | |
| 1800 | + let iColValueTable = 12; | |
| 1801 | + | |
| 1802 | + let showAll2 = true; /* 只显示表格 */ | |
| 1803 | + let bShowLeft2 = true; /* 表格显示在左侧 */ | |
| 1804 | + let iColValueView2 = 12; | |
| 1805 | + const iColValueTable2 = 12; | |
| 1806 | + | |
| 1807 | + let slaveRow = {}; | |
| 1808 | + if (commonUtils.isNotEmptyArr(slaveSelectedRowKeys)) { | |
| 1809 | + const iIndex = slaveData.findIndex(item => slaveSelectedRowKeys.includes(item.sId)); | |
| 1810 | + if (iIndex > -1) { | |
| 1811 | + slaveRow = slaveData[iIndex]; | |
| 1812 | + } else { | |
| 1813 | + slaveRow = slaveData[0]; | |
| 1814 | + } | |
| 1815 | + } else if (commonUtils.isNotEmptyArr(slaveData)) { | |
| 1816 | + slaveRow = slaveData[0]; | |
| 1817 | + } | |
| 1818 | + if (commonUtils.isNotEmptyObject(props.slaveConfig) && commonUtils.isNotEmptyArr(props.slaveConfig.gdsconfigformslave)) { | |
| 1819 | + const iIndexArea = props.slaveConfig.gdsconfigformslave.findIndex(item => item.sControlName !== '' && item.sControlName.includes('bShow')); | |
| 1820 | + if (iIndexArea > -1) { | |
| 1821 | + showAll = false; | |
| 1822 | + } | |
| 1823 | + if (commonUtils.isNotEmptyObject(props.slaveConfig) && commonUtils.isNotEmptyArr(props.slaveConfig.gdsconfigformslave)) { | |
| 1824 | + const iShowLeft = props.slaveConfig.gdsconfigformslave.findIndex(item => item.sControlName === 'bShowLeft' && item.bVisible); | |
| 1825 | + const iShowRight = props.slaveConfig.gdsconfigformslave.findIndex(item => item.sControlName === 'bShowRight' && item.bVisible); | |
| 1826 | + if (iShowLeft > -1) { | |
| 1827 | + bShowLeft = true; | |
| 1828 | + iColValueTable = props.slaveConfig.gdsconfigformslave[iShowLeft].iColValue; | |
| 1829 | + } else if (iShowRight > -1) { | |
| 1830 | + bShowLeft = false; | |
| 1831 | + iColValueTable = props.slaveConfig.gdsconfigformslave[iShowRight].iColValue; | |
| 1832 | + } | |
| 1833 | + } | |
| 1834 | + } | |
| 1835 | + iColValueView = commonUtils.isNotEmptyNumber(iColValueTable) ? 24 - iColValueTable : 12; | |
| 1836 | + iColValueView2 = commonUtils.isNotEmptyNumber(iColValueTable2) ? 24 - iColValueTable2 : 12; | |
| 1837 | + const iShowOrder = bShowLeft ? 1 : 100; | |
| 1838 | + | |
| 1839 | + const iShowOrder2 = bShowLeft2 ? 1 : 100; | |
| 1840 | + | |
| 1841 | + let areaShow1 = true; /* 区域1 */ | |
| 1842 | + if (commonUtils.isNotEmptyObject(props.masterConfig) && commonUtils.isNotEmptyArr(props.masterConfig.gdsconfigformslave)) { | |
| 1843 | + const iIndexArea = props.masterConfig.gdsconfigformslave.findIndex(item => item.sControlName === 'DividerArea1' && item.bVisible); | |
| 1844 | + if (iIndexArea > -1) { | |
| 1845 | + areaShow1 = props.masterConfig.gdsconfigformslave[iIndexArea].showName; | |
| 1846 | + } | |
| 1847 | + } | |
| 1848 | + let areaShow2 = true; /* 区域2 */ | |
| 1849 | + if (commonUtils.isNotEmptyObject(props.masterConfig) && commonUtils.isNotEmptyArr(props.masterConfig.gdsconfigformslave)) { | |
| 1850 | + const iIndexArea = props.masterConfig.gdsconfigformslave.findIndex(item => item.sControlName === 'DividerArea2' && item.bVisible); | |
| 1851 | + if (iIndexArea > -1) { | |
| 1852 | + areaShow2 = props.masterConfig.gdsconfigformslave[iIndexArea].showName; | |
| 1853 | + } | |
| 1854 | + } | |
| 1855 | + | |
| 1856 | + if (commonUtils.isNotEmptyObject(props.controlConfig) && commonUtils.isNotEmptyArr(props.controlConfig.gdsconfigformslave)) { | |
| 1857 | + const iIndexArea = props.controlConfig.gdsconfigformslave.findIndex(item => item.sControlName !== '' && item.sControlName.includes('bShow')); | |
| 1858 | + if (iIndexArea > -1) { | |
| 1859 | + showAll2 = false; | |
| 1860 | + } | |
| 1861 | + if (commonUtils.isNotEmptyObject(props.controlConfig) && commonUtils.isNotEmptyArr(props.controlConfig.gdsconfigformslave)) { | |
| 1862 | + const iShowLeft = props.controlConfig.gdsconfigformslave.findIndex(item => item.sControlName === 'bShowLeft' && item.bVisible); | |
| 1863 | + const iShowRight = props.controlConfig.gdsconfigformslave.findIndex(item => item.sControlName === 'bShowRight' && item.bVisible); | |
| 1864 | + if (iShowLeft > -1) { | |
| 1865 | + bShowLeft2 = true; | |
| 1866 | + iColValueTable = props.controlConfig.gdsconfigformslave[iShowLeft].iColValue; | |
| 1867 | + } else if (iShowRight > -1) { | |
| 1868 | + bShowLeft2 = false; | |
| 1869 | + iColValueTable = props.controlConfig.gdsconfigformslave[iShowRight].iColValue; | |
| 1870 | + } | |
| 1871 | + } | |
| 1872 | + } | |
| 1873 | + | |
| 1874 | + let areaShow3 = true; /* 区域3 */ | |
| 1875 | + if (commonUtils.isNotEmptyObject(props.masterConfig) && commonUtils.isNotEmptyArr(props.masterConfig.gdsconfigformslave)) { | |
| 1876 | + const iIndexArea = props.masterConfig.gdsconfigformslave.findIndex(item => item.sControlName === 'DividerArea3' && item.bVisible); | |
| 1877 | + if (iIndexArea > -1) { | |
| 1878 | + areaShow3 = props.masterConfig.gdsconfigformslave[iIndexArea].showName; | |
| 1879 | + } | |
| 1880 | + } | |
| 1881 | + | |
| 1882 | + let areaShow4 = true; /* 区域4 */ | |
| 1883 | + if (commonUtils.isNotEmptyObject(props.masterConfig) && commonUtils.isNotEmptyArr(props.masterConfig.gdsconfigformslave)) { | |
| 1884 | + const iIndexArea = props.masterConfig.gdsconfigformslave.findIndex(item => item.sControlName === 'DividerArea4' && item.bVisible); | |
| 1885 | + if (iIndexArea > -1) { | |
| 1886 | + areaShow4 = props.masterConfig.gdsconfigformslave[iIndexArea].showName; | |
| 1887 | + } | |
| 1888 | + } | |
| 1889 | + let areaShow5 = true; /* 区域5 */ | |
| 1890 | + if (commonUtils.isNotEmptyObject(props.masterConfig) && commonUtils.isNotEmptyArr(props.masterConfig.gdsconfigformslave)) { | |
| 1891 | + const iIndexArea = props.masterConfig.gdsconfigformslave.findIndex(item => item.sControlName === 'DividerArea5' && item.bVisible); | |
| 1892 | + if (iIndexArea > -1) { | |
| 1893 | + areaShow5 = props.masterConfig.gdsconfigformslave[iIndexArea].showName; | |
| 1894 | + } | |
| 1895 | + } | |
| 1896 | + let bShowReport = true; /* 显示报表区域 */ | |
| 1897 | + if (commonUtils.isNotEmptyObject(props.masterConfig) && commonUtils.isNotEmptyArr(props.masterConfig.gdsconfigformslave)) { | |
| 1898 | + const iIndexArea = props.masterConfig.gdsconfigformslave.findIndex(item => item.sControlName === 'bShowRepoprt'); | |
| 1899 | + if (iIndexArea > -1) { | |
| 1900 | + bShowReport = props.masterConfig.gdsconfigformslave[iIndexArea].bVisible; | |
| 1901 | + } | |
| 1902 | + } | |
| 1903 | + | |
| 1904 | + const bControlShow = commonUtils.isNotEmptyObject(props) && commonUtils.isNotEmptyObject(props.controlConfig); /* 控制表 */ | |
| 1905 | + | |
| 1906 | + const bMaterialShow = commonUtils.isNotEmptyObject(props) && commonUtils.isNotEmptyObject(props.materialsConfig); /* 材料表 */ | |
| 1907 | + | |
| 1908 | + const bProcessShow = commonUtils.isNotEmptyObject(props) && commonUtils.isNotEmptyObject(props.processConfig); /* 工序表 */ | |
| 1909 | + | |
| 1910 | + const bPackShow = commonUtils.isNotEmptyObject(props) && commonUtils.isNotEmptyObject(props.packConfig); /* 工序表 */ | |
| 1911 | + /* 从表view */ | |
| 1912 | + const slaveViewProps = { | |
| 1913 | + ...props, | |
| 1914 | + viewConfigs: ableConfigs, | |
| 1915 | + tableConfig: slaveConfig, | |
| 1916 | + iColValueView, | |
| 1917 | + viewRow: slaveRow, | |
| 1918 | + tableName: 'slave', | |
| 1919 | + }; | |
| 1920 | + | |
| 1921 | + /* 控制表view */ | |
| 1922 | + const controlViewProps = { | |
| 1923 | + ...props, | |
| 1924 | + viewConfigs: ableConfigs, | |
| 1925 | + tableConfig: slaveConfig, | |
| 1926 | + iColValueView2, | |
| 1927 | + viewRow: {}, | |
| 1928 | + tableName: 'control', | |
| 1929 | + }; | |
| 1930 | + /* 从表view */ | |
| 1931 | + const materialsViewProps = { | |
| 1932 | + ...props, | |
| 1933 | + viewConfigs: ableConfigs, | |
| 1934 | + tableConfig: slaveConfig, | |
| 1935 | + iColValueView2, | |
| 1936 | + viewRow: {}, | |
| 1937 | + }; | |
| 1938 | + /* 从表view */ | |
| 1939 | + const processViewProps = { | |
| 1940 | + ...props, | |
| 1941 | + viewConfigs: ableConfigs, | |
| 1942 | + tableConfig: slaveConfig, | |
| 1943 | + iColValueView2, | |
| 1944 | + viewRow: {}, | |
| 1945 | + }; | |
| 1946 | + | |
| 1947 | + /* pack表view */ | |
| 1948 | + const packViewProps = { | |
| 1949 | + ...props, | |
| 1950 | + viewConfigs: ableConfigs, | |
| 1951 | + tableConfig: slaveConfig, | |
| 1952 | + iColValueView2, | |
| 1953 | + viewRow: {}, | |
| 1954 | + }; | |
| 1955 | + | |
| 1956 | + return ( | |
| 1957 | + <Form className="commonCheckBillContainer"> | |
| 1958 | + <Layout> | |
| 1959 | + <Header className={styles.header}> | |
| 1960 | + <div className="billToolBar"> | |
| 1961 | + <Toolbar {...props} className="billBtnGroup btnGroupHasImport" pageFrom="billList" /> | |
| 1962 | + { commonUtils.isNotEmptyArr(ImportData) ? | |
| 1963 | + <div id="btnImportData" className={`importData ${props.enabled}`} > | |
| 1964 | + <Upload {...outProps}><UploadOutlined />{BtnimportData} | |
| 1965 | + <Button {...uploadPropsSales} /> | |
| 1966 | + </Upload> | |
| 1967 | + </div> : ''} | |
| 1968 | + </div> | |
| 1969 | + </Header> | |
| 1970 | + <Layout className={styles.clayout}> | |
| 1971 | + <Content className={customStyles.content} > | |
| 1972 | + <div style={{ | |
| 1973 | + border: '1px solid #c2c3c5', | |
| 1974 | + margin: '0 10px', | |
| 1975 | + marginTop: 8, | |
| 1976 | + backgroundColor: '#ffffff', | |
| 1977 | + }} | |
| 1978 | + > | |
| 1979 | + <div className="bill-search-group" > | |
| 1980 | + <CommonViewFlex {...props} /> | |
| 1981 | + </div> | |
| 1982 | + { | |
| 1983 | + commonUtils.isNotEmptyArr(diliverConfigTypeArr) ? | |
| 1984 | + diliverConfigTypeArr.map((item) => { | |
| 1985 | + // 匹配数字 | |
| 1986 | + // eslint-disable-next-line no-unused-vars | |
| 1987 | + const num = item.replace(/[^\d]/g, ' '); | |
| 1988 | + return ( | |
| 1989 | + <div className="flexArea"> | |
| 1990 | + <Divider orientation="left">{item}</Divider> | |
| 1991 | + <CommonView | |
| 1992 | + {...props} | |
| 1993 | + // 使高度和从表高度一直 | |
| 1994 | + isAutoHeight="ture" | |
| 1995 | + tableConfigType={item} | |
| 1996 | + tableConfigTypeArr={diliverConfigTypeArr} | |
| 1997 | + /> | |
| 1998 | + </div> | |
| 1999 | + ); | |
| 2000 | + }) | |
| 2001 | + : '' | |
| 2002 | + } | |
| 2003 | + </div> | |
| 2004 | + { onlyMaster ? | |
| 2005 | + <div id="slaveTabs" className={`${styles.bShow} bill-search-group commonCheckBill`}> | |
| 2006 | + <div> | |
| 2007 | + <Avatar src={props.imgSrc} className={customStyles.bShowImg} /> | |
| 2008 | + </div> | |
| 2009 | + </div> : | |
| 2010 | + <div id="slaveTabs" className="bill-search-group commonCheckBill"> | |
| 2011 | + {/* <div> */} | |
| 2012 | + {/* <Avatar src={props.imgSrc} /> */} | |
| 2013 | + {/* </div> */} | |
| 2014 | + {/* {areaShow1 ? <Divider orientation="left" style={{ padding: '10px' }}>{areaShow1}</Divider> : '' } */} | |
| 2015 | + <div className={styles.slaveTabs} tabBarStyle={{ margin: '0 10px' }} > | |
| 2016 | + <div className="xly-bill-list"> | |
| 2017 | + <Collapse defaultActiveKey={['1', '1']} className="custom-collapse"> | |
| 2018 | + <Panel header={areaShow1} key="1"> | |
| 2019 | + <Row gutter={[8, 0]}> | |
| 2020 | + <Col span={showAll ? 24 : iColValueTable} order={iShowOrder}> | |
| 2021 | + <StaticEditTable {...slaveTableProps} setOpterationColumn={props.sModelsType !== 'cost/cosexpenseshare' ? 'Y' : ''} /> | |
| 2022 | + </Col> | |
| 2023 | + <CommonViewTable {...slaveViewProps} /> | |
| 2024 | + </Row> | |
| 2025 | + </Panel> | |
| 2026 | + </Collapse> | |
| 2027 | + <Row> | |
| 2028 | + <div id="ModalMaterialRemark" style={{ width: '100%' }}> | |
| 2029 | + {/* {areaShow2 ? <Divider orientation="left">{areaShow2}</Divider> : '' } */} | |
| 2030 | + {bControlShow ? | |
| 2031 | + <Collapse defaultActiveKey={['1', '1']} className="custom-collapse"> | |
| 2032 | + <Panel header={areaShow2} key="1"> | |
| 2033 | + <Row gutter={[8, 0]}> | |
| 2034 | + <Col span={showAll2 ? 24 : iColValueTable2} order={iShowOrder2}> | |
| 2035 | + <StaticEditTable {...controlPropsType} setOpterationColumn={props.sModelsType !== 'cost/cosexpenseshare' ? 'Y' : ''} /> | |
| 2036 | + </Col> | |
| 2037 | + <CommonViewTable {...controlViewProps} /> | |
| 2038 | + </Row> | |
| 2039 | + </Panel> | |
| 2040 | + </Collapse> : '' | |
| 2041 | + } | |
| 2042 | + | |
| 2043 | + {/* {areaShow3 ? <Divider orientation="left">{areaShow3}</Divider> : '' } */} | |
| 2044 | + { | |
| 2045 | + bMaterialShow ? | |
| 2046 | + <Collapse defaultActiveKey={['1', '1']} className="custom-collapse"> | |
| 2047 | + <Panel header={areaShow3} key="1"> | |
| 2048 | + {/* <div style={{ marginTop: 0, overflowY: 'hidden' }}> */} | |
| 2049 | + {/* <StaticEditTable {...materialsPropsType} footer="hidden" setOpterationColumn="Y" /> */} | |
| 2050 | + {/* </div> */} | |
| 2051 | + <Row gutter={[8, 0]}> | |
| 2052 | + <Col span={showAll2 ? 24 : iColValueTable} order={iShowOrder2}> | |
| 2053 | + <StaticEditTable {...materialsPropsType} setOpterationColumn="Y" /> | |
| 2054 | + </Col> | |
| 2055 | + <CommonViewTable {...materialsViewProps} /> | |
| 2056 | + </Row> | |
| 2057 | + </Panel> | |
| 2058 | + </Collapse> : '' | |
| 2059 | + } | |
| 2060 | + {/* {areaShow4 ? <Divider orientation="left">{areaShow4}</Divider> : '' } */} | |
| 2061 | + { | |
| 2062 | + bProcessShow ? | |
| 2063 | + <Collapse defaultActiveKey={['1', '1']} className="custom-collapse"> | |
| 2064 | + <Panel header={areaShow4} key="1"> | |
| 2065 | + {/* <div style={{ marginTop: 0, overflowY: 'hidden' }} id="chooseProcessModal"> */} | |
| 2066 | + {/* <StaticEditTable {...processPropsType} footer="hidden" setOpterationColumn="Y" /> */} | |
| 2067 | + {/* </div> */} | |
| 2068 | + <Row gutter={[8, 0]}> | |
| 2069 | + <Col span={showAll2 ? 24 : iColValueTable} order={iShowOrder2}> | |
| 2070 | + <StaticEditTable {...processPropsType} setOpterationColumn="Y" /> | |
| 2071 | + </Col> | |
| 2072 | + <CommonViewTable {...processViewProps} /> | |
| 2073 | + </Row> | |
| 2074 | + </Panel> | |
| 2075 | + </Collapse> : '' | |
| 2076 | + } | |
| 2077 | + | |
| 2078 | + {/* {areaShow5 ? <Divider orientation="left">{areaShow5}</Divider> : '' } */} | |
| 2079 | + { | |
| 2080 | + bPackShow ? | |
| 2081 | + <Collapse defaultActiveKey={['1', '1']} className="custom-collapse"> | |
| 2082 | + <Panel header={areaShow5} key="1"> | |
| 2083 | + {/* <div style={{ marginTop: 0, overflowY: 'hidden' }} id="chooseProcessModal"> */} | |
| 2084 | + {/* <StaticEditTable {...packPropsType} footer="hidden" setOpterationColumn="Y" /> */} | |
| 2085 | + {/* </div> */} | |
| 2086 | + <Row gutter={[8, 0]}> | |
| 2087 | + <Col span={showAll ? 24 : iColValueTable} order={iShowOrder2}> | |
| 2088 | + <StaticEditTable {...packPropsType} setOpterationColumn="Y" /> | |
| 2089 | + </Col> | |
| 2090 | + <CommonViewTable {...packViewProps} /> | |
| 2091 | + </Row> | |
| 2092 | + </Panel> | |
| 2093 | + </Collapse> : '' | |
| 2094 | + } | |
| 2095 | + { commonUtils.isNotEmptyObject(previewUrl) && bShowReport ? | |
| 2096 | + <Collapse defaultActiveKey={['1', '1']} className="custom-collapse" style={{ marginTop: '5px' }}> | |
| 2097 | + <Panel header="打印区域" key="1"> | |
| 2098 | + <div className="pdfContainer"> | |
| 2099 | + <PrintPdf {...props} /> | |
| 2100 | + </div> | |
| 2101 | + </Panel> | |
| 2102 | + </Collapse> | |
| 2103 | + : '' | |
| 2104 | + } | |
| 2105 | + </div> | |
| 2106 | + </Row> | |
| 2107 | + </div> | |
| 2108 | + </div> | |
| 2109 | + </div> } | |
| 2110 | + </Content> | |
| 2111 | + </Layout> | |
| 2112 | + </Layout> | |
| 2113 | + { | |
| 2114 | + isGetDataVisible ? | |
| 2115 | + <AntdDraggableModal | |
| 2116 | + visible={isGetDataVisible} | |
| 2117 | + title="获取数据" | |
| 2118 | + onOk={onGetDataOk} | |
| 2119 | + onCancel={colseGetDataVisible} | |
| 2120 | + footer={[ | |
| 2121 | + <Button key="back" onClick={onGetDataCancel}> | |
| 2122 | + {isAllGetData} | |
| 2123 | + </Button>, | |
| 2124 | + <Button key="submit" type="primary" onClick={onGetDataOk}> | |
| 2125 | + {isFilterGetDataZero} | |
| 2126 | + </Button>, | |
| 2127 | + ]} | |
| 2128 | + > | |
| 2129 | + <p>{isGetData}</p> | |
| 2130 | + </AntdDraggableModal> | |
| 2131 | + : '' | |
| 2132 | + } | |
| 2133 | + { | |
| 2134 | + props.materialsChooseVisible && !props.visibleModal ? | |
| 2135 | + <AntdDraggableModal | |
| 2136 | + width={1300} | |
| 2137 | + title={props.setMaterialTitle} | |
| 2138 | + visible={props.materialsChooseVisible} | |
| 2139 | + onCancel={props.handleCancelModal.bind(this, 'materialsChooseVisible')} | |
| 2140 | + onSaveState={props.onSaveState} | |
| 2141 | + footer={null} | |
| 2142 | + > | |
| 2143 | + <CommonListSelect {...searchMaterialsType} /> | |
| 2144 | + </AntdDraggableModal> | |
| 2145 | + : '' | |
| 2146 | + } | |
| 2147 | + | |
| 2148 | + | |
| 2149 | + { | |
| 2150 | + props.productProcessInfoChooseVisible ? | |
| 2151 | + <AntdDraggableModal | |
| 2152 | + width={1200} | |
| 2153 | + title={processCardSearchResult} | |
| 2154 | + visible={props.productProcessInfoChooseVisible} | |
| 2155 | + onCancel={props.onCancelProductProcessInfoChooseModal} | |
| 2156 | + footer={null} | |
| 2157 | + wrapClassName="worker-order-pack-modal" | |
| 2158 | + > | |
| 2159 | + <CommonListSelect {...productProcessInfoType} /> | |
| 2160 | + </AntdDraggableModal> : '' | |
| 2161 | + } | |
| 2162 | + | |
| 2163 | + { | |
| 2164 | + props.importFormDataVisible ? | |
| 2165 | + <AntdDraggableModal | |
| 2166 | + width={1300} | |
| 2167 | + zIndex={1000} | |
| 2168 | + title={importPopupTitle} | |
| 2169 | + visible={props.importFormDataVisible} | |
| 2170 | + onCancel={props.handleCancelModal.bind(this, 'importFormDataVisible')} | |
| 2171 | + onSaveState={props.onSaveState} | |
| 2172 | + footer={null} | |
| 2173 | + > | |
| 2174 | + <CommonListSelect {...importPopupProps} /> | |
| 2175 | + </AntdDraggableModal> | |
| 2176 | + : '' | |
| 2177 | + } | |
| 2178 | + { | |
| 2179 | + props.contextMenuModalVisible ? | |
| 2180 | + <ContextMenuModal {...props} /> | |
| 2181 | + : '' | |
| 2182 | + } | |
| 2183 | + </Form> | |
| 2184 | + ); | |
| 2185 | +}); | |
| 2186 | + | |
| 2187 | +export default CommonBase(CommonSales(CommonBill)); | ... | ... |
src/components/Common/CommonCheckBill/index.less
0 → 100644
| 1 | +.pdfContainer{ | |
| 2 | + width: 100%; | |
| 3 | + height: 300px; | |
| 4 | +} | |
| 5 | +/* 处理分隔符间距 */ | |
| 6 | +:global{ | |
| 7 | + .commonCheckBillContainer .ant-divider-horizontal.ant-divider-with-text{ | |
| 8 | + margin: 5px 0 10px 0!important; | |
| 9 | + } | |
| 10 | + /* 主表分隔符间距 */ | |
| 11 | + .commonCheckBillContainer .flexArea .ant-divider-horizontal.ant-divider-with-text{ | |
| 12 | + margin: -8px 0!important; | |
| 13 | + } | |
| 14 | +} | |
| 15 | + | |
| 16 | + | ... | ... |