2025008071805
This commit is contained in:
parent
9b23266010
commit
514248dae7
|
|
@ -0,0 +1,321 @@
|
|||
<template>
|
||||
<el-dialog
|
||||
:title="title"
|
||||
:visible.sync="visible"
|
||||
width="800px"
|
||||
append-to-body
|
||||
:close-on-click-modal="false"
|
||||
:close-on-press-escape="false"
|
||||
>
|
||||
<el-form ref="form" :model="form" :rules="rules" label-width="120px">
|
||||
<el-row :gutter="20">
|
||||
<el-col :span="12">
|
||||
<el-form-item label="申请ID" prop="id">
|
||||
<el-input v-model="form.id" disabled />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="申请状态" prop="status">
|
||||
<el-select v-model="form.status" placeholder="请选择审核状态" style="width: 100%">
|
||||
<el-option
|
||||
v-for="dict in dict.type.worker_apply_status"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
:value="dict.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
<el-row :gutter="20">
|
||||
<el-col :span="12">
|
||||
<el-form-item label="用户姓名" prop="name">
|
||||
<el-input v-model="form.name" disabled />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="联系电话" prop="phone">
|
||||
<el-input v-model="form.phone" disabled />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
<el-row :gutter="20">
|
||||
<el-col :span="12">
|
||||
<el-form-item label="申请地区" prop="address">
|
||||
<el-input v-model="form.address" disabled />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="申请时间" prop="createdAt">
|
||||
<el-input v-model="form.createdAt" disabled />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
<el-form-item label="申请技能" prop="skillId">
|
||||
<div v-if="form.skillId && form.skillId !== '' && isSkillListReady">
|
||||
<el-tag
|
||||
v-for="(skillId, index) in parseSkillIds(form.skillId)"
|
||||
:key="`skill-${form.id}-${index}`"
|
||||
size="medium"
|
||||
type="success"
|
||||
style="margin: 5px;"
|
||||
>
|
||||
{{ getSkillName(skillId) }}
|
||||
</el-tag>
|
||||
</div>
|
||||
<span v-else-if="!isSkillListReady">加载中...</span>
|
||||
<span v-else>-</span>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item v-if="!readonly" label="审核备注" prop="auditRemark">
|
||||
<el-input
|
||||
v-model="form.auditRemark"
|
||||
type="textarea"
|
||||
:rows="3"
|
||||
placeholder="请输入审核备注信息"
|
||||
maxlength="500"
|
||||
show-word-limit
|
||||
/>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item v-if="!readonly" label="审核结果" prop="auditResult">
|
||||
<el-radio-group v-model="form.auditResult">
|
||||
<el-radio label="pass">通过</el-radio>
|
||||
<el-radio label="reject">拒绝</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button @click="handleCancel">{{ readonly ? '关闭' : '取 消' }}</el-button>
|
||||
<el-button v-if="!readonly" type="primary" @click="handleSubmit" :loading="submitLoading">确 定</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { getSiteSkillList } from "@/api/system/SiteSkill"
|
||||
|
||||
export default {
|
||||
name: "WorkerApplyAudit",
|
||||
dicts: ['worker_apply_status'],
|
||||
props: {
|
||||
visible: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
title: {
|
||||
type: String,
|
||||
default: "审核师傅申请"
|
||||
},
|
||||
data: {
|
||||
type: Object,
|
||||
default: () => ({})
|
||||
},
|
||||
readonly: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
form: {},
|
||||
rules: {
|
||||
status: [
|
||||
{ required: true, message: "请选择审核状态", trigger: "change" }
|
||||
],
|
||||
auditResult: [
|
||||
{ required: true, message: "请选择审核结果", trigger: "change" }
|
||||
]
|
||||
},
|
||||
submitLoading: false,
|
||||
skillList: [],
|
||||
skillNameCache: {}
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
isSkillListReady() {
|
||||
return this.skillList.length > 0;
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
visible(val) {
|
||||
if (val) {
|
||||
this.loadSkillList();
|
||||
this.initForm();
|
||||
}
|
||||
},
|
||||
data: {
|
||||
handler(val) {
|
||||
if (val) {
|
||||
this.form = { ...val };
|
||||
// 设置默认审核状态为待审核
|
||||
if (!this.form.status) {
|
||||
this.form.status = "0"; // 假设0是待审核状态
|
||||
}
|
||||
// 设置默认审核结果
|
||||
this.form.auditResult = "pass";
|
||||
// 格式化申请时间
|
||||
if (this.form.createdAt) {
|
||||
this.form.createdAt = this.parseTime(this.form.createdAt, '{y}-{m}-{d} {h}:{i}:{s}');
|
||||
}
|
||||
}
|
||||
},
|
||||
immediate: true
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
// 初始化表单
|
||||
initForm() {
|
||||
this.form = {
|
||||
...this.data,
|
||||
auditRemark: "",
|
||||
auditResult: "pass"
|
||||
};
|
||||
if (!this.form.status) {
|
||||
this.form.status = "0";
|
||||
}
|
||||
if (this.form.createdAt) {
|
||||
this.form.createdAt = this.parseTime(this.form.createdAt, '{y}-{m}-{d} {h}:{i}:{s}');
|
||||
}
|
||||
},
|
||||
|
||||
// 加载技能列表
|
||||
loadSkillList() {
|
||||
if (this.skillList.length > 0) return;
|
||||
|
||||
getSiteSkillList().then(response => {
|
||||
if (response.code === 200) {
|
||||
this.skillList = response.data || [];
|
||||
this.updateSkillNameCache();
|
||||
}
|
||||
}).catch((error) => {
|
||||
console.error('获取技能列表异常:', error);
|
||||
this.useDefaultSkillList();
|
||||
});
|
||||
},
|
||||
|
||||
// 使用默认技能列表
|
||||
useDefaultSkillList() {
|
||||
this.skillList = [
|
||||
{ id: 1, title: '水电工' },
|
||||
{ id: 2, title: '油工师傅' },
|
||||
{ id: 3, title: '改造维修' },
|
||||
{ id: 4, title: '工程施工' }
|
||||
];
|
||||
this.updateSkillNameCache();
|
||||
},
|
||||
|
||||
// 更新技能名称缓存
|
||||
updateSkillNameCache() {
|
||||
this.skillNameCache = {};
|
||||
this.skillList.forEach(skill => {
|
||||
this.skillNameCache[skill.id] = skill.title;
|
||||
});
|
||||
},
|
||||
|
||||
// 解析技能ID数组
|
||||
parseSkillIds(skillIdData) {
|
||||
if (!skillIdData) return [];
|
||||
|
||||
try {
|
||||
if (typeof skillIdData === 'string') {
|
||||
if (skillIdData.startsWith('[') && skillIdData.endsWith(']')) {
|
||||
const parsed = JSON.parse(skillIdData);
|
||||
return Array.isArray(parsed) ? parsed : [];
|
||||
}
|
||||
return skillIdData.split(',').filter(id => id.trim());
|
||||
}
|
||||
|
||||
if (Array.isArray(skillIdData)) {
|
||||
return skillIdData;
|
||||
}
|
||||
|
||||
return [];
|
||||
} catch (error) {
|
||||
console.error('解析技能ID失败:', error, '原始数据:', skillIdData);
|
||||
if (typeof skillIdData === 'string') {
|
||||
return skillIdData.split(',').filter(id => id.trim());
|
||||
}
|
||||
return [];
|
||||
}
|
||||
},
|
||||
|
||||
// 获取技能名称
|
||||
getSkillName(skillId) {
|
||||
if (!skillId) return '-';
|
||||
const id = String(skillId).trim();
|
||||
if (!id) return '-';
|
||||
|
||||
let skillName = this.skillNameCache[id];
|
||||
|
||||
if (!skillName && this.skillList.length > 0) {
|
||||
const skill = this.skillList.find(s => String(s.id) === id);
|
||||
if (skill) {
|
||||
this.skillNameCache[id] = skill.title;
|
||||
skillName = skill.title;
|
||||
}
|
||||
}
|
||||
|
||||
if (!skillName) {
|
||||
return `未知技能(${id})`;
|
||||
}
|
||||
return skillName;
|
||||
},
|
||||
|
||||
// 取消按钮
|
||||
handleCancel() {
|
||||
this.$emit('update:visible', false);
|
||||
},
|
||||
|
||||
// 提交审核
|
||||
handleSubmit() {
|
||||
this.$refs["form"].validate((valid) => {
|
||||
if (valid) {
|
||||
this.submitLoading = true;
|
||||
|
||||
// 根据审核结果设置状态
|
||||
if (this.form.auditResult === 'pass') {
|
||||
this.form.status = "1"; // 假设1是通过状态
|
||||
} else if (this.form.auditResult === 'reject') {
|
||||
this.form.status = "2"; // 假设2是拒绝状态
|
||||
}
|
||||
|
||||
// 发送审核结果
|
||||
this.$emit('confirm', this.form);
|
||||
this.submitLoading = false;
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
// 时间格式化
|
||||
parseTime(time, format) {
|
||||
if (!time) return '';
|
||||
const date = new Date(time);
|
||||
const year = date.getFullYear();
|
||||
const month = String(date.getMonth() + 1).padStart(2, '0');
|
||||
const day = String(date.getDate()).padStart(2, '0');
|
||||
const hours = String(date.getHours()).padStart(2, '0');
|
||||
const minutes = String(date.getMinutes()).padStart(2, '0');
|
||||
const seconds = String(date.getSeconds()).padStart(2, '0');
|
||||
|
||||
return format
|
||||
.replace('{y}', year)
|
||||
.replace('{m}', month)
|
||||
.replace('{d}', day)
|
||||
.replace('{h}', hours)
|
||||
.replace('{i}', minutes)
|
||||
.replace('{s}', seconds);
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.dialog-footer {
|
||||
text-align: right;
|
||||
}
|
||||
</style>
|
||||
|
|
@ -0,0 +1,145 @@
|
|||
<template>
|
||||
<el-dialog
|
||||
title="批量审核师傅申请"
|
||||
:visible.sync="visible"
|
||||
width="600px"
|
||||
append-to-body
|
||||
:close-on-click-modal="false"
|
||||
:close-on-press-escape="false"
|
||||
>
|
||||
<el-form ref="form" :model="form" :rules="rules" label-width="120px">
|
||||
<el-form-item label="审核记录数">
|
||||
<el-input :value="recordCount" disabled />
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="审核状态" prop="status">
|
||||
<el-select v-model="form.status" placeholder="请选择审核状态" style="width: 100%">
|
||||
<el-option
|
||||
v-for="dict in dict.type.worker_apply_status"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
:value="dict.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="审核结果" prop="auditResult">
|
||||
<el-radio-group v-model="form.auditResult">
|
||||
<el-radio label="pass">通过</el-radio>
|
||||
<el-radio label="reject">拒绝</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="审核备注" prop="auditRemark">
|
||||
<el-input
|
||||
v-model="form.auditRemark"
|
||||
type="textarea"
|
||||
:rows="3"
|
||||
placeholder="请输入批量审核备注信息"
|
||||
maxlength="500"
|
||||
show-word-limit
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button @click="handleCancel">取 消</el-button>
|
||||
<el-button type="primary" @click="handleSubmit" :loading="submitLoading">确 定</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: "WorkerApplyBatchAudit",
|
||||
dicts: ['worker_apply_status'],
|
||||
props: {
|
||||
visible: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
recordIds: {
|
||||
type: Array,
|
||||
default: () => []
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
form: {
|
||||
status: "",
|
||||
auditResult: "pass",
|
||||
auditRemark: ""
|
||||
},
|
||||
rules: {
|
||||
status: [
|
||||
{ required: true, message: "请选择审核状态", trigger: "change" }
|
||||
],
|
||||
auditResult: [
|
||||
{ required: true, message: "请选择审核结果", trigger: "change" }
|
||||
]
|
||||
},
|
||||
submitLoading: false
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
recordCount() {
|
||||
return this.recordIds.length;
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
visible(val) {
|
||||
if (val) {
|
||||
this.initForm();
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
// 初始化表单
|
||||
initForm() {
|
||||
this.form = {
|
||||
status: "",
|
||||
auditResult: "pass",
|
||||
auditRemark: ""
|
||||
};
|
||||
},
|
||||
|
||||
// 取消按钮
|
||||
handleCancel() {
|
||||
this.$emit('update:visible', false);
|
||||
},
|
||||
|
||||
// 提交审核
|
||||
handleSubmit() {
|
||||
this.$refs["form"].validate((valid) => {
|
||||
if (valid) {
|
||||
this.submitLoading = true;
|
||||
|
||||
// 根据审核结果设置状态
|
||||
if (this.form.auditResult === 'pass') {
|
||||
this.form.status = "1"; // 假设1是通过状态
|
||||
} else if (this.form.auditResult === 'reject') {
|
||||
this.form.status = "2"; // 假设2是拒绝状态
|
||||
}
|
||||
|
||||
// 准备批量审核数据
|
||||
const auditData = {
|
||||
ids: this.recordIds,
|
||||
status: this.form.status,
|
||||
auditRemark: this.form.auditRemark
|
||||
};
|
||||
|
||||
// 发送审核结果
|
||||
this.$emit('confirm', auditData);
|
||||
this.submitLoading = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.dialog-footer {
|
||||
text-align: right;
|
||||
}
|
||||
</style>
|
||||
Loading…
Reference in New Issue