| | |
| | | <template> |
| | | <div class="add_wordshop"> |
| | | <el-dialog |
| | | :title="editConfig.dialogTitle+'车间管理'" |
| | | :visible.sync="editConfig.visible" |
| | | width="30%" |
| | | :before-close="handleClose"> |
| | | <el-form :inline="true" label-width="20%" style="width: 100%;" :model="editConfig.infomitton" :rules="rules" ref="ruleForm" > |
| | | <el-form-item label="员工编码" style="width: 100%;" |
| | | prop="groupNumber" > |
| | | :visible.sync="islook" |
| | | width="40rem" |
| | | @close="cancelMethod"> |
| | | <div slot="title" class="tac drawerHeader">{{ editRow.title }}人员</div> |
| | | <el-form label-position="right" label-width="120px" style="width: 100%;" :model="form" :rules="rules" ref="form" > |
| | | <el-form-item label="员工姓名" style="width: 100%;" |
| | | prop="name" > |
| | | <UserSimpleSearchInput |
| | | :echoValue="form.workerId" |
| | | :echoName="form.name" |
| | | checkedNum="1" |
| | | request="1" |
| | | :clearable="true" |
| | | @select-user="setFormItem($event, 'workerId', 'name')" |
| | | > |
| | | </UserSimpleSearchInput> |
| | | </el-form-item> |
| | | <el-form-item label="员工编号" style="width: 100%;" prop="workerId" > |
| | | <el-input |
| | | :disabled="this.editConfig.dialogTitle==='查看'" |
| | | v-model="editConfig.infomitton.groupNumber" |
| | | :rows="4" |
| | | style="resize: none !important;" |
| | | placeholder="请输入员工编码" |
| | | v-model="form.workerId" |
| | | disabled |
| | | placeholder="请输入员工编号" |
| | | > |
| | | </el-input> |
| | | </el-form-item> |
| | | <el-form-item label="员工姓名" style="width: 100%;" > |
| | | <el-input |
| | | :disabled="this.editConfig.dialogTitle==='查看'" |
| | | v-model="editConfig.infomitton.groupNumber" |
| | | :rows="4" |
| | | style="resize: none !important;" |
| | | placeholder="请输入员工姓名" |
| | | > |
| | | </el-input> |
| | | </el-form-item> |
| | | <el-form-item label="带徒天数" style="width: 100%;" |
| | | prop="groupNumber"> |
| | | <el-form-item label="带徒月份" style="width: 100%;" |
| | | prop="month"> |
| | | <el-date-picker |
| | | style="width:100%" |
| | | v-model="editConfig.infomitton.groupNumber" |
| | | v-model="form.month" |
| | | type="month" |
| | | placeholder="选择月"> |
| | | placeholder="选择月" |
| | | value-format="yyyy-MM"> |
| | | </el-date-picker> |
| | | </el-form-item> |
| | | <el-form-item label="带徒天数" style="width: 100%;" |
| | | prop="groupNumber" > |
| | | prop="days" > |
| | | <el-input |
| | | :disabled="this.editConfig.dialogTitle==='查看'" |
| | | v-model="editConfig.infomitton.groupNumber" |
| | | :rows="4" |
| | | style="resize: none !important;" |
| | | placeholder="请输入员工编码" |
| | | v-model="form.days" |
| | | placeholder="请输入" |
| | | > |
| | | </el-input> |
| | | </el-form-item> |
| | | </el-form> |
| | | <span slot="footer" class="dialog-footer"> |
| | | <el-button @click="editConfig.visible = false">取 消</el-button> |
| | | <el-button type="primary" @click="commitForm('ruleForm')">确 定</el-button> |
| | | <el-button @click="cancelMethod()">取 消</el-button> |
| | | <el-button type="primary" @click="submitForm('form')">确 定</el-button> |
| | | </span> |
| | | </el-dialog> |
| | | </div> |
| | | </template> |
| | | |
| | | <script> |
| | | // import {} from "@/api/systemSetting/workshopManage" |
| | | import { createMentorInfo, updateMentorInfo } from "@/api/employeeSalary/apprenticeshipManage.js" |
| | | import UserSimpleSearchInput from "@/components/common/UserSimpleSearchInput" |
| | | export default { |
| | | components: { |
| | | UserSimpleSearchInput |
| | | }, |
| | | props: { |
| | | editDiaConfig:{ |
| | | editRow: { |
| | | type: Object, |
| | | default: () => { |
| | | return { |
| | | visible: false, |
| | | dialogTitle:"添加", |
| | | isReadonly:true, |
| | | infomitton: { |
| | | }, |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | data() { |
| | | return { |
| | | editConfig:this.editDiaConfig, |
| | | workshopList:[], |
| | | carFlagList:[ |
| | | ], |
| | | islook:false, |
| | | form:{ |
| | | workerId:'', |
| | | days:null, |
| | | month:'', |
| | | name:'', |
| | | }, |
| | | rules: { |
| | | workshopNumber: [ |
| | | { required: true, message: '请选择车间', trigger: 'change' } |
| | | name: [ |
| | | { required: true, message: '请选择', trigger: ['change','blur'] } |
| | | ], |
| | | groupNumber: [ |
| | | { required: true, message: '请填写组别', trigger: 'change' } |
| | | month: [ |
| | | { required: true, message: '请选择', trigger: ['change','blur'] } |
| | | ], |
| | | days: [ |
| | | { required: true, message: '请填写', trigger: ['change','blur'] }, |
| | | { |
| | | validator: this.validatorNum, |
| | | trigger: ["blur", "change"], |
| | | }, |
| | | ] |
| | | }, |
| | | }; |
| | |
| | | |
| | | }, |
| | | watch: { |
| | | |
| | | islook(newVal) { |
| | | if (newVal) { |
| | | this.formInfo() |
| | | } |
| | | }, |
| | | editRow() { |
| | | this.formInfo() |
| | | }, |
| | | }, |
| | | methods: { |
| | | handleClose(done) { |
| | | done(); |
| | | }, |
| | | setParams(){ |
| | | let params={ |
| | | workshopNumber:this.editConfig.infomitton.workshopNumber+'', |
| | | groupNumber:Number(this.editConfig.infomitton.groupNumber), |
| | | startCarNumber:Number(this.editConfig.infomitton.startCarNumber), |
| | | endCarNumber:Number(this.editConfig.infomitton.endCarNumber), |
| | | carFlag:Number(this.editConfig.infomitton.carFlag), |
| | | notes:this.editConfig.infomitton.notes, |
| | | // id:Number(this.editConfig.infomitton.workshopId), |
| | | formInfo() { |
| | | if (this.islook) { |
| | | this.form = { |
| | | workerId:'', |
| | | days:null, |
| | | month:'', |
| | | name:'', |
| | | }; |
| | | this.$nextTick(()=>{ |
| | | this.$refs["form"].resetFields(); |
| | | if (this.editRow.id) { |
| | | this.form = JSON.parse(JSON.stringify(this.editRow)); |
| | | } |
| | | }) |
| | | } |
| | | return params |
| | | }, |
| | | async commitForm(formName){ |
| | | setFormItem(val, itemMark, itemName) { |
| | | this.$set(this.form, itemMark, val.id); |
| | | this.$set(this.form, itemName, val.name); |
| | | }, |
| | | validatorNum(rule, value, callback) { |
| | | if (value == undefined || value == null) { |
| | | callback(new Error("请输入有效数字")); |
| | | } else { |
| | | let reg2 = |
| | | /(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/; |
| | | if (!reg2.test(value) || value == 0) { |
| | | callback(new Error("请填写大于零的2位小数的数字")); |
| | | } else { |
| | | callback(); |
| | | } |
| | | } |
| | | }, |
| | | cancelMethod(val) { |
| | | this.$refs["form"].resetFields(); |
| | | this.islook = false; |
| | | if(val){ |
| | | this.$emit('refresh') |
| | | } |
| | | |
| | | }, |
| | | submitForm(formName) { |
| | | this.$refs[formName].validate((valid) => { |
| | | if (valid) { |
| | | console.log("校验通过") |
| | | let form = JSON.parse(JSON.stringify(this.form)); |
| | | form.days=Number(form.days) |
| | | if (this.editRow.type == "add") { |
| | | createMentorInfo(form).then((res) => { |
| | | if (res.code == 200) { |
| | | this.$message({ |
| | | message: "添加成功!", |
| | | type: "success", |
| | | }); |
| | | this.cancelMethod(true); |
| | | } |
| | | }); |
| | | } else { |
| | | updateMentorInfo(form).then((res) => { |
| | | if (res.code == 200) { |
| | | this.$message({ |
| | | message: "编辑成功!", |
| | | type: "success", |
| | | }); |
| | | this.cancelMethod(true); |
| | | } |
| | | }); |
| | | } |
| | | } else { |
| | | console.log('error submit!!'); |
| | | return false; |
| | | } |
| | | }); |
| | | |
| | | |
| | | } |
| | | }, |
| | | components: { |
| | | |
| | | }, |
| | | }, |
| | | }; |
| | | </script> |