diff --git a/src/api/system/dict.js b/src/api/system/dict.js index 9e5615f..655b32f 100644 --- a/src/api/system/dict.js +++ b/src/api/system/dict.js @@ -1,14 +1,10 @@ import request from '@/utils/request' -import { getToken } from '@/utils/auth' -export function getDictsList(data) { +export function getDictsList(params) { return request({ url: 'api/dictionary/initDictionaryList', - method: 'post', - headers: { - Authorization: getToken() - }, - data + method: 'get', + params }) } @@ -20,10 +16,7 @@ export function add(data) { }) } -export function del(ids) { - const data = { - id: ids[0] - } +export function del(data) { return request({ url: 'api/dictionary/delDictionary', method: 'post', @@ -39,4 +32,20 @@ export function edit(data) { }) } -export default { add, edit, del, getDictsList } +export function FetchDictionaryTree(params) { + return request({ + url: 'api/dictionary/initDictionaryTree', + method: 'get', + params + }) +} + +export function FetchSonDictionaryList(params) { + return request({ + url: 'api/dictionary/getSonDictionaryList', + method: 'get', + params + }) +} + +export default { add, edit, del, getDictsList, FetchDictionaryTree, FetchSonDictionaryList } diff --git a/src/api/system/metaData.js b/src/api/system/metaData.js new file mode 100644 index 0000000..aef7312 --- /dev/null +++ b/src/api/system/metaData.js @@ -0,0 +1,54 @@ +import request from '@/utils/request' + +// 获取元数据菜单 +export function FetchBuildMetadata(params) { + return request({ + url: 'api/metadata/buildMetadata', + method: 'get', + params + }) +} + +export function add(data) { + return request({ + url: 'api/metadata/editMetadata', + method: 'post', + data + }) +} + +// 删除元数据方案 +export function del(data) { + return request({ + url: 'api/metadata/delMetadata', + method: 'post', + data + }) +} + +// 删除档案元数据 +export function FetchDelMetadataInfos(data) { + return request({ + url: 'api/metadata/delMetadataInfos', + method: 'post', + data + }) +} + +export function edit(data) { + return request({ + url: 'api/metadata/editMetadata', + method: 'post', + data + }) +} + +export function FetchGetMetaInfo(params) { + return request({ + url: 'api/metadata/getMetaInfo', + method: 'get', + params + }) +} + +export default { add, edit, del, FetchGetMetaInfo, FetchDelMetadataInfos, FetchBuildMetadata } diff --git a/src/views/system/dept/index.vue b/src/views/system/dept/index.vue index e8f26a9..660577f 100644 --- a/src/views/system/dept/index.vue +++ b/src/views/system/dept/index.vue @@ -429,6 +429,7 @@ export default { }, getDeptDatas(tree, treeNode, resolve) { setTimeout(() => { + console.log(tree) crudDept.FetchSonDepts({ deptsId: tree.deptsId }).then(res => { const data = res.map(function(obj) { if (obj.sonNum !== 0) { diff --git a/src/views/system/dict/index.vue b/src/views/system/dict/index.vue index 303b863..41f70fe 100644 --- a/src/views/system/dict/index.vue +++ b/src/views/system/dict/index.vue @@ -4,17 +4,23 @@
- + + + 导出 + +
@@ -28,7 +34,7 @@ - + @@ -50,7 +56,9 @@ :options="dicts" :normalizer="normalizer" placeholder="选择上级节点" - /> + > +
{{ getAutoNameUnknown(node.label) }}
+
@@ -88,19 +96,19 @@ lazy :load="getDictsDatas" :data="tableData" - :tree-props="{children: 'childMenus', hasChildren: 'hasChildren'}" - highlight-current-row - row-key="id" + :tree-props="{children: 'children', hasChildren: 'hasChildren'}" + :row-key="getRowKey" style="width: 100%;" - @select="crud.selectChange" - @select-all="crud.selectAllChange" + @select-all="selectAll" + @select="selectTr" @selection-change="crud.selectionChangeHandler" + @row-click="clickRowHandler" > - + - + @@ -127,24 +126,33 @@ import crudDict from '@/api/system/dict' // import crudDictDetail from '@/api/archivesConfig/dictDetail' import CRUD, { presenter, header, form } from '@crud/crud' import crudOperation from '@crud/CRUD.operation' -// import pagination from '@crud/Pagination' +import pagination from '@crud/Pagination' import Treeselect from '@riophae/vue-treeselect' import '@riophae/vue-treeselect/dist/vue-treeselect.css' import { LOAD_CHILDREN_OPTIONS } from '@riophae/vue-treeselect' +import { mapGetters } from 'vuex' +import { exportFile } from '@/utils/index' +import qs from 'qs' const defaultForm = { id: null, dictionaryName: null, isTop: '1', dictionaryCode: null, dictionaryOrder: 999, dictionaryRemarks: null, dictionaryParents: null } export default { name: 'Dicts', - components: { crudOperation, Treeselect }, + components: { crudOperation, Treeselect, pagination }, cruds() { return [ CRUD({ - title: '字典', url: '', + title: '字典', idField: 'dictionaryId', url: 'api/dictionary/initDictionaryList', crudMethod: { ...crudDict }, - queryOnPresenterCreated: false, - sort: [] - }) + sort: [], + optShow: { + add: true, + edit: true, + del: false, + reset: true, + download: false, + group: false + }}) ] }, mixins: [ @@ -161,16 +169,8 @@ export default { }, data() { return { - tableData: [], - blurry: null, - page: { - total: 0, - size: 10, - page: 1 - }, dicts: [], dictionaryParents: null, - needRefreshTree: false, rules: { dictionaryName: [ { required: true, message: '请输入字典名称', trigger: 'blur' } @@ -191,63 +191,154 @@ export default { del: ['admin', 'dict:del'] }, deleteVisible: false, - deleteData: {} + deleteData: {}, + isAllSelect: false } }, + computed: { + ...mapGetters([ + 'baseApi' + ]) + }, mounted() { - this.getDictsList() }, methods: { - resetQuery() { - this.blurry = null - this.getDictsList() + // 处理vue-treeSelect回显出现unknown问题 + getAutoNameUnknown(name) { + if (name.lastIndexOf('unknown') > -1) { + return name.split('(')[0] + } else { + return name + } }, - [CRUD.HOOK.afterSubmit]() { - this.needRefreshTree = true + getRowKey(row) { + return row.dictionaryId }, - [CRUD.HOOK.afterDelete]() { - this.needRefreshTree = true + resetQuery() { + this.crud.query.blurry = '' + this.crud.toQuery() }, // 新增与编辑前做的操作 [CRUD.HOOK.afterToCU](crud, form) { if (form.dictionaryParents !== null) { form.isTop = '0' - } else if (form.id !== null) { + } else if (form.dictionaryId !== null) { form.isTop = '1' } - this.getDictsList() + this.getDictsTreeList() }, // 获取数据前设置默认参数 [CRUD.HOOK.beforeRefresh]() { - this.crud.query.id = this.dictionaryParents + this.tableData = [] }, [CRUD.HOOK.afterRefresh](crud) { - if (this.needRefreshTree) { - this.needRefreshTree = false - this.$emit('treeRefresh', crud.data) + crud.data.forEach(function(item, index) { + if (item.sonNum !== 0) { + item.hasChildren = true + } else { + item.hasChildren = false + } + if (!item.hasChildren) { + item.children = null + } + }) + this.tableData = this.crud.data + }, + // 编辑前 + [CRUD.HOOK.beforeToEdit](crud, form) { + crud.form.id = form.dictionaryId + }, + // 提交前的验证 + [CRUD.HOOK.afterValidateCU](crud) { + if (crud.form.isTop === '1') { + crud.form.dictionaryParents = null } + delete crud.form.isTop + console.log(crud.form) + return true + }, + changeIsTop(val) { + if (val === '0') { + this.getDictsTreeList() + } + }, + selectAll() { + this.isAllSelect = !this.isAllSelect + const data = this.tableData + this.toggleSelect(data, this.isAllSelect, 'all') + console.log(data) + }, + // 选择某行 + selectTr(selection, row) { + this.$set(row, 'isChecked', !row.isChecked) + this.$nextTick(() => { + this.isAllSelect = row.isChecked + this.toggleSelect(row, row.isChecked, 'tr') + }) + }, + // 递归子级 + toggleSelect(data, flag, type) { + if (type === 'all') { + if (data.length > 0) { + data.forEach((item) => { + this.toggleSelection(item, flag) + if (item.children && item.children.length > 0) { + this.toggleSelect(item.children, flag, type) + } + }) + } + } else { + if (data.children && data.children.length > 0) { + data.children.forEach((item) => { + item.isChecked = flag + this.$refs.table.toggleRowSelection(item, flag) + this.toggleSelect(item, flag, type) + }) + } + } + }, + // 改变选中 + toggleSelection(row, flag) { + this.$set(row, 'isChecked', flag) + this.$nextTick(() => { + if (flag) { + this.$refs.table.toggleRowSelection(row, flag) + } else { + this.$refs.table.clearSelection() + } + }) + }, + clickRowHandler(row) { + this.$refs.table.clearSelection() + this.$refs.table.toggleRowSelection(row) }, getDictsDatas(tree, treeNode, resolve) { - const params = { pid: tree.id } setTimeout(() => { - crudDict.getDictsList(params).then(res => { - resolve(res.content) + console.log(treeNode) + crudDict.FetchSonDictionaryList({ pid: tree.dictionaryId }).then(res => { + const data = res.map(function(obj) { + if (obj.sonNum !== 0) { + obj.hasChildren = true + obj.children = null + } else { + obj.hasChildren = false + } + return obj + }) + resolve(data) }) }, 100) }, - getDictsList() { - this.crud.loading = true - const params = { - blurry: this.blurry, - page: this.page.page - 1, - size: this.page.size - } - crudDict.getDictsList(params).then(res => { - this.tableData = res.content - this.total = res.totalPages - this.dicts = res.content.map(function(obj) { - if (!obj.childMenus) { - obj.childMenus = null + getDictsTreeList() { + crudDict.FetchDictionaryTree().then(res => { + this.dicts = res.map(function(obj) { + if (obj.sonNum !== 0) { + obj.hasChildren = true + } else { + obj.hasChildren = false + } + if (obj.hasChildren) { + obj.children = null } return obj }) @@ -257,7 +348,7 @@ export default { // 获取弹窗内字典数据 loadDicts({ action, parentNode, callback }) { if (action === LOAD_CHILDREN_OPTIONS) { - crudDict.getDictsList().then(res => { + crudDict.FetchDictionaryTree().then(res => { parentNode.children = res.map(function(obj) { if (obj.children) { obj.childMenus = null @@ -270,60 +361,60 @@ export default { }) } }, - // clickRowHandler(row) { - // this.$refs.table.clearSelection() - // this.$refs.table.toggleRowSelection(row) - // }, - // selectionChangeHandler(val) { - // if (val.length > 1) { - // // 取出最后val的最后一个返回出来 - // const finalVal = val.pop() - // // 清除所有选中 - // this.$refs.table.clearSelection() - // // 给最后一个加上选中 - // this.$refs.table.toggleRowSelection(finalVal) - // this.crud.selectionChangeHandler([finalVal]) - // } else { - // this.crud.selectionChangeHandler(val) - // } - // }, - // toDelete(data) { - // this.deleteData = data - // this.deleteVisible = true - // }, - // handleConfirm() { - // this.deleteVisible = false - // this.crud.delAllLoading = true - // this.crud.doDelete(this.deleteData) - // }, - // handleClose(done) { - // this.deleteData = {} - // done() - // }, + toDelete(datas) { + this.deleteData = datas + this.$confirm('此操作将删除当前所选' + this.crud.title + '你是否还要继续?', '提示', { + confirmButtonText: '继续', + cancelButtonText: '取消', + type: 'warning', + dangerouslyUseHTMLString: true + }).then(() => { + this.crud.delAllLoading = true + const dictionaryIds = [] + this.deleteData.forEach(val => { + dictionaryIds.push(val.dictionaryId) + }) + crudDict.del(dictionaryIds).then(() => { + this.crud.notify('删除成功', CRUD.NOTIFICATION_TYPE.SUCCESS) + this.crud.delAllLoading = false + this.crud.refresh() + }).catch(err => { + this.crud.delAllLoading = false + console.log(err) + }) + }).catch(() => { + }) + }, + doExport(data) { + console.log(data) + this.crud.downloadLoading = true + this.$confirm('此操作将导出所选数据' + '你是否还要继续?', '提示', { + confirmButtonText: '继续', + cancelButtonText: '取消', + type: 'warning', + dangerouslyUseHTMLString: true + }).then(() => { + const ids = [] + data.forEach(val => { + ids.push(val.dictionaryId) + }) + const params = { + 'dictionaryIds': ids + } + exportFile(this.baseApi + '/api/dictionary/download?' + qs.stringify(params, { indices: false })) + this.crud.downloadLoading = false + }).catch(() => { + }) + }, normalizer(node) { - if (node.childMenus == null || node.childMenus === 'null') { - delete node.childMenus + if (node.childDictionarys == null || node.childDictionarys === 'null') { + delete node.childDictionarys } return { id: node.id, label: node.dictionaryName, - children: node.childMenus + children: node.childDictionarys } - }, - // 每页条数改变 - sizeChangeHandler(e) { - this.crud.loading = true - this.page.size = e - this.page.page = 1 - this.getDictsList() - this.crud.loading = false - }, - // 当前页改变 - pageChangeHandler(e) { - this.crud.loading = true - this.page.page = e - this.getDictsList() - this.crud.loading = false } } } diff --git a/src/views/system/metadata/index.vue b/src/views/system/metadata/index.vue index 790a9f4..94b4fb7 100644 --- a/src/views/system/metadata/index.vue +++ b/src/views/system/metadata/index.vue @@ -28,13 +28,13 @@
- + - - {{ data.label }} + + {{ data.metadataName }} - - {{ data.label }} + + {{ data.metadataName }} @@ -74,13 +74,12 @@