Commit b42d0a49 by yuwei

项目初始化

parent fb9168b4
......@@ -69,6 +69,11 @@
<artifactId>data-masterdata-service-api</artifactId>
<version>2.0.0</version>
</dependency>
<dependency>
<groupId>cn.datax</groupId>
<artifactId>data-standard-service-api</artifactId>
<version>2.0.0</version>
</dependency>
</dependencies>
<build>
......
package cn.datax.service.data.masterdata.service.impl;
import cn.datax.common.core.DataConstant;
import cn.datax.common.core.RedisConstant;
import cn.datax.common.exception.DataException;
import cn.datax.common.redis.service.RedisService;
import cn.datax.service.data.masterdata.api.entity.ModelColumnEntity;
import cn.datax.service.data.masterdata.api.entity.ModelEntity;
import cn.datax.service.data.masterdata.api.dto.ModelDto;
......@@ -11,9 +13,11 @@ import cn.datax.service.data.masterdata.mapstruct.ModelMapstruct;
import cn.datax.service.data.masterdata.service.ModelService;
import cn.datax.service.data.masterdata.dao.ModelDao;
import cn.datax.common.base.BaseServiceImpl;
import cn.datax.service.data.standard.api.entity.DictEntity;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -50,6 +54,12 @@ public class ModelServiceImpl extends BaseServiceImpl<ModelDao, ModelEntity> imp
@Autowired
private MysqlDynamicDao dynamicDao;
@Autowired
private RedisService redisService;
private static String BIND_GB_CODE = "gb_code";
private static String BIND_GB_NAME = "gb_name";
@Override
@Transactional(rollbackFor = Exception.class)
public ModelEntity saveModel(ModelDto modelDto) {
......@@ -143,8 +153,22 @@ public class ModelServiceImpl extends BaseServiceImpl<ModelDao, ModelEntity> imp
Map<String, Object> map = new HashMap<>(4);
map.put("column", s.getColumnName());
map.put("columnName", s.getColumnComment());
map.put("columnType", s.getColumnType());
map.put("columnScale", s.getColumnScale());
map.put("queryType", s.getQueryType());
map.put("htmlType", s.getHtmlType());
if (DataConstant.TrueOrFalse.TRUE.getKey().equals(s.getIsBindDict()) && StrUtil.isNotBlank(s.getBindDictTypeId())) {
String bindDictColumn = s.getBindDictColumn();
List<DictEntity> dictList = (List<DictEntity>) redisService.hget(RedisConstant.STANDARD_DICT_KEY, s.getBindDictTypeId());
List<Map<String, Object>> mapList = dictList.stream().map(d -> {
Map<String, Object> dictMap = new HashMap<>(4);
dictMap.put("id", d.getId());
dictMap.put("value", BIND_GB_CODE.equals(bindDictColumn) ? d.getGbCode() : d.getGbName());
dictMap.put("label", d.getGbName());
return dictMap;
}).collect(Collectors.toList());
map.put("dictList", mapList);
}
return map;
}).collect(Collectors.toList());
Map<String, Object> map = new HashMap<>(4);
......@@ -177,8 +201,18 @@ public class ModelServiceImpl extends BaseServiceImpl<ModelDao, ModelEntity> imp
map.put("isQuery", s.getIsQuery());
map.put("queryType", s.getQueryType());
map.put("isBindDict", s.getIsBindDict());
map.put("bindDictColumn", s.getBindDictColumn());
map.put("dictList", null);
if (DataConstant.TrueOrFalse.TRUE.getKey().equals(s.getIsBindDict()) && StrUtil.isNotBlank(s.getBindDictTypeId())) {
String bindDictColumn = s.getBindDictColumn();
List<DictEntity> dictList = (List<DictEntity>) redisService.hget(RedisConstant.STANDARD_DICT_KEY, s.getBindDictTypeId());
List<Map<String, Object>> mapList = dictList.stream().map(d -> {
Map<String, Object> dictMap = new HashMap<>(4);
dictMap.put("id", d.getId());
dictMap.put("value", BIND_GB_CODE.equals(bindDictColumn) ? d.getGbCode() : d.getGbName());
dictMap.put("label", d.getGbName());
return dictMap;
}).collect(Collectors.toList());
map.put("dictList", mapList);
}
map.put("htmlType", s.getHtmlType());
return map;
}).collect(Collectors.toList());
......
......@@ -54,6 +54,7 @@
<script>
import { validUsername } from '@/utils/validate'
import { log } from '@/api/system/user'
export default {
name: 'Login',
......@@ -112,6 +113,8 @@ export default {
this.$store.dispatch('user/login', this.loginForm).then(() => {
this.$router.push({ path: this.redirect || '/' })
this.loading = false
}).then(() => {
log()
}).catch(() => {
this.loading = false
})
......
......@@ -38,6 +38,40 @@
:precision="parseInt(item.columnScale)"
></el-input-number>
</template>
<template v-if="item.htmlType === 'select'">
<template v-if="item.isBindDict === '1' && item.dictList && item.dictList.length > 0">
<el-select v-model.trim="form[item.columnName]" placeholder="请选择">
<el-option
v-for="item in item.dictList"
:key="item.id"
:label="item.label"
:value="item.value">
</el-option>
</el-select>
</template>
</template>
<template v-if="item.htmlType === 'radio'">
<template v-if="item.isBindDict === '1' && item.dictList && item.dictList.length > 0">
<el-radio-group v-model.trim="form[item.columnName]">
<el-radio
v-for="item in item.dictList"
:key="item.id"
:label="item.value"
>{{ item.label }}</el-radio>
</el-radio-group>
</template>
</template>
<template v-if="item.htmlType === 'checkbox'">
<template v-if="item.isBindDict === '1' && item.dictList && item.dictList.length > 0">
<el-checkbox-group v-model.trim="form[item.columnName]">
<el-checkbox
v-for="item in item.dictList"
:key="item.id"
:label="item.value"
>{{ item.label }}</el-checkbox>
</el-checkbox-group>
</template>
</template>
<template v-if="item.htmlType === 'datetime'">
<template v-if="item.columnType === 'date'">
<el-date-picker
......@@ -125,6 +159,10 @@ export default {
const { data } = response
this.tableName = data.tableName
this.columnList = data.columnList.filter(item => item.isInsert === '1')
// checkbox特殊处理
this.columnList.filter(item => item.htmlType === 'checkbox').forEach((item, index, arr) => {
this.$set(this.form, item.columnName, [])
})
}
})
},
......@@ -136,11 +174,15 @@ export default {
submitForm: function() {
this.$refs['form'].validate(valid => {
if (valid) {
const data = { tableName: this.tableName, datas: this.form }
const data = JSON.parse(JSON.stringify(this.form))
// checkbox特殊处理
this.columnList.filter(item => item.htmlType === 'checkbox').forEach((item, index, arr) => {
this.$set(data, item.columnName, data[item.columnName].join(','))
})
this.loadingOptions.loading = true
this.loadingOptions.loadingText = '保存中...'
this.loadingOptions.isDisabled = true
addData(data).then(response => {
addData({ tableName: this.tableName, datas: data }).then(response => {
if (response.success) {
this.$message.success('保存成功')
setTimeout(() => {
......
......@@ -37,6 +37,40 @@
:precision="parseInt(item.columnScale)"
></el-input-number>
</template>
<template v-if="item.htmlType === 'select'">
<template v-if="item.isBindDict === '1' && item.dictList && item.dictList.length > 0">
<el-select v-model.trim="form[item.columnName]" placeholder="请选择">
<el-option
v-for="item in item.dictList"
:key="item.id"
:label="item.label"
:value="item.value">
</el-option>
</el-select>
</template>
</template>
<template v-if="item.htmlType === 'radio'">
<template v-if="item.isBindDict === '1' && item.dictList && item.dictList.length > 0">
<el-radio-group v-model.trim="form[item.columnName]">
<el-radio
v-for="item in item.dictList"
:key="item.id"
:label="item.value"
>{{ item.label }}</el-radio>
</el-radio-group>
</template>
</template>
<template v-if="item.htmlType === 'checkbox'">
<template v-if="item.isBindDict === '1' && item.dictList && item.dictList.length > 0">
<el-checkbox-group v-model.trim="form[item.columnName]">
<el-checkbox
v-for="item in item.dictList"
:key="item.id"
:label="item.value"
>{{ item.label }}</el-checkbox>
</el-checkbox-group>
</template>
</template>
<template v-if="item.htmlType === 'datetime'">
<template v-if="item.columnType === 'date'">
<el-date-picker
......@@ -126,12 +160,18 @@ export default {
}
})
this.tableName = data.tableName
this.columnList = data.columnList.filter(item => item.isDetail === '1')
await getData({ id: this.data.id, tableName: this.tableName }).then(response => {
const columns = data.columnList.filter(item => item.isDetail === '1')
const formData = await getData({ id: this.data.id, tableName: this.tableName }).then(response => {
if (response.success) {
this.form = response.data
return response.data
}
})
// checkbox特殊处理
columns.filter(item => item.htmlType === 'checkbox').forEach((item, index, arr) => {
this.$set(formData, item.columnName, formData[item.columnName].split(',') || [])
})
this.columnList = columns
this.form = formData
}
}
}
......
......@@ -38,6 +38,40 @@
:precision="parseInt(item.columnScale)"
></el-input-number>
</template>
<template v-if="item.htmlType === 'select'">
<template v-if="item.isBindDict === '1' && item.dictList && item.dictList.length > 0">
<el-select v-model.trim="form[item.columnName]" placeholder="请选择">
<el-option
v-for="item in item.dictList"
:key="item.id"
:label="item.label"
:value="item.value">
</el-option>
</el-select>
</template>
</template>
<template v-if="item.htmlType === 'radio'">
<template v-if="item.isBindDict === '1' && item.dictList && item.dictList.length > 0">
<el-radio-group v-model.trim="form[item.columnName]">
<el-radio
v-for="item in item.dictList"
:key="item.id"
:label="item.value"
>{{ item.label }}</el-radio>
</el-radio-group>
</template>
</template>
<template v-if="item.htmlType === 'checkbox'">
<template v-if="item.isBindDict === '1' && item.dictList && item.dictList.length > 0">
<el-checkbox-group v-model.trim="form[item.columnName]">
<el-checkbox
v-for="item in item.dictList"
:key="item.id"
:label="item.value"
>{{ item.label }}</el-checkbox>
</el-checkbox-group>
</template>
</template>
<template v-if="item.htmlType === 'datetime'">
<template v-if="item.columnType === 'date'">
<el-date-picker
......@@ -133,22 +167,32 @@ export default {
}
})
this.tableName = data.tableName
this.columnList = data.columnList.filter(item => item.isDetail === '1')
await getData({ id: this.data.id, tableName: this.tableName }).then(response => {
const columns = data.columnList.filter(item => item.isDetail === '1')
const formData = await getData({ id: this.data.id, tableName: this.tableName }).then(response => {
if (response.success) {
this.form = response.data
return response.data
}
})
// checkbox特殊处理
columns.filter(item => item.htmlType === 'checkbox').forEach((item, index, arr) => {
this.$set(formData, item.columnName, formData[item.columnName].split(',') || [])
})
this.columnList = columns
this.form = formData
},
/** 提交按钮 */
submitForm: function() {
this.$refs['form'].validate(valid => {
if (valid) {
const data = { id: this.data.id, tableName: this.tableName, datas: this.form }
const data = JSON.parse(JSON.stringify(this.form))
// checkbox特殊处理
this.columnList.filter(item => item.htmlType === 'checkbox').forEach((item, index, arr) => {
this.$set(data, item.columnName, data[item.columnName].join(','))
})
this.loadingOptions.loading = true
this.loadingOptions.loadingText = '保存中...'
this.loadingOptions.isDisabled = true
updateData(data).then(response => {
updateData({ id: this.data.id, tableName: this.tableName, datas: data }).then(response => {
if (response.success) {
this.$message.success('保存成功')
setTimeout(() => {
......
......@@ -22,13 +22,181 @@
<el-col :span="18">
<el-card class="box-card" shadow="always">
<div v-if="tableName">
<el-form ref="queryForm" :model="queryParams" :inline="true">
<el-form ref="queryForm" :model="queryParams" size="mini" :inline="true">
<el-form-item v-for="(item, index) in queryParams.conditions" :label="item.columnName" :prop="item.column" :key="index">
<el-input
v-model.trim="item.value"
clearable
size="small"
></el-input>
<template v-if="item.dictList && item.dictList.length > 0">
<el-select v-model.trim="item.value" clearable placeholder="请选择">
<el-option
v-for="item in item.dictList"
:key="item.id"
:label="item.label"
:value="item.value">
</el-option>
</el-select>
</template>
<template v-else>
<template v-if="item.queryType === 'between'">
<template v-if="item.htmlType === 'number'">
<el-input-number
v-model.trim="item.leftValue"
clearable
:controls="false"
:precision="parseInt(item.columnScale)"
></el-input-number>
~
<el-input-number
v-model.trim="item.rightValue"
clearable
:controls="false"
:precision="parseInt(item.columnScale)"
></el-input-number>
</template>
<template v-if="item.htmlType === 'datetime'">
<template v-if="item.columnType === 'date'">
<el-date-picker
v-model.trim="item.leftValue"
clearable
format="yyyy-MM-dd"
value-format="yyyy-MM-dd"
type="date"
placeholder="选择日期"
></el-date-picker>
~
<el-date-picker
v-model.trim="item.rightValue"
clearable
format="yyyy-MM-dd"
value-format="yyyy-MM-dd"
type="date"
placeholder="选择日期"
></el-date-picker>
</template>
<template v-if="item.columnType === 'time'">
<el-time-picker
v-model.trim="item.leftValue"
clearable
format="HH:mm:ss"
value-format="HH:mm:ss"
placeholder="选择时间点">
</el-time-picker>
~
<el-time-picker
v-model.trim="item.rightValue"
clearable
format="HH:mm:ss"
value-format="HH:mm:ss"
placeholder="选择时间点">
</el-time-picker>
</template>
<template v-if="item.columnType === 'year'">
<el-date-picker
v-model.trim="item.leftValue"
clearable
format="yyyy"
value-format="yyyy"
type="year"
placeholder="选择年份"
></el-date-picker>
~
<el-date-picker
v-model.trim="item.rightValue"
clearable
format="yyyy"
value-format="yyyy"
type="year"
placeholder="选择年份"
></el-date-picker>
</template>
<template v-if="item.columnType === 'datetime'">
<el-date-picker
v-model.trim="item.leftValue"
clearable
format="yyyy-MM-dd HH:mm:ss"
value-format="yyyy-MM-dd HH:mm:ss"
type="datetime"
placeholder="选择日期时间"
></el-date-picker>
~
<el-date-picker
v-model.trim="item.rightValue"
clearable
format="yyyy-MM-dd HH:mm:ss"
value-format="yyyy-MM-dd HH:mm:ss"
type="datetime"
placeholder="选择日期时间"
></el-date-picker>
</template>
</template>
<template v-else>
<el-input
v-model.trim="item.leftValue"
clearable
></el-input>
~
<el-input
v-model.trim="item.rightValue"
clearable
></el-input>
</template>
</template>
<template v-else>
<template v-if="item.htmlType === 'number'">
<el-input-number
v-model.trim="item.value"
clearable
:controls="false"
:precision="parseInt(item.columnScale)"
></el-input-number>
</template>
<template v-if="item.htmlType === 'datetime'">
<template v-if="item.columnType === 'date'">
<el-date-picker
v-model.trim="item.value"
clearable
format="yyyy-MM-dd"
value-format="yyyy-MM-dd"
type="date"
placeholder="选择日期"
></el-date-picker>
</template>
<template v-if="item.columnType === 'time'">
<el-time-picker
v-model.trim="item.value"
clearable
format="HH:mm:ss"
value-format="HH:mm:ss"
placeholder="选择时间点">
</el-time-picker>
</template>
<template v-if="item.columnType === 'year'">
<el-date-picker
v-model.trim="item.value"
clearable
format="yyyy"
value-format="yyyy"
type="year"
placeholder="选择年份"
></el-date-picker>
</template>
<template v-if="item.columnType === 'datetime'">
<el-date-picker
v-model.trim="item.value"
clearable
format="yyyy-MM-dd HH:mm:ss"
value-format="yyyy-MM-dd HH:mm:ss"
type="datetime"
placeholder="选择日期时间"
></el-date-picker>
</template>
</template>
<template v-else>
<el-input
v-model.trim="item.value"
clearable
></el-input>
</template>
</template>
</template>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
......
......@@ -178,21 +178,7 @@
</el-form-item>
</template>
</el-table-column>
<el-table-column label="显示类型" width="120">
<template slot-scope="scope">
<el-form-item :prop="'modelColumns.' + scope.$index + '.htmlType'" :rules="rules.htmlType">
<el-select :disabled="scope.row.isSystem === '1'" v-model="scope.row.htmlType" clearable placeholder="请选择">
<el-option
v-for="item in htmlTypeOptions"
:key="item.id"
:label="item.itemValue"
:value="item.itemText"
/>
</el-select>
</el-form-item>
</template>
</el-table-column>
<el-table-column label="数据标准" align="center" width="55">
<el-table-column label="标准" align="center" width="55">
<template slot-scope="scope">
<el-form-item :prop="'modelColumns.' + scope.$index + '.isBindDict'">
<el-checkbox :disabled="scope.row.isSystem === '1'" v-model="scope.row.isBindDict" true-label="1" false-label="0" />
......@@ -227,6 +213,20 @@
</el-form-item>
</template>
</el-table-column>
<el-table-column label="显示类型" width="120">
<template slot-scope="scope">
<el-form-item :prop="'modelColumns.' + scope.$index + '.htmlType'" :rules="rules.htmlType">
<el-select :disabled="scope.row.isSystem === '1'" v-model="scope.row.htmlType" clearable placeholder="请选择">
<el-option
v-for="item in htmlTypeOptions"
:key="item.id"
:label="item.itemValue"
:value="item.itemText"
/>
</el-select>
</el-form-item>
</template>
</el-table-column>
</el-table>
</el-form>
</el-tab-pane>
......
......@@ -171,21 +171,7 @@
</el-form-item>
</template>
</el-table-column>
<el-table-column label="显示类型" width="120">
<template slot-scope="scope">
<el-form-item>
<el-select v-model="scope.row.htmlType" clearable placeholder="请选择">
<el-option
v-for="item in htmlTypeOptions"
:key="item.id"
:label="item.itemValue"
:value="item.itemText"
/>
</el-select>
</el-form-item>
</template>
</el-table-column>
<el-table-column label="数据标准" align="center" width="55">
<el-table-column label="标准" align="center" width="55">
<template slot-scope="scope">
<el-form-item>
<el-checkbox v-model="scope.row.isBindDict" true-label="1" false-label="0" />
......@@ -220,6 +206,20 @@
</el-form-item>
</template>
</el-table-column>
<el-table-column label="显示类型" width="120">
<template slot-scope="scope">
<el-form-item>
<el-select v-model="scope.row.htmlType" clearable placeholder="请选择">
<el-option
v-for="item in htmlTypeOptions"
:key="item.id"
:label="item.itemValue"
:value="item.itemText"
/>
</el-select>
</el-form-item>
</template>
</el-table-column>
</el-table>
</el-form>
</el-tab-pane>
......
......@@ -178,21 +178,7 @@
</el-form-item>
</template>
</el-table-column>
<el-table-column label="显示类型" width="120">
<template slot-scope="scope">
<el-form-item :prop="'modelColumns.' + scope.$index + '.htmlType'" :rules="rules.htmlType">
<el-select :disabled="scope.row.isSystem === '1'" v-model="scope.row.htmlType" clearable placeholder="请选择">
<el-option
v-for="item in htmlTypeOptions"
:key="item.id"
:label="item.itemValue"
:value="item.itemText"
/>
</el-select>
</el-form-item>
</template>
</el-table-column>
<el-table-column label="数据标准" align="center" width="55">
<el-table-column label="标准" align="center" width="55">
<template slot-scope="scope">
<el-form-item :prop="'modelColumns.' + scope.$index + '.isBindDict'">
<el-checkbox :disabled="scope.row.isSystem === '1'" v-model="scope.row.isBindDict" true-label="1" false-label="0" />
......@@ -227,6 +213,20 @@
</el-form-item>
</template>
</el-table-column>
<el-table-column label="显示类型" width="120">
<template slot-scope="scope">
<el-form-item :prop="'modelColumns.' + scope.$index + '.htmlType'" :rules="rules.htmlType">
<el-select :disabled="scope.row.isSystem === '1'" v-model="scope.row.htmlType" clearable placeholder="请选择">
<el-option
v-for="item in htmlTypeOptions"
:key="item.id"
:label="item.itemValue"
:value="item.itemText"
/>
</el-select>
</el-form-item>
</template>
</el-table-column>
</el-table>
</el-form>
</el-tab-pane>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment