index.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <template>
  2. <div class="mainContentBox">
  3. <avue-crud
  4. ref="crudRef"
  5. v-model:search="search"
  6. v-model="form"
  7. :data="data"
  8. :option="option"
  9. v-model:page="page"
  10. @row-save="createRow"
  11. @row-update="updateRow"
  12. @row-del="deleteRow"
  13. @selection-change="selectionChange"
  14. >
  15. <template #menu-left="{ size }">
  16. <el-button
  17. :disabled="toDeleteIds.length < 1"
  18. type="danger"
  19. icon="el-icon-delete"
  20. :size="size"
  21. @click="multipleDelete"
  22. >删除</el-button
  23. >
  24. </template>
  25. </avue-crud>
  26. </div>
  27. </template>
  28. <script setup>
  29. import { ref, getCurrentInstance } from "vue";
  30. import { useCrud } from "@/hooks/userCrud";
  31. import ButtonPermKeys from "@/common/configs/buttonPermission";
  32. import { useCommonStoreHook } from "@/store";
  33. import dictDataUtil from "@/common/configs/dictDataUtil";
  34. const { isShowTable, tableType } = toRefs(useCommonStoreHook());
  35. const test = () => {
  36. isShowTable.value = true;
  37. tableType.value = tableType.value == 1 ? 2 : 1;
  38. };
  39. // 传入一个url,后面不带/
  40. const { form, data, option, search, page, toDeleteIds, Methords, Utils } =
  41. useCrud({
  42. src: "/api/v1/sys/alias",
  43. });
  44. const { dataList, createRow, updateRow, deleteRow } = Methords; //增删改查
  45. const { selectionChange, multipleDelete } = Methords; //选中和批量删除事件
  46. const { checkBtnPerm } = Utils; //按钮权限等工具
  47. // checkBtnPerm(ButtonPermKeys.PLAN.BTNS.order_add) :permission="permission"
  48. // const permission = reactive({
  49. // delBtn: checkPerm(buttonPermission.PLAN.BTNS.order_del),
  50. // addBtn: checkPerm(buttonPermission.PLAN.BTNS.order_add),
  51. // editBtn: checkPerm(buttonPermission.PLAN.BTNS.order_edit),
  52. // menu: true,
  53. // });
  54. const crudRef = ref(null); //crudRef.value 获取avue-crud对象
  55. // 设置表格列或者其他自定义的option
  56. option.value = Object.assign(option.value, {
  57. delBtn: false,
  58. selection: true,
  59. column: [
  60. {
  61. label: "所属模块",
  62. prop: "tableType",
  63. search: true,
  64. type: "select",
  65. dicUrl:
  66. dictDataUtil.request_url +
  67. dictDataUtil.EXPAND_FIELD_TABLE.expand_table_list,
  68. props: {
  69. label: "dictLabel",
  70. value: "dictValue",
  71. },
  72. },
  73. {
  74. label: "拓展字段",
  75. prop: "field",
  76. type: "select",
  77. dicUrl:
  78. dictDataUtil.request_url +
  79. dictDataUtil.EXPAND_FIELD_TABLE.expand_field_list,
  80. props: {
  81. label: "dictLabel",
  82. value: "dictValue",
  83. },
  84. },
  85. {
  86. label: "页面显示",
  87. prop: "label",
  88. },
  89. {
  90. label: "排序",
  91. prop: "fieldSort",
  92. },
  93. ],
  94. });
  95. onMounted(() => {
  96. // console.log("crudRef", crudRef)
  97. dataList();
  98. });
  99. </script>