gm-printer 10.11.4-beta1 → 10.11.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintcache +1 -1
- package/README.md +102 -7
- package/build/demo.js +54 -0
- package/locales/en.json +1 -0
- package/locales/th.json +1 -0
- package/locales/zh-HK.json +1 -0
- package/package.json +10 -8
- package/src/common/editor_edit_field.js +82 -16
- package/src/common/editor_store.js +58 -0
- package/src/components/tip/index.js +19 -35
- package/src/components/tooltip/index.js +1 -1
- package/src/components/tooltip/style.less +0 -1
- package/src/editor/context_menu.js +16 -16
- package/src/editor/editor.js +10 -8
- package/src/editor/store.js +97 -12
- package/src/editor_account/context_menu.js +17 -3
- package/src/editor_purchase/context_menu.js +0 -1
- package/src/editor_purchase/editor.js +1 -1
- package/src/editor_purchase/editor_special_table.js +5 -2
- package/src/editor_purchase/store.js +39 -15
- package/src/index.js +2 -4
- package/src/printer/block.js +18 -10
- package/src/printer/printer.js +2 -2
- package/src/printer/qrcode.js +5 -2
- package/src/printer/store.js +116 -30
- package/src/printer/style.lesss +13 -3
- package/src/printer/table.js +57 -16
- package/src/printer/table_special_tr.js +1 -0
- package/src/printer/table_subtotal_tr.js +47 -7
- package/src/util.js +53 -2
- package/webpack.config.js +19 -1
- package/global.d.ts +0 -69
- package/src/editor_cannibalize/context_menu.js +0 -77
- package/src/editor_cannibalize/editor.js +0 -76
- package/src/editor_cannibalize/index.js +0 -4
- package/src/editor_cannibalize/store.js +0 -29
- package/yarn-error.log +0 -9770
package/src/printer/table.js
CHANGED
|
@@ -36,6 +36,7 @@ class Table extends React.Component {
|
|
|
36
36
|
const tHead = $table.querySelector('thead')
|
|
37
37
|
const ths = tHead.querySelectorAll('th') || []
|
|
38
38
|
const trs = $table.querySelectorAll('tbody tr') || []
|
|
39
|
+
const detailsDiv = $table.querySelectorAll('tr td .b-table-details')
|
|
39
40
|
|
|
40
41
|
printerStore.setHeight(name, getHeight($table))
|
|
41
42
|
|
|
@@ -45,7 +46,8 @@ class Table extends React.Component {
|
|
|
45
46
|
widths: _.map(ths, th => getWidth(th))
|
|
46
47
|
},
|
|
47
48
|
body: {
|
|
48
|
-
heights: _.map(trs, tr => getHeight(tr))
|
|
49
|
+
heights: _.map(trs, tr => getHeight(tr)),
|
|
50
|
+
children: _.map(detailsDiv, div => getHeight(div))
|
|
49
51
|
}
|
|
50
52
|
})
|
|
51
53
|
}
|
|
@@ -107,14 +109,27 @@ class Table extends React.Component {
|
|
|
107
109
|
for (let i = 2; i <= colNumber; i++) {
|
|
108
110
|
const colNum = i > 2 ? i : '' // 栏数
|
|
109
111
|
const columnsI = columns.map((val, index) => {
|
|
110
|
-
|
|
112
|
+
const data = {
|
|
111
113
|
...val,
|
|
112
114
|
index,
|
|
113
115
|
text: val.text.replace(
|
|
114
|
-
/{{
|
|
115
|
-
(s, s1) =>
|
|
116
|
+
/{{(price\()?列\.([^{{]+)}}/g,
|
|
117
|
+
(s, s1, s2) => {
|
|
118
|
+
if (s1) {
|
|
119
|
+
// 有price函数插进来
|
|
120
|
+
const mix_suffix = s2.replace(/\*/, () => `${MULTI_SUFFIX}*`)
|
|
121
|
+
return `{{${s1}列.${mix_suffix}${colNum}}}`
|
|
122
|
+
} else {
|
|
123
|
+
return `{{列.${s2}${MULTI_SUFFIX}${colNum}}}`
|
|
124
|
+
}
|
|
125
|
+
}
|
|
116
126
|
) // {{列.xx}} => {{列.xxMULTI_SUFFIXi}}
|
|
117
127
|
}
|
|
128
|
+
// 多栏商品的明细取 __details_MULTI_SUFFIX
|
|
129
|
+
if (val.specialDetailsKey)
|
|
130
|
+
data.specialDetailsKey =
|
|
131
|
+
val.specialDetailsKey + `${MULTI_SUFFIX}${colNum}`
|
|
132
|
+
return data
|
|
118
133
|
})
|
|
119
134
|
res = res.concat(columnsI)
|
|
120
135
|
}
|
|
@@ -140,9 +155,34 @@ class Table extends React.Component {
|
|
|
140
155
|
|
|
141
156
|
// 列
|
|
142
157
|
const columns = this.getColumns()
|
|
143
|
-
|
|
144
158
|
// 列宽固定(避免跳页bug)
|
|
145
159
|
const thWidths = printerStore.tablesInfo[name]?.head.widths || []
|
|
160
|
+
// 每页合计在前
|
|
161
|
+
const subtotalTrPageSummary = () => {
|
|
162
|
+
return (
|
|
163
|
+
<>
|
|
164
|
+
<SubtotalTr
|
|
165
|
+
range={range}
|
|
166
|
+
config={config}
|
|
167
|
+
printerStore={printerStore}
|
|
168
|
+
/>
|
|
169
|
+
<PageSummary {...this.props} />
|
|
170
|
+
</>
|
|
171
|
+
)
|
|
172
|
+
}
|
|
173
|
+
// 合计在前
|
|
174
|
+
const PageSummarySubtotalTr = () => {
|
|
175
|
+
return (
|
|
176
|
+
<>
|
|
177
|
+
<PageSummary {...this.props} />
|
|
178
|
+
<SubtotalTr
|
|
179
|
+
range={range}
|
|
180
|
+
config={config}
|
|
181
|
+
printerStore={printerStore}
|
|
182
|
+
/>
|
|
183
|
+
</>
|
|
184
|
+
)
|
|
185
|
+
}
|
|
146
186
|
|
|
147
187
|
return (
|
|
148
188
|
<table>
|
|
@@ -155,7 +195,7 @@ class Table extends React.Component {
|
|
|
155
195
|
data-name={getTableColumnName(name, col.index)}
|
|
156
196
|
draggable
|
|
157
197
|
style={{
|
|
158
|
-
|
|
198
|
+
maxWidth: thWidths[i],
|
|
159
199
|
...col.headStyle
|
|
160
200
|
}}
|
|
161
201
|
className={classNames({
|
|
@@ -178,7 +218,6 @@ class Table extends React.Component {
|
|
|
178
218
|
const _special = tableData[i] && tableData[i]._special
|
|
179
219
|
if (_special)
|
|
180
220
|
return <SpecialTr key={i} config={config} data={_special} />
|
|
181
|
-
|
|
182
221
|
// 如果项为空对象展现一个占满一行的td
|
|
183
222
|
const isItemNone = !_.keys(tableData[i]).length
|
|
184
223
|
|
|
@@ -192,7 +231,11 @@ class Table extends React.Component {
|
|
|
192
231
|
<td
|
|
193
232
|
key={j}
|
|
194
233
|
data-name={getTableColumnName(name, col.index)}
|
|
195
|
-
style={
|
|
234
|
+
style={{
|
|
235
|
+
minWidth: '24px',
|
|
236
|
+
maxWidth: thWidths[j],
|
|
237
|
+
...col.style
|
|
238
|
+
}}
|
|
196
239
|
className={classNames({
|
|
197
240
|
active:
|
|
198
241
|
getTableColumnName(name, col.index) ===
|
|
@@ -205,12 +248,9 @@ class Table extends React.Component {
|
|
|
205
248
|
dataKey,
|
|
206
249
|
i
|
|
207
250
|
)
|
|
208
|
-
: printerStore
|
|
209
|
-
col.text,
|
|
210
|
-
|
|
211
|
-
i,
|
|
212
|
-
pageIndex
|
|
213
|
-
)
|
|
251
|
+
: printerStore
|
|
252
|
+
.templateTable(col.text, dataKey, i, pageIndex)
|
|
253
|
+
.replace(/\(\)/g, '')
|
|
214
254
|
}}
|
|
215
255
|
/>
|
|
216
256
|
)
|
|
@@ -219,8 +259,9 @@ class Table extends React.Component {
|
|
|
219
259
|
</tr>
|
|
220
260
|
)
|
|
221
261
|
})}
|
|
222
|
-
|
|
223
|
-
|
|
262
|
+
{this.props.config.subtotal.isCommutationPlace
|
|
263
|
+
? PageSummarySubtotalTr()
|
|
264
|
+
: subtotalTrPageSummary()}
|
|
224
265
|
</tbody>
|
|
225
266
|
</table>
|
|
226
267
|
)
|
|
@@ -7,6 +7,7 @@ import Big from 'big.js'
|
|
|
7
7
|
import { coverDigit2Uppercase, getDataKey } from '../util'
|
|
8
8
|
import { observer } from 'mobx-react'
|
|
9
9
|
import { get } from 'mobx'
|
|
10
|
+
import { Flex } from '../components'
|
|
10
11
|
|
|
11
12
|
/**
|
|
12
13
|
* 每页合计组件,分页计算后,根据range来统计每页合计数据
|
|
@@ -21,6 +22,8 @@ const SubtotalTr = props => {
|
|
|
21
22
|
subtotal,
|
|
22
23
|
subtotal: {
|
|
23
24
|
show,
|
|
25
|
+
isUpperCaseBefore, // 决定小写金额是否在前
|
|
26
|
+
isUpperLowerCaseSeparate, // 决定大小写金额是否分开在两端
|
|
24
27
|
style,
|
|
25
28
|
fields = [
|
|
26
29
|
{
|
|
@@ -62,21 +65,37 @@ const SubtotalTr = props => {
|
|
|
62
65
|
const list = tableData.slice(range.begin, range.end)
|
|
63
66
|
|
|
64
67
|
const sum = {}
|
|
65
|
-
let subtotalStr = ''
|
|
66
68
|
|
|
67
69
|
_.each(fields, v => {
|
|
68
70
|
sum[v.name] = sumData(list, v.valueField)
|
|
69
71
|
})
|
|
70
72
|
|
|
73
|
+
// 定义每页小记的左右两侧内容
|
|
74
|
+
let subtotalLeftContent
|
|
75
|
+
let subtotalRightContent
|
|
76
|
+
|
|
71
77
|
for (const name in sum) {
|
|
72
78
|
const price = sum[name]
|
|
73
79
|
const priceUpperCase = get(subtotal, 'needUpperCase') // needUpperCase在初始模板中undefined,所以必须用这个方法
|
|
74
80
|
? '大写:' + coverDigit2Uppercase(price)
|
|
75
81
|
: ''
|
|
76
82
|
if (displayName) {
|
|
77
|
-
|
|
83
|
+
// 大写金额是否在前
|
|
84
|
+
if (isUpperCaseBefore) {
|
|
85
|
+
subtotalLeftContent = `${name}${priceUpperCase}`
|
|
86
|
+
subtotalRightContent = `${price}`
|
|
87
|
+
} else {
|
|
88
|
+
subtotalLeftContent = `${price}`
|
|
89
|
+
subtotalRightContent = `${name} ${priceUpperCase}`
|
|
90
|
+
}
|
|
78
91
|
} else {
|
|
79
|
-
|
|
92
|
+
if (isUpperCaseBefore) {
|
|
93
|
+
subtotalLeftContent = `${priceUpperCase}`
|
|
94
|
+
subtotalRightContent = `${price}`
|
|
95
|
+
} else {
|
|
96
|
+
subtotalLeftContent = `${price}`
|
|
97
|
+
subtotalRightContent = `${priceUpperCase}`
|
|
98
|
+
}
|
|
80
99
|
}
|
|
81
100
|
}
|
|
82
101
|
|
|
@@ -85,10 +104,31 @@ const SubtotalTr = props => {
|
|
|
85
104
|
<td
|
|
86
105
|
colSpan={99}
|
|
87
106
|
style={{ fontWeight: 'bold', ...style }}
|
|
88
|
-
dangerouslySetInnerHTML={{
|
|
89
|
-
|
|
90
|
-
}}
|
|
91
|
-
|
|
107
|
+
// dangerouslySetInnerHTML={{
|
|
108
|
+
// __html: `${i18next.t('每页合计')}:${subtotalStr}`
|
|
109
|
+
// }}flex-grow: 1
|
|
110
|
+
>
|
|
111
|
+
{/* 大写金额和小写金额分开在表格的两侧,通过控制类名实现,添加类名后,覆盖原来的居中、靠右靠左 */}
|
|
112
|
+
<div
|
|
113
|
+
className={
|
|
114
|
+
isUpperLowerCaseSeparate
|
|
115
|
+
? 'gm-printer-subtotal-UpperLowerCaseSeparate-outer'
|
|
116
|
+
: ''
|
|
117
|
+
}
|
|
118
|
+
>
|
|
119
|
+
{i18next.t('每页合计')}:
|
|
120
|
+
<span
|
|
121
|
+
className={
|
|
122
|
+
isUpperLowerCaseSeparate
|
|
123
|
+
? 'gm-printer-subtotal-UpperLowerCaseSeparate-inter'
|
|
124
|
+
: ''
|
|
125
|
+
}
|
|
126
|
+
>
|
|
127
|
+
<span> {subtotalLeftContent} </span>
|
|
128
|
+
<span> {subtotalRightContent} </span>
|
|
129
|
+
</span>
|
|
130
|
+
</div>
|
|
131
|
+
</td>
|
|
92
132
|
</tr>
|
|
93
133
|
)
|
|
94
134
|
} else {
|
package/src/util.js
CHANGED
|
@@ -15,7 +15,7 @@ function getHeight(el) {
|
|
|
15
15
|
|
|
16
16
|
function getWidth(el) {
|
|
17
17
|
const styles = window.getComputedStyle(el)
|
|
18
|
-
const width = el.offsetWidth
|
|
18
|
+
const width = Math.ceil(el.offsetWidth)
|
|
19
19
|
const borderLeftWidth = parseFloat(styles.borderLeftWidth)
|
|
20
20
|
const borderRightWidth = parseFloat(styles.borderRightWidth)
|
|
21
21
|
const paddingLeft = parseFloat(styles.paddingLeft)
|
|
@@ -178,6 +178,56 @@ const getDataKey = (dataKey, arrange) =>
|
|
|
178
178
|
? `${dataKey}_vertical`
|
|
179
179
|
: dataKey
|
|
180
180
|
|
|
181
|
+
/**
|
|
182
|
+
* @param {*} table 当前单据的高度信息
|
|
183
|
+
* @param {*} detailsData 当前所有tablelist
|
|
184
|
+
* @param {*} currentPageMinimumHeight 当前page最小高度
|
|
185
|
+
* @param {*} pageHeight page的高度
|
|
186
|
+
* @returns {ranges, detailsPageHeight} detailsPageHeight 每页高度合集
|
|
187
|
+
*/
|
|
188
|
+
const caclSingleDetailsPageHeight = (
|
|
189
|
+
indexEnd,
|
|
190
|
+
table,
|
|
191
|
+
detailsData,
|
|
192
|
+
heightParams
|
|
193
|
+
) => {
|
|
194
|
+
let end = 0
|
|
195
|
+
let begin = 0
|
|
196
|
+
let index = 0
|
|
197
|
+
let currentDetailsMiniHeight = 0
|
|
198
|
+
const ranges = []
|
|
199
|
+
const detailsPageHeight = []
|
|
200
|
+
const { calcHeight, pageHeight, currentPageMinimumHeight } = heightParams
|
|
201
|
+
|
|
202
|
+
while (end < detailsData.length) {
|
|
203
|
+
currentDetailsMiniHeight += table.body.children[end]
|
|
204
|
+
|
|
205
|
+
const _calcHeight = !index && indexEnd === 0 ? calcHeight : pageHeight
|
|
206
|
+
// 如果当前明细高度综合大于页面高度,到此为止进行分页
|
|
207
|
+
if (currentDetailsMiniHeight + currentPageMinimumHeight > _calcHeight) {
|
|
208
|
+
detailsPageHeight.push(
|
|
209
|
+
currentDetailsMiniHeight - table.body.children[end]
|
|
210
|
+
)
|
|
211
|
+
ranges.push([begin, end])
|
|
212
|
+
end++
|
|
213
|
+
index++
|
|
214
|
+
begin = end
|
|
215
|
+
currentDetailsMiniHeight = 0
|
|
216
|
+
} else {
|
|
217
|
+
end++
|
|
218
|
+
if (end === detailsData.length) {
|
|
219
|
+
ranges.push([begin, end])
|
|
220
|
+
detailsPageHeight.push(currentDetailsMiniHeight)
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
return {
|
|
226
|
+
ranges,
|
|
227
|
+
detailsPageHeight
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
181
231
|
export {
|
|
182
232
|
getHeight,
|
|
183
233
|
getWidth,
|
|
@@ -193,5 +243,6 @@ export {
|
|
|
193
243
|
coverDigit2Uppercase,
|
|
194
244
|
getDataKey,
|
|
195
245
|
isMultiTable,
|
|
196
|
-
getMultiNumber
|
|
246
|
+
getMultiNumber,
|
|
247
|
+
caclSingleDetailsPageHeight
|
|
197
248
|
}
|
package/webpack.config.js
CHANGED
|
@@ -36,6 +36,24 @@ module.exports = {
|
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
]
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
test: /\/svg\/(\w|\W)+\.svg$/,
|
|
42
|
+
use: [
|
|
43
|
+
{
|
|
44
|
+
loader: '@svgr/webpack',
|
|
45
|
+
options: {
|
|
46
|
+
icon: true,
|
|
47
|
+
expandProps: 'start',
|
|
48
|
+
svgProps: {
|
|
49
|
+
fill: 'currentColor',
|
|
50
|
+
// className 冗余
|
|
51
|
+
className:
|
|
52
|
+
"{'gm-svg-icon t-svg-icon m-svg-icon ' + (props.className || '')}"
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
]
|
|
39
57
|
}
|
|
40
58
|
]
|
|
41
59
|
},
|
|
@@ -45,7 +63,7 @@ module.exports = {
|
|
|
45
63
|
devServer: {
|
|
46
64
|
compress: true,
|
|
47
65
|
host: '0.0.0.0',
|
|
48
|
-
port:
|
|
66
|
+
port: 5678,
|
|
49
67
|
inline: false,
|
|
50
68
|
disableHostCheck: true,
|
|
51
69
|
proxy: {
|
package/global.d.ts
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
declare module 'gm-printer' {
|
|
2
|
-
import { CSSProperties } from 'react'
|
|
3
|
-
interface EditorProps {
|
|
4
|
-
config: any
|
|
5
|
-
mockData: any
|
|
6
|
-
onSave: (config: any, isSaveAs?: boolean) => void
|
|
7
|
-
showEditor: boolean
|
|
8
|
-
addFields: any
|
|
9
|
-
}
|
|
10
|
-
interface PrinterProps {
|
|
11
|
-
data: any
|
|
12
|
-
config: any
|
|
13
|
-
className?: string
|
|
14
|
-
style?: CSSProperties
|
|
15
|
-
selected?: string
|
|
16
|
-
selectedRegion?: string
|
|
17
|
-
onReady?: () => void
|
|
18
|
-
}
|
|
19
|
-
interface BatchPrinterProps {
|
|
20
|
-
list: any[]
|
|
21
|
-
onReady?: () => void
|
|
22
|
-
}
|
|
23
|
-
// function Editor<P extends EditorProps>(props: P): React.ComponentType<P>
|
|
24
|
-
class Editor<T extends EditorProps> extends React.Component<T, any> {}
|
|
25
|
-
class EditorStockIn<T extends EditorProps> extends React.Component<T, any> {}
|
|
26
|
-
class EditorStockOut<T extends EditorProps> extends React.Component<T, any> {}
|
|
27
|
-
class EditorPurchase<T extends EditorProps> extends React.Component<T, any> {}
|
|
28
|
-
class EditorSettle<T extends EditorProps> extends React.Component<T, any> {}
|
|
29
|
-
class EditorCannibalize<T extends EditorProps> extends React.Component<T, any> {}
|
|
30
|
-
class EditorStatement<T extends EditorProps> extends React.Component<
|
|
31
|
-
T,
|
|
32
|
-
any
|
|
33
|
-
> {}
|
|
34
|
-
class EditorAccoutStatement<T extends EditorProps> extends React.Component<
|
|
35
|
-
T,
|
|
36
|
-
any
|
|
37
|
-
> {}
|
|
38
|
-
class EditorAccount<T extends EditorProps> extends React.Component<T, any> {}
|
|
39
|
-
class EditorBoxLabel<T extends EditorProps> extends React.Component<T, any> {}
|
|
40
|
-
class Printer<T extends PrinterProps> extends React.Component<T, any> {}
|
|
41
|
-
class BatchPrinter<T extends BatchPrinterProps> extends React.Component<T, any> {}
|
|
42
|
-
const MULTI_SUFFIX: string
|
|
43
|
-
function getCSS(): string
|
|
44
|
-
function insertCSS(cssString: string, target?: HTMLElement | ShadowRoot): void
|
|
45
|
-
function doPrint(
|
|
46
|
-
obj: { data: any; config: any },
|
|
47
|
-
isTest?: boolean
|
|
48
|
-
): (obj: { data: any; config: any }) => Promise<any>
|
|
49
|
-
function doBatchPrint(list: any [], isTest?: boolean): (list: []) => Promise<any>
|
|
50
|
-
export {
|
|
51
|
-
Editor,
|
|
52
|
-
EditorStockIn,
|
|
53
|
-
EditorStockOut,
|
|
54
|
-
EditorPurchase,
|
|
55
|
-
EditorSettle,
|
|
56
|
-
EditorCannibalize,
|
|
57
|
-
EditorStatement,
|
|
58
|
-
EditorAccoutStatement,
|
|
59
|
-
EditorAccount,
|
|
60
|
-
EditorBoxLabel,
|
|
61
|
-
Printer,
|
|
62
|
-
BatchPrinter,
|
|
63
|
-
MULTI_SUFFIX,
|
|
64
|
-
insertCSS,
|
|
65
|
-
getCSS,
|
|
66
|
-
doPrint,
|
|
67
|
-
doBatchPrint
|
|
68
|
-
}
|
|
69
|
-
}
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import i18next from '../../locales'
|
|
2
|
-
import React from 'react'
|
|
3
|
-
import CommonContextMenu from '../common/common_context_menu'
|
|
4
|
-
import { inject, observer } from 'mobx-react'
|
|
5
|
-
import { Printer } from '../printer'
|
|
6
|
-
|
|
7
|
-
const blockTypeList = [
|
|
8
|
-
{ value: '', text: i18next.t('插入文本') },
|
|
9
|
-
{ value: 'line', text: i18next.t('插入线条') },
|
|
10
|
-
{ value: 'image', text: i18next.t('插入图片') }
|
|
11
|
-
]
|
|
12
|
-
|
|
13
|
-
@inject(stores => ({
|
|
14
|
-
editStore: stores.editStore,
|
|
15
|
-
mockData: stores.mockData
|
|
16
|
-
}))
|
|
17
|
-
@observer
|
|
18
|
-
class ContextMenu extends React.Component {
|
|
19
|
-
handleChangeTableDataKey = (key, name) => {
|
|
20
|
-
const { editStore } = this.props
|
|
21
|
-
|
|
22
|
-
editStore.changeTableDataKeyStockout(name, key)
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
renderOrderActionBtn = name => {
|
|
26
|
-
const arr = name.split('.')
|
|
27
|
-
const { dataKey } = this.props.editStore.config.contents[arr[2]]
|
|
28
|
-
const keyArr = dataKey.split('_')
|
|
29
|
-
|
|
30
|
-
const isQuantityActive = keyArr.includes('quantity')
|
|
31
|
-
// const isMoneyActive = keyArr.includes('money')
|
|
32
|
-
const isMultiActive = keyArr.includes('multi')
|
|
33
|
-
|
|
34
|
-
return (
|
|
35
|
-
<>
|
|
36
|
-
<div
|
|
37
|
-
onClick={this.handleChangeTableDataKey.bind(this, 'multi', name)}
|
|
38
|
-
className={isMultiActive ? 'active' : ''}
|
|
39
|
-
>
|
|
40
|
-
{i18next.t('双栏商品')}
|
|
41
|
-
</div>
|
|
42
|
-
<div
|
|
43
|
-
onClick={this.handleChangeTableDataKey.bind(this, 'quantity', name)}
|
|
44
|
-
className={isQuantityActive ? 'active' : ''}
|
|
45
|
-
>
|
|
46
|
-
{i18next.t('调拨数小计')}
|
|
47
|
-
</div>
|
|
48
|
-
{/* <div
|
|
49
|
-
onClick={this.handleChangeTableDataKey.bind(this, 'money', name)}
|
|
50
|
-
className={isMoneyActive ? 'active' : ''}
|
|
51
|
-
>
|
|
52
|
-
{i18next.t('调拨金额小计')}
|
|
53
|
-
</div> */}
|
|
54
|
-
</>
|
|
55
|
-
)
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
render() {
|
|
59
|
-
const { editStore, mockData } = this.props
|
|
60
|
-
return (
|
|
61
|
-
<CommonContextMenu
|
|
62
|
-
renderTableAction={this.renderOrderActionBtn}
|
|
63
|
-
insertBlockList={blockTypeList}
|
|
64
|
-
>
|
|
65
|
-
<Printer
|
|
66
|
-
key={editStore.computedPrinterKey}
|
|
67
|
-
selected={editStore.selected}
|
|
68
|
-
selectedRegion={editStore.selectedRegion}
|
|
69
|
-
config={editStore.config}
|
|
70
|
-
data={mockData}
|
|
71
|
-
/>
|
|
72
|
-
</CommonContextMenu>
|
|
73
|
-
)
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
export default ContextMenu
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
import PropTypes from 'prop-types'
|
|
3
|
-
import _ from 'lodash'
|
|
4
|
-
import { Flex } from '../components'
|
|
5
|
-
import { Gap, Title } from '../common/component'
|
|
6
|
-
import editStore from './store'
|
|
7
|
-
import { observer, inject } from 'mobx-react'
|
|
8
|
-
import EditorTitle from '../common/editor_title'
|
|
9
|
-
import EditorSelect from '../common/editor_select'
|
|
10
|
-
import EditorField from '../common/editor_edit_field'
|
|
11
|
-
import EditorAddField from '../common/editor_add_field'
|
|
12
|
-
import ContextMenu from './context_menu'
|
|
13
|
-
import i18next from '../../locales'
|
|
14
|
-
import withStore from '../common/hoc_with_store'
|
|
15
|
-
|
|
16
|
-
const tableDataKeyList = [{ value: 'orders', text: i18next.t('全部商品') }]
|
|
17
|
-
|
|
18
|
-
@withStore(editStore)
|
|
19
|
-
@inject('editStore')
|
|
20
|
-
@observer
|
|
21
|
-
class Editor extends React.Component {
|
|
22
|
-
render() {
|
|
23
|
-
const { onSave, showEditor, addFields } = this.props
|
|
24
|
-
// console.log('挑拨单数据',this.props)
|
|
25
|
-
return (
|
|
26
|
-
<div className='gm-printer-edit'>
|
|
27
|
-
<Flex className='gm-printer-edit-title-fixed'>
|
|
28
|
-
<Title
|
|
29
|
-
title={i18next.t('模板预览')}
|
|
30
|
-
text={
|
|
31
|
-
<span className='gm-text-desc gm-padding-left-5'>
|
|
32
|
-
{i18next.t(
|
|
33
|
-
'说明:选中内容进行编辑,可拖动字段移动位置,右键使用更多功能'
|
|
34
|
-
)}
|
|
35
|
-
</span>
|
|
36
|
-
}
|
|
37
|
-
/>
|
|
38
|
-
</Flex>
|
|
39
|
-
|
|
40
|
-
{showEditor && (
|
|
41
|
-
<div className='gm-printer-edit-zone'>
|
|
42
|
-
<EditorTitle onSave={onSave} />
|
|
43
|
-
<Gap height='10px' />
|
|
44
|
-
<EditorSelect />
|
|
45
|
-
<Gap height='5px' />
|
|
46
|
-
<EditorField tableDataKeyList={tableDataKeyList} />
|
|
47
|
-
<Gap height='5px' />
|
|
48
|
-
<EditorAddField addFields={addFields} />
|
|
49
|
-
|
|
50
|
-
<div id='gm-printer-tip' />
|
|
51
|
-
|
|
52
|
-
<div id='gm-printer-modal' />
|
|
53
|
-
</div>
|
|
54
|
-
)}
|
|
55
|
-
|
|
56
|
-
<div className='gm-printer-edit-wrap'>
|
|
57
|
-
<ContextMenu />
|
|
58
|
-
</div>
|
|
59
|
-
</div>
|
|
60
|
-
)
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
Editor.propTypes = {
|
|
65
|
-
config: PropTypes.object.isRequired,
|
|
66
|
-
onSave: PropTypes.func,
|
|
67
|
-
showEditor: PropTypes.bool,
|
|
68
|
-
mockData: PropTypes.object.isRequired,
|
|
69
|
-
addFields: PropTypes.object.isRequired
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
Editor.deaultProps = {
|
|
73
|
-
onSave: _.noop
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
export default Editor
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import EditorStore from '../common/editor_store'
|
|
2
|
-
import { action } from 'mobx'
|
|
3
|
-
import _ from 'lodash'
|
|
4
|
-
|
|
5
|
-
class Store extends EditorStore {
|
|
6
|
-
@action
|
|
7
|
-
changeTableDataKeyStockout(name, key) {
|
|
8
|
-
const arr = name.split('.')
|
|
9
|
-
const { dataKey } = this.config.contents[arr[2]]
|
|
10
|
-
const keyArr = dataKey.split('_')
|
|
11
|
-
let newDataKey
|
|
12
|
-
// 当前有这个key则去掉
|
|
13
|
-
if (keyArr.includes(key)) {
|
|
14
|
-
newDataKey = _.without(keyArr, key)
|
|
15
|
-
} else {
|
|
16
|
-
newDataKey = _.concat(keyArr, key)
|
|
17
|
-
}
|
|
18
|
-
newDataKey = _.sortBy(newDataKey, [
|
|
19
|
-
o => o === 'money',
|
|
20
|
-
o => o === 'quantity',
|
|
21
|
-
o => o === 'multi',
|
|
22
|
-
o => o === 'orders'
|
|
23
|
-
])
|
|
24
|
-
|
|
25
|
-
this.config.contents[arr[2]].dataKey = newDataKey.join('_')
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export default new Store()
|