补充代码

This commit is contained in:
wyy
2023-11-27 13:46:28 +08:00
parent 275df4962c
commit 3c6080e5ed
7 changed files with 37 additions and 23 deletions

View File

@@ -152,9 +152,7 @@ const destroyTinymce = () => {
const resourcesUrl = import.meta.env.VITE_APP_RESOURCES_URL
// eslint-disable-next-line no-unused-vars
const imageSuccessCBK = (response, file, fileList) => {
fileList.forEach(v => {
window.tinymce.get(props.id).insertContent(`<img alt="" src="${resourcesUrl + v.response.data}" >`)
})
window.tinymce.get(props.id).insertContent(`<img alt="" src="${resourcesUrl + file.response.data}" >`)
}
/**

View File

@@ -27,7 +27,7 @@ export const scoreProdStore = defineStore('prod', {
removeSkuTag (tagIndex) {
this.skuTags.splice(tagIndex, 1)
},
removeSkuTagItem ({ tagIndex, tagItemIndex }) {
removeSkuTagItem (tagIndex, tagItemIndex) {
this.skuTags[tagIndex].tagItems.splice(tagItemIndex, 1)
},
addSkuTagItem ({ tagIndex, tagItem }) {

View File

@@ -512,4 +512,7 @@ const changeOrder = (orderNumber) => {
}
}
}
:deep(.el-steps--horizontal) {
flex: 25% 1 1;
}
</style>

View File

@@ -160,8 +160,8 @@ let initing = false
const tableLeftTitles = computed(() => {
const res = []
for (let i = 0; i < skuTags.length; i++) {
const skuTag = skuTags[i]
for (let i = 0; i < skuTags.value.length; i++) {
const skuTag = skuTags.value[i]
res.push(skuTag.tagName)
}
return res

View File

@@ -126,9 +126,10 @@ const type = ref(0)
const tagItemName = ref('')
const tagItemInputs = ref([])
const dbTagValues = ref([]) // 根据选定的规格所查询出来的规格值
const dbTags = ref([]) // 数据库中的规格
let tagName = ''
let tagNameIndex = 0
let dbTags = [] // 数据库中的规格
let maxValueId = 0 // 规格值id最大
let maxPropId = 0 // 规格id 最大
let initing = false
@@ -138,7 +139,20 @@ const skuTags = computed({
set (val) { prod.updateSkuTags(val) }
})
const unUseTags = ref([])
/**
* 未使用的规格, 通过计算属性计算
*/
const unUseTags = computed(() => {
const res = []
for (let i = 0; i < dbTags.value.length; i++) {
const dbTag = dbTags.value[i]
const specIndex = skuTags.value?.findIndex(tag => tag.tagName === dbTag.propName)
if (specIndex === -1) {
res.push(dbTag)
}
}
return res
})
const defalutSku = computed(() => {
return prod.defalutSku
@@ -245,18 +259,9 @@ onMounted(() => {
params: http.adornParams()
})
.then(({ data }) => {
dbTags = data
dbTags.value = data
if (data) {
maxPropId = Math.max.apply(Math, data.map(item => item.propId))
const res = []
for (let i = 0; i < dbTags.length; i++) {
const dbTag = dbTags[i]
const specIndex = skuTags.value?.findIndex(tag => tag.tagName === dbTag.propName)
if (specIndex === -1) {
res.push(dbTag)
}
}
unUseTags.value = res
} else {
maxPropId = 0
}
@@ -310,7 +315,7 @@ defineExpose({ init })
* 显示规格名、规格值输入框
*/
const shopTagInput = () => {
isShowTagInput.value = !isShowTagInput.value
isShowTagInput.value = true
}
/**
@@ -378,12 +383,12 @@ const handleTagClick = () => {
dbTagValues.value = []
addTagInput.value.selectValues = []
// 判断规格名输入的值是否为数据库中已有的值
const specsIndex = dbTags.findIndex(spec => spec.propName === addTagInput.value.propName)
const specsIndex = dbTags.value?.findIndex(spec => spec.propName === addTagInput.value.propName)
// 如果不是,则说明为用户随便输入
if (specsIndex === -1) return
// 如果数据库已有该规格名则获取根据id获取该规格名称含有的规格值
http({
url: http.adornUrl(`/prod/spec/listSpecValue/${dbTags[specsIndex].propId}`),
url: http.adornUrl(`/prod/spec/listSpecValue/${dbTags.value[specsIndex].propId}`),
method: 'get',
params: http.adornParams()
}).then(({ data }) => {
@@ -523,4 +528,7 @@ const checkTagItem = (tagIndex) => {
margin-left: 18px;
padding-bottom:8px;
}
.el-form-item__content div {
width: 100%;
}
</style>

View File

@@ -268,7 +268,9 @@ const onSubmit = Debounce(() => {
type: 'success',
duration: 1500,
onClose: () => {
router.push({ name: 'prod-prodList' })
router.push({
path: '/prod/prodList'
})
emit('refreshDataList')
}
})

View File

@@ -22,7 +22,7 @@
:expand-on-click-node="false"
>
<template #default="{ node, data }">
<span>{{ node.label }}</span>
<span class="addr-name">{{ node.label }}</span>
<span>
<el-button
type="text"
@@ -159,4 +159,7 @@ const filterNode = (value, data) => {
float: right;
}
}
:deep(.el-tree-node) .addr-name {
width: 100%;
}
</style>