You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

109 lines
3.4 KiB

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