index.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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. @search-change="searchChange"
  14. @search-reset="resetChange"
  15. @size-change="dataList"
  16. @current-change="dataList"
  17. @selection-change="selectionChange1"
  18. >
  19. <template #menu="{ size }">
  20. <el-button
  21. icon="el-icon-setting"
  22. text
  23. type="primary"
  24. :size="size"
  25. >编辑</el-button
  26. >
  27. </template>
  28. </avue-crud>
  29. </div>
  30. </template>
  31. <script setup>
  32. import { ref, getCurrentInstance } from "vue";
  33. import { useCrud } from "@/hooks/userCrud";
  34. import { useCommonStoreHook } from "@/store";
  35. import dictDataUtil from "@/common/configs/dictDataUtil";
  36. const { isShowTable, tableType } = toRefs(useCommonStoreHook());
  37. const test = () => {
  38. isShowTable.value = true;
  39. tableType.value = tableType.value == 1 ? 2 : 1;
  40. };
  41. const clickRows = ref([]);
  42. // 传入一个url,后面不带/
  43. const { form, data, option, search, page, toDeleteIds, Methords, Utils } =
  44. useCrud({
  45. src: "/api/v1/definition",
  46. });
  47. const { dataList, createRow, updateRow, deleteRow, searchChange, resetChange } =
  48. Methords; //增删改查
  49. const { selectionChange, multipleDelete } = Methords; //选中和批量删除事件
  50. const { checkBtnPerm, downloadTemplate, exportData } = Utils; //按钮权限等工具
  51. const crudRef = ref(null); //crudRef.value 获取avue-crud对象
  52. // 设置表格列或者其他自定义的option
  53. option.value = Object.assign(option.value, {
  54. searchEnter: true,
  55. delBtn: false,
  56. selection: false,
  57. addBtn: false,
  58. editBtn:false,
  59. viewBtn:false,
  60. column: [
  61. /*{
  62. label: "流程编码",
  63. prop: "flowCode",
  64. },*/
  65. {
  66. label: "流程名称",
  67. prop: "flowName",
  68. search: true,
  69. },
  70. {
  71. label: "流程类型",
  72. prop: "flowType",
  73. type: "select",
  74. search: true,
  75. dicUrl: dictDataUtil.request_url + dictDataUtil.TYPE_CODE.flow_type,
  76. props: {
  77. label: "dictLabel",
  78. value: "dictValue",
  79. }
  80. },
  81. {
  82. label: "流程版本",
  83. prop: "flowVersion",
  84. html: true,
  85. formatter: (val) => {
  86. return '<b class="el-tag el-tag--success el-tag--light">V'+val.flowVersion+'</b>';
  87. },
  88. },
  89. {
  90. label: "状态",
  91. prop: "enable",
  92. type: "select",
  93. search: true,
  94. dicData: [{"label": "启用","value": "0"},{"label": "禁用","value": "1"}],
  95. html: true,
  96. formatter: (val) => {
  97. if(val.enable === '0'){
  98. return '<b class="el-tag el-tag--success el-tag--light">启用</b>';
  99. }else{
  100. return '<b class="el-tag el-tag--info el-tag--light">禁用</b>';
  101. }
  102. },
  103. },
  104. {
  105. label: "创建时间",
  106. prop: "created",
  107. display: false,
  108. },
  109. {
  110. label: "创建人",
  111. prop: "creator",
  112. display: false,
  113. },
  114. ],
  115. });
  116. onMounted(() => {
  117. // console.log("crudRef", crudRef)
  118. dataList();
  119. });
  120. </script>