48f77bd1 by zhen

产品资料上架,下架,修改接口完成。

1 parent 6c579989
......@@ -12,6 +12,28 @@ export function getProductList(data) {
})
}
/**
* 产品资料管理-上架
* @param {*} data
*/
export function onTheShelf(data) {
return request({
url: '/saleCloud/web/product/on-the-shelf',
method: 'post',
data
})
}
/**
* 产品资料管理-下架
* @param {*} data
*/
export function offTheShelf(data) {
return request({
url: '/saleCloud/web/product/off-the-shelf',
method: 'post',
data
})
}
/**
* 产品资料管理-查看详情
* @param {*} data
*/
......@@ -41,6 +63,7 @@ export function productEdit(data) {
return request({
url: '/saleCloud/web/product/edit',
method: 'post',
headers: { 'Content-Type': 'multipart/form-data' },
data
})
}
......
......@@ -175,11 +175,11 @@ export default {
}
],
form: {
name: 'lztest',
type: '1',
code: '123123',
risk: '1',
channel: [1]
name: '',
type: '',
code: '',
risk: '',
channel: []
},
rules: {
name: [{ required: true, message: '请输入产品名称', trigger: 'blur' }],
......@@ -210,6 +210,8 @@ export default {
mounted() {
if (this.idAndCode.code) {
this.handleProductDetail()
this.rules.code = []
}
},
methods: {
......@@ -236,6 +238,8 @@ export default {
}
this.fileList[this.currentFileIndex].name = file.name
this.fileList[this.currentFileIndex].file = file.raw
this.fileList[this.currentFileIndex].url &&
(this.fileList[this.currentFileIndex].url = null)
},
uploadConfirm() {
return new Promise((resolve, reject) => {
......@@ -251,10 +255,18 @@ export default {
})
},
previewFile() {
// 存在url链接,则为已经返显,再删除此文件的时清空url以保证一致性
if (this.fileList[this.currentFileIndex].url) {
const link = document.createElement('a')
link.href = this.fileList[this.currentFileIndex].url
link.target = '_target'
link.click()
return
}
if (!this.fileList[this.currentFileIndex].file) {
return
}
const file = this.fileList[this.currentFileIndex].file.raw
const file = this.fileList[this.currentFileIndex].file
const myBlob = new Blob([file], {
type: 'application/pdf'
})
......@@ -275,6 +287,8 @@ export default {
await this.deleteConfirm()
this.fileList[this.currentFileIndex].name = null
this.fileList[this.currentFileIndex].file = null
this.fileList[this.currentFileIndex].url &&
(this.fileList[this.currentFileIndex].url = null)
},
deleteConfirm() {
return new Promise((resolve, reject) => {
......@@ -307,10 +321,23 @@ export default {
async editOrAdd() {
const formData = this.constructorFormData()
if (this.idAndCode.code) {
productEdit()
const formData = this.constructorFormData()
const { code } = await productEdit(formData)
if (code === 0) {
this.$message({
message: '修改成功',
type: 'success'
})
}
} else {
const res = await productAdd(formData)
debugger
const { code } = await productAdd(formData)
if (code === 0) {
this.$message({
message: '添加成功',
type: 'success'
})
this.$router.push({ path: 'product-infor-management' })
}
}
},
constructorFormData() {
......@@ -324,7 +351,7 @@ export default {
}
this.fileList.forEach(item => {
if (item.name) {
if (item.file) {
formData.append(`file${item.id}`, item.file)
}
})
......@@ -334,11 +361,27 @@ export default {
return formData
},
async handleProductDetail() {
const res = await productDetail({
const {
result: { channel, code, link, name, risk, type, productMaterialList }
} = await productDetail({
id: this.idAndCode.id,
code: this.idAndCode.code
})
debugger
this.form = {
name: name,
type: type,
code: code,
risk: risk,
channel: channel.split(',').map(item => item - 0)
}
productMaterialList.forEach(item => {
const file = this.fileList.find(file => file.id === item.materialType)
file.name = item.materialName
file.url = item.url
})
this.productLink = link
}
}
}
......
......@@ -131,7 +131,7 @@
<el-table-column align="center" label="操作" fixed="right" width="130">
<template slot-scope="scope">
<el-button type="text" @click="editOrAdd(scope.row)">编辑</el-button>
<el-button type="text" @click="putOnShelf">{{
<el-button type="text" @click="putOnShelf(scope.row)">{{
scope.row.ifShelve === 0 ? '上架' : '下架'
}}</el-button>
</template>
......@@ -151,7 +151,11 @@ import {
fileList
} from '@/utils/mappingData'
import FooterPagination from './components/FooterPagination'
import { getProductList } from '@/api/productInforManagement'
import {
getProductList,
onTheShelf,
offTheShelf
} from '@/api/productInforManagement'
import { parseTime } from '@/utils/util'
export default {
......@@ -219,7 +223,15 @@ export default {
}
this.submit()
},
putOnShelf() {},
async putOnShelf(row) {
const { ifShelve, code } = row
if (ifShelve) {
await offTheShelf({ code })
} else {
await onTheShelf({ code })
}
this.handleGetProductList()
},
async handleGetProductList() {
try {
this.loading = true
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!