device-page.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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-click="rowClick"
  11. @search-change="searchChange"
  12. @search-reset="resetChange"
  13. @size-change="dataList"
  14. @current-change="dataList"
  15. >
  16. </avue-crud>
  17. </div>
  18. </template>
  19. <script setup>
  20. import { ref } from "vue";
  21. import { useCrud } from "@/hooks/userCrud";
  22. import { useCommonStoreHook } from "@/store";
  23. import dictDataUtil from "@/common/configs/dictDataUtil";
  24. const { isShowTable, tableType } = toRefs(useCommonStoreHook());
  25. const test = () => {
  26. isShowTable.value = true;
  27. tableType.value = tableType.value == 1 ? 2 : 1;
  28. };
  29. // 传入一个url,后面不带/
  30. const { form, data, option, search, page, toDeleteIds, Methords, Utils } =
  31. useCrud({
  32. src: "/api/v1/device",
  33. });
  34. const { dataList, createRow, updateRow, deleteRow, searchChange, resetChange } = Methords; //增删改查
  35. const { selectionChange, multipleDelete } = Methords; //选中和批量删除事件
  36. const { checkBtnPerm, downloadTemplate } = Utils; //按钮权限等工具
  37. const crudRef = ref(null); //crudRef.value 获取avue-crud对象
  38. const emit = defineEmits(["deviceInfo"])
  39. const rowClick = (row)=>{
  40. emit("deviceInfo", row)
  41. }
  42. // 设置表格列或者其他自定义的option
  43. option.value = Object.assign(option.value, {
  44. delBtn: false,
  45. selection: false,
  46. search: false,
  47. editBtn: false,
  48. addBtn: false,
  49. viewBtn: false,
  50. menu: false,
  51. column: [
  52. {
  53. label: "设备编号",
  54. prop: "deviceNo",
  55. search: true,
  56. width: '120',
  57. rules: [
  58. {
  59. required: true,
  60. message: "设备编号不能为空",
  61. trigger: "trigger",
  62. },
  63. ],
  64. },
  65. {
  66. label: "设备名称",
  67. prop: "deviceName",
  68. search: true,
  69. width: '120',
  70. rules: [
  71. {
  72. required: true,
  73. message: "设备名称不能为空",
  74. trigger: "trigger",
  75. },
  76. ],
  77. },
  78. {
  79. label: "设备类型",
  80. prop: "deviceType",
  81. type: "select",
  82. search: true,
  83. width: '100',
  84. dicUrl:
  85. dictDataUtil.request_url +
  86. dictDataUtil.TYPE_CODE.device_type,
  87. props: {
  88. label: "dictLabel",
  89. value: "dictValue",
  90. },
  91. },
  92. {
  93. label: "负责人",
  94. width: '100',
  95. prop: "head",
  96. },
  97. {
  98. label: "设备位置",
  99. width: '150',
  100. prop: "devicePosition",
  101. },
  102. {
  103. label: "规格",
  104. width: '150',
  105. prop: "specifications",
  106. },
  107. {
  108. label: "品牌",
  109. width: '150',
  110. prop: "brand",
  111. },
  112. ],
  113. });
  114. onMounted(() => {
  115. dataList();
  116. });
  117. </script>