Commit e6ba2ccf by wangyalan-git

用户管理,权限

parent 9dccdeeb
......@@ -2,7 +2,7 @@ import request from '@/utils/request'
// 平台管理员列表
export function fetchList(params) {
return request({
url: '/admin/manage/queryPageList',
url: '/admin/getPageList',
method: 'get',
params
})
......@@ -10,16 +10,16 @@ export function fetchList(params) {
// 添加管理员
export function createAdmin(data) {
return request({
url: '/admin/manage/addUmsAdmin',
url: '/admin/insertAdmin',
method: 'post',
data
})
}
// 修改管理员
export function updateAdmin(id, data) {
export function updateAdmin(data) {
return request({
url: '/admin/manage/update/' + id,
url: '/admin/updateAdmin',
method: 'post',
data
})
}
\ No newline at end of file
}
......@@ -57,13 +57,15 @@ export function updateFileType(data) {
// 文件下载
export function downloadFile(params) {
return request({
url: '/file/download',
url: '/file/downloadByFileId',
method: 'post',
params,
responseType: 'blob'
})
}
// 文件删除
export function deleteFile(params) {
return request({
......
......@@ -3,40 +3,16 @@ import request from '@/utils/request'
// 万科后台_获取首页统计今日数据
export function getHomeData (params) {
return request({
url: 'vankeStatisticalChart/getHomeData',
method: 'post',
url: 'vankeFile/getHomeData',
method: 'get',
params: params
})
}
// 万科后台_获取首页入库物品类别分布
export function selectInBoundByCategory(data) {
// 万科后台_获取今日下载文件分页操作
export function getTodayDownloadList (params) {
return request({
url: 'vankeStatisticalChart/selectInBoundByCategory',
method: 'post',
data
})
}
// 万科后台_获取首页领取物品类别分布
export function selectOutBoundByCategory(data) {
return request({
url: 'vankeStatisticalChart/selectOutBoundByCategory',
method: 'post',
data
})
}
// 万科后台_获取首页申领人部门分布
export function selectOutBoundByDepartId(data) {
return request({
url: 'vankeStatisticalChart/selectOutBoundByDepartId',
method: 'post',
data
})
}
// 万科后台_获取首页统计出库值和入库值的变化曲线图
export function selectStockByGoodsIdAndTime(data) {
return request({
url: 'vankeStatisticalChart/selectStockByGoodsIdAndTime',
method: 'post',
data
url: 'vankeFile/todayList',
method: 'get',
params: params
})
}
......@@ -54,6 +54,19 @@ export const asyncRouterMap = [
meta: { title: '文档类型', icon: 'product-list' }
}]
},
{
path: '/adm',
component: Layout,
redirect: '/adm/admList',
name: 'adm',
meta: { title: '用户管理', icon: 'ums-admin' },
children: [{
path: 'adminList',
name: 'adminList',
component: () => import('@/views/ums/admin/index'),
meta: { title: '用户管理', icon: 'ums-admin' }
}]
},
// 权限模块
{
path: '/ums',
......@@ -62,12 +75,12 @@ export const asyncRouterMap = [
name: 'ums',
meta: { title: '权限', icon: 'ums' },
children: [
{
path: 'admin',
name: 'admin',
component: () => import('@/views/ums/admin/index'),
meta: { title: '用户列表', icon: 'ums-admin' }
},
// {
// path: 'admin',
// name: 'admin',
// component: () => import('@/views/ums/admin/index'),
// meta: { title: '用户列表', icon: 'ums-admin' }
// },
{
path: 'role',
name: 'role',
......
<template> 
<div class="app-container">
<!-- 表格栏 -->
<el-card class="filter-container mt15"
shadow="never">
<el-row type="flex" class="btn-groups">
<el-button type="primary" @click="handleAdd">新增</el-button>
</el-row>
<div class="table-container">
<el-table :data="list"
v-loading="listLoading"
@selection-change="handleSelectionChange"
border>
<el-table-column type="selection"
align="center"
width="50"></el-table-column>
<el-table-column label="物品类别"
align="center">
<template slot-scope="scope">{{scope.row.name}}</template>
</el-table-column>
<el-table-column label="创建时间"
align="center">
<template slot-scope="scope">{{scope.row.createtime | formatTime}}</template>
</el-table-column>
<el-table-column label="操作"
align="center">
<template slot-scope="scope">
<el-button size="mini"
type="danger"
@click="handleDelete(scope.row.id)">删除</el-button>
</template>
</el-table-column>
</el-table>
</div>
<!-- 分页栏 -->
<div class="pagination-container">
<el-pagination background
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
layout="total, sizes, prev, pager, next, jumper"
:current-page.sync="listQuery.pageNum"
:page-size="listQuery.pageSize"
:page-sizes="[10,30,50]"
:total="total">
</el-pagination>
</div>
</el-card>
<!-- 弹窗-->
<add-department-modal ref="addDepartment" @ok="getList"></add-department-modal>
</div>
</template>
<script>
import moment from 'moment'
import { getDepartmentList, editDepart } from '@/api/inventory'
import AddDepartmentModal from './modules/addDepartmentModal'
// 列表查询参数默认值
const defaultListQuery = {
pageNum: 1,
pageSize: 10
}
export default {
name: 'DepartmentList',
components: {AddDepartmentModal},
data() {
return {
listQuery: Object.assign({}, defaultListQuery),
list: [],
total: 0,
listLoading: false,
multipleSelection: [],
}
},
created() {
this.getList()
},
filters: {
formatTime(time) {
if (!time) {
return '--'
}
return moment(time).format('YYYY-MM-DD HH:mm:ss')
}
},
methods: {
handleResetSearch() {
this.listQuery = Object.assign({}, defaultListQuery)
this.getList()
},
handleSearchList() {
this.listQuery.pageNum = 1
this.getList()
},
handleSizeChange(val) {
this.listQuery.pageNum = 1
this.listQuery.pageSize = val
this.getList()
},
handleCurrentChange(val) {
this.listQuery.pageNum = val
this.getList()
},
handleSelectionChange(vals) {
this.multipleSelection = vals
},
//请求数据
getList() {
this.listLoading = true
//请求数据
console.log('listQuery', this.listQuery)
getDepartmentList(this.listQuery).then(res => {
this.listLoading = false
this.list = res.data.list
this.total = res.data.total
}).catch(err => {
this.listLoading = false
})
},
// 添加
handleAdd(){
this.$refs.addDepartment.add()
},
// 删除
handleDelete(id){
this.$confirm('是否删除该部门?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
editDepart({id: id,deleteStatus: 0 }).then(res=>{
this.getList()
})
}).catch(() => {
});
}
}
}
</script>
<style scoped>
.app-container {
font-size: 14px;
color: #606266;
padding: 0 15px;
margin-top: 0;
}
.mt15 {
margin-top: 15px;
}
.input-width {
width: 180px;
}
.btn-groups button{
width: 100px;
}
</style>
<template>
<el-dialog :visible.sync="visible"
:title="title"
center
width="500px">
<!-- start -->
<el-form :model="model"
ref="attributeForm"
v-loading="loading"
label-width="150px">
<el-form-item label="部门:"
:rules="[{required: true, trigger: 'blur', message: '请输入部门名称'}]"
prop="name">
<el-input size="small"
class="input-width"
placeholder="请输入部门名称"
v-model="model.name"></el-input>
</el-form-item>
</el-form>
<div slot="footer">
<el-button type="primary"
@click="submit">确认</el-button>
<el-button @click="close">取消</el-button>
</div>
<!-- end -->
</el-dialog>
</template>
<script>
import { addDepart } from '@/api/inventory'
// 移动属性
export default {
name: 'addDepartmentModal',
data () {
return {
visible: false,
title: null,
loading: false,
id: null,
model: {}
}
},
methods: {
init () {
this.model = {
name: null
}
this.$nextTick(() => {
this.$refs.attributeForm.clearValidate()
})
},
add(){
this.id = null
this.title="新增部门"
this.init()
this.visible= true
},
// detail (id) {
// this.id = id
// this.init()
// this.visible = true
// this.title = '移动属性'
// this.loading = true
// getAttribute(id).then(res => {
// this.model = res.data
// this.loading = false
// }).catch(err => {
// this.loading = false
// this.close()
// })
// },
// 提交保存
submit () {
this.$refs.attributeForm.validate((valid) => {
if (valid) {
// 验证通过
addDepart(this.model).then(res => {
this.loading = false
this.visible = false
this.$emit('ok')
}).catch(err => {
this.loading = false
})
}
})
},
close () {
this.$emit('close')
this.visible = false
}
}
}
</script>
<style scoped>
.input-width {
width: 200px;
}
</style>
......@@ -59,7 +59,7 @@
<template slot-scope="scope">
<el-button size="mini"
type="primary"
@click="handleDown(scope.row.fileName)">下载
@click="handleDown(scope.row)">下载
</el-button>
<el-button size="mini"
type="danger"
......@@ -160,35 +160,19 @@ export default {
handleImport() {
this.$refs.importFile.add()
},
handleDown(fileName){
downloadFile({fileName:fileName }).then(res=>{
handleDown(row){
downloadFile({fileId:row.id }).then(res=>{
console.log('res',res)
var blob = new Blob([res],{type: "application/octet-stream"});
if (window.navigator.msSaveOrOpenBlob) {//msSaveOrOpenBlob方法返回bool值
navigator.msSaveBlob(blob, fileName);//本地保存
navigator.msSaveBlob(blob, row.fileName);//本地保存
} else {
var link = document.createElement('a');//a标签下载
link.href = window.URL.createObjectURL(blob);
link.download = fileName;
link.download = row.fileName;
link.click();
window.URL.revokeObjectURL(link.href);
}
// const content = res
// console.log('res')
// const blob = new Blob([content])
// const fileName = '导出信息.xlsx'
// if ('download' in document.createElement('a')) { // 非IE下载
// const elink = document.createElement('a')
// elink.download = fileName
// elink.style.display = 'none'
// elink.href = URL.createObjectURL(blob)
// document.body.appendChild(elink)
// elink.click()
// URL.revokeObjectURL(elink.href) // 释放URL 对象
// document.body.removeChild(elink)
// } else { // IE10+下载
// navigator.msSaveBlob(blob, fileName)
// }
})
},
......
......@@ -8,7 +8,7 @@
class="total-icon">
</svg-icon>
<div class="total-title">今日上传</div>
<div class="total-value">{{homeData['今日出库']}}</div>
<div class="total-value">{{homeData.todayUpload || 0}}</div>
</div>
</el-col>
<el-col>
......@@ -17,7 +17,7 @@
class="total-icon">
</svg-icon>
<div class="total-title">今日下载</div>
<div class="total-value">{{homeData['今日入库']}}</div>
<div class="total-value">{{homeData.todayDownload || 0}}</div>
</div>
</el-col>
<el-col>
......@@ -26,7 +26,7 @@
class="total-icon">
</svg-icon>
<div class="total-title">累计上传</div>
<div class="total-value">{{homeData['库存预警']}}</div>
<div class="total-value">{{homeData.totalUpload || 0}}</div>
</div>
</el-col>
<el-col>
......@@ -35,7 +35,7 @@
class="total-icon">
</svg-icon>
<div class="total-title">累计下载</div>
<div class="total-value">{{homeData['今日申领人']}}</div>
<div class="total-value">{{homeData.totalDownload || 0}}</div>
</div>
</el-col>
</el-row>
......@@ -45,15 +45,17 @@
<el-col :span="12">
<div class="out-border">
<div class="layout-title">今日下载排行</div>
<div style="padding: 40px">
<div style="padding: 40px;min-height: 552px;">
<el-table
:data="homeData.stockWarns"
:show-header="false"
:data="todayDownload"
style="width: 100%">
<el-table-column
prop="name">
prop="fileName">
</el-table-column>
<el-table-column
prop="goodsCategoryName">
width="80"
prop="times">
</el-table-column>
</el-table>
</div>
......@@ -62,15 +64,17 @@
<el-col :span="12">
<div class="out-border">
<div class="layout-title">累计下载排行</div>
<div style="padding: 40px">
<div style="padding: 40px;min-height: 552px;">
<el-table
:data="homeData.stockWarns"
:show-header="false"
:data="totalDownload"
style="width: 100%">
<el-table-column
prop="name">
</el-table-column>
<el-table-column
prop="goodsCategoryName">
width="80"
prop="times">
</el-table-column>
</el-table>
</div>
......@@ -83,7 +87,8 @@
<script>
import { str2Date } from '@/utils/date'
import { getHomeData,selectStockByGoodsIdAndTime,selectInBoundByCategory,selectOutBoundByCategory,selectOutBoundByDepartId } from '@/api/home'
import { getHomeData,getTodayDownloadList } from '@/api/home'
import { getFileList } from '@/api/doc'
export default {
name: 'home',
......@@ -91,16 +96,26 @@ export default {
const that = this
return {
homeData: {},
todayDownload: [],
totalDownload: []
}
},
created() {
this.getHomeData()
this.init()
},
methods: {
getHomeData() {
getHomeData({ queryTime: '2020-06-28' }).then(res => {
this.homeData = res.data
this.homeData.stockWarns = res.data['库存预警集合'].splice(0,7)
init() {
// 数据
getHomeData().then(res => {
this.homeData = res.data.context
})
// 今日下载排行
getTodayDownloadList({ pageSize: 10, pageNum: 1}).then(res => {
this.todayDownload = res.data.list
})
// 累计下载排行/
getFileList({ pageSize: 10, pageNum: 1, isByDownloadTimes: 1 }).then(res => {
this.totalDownload = res.data.list
})
}
}
......
......@@ -15,15 +15,9 @@
</div>
<el-dropdown-menu class="user-dropdown"
slot="dropdown">
<el-dropdown-item command="PersonalInfo">
编辑个人资料
</el-dropdown-item>
<el-dropdown-item command="ChangeTel">
更换绑定手机号码
</el-dropdown-item>
<el-dropdown-item divided>
<span @click="logout"
style="display:block;">退出</span>
<el-dropdown-item>
<span @click="logout"
style="display:block;">退出</span>
</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
......@@ -54,15 +48,15 @@ export default {
])
},
methods: {
toggleSideBar () {
toggleSideBar() {
this.$store.dispatch('ToggleSideBar')
},
logout () {
logout() {
this.$store.dispatch('LogOut').then(() => {
location.reload() // 为了重新实例化vue-router对象 避免bug
})
},
handleCommand (command) {
handleCommand(command) {
if (command === 'PersonalInfo') {
this.$refs.detailModal.detail()
} else if (command === 'ChangeTel') {
......@@ -75,44 +69,50 @@ export default {
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
.navbar {
height: 50px;
line-height: 50px;
border-radius: 0px !important;
.hamburger-container {
line-height: 58px;
height: 50px;
float: left;
padding: 0 10px;
}
.screenfull {
position: absolute;
right: 90px;
top: 16px;
color: red;
}
.avatar-container {
.navbar {
height: 50px;
display: inline-block;
position: absolute;
right: 35px;
.avatar-wrapper {
cursor: pointer;
margin-top: 5px;
position: relative;
.user-avatar {
width: 40px;
height: 40px;
border-radius: 10px;
}
.el-icon-caret-bottom {
position: absolute;
right: -20px;
top: 25px;
font-size: 12px;
line-height: 50px;
border-radius: 0px !important;
.hamburger-container {
line-height: 58px;
height: 50px;
float: left;
padding: 0 10px;
}
.screenfull {
position: absolute;
right: 90px;
top: 16px;
color: red;
}
.avatar-container {
height: 50px;
display: inline-block;
position: absolute;
right: 35px;
.avatar-wrapper {
cursor: pointer;
margin-top: 5px;
position: relative;
.user-avatar {
width: 40px;
height: 40px;
border-radius: 10px;
}
.el-icon-caret-bottom {
position: absolute;
right: -20px;
top: 25px;
font-size: 12px;
}
}
}
}
}
</style>
......@@ -56,9 +56,9 @@
<img style="width:100px; padding: 8px;position: absolute;bottom: 10px;right: 10px;"
:src="captchaImage" alt="" @click="refreshCode"> 
</el-form-item>
<div class="row">
<p @click="forgetPwd">忘记密码</p>
</div>
<!-- <div class="row">-->
<!-- <p @click="forgetPwd">忘记密码</p>-->
<!-- </div>-->
<el-form-item>
<el-button type="primary"
style="width: 100%;border-radius: 20px;"
......
<template>
<el-card class="operate-container"
shadow="never">
<!--操作栏-->
<el-form :inline="true"
:model="listQuery"
size="small">
<el-form-item label="操作人:">
<el-input v-model="listQuery.name"
placeholder="请输入操作人名称"></el-input>
</el-form-item>
<el-form-item label="操作时间:">
<el-date-picker type="datetime"
value-format="yyyy-MM-dd HH:mm:ss"
placeholder="开始时间"
v-model="listQuery.startingTime">
</el-date-picker>
<el-date-picker type="datetime"
value-format="yyyy-MM-dd HH:mm:ss"
placeholder="结束时间"
v-model="listQuery.endTime">
</el-date-picker>
</el-form-item>
<el-form-item>
<el-button type="primary"
@click="handleSearchList"
size="small">搜索</el-button>
<el-button style="float:right;margin-right: 15px"
@click="handleResetSearch"
size="small">重置</el-button>
</el-form-item>
</el-form>
<el-divider></el-divider>
<!--列表-->
<div class="table-container">
<el-table :data="list"
v-loading="listLoading"
border>
<el-table-column label="操作人"
align="center"
prop="adminName">
</el-table-column>
<el-table-column label="操作内容"
align="center"
prop="content">
</el-table-column>
<el-table-column label="操作时间"
align="center"
prop="module">
<template slot-scope="scope">{{scope.row.createTime | formatTime}}</template>
</el-table-column>
</el-table>
</div>
<!-- 分页 -->
<div class="pagination-container">
<el-pagination background
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
layout="total, sizes, prev, pager, next, jumper"
:page-size="listQuery.pageSize"
:page-sizes="[10, 20, 30, 50, 100]"
:current-page.sync="listQuery.pageNum"
:total="total">
</el-pagination>
</div>
</el-card>
</template>
<script>
import { logRequest } from '@/api/login'
import moment from 'moment/moment'
const defaultListQuery = {
pageNum: 1,
pageSize: 10,
startingTime: null,
endTime: null,
type: 0,
name: null
}
export default {
name: "capitalSubsidiary",
comments: [],
data() {
return {
total: 0,
listLoading: false,
list: [],
listQuery: Object.assign({}, defaultListQuery)
}
},
created() {
let name = this.$route.params.name
if (name) {
this.listQuery.name = name
}
this.logRequest()
},
methods: {
//时间戳转化时间
dateFormat: function (row, column) {
var date = row[column.property]
if (date == undefined) {
return ""
}
return this.moment(date).format("YYYY-MM-DD")
},
//时间戳转化时间
timeFormat: function (row, column) {
var date = row[column.property]
if (date == undefined) {
return "--"
}
return this.moment(date).format("HH:mm:ss")
},
// 条件查询
handleSearchList() {
this.listQuery.pageNum = 1
this.logRequest()
},
//表单重置
handleResetSearch() {
this.listQuery = Object.assign({}, defaultListQuery)
his.logRequest()
},
// 每页页数变化
handleSizeChange(val) {
this.listQuery.pageNum = 1
this.listQuery.pageSize = val
this.logRequest()
},
//当前页变化
handleCurrentChange(val) {
this.listQuery.pageNum = val
this.logRequest()
},
// 日志
logRequest() {
this.listLoading = true
logRequest(this.listQuery).then(response => {
this.listLoading = false
this.list = response.data.list
this.total = response.data.total
}).catch(err => {
this.listLoading = false
})
}
},
filters: {
formatTime(time) {
if (!time) {
return '--'
}
return moment(time).format('YYYY-MM-DD HH:mm:ss')
}
},
}
</script>
<style scoped>
.operate-container {
font-size: 14px;
color: #606266;
padding: 0 15px;
padding-top: 20px;
margin-top: 0;
}
</style>
<template> 
<el-card class="form-container" shadow="never">
<el-form :model="setting"
ref="orderSettingForm"
:rules="rules">
<el-form-item prop="stockWarning">
<div>物品数量少于多少预警(个/件):</div>
<el-input v-model="setting.stockWarning" class="input-width">
</el-input>
</el-form-item>
<el-form-item prop="receiveInterval">
<div>物品领用间隔时间(小时):</div>
<el-input v-model="setting.receiveInterval" class="input-width">
</el-input>
</el-form-item>
<el-form-item>
<el-button
@click="confirm('orderSettingForm')"
type="primary">提交</el-button>
</el-form-item>
</el-form>
</el-card>
</template>
<script>
import {getSetting,editSetting} from '@/api/setting';
const defaultOrderSetting = {
id: null,
stockWarning: 0,
receiveInterval: 0
};
const checkTime = (rule, value, callback) => {
if (value === '') {
callback(new Error('请输入'))
} else {
let myReg = /^\d{1,}$/
if (!myReg.test(value)) {
callback(new Error('请输入数字值'))
}
callback()
}
}
// const checkTime = (rule, value, callback) => {
// if (!value) {
// return callback(new Error('时间不能为空'));
// }
// console.log("checkTime",value);
// let intValue = parseInt(value);
// if (!Number.isInteger(intValue)) {
// return callback(new Error('请输入数字值'));
// }
// callback();
// };
export default {
name: 'setting',
data() {
return {
setting: Object.assign({}, defaultOrderSetting),
rules: {
stockWarning:{validator: checkTime, trigger: 'blur' },
receiveInterval: {validator: checkTime, trigger: 'blur' }
}
}
},
created(){
this.getDetail();
},
methods:{
confirm(formName){
this.$refs[formName].validate((valid) => {
if (valid) {
this.$confirm('是否要提交修改?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
editSetting(this.setting).then(response=>{
this.$message({
type: 'success',
message: '提交成功!',
duration:1000
});
})
});
} else {
this.$message({
message: '提交参数不合法',
type: 'warning'
});
return false;
}
});
},
getDetail(){
getSetting().then(res=>{
if(res.data){
this.setting={
id: res.data.id,
receiveInterval: res.data.receiveInterval,
stockWarning: res.data.stockWarning
}
}
})
}
}
}
</script>
<style scoped>
.input-width {
width: 50%;
}
.note-margin {
margin-left: 15px;
}
</style>
<template> 
<div class="app-container">
<!-- 搜索栏 -->
<el-card class="filter-container"
shadow="never">
<el-form :inline="true"
:model="listQuery"
size="small">
<el-form-item label="供应商名称:">
<el-input v-model="listQuery.name"
class="input-width"
placeholder="请输入供应商名称"></el-input>
</el-form-item>
<el-form-item>
<el-button type="primary"
@click="handleSearchList"
icon="el-icon-search"
size="small">搜索</el-button>
<el-button @click="handleResetSearch"
icon="el-icon-refresh"
size="small">重置</el-button>
</el-form-item>
<el-button class="btn-add"
size="small"
type="primary"
@click="handleAdd">添加供应商
</el-button>
</el-form>
</el-card>
<!-- 表格栏 -->
<el-card class="filter-container mt15"
shadow="never">
<div class="table-container">
<el-table :data="list"
v-loading="listLoading"
@selection-change="handleSelectionChange"
border>
<el-table-column type="selection"
align="center"
width="50"></el-table-column>
<el-table-column label="供应商名称"
align="center">
<template slot-scope="scope">{{scope.row.supplierName}}</template>
</el-table-column>
<el-table-column label="联系人"
align="center">
<template slot-scope="scope">{{scope.row.name}}</template>
</el-table-column>
<el-table-column label="联系方式"
align="center">
<template slot-scope="scope">{{scope.row.tel || '--'}}</template>
</el-table-column>
<el-table-column label="供应物品"
align="center">
<template slot-scope="scope">{{scope.row.goodsNum || 0}}</template>
</el-table-column>
<el-table-column label="备注"
align="center">
<template slot-scope="scope">{{scope.row.remarks}}</template>
</el-table-column>
<el-table-column label="操作"
width="220"
align="center">
<template slot-scope="scope">
<el-button size="mini"
type="primary"
@click="handleEdit(scope.row.id)">编辑</el-button>
<el-button size="mini"
type="danger"
@click="handleDelete(scope.row.id)">删除</el-button>
</template>
</el-table-column>
</el-table>
</div>
<!-- 分页栏 -->
<div class="pagination-container">
<el-pagination background
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
layout="total, sizes, prev, pager, next, jumper"
:current-page.sync="listQuery.pageNum"
:page-size="listQuery.pageSize"
:page-sizes="[10,30,50]"
:total="total">
</el-pagination>
</div>
</el-card>
<!-- end -->
<!-- 弹窗 -->
<add-supplier ref="addSupplier"
@ok="getList"></add-supplier>
<!-- end -->
</div>
</template>
<script>
import { getSuppliersList, editSupplier } from '@/api/supplier'
import AddSupplier from './modules/AddSupplier'
// 列表查询参数默认值
const defaultListQuery = {
pageNum: 1,
pageSize: 10,
name: ''
}
export default {
name: 'SupplierList',
components: {AddSupplier},
data() {
return {
listQuery: Object.assign({}, defaultListQuery),
list: [],
total: 0,
listLoading: false,
multipleSelection: [],
}
},
created() {
this.getList()
},
methods: {
handleResetSearch() {
this.listQuery = Object.assign({}, defaultListQuery)
this.getList()
},
handleSearchList() {
this.listQuery.pageNum = 1
this.getList()
},
handleSizeChange(val) {
this.listQuery.pageNum = 1
this.listQuery.pageSize = val
this.getList()
},
handleCurrentChange(val) {
this.listQuery.pageNum = val
this.getList()
},
handleSelectionChange(vals) {
this.multipleSelection = vals
},
//请求数据
getList() {
this.listLoading = true
//请求数据
getSuppliersList(this.listQuery).then(res => {
this.listLoading = false
this.list = res.data.list
this.total = res.data.total
}).catch(err => {
this.listLoading = false
})
},
// 添加供应商
handleAdd () {
this.$refs.addSupplier.add()
},
// 删除
handleDelete(id) {
this.$confirm('是否删除该供应商?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
editSupplier({id: id,deleteStatus: 0 }).then(res=>{
this.getList()
})
}).catch(() => {
});
},
//编辑
handleEdit(id) {
this.$refs.addSupplier.detail(id)
}
}
}
</script>
<style scoped>
.app-container {
font-size: 14px;
color: #606266;
padding: 0 15px;
margin-top: 0;
}
.primary{
color: #409EFF;
}
.el-row {
margin-bottom: 20px;
}
.mt15 {
margin-top: 15px;
}
.el-input {
width: 200px;
}
.input-width {
width: 180px;
}
</style>
<template>
<el-dialog :visible.sync="visible"
:title="title"
center
width="720px">
<!-- start -->
<el-form :model="model"
ref="myForm"
v-loading="loading"
label-width="200px">
<div class="scroll-container"
ref="scrollContainer">
<el-form-item label="供应商名称:"
:rules="[{required: true, trigger: 'blur', message: '供应商名称不能为空'}]"
prop="supplierName">
<el-input size="small"
class="input-width"
v-model="model.supplierName"></el-input>
</el-form-item>
<el-form-item label="联系人:"
:rules="[{required: true, trigger: 'blur', message: '联系人不能为空'}]"
prop="name">
<el-input size="small"
class="input-width"
v-model="model.name"></el-input>
</el-form-item>
<el-form-item label="联系方式:"
:rules="[ {required: true,validator: validatePhone, trigger: 'blur'}]"
prop="tel">
<el-input size="small"
class="input-width"
v-model="model.tel"></el-input>
</el-form-item>
<el-form-item label="备注:"
prop="remarks"
:rules="[{required: true, trigger: 'blur', message: '备注不能为空'}]">
<el-input size="small"
type="textarea"
class="input-width"
maxlength="32"
show-word-limit
:autosize="{ minRows: 3, maxRows: 6}"
v-model="model.remarks"></el-input>
</el-form-item>
</div>
</el-form>
<div slot="footer">
<el-button type="primary"
@click="submit">确认
</el-button>
<el-button @click="close">取消</el-button>
</div>
<!-- end -->
</el-dialog>
</template>
<script>
import { addSupplier,getSupplierDetail, editSupplier } from '@/api/supplier'
// 添加编辑属性
export default {
name: 'AddSupplier',
data() {
const validatePhone = (rule, value, callback) => {
if (value === '') {
callback(new Error('请填写手机号码'))
} else {
if (!(/^1(3|4|5|6|7|8|9)\d{9}$/.test(value))) {
callback(new Error('手机号码格式有误'))
} else {
callback()
}
}
}
return {
visible: false,
title: null,
loading: false,
id: null,
model: {},
validatePhone: validatePhone
}
},
methods: {
init() {
this.model = {
supplierName: null,
name: null,
remarks: null,
tel: null
}
this.$nextTick(() => {
this.$refs.myForm.clearValidate()
this.$refs.scrollContainer.scrollTop = 0
})
},
add() {
this.id = null
this.init()
this.visible = true
this.title = '添加供应商'
},
detail(id) {
this.id = id
this.init()
this.visible = true
this.title = '编辑供应商'
this.loading = true
getSupplierDetail({ id: id }).then(res => {
this.model = res.data
this.loading = false
}).catch(err => {
this.loading = false
this.close()
})
},
// 提交保存
submit() {
this.$refs.myForm.validate((valid) => {
if (valid) {
// 验证通过
if (this.id) {
// 修改属性
this.loading = true
let params = {
id: this.model.id,
supplierName: this.model.supplierName,
name: this.model.name,
tel: this.model.tel,
remarks: this.model.remarks
}
editSupplier(params).then(res => {
this.loading = false
this.visible = false
this.$emit('ok')
}).catch(err => {
this.loading = false
})
} else {
// 添加属性
this.loading = true
addSupplier(this.model).then(res => {
this.loading = false
this.visible = false
this.$emit('ok')
}).catch(err => {
this.loading = false
})
}
}
})
},
close() {
this.$emit('close')
this.visible = false
}
}
}
</script>
<style scoped>
.scroll-container {
max-height: 50vh;
overflow: hidden;
overflow-y: auto;
}
.input-width {
width: 300px;
}
</style>
<template> 
<div class="app-container">
<!-- 搜索栏 -->
<el-card class="filter-container"
shadow="never">
<el-form :inline="true"
:model="listQuery"
size="small">
<el-form-item label="供应商:">
<el-select v-model="listQuery.supplierId"
class="input-width"
clearable
placeholder="请选择供应商">
<el-option v-for="item in supplierOptions"
:key="item.id"
:label="item.supplierName"
:value="item.id"></el-option>
</el-select>
</el-form-item>
<el-form-item label="物品类别:">
<el-select v-model="listQuery.goodsCategoryId"
class="input-width"
clearable
placeholder="请选择物品类别"
@visible-change="handleOpenCate">
<el-option v-for="item in categoryOptions"
:key="item.id"
:label="item.name"
:value="item.id"></el-option>
</el-select>
</el-form-item>
<el-form-item label="物品:">
<el-select v-model="listQuery.goodsId"
class="input-width"
clearable
placeholder="请选择物品"
@visible-change="handleOpenGoods">
<el-option v-for="item in goodOptions"
:key="item.id"
:label="item.name"
:value="item.id"></el-option>
</el-select>
</el-form-item>
<el-form-item>
<el-button type="primary"
@click="handleSearchList"
icon="el-icon-search"
size="small">搜索
</el-button>
<el-button @click="handleResetSearch"
icon="el-icon-refresh"
size="small">重置
</el-button>
</el-form-item>
</el-form>
</el-card>
<!-- 表格栏 -->
<el-card class="filter-container mt15"
shadow="never">
<div class="table-container">
<ve-line :data="chartData"
:legend-visible="false"
:loading="loading"
:data-empty="dataEmpty"
></ve-line>
</div>
</el-card>
</div>
</template>
<script>
import moment from 'moment'
import { str2Date } from '@/utils/date'
import { getSuppliersList } from '@/api/supplier'
import { getGoodsList, getGoodsCategoryList } from '@/api/inventory'
import { getInventoryList } from '@/api/report'
// 列表查询参数默认值
const defaultListQuery = {
pageNum: 1,
pageSize: 10,
goodsId: '',
supplierId: '',
goodsCategoryId: ''
}
export default {
name: 'InventoryChart',
data() {
return {
categoryOptions: [],
supplierOptions: [],
goodOptions: [],
inventoryList: [],
orderCountDate: '',
statusOptions: [{
label: '启用',
value: 1
},
{
label: '禁用',
value: 0
}],
listQuery: Object.assign({}, defaultListQuery),
list: [],
total: 0,
listLoading: false,
multipleSelection: [],
chartData: {
columns: ['data', 'num'],
rows: []
},
loading: false,
dataEmpty: false
}
},
created() {
this.getSuppliersList()
// this.getData()
},
filters: {
formatTime(time) {
if (!time) {
return '--'
}
return moment(time).format('YYYY-MM-DD HH:mm:ss')
}
},
methods: {
getDay(day) {
var today = new Date()
var targetday_milliseconds = today.getTime() + 1000 * 60 * 60 * 24 * day
today.setTime(targetday_milliseconds) //注意,这行是关键代码
var tYear = today.getFullYear()
var tMonth = today.getMonth()
var tDate = today.getDate()
tMonth = this.doHandleMonth(tMonth + 1)
tDate = this.doHandleMonth(tDate)
console.log('tYear + \'-\' + tMonth + \'-\' + tDate',tYear + '-' + tMonth + '-' + tDate)
return tYear + '-' + tMonth + '-' + tDate
},
doHandleMonth(month) {
var m = month
if (month.toString().length == 1) {
m = '0' + month
}
return m
},
formatEveryDay() {
let start1 = this.getDay(-7)
let end1 = this.getDay(0)
console.log('start1','end1',start1,end1)
let dateList = []
var startTime = this.getDate(start1)
var endTime = this.getDate(end1)
while ((endTime.getTime() - startTime.getTime()) >= 0) {
var year = startTime.getFullYear()
var month = startTime.getMonth() + 1 < 10 ? '0' + (startTime.getMonth() + 1) : startTime.getMonth() + 1
var day = startTime.getDate().toString().length == 1 ? '0' + startTime.getDate() : startTime.getDate()
dateList.push(year + '-' + month + '-' + day)
startTime.setDate(startTime.getDate() + 1)
}
console.log('dateList',dateList)
return dateList
},
getDate(datestr) {
var temp = datestr.split('-')
var date = new Date(temp[0], temp[1] - 1, temp[2])
console.log('date', date)
return date
},
handleOpenCate(visible) {
if (visible) {
this.getGoodsCategoryList()
}
},
handleOpenGoods(visible) {
if (visible) {
this.getGoodsList()
}
},
// 物品
getGoodsList() {
getGoodsList({
goodsCategoryI: this.listQuery.goodsCategoryId,
supplierId: this.listQuery.supplierId
}).then(res => {
this.goodOptions = res.data.list
})
},
// 物品类别
getGoodsCategoryList() {
getGoodsCategoryList({ supplierId: this.listQuery.supplierId }).then(res => {
this.categoryOptions = res.data.list
})
},
// 供应商
getSuppliersList() {
getSuppliersList().then(res => {
this.supplierOptions = res.data.list
})
},
getList() {
if (!this.listQuery.goodsId) {
this.$message.warning('请选择物品')
return
}
getInventoryList({ dateList: this.formatEveryDay(), goodsId: this.listQuery.goodsId }).then(res => {
this.chartData.rows = res.data
console.log('res', this.chartData)
})
},
handleResetSearch() {
this.listQuery = Object.assign({}, defaultListQuery)
this.getList()
},
handleSearchList() {
this.listQuery.pageNum = 1
this.getList()
},
handleSelectionChange(vals) {
this.multipleSelection = vals
},
handleAdd() {
this.$refs.addGoods.add()
}
}
}
</script>
<style scoped>
.app-container {
font-size: 14px;
color: #606266;
padding: 0 15px;
margin-top: 0;
}
.mt15 {
margin-top: 15px;
}
.input-width {
width: 180px;
}
.btn-groups button {
width: 100px;
}
</style>
<template> 
<div class="app-container">
<!-- 搜索栏 -->
<el-card class="filter-container"
shadow="never">
<el-form :inline="true"
:model="listQuery"
size="small">
<el-form-item label="供应商:">
<el-select v-model="listQuery.supplierId"
class="input-width"
clearable
placeholder="请选择供应商">
<el-option v-for="item in supplierOptions"
:key="item.id"
:label="item.supplierName"
:value="item.id"></el-option>
</el-select>
</el-form-item>
<el-form-item label="物品类别:">
<el-select v-model="listQuery.goodsCategoryId"
class="input-width"
clearable
placeholder="请选择物品类别"
@visible-change="handleOpenCate">
<el-option v-for="item in categoryOptions"
:key="item.id"
:label="item.name"
:value="item.id"></el-option>
</el-select>
</el-form-item>
<el-form-item label="物品:">
<el-select v-model="listQuery.goodsId"
class="input-width"
clearable
placeholder="请选择物品"
@visible-change="handleOpenGoods">
<el-option v-for="item in goodOptions"
:key="item.id"
:label="item.name"
:value="item.id"></el-option>
</el-select>
</el-form-item>
<el-form-item>
<el-button type="primary"
@click="handleSearchList"
icon="el-icon-search"
size="small">搜索
</el-button>
<el-button @click="handleResetSearch"
icon="el-icon-refresh"
size="small">重置
</el-button>
</el-form-item>
</el-form>
</el-card>
<!-- 表格栏 -->
<el-card class="filter-container mt15"
shadow="never">
<div class="table-container">
<ve-line :data="chartData"
:legend-visible="false"
:loading="loading"
:data-empty="dataEmpty"
></ve-line>
</div>
</el-card>
</div>
</template>
<script>
import moment from 'moment'
import { str2Date } from '@/utils/date'
import { getSuppliersList } from '@/api/supplier'
import { getGoodsList, getGoodsCategoryList } from '@/api/inventory'
import { getRecipientList } from '@/api/report'
// 列表查询参数默认值
const defaultListQuery = {
pageNum: 1,
pageSize: 10,
goodsId: '',
supplierId: '',
goodsCategoryId: ''
}
export default {
name: 'Recipients',
data() {
return {
categoryOptions: [],
supplierOptions: [],
goodOptions: [],
inventoryList: [],
orderCountDate: '',
statusOptions: [{
label: '启用',
value: 1
},
{
label: '禁用',
value: 0
}],
listQuery: Object.assign({}, defaultListQuery),
list: [],
total: 0,
listLoading: false,
multipleSelection: [],
chartData: {
columns: ['data', 'num'],
rows: []
},
loading: false,
dataEmpty: false
}
},
created() {
this.getSuppliersList()
// this.getData()
},
filters: {
formatTime(time) {
if (!time) {
return '--'
}
return moment(time).format('YYYY-MM-DD HH:mm:ss')
}
},
methods: {
getDay(day) {
var today = new Date()
var targetday_milliseconds = today.getTime() + 1000 * 60 * 60 * 24 * day
today.setTime(targetday_milliseconds) //注意,这行是关键代码
var tYear = today.getFullYear()
var tMonth = today.getMonth()
var tDate = today.getDate()
tMonth = this.doHandleMonth(tMonth + 1)
tDate = this.doHandleMonth(tDate)
console.log('tYear + \'-\' + tMonth + \'-\' + tDate',tYear + '-' + tMonth + '-' + tDate)
return tYear + '-' + tMonth + '-' + tDate
},
doHandleMonth(month) {
var m = month
if (month.toString().length == 1) {
m = '0' + month
}
return m
},
formatEveryDay() {
let start1 = this.getDay(-7)
let end1 = this.getDay(0)
console.log('start1','end1',start1,end1)
let dateList = []
var startTime = this.getDate(start1)
var endTime = this.getDate(end1)
while ((endTime.getTime() - startTime.getTime()) >= 0) {
var year = startTime.getFullYear()
var month = startTime.getMonth() + 1 < 10 ? '0' + (startTime.getMonth() + 1) : startTime.getMonth() + 1
var day = startTime.getDate().toString().length == 1 ? '0' + startTime.getDate() : startTime.getDate()
dateList.push(year + '-' + month + '-' + day)
startTime.setDate(startTime.getDate() + 1)
}
console.log('dateList',dateList)
return dateList
},
getDate(datestr) {
var temp = datestr.split('-')
var date = new Date(temp[0], temp[1] - 1, temp[2])
console.log('date', date)
return date
},
handleOpenCate(visible) {
if (visible) {
this.getGoodsCategoryList()
}
},
handleOpenGoods(visible) {
if (visible) {
this.getGoodsList()
}
},
// 物品
getGoodsList() {
getGoodsList({
goodsCategoryI: this.listQuery.goodsCategoryId,
supplierId: this.listQuery.supplierId
}).then(res => {
this.goodOptions = res.data.list
})
},
// 物品类别
getGoodsCategoryList() {
getGoodsCategoryList({ supplierId: this.listQuery.supplierId }).then(res => {
this.categoryOptions = res.data.list
})
},
// 供应商
getSuppliersList() {
getSuppliersList().then(res => {
this.supplierOptions = res.data.list
})
},
getList() {
if(!this.listQuery.goodsId){
this.$message.warning('请选择物品')
return
}
getRecipientList({ dateList: this.formatEveryDay(), goodsId: this.listQuery.goodsId }).then(res => {
this.chartData.rows = res.data
})
},
handleResetSearch() {
this.listQuery = Object.assign({}, defaultListQuery)
this.getList()
},
handleSearchList() {
this.listQuery.pageNum = 1
this.getList()
},
handleSelectionChange(vals) {
this.multipleSelection = vals
},
handleAdd() {
this.$refs.addGoods.add()
}
}
}
</script>
<style scoped>
.app-container {
font-size: 14px;
color: #606266;
padding: 0 15px;
margin-top: 0;
}
.mt15 {
margin-top: 15px;
}
.input-width {
width: 180px;
}
.btn-groups button {
width: 100px;
}
</style>
......@@ -213,4 +213,7 @@ export default {
</script>
<style scoped>
.btn-add {
float: none !important;
}
</style>
......@@ -2,28 +2,32 @@
<div class="app-container">
<el-card class="filter-container"
shadow="never">
<el-form :inline="true"
:model="listQuery"
size="small">
<el-form-item label="输入搜索:">
<el-input v-model="listQuery.keyword"
class="input-width"
placeholder="角色名称"
clearable></el-input>
</el-form-item>
<el-form-item>
<el-button type="primary"
@click="handleSearchList"
size="small">搜索</el-button>
<el-button style="float:right;margin-right: 15px"
@click="handleResetSearch"
size="small">重置</el-button>
</el-form-item>
<el-button size="small"
type="primary"
class="btn-add"
@click="handleAdd">添加</el-button>
</el-form>
<!-- <el-form :inline="true"-->
<!-- :model="listQuery"-->
<!-- size="small">-->
<!-- <el-form-item label="输入搜索:">-->
<!-- <el-input v-model="listQuery.keyword"-->
<!-- class="input-width"-->
<!-- placeholder="角色名称"-->
<!-- clearable></el-input>-->
<!-- </el-form-item>-->
<!-- <el-form-item>-->
<!-- <el-button type="primary"-->
<!-- @click="handleSearchList"-->
<!-- size="small">搜索</el-button>-->
<!-- <el-button style="float:right;margin-right: 15px"-->
<!-- @click="handleResetSearch"-->
<!-- size="small">重置</el-button>-->
<!-- </el-form-item>-->
<!-- <el-button size="small"-->
<!-- type="primary"-->
<!-- class="btn-add"-->
<!-- @click="handleAdd">添加</el-button>-->
<!-- </el-form>-->
<el-button size="small"
type="primary"
class="btn-add"
@click="handleAdd">添加</el-button>
</el-card>
<div class="table-container">
<el-table ref="roleTable"
......@@ -297,6 +301,10 @@ export default {
}
}
</script>
<style></style>
<style scoped>
.btn-add{
float: none !important;
}
</style>
<template> 
<div class="app-container">
<!-- 搜索栏 -->
<el-card class="filter-container"
shadow="never">
<el-form :inline="true"
:model="listQuery"
size="small">
<el-form-item label="管理员名称:">
<el-input v-model="listQuery.name"
class="input-width"
placeholder="请输入管理员名称"></el-input>
</el-form-item>
<el-form-item>
<el-button type="primary"
@click="handleSearchList"
icon="el-icon-search"
size="small">搜索
</el-button>
<el-button @click="handleResetSearch"
icon="el-icon-refresh"
size="small">重置
</el-button>
</el-form-item>
<!-- <el-button class="btn-add"-->
<!-- size="small"-->
<!-- type="primary"-->
<!-- @click="handleAdd">添加管理员-->
<!-- </el-button>-->
</el-form>
</el-card>
<!-- 表格栏 -->
<el-card class="filter-container mt15"
shadow="never">
<div class="table-container">
<el-table :data="list"
v-loading="listLoading"
@selection-change="handleSelectionChange"
border>
<el-table-column type="selection"
align="center"
width="50"></el-table-column>
<el-table-column label="姓名"
align="center">
<template slot-scope="scope">{{scope.row.name}}</template>
</el-table-column>
<el-table-column label="AD用户"
align="center">
<template slot-scope="scope">{{scope.row.departName || '--'}}</template>
</el-table-column>
<el-table-column label="部门"
align="center">
<template slot-scope="scope">{{scope.row.departName || '--'}}</template>
</el-table-column>
<el-table-column label="所属库房"
align="center">
<template slot-scope="scope">{{scope.row.stockRoomName}}</template>
</el-table-column>
<el-table-column label="联系方式"
align="center">
<template slot-scope="scope">{{scope.row.phone}}</template>
</el-table-column>
<el-table-column label="操作"
width="220"
align="center">
<template slot-scope="scope">
<el-button size="mini"
type="success"
@click="handleDelete(scope.row.id)">解绑
</el-button>
</template>
</el-table-column>
</el-table>
</div>
<!-- 分页栏 -->
<div class="pagination-container">
<el-pagination background
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
layout="total, sizes, prev, pager, next, jumper"
:current-page.sync="listQuery.pageNum"
:page-size="listQuery.pageSize"
:page-sizes="[10,30,50]"
:total="total">
</el-pagination>
</div>
</el-card>
</div>
</template>
<script>
import moment from 'moment'
import { getAdminList, cancleAdmin } from '@/api/user'
import AddDepot from './modules/AddAdmin'
// 列表查询参数默认值
const defaultListQuery = {
pageNum: 1,
pageSize: 10,
name: '',
condition: 0,
roleId: '',
departId: ''
}
export default {
name: 'AdminList',
components: { AddDepot },
data() {
return {
listQuery: Object.assign({}, defaultListQuery),
list: [],
total: 0,
listLoading: false,
multipleSelection: [],
}
},
created() {
this.getList()
},
filters: {
formatTime(time) {
if (!time) {
return '--'
}
return moment(time).format('YYYY-MM-DD HH:mm:ss')
}
},
methods: {
// 添加管理员
handleAdd() {
this.$refs.addSupplier.add()
},
handleResetSearch() {
this.listQuery = Object.assign({}, defaultListQuery)
this.getList()
},
handleSearchList() {
this.listQuery.pageNum = 1
this.getList()
},
handleSizeChange(val) {
this.listQuery.pageNum = 1
this.listQuery.pageSize = val
this.getList()
},
handleCurrentChange(val) {
this.listQuery.pageNum = val
this.getList()
},
handleSelectionChange(vals) {
this.multipleSelection = vals
},
//请求数据
getList() {
this.listLoading = true
//请求数据
getAdminList(this.listQuery).then(res => {
this.listLoading = false
this.list = res.data.list
this.total = res.data.total
}).catch(err => {
this.listLoading = false
})
},
// 删除
handleDelete(id) {
this.$confirm('是否取消管理员权限?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
cancleAdmin({ id: id, deleteStatus: 1 }).then(res => {
this.getList()
})
}).catch(() => {
})
}
}
}
</script>
<style scoped>
.app-container {
font-size: 14px;
color: #606266;
padding: 0 15px;
margin-top: 0;
}
.el-row {
margin-bottom: 20px;
}
.mt15 {
margin-top: 15px;
}
.el-input {
width: 200px;
}
.input-width {
width: 180px;
}
</style>
<template> 
<div class="app-container">
<!-- 搜索栏 -->
<el-card class="filter-container"
shadow="never">
<el-form :inline="true"
:model="listQuery"
size="small">
<el-form-item label="用户名称:">
<el-input v-model="listQuery.name"
class="input-width"
placeholder="请输入用户名称"></el-input>
</el-form-item>
<el-form-item label="部门:">
<el-select v-model="listQuery.departId"
class="input-width"
clearable
placeholder="请选择部门">
<el-option v-for="item in departmentOptions"
:key="item.id"
:label="item.name"
:value="item.id"></el-option>
</el-select>
</el-form-item>
<el-form-item>
<el-button type="primary"
@click="handleSearchList"
icon="el-icon-search"
size="small">搜索
</el-button>
<el-button @click="handleResetSearch"
icon="el-icon-refresh"
size="small">重置
</el-button>
</el-form-item>
<el-button class="btn-add"
size="small"
type="primary"
@click="handleAdd">导入用户
</el-button>
</el-form>
</el-card>
<!-- 表格栏 -->
<el-card class="filter-container mt15"
shadow="never">
<div class="table-container">
<el-table :data="list"
v-loading="listLoading"
@selection-change="handleSelectionChange"
border>
<el-table-column type="selection"
align="center"
width="50"></el-table-column>
<el-table-column label="姓名"
align="center">
<template slot-scope="scope">{{scope.row.name}}</template>
</el-table-column>
<el-table-column label="AD用户"
align="center">
<template slot-scope="scope">{{scope.row.jobNo || '--'}}</template>
</el-table-column>
<el-table-column label="部门"
align="center">
<template slot-scope="scope">{{scope.row.departName || '--'}}</template>
</el-table-column>
<el-table-column label="联系方式"
align="center">
<template slot-scope="scope">{{scope.row.phone}}</template>
</el-table-column>
<el-table-column label="操作"
width="220"
align="center">
<template slot-scope="scope">
<el-button size="mini"
type="success"
@click="handleSet(scope.row)">设置为管理员
</el-button>
</template>
</el-table-column>
</el-table>
</div>
<!-- 分页栏 -->
<div class="pagination-container">
<el-pagination background
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
layout="total, sizes, prev, pager, next, jumper"
:current-page.sync="listQuery.pageNum"
:page-size="listQuery.pageSize"
:page-sizes="[10,30,50]"
:total="total">
</el-pagination>
</div>
</el-card>
<!-- end -->
<!-- 弹窗 -->
<add-admin ref="addAdmin"
@ok="getList"></add-admin>
<!-- end -->
</div>
</template>
<script>
import moment from 'moment'
import { getMemberList, getAuditDetail, updateMcht } from '@/api/user'
import { getDepartmentList} from '@/api/inventory'
import AddAdmin from './modules/AddAdmin'
// 列表查询参数默认值
const defaultListQuery = {
pageNum: 1,
pageSize: 10,
name: null,
departId: null
}
export default {
name: 'UserList',
components: { AddAdmin },
data() {
return {
departmentOptions: [],
listQuery: Object.assign({}, defaultListQuery),
list: [],
total: 0,
listLoading: false,
multipleSelection: [],
}
},
created() {
this.getList()
this.getDepartmentList()
},
filters: {
formatTime(time) {
if (!time) {
return '--'
}
return moment(time).format('YYYY-MM-DD HH:mm:ss')
}
},
methods: {
// 部门
getDepartmentList() {
getDepartmentList().then(res => {
this.departmentOptions = res.data.list
})
},
handleResetSearch() {
this.listQuery = Object.assign({}, defaultListQuery)
this.getList()
},
handleSearchList() {
this.listQuery.pageNum = 1
this.getList()
},
handleSizeChange(val) {
this.listQuery.pageNum = 1
this.listQuery.pageSize = val
this.getList()
},
handleCurrentChange(val) {
this.listQuery.pageNum = val
this.getList()
},
handleSelectionChange(vals) {
this.multipleSelection = vals
},
//请求数据
getList() {
this.listLoading = true
//请求数据
getMemberList(this.listQuery).then(res => {
this.listLoading = false
this.list = res.data.list
this.total = res.data.total
}).catch(err => {
this.listLoading = false
})
},
// 添加管理员
handleAdd() {
this.$refs.addSupplier.add()
},
// 设置为管理员
handleSet(row) {
this.$refs.addAdmin.add(row)
}
}
}
</script>
<style scoped>
.app-container {
font-size: 14px;
color: #606266;
padding: 0 15px;
margin-top: 0;
}
.el-row {
margin-bottom: 20px;
}
.mt15 {
margin-top: 15px;
}
.el-input {
width: 200px;
}
.input-width {
width: 180px;
}
</style>
<template>
<el-dialog :visible.sync="visible"
:title="title"
center
width="720px">
<!-- start -->
<el-form :model="model"
ref="myForm"
v-loading="loading"
label-width="200px">
<div class="scroll-container"
ref="scrollContainer">
<el-form-item label="用户名称:"
prop="username"
:rules="[{ required: true, message: '用户名称不能为空', trigger: 'blur' }]">
<el-input v-model="model.username"
:disabled="isEdit"
class="input-width"></el-input>
<div class="tip">可使用手机号作为用户名称</div>
</el-form-item>
<el-form-item label="登录密码:"
prop="password"
:rules="[{ required: true, message: '登录密码不能为空', trigger: 'blur' }]">
<el-input
:maxlength="6"
v-model="model.password"
type="password"
auto-complete="new-password"
class="input-width"></el-input>
</el-form-item>
<el-form-item label="库房:"
prop="stockRoomId"
:rules="[{ required: true, trigger: 'change', message: '请选择库房' }]">
<el-select size="small"
class="input-width"
v-model="model.stockRoomId">
<el-option
v-for="item in depotOptions"
:key="item.id"
:label="item.name"
:value="item.id">
</el-option>
</el-select>
</el-form-item>
<el-form-item label="角色分配:"
prop="roleId"
:rules="[{ required: true, message: '角色不能为空', trigger: 'change' }]">
<el-select v-model="model.roleId"
class="input-width">
<el-option v-for="item in allRoleList"
:key="item.id"
:label="item.name"
:value="item.id"></el-option>
</el-select>
</el-form-item>
</div>
</el-form>
<div slot="footer">
<el-button type="primary"
@click="submit">确认
</el-button>
<el-button @click="close">取消</el-button>
</div>
<!-- end -->
</el-dialog>
</template>
<script>
import { setUpAdmin } from '@/api/user'
import { fetchAllRoleList } from '@/api/role'
import { getStockRooms } from '@/api/inventory'
// 添加编辑属性
export default {
name: 'AddAdmin',
data() {
return {
allRoleList: [],
depotOptions: [],
visible: false,
title: null,
loading: false,
id: null,
model: {},
isEdit: false
}
},
methods: {
// 库房
getStockRooms() {
getStockRooms().then(res => {
this.depotOptions = res.data.list
})
},
// 角色分配
fetchAllRoleList() {
fetchAllRoleList().then(response => {
this.allRoleList = response.data
})
},
init() {
this.fetchAllRoleList()
this.getStockRooms()
this.$nextTick(() => {
this.$refs.myForm.clearValidate()
this.$refs.scrollContainer.scrollTop = 0
})
},
add(row) {
this.id = null
this.visible = true
this.init()
this.model = {
departId: row.departId,
roleId: null,
stockRoomId: null,
password: null,
username: null,
id: row.id,
memberId: row.id
}
this.title = '设置管理员'
},
// detail(id) {
// this.id = id
// this.init()
// this.visible = true
// this.title = '编辑管理员'
// this.loading = true
// getSupplierDetail({ id: id }).then(res => {
// this.model = res.data
// this.loading = false
// }).catch(err => {
// this.loading = false
// this.close()
// })
// },
// 提交保存
submit() {
this.$refs.myForm.validate((valid) => {
if (valid) {
// 验证通过
// if (this.id) {
// // 修改属性
// this.loading = true
// updateMcht(this.model).then(res => {
// this.loading = false
// this.visible = false
// this.$emit('ok')
// }).catch(err => {
// this.loading = false
// })
// } else {
// 添加属性
this.loading = true
setUpAdmin(this.model).then(res => {
this.loading = false
this.visible = false
this.$emit('ok')
}).catch(err => {
this.loading = false
})
// }
}
})
},
close() {
this.$emit('close')
this.visible = false
}
}
}
</script>
<style scoped>
.scroll-container {
max-height: 50vh;
overflow: hidden;
overflow-y: auto;
}
.input-width {
width: 300px;
}
.tip {
color: #999;
font-size: 10px;
line-height: 30px;
}
</style>
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