teddyhuang 5 роки тому
джерело
коміт
d5799cff73
14 змінених файлів з 670 додано та 120 видалено
  1. +1
    -1
      app/.idea/.gitignore
  2. +21
    -3
      app/package-lock.json
  3. +4
    -2
      app/package.json
  4. +445
    -83
      app/src/components/AssetGroup.vue
  5. +9
    -9
      app/src/components/Inventory.vue
  6. +3
    -3
      app/src/router/index.js
  7. +4
    -1
      app/vue.config.js
  8. +67
    -7
      src/main/java/com/moze/rms/controller/AssertGroupController.java
  9. +3
    -0
      src/main/java/com/moze/rms/controller/InventoryController.java
  10. +101
    -2
      src/main/java/com/moze/rms/dao/AssertDAO.java
  11. +9
    -5
      src/main/java/com/moze/rms/entity/model/MappingCol.java
  12. +1
    -1
      src/main/resources/application-dev.properties
  13. +2
    -1
      src/main/resources/application-pro.properties
  14. +0
    -2
      src/main/resources/application.properties

+ 1
- 1
app/.idea/.gitignore Переглянути файл

@@ -1,3 +1,3 @@
# Default ignored files
# Default ignored files
/workspace.xml
/inspectionProfiles/Project_Default.xml

+ 21
- 3
app/package-lock.json Переглянути файл

@@ -1087,6 +1087,11 @@
"postcss": "^7.0.0"
}
},
"@lzhoucs/vuetify": {
"version": "1.5.14-modified.5",
"resolved": "https://registry.npmjs.org/@lzhoucs/vuetify/-/vuetify-1.5.14-modified.5.tgz",
"integrity": "sha512-joWHpldYaSBFavc9xqaQRLMB/aGYUz4MCJr5dM4HDlAZeVJQqjHak5+YBArN1O3BdOLTXIuTw4WN5BaSKBRhQw=="
},
"@mrmlnc/readdir-enhanced": {
"version": "2.2.1",
"resolved": "https://registry.npmjs.org/@mrmlnc/readdir-enhanced/-/readdir-enhanced-2.2.1.tgz",
@@ -9878,6 +9883,11 @@
"is-plain-obj": "^1.0.0"
}
},
"sortablejs": {
"version": "1.10.2",
"resolved": "https://registry.npmjs.org/sortablejs/-/sortablejs-1.10.2.tgz",
"integrity": "sha512-YkPGufevysvfwn5rfdlGyrGjt7/CRHwvRPogD/lC+TnvcN29jDpCifKP+rBqf+LRldfXSTh+0CGLcSg0VIxq3A=="
},
"source-list-map": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/source-list-map/-/source-list-map-2.0.1.tgz",
@@ -11221,10 +11231,18 @@
"integrity": "sha512-4gDntzrifFnCEvyoO8PqyJDmguXgVPxKiIxrBKjIowvL9l+N66196+72XVYR8BBf1Uv1Fgt3bGevJ+sEmxfZzw==",
"dev": true
},
"vuedraggable": {
"version": "2.24.3",
"resolved": "https://registry.npmjs.org/vuedraggable/-/vuedraggable-2.24.3.tgz",
"integrity": "sha512-6/HDXi92GzB+Hcs9fC6PAAozK1RLt1ewPTLjK0anTYguXLAeySDmcnqE8IC0xa7shvSzRjQXq3/+dsZ7ETGF3g==",
"requires": {
"sortablejs": "1.10.2"
}
},
"vuetify": {
"version": "2.4.3",
"resolved": "https://registry.npmjs.org/vuetify/-/vuetify-2.4.3.tgz",
"integrity": "sha512-i2/Df0U0sedlaCbft4NMbna7WXbTCBhKVYTMjBrLVzrYTTWqzSO7ZCxLuDRY7MjwQhn7AOec7ent9U/NyIICqA=="
"version": "2.4.7",
"resolved": "https://registry.npmjs.org/vuetify/-/vuetify-2.4.7.tgz",
"integrity": "sha512-4RvdZ+BO23fPq8JCEdo9ENjE1AoMqDe1bm+4M57wNTfvW4djScxQnVYeUSE/7PHuzdSW/nROR5oyLQnGDB+DIA=="
},
"vuetify-loader": {
"version": "1.7.1",


+ 4
- 2
app/package.json Переглянути файл

@@ -3,17 +3,19 @@
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve --port 3000",
"serve": "vue-cli-service serve --port 3001",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint"
},
"dependencies": {
"@lzhoucs/vuetify": "^1.5.14-modified.5",
"axios": "^0.21.1",
"core-js": "^3.6.5",
"lodash": "^4.17.20",
"vue": "^2.6.11",
"vue-router": "^3.5.1",
"vuetify": "^2.4.3"
"vuedraggable": "^2.24.3",
"vuetify": "^2.4.7"
},
"devDependencies": {
"@vue/cli-plugin-babel": "~4.5.0",


+ 445
- 83
app/src/components/AssetGroup.vue Переглянути файл

@@ -8,18 +8,13 @@
background-color='grey lighten-4'
show-arrows
>
<v-tab
v-for='item in assertGroup'
:key='item.text'
class=' font-weight-bold'

>
<v-icon small>{{ item.text }}</v-icon>
</v-tab>
<div class="d-flex align-center">
<!--新增資產群駔對話-->
<v-dialog
v-model='dialogNewAssertGroup'
@click:outside='close'
:retain-focus="false"
overlay-opacity="0"
>
<template v-slot:activator='{ on, attrs }'>
<v-btn
@@ -44,19 +39,19 @@
class='d-flex'
>
<v-text-field
v-model="assertGroupDescript"
v-model="insertAssertGroupDescript"
label='群組名稱'
hint='必填'
/>
</v-col>
<v-col
v-model="assertGroupTablename"
cols='12'
sm='6'
md='4'
class='d-flex'
>
<v-text-field
v-model="insertAssertGroupTablename"
label='資料庫表格名稱'
hint='必填'
/>
@@ -76,7 +71,7 @@
<v-btn
color='blue darken-1'
text
@click='mockInsertAssertGroup'
@click='insertAssertGroup'
>
新增
</v-btn>
@@ -84,40 +79,120 @@
</v-card>
</v-dialog>
</div>
<v-tab
v-for='(item, index) in assertGroup'
:key='index'
class=' font-weight-bold'
@mouseover="showTabOptionIcon(index)"
@mouseleave="optionIconShow = -1"
>
<v-icon small>{{ item.text }}</v-icon>
<v-spacer></v-spacer>
<!--修改資產群駔對話-->
<v-dialog
:id="index"
v-model='dialogModifyAssertGroupName'
:retain-focus="false"
overlay-opacity="0"
@click:outside='close'
>
<template v-slot:activator='{ on, attrs }'>
<v-btn
v-bind='attrs'
v-on='on'
icon
>
<v-icon v-show="optionIconShow === index" small
@click="modifyAssertGroup = JSON.parse(JSON.stringify(item))">mdi-pencil
</v-icon>
</v-btn>
</template>
<v-card>
<v-card-title>
<span class='headline font-weight-bold'>修改資產群組名稱</span>
</v-card-title>
<v-card-text>
<v-container>
<v-row>
<v-col
cols='12'
sm='6'
md='4'
class='d-flex'
>
<v-text-field
v-model="modifyAssertGroup.text"
label='群組名稱'
hint='必填'
/>
</v-col>
</v-row>
</v-container>
</v-card-text>
<v-card-actions>
<v-spacer></v-spacer>
<v-btn
color='blue darken-1'
text
@click='close'
>
取消
</v-btn>
<v-btn
color='blue darken-1'
text
@click='modifyAssertGroupName'
>
修改
</v-btn>
</v-card-actions>
</v-card>
</v-dialog>
<v-btn icon>
<v-icon v-show="optionIconShow === index" small @click="deleteAssertGroup(item)">
mdi-delete
</v-icon>
</v-btn>
</v-tab>
<div class="d-flex align-center">
</div>
<v-tabs-items v-model='currentTab'>
<v-tab-item
v-for='cols in inventoryItems'
:key='cols.index'
v-for='(item, index) in assertGroup'
:key='index'
>
<v-data-table
:items='cols'
:items='allCols[item.value]'
:headers='headers'
hide-default-footer
>
<template v-slot:item.actions='{ item }'>
<!--修改資產群駔欄位對話-->
<v-dialog
v-model='dialogModify'
@click:outside='close'
:retain-focus="false"
overlay-opacity="0"
>
<template v-slot:activator='{ on, attrs }'>
<v-btn
v-bind='attrs'
v-on='on'
icon
@click='log(item)'
@click='modifyColItem = JSON.parse(JSON.stringify(item))'
>
<v-icon>mdi-pencil</v-icon>
</v-btn>
</template>
<v-card>
<v-card-title>
<span class='headline font-weight-bold'>修改</span>
<span class='headline font-weight-bold'>修改欄位</span>
</v-card-title>
<v-card-text>
<v-container>
<v-row>
<v-col
v-for='(val, key, index) in item'
v-for='(header, index) in headers'
:key='index'
cols='12'
sm='6'
@@ -125,12 +200,36 @@
class='d-flex'
>
<v-text-field
v-if='headers[index]'
:label='headers[index].text'
v-bind:value='val'
v-if="header.text !== '' && header.value !== 'isselect' && isBooleanCol.indexOf(header.value) < 0"
:label='header.text'
:value="modifyColItem[header.value]"
hint='必填'
v-on:input='oninput(modifyCol, key, $event)'
v-on:input='oninput(modifyColItem, header.value, $event)'
/>
<v-select
v-if="header.value === 'isselect' && isBooleanCol.indexOf(header.value) < 0"
:label='header.text' hint='必填'
:value="modifyColItem[header.value]"
v-on:input='oninput(modifyColItem, header.value, $event)'
:items="selectColItem.isselect"
:item-text="selectColItem.isselect.text"
:item-value="selectColItem.isselect.value"
/>
<v-select
v-if="header.value && isBooleanCol.indexOf(header.value) >= 0"
:label='header.text' hint='必填'
:value="modifyColItem[header.value]"
v-on:input='oninput(modifyColItem, header.value, $event)'
:items="selectColItem.boolean"
:item-text="selectColItem.boolean.text"
:item-value="selectColItem.boolean.value"
/>
<v-btn
v-if="header.value === 'isselect' && modifyColItem.isselect === 'true'"
@click='dialogModifySelectItem = true'
>
編輯選項
</v-btn>
</v-col>
</v-row>
</v-container>
@@ -147,7 +246,7 @@
<v-btn
color='blue darken-1'
text
@click='modifyOne(item)'
@click='modifyCol(modifyColItem)'
>
修改
</v-btn>
@@ -156,17 +255,20 @@
</v-dialog>
<v-icon
small
@click='deleteOne(item)'
@click='deleteCol(item)'
>
mdi-delete
</v-icon>
</template>
<template v-slot:footer>
<div class='d-flex ma-2'>
<v-spacer/>
<v-spacer/>
<!--新增資產群駔欄位對話-->
<v-dialog
v-model='dialogInsert'
@click:outside='close'
:retain-focus="false"
overlay-opacity="0"
>
<template v-slot:activator='{ on, attrs }'>
<v-btn
@@ -179,13 +281,13 @@
</template>
<v-card>
<v-card-title>
<span class='headline font-weight-bold'>新增</span>
<span class='headline font-weight-bold'>新增欄位</span>
</v-card-title>
<v-card-text>
<v-container>
<v-row>
<v-col
v-for='(val, key, index) in insertCol'
v-for='(header, index) in headers'
:key='index'
cols='12'
sm='6'
@@ -193,12 +295,33 @@
class='d-flex'
>
<v-text-field
v-if='headers[index]'
:label='headers[index].text'
v-bind:value='val'
v-if="header.text !== '' && header.value !== 'isselect' && isBooleanCol.indexOf(header.value) < 0"
:label='header.text'
hint='必填'
v-on:input='oninput(insertCol, key, $event)'
v-on:input='oninput(insertColItem, header.value, $event)'
/>
<v-select
v-if="header.value === 'isselect' && isBooleanCol.indexOf(header.value) < 0"
:label='header.text' hint='必填'
v-on:input='oninput(insertColItem, header.value, $event)'
:items="selectColItem.isselect"
:item-text="selectColItem.isselect.text"
:item-value="selectColItem.isselect.value"
/>
<v-select
v-if="header.value && isBooleanCol.indexOf(header.value) >= 0"
:label='header.text' hint='必填'
v-on:input='oninput(insertColItem, header.value, $event)'
:items="selectColItem.boolean"
:item-text="selectColItem.boolean.text"
:item-value="selectColItem.boolean.value"
/>
<v-btn
v-if="header.value === 'isselect' && insertColItem.isselect === 'true'"
@click='dialogInsertSelectItem = true'
>
編輯選項
</v-btn>
</v-col>
</v-row>
</v-container>
@@ -215,9 +338,9 @@
<v-btn
color='blue darken-1'
text
@click='modifyOne(item)'
@click='insertCol(item)'
>
修改
新增
</v-btn>
</v-card-actions>
</v-card>
@@ -227,13 +350,140 @@
</v-data-table>
</v-tab-item>
</v-tabs-items>
<!--新增資產群組欄位選項對話-->
<v-dialog
width="80%"
v-model='dialogInsertSelectItem'
@click:outside='closeDialogInsertSelectItem'
:retain-focus="false"
overlay-opacity="0"
>
<v-card>
<v-card-title>
<span class='headline font-weight-bold'>編輯選項</span>
</v-card-title>
<v-card-text>
<v-container>
<v-row>
<v-col cols="3" class="d-flex align-center">
<v-text-field outlined rounded hide-details
v-model="insertSelectItem"/>
<v-btn class="ml-2" @click='pushSelectItem'>新增</v-btn>
</v-col>
</v-row>
<v-card class="mt-2 elevation-2"
style="border: 1px solid grey;min-height: 250px;border-radius: 10px">
<v-chip
v-for="(insertSelectItem, index) in insertSelectItems"
:key="index"
class="ma-2"
color="secondary"
>
{{insertSelectItem}}
<v-icon small class="ml-4" @click="deleteSelectItem(index)">mdi-close</v-icon>
</v-chip>
</v-card>
</v-container>
</v-card-text>
<v-card-actions>
<v-spacer></v-spacer>
<v-btn
color='blue darken-1'
text
@click='closeDialogInsertSelectItem'
>
關閉
</v-btn>
</v-card-actions>
</v-card>
</v-dialog>
<!--修改資產群組欄位選項對話-->
<v-dialog
width="40%"
v-model='dialogModifySelectItem'
@click:outside='closeDialogModifySelectItem'
:retain-focus="false"
overlay-opacity="0"
>
<v-card>
<v-card-title>
<span class='headline font-weight-bold'>編輯選項</span>
</v-card-title>
<v-card-text>
<v-container>
<v-row>
<v-col cols="11" class="d-flex align-center">
<v-text-field outlined rounded hide-details
v-model="insertSelectItem"/>
<v-btn class="ml-2" @click='pushSelectItem'>新增</v-btn>
</v-col>
</v-row>
<v-card
max-width="80%"
class="mt-2"
style="border: 1px solid grey; border-radius: 10px"
>
<v-card-text>
<v-chip-group
v-model="selection"
column
>
<draggable @start="dragStart" @end="dragEnd">
<v-chip v-for="(modifySelectItem, i) in modifySelectItems" :key="i" color="secondary" class="col-12" draggable>
{{ modifySelectItem }}
</v-chip>
</draggable>
</v-chip-group>
</v-card-text>
</v-card>
</v-container>
</v-card-text>
<v-card-actions>
<v-spacer></v-spacer>
<v-btn
color='blue darken-1'
text
@click='closeDialogModifySelectItem'
>
關閉
</v-btn>
</v-card-actions>
</v-card>
<div id="app">
<v-app id="inspire">
<v-card
max-width="400"
class="mx-auto"
>
<v-card-text>
<v-chip-group
v-model="selection"
column
active-class="primary--text"
>
<draggable v-model="tags" @start="dragStart" @end="dragEnd">
<v-chip v-for="(tag, i) in tags" :key="i" draggable>
{{ tag.name }}
</v-chip>
</draggable>
</v-chip-group>
</v-card-text>
</v-card>
</v-app>
</div>
</v-dialog>
</v-tabs>
</div>
</div>
</template>
<script>
import draggable from 'vuedraggable';

export default {
name: '',
components: {
draggable,
},
data() {
return {
dialogInsert: false,
@@ -242,34 +492,68 @@
// dialogSearch: false,
title: '資訊資產群組',
headers: [
{'text': '', 'value': 'actions', fixed: true, sortable: false},
{'text': '中文名稱', 'value': 'descript'},
{'text': '資料庫欄位名稱', 'value': 'colname'},
{'text': '型態', 'value': 'type'},
{'text': '文字框或選項', 'value': 'select'},
// {'text': '型態', 'value': 'type'},
{'text': '文字框或選項', 'value': 'isselect'},
{'text': '順序', 'value': 'index'},
{'text': '必填', 'value': 'require'},
{'text': '', 'value': 'actions', sortable: false}
{'text': '必填', 'value': 'isrequire'},
{'text': '可匯出', 'value': 'isexport'},
{'text': '可搜尋', 'value': 'issearch'},
],
inventoryItems: [],
insertCol: {
allCols: [],
insertColItem: {
'tablename': '',
'descript': '',
'colname': '',
'level': null,
'descript': '',
'type': '',
'select': '',
'search': '',
'export': '',
'require': ''
// 'type': '',
'index': '',
'isselect': '',
'issearch': '',
'isexport': '',
'isrequire': ''
},
isBooleanCol: ['isexport', 'isrequire', 'issearch'],
selectColItem: {
'isselect': [{'text': '文字', 'value': 'false'},
{'text': '選項', 'value': 'true'}]
, 'boolean': [{'text': '是', 'value': 'true'},
{'text': '否', 'value': 'false'}]
},
modifyCol: {},
modifyColItem: {},
assertGroup: [],
currentTab: 0,
types: [],
// selectItem: {},
// searchItem: {},
assertGroupDescript: '',
assertGroupTablename: '',
insertAssertGroupDescript: '',
insertAssertGroupTablename: '',
optionIconShow: -1,
dialogModifyAssertGroupName: false,
modifyAssertGroup: {
text: '',
valsue: '',
},
dialogInsertSelectItem: false,
insertSelectItems: [],
insertSelectItem: '',
modifySelectItems: [],
modifySelectItem: '',
dialogModifySelectItem: false,
selection: null,
currentTag: null,
tags: [{
name: 'Shoping',
},{
name: 'Art',
}, {
name: 'Tech',
}, {
name: 'Creative Writing'
}
],
}
},
async mounted() {
@@ -277,26 +561,80 @@
this.getTabs();
this.getTypes();
this.inventoryItems = [];
this.getInventoryItem();
this.getCols();
},
computed: {},
watch: {
currentTab() {
// // this.getTabs();
console.log(this.assertGroup[this.currentTab].value);
this.getTypes();
this.getInventoryItem();
this.getCols();
},
dialogModifySelectItem() {
this.getModifySelectItems();
},
},
methods: {
log(col) {
console.log(col);
// eslint-disable-next-line no-unused-vars
log() {
// console.log(col);
console.log(this.modifySelectItems);
},
dragStart() {

if (this.modifySelectItems[this.selection]) {
this.currentTag = this.modifySelectItems[this.selection];
}
else {
this.currentTag = null;
}
// console.log(this.selection);
// console.log(this.currentTag);
// console.log(this.tags[0].name);
},
dragEnd() {
var self = this;
console.log(this.currentTag);
if (this.currentTag) {
this.modifySelectItems.forEach((x, i) => {
if (x === self.currentTag) self.selection = i;
});
}
// console.log(this.selection);
// console.log(this.currentTag);
console.log(this.modifySelectItems[0]);

},
closeDialogInsertSelectItem() {
this.dialogInsertSelectItem = false
this.insertSelectItems = [];
},
getModifySelectItems() {
this.$axios.get(`/assert/selectItems?tablename=${this.modifyColItem.tablename}&&colname=${this.modifyColItem.colname}`).then((resp) => {
console.log(resp.data.data);
this.modifySelectItems = resp.data.data;
});
},
closeDialogModifySelectItem() {
this.dialogModifySelectItem = false;
this.modifySelectItems = [];
},
pushSelectItem() {
if (this.insertSelectItems.indexOf(this.insertSelectItem) >= 0 || this.insertSelectItem === '') {
alert('選項不得重複或為空');
} else {
this.insertSelectItems.push(this.insertSelectItem);
this.insertSelectItem = '';
}
},
deleteSelectItem(index) {
this.insertSelectItems.splice(index, 1);
},
oninput(item, key, val) {
this.$set(item, key, val);
},
getTabs() {
this.$axios.get(`/assert/assertGroups`).then((resp) => {
async getTabs() {
await this.$axios.get(`/assert/assertGroups`).then((resp) => {
this.assertGroup = [];
resp.data.data.forEach((item) => {
let header = {'text': null, 'value': null};
header.text = item.descript;
@@ -312,25 +650,34 @@
this.types = resp.data.data;
});
},
getInventoryItem() {
getCols() {
const tablename = this.assertGroup[this.currentTab] ? this.assertGroup[this.currentTab].value : 'hardware';
this.$axios.get(`/assert/InventoryItems?tablename=${tablename}`).then((resp) => {
this.inventoryItems = resp.data.data;
this.$axios.get(`/assert/allCols?tablename=${tablename}`).then((resp) => {
this.allCols = resp.data.data;
});
},
insertOne() {
this.insertItem.tablename = this.tablename;
this.$axios.post(`/inventory?`, this.insertItem).then(() => {
delete this.insertItem.tablename;
this.getInventories();
this.close();
insertCol() {
for (const key in this.insertColItem) {
if (this.insertColItem[key] === '') {
alert('所有資料不可為空');
return;
} else {
this.insertColItem.tablename = this.assertGroup[this.currentTab].value;
this.insertColItem.insertselectItems = this.insertSelectItems;
this.$axios.post(`/assert/col`, this.insertColItem).then(() => {
this.getCols();
this.close();
this.insertSelectItems = [];
}
);
}
);
}
},
close() {
this.dialogInsert = false;
this.dialogModify = false;
this.dialogNewAssertGroup = false;
this.dialogModifyAssertGroupName = false;
},
isDisabled(key) {
const disabledKey = ['id'];
@@ -350,23 +697,23 @@
this.selectItem = resp.data.data;
});
},
modifyOne(item) {
modifyCol(item) {
console.log(item);
item.tablename = this.tablename;
this.$axios.put(`/inventory?`, item).then(() => {
this.getInventories();
this.$axios.put(`/assert/col`, item).then(() => {
this.getCols();
this.close();
}
);
},
deleteOne(item) {
deleteCol(item) {
let yes = confirm('確定刪除');
if (yes) {
this.$axios.delete(`/deleteOne?tablename=${this.tablename}&&id=${item.id}`).then(() => {
this.getInventories();
this.$axios.delete(`/assert/deleteCol?tablename=${item.tablename}&&colname=${item.colname}`).then(() => {
this.getCols();
alert('已刪除');
});
}
console.log(item);
},
exportFile() {
let yes = confirm('確定匯出');
@@ -378,19 +725,34 @@
}

},
mockInsertAssertGroup() {
// this.$axios.get(`/assert/assertGroups`).then((resp) => {
// resp.data.data.forEach((item) => {
// let header = {'text': null, 'value': null};
// header.text = item.descript;
// header.value = item.tablename;
// this.assertGroup.push(header);
// });
this.assertGroup.push({'text': this.assertGroupDescript, 'value': this.assertGroupTablename});
console.log(this.assertGroup);
// });
async insertAssertGroup() {
await this.$axios.post(`/assert/assertGroups`, {
assertGroupDescript: this.insertAssertGroupDescript,
assertGroupTablename: this.insertAssertGroupTablename
});
await this.getTabs();
this.close();
},
showTabOptionIcon(index) {
this.optionIconShow = index;
},
async deleteAssertGroup(item) {
let yes = confirm('確認刪除此群組?');
if (yes) {
await this.$axios.delete(`/assert/assertGroups?tablename=${item.value}`).then(() => {
this.getTabs();
alert('已刪除');
});
}
},
async modifyAssertGroupName() {
await this.$axios.put(`/assert/assertGroups?tablename=${this.modifyAssertGroup.value}&&newDescript=${this.modifyAssertGroup.text}`).then(() => {
this.getTabs();
alert('已修改');
this.close();
});
},


}
}


+ 9
- 9
app/src/components/Inventory.vue Переглянути файл

@@ -273,8 +273,8 @@
headers: [],
cols: {},
items: [],
select: [],
required: [],
isselect: [],
isrequired: [],
insertItem: {},
modifyItem: {},
selectItem: {},
@@ -328,11 +328,11 @@
header.text = item.descript;
header.value = item.colname;
this.headers.push(header);
if (item.select === 'true') {
this.select.push(item.colname);
if (item.isselect === 'true') {
this.isselect.push(item.colname);
}
if (item.require === 'true') {
this.required.push(item.colname);
if (item.isrequire === 'true') {
this.isrequired.push(item.colname);
}
this.insertItem[item.colname] = null;
this.searchItem[item.colname] = null;
@@ -364,13 +364,13 @@
return disabledKey.indexOf(key) >= 0;
},
isTextField(key) {
return this.select.indexOf(key) < 0;
return this.isselect.indexOf(key) < 0;
},
isSelect(key) {
return this.select.indexOf(key) >= 0;
return this.isselect.indexOf(key) >= 0;
},
isRequire(key) {
return this.required.indexOf(key) >= 0;
return this.isrequired.indexOf(key) >= 0;
},
getSelectItem() {
this.$axios.get(`/selectItem?tablename=${this.tablename}`).then((resp) => {


+ 3
- 3
app/src/router/index.js Переглянути файл

@@ -4,8 +4,8 @@ import Login from '@/components/Login'
import Home from '../components/Home';
import AssetGroup from '../components/AssetGroup';
import Inventory from '../components/Inventory';
// import Search from '../components/Search';
import MockSearch from '../components/MockSearch';
import Search from '../components/Search';
// import MockSearch from '../components/MockSearch';

Vue.use(Router);

@@ -33,7 +33,7 @@ export const constantRoutes = [
{
path: 'search',
name: 'search',
component: MockSearch
component: Search
},
]
}


+ 4
- 1
app/vue.config.js Переглянути файл

@@ -5,6 +5,7 @@ function resolve(dir) {
return path.join(__dirname, dir);
}
module.exports= {
// publicPath: process.env.NODE_ENV = '/',
configureWebpack: {
name: config.title,
resolve: {
@@ -16,7 +17,7 @@ module.exports= {
devServer: {
proxy: {
'/api': {
target: 'http://localhost:8080/api/',
target: 'http://localhost:8081/api/',
changeOrigin: true,
pathRewrite: {
'^/api': '',
@@ -26,4 +27,6 @@ module.exports= {
disableHostCheck: true,
},
outputDir: '../src/main/resources/public/',

}


+ 67
- 7
src/main/java/com/moze/rms/controller/AssertGroupController.java Переглянути файл

@@ -4,10 +4,7 @@ import com.moze.rms.dao.AssertDAO;
import com.moze.rms.entity.dto.SelectItemDTO;
import com.moze.rms.entity.model.MappingCol;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;
@@ -25,7 +22,34 @@ public class AssertGroupController {
public JsonResult getAsserts() {

return new JsonResult(StatusCode.SUCCESS, assertDAO.findAssertGroups());
}

@PostMapping("/assertGroups")
public JsonResult insertAssert(@RequestBody Map<String, Object> data) {

assertDAO.insertAssertGroup(data);
assertDAO.insertMappingTable(data);
assertDAO.insertMappingType(data);

return new JsonResult(StatusCode.SUCCESS, null);
}

@DeleteMapping("/assertGroups")
public JsonResult deleteAssert(@RequestParam String tablename) {

assertDAO.deleteAssertGroup(tablename);
assertDAO.deleteMappingTable(tablename);
assertDAO.deleteMappingType(tablename);

return new JsonResult(StatusCode.SUCCESS, null);
}

@PutMapping("/assertGroups")
public JsonResult modifyAssert(@RequestParam String tablename, @RequestParam String newDescript) {

assertDAO.modifyMappingTable(tablename, newDescript);

return new JsonResult(StatusCode.SUCCESS, null);
}

@GetMapping("/Types")
@@ -33,13 +57,49 @@ public class AssertGroupController {
return new JsonResult(StatusCode.SUCCESS, assertDAO.findTypesByTable(tablename));
}

@GetMapping("/InventoryItems")
public JsonResult getInventoryItems(@RequestParam String tablename) {
@GetMapping("/allCols")
public JsonResult getCols(@RequestParam String tablename) {

// return new JsonResult(StatusCode.SUCCESS, data.stream().collect(Collectors.groupingBy(SelectItemDTO::getColname)));
List<MappingCol> data = assertDAO.findInventoryItems();
List<MappingCol> data = assertDAO.findAllCols();

return new JsonResult(StatusCode.SUCCESS, data.stream().collect(Collectors.groupingBy(MappingCol::getTablename)));
}

@PostMapping("/col")
public JsonResult insertCol(@RequestBody MappingCol mappingCol) {

System.out.println(mappingCol);
assertDAO.insertCol(mappingCol);

return new JsonResult(StatusCode.SUCCESS, null);
}
@PutMapping("/col")
public JsonResult modifyCol(@RequestBody MappingCol mappingCol) {

System.out.println(mappingCol);
// assertDAO.modifyCol(mappingCol;

return new JsonResult(StatusCode.SUCCESS, null);
}

@DeleteMapping("/deleteCol")
public JsonResult deleteCol(@RequestParam String tablename, @RequestParam String colname) {

// assertDAO.deleteColFromTable(tablename, colname);
assertDAO.deleteColFromMappingCol(tablename, colname);
if (colname.equals("type")) {
//TODO
}
assertDAO.deleteColFromSelectItem(tablename, colname);
return new JsonResult(StatusCode.SUCCESS, null);
}

@GetMapping("/selectItems")
public JsonResult getSelectItemsByCol(@RequestParam String tablename, @RequestParam String colname) {

List<String> data = assertDAO.getSelectItemsByCol(tablename , colname);
return new JsonResult(StatusCode.SUCCESS, data);
}
}


+ 3
- 0
src/main/java/com/moze/rms/controller/InventoryController.java Переглянути файл

@@ -71,6 +71,7 @@ public class InventoryController {
List<SelectItemDTO> data = inventoryDAO.getSelectItemByTable(tablename);
return new JsonResult(StatusCode.SUCCESS, data.stream().collect(Collectors.groupingBy(SelectItemDTO::getColname)));
}

@DeleteMapping("deleteOne")
public JsonResult deleteOne(@RequestParam String tablename, @RequestParam String id) {
System.out.println(tablename);
@@ -79,4 +80,6 @@ public class InventoryController {
return new JsonResult(StatusCode.SUCCESS, null);
}



}

+ 101
- 2
src/main/java/com/moze/rms/dao/AssertDAO.java Переглянути файл

@@ -1,6 +1,7 @@
package com.moze.rms.dao;


import com.moze.rms.entity.dto.SelectItemDTO;
import com.moze.rms.entity.model.MappingCol;
import org.jdbi.v3.core.Handle;
import org.jdbi.v3.sqlobject.SqlObject;
@@ -44,6 +45,104 @@ public interface AssertDAO extends SqlObject {
// }

@RegisterBeanMapper(MappingCol.class)
@SqlQuery("select * from mapping.mapping_col")
List<MappingCol> findInventoryItems();
@SqlQuery("select * from mapping.mapping_col;")
List<MappingCol> findAllCols();


default void insertAssertGroup(Map<String, Object> data) {
Handle handle = this.getHandle();
String sql = "CREATE TABLE " + data.get("assertGroupTablename") + "()";
handle.createUpdate(sql).execute();
}

default void deleteAssertGroup(String tablename) {
Handle handle = this.getHandle();
String sql = "drop TABLE " + tablename;
handle.createUpdate(sql).execute();
}

default void insertMappingTable(Map<String, Object> data) {
Handle handle = this.getHandle();
String sql = "insert into mapping.mapping_table(tablename, descript) values ('" + data.get("assertGroupTablename") + "', '" + data.get("assertGroupDescript") + "')";
handle.createUpdate(sql).execute();
}

default void modifyMappingTable(String tablename, String newDescript) {
Handle handle = this.getHandle();
String sql = "update mapping.mapping_table set descript = '" + newDescript + "' where tablename = '" + tablename + "'";
handle.createUpdate(sql).execute();
}

default void deleteMappingTable(String tablename) {
Handle handle = this.getHandle();
String sql = "delete from mapping.mapping_table where tablename = '" + tablename + "'";
handle.createUpdate(sql).execute();
}

default void insertMappingType(Map<String, Object> data) {

Handle handle = this.getHandle();
String sql = "CREATE TABLE mapping.mapping_" + data.get("assertGroupTablename") + "(";

sql += " type varchar not null";
sql += " constraint mapping_" + data.get("assertGroupTablename") + "_pk primary key,";
sql += " name varchar,";
sql += " descript varchar,";
sql += " example varchar";
sql += ")";

handle.createUpdate(sql).execute();
}

default void deleteMappingType(String tablename) {

Handle handle = this.getHandle();
String sql = "drop TABLE mapping.mapping_" + tablename;
handle.createUpdate(sql).execute();

}

default void deleteColFromMappingCol(String tablename, String colname) {

Handle handle = this.getHandle();
String sql = "delete from mapping.mapping_col where tablename = '" + tablename + "' and colname = '" + colname + "'";
handle.createUpdate(sql).execute();
}

default void deleteColFromTable(String tablename, String colname) {

Handle handle = this.getHandle();
String sql = "ALTER TABLE " + tablename + " DROP " + colname;
handle.createUpdate(sql).execute();
}

default void deleteColFromSelectItem(String tablename, String colname) {

Handle handle = this.getHandle();
String sql = "delete from mapping.\"selectItem\" where tablename = '" + tablename + "' and colname = '" + colname + "'";
handle.createUpdate(sql).execute();
}

default void insertCol(MappingCol m) {

Handle handle = this.getHandle();
String sql = "insert into mapping.mapping_col(tablename,colname,descript,level,type,index,\"isselect\",isrequire,issearch,isexport)";
sql += " values (";
sql += "'" + m.getTablename() + "',";
sql += "'" + m.getColname() + "',";
sql += "'" + m.getDescript() + "',";
sql += "'" + m.getLevel() + "',";
sql += "'" + m.getType() + "',";
sql += "" + m.getIndex() + ",";
sql += "'" + m.getIsselect() + "',";
sql += "'" + m.getIsrequire() + "',";
sql += "'" + m.getIssearch() + "',";
sql += "'" + m.getIsexport() + "'";
sql += ")";
handle.createUpdate(sql).execute();
}

@SqlQuery("select item from mapping.\"selectItem\" where tablename = ? and colname = ? order by index;")
@RegisterBeanMapper(SelectItemDTO.class)
List<String> getSelectItemsByCol(String tablename, String colname);
}

+ 9
- 5
src/main/java/com/moze/rms/entity/model/MappingCol.java Переглянути файл

@@ -3,17 +3,21 @@ package com.moze.rms.entity.model;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;

@Data
@NoArgsConstructor
public class MappingCol {

private String tablename;
private String colname;
private Integer level;
private String level;
private String descript;
private String type;
private String select;
private String search;
private String export;
private String require;
private String index;
private String isselect;
private String issearch;
private String isexport;
private String isrequire;
private List<String> insertselectItem;
}

+ 1
- 1
src/main/resources/application-dev.properties Переглянути файл

@@ -3,6 +3,6 @@ server.servlet.context-path=/
spring.datasource.url=jdbc:postgresql://172.105.222.191:54132/rms
spring.datasource.username=moze
spring.datasource.password=moze794064,!
server.port=8081



+ 2
- 1
src/main/resources/application-pro.properties Переглянути файл

@@ -1,3 +1,4 @@
spring.datasource.url=jdbc:postgresql://172.105.222.191:54132/rms
spring.datasource.username=moze
spring.datasource.password=moze794064,!
spring.datasource.password=moze794064,!
server.port=8080

+ 0
- 2
src/main/resources/application.properties Переглянути файл

@@ -1,4 +1,2 @@
spring.profiles.active=dev
#spring.profiles.active=pro

server.port=8080

Завантаження…
Відмінити
Зберегти