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
     <form class="mainForm">
3
     <form class="mainForm">
4
       <ul>
4
       <ul>
5
          <li class="flex-h">
5
          <li class="flex-h">
6
-          <!-- <span>选择案场:</span> -->
6
+          <span>选择案场:</span>
7
           <div class="flex-item">
7
           <div class="flex-item">
8
             <div style="width:50%">
8
             <div style="width:50%">
9
               <el-select v-model="Case" placeholder="请选择">
9
               <el-select v-model="Case" placeholder="请选择">
43
                 :on-exceed="exceed">
43
                 :on-exceed="exceed">
44
                 <i class="el-icon-plus"></i>
44
                 <i class="el-icon-plus"></i>
45
               </el-upload>
45
               </el-upload>
46
-              <el-dialog :visible.sync="dialogVisible">
47
-                <img width="100%" :src="imgs" alt="">
48
-              </el-dialog>
49
             </div>
46
             </div>
50
           </div>
47
           </div>
51
         </li>
48
         </li>
65
           <span>商品规格:</span>
62
           <span>商品规格:</span>
66
           <div class="flex-item">
63
           <div class="flex-item">
67
             <div style="width:50%">
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
                 <el-option
66
                 <el-option
70
                   v-for="item in specs.list"
67
                   v-for="item in specs.list"
71
                   :key="item.SpecId"
68
                   :key="item.SpecId"
108
   name: '',
105
   name: '',
109
   data () {
106
   data () {
110
     return {
107
     return {
111
-      imgs: '',
112
-      imgsArr: [],
113
-      limit: 1,
108
+      limit: 2,
114
       dialogVisible: false,
109
       dialogVisible: false,
110
+      infoSpecs: null,
115
     }
111
     }
116
   },
112
   },
117
   components: {},
113
   components: {},
135
         this.GetGoodTypes({ pagesize: 1000, caseid: this.Case })
131
         this.GetGoodTypes({ pagesize: 1000, caseid: this.Case })
136
         this.GetGoodSpecs({ pagesize: 1000, caseid: this.Case })
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
   methods: {
149
   methods: {
141
     ...mapGoodsActions([
150
     ...mapGoodsActions([
148
       'GetGoodSpecs',
157
       'GetGoodSpecs',
149
     ]),
158
     ]),
150
     submit () {
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
         this.detail.OrgId = this.orgid
169
         this.detail.OrgId = this.orgid
154
         if (!this.detail.CaseId || this.detail.CaseId === '') {
170
         if (!this.detail.CaseId || this.detail.CaseId === '') {
155
           this.detail.CaseId = this.caseid
171
           this.detail.CaseId = this.caseid
156
         }
172
         }
157
-        this.detail.images = this.imgs
158
         this.AddGoods(this.detail)
173
         this.AddGoods(this.detail)
159
       } else {
174
       } else {
160
         this.UpdateGoods(this.detail)
175
         this.UpdateGoods(this.detail)
169
       this.$router.go(-1)
184
       this.$router.go(-1)
170
     },
185
     },
171
     handlePictureCardPreview (res, file, fileList) {
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
     handleRemove (file, fileList) {
189
     handleRemove (file, fileList) {
177
-      this.imgsArr = fileList
190
+      this.detail.Images = fileList
178
     },
191
     },
179
     exceed () {
192
     exceed () {
180
       this.$message({
193
       this.$message({

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

44
     </div>
44
     </div>
45
     <div class="system-table-box">
45
     <div class="system-table-box">
46
       <el-table :data="goods.list" stripe style="width: 100%">
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
         </el-table-column>
48
         </el-table-column>
49
-        <el-table-column label="创建时间" width="300">
49
+        <el-table-column label="图片" width="300">
50
           <template slot-scope="scope">
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
           </template>
69
           </template>
53
         </el-table-column>
70
         </el-table-column>
54
         <el-table-column fixed='right' label="操作" width="300">
71
         <el-table-column fixed='right' label="操作" width="300">
117
     ...mapGoodsActions([
134
     ...mapGoodsActions([
118
       'GetGoodsList',
135
       'GetGoodsList',
119
       'GetGoodTypes',
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
     search () { // 搜索
148
     search () { // 搜索
122
       this.postData.page = 1
149
       this.postData.page = 1
123
       this.currentList = []
150
       this.currentList = []
130
       console.log(`每页 ${val} 条`)
157
       console.log(`每页 ${val} 条`)
131
     },
158
     },
132
     handleCurrentChange (val) {
159
     handleCurrentChange (val) {
133
-      this.GetRolesList({ page: val })
134
-      console.log(`当前页: ${val}`)
160
+      this.postData.page = this.currentPage
161
+      this.getList()
135
     },
162
     },
136
     handleEdit (index, row) {
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
     handleDelete (index, row) {
167
     handleDelete (index, row) {
141
       // 删除
168
       // 删除
142
       console.log(index, row)
169
       console.log(index, row)
143
-      this.$confirm('确认删除此角色?', '提示', {
170
+      this.$confirm('确认删除此商品?', '提示', {
144
         confirmButtonText: '确定',
171
         confirmButtonText: '确定',
145
         cancelButtonText: '取消',
172
         cancelButtonText: '取消',
146
         type: 'warning'
173
         type: 'warning'
147
       })
174
       })
148
         .then(() => {
175
         .then(() => {
149
-          this.DelRole({id: row.RoleId, callback: this.delCallBack})
176
+          this.DelGoods({id: row.GoodsId, callback: this.delCallBack})
150
         })
177
         })
151
         .catch(() => {
178
         .catch(() => {
152
           this.$message({
179
           this.$message({
166
       this.$router.push({ name: 'editGoods' })
193
       this.$router.push({ name: 'editGoods' })
167
     },
194
     },
168
   },
195
   },
169
-  mounted () {
196
+  created () {
170
     this.GetGoodTypes({ pagesize: 1000, caseid: this.CaseId })
197
     this.GetGoodTypes({ pagesize: 1000, caseid: this.CaseId })
171
     this.$nextTick(function () {
198
     this.$nextTick(function () {
172
       this.getList()
199
       this.getList()

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

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

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

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