Browse Source

feat: 增加表格字典数据的处理

Mr. Robot 1 week ago
parent
commit
c8870b946b

+ 14 - 12
src/views/ip/patent-management/domestic/hooks/useData.hook.ts

@@ -42,6 +42,16 @@ export const useDataListInit = () => {
   const totalItems = ref(0);
   const tableData = ref([]);
   // 定义所有字段的配置项
+
+  // 配置
+  const formLabelWidth = "120px";
+
+  // 字典
+  const patentsType = dictStore.dictData.patents_type;
+  const legalStatus = dictStore.dictData.legal_status;
+  const priorityReviewStatus = dictStore.dictData.priority_review_status;
+  const ipap = dictStore.dictData.internal_patent_application_progress;
+
   const fieldsConfig = ref([
     { key: "patentsName", label: "专利名称", visible: true }, // 专利名称
     { key: "applicationNumber", label: "申请号", visible: true }, // 申请号
@@ -52,11 +62,11 @@ export const useDataListInit = () => {
     { key: "patentRemarks", label: "专利备注", visible: true }, // 专利备注
     { key: "patentee", label: "专利权人", visible: false }, // 专利权人
     { key: "firstDeviseName", label: "发明人", visible: false }, // 发明人
-    { key: "patentType", label: "专利类型", visible: false }, // 专利类型
-    { key: "patentStatus", label: "专利进度", visible: false }, // 专利进度
-    { key: "legislationStatus", label: "法律状态", visible: false }, // 法律状态
+    { key: "patentType", label: "专利类型", visible: false, isDict: true, dict: patentsType }, // 专利类型
+    { key: "patentStatus", label: "专利进度", visible: false, isDict: true, dict: ipap }, // 专利进度
+    { key: "legislationStatus", label: "法律状态", visible: false, isDict: true, dict: legalStatus }, // 法律状态
     { key: "paymentStatus", label: "年费缴纳", visible: false }, // 年费缴纳
-    { key: "priorityReview", label: "优先审查", visible: false }, // 优先审查
+    { key: "priorityReview", label: "优先审查", visible: false, isDict: true, dict: priorityReviewStatus }, // 优先审查
     { key: "agency", label: "代理机构", visible: false }, // 代理机构
     { key: "involvingTechnicalRoutes", label: "涉及技术路线", visible: false }, // 涉及技术路线
     { key: "logs", label: "日志", visible: false }, // 日志
@@ -70,14 +80,6 @@ export const useDataListInit = () => {
       .map((field) => field.key)
   );
 
-  // 配置
-  const formLabelWidth = "120px";
-
-  // 字典
-  const patentsType = dictStore.dictData.patents_type;
-  const legalStatus = dictStore.dictData.legal_status;
-  const priorityReviewStatus = dictStore.dictData.priority_review_status;
-  const ipap = dictStore.dictData.internal_patent_application_progress;
 
   const formFields = [
     {

+ 12 - 1
src/views/ip/patent-management/domestic/index.vue

@@ -64,7 +64,18 @@
           :prop="field.key"
           :label="field.label"
           width="200"
-        />
+        >
+          <template v-slot="scope">
+            <!-- 如果字段是字典,则显示字典映射 -->
+            <span v-if="scope.row[field.key] && field.isDict">
+              {{ field.dict[scope.row[field.key]]['label'] }}
+            </span>
+            <!-- 如果不是字典,直接显示原始值 -->
+            <span v-else>
+              {{ scope.row[field.key] }}
+            </span>
+          </template>
+        </el-table-column>
         <el-table-column fixed="right" label="操作" width="300" align="center">
           <template v-slot="scope">
             <el-button type="primary" text @click="onUpdate(scope.row)"