-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
315 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
{ | ||
"name": "gm-x-printer", | ||
"version": "1.9.23-beta.5", | ||
"description": "diy printer", | ||
"main": "lib/main.js", | ||
"scripts": { | ||
"precommit": "lint-staged", | ||
"start": "webpack-dev-server --hot", | ||
"build": "webpack --progress --colors --config ./webpack.prod.config.js ", | ||
"build:watch": "webpack --progress --colors --config ./webpack.prod.config.js --watch", | ||
"locale": "i18n-m sync src/", | ||
"release": "bumpp" | ||
}, | ||
"lint-staged": { | ||
"./src/**/*.js": [ | ||
"eslint --cache --fix", | ||
"git add" | ||
] | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/gmfe/gm-x-printer.git" | ||
}, | ||
"types": "global.d.ts", | ||
"author": "", | ||
"license": "ISC", | ||
"files": [ | ||
"lib", | ||
"global.d.ts" | ||
], | ||
"bugs": { | ||
"url": "https://github.com/gmfe/gm-printer/issues" | ||
}, | ||
"standard": { | ||
"parser": "babel-eslint" | ||
}, | ||
"homepage": "https://github.com/gmfe/gm-printer#readme", | ||
"dependencies": { | ||
"big.js": "^5.2.2", | ||
"classnames": "^2.2.6", | ||
"gm-util": "^5.12.9", | ||
"jsbarcode": "^3.11.0", | ||
"lodash": "^4.17.10", | ||
"mobx": "^4.3.0", | ||
"mobx-react": "^6.1.1", | ||
"moment": "^2.22.2", | ||
"precss": "^4.0.0", | ||
"prop-types": "^15.6.2", | ||
"qrcode.react": "^0.9.2", | ||
"query-string": "^6.1.0", | ||
"react": "^16.14.0", | ||
"react-dom": "^16.14.0" | ||
}, | ||
"devDependencies": { | ||
"@babel/cli": "^7.23.4", | ||
"@babel/core": "^7.23.7", | ||
"@babel/preset-env": "^7.23.8", | ||
"@babel/runtime": "^7.23.8", | ||
"@babel/runtime-corejs3": "^7.23.8", | ||
"@svgr/webpack": "^4.3.2", | ||
"@types/react": "^16.14.55", | ||
"add-asset-html-webpack-plugin": "^3.2.2", | ||
"autoprefixer": "^9.8.8", | ||
"babel-eslint": "^10.0.2", | ||
"babel-loader": "^8.3.0", | ||
"babel-preset-gmfe": "^2.0.0", | ||
"big.js": "^5.2.2", | ||
"bumpp": "8.2.0", | ||
"classnames": "^2.2.6", | ||
"clipboard": "^2.0.1", | ||
"css-loader": "^3.6.0", | ||
"eslint": "^6.8.0", | ||
"eslint-config-prettier": "^6.15.0", | ||
"eslint-config-standard": "^14.1.1", | ||
"eslint-config-standard-jsx": "^8.1.0", | ||
"eslint-import-resolver-gmfe-alias": "0.0.2", | ||
"eslint-import-resolver-webpack": "^0.11.1", | ||
"eslint-plugin-gmfe": "^1.3.5", | ||
"eslint-plugin-import": "^2.18.2", | ||
"eslint-plugin-node": "^10.0.0", | ||
"eslint-plugin-prettier": "^3.1.0", | ||
"eslint-plugin-promise": "^4.2.1", | ||
"eslint-plugin-react": "^7.14.2", | ||
"eslint-plugin-standard": "^4.0.0", | ||
"file-loader": "^1.1.11", | ||
"gm-svg": "^0.3.0", | ||
"gm-util": "^5.12.6", | ||
"gm-webpack": "^2.2.1", | ||
"happypack": "^5.0.1", | ||
"html-webpack-plugin": "4.0.0", | ||
"husky": "^0.14.3", | ||
"jsbarcode": "^3.11.0", | ||
"less": "^3.13.1", | ||
"less-loader": "^5.0.0", | ||
"lint-staged": "^7.3.0", | ||
"lodash": "^4.17.10", | ||
"mini-css-extract-plugin": "^0.8.2", | ||
"moment": "^2.22.2", | ||
"path": "^0.12.7", | ||
"postcss-loader": "^3.0.0", | ||
"precss": "^4.0.0", | ||
"prettier": "^1.19.1", | ||
"prop-types": "^15.6.2", | ||
"query-string": "^6.1.0", | ||
"raw-loader": "^4.0.2", | ||
"react-hot-loader": "^4.12.14", | ||
"shelljs": "^0.8.3", | ||
"style-loader": "^0.23.1", | ||
"stylelint": "^9.10.1", | ||
"stylelint-config-standard": "^18.3.0", | ||
"terser-webpack-plugin": "^2.3.8", | ||
"url-loader": "^1.1.2", | ||
"webpack": "^4.47.0", | ||
"webpack-bundle-analyzer": "^4.10.1", | ||
"webpack-cli": "^3.3.12", | ||
"webpack-dev-server": "^3.11.3" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import i18next from '../../locales' | ||
import React from 'react' | ||
import PropTypes from 'prop-types' | ||
import CommonContextMenu from '../common/common_context_menu' | ||
import { inject, observer } from 'mobx-react' | ||
import { Printer } from '../printer' | ||
|
||
const blockTypeList = [ | ||
{ value: '', text: i18next.t('插入文本') }, | ||
{ value: 'line', text: i18next.t('插入线条') } | ||
] | ||
|
||
@inject(stores => ({ | ||
editStore: stores.editStore, | ||
mockData: stores.mockData | ||
})) | ||
@observer | ||
class ContextMenu extends React.Component { | ||
handleChangeTableDataKey = (key, name) => { | ||
const { editStore } = this.props | ||
|
||
editStore.changeTableDataKeyStockIn(name, key) | ||
} | ||
|
||
renderOrderActionBtn = name => { | ||
return <></> | ||
} | ||
|
||
render() { | ||
const { editStore, mockData, uploadQiniuImage } = this.props | ||
return ( | ||
<CommonContextMenu | ||
renderTableAction={this.renderOrderActionBtn} | ||
insertBlockList={blockTypeList} | ||
uploadQiniuImage={uploadQiniuImage} | ||
> | ||
<Printer | ||
key={editStore.computedPrinterKey} | ||
selected={editStore.selected} | ||
selectedRegion={editStore.selectedRegion} | ||
config={editStore.config} | ||
data={mockData} | ||
/> | ||
</CommonContextMenu> | ||
) | ||
} | ||
} | ||
|
||
ContextMenu.propTypes = { | ||
editStore: PropTypes.any, | ||
mockData: PropTypes.object, | ||
uploadQiniuImage: PropTypes.func | ||
} | ||
|
||
export default ContextMenu |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
import React from 'react' | ||
import PropTypes from 'prop-types' | ||
import _ from 'lodash' | ||
import { Flex } from '../components' | ||
import { Gap, Title } from '../common/component' | ||
import editStore from './store' | ||
import { observer, inject } from 'mobx-react' | ||
import EditorTitle from '../common/editor_title' | ||
import EditorSelect from '../common/editor_select' | ||
import EditorField from '../common/editor_edit_field' | ||
import EditorAddField from '../common/editor_add_field' | ||
import EditorSubtotal from '../common/editor_subtotal' | ||
import ContextMenu from './context_menu' | ||
import i18next from '../../locales' | ||
import withStore from '../common/hoc_with_store' | ||
import classNames from 'classnames' | ||
|
||
// const tableDataKeyList = [{ value: 'orders', text: i18next.t('全部商品') }] | ||
|
||
@withStore(editStore) | ||
@inject('editStore') | ||
@observer | ||
class Editor extends React.Component { | ||
render() { | ||
const { | ||
onSave, | ||
showEditor, | ||
addFields, | ||
className, | ||
uploadQiniuImage, | ||
type, | ||
templateType | ||
} = this.props | ||
return ( | ||
<div className={classNames('gm-printer-edit', className)}> | ||
<Flex className='gm-printer-edit-title-fixed'> | ||
<Title | ||
title={i18next.t('模板预览')} | ||
text={ | ||
<span className='gm-text-desc gm-padding-left-5'> | ||
{i18next.t( | ||
'说明:选中内容进行编辑,可拖动字段移动位置,右键使用更多功能' | ||
)} | ||
</span> | ||
} | ||
/> | ||
</Flex> | ||
<div style={{ display: 'none' }}> | ||
{this.props?.editStore?.config?.templateType} | ||
</div> | ||
|
||
{showEditor && ( | ||
<div className='gm-printer-edit-zone'> | ||
<EditorTitle onSave={onSave} /> | ||
<Gap height='10px' /> | ||
<EditorSelect type={type} /> | ||
<Gap height='5px' /> | ||
<EditorField tableDataKeyList={null} /> | ||
<Gap height='5px' /> | ||
{typeof addFields === 'function' ? ( | ||
<EditorAddField | ||
addFields={addFields(this?.props?.editStore?.config)} | ||
/> | ||
) : ( | ||
<EditorAddField addFields={addFields} /> | ||
)} | ||
|
||
<div id='gm-printer-tip' /> | ||
|
||
<div id='gm-printer-modal' /> | ||
</div> | ||
)} | ||
|
||
<div className='gm-printer-edit-wrap'> | ||
<ContextMenu | ||
type={type} | ||
templateType={templateType} | ||
uploadQiniuImage={uploadQiniuImage} | ||
/> | ||
</div> | ||
</div> | ||
) | ||
} | ||
} | ||
|
||
Editor.propTypes = { | ||
config: PropTypes.object.isRequired, | ||
onSave: PropTypes.func, | ||
uploadQiniuImage: PropTypes.func, | ||
showEditor: PropTypes.bool, | ||
mockData: PropTypes.object.isRequired, | ||
addFields: PropTypes.object.isRequired, | ||
type: PropTypes.string, | ||
editStore: PropTypes.object, | ||
templateType: PropTypes.number | ||
} | ||
|
||
Editor.deaultProps = { | ||
onSave: _.noop | ||
} | ||
|
||
export default Editor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import withShadowDom from '../common/hoc_with_shadow_dom' | ||
import Editor from './editor' | ||
|
||
export default withShadowDom(Editor) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import EditorStore from '../common/editor_store' | ||
import { action } from 'mobx' | ||
import _ from 'lodash' | ||
|
||
class Store extends EditorStore { | ||
@action | ||
changeTableDataKeyStockIn(name, key) { | ||
const arr = name.split('.') | ||
const { dataKey } = this.config.contents[arr[2]] | ||
const keyArr = dataKey.split('_') | ||
let newDataKey | ||
// 当前有这个key则去掉 | ||
if (keyArr.includes(key)) { | ||
newDataKey = _.without(keyArr, key) | ||
} else { | ||
newDataKey = _.concat(keyArr, key) | ||
} | ||
newDataKey = _.sortBy(newDataKey, [ | ||
o => o === 'money', | ||
o => o === 'quantity', | ||
o => o === 'multi', | ||
o => o === 'orders' | ||
]) | ||
|
||
this.config.contents[arr[2]].dataKey = newDataKey.join('_') | ||
} | ||
} | ||
|
||
export default new Store() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters