Browse Source

分离弹窗

daxiong.yang 7 years ago
parent
commit
f001da8d00

+ 94 - 0
src/views/config/add-or-update.vue

@ -0,0 +1,94 @@
1
<template>
2
  <el-dialog
3
    :title="!dataForm.id ? '新增' : '修改'"
4
    :close-on-click-modal="false"
5
    :visible.sync="visible">
6
    <el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmit()" label-width="80px">
7
      <el-form-item label="参数名" prop="key">
8
        <el-input v-model="dataForm.key" placeholder="参数名"></el-input>
9
      </el-form-item>
10
      <el-form-item label="参数值" prop="value">
11
        <el-input v-model="dataForm.value" placeholder="参数值"></el-input>
12
      </el-form-item>
13
      <el-form-item label="备注" prop="remark">
14
        <el-input v-model="dataForm.remark" placeholder="备注"></el-input>
15
      </el-form-item>
16
    </el-form>
17
    <span slot="footer" class="dialog-footer">
18
      <el-button @click="visible = false">取消</el-button>
19
      <el-button type="primary" @click="dataFormSubmit()">确定</el-button>
20
    </span>
21
  </el-dialog>
22
</template>
23
24
<script>
25
  import API from '@/api'
26
  export default {
27
    data () {
28
      return {
29
        visible: false,
30
        dataForm: {
31
          id: 0,
32
          key: '',
33
          value: '',
34
          remark: ''
35
        },
36
        dataRule: {
37
          key: [
38
            { required: true, message: '参数名不能为空', trigger: 'blur' }
39
          ],
40
          value: [
41
            { required: true, message: '参数值不能为空', trigger: 'blur' }
42
          ]
43
        }
44
      }
45
    },
46
    methods: {
47
      init (id) {
48
        this.dataForm.id = id || 0
49
        this.visible = true
50
        this.$nextTick(() => {
51
          this.$refs['dataForm'].resetFields()
52
          if (this.dataForm.id) {
53
            API.config.info(this.dataForm.id).then(({data}) => {
54
              if (data && data.code === 0) {
55
                this.dataForm.key = data.config.key
56
                this.dataForm.value = data.config.value
57
                this.dataForm.remark = data.config.remark
58
              }
59
            })
60
          }
61
        })
62
      },
63
      // 表单提交
64
      dataFormSubmit () {
65
        this.$refs['dataForm'].validate((valid) => {
66
          if (valid) {
67
            var params = {
68
              'id': this.dataForm.id || undefined,
69
              'key': this.dataForm.key,
70
              'value': this.dataForm.value,
71
              'remark': this.dataForm.remark
72
            }
73
            var tick = !this.dataForm.id ? API.config.add(params) : API.config.update(params)
74
            tick.then(({data}) => {
75
              if (data && data.code === 0) {
76
                this.$message({
77
                  message: '操作成功',
78
                  type: 'success',
79
                  duration: 1500,
80
                  onClose: () => {
81
                    this.visible = false
82
                    this.$emit('refreshDataList')
83
                  }
84
                })
85
              } else {
86
                this.$message.error(data.msg)
87
              }
88
            })
89
          }
90
        })
91
      }
92
    }
93
  }
94
</script>

+ 8 - 76
src/views/config/index.vue

@ -69,31 +69,13 @@
69 69
      layout="total, sizes, prev, pager, next, jumper">
70 70
    </el-pagination>
71 71
    <!-- 弹窗, 新增 / 修改 -->
72
    <el-dialog
73
      :title="!addOrUpdateForm.id ? '新增' : '修改'"
74
      :close-on-click-modal="false"
75
      :visible.sync="addOrUpdateDialogVisible">
76
      <el-form :model="addOrUpdateForm" :rules="addOrUpdateRule" ref="addOrUpdateForm" label-width="80px">
77
        <el-form-item label="参数名" prop="key">
78
          <el-input v-model="addOrUpdateForm.key" placeholder="参数名"></el-input>
79
        </el-form-item>
80
        <el-form-item label="参数值" prop="value">
81
          <el-input v-model="addOrUpdateForm.value" placeholder="参数值"></el-input>
82
        </el-form-item>
83
        <el-form-item label="备注" prop="remark">
84
          <el-input v-model="addOrUpdateForm.remark" placeholder="备注"></el-input>
85
        </el-form-item>
86
      </el-form>
87
      <span slot="footer" class="dialog-footer">
88
        <el-button @click="addOrUpdateDialogVisible = false">取消</el-button>
89
        <el-button type="primary" @click="addOrUpdateFormSubmit()">确定</el-button>
90
      </span>
91
    </el-dialog>
72
    <add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></add-or-update>
92 73
  </div>
93 74
</template>
94 75
95 76
<script>
96 77
  import API from '@/api'
78
  import AddOrUpdate from './add-or-update'
97 79
  export default {
98 80
    data () {
99 81
      return {
@ -106,23 +88,12 @@
106 88
        totalPage: 0,
107 89
        dataListLoading: false,
108 90
        dataListSelections: [],
109
        addOrUpdateDialogVisible: false,
110
        addOrUpdateForm: {
111
          id: 0,
112
          key: '',
113
          value: '',
114
          remark: ''
115
        },
116
        addOrUpdateRule: {
117
          key: [
118
            { required: true, message: '参数名不能为空', trigger: 'blur' }
119
          ],
120
          value: [
121
            { required: true, message: '参数值不能为空', trigger: 'blur' }
122
          ]
123
        }
91
        addOrUpdateVisible: false
124 92
      }
125 93
    },
94
    components: {
95
      AddOrUpdate
96
    },
126 97
    activated () {
127 98
      this.getDataList()
128 99
    },
@ -163,48 +134,9 @@
163 134
      },
164 135
      // 新增 / 修改
165 136
      addOrUpdateHandle (id) {
166
        this.addOrUpdateForm.id = id || 0
167
        this.addOrUpdateDialogVisible = true
137
        this.addOrUpdateVisible = true
168 138
        this.$nextTick(() => {
169
          this.$refs['addOrUpdateForm'].resetFields()
170
          if (this.addOrUpdateForm.id) {
171
            API.config.info(this.addOrUpdateForm.id).then(({data}) => {
172
              if (data && data.code === 0) {
173
                this.addOrUpdateForm.key = data.config.key
174
                this.addOrUpdateForm.value = data.config.value
175
                this.addOrUpdateForm.remark = data.config.remark
176
              }
177
            })
178
          }
179
        })
180
      },
181
      // 新增 / 修改, 提交
182
      addOrUpdateFormSubmit () {
183
        this.$refs['addOrUpdateForm'].validate((valid) => {
184
          if (valid) {
185
            var params = {
186
              'id': this.addOrUpdateForm.id || undefined,
187
              'key': this.addOrUpdateForm.key,
188
              'value': this.addOrUpdateForm.value,
189
              'remark': this.addOrUpdateForm.remark
190
            }
191
            var tick = this.addOrUpdateForm.id ? API.config.update(params) : API.config.add(params)
192
            tick.then(({data}) => {
193
              if (data && data.code === 0) {
194
                this.$message({
195
                  message: '操作成功',
196
                  type: 'success',
197
                  duration: 1500,
198
                  onClose: () => {
199
                    this.addOrUpdateDialogVisible = false
200
                    this.getDataList()
201
                  }
202
                })
203
              } else {
204
                this.$message.error(data.msg)
205
              }
206
            })
207
          }
139
          this.$refs.addOrUpdate.init(id)
208 140
        })
209 141
      },
210 142
      // 删除

+ 0 - 1
src/views/menu/add-or-update.vue

@ -201,4 +201,3 @@
201 201
    }
202 202
  }
203 203
</style>
204

+ 126 - 0
src/views/oss/config.vue

@ -0,0 +1,126 @@
1
<template>
2
  <el-dialog
3
    title="云存储配置"
4
    :close-on-click-modal="false"
5
    :visible.sync="visible">
6
    <el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmit()" label-width="120px">
7
      <el-form-item size="mini" label="存储类型">
8
        <el-radio-group v-model="dataForm.type">
9
          <el-radio :label="1">七牛</el-radio>
10
          <el-radio :label="2">阿里云</el-radio>
11
          <el-radio :label="3">腾讯云</el-radio>
12
        </el-radio-group>
13
      </el-form-item>
14
      <template v-if="dataForm.type === 1">
15
        <el-form-item size="mini">
16
          <a href="http://www.renren.io/open/qiniu.html" target="_blank">免费申请(七牛)10GB储存空间</a>
17
        </el-form-item>
18
        <el-form-item label="域名">
19
          <el-input v-model="dataForm.qiniuDomain" placeholder="七牛绑定的域名"></el-input>
20
        </el-form-item>
21
        <el-form-item label="路径前缀">
22
          <el-input v-model="dataForm.qiniuPrefix" placeholder="不设置默认为空"></el-input>
23
        </el-form-item>
24
        <el-form-item label="AccessKey">
25
          <el-input v-model="dataForm.qiniuAccessKey" placeholder="七牛AccessKey"></el-input>
26
        </el-form-item>
27
        <el-form-item label="SecretKey">
28
          <el-input v-model="dataForm.qiniuSecretKey" placeholder="七牛SecretKey"></el-input>
29
        </el-form-item>
30
        <el-form-item label="空间名">
31
          <el-input v-model="dataForm.qiniuBucketName" placeholder="七牛存储空间名"></el-input>
32
        </el-form-item>
33
      </template>
34
      <template v-else-if="dataForm.type === 2">
35
        <el-form-item label="域名">
36
          <el-input v-model="dataForm.aliyunDomain" placeholder="阿里云绑定的域名"></el-input>
37
        </el-form-item>
38
        <el-form-item label="路径前缀">
39
          <el-input v-model="dataForm.aliyunPrefix" placeholder="不设置默认为空"></el-input>
40
        </el-form-item>
41
        <el-form-item label="EndPoint">
42
          <el-input v-model="dataForm.aliyunEndPoint" placeholder="阿里云EndPoint"></el-input>
43
        </el-form-item>
44
        <el-form-item label="AccessKeyId">
45
          <el-input v-model="dataForm.aliyunAccessKeyId" placeholder="阿里云AccessKeyId"></el-input>
46
        </el-form-item>
47
        <el-form-item label="AccessKeySecret">
48
          <el-input v-model="dataForm.aliyunAccessKeySecret" placeholder="阿里云AccessKeySecret"></el-input>
49
        </el-form-item>
50
        <el-form-item label="BucketName">
51
          <el-input v-model="dataForm.aliyunBucketName" placeholder="阿里云BucketName"></el-input>
52
        </el-form-item>
53
      </template>
54
      <template v-else-if="dataForm.type === 3">
55
        <el-form-item label="域名">
56
          <el-input v-model="dataForm.qcloudDomain" placeholder="腾讯云绑定的域名"></el-input>
57
        </el-form-item>
58
        <el-form-item label="路径前缀">
59
          <el-input v-model="dataForm.qcloudPrefix" placeholder="不设置默认为空"></el-input>
60
        </el-form-item>
61
        <el-form-item label="AppId">
62
          <el-input v-model="dataForm.qcloudAppId" placeholder="腾讯云AppId"></el-input>
63
        </el-form-item>
64
        <el-form-item label="SecretId">
65
          <el-input v-model="dataForm.qcloudSecretId" placeholder="腾讯云SecretId"></el-input>
66
        </el-form-item>
67
        <el-form-item label="SecretKey">
68
          <el-input v-model="dataForm.qcloudSecretKey" placeholder="腾讯云SecretKey"></el-input>
69
        </el-form-item>
70
        <el-form-item label="BucketName">
71
          <el-input v-model="dataForm.qcloudBucketName" placeholder="腾讯云BucketName"></el-input>
72
        </el-form-item>
73
        <el-form-item label="Bucket所属地区">
74
          <el-input v-model="dataForm.qcloudRegion" placeholder="如:sh(可选值 ,华南:gz 华北:tj 华东:sh)"></el-input>
75
        </el-form-item>
76
      </template>
77
    </el-form>
78
    <span slot="footer" class="dialog-footer">
79
      <el-button @click="visible = false">取消</el-button>
80
      <el-button type="primary" @click="dataFormSubmit()">确定</el-button>
81
    </span>
82
  </el-dialog>
83
</template>
84
85
<script>
86
  import API from '@/api'
87
  export default {
88
    data () {
89
      return {
90
        visible: false,
91
        dataForm: {},
92
        dataRule: {}
93
      }
94
    },
95
    methods: {
96
      init (id) {
97
        this.visible = true
98
        API.oss.config().then(({data}) => {
99
          this.dataForm = data && data.code === 0 ? data.config : []
100
        })
101
      },
102
      // 表单提交
103
      dataFormSubmit () {
104
        this.$refs['dataForm'].validate((valid) => {
105
          if (valid) {
106
            API.oss.addConfig(this.dataForm).then(({data}) => {
107
              if (data && data.code === 0) {
108
                this.$message({
109
                  message: '操作成功',
110
                  type: 'success',
111
                  duration: 1500,
112
                  onClose: () => {
113
                    this.visible = false
114
                  }
115
                })
116
              } else {
117
                this.$message.error(data.msg)
118
              }
119
            })
120
          }
121
        })
122
      }
123
    }
124
  }
125
</script>
126

+ 17 - 164
src/views/oss/index.vue

@ -60,111 +60,16 @@
60 60
      layout="total, sizes, prev, pager, next, jumper">
61 61
    </el-pagination>
62 62
    <!-- 弹窗, 云存储配置 -->
63
    <el-dialog
64
      title="云存储配置"
65
      :close-on-click-modal="false"
66
      :visible.sync="configDialogVisible">
67
      <el-form :model="configForm" :rules="configRule" ref="configForm" label-width="120px">
68
        <el-form-item size="mini" label="存储类型">
69
          <el-radio-group v-model="configForm.type">
70
            <el-radio :label="1">七牛</el-radio>
71
            <el-radio :label="2">阿里云</el-radio>
72
            <el-radio :label="3">腾讯云</el-radio>
73
          </el-radio-group>
74
        </el-form-item>
75
        <template v-if="configForm.type === 1">
76
          <el-form-item size="mini">
77
            <a href="http://www.renren.io/open/qiniu.html" target="_blank">免费申请(七牛)10GB储存空间</a>
78
          </el-form-item>
79
          <el-form-item label="域名">
80
            <el-input v-model="configForm.qiniuDomain" placeholder="七牛绑定的域名"></el-input>
81
          </el-form-item>
82
          <el-form-item label="路径前缀">
83
            <el-input v-model="configForm.qiniuPrefix" placeholder="不设置默认为空"></el-input>
84
          </el-form-item>
85
          <el-form-item label="AccessKey">
86
            <el-input v-model="configForm.qiniuAccessKey" placeholder="七牛AccessKey"></el-input>
87
          </el-form-item>
88
          <el-form-item label="SecretKey">
89
            <el-input v-model="configForm.qiniuSecretKey" placeholder="七牛SecretKey"></el-input>
90
          </el-form-item>
91
          <el-form-item label="空间名">
92
            <el-input v-model="configForm.qiniuBucketName" placeholder="七牛存储空间名"></el-input>
93
          </el-form-item>
94
        </template>
95
        <template v-else-if="configForm.type === 2">
96
          <el-form-item label="域名">
97
            <el-input v-model="configForm.aliyunDomain" placeholder="阿里云绑定的域名"></el-input>
98
          </el-form-item>
99
          <el-form-item label="路径前缀">
100
            <el-input v-model="configForm.aliyunPrefix" placeholder="不设置默认为空"></el-input>
101
          </el-form-item>
102
          <el-form-item label="EndPoint">
103
            <el-input v-model="configForm.aliyunEndPoint" placeholder="阿里云EndPoint"></el-input>
104
          </el-form-item>
105
          <el-form-item label="AccessKeyId">
106
            <el-input v-model="configForm.aliyunAccessKeyId" placeholder="阿里云AccessKeyId"></el-input>
107
          </el-form-item>
108
          <el-form-item label="AccessKeySecret">
109
            <el-input v-model="configForm.aliyunAccessKeySecret" placeholder="阿里云AccessKeySecret"></el-input>
110
          </el-form-item>
111
          <el-form-item label="BucketName">
112
            <el-input v-model="configForm.aliyunBucketName" placeholder="阿里云BucketName"></el-input>
113
          </el-form-item>
114
        </template>
115
        <template v-else-if="configForm.type === 3">
116
          <el-form-item label="域名">
117
            <el-input v-model="configForm.qcloudDomain" placeholder="腾讯云绑定的域名"></el-input>
118
          </el-form-item>
119
          <el-form-item label="路径前缀">
120
            <el-input v-model="configForm.qcloudPrefix" placeholder="不设置默认为空"></el-input>
121
          </el-form-item>
122
          <el-form-item label="AppId">
123
            <el-input v-model="configForm.qcloudAppId" placeholder="腾讯云AppId"></el-input>
124
          </el-form-item>
125
          <el-form-item label="SecretId">
126
            <el-input v-model="configForm.qcloudSecretId" placeholder="腾讯云SecretId"></el-input>
127
          </el-form-item>
128
          <el-form-item label="SecretKey">
129
            <el-input v-model="configForm.qcloudSecretKey" placeholder="腾讯云SecretKey"></el-input>
130
          </el-form-item>
131
          <el-form-item label="BucketName">
132
            <el-input v-model="configForm.qcloudBucketName" placeholder="腾讯云BucketName"></el-input>
133
          </el-form-item>
134
          <el-form-item label="Bucket所属地区">
135
            <el-input v-model="configForm.qcloudRegion" placeholder="如:sh(可选值 ,华南:gz 华北:tj 华东:sh)"></el-input>
136
          </el-form-item>
137
        </template>
138
      </el-form>
139
      <span slot="footer" class="dialog-footer">
140
        <el-button @click="configDialogVisible = false">取消</el-button>
141
        <el-button type="primary" @click="configFormSubmit()">确定</el-button>
142
      </span>
143
    </el-dialog>
63
    <config v-if="configVisible" ref="config"></config>
144 64
    <!-- 弹窗, 上传文件 -->
145
    <el-dialog
146
      title="上传文件"
147
      :close-on-click-modal="false"
148
      @close="uploadDialogCloseHandle"
149
      :visible.sync="uploadDialogVisible">
150
      <el-upload
151
        drag
152
        :action="uploadUrl"
153
        :before-upload="uploadBeforeUploadHandle"
154
        :on-success="uploadSuccessHandle"
155
        multiple
156
        :file-list="uploadFileList"
157
        style="text-align: center;">
158
        <i class="el-icon-upload"></i>
159
        <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
160
        <div class="el-upload__tip" slot="tip">只支持jpg、png、gif格式的图片!</div>
161
      </el-upload>
162
    </el-dialog>
65
    <upload v-if="uploadVisible" ref="upload" @refreshDataList="getDataList"></upload>
163 66
  </div>
164 67
</template>
165 68
166 69
<script>
167 70
  import API from '@/api'
71
  import Config from './config'
72
  import Upload from './upload'
168 73
  export default {
169 74
    data () {
170 75
      return {
@ -175,16 +80,14 @@
175 80
        totalPage: 0,
176 81
        dataListLoading: false,
177 82
        dataListSelections: [],
178
        configDialogVisible: false,
179
        configForm: {},
180
        configRule: {},
181
        uploadDialogVisible: false,
182
        uploadUrl: '',
183
        uploadNum: 0,
184
        uploadSuccessNum: 0,
185
        uploadFileList: []
83
        configVisible: false,
84
        uploadVisible: false
186 85
      }
187 86
    },
87
    components: {
88
      Config,
89
      Upload
90
    },
188 91
    activated () {
189 92
      this.getDataList()
190 93
    },
@ -224,67 +127,17 @@
224 127
      },
225 128
      // 云存储配置
226 129
      configHandle () {
227
        this.configDialogVisible = true
228
        API.oss.config().then(({data}) => {
229
          this.configForm = data && data.code === 0 ? data.config : []
230
        })
231
      },
232
      // 云存储配置, 提交
233
      configFormSubmit () {
234
        this.$refs['configForm'].validate((valid) => {
235
          if (valid) {
236
            API.oss.addConfig(this.configForm).then(({data}) => {
237
              if (data && data.code === 0) {
238
                this.$message({
239
                  message: '操作成功',
240
                  type: 'success',
241
                  duration: 1500,
242
                  onClose: () => {
243
                    this.configDialogVisible = false
244
                  }
245
                })
246
              } else {
247
                this.$message.error(data.msg)
248
              }
249
            })
250
          }
130
        this.configVisible = true
131
        this.$nextTick(() => {
132
          this.$refs.config.init()
251 133
        })
252 134
      },
253 135
      // 上传文件
254 136
      uploadHandle () {
255
        this.uploadUrl = API.oss.upload(this.$cookie.get('token'))
256
        this.uploadDialogVisible = true
257
      },
258
      // 图片上传之前
259
      uploadBeforeUploadHandle (file) {
260
        if (file.type !== 'image/jpg' && file.type !== 'image/jpeg' && file.type !== 'image/png' && file.type !== 'image/gif') {
261
          this.$message.error('只支持jpg、png、gif格式的图片!')
262
          return false
263
        }
264
        this.uploadNum++
265
      },
266
      // 图片上传成功
267
      uploadSuccessHandle (response, file, fileList) {
268
        this.uploadFileList = fileList
269
        this.uploadSuccessNum++
270
        if (response && response.code === 0) {
271
          if (this.uploadNum === this.uploadSuccessNum) {
272
            this.$confirm('操作成功, 是否继续操作?', '提示', {
273
              confirmButtonText: '确定',
274
              cancelButtonText: '取消',
275
              type: 'warning'
276
            }).catch(() => {
277
              this.uploadDialogVisible = false
278
            })
279
          }
280
        } else {
281
          this.$message.error(response.msg)
282
        }
283
      },
284
      // 图片上传, 弹窗关闭
285
      uploadDialogCloseHandle () {
286
        this.uploadFileList = []
287
        this.getDataList()
137
        this.uploadVisible = true
138
        this.$nextTick(() => {
139
          this.$refs.upload.init()
140
        })
288 141
      },
289 142
      // 删除
290 143
      deleteHandle (id) {

+ 72 - 0
src/views/oss/upload.vue

@ -0,0 +1,72 @@
1
<template>
2
  <el-dialog
3
    title="上传文件"
4
    :close-on-click-modal="false"
5
    @close="closeHandle"
6
    :visible.sync="visible">
7
    <el-upload
8
      drag
9
      :action="url"
10
      :before-upload="beforeUploadHandle"
11
      :on-success="successHandle"
12
      multiple
13
      :file-list="fileList"
14
      style="text-align: center;">
15
      <i class="el-icon-upload"></i>
16
      <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
17
      <div class="el-upload__tip" slot="tip">只支持jpg、png、gif格式的图片!</div>
18
    </el-upload>
19
  </el-dialog>
20
</template>
21
22
<script>
23
  import API from '@/api'
24
  export default {
25
    data () {
26
      return {
27
        visible: false,
28
        url: '',
29
        num: 0,
30
        successNum: 0,
31
        fileList: []
32
      }
33
    },
34
    methods: {
35
      init (id) {
36
        this.url = API.oss.upload(this.$cookie.get('token'))
37
        this.visible = true
38
      },
39
      // 上传之前
40
      beforeUploadHandle (file) {
41
        if (file.type !== 'image/jpg' && file.type !== 'image/jpeg' && file.type !== 'image/png' && file.type !== 'image/gif') {
42
          this.$message.error('只支持jpg、png、gif格式的图片!')
43
          return false
44
        }
45
        this.num++
46
      },
47
      // 上传成功
48
      successHandle (response, file, fileList) {
49
        this.fileList = fileList
50
        this.successNum++
51
        if (response && response.code === 0) {
52
          if (this.num === this.successNum) {
53
            this.$confirm('操作成功, 是否继续操作?', '提示', {
54
              confirmButtonText: '确定',
55
              cancelButtonText: '取消',
56
              type: 'warning'
57
            }).catch(() => {
58
              this.visible = false
59
            })
60
          }
61
        } else {
62
          this.$message.error(response.msg)
63
        }
64
      },
65
      // 弹窗关闭时
66
      closeHandle () {
67
        this.fileList = []
68
        this.$emit('refreshDataList')
69
      }
70
    }
71
  }
72
</script>

+ 109 - 0
src/views/role/add-or-update.vue

@ -0,0 +1,109 @@
1
<template>
2
  <el-dialog
3
    :title="!dataForm.id ? '新增' : '修改'"
4
    :close-on-click-modal="false"
5
    :visible.sync="visible">
6
    <el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmit()" label-width="80px">
7
      <el-form-item label="角色名称" prop="roleName">
8
        <el-input v-model="dataForm.roleName" placeholder="角色名称"></el-input>
9
      </el-form-item>
10
      <el-form-item label="备注" prop="remark">
11
        <el-input v-model="dataForm.remark" placeholder="备注"></el-input>
12
      </el-form-item>
13
      <el-form-item size="mini" label="授权">
14
        <el-tree
15
          :data="menuList"
16
          :props="menuListTreeProps"
17
          node-key="menuId"
18
          ref="menuListTree"
19
          :default-expand-all="true"
20
          show-checkbox>
21
        </el-tree>
22
      </el-form-item>
23
    </el-form>
24
    <span slot="footer" class="dialog-footer">
25
      <el-button @click="visible = false">取消</el-button>
26
      <el-button type="primary" @click="dataFormSubmit()">确定</el-button>
27
    </span>
28
  </el-dialog>
29
</template>
30
31
<script>
32
  import API from '@/api'
33
  import { treeDataTranslate } from '@/utils'
34
  export default {
35
    data () {
36
      return {
37
        visible: false,
38
        menuList: [],
39
        menuListTreeProps: {
40
          label: 'name',
41
          children: 'children'
42
        },
43
        dataForm: {
44
          id: 0,
45
          roleName: '',
46
          remark: ''
47
        },
48
        dataRule: {
49
          roleName: [
50
            { required: true, message: '角色名称不能为空', trigger: 'blur' }
51
          ]
52
        }
53
      }
54
    },
55
    methods: {
56
      init (id) {
57
        this.dataForm.id = id || 0
58
        API.menu.list().then(({data}) => {
59
          this.menuList = treeDataTranslate(data, 'menuId')
60
        }).then(() => {
61
          this.visible = true
62
          this.$nextTick(() => {
63
            this.$refs['dataForm'].resetFields()
64
            this.$refs.menuListTree.setCheckedKeys([])
65
          })
66
        }).then(() => {
67
          if (this.dataForm.id) {
68
            API.role.info(this.dataForm.id).then(({data}) => {
69
              if (data && data.code === 0) {
70
                this.dataForm.roleName = data.role.roleName
71
                this.dataForm.remark = data.role.remark
72
                this.$refs.menuListTree.setCheckedKeys(data.role.menuIdList)
73
              }
74
            })
75
          }
76
        })
77
      },
78
      // 表单提交
79
      dataFormSubmit () {
80
        this.$refs['dataForm'].validate((valid) => {
81
          if (valid) {
82
            var params = {
83
              'roleId': this.dataForm.id || undefined,
84
              'roleName': this.dataForm.roleName,
85
              'remark': this.dataForm.remark,
86
              'menuIdList': this.$refs.menuListTree.getCheckedKeys()
87
            }
88
            var tick = !this.dataForm.id ? API.role.add(params) : API.role.update(params)
89
            tick.then(({data}) => {
90
              if (data && data.code === 0) {
91
                this.$message({
92
                  message: '操作成功',
93
                  type: 'success',
94
                  duration: 1500,
95
                  onClose: () => {
96
                    this.visible = false
97
                    this.$emit('refreshDataList')
98
                  }
99
                })
100
              } else {
101
                this.$message.error(data.msg)
102
              }
103
            })
104
          }
105
        })
106
      }
107
    }
108
  }
109
</script>

+ 12 - 94
src/views/role/index.vue

@ -70,39 +70,13 @@
70 70
      layout="total, sizes, prev, pager, next, jumper">
71 71
    </el-pagination>
72 72
    <!-- 弹窗, 新增 / 修改 -->
73
    <el-dialog
74
      :title="!addOrUpdateForm.roleId ? '新增' : '修改'"
75
      :close-on-click-modal="false"
76
      :visible.sync="addOrUpdateDialogVisible">
77
      <el-form :model="addOrUpdateForm" :rules="addOrUpdateRule" ref="addOrUpdateForm" label-width="80px">
78
        <el-form-item label="角色名称" prop="roleName">
79
          <el-input v-model="addOrUpdateForm.roleName" placeholder="角色名称"></el-input>
80
        </el-form-item>
81
        <el-form-item label="备注" prop="remark">
82
          <el-input v-model="addOrUpdateForm.remark" placeholder="备注"></el-input>
83
        </el-form-item>
84
        <el-form-item size="mini" label="授权">
85
          <el-tree
86
            :data="menuList"
87
            :props="menuListTreeProps"
88
            node-key="menuId"
89
            ref="menuListTree"
90
            :default-expand-all="true"
91
            show-checkbox>
92
          </el-tree>
93
        </el-form-item>
94
      </el-form>
95
      <span slot="footer" class="dialog-footer">
96
        <el-button @click="addOrUpdateDialogVisible = false">取消</el-button>
97
        <el-button type="primary" @click="addOrUpdateFormSubmit()">确定</el-button>
98
      </span>
99
    </el-dialog>
73
    <add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></add-or-update>
100 74
  </div>
101 75
</template>
102 76
103 77
<script>
78
  import AddOrUpdate from './add-or-update'
104 79
  import API from '@/api'
105
  import { treeDataTranslate } from '@/utils'
106 80
  export default {
107 81
    data () {
108 82
      return {
@ -115,24 +89,12 @@
115 89
        totalPage: 0,
116 90
        dataListLoading: false,
117 91
        dataListSelections: [],
118
        menuList: [],
119
        menuListTreeProps: {
120
          label: 'name',
121
          children: 'children'
122
        },
123
        addOrUpdateDialogVisible: false,
124
        addOrUpdateForm: {
125
          roleId: 0,
126
          roleName: '',
127
          remark: ''
128
        },
129
        addOrUpdateRule: {
130
          roleName: [
131
            { required: true, message: '角色名称不能为空', trigger: 'blur' }
132
          ]
133
        }
92
        addOrUpdateVisible: false
134 93
      }
135 94
    },
95
    components: {
96
      AddOrUpdate
97
    },
136 98
    activated () {
137 99
      this.getDataList()
138 100
    },
@ -173,66 +135,22 @@
173 135
      },
174 136
      // 新增 / 修改
175 137
      addOrUpdateHandle (id) {
176
        this.addOrUpdateForm.roleId = id || 0
177
        API.menu.list().then(({data}) => {
178
          this.menuList = treeDataTranslate(data, 'menuId')
179
        }).then(() => {
180
          this.addOrUpdateDialogVisible = true
181
          this.$nextTick(() => {
182
            this.$refs['addOrUpdateForm'].resetFields()
183
          })
184
        }).then(() => {
185
          if (this.addOrUpdateForm.roleId) {
186
            API.role.info(this.addOrUpdateForm.roleId).then(({data}) => {
187
              if (data && data.code === 0) {
188
                this.addOrUpdateForm.roleName = data.role.roleName
189
                this.addOrUpdateForm.remark = data.role.remark
190
                this.$refs.menuListTree.setCheckedKeys(data.role.menuIdList)
191
              }
192
            })
193
          }
194
        })
195
      },
196
      // 新增 / 修改, 提交
197
      addOrUpdateFormSubmit () {
198
        this.$refs['addOrUpdateForm'].validate((valid) => {
199
          if (valid) {
200
            var params = {
201
              'roleId': this.addOrUpdateForm.roleId || undefined,
202
              'roleName': this.addOrUpdateForm.roleName,
203
              'remark': this.addOrUpdateForm.remark,
204
              'menuIdList': this.$refs.menuListTree.getCheckedKeys()
205
            }
206
            var tick = this.addOrUpdateForm.roleId ? API.role.update(params) : API.role.add(params)
207
            tick.then(({data}) => {
208
              if (data && data.code === 0) {
209
                this.$message({
210
                  message: '操作成功',
211
                  type: 'success',
212
                  duration: 1500,
213
                  onClose: () => {
214
                    this.addOrUpdateDialogVisible = false
215
                    this.getDataList()
216
                  }
217
                })
218
              } else {
219
                this.$message.error(data.msg)
220
              }
221
            })
222
          }
138
        this.addOrUpdateVisible = true
139
        this.$nextTick(() => {
140
          this.$refs.addOrUpdate.init(id)
223 141
        })
224 142
      },
225 143
      // 删除
226 144
      deleteHandle (id) {
227
        var roleIds = id ? [id] : this.dataListSelections.map(item => {
145
        var ids = id ? [id] : this.dataListSelections.map(item => {
228 146
          return item.roleId
229 147
        })
230
        this.$confirm(`确定对[id=${roleIds.join(',')}]进行[${id ? '删除' : '批量删除'}]操作?`, '提示', {
148
        this.$confirm(`确定对[id=${ids.join(',')}]进行[${id ? '删除' : '批量删除'}]操作?`, '提示', {
231 149
          confirmButtonText: '确定',
232 150
          cancelButtonText: '取消',
233 151
          type: 'warning'
234 152
        }).then(() => {
235
          API.role.del(roleIds).then(({data}) => {
153
          API.role.del(ids).then(({data}) => {
236 154
            if (data && data.code === 0) {
237 155
              this.$message({
238 156
                message: '操作成功',

+ 112 - 0
src/views/schedule/add-or-update.vue

@ -0,0 +1,112 @@
1
<template>
2
  <el-dialog
3
    :title="!dataForm.id ? '新增' : '修改'"
4
    :close-on-click-modal="false"
5
    :visible.sync="visible">
6
    <el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmit()" label-width="100px">
7
      <el-form-item label="bean名称" prop="beanName">
8
        <el-input v-model="dataForm.beanName" placeholder="spring bean名称, 如: testTask"></el-input>
9
      </el-form-item>
10
      <el-form-item label="方法名称" prop="methodName">
11
        <el-input v-model="dataForm.methodName" placeholder="方法名称"></el-input>
12
      </el-form-item>
13
      <el-form-item label="参数" prop="params">
14
        <el-input v-model="dataForm.params" placeholder="参数"></el-input>
15
      </el-form-item>
16
      <el-form-item label="cron表达式" prop="cronExpression">
17
        <el-input v-model="dataForm.cronExpression" placeholder="如: 0 0 12 * * ?"></el-input>
18
      </el-form-item>
19
      <el-form-item label="备注" prop="remark">
20
        <el-input v-model="dataForm.remark" placeholder="备注"></el-input>
21
      </el-form-item>
22
    </el-form>
23
    <span slot="footer" class="dialog-footer">
24
      <el-button @click="visible = false">取消</el-button>
25
      <el-button type="primary" @click="dataFormSubmit()">确定</el-button>
26
    </span>
27
  </el-dialog>
28
</template>
29
30
<script>
31
  import API from '@/api'
32
  export default {
33
    data () {
34
      return {
35
        visible: false,
36
        dataForm: {
37
          id: 0,
38
          beanName: '',
39
          methodName: '',
40
          params: '',
41
          cronExpression: '',
42
          remark: '',
43
          status: 0
44
        },
45
        dataRule: {
46
          beanName: [
47
            { required: true, message: '用户名不能为空', trigger: 'blur' }
48
          ],
49
          methodName: [
50
            { required: true, message: '方法名称不能为空', trigger: 'blur' }
51
          ],
52
          cronExpression: [
53
            { required: true, message: 'cron表达式不能为空', trigger: 'blur' }
54
          ]
55
        }
56
      }
57
    },
58
    methods: {
59
      init (id) {
60
        this.dataForm.id = id || 0
61
        this.visible = true
62
        this.$nextTick(() => {
63
          this.$refs['dataForm'].resetFields()
64
          if (this.dataForm.id) {
65
            API.schedule.info(this.dataForm.id).then(({data}) => {
66
              if (data && data.code === 0) {
67
                this.dataForm.beanName = data.schedule.beanName
68
                this.dataForm.methodName = data.schedule.methodName
69
                this.dataForm.params = data.schedule.params
70
                this.dataForm.cronExpression = data.schedule.cronExpression
71
                this.dataForm.remark = data.schedule.remark
72
                this.dataForm.status = data.schedule.status
73
              }
74
            })
75
          }
76
        })
77
      },
78
      // 表单提交
79
      dataFormSubmit () {
80
        this.$refs['dataForm'].validate((valid) => {
81
          if (valid) {
82
            var params = {
83
              'jobId': this.dataForm.id || undefined,
84
              'beanName': this.dataForm.beanName,
85
              'methodName': this.dataForm.methodName,
86
              'params': this.dataForm.params,
87
              'cronExpression': this.dataForm.cronExpression,
88
              'remark': this.dataForm.remark,
89
              'status': !this.dataForm.id ? undefined : this.dataForm.status
90
            }
91
            var tick = !this.dataForm.id ? API.schedule.add(params) : API.schedule.update(params)
92
            tick.then(({data}) => {
93
              if (data && data.code === 0) {
94
                this.$message({
95
                  message: '操作成功',
96
                  type: 'success',
97
                  duration: 1500,
98
                  onClose: () => {
99
                    this.visible = false
100
                    this.$emit('refreshDataList')
101
                  }
102
                })
103
              } else {
104
                this.$message.error(data.msg)
105
              }
106
            })
107
          }
108
        })
109
      }
110
    }
111
  }
112
</script>

+ 28 - 115
src/views/schedule/index.vue

@ -11,7 +11,7 @@
11 11
        <el-button v-if="isAuth('sys:schedule:pause')" type="danger" @click="pauseHandle()" :disabled="dataListSelections.length <= 0">批量暂停</el-button>
12 12
        <el-button v-if="isAuth('sys:schedule:resume')" type="danger" @click="resumeHandle()" :disabled="dataListSelections.length <= 0">批量恢复</el-button>
13 13
        <el-button v-if="isAuth('sys:schedule:run')" type="danger" @click="runHandle()" :disabled="dataListSelections.length <= 0">批量立即执行</el-button>
14
        <el-button v-if="isAuth('sys:schedule:log')" type="success" @click="logDialogVisible = true">日志列表</el-button>
14
        <el-button v-if="isAuth('sys:schedule:log')" type="success" @click="logHandle()">日志列表</el-button>
15 15
      </el-form-item>
16 16
    </el-form>
17 17
    <el-table
@ -98,45 +98,15 @@
98 98
      layout="total, sizes, prev, pager, next, jumper">
99 99
    </el-pagination>
100 100
    <!-- 弹窗, 新增 / 修改 -->
101
    <el-dialog
102
      :title="!addOrUpdateForm.jobId ? '新增' : '修改'"
103
      :close-on-click-modal="false"
104
      :visible.sync="addOrUpdateDialogVisible">
105
      <el-form :model="addOrUpdateForm" :rules="addOrUpdateRule" ref="addOrUpdateForm" label-width="100px">
106
        <el-form-item label="bean名称" prop="beanName">
107
          <el-input v-model="addOrUpdateForm.beanName" placeholder="spring bean名称, 如: testTask"></el-input>
108
        </el-form-item>
109
        <el-form-item label="方法名称" prop="methodName">
110
          <el-input v-model="addOrUpdateForm.methodName" placeholder="方法名称"></el-input>
111
        </el-form-item>
112
        <el-form-item label="参数" prop="params">
113
          <el-input v-model="addOrUpdateForm.params" placeholder="参数"></el-input>
114
        </el-form-item>
115
        <el-form-item label="cron表达式" prop="cronExpression">
116
          <el-input v-model="addOrUpdateForm.cronExpression" placeholder="如: 0 0 12 * * ?"></el-input>
117
        </el-form-item>
118
        <el-form-item label="备注" prop="remark">
119
          <el-input v-model="addOrUpdateForm.remark" placeholder="备注"></el-input>
120
        </el-form-item>
121
      </el-form>
122
      <span slot="footer" class="dialog-footer">
123
        <el-button @click="addOrUpdateDialogVisible = false">取消</el-button>
124
        <el-button type="primary" @click="addOrUpdateFormSubmit()">确定</el-button>
125
      </span>
126
    </el-dialog>
101
    <add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></add-or-update>
127 102
    <!-- 弹窗, 日志列表 -->
128
    <el-dialog
129
      title="日志列表"
130
      :close-on-click-modal="false"
131
      :visible.sync="logDialogVisible"
132
      width="75%">
133
      <log></log>
134
    </el-dialog>
103
    <log v-if="logVisible" ref="log"></log>
135 104
  </div>
136 105
</template>
137 106
138 107
<script>
139 108
  import API from '@/api'
109
  import AddOrUpdate from './add-or-update'
140 110
  import Log from './log'
141 111
  export default {
142 112
    data () {
@ -150,31 +120,12 @@
150 120
        totalPage: 0,
151 121
        dataListLoading: false,
152 122
        dataListSelections: [],
153
        addOrUpdateDialogVisible: false,
154
        addOrUpdateForm: {
155
          jobId: 0,
156
          beanName: '',
157
          methodName: '',
158
          params: '',
159
          cronExpression: '',
160
          remark: '',
161
          status: 0
162
        },
163
        addOrUpdateRule: {
164
          beanName: [
165
            { required: true, message: '用户名不能为空', trigger: 'blur' }
166
          ],
167
          methodName: [
168
            { required: true, message: '方法名称不能为空', trigger: 'blur' }
169
          ],
170
          cronExpression: [
171
            { required: true, message: 'cron表达式不能为空', trigger: 'blur' }
172
          ]
173
        },
174
        logDialogVisible: false
123
        addOrUpdateVisible: false,
124
        logVisible: false
175 125
      }
176 126
    },
177 127
    components: {
128
      AddOrUpdate,
178 129
      Log
179 130
    },
180 131
    activated () {
@ -217,67 +168,22 @@
217 168
      },
218 169
      // 新增 / 修改
219 170
      addOrUpdateHandle (id) {
220
        this.addOrUpdateForm.jobId = id || 0
221
        this.addOrUpdateDialogVisible = true
171
        this.addOrUpdateVisible = true
222 172
        this.$nextTick(() => {
223
          this.$refs['addOrUpdateForm'].resetFields()
224
          if (this.addOrUpdateForm.jobId) {
225
            API.schedule.info(this.addOrUpdateForm.jobId).then(({data}) => {
226
              if (data && data.code === 0) {
227
                this.addOrUpdateForm.beanName = data.schedule.beanName
228
                this.addOrUpdateForm.methodName = data.schedule.methodName
229
                this.addOrUpdateForm.params = data.schedule.params
230
                this.addOrUpdateForm.cronExpression = data.schedule.cronExpression
231
                this.addOrUpdateForm.remark = data.schedule.remark
232
                this.addOrUpdateForm.status = data.schedule.status
233
              }
234
            })
235
          }
236
        })
237
      },
238
      // 新增 / 修改, 提交
239
      addOrUpdateFormSubmit () {
240
        this.$refs['addOrUpdateForm'].validate((valid) => {
241
          if (valid) {
242
            var params = {
243
              'jobId': this.addOrUpdateForm.jobId || undefined,
244
              'beanName': this.addOrUpdateForm.beanName,
245
              'methodName': this.addOrUpdateForm.methodName,
246
              'params': this.addOrUpdateForm.params,
247
              'cronExpression': this.addOrUpdateForm.cronExpression,
248
              'remark': this.addOrUpdateForm.remark,
249
              'status': this.addOrUpdateForm.jobId ? this.addOrUpdateForm.status : undefined
250
            }
251
            var tick = this.addOrUpdateForm.jobId ? API.schedule.update(params) : API.schedule.add(params)
252
            tick.then(({data}) => {
253
              if (data && data.code === 0) {
254
                this.$message({
255
                  message: '操作成功',
256
                  type: 'success',
257
                  duration: 1500,
258
                  onClose: () => {
259
                    this.addOrUpdateDialogVisible = false
260
                    this.getDataList()
261
                  }
262
                })
263
              } else {
264
                this.$message.error(data.msg)
265
              }
266
            })
267
          }
173
          this.$refs.addOrUpdate.init(id)
268 174
        })
269 175
      },
270 176
      // 删除
271 177
      deleteHandle (id) {
272
        var jobIds = id ? [id] : this.dataListSelections.map(item => {
178
        var ids = id ? [id] : this.dataListSelections.map(item => {
273 179
          return item.jobId
274 180
        })
275
        this.$confirm(`确定对[id=${jobIds.join(',')}]进行[${id ? '删除' : '批量删除'}]操作?`, '提示', {
181
        this.$confirm(`确定对[id=${ids.join(',')}]进行[${id ? '删除' : '批量删除'}]操作?`, '提示', {
276 182
          confirmButtonText: '确定',
277 183
          cancelButtonText: '取消',
278 184
          type: 'warning'
279 185
        }).then(() => {
280
          API.schedule.del(jobIds).then(({data}) => {
186
          API.schedule.del(ids).then(({data}) => {
281 187
            if (data && data.code === 0) {
282 188
              this.$message({
283 189
                message: '操作成功',
@ -295,15 +201,15 @@
295 201
      },
296 202
      // 暂停
297 203
      pauseHandle (id) {
298
        var jobIds = id ? [id] : this.dataListSelections.map(item => {
204
        var ids = id ? [id] : this.dataListSelections.map(item => {
299 205
          return item.jobId
300 206
        })
301
        this.$confirm(`确定对[id=${jobIds.join(',')}]进行[${id ? '暂停' : '批量暂停'}]操作?`, '提示', {
207
        this.$confirm(`确定对[id=${ids.join(',')}]进行[${id ? '暂停' : '批量暂停'}]操作?`, '提示', {
302 208
          confirmButtonText: '确定',
303 209
          cancelButtonText: '取消',
304 210
          type: 'warning'
305 211
        }).then(() => {
306
          API.schedule.pause(jobIds).then(({data}) => {
212
          API.schedule.pause(ids).then(({data}) => {
307 213
            if (data && data.code === 0) {
308 214
              this.$message({
309 215
                message: '操作成功',
@ -321,15 +227,15 @@
321 227
      },
322 228
      // 恢复
323 229
      resumeHandle (id) {
324
        var jobIds = id ? [id] : this.dataListSelections.map(item => {
230
        var ids = id ? [id] : this.dataListSelections.map(item => {
325 231
          return item.jobId
326 232
        })
327
        this.$confirm(`确定对[id=${jobIds.join(',')}]进行[${id ? '恢复' : '批量恢复'}]操作?`, '提示', {
233
        this.$confirm(`确定对[id=${ids.join(',')}]进行[${id ? '恢复' : '批量恢复'}]操作?`, '提示', {
328 234
          confirmButtonText: '确定',
329 235
          cancelButtonText: '取消',
330 236
          type: 'warning'
331 237
        }).then(() => {
332
          API.schedule.resume(jobIds).then(({data}) => {
238
          API.schedule.resume(ids).then(({data}) => {
333 239
            if (data && data.code === 0) {
334 240
              this.$message({
335 241
                message: '操作成功',
@ -347,15 +253,15 @@
347 253
      },
348 254
      // 立即执行
349 255
      runHandle (id) {
350
        var jobIds = id ? [id] : this.dataListSelections.map(item => {
256
        var ids = id ? [id] : this.dataListSelections.map(item => {
351 257
          return item.jobId
352 258
        })
353
        this.$confirm(`确定对[id=${jobIds.join(',')}]进行[${id ? '立即执行' : '批量立即执行'}]操作?`, '提示', {
259
        this.$confirm(`确定对[id=${ids.join(',')}]进行[${id ? '立即执行' : '批量立即执行'}]操作?`, '提示', {
354 260
          confirmButtonText: '确定',
355 261
          cancelButtonText: '取消',
356 262
          type: 'warning'
357 263
        }).then(() => {
358
          API.schedule.run(jobIds).then(({data}) => {
264
          API.schedule.run(ids).then(({data}) => {
359 265
            if (data && data.code === 0) {
360 266
              this.$message({
361 267
                message: '操作成功',
@ -370,6 +276,13 @@
370 276
            }
371 277
          })
372 278
        })
279
      },
280
      // 日志列表
281
      logHandle () {
282
        this.logVisible = true
283
        this.$nextTick(() => {
284
          this.$refs.log.init()
285
        })
373 286
      }
374 287
    }
375 288
  }

+ 15 - 9
src/views/schedule/log.vue

@ -1,8 +1,12 @@
1 1
<template>
2
  <div class="mod-schedule__log">
3
    <el-form :inline="true" :model="dataForm">
2
  <el-dialog
3
    title="日志列表"
4
    :close-on-click-modal="false"
5
    :visible.sync="visible"
6
    width="75%">
7
    <el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">
4 8
      <el-form-item>
5
        <el-input v-model="dataForm.jobId" placeholder="任务ID" clearable></el-input>
9
        <el-input v-model="dataForm.id" placeholder="任务ID" clearable></el-input>
6 10
      </el-form-item>
7 11
      <el-form-item>
8 12
        <el-button @click="getDataList()">查询</el-button>
@ -79,7 +83,7 @@
79 83
      :total="totalPage"
80 84
      layout="total, sizes, prev, pager, next, jumper">
81 85
    </el-pagination>
82
  </div>
86
  </el-dialog>
83 87
</template>
84 88
85 89
<script>
@ -87,8 +91,9 @@
87 91
  export default {
88 92
    data () {
89 93
      return {
94
        visible: false,
90 95
        dataForm: {
91
          jobId: ''
96
          id: ''
92 97
        },
93 98
        dataList: [],
94 99
        pageIndex: 1,
@ -97,17 +102,18 @@
97 102
        dataListLoading: false
98 103
      }
99 104
    },
100
    created () {
101
      this.getDataList()
102
    },
103 105
    methods: {
106
      init () {
107
        this.visible = true
108
        this.getDataList()
109
      },
104 110
      // 获取数据列表
105 111
      getDataList () {
106 112
        this.dataListLoading = true
107 113
        var params = {
108 114
          page: this.pageIndex,
109 115
          limit: this.pageSize,
110
          jobId: this.dataForm.jobId
116
          jobId: this.dataForm.id
111 117
        }
112 118
        API.log.scheduleList(params).then(({data}) => {
113 119
          if (data && data.code === 0) {

+ 5 - 6
src/views/user/add-or-update.vue

@ -33,7 +33,7 @@
33 33
    </el-form>
34 34
    <span slot="footer" class="dialog-footer">
35 35
      <el-button @click="visible = false">取消</el-button>
36
      <el-button type="primary" @click="addOrUpdateFormSubmit()">确定</el-button>
36
      <el-button type="primary" @click="dataFormSubmit()">确定</el-button>
37 37
    </span>
38 38
  </el-dialog>
39 39
</template>
@ -131,8 +131,8 @@
131 131
          }
132 132
        })
133 133
      },
134
      // 新增 / 修改, 提交
135
      addOrUpdateFormSubmit () {
134
      // 表单提交
135
      dataFormSubmit () {
136 136
        this.$refs['dataForm'].validate((valid) => {
137 137
          if (valid) {
138 138
            var params = {
@ -144,7 +144,7 @@
144 144
              'status': this.dataForm.status,
145 145
              'roleIdList': this.dataForm.roleIdList
146 146
            }
147
            var tick = this.dataForm.id ? API.user.update(params) : API.user.add(params)
147
            var tick = !this.dataForm.id ? API.user.add(params) : API.user.update(params)
148 148
            tick.then(({data}) => {
149 149
              if (data && data.code === 0) {
150 150
                this.$message({
@ -153,7 +153,7 @@
153 153
                  duration: 1500,
154 154
                  onClose: () => {
155 155
                    this.visible = false
156
                    this.getDataList()
156
                    this.$emit('refreshDataList')
157 157
                  }
158 158
                })
159 159
              } else {
@ -166,4 +166,3 @@
166 166
    }
167 167
  }
168 168
</script>
169