细节修改

master
fanfan 6 months ago
parent e38c45b4da
commit 9ba3f0f03e
  1. 4
      src/components/SelectImage/SelectImage.vue
  2. 16
      src/views/goods/Create.vue
  3. 16
      src/views/goods/modules/Update.vue

@ -4,7 +4,7 @@
<!-- draggable是拖拽组件 --> <!-- draggable是拖拽组件 -->
<draggable v-if="selectedItems.length" v-model="selectedItems" @start="drag=true" @end="drag=false" @update="onUpdate"> <draggable v-if="selectedItems.length" v-model="selectedItems" @start="drag=true" @end="drag=false" @update="onUpdate">
<transition-group class="draggable-item" type="transition" :name="'flip-list'"> <transition-group class="draggable-item" type="transition" :name="'flip-list'">
<div v-for="(item, index) in selectedItems" :key="item.file_id>0?item.file_id:item.id" class="file-item" :style="{ width: `${width}px`, height: `${width}px` }"> <div v-for="(item, index) in selectedItems" :key="item.file_id>0?item.file_id:index" class="file-item" :style="{ width: `${width}px`, height: `${width}px` }">
<!-- 预览图 --> <!-- 预览图 -->
<a :href="item.preview_url" target="_blank"> <a :href="item.preview_url" target="_blank">
<div class="img-cover" :style="{ backgroundImage: `url('${item.preview_url}')` }"></div> <div class="img-cover" :style="{ backgroundImage: `url('${item.preview_url}')` }"></div>
@ -119,7 +119,7 @@ export default {
let fileId = [] let fileId = []
const list = multiple ? selectedItems.map(item => item) : selectedItems[0].file_id const list = multiple ? selectedItems.map(item => item) : selectedItems[0].file_id
list.forEach(function (item) { list.forEach(function (item) {
fileId.push({ file_id: item.file_id, image: item.preview_url }) fileId.push({ file_id: item.file_id, preview_url: item.preview_url })
}) })
return this.$emit('change', fileId, selectedItems) return this.$emit('change', fileId, selectedItems)
} else { } else {

@ -18,7 +18,7 @@
<a-form-item label="商品SKU" :labelCol="labelCol" :wrapperCol="wrapperCol"> <a-form-item label="商品SKU" :labelCol="labelCol" :wrapperCol="wrapperCol">
<div style=" display: flex;align-items: center;width:100%"> <div style=" display: flex;align-items: center;width:100%">
<a-input style="width:242px" placeholder="输入商品SKU" v-decorator="['goods_no', { rules: [{ required: true, min: 2, message: '请输入至少2个字符' }] }]" /> <a-input style="width:242px" placeholder="输入商品SKU" v-decorator="['goods_no', { rules: [{ required: true, min: 2, message: '请输入至少2个字符' }] }]" />
<div class="action-item"> <div class="action-item" style="margin-left:15px">
<a-button type="primary" @click="handInfo">一键获取</a-button> <a-button type="primary" @click="handInfo">一键获取</a-button>
</div> </div>
</div> </div>
@ -422,13 +422,6 @@ export default {
}) })
}, },
methods: { methods: {
generateRandomDigits(length) {
let result = '';
for (let i = 0; i < length; i++) {
result += Math.floor(Math.random() * 10); // 0-9
}
return result;
},
handInfo() { handInfo() {
const { form } = this const { form } = this
const goods_no = form.getFieldValue('goods_no') const goods_no = form.getFieldValue('goods_no')
@ -438,16 +431,13 @@ export default {
} }
this.isLoading = true this.isLoading = true
GoodsApi.getCollector(param).then((result) => { GoodsApi.getCollector(param).then((result) => {
if (result.data.goods_images.length > 0) {
result.data.goods_images.forEach(item => {
item.id = Number(this.generateRandomDigits(7))
});
}
this.$refs.childComponent.selectedItems = result.data.goods_images this.$refs.childComponent.selectedItems = result.data.goods_images
let obj = { let obj = {
goods_name: result.data.name, goods_name: result.data.name,
content: result.data.content, content: result.data.content,
goods_price: result.data.proxyPrice, goods_price: result.data.proxyPrice,
imagesIds: result.data.goods_images,
goods_images: result.data.goods_images,
} }
this.form.setFieldsValue(obj) this.form.setFieldsValue(obj)
this.isLoading = false this.isLoading = false

@ -18,7 +18,7 @@
<a-form-item label="商品SKU" :labelCol="labelCol" :wrapperCol="wrapperCol"> <a-form-item label="商品SKU" :labelCol="labelCol" :wrapperCol="wrapperCol">
<div style=" display: flex;align-items: center;width:100%"> <div style=" display: flex;align-items: center;width:100%">
<a-input style="width:242px" placeholder="输入商品SKU" v-decorator="['goods_no', { rules: [{ required: true, min: 2, message: '请输入至少2个字符' }] }]" /> <a-input style="width:242px" placeholder="输入商品SKU" v-decorator="['goods_no', { rules: [{ required: true, min: 2, message: '请输入至少2个字符' }] }]" />
<div class="action-item"> <div class="action-item" style="margin-left:15px">
<a-button type="primary" @click="handInfo">一键获取</a-button> <a-button type="primary" @click="handInfo">一键获取</a-button>
</div> </div>
</div> </div>
@ -423,13 +423,6 @@ export default {
} }
}, },
methods: { methods: {
generateRandomDigits(length) {
let result = '';
for (let i = 0; i < length; i++) {
result += Math.floor(Math.random() * 10); // 0-9
}
return result;
},
handInfo() { handInfo() {
const { form } = this const { form } = this
const goods_no = form.getFieldValue('goods_no') const goods_no = form.getFieldValue('goods_no')
@ -440,12 +433,7 @@ export default {
} }
this.isLoading = true this.isLoading = true
GoodsApi.getCollector(param).then((result) => { GoodsApi.getCollector(param).then((result) => {
this.formData.goods.goods_images = [] this.formData.goods.imagesIds=result.data.goods_images
if (result.data.goods_images.length > 0) {
result.data.goods_images.forEach(item => {
item.id = Number(this.generateRandomDigits(7))
});
}
this.formData.goods.goods_images = result.data.goods_images this.formData.goods.goods_images = result.data.goods_images
this.$refs.childComponent.selectedItems = result.data.goods_images this.$refs.childComponent.selectedItems = result.data.goods_images
this.formData.goods.goods_name = result.data.name this.formData.goods.goods_name = result.data.name

Loading…
Cancel
Save