device-page.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  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 props = defineProps({
  38. deviceType: {
  39. type: String,
  40. default: () => {
  41. return 0;
  42. }
  43. }
  44. })
  45. const crudRef = ref(null); //crudRef.value 获取avue-crud对象
  46. const emit = defineEmits(["deviceInfo"])
  47. const rowClick = (row)=>{
  48. emit("deviceInfo", row)
  49. }
  50. // 设置表格列或者其他自定义的option
  51. option.value = Object.assign(option.value, {
  52. delBtn: false,
  53. selection: false,
  54. search: false,
  55. editBtn: false,
  56. addBtn: false,
  57. viewBtn: false,
  58. menu: false,
  59. column: [
  60. {
  61. label: "资产编号",
  62. prop: "deviceNo",
  63. search: true,
  64. width: '120',
  65. rules: [
  66. {
  67. required: true,
  68. message: "设备编号不能为空",
  69. trigger: "trigger",
  70. },
  71. ],
  72. },
  73. {
  74. label: "设备名称",
  75. prop: "deviceName",
  76. search: true,
  77. width: '120',
  78. rules: [
  79. {
  80. required: true,
  81. message: "设备名称不能为空",
  82. trigger: "trigger",
  83. },
  84. ],
  85. },
  86. {
  87. label: "负责人",
  88. width: '100',
  89. prop: "head",
  90. },
  91. {
  92. label: "存放位置",
  93. width: '150',
  94. prop: "devicePosition",
  95. },
  96. {
  97. label: "型号",
  98. width: '150',
  99. prop: "specifications",
  100. },
  101. {
  102. label: "制造厂",
  103. width: '150',
  104. prop: "brand",
  105. },
  106. {
  107. label: "原值",
  108. prop: "originalValue",
  109. width: 100,
  110. overHidden: true,
  111. },
  112. {
  113. label: "出厂编号",
  114. prop: "serialNumber",
  115. width: 100,
  116. overHidden: true,
  117. },
  118. {
  119. label: "设备类型",
  120. prop: "deviceType",
  121. type: "select",
  122. search: true,
  123. width: '100',
  124. dicUrl:
  125. dictDataUtil.request_url +
  126. dictDataUtil.TYPE_CODE.device_type,
  127. props: {
  128. label: "dictLabel",
  129. value: "dictValue",
  130. },
  131. },
  132. ],
  133. });
  134. onMounted(() => {
  135. if(props.deviceType!=null){
  136. search.value.deviceType = props.deviceType;
  137. }
  138. dataList();
  139. });
  140. </script>