|
|
|
|
@ -6,7 +6,7 @@
|
|
|
|
|
<a-input v-model:value="currentInfo.title" placeholder="请输入标题"></a-input>
|
|
|
|
|
</a-form-item>
|
|
|
|
|
<a-form-item class="g_mb_12" label="发布时间" name="publishTimeStr" :rules="[{ required: false, message: '请选择发布时间' }]">
|
|
|
|
|
<a-date-picker v-model:value="currentInfo.publishTimeStr" placeholder="请选择发布时间" :minuteStep="30" format="YYYY-MM-DD HH:mm" :show-time="{ defaultValue: dayjs(currentTime, 'HH:mm:ss') }" style="width: 100%" />
|
|
|
|
|
<a-date-picker v-model:value=" currentInfo.publishTimeStr" placeholder="请选择发布时间" :minuteStep="30" format="YYYY-MM-DD HH:mm" :showTime="{ format: 'HH:mm' }" style="width: 100%" />
|
|
|
|
|
</a-form-item>
|
|
|
|
|
<a-form-item class="g_mb_12" label="内容" :rules="[{ required: true, message: '请输入内容' }]" name="content">
|
|
|
|
|
<iframe src="../../../public/static/editor.html" class="g_border_d" width="100%" height="500px" frameborder="0" ref="iframeDom" style="border-radius: 6px"></iframe>
|
|
|
|
|
@ -40,13 +40,14 @@ const commonJS = getCurrentInstance().appContext.app.config.globalProperties.G;
|
|
|
|
|
import { useRouter, useRoute } from "vue-router";
|
|
|
|
|
const router = useRouter(); // 应用路由
|
|
|
|
|
const route = useRoute();
|
|
|
|
|
import dayjs from "dayjs";
|
|
|
|
|
import dayjs from "dayjs"
|
|
|
|
|
dayjs.locale("zh-cn");;
|
|
|
|
|
|
|
|
|
|
import { saveMessageApi,getMessageDetailApi } from "../../api/messageConfig/message";
|
|
|
|
|
import { saveMessageApi,getMessageDetailApi,updateMessageApi } from "../../api/messageConfig/message";
|
|
|
|
|
import { message } from "ant-design-vue";
|
|
|
|
|
import { useStore } from "@/stores/counter";
|
|
|
|
|
// 设置当前时间作为发布时间的默认选项
|
|
|
|
|
const currentTime = ref(dayjs().format("HH") + ":00" + ":00");
|
|
|
|
|
// const currentTime = ref(dayjs());
|
|
|
|
|
// console.log('currentTime.value',currentTime.value);
|
|
|
|
|
const storeJS = useStore();
|
|
|
|
|
let currentInfo = ref({});
|
|
|
|
|
@ -61,12 +62,21 @@ onMounted(() => {
|
|
|
|
|
item.time = "2024-03-11 13:04:24";
|
|
|
|
|
});
|
|
|
|
|
if (route.query.id) {
|
|
|
|
|
currentInfo.value = newList[Number(route.query.id)];
|
|
|
|
|
// currentInfo.value = newList[Number(route.query.id)];
|
|
|
|
|
getMessageDetailApi(route.query.id).then((res) => {
|
|
|
|
|
console.log(res.data);
|
|
|
|
|
// currentInfo.value.publishTimeStr = res.data.publishTime;
|
|
|
|
|
currentInfo.value = res.data;
|
|
|
|
|
currentInfo.value.publishTimeStr = dayjs(res.data.publishTime);
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
initData();
|
|
|
|
|
}, 1000);
|
|
|
|
|
// getMessageDetailApi(route.query.id).then((res) => {
|
|
|
|
|
// console.log(res);
|
|
|
|
|
// })
|
|
|
|
|
initData();
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
const iframeDom = ref();
|
|
|
|
|
window.addEventListener("message", (val) => {
|
|
|
|
|
@ -79,16 +89,16 @@ window.addEventListener("message", (val) => {
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
const initData = () => {
|
|
|
|
|
// iframeDom.value.contentWindow.postMessage("");
|
|
|
|
|
|
|
|
|
|
iframeDom.value.onload = function () {
|
|
|
|
|
iframeDom.value.contentWindow.postMessage("");
|
|
|
|
|
console.log(currentInfo.value.content);
|
|
|
|
|
// iframeDom.value.onload = function () {
|
|
|
|
|
console.log(route);
|
|
|
|
|
if (route.name == "messageEdit") {
|
|
|
|
|
iframeDom.value.contentWindow.postMessage(currentInfo.value.content);
|
|
|
|
|
} else {
|
|
|
|
|
iframeDom.value.contentWindow.postMessage("");
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
// };
|
|
|
|
|
};
|
|
|
|
|
const cancel = () => {
|
|
|
|
|
router.back();
|
|
|
|
|
@ -107,9 +117,17 @@ const submitInfo = () => {
|
|
|
|
|
publishTimeStr: dayjs(currentInfo.value.publishTimeStr).format("YYYY-MM-DD HH:mm") + ":00",
|
|
|
|
|
status: subType.value,
|
|
|
|
|
};
|
|
|
|
|
saveMessageApi(obj).then((res) => {
|
|
|
|
|
if (route.name == "messageEdit") {
|
|
|
|
|
obj.recordId = route.query.id
|
|
|
|
|
updateMessageApi(obj).then((res) => {
|
|
|
|
|
router.back();
|
|
|
|
|
})
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
|
|
saveMessageApi(obj).then((res) => {
|
|
|
|
|
router.back();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|