viewDrawer.vue.btl 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <template>
  2. <BasicDrawer
  3. v-bind="$attrs"
  4. destroyOnClose
  5. @register="registerDrawer"
  6. :title="getTitle"
  7. :width="width">
  8. <Description @register="registerDesc" :data="descData" />
  9. </BasicDrawer>
  10. </template>
  11. <script lang="ts" setup>
  12. import { onBeforeMount, ref } from 'vue'; // onBeforeMount,
  13. import { BasicDrawer, useDrawerInner } from '/@/components/Drawer';
  14. import { Description, useDescription } from '/@/components/Description';
  15. import { viewSchema } from './data';
  16. import { ${frontModuleName}${busNameFirstUpper}Detail } from '/@/api/${frontModuleName}/${frontModuleName}${busNameFirstUpper}Api';
  17. import { listDictModel } from '/@/api/common';
  18. import { formatDictValue } from '/@/utils';
  19. const descData = ref({});
  20. const getTitle = '查看${functionName}';
  21. const width = '45%';
  22. <% for(var i = 0; i < configList.~size; i++) { %>
  23. <% if(configList[i].dictTypeCode!=null) {%>
  24. const ${configList[i].fieldNameCamelCase}Options = ref();
  25. <% } %>
  26. <% } %>
  27. onBeforeMount(async () => {
  28. <% for(var i = 0; i < configList.~size; i++) { %>
  29. <% if(configList[i].dictTypeCode!=null) {%>
  30. ${configList[i].fieldNameCamelCase}Options.value = await listDictModel({ dictCode: '${configList[i].dictTypeCode}' });
  31. <% } %>
  32. <% } %>
  33. });
  34. const [registerDrawer] = useDrawerInner(async data => {
  35. console.log('::::::::::', data.record);
  36. const resData = await ${frontModuleName}${busNameFirstUpper}Detail(data.record.id);
  37. descData.value = {
  38. ...resData,
  39. <% for(var i = 0; i < configList.~size; i++) { %>
  40. <% if(configList[i].dictTypeCode!=null) {%>
  41. ${configList[i].fieldNameCamelCase}: formatDictValue(${configList[i].fieldNameCamelCase}Options.value, resData.${configList[i].fieldNameCamelCase}),
  42. <% } %>
  43. <% } %>
  44. };
  45. });
  46. const [registerDesc] = useDescription({
  47. schema: viewSchema,
  48. column: 2,
  49. size: 'middle',
  50. labelStyle: {
  51. width: '120px',
  52. },
  53. });
  54. </script>