refactor(material-center): 优化标签选择逻辑和组件模式
This commit is contained in:
@ -71,6 +71,7 @@ export default defineComponent({
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleTagChange = (value, option, record) => {
|
const handleTagChange = (value, option, record) => {
|
||||||
|
// console.log('handleTagChange', value);
|
||||||
if (value.length < 6) {
|
if (value.length < 6) {
|
||||||
record.tag_ids = value;
|
record.tag_ids = value;
|
||||||
} else {
|
} else {
|
||||||
@ -88,8 +89,8 @@ export default defineComponent({
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (record.tag_ids.length >= 5) {
|
if (record.tag_ids.length === 5) {
|
||||||
message.warning('最多选择5个');
|
// message.warning('最多选择5个');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,7 +104,8 @@ export default defineComponent({
|
|||||||
});
|
});
|
||||||
e.target.value = '';
|
e.target.value = '';
|
||||||
|
|
||||||
record.tag_ids = [...record.tag_ids, data.id];
|
record.tag_ids = record.tag_ids.filter((item) => item !== inputValue);
|
||||||
|
record.tag_ids.push(data.id);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
message.error('添加标签失败');
|
message.error('添加标签失败');
|
||||||
@ -260,7 +262,6 @@ export default defineComponent({
|
|||||||
|
|
||||||
const onConfirm = async () => {
|
const onConfirm = async () => {
|
||||||
try {
|
try {
|
||||||
submitLoading.value = true;
|
|
||||||
const hasUploading = uploadData.value.some((item) => item.uploadStatus === EnumUploadStatus.uploading);
|
const hasUploading = uploadData.value.some((item) => item.uploadStatus === EnumUploadStatus.uploading);
|
||||||
if (hasUploading) {
|
if (hasUploading) {
|
||||||
modalRef.value = Modal.warning({
|
modalRef.value = Modal.warning({
|
||||||
@ -272,6 +273,7 @@ export default defineComponent({
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
submitLoading.value = true;
|
||||||
const raw_materials = uploadData.value.filter((item) => item.uploadStatus !== EnumUploadStatus.error);
|
const raw_materials = uploadData.value.filter((item) => item.uploadStatus !== EnumUploadStatus.error);
|
||||||
const { code } = await postBatchRawMaterial({ raw_materials });
|
const { code } = await postBatchRawMaterial({ raw_materials });
|
||||||
if (code === 200) {
|
if (code === 200) {
|
||||||
@ -387,7 +389,7 @@ export default defineComponent({
|
|||||||
<Select
|
<Select
|
||||||
disabled={record.uploadStatus === EnumUploadStatus.uploading}
|
disabled={record.uploadStatus === EnumUploadStatus.uploading}
|
||||||
value={record.tag_ids}
|
value={record.tag_ids}
|
||||||
mode="multiple"
|
mode="tags"
|
||||||
size="middle"
|
size="middle"
|
||||||
placeholder="请选择标签"
|
placeholder="请选择标签"
|
||||||
allowClear
|
allowClear
|
||||||
|
|||||||
@ -126,8 +126,8 @@ export default {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (form.value.tag_ids.length >= 5) {
|
if (form.value.tag_ids.length === 5) {
|
||||||
message.warning('最多选择5个');
|
// message.warning('最多选择5个');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -141,7 +141,8 @@ export default {
|
|||||||
});
|
});
|
||||||
e.target.value = '';
|
e.target.value = '';
|
||||||
|
|
||||||
form.value.tag_ids = [...form.value.tag_ids, data.id];
|
form.value.tag_ids = form.value.tag_ids.filter((item) => item !== inputValue);
|
||||||
|
form.value.tag_ids.push(data.id);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
message.error('添加标签失败');
|
message.error('添加标签失败');
|
||||||
@ -203,7 +204,7 @@ export default {
|
|||||||
<FormItem label="标签" name="tag_ids" v-model:value={form.value.tag_ids}>
|
<FormItem label="标签" name="tag_ids" v-model:value={form.value.tag_ids}>
|
||||||
<Select
|
<Select
|
||||||
value={form.value.tag_ids}
|
value={form.value.tag_ids}
|
||||||
mode="multiple"
|
mode="tags"
|
||||||
size="large"
|
size="large"
|
||||||
placeholder="请选择标签"
|
placeholder="请选择标签"
|
||||||
allowClear
|
allowClear
|
||||||
|
|||||||
Reference in New Issue
Block a user