소스 검색

主题管理

xiaoqiao 1 년 전
부모
커밋
c004bea92d

+ 17 - 17
lib/华北油田Ai检索.PDM

@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<?PowerDesigner AppLocale="UTF16" ID="{88086B01-C9E1-11D4-9552-0090277716A9}" Label="" LastModificationDate="1698394794" Name="SmartSearch" Objects="341" Symbols="39" Target="MySQL 5.0" Type="{CDE44E21-9669-11D1-9914-006097355D9B}" signature="PDM_DATA_MODEL_XML" version="16.0.0.3514"?>
+<?PowerDesigner AppLocale="UTF16" ID="{88086B01-C9E1-11D4-9552-0090277716A9}" Label="" LastModificationDate="1698653795" Name="SmartSearch" Objects="330" Symbols="39" Target="MySQL 5.0" Type="{CDE44E21-9669-11D1-9914-006097355D9B}" signature="PDM_DATA_MODEL_XML" version="16.0.0.3514"?>
 <!-- do not edit this file -->
 
 <Model xmlns:a="attribute" xmlns:c="collection" xmlns:o="object">
@@ -1589,9 +1589,9 @@ Shadow=0</a:DisplayPreferences>
 <c:Symbols>
 <o:ReferenceSymbol Id="o5">
 <a:CreationDate>1698204236</a:CreationDate>
-<a:ModificationDate>1698374389</a:ModificationDate>
-<a:Rect>((-43412,-6453), (-30892,10780))</a:Rect>
-<a:ListOfPoints>((-43012,-6053),(-31292,-6053),(-31292,10380))</a:ListOfPoints>
+<a:ModificationDate>1698653795</a:ModificationDate>
+<a:Rect>((-31917,4225), (-30667,10780))</a:Rect>
+<a:ListOfPoints>((-31292,4625),(-31292,10380))</a:ListOfPoints>
 <a:CornerStyle>1</a:CornerStyle>
 <a:ArrowStyle>1</a:ArrowStyle>
 <a:LineColor>12615680</a:LineColor>
@@ -1655,9 +1655,9 @@ DESTINATION 0 新宋体,8,N</a:FontList>
 </o:ReferenceSymbol>
 <o:ReferenceSymbol Id="o15">
 <a:CreationDate>1698206246</a:CreationDate>
-<a:ModificationDate>1698374389</a:ModificationDate>
-<a:Rect>((-43412,2645), (-8214,3895))</a:Rect>
-<a:ListOfPoints>((-8614,3270),(-43012,3270))</a:ListOfPoints>
+<a:ModificationDate>1698653795</a:ModificationDate>
+<a:Rect>((-30126,2645), (-8214,3895))</a:Rect>
+<a:ListOfPoints>((-8614,3270),(-29726,3270))</a:ListOfPoints>
 <a:CornerStyle>1</a:CornerStyle>
 <a:ArrowStyle>1</a:ArrowStyle>
 <a:LineColor>12615680</a:LineColor>
@@ -1699,9 +1699,9 @@ DESTINATION 0 新宋体,8,N</a:FontList>
 </o:ReferenceSymbol>
 <o:ReferenceSymbol Id="o20">
 <a:CreationDate>1698285622</a:CreationDate>
-<a:ModificationDate>1698374389</a:ModificationDate>
-<a:Rect>((-43412,-10164), (-8422,-8914))</a:Rect>
-<a:ListOfPoints>((-8822,-9539),(-43012,-9539))</a:ListOfPoints>
+<a:ModificationDate>1698653795</a:ModificationDate>
+<a:Rect>((-30126,-8964), (-8422,-7714))</a:Rect>
+<a:ListOfPoints>((-8822,-8339),(-29726,-8339))</a:ListOfPoints>
 <a:CornerStyle>1</a:CornerStyle>
 <a:ArrowStyle>1</a:ArrowStyle>
 <a:LineColor>12615680</a:LineColor>
@@ -1722,8 +1722,8 @@ DESTINATION 0 新宋体,8,N</a:FontList>
 <o:ReferenceSymbol Id="o22">
 <a:CreationDate>1698290862</a:CreationDate>
 <a:ModificationDate>1698374381</a:ModificationDate>
-<a:Rect>((-11474,-21026), (-7996,11681))</a:Rect>
-<a:ListOfPoints>((-8396,-20626),(-11074,-20626),(-11074,11281))</a:ListOfPoints>
+<a:Rect>((-11474,-19826), (-7996,11681))</a:Rect>
+<a:ListOfPoints>((-8396,-19426),(-11074,-19426),(-11074,11281))</a:ListOfPoints>
 <a:CornerStyle>1</a:CornerStyle>
 <a:ArrowStyle>1</a:ArrowStyle>
 <a:LineColor>12615680</a:LineColor>
@@ -1743,9 +1743,9 @@ DESTINATION 0 新宋体,8,N</a:FontList>
 </o:ReferenceSymbol>
 <o:ReferenceSymbol Id="o25">
 <a:CreationDate>1698290863</a:CreationDate>
-<a:ModificationDate>1698374389</a:ModificationDate>
-<a:Rect>((-43412,-16248), (-7996,-14998))</a:Rect>
-<a:ListOfPoints>((-8396,-15623),(-43012,-15623))</a:ListOfPoints>
+<a:ModificationDate>1698653795</a:ModificationDate>
+<a:Rect>((-39575,-21026), (-7996,-15315))</a:Rect>
+<a:ListOfPoints>((-8396,-20626),(-39175,-20626),(-39175,-15715))</a:ListOfPoints>
 <a:CornerStyle>1</a:CornerStyle>
 <a:ArrowStyle>1</a:ArrowStyle>
 <a:LineColor>12615680</a:LineColor>
@@ -1792,9 +1792,9 @@ LABL 0 Microsoft Sans Serif,8,N</a:FontList>
 </o:TableSymbol>
 <o:TableSymbol Id="o6">
 <a:CreationDate>1698201642</a:CreationDate>
-<a:ModificationDate>1698374389</a:ModificationDate>
+<a:ModificationDate>1698653795</a:ModificationDate>
 <a:IconMode>-1</a:IconMode>
-<a:Rect>((-61910,-16223), (-43012,4117))</a:Rect>
+<a:Rect>((-48624,-15715), (-29726,4625))</a:Rect>
 <a:AutoAdjustToText>0</a:AutoAdjustToText>
 <a:LineColor>12615680</a:LineColor>
 <a:FillColor>16570034</a:FillColor>

+ 17 - 17
lib/华北油田Ai检索.pdb

@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<?PowerDesigner AppLocale="UTF16" ID="{88086B01-C9E1-11D4-9552-0090277716A9}" Label="" LastModificationDate="1698394794" Name="SmartSearch" Objects="341" Symbols="39" Target="MySQL 5.0" Type="{CDE44E21-9669-11D1-9914-006097355D9B}" signature="PDM_DATA_MODEL_XML" version="16.0.0.3514"?>
+<?PowerDesigner AppLocale="UTF16" ID="{88086B01-C9E1-11D4-9552-0090277716A9}" Label="" LastModificationDate="1698653795" Name="SmartSearch" Objects="341" Symbols="39" Target="MySQL 5.0" Type="{CDE44E21-9669-11D1-9914-006097355D9B}" signature="PDM_DATA_MODEL_XML" version="16.0.0.3514"?>
 <!-- do not edit this file -->
 
 <Model xmlns:a="attribute" xmlns:c="collection" xmlns:o="object">
@@ -1589,9 +1589,9 @@ Shadow=0</a:DisplayPreferences>
 <c:Symbols>
 <o:ReferenceSymbol Id="o5">
 <a:CreationDate>1698204236</a:CreationDate>
-<a:ModificationDate>1698374389</a:ModificationDate>
-<a:Rect>((-43412,-6453), (-30892,10780))</a:Rect>
-<a:ListOfPoints>((-43012,-6053),(-31292,-6053),(-31292,10380))</a:ListOfPoints>
+<a:ModificationDate>1698653795</a:ModificationDate>
+<a:Rect>((-31917,4225), (-30667,10780))</a:Rect>
+<a:ListOfPoints>((-31292,4625),(-31292,10380))</a:ListOfPoints>
 <a:CornerStyle>1</a:CornerStyle>
 <a:ArrowStyle>1</a:ArrowStyle>
 <a:LineColor>12615680</a:LineColor>
@@ -1655,9 +1655,9 @@ DESTINATION 0 新宋体,8,N</a:FontList>
 </o:ReferenceSymbol>
 <o:ReferenceSymbol Id="o15">
 <a:CreationDate>1698206246</a:CreationDate>
-<a:ModificationDate>1698374389</a:ModificationDate>
-<a:Rect>((-43412,2645), (-8214,3895))</a:Rect>
-<a:ListOfPoints>((-8614,3270),(-43012,3270))</a:ListOfPoints>
+<a:ModificationDate>1698653795</a:ModificationDate>
+<a:Rect>((-30126,2645), (-8214,3895))</a:Rect>
+<a:ListOfPoints>((-8614,3270),(-29726,3270))</a:ListOfPoints>
 <a:CornerStyle>1</a:CornerStyle>
 <a:ArrowStyle>1</a:ArrowStyle>
 <a:LineColor>12615680</a:LineColor>
@@ -1699,9 +1699,9 @@ DESTINATION 0 新宋体,8,N</a:FontList>
 </o:ReferenceSymbol>
 <o:ReferenceSymbol Id="o20">
 <a:CreationDate>1698285622</a:CreationDate>
-<a:ModificationDate>1698374389</a:ModificationDate>
-<a:Rect>((-43412,-10164), (-8422,-8914))</a:Rect>
-<a:ListOfPoints>((-8822,-9539),(-43012,-9539))</a:ListOfPoints>
+<a:ModificationDate>1698653795</a:ModificationDate>
+<a:Rect>((-30126,-8964), (-8422,-7714))</a:Rect>
+<a:ListOfPoints>((-8822,-8339),(-29726,-8339))</a:ListOfPoints>
 <a:CornerStyle>1</a:CornerStyle>
 <a:ArrowStyle>1</a:ArrowStyle>
 <a:LineColor>12615680</a:LineColor>
@@ -1722,8 +1722,8 @@ DESTINATION 0 新宋体,8,N</a:FontList>
 <o:ReferenceSymbol Id="o22">
 <a:CreationDate>1698290862</a:CreationDate>
 <a:ModificationDate>1698374381</a:ModificationDate>
-<a:Rect>((-11474,-21026), (-7996,11681))</a:Rect>
-<a:ListOfPoints>((-8396,-20626),(-11074,-20626),(-11074,11281))</a:ListOfPoints>
+<a:Rect>((-11474,-19826), (-7996,11681))</a:Rect>
+<a:ListOfPoints>((-8396,-19426),(-11074,-19426),(-11074,11281))</a:ListOfPoints>
 <a:CornerStyle>1</a:CornerStyle>
 <a:ArrowStyle>1</a:ArrowStyle>
 <a:LineColor>12615680</a:LineColor>
@@ -1743,9 +1743,9 @@ DESTINATION 0 新宋体,8,N</a:FontList>
 </o:ReferenceSymbol>
 <o:ReferenceSymbol Id="o25">
 <a:CreationDate>1698290863</a:CreationDate>
-<a:ModificationDate>1698374389</a:ModificationDate>
-<a:Rect>((-43412,-16248), (-7996,-14998))</a:Rect>
-<a:ListOfPoints>((-8396,-15623),(-43012,-15623))</a:ListOfPoints>
+<a:ModificationDate>1698653795</a:ModificationDate>
+<a:Rect>((-39575,-21026), (-7996,-15315))</a:Rect>
+<a:ListOfPoints>((-8396,-20626),(-39175,-20626),(-39175,-15715))</a:ListOfPoints>
 <a:CornerStyle>1</a:CornerStyle>
 <a:ArrowStyle>1</a:ArrowStyle>
 <a:LineColor>12615680</a:LineColor>
@@ -1792,9 +1792,9 @@ LABL 0 Microsoft Sans Serif,8,N</a:FontList>
 </o:TableSymbol>
 <o:TableSymbol Id="o6">
 <a:CreationDate>1698201642</a:CreationDate>
-<a:ModificationDate>1698374389</a:ModificationDate>
+<a:ModificationDate>1698653795</a:ModificationDate>
 <a:IconMode>-1</a:IconMode>
-<a:Rect>((-61910,-16223), (-43012,4117))</a:Rect>
+<a:Rect>((-48624,-15715), (-29726,4625))</a:Rect>
 <a:AutoAdjustToText>0</a:AutoAdjustToText>
 <a:LineColor>12615680</a:LineColor>
 <a:FillColor>16570034</a:FillColor>

+ 52 - 0
src/main/java/com/bowintek/practice/controller/SubjectController.java

@@ -0,0 +1,52 @@
+package com.bowintek.practice.controller;
+
+import com.alibaba.fastjson.JSONObject;
+import com.bowintek.practice.filter.exception.BaseResponse;
+import com.bowintek.practice.filter.exception.RespGenerstor;
+import com.bowintek.practice.model.SrSubject;
+import com.bowintek.practice.model.SrSubjectfield;
+import com.bowintek.practice.services.service.AccountService;
+import com.bowintek.practice.services.service.SubjectService;
+import com.bowintek.practice.services.service.UserService;
+import com.bowintek.practice.util.JsonMapper;
+import com.bowintek.practice.util.MapUtils;
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+import java.util.Map;
+
+@RestController
+@RequestMapping(value = "/api/subject")
+public class SubjectController {
+
+    @Autowired
+    private SubjectService subjectService;
+    @Autowired
+    private JsonMapper jsonMapper;
+    @Autowired
+    private UserService userService;
+    @Autowired
+    private AccountService accountService;
+    @Autowired
+    private MapUtils mapUtils;
+
+    @ResponseBody
+    @PostMapping("/saveSubject")
+    public BaseResponse saveSubject(@RequestBody JSONObject reqMap) {
+
+        int count = 0;
+        ObjectMapper mapper = new ObjectMapper();
+        try {
+
+            SrSubject dataModel = reqMap.getObject("dataModel", SrSubject.class);
+            List<SrSubjectfield> fieldList = reqMap.getJSONArray("fieldList").toJavaList(SrSubjectfield.class);
+            count = subjectService.saveSubject(dataModel, fieldList, accountService.getLoginUserID());
+        } catch (Exception e) {
+            return RespGenerstor.fail("-1", "程序异常:" + e.getMessage());
+        }
+        return RespGenerstor.success(count);
+    }
+}

+ 69 - 0
src/main/java/com/bowintek/practice/services/impl/SubjectServiceImpl.java

@@ -0,0 +1,69 @@
+package com.bowintek.practice.services.impl;
+
+import com.bowintek.practice.mapper.SrSubjectMapper;
+import com.bowintek.practice.mapper.SrSubjectfieldMapper;
+import com.bowintek.practice.model.SrSubject;
+import com.bowintek.practice.model.SrSubjectfield;
+import com.bowintek.practice.model.SrSubjectfieldExample;
+import com.bowintek.practice.services.service.SubjectService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.Date;
+import java.util.List;
+import java.util.UUID;
+import java.util.stream.Collectors;
+
+@Service("SubjectService")
+public class SubjectServiceImpl implements SubjectService {
+    @Autowired
+    private SrSubjectMapper subjectMapper;
+    @Autowired
+    private SrSubjectfieldMapper subjectfieldMapper;
+
+    @Override
+    public int saveSubject(SrSubject model, List<SrSubjectfield> fieldList, String userId) {
+
+        if (model.getIsReferences() == 0) {
+            model.setExecSql(model.getTabCode());
+        }
+        SrSubject dbData = subjectMapper.selectByPrimaryKey(model.getSubId());
+        int result = 0;
+        if (dbData == null) {
+            model.setSubId(UUID.randomUUID().toString());
+            model.setStatus(1);
+            model.setCreatedBy(userId);
+            model.setCreateTime(new Date());
+            model.setModiTime(new Date());
+            result = subjectMapper.insert(model);
+        } else {
+            model.setModiTime(new Date());
+            result = subjectMapper.updateByPrimaryKey(model);
+        }
+
+        if (fieldList != null && fieldList.size() > 0) {
+            SrSubjectfieldExample example = new SrSubjectfieldExample();
+            SrSubjectfieldExample.Criteria criteria= example.or();
+            criteria.andSubIdEqualTo(model.getSubId());
+            List<SrSubjectfield> dbList =subjectfieldMapper.selectByExample(example);
+            List<String> ids = fieldList.stream().map(x->x.getFieldId()).collect(Collectors.toList());
+
+            criteria.andFieldIdNotIn(ids);
+            subjectfieldMapper.deleteByExample(example);
+            fieldList.stream().forEach(x -> {
+                long count = dbList.stream().filter(f->f.getFieldId()==x.getFieldId()).count();
+                if(count>0){
+                    x.setModifyTime(new Date());
+                    subjectfieldMapper.updateByPrimaryKeySelective(x);
+                }else{
+                    x.setSubId(model.getSubId());
+                    x.setFieldId(UUID.randomUUID().toString());
+                    x.setCreatedBy(userId);
+                    x.setStatus(1);
+                    subjectfieldMapper.insertSelective(x);
+                }
+            });
+        }
+        return result;
+    }
+}

+ 13 - 0
src/main/java/com/bowintek/practice/services/service/SubjectService.java

@@ -0,0 +1,13 @@
+package com.bowintek.practice.services.service;
+
+import com.bowintek.practice.model.SrSubject;
+import com.bowintek.practice.model.SrSubjectfield;
+
+import java.util.List;
+
+public interface SubjectService {
+
+    int saveSubject(SrSubject model,
+                         List<SrSubjectfield>  fieldList,
+                         String userId);
+}

+ 26 - 6
target/classes/application.yml

@@ -10,15 +10,35 @@ spring:
   datasource:
     name: practice_db
     type: com.alibaba.druid.pool.DruidDataSource
+    driver-class-name: com.mysql.cj.jdbc.Driver
+    #基本属性
+    url: jdbc:mysql://office.bowintek.com:3306/smartSearchDB?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai&allowMultiQueries=true&zeroDateTimeBehavior=convertToNull&allowPublicKeyRetrieval=true
+    #url: jdbc:mysql://office.bowintek.com:3306/practicedb?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai&allowMultiQueries=true&zeroDateTimeBehavior=convertToNull&allowPublicKeyRetrieval=true
+    username: root
+    password: bowin123
+    smartsearch:
+      # 数据源基本配置
+      username: root
+      password: bowin123
+      url: jdbc:mysql://office.bowintek.com:3306/smartSearchDB?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai
+      # driver-class需要注意mysql驱动的版本(com.mysql.cj.jdbc.Driver 或 com.mysql.jdbc.Driver)
+      driver-class-name: com.mysql.jdbc.Driver
+    postgre:
+      # 数据源基本配置
+      username: root
+      password: bowin123
+      url: jdbc:mysql://office.bowintek.com:3306/practicedb?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai
+      # driver-class需要注意mysql驱动的版本(com.mysql.cj.jdbc.Driver 或 com.mysql.jdbc.Driver)
+      driver-class-name: com.mysql.jdbc.Driver
     druid:
       #监控统计拦截的filters
       filters: stat
-      driver-class-name: com.mysql.cj.jdbc.Driver
-      #基本属性
-      url: jdbc:mysql://office.bowintek.com:3306/smartSearchDB?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai&allowMultiQueries=true&zeroDateTimeBehavior=convertToNull&allowPublicKeyRetrieval=true
-      #url: jdbc:mysql://office.bowintek.com:3306/practicedb?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai&allowMultiQueries=true&zeroDateTimeBehavior=convertToNull&allowPublicKeyRetrieval=true
-      username: root
-      password: bowin123
+#      driver-class-name: com.mysql.cj.jdbc.Driver
+#      #基本属性
+#      url: jdbc:mysql://office.bowintek.com:3306/smartSearchDB?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai&allowMultiQueries=true&zeroDateTimeBehavior=convertToNull&allowPublicKeyRetrieval=true
+#      #url: jdbc:mysql://office.bowintek.com:3306/practicedb?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai&allowMultiQueries=true&zeroDateTimeBehavior=convertToNull&allowPublicKeyRetrieval=true
+#      username: root
+#      password: bowin123
       #配置初始化大小/最小/最大
       initial-size: 1
       min-idle: 1

+ 0 - 5
target/classes/generatorConfig.xml

@@ -121,10 +121,5 @@
             <table schema="" tableName="Sys_Log"><property name="useActualColumnNames" value="true"/></table>
         </table>-->
         <table schema="" tableName="sr_subject"><property name="useActualColumnNames" value="true"/></table>
-        <table schema="" tableName="sr_subjectField"><property name="useActualColumnNames" value="true"/></table>
-        <table schema="" tableName="sr_saerchTemp"><property name="useActualColumnNames" value="true"/></table>
-        <table schema="" tableName="sr_tempField"><property name="useActualColumnNames" value="true"/></table>
-        <table schema="" tableName="sr_tempDimension"><property name="useActualColumnNames" value="true"/></table>
-        <table schema="" tableName="sr_tempMeasure"><property name="useActualColumnNames" value="true"/></table>
     </context>
 </generatorConfiguration>

+ 154 - 0
vue/package-lock.json

@@ -1294,6 +1294,99 @@
         "to-fast-properties": "^2.0.0"
       }
     },
+    "@codemirror/autocomplete": {
+      "version": "6.10.2",
+      "resolved": "https://registry.npmmirror.com/@codemirror/autocomplete/-/autocomplete-6.10.2.tgz",
+      "integrity": "sha512-3dCL7b0j2GdtZzWN5j7HDpRAJ26ip07R4NGYz7QYthIYMiX8I4E4TNrYcdTayPJGeVQtd/xe7lWU4XL7THFb/w==",
+      "requires": {
+        "@codemirror/language": "^6.0.0",
+        "@codemirror/state": "^6.0.0",
+        "@codemirror/view": "^6.17.0",
+        "@lezer/common": "^1.0.0"
+      }
+    },
+    "@codemirror/commands": {
+      "version": "6.3.0",
+      "resolved": "https://registry.npmmirror.com/@codemirror/commands/-/commands-6.3.0.tgz",
+      "integrity": "sha512-tFfcxRIlOWiQDFhjBSWJ10MxcvbCIsRr6V64SgrcaY0MwNk32cUOcCuNlWo8VjV4qRQCgNgUAnIeo0svkk4R5Q==",
+      "requires": {
+        "@codemirror/language": "^6.0.0",
+        "@codemirror/state": "^6.2.0",
+        "@codemirror/view": "^6.0.0",
+        "@lezer/common": "^1.1.0"
+      }
+    },
+    "@codemirror/lang-sql": {
+      "version": "6.5.4",
+      "resolved": "https://registry.npmmirror.com/@codemirror/lang-sql/-/lang-sql-6.5.4.tgz",
+      "integrity": "sha512-5Gq7fYtT/5HbNyIG7a8vYaqOYQU3JbgtBe3+derkrFUXRVcjkf8WVgz++PIbMFAQsOFMDdDR+uiNM8ZRRuXH+w==",
+      "requires": {
+        "@codemirror/autocomplete": "^6.0.0",
+        "@codemirror/language": "^6.0.0",
+        "@codemirror/state": "^6.0.0",
+        "@lezer/highlight": "^1.0.0",
+        "@lezer/lr": "^1.0.0"
+      }
+    },
+    "@codemirror/language": {
+      "version": "6.9.2",
+      "resolved": "https://registry.npmmirror.com/@codemirror/language/-/language-6.9.2.tgz",
+      "integrity": "sha512-QGTQXSpAKDIzaSE96zNK1UfIUhPgkT1CLjh1N5qVzZuxgsEOhz5RqaN8QCIdyOQklGLx3MgHd9YrE3X3+Pl1ow==",
+      "requires": {
+        "@codemirror/state": "^6.0.0",
+        "@codemirror/view": "^6.0.0",
+        "@lezer/common": "^1.1.0",
+        "@lezer/highlight": "^1.0.0",
+        "@lezer/lr": "^1.0.0",
+        "style-mod": "^4.0.0"
+      }
+    },
+    "@codemirror/lint": {
+      "version": "6.4.2",
+      "resolved": "https://registry.npmmirror.com/@codemirror/lint/-/lint-6.4.2.tgz",
+      "integrity": "sha512-wzRkluWb1ptPKdzlsrbwwjYCPLgzU6N88YBAmlZi8WFyuiEduSd05MnJYNogzyc8rPK7pj6m95ptUApc8sHKVA==",
+      "requires": {
+        "@codemirror/state": "^6.0.0",
+        "@codemirror/view": "^6.0.0",
+        "crelt": "^1.0.5"
+      }
+    },
+    "@codemirror/search": {
+      "version": "6.5.4",
+      "resolved": "https://registry.npmmirror.com/@codemirror/search/-/search-6.5.4.tgz",
+      "integrity": "sha512-YoTrvjv9e8EbPs58opjZKyJ3ewFrVSUzQ/4WXlULQLSDDr1nGPJ67mMXFNNVYwdFhybzhrzrtqgHmtpJwIF+8g==",
+      "requires": {
+        "@codemirror/state": "^6.0.0",
+        "@codemirror/view": "^6.0.0",
+        "crelt": "^1.0.5"
+      }
+    },
+    "@codemirror/state": {
+      "version": "6.3.1",
+      "resolved": "https://registry.npmmirror.com/@codemirror/state/-/state-6.3.1.tgz",
+      "integrity": "sha512-88e4HhMtKJyw6fKprGaN/yZfiaoGYOi2nM45YCUC6R/kex9sxFWBDGatS1vk4lMgnWmdIIB9tk8Gj1LmL8YfvA=="
+    },
+    "@codemirror/theme-one-dark": {
+      "version": "6.1.2",
+      "resolved": "https://registry.npmmirror.com/@codemirror/theme-one-dark/-/theme-one-dark-6.1.2.tgz",
+      "integrity": "sha512-F+sH0X16j/qFLMAfbciKTxVOwkdAS336b7AXTKOZhy8BR3eH/RelsnLgLFINrpST63mmN2OuwUt0W2ndUgYwUA==",
+      "requires": {
+        "@codemirror/language": "^6.0.0",
+        "@codemirror/state": "^6.0.0",
+        "@codemirror/view": "^6.0.0",
+        "@lezer/highlight": "^1.0.0"
+      }
+    },
+    "@codemirror/view": {
+      "version": "6.21.4",
+      "resolved": "https://registry.npmmirror.com/@codemirror/view/-/view-6.21.4.tgz",
+      "integrity": "sha512-WKVZ7nvN0lwWPfAf05WxWqTpwjC8YN3q5goj3CsSig7//DD81LULgOx3nBegqpqP0iygBqRmW8z0KSc2QTAdAg==",
+      "requires": {
+        "@codemirror/state": "^6.1.4",
+        "style-mod": "^4.1.0",
+        "w3c-keyname": "^2.2.4"
+      }
+    },
     "@commitlint/cli": {
       "version": "17.0.3",
       "resolved": "https://registry.npmmirror.com/@commitlint/cli/-/cli-17.0.3.tgz",
@@ -1715,6 +1808,27 @@
       "integrity": "sha512-Hcv+nVC0kZnQ3tD9GVu5xSMR4VVYOteQIr/hwFPVEvPdlXqgGEuRjiheChHgdM+JyqdgNcmzZOX/tnl0JOiI7A==",
       "dev": true
     },
+    "@lezer/common": {
+      "version": "1.1.0",
+      "resolved": "https://registry.npmmirror.com/@lezer/common/-/common-1.1.0.tgz",
+      "integrity": "sha512-XPIN3cYDXsoJI/oDWoR2tD++juVrhgIago9xyKhZ7IhGlzdDM9QgC8D8saKNCz5pindGcznFr2HBSsEQSWnSjw=="
+    },
+    "@lezer/highlight": {
+      "version": "1.1.6",
+      "resolved": "https://registry.npmmirror.com/@lezer/highlight/-/highlight-1.1.6.tgz",
+      "integrity": "sha512-cmSJYa2us+r3SePpRCjN5ymCqCPv+zyXmDl0ciWtVaNiORT/MxM7ZgOMQZADD0o51qOaOg24qc/zBViOIwAjJg==",
+      "requires": {
+        "@lezer/common": "^1.0.0"
+      }
+    },
+    "@lezer/lr": {
+      "version": "1.3.13",
+      "resolved": "https://registry.npmmirror.com/@lezer/lr/-/lr-1.3.13.tgz",
+      "integrity": "sha512-RLAbau/4uSzKgIKj96mI5WUtG1qtiR0Frn0Ei9zhPj8YOkHM+1Bb8SgdVvmR/aWJCFIzjo2KFnDiRZ75Xf5NdQ==",
+      "requires": {
+        "@lezer/common": "^1.0.0"
+      }
+    },
     "@node-ipc/js-queue": {
       "version": "2.0.3",
       "resolved": "https://registry.npmmirror.com/@node-ipc/js-queue/-/js-queue-2.0.3.tgz",
@@ -4443,6 +4557,20 @@
         }
       }
     },
+    "codemirror": {
+      "version": "6.0.1",
+      "resolved": "https://registry.npmmirror.com/codemirror/-/codemirror-6.0.1.tgz",
+      "integrity": "sha512-J8j+nZ+CdWmIeFIGXEFbFPtpiYacFMDR8GlHK3IyHQJMCaVRfGx9NT+Hxivv1ckLWPvNdZqndbr/7lVhrf/Svg==",
+      "requires": {
+        "@codemirror/autocomplete": "^6.0.0",
+        "@codemirror/commands": "^6.0.0",
+        "@codemirror/language": "^6.0.0",
+        "@codemirror/lint": "^6.0.0",
+        "@codemirror/search": "^6.0.0",
+        "@codemirror/state": "^6.0.0",
+        "@codemirror/view": "^6.0.0"
+      }
+    },
     "codepage": {
       "version": "1.15.0",
       "resolved": "https://registry.npmmirror.com/codepage/-/codepage-1.15.0.tgz",
@@ -5021,6 +5149,11 @@
       "integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==",
       "dev": true
     },
+    "crelt": {
+      "version": "1.0.6",
+      "resolved": "https://registry.npmmirror.com/crelt/-/crelt-1.0.6.tgz",
+      "integrity": "sha512-VQ2MBenTq1fWZUH9DJNGti7kKv6EeAuYr3cLwxUWhIu1baTaXh4Ib5W2CqHVqib4/MqbYGJqiL3Zb8GJZr3l4g=="
+    },
     "cross-env": {
       "version": "7.0.3",
       "resolved": "https://registry.npmmirror.com/cross-env/-/cross-env-7.0.3.tgz",
@@ -12061,6 +12194,11 @@
       "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==",
       "dev": true
     },
+    "style-mod": {
+      "version": "4.1.0",
+      "resolved": "https://registry.npmmirror.com/style-mod/-/style-mod-4.1.0.tgz",
+      "integrity": "sha512-Ca5ib8HrFn+f+0n4N4ScTIA9iTOQ7MaGS1ylHcoVqW9J7w2w8PzN6g9gKmTYgGEBH8e120+RCmhpje6jC5uGWA=="
+    },
     "style-search": {
       "version": "0.1.0",
       "resolved": "https://registry.npmmirror.com/style-search/-/style-search-0.1.0.tgz",
@@ -13378,6 +13516,17 @@
         "windicss-webpack-plugin": "^1.7.4"
       }
     },
+    "vue-codemirror": {
+      "version": "6.1.1",
+      "resolved": "https://registry.npmmirror.com/vue-codemirror/-/vue-codemirror-6.1.1.tgz",
+      "integrity": "sha512-rTAYo44owd282yVxKtJtnOi7ERAcXTeviwoPXjIc6K/IQYUsoDkzPvw/JDFtSP6T7Cz/2g3EHaEyeyaQCKoDMg==",
+      "requires": {
+        "@codemirror/commands": "6.x",
+        "@codemirror/language": "6.x",
+        "@codemirror/state": "6.x",
+        "@codemirror/view": "6.x"
+      }
+    },
     "vue-eslint-parser": {
       "version": "9.0.3",
       "resolved": "https://registry.npmmirror.com/vue-eslint-parser/-/vue-eslint-parser-9.0.3.tgz",
@@ -13509,6 +13658,11 @@
         "is-plain-object": "5.0.0"
       }
     },
+    "w3c-keyname": {
+      "version": "2.2.8",
+      "resolved": "https://registry.npmmirror.com/w3c-keyname/-/w3c-keyname-2.2.8.tgz",
+      "integrity": "sha512-dpojBhNsCNN7T82Tm7k26A6G9ML3NkhDsnw9n/eoxSRlVBB4CEtIQ/KTCLI2Fwf3ataSXRhYFkQi3SlnFwPvPQ=="
+    },
     "warning": {
       "version": "4.0.3",
       "resolved": "https://registry.npmmirror.com/warning/-/warning-4.0.3.tgz",

+ 5 - 0
vue/package.json

@@ -36,9 +36,13 @@
     "@vueuse/core": "~9.1.0",
     "@wangeditor/editor": "^5.1.23",
     "@wangeditor/editor-for-vue": "^5.1.12",
+    "@codemirror/lang-sql": "^6.x",
+    "@codemirror/language": "^6.x",
+    "@codemirror/theme-one-dark": "^6.x",
     "animate.css": "^4.1.1",
     "ant-design-vue": "3.2.17",
     "axios": "~0.27.2",
+    "codemirror": "^6.0.1",
     "core-js": "~3.24.1",
     "crypto-js": "^4.1.1",
     "dayjs": "~1.11.5",
@@ -54,6 +58,7 @@
     "sortablejs": "~1.15.0",
     "uuid": "^9.0.0",
     "vue": "3.2.47",
+    "vue-codemirror": "^6.1.1",
     "vue-i18n": "9.2.2",
     "vue-router": "^4.1.6",
     "vue-types": "~4.2.1",

+ 130 - 72
vue/src/views/subject/edit.vue

@@ -4,33 +4,40 @@
       <a-divider orientation="left">主题定义</a-divider>
       <a-row :gutter="24">
         <a-col :span="8">
-          <a-form-item :label-col="{span:6}" label="表编码" name="tabcode"
+          <a-form-item :label-col="{span:6}" label="主题名称" name="subjectName"
+                       :rules="[{ required: true, message: '请填写主题名称!' }]">
+            <a-input v-model:value="dataModel.subjectName" placeholder="">
+            </a-input>
+          </a-form-item>
+        </a-col>
+        <a-col :span="8">
+          <a-form-item :label-col="{span:6}" label="表编码" name="tabCode"
                        :rules="[{ required: true, message: '请填写表编码!' }]">
-            <a-input v-model:value="dataModel.tabcode" placeholder="">
+            <a-input v-model:value="dataModel.tabCode" placeholder="">
             </a-input>
           </a-form-item>
         </a-col>
         <a-col :span="8">
-          <a-form-item :label-col="{span:6}" label="表名称" name="tabname"
+          <a-form-item :label-col="{span:6}" label="表名称" name="tabName"
                        :rules="[{ required: true, message: '请填表名称!' }]">
-            <a-input v-model:value="dataModel.tabname" placeholder="">
+            <a-input v-model:value="dataModel.tabName" placeholder="">
             </a-input>
           </a-form-item>
         </a-col>
       </a-row>
       <a-row :gutter="24">
         <a-col :span="8">
-          <a-form-item :label-col="{span:6}" label="是否有外键字段" name="isreferences"
+          <a-form-item :label-col="{span:8}" label="是否有外键字段" name="isReferences"
                        :rules="[{ required: true, message: '请填写是否有外键字段!' }]">
-            <a-radio-group v-model:value="dataModel.isreferences">
+            <a-radio-group v-model:value="dataModel.isReferences">
               <a-radio :value="1">是</a-radio>
               <a-radio :value="0">否</a-radio>
             </a-radio-group>
           </a-form-item>
         </a-col>
         <a-col :span="8">
-          <a-form-item :label-col="{span:6}" label="描述" name="tabdesc">
-            <a-input v-model:value="dataModel.tabdesc" placeholder="">
+          <a-form-item :label-col="{span:6}" label="描述" name="tabDesc">
+            <a-input v-model:value="dataModel.tabDesc" placeholder="">
             </a-input>
           </a-form-item>
         </a-col>
@@ -52,51 +59,35 @@
       </a-row>
       <a-row>
         <a-col style="margin-bottom: 20px;">
-          <a-table :columns="columns" :data-source="data" :pagination="false"
+          <a-table :columns="columns" :data-source="fieldData" :pagination="false"
                    bordered>
-            <template #bodyCell="{ column ,index}">
-              <template v-if="column.key === 'name'">
-                <div>
-                  <a-input v-if="isEdit"
-                           v-model:value="data[index][column.key]" style="width: 200px"
-                  />
-                  <template v-else>
-                    {{ data[index][column.key] }}
-                  </template>
-                </div>
-              </template>
-              <template v-if="column.key === 'typeName'">
-                <div>
-                  <a-input v-if="isEdit"
-                           v-model:value="data[index][column.key]" style="width: 200px"
-                  />
-                  <template v-else>
-                    {{ data[index][column.key] }}
-                  </template>
-                </div>
-              </template>
-              <template v-if="column.key === 'qty'">
-                <div>
-                  <a-input v-if="isEdit"
-                           v-model:value="data[index][column.key]" style="width: 200px"
-                  />
-                  <template v-else>
-                    {{ data[index][column.key] }}
-                  </template>
-                </div>
-              </template>
+            <template #bodyCell="{ column ,record,index}">
               <template v-if="column.key === 'operation'">
-                <a-button type="link" size="small" @click="deleteDevice(index)">删除</a-button>
+                <a-button type="link" size="small" @click="edit(record)">修改</a-button>
+                <a-popconfirm placement="leftTop"
+                              title="是否删除数据?"
+                              @confirm="onDelete(index)">
+                  <a-button type="link" size="small">删除</a-button>
+                </a-popconfirm>
               </template>
             </template>
           </a-table>
         </a-col>
       </a-row>
-      <a-divider orientation="left">生成Sql</a-divider>
+      <a-divider orientation="left">Sql预览</a-divider>
       <a-row>
         <a-col class="table-bottom-a1">
           <a-form-item :label-col="{span:8}" label="" name="remark">
-            <a-textarea v-model:value="dataModel.remark" placeholder="备注" :rows="5"/>
+            <codemirror
+              v-model="code"
+              :style="{ height: '100px',width:'100%' }"
+              :autofocus="true"
+              :indent-with-tab="true"
+              :lang="lang"
+              disabled="false"
+              tab-size="2"
+              :theme="'oneDark'"
+            />
           </a-form-item>
         </a-col>
       </a-row>
@@ -111,85 +102,152 @@
         </a-col>
       </a-row>
     </a-form>
-    <FieldEdit ref="modalRef" :loadData="loadData"></FieldEdit>
+    <FieldEdit ref="modalRef" :onSave="onFieldSave"></FieldEdit>
   </div>
 </template>
 
 <script lang="ts">
-import {defineComponent, reactive, ref, toRefs} from 'vue';
+import {defineComponent, reactive, ref, toRefs, watch} from 'vue';
 import {useTabsViewStore} from '@/store/modules/tabsView';
 import BUploadFile from "@/components/file/uploadFile.vue";
 import type {TableColumnsType} from 'ant-design-vue';
 import {save} from '@/api/common';
 import FieldEdit from "@/views/subject/fieldedit.vue";
+import {getDictionaryItemList} from "@/api/system/dictionary";
+import {Codemirror} from 'vue-codemirror'
+import {oneDark} from '@codemirror/theme-one-dark'
+import {sql, MySQL} from '@codemirror/lang-sql';
+import type {Subjectfield, Subject} from "@/views/subject/model";
 
 interface FormState {
-  dataModel: any;
+  dataModel: Subject;
 }
 
 export default defineComponent({
-  name: 'ClassroomEditForm',
+  name: 'subjectEditForm',
   components: {
-    BUploadFile,FieldEdit
+    BUploadFile, FieldEdit, Codemirror, MySQL, sql, oneDark
   },
   setup() {
-    const formState = reactive<FormState>({dataModel: {}});
+    const subject: Subject = {
+      subjectName: "",
+      tabCode: "",
+      tabName: "",
+      isReferences: 0,
+      tabDesc: ""
+    }
+    const formState = reactive<FormState>({dataModel: subject});
     const tabsViewStore = useTabsViewStore();
     const modalRef = ref();
+    const fieldData = ref<Subjectfield[]>([]);
+    const settingTypeList = ref([{name: '', value: ''}]);
+    const queryTypeList = ref([{name: '', value: ''}]);
+    const lang = sql();
+    const code = ref("");
+    let isEdit = false;
 
     const onFinish = () => {
-      formState.dataModel.device = data.value
-      save('', formState.dataModel).then(result => {
+      save('/subject/saveSubject', {dataModel: formState.dataModel, fieldList: fieldData.value}).then(result => {
+        debugger
         if (result) {
           onClose(1)
         }
       });
     };
-    const onFinishFailed = (errorInfo: any) => {
-      console.log('Failed:', errorInfo);
-    };
 
     const onClose = (reload: any) => {
-      tabsViewStore.closeCurrentTabByPath("/practicebase/classroom/edit");
-      tabsViewStore.openTab("/practicebase/classroom/list", {reload: reload});
+      tabsViewStore.closeCurrentTabByPath("/views/subjectedit");
+      tabsViewStore.openTab("views/subjectlist", {reload: reload});
     };
 
-    const loadData = async (id) => {
+    getDictionaryItemList({code: "queryType"}).then(data => {
+      queryTypeList.value = data;
+    });
+
+    getDictionaryItemList({code: "settingType"}).then(data => {
+      settingTypeList.value = data;
+    });
+
+    const onFieldSave = async (model: Subjectfield) => {
+      if (!isEdit) {
+        fieldData.value.push(model);
+      }
+      formState.dataModel.isReferences = fieldData.value.filter((x) => x.isForeignKey == 1).length > 0 ? 1 : 0;
+    }
+    const loadData = (id) => {
       console.log(id)
     }
-
     const columns: TableColumnsType = [
       {
         title: '序号', width: 80, dataIndex: 'num', key: 'num', align: "center", customRender: ({index}) => {
           return `${index + 1}`;
         }
       },
-      {title: '设备名称', dataIndex: 'name', key: 'name', align: "center"},
-      {title: '设备型号', dataIndex: 'typeName', key: 'typeName', align: "center"},
-      {title: '数量', dataIndex: 'qty', key: 'qty', align: "center"},
+      {title: '字段编码', dataIndex: 'fieldCode', key: 'fieldCode', align: "center"},
+      {title: '字段名称', dataIndex: 'fieldName', key: 'fieldName', align: "center"},
+      {
+        title: '配置类型', dataIndex: 'settingTypeId', key: 'settingTypeId', align: "center", customRender: ({record}) => {
+          return settingTypeList.value.filter(x => x.value == record.settingTypeId)[0]?.name;
+        }
+      },
+      {
+        title: '是否查询字段', dataIndex: 'isSearchField', key: 'isSearchField', align: "center", customRender: ({record}) =>
+          record.isSearchField == "1" ? "是" : "否"
+      },
+      {
+        title: '查询类型', dataIndex: 'queryTypeId', key: 'queryTypeId', align: "center", customRender: ({record}) =>
+          queryTypeList.value.filter(x => x.value == record.queryTypeId)[0]?.name
+      },
+      {title: '取数字典编码', dataIndex: 'dictionaryCode', key: 'dictionaryCode', align: "center"},
+      {title: '显示排序', dataIndex: 'disOrder', key: 'disOrder', align: "center"},
+      {
+        title: '是否关联字段', dataIndex: 'isForeignKey', key: 'isForeignKey', align: "center", customRender: ({record}) =>
+          record.isForeignKey == "1" ? "是" : "否"
+      },
+      {title: '显示别名', dataIndex: 'fieldAlias', key: 'fieldAlias', align: "center"},
+      {title: '外键表', dataIndex: 'referencesTab', key: 'referencesTab', align: "center"},
+      {title: '外键列', dataIndex: 'foreignKey', key: 'foreignKey', align: "center"},
+      {title: '外键表显示列', dataIndex: 'displayColumn', key: 'displayColumn', align: "center"},
       {title: '操作', key: 'operation', fixed: 'right', width: 120, align: "center"},
     ];
-    const isEdit = true;
     const data = ref([]);
 
     const add = () => {
-      modalRef.value.show(formState.dataModel.subid);
+      isEdit = false;
+      modalRef.value.show(null);
+    }
+    const edit = (record) => {
+      isEdit = true;
+      modalRef.value.show(record);
     }
-    const deleteDevice = (record) => {
-      (data.value as any[]).splice(record, 1);
-      // delDev();
+    const onDelete = (record) => {
+      fieldData.value.splice(record, 1);
     }
+    watch(
+      () => [formState.dataModel.tabCode, fieldData],
+      () => {
+        code.value = ` select ${formState.dataModel.tabCode}.*`;
+        fieldData.value.filter(x => x.isForeignKey == 1).forEach(x => {
+          code.value += `,${x.referencesTab}.${x.displayColumn} as ${x.fieldAlias}`
+        })
+        code.value += ` from ${formState.dataModel.tabCode}`;
+        fieldData.value.filter(x => x.isForeignKey == 1).forEach(x => {
+          code.value += ` left join ${x.referencesTab} on ${formState.dataModel.tabCode}.${x.fieldCode}=${x.referencesTab}.${x.foreignKey}`
+        })
+      }, {deep: true}
+    );
     return {
       ...toRefs(formState),
-      onFinish,
-      onFinishFailed,
-      loadData,
-      onClose,
-      add,
-      deleteDevice,
+      onFinish, onFieldSave, onClose, add,
+      edit,
+      onDelete,
+      loadData, oneDark,
+      fieldData,
       columns,
       isEdit,
       data,
+      lang,
+      code,
       modalRef,
     };
   },

+ 94 - 67
vue/src/views/subject/fieldedit.vue

@@ -7,7 +7,7 @@
     :keyboard="false"
     :footer="null"
     :mask-closable="false">
-    <Form :ref="modalFormRef" :model="dataModel" autocomplete="off">
+    <Form :ref="modalFormRef" :model="dataModel" @finish="handleOk" autocomplete="off">
       <a-divider orientation="left">基础信息</a-divider>
       <a-row type="flex">
         <a-col :span="7">
@@ -24,13 +24,6 @@
             </a-input>
           </a-form-item>
         </a-col>
-        <a-col :span="7">
-          <a-form-item label="显示别名" name="fieldAlias" :label-col="{span:7}"
-                       :rules="[{ required: true, message: '请填写显示别名!' }]">
-            <a-input v-model:value="dataModel.fieldAlias" placeholder="">
-            </a-input>
-          </a-form-item>
-        </a-col>
       </a-row>
       <a-row type="flex">
         <a-col :span="7">
@@ -67,7 +60,7 @@
             </a-select>
           </a-form-item>
         </a-col>
-        <a-col :span="7">
+        <a-col :span="7" v-if="dataModel.queryTypeId==8">
           <a-form-item label="取数字典编码" name="dictionaryCode" :label-col="{span:7}"
                        :rules="[{ required: true, message: '请选择数据类型!' }]">
             <a-input v-model:value="dataModel.dictionaryCode" placeholder="">
@@ -75,38 +68,68 @@
           </a-form-item>
         </a-col>
         <a-col :span="7">
-          <a-form-item label="是否查询字段" name="isSearchField" :label-col="{span:7}">
-            <a-radio-group v-model:value="dataModel.isSearchField">
-              <a-radio :value="1">是</a-radio>
-              <a-radio :value="0">否</a-radio>
-            </a-radio-group>
+          <a-form-item label="显示排序" name="disOrder" :label-col="{span:7}" :rules="[{ required: true, message: '请输入显示排序!' }]">
+            <a-input-number v-model:value="dataModel.disOrder">
+            </a-input-number>
           </a-form-item>
         </a-col>
       </a-row>
-      <a-divider orientation="left">问题描述</a-divider>
-      <a-row>
-        <a-textarea :auto-size="{ minRows: 4, maxRows: 10 }" v-model:value="dataModel.problemDesc"
-                    :disabled="isDetail"/>
-      </a-row>
-      <a-row style="height: 20px"></a-row>
       <a-row type="flex">
         <a-col :span="7">
-          <a-form-item label="是否解决" name="IsResolve" :label-col="{span:7}">
-            <a-radio-group v-model:value="dataModel.isResolve">
+          <a-form-item label="是否关联字段" name="isForeignKey" :label-col="{span:7}">
+            <a-radio-group v-model:value="dataModel.isForeignKey">
               <a-radio :value="1">是</a-radio>
               <a-radio :value="0">否</a-radio>
             </a-radio-group>
           </a-form-item>
         </a-col>
+        <a-col :span="7" v-if="dataModel.isForeignKey==1">
+          <a-form-item label="显示别名" name="fieldAlias" :label-col="{span:7}"
+                       :rules="[{ required: true, message: '请填写显示别名!' }]">
+            <a-input v-model:value="dataModel.fieldAlias" placeholder="">
+            </a-input>
+          </a-form-item>
+        </a-col>
+      </a-row>
+      <a-row type="flex"  v-if="dataModel.isForeignKey==1">
+        <a-col :span="7">
+          <a-form-item label="外键表" name="referencesTab" :label-col="{span:7}"
+                       :rules="[{ required: true, message: '请输入外键表!' }]">
+            <a-input v-model:value="dataModel.referencesTab" placeholder="">
+            </a-input>
+          </a-form-item>
+        </a-col>
         <a-col :span="7">
-          <a-form-item label="解决时间" name="ResolveDate" :label-col="{span:7}">
-            <label v-if="isDetail">{{ resolveDateDetail }}</label>
-            <a-date-picker name="resolveDate2" v-model:value="dataModel.resolveDate" value-format="YYYY-MM-DD"
-                           placeholder="请选择解决时间" v-if="!isDetail"/>
+          <a-form-item label="外键列" name="foreignKey" :label-col="{span:7}"
+                       :rules="[{ required: true, message: '请输入外键列!' }]">
+            <a-input v-model:value="dataModel.foreignKey" placeholder="">
+            </a-input>
+          </a-form-item>
+        </a-col>
+        <a-col :span="7">
+          <a-form-item label="外键表显示列" name="displayColumn" :label-col="{span:7}" :rules="[{ required: true, message: '请输入外键表显示列!' }]">
+            <a-input v-model:value="dataModel.displayColumn" placeholder="">
+            </a-input>
+          </a-form-item>
+        </a-col>
+      </a-row>
+      <a-row v-if="dataModel.isForeignKey==1">
+        <a-col :span="21">
+          <a-form-item label="sql预览" name="displayColumn" :label-col="{span:2}" >
+            <codemirror
+              v-model="code"
+              :style="{ height: '100px',width:'100%' }"
+              :autofocus="true"
+              :indent-with-tab="true"
+              :lang="lang"
+              disabled="false"
+              tab-size="2"
+              :theme="oneDark"
+            />
           </a-form-item>
         </a-col>
-        <a-col :span="10"></a-col>
       </a-row>
+      <a-row style="height: 20px"></a-row>
       <a-row type="flex">
         <a-col :span="24" style="text-align: right;margin-right: 20px;">
           <a-button type="primary" html-type="submit">提交</a-button>
@@ -117,19 +140,22 @@
 </template>
 <script lang="ts">
 import {Form} from 'ant-design-vue';
-import {defineComponent, ref} from "vue";
+import {defineComponent, reactive, ref, watch} from "vue";
 import BUploadFile from "@/components/file/uploadFile.vue";
 import type {SelectProps} from "ant-design-vue";
 import {getDictionaryItemList} from "@/api/system/dictionary";
-import {get, save} from "@/api/common";
 import type {FormInstance} from 'ant-design-vue';
 import {DataTypeList} from '@/enums/dictions';
+import { Codemirror } from 'vue-codemirror'
+import { oneDark } from '@codemirror/theme-one-dark'
+import { sql, MySQL } from '@codemirror/lang-sql';
+import type {Subjectfield} from "@/views/subject/model";
 
 export default defineComponent({
   name: 'FieldEdit',
-  components: {BUploadFile, Form},
+  components: {BUploadFile, Form,Codemirror,MySQL,sql,oneDark},
   props: {
-    loadData: {
+    onSave: {
       type: Function,
       default: null
     }
@@ -138,26 +164,37 @@ export default defineComponent({
     const visible = ref<boolean>(false);
     const confirmLoading = ref<boolean>(false);
     const modalFormRef = ref<FormInstance>();
-
-    const dataModel = ref({
+    const defaultValue = reactive<Subjectfield>({
       fieldCode: "",
       fieldName: "",
       fieldAlias: "",
       settingTypeId: "",
-      fieldDesc: null,
+      fieldDesc: "",
       dataType: null,
       queryTypeId: "",
       isSearchField: 1,
-      dictionaryCode:''
+      dictionaryCode: '',
+      isForeignKey: 0,
+      foreignKey: '',
+      displayColumn: '',
+      referencesTab: ''
     });
+    const dataModel = ref({...defaultValue});
     const settingTypeList = ref<SelectProps['options']>();
     const queryTypeList = ref<SelectProps['options']>();
-
-    const fileList = ref();
     const title = ref();
-    const isAllowCommit = ref<boolean>(false);
-    const isDetail = ref<boolean>(false);
 
+    const lang=sql();
+    const code =ref("");
+    const options = {
+      disabled: false,
+      indentWithTab: true,
+      tabSize: 2,
+      autofocus: true,
+      height: 'auto',
+      language: 'javascript',
+      theme:'oneDark'
+    }
     getDictionaryItemList({code: "settingType"}).then(data => {
       settingTypeList.value = data;
     });
@@ -165,55 +202,45 @@ export default defineComponent({
       queryTypeList.value = data;
     });
 
-    const show = (id: any) => {
-      loadData(id);
+    const show = (record: any) => {
+      if(record==null) {
+        record = {...defaultValue} ;
+      }
+      dataModel.value =record;
       title.value = "主题字段定义";
       visible.value = true;
     };
 
 
     const handleOk = () => {
-      save('', dataModel).then(result => {
-        if (result) {
-          visible.value = false;
-          props.loadData();
-        }
-      });
+      props.onSave(dataModel.value);
+      visible.value=false;
     };
 
     const handleCancel = () => {
       visible.value = false;
     };
 
-    const setFileList = (files) => {
-      fileList.value = files;
-    }
-
-
-    const loadData = (id: string) => {
-      get('', id).then((result: any) => {
-        console.log(result);
-      });
-    }
-
+    watch(
+      () => [dataModel.value.fieldCode,dataModel.value.fieldAlias,dataModel.value.foreignKey,dataModel.value.referencesTab,dataModel.value.displayColumn],
+      () => {
+       code.value=` select 主表.*,${dataModel.value.referencesTab}.${dataModel.value.displayColumn} as ${dataModel.value.fieldAlias} from 主表 ` +
+         `inner join ${dataModel.value.referencesTab}  on 主表.${dataModel.value.fieldCode} =${dataModel.value.referencesTab}.${dataModel.value.foreignKey}`
+      },
+    );
     return {
       dataModel,
       modalFormRef,
-      isAllowCommit,
-      isDetail,
-      visible,
-      title,
+      visible,title,options,code,oneDark,lang,
       confirmLoading,
       settingTypeList,
       DataTypeList,
       queryTypeList,
-      show,
-      handleOk,
-      handleCancel,
-      setFileList,
+      show, handleOk,handleCancel,
     };
   },
-  created() {
+  mounted() {
+
   },
 })
 </script>

+ 23 - 0
vue/src/views/subject/model.ts

@@ -0,0 +1,23 @@
+export interface Subject {
+  subjectName: string,
+  tabCode: string,
+  tabName: string,
+  isReferences: number | null,
+  tabDesc: string
+}
+
+export interface Subjectfield {
+  fieldCode: string,
+  fieldName: string,
+  fieldAlias: string,
+  settingTypeId: string,
+  fieldDesc: string,
+  dataType: number | null,
+  queryTypeId: string,
+  isSearchField: number,
+  dictionaryCode: string,
+  isForeignKey: number,
+  foreignKey: string,
+  displayColumn: string,
+  referencesTab: string
+}