linkmore-design 1.0.64 → 1.0.66

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.
@@ -0,0 +1,24 @@
1
+ import React from 'react';
2
+ declare type VoidFunction = () => void;
3
+ export interface IApprovalItemProps {
4
+ avator?: string;
5
+ name?: string;
6
+ time?: string;
7
+ type?: 'start' | 'comment' | 'carbonCopy' | 'agree' | 'refuse';
8
+ [prop: string]: any;
9
+ }
10
+ export interface IApprovalProps {
11
+ visible?: boolean;
12
+ title?: string;
13
+ close?: () => void;
14
+ className?: string;
15
+ style?: React.CSSProperties;
16
+ userType?: 'self' | 'approver';
17
+ status?: number;
18
+ steps?: [];
19
+ onComment: VoidFunction;
20
+ onRefuse: VoidFunction;
21
+ onAgree: VoidFunction;
22
+ }
23
+ declare const LMApproval: React.FC<IApprovalProps>;
24
+ export default LMApproval;
@@ -0,0 +1,210 @@
1
+ var __rest = this && this.__rest || function (s, e) {
2
+ var t = {};
3
+
4
+ for (var p in s) {
5
+ if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
6
+ }
7
+
8
+ if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
9
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
10
+ }
11
+ return t;
12
+ };
13
+
14
+ import React from 'react';
15
+ import classNames from 'classnames';
16
+ import { Button, Drawer, Space } from '..';
17
+ var prefixCls = 'lm_approval';
18
+ var colors = ['#36BCF1', '#AE86DC', '#8BD248', '#F5A173'];
19
+ var statusMap = new Map([[1, '审核中'], [2, '已审核'], [3, '未通过']]);
20
+ var defaultStatus = 1;
21
+
22
+ var LMDrawer = function LMDrawer(props) {
23
+ var _props$visible = props.visible,
24
+ visible = _props$visible === void 0 ? false : _props$visible,
25
+ _props$title = props.title,
26
+ title = _props$title === void 0 ? '' : _props$title,
27
+ _props$status = props.status,
28
+ status = _props$status === void 0 ? defaultStatus : _props$status,
29
+ _props$userType = props.userType,
30
+ userType = _props$userType === void 0 ? 'self' : _props$userType,
31
+ close = props.close,
32
+ children = props.children,
33
+ _props$onComment = props.onComment,
34
+ onComment = _props$onComment === void 0 ? function () {} : _props$onComment,
35
+ _props$onRefuse = props.onRefuse,
36
+ onRefuse = _props$onRefuse === void 0 ? function () {} : _props$onRefuse,
37
+ _props$onAgree = props.onAgree,
38
+ onAgree = _props$onAgree === void 0 ? function () {} : _props$onAgree;
39
+ var currentStatusCls = classNames(prefixCls + '_title_status');
40
+ var drawerCls = classNames(prefixCls + '_drawer');
41
+ var statusText = statusMap.has(status) ? statusMap.get(status) : statusMap.get(1);
42
+
43
+ var handleClose = function handleClose() {
44
+ visible = false;
45
+ close();
46
+ };
47
+
48
+ return /*#__PURE__*/React.createElement(Drawer, {
49
+ className: drawerCls,
50
+ visible: visible,
51
+ title: title,
52
+ onClose: handleClose,
53
+ extra: /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
54
+ className: currentStatusCls
55
+ }, /*#__PURE__*/React.createElement("span", null, statusText)), status === 1 && userType === 'approver' && /*#__PURE__*/React.createElement(Space, null, /*#__PURE__*/React.createElement(Button, {
56
+ size: "small",
57
+ onClick: onComment
58
+ }, "\u4EC5\u8BC4\u8BBA"), /*#__PURE__*/React.createElement(Button, {
59
+ size: "small",
60
+ onClick: onRefuse,
61
+ style: {
62
+ borderColor: '#FA4F53',
63
+ color: '#FA4F53'
64
+ }
65
+ }, "\u62D2\u7EDD"), /*#__PURE__*/React.createElement(Button, {
66
+ size: "small",
67
+ onClick: onAgree,
68
+ type: "primary"
69
+ }, "\u540C\u610F")))
70
+ }, children);
71
+ };
72
+
73
+ var ApprovalItem = function ApprovalItem(props) {
74
+ var _props$avator = props.avator,
75
+ avator = _props$avator === void 0 ? '' : _props$avator,
76
+ _props$name = props.name,
77
+ name = _props$name === void 0 ? '' : _props$name,
78
+ _props$time = props.time,
79
+ time = _props$time === void 0 ? '' : _props$time,
80
+ color = props.color,
81
+ status = props.status,
82
+ _props$type = props.type,
83
+ type = _props$type === void 0 ? 'start' : _props$type;
84
+ var itemCls = classNames(prefixCls + '_item');
85
+ var itemHeaderCls = classNames(itemCls + '_header');
86
+ var itemBodyCls = classNames(itemCls + '_body');
87
+
88
+ var getIcon = function getIcon() {
89
+ if (status === 1) {
90
+ return /*#__PURE__*/React.createElement("i", {
91
+ className: 'icon iconfont lmweb-icon_china1'
92
+ });
93
+ }
94
+
95
+ if (status === 2) {
96
+ return /*#__PURE__*/React.createElement("i", {
97
+ className: 'icon iconfont lmweb-icon_china1'
98
+ }); // return <img className='icon' src={fulfilledSvg} alt="" />
99
+ }
100
+
101
+ if (status === 3) {
102
+ return /*#__PURE__*/React.createElement("i", {
103
+ className: 'icon iconfont lmweb-icon_china1'
104
+ }); // return <img className='icon' src={rejectdSvg} alt="" />
105
+ }
106
+
107
+ return null;
108
+ };
109
+
110
+ var getApprovalText = function getApprovalText() {
111
+ if (type === 'refuse') {
112
+ return /*#__PURE__*/React.createElement("div", {
113
+ className: 'desc red'
114
+ }, "\u62D2\u7EDD");
115
+ }
116
+
117
+ if (type === 'start') {
118
+ return /*#__PURE__*/React.createElement("div", {
119
+ className: 'desc'
120
+ }, "\u53D1\u8D77\u5BA1\u6279");
121
+ }
122
+
123
+ if (type === 'comment') {
124
+ return /*#__PURE__*/React.createElement("div", {
125
+ className: 'desc grey'
126
+ }, "\u4EC5\u8BC4\u8BBA");
127
+ }
128
+
129
+ if (type === 'carbonCopy') {
130
+ return /*#__PURE__*/React.createElement("div", {
131
+ className: 'desc grey'
132
+ }, "\u5DF2\u6284\u90018\u4EBA");
133
+ }
134
+
135
+ if (type === 'agree') {
136
+ return /*#__PURE__*/React.createElement("div", {
137
+ className: 'desc'
138
+ }, "\u5DF2\u540C\u610F");
139
+ }
140
+
141
+ return null;
142
+ };
143
+
144
+ var subname = name.substring(name.length - 1, name.length);
145
+ return /*#__PURE__*/React.createElement("div", {
146
+ className: itemCls
147
+ }, /*#__PURE__*/React.createElement("div", {
148
+ className: itemHeaderCls
149
+ }, /*#__PURE__*/React.createElement("div", {
150
+ className: "avator"
151
+ }, avator ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("img", {
152
+ className: 'picture',
153
+ src: avator,
154
+ alt: ""
155
+ }), getIcon()) : /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
156
+ className: 'subname',
157
+ style: {
158
+ backgroundColor: color
159
+ }
160
+ }, subname), getIcon())), /*#__PURE__*/React.createElement("div", {
161
+ className: "content"
162
+ }, /*#__PURE__*/React.createElement("div", {
163
+ className: 'name'
164
+ }, name), getApprovalText()), /*#__PURE__*/React.createElement("div", {
165
+ className: "right"
166
+ }, time)), type !== 'start' && /*#__PURE__*/React.createElement("div", {
167
+ className: itemBodyCls
168
+ }, "sdf"));
169
+ };
170
+
171
+ var Approval = function Approval(props) {
172
+ var _props$status2 = props.status,
173
+ status = _props$status2 === void 0 ? 1 : _props$status2,
174
+ _props$steps = props.steps,
175
+ steps = _props$steps === void 0 ? [] : _props$steps;
176
+ var cacheColorMap = new Map();
177
+ steps.forEach(function (step, i) {
178
+ if (i === 0) {
179
+ step.status = status;
180
+ } else {
181
+ step.status = 2;
182
+ }
183
+
184
+ if (!step.color) {
185
+ if (cacheColorMap.has(step.name)) {
186
+ step.color = cacheColorMap.get(step.name);
187
+ } else {
188
+ var index = parseInt(Math.random() * 4 + '');
189
+ var color = colors[index];
190
+ step.color = color;
191
+ cacheColorMap.set(step.name, color);
192
+ }
193
+ }
194
+ });
195
+ var list = steps.map(function (step) {
196
+ return /*#__PURE__*/React.createElement(ApprovalItem, Object.assign({}, step));
197
+ });
198
+ return /*#__PURE__*/React.createElement(React.Fragment, null, list);
199
+ };
200
+
201
+ var LMApproval = function LMApproval(props) {
202
+ var className = props.className,
203
+ others = __rest(props, ["className"]);
204
+
205
+ return /*#__PURE__*/React.createElement(LMDrawer, Object.assign({
206
+ className: classNames(className, prefixCls)
207
+ }, others), /*#__PURE__*/React.createElement(Approval, Object.assign({}, others)));
208
+ };
209
+
210
+ export default LMApproval;