info.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <template>
  2. <div id="info">
  3. <el-row>
  4. <el-col :span="24" class="main animate__animated animate__backInRight">
  5. <component :is="CForm" :fields="field" :rules="{}" :form="form" labelWidth="auto" :isSave="false">
  6. <template #fieldsList="{ item }">
  7. <span v-for="(i, index) in form[item.model]" :key="index" class="direction">
  8. <span>{{ index + 1 }}.</span>{{ i.name }}
  9. </span>
  10. </template>
  11. <template #file="{ item }">
  12. <el-link class="link" :href="i.url" :underline="false" v-for="(i, index) in form[item.model]" :key="index" target="_blank">
  13. <i class="el-icon-view el-icon--right"></i><span>{{ index + 1 }}.{{ i.name }}</span>
  14. </el-link>
  15. </template>
  16. <template #content="{ item }">
  17. <p v-html="form[item.model]"></p>
  18. </template>
  19. </component>
  20. </el-col>
  21. </el-row>
  22. </div>
  23. </template>
  24. <script lang="ts" setup>
  25. import CForm from '@common/src/components/frame/c-form.vue';
  26. import { ref, toRefs, watch } from 'vue';
  27. import type { Ref } from 'vue';
  28. import _ from 'lodash';
  29. import { DictDataStore } from '@common/src/stores/users/sysdictdata'; // 字典表
  30. import type { IQueryResult } from '@/util/types.util';
  31. const sysdictdata = DictDataStore();
  32. const props = defineProps({
  33. info: { type: Object, default: () => {} },
  34. type: { type: String },
  35. });
  36. const { info } = toRefs(props);
  37. let field: Ref<any[]> = ref([
  38. { label: '标题', model: 'title', options: { readonly: true } },
  39. { label: '发布时间', model: 'date', options: { readonly: true } },
  40. { label: '科学家姓名', model: 'scientist_name', options: { readonly: true } },
  41. { label: '单位名称', model: 'company_name', options: { readonly: true } },
  42. { label: '行业领域', model: 'fieldsList', custom: true },
  43. { label: '文件信息', model: 'file', custom: true },
  44. { label: '信息内容', model: 'content', custom: true },
  45. ]);
  46. let form: Ref<{}> = ref({});
  47. let fieldsList: Ref<any[]> = ref([]);
  48. // 查询
  49. const search = async (info) => {
  50. let e = _.cloneDeep(info);
  51. e.fieldsList = getFields(e.fields);
  52. form.value = e;
  53. };
  54. // 获得领域
  55. const getFields = (e) => {
  56. let field = [];
  57. for (const val of e) {
  58. let data = fieldsList.value.find((i) => i.dict_value == val);
  59. if (data) field.push({ name: data.dict_label });
  60. }
  61. return field;
  62. };
  63. const searchOther = async () => {
  64. const p1: IQueryResult = await sysdictdata.query({ dict_type: 'studio_field' });
  65. fieldsList.value = p1.data as [];
  66. };
  67. watch(info, async (newVal) => {
  68. if (newVal && newVal._id) {
  69. await searchOther();
  70. await search(newVal);
  71. }
  72. });
  73. </script>
  74. <style lang="scss" scoped>
  75. .direction {
  76. display: inline-block;
  77. background-color: #409eff;
  78. border-radius: 5px;
  79. padding: 0 5px;
  80. margin: 0 5px 5px 0;
  81. color: #ffffff;
  82. line-height: 2.5;
  83. span {
  84. padding: 0 5px 0 0;
  85. }
  86. }
  87. </style>