1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
| <template>
| <GlobalWindow
| :title="title"
| :visible.sync="visible"
| :confirm-working="isWorking.create"
| @confirm="confirm"
| >
| <el-form :model="form" ref="form" :rules="rules">
| <el-form-item label="数据标签" prop="label" required>
| <el-input v-model="form.label" placeholder="请输入数据标签" v-trim maxlength="50"/>
| </el-form-item>
| <el-form-item label="数据值" prop="code" required>
| <el-tiptap
| v-if="[175].includes(form.id)"
| v-model="form.code"
| :extensions="extensions"
| />
| <el-input v-else v-model="form.code" placeholder="请输入数据值" v-trim maxlength="50"/>
| </el-form-item>
| <el-form-item label="状态" prop="disabled" required class="form-item-status">
| <el-switch v-model="form.disabled" :active-value="false" :inactive-value="true"/>
| <span class="status-text">{{form.disabled | disabledText}}</span>
| </el-form-item>
| </el-form>
| </GlobalWindow>
| </template>
|
| <script>
| import BaseOpera from '@/components/base/BaseOpera'
| import GlobalWindow from '@/components/common/GlobalWindow'
| import { upload } from '@/api/system/common'
| import {
| // necessary extensions
| Doc,
| Text,
| Paragraph,
| Heading,
| Bold,
| Underline,
| Italic,
| Strike,
| ListItem,
| BulletList,
| OrderedList,
| Image,
| Blockquote,
| TextAlign,
| Indent,
| Table,
| TableHeader,
| TableCell,
| TableRow,
| TextColor,
| HorizontalRule
| } from 'element-tiptap'
| export default {
| name: 'OperaDictDataWindow',
| extends: BaseOpera,
| components: { GlobalWindow },
| data () {
| return {
| // 表单数据
| form: {
| id: null,
| dictId: null,
| code: '',
| label: '',
| disabled: false
| },
| // 验证规则
| rules: {
| label: [
| { required: true, message: '请输入数据标签' }
| ],
| code: [
| { required: true, message: '请输入数据值' }
| ]
| },
| extensions: [
| new Doc(),
| new Text(),
| new Paragraph(),
| new Heading({ level: 5 }),
| new Bold({ bubble: true }),
| new Underline({ bubble: true, menubar: false }),
| new Italic(),
| new Strike(),
| new ListItem(),
| new BulletList(),
| new OrderedList(),
| new Image({
| uploadRequest (file) {
| const fd = new FormData()
| fd.append('folder', 'visit')
| fd.append('file', file)
| return upload(fd).then(res => {
| return res.url
| })
| }
| }),
| new Blockquote(),
| new TextAlign(),
| new Indent(),
| new Table(),
| new TableHeader(),
| new TableCell(),
| new TableRow(),
| new HorizontalRule(),
| new TextColor()
| ]
| }
| },
| methods: {
| /**
| * @title 窗口标题
| * @dict 所属字典ID
| * @target 编辑的字典数据对象
| */
| open (title, dictId, target) {
| this.title = title
| this.visible = true
| // 新建
| if (target == null) {
| this.$nextTick(() => {
| this.$refs.form.resetFields()
| this.form.id = null
| this.form.dictId = dictId
| })
| return
| }
| // 编辑
| this.$nextTick(() => {
| for (const key in this.form) {
| this.form[key] = target[key]
| }
| })
| }
| },
| created () {
| this.config({
| api: '/system/dictData'
| })
| }
| }
| </script>
|
| <style scoped lang="scss">
| .form-item-status {
| .status-text {
| color: #999;
| margin-left: 6px;
| font-size: 13px;
| vertical-align: middle;
| }
| }
| </style>
|
|