dydataset-updata.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  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="100px">
  7. <el-form-item label="数据集名称" prop="datasetName">
  8. <el-input v-model="dataForm.datasetName" placeholder="数据集名称, 如: testTask"></el-input>
  9. </el-form-item>
  10. <el-form-item label="分类" prop="params">
  11. <!-- <el-input v-model="dataForm.params" placeholder="参数"></el-input>-->
  12. <el-select v-model="dataForm.params" placeholder="类别" >
  13. <el-option v-for="data in dataForm.classification" :key="data.categoryId" :label="data.categoryName" :value="data.categoryId">
  14. </el-option>
  15. </el-select>
  16. </el-form-item>
  17. <el-form-item label="cron表达式" prop="cronExpression">
  18. <el-input v-model="dataForm.cronExpression" placeholder="如: 0 0 12 * * ?"></el-input>
  19. </el-form-item>
  20. <el-form-item label="备注" prop="remark">
  21. <el-input v-model="dataForm.remark" placeholder="备注"></el-input>
  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. <script>
  31. import { Message } from "element-ui"
  32. import { MessageBox } from 'element-ui'
  33. export default {
  34. data () {
  35. return {
  36. visible: false,
  37. dataForm: {
  38. id: 0,
  39. datasetName: '',
  40. params: '',
  41. classification: '',
  42. cronExpression: '',
  43. remark: '',
  44. status: 0
  45. },
  46. dataRule: {
  47. datasetName: [
  48. { required: true, message: '用户名不能为空', trigger: 'blur' }
  49. ],
  50. cronExpression: [
  51. { required: true, message: 'cron表达式不能为空', trigger: 'blur' }
  52. ]
  53. }
  54. }
  55. },
  56. methods: {
  57. init (info) {
  58. // console.log(info)
  59. this.dataForm.datasetName = info.datasetName
  60. this.dataForm.params = info.categoryId
  61. this.dataForm.cronExpression = info.cronExpression
  62. this.dataForm.remark = info.remark
  63. this.dataForm.status = info.status
  64. this.dataForm.id = info.datasetId
  65. this.dataForm.classification = info.classification
  66. this.visible = true
  67. // this.dataForm.id = id || 0
  68. // this.visible = true
  69. // this.$nextTick(() => {
  70. // this.$refs['dataForm'].resetFields()
  71. // if (this.dataForm.id) {
  72. // this.$http({
  73. // url: this.$http.adornUrl(`/sys/schedule/info/${this.dataForm.id}`),
  74. // method: 'get',
  75. // params: this.$http.adornParams()
  76. // }).then(({data}) => {
  77. // if (data && data.code === 0) {
  78. // this.dataForm.beanName = data.schedule.beanName
  79. // this.dataForm.params = data.schedule.params
  80. // this.dataForm.cronExpression = data.schedule.cronExpression
  81. // this.dataForm.remark = data.schedule.remark
  82. // this.dataForm.status = data.schedule.status
  83. // }
  84. // })
  85. // }
  86. // })
  87. },
  88. // 表单提交
  89. dataFormSubmit () {
  90. // console.log(this.dataForm.params)
  91. this.$refs['dataForm'].validate((valid) => {
  92. if (valid) {
  93. this.visible = false
  94. MessageBox.confirm(`确定保存修改?`, '提示', {
  95. confirmButtonText: '确定',
  96. cancelButtonText: '取消',
  97. type: 'warning'
  98. }).then(() => {
  99. this.$http({
  100. url: this.$http.adornUrl(`/sys/schedule/update`),
  101. method: 'post',
  102. data: this.$http.adornData({
  103. 'datasetId': this.dataForm.id || undefined,
  104. 'datasetName': this.dataForm.datasetName,
  105. 'categoryId': this.dataForm.params, // 分类对应的ID
  106. 'cronExpression': this.dataForm.cronExpression,
  107. 'remark': this.dataForm.remark
  108. })
  109. }).then(({data}) => {
  110. if (data && data.code === 0) {
  111. Message({
  112. message: '操作成功',
  113. type: 'success',
  114. duration: 1500,
  115. onClose: () => {
  116. this.visible = false
  117. this.$emit('refreshDataList')
  118. }
  119. })
  120. } else {
  121. Message.error(data.msg)
  122. }
  123. })
  124. }).catch(() => {
  125. this.visible=true
  126. })
  127. }
  128. })
  129. }
  130. }
  131. }
  132. </script>