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
| <template>
| <el-dialog :visible.sync="visible" append-to-body :title="!dataForm.id ? $t('add') : $t('update')"
| :close-on-click-modal="false" :close-on-press-escape="false">
| <el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmitHandle()"
| label-width="120px">
| <el-row>
| <el-col :span="12">
| <el-form-item prop="itemText" :label="$t('prodParamMz.itemText')">
| <el-input v-model="dataForm.itemText" :placeholder="$t('sysDictItem.itemText')"></el-input>
| </el-form-item>
| </el-col>
| <el-col :span="12">
| <el-form-item prop="itemValue" :label="$t('prodParamMz.itemValue')">
| <el-input v-model="dataForm.itemValue" :placeholder="$t('sysDictItem.itemValue')"></el-input>
| </el-form-item>
| </el-col>
| </el-row>
| <el-row>
| <el-col :span="12">
| <el-form-item prop="sortOrder" :label="$t('prodParamMc.sortOrder')">
| <el-input v-model="dataForm.sortOrder" :placeholder="$t('sysDictItem.sortOrder')"></el-input>
| </el-form-item>
| </el-col>
| </el-row>
| </el-form>
| <template slot="footer">
| <el-button size="mini" :loading="loading" @click="visible = false">{{ $t('cancel') }}</el-button>
| <el-button size="mini" :loading="loading" type="primary" @click="dataFormSubmitHandle()">{{ $t('confirm') }}
| </el-button>
| </template>
| </el-dialog>
| </template>
|
| <script>
| import debounce from 'lodash/debounce'
| import DictSelectTag from "@/components/dict/dict-select-tag";
|
| export default {
| components: {DictSelectTag},
| data() {
| return {
| visible: false,
| loading: false,
| dataForm: {
| id: '',
| dictId: '',
| itemText: '',
| itemValue: '',
| sortOrder: '',
| shortName: '',
| ext1: '',
| ext2: '',
| ext3: '',
| ext4: '',
| ext5: '',
| ext6: '',
| ext7: '',
| ext8: '',
| ext9: '',
| ext10: ''
| }
| }
| },
| computed: {
| dataRule() {
| return {
| itemText: [
| {required: true, message: this.$t('validate.required'), trigger: 'blur'}
| ],
| itemValue: [
| {required: true, message: this.$t('validate.required'), trigger: 'blur'}
| ],
| ext1: [
| {required: true, message: this.$t('validate.required'), trigger: 'blur'}
| ],
| ext2: [
| {required: true, message: this.$t('validate.required'), trigger: 'blur'}
| ],
| ext3: [
| {required: true, message: this.$t('validate.required'), trigger: 'blur'}
| ],
| sortOrder: [
| {required: true, message: this.$t('validate.required'), trigger: 'blur'}
| ]
| }
| }
| },
| methods: {
| init(id, dictId, dictCode) {
| this.visible = true
| this.$nextTick(() => {
| this.$refs['dataForm'].resetFields()
| this.dataForm.dictId = dictId || null
| this.dataForm.id = id || ''
| if (this.dataForm.id) {
| this.getInfo()
| }
| })
| },
| // 获取信息
| getInfo() {
| this.$http.get(`/iailab-iems-system/sys/dict-item/${this.dataForm.id}`).then(({data: res}) => {
| if (res.code !== 0) {
| return this.$message.error(res.msg)
| }
| this.dataForm = {
| ...this.dataForm,
| ...res.data
| }
| }).catch(() => {
| })
| },
| // 表单提交
| dataFormSubmitHandle: debounce(function () {
| this.$refs['dataForm'].validate((valid) => {
| if (!valid) {
| return false
| }
| this.loading = true
| this.$http[!this.dataForm.id ? 'post' : 'put']('/iailab-iems-system/sys/dict-item', this.dataForm).then(({data: res}) => {
| if (res.code !== 0) {
| return this.$message.error(res.msg)
| }
| this.$message({
| message: this.$t('prompt.success'),
| type: 'success',
| duration: 500,
| onClose: () => {
| this.visible = false
| this.$emit('refreshDataList')
| }
| })
| this.loading = false
| }).catch(() => {
| })
| })
| }, 1000, {'leading': true, 'trailing': false})
| }
| }
| </script>
|
|