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.

107 lines
2.7 KiB

2 years ago
  1. <template>
  2. <el-dialog
  3. width="255px"
  4. :title="buttons.language"
  5. :close-on-click-modal="false"
  6. :visible.sync="visible">
  7. <el-row v-for="(item,index) in dataList"
  8. :key="item.columnProp"
  9. :label="item.columnLabel"
  10. :prop="item.columnProp">
  11. <el-col :span="24">
  12. {{
  13. languageList[index].languageCode == item.languageCode ? languageList[index].languageName : item.languageCode
  14. }}
  15. <el-input v-model="item.languageValue" controls-position="right" style="display:inline"></el-input>
  16. </el-col>
  17. </el-row>
  18. <span slot="footer" class="dialog-footer">
  19. <el-button type="primary" @click="dataFormSubmit()"> {{ buttons.add }}</el-button>
  20. <el-button @click="visible = false" type="primary">{{ buttons.close }}</el-button>
  21. </span>
  22. </el-dialog>
  23. </template>
  24. <script>
  25. import {searchMenuLanguageById, saveMenuLanguage,} from '@/api/sysLanguageMenu.js'
  26. import {searchSysLanguage} from '@/api/sysLanguage.js'
  27. import {
  28. searchFunctionButtonList,
  29. } from "@/api/sysLanguage.js"
  30. export default {
  31. data() {
  32. return {
  33. visible: false,
  34. dataList: [],
  35. languageList: [],
  36. buttons: {
  37. add: '确认',
  38. close: '关闭',
  39. language: '语言'
  40. },
  41. }
  42. },
  43. methods: {
  44. // 获取button的词典
  45. getFunctionButtonList() {
  46. let queryButton = {
  47. functionId: this.$route.meta.menuId,
  48. tableId: '*',
  49. languageCode: this.$i18n.locale,
  50. objectType: 'button'
  51. }
  52. searchFunctionButtonList(queryButton).then(({data}) => {
  53. if (data.code == 0 && data.data) {
  54. this.buttons = data.data
  55. }
  56. })
  57. },
  58. async init(id) {
  59. this.visible = true
  60. await this.getLanguageList()
  61. let menu = {
  62. menuId: id
  63. }
  64. searchMenuLanguageById(menu).then(({data}) => {
  65. this.dataList = data.menuLanguageList
  66. })
  67. },
  68. // 获取数据列表
  69. getDataList() {
  70. this.dataListLoading = false
  71. },
  72. // 表单提交
  73. dataFormSubmit(val) {
  74. saveMenuLanguage(this.dataList).then(({data}) => {
  75. if (data.code == 0) {
  76. this.$message.success(data.msg)
  77. this.$emit('refreshDataList')
  78. this.visible = false
  79. } else {
  80. this.$message.error(data.msg)
  81. }
  82. })
  83. },
  84. // 获取多语言列表
  85. async getLanguageList() {
  86. await searchSysLanguage({languageCode: this.$i18n.locale}).then(({data}) => {
  87. this.languageList = data.rows
  88. })
  89. },
  90. },
  91. created() {
  92. this.getFunctionButtonList()
  93. },
  94. }
  95. </script>
  96. <style lang="scss">
  97. .el-form-item--mini.el-form-item, .el-form-item--small.el-form-item {
  98. margin-bottom: 5px;
  99. }
  100. </style>