| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259 |
- <template>
- <div class="table-demo">
- <bs-table v-bind="tableOptions">
- <template #searchRight>
- <a-space>
- <a-button type="primary" @click="goDetailPage">
- <template #icon>
- <PlusOutlined />
- </template>
- <span>新增</span>
- </a-button>
- </a-space>
- </template>
- </bs-table>
- </div>
- </template>
- <script setup lang="jsx">
- import BsTable, { useBsTable } from '/@/components/BsUi/Table/index.js';
- import { onMounted, ref, watch } from 'vue';
- import { useRouter } from 'vue-router';
- const props = defineProps({
- selectedRulesId: String,
- });
- const {
- tableOptions,
- fetchTableData,
- setTablePropsValue: setValue,
- getTablePropsValue: getValue,
- } = useBsTable({
- tableOptions: {
- url: '/supports/risk/rule/queryPage',
- gridOptions: {
- loading: false,
- columns: [
- {
- type: 'seq',
- width: 80,
- align: 'center',
- },
- {
- title: '风险维度',
- field: 'riskDimension',
- width: 85,
- ellipsis: true,
- formatter: ({ cellValue }) => {
- return cellValue && cellValue.length > 0 ? cellValue[0].valueName : '';
- },
- },
- {
- title: '风险模板',
- // field: 'riskModel',
- width: 85,
- ellipsis: true,
- slots: {
- default({ row, column }) {
- return <span>{row?.riskModel?.[0].valueName}</span>;
- },
- },
- },
- {
- title: '风险等级',
- field: 'riskLevel',
- width: 85,
- ellipsis: true,
- slots: {
- default({ row, column }) {
- return <span>{row?.riskLevel?.[0].valueName}</span>;
- },
- },
- },
- {
- title: '风险指标',
- field: 'riskMetrics',
- width: 110,
- ellipsis: true,
- },
- {
- title: '指标定义',
- field: 'definedMetrics',
- width: 100,
- ellipsis: true,
- },
- {
- title: '条件运算符',
- field: 'operator',
- width: 100,
- ellipsis: true,
- slots: {
- default({ row, column }) {
- return <span>{row?.operator?.[0].valueName}</span>;
- },
- },
- },
- {
- title: '条件控制值',
- field: 'conditionalValue',
- width: 100,
- ellipsis: true,
- },
- {
- title: '提醒方式',
- field: 'remindWay',
- width: 100,
- ellipsis: true,
- slots: {
- default({ row, column }) {
- return <span>{row?.remindWay?.[0].valueName}</span>;
- },
- },
- },
- {
- title: '提醒时间(每天)',
- field: 'remindTime',
- width: 120,
- ellipsis: true,
- },
- {
- title: '风险等级',
- field: 'riskGrade',
- width: 100,
- ellipsis: true,
- slots: {
- default({ row, column }) {
- return <span>{row?.riskGrade?.[0].valueName}</span>;
- },
- },
- },
- {
- title: '状态',
- field: 'enable',
- width: 100,
- ellipsis: true,
- // formatter: (cellValue) => {
- // return cellValue === 'true' ? '启用' : '禁用';
- // },
- slots: {
- default({ row, column }) {
- return <span>{row.enable === 'true' ? '启用' : '禁用'}</span>;
- },
- },
- },
- {
- field: 'opt',
- title: '操作',
- width: '120px',
- fixed: 'right',
- align: 'center',
- slots: {
- default({ row, column }) {
- return (
- <a-button
- type='text'
- size='small'
- onClick={() => {
- goDetailPage(row);
- }}
- >
- 编辑
- </a-button>
- );
- },
- },
- },
- ],
- data: [
- {
- id: 1,
- name: '测试数据',
- dictField: [
- {
- dictKeyId: '',
- dictValueId: '',
- remark: '',
- sort: 3,
- status: 1,
- valueCode: '03',
- valueName: '微信公众号',
- },
- ],
- },
- ], // 模拟数据源
- },
- searchConfig: {
- enabled: true,
- fieldSpan: 6,
- fields: [
- {
- field: 'name',
- label: '',
- component: 'a-input',
- componentProps: {
- placeholder: '请输入服务商名称',
- },
- },
- {
- field: 'name1',
- label: '',
- component: 'a-select',
- componentProps: {
- placeholder: '请选择地址',
- },
- },
- {
- field: 'name2',
- label: '',
- component: 'a-select',
- componentProps: {
- placeholder: '请选择服务商类型',
- },
- },
- ],
- },
- pagerConfig: {
- enabled: true,
- pageSize: 10,
- pageNum: 1,
- },
- toolbarConfig: {},
- tableSearchBeforeBiz() {
- const searchParams = getValue('searchConfig.data');
- setValue('searchConfig.data', { ...searchParams, key: props.selectedRulesId });
- },
- },
- });
- // 监听 selectedRulesId 的变化
- watch(
- () => props.selectedRulesId,
- (newVal, oldVal) => {
- if (newVal !== oldVal) {
- fetchTableData(newVal);
- }
- },
- { immediate: true }
- );
- onMounted(() => {
- console.log('表格已加载');
- });
- const router = useRouter();
- function goDetailPage(record) {
- console.log('record', record);
- router.push({
- path: '/business-rules/create-rules',
- query: {
- id: record.id,
- },
- });
- }
- </script>
- <style scoped lang="scss">
- .table-demo {
- }
- </style>
|