bffca5a2 by zhen

区分新增和修改产品路由

1 parent 48f77bd1
...@@ -82,13 +82,23 @@ export const constantRoutes = [ ...@@ -82,13 +82,23 @@ export const constantRoutes = [
82 } 82 }
83 }, 83 },
84 { 84 {
85 path: 'add-product',
86 name: 'add-product',
87 hidden: true,
88 component: () => import('@/views/editProduct'),
89 meta: {
90 title: '新增产品',
91 icon: 'report'
92 }
93 },
94 {
85 path: 'edit-product', 95 path: 'edit-product',
86 name: 'edit-product', 96 name: 'edit-product',
87 hidden: true, 97 hidden: true,
88 component: () => import('@/views/editProduct'), 98 component: () => import('@/views/editProduct'),
89 props: route => ({ idAndCode: route.query }), 99 props: route => ({ idAndCode: route.query }),
90 meta: { 100 meta: {
91 title: '新增产品', 101 title: '编辑产品',
92 icon: 'report' 102 icon: 'report'
93 } 103 }
94 } 104 }
......
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
33 v-model.trim="form.code" 33 v-model.trim="form.code"
34 placeholder="请输入产品编号" 34 placeholder="请输入产品编号"
35 :maxlength="inputMaxLength" 35 :maxlength="inputMaxLength"
36 :disabled="!!idAndCode.code" 36 :disabled="!!idAndCode"
37 > 37 >
38 </el-input> 38 </el-input>
39 </el-form-item> 39 </el-form-item>
...@@ -208,7 +208,7 @@ export default { ...@@ -208,7 +208,7 @@ export default {
208 } 208 }
209 }, 209 },
210 mounted() { 210 mounted() {
211 if (this.idAndCode.code) { 211 if (this.idAndCode) {
212 this.handleProductDetail() 212 this.handleProductDetail()
213 213
214 this.rules.code = [] 214 this.rules.code = []
...@@ -320,7 +320,7 @@ export default { ...@@ -320,7 +320,7 @@ export default {
320 }, 320 },
321 async editOrAdd() { 321 async editOrAdd() {
322 const formData = this.constructorFormData() 322 const formData = this.constructorFormData()
323 if (this.idAndCode.code) { 323 if (this.idAndCode) {
324 const formData = this.constructorFormData() 324 const formData = this.constructorFormData()
325 const { code } = await productEdit(formData) 325 const { code } = await productEdit(formData)
326 if (code === 0) { 326 if (code === 0) {
......
...@@ -197,11 +197,12 @@ export default { ...@@ -197,11 +197,12 @@ export default {
197 methods: { 197 methods: {
198 editOrAdd(row) { 198 editOrAdd(row) {
199 const url = { 199 const url = {
200 path: 'edit-product' 200 path: 'add-product'
201 } 201 }
202 if (row.id && row.code) { 202 if (row.id && row.code) {
203 const { id, code } = row 203 const { id, code } = row
204 url.query = { id, code } 204 url.query = { id, code }
205 url.path = 'edit-product'
205 } 206 }
206 this.$router.push(url) 207 this.$router.push(url)
207 }, 208 },
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!