177 lines
4.7 KiB
Vue
177 lines
4.7 KiB
Vue
<template>
|
|
<el-dialog v-model="dialogVisible" title="添加客户消息" width="900px" @closed="closeDialog" @open="openDialog">
|
|
<el-form ref="formRef" :model="formData" :rules="rules">
|
|
<el-row>
|
|
<el-col :span="12">
|
|
<el-form-item :label-width="labelWidth" label="标题" prop="customer_message_title">
|
|
<el-input v-model='formData.customer_message_title' type="text" placeholder='请输入标题'></el-input>
|
|
</el-form-item>
|
|
</el-col>
|
|
</el-row>
|
|
<el-row>
|
|
<el-col :span="24">
|
|
<el-form-item :label-width="labelWidth" label="内容" prop="customer_message_content">
|
|
<el-input v-model='formData.customer_message_content' type="textarea" :rows="5"
|
|
placeholder='请输入消息内容'></el-input>
|
|
</el-form-item>
|
|
</el-col>
|
|
</el-row>
|
|
<el-row>
|
|
<el-col :span="24">
|
|
<el-form-item :label-width="labelWidth" label="附言" prop="customer_message_postscript">
|
|
<el-input v-model='formData.customer_message_postscript' type="textarea" :rows="5"
|
|
placeholder='请输入附言'></el-input>
|
|
</el-form-item>
|
|
</el-col>
|
|
</el-row>
|
|
<el-row>
|
|
<el-col :span="12">
|
|
<el-form-item :label-width="labelWidth" label="全部人" prop="customer_guid">
|
|
<el-switch v-model="formData.customer_all" class="ml-2"
|
|
style="--el-switch-on-color: #13ce66; --el-switch-off-color: #ff4949" />
|
|
</el-form-item>
|
|
</el-col>
|
|
</el-row>
|
|
<el-row v-if="!formData.customer_all">
|
|
<el-col :span="12">
|
|
<el-form-item :label-width="labelWidth" label="所属客户" prop="customer_guid">
|
|
<el-select filterable :disabled="commonFiledDisabled" style="width: 100%;" v-model="formData.customer_guid"
|
|
clearable placeholder="请选择">
|
|
<el-option v-for="item in customerOptionList" :key="item.dictionary_guid" :label="item.customer_show_text"
|
|
:value="item.customer_guid"></el-option>
|
|
</el-select>
|
|
</el-form-item>
|
|
</el-col>
|
|
</el-row>
|
|
</el-form>
|
|
|
|
<template #footer>
|
|
<span class="dialog-footer">
|
|
<el-button type="primary" @click="handleAddClick(formRef)">添加</el-button>
|
|
<el-button @click="handleResetClick(formRef)">重置</el-button>
|
|
</span>
|
|
</template>
|
|
</el-dialog>
|
|
</template>
|
|
|
|
<script setup>
|
|
import { reactive, ref, watch } from "vue";
|
|
import { addCustomerMessage, getDictionary } from "~/service/customer_message";
|
|
import { getCustomerOptionList } from "~/service/customer";
|
|
import { useLoginStore } from "~/store";
|
|
|
|
// --业务参数
|
|
|
|
|
|
|
|
// --业务方法
|
|
|
|
// 字典获取
|
|
const reading_status = ref([]);
|
|
async function get_reading_status() {
|
|
await getDictionary({ dictionary_value: 'reading_status' }).then((res) => {
|
|
reading_status.value = res
|
|
})
|
|
}
|
|
// 获取客户下拉选项数据
|
|
const customerOptionList = ref([]);
|
|
async function getCustomerOptions() {
|
|
await getCustomerOptionList().then((res) => {
|
|
customerOptionList.value = res.data
|
|
})
|
|
}
|
|
|
|
|
|
|
|
|
|
// --基础参数
|
|
const store = useLoginStore();
|
|
const headers = {
|
|
Accept: "application/json",
|
|
...store.headers,
|
|
};
|
|
|
|
const isBtnLod = ref(false);
|
|
const formRef = ref();
|
|
const labelWidth = 90;
|
|
const props = defineProps({
|
|
modelValue: Boolean,
|
|
done: Function,
|
|
});
|
|
const emits = defineEmits(["update:modelValue"]);
|
|
const dialogVisible = ref(props.modelValue);
|
|
const formData = reactive({
|
|
customer_all: false
|
|
});
|
|
|
|
const uoloadData = ref({
|
|
dirName: "CustomerMessage"
|
|
})
|
|
|
|
watch(props, (v) => {
|
|
dialogVisible.value = v.modelValue;
|
|
});
|
|
|
|
const rules = reactive({
|
|
customer_message_title: [
|
|
{
|
|
required: true,
|
|
message: '标题不能为空'
|
|
}
|
|
],
|
|
customer_message_content: [
|
|
{
|
|
required: true,
|
|
message: '内容不能为空'
|
|
}
|
|
],
|
|
customer_message_reading_status: [
|
|
{
|
|
required: true,
|
|
message: '阅读状态不能为空'
|
|
}
|
|
],
|
|
});
|
|
|
|
|
|
// --基础方法
|
|
|
|
// 打开弹窗时执行
|
|
const openDialog = () => {
|
|
get_reading_status()
|
|
getCustomerOptions()
|
|
|
|
};
|
|
|
|
const closeDialog = () => {
|
|
handleResetClick(formRef.value);
|
|
dialogVisible.value = false;
|
|
emits("update:modelValue", false);
|
|
};
|
|
|
|
const handleAddClick = async (formEl) => {
|
|
if (!formEl) return;
|
|
formEl.validate(async (valid) => {
|
|
if (!valid) {
|
|
return;
|
|
}
|
|
isBtnLod.value = true;
|
|
|
|
|
|
const { code } = await addCustomerMessage(formData);
|
|
if (code == 0) {
|
|
closeDialog();
|
|
props.done();
|
|
}
|
|
isBtnLod.value = flase;
|
|
});
|
|
};
|
|
|
|
const handleResetClick = async (formEl) => {
|
|
if (!formEl) return;
|
|
formEl.resetFields();
|
|
};
|
|
</script>
|
|
|
|
<style lang="less" scoped></style>
|