访客模块待完成
This commit is contained in:
182
src/views/system/Repair/addRepairlist.vue
Normal file
182
src/views/system/Repair/addRepairlist.vue
Normal file
@@ -0,0 +1,182 @@
|
||||
<template>
|
||||
<div class="AddBuildingBox">
|
||||
<PageHeader :title="userid ? '编辑车辆信息' : '添加车辆信息'"></PageHeader>
|
||||
<div class="AddBuildingBody">
|
||||
<div class="title">基本信息</div>
|
||||
<div class="addBuildingFormBody">
|
||||
<el-form class="formBody" label-position="right" ref="formRef" :model="form" :rules="rules" label-width="130px">
|
||||
<el-row>
|
||||
<el-col :span="11">
|
||||
<el-form-item label="维修项目名" prop="projectName">
|
||||
<el-input v-model.trim="form.projectName" placeholder="请输入维修项目名" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="2"></el-col>
|
||||
<el-col :span="11">
|
||||
<el-form-item label="项目类型" prop="projectType">
|
||||
<el-radio-group v-model="form.projectType">
|
||||
<el-radio v-for="item in com_repair_project_types" :key="item.id" :value="item.value">{{ item.label }}</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row>
|
||||
<el-col :span="11">
|
||||
<el-form-item label="项目层级" prop="projectLevel">
|
||||
<el-radio-group v-model="form.projectLevel">
|
||||
<el-radio v-for="item in com_repair_project_level" :key="item.id" :value="item.value">{{ item.label }}</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="2"></el-col>
|
||||
<el-col :span="11">
|
||||
<el-form-item label="项目状态" prop="status">
|
||||
<el-radio-group v-model="form.status">
|
||||
<el-radio v-for="item in com_repair_project_status" :key="item.id" :value="item.value">{{ item.label }}</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row v-if="form.projectLevel === '1'">
|
||||
<el-col :span="11">
|
||||
<el-form-item label="隶属父级" prop="email">
|
||||
<el-select v-model="form.parentId" placeholder="请选择隶属父级" style="width: 240px">
|
||||
<el-option v-for="item in options" :key="item.id" :label="item.projectName" :value="item.id" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-form-item style="margin-top: 30px">
|
||||
<el-button type="primary" @click="submitForm">提交</el-button>
|
||||
<el-button @click="cancelForm">返回</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue';
|
||||
import PageHeader from '@/components/Pageheader/index.vue';
|
||||
import { addRepairProject, listRepairProject, updateRepairProject } from '@/api/system/RepairProject';
|
||||
import { buildTreeByLevel } from '@/utils';
|
||||
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
|
||||
const { com_repair_project_types } = toRefs<any>(proxy?.useDict('com_repair_project_types'));
|
||||
const { com_repair_project_status } = toRefs<any>(proxy?.useDict('com_repair_project_status'));
|
||||
const { com_repair_project_level } = toRefs<any>(proxy?.useDict('com_repair_project_level'));
|
||||
|
||||
const router = useRouter();
|
||||
const route = useRoute();
|
||||
|
||||
const formRef = ref();
|
||||
const form = ref({
|
||||
id: null,
|
||||
projectName: null, // 项目名称
|
||||
parentId: '', // 父级项目id
|
||||
projectType: '0', // 项目类型
|
||||
projectLevel: '0', //项目层级
|
||||
status: '0' //状态
|
||||
});
|
||||
const rules = ref({
|
||||
projectName: [{ required: true, message: '请选择房屋', trigger: 'blur' }],
|
||||
parentId: [{ required: true, message: '请选择房屋', trigger: 'blur' }],
|
||||
projectType: [{ required: true, message: '请选择房屋', trigger: 'blur' }],
|
||||
projectLevel: [{ required: true, message: '请选择房屋', trigger: 'blur' }],
|
||||
status: [{ required: true, message: '请输入名称', trigger: 'blur' }]
|
||||
});
|
||||
const userid = ref(null);
|
||||
const options = ref([]);
|
||||
// != ==========================================
|
||||
|
||||
function init() {
|
||||
listRepairProject({ pageSize: 999999999, pageNum: 1 }).then((res) => {
|
||||
const arr = res.rows.filter((ite) => ite.projectLevel === 0);
|
||||
options.value = arr;
|
||||
if (route.query.id) {
|
||||
userid.value = route.query.id;
|
||||
const find = res.rows.find((item) => item.id === userid.value);
|
||||
if (find) {
|
||||
form.value = {
|
||||
...form.value,
|
||||
...find,
|
||||
projectLevel: String(find.projectLevel)
|
||||
};
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
init();
|
||||
// !== 提交 =============================================================================
|
||||
// 提交
|
||||
const submitForm = () => {
|
||||
formRef.value?.validate(async (valid: boolean) => {
|
||||
if (valid) {
|
||||
console.log(form.value);
|
||||
if (!userid.value) {
|
||||
addRepairProject(form.value).then(() => {
|
||||
ElMessage.success('添加成功');
|
||||
cancelForm();
|
||||
});
|
||||
} else {
|
||||
updateRepairProject(form.value).then(() => {
|
||||
ElMessage.success('编辑成功');
|
||||
cancelForm();
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
// 推出
|
||||
const cancelForm = () => {
|
||||
router.push({
|
||||
path: '/repair/repairProjectList'
|
||||
});
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.AddBuildingBox {
|
||||
padding: 15px;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
}
|
||||
.AddBuildingBody {
|
||||
margin-top: 20px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
background-color: white;
|
||||
padding: 15px;
|
||||
.title {
|
||||
height: 40px;
|
||||
line-height: 40px;
|
||||
padding-left: 20px;
|
||||
background-color: rgba(255, 255, 255, 1);
|
||||
color: rgba(16, 16, 16, 1);
|
||||
border-bottom: 1px solid #bbbbbb;
|
||||
margin-bottom: 60px;
|
||||
}
|
||||
|
||||
.formBody {
|
||||
width: 1050px;
|
||||
margin: 0 auto;
|
||||
&:deep(.el-form-item__content, .el-select, .el-input) {
|
||||
width: 350px !important;
|
||||
margin-right: 10px;
|
||||
.el-cascader {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
.el-form-item {
|
||||
margin-bottom: 20px;
|
||||
align-items: center;
|
||||
}
|
||||
.el-button {
|
||||
width: 80px;
|
||||
height: 35px;
|
||||
margin-right: 20px;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user