Browse Source

修改部分报错以及接口

master
xiaobai 3 years ago
parent
commit
905e2ffd52
  1. 8
      src/api/common.js
  2. 7
      src/api/dic_data.js
  3. 14
      src/directive/permission/index.js
  4. 20
      src/directive/permission/permission.js
  5. 5
      src/main.js
  6. 31
      src/views/device_management/index.vue
  7. 218
      src/views/dic/category.vue
  8. 2
      src/views/dic/dic_data.vue
  9. 14
      src/views/dic/dic_type.vue

8
src/api/common.js

@ -125,7 +125,7 @@ export function initData(params) {
}
export function getDepartmentTreeList(params) {
return api({
url: '/department',
url: '/department/tree',
method: 'get',
params
})
@ -149,4 +149,10 @@ export function deletejobFn(params) {
return require('qs').stringify(data, { indices: false })
}
})
}
export function getDicAssetTreeList() {
return api({
url: '/sedirectory/getList',
method: 'get'
})
}

7
src/api/dic_data.js

@ -30,10 +30,11 @@ export function getAllDicData() {
})
}
export function getDicDataListByTypeName(typeName) {
export function getDicDataListByTypeName(params) {
return api({
url: '/dicData/getDicDataListByTypeName/' + typeName,
method: 'get'
url: '/dicData/getDicDataByTypeCode',
method: 'get',
params
})
}

14
src/directive/permission/index.js

@ -0,0 +1,14 @@
import permission from './permission'
const install = function(Vue) {
Vue.directive('permission', permission)
}
if (window.Vue) {
window['permission'] = permission
// eslint-disable-next-line no-undef
Vue.use(install)
}
permission.install = install
export default permission

20
src/directive/permission/permission.js

@ -0,0 +1,20 @@
import store from '@/store'
export default {
inserted(el, binding, vnode) {
const { value } = binding
const roles = store.getters && store.getters.permissions
console.log(roles)
if (value && value instanceof Array && value.length > 0) {
const permissionRoles = value
const hasPermission = roles.some(role => {
return permissionRoles.includes(role)
})
if (!hasPermission) {
el.parentNode && el.parentNode.removeChild(el)
}
} else {
throw new Error(`need roles! Like v-permission="['admin','editor']"`)
}
}
}

5
src/main.js

@ -1,6 +1,6 @@
import Vue from 'vue'
import 'normalize.css/normalize.css'// A modern alternative to CSS resets
import 'normalize.css/normalize.css' // A modern alternative to CSS resets
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
@ -26,9 +26,10 @@ import server from './utils/server'
import formatter from './utils/formatter'
import numToChinese from './utils/numberToChinese'
import controller from './controller'
import permission from './directive/permission'
import adaptive from './directive/el-table'
import vueqr from 'vue-qr'
Vue.use(permission)
Vue.use(adaptive)
Vue.use(vueqr)

31
src/views/device_management/index.vue

@ -248,7 +248,7 @@ import CrudInstrument from '@/api/instrument'
import TreeSelect from '@/components/TreeSelect'
// import { uploadInstrumentData } from '@/api/file'
import { getDicDataListByTypeName } from '@/api/dic_data'
import { getDepartmentTreeList } from '@/api/common'
import { getDepartmentTreeList, getDicAssetTreeList } from '@/api/common'
import Move from './components/Move'
import { downloadFile, parseTime } from '@/utils'
@ -351,10 +351,10 @@ export default {
departmentId: 0,
treeSelectProps: {
children: 'children',
label: 'departmentName',
label: 'name',
value: 'id'
},
userList: this.$store.getters.allUserList,
userList: this.$store.getters.allUser,
useStateList: [],
useDirectionList: [],
usePurposeList: [],
@ -402,8 +402,15 @@ export default {
mounted() {
this.initDicDataList()
this.getDepartmentTree()
this.getDicAssetTreeList()
},
methods: {
//
getDicAssetTreeList() {
getDicAssetTreeList().then(data => {
this.dicAssetTree = data
})
},
//
[CRUD.HOOK.afterResetQuery]() {
if (this.$refs.queryTreeSelect) {
@ -465,23 +472,23 @@ export default {
//
initDicDataList() {
//
getDicDataListByTypeName('value_type').then(data => { this.valueTypeList = data })
getDicDataListByTypeName({ typeCode: 'value_type' }).then(data => { this.valueTypeList = data })
//
getDicDataListByTypeName('asset_source').then(data => { this.assetSourceList = data })
getDicDataListByTypeName({ typeCode: 'asset_source' }).then(data => { this.assetSourceList = data })
//
getDicDataListByTypeName('funding_source').then(data => { this.fundingSourceList = data })
getDicDataListByTypeName({ typeCode: 'funding_source' }).then(data => { this.fundingSourceList = data })
//
getDicDataListByTypeName('procurement_type').then(data => { this.procurementTypeList = data })
getDicDataListByTypeName({ typeCode: 'procurement_type' }).then(data => { this.procurementTypeList = data })
//
getDicDataListByTypeName('depreciation_state').then(data => { this.depreciationStateList = data })
getDicDataListByTypeName({ typeCode: 'depreciation_state' }).then(data => { this.depreciationStateList = data })
// 使
getDicDataListByTypeName('use_state').then(data => { this.useStateList = data })
getDicDataListByTypeName({ typeCode: 'use_state' }).then(data => { this.useStateList = data })
// 使
getDicDataListByTypeName('use_direction').then(data => { this.useDirectionList = data })
getDicDataListByTypeName({ typeCode: 'use_direction' }).then(data => { this.useDirectionList = data })
// 使
getDicDataListByTypeName('use_purpose').then(data => { this.usePurposeList = data })
getDicDataListByTypeName({ typeCode: 'use_purpose' }).then(data => { this.usePurposeList = data })
//
getDicDataListByTypeName('verification_cycle').then(data => { this.cycleList = data })
getDicDataListByTypeName({ typeCode: 'verification_cycle' }).then(data => { this.cycleList = data })
},
//
getDepartmentValue(value) {

218
src/views/dic/category.vue

@ -107,6 +107,7 @@
<span>字典详情</span>
</div>
<el-table
v-if="list.length > 0"
ref="list"
:data="list"
:row-class-name="tableRowClassName"
@ -115,7 +116,6 @@
highlight-current-row
@row-click="onRowClick"
@selection-change="handleSelectionChange"
v-if="list.length > 0"
>
<el-table-column type="selection" width="40" />
<el-table-column
@ -155,7 +155,9 @@
</template>
</el-table-column>
</el-table>
<div v-else>点击左侧字典查看详情</div>
<div v-else>
点击左侧字典查看详情
</div>
</el-card>
</el-col>
</el-row>
@ -204,7 +206,9 @@
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="dialogFormVisible = false"> </el-button>
<el-button @click="dialogFormVisible = false">
</el-button>
<el-button
v-if="dialogStatus === 'create'"
type="success"
@ -221,9 +225,9 @@
</template>
<script>
import Pagination from "@/components/Pagination";
import Pagination from '@/components/Pagination'
export default {
name: "Category",
name: 'Category',
components: { Pagination },
data() {
return {
@ -233,195 +237,195 @@ export default {
listQuery: {
pageNum: 1, //
pageSize: 20,
orderBy: "sort asc",
parentId: "",
orderBy: 'sort asc',
parentId: ''
},
dialogStatus: "create",
dialogStatus: 'create',
dialogFormVisible: false,
textMap: {
update: "编辑",
create: "新建检验类别",
update: '编辑',
create: '新建检验类别'
},
tempCategory: {},
multipleSelection: [],
sbzlList: [],
species: [],
parentList: [],
leftList: [],
};
leftList: []
}
},
created() {
// this.getList()
this.getSbzlList();
this.getParentList();
this.getLeftList();
this.getSbzlList()
this.getParentList()
this.getLeftList()
},
methods: {
getList() {
this.api({
url: "/category/list",
method: "get",
params: this.listQuery,
url: '/category/list',
method: 'get',
params: this.listQuery
}).then((data) => {
this.list = data.list;
this.totalCount = data.total;
});
this.list = data.list
this.totalCount = data.total
})
},
handleFilter() {
//
this.listQuery.pageNum = 1;
this.getList();
this.listQuery.pageNum = 1
this.getList()
},
onRowClick(row) {
this.$refs.list.toggleRowSelection(row);
this.listQuery.parentId = row.id;
this.getList();
this.$refs.list.toggleRowSelection(row)
this.listQuery.parentId = row.id
this.getList()
},
handleSelectionChange: function (val) {
this.multipleSelection = val;
handleSelectionChange: function(val) {
this.multipleSelection = val
},
showCreate() {
this.tempCategory = {};
this.dialogStatus = "create";
this.dialogFormVisible = true;
this.tempCategory = {}
this.dialogStatus = 'create'
this.dialogFormVisible = true
},
createCategory() {
this.$refs["tempCategory"].validate((valid) => {
this.$refs['tempCategory'].validate((valid) => {
if (valid) {
this.tempCategory.species = JSON.stringify(this.species);
this.tempCategory.species = JSON.stringify(this.species)
this.api({
url: "/category/addCategory",
method: "post",
data: this.tempCategory,
url: '/category/addCategory',
method: 'post',
data: this.tempCategory
}).then(() => {
this.$message({ message: "添加成功。", type: "success" });
this.getList();
this.dialogFormVisible = false;
});
this.$message({ message: '添加成功。', type: 'success' })
this.getList()
this.dialogFormVisible = false
})
} else {
return false;
return false
}
});
})
},
showUpdate($index) {
this.tempCategory = this.list[$index];
this.species = JSON.parse(this.tempCategory.species);
this.dialogStatus = "update";
this.dialogFormVisible = true;
this.tempCategory = this.list[$index]
this.species = JSON.parse(this.tempCategory.species)
this.dialogStatus = 'update'
this.dialogFormVisible = true
},
updateCategory() {
this.$refs["tempCategory"].validate((valid) => {
this.$refs['tempCategory'].validate((valid) => {
if (valid) {
this.tempCategory.species = JSON.stringify(this.species);
this.tempCategory.species = JSON.stringify(this.species)
this.api({
url: "/category/updateCategory",
method: "post",
data: this.tempCategory,
url: '/category/updateCategory',
method: 'post',
data: this.tempCategory
}).then(() => {
this.$message({ message: "数据更新成功。", type: "success" });
this.getList();
this.dialogFormVisible = false;
});
this.$message({ message: '数据更新成功。', type: 'success' })
this.getList()
this.dialogFormVisible = false
})
} else {
return false;
return false
}
});
})
},
deleteCategory() {
if (this.multipleSelection.length === 0) {
this.$message({
type: "error",
message: "请选中需要删除的数据!",
});
return false;
type: 'error',
message: '请选中需要删除的数据!'
})
return false
} else {
this.$confirm("确定删除当前选中记录?", "提示", {
confirmButtonText: "确定",
this.$confirm('确定删除当前选中记录?', '提示', {
confirmButtonText: '确定',
showCancelButton: true,
type: "warning",
type: 'warning'
}).then(() => {
const pks = [];
const qs = require("qs");
const pks = []
const qs = require('qs')
this.multipleSelection.forEach((category) => {
pks.push(category.id);
});
pks.push(category.id)
})
this.api({
url: "/category/delCategory",
method: "delete",
url: '/category/delCategory',
method: 'delete',
params: {
pks: pks,
},
paramsSerializer: function (params) {
return qs.stringify(params, { indices: false });
pks: pks
},
paramsSerializer: function(params) {
return qs.stringify(params, { indices: false })
}
}).then(() => {
this.$message({ message: "删除成功。", type: "success" });
this.getList();
});
});
this.$message({ message: '删除成功。', type: 'success' })
this.getList()
})
})
}
},
getSbzlList() {
this.api({
url: "/sedirectory/getList",
method: "get",
url: '/sedirectory/getList',
method: 'get',
params: {
sbzl: undefined,
level: "1",
},
level: '1'
}
}).then((data) => {
this.sbzlList = data;
});
this.sbzlList = data
})
},
getParentList() {
this.api({
url: "/category/all",
method: "get",
url: '/category/all',
method: 'get',
params: {
parentCode: null,
species: null,
},
species: null
}
}).then((data) => {
this.parentList = data;
});
this.parentList = data
})
},
getLeftList() {
this.api({
url: "/category/getTopLevel",
method: "get",
url: '/category/getTopLevel',
method: 'get',
params: {
pageNum: 10,
pageSize: 10,
},
pageSize: 10
}
}).then((data) => {
this.leftList = data.list;
});
this.leftList = data.list
})
},
closeDialog() {
this.species = [];
this.species = []
},
formatSpecies(row, column, cellValue) {
const value = JSON.parse(cellValue);
let lable = "";
const value = JSON.parse(cellValue)
let lable = ''
for (let i = 0; i < value.length; i++) {
for (let j = 0; j < this.sbzlList.length; j++) {
if (value[i] === this.sbzlList[j].value) {
lable = this.sbzlList[j].label + "," + lable;
break;
lable = this.sbzlList[j].label + ',' + lable
break
}
}
}
return lable.substring(0, lable.length - 1);
return lable.substring(0, lable.length - 1)
},
tableRowClassName({ row }) {
if (row.parentId === null) {
return "main-row";
return 'main-row'
} else {
return "";
return ''
}
},
},
};
}
}
}
</script>
<style>
.el-table .main-row {

2
src/views/dic/dic_data.vue

@ -183,7 +183,7 @@ export default {
this.$refs['tempDicData'].validate(valid => {
if (valid) {
this.api({
url: '/dicData/addDicData',
url: '/dicData',
method: 'post',
data: this.tempDicData
}).then(() => {

14
src/views/dic/dic_type.vue

@ -376,7 +376,7 @@ export default {
this.$refs['tempDicType'].validate((valid) => {
if (valid) {
this.api({
url: '/dicType/addDicType',
url: '/dicType',
method: 'post',
data: this.tempDicType
}).then(() => {
@ -394,8 +394,8 @@ export default {
this.$refs['tempDicType'].validate((valid) => {
if (valid) {
this.api({
url: '/dicType/updateDicType',
method: 'post',
url: '/dicType',
method: 'put',
data: this.tempDicType
}).then(() => {
this.$message({ message: '更新成功。', type: 'success' })
@ -474,12 +474,12 @@ export default {
this.$refs['tempDicData'].validate(valid => {
if (valid) {
this.api({
url: '/dicData/addDicData',
url: '/dicData',
method: 'post',
data: this.tempDicData
}).then(() => {
this.$message({ message: '添加成功。', type: 'success' })
this.getList()
this.getsubList()
this.secondDialogFormVisible = false
})
} else {
@ -491,8 +491,8 @@ export default {
this.$refs['tempDicData'].validate(valid => {
if (valid) {
this.api({
url: '/dicData/updateDicData',
method: 'post',
url: '/dicData',
method: 'put',
data: this.tempDicData
}).then(() => {
this.$message({ message: '更新成功。', type: 'success' })

Loading…
Cancel
Save