record-page.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  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. @search-change="searchChange"
  11. @search-reset="resetChange"
  12. @size-change="dataList"
  13. @current-change="dataList"
  14. >
  15. </avue-crud>
  16. </div>
  17. </template>
  18. <script setup>
  19. import { ref,defineProps } from "vue";
  20. import { useCrud } from "@/hooks/userCrud";
  21. import { useCommonStoreHook } from "@/store";
  22. import dictDataUtil from "@/common/configs/dictDataUtil";
  23. const { isShowTable, tableType } = toRefs(useCommonStoreHook());
  24. const test = () => {
  25. isShowTable.value = true;
  26. tableType.value = tableType.value == 1 ? 2 : 1;
  27. };
  28. // 传入一个url,后面不带/
  29. const { form, data, option, search, page, toDeleteIds, Methords, Utils } =
  30. useCrud({
  31. src: "/api/v1/device/maintenanceRecord",
  32. });
  33. const { dataList, createRow, updateRow, deleteRow, searchChange, resetChange } = Methords; //增删改查
  34. const { selectionChange, multipleDelete } = Methords; //选中和批量删除事件
  35. const { checkBtnPerm, downloadTemplate } = Utils; //按钮权限等工具
  36. const mType = ref("-1")
  37. const crudRef = ref(null); //crudRef.value 获取avue-crud对象
  38. const props = defineProps({
  39. maintenance: {
  40. type: Object,
  41. default: () => {
  42. return {};
  43. }
  44. }
  45. })
  46. watch?.(
  47. () => props.maintenance,
  48. (newVal) => {
  49. search.value.maintenanceId = newVal.id
  50. mType.value = newVal.type
  51. handleOption()
  52. dataList()
  53. }
  54. );
  55. const handleOption =()=>{
  56. // 设置表格列或者其他自定义的option
  57. option.value = Object.assign(option.value, {
  58. delBtn: false,
  59. selection: false,
  60. search: false,
  61. editBtn: false,
  62. addBtn: false,
  63. viewBtn: false,
  64. menu: false,
  65. column: [
  66. /*{
  67. label: "设备类型",
  68. prop: "deviceType",
  69. type: "select",
  70. width: '100',
  71. dicUrl:
  72. dictDataUtil.request_url +
  73. dictDataUtil.TYPE_CODE.device_type,
  74. props: {
  75. label: "dictLabel",
  76. value: "dictValue",
  77. },
  78. },*/
  79. /* {
  80. label: "设备位置",
  81. width: '150',
  82. prop: "devicePosition",
  83. },*/
  84. /*{
  85. label: "维护类型",
  86. prop: "type",
  87. type: "select",
  88. editDisplay: false,
  89. dicData: [{label: '点检',value:'0'},{label: '保养',value:'1'}]
  90. },*/
  91. {
  92. label: mType.value === "1" ? "保养日期" : "点检时间",
  93. width: '180',
  94. format: 'YYYY-MM-DD',
  95. valueFormat: 'YYYY-MM-DD',
  96. prop: "maintenanceTime",
  97. },
  98. {
  99. label: mType.value === "1" ? "保养项目" : "点检内容",
  100. prop: "maintenanceContent",
  101. minRows: 2, //最小行/最小值
  102. maxlength: 512, //最大输入长度
  103. overHidden: true
  104. },
  105. {
  106. label: mType.value === "1" ? "维护人" : "点检人员",
  107. prop: "maintenanceUser",
  108. },
  109. {
  110. label: "确认人",
  111. prop: "confirmUser",
  112. },
  113. {
  114. label: "设备编号",
  115. prop: "deviceNo",
  116. width: '120',
  117. rules: [
  118. {
  119. required: true,
  120. message: "设备编号不能为空",
  121. trigger: "trigger",
  122. },
  123. ],
  124. },
  125. {
  126. label: "设备名称",
  127. prop: "deviceName",
  128. width: '120',
  129. rules: [
  130. {
  131. required: true,
  132. message: "设备名称不能为空",
  133. trigger: "trigger",
  134. },
  135. ],
  136. },
  137. {
  138. label: mType.value === "1" ? "维护结果" : "点检结果",
  139. prop: "result",
  140. search: true,
  141. type: "select",
  142. editDisplay: false,
  143. dicData: mType.value === "1" ? [{label: '正常',value:"0"},{label: '报故',value:"1"}] : [{label: '合格',value:"0"},{label: '不合格',value:"1"}]
  144. },
  145. ],
  146. })
  147. }
  148. onMounted?.(() => {
  149. search.value.maintenanceId = props.maintenance.id
  150. handleOption()
  151. dataList();
  152. });
  153. </script>