|
@ -20,56 +20,64 @@ |
|
|
</view> |
|
|
</view> |
|
|
</template> |
|
|
</template> |
|
|
|
|
|
|
|
|
<script setup> |
|
|
<script> |
|
|
import { computed, ref, onMounted } from 'vue'; |
|
|
import { mapState, mapGetters } from 'vuex'; |
|
|
import { useStore } from 'vuex'; |
|
|
|
|
|
|
|
|
|
|
|
const props = defineProps({ |
|
|
export default { |
|
|
|
|
|
name: 'RenderHtmlFragment', |
|
|
|
|
|
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: '', type: String }, |
|
|
pluginTaskId: { default: '', type: String }, |
|
|
businessPluginId: { default: '', type: String }, |
|
|
businessPluginId: { default: '', type: String }, |
|
|
param: { type: String, default: '' }, |
|
|
param: { type: String, default: '' }, |
|
|
}); |
|
|
}, |
|
|
|
|
|
data() { |
|
|
const store = useStore(); |
|
|
return { |
|
|
const roleId = computed(() => store.state.role.roleId); |
|
|
pluginInfo: null, |
|
|
const token = computed(() => store.state.user.token); |
|
|
}; |
|
|
const userId = computed(() => store.getters['user/userId']); |
|
|
}, |
|
|
const projectId = computed(() => store.getters['project/projectId']); |
|
|
computed: { |
|
|
const pluginInfo = ref(null); // 插件的具体数据 |
|
|
...mapState(['allPlugin']), |
|
|
|
|
|
...mapState('role', ['roleId']), |
|
|
|
|
|
...mapState('user', ['token']), |
|
|
|
|
|
...mapGetters('project', ['projectId']), |
|
|
|
|
|
...mapGetters('user', ['userId']), |
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
onMounted(() => { |
|
|
mounted() { |
|
|
getPlugin(); |
|
|
this.getPlugin(); |
|
|
}); |
|
|
}, |
|
|
// 获取插件信息 |
|
|
methods: { |
|
|
async function getPlugin() { |
|
|
getPlugin() { |
|
|
const allPlugin = uni.$storage.getStorageSync('allPlugin'); |
|
|
const allPlugin = this.allPlugin || uni.$storage.getStorageSync('allPlugin'); |
|
|
if (allPlugin && JSON.parse(allPlugin)) { |
|
|
if (allPlugin && JSON.parse(allPlugin)) { |
|
|
// 有本地数据 |
|
|
// 有本地数据 |
|
|
try { |
|
|
try { |
|
|
const pluginLists = JSON.parse(allPlugin); |
|
|
const pluginLists = JSON.parse(allPlugin); |
|
|
// pluginLists 肯能没有find方法,交给catch处理 |
|
|
// pluginLists 肯能没有find方法,交给catch处理 |
|
|
const pluginTarget = pluginLists.find(item => item.id === props.pluginId); |
|
|
const pluginTarget = pluginLists.find(item => item.id === this.pluginId); |
|
|
pluginInfo.value = pluginTarget || null; |
|
|
this.pluginInfo = pluginTarget || null; |
|
|
} catch (error) { |
|
|
} catch (error) { |
|
|
console.error('error: ', error); |
|
|
console.error('error: ', error); |
|
|
pluginInfo.value = null; |
|
|
this.pluginInfo = null; |
|
|
} |
|
|
} |
|
|
} else { |
|
|
} else { |
|
|
// 没有本地数据 API 查询 |
|
|
// 没有本地数据 API 查询 |
|
|
const params = { businessPluginId: props.businessPluginId }; |
|
|
const params = { businessPluginId: this.businessPluginId }; |
|
|
uni.$catchReq.getOtherPlugin(params, (err, res) => { |
|
|
uni.$catchReq.getOtherPlugin(params, (err, res) => { |
|
|
if (err) { |
|
|
if (err) { |
|
|
console.error('err: ', err); |
|
|
console.error('err: ', err); |
|
|
pluginInfo.value = null; |
|
|
this.pluginInfo = null; |
|
|
} else { |
|
|
} else { |
|
|
pluginInfo.value = res || null; |
|
|
this.pluginInfo = res || null; |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
} |
|
|
}, |
|
|
|
|
|
}, |
|
|
|
|
|
}; |
|
|
</script> |
|
|
</script> |
|
|
|
|
|
|
|
|
<script module="project" lang="renderjs"> |
|
|
<script module="project" lang="renderjs"> |
|
|