48f77bd1 by zhen

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

1 parent 6c579989
...@@ -12,6 +12,28 @@ export function getProductList(data) { ...@@ -12,6 +12,28 @@ export function getProductList(data) {
12 }) 12 })
13 } 13 }
14 /** 14 /**
15 * 产品资料管理-上架
16 * @param {*} data
17 */
18 export function onTheShelf(data) {
19 return request({
20 url: '/saleCloud/web/product/on-the-shelf',
21 method: 'post',
22 data
23 })
24 }
25 /**
26 * 产品资料管理-下架
27 * @param {*} data
28 */
29 export function offTheShelf(data) {
30 return request({
31 url: '/saleCloud/web/product/off-the-shelf',
32 method: 'post',
33 data
34 })
35 }
36 /**
15 * 产品资料管理-查看详情 37 * 产品资料管理-查看详情
16 * @param {*} data 38 * @param {*} data
17 */ 39 */
...@@ -41,6 +63,7 @@ export function productEdit(data) { ...@@ -41,6 +63,7 @@ export function productEdit(data) {
41 return request({ 63 return request({
42 url: '/saleCloud/web/product/edit', 64 url: '/saleCloud/web/product/edit',
43 method: 'post', 65 method: 'post',
66 headers: { 'Content-Type': 'multipart/form-data' },
44 data 67 data
45 }) 68 })
46 } 69 }
......
...@@ -175,11 +175,11 @@ export default { ...@@ -175,11 +175,11 @@ export default {
175 } 175 }
176 ], 176 ],
177 form: { 177 form: {
178 name: 'lztest', 178 name: '',
179 type: '1', 179 type: '',
180 code: '123123', 180 code: '',
181 risk: '1', 181 risk: '',
182 channel: [1] 182 channel: []
183 }, 183 },
184 rules: { 184 rules: {
185 name: [{ required: true, message: '请输入产品名称', trigger: 'blur' }], 185 name: [{ required: true, message: '请输入产品名称', trigger: 'blur' }],
...@@ -210,6 +210,8 @@ export default { ...@@ -210,6 +210,8 @@ export default {
210 mounted() { 210 mounted() {
211 if (this.idAndCode.code) { 211 if (this.idAndCode.code) {
212 this.handleProductDetail() 212 this.handleProductDetail()
213
214 this.rules.code = []
213 } 215 }
214 }, 216 },
215 methods: { 217 methods: {
...@@ -236,6 +238,8 @@ export default { ...@@ -236,6 +238,8 @@ export default {
236 } 238 }
237 this.fileList[this.currentFileIndex].name = file.name 239 this.fileList[this.currentFileIndex].name = file.name
238 this.fileList[this.currentFileIndex].file = file.raw 240 this.fileList[this.currentFileIndex].file = file.raw
241 this.fileList[this.currentFileIndex].url &&
242 (this.fileList[this.currentFileIndex].url = null)
239 }, 243 },
240 uploadConfirm() { 244 uploadConfirm() {
241 return new Promise((resolve, reject) => { 245 return new Promise((resolve, reject) => {
...@@ -251,10 +255,18 @@ export default { ...@@ -251,10 +255,18 @@ export default {
251 }) 255 })
252 }, 256 },
253 previewFile() { 257 previewFile() {
258 // 存在url链接,则为已经返显,再删除此文件的时清空url以保证一致性
259 if (this.fileList[this.currentFileIndex].url) {
260 const link = document.createElement('a')
261 link.href = this.fileList[this.currentFileIndex].url
262 link.target = '_target'
263 link.click()
264 return
265 }
254 if (!this.fileList[this.currentFileIndex].file) { 266 if (!this.fileList[this.currentFileIndex].file) {
255 return 267 return
256 } 268 }
257 const file = this.fileList[this.currentFileIndex].file.raw 269 const file = this.fileList[this.currentFileIndex].file
258 const myBlob = new Blob([file], { 270 const myBlob = new Blob([file], {
259 type: 'application/pdf' 271 type: 'application/pdf'
260 }) 272 })
...@@ -275,6 +287,8 @@ export default { ...@@ -275,6 +287,8 @@ export default {
275 await this.deleteConfirm() 287 await this.deleteConfirm()
276 this.fileList[this.currentFileIndex].name = null 288 this.fileList[this.currentFileIndex].name = null
277 this.fileList[this.currentFileIndex].file = null 289 this.fileList[this.currentFileIndex].file = null
290 this.fileList[this.currentFileIndex].url &&
291 (this.fileList[this.currentFileIndex].url = null)
278 }, 292 },
279 deleteConfirm() { 293 deleteConfirm() {
280 return new Promise((resolve, reject) => { 294 return new Promise((resolve, reject) => {
...@@ -307,10 +321,23 @@ export default { ...@@ -307,10 +321,23 @@ export default {
307 async editOrAdd() { 321 async editOrAdd() {
308 const formData = this.constructorFormData() 322 const formData = this.constructorFormData()
309 if (this.idAndCode.code) { 323 if (this.idAndCode.code) {
310 productEdit() 324 const formData = this.constructorFormData()
325 const { code } = await productEdit(formData)
326 if (code === 0) {
327 this.$message({
328 message: '修改成功',
329 type: 'success'
330 })
331 }
311 } else { 332 } else {
312 const res = await productAdd(formData) 333 const { code } = await productAdd(formData)
313 debugger 334 if (code === 0) {
335 this.$message({
336 message: '添加成功',
337 type: 'success'
338 })
339 this.$router.push({ path: 'product-infor-management' })
340 }
314 } 341 }
315 }, 342 },
316 constructorFormData() { 343 constructorFormData() {
...@@ -324,7 +351,7 @@ export default { ...@@ -324,7 +351,7 @@ export default {
324 } 351 }
325 352
326 this.fileList.forEach(item => { 353 this.fileList.forEach(item => {
327 if (item.name) { 354 if (item.file) {
328 formData.append(`file${item.id}`, item.file) 355 formData.append(`file${item.id}`, item.file)
329 } 356 }
330 }) 357 })
...@@ -334,11 +361,27 @@ export default { ...@@ -334,11 +361,27 @@ export default {
334 return formData 361 return formData
335 }, 362 },
336 async handleProductDetail() { 363 async handleProductDetail() {
337 const res = await productDetail({ 364 const {
365 result: { channel, code, link, name, risk, type, productMaterialList }
366 } = await productDetail({
338 id: this.idAndCode.id, 367 id: this.idAndCode.id,
339 code: this.idAndCode.code 368 code: this.idAndCode.code
340 }) 369 })
341 debugger 370 this.form = {
371 name: name,
372 type: type,
373 code: code,
374 risk: risk,
375 channel: channel.split(',').map(item => item - 0)
376 }
377
378 productMaterialList.forEach(item => {
379 const file = this.fileList.find(file => file.id === item.materialType)
380 file.name = item.materialName
381 file.url = item.url
382 })
383
384 this.productLink = link
342 } 385 }
343 } 386 }
344 } 387 }
......
...@@ -131,7 +131,7 @@ ...@@ -131,7 +131,7 @@
131 <el-table-column align="center" label="操作" fixed="right" width="130"> 131 <el-table-column align="center" label="操作" fixed="right" width="130">
132 <template slot-scope="scope"> 132 <template slot-scope="scope">
133 <el-button type="text" @click="editOrAdd(scope.row)">编辑</el-button> 133 <el-button type="text" @click="editOrAdd(scope.row)">编辑</el-button>
134 <el-button type="text" @click="putOnShelf">{{ 134 <el-button type="text" @click="putOnShelf(scope.row)">{{
135 scope.row.ifShelve === 0 ? '上架' : '下架' 135 scope.row.ifShelve === 0 ? '上架' : '下架'
136 }}</el-button> 136 }}</el-button>
137 </template> 137 </template>
...@@ -151,7 +151,11 @@ import { ...@@ -151,7 +151,11 @@ import {
151 fileList 151 fileList
152 } from '@/utils/mappingData' 152 } from '@/utils/mappingData'
153 import FooterPagination from './components/FooterPagination' 153 import FooterPagination from './components/FooterPagination'
154 import { getProductList } from '@/api/productInforManagement' 154 import {
155 getProductList,
156 onTheShelf,
157 offTheShelf
158 } from '@/api/productInforManagement'
155 import { parseTime } from '@/utils/util' 159 import { parseTime } from '@/utils/util'
156 160
157 export default { 161 export default {
...@@ -219,7 +223,15 @@ export default { ...@@ -219,7 +223,15 @@ export default {
219 } 223 }
220 this.submit() 224 this.submit()
221 }, 225 },
222 putOnShelf() {}, 226 async putOnShelf(row) {
227 const { ifShelve, code } = row
228 if (ifShelve) {
229 await offTheShelf({ code })
230 } else {
231 await onTheShelf({ code })
232 }
233 this.handleGetProductList()
234 },
223 async handleGetProductList() { 235 async handleGetProductList() {
224 try { 236 try {
225 this.loading = true 237 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!