1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
| <template>
| <div class="add_wordshop">
| <el-dialog
| :visible.sync="islook"
| width="38rem"
| @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
| v-model="form.workerId"
| disabled
| placeholder="请输入员工编号"
| >
| </el-input>
| </el-form-item>
| <el-form-item label="带徒月份" style="width: 100%;"
| prop="month">
| <el-date-picker
| style="width:100%"
| v-model="form.month"
| type="month"
| placeholder="选择月"
| value-format="yyyy-MM">
| </el-date-picker>
| </el-form-item>
| <el-form-item label="带徒天数" style="width: 100%;"
| prop="days" >
| <el-input
| v-model="form.days"
| placeholder="请输入"
| >
| </el-input>
| </el-form-item>
| </el-form>
| <span slot="footer" class="dialog-footer">
| <el-button @click="cancelMethod()">取 消</el-button>
| <el-button type="primary" @click="submitForm('form')">确 定</el-button>
| </span>
| </el-dialog>
| </div>
| </template>
|
| <script>
| import { createMentorInfo, updateMentorInfo } from "@/api/employeeSalary/apprenticeshipManage.js"
| import UserSimpleSearchInput from "@/components/common/UserSimpleSearchInput"
| export default {
| components: {
| UserSimpleSearchInput
| },
| props: {
| editRow: {
| type: Object,
| }
| },
| data() {
| return {
| islook:false,
| form:{
| workerId:'',
| days:null,
| month:'',
| name:'',
| },
| rules: {
| name: [
| { required: true, message: '请选择', trigger: ['change','blur'] }
| ],
| month: [
| { required: true, message: '请选择', trigger: ['change','blur'] }
| ],
| days: [
| { required: true, message: '请填写', trigger: ['change','blur'] },
| {
| validator: this.validatorNum,
| trigger: ["blur", "change"],
| },
| ]
| },
| };
| },
| computed: {
| },
| created() {
| },
| mounted() {
|
| },
| watch: {
| islook(newVal) {
| if (newVal) {
| this.formInfo()
| }
| },
| editRow() {
| this.formInfo()
| },
| },
| methods: {
| 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));
| }
| })
| }
| },
| 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) {
| 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;
| }
| });
| },
| },
| };
| </script>
|
| <style scoped lang="scss">
| .el-form{
| margin-bottom:50px;
| width:94%;
| margin: 0 auto;
| }
| ::v-deep{
| .el-form{
| .el-input__inner {
| text-align: left;
| }
| }
| .el-select{
| width: 100%;
| }
| }
| </style>
|
|