class="lines-num lines-num-old">
<t-form-item label="出生年月" prop="age">
<!-- <t-input v-model="formValidate.age" placeholder="请输入数字"></t-input>-->
<t-date-picker v-model="updateFormValidate.age"
placeholder="请选择出生年月"></t-date-picker>
</t-form-item>
<t-form-item label="手机" prop="phone">
<t-input v-model="updateFormValidate.phone" placeholder="请输入手机号码"></t-input>
</t-form-item>
</t-form>
<div slot="footer">
<t-button @click="cancel">取消</t-button>
<t-button class="submit-button" @click="updateSubmit">保存</t-button>
</div>
</t-modal>
<t-loading v-model="fullLoading" fullscreen tip="加载中...."></t-loading>
</div>
</template>
<script>
@ -128,6 +161,9 @@ export default {
},
departments: [],
selections: [],
JobPostions: [],
fullLoading: false,
tableLoading: true,
queryCondition: {
type: '',
employeeNo: '',
@ -227,6 +263,81 @@ export default {
}
}
]
},
updateModal: false,
updateFormValidate: {
id: '',
name: '',
number: '',
department: '',
job: '',
age: '',
phone: ''
},
updateRuleValidate: {
name: [
{
required: true,
message: '姓名不能为空',
trigger: 'blur'
}
],
department: [
{
required: true,
message: '部门不能为空',
trigger: 'change',
validator: function(rule, value, callback) {
// TODO 判断编号重复
if (!value) {
callback(rule.message)
} else {
return true
}
}
}
],
job: [
{
required: true,
message: '职务不能为空',
trigger: 'change',
validator: function(rule, value, callback) {
// TODO 判断编号重复
if (!value) {
callback(rule.message)
} else {
return true
}
}
}
],
age: [
{
required: true,
message: '出生年月不能为空',
trigger: 'change'
}
],
phone: [
{
required: true,
message: '手机不能为空',
trigger: 'blur'
},
{
message: '手机格式不正确',
trigger: 'blur',
validator: function(rule, value, callback) {
let pattern = /^1[3456789]\d{9}$/
if (!pattern.test(value)) {
callback(rule.message)
} else {
return true
}
}
}
]
}
}
},
@ -247,17 +358,17 @@ export default {
}
},
mounted() {
// this.table.data = this.table.data.concat(this.table.data)
// this.table.pager.total = this.table.data.length
this.getList()
this.getDepartmentsList()
this.initJobPostion()
},
methods: {
getList: function () {
this.tableLoading = true
this.$test
.post(services.workEmployee.GET_WORK_EMPLOYEE, {
data: {
orgId: this.queryCondition.department,
orgCode: this.queryCondition.department,
code: this.queryCondition.employeeNo,
name: this.queryCondition.employeeName
},
@ -266,13 +377,23 @@ export default {
})
.then((res) => {
// 请求成功处理...
this.tableLoading = false
this.table.data = res.data.data
this.table.pager.total = res.data.total
})
.catch((res) => {
// 请求失败处理...
this.tableLoading = false
})
},
type_formatter(row, column) {
var arr = this.JobPostions.filter((item) => {
return item.code === row.mainJobPosition
})
if (arr[0]) {
return arr[0].value
}
},
getDepartmentsList: function () {
this.$test
.post(services.workEmployee.GET_ALL_ORGANIZE, {})
@ -286,7 +407,7 @@ export default {
label: res.data[i].name,
title: res.data[i].name,
id: res.data[i].code,
data: res.data[i].id,
data: res.data[i].code,
pid: res.data[i].parentCode
})
} else {
@ -294,7 +415,7 @@ export default {
label: res.data[i].name,
title: res.data[i].name,
id: res.data[i].code,
data: res.data[i].id
data: res.data[i].code
})
}
}
@ -303,6 +424,17 @@ export default {
// 请求失败处理...
})
},
initJobPostion: function () {
this.$test
.post(services.workEmployee.GET_JOB_POSTION, {})
.then((res) => {
// 请求成功处理...
this.JobPostions = res.data
})
.catch((res) => {
// 请求失败处理...
})
},
onChange(value) {
console.log('date change:' + value)
},
@ -330,68 +462,67 @@ export default {
this.getList()
},
handleClick(row) {
this.modal = true
// var params = new FormData()
// params.append('data', JSON.stringify({
// FACILITY_ID: row.FACILITY_ID
// }))
// this.$test.post(services.equipment.GET_ONE_EQUIPMENT, params
// ).then(res => {
// // 请求成功处理...
// this.updateModal = true
// this.updateRow = res.data.resultData
// this.typeChange(2)
// }).catch(res => {
// // 请求失败处理...
// })
this.updateModal = true
this.$test
.post(services.workEmployee.GET_WORK_EMPLOYEE, {
data: {
id: row.id
},
pageNumber: 1,
pageSize: 1
})
.then((res) => {
// 请求成功处理...
var user = res.data.data[0]
this.updateFormValidate = {
id: user.id,
name: user.name,
number: user.code,
department: user.orgCode,
job: user.mainJobPosition,
age: user.birthday,
phone: user.mainWirelessCall
}
})
.catch((res) => {
// 请求失败处理...
})
},
remove(row) {
this.$Confirm.confirm({
title: '确认要删除用户张三吗?',
content: '删除后不可恢复',
let confirm = {
title: '请确认',
content: '删除后不可恢复,确认删除吗?',
ok: () => {
console.log('点击了确定')
},
cancel: () => {
console.log('点击了取消')
this.fullLoading = true
this.$test.post(services.workEmployee.DEL_WORK_EMPLOYEE, {ids: row.id this.$test.post(services.workEmployee.DEL_WORK_EMPLOYEE, {ids: row.id}
).then(res => {
// 请求成功处理...
this.fullLoading = false
this.$Message.success('操作成功')
this.getList()
}).catch(res => {
// 请求失败处理...
this.fullLoading = false
})
}
})
// let that = this
// let confirm = {
// title: '请确认',
// content: '删除后不可恢复,确认删除吗?',
// ok: function () {
// var params = new FormData()
// params.append('data', JSON.stringify({
// params: {
// FACILITY_ID: row.FACILITY_ID
// }
// }))
// this.$test.post(services.equipment.DEL_EQUIPMENT, params
// ).then(res => {
// // 请求成功处理...
// that.$Message.success('操作成功')
// that.getList()
// }).catch(res => {
// // 请求失败处理...
// })
// }
// }
// this.$Confirm.confirm(confirm)
}
this.$Confirm.confirm(confirm)
},
cancel() {
this.modal = false
this.updateModal = false
this.$refs['formValidate'].resetFields()
},
submit() {
var that = this
this.$refs.formValidate.validate(valid => {
if (valid) {
that.fullLoading = true
that.$test.post(services.workEmployee.ADD_WORK_EMPLOYEE, {
name: that.formValidate.name,
code: that.formValidate.number,
organizeCode: that.formValidate.department,
mainJobPosition: that.formValidate.job.value,
mainJobPosition: that.formValidate.job,
birthday: that.formValidate.age,
// cardType: "居民身份证",
// cardNo: "43252345455412305567X",
@ -400,16 +531,47 @@ export default {
}
).then(res => {
// 请求成功处理...
if (res.data) {
that.$Message.success('提交成功!')
that.cancel()
that.getList()
} else {
this.$Message.danger('终端编号重复!')
}
that.fullLoading = false
that.$Message.success('提交成功!')
that.cancel()
that.getList()
// this.getList(this.table.pager.currentPage, this.table.pager.size, this.queryCondition.equipmentType, this.queryCondition.equipmentName, this.queryCondition.equipmentNumber)
}).catch(res => {
// 请求失败处理...
that.fullLoading = false
})
} else {
this.$Message.danger('表单验证失败!')
}
})
},
updateSubmit() {
var that = this
this.$refs.updateFormValidate.validate(valid => {
if (valid) {
that.fullLoading = true
var birthday = that.updateFormValidate.age.replaceAll(' 00:00:00', '')
that.$test.post(services.workEmployee.UPD_WORK_EMPLOYEE, {
id: that.updateFormValidate.id,
name: that.updateFormValidate.name,
code: that.updateFormValidate.number,
organizeCode: that.updateFormValidate.department,
mainJobPosition: that.updateFormValidate.job,
birthday: birthday,
// cardType: "居民身份证",
// cardNo: "43252345455412305567X",
// gender: "男",
mainWirelessCall: that.updateFormValidate.phone
}
).then(res => {
// 请求成功处理...
this.fullLoading = false
that.$Message.success('提交成功!')
that.cancel()
that.getList()
}).catch(res => {
// 请求失败处理...
this.fullLoading = false
})
} else {
this.$Message.danger('表单验证失败!')
@ -422,6 +584,38 @@ export default {
addUser() {
this.modal = true
this.getDepartmentsList()
},
toBatchRemove(row) { // 批量删除
if (this.selections.length === 0) {
this.$Confirm.info({
title: '提示',
content: '请选中需要删除的人员。'
})
} else {
var ids = ''
for (let i = 0; i < this.selections.length; i++) {
ids += this.selections[i].id + ','
}
ids = ids.substring(0, ids.length - 1)
let confirm = {
title: '请确认',
content: '删除后不可恢复,确认删除吗?',
ok: () => {
this.fullLoading = true
this.$test.post(services.workEmployee.DEL_WORK_EMPLOYEE, {ids: ids}
).then(res => {
// 请求成功处理...
this.fullLoading = false
this.$Message.success('操作成功')
this.getList()
}).catch(res => {
// 请求失败处理...
this.fullLoading = false
})
}
}
this.$Confirm.confirm(confirm)
}
}
}
}