|
@@ -0,0 +1,228 @@
|
|
|
|
+<template>
|
|
|
|
+ <el-dialog v-model="state.dialogVisible" width="70%" draggable title="新增随手拍信息配置" @close="close">
|
|
|
|
+ <el-form :model="state.ruleForm" label-width="110px" ref="ruleFormRef" v-loading="loading" scroll-to-error>
|
|
|
|
+ <el-row :gutter="10">
|
|
|
|
+ <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
|
|
|
|
+ <el-form-item label="公告类型" prop="bulletinObj" :rules="[{ required: true, message: '请选择公告类型', trigger: 'change' }]">
|
|
|
|
+ <el-select
|
|
|
|
+ v-model="state.ruleForm.bulletinObj"
|
|
|
|
+ placeholder="请选择公告类型"
|
|
|
|
+ value-key="dicDataValue"
|
|
|
|
+ class="w100"
|
|
|
|
+ @change="
|
|
|
|
+ (e) => {
|
|
|
|
+ state.ruleForm.bulletinTypeId = e.dicDataValue;
|
|
|
|
+ state.ruleForm.bulletinTypeName = e.dicDataName;
|
|
|
|
+ }
|
|
|
|
+ "
|
|
|
|
+ >
|
|
|
|
+ <el-option v-for="item in bulletinTypeOptions" :value="item" :key="item.dicDataValue" :label="item.dicDataName" />
|
|
|
|
+ </el-select>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ </el-col>
|
|
|
|
+ <el-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12">
|
|
|
|
+ <el-form-item label="公告标题" prop="title" :rules="[{ required: true, message: '请填写公告标题', trigger: 'blur' }]">
|
|
|
|
+ <el-input v-model="state.ruleForm.title" placeholder="请填写公告标题" clearable show-word-limit maxlength="200"></el-input>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ </el-col>
|
|
|
|
+ <el-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12">
|
|
|
|
+ <el-form-item label="失效时间" prop="loseEfficacyTime" :rules="[{ required: true, message: '请选择失效时间', trigger: 'change' }]">
|
|
|
|
+ <el-date-picker
|
|
|
|
+ v-model="state.ruleForm.loseEfficacyTime"
|
|
|
|
+ type="datetime"
|
|
|
|
+ placeholder="请选择失效时间"
|
|
|
|
+ value-format="YYYY-MM-DD[T]HH:mm:ss"
|
|
|
|
+ class="w100"
|
|
|
|
+ :disabled-date="disabledDate"
|
|
|
|
+ popper-class="no-atTheMoment"
|
|
|
|
+ />
|
|
|
|
+ </el-form-item>
|
|
|
|
+ </el-col>
|
|
|
|
+ <el-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12">
|
|
|
|
+ <el-form-item label="来源单位" prop="sourceOrgId" :rules="[{ required: true, message: '请选择来源单位', trigger: 'change' }]">
|
|
|
|
+ <el-cascader
|
|
|
|
+ :options="orgsOptions"
|
|
|
|
+ filterable
|
|
|
|
+ :props="{ value: 'id', label: 'name', emitPath: false, checkStrictly: true }"
|
|
|
|
+ placeholder="请选择来源单位"
|
|
|
|
+ class="w100"
|
|
|
|
+ v-model="state.ruleForm.sourceOrgId"
|
|
|
|
+ ref="orgRef"
|
|
|
|
+ @change="changeOrg"
|
|
|
|
+ >
|
|
|
|
+ </el-cascader>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ </el-col>
|
|
|
|
+ <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
|
|
|
|
+ <el-form-item label="公告范围" prop="pushRangesArray" :rules="[{ required: true, message: '请选择公告范围', trigger: 'change' }]">
|
|
|
|
+ <el-checkbox-group v-model="state.ruleForm.pushRangesArray">
|
|
|
|
+ <el-checkbox :value="item" v-for="item in pushRangesOptions" :key="item.dicDataValue">{{ item.dicDataName }}</el-checkbox>
|
|
|
|
+ </el-checkbox-group>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ </el-col>
|
|
|
|
+ <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
|
|
|
|
+ <el-form-item label="公告位置" prop="displayLocationArr" :rules="[{ required: false, message: '请选择公告位置', trigger: 'change' }]">
|
|
|
|
+ <el-checkbox-group v-model="state.ruleForm.displayLocationArr">
|
|
|
|
+ <el-checkbox :value="item" v-for="item in bulletinDisplayLocation" :key="item.dicDataValue">{{ item.dicDataName }}</el-checkbox>
|
|
|
|
+ </el-checkbox-group>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ </el-col>
|
|
|
|
+ <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
|
|
|
|
+ <el-form-item label="公告内容" prop="content" :rules="[{ required: true, message: '请填写公告内容', trigger: 'blur' }]">
|
|
|
|
+ <editor v-model:get-html="state.ruleForm.content" placeholder="请填写公告内容" height="450px" />
|
|
|
|
+ </el-form-item>
|
|
|
|
+ </el-col>
|
|
|
|
+ </el-row>
|
|
|
|
+ </el-form>
|
|
|
|
+ <template #footer>
|
|
|
|
+ <span class="dialog-footer">
|
|
|
|
+ <el-button @click="closeDialog" class="default-button">取 消</el-button>
|
|
|
|
+ <el-button type="primary" @click="onSubmit(ruleFormRef)" :loading="loading">确 定</el-button>
|
|
|
|
+ </span>
|
|
|
|
+ </template>
|
|
|
|
+ </el-dialog>
|
|
|
|
+</template>
|
|
|
|
+
|
|
|
|
+<script setup lang="tsx" name="noticeDetail">
|
|
|
|
+import { reactive, ref, defineAsyncComponent, computed, unref, FunctionalComponent } from 'vue';
|
|
|
|
+import { bulletinAdd, bulletinAddBaseData, circularAdd, circularAddBaseData, getAllUsers } from '@/api/auxiliary/notice';
|
|
|
|
+import { throttle } from '@/utils/tools';
|
|
|
|
+import { CheckboxValueType, ElMessage, FormInstance } from 'element-plus';
|
|
|
|
+import { disabledDate } from '@/utils/constants';
|
|
|
|
+import { ElCheckbox } from 'element-plus';
|
|
|
|
+// 引入组件
|
|
|
|
+const Editor = defineAsyncComponent(() => import('@/components/Editor/index.vue')); // 富文本编辑器
|
|
|
|
+// 定义子组件向父组件传值/事件
|
|
|
|
+const emit = defineEmits(['updateList']);
|
|
|
|
+// 定义变量内容
|
|
|
|
+const state = reactive<any>({
|
|
|
|
+ dialogVisible: false,
|
|
|
|
+ ruleForm: {
|
|
|
|
+ isMustRead: false, // 是否必须阅读
|
|
|
|
+ displayLocationArr:[],
|
|
|
|
+ },
|
|
|
|
+ searchContent: '', // 搜索内容
|
|
|
|
+});
|
|
|
|
+let loading = ref<boolean>(false); // 加载状态
|
|
|
|
+// 打开弹窗
|
|
|
|
+const ruleFormRef = ref<RefType>();
|
|
|
|
+
|
|
|
|
+const bulletinTypeOptions = ref<EmptyArrayType>([]); // 公告类型
|
|
|
|
+const pushRangesOptions = ref<EmptyArrayType>([]); // 公告范围
|
|
|
|
+const orgsOptions = ref<EmptyArrayType>([]); // 来源单位
|
|
|
|
+const userTables = ref<EmptyArrayType>([]); // 通知对象 个人
|
|
|
|
+const bulletinDisplayLocation = ref<EmptyArrayType>([]); // 公告位置
|
|
|
|
+const openDialog = async (type: string) => {
|
|
|
|
+ loading.value = true;
|
|
|
|
+ state.dialogVisible = true;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ try {
|
|
|
|
+ const [responseAnnounce] = await Promise.all([bulletinAddBaseData()]);
|
|
|
|
+ bulletinTypeOptions.value = responseAnnounce.result?.bulletinType ?? [];
|
|
|
|
+ pushRangesOptions.value = responseAnnounce.result?.pushRanges ?? [];
|
|
|
|
+ orgsOptions.value = responseAnnounce.result?.orgsOptions ?? [];
|
|
|
|
+ bulletinDisplayLocation.value = responseAnnounce.result?.bulletinDisplayLocation ?? [];
|
|
|
|
+ loading.value = false;
|
|
|
|
+ } catch (error) {
|
|
|
|
+ console.log(error);
|
|
|
|
+ loading.value = true;
|
|
|
|
+ }
|
|
|
|
+};
|
|
|
|
+const orgRef = ref<RefType>(); //来源单位
|
|
|
|
+const changeOrg = () => {
|
|
|
|
+ const currentNode = orgRef.value.getCheckedNodes();
|
|
|
|
+ state.ruleForm.sourceOrgName = currentNode[0].label;
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+type SelectionCellProps = {
|
|
|
|
+ value: boolean;
|
|
|
|
+ intermediate?: boolean;
|
|
|
|
+ onChange: (value: CheckboxValueType) => void;
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+const SelectionCell: FunctionalComponent<SelectionCellProps> = ({ value, intermediate = false, onChange }) => {
|
|
|
|
+ return <ElCheckbox onChange={onChange} modelValue={value} indeterminate={intermediate} />;
|
|
|
|
+};
|
|
|
|
+const tables = computed({
|
|
|
|
+ get() {
|
|
|
|
+ // 注意: filter() 不会改变原始数组。
|
|
|
|
+ // 模糊搜索
|
|
|
|
+ if (!state.searchContent) return userTables.value;
|
|
|
|
+ // filter() 方法创建一个新的数组,新数组中的元素是通过检查指定数组中符合条件的所有元素。
|
|
|
|
+ // 注意: filter() 不会对空数组进行检测。
|
|
|
|
+ return userTables.value.filter((data: any) => {
|
|
|
|
+ // some() 方法用于检测数组中的元素是否满足指定条件;
|
|
|
|
+ // some() 方法会依次执行数组的每个元素:
|
|
|
|
+ // 如果有一个元素满足条件,则表达式返回true , 剩余的元素不会再执行检测;
|
|
|
|
+ // 如果没有满足条件的元素,则返回false。
|
|
|
|
+ // 注意: some() 不会对空数组进行检测。
|
|
|
|
+ // 注意: some() 不会改变原始数组。
|
|
|
|
+ return Object.keys(data).some((key) => {
|
|
|
|
+ // indexOf() 返回某个指定的字符在某个字符串中首次出现的位置,如果没有找到就返回-1;
|
|
|
|
+ // 该方法对大小写敏感!所以之前需要toLowerCase()方法将所有查询到内容变为小写。
|
|
|
|
+ return String(data[key]).toLowerCase().indexOf(state.searchContent) > -1;
|
|
|
|
+ });
|
|
|
|
+ });
|
|
|
|
+ },
|
|
|
|
+ set(val) {
|
|
|
|
+ // userTables.value = val;
|
|
|
|
+ },
|
|
|
|
+});
|
|
|
|
+
|
|
|
|
+// 保存
|
|
|
|
+const onSubmit = throttle(async (formEl: FormInstance | undefined) => {
|
|
|
|
+ if (!formEl) return;
|
|
|
|
+ await formEl.validate((valid: boolean) => {
|
|
|
|
+ if (!valid) return;
|
|
|
|
+ loading.value = true;
|
|
|
|
+
|
|
|
|
+ const pushRanges = state.ruleForm.pushRangesArray.map((item: any) => {
|
|
|
|
+ return {
|
|
|
|
+ key: item.dicDataValue,
|
|
|
|
+ value: item.dicDataName,
|
|
|
|
+ };
|
|
|
|
+ });
|
|
|
|
+ const displayLocation = state.ruleForm.displayLocationArr.map((item: any) => {
|
|
|
|
+ return {
|
|
|
|
+ key: item.dicDataValue,
|
|
|
|
+ value: item.dicDataName,
|
|
|
|
+ };
|
|
|
|
+ });
|
|
|
|
+ const bulletinRequest = {
|
|
|
|
+ title: state.ruleForm.title,
|
|
|
|
+ content: state.ruleForm.content,
|
|
|
|
+ bulletinTypeId: state.ruleForm.bulletinTypeId,
|
|
|
|
+ bulletinTypeName: state.ruleForm.bulletinTypeName,
|
|
|
|
+ loseEfficacyTime: state.ruleForm.loseEfficacyTime,
|
|
|
|
+ sourceOrgId: state.ruleForm.sourceOrgId,
|
|
|
|
+ sourceOrgName: state.ruleForm.sourceOrgName,
|
|
|
|
+ pushRanges,
|
|
|
|
+ displayLocation
|
|
|
|
+ };
|
|
|
|
+ bulletinAdd(bulletinRequest)
|
|
|
|
+ .then(() => {
|
|
|
|
+ loading.value = false;
|
|
|
|
+ closeDialog();
|
|
|
|
+ emit('updateList');
|
|
|
|
+ ElMessage.success('操作成功');
|
|
|
|
+ })
|
|
|
|
+ .catch(() => {
|
|
|
|
+ loading.value = false;
|
|
|
|
+ });
|
|
|
|
+ });
|
|
|
|
+}, 300);
|
|
|
|
+// 关闭弹窗
|
|
|
|
+const closeDialog = () => {
|
|
|
|
+ state.dialogVisible = false;
|
|
|
|
+};
|
|
|
|
+const close = () => {
|
|
|
|
+ ruleFormRef.value?.clearValidate();
|
|
|
|
+ ruleFormRef.value?.resetFields();
|
|
|
|
+};
|
|
|
|
+// 暴露变量
|
|
|
|
+defineExpose({
|
|
|
|
+ openDialog,
|
|
|
|
+ closeDialog,
|
|
|
|
+});
|
|
|
|
+</script>
|