Browse Source

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	vue/src/views/query/table.vue
周壕 1 year ago
parent
commit
0be4f9fa02

+ 10 - 2
src/main/java/com/bowintek/practice/controller/TempController.java

@@ -10,6 +10,7 @@ import com.bowintek.practice.services.service.AccountService;
 import com.bowintek.practice.services.service.GenSqlStringService;
 import com.bowintek.practice.services.service.TempService;
 import com.bowintek.practice.services.service.system.RoleService;
+import com.bowintek.practice.vo.SaerchtempVo;
 import com.bowintek.practice.vo.system.FunctionCodeModel;
 import com.bowintek.practice.vo.system.RoleFunctionCodeModel;
 import com.bowintek.practice.vo.system.RoleModel;
@@ -38,9 +39,9 @@ public class TempController {
 
     @ResponseBody
     @GetMapping("/getList")
-    public BaseResponse<PageInfo<SrSaerchtemp>> getList(@RequestParam("page") int page, @RequestParam("rows") int rows,
+    public BaseResponse<PageInfo<SaerchtempVo>> getList(@RequestParam("page") int page, @RequestParam("rows") int rows,
                                                         String tempNo, String tempName) throws Exception {
-        PageInfo<SrSaerchtemp> result = tempService.getList(page, rows, tempNo, tempName, null);
+        PageInfo<SaerchtempVo> result = tempService.getList(page, rows, tempNo, tempName, null);
         return RespGenerstor.success(result);
     }
 
@@ -81,4 +82,11 @@ public class TempController {
         }
         return RespGenerstor.success(rtnObject);
     }
+    @ResponseBody
+    @PostMapping("/deletes")
+    public BaseResponse delete(@RequestBody List<String> idList) {
+        Integer result = tempService.deleteTemp(idList);
+
+        return RespGenerstor.success(result);
+    }
 }

+ 2 - 1
src/main/java/com/bowintek/practice/mapper/cquery/TempCQuery.java

@@ -1,6 +1,7 @@
 package com.bowintek.practice.mapper.cquery;
 
 import com.bowintek.practice.model.*;
+import com.bowintek.practice.vo.SaerchtempVo;
 import com.bowintek.practice.vo.system.RoleFunctionCodeModel;
 import org.apache.ibatis.annotations.Param;
 
@@ -8,7 +9,7 @@ import java.util.HashMap;
 import java.util.List;
 
 public interface TempCQuery {
-    List<SrSaerchtemp> getList(String tempNo, String tempName, String tempIdsString);
+    List<SaerchtempVo> getList(String tempNo, String tempName, String tempIdsString);
     List<HashMap<String,Object>> getListBySqlString(String sqlString);
     List<HashMap<String,Object>> getListToHashMap(String tempName);
     Integer batchInsertDimension(@Param("dataList") List<SrTempdimension> dataList);

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

@@ -62,6 +62,8 @@ public class SubjectServiceImpl implements SubjectService {
 
         if (model.getIsReferences() == 0) {
             model.setExecSql(model.getTabCode());
+        }else{
+            model.setExecSql(model.getExecSql().replaceAll("\\n",""));
         }
         SrSubject dbData = subjectMapper.selectByPrimaryKey(model.getSubId());
         int result = 0;

+ 27 - 17
src/main/java/com/bowintek/practice/services/impl/TempServiceImpl.java

@@ -9,6 +9,7 @@ import com.bowintek.practice.services.service.TempService;
 import com.bowintek.practice.services.service.UserService;
 import com.bowintek.practice.util.DateUtils;
 import com.bowintek.practice.util.StringUtils;
+import com.bowintek.practice.vo.SaerchtempVo;
 import com.bowintek.practice.vo.temp.TempObjectModel;
 import com.bowintek.practice.vo.temp.TempSaveResult;
 import com.bowintek.practice.vo.user.DataRange;
@@ -35,19 +36,19 @@ public class TempServiceImpl implements TempService {
     private StringUtils stringUtils;
 
     @Override
-    public PageInfo<SrSaerchtemp> getList(Integer page, Integer rows,
-                                       String tempNo, String tempName, List<String> idList) {
+    public PageInfo<SaerchtempVo> getList(Integer page, Integer rows,
+                                          String tempNo, String tempName, List<String> idList) {
         PageHelper.startPage(page, rows);
 
-        List<SrSaerchtemp> dataList = tempCQuery.getList(tempNo, tempName,
+        List<SaerchtempVo> dataList = tempCQuery.getList(tempNo, tempName,
                 stringUtils.ListToInSql(idList));
 
-        PageInfo<SrSaerchtemp> result = new PageInfo(dataList);
+        PageInfo<SaerchtempVo> result = new PageInfo(dataList);
         return result;
     }
 
     @Override
-    public TempObjectModel getTemp(String tempId){
+    public TempObjectModel getTemp(String tempId) {
         TempObjectModel data = new TempObjectModel();
         data.temp = srSaerchtempMapper.selectByPrimaryKey(tempId);
         data.sub = srSubjectMapper.selectByPrimaryKey(data.temp.getSubId());
@@ -59,18 +60,27 @@ public class TempServiceImpl implements TempService {
     }
 
     @Override
-    public TempSaveResult saveTemp(TempObjectModel data, String userID){
+    public int deleteTemp(List<String> idList) {
+        tempCQuery.deletesDimensionByTempId(idList);
+        tempCQuery.deletesFieldByTempId(idList);
+        tempCQuery.deletesMeasureByTempId(idList);
+        SrSaerchtempExample example=new SrSaerchtempExample();
+        example.or().andTempIdIn(idList);
+        return srSaerchtempMapper.deleteByExample(example);
+    }
+
+    @Override
+    public TempSaveResult saveTemp(TempObjectModel data, String userID) {
         TempSaveResult rtn = new TempSaveResult();
         //保存模板主表
-        if(data.temp.getTempId().isEmpty()){
+        if (data.temp.getTempId().isEmpty()) {
             rtn.tempId = UUID.randomUUID().toString();
             data.temp.setTempId(UUID.randomUUID().toString());
             data.temp.setCreateTime(new Date());
             data.temp.setCreatedBy(userID);
             data.temp.setStatus(0);
             rtn.effectCount += srSaerchtempMapper.insert(data.temp);
-        }
-        else{
+        } else {
             rtn.tempId = data.temp.getTempId();
             data.temp.setModifyTime(new Date());
             data.temp.setModifyBy(userID);
@@ -81,15 +91,15 @@ public class TempServiceImpl implements TempService {
             tempCQuery.deletesMeasureByTempId(Arrays.asList(data.temp.getTempId()));
         }
 
-        data.bases.forEach(row->{
+        data.bases.forEach(row -> {
             row.setTempFeildId(UUID.randomUUID().toString());
             row.setTempId(data.temp.getTempId());
         });
-        data.wheres.forEach(row->{
+        data.wheres.forEach(row -> {
             row.setTempFeildId(UUID.randomUUID().toString());
             row.setTempId(data.temp.getTempId());
         });
-        data.measures.forEach(row->{
+        data.measures.forEach(row -> {
             row.setTempFeildId(UUID.randomUUID().toString());
             row.setTempId(data.temp.getTempId());
         });
@@ -106,7 +116,7 @@ public class TempServiceImpl implements TempService {
     public List<HashMap<String, Object>> getSubjectTree(String likeName) {
         List<HashMap<String, Object>> subjectTrees = subjectCQuery.getListToHashMap(likeName);
         List<String> subIdList = subjectTrees.stream()
-                .map(m->m.get("subId").toString())
+                .map(m -> m.get("subId").toString())
                 .collect(Collectors.toList());
         List<HashMap<String, Object>> subFields = subjectCQuery.getSubjectFieldToHashMapList(subIdList);
 
@@ -122,14 +132,14 @@ public class TempServiceImpl implements TempService {
             HashMap<String, Object> dimension = new HashMap<>();
             dimension.put("title", "维度");
             dimension.put("key", sub.get("subId").toString() + "-维度");
-            dimension.put("children", findSubjectFields(subFields, subId, Arrays.asList(new Integer[]{1}),subjectName, "维度"));
+            dimension.put("children", findSubjectFields(subFields, subId, Arrays.asList(new Integer[]{1}), subjectName, "维度"));
             groups.add(dimension);
 
             //生成度量
             HashMap<String, Object> measure = new HashMap<>();
             measure.put("title", "度量");
             measure.put("key", sub.get("subId").toString() + "-度量");
-            measure.put("children", findSubjectFields(subFields, subId, Arrays.asList(new Integer[]{2}),subjectName, "度量"));
+            measure.put("children", findSubjectFields(subFields, subId, Arrays.asList(new Integer[]{2}), subjectName, "度量"));
             groups.add(measure);
 
             sub.put("children", groups);
@@ -142,10 +152,10 @@ public class TempServiceImpl implements TempService {
                                                            String subId,
                                                            List<Integer> queryTypeIds,
                                                            String subjectName,
-                                                           String groupName){
+                                                           String groupName) {
         List<HashMap<String, Object>> fields = subFields.stream()
                 .filter(x -> subId.equals((String) x.get("subId"))
-                        && queryTypeIds.indexOf(x.get("settingTypeId"))>=0)
+                        && queryTypeIds.indexOf(x.get("settingTypeId")) >= 0)
                 .collect(Collectors.toList());
 
         //生成树标题,key

+ 3 - 1
src/main/java/com/bowintek/practice/services/service/TempService.java

@@ -2,6 +2,7 @@ package com.bowintek.practice.services.service;
 
 import com.bowintek.practice.model.SrSaerchtemp;
 import com.bowintek.practice.model.SysMenu;
+import com.bowintek.practice.vo.SaerchtempVo;
 import com.bowintek.practice.vo.temp.TempObjectModel;
 import com.bowintek.practice.vo.temp.TempSaveResult;
 import com.github.pagehelper.PageInfo;
@@ -10,9 +11,10 @@ import java.util.HashMap;
 import java.util.List;
 
 public interface TempService {
-    PageInfo<SrSaerchtemp> getList(Integer page, Integer rows,
+    PageInfo<SaerchtempVo> getList(Integer page, Integer rows,
                                    String tempNo, String tempName, List<String> idList);
     List<HashMap<String,Object>> getSubjectTree(String likeName);
     TempSaveResult saveTemp(TempObjectModel data, String userID);
     TempObjectModel getTemp(String tempId);
+    int deleteTemp(List<String> idList);
 }

+ 10 - 0
src/main/java/com/bowintek/practice/vo/SaerchtempVo.java

@@ -0,0 +1,10 @@
+package com.bowintek.practice.vo;
+
+import com.bowintek.practice.model.SrSaerchtemp;
+import lombok.Data;
+
+@Data
+public class SaerchtempVo extends SrSaerchtemp {
+    private String dimensionName;
+    private String measurName;
+}

+ 8 - 2
src/main/resources/mapping/cquery/TempCQuery.xml

@@ -1,9 +1,15 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
 <mapper namespace="com.bowintek.practice.mapper.cquery.TempCQuery">
-    <select id="getList" resultType="com.bowintek.practice.model.SrSaerchtemp">
-        select *
+    <select id="getList" resultType="com.bowintek.practice.vo.SaerchtempVo">
+        select tmp.*,td.dimensionName,tm.measurName
         from sr_saerchtemp tmp
+        left join(
+        select d.tempId,group_concat(d.fieldName) dimensionName from  sr_tempDimension d group by d.tempId
+        ) td on tmp.tempId = td.tempId
+        left join(
+        select m.tempId,group_concat(concat(m.fieldName,'(',m.operation,')')) measurName from  sr_tempMeasure m group by m.tempId
+        ) tm on tmp.tempId = tm.tempId
         where 1=1
         <if test="tempName!='' and tempName!=null">
             and tmp.tempName like Concat('%',#{tempName},'%')

BIN
target/classes/com/bowintek/practice/vo/common/ImportBaseModel.class


BIN
target/classes/com/bowintek/practice/vo/practicebase/ImportPositionModel.class


+ 5 - 0
vue/package-lock.json

@@ -12849,6 +12849,11 @@
       "integrity": "sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==",
       "dev": true
     },
+    "thememirror": {
+      "version": "2.0.1",
+      "resolved": "https://registry.npmmirror.com/thememirror/-/thememirror-2.0.1.tgz",
+      "integrity": "sha512-d5i6FVvWWPkwrm4cHLI3t9AT1OrkAt7Ig8dtdYSofgF7C/eiyNuq6zQzSTusWTde3jpW9WLvA9J/fzNKMUsd0w=="
+    },
     "thenify": {
       "version": "3.3.1",
       "resolved": "https://registry.npmmirror.com/thenify/-/thenify-3.3.1.tgz",

+ 1 - 0
vue/package.json

@@ -39,6 +39,7 @@
     "@codemirror/lang-sql": "^6.x",
     "@codemirror/language": "^6.x",
     "@codemirror/theme-one-dark": "^6.x",
+    "thememirror": "^2.0.1",
     "animate.css": "^4.1.1",
     "ant-design-vue": "3.2.17",
     "axios": "~0.27.2",

+ 2 - 2
vue/src/plugins/antd.ts

@@ -19,7 +19,7 @@ import {
   Switch,
   Space, Cascader,
   Tree,
-  Transfer,Image,Progress,List,Avatar,Badge,Spin,Pagination
+  Transfer,Image,Progress,List,Avatar,Badge,Spin,Pagination,Popover
 } from 'ant-design-vue';
 import type { App } from 'vue';
 //导入组件库
@@ -68,5 +68,5 @@ export function setupAntd(app: App<Element>) {
     .use(Transfer)
     .use(Cascader)
     .use(Image)
-    .use(Tree).use(Progress).use(List).use(Avatar).use(Badge).use(Spin).use(Pagination);
+    .use(Tree).use(Progress).use(List).use(Avatar).use(Badge).use(Spin).use(Pagination).use(Popover);
 }

+ 105 - 24
vue/src/views/query/table.vue

@@ -24,28 +24,74 @@
             <a-input v-model:value="formState.tempNo" style="width: 200px"></a-input>
           </a-form-item>
         </a-col>
-        <a-col  :span="6" style="text-align: left">
+        <a-col :span="6" style="text-align: left">
           <a-button type="primary" html-type="submit" @click="onFinish">查询</a-button>
           <a-button style="margin: 0 8px" @click="() => {formRef.resetFields();loadData()}">重置</a-button>
         </a-col>
       </a-row>
       <a-row class="edit-operation">
         <a-col :span="24" style="text-align: right">
-          <a-button type="primary" html-type="button" @click="add" functioncode="T010601">新增</a-button>
+          <a-radio-group v-model:value="viewModel" style="text-align: left">
+            <a-radio-button value="list">列表</a-radio-button>
+            <a-radio-button value="card">卡片</a-radio-button>
+          </a-radio-group>
+          <a-button type="primary" html-type="button" @click="add">
+            <template #icon>
+              <PlusOutlined  />
+            </template>
+            添加搜索模板
+          </a-button>
           <a-popconfirm placement="leftTop"
-            title="是否删除模板数据?"
-            @confirm="onDelete()">
-            <a-button type="primary" style="margin: 0 8px" html-type="button" functioncode="T010604">删除</a-button>
+                        title="是否删除模板?"
+                        @confirm="onDelete()">
+            <a-button type="primary" style="margin: 0 8px" html-type="button">删除</a-button>
           </a-popconfirm>
         </a-col>
       </a-row>
     </a-form>
-    <div class="search-result-list">
+    <div class="search-result-list" v-if="viewModel=='card'">
+      <a-spin :spinning="loading">
+        <a-row :gutter="[24,8]">
+        <a-col :span="6" v-for="item in data">
+          <a-card :title="item.tempName" >
+            <template #extra>
+              <a-button type="link" @click="edit(item.tempId)">查看详情</a-button>
+            </template>
+            <template class="ant-card-actions" #actions>
+              <FormOutlined  key="edit" @click="edit(item.tempId)"/>
+              <a-popconfirm placement="leftTop"
+                            title="是否删除数据?"
+                            @confirm="deleteSingle(item.tempId)">
+                <DeleteOutlined  key="ellipsis"/>
+              </a-popconfirm>
+            </template>
+            <a-popover title="详细信息" :visible="item.visible">
+              <template #content>
+                <p>维度:{{ item.dimensionName }}</p>
+                <p>度量:{{ item.measurName }}</p>
+              </template>
+            </a-popover>
+            <a-row :gutter="[24,4]" @mouseover="item.visible=true"  @mouseout="item.visible=false">
+              <a-col :span="10" class="col-text">维度:</a-col>
+              <a-col :span="12" class="col-content" >{{ item.dimensionName }}</a-col>
+              <a-col :span="10" class="col-text">度量:</a-col>
+              <a-col :span="12" class="col-content" >{{ item.measurName }}</a-col>
+              <a-col :span="10" class="col-text">创建人:</a-col>
+              <a-col :span="12">{{ item.createdName }}</a-col>
+              <a-col :span="10" class="col-text">创建/更新日期:</a-col>
+              <a-col :span="12">{{ dayjs(item.createTime ?? item.modifyTime).format('YYYY-MM-DD') }}</a-col>
+              <a-col :span="10" class="col-text">备注:</a-col>
+              <a-col :span="12" class="col-content">{{ item.remark }}</a-col>
+            </a-row>
+          </a-card>
+        </a-col>
+      </a-row>
+      </a-spin>
+    </div>
+    <div class="search-result-list" v-else="viewModel=='list'">
       <a-table :columns="columns" :data-source="data" :scroll="{ x:'100%', y: 500 }"
-               :pagination="pagination"
                :loading="loading"
-               :row-selection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
-               @change="handleTableChange" :row-key="record=>record.positionID"
+               :row-selection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange}" :row-key="record=>record.tempId"
                bordered>
         <template #bodyCell="{ column,record }">
           <template v-if="column.key === 'operation'">
@@ -54,6 +100,10 @@
         </template>
       </a-table>
     </div>
+    <a-pagination :page-size-options="['5', '20', '30', '40', '50']" show-size-changer v-model:current="pagination.current" :total="pagination.total" style="float: right;margin-top: 10px;"
+                  :pageSize="pagination.pageSize" :show-total="total => `共 ${total} 条`"
+                  @change="(current)=>handleTableChange({ current: current,pageSize: pagination.pageSize })"
+                  @showSizeChange="(current,pageSize)=>handleTableChange({ current: current,pageSize: pageSize })"/>
   </div>
 </template>
 
@@ -61,7 +111,7 @@
 import {reactive, ref, defineComponent, computed} from 'vue';
 import type {FormInstance} from 'ant-design-vue';
 import type {TableColumnsType, TableProps} from 'ant-design-vue';
-import { get, postdel} from '@/api/common';
+import {get, postdel} from '@/api/common';
 import {useRoute, useRouter} from "vue-router";
 import {useTabsViewStore} from "@/store/modules/tabsView";
 import {message} from "ant-design-vue";
@@ -78,11 +128,11 @@ export default defineComponent({
     const expand = ref(false);
     const formRef = ref<FormInstance>();
     const tabsViewStore = useTabsViewStore();
-    const selectedRowKeys =ref([]) ;
+    const selectedRowKeys = ref([]);
+    const viewModel = ref("card");
     const formState = reactive({
-      page: 1, rows: 10, tempName: '', tempNo: '', tempId: "", total: 0,isPostManage:true
+      page: 1, rows: 10, tempName: '', tempNo: '', tempId: "", total: 0, isPostManage: true
     });
-
     const columns: TableColumnsType = [
       {
         title: '序号',
@@ -92,13 +142,17 @@ export default defineComponent({
         align: "center",
         customRender: item => `${formState.rows * (formState.page - 1) + item.index + 1}`
       },
-      {title: '模板编号', dataIndex: 'tempNo', key: 'tempNo', width:180,align:"center"},
-      {title: '模板名称', dataIndex: 'tempName', key: '1', width:300},
-      {title: '创建时间', dataIndex: 'createTime', key: '2', width: 180, customRender: ({record}) =>
-          record.createTime==null?"": (dayjs(record.createTime).format('YYYY-MM-DD HH:mm'))},
-      {title: '模板状态', dataIndex: 'status', key: '3', width: 100,align:"center", customRender: ({record}) =>
-          record.status==0?"正常":"禁用"},
-      {title: '备注', dataIndex: 'remark', key: '4',ellipsis: true},
+      {title: '模板编号', dataIndex: 'tempNo', key: 'tempNo', width: 180, align: "center"},
+      {title: '模板名称', dataIndex: 'tempName', key: '1', width: 300},
+      {
+        title: '创建时间', dataIndex: 'createTime', key: '2', width: 180, customRender: ({record}) =>
+          record.createTime == null ? "" : (dayjs(record.createTime).format('YYYY-MM-DD HH:mm'))
+      },
+      {
+        title: '模板状态', dataIndex: 'status', key: '3', width: 100, align: "center", customRender: ({record}) =>
+          record.status == 0 ? "正常" : "禁用"
+      },
+      {title: '备注', dataIndex: 'remark', key: '4', ellipsis: true},
       {title: '操作', key: 'operation', width: 120, align: "center"},
     ];
 
@@ -141,6 +195,11 @@ export default defineComponent({
         loadData();
       })
     };
+    const deleteSingle=(id:string)=>{
+      postdel('temp/deletes', [id]).then(() => {
+        loadData();
+      })
+    }
     const add = () => {
       tabsViewStore.addTabByPath('/query/index', {});
     };
@@ -155,15 +214,15 @@ export default defineComponent({
       route,
       expand,
       formRef,
-      formState,
-      columns,data,loading,selectedRowKeys,
+      formState, viewModel, dayjs,
+      columns, data, loading, selectedRowKeys,
       pagination,
       handleTableChange,
       onSelectChange,
       onFinish,
       loadData,
-      add,
-      edit,onDelete
+      add,deleteSingle,
+      edit, onDelete
     };
   },
   created() {
@@ -175,3 +234,25 @@ export default defineComponent({
   }
 });
 </script>
+<style lang="less" scoped>
+.ant-card-actions {
+  margin: 0;
+  padding: 0;
+  list-style: none;
+  background: #fafafa;
+  border-top: 1px solid #f0f0f0;
+}
+
+.col-text {
+  padding-right: 0px !important;
+  text-align: right;
+  font-weight: bold;
+}
+
+.col-content {
+  width: 200px;
+  overflow: hidden;
+  text-overflow: ellipsis;
+  white-space: nowrap;
+}
+</style>

+ 10 - 6
vue/src/views/subject/detail.vue

@@ -15,12 +15,12 @@
     <a-divider orientation="left">Sql预览</a-divider>
     <codemirror
       v-model="dataModel.execSql"
-      :style="{ height: '100px',width:'100%' }"
+      :style="{ height: '100px',width:'100%' ,fontSize:'16px'}"
       :autofocus="true"
       :indent-with-tab="true"
       disabled="false"
       tab-size="2"
-      :theme="'oneDark'"
+      :extensions="[sql(),solarizedLight]"
     />
     <a-form-item class="buttom-btns">
       <a-button @click="onClose">关闭</a-button>
@@ -37,14 +37,14 @@ import {getDictionaryItemList} from "@/api/system/dictionary";
 import type {Subject, Subjectfield} from "@/views/subject/model";
 import {Codemirror} from 'vue-codemirror';
 import {MySQL, sql} from "@codemirror/lang-sql";
-import {oneDark} from "@codemirror/theme-one-dark";
+import {solarizedLight} from 'thememirror';
 import {useRoute} from "vue-router";
 import router from "@/router";
 
 export default defineComponent({
   name: 'subjectDetail',
   components: {
-    Codemirror, MySQL, sql, oneDark
+    Codemirror, MySQL, sql, solarizedLight
   },
   setup() {
     const tabsViewStore = useTabsViewStore();
@@ -84,6 +84,10 @@ export default defineComponent({
       },
       {title: '取数字典编码', dataIndex: 'dictionaryCode', key: 'dictionaryCode', align: "center"},
       {title: '显示排序', dataIndex: 'disOrder', key: 'disOrder', align: "center"},
+      {
+        title: '标签', dataIndex: 'tagList', key: 'tagList', align: "center", customRender: ({record}) =>
+          record.tagList == null ? "" : (record.tagList as []).join(",")
+      },
       {
         title: '是否关联字段', dataIndex: 'isForeignKey', key: 'isForeignKey', align: "center", customRender: ({record}) =>
           record.isForeignKey == "1" ? "是" : "否"
@@ -111,8 +115,8 @@ export default defineComponent({
     };
 
     return {
-      loadData,columns,fieldData,
-      onClose,
+      loadData,columns,fieldData,sql,
+      onClose,solarizedLight,
       dataModel,
       dayjs
     };

+ 12 - 14
vue/src/views/subject/edit.vue

@@ -81,14 +81,14 @@
         <a-col class="table-bottom-a1">
           <a-form-item :label-col="{span:8}" label="" name="remark">
             <codemirror
-              v-model="code"
-              :style="{ height: '100px',width:'100%' }"
+              v-model="dataModel.execSql"
+              :style="{ height: '100px',width:'100%' ,fontSize:'16px'}"
               :autofocus="true"
               :indent-with-tab="true"
               :lang="lang"
               disabled="false"
               tab-size="2"
-              :theme="'oneDark'"
+              :extensions="[sql(),solarizedLight]"
             />
           </a-form-item>
         </a-col>
@@ -117,7 +117,7 @@ import {get, 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 {solarizedLight} from 'thememirror';
 import {sql, MySQL} from '@codemirror/lang-sql';
 import type {Subjectfield, Subject} from "@/views/subject/model";
 import type {ImportProps} from "@/components/basic/excel/importExcel/ImportProps";
@@ -131,7 +131,7 @@ interface FormState {
 export default defineComponent({
   name: 'subjectEditForm',
   components: {
-    BUploadFile, FieldEdit, Codemirror, MySQL, sql, oneDark, BImportExcel
+    BUploadFile, FieldEdit, Codemirror, MySQL, sql, solarizedLight, BImportExcel
   },
   setup() {
     const subject: Subject = {
@@ -148,8 +148,6 @@ export default defineComponent({
     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 = () => {
@@ -280,13 +278,13 @@ export default defineComponent({
     watch(
       () => [formState.dataModel.tabCode, fieldData],
       () => {
-        code.value = ` select ${formState.dataModel.tabCode}.*`;
+        formState.dataModel.execSql = ` select ${formState.dataModel.tabCode}.* `;
         fieldData.value.filter(x => x.isForeignKey == 1).forEach(x => {
-          code.value += `,${x.referencesTab}.${x.displayColumn} as ${x.fieldAlias}`
+          formState.dataModel.execSql += `,${x.referencesTab}.${x.displayColumn} as ${x.fieldAlias}`
         })
-        code.value += ` from ${formState.dataModel.tabCode}`;
+        formState.dataModel.execSql += `\n 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}`
+          formState.dataModel.execSql += ` \n left join ${x.referencesTab} on ${formState.dataModel.tabCode}.${x.fieldCode}=${x.referencesTab}.${x.foreignKey}`
         })
       }, {deep: true}
     );
@@ -295,9 +293,9 @@ export default defineComponent({
       onFinish, onFieldSave, onClose, add, onImportSuccess,
       edit, importOptions,
       onDelete,
-      loadData, oneDark,
-      fieldData, columns,
-      isEdit, data, lang, code, modalRef,
+      loadData, solarizedLight,
+      fieldData, columns, sql,
+      isEdit, data,  modalRef,
     };
   },
   created() {

+ 6 - 8
vue/src/views/subject/fieldedit.vue

@@ -133,13 +133,12 @@
           <a-form-item label="sql预览" name="displayColumn" :label-col="{span:2}">
             <codemirror
               v-model="code"
-              :style="{ height: '100px',width:'100%' }"
+              :style="{ height: '100px',width:'100%' ,fontSize:'16px'}"
               :autofocus="true"
               :indent-with-tab="true"
-              :lang="lang"
               disabled="false"
               tab-size="2"
-              :theme="oneDark"
+              :extensions="[sql(),solarizedLight]"
             />
           </a-form-item>
         </a-col>
@@ -162,14 +161,14 @@ import {getDictionaryItemList} from "@/api/system/dictionary";
 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 {solarizedLight} from 'thememirror';
 import {sql, MySQL} from '@codemirror/lang-sql';
 import type {Subjectfield} from "@/views/subject/model";
 import {get} from '@/api/common';
 
 export default defineComponent({
   name: 'FieldEdit',
-  components: {BUploadFile, Form, Codemirror, MySQL, sql, oneDark},
+  components: {BUploadFile, Form, Codemirror, MySQL, sql, solarizedLight},
   props: {
     onSave: {
       type: Function,
@@ -202,7 +201,6 @@ export default defineComponent({
     const tagOptions = ref();
     const title = ref();
 
-    const lang = sql();
     const code = ref("");
     const options = {
       disabled: false,
@@ -246,13 +244,13 @@ export default defineComponent({
       () => {
         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}`
+          ` inner join ${dataModel.value.referencesTab}  on 主表.${dataModel.value.fieldCode} =${dataModel.value.referencesTab}.${dataModel.value.foreignKey}`
       },
     );
     return {
       dataModel,
       modalFormRef,
-      visible, title, options, code, oneDark, lang, tagOptions,
+      visible, title, options, code,sql, solarizedLight, tagOptions,
       confirmLoading,
       settingTypeList,
       DataTypeList,

+ 2 - 2
vue/src/views/subject/model.ts

@@ -4,7 +4,7 @@ export interface Subject {
   tabName: string,
   isReferences: number | null,
   tabDesc: string,
-  execSql:string
+  execSql: string
 }
 
 export interface Subjectfield {
@@ -21,5 +21,5 @@ export interface Subjectfield {
   foreignKey: string,
   displayColumn: string,
   referencesTab: string,
-  tagList:[]
+  tagList: []
 }