ny
昨天 282fbc6488f4e8ceb5fda759f963ee88fbf7b999
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
<script lang="ts" setup>
import { reactive, toRefs } from 'vue';
 
import { BasicPopup, usePopup, usePopupInner } from '@jnpf/ui/popup';
 
import { Grid as VxeGrid } from 'vxe-table';
 
import { getInfo } from '#/api/msgCenter/sendConfig';
import { $t } from '#/locales';
import { useBaseStore } from '#/store';
 
import Detail from '../msgTemplate/Detail.vue';
 
interface State {
  dataForm: any;
  messageTypeList: any[];
}
 
const state = reactive<State>({
  dataForm: {
    id: '',
    fullName: '',
    enCode: '',
    description: '',
    enabledMark: 1,
    sortCode: 0,
    messageSource: '',
    templateType: 0,
    sendConfigTemplateList: [],
  },
  messageTypeList: [],
});
const { dataForm } = toRefs(state);
const baseStore = useBaseStore();
const [registerPopup, { changeLoading }] = usePopupInner(init);
const [registerDetail, { openPopup: openDetailPopup }] = usePopup();
const columns: any[] = [
  { title: $t('component.table.index'), width: 50, type: 'seq' },
  { title: '消息类型', field: 'messageType', width: 150, slots: { default: 'messageType' } },
  { title: '模板编码', field: 'templateCode', width: 150 },
  { title: '模板名称', field: 'templateName', minWidth: 150 },
  { title: '账号编码', field: 'accountCode', width: 150 },
  { title: '账号名称', field: 'accountName', width: 150 },
  { title: '状态', field: 'enabledMark', width: 70, align: 'center', slots: { default: 'enabledMark' } },
  { title: '操作', field: 'action', width: 50, slots: { default: 'action' } },
];
 
function init(data) {
  initData();
  state.dataForm.id = data.id || '';
  if (state.dataForm.id) {
    changeLoading(true);
    getInfo(state.dataForm.id)
      .then((res) => {
        changeLoading(false);
        state.dataForm = res.data;
        state.dataForm.enabledMark = Number(state.dataForm.enabledMark);
        state.dataForm.messageSourceName = data.messageSourceName;
      })
      .catch(() => {
        changeLoading(false);
      });
  }
}
async function initData() {
  state.messageTypeList = (await baseStore.getDictionaryData('msgSendType')) as any[];
  state.messageTypeList.map((o) => (o.id = o.enCode));
}
function handleDetail(id) {
  openDetailPopup(true, { id, msgTypeList: state.messageTypeList });
}
function getMsgType(record) {
  const item = state.messageTypeList.find((o) => record.messageType == o.enCode);
  return item.fullName || '';
}
</script>
<template>
  <BasicPopup v-bind="$attrs" @register="registerPopup" :title="$t('common.detailText')" destroy-on-close>
    <a-form class="!mx-[20px]" :colon="false" :model="dataForm" :label-col="{ style: { width: '100px' } }">
      <a-row :gutter="20">
        <a-col :span="12">
          <a-form-item label="名称" name="fullName">
            <p>{{ dataForm.fullName }}</p>
          </a-form-item>
        </a-col>
        <a-col :span="12">
          <a-form-item label="编码" name="enCode">
            <p>{{ dataForm.enCode }}</p>
          </a-form-item>
        </a-col>
        <a-col :span="12">
          <a-form-item label="模板类型">
            <p>{{ dataForm.templateType == '0' ? '自定义模板' : '系统模板' }}</p>
          </a-form-item>
        </a-col>
        <a-col :span="12">
          <a-form-item label="消息来源" name="messageSource">
            <p>{{ dataForm.messageSourceName }}</p>
          </a-form-item>
        </a-col>
        <a-col :span="12">
          <a-form-item label="排序" name="sortCode">
            <p>{{ dataForm.sortCode }}</p>
          </a-form-item>
        </a-col>
        <a-col :span="12">
          <a-form-item label="状态" name="enabledMark">
            <jnpf-switch v-model:value="dataForm.enabledMark" disabled />
          </a-form-item>
        </a-col>
        <a-col :span="24">
          <a-form-item label="说明" name="description">
            <p>{{ dataForm.description }}</p>
          </a-form-item>
        </a-col>
        <a-col :span="24">
          <VxeGrid :data="dataForm.sendConfigTemplateList" :columns size="small" border="inner">
            <template #enabledMark="{ row }">
              <a-switch v-model:checked="row.enabledMark" :checked-value="1" :un-checked-value="0" disabled />
            </template>
            <template #messageType="{ row }">
              {{ getMsgType(row) }}
            </template>
            <template #action="{ row }">
              <a-button size="small" type="link" @click="handleDetail(row.templateId)">{{ $t('common.detailText') }}</a-button>
            </template>
          </VxeGrid>
        </a-col>
      </a-row>
    </a-form>
  </BasicPopup>
  <Detail @register="registerDetail" />
</template>