index.vue
2.31 KB
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
<template>
<div class="container">
<Breadcrumb :items="['system', 'system-customer']" />
<a-card class="minHeight">
<a-space direction="vertical" fill>
<div style="color: #4e5969">工作简介:</div>
<div style="margin: 8px 0; color: #2c2c2c">{{ config.content }}</div>
<icon-button v-permission="['system-customer-edit']" icon="edit" type="primary" label="编辑" @click="onUpdate" />
</a-space>
</a-card>
</div>
</template>
<script lang="ts" setup>
import { createVNode, onMounted, ref } from 'vue';
import { SystemConfig } from '@/types/system-config';
import { Form, FormItem, Input, Modal } from '@arco-design/web-vue';
import useConfigApi from '@/http/config';
import { set } from 'lodash';
const { update, getOne } = useConfigApi;
const config = ref<Pick<SystemConfig, 'id' | 'content'>>({ id: 0, content: '' });
const onUpdate = () => {
const content = ref<string>(config.value?.content || '');
Modal.open({
title: '编辑',
content: () =>
createVNode(
Form,
{ model: content },
{
default: () =>
createVNode(
FormItem,
{ label: '工作简介' },
{
default: () =>
createVNode(Input, {
'maxLength': 30,
'modelValue': content.value,
'showWordLimit': true,
'onUpdate:modelValue': (val: string | undefined) => {
content.value = val || '';
},
}),
}
),
}
),
closable: false,
escToClose: false,
maskClosable: false,
onBeforeOk: (done) => {
update(config.value?.id, { ...config.value, content: content.value })
.then(() => {
set(config.value, 'content', content.value);
done(true);
})
.catch(() => {
done(false);
});
},
});
};
onMounted(() => {
getOne({ identifier: 'customer_service' }).then((data?: SystemConfig) => {
config.value = data || { id: 0, content: '' };
});
});
</script>
<style lang="less" scoped>
.minHeight {
min-height: calc(100vh - 200px);
}
</style>