|
@@ -28,6 +28,28 @@
|
|
>
|
|
>
|
|
<el-input v-model="form.product_name_cn"></el-input>
|
|
<el-input v-model="form.product_name_cn"></el-input>
|
|
</el-form-item>
|
|
</el-form-item>
|
|
|
|
+
|
|
|
|
+ <template v-if="id">
|
|
|
|
+ <el-form-item
|
|
|
|
+ label="材质"
|
|
|
|
+ prop="material"
|
|
|
|
+ >
|
|
|
|
+ <el-input v-model="form.material"></el-input>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <el-form-item
|
|
|
|
+ label="颜色"
|
|
|
|
+ prop="colour"
|
|
|
|
+ >
|
|
|
|
+ <el-input v-model="form.colour"></el-input>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <el-form-item
|
|
|
|
+ label="尺寸"
|
|
|
|
+ prop="size"
|
|
|
|
+ >
|
|
|
|
+ <el-input v-model="form.size"></el-input>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ </template>
|
|
|
|
+
|
|
<el-form-item
|
|
<el-form-item
|
|
prop=""
|
|
prop=""
|
|
label="产品图片"
|
|
label="产品图片"
|
|
@@ -77,7 +99,7 @@ import {
|
|
import type { FormInstance } from 'element-plus'
|
|
import type { FormInstance } from 'element-plus'
|
|
import { $t } from '@/i18n/index'
|
|
import { $t } from '@/i18n/index'
|
|
import imageUpload from '@/components/ImageUpload.vue'
|
|
import imageUpload from '@/components/ImageUpload.vue'
|
|
-import { applySKU } from '@/api/indent'
|
|
|
|
|
|
+import { applySKU, getProductDetailByID } from '@/api/indent'
|
|
|
|
|
|
defineComponent({
|
|
defineComponent({
|
|
name: 'ComponentApplySku',
|
|
name: 'ComponentApplySku',
|
|
@@ -86,7 +108,15 @@ const show = ref(false)
|
|
const loading = ref(false)
|
|
const loading = ref(false)
|
|
const imageList = ref([])
|
|
const imageList = ref([])
|
|
|
|
|
|
-const { visible = false } = defineProps<{ visible: boolean }>()
|
|
|
|
|
|
+const {
|
|
|
|
+ visible = false,
|
|
|
|
+ id = '',
|
|
|
|
+ auditUser = '',
|
|
|
|
+} = defineProps<{
|
|
|
|
+ visible: boolean
|
|
|
|
+ id?: string
|
|
|
|
+ auditUser?: string
|
|
|
|
+}>()
|
|
const $emit = defineEmits(['update:visible', 'apply'])
|
|
const $emit = defineEmits(['update:visible', 'apply'])
|
|
|
|
|
|
const rules = {
|
|
const rules = {
|
|
@@ -104,19 +134,89 @@ const rules = {
|
|
trigger: 'change',
|
|
trigger: 'change',
|
|
},
|
|
},
|
|
],
|
|
],
|
|
|
|
+ material: [
|
|
|
|
+ {
|
|
|
|
+ required: true,
|
|
|
|
+ message: $t('text_please_input'),
|
|
|
|
+ trigger: 'change',
|
|
|
|
+ },
|
|
|
|
+ ],
|
|
|
|
+ colour: [
|
|
|
|
+ {
|
|
|
|
+ required: true,
|
|
|
|
+ message: $t('text_please_input'),
|
|
|
|
+ trigger: 'change',
|
|
|
|
+ },
|
|
|
|
+ ],
|
|
|
|
+ size: [
|
|
|
|
+ {
|
|
|
|
+ required: true,
|
|
|
|
+ message: $t('text_please_input'),
|
|
|
|
+ trigger: 'change',
|
|
|
|
+ },
|
|
|
|
+ ],
|
|
}
|
|
}
|
|
watch(
|
|
watch(
|
|
() => visible,
|
|
() => visible,
|
|
() => {
|
|
() => {
|
|
show.value = visible
|
|
show.value = visible
|
|
resetData()
|
|
resetData()
|
|
|
|
+ if (id && visible) {
|
|
|
|
+ loading.value = true
|
|
|
|
+ getProductDetailByID({ id })
|
|
|
|
+ .then((response: any) => {
|
|
|
|
+ if (response.code === 1) {
|
|
|
|
+ const data = response.result
|
|
|
|
+ form.value.product_name = data.product_name
|
|
|
|
+ form.value.product_name_cn = data.product_name_cn
|
|
|
|
+ form.value.material = data.material
|
|
|
|
+ form.value.colour = data.colour
|
|
|
|
+ form.value.size = data.size
|
|
|
|
+ form.value.id = data.id
|
|
|
|
+ form.value.status = data.status
|
|
|
|
+ if (data.images) {
|
|
|
|
+ imageList.value = data.images.split(',').map((url: string) => {
|
|
|
|
+ return {
|
|
|
|
+ url: url.startsWith('http')
|
|
|
|
+ ? url
|
|
|
|
+ : import.meta.env.VITE_APP_OSS_PREFIX + url,
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ const targetStatus = ['0', 0]
|
|
|
|
+ if (targetStatus.includes(data.status)) {
|
|
|
|
+ if (!data.colour || !data.size || !data.material) {
|
|
|
|
+ ElNotification({
|
|
|
|
+ type: 'warning',
|
|
|
|
+ title: '提示',
|
|
|
|
+ message: `请完善SKU信息以方便审核`,
|
|
|
|
+ duration: 6000,
|
|
|
|
+ })
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ ElNotification({
|
|
|
|
+ type: 'warning',
|
|
|
|
+ title: '提示',
|
|
|
|
+ message: `SKU已经在申请中, 正在等待: ${auditUser} 进行审批`,
|
|
|
|
+ duration: 6000,
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ .finally(() => {
|
|
|
|
+ loading.value = false
|
|
|
|
+ })
|
|
|
|
+ }
|
|
},
|
|
},
|
|
)
|
|
)
|
|
const form = ref({
|
|
const form = ref({
|
|
product_name: '',
|
|
product_name: '',
|
|
product_name_cn: '',
|
|
product_name_cn: '',
|
|
images: '',
|
|
images: '',
|
|
-})
|
|
|
|
|
|
+ material: '',
|
|
|
|
+ colour: '',
|
|
|
|
+ size: '',
|
|
|
|
+} as any)
|
|
const formRef = ref()
|
|
const formRef = ref()
|
|
const $mediaRegExp = inject('mediaRegExp') as RegExp
|
|
const $mediaRegExp = inject('mediaRegExp') as RegExp
|
|
|
|
|
|
@@ -133,6 +233,7 @@ const checkForm = (formEl: FormInstance | undefined) => {
|
|
loading.value = true
|
|
loading.value = true
|
|
applySKU(form.value)
|
|
applySKU(form.value)
|
|
.then((response: any) => {
|
|
.then((response: any) => {
|
|
|
|
+ console.log(response, 'response')
|
|
if (response.code === 1) {
|
|
if (response.code === 1) {
|
|
ElNotification({
|
|
ElNotification({
|
|
title: '操作成功',
|
|
title: '操作成功',
|
|
@@ -140,7 +241,7 @@ const checkForm = (formEl: FormInstance | undefined) => {
|
|
type: 'success',
|
|
type: 'success',
|
|
duration: 3000,
|
|
duration: 3000,
|
|
})
|
|
})
|
|
- $emit('apply', { product_name: form.value.product_name })
|
|
|
|
|
|
+ $emit('apply', { product_name: form.value.product_name, id: response.result })
|
|
close()
|
|
close()
|
|
}
|
|
}
|
|
})
|
|
})
|
|
@@ -154,6 +255,9 @@ const resetData = () => {
|
|
product_name: '',
|
|
product_name: '',
|
|
product_name_cn: '',
|
|
product_name_cn: '',
|
|
images: '',
|
|
images: '',
|
|
|
|
+ material: '',
|
|
|
|
+ colour: '',
|
|
|
|
+ size: '',
|
|
}
|
|
}
|
|
imageList.value = []
|
|
imageList.value = []
|
|
}
|
|
}
|