| | |
| | | <template> |
| | | <el-dialog |
| | | :title="!dataForm.id ? '新增' : '修改'" |
| | | :close-on-click-modal="false" |
| | | :visible.sync="visible" |
| | | > |
| | | <el-form |
| | | :model="dataForm" |
| | | :rules="rules" |
| | | ref="dataForm" |
| | | label-width="100px" |
| | | class="l-mes" |
| | | > |
| | | <el-dialog :title="!dataForm.id ? '新增' : '修改'" :close-on-click-modal="false" :visible.sync="visible"> |
| | | <el-form :model="dataForm" :rules="rules" ref="dataForm" label-width="100px" class="l-mes"> |
| | | <el-row> |
| | | <el-col :span="12"> |
| | | <el-form-item label="人员编号" prop="staffNo"> |
| | | <el-input |
| | | v-model="dataForm.staffNo" |
| | | placeholder="人员编号" |
| | | ></el-input> |
| | | <el-input v-model="dataForm.staffNo" placeholder="人员编号"></el-input> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="人员名称" prop="staffName"> |
| | | <el-input |
| | | v-model="dataForm.staffName" |
| | | placeholder="人员名称" |
| | | ></el-input> |
| | | <el-input v-model="dataForm.staffName" placeholder="人员名称"></el-input> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row> |
| | | <el-col :span="12"> |
| | | <el-form-item label="公司" prop="companyId"> |
| | | <el-select @change="changeCompany" style="width: 100%;" v-model="dataForm.companyId" placeholder="请选择"> |
| | | <el-option v-for="item in options" :key="item.id" :label="item.companyName" :value="item.id"> |
| | | </el-option> |
| | | </el-select> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="工厂" prop="factoryId"> |
| | | <el-select @change="changeFactory" style="width: 100%;" v-model="dataForm.factoryId" placeholder="请选择"> |
| | | <el-option v-for="item in optionsfactory" :key="item.id" :label="item.factoryName" :value="item.id"> |
| | | </el-option> |
| | | </el-select> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row> |
| | | <el-col :span="12"> |
| | | <el-form-item label="部门" prop="divisionId"> |
| | | <el-select |
| | | v-model="dataForm.divisionId" |
| | | filterable |
| | | placeholder="请选择" |
| | | style="width: 100%;" |
| | | > |
| | | <el-option |
| | | v-for="(item, index) in this.divisionOptions" |
| | | :key="index" |
| | | :label="item.divisionName" |
| | | :value="item.id" |
| | | > |
| | | <el-select @change="changeDivision" v-model="dataForm.divisionId" filterable placeholder="请选择" style="width: 100%;"> |
| | | <el-option v-for="(item, index) in this.divisionOptions" :key="index" :label="item.divisionName" |
| | | :value="item.id"> |
| | | </el-option> |
| | | </el-select> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="电话" prop="phone"> |
| | | <el-input v-model="dataForm.phone" placeholder="电话"></el-input> |
| | | <el-form-item label="岗位" prop="postId"> |
| | | <el-select v-model="dataForm.postId" filterable placeholder="请选择" style="width: 100%;"> |
| | | <el-option v-for="item in this.postOptions" :key="item.id" :label="item.postName" :value="item.id"> |
| | | </el-option> |
| | | </el-select> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | |
| | | <el-input v-model="dataForm.email" placeholder="邮箱"></el-input> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="电话" prop="phone"> |
| | | <el-input v-model="dataForm.phone" placeholder="电话"></el-input> |
| | | </el-form-item> |
| | | </el-col> |
| | | <!-- <el-col :span="12"> |
| | | <el-form-item label="岗位" prop="post"> |
| | | <el-input v-model="dataForm.post" placeholder="岗位"></el-input> |
| | | </el-form-item> |
| | | </el-col>--> |
| | | <el-col :span="12"> |
| | | <el-form-item label="岗位" prop="postId"> |
| | | <el-select |
| | | v-model="dataForm.postId" |
| | | filterable |
| | | placeholder="请选择" |
| | | style="width: 100%;" |
| | | > |
| | | <el-option |
| | | v-for="item in this.postOptions" |
| | | :key="item.id" |
| | | :label="item.postName" |
| | | :value="item.id" |
| | | > |
| | | </el-option> |
| | | </el-select> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row> |
| | | <el-col :span="12"> |
| | | <el-form-item label="人员系数" prop="personnelFactor"> |
| | | <el-input |
| | | v-model="dataForm.personnelFactor" |
| | | placeholder="人员系数" |
| | | ></el-input> |
| | | <el-input v-model="dataForm.personnelFactor" placeholder="人员系数"></el-input> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row> |
| | | <el-col :span="12"> |
| | | <el-form-item label="人员性质" prop="personNature"> |
| | | <el-select |
| | | v-model="dataForm.personNature" |
| | | placeholder="请选择" |
| | | style="width: 100%;" |
| | | > |
| | | <el-option |
| | | v-for="item in this.personNatureOptions" |
| | | :key="item.value" |
| | | :label="item.label" |
| | | :value="item.value" |
| | | > |
| | | <el-select v-model="dataForm.personNature" placeholder="请选择" style="width: 100%;"> |
| | | <el-option v-for="item in this.personNatureOptions" :key="item.value" :label="item.label" |
| | | :value="item.value"> |
| | | </el-option> |
| | | </el-select> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="试用截止日期" prop="trialDeadline"> |
| | | <el-input |
| | | v-model="dataForm.trialDeadline" |
| | | placeholder="" |
| | | ></el-input> |
| | | <el-input v-model="dataForm.trialDeadline" placeholder=""></el-input> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | </el-form> |
| | | <span slot="footer" class="dialog-footer"> |
| | | <el-button @click="visible = false">取消</el-button> |
| | | <el-button |
| | | type="primary" |
| | | :disabled="isSubmit" |
| | | v-thinclick="`dataFormSubmit`" |
| | | >确定</el-button |
| | | > |
| | | <el-button type="primary" :disabled="isSubmit" v-thinclick="`dataFormSubmit`">确定</el-button> |
| | | </span> |
| | | </el-dialog> |
| | | </template> |
| | | |
| | | <script> |
| | | import { getObj, loadDivision, dataFormTransfer } from '@/api/basic/staff' |
| | | import { getList } from '@/api/basic/post' |
| | | import { getList, getDivisionByFactoryId ,getObjById} from '@/api/basic/post' |
| | | import { dateFormat, dateFormatYearMonthDate } from '@/util/date' |
| | | import { |
| | | loadFactoryListByCompany |
| | | } from '@/api/basic/division' |
| | | |
| | | import { loadCompany } from '@/api/basic/factory' |
| | | |
| | | export default { |
| | | props: { |
| | |
| | | data() { |
| | | return { |
| | | visible: false, |
| | | options: [], |
| | | optionsfactory: [], |
| | | dataForm: { |
| | | id: 0, |
| | | staffNo: '', |
| | |
| | | updateUser: '', |
| | | divisionId: '', |
| | | personNature: '', |
| | | trialDeadline: '' |
| | | trialDeadline: '', |
| | | companyId: null, |
| | | companyName: null, |
| | | factoryId: null, |
| | | factoryName: null, |
| | | }, |
| | | divisionOptions: [], |
| | | postOptions: [], |
| | |
| | | } |
| | | }, |
| | | computed: { |
| | | rules: function() { |
| | | rules: function () { |
| | | return { |
| | | divisionId: [ |
| | | { required: true, message: '部门不能为空', trigger: 'blur' } |
| | |
| | | ], |
| | | staffName: [ |
| | | { required: true, message: '人员名称不能为空', trigger: 'blur' } |
| | | ], |
| | | companyId: [ |
| | | { required: true, message: '公司名称不能为空', trigger: 'blur' } |
| | | ], |
| | | factoryId: [ |
| | | { required: true, message: '工厂名称不能为空', trigger: 'blur' } |
| | | ] |
| | | } |
| | | } |
| | | }, |
| | | methods: { |
| | | changeDivision(){ |
| | | getObjById(this.dataForm.companyId,this.dataForm.factoryId,this.dataForm.divisionId).then((response) => { |
| | | this.postOptions = response.data.data |
| | | }) |
| | | }, |
| | | changeCompany() { |
| | | loadFactoryListByCompany(this.dataForm.companyId).then((res) => { |
| | | this.optionsfactory = res.data.data |
| | | }) |
| | | // this.divisionOptions=[] |
| | | // this.dataForm.divisionId='' |
| | | this.dataForm.companyName = this.options.filter(item => { |
| | | return item.id == this.dataForm.companyId |
| | | })[0].companyName; |
| | | }, |
| | | changeFactory() { |
| | | getDivisionByFactoryId(this.dataForm.companyId, this.dataForm.factoryId).then((res) => { |
| | | this.divisionOptions=res.data.data |
| | | }) |
| | | this.dataForm.factoryName = this.optionsfactory.filter(item => { |
| | | return item.id == this.dataForm.factoryId |
| | | })[0].factoryName; |
| | | }, |
| | | initCompanySelect() { |
| | | loadCompany().then((res) => { |
| | | this.options = res.data |
| | | }) |
| | | }, |
| | | init(id) { |
| | | this.dataForm.id = id || 0 |
| | | this.visible = true |
| | |
| | | if (this.dataForm.id) { |
| | | getObj(this.dataForm.id).then((response) => { |
| | | this.dataForm = response.data.data |
| | | this.changeCompany() |
| | | this.changeFactory() |
| | | this.changeDivision() |
| | | }) |
| | | } else { |
| | | const trialDeadline = new Date() |
| | |
| | | id: this.dataForm.id, |
| | | personnelFactor: this.dataForm.personnelFactor, |
| | | personNature: this.dataForm.personNature, |
| | | trialDeadline: this.dataForm.trialDeadline |
| | | trialDeadline: this.dataForm.trialDeadline, |
| | | factoryId: this.dataForm.factoryId, |
| | | factoryName: this.dataForm.factoryName, |
| | | companyId: this.dataForm.companyId, |
| | | companyName: this.dataForm.companyName |
| | | } |
| | | this.$refs.dataForm.validate((valid) => { |
| | | if (valid) { |
| | |
| | | } |
| | | }, |
| | | created() { |
| | | this.initDivisionSelect() |
| | | this.initPostSelect() |
| | | // this.initDivisionSelect() |
| | | // this.initPostSelect() |
| | | this.initCompanySelect() |
| | | if(this.dataForm.staffNo!=''){ |
| | | console.log(121212); |
| | | this.changeCompany() |
| | | this.changeDivision() |
| | | } |
| | | }, |
| | | watch: { |
| | | 'dataForm.divisionId': { |
| | | handler(newValue, oldValue) { |
| | | if (newValue != ''&&oldValue!=''&&oldValue!=undefined&&newValue!=undefined) { |
| | | if(oldValue!=newValue){ |
| | | this.dataForm.postId=null |
| | | this.postOptions=[] |
| | | } |
| | | } |
| | | }, |
| | | immediate: true, |
| | | deep: true |
| | | }, |
| | | 'dataForm.companyId': { |
| | | handler(newValue, oldValue) { |
| | | if (newValue != ''&&oldValue!=''&&oldValue!=undefined&&newValue!=undefined) { |
| | | console.log(newValue); |
| | | console.log(oldValue); |
| | | if(oldValue!=newValue){ |
| | | this.dataForm.factoryId=null |
| | | this.dataForm.divisionId=null |
| | | this.divisionOptions=[] |
| | | this.dataForm.postId=null |
| | | this.postOptions=[] |
| | | } |
| | | } |
| | | }, |
| | | immediate: true, |
| | | deep: true |
| | | }, |
| | | 'dataForm.factoryId': { |
| | | handler(newValue, oldValue) { |
| | | if (newValue != ''&&oldValue!=''&&oldValue!=undefined&&newValue!=undefined) { |
| | | console.log(newValue); |
| | | console.log(oldValue); |
| | | if(oldValue!=newValue){ |
| | | this.dataForm.divisionId=null |
| | | this.divisionOptions=[] |
| | | this.dataForm.postId=null |
| | | this.postOptions=[] |
| | | } |
| | | } |
| | | }, |
| | | immediate: true, |
| | | deep: true |
| | | }, |
| | | 'dataForm.personNature': { |
| | | handler(newValue, oldValue) { |
| | | if ( |