feat(uniapp): 多行展示商品名
This commit is contained in:
1 parent
0e117875c7
commit
c902d018d9
3 files changed
+34
-22
No files matched your search
@@ -957,6 +957,17 @@ $menu-divider-height: 2rpx;
|
|||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 商品名:最多三行展示,超出省略
|
||||||
|
@mixin text-ellipsis-3 {
|
||||||
|
display: -webkit-box;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: normal;
|
||||||
|
word-break: break-all;
|
||||||
|
-webkit-box-orient: vertical;
|
||||||
|
-webkit-line-clamp: 3;
|
||||||
|
}
|
||||||
|
|
||||||
@mixin quantity-control($size) {
|
@mixin quantity-control($size) {
|
||||||
.btn,
|
.btn,
|
||||||
.number {
|
.number {
|
||||||
@@ -1247,8 +1258,10 @@ page {
|
|||||||
.name {
|
.name {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
margin-bottom: $menu-gap-sm;
|
margin-bottom: $menu-gap-sm;
|
||||||
font-size: $font-size-base;
|
font-size: 24rpx;
|
||||||
@include text-ellipsis;
|
line-height: 32rpx;
|
||||||
|
font-weight: 600;
|
||||||
|
@include text-ellipsis-3;
|
||||||
}
|
}
|
||||||
|
|
||||||
.tips {
|
.tips {
|
||||||
|
|||||||
@@ -185,7 +185,7 @@ import { getPage, addObj, delObj } from '@/api/tools/material'
|
|||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
modelValue: {
|
modelValue: {
|
||||||
type: Array,
|
type: [String, Array],
|
||||||
default() {
|
default() {
|
||||||
return []
|
return []
|
||||||
}
|
}
|
||||||
@@ -280,15 +280,10 @@ function deleteMaterial(index) {
|
|||||||
cancelButtonText: '取消',
|
cancelButtonText: '取消',
|
||||||
type: 'warning'
|
type: 'warning'
|
||||||
}).then(function () {
|
}).then(function () {
|
||||||
value.value.splice(index, 1)
|
const nextValue = [...value.value]
|
||||||
|
nextValue.splice(index, 1)
|
||||||
urls.value = []
|
urls.value = []
|
||||||
// if (urls.value.length > 1 || props.num > 1) {
|
emitMaterialValue(nextValue)
|
||||||
// emit('update:modelValue', urls.value)
|
|
||||||
// } else {
|
|
||||||
// emit('update:modelValue', urls.value[0])
|
|
||||||
// }
|
|
||||||
emit('update:modelValue', value.value)
|
|
||||||
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
function toSeleteMaterial() {
|
function toSeleteMaterial() {
|
||||||
@@ -472,20 +467,16 @@ function beforeUpload(file) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const emit = defineEmits(['update:modelValue'])
|
const emit = defineEmits(['update:modelValue'])
|
||||||
|
function emitMaterialValue(materials) {
|
||||||
|
emit('update:modelValue', props.num === 1 ? (materials[0] || '') : materials)
|
||||||
|
}
|
||||||
|
|
||||||
function sureUrls() {
|
function sureUrls() {
|
||||||
console.log('value.value.length:',value.value.length)
|
console.log('value.value.length:',value.value.length)
|
||||||
urls.value.forEach((item) => {
|
const nextValue = [...value.value, ...urls.value]
|
||||||
value.value[value.value.length] = item
|
console.log('urls.value:',nextValue)
|
||||||
})
|
|
||||||
console.log('urls.value:',value.value)
|
|
||||||
listDialogVisible.value = false
|
listDialogVisible.value = false
|
||||||
if (urls.value.length > 1 || props.num > 1) {
|
emitMaterialValue(nextValue)
|
||||||
emit('update:modelValue', value.value)
|
|
||||||
} else {
|
|
||||||
emit('update:modelValue', value.value[0])
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -497,6 +497,9 @@ const getList = async () => {
|
|||||||
|
|
||||||
/** 提交表单 */
|
/** 提交表单 */
|
||||||
const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调
|
const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调
|
||||||
|
const normalizeSingleImage = (image: string | string[] | null | undefined) =>
|
||||||
|
Array.isArray(image) ? (image[0] || '') : (image || '')
|
||||||
|
|
||||||
const submitForm = async () => {
|
const submitForm = async () => {
|
||||||
// 校验表单
|
// 校验表单
|
||||||
if (!formRef) return
|
if (!formRef) return
|
||||||
@@ -520,6 +523,11 @@ const submitForm = async () => {
|
|||||||
formValidate.value.items = attrs.value;
|
formValidate.value.items = attrs.value;
|
||||||
formValidate.value.attrs = manyFormValidate.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){
|
if(formValidate.value.spec_type === 1 && manyFormValidate.value.length===0){
|
||||||
message.warning('请点击生成规格!');
|
message.warning('请点击生成规格!');
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user