IndexTable.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <template>
  2. <j-editable-table
  3. ref="editableTable"
  4. :loading="loading"
  5. :columns="columns"
  6. :dataSource="dataSource"
  7. :rowNumber="true"
  8. :rowSelection="true"
  9. :actionButton="actionButton"
  10. :maxHeight="300"
  11. />
  12. </template>
  13. <script>
  14. import { FormTypes } from '@/utils/JEditableTableUtil'
  15. export default {
  16. name: 'IndexTable',
  17. components: {},
  18. props: {
  19. actionButton: {
  20. type: Boolean,
  21. default: true,
  22. required: false
  23. }
  24. },
  25. data: function () {
  26. return {
  27. loading: false,
  28. dataSource: [],
  29. columns: [{
  30. title: "索引名称",
  31. key: "indexName",
  32. width: "330px",
  33. type: FormTypes.input,
  34. defaultValue: "",
  35. placeholder: "请输入${title}",
  36. validateRules: [
  37. {
  38. required: true,
  39. message: "${title}不能为空"
  40. }
  41. ]
  42. }, {
  43. title: "索引栏位",
  44. key: "indexField",
  45. width: "330px",
  46. type: FormTypes.list_multi,
  47. options: [],
  48. defaultValue: "",
  49. placeholder: "请选择${title}",
  50. validateRules: [
  51. {
  52. required: true,
  53. message: "请选择${title}"
  54. }
  55. ],
  56. props: {
  57. notFoundContent: "没有什么好选择的"
  58. }
  59. }, {
  60. title: "索引类型",
  61. key: "indexType",
  62. width: "330px",
  63. type: FormTypes.select,
  64. options: [
  65. {
  66. title: "normal",
  67. value: "normal"
  68. },
  69. {
  70. title: "unique",
  71. value: "unique"
  72. }
  73. ],
  74. defaultValue: "normal",
  75. placeholder: "请选择${title}",
  76. validateRules: [
  77. {
  78. required: true,
  79. message: "请选择${title}"
  80. }
  81. ]
  82. }]
  83. }
  84. },
  85. methods: {
  86. syncTable(target) {
  87. target.$refs.editableTable.getValuesPromise(false)
  88. .then(values => {
  89. let arr = [];
  90. values.forEach(((item) => {
  91. if (item.dbFieldName) {
  92. arr.push({title: item.dbFieldName, value: item.dbFieldName})
  93. }
  94. }))
  95. this.columns[1].options = arr
  96. });
  97. }
  98. }
  99. }
  100. </script>
  101. <style scoped>
  102. </style>