feat(uniapp): 多行展示商品名
This commit is contained in:
1 parent
0e117875c7
commit
c902d018d9
3 files changed
+34
-22
No files matched your search
@@ -185,7 +185,7 @@ import { getPage, addObj, delObj } from '@/api/tools/material'
|
||||
|
||||
const props = defineProps({
|
||||
modelValue: {
|
||||
type: Array,
|
||||
type: [String, Array],
|
||||
default() {
|
||||
return []
|
||||
}
|
||||
@@ -280,15 +280,10 @@ function deleteMaterial(index) {
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(function () {
|
||||
value.value.splice(index, 1)
|
||||
const nextValue = [...value.value]
|
||||
nextValue.splice(index, 1)
|
||||
urls.value = []
|
||||
// if (urls.value.length > 1 || props.num > 1) {
|
||||
// emit('update:modelValue', urls.value)
|
||||
// } else {
|
||||
// emit('update:modelValue', urls.value[0])
|
||||
// }
|
||||
emit('update:modelValue', value.value)
|
||||
|
||||
emitMaterialValue(nextValue)
|
||||
})
|
||||
}
|
||||
function toSeleteMaterial() {
|
||||
@@ -472,20 +467,16 @@ function beforeUpload(file) {
|
||||
}
|
||||
|
||||
const emit = defineEmits(['update:modelValue'])
|
||||
function emitMaterialValue(materials) {
|
||||
emit('update:modelValue', props.num === 1 ? (materials[0] || '') : materials)
|
||||
}
|
||||
|
||||
function sureUrls() {
|
||||
console.log('value.value.length:',value.value.length)
|
||||
urls.value.forEach((item) => {
|
||||
value.value[value.value.length] = item
|
||||
})
|
||||
console.log('urls.value:',value.value)
|
||||
const nextValue = [...value.value, ...urls.value]
|
||||
console.log('urls.value:',nextValue)
|
||||
listDialogVisible.value = false
|
||||
if (urls.value.length > 1 || props.num > 1) {
|
||||
emit('update:modelValue', value.value)
|
||||
} else {
|
||||
emit('update:modelValue', value.value[0])
|
||||
}
|
||||
|
||||
|
||||
emitMaterialValue(nextValue)
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
@@ -497,6 +497,9 @@ const getList = async () => {
|
||||
|
||||
/** 提交表单 */
|
||||
const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调
|
||||
const normalizeSingleImage = (image: string | string[] | null | undefined) =>
|
||||
Array.isArray(image) ? (image[0] || '') : (image || '')
|
||||
|
||||
const submitForm = async () => {
|
||||
// 校验表单
|
||||
if (!formRef) return
|
||||
@@ -520,6 +523,11 @@ const submitForm = async () => {
|
||||
formValidate.value.items = attrs.value;
|
||||
formValidate.value.attrs = manyFormValidate.value;
|
||||
}
|
||||
formValidate.value.image = normalizeSingleImage(formValidate.value.image)
|
||||
formValidate.value.attrs = formValidate.value.attrs.map((item) => ({
|
||||
...item,
|
||||
pic: normalizeSingleImage(item.pic)
|
||||
}))
|
||||
if(formValidate.value.spec_type === 1 && manyFormValidate.value.length===0){
|
||||
message.warning('请点击生成规格!');
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user