|
|
@ -41,6 +41,16 @@ |
|
|
</el-option> |
|
|
</el-option> |
|
|
</el-select> |
|
|
</el-select> |
|
|
</el-form-item> |
|
|
</el-form-item> |
|
|
|
|
|
<el-form-item label="类型" class="is-required"> |
|
|
|
|
|
<el-select v-model="dataForm.type" placeholder="请选择类型" style="width: 150px;"> |
|
|
|
|
|
<el-option |
|
|
|
|
|
v-for="i in typeOptions" |
|
|
|
|
|
:key="i.value" |
|
|
|
|
|
:label="i.label" |
|
|
|
|
|
:value="i.value"> |
|
|
|
|
|
</el-option> |
|
|
|
|
|
</el-select> |
|
|
|
|
|
</el-form-item> |
|
|
<!-- <el-form-item label="车间">--> |
|
|
<!-- <el-form-item label="车间">--> |
|
|
<!-- <el-select v-model="dataForm.workShopId" placeholder="请选择" style="width: 150px;" clearable>--> |
|
|
<!-- <el-select v-model="dataForm.workShopId" placeholder="请选择" style="width: 150px;" clearable>--> |
|
|
<!-- <el-option--> |
|
|
<!-- <el-option--> |
|
|
@ -60,7 +70,7 @@ |
|
|
<el-form-item label="角色" size="mini" prop="roleIdList"> |
|
|
<el-form-item label="角色" size="mini" prop="roleIdList"> |
|
|
<el-checkbox-group v-model="dataForm.roleIdList"> |
|
|
<el-checkbox-group v-model="dataForm.roleIdList"> |
|
|
<el-checkbox |
|
|
<el-checkbox |
|
|
v-for="role in roleList" |
|
|
|
|
|
|
|
|
v-for="role in filteredRoleList" |
|
|
:key="role.roleId" |
|
|
:key="role.roleId" |
|
|
:label="role.roleId">{{role.roleName}} |
|
|
:label="role.roleId">{{role.roleName}} |
|
|
</el-checkbox> |
|
|
</el-checkbox> |
|
|
@ -117,6 +127,7 @@ export default { |
|
|
roleIdList: [], |
|
|
roleIdList: [], |
|
|
status: 1, |
|
|
status: 1, |
|
|
site: '', |
|
|
site: '', |
|
|
|
|
|
type: '', |
|
|
userDisplay: '', |
|
|
userDisplay: '', |
|
|
workShopId:'', |
|
|
workShopId:'', |
|
|
supplierNo: '', |
|
|
supplierNo: '', |
|
|
@ -140,6 +151,11 @@ export default { |
|
|
}, |
|
|
}, |
|
|
workShopList:[], |
|
|
workShopList:[], |
|
|
siteOptions: [], |
|
|
siteOptions: [], |
|
|
|
|
|
typeOptions: [ |
|
|
|
|
|
{ label: '员工', value: 'EMPLOYEE' }, |
|
|
|
|
|
{ label: '供应商', value: 'SUPPLIER' }, |
|
|
|
|
|
{ label: '客户', value: 'CUSTOMER' } |
|
|
|
|
|
], |
|
|
showSupplierPicker: false, |
|
|
showSupplierPicker: false, |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
@ -154,6 +170,41 @@ export default { |
|
|
this.dataForm.supplierNo = '' |
|
|
this.dataForm.supplierNo = '' |
|
|
} |
|
|
} |
|
|
this.showSupplierPicker = hasSupplier |
|
|
this.showSupplierPicker = hasSupplier |
|
|
|
|
|
}, |
|
|
|
|
|
// 切换类型时,移除不在当前类型可选范围内的已选角色;选供应商时默认勾选“供应商”角色 |
|
|
|
|
|
'dataForm.type'() { |
|
|
|
|
|
const visibleIds = this.filteredRoleList.map(r => r.roleId) |
|
|
|
|
|
let selected = Array.isArray(this.dataForm.roleIdList) ? this.dataForm.roleIdList.filter(id => visibleIds.includes(id)) : [] |
|
|
|
|
|
if (this.dataForm.type === 'SUPPLIER') { |
|
|
|
|
|
// 默认将供应商角色选上 |
|
|
|
|
|
visibleIds.forEach(id => { |
|
|
|
|
|
if (!selected.includes(id)) { |
|
|
|
|
|
selected.push(id) |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
this.dataForm.roleIdList = selected |
|
|
|
|
|
} |
|
|
|
|
|
}, |
|
|
|
|
|
computed: { |
|
|
|
|
|
// 根据“类型”过滤可选角色:员工不显示供应商/客户角色,供应商只显示供应商角色,客户只显示客户角色 |
|
|
|
|
|
filteredRoleList() { |
|
|
|
|
|
const type = this.dataForm.type |
|
|
|
|
|
const isSupplierRole = (role) => role.roleName && role.roleName.indexOf('供应商') !== -1 |
|
|
|
|
|
const isCustomerRole = (role) => role.roleName && role.roleName.indexOf('客户') !== -1 |
|
|
|
|
|
return this.roleList.filter(role => { |
|
|
|
|
|
if (type === 'SUPPLIER') { |
|
|
|
|
|
return isSupplierRole(role) |
|
|
|
|
|
} |
|
|
|
|
|
if (type === 'CUSTOMER') { |
|
|
|
|
|
return isCustomerRole(role) |
|
|
|
|
|
} |
|
|
|
|
|
if (type === 'EMPLOYEE') { |
|
|
|
|
|
return !isSupplierRole(role) && !isCustomerRole(role) |
|
|
|
|
|
} |
|
|
|
|
|
// 未选择类型时展示全部角色 |
|
|
|
|
|
return true |
|
|
|
|
|
}) |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
methods: { |
|
|
methods: { |
|
|
@ -219,9 +270,10 @@ export default { |
|
|
|
|
|
|
|
|
init(id) { |
|
|
init(id) { |
|
|
this.dataForm.id = id || 0 |
|
|
this.dataForm.id = id || 0 |
|
|
// 新增用户时,工厂默认设置为 1 |
|
|
|
|
|
|
|
|
// 新增用户时,工厂默认设置为 1,类型默认为员工 |
|
|
if (!id) { |
|
|
if (!id) { |
|
|
this.dataForm.site = '1' |
|
|
this.dataForm.site = '1' |
|
|
|
|
|
this.dataForm.type = 'EMPLOYEE' |
|
|
} |
|
|
} |
|
|
this.loadSiteOptions() |
|
|
this.loadSiteOptions() |
|
|
this.getLanguageList(); |
|
|
this.getLanguageList(); |
|
|
@ -252,6 +304,7 @@ export default { |
|
|
this.dataForm.status = data.user.status |
|
|
this.dataForm.status = data.user.status |
|
|
this.dataForm.languageDefault = data.user.languageDefault |
|
|
this.dataForm.languageDefault = data.user.languageDefault |
|
|
this.dataForm.site = data.user.site == null ? '' : data.user.site.toString() |
|
|
this.dataForm.site = data.user.site == null ? '' : data.user.site.toString() |
|
|
|
|
|
this.dataForm.type = data.user.type == null ? '' : data.user.type |
|
|
this.dataForm.userDisplay = data.user.userDisplay |
|
|
this.dataForm.userDisplay = data.user.userDisplay |
|
|
this.dataForm.workShopId = data.user.workShopId |
|
|
this.dataForm.workShopId = data.user.workShopId |
|
|
this.dataForm.supplierNo = data.user.supplierNo |
|
|
this.dataForm.supplierNo = data.user.supplierNo |
|
|
@ -271,6 +324,10 @@ export default { |
|
|
this.$message.warning('请选择工厂') |
|
|
this.$message.warning('请选择工厂') |
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|
|
|
|
if (!this.dataForm.type) { |
|
|
|
|
|
this.$message.warning('请选择类型') |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
if (!this.dataForm.userDisplay || !String(this.dataForm.userDisplay).trim()) { |
|
|
if (!this.dataForm.userDisplay || !String(this.dataForm.userDisplay).trim()) { |
|
|
this.$message.warning('用户名不能为空') |
|
|
this.$message.warning('用户名不能为空') |
|
|
return |
|
|
return |
|
|
@ -295,6 +352,7 @@ export default { |
|
|
'roleIdList': this.dataForm.roleIdList, |
|
|
'roleIdList': this.dataForm.roleIdList, |
|
|
'languageDefault': this.dataForm.languageDefault, |
|
|
'languageDefault': this.dataForm.languageDefault, |
|
|
'site': this.dataForm.site, |
|
|
'site': this.dataForm.site, |
|
|
|
|
|
'type': this.dataForm.type, |
|
|
'userDisplay': this.dataForm.userDisplay, |
|
|
'userDisplay': this.dataForm.userDisplay, |
|
|
'workShopId': this.dataForm.workShopId, |
|
|
'workShopId': this.dataForm.workShopId, |
|
|
'supplierNo': this.dataForm.supplierNo, |
|
|
'supplierNo': this.dataForm.supplierNo, |
|
|
@ -321,6 +379,7 @@ export default { |
|
|
this.dataForm.roleIdList = [] |
|
|
this.dataForm.roleIdList = [] |
|
|
this.dataForm.status = 1 |
|
|
this.dataForm.status = 1 |
|
|
this.dataForm.site = '' |
|
|
this.dataForm.site = '' |
|
|
|
|
|
this.dataForm.type = '' |
|
|
this.dataForm.userDisplay = '' |
|
|
this.dataForm.userDisplay = '' |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
|