fix: 场景联动

This commit is contained in:
100011797 2023-03-28 15:06:19 +08:00
parent a1614752f2
commit 716df45891
10 changed files with 80 additions and 52 deletions

View File

@ -1,6 +1,6 @@
<template> <template>
<a-space align="end"> <j-space align="end">
<a-upload <j-upload
v-model:fileList="modelValue.upload" v-model:fileList="modelValue.upload"
name="file" name="file"
:action="FILE_UPLOAD" :action="FILE_UPLOAD"
@ -12,21 +12,22 @@
:showUploadList="false" :showUploadList="false"
@change="uploadChange" @change="uploadChange"
> >
<a-button> <j-button>
<template #icon><AIcon type="UploadOutlined" /></template> <template #icon><AIcon type="UploadOutlined" /></template>
文件上传 文件上传
</a-button> </j-button>
</a-upload> </j-upload>
<div style="margin-left: 20px"> <div style="margin-left: 20px">
<a-space> <j-space>
下载模板
<a @click="downFile('xlsx')">.xlsx</a> <a @click="downFile('xlsx')">.xlsx</a>
<a @click="downFile('csv')">.csv</a> <a @click="downFile('csv')">.csv</a>
</a-space> </j-space>
</div> </div>
</a-space> </j-space>
<div style="margin-top: 20px" v-if="importLoading"> <div style="margin-top: 20px" v-if="importLoading">
<a-badge v-if="flag" status="processing" text="进行中" /> <j-badge v-if="flag" status="processing" text="进行中" />
<a-badge v-else status="success" text="已完成" /> <j-badge v-else status="success" text="已完成" />
<span>总数量{{ count }}</span> <span>总数量{{ count }}</span>
<p style="color: red">{{ errMessage }}</p> <p style="color: red">{{ errMessage }}</p>
</div> </div>

View File

@ -4,7 +4,6 @@
width="800px" width="800px"
:visible="true" :visible="true"
title="导入" title="导入"
@ok="handleSave"
@cancel="handleCancel" @cancel="handleCancel"
> >
<div style="margin-top: 10px"> <div style="margin-top: 10px">
@ -44,6 +43,9 @@
</j-row> </j-row>
</j-form> </j-form>
</div> </div>
<template #footer>
<j-button type="primary" @click="handleSave">关闭</j-button>
</template>
</j-modal> </j-modal>
</template> </template>
@ -100,6 +102,7 @@ const handleCancel = () => {
}; };
const handleSave = () => { const handleSave = () => {
emit('close');
emit('save'); emit('save');
}; };
</script> </script>

View File

@ -193,6 +193,8 @@ watch(
} }
}); });
Object.assign(modelRef, newValue); Object.assign(modelRef, newValue);
// description describe
modelRef.describe = newValue?.describe || newValue?.description
}, },
{ immediate: true, deep: true }, { immediate: true, deep: true },
); );

View File

@ -117,11 +117,16 @@ const routeChange = async (id: string) => {
}); });
} }
} }
watch(
() => route.params.id, // watch(
(id) => routeChange(id as string), // () => route.params.id,
{ immediate: true } // (id) => routeChange(id as string),
) // { immediate: true }
// )
onMounted(() => {
routeChange(route.params.id as string)
})
watch( watch(
() => [props.visible, props.type], () => [props.visible, props.type],

View File

@ -12,7 +12,7 @@
placeholder="请输入时间" placeholder="请输入时间"
v-model:value="_value" v-model:value="_value"
:precision="3" :precision="3"
:min="0" :min="0.001"
:max="65535" :max="65535"
> >
<template #addonAfter> <template #addonAfter>
@ -60,8 +60,8 @@ const unit = ref<'seconds' | 'minutes' | 'hours'>(
watch( watch(
() => props.value, () => props.value,
(newVal) => { (newVal) => {
_value.value = newVal?.time || 0 _value.value = newVal?.time || 0;
unit.value = newVal?.unit || 'seconds' unit.value = newVal?.unit || 'seconds';
}, },
{ {
immediate: true, immediate: true,
@ -73,17 +73,21 @@ const onCancel = () => {
emit('cancel'); emit('cancel');
}; };
const onOk = () => { const onOk = () => {
if (unref(_value) || unref(_value) === 0) { if (unref(_value)) {
emit(
'save',
{
time: _value.value,
unit: unit.value,
},
{
name: `${_value.value} ${
timeUnitEnum[unit.value]
}执行后续动作`,
},
);
} else { } else {
onlyMessage('请输入时间', 'error'); onlyMessage('请输入时间', 'error');
} }
emit(
'save',
{
time: _value.value,
unit: unit.value,
},
{ name: `${_value.value} ${timeUnitEnum[unit.value]}后,执行后续动作` },
);
}; };
</script> </script>

View File

@ -172,9 +172,8 @@ const handleClick = (_detail: any) => {
}; };
watch(() => props.value?.[0]?.value, (newVal) => { watch(() => props.value?.[0]?.value, (newVal) => {
console.log(newVal, '123')
if(newVal){ if(newVal){
detail(newVal[0]?.value).then(resp => { detail(newVal).then(resp => {
emit('change', resp.result); emit('change', resp.result);
}) })
} }

View File

@ -99,7 +99,7 @@ const handleItem = (data: any) => {
valueType: data.valueType ? data.valueType.type : '-', valueType: data.valueType ? data.valueType.type : '-',
format: data.valueType ? data.valueType.format : undefined, format: data.valueType ? data.valueType.format : undefined,
options: data.valueType ? data.valueType.elements : undefined, options: data.valueType ? data.valueType.elements : undefined,
value: data.value, value: data?.value,
}; };
}; };
@ -135,9 +135,9 @@ watch(
options.value = newTag.map((item: any) => { options.value = newTag.map((item: any) => {
return { label: item.name, value: item.id, ...item }; return { label: item.name, value: item.id, ...item };
}); });
if (newVal && newVal[0] && newVal[0].name && newTag && newTag.length) { if (newVal && newVal[0] && newVal[0]?.name && newTag && newTag.length) {
const names: string[] = []; const names: string[] = [];
const newTagList = newVal[0].value const newTagList = newVal[0]?.value
.filter((valueItem: any) => { .filter((valueItem: any) => {
return newTag.some( return newTag.some(
(item: any) => valueItem.column === item.id, (item: any) => valueItem.column === item.id,
@ -151,8 +151,8 @@ watch(
names.push(oldItem.name); names.push(oldItem.name);
return { return {
...handleItem(oldItem), ...handleItem(oldItem),
value: valueItem.value, value: valueItem?.value,
type: valueItem.type, type: valueItem?.type,
}; };
} }
return valueItem; return valueItem;
@ -169,12 +169,12 @@ watch(
); );
const onValueChange = () => { const onValueChange = () => {
const _data = tagList.value.filter((item) => !!item.value); const _data = tagList.value.filter((item) => !!item?.value);
const newValue = _data.map((item: any) => { const newValue = _data.map((item: any) => {
return { return {
column: item.id, column: item.id,
type: item.type, type: item?.type,
value: item.value, value: item?.value,
}; };
}); });
emits('update:value', [{ value: newValue, name: '标签' }]); emits('update:value', [{ value: newValue, name: '标签' }]);

View File

@ -77,10 +77,10 @@
钉钉 钉钉
</span> </span>
<span class="notify-text-highlight">{{ <span class="notify-text-highlight">{{
options?.orgName || '' options?.sendTo || ''
}}</span> }}</span>
<span class="notify-text-highlight">{{ <span class="notify-text-highlight">{{
options?.sendTo || '' options?.orgName || ''
}}</span> }}</span>
发送 发送
<span class="notify-text-highlight"> <span class="notify-text-highlight">
@ -107,10 +107,10 @@
微信 微信
</span> </span>
<span class="notify-text-highlight">{{ <span class="notify-text-highlight">{{
options?.orgName || '' options?.sendTo || ''
}}</span> }}</span>
<span class="notify-text-highlight">{{ <span class="notify-text-highlight">{{
options?.sendTo || '' options?.orgName || ''
}}</span> }}</span>
<span class="notify-text-highlight">{{ <span class="notify-text-highlight">{{
options?.tagName || '' options?.tagName || ''

View File

@ -44,7 +44,12 @@
v-else-if="getType(item) === 'link'" v-else-if="getType(item) === 'link'"
v-model:value="modelRef[item.id]" v-model:value="modelRef[item.id]"
/> />
<BuildIn v-else :item="item" v-model:value="modelRef[item.id]" /> <BuildIn
v-else
:item="item"
v-model:value="modelRef[item.id]"
@change="(val) => onChange(val, 'build-in')"
/>
</j-form-item> </j-form-item>
</j-form> </j-form>
</template> </template>
@ -79,7 +84,6 @@ const formRef = ref();
const modelRef = reactive({}); const modelRef = reactive({});
watchEffect(() => { watchEffect(() => {
console.log(props?.value)
Object.assign(modelRef, props?.value); Object.assign(modelRef, props?.value);
}); });
@ -88,6 +92,9 @@ const getType = (item: any) => {
}; };
const checkValue = (_rule: any, value: any, item: any) => { const checkValue = (_rule: any, value: any, item: any) => {
if(!value){
return Promise.resolve();
}
const type = item.expands?.businessType || item?.type; const type = item.expands?.businessType || item?.type;
if (type === 'file') { if (type === 'file') {
return Promise.resolve(); return Promise.resolve();
@ -153,7 +160,7 @@ const checkValue = (_rule: any, value: any, item: any) => {
if ( if (
props.notify.notifyType && props.notify.notifyType &&
['sms', 'voice'].includes(props?.notify?.notifyType) && ['sms', 'voice'].includes(props?.notify?.notifyType) &&
value?.source !== 'relation' value?.source !== 'relation' && value?.value
) { ) {
const reg = /^[1][3-9]\d{9}$/; const reg = /^[1][3-9]\d{9}$/;
if (!reg.test(value?.value)) { if (!reg.test(value?.value)) {
@ -173,6 +180,8 @@ const onChange = (val: any, type: any) => {
emit('change', { tagName: val }); emit('change', { tagName: val });
} else if (type === 'user') { } else if (type === 'user') {
emit('change', { sendTo: val }); emit('change', { sendTo: val });
} else if (type === 'build-in') {
// emit('change', { sendTo: val });
} }
}; };

View File

@ -16,12 +16,14 @@
placeholder="请选择参数" placeholder="请选择参数"
style="width: calc(100% - 120px)" style="width: calc(100% - 120px)"
:fieldNames="{ label: 'name', value: 'id' }" :fieldNames="{ label: 'name', value: 'id' }"
@change="(val) => itemOnChange(undefined, val)" @change="(val, label) => itemOnChange(undefined, val, label)"
> >
<template #title="{ fullName, description }"> <template #title="{ fullName, description }">
<j-space> <j-space>
{{ fullName }} {{ fullName }}
<span style="color: grey; margin-left: 5px">{{ description }}</span> <span style="color: grey; margin-left: 5px">{{
description
}}</span>
</j-space> </j-space>
</template> </template>
</j-tree-select> </j-tree-select>
@ -84,7 +86,7 @@ const props = defineProps({
}, },
}); });
const emit = defineEmits(['update:value']); const emit = defineEmits(['update:value', 'change']);
const source = computed(() => { const source = computed(() => {
return props.value?.source || 'fixed'; return props.value?.source || 'fixed';
@ -97,15 +99,18 @@ const sourceChange = (val: any) => {
emit('update:value', { emit('update:value', {
...props.value, ...props.value,
source: val, source: val,
value: undefined value: undefined,
}); });
}; };
const itemOnChange = (val: any, _upperKey?: string) => { const itemOnChange = (val: any, _upperKey?: string, label?: any) => {
emit('update:value', { emit('update:value', {
...props.value, ...props.value,
value: val, value: val,
upperKey: _upperKey upperKey: _upperKey,
});
emit('change', {
sendTo: label?.[0] || val,
}); });
}; };
@ -164,7 +169,7 @@ watch(
watch( watch(
() => props.value.upperKey, () => props.value.upperKey,
(newVal) => { (newVal) => {
upperKey.value = newVal upperKey.value = newVal;
}, },
{ immediate: true }, { immediate: true },
); );