bffca5a2 by zhen

区分新增和修改产品路由

1 parent 48f77bd1
......@@ -82,13 +82,23 @@ export const constantRoutes = [
}
},
{
path: 'add-product',
name: 'add-product',
hidden: true,
component: () => import('@/views/editProduct'),
meta: {
title: '新增产品',
icon: 'report'
}
},
{
path: 'edit-product',
name: 'edit-product',
hidden: true,
component: () => import('@/views/editProduct'),
props: route => ({ idAndCode: route.query }),
meta: {
title: '新增产品',
title: '编辑产品',
icon: 'report'
}
}
......
......@@ -33,7 +33,7 @@
v-model.trim="form.code"
placeholder="请输入产品编号"
:maxlength="inputMaxLength"
:disabled="!!idAndCode.code"
:disabled="!!idAndCode"
>
</el-input>
</el-form-item>
......@@ -208,7 +208,7 @@ export default {
}
},
mounted() {
if (this.idAndCode.code) {
if (this.idAndCode) {
this.handleProductDetail()
this.rules.code = []
......@@ -320,7 +320,7 @@ export default {
},
async editOrAdd() {
const formData = this.constructorFormData()
if (this.idAndCode.code) {
if (this.idAndCode) {
const formData = this.constructorFormData()
const { code } = await productEdit(formData)
if (code === 0) {
......
......@@ -197,11 +197,12 @@ export default {
methods: {
editOrAdd(row) {
const url = {
path: 'edit-product'
path: 'add-product'
}
if (row.id && row.code) {
const { id, code } = row
url.query = { id, code }
url.path = 'edit-product'
}
this.$router.push(url)
},
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!