index.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. <route lang="yaml">
  2. meta:
  3. enabled: false
  4. </route>
  5. <script lang="ts" setup name="BizObjectMappingList">
  6. import { ElMessage } from 'element-plus'
  7. import {
  8. deleteObjectMappingById,
  9. getObjectAttrListById,
  10. } from '@/api/biz/bizObjectMappingApi'
  11. const props = withDefaults(defineProps<{
  12. bizId: number
  13. objectId: number
  14. }>(), {
  15. bizId: 0,
  16. objectId: 0,
  17. })
  18. // 数据
  19. const state = reactive({
  20. title: '',
  21. dialogVisible: false,
  22. loading: false,
  23. search: {
  24. keywords: '',
  25. },
  26. conditions: {
  27. bizId: props.bizId,
  28. objectId: props.objectId,
  29. },
  30. dataList: [],
  31. actionType: 1,
  32. })
  33. // 查询数据
  34. const getData = async () => {
  35. state.loading = true
  36. const { bizId, objectId } = state.conditions
  37. const { data } = await getObjectAttrListById(bizId, objectId)
  38. state.loading = false
  39. state.dataList = data
  40. }
  41. const objectMappingTableRef = ref()
  42. function onObjectMappingAdd() {
  43. state.actionType = 2
  44. }
  45. async function onObjectMappingDelete(row: any) {
  46. const { bizId, objectId } = state.conditions
  47. const mappingId = row.mappingId
  48. await deleteObjectMappingById(bizId, objectId, mappingId)
  49. ElMessage.success('删除成功')
  50. }
  51. onMounted(() => {
  52. getData()
  53. nextTick(() => {
  54. })
  55. })
  56. </script>
  57. <template>
  58. <div class="absolute-container">
  59. <div class="container">
  60. <tool-bar>
  61. <template #left>
  62. <h4>模型映射</h4>
  63. </template>
  64. <template #right>
  65. <el-input v-model="state.search.keywords" placeholder="请输入关键词筛选" clearable style="width: 200px;" />
  66. <el-button style="margin-left:10px" @click="getData">
  67. <template #icon>
  68. <el-icon>
  69. <svg-icon name="i-ep:search" />
  70. </el-icon>
  71. </template>
  72. </el-button>
  73. <el-button type="default" @click="onObjectMappingAdd">
  74. <template #icon>
  75. <el-icon>
  76. <svg-icon name="i-ep:plus" />
  77. </el-icon>
  78. </template>
  79. </el-button>
  80. </template>
  81. </tool-bar>
  82. <el-table ref="objectMappingTableRef" :data="state.dataList" class="list-table" size="small" border stripe highlight-current-row>
  83. <el-table-column type="index" label="序号" header-align="center" align="center" width="70" />
  84. <el-table-column label="模型" header-align="center" align="center" width="300">
  85. <template #default="scope">
  86. <span>{{ scope.row.mappingModelTitle }}</span>
  87. </template>
  88. </el-table-column>
  89. <el-table-column label="对象" header-align="center" align="center" width="300">
  90. <template #default="scope">
  91. <span>{{ scope.row.mappingObjectTitle }}</span>
  92. </template>
  93. </el-table-column>
  94. <el-table-column label="映射代码" header-align="center" align="center">
  95. <template #default="scope">
  96. <el-input v-if="scope.row.isEdit" v-model="scope.row.mappingCode" size="small" />
  97. <span v-else>{{ scope.row.mappingCode }}</span>
  98. </template>
  99. </el-table-column>
  100. <el-table-column label="操作" align="center">
  101. <template #default="scope">
  102. <el-popconfirm title="是否要删除此行?" style="margin-left: 10px;" @confirm="onObjectMappingDelete(scope.row)">
  103. <template #reference>
  104. <el-button type="danger" plain size="small">
  105. 删除
  106. </el-button>
  107. </template>
  108. </el-popconfirm>
  109. </template>
  110. </el-table-column>
  111. </el-table>
  112. </div>
  113. </div>
  114. </template>
  115. <style lang="scss" scoped>
  116. .page-main {
  117. :deep(.el-table) {
  118. height: 100%;
  119. .el-table__row {
  120. .index {
  121. display: inline-block;
  122. }
  123. .delete {
  124. display: none;
  125. }
  126. &:hover {
  127. .index {
  128. display: none;
  129. }
  130. .delete {
  131. display: inline-block;
  132. }
  133. }
  134. .el-tag.sortable,
  135. .el-tag.sortable .el-icon {
  136. cursor: s-resize;
  137. }
  138. }
  139. }
  140. h4{
  141. padding: 0;
  142. margin: 0;
  143. }
  144. }
  145. </style>