@sunny-base/effects 0.0.1 → 0.0.3

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,229 @@
1
+ <template>
2
+ <div>
3
+ <el-row :getter="20">
4
+ <el-col :span="6">
5
+ <div style="overflow-y: auto;">
6
+ <resource-tree @currentChange="treeCurrentChange" />
7
+ </div>
8
+ </el-col>
9
+ <el-col :span="18">
10
+ <el-card
11
+ v-loading="loading"
12
+ style="padding: 10px;"
13
+ >
14
+ <el-tabs v-model="activeName">
15
+ <el-tab-pane label="菜单资源" name="first">
16
+ <el-table
17
+ :data="menuTable.data"
18
+ border
19
+ >
20
+ <el-table-column
21
+ v-for="(item,index) in menuTable.conditions"
22
+ :key="index"
23
+ :label="item.label"
24
+ >
25
+ <template slot-scope="scope">
26
+ <span v-if="item.type === 'spanselect'">
27
+ {{ filterSelect(scope.row[item.prop], item.optionlist) }}
28
+ </span>
29
+ <span v-else-if="item.type === 'input'">
30
+ <el-input
31
+ v-model="scope.row[item.prop]"
32
+ />
33
+ </span>
34
+ <span v-else>{{ scope.row[item.prop] }}</span>
35
+ </template>
36
+ </el-table-column>
37
+ </el-table>
38
+ <el-table
39
+ :data="resourceTable.data"
40
+ border
41
+ >
42
+ <el-table-column
43
+ v-for="(item,index) in resourceTable.conditions"
44
+ :key="index"
45
+ :label="item.label"
46
+ >
47
+ <template slot-scope="scope">
48
+ <span v-if="item.type === 'spanselect'">
49
+ {{ filterSelect(scope.row[item.prop], item.optionlist) }}
50
+ </span>
51
+ <span v-else-if="item.type === 'input'">
52
+ <el-input
53
+ v-model="scope.row[item.prop]"
54
+ />
55
+ </span>
56
+ <span v-else>{{ scope.row[item.prop] }}</span>
57
+ </template>
58
+ </el-table-column>
59
+ </el-table>
60
+ </el-tab-pane>
61
+ <el-tab-pane label="自定义资源" name="second">
62
+ <el-row v-loading="loading" style="margin-bottom: 10px;">
63
+ <el-button :disabled="!nodeData.id" @click="addRow">新增</el-button>
64
+ </el-row>
65
+ <el-table
66
+ :data="customTable.data"
67
+ border
68
+ >
69
+ <el-table-column
70
+ v-for="(item,index) in customTable.conditions"
71
+ :key="index"
72
+ :label="item.label"
73
+ >
74
+ <template slot-scope="scope">
75
+ <span v-if="item.type === 'spanselect'">
76
+ {{ filterSelect(scope.row[item.prop], item.optionlist) }}
77
+ </span>
78
+ <span v-else-if="item.type === 'input'">
79
+ <el-input
80
+ v-model="scope.row[item.prop]"
81
+ />
82
+ </span>
83
+ <span v-else>{{ scope.row[item.prop] }}</span>
84
+ </template>
85
+ </el-table-column>
86
+ <el-table-column width="55">
87
+ <template slot-scope="scope">
88
+ <el-button type="text" @click="delRow(scope)">删除</el-button>
89
+ </template>
90
+ </el-table-column>
91
+ </el-table>
92
+ </el-tab-pane>
93
+ </el-tabs>
94
+ </el-card>
95
+ </el-col>
96
+ </el-row>
97
+ </div>
98
+ </template>
99
+
100
+ <script>
101
+ import { queryI18nResource, saveI18nResource } from '@/api/i18nConfig'
102
+ import { queryByXuhao } from '@/api/core'
103
+ import { filterSelect } from '@/mixins/configurationFile/utils'
104
+ import ResourceTree from './ResourceTree.vue'
105
+ import selectOpts from '@/utils/select-options'
106
+ export default {
107
+ components: {
108
+ ResourceTree
109
+ },
110
+ data() {
111
+ return {
112
+ nodeData: '',
113
+ menuTable: { // 菜单表格
114
+ data: [],
115
+ conditions: []
116
+ },
117
+ resourceTable: { // 资源表格
118
+ data: [],
119
+ conditions: []
120
+ },
121
+ customTable: { // 自定义表格
122
+ data: [],
123
+ conditions: []
124
+ },
125
+ langCol: [], // 语言列表
126
+ loading: false,
127
+ activeName: 'first',
128
+ selectOpts
129
+ }
130
+ },
131
+ methods: {
132
+ // 初始化
133
+ openInit() {
134
+ queryByXuhao({ cXuhao: 'LANG' }).then(res => {
135
+ const langCol = res.result.map((item) => {
136
+ return {
137
+ label: item.cName,
138
+ prop: item.cXuhao,
139
+ type: 'input',
140
+ show: true
141
+ }
142
+ })
143
+ const menuCol = [{
144
+ label: '菜单名',
145
+ prop: 'cKey',
146
+ show: true
147
+ }]
148
+ const resourceCol = [{
149
+ label: '资源ID',
150
+ prop: 'nResourceid',
151
+ show: true
152
+ }, {
153
+ label: '资源名称',
154
+ prop: 'cKey',
155
+ show: true
156
+ }, {
157
+ label: '资源类别',
158
+ prop: 'nType',
159
+ type: 'spanselect',
160
+ optionlist: selectOpts.i18nTypeOpts,
161
+ show: true
162
+ }]
163
+ const customCol = [{
164
+ label: 'KEY',
165
+ prop: 'cKey',
166
+ type: 'input',
167
+ show: true
168
+ }]
169
+ this.menuTable.conditions = [...menuCol, ...langCol]
170
+ this.resourceTable.conditions = [...resourceCol, ...langCol]
171
+ this.customTable.conditions = [...customCol, ...langCol]
172
+ })
173
+ },
174
+ // 树节点点击事件
175
+ treeCurrentChange(data) {
176
+ this.customTable.data = []
177
+ this.nodeData = data
178
+ this.loading = true
179
+ queryI18nResource({ authResMenu: { id: this.nodeData.id }}).then(res => {
180
+ this.menuTable.data = []
181
+ if (Object.keys(res.result).length !== 0) { // 排除点击基础系统
182
+ this.menuTable.data.push(res.result.mapMenu)
183
+ this.resourceTable.data = res.result.mapAll
184
+ this.customTable.data = res.result.customMapAll
185
+ }
186
+ }).finally(() => {
187
+ this.loading = false
188
+ })
189
+ },
190
+ // 自定义表格新增行
191
+ addRow() {
192
+ this.customTable.data.push({
193
+ nResourceid: this.nodeData.id
194
+ })
195
+ },
196
+ // 自定义表格删除行
197
+ delRow(scope) {
198
+ this.customTable.data.splice(scope.$index, 1)
199
+ },
200
+ saveAction() {
201
+ if (!this.nodeData.id) {
202
+ this.$store.dispatch('i18nConfig/closeDialog')
203
+ return false
204
+ }
205
+ const arr = this.customTable.data.map((item) => {
206
+ return {
207
+ ...item,
208
+ nResourceid: this.nodeData.id,
209
+ cResname: this.nodeData.cModname,
210
+ nType: 8
211
+ }
212
+ })
213
+ const jsonStr = {
214
+ authI18n: {
215
+ nResourceid: this.nodeData.id
216
+ },
217
+ mapMenu: this.menuTable.data[0],
218
+ mapAll: this.resourceTable.data,
219
+ customMapAll: arr
220
+ }
221
+ saveI18nResource(jsonStr).then(res => {
222
+ this.$message.success(res.message)
223
+ this.$store.dispatch('i18nConfig/closeDialog')
224
+ })
225
+ },
226
+ filterSelect
227
+ }
228
+ }
229
+ </script>
@@ -0,0 +1,132 @@
1
+ <template>
2
+ <div v-loading="treeLoading" class="tree-content">
3
+ <el-tree
4
+ ref="treeInstance"
5
+ :data="treeData.list"
6
+ node-key="id"
7
+ highlight-current
8
+ lazy
9
+ draggable
10
+ :load="loadNode"
11
+ :expand-on-click-node="false"
12
+ :current-node-key="treeData.currentNode"
13
+ @node-click="nodeClick"
14
+ >
15
+ <span slot-scope="{ data }" class="custom-tree-node">
16
+ <i v-if="data.loading" class="el-icon-loading" /> <span>{{ data.id }} - {{ data.cModname }}</span>
17
+ </span>
18
+ </el-tree>
19
+ </div>
20
+ </template>
21
+
22
+ <script setup>
23
+ import { ref, reactive } from 'vue'
24
+ import { findMenuAll } from '@/api/resource'
25
+ import { Message } from 'element-ui'
26
+ // * 获取this指向
27
+ const treeInstance = ref() // tree本身
28
+ // 对外emit
29
+ const emit = defineEmits(['currentChange'])
30
+ const treeLoading = ref(false)
31
+ // 树的相关响应式数据
32
+ const treeData = reactive({
33
+ // 树形数据
34
+ list: [],
35
+ // 当前节点
36
+ currentNode: null
37
+ })
38
+ // 节点被点击
39
+ const nodeClick = (data, node, item) => {
40
+ treeData.currentNode = data.id
41
+ emit('currentChange', data)
42
+ }
43
+ // 加载子节点
44
+ const loadNode = async(node, resolve, reject) => {
45
+ if (node.level === 0) {
46
+ resolve(JSON.parse(process.env.VUE_APP_SYSTEM))
47
+ } else {
48
+ try {
49
+ const nParent = node.data // get parent
50
+ const data = await getChildrenNode(nParent)
51
+ resolve(data || [])
52
+ } catch {
53
+ resolve([])
54
+ }
55
+ }
56
+ }
57
+ // 更具id获取下级列表
58
+ const getChildrenNode = (nParent) => {
59
+ return new Promise((resolve, reject) => {
60
+ const { id, cSystem } = nParent
61
+ const payload = {
62
+ authResMenu:
63
+ {
64
+ // 1.菜单 4超链接 5:弹窗 -1:everyone资源 6打开新窗口的外链
65
+ cType: '0,1,4,5,6',
66
+ nParkeyid: id,
67
+ cSystem
68
+ }
69
+ }
70
+ findMenuAll(payload).then(res => {
71
+ if (res.success) {
72
+ const result = res.result.map(it => {
73
+ return {
74
+ ...it,
75
+ isLeaf: it.cType !== '1', // 如果不是菜单,就没有下级
76
+ loading: false // 预设一个loading
77
+ }
78
+ })
79
+ resolve(result)
80
+ } else {
81
+ Message({
82
+ showClose: true,
83
+ message: `error:${res.message}`,
84
+ duration: 3500,
85
+ type: 'error'
86
+ })
87
+ reject(new Error('error'))
88
+ }
89
+ }).catch(err => {
90
+ reject(err)
91
+ })
92
+ })
93
+ }
94
+ </script>
95
+
96
+ <style lang="scss" scoped>
97
+ .tree-content {
98
+ width: 100%;
99
+ height: 100%;
100
+ overflow-y: auto;
101
+ }
102
+
103
+ :deep(.el-tree--highlight-current .el-tree-node.is-current>.el-tree-node__content) {
104
+ background-color: #ECFDF5;
105
+ border-radius: 3px;
106
+ position: relative;
107
+ overflow: hidden;
108
+
109
+ &::before {
110
+ display: block;
111
+ content: " ";
112
+ position: absolute;
113
+ left: 0;
114
+ top: 0;
115
+ height: 100%;
116
+ width: 5px;
117
+ background-color: #10B981;
118
+ border-radius: 3px;
119
+ }
120
+ }
121
+
122
+ :deep(.el-tree__drop-indicator) {
123
+ height: 5px;
124
+ border-radius: 3px;
125
+ }
126
+
127
+ .custom-tree-node {
128
+ font-size: 14px;
129
+ color: #606266;
130
+ padding-right: 8px;
131
+ }
132
+ </style>
@@ -0,0 +1,200 @@
1
+ <template>
2
+ <div>
3
+ <el-row>
4
+ <el-form ref="ruleForm" :model="ruleForm" label-width="100px" :show-message="false">
5
+ <el-col :span="12">
6
+ <el-form-item label="资源类型" prop="nType" required>
7
+ <el-select v-model="ruleForm.nType">
8
+ <el-option label="菜单字段按钮" value="1" />
9
+ <el-option label="静态资源" value="5" />
10
+ <el-option label="kunkka翻译包" value="7" />
11
+ </el-select>
12
+ </el-form-item>
13
+ </el-col>
14
+ <el-col v-if="ruleForm.nType == 1 || ruleForm.nType == 5" :span="12">
15
+ <el-form-item label="系统" prop="cSystem" required>
16
+ <el-select v-model="ruleForm.cSystem">
17
+ <el-option
18
+ v-for="ss in selectOpts.systemOpts"
19
+ :key="ss.cKeynumb"
20
+ :label="ss.cKeyname"
21
+ :value="ss.cKeynumb"
22
+ />
23
+ </el-select>
24
+ </el-form-item>
25
+ </el-col>
26
+ <div v-if="ruleForm.nType == 5">
27
+ <el-col :span="24">
28
+ <el-divider content-position="left">GitLab代码仓库</el-divider>
29
+ </el-col>
30
+ <el-col :span="12">
31
+ <el-form-item label="用户名" prop="userName" required>
32
+ <el-input v-model="ruleForm.userName" />
33
+ </el-form-item>
34
+ </el-col>
35
+ <el-col :span="12">
36
+ <el-form-item label="密码" prop="passWord" required>
37
+ <el-input v-model="ruleForm.passWord" show-password />
38
+ </el-form-item>
39
+ </el-col>
40
+ <el-col :span="12">
41
+ <el-form-item label="项目" prop="projectId" required>
42
+ <el-select
43
+ v-model="ruleForm.projectId"
44
+ filterable
45
+ placeholder="请输入关键词"
46
+ :loading="loading"
47
+ style="width: 100%"
48
+ @focus="remoteMethod"
49
+ @change="projectCheck"
50
+ >
51
+ <el-option
52
+ v-for="item in projectOptions"
53
+ :key="item.value"
54
+ :label="item.label"
55
+ :value="item.value"
56
+ />
57
+ </el-select>
58
+ </el-form-item>
59
+ </el-col>
60
+ <el-col :span="12">
61
+ <el-form-item label="分支" prop="branchName" required>
62
+ <el-select
63
+ v-model="ruleForm.branchName"
64
+ filterable
65
+ style="width: 100%"
66
+ >
67
+ <el-option
68
+ v-for="item in branchOptions"
69
+ :key="item.value"
70
+ :label="item.label"
71
+ :value="item.value"
72
+ />
73
+ </el-select>
74
+ </el-form-item>
75
+ </el-col>
76
+ <el-col :span="12">
77
+ <el-form-item label="搜索路径" prop="searchPath" required>
78
+ <el-input v-model="ruleForm.searchPath" placeholder="举例:文件夹名/src/views" />
79
+ </el-form-item>
80
+ </el-col>
81
+ </div>
82
+ </el-form>
83
+ </el-row>
84
+ </div>
85
+ </template>
86
+
87
+ <script>
88
+ import { exportI18n, findProjectList, findBranchList } from '@/api/i18nConfig'
89
+ import selectOpts from '@/utils/select-options'
90
+ import { FileSaverDoExport } from '@/utils/file-saver'
91
+
92
+ export default {
93
+ data() {
94
+ return {
95
+ name: 'i18nConfig',
96
+ loading: false,
97
+ ruleForm: {},
98
+ projectOptions: [],
99
+ branchOptions: [],
100
+ selectOpts
101
+ }
102
+ },
103
+ methods: {
104
+ openInit() {
105
+ this.ruleForm = {}
106
+ this.$nextTick(() => {
107
+ this.$refs['ruleForm'].clearValidate()
108
+ })
109
+ },
110
+ submitForm() {
111
+ this.$refs['ruleForm'].validate((valid) => {
112
+ if (valid) {
113
+ this.loading = true
114
+ this.$emit('changeLoading', 'exportDialogModal', true)
115
+ var json
116
+ if (this.ruleForm.nType == 1) {
117
+ json = {
118
+ 'nType': this.ruleForm.nType,
119
+ 'authI18n': {
120
+ 'cSystem': this.ruleForm.cSystem
121
+ }
122
+ }
123
+ } else if (this.ruleForm.nType == 5) {
124
+ json = {
125
+ 'nType': this.ruleForm.nType,
126
+ 'authI18n': {
127
+ 'cSystem': this.ruleForm.cSystem
128
+ },
129
+ 'gitLabDTO': {
130
+ 'userName': this.ruleForm.userName,
131
+ 'passWord': this.ruleForm.passWord,
132
+ 'projectId': this.ruleForm.projectId,
133
+ 'searchPath': this.ruleForm.searchPath,
134
+ 'branchName': this.ruleForm.branchName
135
+ }
136
+ }
137
+ } else if (this.ruleForm.nType == 7) {
138
+ json = {
139
+ 'nType': this.ruleForm.nType
140
+ }
141
+ }
142
+ exportI18n(json).then(res => {
143
+ const _this = this
144
+ const fileReader = new FileReader()
145
+ fileReader.onload = function() {
146
+ try {
147
+ const jsonData = JSON.parse(this.result)
148
+ if (jsonData.code) {
149
+ _this.$message.error(jsonData.message)
150
+ }
151
+ } catch (err) {
152
+ const fileName = res.headers['content-disposition'].split('attachment;filename=')[1]
153
+ FileSaverDoExport(res.data, fileName)
154
+ }
155
+ }
156
+ fileReader.readAsText(res.data ? res.data : res)
157
+ }).finally(() => {
158
+ this.loading = false
159
+ this.$emit('changeLoading', 'exportDialogModal', false)
160
+ this.$store.dispatch('i18nConfig/closeDialog')
161
+ })
162
+ } else {
163
+ return false
164
+ }
165
+ })
166
+ },
167
+ remoteMethod() {
168
+ this.loading = true
169
+ findProjectList({
170
+ 'userName': this.ruleForm.userName,
171
+ 'passWord': this.ruleForm.passWord
172
+ }).then(res => {
173
+ this.projectOptions = res.result.map(el => {
174
+ return {
175
+ label: el.nameWithNamespace,
176
+ value: el.projectId
177
+ }
178
+ })
179
+ }).finally(() => {
180
+ this.loading = false
181
+ })
182
+ },
183
+ projectCheck() {
184
+ findBranchList({
185
+ 'userName': this.ruleForm.userName,
186
+ 'passWord': this.ruleForm.passWord,
187
+ 'projectId': this.ruleForm.projectId
188
+ }).then(res => {
189
+ this.$set(this.ruleForm, 'branchName', '')
190
+ this.branchOptions = res.result.map(el => {
191
+ return {
192
+ label: el,
193
+ value: el
194
+ }
195
+ })
196
+ })
197
+ }
198
+ }
199
+ }
200
+ </script>
@@ -0,0 +1,124 @@
1
+ <template>
2
+ <div>
3
+ <el-row>
4
+ <el-form ref="ruleForm" :model="ruleForm" label-width="100px" :show-message="false">
5
+ <el-col :span="12">
6
+ <el-form-item label="资源类型" prop="nType" required>
7
+ <el-select v-model="ruleForm.nType">
8
+ <el-option label="菜单字段按钮" value="1" />
9
+ <el-option label="静态资源" value="5" />
10
+ <el-option label="kunkka翻译包" value="7" />
11
+ </el-select>
12
+ </el-form-item>
13
+ </el-col>
14
+ <el-col v-if="ruleForm.nType == 1 || ruleForm.nType == 5" :span="12">
15
+ <el-form-item label="系统" prop="cSystem" required>
16
+ <el-select v-model="ruleForm.cSystem">
17
+ <el-option
18
+ v-for="ss in selectOpts.systemOpts"
19
+ :key="ss.cKeynumb"
20
+ :label="ss.cKeyname"
21
+ :value="ss.cKeynumb"
22
+ />
23
+ </el-select>
24
+ </el-form-item>
25
+ </el-col>
26
+ <el-col :span="24">
27
+ <el-form-item label="导入文件" required>
28
+ <el-upload
29
+ ref="upload"
30
+ class="upload-demo"
31
+ :action="url"
32
+ :http-request="uploadAction"
33
+ name="fileName"
34
+ :file-list="fileList"
35
+ :auto-upload="false"
36
+ :limit="1"
37
+ accept=".xlsx, .xls"
38
+ >
39
+ <el-button
40
+ slot="trigger"
41
+ :style="{padding:'5px 10px'}"
42
+ type="primary"
43
+ ><i class="icon-btn-small iconfont icon-excel" />选取文件</el-button>
44
+ </el-upload>
45
+ <el-button slot="trigger" size="small" type="primary">选取文件</el-button>
46
+ </el-form-item>
47
+ </el-col>
48
+ </el-form>
49
+ </el-row>
50
+ </div>
51
+
52
+ </template>
53
+
54
+ <script>
55
+ import { importI18n } from '@/api/i18nConfig'
56
+ import selectOpts from '@/utils/select-options'
57
+
58
+ export default {
59
+ data() {
60
+ return {
61
+ name: 'i18nConfig',
62
+ ruleForm: {},
63
+ fileList: [], // 上传的文件列表
64
+ // 上传路径
65
+ url: process.env.VUE_APP_BASE_API + '/business/authI18n/importI18n',
66
+ loading: false,
67
+ selectOpts
68
+ }
69
+ },
70
+ methods: {
71
+ openInit() {
72
+ this.ruleForm = {}
73
+ this.visible = true
74
+ },
75
+ // 文件上传
76
+ uploadAction(data) {
77
+ this.$refs['ruleForm'].validate((valid) => {
78
+ if (valid) {
79
+ if (data.file.type !== 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet') {
80
+ this.$message.error('文件类型错误')
81
+ return false
82
+ }
83
+ this.loading = true
84
+ this.$emit('changeLoading', 'importDialogModal', true)
85
+ var formData = new FormData()
86
+ formData.append('fileName', data.file)
87
+ formData.append('cWork', this.$store.getters.code)
88
+ formData.append('cSystem', this.ruleForm.cSystem)
89
+ formData.append('nType', this.ruleForm.nType)
90
+ importI18n(formData).then(res => {
91
+ this.$message.success(res.message)
92
+ this.visible = false
93
+ }).catch(() => {
94
+ this.$refs.upload.clearFiles()
95
+ }).finally(() => {
96
+ this.$emit('changeLoading', 'importDialogModal', false)
97
+ this.loading = false
98
+ this.$store.dispatch('i18nConfig/closeDialog')
99
+ })
100
+ } else {
101
+ return false
102
+ }
103
+ })
104
+ },
105
+ // 文件上传
106
+ upLoads() {
107
+ this.$refs.upload.submit()
108
+ }
109
+ }
110
+ }
111
+
112
+ </script>
113
+
114
+ <style lang="scss">
115
+ .filedialog {
116
+ .el-dialog__body {
117
+ padding-top: 0;
118
+ padding-bottom: 10px;
119
+ }
120
+ }
121
+ .el-upload__tip{
122
+ font-weight: 600;
123
+ }
124
+ </style>