index.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <template>
  2. <div class="default-main ">
  3. <el-alert class="ba-table-alert" v-if="baTable.table.remark" :title="baTable.table.remark" type="info"
  4. show-icon/>
  5. <el-row>
  6. <el-col :span="24">
  7. <!-- 表格顶部菜单 -->
  8. <TableHeader :buttons="['refresh', 'add', 'edit', 'delete', 'comSearch']"
  9. quick-search-placeholder="通过标题模糊搜索"
  10. @action="baTable.onTableHeaderAction"/>
  11. <!-- 表格 -->
  12. <!-- 要使用`el-table`组件原有的属性,直接加在Table标签上即可 -->
  13. <Table @action="baTable.onTableAction">
  14. </Table>
  15. </el-col>
  16. </el-row>
  17. <!-- 表单 -->
  18. <PopupForm ref="formRef"/>
  19. </div>
  20. </template>
  21. <script setup lang="ts">
  22. import {ref, onMounted, provide} from 'vue'
  23. import {map} from '/@/api/controllerUrls'
  24. import Table from '/@/components/table/index.vue'
  25. import TableHeader from '/@/components/table/header/index.vue'
  26. import {defaultOptButtons} from '/@/components/table'
  27. import PopupForm from './popupForm.vue'
  28. import {baTableApi} from '/@/api/common'
  29. import baTableClass from '/@/utils/baTable'
  30. //重写baTableClass类,在获取编辑行数据的同时,将数据抛出,用于进行后续数据请求
  31. class newBaTable extends baTableClass{
  32. public mapInfo = ref({})
  33. requestEdit = (id: string) => {
  34. if (this.runBefore('requestEdit', {id}) === false) return
  35. this.form.loading = true
  36. this.form.items = {}
  37. return this.api
  38. .edit({
  39. id: id,
  40. })
  41. .then((res) => {
  42. this.form.loading = false
  43. // this.form.items = Object.assign(res.data.row, this.form.defaultItems)
  44. this.form.items = res.data.row
  45. if (res.data.row.hasOwnProperty('status')) {
  46. this.form.items!.status = res.data.row.status + ''
  47. }
  48. this.mapInfo.value = res.data.row
  49. this.runAfter('requestEdit', {res})
  50. })
  51. }
  52. }
  53. const baTable = new newBaTable(
  54. new baTableApi(map),
  55. {
  56. dblClickNotEditColumn: [undefined, 'status'],
  57. column: [
  58. {type: "selection", align: "center", operator: false },
  59. { label: "所在区县", prop: "districtName", align: "left", "min-width": "150", operator: "LIKE" },
  60. { label: "小区名称", prop: "communityName", align: "left", "min-width": "150", operator: "LIKE" },
  61. { label: "地图名称", prop: "mapName", align: "left", "min-width": "150", operator: "LIKE" },
  62. { label: "关联楼号", prop: "buildingName", align: "left", "min-width": "150", operator: "LIKE" },
  63. { label: "创建人", prop: "creatorName", align: "center", width: "120", operator: false },
  64. { label: "创建时间", prop: "createTime", align: "center", width: "180", operator: false },
  65. {
  66. label: '操作',
  67. align: 'center',
  68. width: '160',
  69. render: 'buttons',
  70. buttons: defaultOptButtons(),
  71. operator: false
  72. },
  73. ],
  74. },
  75. {
  76. defaultItems: {},
  77. },
  78. {
  79. // 获得编辑数据后
  80. requestEdit: () => {
  81. if (baTable.form.items && !baTable.form.items.icon) baTable.form.items.icon = 'el-icon-Minus'
  82. },
  83. },
  84. )
  85. provide('baTable', baTable)
  86. onMounted(() => {
  87. baTable.mount()
  88. baTable.getIndex()
  89. })
  90. </script>
  91. <style scoped lang="scss"></style>