Browse Source

Merge branch 'dev' of http://git.ycjcjy.com/SpaceOfCheng/admin into dev

许成详 6 years ago
parent
commit
df12e368c7

+ 29
- 16
src/pages/system/goodsManager/goodManager/edit.vue View File

@@ -3,7 +3,7 @@
3 3
     <form class="mainForm">
4 4
       <ul>
5 5
          <li class="flex-h">
6
-          <!-- <span>选择案场:</span> -->
6
+          <span>选择案场:</span>
7 7
           <div class="flex-item">
8 8
             <div style="width:50%">
9 9
               <el-select v-model="Case" placeholder="请选择">
@@ -43,9 +43,6 @@
43 43
                 :on-exceed="exceed">
44 44
                 <i class="el-icon-plus"></i>
45 45
               </el-upload>
46
-              <el-dialog :visible.sync="dialogVisible">
47
-                <img width="100%" :src="imgs" alt="">
48
-              </el-dialog>
49 46
             </div>
50 47
           </div>
51 48
         </li>
@@ -65,7 +62,7 @@
65 62
           <span>商品规格:</span>
66 63
           <div class="flex-item">
67 64
             <div style="width:50%">
68
-              <el-select v-model="detail.specs" multiple placeholder="请选择" style="width:100%;">
65
+              <el-select v-model="detailSpecs" multiple placeholder="请选择" style="width:100%;">
69 66
                 <el-option
70 67
                   v-for="item in specs.list"
71 68
                   :key="item.SpecId"
@@ -108,10 +105,9 @@ export default {
108 105
   name: '',
109 106
   data () {
110 107
     return {
111
-      imgs: '',
112
-      imgsArr: [],
113
-      limit: 1,
108
+      limit: 2,
114 109
       dialogVisible: false,
110
+      infoSpecs: null,
115 111
     }
116 112
   },
117 113
   components: {},
@@ -135,7 +131,20 @@ export default {
135 131
         this.GetGoodTypes({ pagesize: 1000, caseid: this.Case })
136 132
         this.GetGoodSpecs({ pagesize: 1000, caseid: this.Case })
137 133
       }
138
-    }
134
+    },
135
+    detailSpecs: {
136
+      get () {
137
+        return this.infoSpecs || (this.detail.Specs || []).map(x => x.SpecId)
138
+      },
139
+      set (val) {
140
+        this.infoSpecs = val
141
+      },
142
+    },
143
+    imgsArr () {
144
+      return (this.detail.Images || []).map(x => {
145
+        return {...x, url: x.url || x.ImgUrl}
146
+      })
147
+    },
139 148
   },
140 149
   methods: {
141 150
     ...mapGoodsActions([
@@ -148,13 +157,19 @@ export default {
148 157
       'GetGoodSpecs',
149 158
     ]),
150 159
     submit () {
151
-      this.detail.specs = JSON.stringify(this.detail.specs.map(x => ({SpecId: x, GoodsPrice: this.detail.Price})))
152
-      if ((this.detail.EquipmentId || '') === '') {
160
+      this.detail.specs = JSON.stringify(this.detailSpecs.map(x => ({SpecId: x, GoodsPrice: this.detail.Price})))
161
+      this.detail.images = this.detail.Images.map(x => {
162
+        if (x.response) {
163
+          return x.response.result.url
164
+        } else {
165
+          return x.ImgUrl
166
+        }
167
+      }).join(',')
168
+      if ((this.detail.GoodsId || '') === '') {
153 169
         this.detail.OrgId = this.orgid
154 170
         if (!this.detail.CaseId || this.detail.CaseId === '') {
155 171
           this.detail.CaseId = this.caseid
156 172
         }
157
-        this.detail.images = this.imgs
158 173
         this.AddGoods(this.detail)
159 174
       } else {
160 175
         this.UpdateGoods(this.detail)
@@ -169,12 +184,10 @@ export default {
169 184
       this.$router.go(-1)
170 185
     },
171 186
     handlePictureCardPreview (res, file, fileList) {
172
-      this.imgs = res.result.url
173
-      this.dialogVisible = false
174
-      this.imgsArr = fileList
187
+      this.detail.Images = fileList
175 188
     },
176 189
     handleRemove (file, fileList) {
177
-      this.imgsArr = fileList
190
+      this.detail.Images = fileList
178 191
     },
179 192
     exceed () {
180 193
       this.$message({

+ 36
- 9
src/pages/system/goodsManager/goodManager/index.vue View File

@@ -44,11 +44,28 @@
44 44
     </div>
45 45
     <div class="system-table-box">
46 46
       <el-table :data="goods.list" stripe style="width: 100%">
47
-        <el-table-column prop="RoleName" label="角色名">
47
+        <el-table-column prop="GoodsName" label="商品名称">
48 48
         </el-table-column>
49
-        <el-table-column label="创建时间" width="300">
49
+        <el-table-column label="图片" width="300">
50 50
           <template slot-scope="scope">
51
-            <label>{{FormatDate(scope.row.CreateDate)}}</label>
51
+            <img :src="(scope.row.Images[0] || {}).ImgUrl" style="width:200px;" />
52
+          </template>
53
+        </el-table-column>
54
+        <el-table-column prop="Price" label="价格">
55
+        </el-table-column>
56
+        <el-table-column label="类型">
57
+          <template slot-scope="scope">
58
+            <label>{{getTypeName(scope.row.TypeId)}}</label>
59
+          </template>
60
+        </el-table-column>
61
+        <el-table-column label="规格">
62
+          <template slot-scope="scope">
63
+            <label>{{getSpecNames(scope.row.Specs)}}</label>
64
+          </template>
65
+        </el-table-column>
66
+        <el-table-column label="案场">
67
+          <template slot-scope="scope">
68
+            <label>{{getCaseName(scope.row.CaseId)}}</label>
52 69
           </template>
53 70
         </el-table-column>
54 71
         <el-table-column fixed='right' label="操作" width="300">
@@ -117,7 +134,17 @@ export default {
117 134
     ...mapGoodsActions([
118 135
       'GetGoodsList',
119 136
       'GetGoodTypes',
137
+      'DelGoods',
120 138
     ]),
139
+    getTypeName (typeid) {
140
+      return (this.types.list.filter(x => x.TypeId === typeid)[0] || {}).TypeName
141
+    },
142
+    getSpecNames (specs) {
143
+      return (specs || []).map(x => x.SpecName).join(',')
144
+    },
145
+    getCaseName (caseid) {
146
+      return (this.cases.filter(x => x.CaseId === caseid)[0] || {}).CaseName
147
+    },
121 148
     search () { // 搜索
122 149
       this.postData.page = 1
123 150
       this.currentList = []
@@ -130,23 +157,23 @@ export default {
130 157
       console.log(`每页 ${val} 条`)
131 158
     },
132 159
     handleCurrentChange (val) {
133
-      this.GetRolesList({ page: val })
134
-      console.log(`当前页: ${val}`)
160
+      this.postData.page = this.currentPage
161
+      this.getList()
135 162
     },
136 163
     handleEdit (index, row) {
137 164
       // 编辑
138
-      this.$router.push({ name: 'editGoods', query: { id: row.GooddId } })
165
+      this.$router.push({ name: 'editGoods', query: { id: row.GoodsId } })
139 166
     },
140 167
     handleDelete (index, row) {
141 168
       // 删除
142 169
       console.log(index, row)
143
-      this.$confirm('确认删除此角色?', '提示', {
170
+      this.$confirm('确认删除此商品?', '提示', {
144 171
         confirmButtonText: '确定',
145 172
         cancelButtonText: '取消',
146 173
         type: 'warning'
147 174
       })
148 175
         .then(() => {
149
-          this.DelRole({id: row.RoleId, callback: this.delCallBack})
176
+          this.DelGoods({id: row.GoodsId, callback: this.delCallBack})
150 177
         })
151 178
         .catch(() => {
152 179
           this.$message({
@@ -166,7 +193,7 @@ export default {
166 193
       this.$router.push({ name: 'editGoods' })
167 194
     },
168 195
   },
169
-  mounted () {
196
+  created () {
170 197
     this.GetGoodTypes({ pagesize: 1000, caseid: this.CaseId })
171 198
     this.$nextTick(function () {
172 199
       this.getList()

+ 3
- 0
src/store/goods/goods.js View File

@@ -79,6 +79,9 @@ export default {
79 79
         method: api.goodsManager.updateGoods.method,
80 80
         data: {
81 81
           ...payload
82
+        },
83
+        urlData: {
84
+          id: payload.GoodsId,
82 85
         }
83 86
       }).then(res => {
84 87
       })

+ 6
- 5
src/util/ajax.js View File

@@ -1,6 +1,7 @@
1 1
 import axios from 'axios'
2 2
 import qs from 'qs'
3 3
 import router from '../router'
4
+import { Message } from 'element-ui'
4 5
 
5 6
 const Axios = axios.create({
6 7
   timeout: 60000,
@@ -69,16 +70,16 @@ const ajax = (...args) => {
69 70
   return new Promise((resolve, reject) => {
70 71
     Axios(...args).then(({ data }) => {
71 72
       // console.log(111)
72
-      const { code, result } = data
73
+      const { code, message, result } = data
73 74
       if (code === 200) {
74 75
         resolve(result)
75 76
       } else if (code === 401) {
76 77
         router.push({ name: 'login' })
77 78
       } else {
78
-        // Message({
79
-        //   message: message,
80
-        //   type: 'error'
81
-        // })
79
+        Message({
80
+          message: message,
81
+          type: 'error'
82
+        })
82 83
       }
83 84
     }).catch(reject)
84 85
   })