|
@ -1,7 +1,20 @@ |
|
|
<template> |
|
|
<template> |
|
|
<view class="u-font-14" style="height: 100%"> |
|
|
<view class="u-font-14" style="height: 100%"> |
|
|
<view v-if="pluginContent"> |
|
|
<view v-if="pluginContent"> |
|
|
<view style="height: 100%" v-html="pluginContent"></view> |
|
|
<view |
|
|
|
|
|
style="height: 100%" |
|
|
|
|
|
:data-uid="userId" |
|
|
|
|
|
:data-pid="projectId" |
|
|
|
|
|
:data-did="task.detailId" |
|
|
|
|
|
:data-rid="roleId" |
|
|
|
|
|
:data-tid="task.id" |
|
|
|
|
|
:data-tname="task.name" |
|
|
|
|
|
:data-pstart="task.planStart" |
|
|
|
|
|
:data-rstart="task.realStart" |
|
|
|
|
|
:data-pdu="task.planDuration" |
|
|
|
|
|
:data-rdu="task.realDuration" |
|
|
|
|
|
v-html="pluginContent" |
|
|
|
|
|
></view> |
|
|
</view> |
|
|
</view> |
|
|
|
|
|
|
|
|
<view v-else> |
|
|
<view v-else> |
|
@ -19,19 +32,27 @@ |
|
|
</template> |
|
|
</template> |
|
|
|
|
|
|
|
|
<script> |
|
|
<script> |
|
|
|
|
|
import { mapGetters, mapState } from 'vuex'; |
|
|
|
|
|
|
|
|
export default { |
|
|
export default { |
|
|
name: 'Plugin', |
|
|
name: 'Plugin', |
|
|
props: { |
|
|
props: { |
|
|
task: { default: () => {}, type: Object }, |
|
|
task: { default: () => {}, type: Object }, |
|
|
pluginId: { default: '1', type: String }, |
|
|
pluginId: { default: '1', type: String }, |
|
|
styleType: { default: 0, type: Number }, |
|
|
styleType: { default: 0, type: Number }, |
|
|
pluginTaskId: { default: '0', type: String }, |
|
|
pluginTaskId: { default: '', type: String }, |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
data() { |
|
|
data() { |
|
|
return { pluginContent: null }; |
|
|
return { pluginContent: null }; |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
computed: { |
|
|
|
|
|
...mapGetters('user', ['userId']), |
|
|
|
|
|
...mapGetters('project', ['projectId']), |
|
|
|
|
|
...mapState('role', ['roleId']), |
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
created() { |
|
|
created() { |
|
|
this.getPlugin(); |
|
|
this.getPlugin(); |
|
|
}, |
|
|
}, |
|
@ -45,19 +66,27 @@ export default { |
|
|
styleType, |
|
|
styleType, |
|
|
}); |
|
|
}); |
|
|
if (!data || !data.id) return; |
|
|
if (!data || !data.id) return; |
|
|
|
|
|
const reg = /data-root=["|']?(\w+)["|']?/gi; |
|
|
|
|
|
console.log(data.html); |
|
|
if (data.html) { |
|
|
if (data.html) { |
|
|
// 查有没有data-root=“xxx” 有的话 将xxx替换为 pluginTaskId |
|
|
// 查有没有data-root=“xxx” 有的话 将xxx替换为 pluginTaskId |
|
|
const reg = /data-root="(\w+)"/gi; |
|
|
|
|
|
if (reg.test(data.html)) { |
|
|
if (reg.test(data.html)) { |
|
|
const str = data.html.replace(RegExp.$1, this.pluginTaskId); |
|
|
const uuid = RegExp.$1; |
|
|
|
|
|
console.log('uuid: ', uuid, `p${this.pluginTaskId}`); |
|
|
|
|
|
|
|
|
|
|
|
const str = data.html.replaceAll(uuid, `p${this.pluginTaskId}`); |
|
|
this.pluginContent = str; |
|
|
this.pluginContent = str; |
|
|
} else { |
|
|
} else { |
|
|
this.pluginContent = data.html; |
|
|
this.pluginContent = data.html; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
console.log(this.pluginContent); |
|
|
|
|
|
|
|
|
if (data.js) { |
|
|
if (data.js) { |
|
|
if (reg.test(data.js)) { |
|
|
if (reg.test(data.js)) { |
|
|
const str = data.js.replace(RegExp.$1, this.pluginTaskId); |
|
|
const uuid = RegExp.$1; |
|
|
|
|
|
const str = data.js.replaceAll(uuid, `p${this.pluginTaskId}`); |
|
|
this.handleDom(str); |
|
|
this.handleDom(str); |
|
|
} else { |
|
|
} else { |
|
|
this.handleDom(data.js); |
|
|
this.handleDom(data.js); |
|
@ -74,7 +103,9 @@ export default { |
|
|
const scriptDom = document.createElement('script'); |
|
|
const scriptDom = document.createElement('script'); |
|
|
scriptDom.id = `p${pluginId}`; |
|
|
scriptDom.id = `p${pluginId}`; |
|
|
scriptDom.innerHTML = js; |
|
|
scriptDom.innerHTML = js; |
|
|
document.body.append(scriptDom); |
|
|
this.$nextTick(() => { |
|
|
|
|
|
document.body.append(scriptDom); |
|
|
|
|
|
}); |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
}, |
|
|
}, |
|
|