|
@@ -5,7 +5,6 @@ import { useQuery, useMutation } from '@tanstack/vue-query'
|
|
|
import { getRecordsDetail, editRecordsDetail } from '@/api/oa/staffRecords'
|
|
|
import { formConfigList, formRules } from './index'
|
|
|
import { FormInstance } from 'element-plus'
|
|
|
-import { staffNumFormatter } from '@/utils/formatter'
|
|
|
|
|
|
const { query } = useRoute()
|
|
|
const { id, type } = query
|
|
@@ -15,7 +14,7 @@ const formRef = ref<FormInstance>()
|
|
|
const formData = ref({})
|
|
|
|
|
|
/**获取员工档案详情 */
|
|
|
-const { data } = useQuery(
|
|
|
+useQuery(
|
|
|
['fetch-staff-detail', id],
|
|
|
async () => {
|
|
|
return await getRecordsDetail({ userId: id })
|
|
@@ -67,32 +66,33 @@ const submitForm = (formEl: FormInstance | undefined) => {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
-/**重置表单 */
|
|
|
-const resetForm = (formEl: FormInstance | undefined) => {
|
|
|
- if (!formEl) return
|
|
|
- formEl.resetFields()
|
|
|
- formData.value = data
|
|
|
-}
|
|
|
+const isEdit = computed(() => {
|
|
|
+ return type === 'edit'
|
|
|
+})
|
|
|
</script>
|
|
|
<template>
|
|
|
<div class="staff-files-wrap">
|
|
|
<div class="staff-name">
|
|
|
- <span>{{ formData?.nickname }}员工档案</span>
|
|
|
+ <span>{{ formData?.['nickname'] }}员工档案</span>
|
|
|
</div>
|
|
|
|
|
|
- <div class="my-portrait" v-if="formData != undefined">
|
|
|
+ <div
|
|
|
+ v-if="formData != undefined"
|
|
|
+ :class="isEdit ? 'my-portrait' : 'my-portrait form-unable-edit'"
|
|
|
+ >
|
|
|
<el-form
|
|
|
ref="formRef"
|
|
|
:model="formData"
|
|
|
:rules="formRules"
|
|
|
- label-width="120px"
|
|
|
- :disabled="type === 'view'"
|
|
|
+ label-width="150px"
|
|
|
+ :disabled="!isEdit"
|
|
|
>
|
|
|
<div class="my-portrait-item" v-for="(item, index) in formConfigList" :key="index">
|
|
|
<div class="title">
|
|
|
<i></i>
|
|
|
<span>{{ item.title }}</span>
|
|
|
</div>
|
|
|
+
|
|
|
<div class="my-portrait-card">
|
|
|
<ul>
|
|
|
<li v-for="(child, c) in item.children" :key="c">
|
|
@@ -101,24 +101,39 @@ const resetForm = (formEl: FormInstance | undefined) => {
|
|
|
v-if="child.type === 'time'"
|
|
|
v-model="formData[child?.name]"
|
|
|
style="width: 100%"
|
|
|
- :placeholder="child.title"
|
|
|
+ :placeholder="isEdit ? child.title : ''"
|
|
|
type="date"
|
|
|
value-format="YYYY-MM-DD"
|
|
|
/>
|
|
|
- <el-input v-else v-model="formData[child?.name]" placeholder="" />
|
|
|
+
|
|
|
+ <el-select
|
|
|
+ v-if="child.type === 'select'"
|
|
|
+ v-model="formData[child?.name]"
|
|
|
+ style="width: 100%"
|
|
|
+ placeholder=""
|
|
|
+ >
|
|
|
+ <el-option
|
|
|
+ v-for="item in child.options"
|
|
|
+ :key="item.value"
|
|
|
+ :label="item.label"
|
|
|
+ :value="item.value"
|
|
|
+ />
|
|
|
+ </el-select>
|
|
|
+
|
|
|
+ <el-input
|
|
|
+ v-if="child?.type === undefined"
|
|
|
+ v-model="formData[child?.name]"
|
|
|
+ placeholder=""
|
|
|
+ />
|
|
|
</el-form-item>
|
|
|
- <!-- :formatter="(value) => staffNumFormatter(value, child?.name)"
|
|
|
- -->
|
|
|
</li>
|
|
|
<li></li>
|
|
|
</ul>
|
|
|
</div>
|
|
|
</div>
|
|
|
-
|
|
|
- <el-row justify="center">
|
|
|
- <el-form-item v-if="type === 'edit'">
|
|
|
+ <el-row justify="end">
|
|
|
+ <el-form-item v-if="isEdit">
|
|
|
<el-button color="#1B80EB" type="primary" @click="submitForm(formRef)">保存</el-button>
|
|
|
- <el-button @click="resetForm(formRef)">重置</el-button>
|
|
|
</el-form-item>
|
|
|
</el-row>
|
|
|
</el-form>
|
|
@@ -149,7 +164,7 @@ const resetForm = (formEl: FormInstance | undefined) => {
|
|
|
.my-portrait {
|
|
|
width: 100%;
|
|
|
height: calc(100% - 40px);
|
|
|
- padding: 10px 0 0;
|
|
|
+ padding: 0 0 10px;
|
|
|
overflow: auto;
|
|
|
|
|
|
.my-portrait-item {
|
|
@@ -179,7 +194,7 @@ const resetForm = (formEl: FormInstance | undefined) => {
|
|
|
ul {
|
|
|
display: flex;
|
|
|
padding: 20px 40px 0;
|
|
|
- background-color: #f7f8fa;
|
|
|
+ background: #f7f8fa;
|
|
|
border-radius: 4px;
|
|
|
flex-wrap: wrap;
|
|
|
justify-content: space-between;
|
|
@@ -190,5 +205,41 @@ const resetForm = (formEl: FormInstance | undefined) => {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ .form-unable-edit {
|
|
|
+ .my-portrait-item {
|
|
|
+ ul {
|
|
|
+ background: linear-gradient(90deg, #f2f7ff 0%, rgb(245 249 255 / 0%) 100%);
|
|
|
+ border: 1px solid #e4e9f1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ :deep(.el-form) {
|
|
|
+ .el-input.is-disabled .el-input__wrapper {
|
|
|
+ background-color: unset;
|
|
|
+ box-shadow: none;
|
|
|
+ }
|
|
|
+
|
|
|
+ .el-form-item__label {
|
|
|
+ font-size: 16px;
|
|
|
+ color: #455773;
|
|
|
+ }
|
|
|
+
|
|
|
+ .el-form-item--default {
|
|
|
+ margin-bottom: 10px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .el-input__inner {
|
|
|
+ font-family: 'Microsoft YaHei';
|
|
|
+ font-size: 16px;
|
|
|
+ font-weight: 500;
|
|
|
+ color: #2d333c;
|
|
|
+ }
|
|
|
+
|
|
|
+ .el-input__suffix {
|
|
|
+ display: none;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
</style>
|