|
|
@@ -77,15 +77,15 @@ import {ElMessage} from "element-plus"
|
|
|
import type { ComponentSize, FormInstance, FormRules, } from "element-plus";
|
|
|
import api from "@/api";
|
|
|
import router from "@/router";
|
|
|
-import { useRoute } from "vue-router";
|
|
|
+import { useRoute, useRouter } from "vue-router";
|
|
|
|
|
|
interface RuleForm {
|
|
|
title: string;
|
|
|
sendDeptId: string;
|
|
|
sendDeptName: string;
|
|
|
content: string;
|
|
|
- isChildren: string;
|
|
|
- isForce: string;
|
|
|
+ isChildren: string | number;
|
|
|
+ isForce: string | number;
|
|
|
}
|
|
|
const tableProps = ref({
|
|
|
value: "id",
|
|
|
@@ -94,12 +94,13 @@ const tableProps = ref({
|
|
|
checkStrictly: true,
|
|
|
});
|
|
|
const route=useRoute()
|
|
|
+const myRouter = useRouter()
|
|
|
onMounted(() => {
|
|
|
getInstitutionList(); //机构列表
|
|
|
console.log(route)
|
|
|
if(route.query?.id){
|
|
|
api.contentApi.noticeGet({id:route.query?.id}).then(res=>{
|
|
|
-
|
|
|
+
|
|
|
if(res.code===200){
|
|
|
ruleForm.title=res.data.title
|
|
|
ruleForm.sendDeptId=res.data.sendDeptId
|
|
|
@@ -108,7 +109,7 @@ onMounted(() => {
|
|
|
ruleForm.sendDeptName=res.data.sendDeptName
|
|
|
ruleForm.isForce=res.data.isForce
|
|
|
ruleForm.content=res.data.content
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
@@ -120,8 +121,8 @@ const ruleForm = reactive<RuleForm>({
|
|
|
title: "",
|
|
|
sendDeptId: "",
|
|
|
sendDeptName: "",
|
|
|
- isChildren: "",
|
|
|
- isForce: "",
|
|
|
+ isChildren: 0,
|
|
|
+ isForce: 0,
|
|
|
content: "",
|
|
|
});
|
|
|
|
|
|
@@ -151,16 +152,14 @@ const sendDeptId=ref('')
|
|
|
function deptChange(e:any){
|
|
|
if(e){
|
|
|
sendDeptId.value=e[e.length-1]
|
|
|
-
|
|
|
- ruleForm.sendDeptName=getID(institutionList.value,sendDeptId.value).name
|
|
|
- // console.log(getID(institutionList.value,sendDeptId.value))
|
|
|
+ ruleForm.sendDeptName=getID(institutionList.value,e[e.length-1]).name
|
|
|
}else{
|
|
|
sendDeptId.value=''
|
|
|
}
|
|
|
}
|
|
|
|
|
|
const submitForm = async (formEl: FormInstance | undefined) => {
|
|
|
-
|
|
|
+
|
|
|
if (!formEl) return;
|
|
|
await formEl.validate((valid, fields) => {
|
|
|
if (valid) {
|
|
|
@@ -187,14 +186,17 @@ const submitForm = async (formEl: FormInstance | undefined) => {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- }
|
|
|
+
|
|
|
+ }
|
|
|
});
|
|
|
};
|
|
|
|
|
|
const resetForm = (formEl: FormInstance | undefined) => {
|
|
|
- if (!formEl) return;
|
|
|
- formEl.resetFields();
|
|
|
+ // if (!formEl) return;
|
|
|
+ // formEl.resetFields();
|
|
|
+ myRouter.push({
|
|
|
+ path: '/content/message'
|
|
|
+ })
|
|
|
};
|
|
|
|
|
|
//机构列表
|
|
|
@@ -209,18 +211,26 @@ function getID(json:any, id:string) {
|
|
|
var o = {}; //专门用来保存筛选后的数组
|
|
|
//定义一个函数getID(json,id),形参json用来接受传入的数组,形参id用来接受id号
|
|
|
//核心:利用arry.forEach(function(currentValue),index,arr)遍历数组
|
|
|
- json.forEach(function(item:any) {
|
|
|
- //if用来判断外层,else if用来判断里层,调用递归函数的有2个判断条件在“有goods属性并且不为空”情况下才调用
|
|
|
-
|
|
|
- if (item.id == id) {
|
|
|
-
|
|
|
- return o = item;
|
|
|
-
|
|
|
- } else if (item.children && item.children.length > 0) {
|
|
|
- o = getID(item.children, id)//递归
|
|
|
- }
|
|
|
- });
|
|
|
- return o; //全部遍历完之后返回对象o
|
|
|
+ // json.forEach(function(item:any) {
|
|
|
+ // console.log(123, item)
|
|
|
+ // //if用来判断外层,else if用来判断里层,调用递归函数的有2个判断条件在“有goods属性并且不为空”情况下才调用
|
|
|
+ // if (item.id == id) {
|
|
|
+ // o = item
|
|
|
+ // return o;
|
|
|
+ // } else if (item.children && item.children.length > 0) {
|
|
|
+ // o = getID(item.children, id)//递归
|
|
|
+ // }
|
|
|
+ // });
|
|
|
+ // return o; //全部遍历完之后返回对象o
|
|
|
+ for (let i=0; i<json.length-1; i++) {
|
|
|
+ if(json[i].id === id) {
|
|
|
+ o = json[i]
|
|
|
+ break
|
|
|
+ } else if(json[i].children && json[i].children.length > 0) {
|
|
|
+ getID(json[i].children, id)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return o;
|
|
|
}
|
|
|
</script>
|
|
|
<style lang="scss" scoped>
|