previewPage.vue 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <template>
  2. <hc-dialog
  3. v-model="isShow"
  4. :footer="false"
  5. :title="info.tableName"
  6. @close="dialogClose"
  7. widths="56rem"
  8. :isTable="true"
  9. >
  10. <hc-table :column="tableColumn" :datas="tableData">
  11. <template #eType="{ row }">
  12. {{ getDictionaryName(dataTypeList, row.eType, true) }}
  13. </template>
  14. </hc-table>
  15. </hc-dialog>
  16. </template>
  17. <script setup>
  18. import { ref, watch } from "vue";
  19. import treeApi from "~api/wbs/tree";
  20. import { getArrValue } from "js-fast-way";
  21. import { getDictionaryData, getDictionaryName } from "~src/utils/tools";
  22. const props = defineProps({
  23. info: {
  24. type: Object,
  25. default: () => {},
  26. },
  27. });
  28. //事件
  29. const emit = defineEmits(["close"]);
  30. //双向绑定
  31. // eslint-disable-next-line no-undef
  32. const isShow = defineModel("modelValue", {
  33. default: false,
  34. });
  35. const tableData = ref([]);
  36. const getTableData = async () => {
  37. const { data } = await treeApi.selectPrivateFormElements({
  38. id: info.value?.initTableId,
  39. });
  40. tableData.value = getArrValue(data);
  41. };
  42. //监听显示
  43. watch(isShow, (val) => {
  44. if (val) {
  45. getTableData();
  46. getDataTypelist();
  47. }
  48. });
  49. const info = ref(props.info);
  50. watch(
  51. () => [props.info],
  52. ([inf]) => {
  53. info.value = inf;
  54. },
  55. { deep: true }
  56. );
  57. //关闭弹窗
  58. const dialogClose = () => {
  59. isShow.value = false;
  60. emit("close");
  61. };
  62. const tableColumn = ref([
  63. { key: "eName", name: "字段信息" },
  64. { key: "eType", name: "数据类型" },
  65. { key: "eLength", name: "长度" },
  66. { key: "eAllowDeviation", name: "允许偏差值" },
  67. { key: "eInspectionMethod", name: "检查方法和频率" },
  68. ]);
  69. //获取数据类型
  70. const dataTypeList = ref([]);
  71. const getDataTypelist = async () => {
  72. if (dataTypeList.value.length > 1) {
  73. return;
  74. }
  75. dataTypeList.value = await getDictionaryData("data_type", false);
  76. };
  77. </script>