This commit is contained in:
lb 2022-08-04 16:20:07 +08:00
parent affea8af59
commit ffad1a2643
26 changed files with 368 additions and 488 deletions

View File

@ -178,7 +178,7 @@
getDataList () {
this.dataListLoading = true
this.$http({
url: this.$http.adornUrl('/monitoring/equipmenfile/list'),
url: this.$http.adornUrl('/monitoring/equipmenfile/page'),
method: 'get',
params: this.$http.adornParams({
'page': this.pageIndex,

View File

@ -160,7 +160,7 @@
getDataList () {
this.dataListLoading = true
this.$http({
url: this.$http.adornUrl('/monitoring/equipmengroup/list'),
url: this.$http.adornUrl('/monitoring/equipmengroup/page'),
method: 'get',
params: this.$http.adornParams({
'page': this.pageIndex,

View File

@ -154,7 +154,7 @@
getDataList () {
this.dataListLoading = true
this.$http({
url: this.$http.adornUrl('/monitoring/equipmenattr/list'),
url: this.$http.adornUrl('/monitoring/equipmenattr/page'),
method: 'get',
params: this.$http.adornParams({
'page': this.pageIndex,

View File

@ -160,7 +160,7 @@
getDataList () {
this.dataListLoading = true
this.$http({
url: this.$http.adornUrl('/monitoring/equipmenalarmlog/list'),
url: this.$http.adornUrl('/monitoring/equipmenalarmlog/page'),
method: 'get',
params: this.$http.adornParams({
'page': this.pageIndex,

View File

@ -190,7 +190,7 @@
getDataList () {
this.dataListLoading = true
this.$http({
url: this.$http.adornUrl('/monitoring/equipmengroupalarm/list'),
url: this.$http.adornUrl('/monitoring/equipmengroupalarm/page'),
method: 'get',
params: this.$http.adornParams({
'page': this.pageIndex,

View File

@ -208,7 +208,7 @@
getDataList () {
this.dataListLoading = true
this.$http({
url: this.$http.adornUrl('/monitoring/equipmenplc/list'),
url: this.$http.adornUrl('/monitoring/equipmenplc/page'),
method: 'get',
params: this.$http.adornParams({
'page': this.pageIndex,

View File

@ -154,7 +154,7 @@
getDataList () {
this.dataListLoading = true
this.$http({
url: this.$http.adornUrl('/monitoring/equipmenplcconnect/list'),
url: this.$http.adornUrl('/monitoring/equipmenplcconnect/page'),
method: 'get',
params: this.$http.adornParams({
'page': this.pageIndex,

View File

@ -238,7 +238,7 @@
getDataList () {
this.dataListLoading = true
this.$http({
url: this.$http.adornUrl('/monitoring/equipmenplcparam/list'),
url: this.$http.adornUrl('/monitoring/equipmenplcparam/page'),
method: 'get',
params: this.$http.adornParams({
'page': this.pageIndex,

View File

@ -184,7 +184,7 @@
getDataList () {
this.dataListLoading = true
this.$http({
url: this.$http.adornUrl('/monitoring/equipmenquantity/list'),
url: this.$http.adornUrl('/monitoring/equipmenquantity/page'),
method: 'get',
params: this.$http.adornParams({
'page': this.pageIndex,

View File

@ -178,7 +178,7 @@
getDataList () {
this.dataListLoading = true
this.$http({
url: this.$http.adornUrl('/monitoring/equipmenstatuslog/list'),
url: this.$http.adornUrl('/monitoring/equipmenstatuslog/page'),
method: 'get',
params: this.$http.adornParams({
'page': this.pageIndex,

View File

@ -172,7 +172,7 @@
getDataList () {
this.dataListLoading = true
this.$http({
url: this.$http.adornUrl('/monitoring/equipmentype/list'),
url: this.$http.adornUrl('/monitoring/equipmentype/page'),
method: 'get',
params: this.$http.adornParams({
'page': this.pageIndex,

View File

@ -178,7 +178,7 @@
getDataList () {
this.dataListLoading = true
this.$http({
url: this.$http.adornUrl('/monitoring/equipmentypefile/list'),
url: this.$http.adornUrl('/monitoring/equipmentypefile/page'),
method: 'get',
params: this.$http.adornParams({
'page': this.pageIndex,

View File

@ -178,7 +178,7 @@
getDataList () {
this.dataListLoading = true
this.$http({
url: this.$http.adornUrl('/monitoring/producarrt/list'),
url: this.$http.adornUrl('/monitoring/producarrt/page'),
method: 'get',
params: this.$http.adornParams({
'page': this.pageIndex,

View File

@ -1,271 +1,158 @@
<template>
<div class="mod-config">
<el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">
<el-form-item>
<el-input v-model="dataForm.key" placeholder="参数名" clearable></el-input>
</el-form-item>
<el-form-item>
<el-button @click="getDataList()">查询</el-button>
<el-button v-if="$hasPermission('monitoring:product:save')" type="primary" @click="addOrUpdateHandle()">新增</el-button>
<el-button v-if="$hasPermission('monitoring:product:delete')" type="danger" @click="deleteHandle()" :disabled="dataListSelections.length <= 0">批量删除</el-button>
</el-form-item>
</el-form>
<el-table
:data="dataList"
border
v-loading="dataListLoading"
@selection-change="selectionChangeHandle"
style="width: 100%;">
<el-table-column
type="selection"
header-align="center"
align="center"
width="50">
</el-table-column>
<el-table-column
prop="id"
header-align="center"
align="center"
label="ID">
</el-table-column>
<el-table-column
prop="code"
header-align="center"
align="center"
label="编码">
</el-table-column>
<el-table-column
prop="name"
header-align="center"
align="center"
label="名称">
</el-table-column>
<el-table-column
prop="description"
header-align="center"
align="center"
label="描述">
</el-table-column>
<el-table-column
prop="externalCode"
header-align="center"
align="center"
label="外部编码,用于对照外部系统的编码">
</el-table-column>
<el-table-column
prop="specifications"
header-align="center"
align="center"
label="规格">
</el-table-column>
<el-table-column
prop="unitDictValue"
header-align="center"
align="center"
label="单位value对应到数据字典label_value">
</el-table-column>
<el-table-column
prop="area"
header-align="center"
align="center"
label="一单位的面积(平方米)">
</el-table-column>
<el-table-column
prop="processTime"
header-align="center"
align="center"
label="加工一单位产品需要的时间">
</el-table-column>
<el-table-column
prop="typeDictValue"
header-align="center"
align="center"
label="产品类型value对应到数据字典label_value">
</el-table-column>
<el-table-column
prop="enabled"
header-align="center"
align="center"
label="启用状态:0 、停用1、启用">
</el-table-column>
<el-table-column
prop="remark"
header-align="center"
align="center"
label="备注">
</el-table-column>
<el-table-column
prop="valid"
header-align="center"
align="center"
label="删除标志,是否有效:1 可用 0不可用">
</el-table-column>
<el-table-column
prop="creatorId"
header-align="center"
align="center"
label="创建人">
</el-table-column>
<el-table-column
prop="creatorName"
header-align="center"
align="center"
label="创建人姓名">
</el-table-column>
<el-table-column
prop="createTime"
header-align="center"
align="center"
label="创建时间">
</el-table-column>
<el-table-column
prop="updaterId"
header-align="center"
align="center"
label="更新人">
</el-table-column>
<el-table-column
prop="updaterName"
header-align="center"
align="center"
label="更新人姓名">
</el-table-column>
<el-table-column
prop="updateTime"
header-align="center"
align="center"
label="更新时间">
</el-table-column>
<el-table-column
prop="version"
header-align="center"
align="center"
label="版本号">
</el-table-column>
<el-table-column
fixed="right"
header-align="center"
align="center"
width="150"
label="操作">
<template slot-scope="scope">
<el-button type="text" size="small" @click="addOrUpdateHandle(scope.row.id)">修改</el-button>
<el-button type="text" size="small" @click="deleteHandle(scope.row.id)">删除</el-button>
</template>
</el-table-column>
</el-table>
<el-pagination
@size-change="sizeChangeHandle"
@current-change="currentChangeHandle"
:current-page="pageIndex"
:page-sizes="[10, 20, 50, 100]"
:page-size="pageSize"
:total="totalPage"
layout="total, sizes, prev, pager, next, jumper">
</el-pagination>
<!-- 弹窗, 新增 / 修改 -->
<add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></add-or-update>
</div>
<div class="mod-config">
<el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">
<el-form-item>
<el-input v-model="dataForm.key" placeholder="参数名" clearable></el-input>
</el-form-item>
<el-form-item>
<el-button @click="getDataList()">查询</el-button>
<el-button v-if="$hasPermission('monitoring:product:save')" type="primary" @click="addOrUpdateHandle()">新增</el-button>
<el-button v-if="$hasPermission('monitoring:product:delete')" type="danger" @click="deleteHandle()" :disabled="dataListSelections.length <= 0">批量删除</el-button>
</el-form-item>
</el-form>
<el-table :data="dataList" border v-loading="dataListLoading" @selection-change="selectionChangeHandle" style="width: 100%;">
<el-table-column type="selection" header-align="center" align="center" width="50"></el-table-column>
<el-table-column prop="id" header-align="center" align="center" label="ID"></el-table-column>
<el-table-column prop="code" header-align="center" align="center" label="编码"></el-table-column>
<el-table-column prop="name" header-align="center" align="center" label="名称"></el-table-column>
<el-table-column prop="description" header-align="center" align="center" label="描述"></el-table-column>
<el-table-column prop="externalCode" header-align="center" align="center" label="外部编码,用于对照外部系统的编码"></el-table-column>
<el-table-column prop="specifications" header-align="center" align="center" label="规格"></el-table-column>
<el-table-column prop="unitDictValue" header-align="center" align="center" label="单位value对应到数据字典label_value"></el-table-column>
<el-table-column prop="area" header-align="center" align="center" label="一单位的面积(平方米)"></el-table-column>
<el-table-column prop="processTime" header-align="center" align="center" label="加工一单位产品需要的时间"></el-table-column>
<el-table-column prop="typeDictValue" header-align="center" align="center" label="产品类型value对应到数据字典label_value"></el-table-column>
<el-table-column prop="enabled" header-align="center" align="center" label="启用状态:0 、停用1、启用"></el-table-column>
<el-table-column prop="remark" header-align="center" align="center" label="备注"></el-table-column>
<el-table-column prop="valid" header-align="center" align="center" label="删除标志,是否有效:1 可用 0不可用"></el-table-column>
<el-table-column prop="creatorId" header-align="center" align="center" label="创建人"></el-table-column>
<el-table-column prop="creatorName" header-align="center" align="center" label="创建人姓名"></el-table-column>
<el-table-column prop="createTime" header-align="center" align="center" label="创建时间"></el-table-column>
<el-table-column prop="updaterId" header-align="center" align="center" label="更新人"></el-table-column>
<el-table-column prop="updaterName" header-align="center" align="center" label="更新人姓名"></el-table-column>
<el-table-column prop="updateTime" header-align="center" align="center" label="更新时间"></el-table-column>
<el-table-column prop="version" header-align="center" align="center" label="版本号"></el-table-column>
<el-table-column fixed="right" header-align="center" align="center" width="150" label="操作">
<template slot-scope="scope">
<el-button type="text" size="small" @click="addOrUpdateHandle(scope.row.id)">修改</el-button>
<el-button type="text" size="small" @click="deleteHandle(scope.row.id)">删除</el-button>
</template>
</el-table-column>
</el-table>
<el-pagination
@size-change="sizeChangeHandle"
@current-change="currentChangeHandle"
:current-page="pageIndex"
:page-sizes="[10, 20, 50, 100]"
:page-size="pageSize"
:total="totalPage"
layout="total, sizes, prev, pager, next, jumper"
></el-pagination>
<!-- 弹窗, 新增 / 修改 -->
<add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></add-or-update>
</div>
</template>
<script>
import AddOrUpdate from './product-add-or-update'
export default {
data () {
return {
dataForm: {
key: ''
},
dataList: [],
pageIndex: 1,
pageSize: 10,
totalPage: 0,
dataListLoading: false,
dataListSelections: [],
addOrUpdateVisible: false
}
},
components: {
AddOrUpdate
},
activated () {
this.getDataList()
},
methods: {
//
getDataList () {
this.dataListLoading = true
this.$http({
url: this.$http.adornUrl('/monitoring/product/list'),
method: 'get',
params: this.$http.adornParams({
'page': this.pageIndex,
'limit': this.pageSize,
'key': this.dataForm.key
})
}).then(({data}) => {
if (data && data.code === 0) {
this.dataList = data.data.list
this.totalPage = data.data.total
} else {
this.dataList = []
this.totalPage = 0
}
this.dataListLoading = false
})
},
//
sizeChangeHandle (val) {
this.pageSize = val
this.pageIndex = 1
this.getDataList()
},
//
currentChangeHandle (val) {
this.pageIndex = val
this.getDataList()
},
//
selectionChangeHandle (val) {
this.dataListSelections = val
},
// /
addOrUpdateHandle (id) {
this.addOrUpdateVisible = true
this.$nextTick(() => {
this.$refs.addOrUpdate.init(id)
})
},
//
deleteHandle (id) {
var ids = id ? [id] : this.dataListSelections.map(item => {
return item.id
})
this.$confirm(`确定对[id=${ids.join(',')}]进行[${id ? '删除' : '批量删除'}]操作?`, '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.$http({
url: this.$http.adornUrl('/monitoring/product/delete'),
method: 'post',
data: this.$http.adornData(ids, false)
}).then(({data}) => {
if (data && data.code === 0) {
this.$message({
message: '操作成功',
type: 'success',
duration: 1500,
onClose: () => {
this.getDataList()
}
})
} else {
this.$message.error(data.msg)
}
})
})
}
}
}
import AddOrUpdate from './product-add-or-update'
export default {
data() {
return {
dataForm: {
key: ''
},
dataList: [],
pageIndex: 1,
pageSize: 10,
totalPage: 0,
dataListLoading: false,
dataListSelections: [],
addOrUpdateVisible: false
}
},
components: {
AddOrUpdate
},
activated() {
this.getDataList()
},
methods: {
//
getDataList() {
this.dataListLoading = true
this.$http({
url: this.$http.adornUrl('/monitoring/product/page'),
method: 'get',
params: this.$http.adornParams({
page: this.pageIndex,
limit: this.pageSize,
key: this.dataForm.key
})
}).then(({ data }) => {
if (data && data.code === 0) {
this.dataList = data.data.list
this.totalPage = data.data.total
} else {
this.dataList = []
this.totalPage = 0
}
this.dataListLoading = false
})
},
//
sizeChangeHandle(val) {
this.pageSize = val
this.pageIndex = 1
this.getDataList()
},
//
currentChangeHandle(val) {
this.pageIndex = val
this.getDataList()
},
//
selectionChangeHandle(val) {
this.dataListSelections = val
},
// /
addOrUpdateHandle(id) {
this.addOrUpdateVisible = true
this.$nextTick(() => {
this.$refs.addOrUpdate.init(id)
})
},
//
deleteHandle(id) {
var ids = id
? [id]
: this.dataListSelections.map(item => {
return item.id
})
this.$confirm(`确定对[id=${ids.join(',')}]进行[${id ? '删除' : '批量删除'}]操作?`, '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.$http({
url: this.$http.adornUrl('/monitoring/product/delete'),
method: 'post',
data: this.$http.adornData(ids, false)
}).then(({ data }) => {
if (data && data.code === 0) {
this.$message({
message: '操作成功',
type: 'success',
duration: 1500,
onClose: () => {
this.getDataList()
}
})
} else {
this.$message.error(data.msg)
}
})
})
}
}
}
</script>

View File

@ -184,7 +184,7 @@
getDataList () {
this.dataListLoading = true
this.$http({
url: this.$http.adornUrl('/monitoring/productionline/list'),
url: this.$http.adornUrl('/monitoring/productionline/page'),
method: 'get',
params: this.$http.adornParams({
'page': this.pageIndex,

View File

@ -124,7 +124,7 @@
getDataList () {
this.dataListLoading = true
this.$http({
url: this.$http.adornUrl('/monitoring/productionlinerecsch/list'),
url: this.$http.adornUrl('/monitoring/productionlinerecsch/page'),
method: 'get',
params: this.$http.adornParams({
'page': this.pageIndex,

View File

@ -154,7 +154,7 @@
getDataList () {
this.dataListLoading = true
this.$http({
url: this.$http.adornUrl('/monitoring/qualityinspectiondet/list'),
url: this.$http.adornUrl('/monitoring/qualityinspectiondet/page'),
method: 'get',
params: this.$http.adornParams({
'page': this.pageIndex,

View File

@ -184,7 +184,7 @@
getDataList () {
this.dataListLoading = true
this.$http({
url: this.$http.adornUrl('/monitoring/qualityinspectionrecord/list'),
url: this.$http.adornUrl('/monitoring/qualityinspectionrecord/page'),
method: 'get',
params: this.$http.adornParams({
'page': this.pageIndex,

View File

@ -148,7 +148,7 @@
getDataList () {
this.dataListLoading = true
this.$http({
url: this.$http.adornUrl('/monitoring/qualityinspectiontype/list'),
url: this.$http.adornUrl('/monitoring/qualityinspectiontype/page'),
method: 'get',
params: this.$http.adornParams({
'page': this.pageIndex,

View File

@ -184,7 +184,7 @@
getDataList () {
this.dataListLoading = true
this.$http({
url: this.$http.adornUrl('/monitoring/reporsheet/list'),
url: this.$http.adornUrl('/monitoring/reporsheet/page'),
method: 'get',
params: this.$http.adornParams({
'page': this.pageIndex,

View File

@ -166,7 +166,7 @@
getDataList () {
this.dataListLoading = true
this.$http({
url: this.$http.adornUrl('/monitoring/reporsheecategory/list'),
url: this.$http.adornUrl('/monitoring/reporsheecategory/page'),
method: 'get',
params: this.$http.adornParams({
'page': this.pageIndex,

View File

@ -160,7 +160,7 @@
getDataList () {
this.dataListLoading = true
this.$http({
url: this.$http.adornUrl('/monitoring/sysfile/list'),
url: this.$http.adornUrl('/monitoring/sysfile/page'),
method: 'get',
params: this.$http.adornParams({
'page': this.pageIndex,

View File

@ -148,7 +148,7 @@
getDataList () {
this.dataListLoading = true
this.$http({
url: this.$http.adornUrl('/monitoring/sysfiletype/list'),
url: this.$http.adornUrl('/monitoring/sysfiletype/page'),
method: 'get',
params: this.$http.adornParams({
'page': this.pageIndex,

View File

@ -178,7 +178,7 @@
getDataList () {
this.dataListLoading = true
this.$http({
url: this.$http.adornUrl('/monitoring/workshopsection/list'),
url: this.$http.adornUrl('/monitoring/workshopsection/page'),
method: 'get',
params: this.$http.adornParams({
'page': this.pageIndex,

View File

@ -154,7 +154,7 @@
getDataList () {
this.dataListLoading = true
this.$http({
url: this.$http.adornUrl('/monitoring/workshopsectionequipment/list'),
url: this.$http.adornUrl('/monitoring/workshopsectionequipment/page'),
method: 'get',
params: this.$http.adornParams({
'page': this.pageIndex,

View File

@ -1,212 +1,205 @@
<template>
<el-dialog :visible.sync="visible" :title="!dataForm.id ? $t('add') : $t('update')" :close-on-click-modal="false" :close-on-press-escape="false">
<el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmitHandle()" label-width="120px">
<el-form-item prop="username" :label="$t('user.username')">
<el-input v-model="dataForm.username" :placeholder="$t('user.username')"></el-input>
</el-form-item>
<el-form-item prop="deptName" :label="$t('user.deptName')">
<ren-dept-tree v-model="dataForm.deptId" :placeholder="$t('dept.title')" :dept-name.sync="dataForm.deptName"></ren-dept-tree>
</el-form-item>
<el-form-item prop="password" :label="$t('user.password')" :class="{ 'is-required': !dataForm.id }">
<el-input v-model="dataForm.password" type="password" :placeholder="$t('user.password')"></el-input>
</el-form-item>
<el-form-item prop="confirmPassword" :label="$t('user.confirmPassword')" :class="{ 'is-required': !dataForm.id }">
<el-input v-model="dataForm.confirmPassword" type="password" :placeholder="$t('user.confirmPassword')"></el-input>
</el-form-item>
<el-form-item prop="realName" :label="$t('user.realName')">
<el-input v-model="dataForm.realName" :placeholder="$t('user.realName')"></el-input>
</el-form-item>
<el-form-item prop="gender" :label="$t('user.gender')">
<ren-radio-group v-model="dataForm.gender" dict-type="gender"></ren-radio-group>
</el-form-item>
<el-form-item prop="email" :label="$t('user.email')">
<el-input v-model="dataForm.email" :placeholder="$t('user.email')"></el-input>
</el-form-item>
<el-form-item prop="mobile" :label="$t('user.mobile')">
<el-input v-model="dataForm.mobile" :placeholder="$t('user.mobile')"></el-input>
</el-form-item>
<el-form-item prop="roleIdList" :label="$t('user.roleIdList')" class="role-list">
<el-select v-model="dataForm.roleIdList" multiple :placeholder="$t('user.roleIdList')">
<el-option v-for="role in roleList" :key="role.id" :label="role.name" :value="role.id"></el-option>
</el-select>
</el-form-item>
<el-form-item prop="status" :label="$t('user.status')" size="mini">
<el-radio-group v-model="dataForm.status">
<el-radio :label="0">{{ $t('user.status0') }}</el-radio>
<el-radio :label="1">{{ $t('user.status1') }}</el-radio>
</el-radio-group>
</el-form-item>
</el-form>
<template slot="footer">
<el-button @click="visible = false">{{ $t('cancel') }}</el-button>
<el-button type="primary" @click="dataFormSubmitHandle()">{{ $t('confirm') }}</el-button>
</template>
</el-dialog>
<el-dialog :visible.sync="visible" :title="!dataForm.id ? $t('add') : $t('update')" :close-on-click-modal="false" :close-on-press-escape="false">
<el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmitHandle()" label-width="120px">
<el-form-item prop="username" :label="$t('user.username')">
<el-input v-model="dataForm.username" :placeholder="$t('user.username')"></el-input>
</el-form-item>
<el-form-item prop="deptName" :label="$t('user.deptName')">
<ren-dept-tree v-model="dataForm.deptId" :placeholder="$t('dept.title')" :dept-name.sync="dataForm.deptName"></ren-dept-tree>
</el-form-item>
<el-form-item prop="password" :label="$t('user.password')" :class="{ 'is-required': !dataForm.id }">
<el-input v-model="dataForm.password" type="password" :placeholder="$t('user.password')"></el-input>
</el-form-item>
<el-form-item prop="confirmPassword" :label="$t('user.confirmPassword')" :class="{ 'is-required': !dataForm.id }">
<el-input v-model="dataForm.confirmPassword" type="password" :placeholder="$t('user.confirmPassword')"></el-input>
</el-form-item>
<el-form-item prop="realName" :label="$t('user.realName')">
<el-input v-model="dataForm.realName" :placeholder="$t('user.realName')"></el-input>
</el-form-item>
<el-form-item prop="gender" :label="$t('user.gender')">
<ren-radio-group v-model="dataForm.gender" dict-type="gender"></ren-radio-group>
</el-form-item>
<el-form-item prop="email" :label="$t('user.email')">
<el-input v-model="dataForm.email" :placeholder="$t('user.email')"></el-input>
</el-form-item>
<el-form-item prop="mobile" :label="$t('user.mobile')">
<el-input v-model="dataForm.mobile" :placeholder="$t('user.mobile')"></el-input>
</el-form-item>
<el-form-item prop="roleIdList" :label="$t('user.roleIdList')" class="role-list">
<el-select v-model="dataForm.roleIdList" multiple :placeholder="$t('user.roleIdList')">
<el-option v-for="role in roleList" :key="role.id" :label="role.name" :value="role.id"></el-option>
</el-select>
</el-form-item>
<el-form-item prop="status" :label="$t('user.status')" size="mini">
<el-radio-group v-model="dataForm.status">
<el-radio :label="0">{{ $t('user.status0') }}</el-radio>
<el-radio :label="1">{{ $t('user.status1') }}</el-radio>
</el-radio-group>
</el-form-item>
</el-form>
<template slot="footer">
<el-button @click="visible = false">{{ $t('cancel') }}</el-button>
<el-button type="primary" @click="dataFormSubmitHandle()">{{ $t('confirm') }}</el-button>
</template>
</el-dialog>
</template>
<script>
import debounce from 'lodash/debounce'
import { isEmail, isMobile } from '@/utils/validate'
export default {
data () {
return {
visible: false,
roleList: [],
roleIdListDefault: [],
dataForm: {
id: '',
username: '',
deptId: '',
deptName: '',
password: '',
confirmPassword: '',
realName: '',
gender: 0,
email: '',
mobile: '',
roleIdList: [],
status: 1
}
}
},
computed: {
dataRule () {
var validatePassword = (rule, value, callback) => {
if (!this.dataForm.id && !/\S/.test(value)) {
return callback(new Error(this.$t('validate.required')))
}
callback()
}
var validateConfirmPassword = (rule, value, callback) => {
if (!this.dataForm.id && !/\S/.test(value)) {
return callback(new Error(this.$t('validate.required')))
}
if (this.dataForm.password !== value) {
return callback(new Error(this.$t('user.validate.confirmPassword')))
}
callback()
}
var validateEmail = (rule, value, callback) => {
if (value && !isEmail(value)) {
return callback(new Error(this.$t('validate.format', { 'attr': this.$t('user.email') })))
}
callback()
}
var validateMobile = (rule, value, callback) => {
if (value && !isMobile(value)) {
return callback(new Error(this.$t('validate.format', { 'attr': this.$t('user.mobile') })))
}
callback()
}
return {
username: [
{ required: true, message: this.$t('validate.required'), trigger: 'blur' }
],
deptName: [
{ required: true, message: this.$t('validate.required'), trigger: 'change' }
],
password: [
{ validator: validatePassword, trigger: 'blur' }
],
confirmPassword: [
{ validator: validateConfirmPassword, trigger: 'blur' }
],
realName: [
{ required: true, message: this.$t('validate.required'), trigger: 'blur' }
],
email: [
{ validator: validateEmail, trigger: 'blur' }
],
mobile: [
{ validator: validateMobile, trigger: 'blur' }
]
}
}
},
methods: {
init () {
this.visible = true
this.dataForm.deptId = ''
this.$nextTick(() => {
this.$refs['dataForm'].resetFields()
this.roleIdListDefault = []
Promise.all([
this.getRoleList()
]).then(() => {
if (this.dataForm.id) {
this.getInfo()
}
})
})
},
//
getRoleList () {
return this.$http.get(this.$http.adornUrl('/sys/role/list')).then(({ data: res }) => {
if (res.code !== 0) {
return this.$message.error(res.msg)
}
this.roleList = res.data
}).catch(() => {})
},
//
getInfo () {
this.$http.get(this.$http.adornUrl(`/sys/user/${this.dataForm.id}`)).then(({ data: res }) => {
if (res.code !== 0) {
return this.$message.error(res.msg)
}
this.dataForm = {
...this.dataForm,
...res.data,
roleIdList: []
}
// ,
for (var i = 0; i < res.data.roleIdList.length; i++) {
if (this.roleList.filter(item => item.id === res.data.roleIdList[i])[0]) {
this.dataForm.roleIdList.push(res.data.roleIdList[i])
continue
}
this.roleIdListDefault.push(res.data.roleIdList[i])
}
}).catch(() => {})
},
//
dataFormSubmitHandle: debounce(function () {
this.$refs['dataForm'].validate((valid) => {
if (!valid) {
return false
}
this.$http[!this.dataForm.id ? 'post' : 'put']('/sys/user', {
...this.dataForm,
roleIdList: [
...this.dataForm.roleIdList,
...this.roleIdListDefault
]
}).then(({ data: res }) => {
if (res.code !== 0) {
return this.$message.error(res.msg)
}
this.$message({
message: this.$t('prompt.success'),
type: 'success',
duration: 500,
onClose: () => {
this.visible = false
this.$emit('refreshDataList')
}
})
}).catch(() => {})
})
}, 1000, { 'leading': true, 'trailing': false })
}
data() {
return {
visible: false,
roleList: [],
roleIdListDefault: [],
dataForm: {
id: '',
username: '',
deptId: '',
deptName: '',
password: '',
confirmPassword: '',
realName: '',
gender: 0,
email: '',
mobile: '',
roleIdList: [],
status: 1
}
}
},
computed: {
dataRule() {
var validatePassword = (rule, value, callback) => {
if (!this.dataForm.id && !/\S/.test(value)) {
return callback(new Error(this.$t('validate.required')))
}
callback()
}
var validateConfirmPassword = (rule, value, callback) => {
if (!this.dataForm.id && !/\S/.test(value)) {
return callback(new Error(this.$t('validate.required')))
}
if (this.dataForm.password !== value) {
return callback(new Error(this.$t('user.validate.confirmPassword')))
}
callback()
}
var validateEmail = (rule, value, callback) => {
if (value && !isEmail(value)) {
return callback(new Error(this.$t('validate.format', { attr: this.$t('user.email') })))
}
callback()
}
var validateMobile = (rule, value, callback) => {
if (value && !isMobile(value)) {
return callback(new Error(this.$t('validate.format', { attr: this.$t('user.mobile') })))
}
callback()
}
return {
username: [{ required: true, message: this.$t('validate.required'), trigger: 'blur' }],
deptName: [{ required: true, message: this.$t('validate.required'), trigger: 'change' }],
password: [{ validator: validatePassword, trigger: 'blur' }],
confirmPassword: [{ validator: validateConfirmPassword, trigger: 'blur' }],
realName: [{ required: true, message: this.$t('validate.required'), trigger: 'blur' }],
email: [{ validator: validateEmail, trigger: 'blur' }],
mobile: [{ validator: validateMobile, trigger: 'blur' }]
}
}
},
methods: {
init() {
this.visible = true
this.dataForm.deptId = ''
this.$nextTick(() => {
this.$refs['dataForm'].resetFields()
this.roleIdListDefault = []
Promise.all([this.getRoleList()]).then(() => {
if (this.dataForm.id) {
this.getInfo()
}
})
})
},
//
getRoleList() {
return this.$http
.get(this.$http.adornUrl('/sys/role/list'))
.then(({ data: res }) => {
if (res.code !== 0) {
return this.$message.error(res.msg)
}
this.roleList = res.data
})
.catch(() => {})
},
//
getInfo() {
this.$http
.get(this.$http.adornUrl(`/sys/user/${this.dataForm.id}`))
.then(({ data: res }) => {
if (res.code !== 0) {
return this.$message.error(res.msg)
}
this.dataForm = {
...this.dataForm,
...res.data,
roleIdList: []
}
// ,
for (var i = 0; i < res.data.roleIdList.length; i++) {
if (this.roleList.filter(item => item.id === res.data.roleIdList[i])[0]) {
this.dataForm.roleIdList.push(res.data.roleIdList[i])
continue
}
this.roleIdListDefault.push(res.data.roleIdList[i])
}
})
.catch(() => {})
},
//
dataFormSubmitHandle: debounce(
function() {
this.$refs['dataForm'].validate(valid => {
if (!valid) {
return false
}
this.$http[!this.dataForm.id ? 'post' : 'put']('/sys/user', {
...this.dataForm,
roleIdList: [...this.dataForm.roleIdList, ...this.roleIdListDefault]
})
.then(({ data: res }) => {
if (res.code !== 0) {
return this.$message.error(res.msg)
}
this.$message({
message: this.$t('prompt.success'),
type: 'success',
duration: 500,
onClose: () => {
this.visible = false
this.$emit('refreshDataList')
}
})
})
.catch(() => {})
})
},
1000,
{ leading: true, trailing: false }
)
}
}
</script>
<style lang="scss">
.mod-sys__user {
.role-list {
.el-select {
width: 100%;
}
}
.role-list {
.el-select {
width: 100%;
}
}
}
</style>