index.hbs 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <!-- {{ title }} -->
  2. <template>
  3. <div class="app-container">
  4. <el-container>
  5. <el-main>
  6. <!-- 查询 -->
  7. <Conditions ref="conditions" :search-params.sync="searchParams" @search="search" />
  8. <!-- 表格 -->
  9. <Tables ref="dyTable" :search-params="searchParams" @rowOperation="rowOperation" />
  10. <!-- 弹窗 -->
  11. <Details ref="detail" />
  12. </el-main>
  13. </el-container>
  14. </div>
  15. </template>
  16. <script>
  17. import Tables from './components/table.vue'
  18. import Conditions from './components/conditions.vue'
  19. import Details from './components/detail.vue'
  20. export default {
  21. name: '{{ properCase name }}',
  22. components: { Conditions, Tables, Details },
  23. data() {
  24. return {
  25. global: {
  26. loading: true,
  27. },
  28. searchParams: {} // 查询(此处不赋值)
  29. }
  30. },
  31. provide() {
  32. return {
  33. global: this.global, // 全局数据对象
  34. reload: this.reload, // 重置
  35. refresh: this.refresh // 刷新
  36. }
  37. },
  38. created() {
  39. this.updateOptions()
  40. },
  41. methods: {
  42. /* common */
  43. reload() { // 重置搜索 回到第一页
  44. this.$refs.conditions.reset()
  45. },
  46. refresh() { // 不重置搜索 刷新当前页
  47. this.$refs.dyTable.getList(this.searchParams)
  48. },
  49. /* search -> table */
  50. search(params) { // 搜索
  51. this.searchParams = params
  52. this.$refs.dyTable.pageObj.current = 1
  53. this.$refs.dyTable.getList(this.searchParams)
  54. },
  55. /* table -> dialog */
  56. async rowOperation(row, idx, actionName, params = {}) {
  57. if (['add', 'edit', 'see'].includes(actionName)) { // 增改查统一
  58. this.$refs['detail'].showDialog({
  59. mode: actionName,
  60. formData: row || {},
  61. ...params // 自定义字段
  62. })
  63. } else if (actionName === 'delete') { // 删除
  64. const txt = `<p class="delText">您确定要删除该条记录吗?</p>`
  65. await this.$confirm(txt, '温馨提示', {
  66. dangerouslyUseHTMLString: true,
  67. type: 'warning'
  68. })
  69. try {
  70. this.loading = true
  71. // TODO: 删除
  72. // const res = await deleteInvitation({ id: row.id })
  73. if (res.success) {
  74. this.reload()
  75. }
  76. } finally {
  77. this.loading = false
  78. }
  79. } else { // 表格其它操作
  80. this.$refs[actionName].showDialog({
  81. formData: row || {},
  82. ...params // 自定义字段
  83. })
  84. }
  85. },
  86. updateOptions() {
  87. }
  88. }
  89. }
  90. </script>
  91. <style lang="scss" scoped>
  92. </style>