|
@@ -36,6 +36,7 @@
|
|
|
</template>
|
|
|
<script setup>
|
|
|
import { ref, inject, onMounted, onBeforeUnmount, watch } from 'vue'
|
|
|
+import { convertBlob2File } from '@/utils/file'
|
|
|
import { http } from '@/utils/request'
|
|
|
import browser from '@/utils/browser'
|
|
|
import Toast from '@/components/dialog/Toast'
|
|
@@ -48,6 +49,7 @@ import { from } from 'readable-stream'
|
|
|
const showTips = ref(null)
|
|
|
const projectId = browser.valueFromUrl('projectId') || 1
|
|
|
const notify = inject('notify')
|
|
|
+const tags = inject('tags')
|
|
|
const height = ref(0)
|
|
|
const form = ref({
|
|
|
title: '',
|
|
@@ -55,6 +57,9 @@ const form = ref({
|
|
|
status: '',
|
|
|
members: [],
|
|
|
})
|
|
|
+const typeList = ['image', 'video', 'audio', 'link']
|
|
|
+let mediaList = []
|
|
|
+let tag = null
|
|
|
const data = ref({
|
|
|
status: [
|
|
|
{ text: '待处理', value: 1 },
|
|
@@ -73,7 +78,7 @@ const onClose = () => {
|
|
|
}
|
|
|
notify.value = null
|
|
|
}
|
|
|
-const onSubmit = () => {
|
|
|
+const onSubmit = async () => {
|
|
|
if (!form.value.title) {
|
|
|
return (showTips.value = '请输入资料名称')
|
|
|
}
|
|
@@ -82,26 +87,66 @@ const onSubmit = () => {
|
|
|
}
|
|
|
notify.value.title = form.value.title
|
|
|
notify.value.content = form.value.describe
|
|
|
- let tag = JSON.stringify(notify.value, (key, value) => {
|
|
|
+ //提交前删除别的数据
|
|
|
+ typeList.forEach(item => {
|
|
|
+ if (notify.value.type != item) {
|
|
|
+ delete notify.value.media[item]
|
|
|
+ }
|
|
|
+ })
|
|
|
+ tag = JSON.stringify(notify.value, (key, value) => {
|
|
|
if (key === 'visiblePanos') {
|
|
|
return value.map(item => item.id)
|
|
|
}
|
|
|
+
|
|
|
+ if (key === 'media' && notify.value.media[notify.value.type]) {
|
|
|
+ mediaList = notify.value.media[notify.value.type]
|
|
|
+ }
|
|
|
+
|
|
|
return value
|
|
|
})
|
|
|
-
|
|
|
tag = JSON.parse(tag)
|
|
|
tag.status = form.value.status
|
|
|
tag.members = form.value.members.map(item => item.value)
|
|
|
delete tag.__temp
|
|
|
- http.post(`smart-site/marking/addOrUpdate`, {
|
|
|
+ await handlerUpload(tag)
|
|
|
+}
|
|
|
+const handlerUpload = async data => {
|
|
|
+ if (mediaList.length) {
|
|
|
+ for (let i = 0; i < mediaList.length; i++) {
|
|
|
+ if (mediaList[i].file) {
|
|
|
+ let res = await http.postFile(`smart-site/upload/${projectId}/${notify.value.type}/file/`, {
|
|
|
+ file: mediaList[i].file,
|
|
|
+ })
|
|
|
+ if (res.success) {
|
|
|
+ delete tag.media[notify.value.type][i].file
|
|
|
+ delete notify.value.media[notify.value.type][i].file
|
|
|
+ tag.media[notify.value.type][i].src = res.data
|
|
|
+ notify.value.media[notify.value.type][i].src = res.data
|
|
|
+ } else if (res.code == 4008) {
|
|
|
+ showTips.value = '请先登录'
|
|
|
+ } else {
|
|
|
+ showTips.value = res.message
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ mediaList = []
|
|
|
+ }
|
|
|
+ console.log(tag)
|
|
|
+ let params = {
|
|
|
projectId,
|
|
|
userIds: tag.members,
|
|
|
markingStatus: form.value.status,
|
|
|
markingTitle: form.value.title,
|
|
|
hotData: tag,
|
|
|
- }).then(response => {
|
|
|
+ }
|
|
|
+ if (tag.id) {
|
|
|
+ params.markingId = tag.id
|
|
|
+ }
|
|
|
+ http.post(`smart-site/marking/addOrUpdate`, params).then(response => {
|
|
|
if (response.success) {
|
|
|
delete notify.value.__temp
|
|
|
+ notify.value.id = response.data
|
|
|
notify.value = null
|
|
|
} else if (response.code == 4008) {
|
|
|
showTips.value = '请先登录'
|
|
@@ -113,7 +158,7 @@ const onSubmit = () => {
|
|
|
const onResize = () => {
|
|
|
height.value = window.innerHeight - 90
|
|
|
}
|
|
|
-
|
|
|
+let markingId = null
|
|
|
onMounted(() => {
|
|
|
http.post(`smart-site/projectTeam/select`, { projectId }).then(response => {
|
|
|
data.value.members = response.data.map(item => {
|
|
@@ -136,6 +181,11 @@ onMounted(() => {
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
+ //初始化markingId
|
|
|
+ console.log(notify.value)
|
|
|
+ console.log(tags)
|
|
|
+ tags.value.forEach(item => {})
|
|
|
+ console.log(markingId)
|
|
|
}
|
|
|
})
|
|
|
|