vue2-client 1.18.7 → 1.18.9

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.
Files changed (109) hide show
  1. package/.eslintrc.js +90 -90
  2. package/Components.md +60 -60
  3. package/docs/index.md +30 -30
  4. package/index.js +31 -31
  5. package/jest-transform-stub.js +8 -8
  6. package/jest.setup.js +7 -7
  7. package/package.json +1 -1
  8. package/src/assets/img/querySlotDemo.svg +15 -15
  9. package/src/assets/svg/female.svg +1 -1
  10. package/src/assets/svg/male.svg +1 -1
  11. package/src/base-client/components/common/AmapMarker/AmapPointRendering.vue +120 -120
  12. package/src/base-client/components/common/CitySelect/index.js +3 -3
  13. package/src/base-client/components/common/CitySelect/index.md +109 -109
  14. package/src/base-client/components/common/CreateQuery/CreateQuery.vue +669 -669
  15. package/src/base-client/components/common/CreateQuery/index.js +3 -3
  16. package/src/base-client/components/common/CreateQuery/index.md +42 -42
  17. package/src/base-client/components/common/CreateSimpleFormQuery/index.js +3 -3
  18. package/src/base-client/components/common/CreateSimpleFormQuery/index.md +42 -42
  19. package/src/base-client/components/common/FormGroupEdit/index.js +3 -3
  20. package/src/base-client/components/common/FormGroupEdit/index.md +43 -43
  21. package/src/base-client/components/common/FormGroupQuery/FormGroupQuery.vue +166 -166
  22. package/src/base-client/components/common/FormGroupQuery/index.js +3 -3
  23. package/src/base-client/components/common/FormGroupQuery/index.md +43 -43
  24. package/src/base-client/components/common/HIS/HButtons/HButtons.vue +491 -491
  25. package/src/base-client/components/common/HIS/HForm/HForm.vue +32 -10
  26. package/src/base-client/components/common/HIS/HFormGroup/index.js +3 -3
  27. package/src/base-client/components/common/HIS/HTab/HTab.vue +443 -443
  28. package/src/base-client/components/common/JSONToTree/jsontotree.vue +271 -271
  29. package/src/base-client/components/common/PersonSetting/PersonSetting.vue +208 -208
  30. package/src/base-client/components/common/PersonSetting/index.js +3 -3
  31. package/src/base-client/components/common/Tree/Tree.vue +149 -149
  32. package/src/base-client/components/common/Tree/index.js +2 -2
  33. package/src/base-client/components/common/Upload/index.js +3 -3
  34. package/src/base-client/components/common/XAddNativeForm/index.md +146 -146
  35. package/src/base-client/components/common/XCard/XCard.vue +64 -64
  36. package/src/base-client/components/common/XCollapse/XCollapse.vue +830 -830
  37. package/src/base-client/components/common/XDataDrawer/XDataDrawer.vue +180 -180
  38. package/src/base-client/components/common/XDataDrawer/index.js +3 -3
  39. package/src/base-client/components/common/XDataDrawer/index.md +41 -41
  40. package/src/base-client/components/common/XDescriptions/index.js +3 -3
  41. package/src/base-client/components/common/XDescriptions/index.md +83 -83
  42. package/src/base-client/components/common/XForm/index.md +178 -178
  43. package/src/base-client/components/common/XInput/XInput.vue +12 -6
  44. package/src/base-client/components/common/XStepView/XStepView.vue +252 -252
  45. package/src/base-client/components/common/XStepView/index.js +3 -3
  46. package/src/base-client/components/common/XStepView/index.md +31 -31
  47. package/src/base-client/components/common/XTable/index.md +255 -255
  48. package/src/base-client/components/common/XTimeline/XTimeline.vue +477 -477
  49. package/src/base-client/components/his/HChart/HChart.vue +500 -53
  50. package/src/base-client/components/his/XHDescriptions/XHDescriptions.vue +44 -78
  51. package/src/base-client/components/his/XHisEditor/XHisEditor.vue +705 -705
  52. package/src/base-client/components/his/XList/XList.vue +938 -938
  53. package/src/base-client/components/his/XTimeSelect/XTimeSelect.vue +354 -354
  54. package/src/base-client/components/his/XTitle/XTitle.vue +314 -314
  55. package/src/base-client/components/his/XTreeRows/XTreeRows.vue +341 -341
  56. package/src/base-client/components/his/threeTestOrders/editor.vue +113 -113
  57. package/src/base-client/components/system/DictionaryDetailsView/DictionaryDetailsView.vue +232 -232
  58. package/src/base-client/plugins/Config.js +19 -19
  59. package/src/base-client/plugins/tabs-page-plugin.js +39 -39
  60. package/src/components/Charts/Bar.vue +62 -62
  61. package/src/components/Charts/ChartCard.vue +134 -134
  62. package/src/components/Charts/Liquid.vue +67 -67
  63. package/src/components/Charts/MiniArea.vue +39 -39
  64. package/src/components/Charts/MiniBar.vue +39 -39
  65. package/src/components/Charts/MiniProgress.vue +75 -75
  66. package/src/components/Charts/MiniSmoothArea.vue +40 -40
  67. package/src/components/Charts/Radar.vue +68 -68
  68. package/src/components/Charts/RankList.vue +77 -77
  69. package/src/components/Charts/TagCloud.vue +113 -113
  70. package/src/components/Charts/TransferBar.vue +64 -64
  71. package/src/components/Charts/Trend.vue +82 -82
  72. package/src/components/Charts/chart.less +12 -12
  73. package/src/components/Charts/smooth.area.less +13 -13
  74. package/src/components/NumberInfo/NumberInfo.vue +54 -54
  75. package/src/components/NumberInfo/index.js +3 -3
  76. package/src/components/NumberInfo/index.less +54 -54
  77. package/src/components/NumberInfo/index.md +43 -43
  78. package/src/components/card/ChartCard.vue +79 -79
  79. package/src/components/chart/Bar.vue +60 -60
  80. package/src/components/chart/MiniArea.vue +67 -67
  81. package/src/components/chart/MiniBar.vue +59 -59
  82. package/src/components/chart/MiniProgress.vue +57 -57
  83. package/src/components/chart/Radar.vue +80 -80
  84. package/src/components/chart/RankingList.vue +60 -60
  85. package/src/components/chart/Trend.vue +79 -79
  86. package/src/components/chart/index.less +9 -9
  87. package/src/components/checkbox/ColorCheckbox.vue +157 -157
  88. package/src/components/index.js +36 -36
  89. package/src/components/input/IInput.vue +66 -66
  90. package/src/components/menu/SideMenu.vue +75 -75
  91. package/src/components/menu/menu.js +273 -273
  92. package/src/components/tool/AStepItem.vue +60 -60
  93. package/src/layouts/CommonLayout.vue +56 -56
  94. package/src/layouts/header/HeaderNotice.vue +177 -177
  95. package/src/lib.js +1 -1
  96. package/src/mock/extend/index.js +84 -84
  97. package/src/mock/goods/index.js +108 -108
  98. package/src/pages/dashboard/workplace/WorkPlace.vue +141 -141
  99. package/src/pages/system/dictionary/index.vue +44 -44
  100. package/src/pages/system/monitor/loginInfor/index.vue +37 -37
  101. package/src/pages/system/monitor/operLog/index.vue +37 -37
  102. package/src/pages/userInfoDetailManage/ExceptionRecordQuery/index.vue +45 -45
  103. package/src/services/api/cas.js +79 -79
  104. package/src/store/modules/setting.js +119 -119
  105. package/src/utils/authority-utils.js +85 -85
  106. package/src/utils/errorCode.js +6 -6
  107. package/src-base-client/components/common/HIS/HForm/HForm.vue +347 -0
  108. package/src-base-client/components/common/XCollapse/XCollapse.vue +0 -0
  109. package//350/277/201/347/247/273/346/227/245/345/277/227.md +15 -15
@@ -1,56 +1,56 @@
1
- <template>
2
- <div class="common-layout">
3
- <div class="top"><a class="clearCacheBtn" @click="clearCache">清除缓存</a></div>
4
- <div class="content"><slot></slot></div>
5
- <page-footer :link-list="footerLinks" :copyright="copyright" :copyrightStyle="copyrightStyle"></page-footer>
6
- </div>
7
- </template>
8
-
9
- <script>
10
- import PageFooter from '@vue2-client/layouts/footer/PageFooter'
11
- import { mapState } from 'vuex'
12
- import { indexedDB } from '@vue2-client/utils/indexedDB'
13
-
14
- export default {
15
- name: 'CommonLayout',
16
- components: { PageFooter },
17
- computed: {
18
- ...mapState('setting', ['footerLinks', 'copyright', 'copyrightStyle'])
19
- },
20
- methods: {
21
- clearCache () {
22
- indexedDB.clearCache()
23
- }
24
- }
25
- }
26
- </script>
27
-
28
- <style scoped lang="less">
29
- .common-layout{
30
- display: flex;
31
- flex-direction: column;
32
- height: 100vh;
33
- overflow: auto;
34
- background-color: @layout-body-background;
35
- background-image: url('https://gw.alipayobjects.com/zos/rmsportal/TVYTbAXWheQpRcWDaDMu.svg');
36
- background-repeat: no-repeat;
37
- background-position-x: center;
38
- background-position-y: 110px;
39
- background-size: 100%;
40
- .top {
41
- padding: 5px 10px;
42
- text-align: right;
43
- .clearCacheBtn {
44
- color: #fff !important;
45
- }
46
- }
47
- .content{
48
- padding: 32px 0;
49
- flex: 1;
50
- @media (min-width: 768px){
51
-
52
- padding: 112px 0 24px;
53
- }
54
- }
55
- }
56
- </style>
1
+ <template>
2
+ <div class="common-layout">
3
+ <div class="top"><a class="clearCacheBtn" @click="clearCache">清除缓存</a></div>
4
+ <div class="content"><slot></slot></div>
5
+ <page-footer :link-list="footerLinks" :copyright="copyright" :copyrightStyle="copyrightStyle"></page-footer>
6
+ </div>
7
+ </template>
8
+
9
+ <script>
10
+ import PageFooter from '@vue2-client/layouts/footer/PageFooter'
11
+ import { mapState } from 'vuex'
12
+ import { indexedDB } from '@vue2-client/utils/indexedDB'
13
+
14
+ export default {
15
+ name: 'CommonLayout',
16
+ components: { PageFooter },
17
+ computed: {
18
+ ...mapState('setting', ['footerLinks', 'copyright', 'copyrightStyle'])
19
+ },
20
+ methods: {
21
+ clearCache () {
22
+ indexedDB.clearCache()
23
+ }
24
+ }
25
+ }
26
+ </script>
27
+
28
+ <style scoped lang="less">
29
+ .common-layout{
30
+ display: flex;
31
+ flex-direction: column;
32
+ height: 100vh;
33
+ overflow: auto;
34
+ background-color: @layout-body-background;
35
+ background-image: url('https://gw.alipayobjects.com/zos/rmsportal/TVYTbAXWheQpRcWDaDMu.svg');
36
+ background-repeat: no-repeat;
37
+ background-position-x: center;
38
+ background-position-y: 110px;
39
+ background-size: 100%;
40
+ .top {
41
+ padding: 5px 10px;
42
+ text-align: right;
43
+ .clearCacheBtn {
44
+ color: #fff !important;
45
+ }
46
+ }
47
+ .content{
48
+ padding: 32px 0;
49
+ flex: 1;
50
+ @media (min-width: 768px){
51
+
52
+ padding: 112px 0 24px;
53
+ }
54
+ }
55
+ }
56
+ </style>
@@ -1,177 +1,177 @@
1
- <template>
2
- <div>
3
- <a-drawer
4
- :closable="false"
5
- :visible="institutionDetailVisible"
6
- :width="screenWidth * 0.5"
7
- placement="right"
8
- @close="onClose"
9
- >
10
- <institution-detail
11
- :affirmInstitution="affirmInstitution"
12
- :institutionId="institution"
13
- @get_to_be_confirmed="getToBeConfirmed"/>
14
- </a-drawer>
15
- <a-dropdown v-model="show" :trigger="['click']">
16
- <div slot="overlay">
17
- <a-spin :spinning="loading">
18
- <a-tabs
19
- v-model="activeKey"
20
- :style="{width: '500px'}"
21
- :tabBarStyle="{textAlign: 'center'}"
22
- class="dropdown-tabs">
23
- <a-tab-pane key="1" tab="通知">
24
- <a-list class="tab-pane">
25
- </a-list>
26
- </a-tab-pane>
27
- <a-tab-pane key="2" tab="消息">
28
- <a-list class="tab-pane"></a-list>
29
- </a-tab-pane>
30
- <a-tab-pane key="3" tab="待办">
31
- <a-list :data-source="backlog" class="tab-pane" item-layout="horizontal" :pagination="pagination">
32
- <a-list-item slot="renderItem" slot-scope="item">
33
- <a v-if="item.type==='制度待确认'" slot="actions" @click="confirm_institution(item)">查看</a>
34
- <a-list-item-meta :description="item.description" :title="item.title"/>
35
- </a-list-item>
36
- </a-list>
37
- </a-tab-pane>
38
- </a-tabs>
39
- </a-spin>
40
- </div>
41
- <span class="header-notice" @click="fetchNotice">
42
- <a-badge :count="backlog.length" class="notice-badge">
43
- <a-icon :class="['header-notice-icon']" type="bell"/>
44
- </a-badge>
45
- </span>
46
- </a-dropdown>
47
- </div>
48
- </template>
49
-
50
- <script>
51
- import { post } from '@vue2-client/services/api'
52
- import InstitutionDetail from './InstitutionDetail'
53
- import ellipsis from '@vue2-client/components/Ellipsis'
54
-
55
- export default {
56
- name: 'HeaderNotice',
57
- data () {
58
- return {
59
- loading: false,
60
- screenWidth: document.documentElement.clientWidth,
61
- show: false,
62
- institutionDetailVisible: false,
63
- institution: undefined,
64
- affirmInstitution: undefined,
65
- backlog: [],
66
- pagination: {
67
- onChange: page => {
68
- console.log(page)
69
- },
70
- pageSize: 5
71
- },
72
- activeKey: '1'
73
- }
74
- },
75
- components: { InstitutionDetail },
76
- computed: {},
77
- created () {
78
- this.getToBeConfirmed()
79
- },
80
- methods: {
81
- onClose () {
82
- this.institutionDetailVisible = false
83
- this.getToBeConfirmed()
84
- },
85
- getToBeConfirmed () {
86
- this.institutionDetailVisible = false
87
- try {
88
- if (this.$login.f.name) {
89
- post('/api/af-system/logic/getTodo', { name: this.$login.f.name }).then(res => {
90
- this.backlog = [...res]
91
- if (this.backlog.length > 0) {
92
- const key = `open${Date.now()}`
93
- this.$notification.open({
94
- key,
95
- message: `您有${this.backlog.length}条待办需要确认`,
96
- top: '50px',
97
- description: <ellipsis length="200">{ this.backlog.map((item, index) => index + 1 + '、' + item.title).join(';') }</ellipsis>,
98
- icon: <a-icon type="container" style="color: #f5222d"/>,
99
- btn: h => {
100
- return h(
101
- 'a-button',
102
- {
103
- props: {
104
- type: 'primary',
105
- size: 'small',
106
- },
107
- on: {
108
- click: () => this.viewBacklog(key),
109
- },
110
- },
111
- '查看',
112
- )
113
- }
114
- })
115
- }
116
- })
117
- }
118
- } catch (e) {
119
- console.log(e)
120
- }
121
- },
122
- viewBacklog (key) {
123
- this.$notification.close(key)
124
- this.show = true
125
- this.activeKey = '3'
126
- },
127
- confirm_institution (item) {
128
- this.institutionDetailVisible = true
129
- this.show = false
130
- this.institution = item.institution
131
- this.affirmInstitution = item.id
132
- },
133
- fetchNotice () {
134
- if (this.loading) {
135
- this.loading = false
136
- return
137
- }
138
- if (this.show) return
139
- this.loading = true
140
- setTimeout(() => {
141
- this.loading = false
142
- }, 1000)
143
- }
144
- }
145
- }
146
- </script>
147
-
148
- <style lang="less">
149
- .header-notice {
150
- display: inline-block;
151
- transition: all 0.3s;
152
-
153
- span {
154
- vertical-align: initial;
155
- }
156
-
157
- .notice-badge {
158
- color: inherit;
159
-
160
- .header-notice-icon {
161
- font-size: 16px;
162
- padding: 4px;
163
- }
164
- }
165
- }
166
-
167
- .dropdown-tabs {
168
- background-color: @base-bg-color;
169
- box-shadow: 0 2px 8px @shadow-color;
170
- border-radius: 4px;
171
-
172
- .tab-pane {
173
- padding: 0 24px 12px;
174
- min-height: 250px;
175
- }
176
- }
177
- </style>
1
+ <template>
2
+ <div>
3
+ <a-drawer
4
+ :closable="false"
5
+ :visible="institutionDetailVisible"
6
+ :width="screenWidth * 0.5"
7
+ placement="right"
8
+ @close="onClose"
9
+ >
10
+ <institution-detail
11
+ :affirmInstitution="affirmInstitution"
12
+ :institutionId="institution"
13
+ @get_to_be_confirmed="getToBeConfirmed"/>
14
+ </a-drawer>
15
+ <a-dropdown v-model="show" :trigger="['click']">
16
+ <div slot="overlay">
17
+ <a-spin :spinning="loading">
18
+ <a-tabs
19
+ v-model="activeKey"
20
+ :style="{width: '500px'}"
21
+ :tabBarStyle="{textAlign: 'center'}"
22
+ class="dropdown-tabs">
23
+ <a-tab-pane key="1" tab="通知">
24
+ <a-list class="tab-pane">
25
+ </a-list>
26
+ </a-tab-pane>
27
+ <a-tab-pane key="2" tab="消息">
28
+ <a-list class="tab-pane"></a-list>
29
+ </a-tab-pane>
30
+ <a-tab-pane key="3" tab="待办">
31
+ <a-list :data-source="backlog" class="tab-pane" item-layout="horizontal" :pagination="pagination">
32
+ <a-list-item slot="renderItem" slot-scope="item">
33
+ <a v-if="item.type==='制度待确认'" slot="actions" @click="confirm_institution(item)">查看</a>
34
+ <a-list-item-meta :description="item.description" :title="item.title"/>
35
+ </a-list-item>
36
+ </a-list>
37
+ </a-tab-pane>
38
+ </a-tabs>
39
+ </a-spin>
40
+ </div>
41
+ <span class="header-notice" @click="fetchNotice">
42
+ <a-badge :count="backlog.length" class="notice-badge">
43
+ <a-icon :class="['header-notice-icon']" type="bell"/>
44
+ </a-badge>
45
+ </span>
46
+ </a-dropdown>
47
+ </div>
48
+ </template>
49
+
50
+ <script>
51
+ import { post } from '@vue2-client/services/api'
52
+ import InstitutionDetail from './InstitutionDetail'
53
+ import ellipsis from '@vue2-client/components/Ellipsis'
54
+
55
+ export default {
56
+ name: 'HeaderNotice',
57
+ data () {
58
+ return {
59
+ loading: false,
60
+ screenWidth: document.documentElement.clientWidth,
61
+ show: false,
62
+ institutionDetailVisible: false,
63
+ institution: undefined,
64
+ affirmInstitution: undefined,
65
+ backlog: [],
66
+ pagination: {
67
+ onChange: page => {
68
+ console.log(page)
69
+ },
70
+ pageSize: 5
71
+ },
72
+ activeKey: '1'
73
+ }
74
+ },
75
+ components: { InstitutionDetail },
76
+ computed: {},
77
+ created () {
78
+ this.getToBeConfirmed()
79
+ },
80
+ methods: {
81
+ onClose () {
82
+ this.institutionDetailVisible = false
83
+ this.getToBeConfirmed()
84
+ },
85
+ getToBeConfirmed () {
86
+ this.institutionDetailVisible = false
87
+ try {
88
+ if (this.$login.f.name) {
89
+ post('/api/af-system/logic/getTodo', { name: this.$login.f.name }).then(res => {
90
+ this.backlog = [...res]
91
+ if (this.backlog.length > 0) {
92
+ const key = `open${Date.now()}`
93
+ this.$notification.open({
94
+ key,
95
+ message: `您有${this.backlog.length}条待办需要确认`,
96
+ top: '50px',
97
+ description: <ellipsis length="200">{ this.backlog.map((item, index) => index + 1 + '、' + item.title).join(';') }</ellipsis>,
98
+ icon: <a-icon type="container" style="color: #f5222d"/>,
99
+ btn: h => {
100
+ return h(
101
+ 'a-button',
102
+ {
103
+ props: {
104
+ type: 'primary',
105
+ size: 'small',
106
+ },
107
+ on: {
108
+ click: () => this.viewBacklog(key),
109
+ },
110
+ },
111
+ '查看',
112
+ )
113
+ }
114
+ })
115
+ }
116
+ })
117
+ }
118
+ } catch (e) {
119
+ console.log(e)
120
+ }
121
+ },
122
+ viewBacklog (key) {
123
+ this.$notification.close(key)
124
+ this.show = true
125
+ this.activeKey = '3'
126
+ },
127
+ confirm_institution (item) {
128
+ this.institutionDetailVisible = true
129
+ this.show = false
130
+ this.institution = item.institution
131
+ this.affirmInstitution = item.id
132
+ },
133
+ fetchNotice () {
134
+ if (this.loading) {
135
+ this.loading = false
136
+ return
137
+ }
138
+ if (this.show) return
139
+ this.loading = true
140
+ setTimeout(() => {
141
+ this.loading = false
142
+ }, 1000)
143
+ }
144
+ }
145
+ }
146
+ </script>
147
+
148
+ <style lang="less">
149
+ .header-notice {
150
+ display: inline-block;
151
+ transition: all 0.3s;
152
+
153
+ span {
154
+ vertical-align: initial;
155
+ }
156
+
157
+ .notice-badge {
158
+ color: inherit;
159
+
160
+ .header-notice-icon {
161
+ font-size: 16px;
162
+ padding: 4px;
163
+ }
164
+ }
165
+ }
166
+
167
+ .dropdown-tabs {
168
+ background-color: @base-bg-color;
169
+ box-shadow: 0 2px 8px @shadow-color;
170
+ border-radius: 4px;
171
+
172
+ .tab-pane {
173
+ padding: 0 24px 12px;
174
+ min-height: 250px;
175
+ }
176
+ }
177
+ </style>
package/src/lib.js CHANGED
@@ -1 +1 @@
1
- console.log('进入模块')
1
+ console.log('进入模块')
@@ -1,84 +1,84 @@
1
- import Mock from 'mockjs'
2
- import { logos, sayings, positions, avatars, admins } from '../common'
3
-
4
- const Random = Mock.Random
5
-
6
- const timeList = [
7
- {
8
- CN: '早上好',
9
- HK: '早晨啊',
10
- US: 'Good morning'
11
- }, {
12
- CN: '上午好',
13
- HK: '上午好',
14
- US: 'Good morning'
15
- }, {
16
- CN: '中午好',
17
- HK: '中午好',
18
- US: 'Good afternoon'
19
- }, {
20
- CN: '下午好',
21
- HK: '下午好',
22
- US: 'Good afternoon'
23
- }, {
24
- CN: '晚上好',
25
- HK: '晚上好',
26
- US: 'Good evening'
27
- }
28
- ]
29
-
30
- const welcomeMessages = [
31
- {
32
- CN: '休息一会儿吧',
33
- HK: '休息一會兒吧',
34
- US: 'you may need a break'
35
- },
36
- {
37
- CN: '准备吃什么呢',
38
- HK: '準備吃什麼呢',
39
- US: 'what are you going to eat'
40
- },
41
- {
42
- CN: '要不要打一把 LOL',
43
- HK: '要不要打一把 LOL',
44
- US: 'how about a game of DOTA'
45
- },
46
- {
47
- CN: '我猜你可能累了',
48
- HK: '我猜你可能累了',
49
- US: 'i guess you might be tired'
50
- }
51
- ]
52
-
53
- const goods = ['运动鞋', '短裤', 'T恤', '七分裤', '风衣', '寸衫']
54
-
55
- Random.extend({
56
- admin () {
57
- return this.pick(admins)
58
- },
59
- welcome () {
60
- return this.pick(welcomeMessages)
61
- },
62
- timeFix () {
63
- const time = new Date()
64
- const hour = time.getHours()
65
- return hour < 9
66
- ? timeList[0]
67
- : (hour <= 11 ? timeList[1] : (hour <= 13 ? timeList[2] : (hour <= 20 ? timeList[3] : timeList[4])))
68
- },
69
- avatar () {
70
- return this.pick(avatars)
71
- },
72
- position () {
73
- return this.pick(positions)
74
- },
75
- goods () {
76
- return this.pick(goods)
77
- },
78
- saying () {
79
- return this.pick(sayings)
80
- },
81
- logo () {
82
- return this.pick(logos)
83
- }
84
- })
1
+ import Mock from 'mockjs'
2
+ import { logos, sayings, positions, avatars, admins } from '../common'
3
+
4
+ const Random = Mock.Random
5
+
6
+ const timeList = [
7
+ {
8
+ CN: '早上好',
9
+ HK: '早晨啊',
10
+ US: 'Good morning'
11
+ }, {
12
+ CN: '上午好',
13
+ HK: '上午好',
14
+ US: 'Good morning'
15
+ }, {
16
+ CN: '中午好',
17
+ HK: '中午好',
18
+ US: 'Good afternoon'
19
+ }, {
20
+ CN: '下午好',
21
+ HK: '下午好',
22
+ US: 'Good afternoon'
23
+ }, {
24
+ CN: '晚上好',
25
+ HK: '晚上好',
26
+ US: 'Good evening'
27
+ }
28
+ ]
29
+
30
+ const welcomeMessages = [
31
+ {
32
+ CN: '休息一会儿吧',
33
+ HK: '休息一會兒吧',
34
+ US: 'you may need a break'
35
+ },
36
+ {
37
+ CN: '准备吃什么呢',
38
+ HK: '準備吃什麼呢',
39
+ US: 'what are you going to eat'
40
+ },
41
+ {
42
+ CN: '要不要打一把 LOL',
43
+ HK: '要不要打一把 LOL',
44
+ US: 'how about a game of DOTA'
45
+ },
46
+ {
47
+ CN: '我猜你可能累了',
48
+ HK: '我猜你可能累了',
49
+ US: 'i guess you might be tired'
50
+ }
51
+ ]
52
+
53
+ const goods = ['运动鞋', '短裤', 'T恤', '七分裤', '风衣', '寸衫']
54
+
55
+ Random.extend({
56
+ admin () {
57
+ return this.pick(admins)
58
+ },
59
+ welcome () {
60
+ return this.pick(welcomeMessages)
61
+ },
62
+ timeFix () {
63
+ const time = new Date()
64
+ const hour = time.getHours()
65
+ return hour < 9
66
+ ? timeList[0]
67
+ : (hour <= 11 ? timeList[1] : (hour <= 13 ? timeList[2] : (hour <= 20 ? timeList[3] : timeList[4])))
68
+ },
69
+ avatar () {
70
+ return this.pick(avatars)
71
+ },
72
+ position () {
73
+ return this.pick(positions)
74
+ },
75
+ goods () {
76
+ return this.pick(goods)
77
+ },
78
+ saying () {
79
+ return this.pick(sayings)
80
+ },
81
+ logo () {
82
+ return this.pick(logos)
83
+ }
84
+ })