index.hbs 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <template>
  2. <div class="default-main" >
  3. <el-row :gutter="20">
  4. <el-col :span="24" :lg="24" :xl="24" :md="24" :xs="24" :sm="24">
  5. <el-card class="el-card is-hover-shadow" header="职务列表">
  6. <!-- style="height:calc(100vh - 107px);"-->
  7. <el-row>
  8. <el-col :span="24">
  9. <!-- 表格顶部菜单 -->
  10. <TableHeader :buttons="['refresh', 'add', 'edit', 'delete']" quick-search-placeholder="通过职务名称模糊搜索"
  11. @action="baTable.onTableHeaderAction" />
  12. <Table @action="baTable.onTableAction" />
  13. </el-col>
  14. <!-- 表单 -->
  15. <PopupForm ref="formRef" />
  16. </el-row>
  17. </el-card>
  18. </el-col>
  19. </el-row>
  20. </div>
  21. </template>
  22. <script lang="ts" setup>
  23. import { provide, ref, reactive, toRefs, onMounted, watch } from 'vue'
  24. import baTableClass from '/@/utils/baTable'
  25. import Table from '/@/components/table/index.vue'
  26. import TableHeader from '/@/components/table/header/index.vue'
  27. import PopupForm from './popupForm.vue'
  28. import { sysPos } from '/@/api/controllerUrls'
  29. import { defaultOptButtons } from '/@/components/table'
  30. import { baTableApi } from '/@/api/common'
  31. import { ElForm } from 'element-plus'
  32. const baTable = new baTableClass(
  33. new baTableApi(sysPos),
  34. {
  35. column: [
  36. { type: 'selection', align: 'center', operator: false },
  37. { label: '名称', prop: 'name', align: 'center', operator: false },
  38. { label: '唯一编码', prop: 'code', align: 'center', operator: false },
  39. { label: '排序', prop: 'sort', align: 'center', operator: false },
  40. { label: '备注', prop: 'remark', align: 'center', operator: false },
  41. {
  42. label: '操作',
  43. align: 'center',
  44. width: '100',
  45. render: 'buttons',
  46. buttons: defaultOptButtons(['edit', 'delete']),
  47. operator: false,
  48. },
  49. ],
  50. dblClickNotEditColumn: [undefined, 'status'],
  51. },
  52. {
  53. defaultItems: {},
  54. },
  55. {
  56. // 提交前
  57. onSubmit: (params: { formEl: InstanceType<typeof ElForm> }) => {
  58. var items = cloneDeep(baTable.form.items!)
  59. // 表单验证通过后执行的api请求操作
  60. let submitCallback = () => {
  61. baTable.form.submitLoading = true
  62. baTable.api
  63. .postData(baTable.form.operate!, items)
  64. .then((res) => {
  65. baTable.onTableHeaderAction('refresh', {})
  66. baTable.form.submitLoading = false
  67. baTable.form.operateIds?.shift()
  68. if (baTable.form.operateIds?.length! > 0) {
  69. baTable.toggleForm('edit', baTable.form.operateIds)
  70. } else {
  71. baTable.toggleForm()
  72. }
  73. baTable.runAfter('onSubmit', { res })
  74. })
  75. .catch((err) => {
  76. baTable.form.submitLoading = false
  77. })
  78. }
  79. if (params.formEl) {
  80. baTable.form.ref = params.formEl
  81. params.formEl.validate((valid) => {
  82. if (valid) {
  83. submitCallback()
  84. }
  85. })
  86. } else {
  87. submitCallback()
  88. }
  89. return false
  90. },
  91. }
  92. )
  93. provide('baTable', baTable)
  94. onMounted(() => {
  95. baTable.mount()
  96. baTable.getIndex()
  97. })
  98. </script>
  99. <script lang="ts">
  100. import { defineComponent } from 'vue'
  101. import { cloneDeep, String } from 'lodash'
  102. export default defineComponent({
  103. name: 'organizational/post',
  104. })
  105. </script>
  106. <style scoped>
  107. </style>