init
This commit is contained in:
282
src/views/basicData/GroupModule/components/group-add.vue
Normal file
282
src/views/basicData/GroupModule/components/group-add.vue
Normal file
@@ -0,0 +1,282 @@
|
||||
<!--
|
||||
* @Author: zwq
|
||||
* @Date: 2020-12-29 16:37:56
|
||||
* @LastEditors: zwq
|
||||
* @LastEditTime: 2021-04-07 14:53:04
|
||||
* @Description:
|
||||
-->
|
||||
<template>
|
||||
<el-dialog
|
||||
:title="isdetail? 'btn.detail' : !groupData.id ? 'btn.add' : 'btn.edit' | i18nFilter"
|
||||
:close-on-click-modal="false"
|
||||
:before-close="handleClose"
|
||||
width="70%"
|
||||
:visible.sync="visible"
|
||||
>
|
||||
<el-form
|
||||
ref="groupForm"
|
||||
:model="groupData"
|
||||
:rules="rules"
|
||||
size="medium"
|
||||
label-width="120px"
|
||||
>
|
||||
<el-row>
|
||||
<el-col :span="6">
|
||||
<el-form-item :label="$t('module.basicData.group.TeamName')" prop="name">
|
||||
<el-input v-model="groupData.name" :disabled="isdetail" :placeholder="$i18nForm(['placeholder.input', $t('module.basicData.group.TeamName')])" clearable :style="{width: '100%'}" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="6">
|
||||
<el-form-item :label="$t('module.basicData.group.GroupLeader')" prop="teamLeaderId">
|
||||
<el-select
|
||||
v-model="groupData.teamLeaderId"
|
||||
:disabled="isdetail"
|
||||
:placeholder="$i18nForm(['placeholder.input', $t('module.basicData.group.GroupLeader')])"
|
||||
filterable
|
||||
clearable
|
||||
:style="{width: '100%'}"
|
||||
>
|
||||
<el-option
|
||||
v-for="(item) in groupArr"
|
||||
:key="item.id"
|
||||
:label="item.name"
|
||||
:value="item.id"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="6">
|
||||
<el-form-item label-width="100px" :label="$t('module.basicData.group.TeamStatus')" prop="workStatus">
|
||||
<el-switch
|
||||
v-model="groupData.workStatus"
|
||||
:disabled="isdetail"
|
||||
:active-value="1"
|
||||
:inactive-value="0"
|
||||
active-color="#13ce66"
|
||||
inactive-color="#AAAAAA"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="6">
|
||||
<el-form-item label-width="50px">
|
||||
<el-button v-if="isdetail" type="primary" @click="goEdit()">{{ 'btn.edit' | i18nFilter }}</el-button>
|
||||
<div v-if="!isdetail">
|
||||
<el-button type="primary" @click="handelConfirm">{{ 'btn.confirm' | i18nFilter }}</el-button>
|
||||
</div>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<div v-if="!isdetail">
|
||||
<el-button v-if="listQuery.teamId" type="primary" icon="el-icon-user" size="medium" @click="addNew()"> {{ 'btn.addgroup' | i18nFilter }} </el-button>
|
||||
</div>
|
||||
</el-form>
|
||||
<base-table
|
||||
v-if="listQuery.teamId"
|
||||
:table-config="tableProps"
|
||||
:table-data="list"
|
||||
:is-loading="listLoading"
|
||||
>
|
||||
<method-btn
|
||||
v-if="!isdetail"
|
||||
slot="handleBtn"
|
||||
:width="trueWidth"
|
||||
:method-list="tableBtn"
|
||||
@clickBtn="handleClick"
|
||||
/>
|
||||
</base-table>
|
||||
<group-member v-if="addOrUpdateVisible" ref="addOrUpdate" :team-id="listQuery.teamId" @refreshDataList="getList" />
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script>import i18n from '@/lang'
|
||||
import { groupDetail, groupUpdate, groupAdd, groupCode } from '@/api/basicData/GroupModule/group'
|
||||
import { groupAttrList, groupAttrDelete } from '@/api/basicData/GroupModule/groupAttr'
|
||||
import { staffList } from '@/api/basicData/GroupModule/staff'
|
||||
import BaseTable from '@/components/BaseTable'
|
||||
import groupMember from './group-member.vue'
|
||||
import MethodBtn from '@/components/BaseTable/subcomponents/MethodBtn'
|
||||
|
||||
const tableBtn = [
|
||||
{
|
||||
type: 'delete',
|
||||
btnName: 'btn.delete'
|
||||
}
|
||||
]
|
||||
const tableProps = [
|
||||
{
|
||||
prop: 'name',
|
||||
label: i18n.t('module.basicData.staff.Name'),
|
||||
align: 'center'
|
||||
},
|
||||
{
|
||||
prop: 'majorArr',
|
||||
label: i18n.t('module.basicData.staff.Profession'),
|
||||
align: 'center'
|
||||
},
|
||||
{
|
||||
prop: 'telephone',
|
||||
label: i18n.t('module.basicData.staff.Telephone'),
|
||||
align: 'center'
|
||||
},
|
||||
{
|
||||
prop: 'workshop',
|
||||
label: i18n.t('module.basicData.staff.Workshop'),
|
||||
align: 'center'
|
||||
}
|
||||
]
|
||||
|
||||
export default {
|
||||
components: { BaseTable, MethodBtn, groupMember },
|
||||
data() {
|
||||
return {
|
||||
visible: false,
|
||||
addOrUpdateVisible: false,
|
||||
tableBtn,
|
||||
trueWidth: 100,
|
||||
isdetail: false,
|
||||
tableProps,
|
||||
listLoading: false,
|
||||
list: [],
|
||||
groupArr: [],
|
||||
groupData: {
|
||||
id: 0,
|
||||
name: '',
|
||||
teamLeaderId: '',
|
||||
workStatus: 1,
|
||||
code: ''
|
||||
},
|
||||
rules: {
|
||||
name: [{
|
||||
required: true,
|
||||
message: this.$i18nForm(['placeholder.input', this.$t('module.basicData.group.TeamName')]),
|
||||
trigger: 'blur'
|
||||
}],
|
||||
teamLeaderId: [{
|
||||
required: true,
|
||||
message: this.$i18nForm(['placeholder.input', this.$t('module.basicData.group.GroupLeader')]),
|
||||
trigger: 'change'
|
||||
}]
|
||||
},
|
||||
listQuery: {
|
||||
current: 1,
|
||||
size: 999,
|
||||
teamId: '',
|
||||
key: ''
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
init(id, isdetail) {
|
||||
this.isdetail = false
|
||||
this.isdetail = isdetail
|
||||
staffList(this.listQuery).then(response => {
|
||||
if (response.data.records) {
|
||||
this.groupArr = response.data.records
|
||||
} else {
|
||||
this.groupArr.splice(0, this.list.length)
|
||||
}
|
||||
})
|
||||
this.groupData.id = id || ''
|
||||
this.listQuery.teamId = ''
|
||||
this.list.splice(0, this.list.length)
|
||||
this.visible = true
|
||||
this.$nextTick(() => {
|
||||
this.$refs['groupForm'].resetFields()
|
||||
if (this.groupData.id) {
|
||||
this.listQuery.teamId = this.groupData.id
|
||||
groupDetail(this.groupData.id).then(res => {
|
||||
this.groupData = res.data
|
||||
this.getList()
|
||||
})
|
||||
} else {
|
||||
groupCode().then(res => {
|
||||
this.groupData.code = res.data
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
getList() {
|
||||
groupAttrList(this.listQuery).then(response => {
|
||||
if (response.data.records) {
|
||||
this.list = response.data.records
|
||||
this.list.forEach(item => {
|
||||
if (item.major) { item.majorArr = item.major.toString() }
|
||||
})
|
||||
} else {
|
||||
this.list.splice(0, this.list.length)
|
||||
}
|
||||
this.total = response.data.total
|
||||
})
|
||||
},
|
||||
handleClick(raw) {
|
||||
if (raw.type === 'delete') {
|
||||
this.$confirm(`${this.$t('module.basicData.visual.TipsBefore')}[${raw.data.name}]?`, this.$t('module.basicData.visual.Tips'), {
|
||||
confirmButtonText: this.$t('module.basicData.visual.confirmButtonText'),
|
||||
cancelButtonText: this.$t('module.basicData.visual.cancelButtonText'),
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
const data = {
|
||||
teamId: this.listQuery.teamId,
|
||||
workerId: raw.data.id
|
||||
}
|
||||
groupAttrDelete(data).then(response => {
|
||||
this.$message({
|
||||
message: this.$t('module.basicData.visual.success'),
|
||||
type: 'success',
|
||||
duration: 1500,
|
||||
onClose: () => {
|
||||
this.getList()
|
||||
}
|
||||
})
|
||||
})
|
||||
}).catch(() => {})
|
||||
}
|
||||
},
|
||||
// 表单提交
|
||||
handelConfirm() {
|
||||
this.$refs['groupForm'].validate((valid) => {
|
||||
if (valid) {
|
||||
const data = this.groupData
|
||||
if (this.groupData.id) {
|
||||
groupUpdate(data).then(res => {
|
||||
this.$message({
|
||||
message: this.$t('module.basicData.visual.success'),
|
||||
type: 'success',
|
||||
duration: 1500,
|
||||
onClose: () => {
|
||||
this.visible = false
|
||||
this.$emit('refreshDataList')
|
||||
}
|
||||
})
|
||||
})
|
||||
} else {
|
||||
groupAdd(data).then(res => {
|
||||
this.$message({
|
||||
message: this.$t('module.basicData.visual.success'),
|
||||
type: 'success',
|
||||
duration: 1500
|
||||
})
|
||||
this.groupData.id = res.data.id
|
||||
this.listQuery.teamId = res.data.id
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
handleClose() {
|
||||
this.visible = false
|
||||
this.$emit('refreshDataList')
|
||||
},
|
||||
goEdit() {
|
||||
this.isdetail = false
|
||||
},
|
||||
// 新增
|
||||
addNew() {
|
||||
this.addOrUpdateVisible = true
|
||||
this.$nextTick(() => {
|
||||
this.$refs.addOrUpdate.init(this.groupData.teamLeaderId)
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
227
src/views/basicData/GroupModule/components/group-member.vue
Normal file
227
src/views/basicData/GroupModule/components/group-member.vue
Normal file
@@ -0,0 +1,227 @@
|
||||
<!--
|
||||
* @Author: zwq
|
||||
* @Date: 2020-12-29 15:41:11
|
||||
* @LastEditors: zwq
|
||||
* @LastEditTime: 2021-03-31 16:21:04
|
||||
* @Description:
|
||||
-->
|
||||
<template>
|
||||
<el-dialog
|
||||
:title="'btn.add' | i18nFilter"
|
||||
:visible.sync="visible"
|
||||
:before-close="goback"
|
||||
:append-to-body="true"
|
||||
width="80%"
|
||||
><el-form
|
||||
:model="listQuery"
|
||||
:inline="true"
|
||||
size="medium"
|
||||
label-width="80px"
|
||||
>
|
||||
<el-form-item :label="$t('module.basicData.staff.Name')" prop="key">
|
||||
<el-input v-model="listQuery.key" :placeholder="$i18nForm(['placeholder.input', $t('module.basicData.staff.Name')])" style="width:200px" clearable />
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="getList()"> {{ 'btn.search' | i18nFilter }} </el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<base-table
|
||||
:page="listQuery.current"
|
||||
:limit="listQuery.size"
|
||||
:table-config="tableProps"
|
||||
:table-data="list"
|
||||
:is-loading="listLoading"
|
||||
>
|
||||
<method-btn
|
||||
slot="handleBtn"
|
||||
:width="trueWidth"
|
||||
:method-list="tableBtn"
|
||||
@clickBtn="handleClick"
|
||||
/>
|
||||
</base-table>
|
||||
<pagination
|
||||
v-show="total > 0"
|
||||
:total="total"
|
||||
:page.sync="listQuery.current"
|
||||
:limit.sync="listQuery.size"
|
||||
@pagination="getList()"
|
||||
/>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script>import i18n from '@/lang'
|
||||
import { workerList } from '@/api/basicData/GroupModule/staff'
|
||||
import { groupAttrAdd } from '@/api/basicData/GroupModule/groupAttr'
|
||||
import MethodBtn from '@/components/BaseTable/subcomponents/MethodBtn'
|
||||
import BaseTable from '@/components/BaseTable'
|
||||
import basicData from '@/filters/basicData'
|
||||
import Pagination from '@/components/Pagination' // Secondary package based on el-pagination
|
||||
import { timeFormatter } from '@/filters'
|
||||
/**
|
||||
* 表格表头配置项 TypeScript接口注释
|
||||
* tableConfig<ConfigItem> = []
|
||||
*
|
||||
* Interface ConfigItem = {
|
||||
* prop: string,
|
||||
* label: string,
|
||||
* width: string,
|
||||
* align: string,
|
||||
* subcomponent: function,
|
||||
* filter: function
|
||||
* }
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
const tableBtn = [
|
||||
{
|
||||
type: 'add',
|
||||
btnName: 'btn.addgroup'
|
||||
}
|
||||
]
|
||||
const tableProps = [
|
||||
{
|
||||
prop: 'createTime',
|
||||
label: i18n.t('module.basicData.factory.createTime'),
|
||||
filter: timeFormatter,
|
||||
align: 'center'
|
||||
},
|
||||
{
|
||||
prop: 'name',
|
||||
label: i18n.t('module.basicData.staff.Name'),
|
||||
align: 'center'
|
||||
},
|
||||
{
|
||||
prop: 'code',
|
||||
label: i18n.t('module.basicData.staff.EmployeeID'),
|
||||
align: 'center'
|
||||
},
|
||||
{
|
||||
prop: 'sex',
|
||||
label: i18n.t('module.basicData.staff.Gender'),
|
||||
filter: basicData('sex'),
|
||||
align: 'center'
|
||||
},
|
||||
{
|
||||
prop: 'entryTime',
|
||||
label: i18n.t('module.basicData.staff.EntryTime'),
|
||||
align: 'center'
|
||||
},
|
||||
{
|
||||
prop: 'telephone',
|
||||
label: i18n.t('module.basicData.staff.Telephone'),
|
||||
align: 'center'
|
||||
},
|
||||
{
|
||||
prop: 'wechatCode',
|
||||
label: i18n.t('module.basicData.staff.Wechat'),
|
||||
align: 'center'
|
||||
},
|
||||
{
|
||||
prop: 'majorArr',
|
||||
label: i18n.t('module.basicData.staff.Profession'),
|
||||
align: 'center'
|
||||
},
|
||||
{
|
||||
prop: 'workshop',
|
||||
label: i18n.t('module.basicData.staff.Workshop'),
|
||||
align: 'center'
|
||||
},
|
||||
{
|
||||
prop: 'onDuty',
|
||||
label: i18n.t('module.basicData.staff.onDuty'),
|
||||
filter: basicData('onDuty'),
|
||||
align: 'center'
|
||||
}
|
||||
]
|
||||
|
||||
export default {
|
||||
name: '',
|
||||
components: { Pagination, BaseTable, MethodBtn },
|
||||
props: {
|
||||
teamId: {
|
||||
type: String,
|
||||
default: () => {
|
||||
return ''
|
||||
}
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
visible: false,
|
||||
tableProps,
|
||||
tableBtn,
|
||||
trueWidth: 200,
|
||||
list: [],
|
||||
total: 0,
|
||||
teamLeaderId: '',
|
||||
listLoading: true,
|
||||
listQuery: {
|
||||
current: 1,
|
||||
size: 10,
|
||||
teamId: '',
|
||||
key: ''
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
init(id) {
|
||||
this.visible = true
|
||||
this.teamLeaderId = id
|
||||
this.listQuery.teamId = this.teamId
|
||||
this.getList()
|
||||
},
|
||||
getList() {
|
||||
this.listLoading = true
|
||||
workerList(this.listQuery).then(response => {
|
||||
if (response.data.records) {
|
||||
this.list = response.data.records
|
||||
this.list.forEach(item => {
|
||||
if (item.major) { item.majorArr = item.major.toString() }
|
||||
})
|
||||
} else {
|
||||
this.list.splice(0, this.list.length)
|
||||
}
|
||||
this.total = response.data.total
|
||||
this.listLoading = false
|
||||
})
|
||||
},
|
||||
handleClick(raw) {
|
||||
if (raw.type === 'add') {
|
||||
const data = {
|
||||
'workerId': raw.data.id,
|
||||
'name': raw.data.name,
|
||||
'teamId': this.teamId,
|
||||
'current': this.listQuery.current,
|
||||
'size': this.listQuery.size
|
||||
}
|
||||
groupAttrAdd(data).then(res => {
|
||||
this.$message({
|
||||
message: this.$t('module.basicData.visual.success'),
|
||||
type: 'success',
|
||||
duration: 1500,
|
||||
onClose: () => {
|
||||
this.getList()
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
},
|
||||
goback() {
|
||||
this.visible = false
|
||||
this.$emit('refreshDataList')
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.edit-input {
|
||||
padding-right: 100px;
|
||||
}
|
||||
.cancel-btn {
|
||||
position: absolute;
|
||||
right: 15px;
|
||||
top: 10px;
|
||||
}
|
||||
</style>
|
||||
118
src/views/basicData/GroupModule/components/major-add.vue
Normal file
118
src/views/basicData/GroupModule/components/major-add.vue
Normal file
@@ -0,0 +1,118 @@
|
||||
<!--
|
||||
* @Author: zwq
|
||||
* @Date: 2020-12-29 16:37:56
|
||||
* @LastEditors: zwq
|
||||
* @LastEditTime: 2021-03-25 16:26:22
|
||||
* @Description:
|
||||
-->
|
||||
<template>
|
||||
<el-dialog
|
||||
:title="!dataForm.id ? 'btn.add' : 'btn.edit' | i18nFilter"
|
||||
:visible.sync="visible"
|
||||
>
|
||||
<el-form ref="dataForm" :model="dataForm" :rules="dataRule" label-width="160px" @keyup.enter.native="dataFormSubmit()">
|
||||
<el-form-item :label="$t('module.basicData.major.ProfessionalName')" prop="name">
|
||||
<el-input v-model="dataForm.name" :placeholder="$i18nForm(['placeholder.input', $t('module.basicData.major.ProfessionalName')])" clearable />
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('module.basicData.major.ProfessionalCoding')" prop="code">
|
||||
<el-input v-model="dataForm.code" :placeholder="$i18nForm(['placeholder.input', $t('module.basicData.major.ProfessionalCoding')])" clearable />
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('module.basicData.visual.Abbreviation')" prop="abbreviation">
|
||||
<el-input v-model="dataForm.abbreviation" :placeholder="$i18nForm(['placeholder.input', $t('module.basicData.visual.Abbreviation')])" clearable />
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('module.basicData.visual.Remarks')" prop="description">
|
||||
<el-input v-model="dataForm.description" :placeholder="$i18nForm(['placeholder.input', $t('module.basicData.visual.Remarks')])" clearable />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<span slot="footer" class="dialog-footer">
|
||||
<el-button @click="visible = false">{{ 'btn.cancel' | i18nFilter }}</el-button>
|
||||
<el-button type="primary" @click="dataFormSubmit()">{{ 'btn.confirm' | i18nFilter }}</el-button>
|
||||
</span>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { majorDetail, majorUpdate, majorAdd, majorCode } from '@/api/basicData/GroupModule/major'
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
visible: false,
|
||||
dataForm: {
|
||||
id: 0,
|
||||
name: '',
|
||||
code: '',
|
||||
description: '',
|
||||
abbreviation: ''
|
||||
},
|
||||
dataRule: {
|
||||
name: [
|
||||
{ required: true, message: this.$i18nForm(['placeholder.input', this.$t('module.basicData.major.ProfessionalName')]), trigger: 'blur' }
|
||||
],
|
||||
code: [
|
||||
{ required: true, message: this.$i18nForm(['placeholder.input', this.$t('module.basicData.major.ProfessionalCoding')]), trigger: 'blur' }
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
init(id) {
|
||||
majorCode().then(res => {
|
||||
this.dataForm.code = res.data
|
||||
})
|
||||
this.dataForm.id = id || ''
|
||||
this.visible = true
|
||||
this.$nextTick(() => {
|
||||
this.$refs['dataForm'].resetFields()
|
||||
if (this.dataForm.id) {
|
||||
majorDetail(this.dataForm.id).then(res => {
|
||||
this.dataForm.name = res.data.name
|
||||
this.dataForm.code = res.data.code
|
||||
this.dataForm.description = res.data.description
|
||||
this.dataForm.abbreviation = res.data.abbreviation
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
// 表单提交
|
||||
dataFormSubmit() {
|
||||
this.$refs['dataForm'].validate((valid) => {
|
||||
if (valid) {
|
||||
const data = {
|
||||
'name': this.dataForm.name,
|
||||
'code': this.dataForm.code,
|
||||
'description': this.dataForm.description,
|
||||
'abbreviation': this.dataForm.abbreviation,
|
||||
'id': this.dataForm.id
|
||||
}
|
||||
if (this.dataForm.id) {
|
||||
majorUpdate(data).then(res => {
|
||||
this.$message({
|
||||
message: this.$t('module.basicData.visual.success'),
|
||||
type: 'success',
|
||||
duration: 1500,
|
||||
onClose: () => {
|
||||
this.visible = false
|
||||
this.$emit('refreshDataList')
|
||||
}
|
||||
})
|
||||
})
|
||||
} else {
|
||||
majorAdd(data).then(res => {
|
||||
this.$message({
|
||||
message: this.$t('module.basicData.visual.success'),
|
||||
type: 'success',
|
||||
duration: 1500,
|
||||
onClose: () => {
|
||||
this.visible = false
|
||||
this.$emit('refreshDataList')
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
281
src/views/basicData/GroupModule/components/staff-add.vue
Normal file
281
src/views/basicData/GroupModule/components/staff-add.vue
Normal file
@@ -0,0 +1,281 @@
|
||||
<!--
|
||||
* @Author: zwq
|
||||
* @Date: 2020-12-29 16:37:56
|
||||
* @LastEditors: gtz
|
||||
* @LastEditTime: 2021-04-17 16:33:37
|
||||
* @Description:
|
||||
-->
|
||||
<template>
|
||||
<el-dialog
|
||||
:title="!staffData.id ? 'btn.add' : 'btn.edit' | i18nFilter"
|
||||
:visible.sync="visible"
|
||||
>
|
||||
<el-row :gutter="15">
|
||||
<el-form
|
||||
ref="staffForm"
|
||||
:model="staffData"
|
||||
:rules="rules"
|
||||
size="medium"
|
||||
label-width="110px"
|
||||
>
|
||||
<el-col :span="10">
|
||||
<el-row>
|
||||
<el-col :span="20">
|
||||
<el-form-item :label="$t('module.basicData.staff.Name')" prop="name">
|
||||
<el-input v-model="staffData.name" :placeholder="$i18nForm(['placeholder.input', $t('module.basicData.staff.Name')])" clearable :style="{width: '100%'}" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="20">
|
||||
<el-form-item :label="$t('module.basicData.staff.role')" prop="roleId">
|
||||
<el-select v-model="staffData.roleId">
|
||||
<el-option v-for="item in roleList" :key="item.id" :value="item.id" :label="item.dataName" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="20">
|
||||
<el-form-item :label="$t('module.basicData.staff.Gender')" prop="sex">
|
||||
<el-select v-model="staffData.sex" :placeholder="$i18nForm(['placeholder.input', $t('module.basicData.staff.Gender')])" clearable :style="{width: '100%'}">
|
||||
<el-option
|
||||
v-for="(item, index) in sexOptions"
|
||||
:key="index"
|
||||
:label="item.label"
|
||||
:value="item.value"
|
||||
:disabled="item.disabled"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="20">
|
||||
<el-form-item :label="$t('module.basicData.staff.Telephone')" prop="telephone">
|
||||
<el-input
|
||||
v-model="staffData.telephone"
|
||||
:placeholder="$i18nForm(['placeholder.input', $t('module.basicData.staff.Telephone')])"
|
||||
clearable
|
||||
prefix-icon="el-icon-phone"
|
||||
:style="{width: '100%'}"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="20">
|
||||
<el-form-item :label="$t('module.basicData.staff.Email')" prop="email">
|
||||
<el-input v-model="staffData.email" :placeholder="$i18nForm(['placeholder.input', $t('module.basicData.staff.Email')])" clearable :style="{width: '100%'}" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="20">
|
||||
<el-form-item :label="$t('module.basicData.staff.Profession')" prop="majorId">
|
||||
<el-select
|
||||
v-model="staffData.majorId"
|
||||
:placeholder="$i18nForm(['placeholder.input', $t('module.basicData.staff.Profession')])"
|
||||
multiple
|
||||
filterable
|
||||
clearable
|
||||
:style="{width: '100%'}"
|
||||
>
|
||||
<el-option
|
||||
v-for="(item, index) in majorArr"
|
||||
:key="index"
|
||||
:label="item.name"
|
||||
:value="item.id"
|
||||
:disabled="item.disabled"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-col>
|
||||
<el-col :span="10">
|
||||
<el-row>
|
||||
<el-col :span="20">
|
||||
<el-form-item :label="$t('module.basicData.staff.EmployeeID')" prop="code">
|
||||
<el-input v-model="staffData.code" :placeholder="$i18nForm(['placeholder.input', $t('module.basicData.staff.EmployeeID')])" clearable :style="{width: '100%'}" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="20">
|
||||
<el-form-item :label="$t('module.basicData.staff.Wechat')" prop="wechatCode">
|
||||
<el-input v-model="staffData.wechatCode" :placeholder="$i18nForm(['placeholder.input', $t('module.basicData.staff.Wechat')])" clearable :style="{width: '100%'}" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="20">
|
||||
<el-form-item :label="$t('module.basicData.staff.EntryTime')" prop="entryTime">
|
||||
<el-date-picker
|
||||
v-model="staffData.entryTime"
|
||||
:style="{width: '100%'}"
|
||||
:placeholder="$i18nForm(['placeholder.input', $t('module.basicData.staff.EntryTime')])"
|
||||
clearable
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="20">
|
||||
<el-form-item :label="$t('module.basicData.staff.Workshop')" prop="workshop">
|
||||
<el-input v-model="staffData.workshop" :placeholder="$i18nForm(['placeholder.input', $t('module.basicData.staff.Workshop')])" clearable :style="{width: '100%'}" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="20">
|
||||
<el-form-item :label="$t('module.basicData.staff.onDuty')" prop="onDuty">
|
||||
<el-radio-group v-model="staffData.onDuty" size="medium">
|
||||
<el-radio
|
||||
v-for="(item, index) in onDutyOptions"
|
||||
:key="index"
|
||||
:label="item.value"
|
||||
:disabled="item.disabled"
|
||||
>{{ item.label }}</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="20">
|
||||
<el-form-item :label="$t('module.basicData.visual.Remarks')" prop="description">
|
||||
<el-input v-model="staffData.description" :placeholder="$i18nForm(['placeholder.input', $t('module.basicData.visual.Remarks')])" clearable :style="{width: '100%'}" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-col>
|
||||
</el-form>
|
||||
</el-row>
|
||||
<span slot="footer" class="dialog-footer">
|
||||
<el-button @click="visible = false">{{ 'btn.cancel' | i18nFilter }}</el-button>
|
||||
<el-button type="primary" size="medium" @click="staffDataSubmit()"> {{ 'btn.save' | i18nFilter }} </el-button>
|
||||
</span>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { staffDetail, staffUpdate, staffAdd, staffCode } from '@/api/basicData/GroupModule/staff'
|
||||
import { majorList } from '@/api/basicData/GroupModule/major'
|
||||
|
||||
export default {
|
||||
props: {
|
||||
roleList: {
|
||||
type: Array,
|
||||
default: () => []
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
visible: false,
|
||||
majorArr: [],
|
||||
staffData: {
|
||||
name: undefined,
|
||||
sex: '',
|
||||
telephone: '',
|
||||
email: '',
|
||||
majorId: [],
|
||||
description: undefined,
|
||||
code: undefined,
|
||||
wechatCode: undefined,
|
||||
entryTime: null,
|
||||
workshop: undefined,
|
||||
onDuty: 1,
|
||||
roleId: null
|
||||
},
|
||||
rules: {
|
||||
name: [{
|
||||
required: true,
|
||||
message: this.$i18nForm(['placeholder.input', this.$t('module.basicData.staff.Name')]),
|
||||
trigger: 'blur'
|
||||
}],
|
||||
telephone: [{
|
||||
pattern: /(^1\d{10}$)|(^[0-9]\d{7}$)/,
|
||||
message: this.$t('module.basicData.staff.Telephone') + this.$t('module.basicData.customer.format'),
|
||||
trigger: 'blur'
|
||||
}],
|
||||
email: [{
|
||||
pattern: /^\w+@[a-z0-9]+\.[a-z]{2,4}$/,
|
||||
message: this.$t('module.basicData.staff.Email') + this.$t('module.basicData.customer.format'),
|
||||
trigger: 'blur'
|
||||
}],
|
||||
description: [],
|
||||
code: [{
|
||||
required: true,
|
||||
message: this.$i18nForm(['placeholder.input', this.$t('module.basicData.staff.EmployeeID')]),
|
||||
trigger: 'blur'
|
||||
}]
|
||||
},
|
||||
sexOptions: [{
|
||||
'label': '男',
|
||||
'value': 1
|
||||
}, {
|
||||
'label': '女',
|
||||
'value': 0
|
||||
}],
|
||||
onDutyOptions: [{
|
||||
'label': this.$t('module.basicData.visual.Yes'),
|
||||
'value': 1
|
||||
}, {
|
||||
'label': this.$t('module.basicData.visual.No'),
|
||||
'value': 0
|
||||
}]
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
init(id) {
|
||||
staffCode().then(res => {
|
||||
this.staffData.code = res.data
|
||||
})
|
||||
majorList({
|
||||
current: 1,
|
||||
size: 999,
|
||||
name: ''
|
||||
}).then(response => {
|
||||
this.majorArr = response.data.records
|
||||
})
|
||||
this.staffData.id = id || ''
|
||||
this.visible = true
|
||||
this.$nextTick(() => {
|
||||
this.$refs['staffForm'].resetFields()
|
||||
if (this.staffData.id) {
|
||||
staffDetail(this.staffData.id).then(res => {
|
||||
this.staffData = res.data
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
// 表单提交
|
||||
staffDataSubmit() {
|
||||
this.$refs['staffForm'].validate((valid) => {
|
||||
if (valid) {
|
||||
const data = {
|
||||
'name': this.staffData.name,
|
||||
'sex': this.staffData.sex,
|
||||
'telephone': this.staffData.telephone,
|
||||
'description': this.staffData.description,
|
||||
'code': this.staffData.code,
|
||||
'email': this.staffData.email,
|
||||
'entryTime': this.staffData.entryTime,
|
||||
'majorId': this.staffData.majorId,
|
||||
'onDuty': this.staffData.onDuty,
|
||||
'wechatCode': this.staffData.wechatCode,
|
||||
'workshop': this.staffData.workshop,
|
||||
'roleId': this.staffData.roleId,
|
||||
'id': this.staffData.id
|
||||
}
|
||||
if (this.staffData.id) {
|
||||
staffUpdate(data).then(res => {
|
||||
this.$message({
|
||||
message: this.$t('module.basicData.visual.success'),
|
||||
type: 'success',
|
||||
duration: 1500,
|
||||
onClose: () => {
|
||||
this.visible = false
|
||||
this.$emit('refreshDataList')
|
||||
}
|
||||
})
|
||||
})
|
||||
} else {
|
||||
staffAdd(data).then(res => {
|
||||
this.$message({
|
||||
message: this.$t('module.basicData.visual.success'),
|
||||
type: 'success',
|
||||
duration: 1500,
|
||||
onClose: () => {
|
||||
this.visible = false
|
||||
this.$emit('refreshDataList')
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
Reference in New Issue
Block a user