index.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  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. :table-loading="loading"
  10. v-model:page="page"
  11. @row-save="createRow"
  12. @row-update="updateRow"
  13. @row-del="deleteRow"
  14. @search-change="searchPage"
  15. @search-reset="resetChange"
  16. @size-change="dataList"
  17. @current-change="dataList"
  18. @selection-change="selectionChange"
  19. >
  20. </avue-crud>
  21. </div>
  22. </template>
  23. <script setup>
  24. import { ref, getCurrentInstance } from "vue";
  25. import { useCrud } from "@/hooks/userCrud";
  26. import buttonPermission from "@/common/configs/buttonPermission";
  27. import {queryDeviceList,queryTypeAliasList} from "@/api/device";
  28. import { useCommonStoreHook } from "@/store";
  29. const { isShowTable, tableType } = toRefs(useCommonStoreHook());
  30. const loading = ref(false);
  31. const test = () => {
  32. isShowTable.value = true;
  33. tableType.value = tableType.value == 1 ? 2 : 1;
  34. };
  35. // 传入一个url,后面不带/
  36. const { form, data, option, search, page, toDeleteIds, Methords, Utils } =
  37. useCrud({
  38. src: "/api/v1/device/data",
  39. });
  40. const { dataList, createRow, updateRow, deleteRow, searchChange, resetChange } = Methords; //增删改查
  41. const { selectionChange, multipleDelete } = Methords; //选中和批量删除事件
  42. const { checkBtnPerm, downloadTemplate, exportData } = Utils; //按钮权限等工具
  43. const crudRef = ref(null); //crudRef.value 获取avue-crud对象
  44. const deviceList = ref([])
  45. const searchPage = (params, done) =>{
  46. if(!search.value.deviceNo){
  47. ElMessage.warning("请先选择设备进行查询");
  48. done()
  49. return;
  50. }
  51. queryTypeAliasList({deviceNo: search.value.deviceNo}).then((data)=>{
  52. if(data.data){
  53. option.value.column = [{
  54. label: "设备编号",
  55. prop: "deviceNo",
  56. search: true,
  57. hide: true,
  58. type: "select",
  59. dicData: deviceList,
  60. props: { label: "deviceNo", value: "deviceNo", },
  61. },
  62. {
  63. label: "任务信息",
  64. prop: "taskNo",
  65. search: true,
  66. hide: true,
  67. },
  68. /*{
  69. label: "序列号",
  70. prop: "seqNo",
  71. search: true,
  72. hide: true,
  73. },*/
  74. {
  75. label: "采集时间",
  76. prop: "ts",
  77. search: true,
  78. hide: true,
  79. type: 'datetimerange',
  80. format: 'YYYY-MM-DD HH:mm:ss',
  81. valueFormat: 'YYYY-MM-DD HH:mm:ss',
  82. searchRange: true,
  83. startPlaceholder: '开始范围',
  84. endPlaceholder: '结束范围',
  85. }, {
  86. label: "采集时间",
  87. prop: "ts",
  88. },
  89. ]
  90. data.data.forEach(item=>{
  91. option.value.column.push({
  92. label: item.filedLabel,
  93. prop: item.alias,
  94. overHidden: true,
  95. })
  96. })
  97. }
  98. })
  99. if(search.value.ts){
  100. search.value.startTime = search.value.ts[0]
  101. search.value.endTime = search.value.ts[1]
  102. }
  103. dataList()
  104. done()
  105. }
  106. // 设置表格列或者其他自定义的option
  107. option.value = Object.assign(option.value, {
  108. delBtn: false,
  109. selection: false,
  110. index: false,
  111. addBtn: false,
  112. viewBtn: false,
  113. editBtn: false,
  114. menu: false,
  115. column: [{
  116. label: "设备编号",
  117. prop: "deviceNo",
  118. search: true,
  119. hide: true,
  120. type: "select",
  121. dicData: deviceList,
  122. props: { label: "deviceNo", value: "deviceNo", },
  123. },
  124. {
  125. label: "任务信息",
  126. prop: "taskNo",
  127. search: true,
  128. hide: true,
  129. },
  130. /* {
  131. label: "序列号",
  132. prop: "seqNo",
  133. search: true,
  134. hide: true,
  135. },*/
  136. {
  137. label: "采集时间",
  138. prop: "ts",
  139. search: true,
  140. hide: true,
  141. type: 'datetimerange',
  142. format: 'YYYY-MM-DD HH:mm:ss',
  143. valueFormat: 'YYYY-MM-DD HH:mm:ss',
  144. searchRange: true,
  145. startPlaceholder: '开始范围',
  146. endPlaceholder: '结束范围',
  147. }],
  148. });
  149. onMounted(() => {
  150. queryDeviceList({protocol: 1}).then((data)=>{
  151. deviceList.value = data.data
  152. })
  153. });
  154. </script>