|
@@ -1,6 +1,12 @@
|
|
|
<template>
|
|
|
- <div>
|
|
|
- <el-drawer v-model="state.showDrawer" size="35%" title="" :show-close="false" :modal="props.modal">
|
|
|
+ <div class="textarea w100">
|
|
|
+ <el-input v-model="value" type="textarea" :autosize="{ minRows: 10, maxRows: 20 }" :placeholder="placeholder" maxlength="2000"> </el-input>
|
|
|
+ <span class="bttons">
|
|
|
+ <el-button @click="showComents" class="default-button" :loading="loading">常用意见</el-button>
|
|
|
+ <el-button type="primary" @click="onAddComments" :loading="loading">添加到常用意见</el-button>
|
|
|
+ </span>
|
|
|
+
|
|
|
+ <el-drawer v-model="state.showDrawer" size="35%" title="" :show-close="false" :modal="modal">
|
|
|
<template #header="{ close }">
|
|
|
<div class="comments-header">
|
|
|
<div>
|
|
@@ -25,7 +31,7 @@
|
|
|
<template v-if="state.active === 'default' && !state.manage">
|
|
|
<ul class="comments-box">
|
|
|
<li class="comments-item" v-for="(item, index) in state.commentsList" :key="index" @click="chooseComment(item)">
|
|
|
- <p class="text-ellipsis2">{{ item.content }}</p>
|
|
|
+ <p class="text-ellipsis2" :title="item.content">{{ item.content }}</p>
|
|
|
</li>
|
|
|
</ul>
|
|
|
</template>
|
|
@@ -37,9 +43,9 @@
|
|
|
v-for="(item, index) in state.commentsList"
|
|
|
:class="[item.ischeck === true ? 'choosed' : '']"
|
|
|
:key="index"
|
|
|
- @click="handelRepeat(item, index)"
|
|
|
+ @click="handelComent(item, index)"
|
|
|
>
|
|
|
- <p>{{ item.content }}</p>
|
|
|
+ <p class="text-ellipsis2" :title="item.content">{{ item.content }}</p>
|
|
|
<el-checkbox v-model="item.ischeck" class="check-icon" label="" v-if="item.ischeck" size="large" />
|
|
|
</li>
|
|
|
</ul>
|
|
@@ -76,16 +82,41 @@
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
-<script setup lang="ts" name="orderCrculationRecord">
|
|
|
-import { reactive, ref } from 'vue';
|
|
|
+<script setup lang="ts" name="commentManage">
|
|
|
+import { reactive, ref, computed } from 'vue';
|
|
|
import { ElMessage, ElMessageBox } from 'element-plus';
|
|
|
import { commonList, addCommon, deleteCommon } from '/@/api/business/commonP';
|
|
|
-const emit = defineEmits(['chooseComment']);
|
|
|
+import { commonEeum } from '/@/utils/tools';
|
|
|
+const emit = defineEmits(['chooseComment', 'update:modelValue']);
|
|
|
const props = defineProps({
|
|
|
modal: {
|
|
|
type: Boolean,
|
|
|
default: false,
|
|
|
},
|
|
|
+ modelValue: {
|
|
|
+ type: String,
|
|
|
+ default: '',
|
|
|
+ },
|
|
|
+ placeholder: {
|
|
|
+ type: String,
|
|
|
+ default: '请填写内容',
|
|
|
+ },
|
|
|
+ loading: {
|
|
|
+ type: Boolean,
|
|
|
+ default: false,
|
|
|
+ },
|
|
|
+ commonEeum: {
|
|
|
+ type: String,
|
|
|
+ default: commonEeum.Seat,
|
|
|
+ },
|
|
|
+});
|
|
|
+const value = computed({
|
|
|
+ get() {
|
|
|
+ return props.modelValue;
|
|
|
+ },
|
|
|
+ set(value) {
|
|
|
+ emit('update:modelValue', value);
|
|
|
+ },
|
|
|
});
|
|
|
// 定义变量内容
|
|
|
const state = reactive<any>({
|
|
@@ -101,27 +132,44 @@ const state = reactive<any>({
|
|
|
typecode: '',
|
|
|
});
|
|
|
const commentsFormRef = ref();
|
|
|
+// 打开常用意见管理
|
|
|
+const showComents = () => {
|
|
|
+ openDialog();
|
|
|
+};
|
|
|
+// 添加到常用意见
|
|
|
+const onAddComments = async () => {
|
|
|
+ if (!props.modelValue) {
|
|
|
+ ElMessage.warning(props.placeholder);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ await addCommon({
|
|
|
+ typeCode: props.commonEeum,
|
|
|
+ content: props.modelValue,
|
|
|
+ });
|
|
|
+ ElMessage.success('操作成功');
|
|
|
+ closeDialog();
|
|
|
+};
|
|
|
// 打开弹窗
|
|
|
-const openDialog = async (val: any) => {
|
|
|
- state.typecode = val;
|
|
|
+const openDialog = async () => {
|
|
|
+ state.typecode = props.commonEeum;
|
|
|
state.active = 'default';
|
|
|
commentsFormRef.value?.resetFields();
|
|
|
state.manage = false;
|
|
|
- getList(val);
|
|
|
+ getList();
|
|
|
state.showDrawer = true;
|
|
|
};
|
|
|
-const getList = async (val: any) => {
|
|
|
+const getList = async () => {
|
|
|
try {
|
|
|
state.loading = true;
|
|
|
- const res: any = await commonList({ typecode: val });
|
|
|
+ const res: any = await commonList({ typecode: props.commonEeum });
|
|
|
state.commentsList = res.result;
|
|
|
state.loading = false;
|
|
|
} catch (error) {
|
|
|
state.loading = false;
|
|
|
}
|
|
|
};
|
|
|
-// 选中常用意见
|
|
|
-const handelRepeat = (item: any, index: number) => {
|
|
|
+// 选中常用意见(管理)
|
|
|
+const handelComent = (item: any, index: number) => {
|
|
|
const repeatData = [...state.commentsList];
|
|
|
const repeatSelarr = [...state.chooseCommentList];
|
|
|
if (!repeatData[index].ischeck) {
|
|
@@ -136,12 +184,13 @@ const handelRepeat = (item: any, index: number) => {
|
|
|
}
|
|
|
state.chooseCommentList = repeatSelarr.filter((item: any) => item.ischeck);
|
|
|
};
|
|
|
+// 重置状态
|
|
|
const resetState = () => {
|
|
|
state.active = 'default';
|
|
|
state.manage = false;
|
|
|
state.chooseCommentList = [];
|
|
|
state.commentsForm.content = '';
|
|
|
- getList(state.typecode);
|
|
|
+ getList();
|
|
|
};
|
|
|
// 删除常用意见
|
|
|
const deleteComment = () => {
|
|
@@ -189,6 +238,7 @@ const commentSave = () => {
|
|
|
// 选择常用意见 填入填写框
|
|
|
const chooseComment = (item: any) => {
|
|
|
emit('chooseComment', item);
|
|
|
+ closeDialog();
|
|
|
};
|
|
|
// 关闭弹窗
|
|
|
const closeDialog = () => {
|
|
@@ -201,6 +251,17 @@ defineExpose({
|
|
|
});
|
|
|
</script>
|
|
|
<style lang="scss" scoped>
|
|
|
+.textarea {
|
|
|
+ position: relative;
|
|
|
+ .bttons {
|
|
|
+ position: absolute;
|
|
|
+ right: 10px;
|
|
|
+ bottom: 10px;
|
|
|
+ }
|
|
|
+ :deep(.el-textarea__inner) {
|
|
|
+ padding-bottom: 40px;
|
|
|
+ }
|
|
|
+}
|
|
|
.comments-container {
|
|
|
.comments-box {
|
|
|
.comments-item {
|
|
@@ -210,6 +271,7 @@ defineExpose({
|
|
|
padding: 8px 15px;
|
|
|
cursor: pointer;
|
|
|
position: relative;
|
|
|
+ line-height: 18px;
|
|
|
&:hover {
|
|
|
box-shadow: 0 0 0 1px var(--el-color-primary) inset;
|
|
|
background-color: var(--hotline-bg-main-color);
|