plm前端
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.

136 lines
4.3 KiB

2 years ago
  1. <template>
  2. <el-dialog
  3. width="285px"
  4. :title="!dataForm.id ? buttons.add :buttons.edit"
  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="buttons.paramKey || '参数名'" prop="paramKey">
  10. <el-input v-model="dataForm.paramKey" style="width: 150px;" placeholder="参数名"></el-input>
  11. </el-form-item>
  12. <el-form-item :label="buttons.paramValue || '参数值'" prop="paramValue">
  13. <el-input v-model="dataForm.paramValue" style="width: 150px;" placeholder="参数值"></el-input>
  14. </el-form-item>
  15. <el-form-item :label="buttons.remark || '备注'" prop="remark">
  16. <el-input v-model="dataForm.remark" style="width: 150px;" placeholder="备注"></el-input>
  17. </el-form-item>
  18. <el-form-item :label="buttons.status || '状态'" size="mini" prop="status">
  19. <el-radio-group v-model="dataForm.status">
  20. <el-radio :label="0">{{ buttons.disable || '禁用' }}</el-radio>
  21. <el-radio :label="1">{{ buttons.normal || '正常' }}</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()">{{ buttons.submit || '确定' }}</el-button>
  27. <el-button type="primary" @click="visible = false">{{ buttons.close || '关闭' }}</el-button>
  28. </span>
  29. </el-dialog>
  30. </template>
  31. <script>
  32. import {
  33. searchFunctionButtonList,
  34. } from "@/api/sysLanguage.js"
  35. export default {
  36. data() {
  37. return {
  38. visible: false,
  39. dataForm: {
  40. id: 0,
  41. paramKey: '',
  42. paramValue: '',
  43. remark: '',
  44. status: ''
  45. },
  46. dataRule: {
  47. paramKey: [
  48. {required: true, message: '参数名不能为空', trigger: 'blur'}
  49. ],
  50. paramValue: [
  51. {required: true, message: '参数值不能为空', trigger: 'blur'}
  52. ]
  53. },
  54. buttons: {
  55. close: '关闭',
  56. submit: '确定',
  57. add: '添加',
  58. edit: '编辑',
  59. delete: '删除',
  60. paramKey: '参数名',
  61. paramValue: '参数值',
  62. remark: '备注',
  63. disable: '禁用',
  64. normal: '正常',
  65. status: '状态'
  66. },
  67. }
  68. },
  69. methods: {
  70. // 获取button的词典
  71. getFunctionButtonList() {
  72. let queryButton = {
  73. functionId: this.$route.meta.menuId,
  74. tableId: '*',
  75. languageCode: this.$i18n.locale,
  76. objectType: 'button'
  77. }
  78. searchFunctionButtonList(queryButton).then(({data}) => {
  79. if (data.code == 0 && data.data) {
  80. this.buttons = data.data
  81. }
  82. })
  83. },
  84. init(id) {
  85. this.dataForm.id = id || 0
  86. this.visible = true
  87. this.$nextTick(() => {
  88. this.$refs['dataForm'].resetFields()
  89. if (this.dataForm.id) {
  90. this.$http({
  91. url: this.$http.adornUrl(`/sys/config/info/${this.dataForm.id}`),
  92. method: 'get',
  93. params: this.$http.adornParams()
  94. }).then(({data}) => {
  95. if (data && data.code === 0) {
  96. this.dataForm.paramKey = data.config.paramKey
  97. this.dataForm.paramValue = data.config.paramValue
  98. this.dataForm.remark = data.config.remark
  99. }
  100. })
  101. }
  102. })
  103. },
  104. // 表单提交
  105. dataFormSubmit() {
  106. this.$refs['dataForm'].validate((valid) => {
  107. if (valid) {
  108. this.$http({
  109. url: this.$http.adornUrl(`/sys/config/${!this.dataForm.id ? 'save' : 'update'}`),
  110. method: 'post',
  111. data: this.$http.adornData({
  112. 'id': this.dataForm.id || undefined,
  113. 'paramKey': this.dataForm.paramKey,
  114. 'paramValue': this.dataForm.paramValue,
  115. 'remark': this.dataForm.remark,
  116. 'status': this.dataForm.status
  117. })
  118. }).then(({data}) => {
  119. if (data && data.code === 0) {
  120. this.$message.success('操作成功')
  121. this.visible = false
  122. this.$emit('refreshDataList')
  123. } else {
  124. this.$message.error(data.msg)
  125. }
  126. })
  127. }
  128. })
  129. }
  130. }, created() {
  131. this.getFunctionButtonList()
  132. }
  133. }
  134. </script>