253 lines
6.6 KiB
Vue
253 lines
6.6 KiB
Vue
<template>
|
|
<div class="system-menu-container layout-padding">
|
|
<ProTable ref="tableRef" :request-api="projectPageGet" :columns="columns" :pagination="true"
|
|
:tool-button="false">
|
|
<template #tools>
|
|
<el-button v-auth="'project:add'" type="primary" icon="ele-Plus" @click="onOpenMenu"> 新增 </el-button>
|
|
</template>
|
|
<template #index="scope">
|
|
{{ scope.$index + 1 }}
|
|
</template>
|
|
|
|
<template #projectTypeId="scope">
|
|
{{ scope.row.projectTypeName }}
|
|
</template>
|
|
|
|
<template #action="scope">
|
|
<el-button v-auth="'project:edit'" icon="ele-Edit" size="small" text type="primary"
|
|
@click="onOpenMenu(scope.row.id)"> 编辑 </el-button>
|
|
<el-popconfirm title="确认删除吗?" @confirm="onDeleteMenu(scope.row.id)">
|
|
<template #reference>
|
|
<el-button v-auth="'project:delete'" icon="ele-Delete" size="small" text type="danger"> 删除
|
|
</el-button>
|
|
</template>
|
|
</el-popconfirm>
|
|
|
|
<el-button v-auth="'project:detail'" size="small" text type="primary" @click="onOpenMenu(scope.row.id)">
|
|
查看详情 </el-button>
|
|
</template>
|
|
</ProTable>
|
|
|
|
<!-- 弹窗 -->
|
|
<el-dialog title="新增" v-model="isShowDialog" width="60%">
|
|
<el-form ref="formRef" :model="formData" :rules="formRules" label-width="150px"
|
|
style="width: 70%;margin-bottom: 30px;" v-if="isShowDialog">
|
|
|
|
<!-- 项目名称 -->
|
|
<el-form-item label="项目名称:" prop="name">
|
|
<el-input v-model="formData.name" placeholder="请输入项目名称"></el-input>
|
|
</el-form-item>
|
|
|
|
<!-- 项目类型 -->
|
|
<el-form-item label="项目类型:" prop="projectTypeId">
|
|
<el-select v-model="formData.projectTypeId" placeholder="请选择项目类型" style="width: 100%;">
|
|
<el-option label="个人速度" value="1003"></el-option>
|
|
<el-option label="个人花样" value="1004"></el-option>
|
|
<el-option label="团队速度" value="1001"></el-option>
|
|
<el-option label="团队花样" value="1002"></el-option>
|
|
</el-select>
|
|
</el-form-item>
|
|
|
|
<!-- 完成人数 -->
|
|
<el-form-item label="完成人数:" prop="completionCount" v-if="formData.projectTypeId == 1001 || formData.projectTypeId == 1002">
|
|
<el-input v-model="formData.completionCount" placeholder="请输入完成人数"></el-input>
|
|
</el-form-item>
|
|
|
|
<!-- 费用 -->
|
|
<el-form-item label="费用:" prop="fee">
|
|
<el-input v-model="formData.fee" placeholder="请输入费用" class="fee-input">
|
|
<template slot="append">元</template>
|
|
</el-input>
|
|
</el-form-item>
|
|
|
|
<!-- 时长 -->
|
|
<el-form-item label="时长:" prop="duration">
|
|
<div class="duration-row">
|
|
<el-input v-model="formData.durationMinutes" placeholder="分"></el-input>
|
|
<span class="duration-label">分</span>
|
|
<span class="duration-separator">--</span>
|
|
<el-input v-model="formData.durationSeconds" placeholder="秒" value="30"></el-input>
|
|
<span class="duration-label">秒</span>
|
|
</div>
|
|
</el-form-item>
|
|
|
|
</el-form>
|
|
<template #footer>
|
|
<span class="dialog-footer">
|
|
<el-button @click="onCancel">取消</el-button>
|
|
<el-button type="primary" @click="onSubmit">确定</el-button>
|
|
</span>
|
|
</template>
|
|
</el-dialog>
|
|
</div>
|
|
</template>
|
|
|
|
<script setup name="project">
|
|
import { defineAsyncComponent, ref, reactive } from 'vue';
|
|
import { ElMessage, ElForm } from 'element-plus';
|
|
import SysMenuApi from '/@/api/SysMenuApi';
|
|
import { auths } from '/@/utils/authFunction';
|
|
import ProTable from '/@/components/ProTable/index.vue';
|
|
import { projectPageGet, projectAddPost ,projectEditPut ,projectDeleteDelete} from '/@/api/match/project';
|
|
|
|
|
|
|
|
// 定义表单引用类型
|
|
const formRef = ref();
|
|
|
|
const formData = ref({
|
|
name: '',
|
|
projectTypeId: '',
|
|
completionCount: '',
|
|
fee: '',
|
|
durationMinutes: '0',
|
|
durationSeconds: '0'
|
|
})
|
|
|
|
const formRules = ref({
|
|
name: [
|
|
{ required: true, message: '请输入项目名称', trigger: 'blur' }
|
|
],
|
|
projectTypeId: [
|
|
{ required: true, message: '请选择项目类型', trigger: 'change' }
|
|
],
|
|
completionCount: [
|
|
{ required: true, message: '请输入完成人数', trigger: 'blur' }
|
|
],
|
|
description: [
|
|
{ required: true, message: '请输入项目描述', trigger: 'blur' }
|
|
],
|
|
fee: [
|
|
{ required: true, message: '请输入费用', trigger: 'blur' }
|
|
],
|
|
durationMinutes: [
|
|
{ required: true, message: '请输入时长(分)', trigger: 'blur' }
|
|
],
|
|
durationSeconds: [
|
|
{ required: true, message: '请输入时长(秒)', trigger: 'blur' }
|
|
]
|
|
});
|
|
|
|
const columns = ref([
|
|
{
|
|
prop: 'index',
|
|
label: '序号',
|
|
align: 'center',
|
|
},
|
|
{
|
|
prop: 'name',
|
|
label: '项目名称',
|
|
align: 'center',
|
|
search: {
|
|
el: 'input',
|
|
},
|
|
},
|
|
{
|
|
prop: 'projectTypeId',
|
|
label: '项目类型',
|
|
search: {
|
|
el: 'select',
|
|
},
|
|
enum: [
|
|
{ label: '全部', value: 0 },
|
|
{ label: '团队速度', value: 1001 },
|
|
{ label: '团队花样', value: 1002 },
|
|
{ label: '个人速度', value: 1003 },
|
|
{ label: '个人花样', value: 1004 },
|
|
],
|
|
},
|
|
{
|
|
prop: 'completionCount',
|
|
label: '完成人数',
|
|
},
|
|
|
|
{ prop: 'fee', label: '费用(元)' },
|
|
|
|
{ prop: 'action', label: '操作', align: 'center', fixed: 'right', isShow: auths(['project:delete', 'project:edit', 'project:add']) },
|
|
]);
|
|
|
|
const isShowDialog = ref(false);
|
|
const dialogTitle = ref('新增');
|
|
|
|
const onOpenMenu = (id) => {
|
|
dialogTitle.value = id ? '编辑' : '新增';
|
|
formData.value = {
|
|
projectName: '',
|
|
projectTypeId: '',
|
|
completionCount: '',
|
|
description: '',
|
|
fee: '',
|
|
durationMinutes: '',
|
|
durationSeconds: ''
|
|
};
|
|
isShowDialog.value = true;
|
|
};
|
|
|
|
//删除菜单
|
|
const onDeleteMenu = async (id) => {
|
|
const { succeeded, errors } = await merchantDeleteDelete({ id });
|
|
if (succeeded) {
|
|
ElMessage.success('删除成功');
|
|
} else {
|
|
ElMessage.error(errors);
|
|
}
|
|
};
|
|
|
|
// 表单提交
|
|
const onSubmit = () => {
|
|
if (!formRef.value) return;
|
|
|
|
formRef.value.validate(async (valid) => {
|
|
if (!valid) return;
|
|
|
|
try {
|
|
let res;
|
|
if (formData.value.id) {
|
|
res = await projectEditPut(formData.value);
|
|
} else {
|
|
res = await projectAddPost(formData.value);
|
|
}
|
|
|
|
if (res.succeeded) {
|
|
ElMessage.success(dialogTitle.value + '成功');
|
|
isShowDialog.value = false;
|
|
} else {
|
|
ElMessage.error(res.errors);
|
|
}
|
|
} catch (error) {
|
|
console.error(error);
|
|
}
|
|
});
|
|
};
|
|
|
|
// 取消
|
|
const onCancel = () => {
|
|
isShowDialog.value = false;
|
|
};
|
|
</script>
|
|
<style scoped lang="scss">
|
|
.dialog-footer {
|
|
margin-top: 80px;
|
|
}
|
|
|
|
/* 时长组合框样式 */
|
|
.duration-row {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 8px;
|
|
}
|
|
|
|
.duration-row .el-input {
|
|
width: 120px;
|
|
}
|
|
|
|
.duration-separator {
|
|
color: #606266;
|
|
font-size: 14px;
|
|
}
|
|
|
|
.duration-label {
|
|
color: #909399;
|
|
font-size: 14px;
|
|
}
|
|
</style> |