运维管理平台前端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

185 lines
5.1 KiB

3 months ago
<template>
<PageWrapper dense>
<BasicTable @register="registerTable">
<template #toolbar>
<a-button type="primary" @click="handleAdd">新增</a-button>
2 months ago
<!-- <a-button type="primary" @click="addWorker">配置人员</a-button> -->
<a-button type="primary" @click="addService">配置服务目录</a-button>
3 months ago
</template>
<template #bodyCell="{ column, record }">
<template v-if="column && record && column.key === 'action'">
<a-button type="link" @click="handleEdit(record.id)">编辑</a-button>
<a-popconfirm
title="确定要删除吗?"
ok-text="是"
cancel-text="否"
@confirm="handleDelete(record.id)"
>
<a-button type="link">删除</a-button>
</a-popconfirm>
<a-button type="link" @click="handleDetail(record.id)">详情</a-button>
3 months ago
</template>
</template>
</BasicTable>
2 months ago
<a-modal
v-model:open="serviceVisible"
title="服务目录配置"
@ok="serviceSubmit"
@cancel="closeService"
width="30%"
>
<a-form :model="serviceForm" layout="vertical" :rules="serviceRules" ref="serviceRef">
<a-row :gutter="[16, 16]">
<a-col :span="24">
<a-form-item label="合同名称" name="contractId">
<a-select
v-model:value="serviceForm.contractId"
:options="contractOptions"
placeholder="请选择"
:fieldNames="{
value: 'id',
label: 'contractName',
options: 'options',
}"
/>
</a-form-item>
</a-col>
</a-row>
<a-row>
<a-col :span="24">
<a-form-item label="目录名称" name="categoryId">
<a-select
v-model:value="serviceForm.categoryId"
:options="categoryOptions"
placeholder="请选择"
:fieldNames="{
value: 'id',
label: 'categoryName',
options: 'options',
}"
/>
</a-form-item>
</a-col>
</a-row>
</a-form>
</a-modal>
3 months ago
<detailDrawer ref="detailDrawerRef" />
<addModal ref="addModalRef" />
</PageWrapper>
</template>
<script setup lang="ts">
import { PageWrapper } from '@/components/Page';
import { BasicTable, useTable } from '@/components/Table';
2 months ago
import { list, removeByIds, createPlans, getCategory } from './api';
3 months ago
import { formSchemas, columns } from './data';
import detailDrawer from './detailDrawer.vue';
2 months ago
import { ref, reactive } from 'vue';
3 months ago
import addModal from './addModal.vue';
2 months ago
import { message } from 'ant-design-vue';
3 months ago
defineOptions({ name: 'ContractManage' });
const [registerTable, { reload }] = useTable({
3 months ago
rowSelection: {
type: 'checkbox',
},
title: '合同管理',
api: list,
showIndexColumn: true,
rowKey: 'id',
useSearchForm: true,
formConfig: {
schemas: formSchemas,
name: 'contractManage',
baseColProps: {
xs: 24,
sm: 24,
md: 24,
lg: 6,
},
},
columns: columns,
actionColumn: {
width: 200,
title: '操作',
key: 'action',
fixed: 'right',
},
});
//抽屉
const detailDrawerRef = ref();
const handleDetail = (id: any) => {
detailDrawerRef.value.showDrawer(id);
};
const handleDelete = async (id: any) => {
await removeByIds([id]);
reload();
3 months ago
};
//新增编辑弹窗
const addModalRef = ref();
const handleAdd = () => {
addModalRef.value.showModal(1);
};
const handleEdit = (id: any) => {
addModalRef.value.showModal(2, id);
};
2 months ago
//服务配置弹窗
let serviceForm = reactive({
contractId: '',
categoryId: '',
});
const serviceVisible = ref(false);
const serviceRef = ref();
const serviceSubmit = () => {
serviceRef.value.validate().then((valid: any) => {
if (valid) {
let params = {
contractId: serviceForm.contractId,
categoryId: serviceForm.categoryId,
};
createPlans(params).then((_) => {
message.success('操作成功');
closeService();
});
}
});
};
const serviceRules = {
contractId: [{ required: true, message: '请选择' }],
categoryId: [{ required: true, message: '请选择' }],
};
const addService = () => {
serviceVisible.value = true;
getOptions();
};
const closeService = () => {
serviceVisible.value = false;
serviceForm = {
contractId: '',
categoryId: '',
};
};
const contractOptions = ref([]);
const getContractOptions = () => {
list({ pageNum: 1, pageSize: 100 }).then((res) => {
contractOptions.value = res.rows;
});
};
const categoryOptions = ref([]);
const getCategoryOptions = () => {
getCategory().then((res) => {
categoryOptions.value = res;
});
};
const getOptions = () => {
getCategoryOptions();
getContractOptions();
};
3 months ago
</script>
<style scoped></style>