weiximei пре 6 година
родитељ
комит
4f0d3fad85

+ 10
- 0
CODE/smart-community/community-common/src/main/java/com/community/commom/utils/PayPriceUtils.java Прегледај датотеку

@@ -14,4 +14,14 @@ public class PayPriceUtils {
14 14
          return  price * 100;
15 15
     }
16 16
 
17
+    /**
18
+     * 元转换为分
19
+     * @param price
20
+     * @return
21
+     */
22
+    public static Integer yuanConversionPoints(Double price) {
23
+        Double d = price * 100;
24
+        return  Integer.parseInt(d + "");
25
+    }
26
+
17 27
 }

+ 26
- 7
CODE/smart-community/property-api/src/main/java/com/community/huiju/controller/BillController.java Прегледај датотеку

@@ -12,14 +12,11 @@ import io.swagger.annotations.ApiImplicitParams;
12 12
 import io.swagger.annotations.ApiOperation;
13 13
 import org.springframework.beans.factory.annotation.Autowired;
14 14
 import org.springframework.cloud.context.config.annotation.RefreshScope;
15
-import org.springframework.web.bind.annotation.PathVariable;
16
-import org.springframework.web.bind.annotation.RequestBody;
17
-import org.springframework.web.bind.annotation.RequestMapping;
18
-import org.springframework.web.bind.annotation.RequestMethod;
19
-import org.springframework.web.bind.annotation.RequestParam;
20
-import org.springframework.web.bind.annotation.RestController;
15
+import org.springframework.web.bind.annotation.*;
16
+import org.springframework.web.multipart.MultipartFile;
21 17
 
22 18
 import javax.servlet.http.HttpSession;
19
+import java.util.Date;
23 20
 import java.util.List;
24 21
 
25 22
 /**
@@ -40,7 +37,7 @@ public class BillController extends BaseController {
40 37
     private IBillService iBillService;
41 38
     
42 39
     
43
-    @ApiOperation(value = "根据搜索条件获取二手租赁列表", notes = "根据搜索条件获取二手租赁列表")
40
+    @ApiOperation(value = "根据搜索条件获取缴费项列表", notes = "根据搜索条件获取缴费项列表")
44 41
     @ApiImplicitParams({
45 42
             @ApiImplicitParam(paramType = "query", dataType = "Integer", name = "billId", value = "收费组编号"),
46 43
             @ApiImplicitParam(paramType = "query", dataType = "String", name = "billName", value = "收费组名(模糊查询)"),
@@ -76,4 +73,26 @@ public class BillController extends BaseController {
76 73
         return responseBean;
77 74
     }
78 75
 
76
+    @ApiOperation(value = "上传缴费项接口, 预览", notes = "上传缴费项接口, 预览")
77
+    @PostMapping(value = "/bill/uploadExcel/get", consumes = "multipart/*", headers = "content-type=multipart/form-data")
78
+    public ResponseBean getUploadExcel(@RequestParam("file") MultipartFile file, @RequestParam("billExplain") String billExplain) {
79
+        ResponseBean responseBean = new ResponseBean();
80
+        responseBean = iBillService.getExcelData(file, billExplain);
81
+        return responseBean;
82
+    }
83
+
84
+    @ApiOperation(value = "上传缴费项接口, 保存", notes = "上传缴费项接口, 保存")
85
+    @PostMapping(value = "/bill/uploadExcel/add", consumes = "multipart/*", headers = "content-type=multipart/form-data")
86
+    public ResponseBean addUploadExcel(HttpSession session, @RequestParam("file") MultipartFile file,
87
+                                       @RequestParam("billExplain") String billExplain,
88
+                                       @RequestParam("billName") String billName,
89
+                                       @RequestParam("endDate") Date endDate,
90
+                                       @RequestParam("billStatus") String billStatus) {
91
+        ResponseBean responseBean = new ResponseBean();
92
+        UserElement userElement = getUserElement(session);
93
+        responseBean = iBillService.getExcelData(file, billExplain, billName, endDate, billStatus, userElement);
94
+        return responseBean;
95
+    }
96
+
97
+
79 98
 }

+ 2
- 2
CODE/smart-community/property-api/src/main/java/com/community/huiju/model/Bill.java Прегледај датотеку

@@ -80,7 +80,7 @@ public class Bill implements Serializable {
80 80
     /**
81 81
      * 创建时间
82 82
      */
83
-    private LocalDateTime createDate;
83
+    private Date createDate;
84 84
 
85 85
     /**
86 86
      * 更新人
@@ -90,7 +90,7 @@ public class Bill implements Serializable {
90 90
     /**
91 91
      * 更新时间
92 92
      */
93
-    private LocalDateTime updateDate;
93
+    private Date updateDate;
94 94
 
95 95
 
96 96
 }

+ 21
- 0
CODE/smart-community/property-api/src/main/java/com/community/huiju/service/IBillService.java Прегледај датотеку

@@ -4,6 +4,9 @@ import com.baomidou.mybatisplus.extension.service.IService;
4 4
 import com.community.commom.mode.ResponseBean;
5 5
 import com.community.commom.session.UserElement;
6 6
 import com.community.huiju.model.Bill;
7
+import org.springframework.web.multipart.MultipartFile;
8
+
9
+import java.util.Date;
7 10
 
8 11
 /**
9 12
  * <p>
@@ -39,4 +42,22 @@ public interface IBillService extends IService<Bill> {
39 42
 	 * @return
40 43
 	 */
41 44
 	ResponseBean getBillList(Bill bill, Integer pageNum, Integer pageSize);
45
+
46
+	/**
47
+	 * 上传excel, 解析, 但不入库
48
+	 * @param file
49
+	 * @return
50
+	 */
51
+    ResponseBean getExcelData(MultipartFile file, String billExplain);
52
+
53
+	/**
54
+	 * 上传excel, 解析 入库
55
+	 * @param file
56
+	 * @param billExplain
57
+	 * @param billName
58
+	 * @param endDate
59
+	 * @param billStatus
60
+	 * @return
61
+	 */
62
+	ResponseBean getExcelData(MultipartFile file, String billExplain, String billName, Date endDate, String billStatus, UserElement userElement);
42 63
 }

+ 243
- 5
CODE/smart-community/property-api/src/main/java/com/community/huiju/service/impl/BillServiceImpl.java Прегледај датотеку

@@ -1,24 +1,39 @@
1 1
 package com.community.huiju.service.impl;
2 2
 
3 3
 import com.alibaba.fastjson.JSONObject;
4
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
4 5
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
5 6
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
7
+import com.community.commom.constant.Constant;
6 8
 import com.community.commom.mode.ResponseBean;
7 9
 import com.community.commom.session.UserElement;
8
-import com.community.huiju.dao.BillInvoiceMapper;
9
-import com.community.huiju.dao.BillStatementMapper;
10
-import com.community.huiju.model.Bill;
11
-import com.community.huiju.dao.BillMapper;
12
-import com.community.huiju.model.TpTransaction;
10
+import com.community.commom.utils.PayPriceUtils;
11
+import com.community.huiju.dao.*;
12
+import com.community.huiju.exception.WisdomException;
13
+import com.community.huiju.model.*;
14
+import com.community.huiju.service.IBillInvoiceService;
13 15
 import com.community.huiju.service.IBillService;
16
+import com.google.common.collect.Lists;
14 17
 import com.google.common.collect.Maps;
18
+import lombok.Data;
19
+import lombok.extern.slf4j.Slf4j;
15 20
 import org.apache.commons.lang3.StringUtils;
21
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
22
+import org.apache.poi.ss.usermodel.Cell;
23
+import org.apache.poi.ss.usermodel.Row;
24
+import org.apache.poi.ss.usermodel.Sheet;
25
+import org.apache.poi.ss.usermodel.Workbook;
26
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
16 27
 import org.springframework.beans.factory.annotation.Autowired;
17 28
 import org.springframework.stereotype.Service;
18 29
 import org.springframework.transaction.annotation.Transactional;
30
+import org.springframework.web.multipart.MultipartFile;
19 31
 
32
+import java.io.IOException;
33
+import java.util.Date;
20 34
 import java.util.List;
21 35
 import java.util.Map;
36
+import java.util.stream.Collectors;
22 37
 
23 38
 /**
24 39
  * <p>
@@ -29,6 +44,7 @@ import java.util.Map;
29 44
  * @since 2019-02-13
30 45
  */
31 46
 @Service
47
+@Slf4j
32 48
 public class BillServiceImpl extends ServiceImpl<BillMapper, Bill> implements IBillService {
33 49
 
34 50
     /** 缴费项表 **/
@@ -39,10 +55,19 @@ public class BillServiceImpl extends ServiceImpl<BillMapper, Bill> implements IB
39 55
     @Autowired
40 56
     private BillInvoiceMapper billInvoiceMapper;
41 57
 
58
+    private IBillInvoiceService iBillInvoiceService;
59
+
42 60
     /** 账单流水表 **/
43 61
     @Autowired
44 62
     private BillStatementMapper billStatementMapper;
45 63
 
64
+    @Autowired
65
+    private TpBuildingOwnerInfoMapper tpBuildingOwnerInfoMapper;
66
+
67
+    @Autowired
68
+    private TaUserMapper taUserMapper;
69
+
70
+
46 71
     @Override
47 72
     @Transactional(rollbackFor = Exception.class)
48 73
     public ResponseBean updateBillNameAndBillExplainAndEndDate(UserElement userElement, String parameter) {
@@ -100,4 +125,217 @@ public class BillServiceImpl extends ServiceImpl<BillMapper, Bill> implements IB
100 125
         responseBean.addSuccess(map);
101 126
         return responseBean;
102 127
     }
128
+
129
+
130
+    @Override
131
+    public ResponseBean getExcelData(MultipartFile file, String billExplain) {
132
+        ResponseBean responseBean = new ResponseBean();
133
+        if (file == null) {
134
+            responseBean.addError("对象不能为空");
135
+            return responseBean;
136
+        }
137
+
138
+        responseBean = getExcelData(file, responseBean);
139
+        List<TempBill> tempBills = (List<TempBill>) responseBean.getData();
140
+        tempBills.forEach(e -> {
141
+            e.setBillExplain(billExplain);
142
+        });
143
+
144
+        Map<String, Object> map = Maps.newHashMap();
145
+        map.put("list", tempBills);
146
+        map.put("total", tempBills.size());
147
+        responseBean.addSuccess(map);
148
+
149
+        return responseBean;
150
+    }
151
+
152
+    @Override
153
+    public ResponseBean getExcelData(MultipartFile file, String billExplain, String billName, Date endDate, String billStatus, UserElement userElement) {
154
+        ResponseBean responseBean = new ResponseBean();
155
+        responseBean = getExcelData(file, responseBean);
156
+        List<TempBill> tempBills = (List<TempBill>) responseBean.getData();
157
+
158
+        Double sumDouble = tempBills.stream().mapToDouble(TempBill::getMoney).sum();
159
+
160
+        // 存入缴费项表
161
+        Bill bill = new Bill();
162
+        bill.setBillName(billName);
163
+        bill.setBillExplain(billExplain);
164
+        bill.setEndDate(endDate);
165
+        bill.setPayedNum(PayPriceUtils.yuanConversionPoints(Double.valueOf(sumDouble)));
166
+        bill.setPayTotalNum(tempBills.size());
167
+        bill.setPayedNum(0);
168
+        bill.setUnpayedNum(tempBills.size());
169
+        bill.setBillStatus(billStatus);
170
+        bill.setCreateUser(userElement.getId());
171
+        bill.setCreateDate(new Date());
172
+
173
+        int rows = billMapper.insert(bill);
174
+        if (rows > 0) {
175
+            List<BillInvoice> billInvoices = tempBills.stream().map(e -> {
176
+                BillInvoice billInvoice = new BillInvoice();
177
+                billInvoice.setCommunityId(userElement.getCommunityId());
178
+                billInvoice.setBillId(bill.getId());
179
+
180
+                // 楼栋资料库
181
+                QueryWrapper<TpBuildingOwnerInfo> queryWrapper = new QueryWrapper<>();
182
+                queryWrapper.eq("phase", e.getPhase());
183
+                queryWrapper.eq("building", e.getBuilding());
184
+                queryWrapper.eq("unit", e.getUnit());
185
+                queryWrapper.eq("room_no", e.getRoomNo());
186
+                queryWrapper.eq("community_id", userElement.getCommunityId());
187
+                TpBuildingOwnerInfo buildingOwnerInfo = tpBuildingOwnerInfoMapper.selectOne(queryWrapper);
188
+
189
+                // 查询app用户id
190
+                QueryWrapper<TaUser> userQueryWrapper = new QueryWrapper<>();
191
+                userQueryWrapper.eq("community_id", userElement.getCommunityId());
192
+                userQueryWrapper.eq("login_name", buildingOwnerInfo.getOwnerTel());
193
+                TaUser taUser = taUserMapper.selectOne(userQueryWrapper);
194
+
195
+                billInvoice.setBuildingOwnerInfoId(buildingOwnerInfo.getId());
196
+                billInvoice.setTaUserId(taUser.getId());
197
+                billInvoice.setBillInvoiceExplain(bill.getBillExplain());
198
+                billInvoice.setPayPrice(e.getMoney());
199
+                billInvoice.setBillStatus("0");
200
+                billInvoice.setCreateUser(userElement.getId());
201
+                billInvoice.setCreateDate(new Date());
202
+                billInvoice.setStatus(1);
203
+                return billInvoice;
204
+            }).collect(Collectors.toList());
205
+
206
+            iBillInvoiceService.saveBatch(billInvoices);
207
+            responseBean.addSuccess("操作成功!");
208
+        } else {
209
+            responseBean.addError("操作失败!");
210
+        }
211
+
212
+
213
+        return responseBean;
214
+    }
215
+
216
+    private ResponseBean getExcelData(MultipartFile file, ResponseBean responseBean) {
217
+        ResponseBean responseBean1 = new ResponseBean();
218
+        //获取文件的名字
219
+        String originalFilename = file.getOriginalFilename();
220
+        Workbook workbook = null;
221
+        try {
222
+            if (originalFilename.endsWith(Constant.SUFFIX_2003)) {
223
+                workbook = new HSSFWorkbook(file.getInputStream());
224
+            } else if (originalFilename.endsWith(Constant.SUFFIX_2007)) {
225
+                workbook = new XSSFWorkbook(file.getInputStream());
226
+            }
227
+        } catch (Exception e) {
228
+            log.info(originalFilename);
229
+            e.printStackTrace();
230
+            responseBean.addError("格式错误");
231
+            return responseBean;
232
+        }
233
+
234
+        // 获取 Sheet 第一页
235
+        Sheet sheetAt = workbook.getSheetAt(0);
236
+        int lastRowNum = sheetAt.getLastRowNum();
237
+
238
+        // 数据
239
+        List<TempBill> tempBills = Lists.newArrayList();
240
+
241
+        // 从第7行开始读取
242
+        for (int i= 6; i<= lastRowNum; i++) {
243
+            Row row = sheetAt.getRow(i);
244
+            Cell cell = getCell(row.getCell(0));
245
+            if (null == cell) {
246
+                throw new WisdomException("第" + i + "行 期/区 不能为空");
247
+            }
248
+            String phase = cell.getStringCellValue().trim();
249
+            cell = getCell(row.getCell(1));
250
+            if (null == cell) {
251
+                throw new WisdomException("第" + i + "行 楼栋 不能为空");
252
+            }
253
+            String building = cell.getStringCellValue().trim();
254
+            cell = getCell(row.getCell(2));
255
+            if (null == cell) {
256
+                throw new WisdomException("第" + i + "行 单元 不能为空");
257
+            }
258
+            String unit = cell.getStringCellValue().trim();
259
+            cell = getCell(row.getCell(3));
260
+            if (null == cell) {
261
+                throw new WisdomException("第" + i + "行 楼层 不能为空");
262
+            }
263
+            String level = cell.getStringCellValue().trim();
264
+            cell = getCell(row.getCell(4));
265
+            if (null == cell) {
266
+                throw new WisdomException("第" + i + "行 房号 不能为空");
267
+            }
268
+            String roomNo = cell.getStringCellValue().trim();
269
+            cell = getCell(row.getCell(5));
270
+            if (null == cell) {
271
+                throw new WisdomException("第" + i + "行 业主姓名 不能为空");
272
+            }
273
+            String ownerName = cell.getStringCellValue().trim();
274
+            cell = getCell(row.getCell(6));
275
+            if (null == cell) {
276
+                throw new WisdomException("第" + i + "行 金额 不能为空");
277
+            }
278
+            String money = cell.getStringCellValue().trim();
279
+
280
+
281
+            TempBill temp = new TempBill();
282
+            temp.setPhase(phase);
283
+            temp.setBuilding(building);
284
+            temp.setLevel(level);
285
+            temp.setUnit(unit);
286
+            temp.setRoomNo(roomNo);
287
+            temp.setOwnerName(ownerName);
288
+
289
+            if (StringUtils.isNotBlank(money)) {
290
+                String[] split = money.split(".");
291
+                // 判断是否包含 . ,包含表示 0.00 的格式, 并且最后一位不等于 "."
292
+                if (money.endsWith(".") && !split[1].equals(".")) {
293
+                    temp.setMoney(PayPriceUtils.yuanConversionPoints(Double.valueOf(money)));
294
+                }else if (!money.endsWith(".")){
295
+                    temp.setMoney(PayPriceUtils.yuanConversionPoints(Integer.valueOf(money)));
296
+                } else {
297
+                    throw new WisdomException("第" + i + "行 金额 格式不合法");
298
+                }
299
+            }
300
+
301
+            tempBills.add(temp);
302
+        }
303
+
304
+        responseBean.addSuccess(tempBills);
305
+        return responseBean;
306
+    }
307
+
308
+    private Cell getCell(Cell ce){
309
+        Cell cell = ce;
310
+        if (null == cell) {
311
+            return null;
312
+        }
313
+        //把数字当成String来读,避免出现1读成1.0的情况
314
+        if(cell.getCellType() == Cell.CELL_TYPE_NUMERIC){
315
+            cell.setCellType(Cell.CELL_TYPE_STRING);
316
+        }
317
+
318
+        return cell;
319
+    }
320
+
321
+    @Data
322
+    private class TempBill {
323
+        // 期 / 区
324
+        private String phase;
325
+        // 栋
326
+        private String building;
327
+        // 单元
328
+        private String unit;
329
+        // 楼层
330
+        private String level;
331
+        // 户号
332
+        private String roomNo;
333
+        // 业主姓名
334
+        private String ownerName;
335
+        // 金额
336
+        private Integer money;
337
+
338
+        // 收费说明
339
+        private String billExplain;
340
+    }
103 341
 }

+ 16
- 0
VUECODE/smart-property-manage/src/api/bill.js Прегледај датотеку

@@ -7,3 +7,19 @@ export function fetchBillList(query) {
7 7
     params: query
8 8
   })
9 9
 }
10
+
11
+// 保存草稿 或者 发布账单
12
+export function billUploadExcelAdd(data) {
13
+  return request({
14
+    url: '/bill/uploadExcel/add',
15
+    method: 'post',
16
+    data: {
17
+      file: data.files,
18
+      billName: data.billName,
19
+      billExplain: data.billExplain,
20
+      endDate: data.endDate,
21
+      billStatus: data.billStatus
22
+    }
23
+  })
24
+}
25
+

+ 10
- 1
VUECODE/smart-property-manage/src/store/modules/bill.js Прегледај датотеку

@@ -1,4 +1,4 @@
1
-import { fetchBillList } from '@/api/bill'
1
+import { fetchBillList, billUploadExcelAdd } from '@/api/bill'
2 2
 
3 3
 const transaction = {
4 4
   namespaced: true,
@@ -29,6 +29,15 @@ const transaction = {
29 29
           reject(error)
30 30
         })
31 31
       })
32
+    },
33
+    BillUploadExcelAdd({ commit }, data) { // 上传缴费项接口, 保存
34
+      return new Promise((resolve, reject) => {
35
+        billUploadExcelAdd(data).then(response => {
36
+          resolve(response)
37
+        }).catch(error => {
38
+          reject(error)
39
+        })
40
+      })
32 41
     }
33 42
   }
34 43
 }

+ 150
- 17
VUECODE/smart-property-manage/src/views/bill/add/index.vue Прегледај датотеку

@@ -9,23 +9,70 @@
9 9
       </el-form-item>
10 10
       <el-form-item label="截止时间" prop="endDate">
11 11
         <el-date-picker
12
-            v-model="ruleForm.endDate"
13
-            value-format="timestamp"
14
-            type="date"
15
-            placeholder="选择日期"/>
12
+          v-model="ruleForm.endDate"
13
+          value-format="timestamp"
14
+          type="date"
15
+          placeholder="选择日期"/>
16 16
       </el-form-item>
17 17
       <div>
18 18
         <span>
19
-          <el-upload :on-preview="handlePreview" :on-change="handleChange" :before-upload="beforeUpload" :limit="1" :on-exceed="handleExceed" class="upload-demo" action="" multiple>
19
+          <el-upload
20
+            :on-success="successUpload"
21
+            :limit="1"
22
+            :on-exceed="handleExceed"
23
+            :before-upload="beforeUpload"
24
+            :data="ruleForm"
25
+            name="file"
26
+            class="upload-demo"
27
+            action="http://localhost:8086/property-api/bill/uploadExcel/get"
28
+            multiple>
20 29
             <el-button slot="trigger" size="large" type="primary">选取文件并预览</el-button>
21 30
           </el-upload>
22 31
           如果还未制作账单,请先下载账单模板,按规则填写费用后再上传
23 32
           <el-button type="primary" size="small" icon="el-icon-download" @click="submitForm('ruleForm')">下载模板</el-button>
24
-          </span>
33
+        </span>
25 34
       </div>
26
-      <el-form-item>
27
-        <el-button type="primary" @click="submitForm('ruleForm')">立即创建</el-button>
28
-        <el-button @click="resetForm('ruleForm')">重置</el-button>
35
+      <el-table
36
+        :data="list"
37
+        border
38
+        style="width: 100%; margin-top: 20px;">
39
+        <el-table-column
40
+          prop="id"
41
+          type="index"
42
+          label="选择"
43
+          align="center"/>
44
+        <el-table-column
45
+          prop="name"
46
+          label="房屋信息"
47
+          align="center"
48
+          width="180">
49
+          <template slot-scope="scope">{{ scope.row.phase + scope.row.building + scope.row.unit + scope.row.level + scope.row.roomNo }}</template>
50
+        </el-table-column>
51
+        <el-table-column
52
+          prop="ownerName"
53
+          label="业主姓名"/>
54
+        <el-table-column
55
+          prop="billExplain"
56
+          align="center"
57
+          label="收费说明"/>
58
+        <el-table-column
59
+          prop="money"
60
+          align="center"
61
+          label="收费金额(元)">
62
+          <template slot-scope="scope">{{ showPayPrice(scope.row.money) }}</template>
63
+        </el-table-column>
64
+      </el-table>
65
+      <el-pagination
66
+        :current-page="listQuery.pageNum"
67
+        :page-sizes="[10, 20, 40, 100]"
68
+        :page-size="listQuery.pageSize"
69
+        :total="total"
70
+        layout="total, sizes, prev, pager, next, jumper"
71
+        @size-change="handleSizeChange"
72
+        @current-change="handleCurrentChange"/>
73
+      <el-form-item style="margin-top: 20px;">
74
+        <el-button @click="submitForm('ruleForm', 2)">保存草稿</el-button>
75
+        <el-button type="primary" @click="submitForm('ruleForm', 0)">发送账单</el-button>
29 76
       </el-form-item>
30 77
     </el-form>
31 78
   </div>
@@ -47,7 +94,8 @@ export default {
47 94
       ruleForm: {
48 95
         billName: '',
49 96
         billExplain: '',
50
-        endDate: ''
97
+        endDate: '',
98
+        billStatus: '' // 缴费状态  0:未缴费  1:已线上缴费 2:已线下缴费
51 99
       },
52 100
       rules: {
53 101
         billName: [
@@ -63,7 +111,15 @@ export default {
63 111
       defaultProps: {
64 112
         children: 'children',
65 113
         label: 'menuName'
66
-      }
114
+      },
115
+      listQuery: { // 查询
116
+        pageNum: 1,
117
+        pageSize: 10
118
+      },
119
+      total: 0,
120
+      list: [], // 数据
121
+      tempList: [], // 临时数据
122
+      files: '' // 文件
67 123
     }
68 124
   },
69 125
   created() {
@@ -76,22 +132,89 @@ export default {
76 132
       'FetchMenuList',
77 133
       'AddRoleInfo'
78 134
     ]),
79
-    submitForm(formName) { // 提交
80
-      // 获取选中的树形节点 key
81
-      this.ruleForm.menuArray = this.$refs.tree.getCheckedKeys()
82
-      if (this.ruleForm.menuArray.length < 1) {
83
-        this.$message.error('请至少选择一个菜单权限')
135
+    getList() { // 计算分页数据
136
+      const tempList = this.tempList
137
+      const list = []
138
+      let counNum = 0
139
+      for (let t = (this.listQuery.pageNum - 1) * this.listQuery.pageSize; t < tempList.length; t++) {
140
+        if (counNum === this.listQuery.pageSize) {
141
+          break
142
+        }
143
+        list.push(tempList[t])
144
+        counNum++
145
+      }
146
+
147
+      // for (const i in tempList) {
148
+      //   list.push(tempList[i])
149
+      // }
150
+      return list
151
+    },
152
+    beforeUpload(file) {
153
+      const extension = file.name.split('.')[1] === 'xls'
154
+      const extension2 = file.name.split('.')[1] === 'xlsx'
155
+      if (!extension && !extension2) {
156
+        this.$message.warning('上传文件只能是 xls、xlsx格式!')
84 157
         return
85 158
       }
159
+      this.files = file
160
+      return true // 返回false不会自动上传
161
+    },
162
+    successUpload(response, file, fileList) { // 上传成功时
163
+      const resCode = response.code
164
+      if (resCode === '1') {
165
+        this.$message.error(response.message)
166
+        return
167
+      }
168
+      this.tempList = response.data.list
169
+      this.total = response.data.total
170
+      this.list = this.getList()
171
+      console.log(response)
172
+    },
173
+    handleExceed(files, fileList) {
174
+      console.log('只能选择一个文件')
175
+    },
176
+    submitForm(formName, status) { // 提交
86 177
       this.$refs[formName].validate((valid) => {
87 178
         if (valid) {
88
-          this.addRole()
179
+          this.ruleForm.billStatus = status
180
+          const data = this.ruleForm
181
+          data.files = this.files
182
+          console.log('data: ', data)
183
+          this.$store.dispatch('BillUploadExcelAdd', data).then(res => {
184
+            const resCode = res.code
185
+            if (resCode === '1') {
186
+              this.$message.error(res.message)
187
+              return
188
+            }
189
+            this.$message.success(res.message)
190
+          }).catch(() => {
191
+            console.log('BillUploadExcelAdd error')
192
+          })
89 193
         } else {
90 194
           console.log('error submit!!')
91 195
           return false
92 196
         }
93 197
       })
94 198
     },
199
+    addInvoice(status) { // 保存
200
+      this.ruleForm.status = status
201
+      const data = this.ruleForm
202
+      data.files = this.files
203
+      this.$store.dispatch('BillUploadExcelAdd', data).then(res => {
204
+        const resCode = res.code
205
+        if (resCode === '1') {
206
+          this.$message.error(res.message)
207
+          return
208
+        }
209
+        this.$message.success(res.message)
210
+      }).catch(() => {
211
+        console.log('BillUploadExcelAdd error')
212
+      })
213
+    },
214
+    showPayPrice(payPrice) { //  转换金额
215
+      const price = payPrice / 100
216
+      return price
217
+    },
95 218
     getMenuList() {
96 219
       this.FetchMenuList().then(() => {
97 220
       }).catch(() => {
@@ -128,6 +251,16 @@ export default {
128 251
         loading.close()
129 252
         console.log('error addRole')
130 253
       })
254
+    },
255
+    handleSizeChange(val) {
256
+      console.log(`每页 ${val} 条`)
257
+      this.listQuery.pageSize = val
258
+      this.list = this.getList()
259
+    },
260
+    handleCurrentChange(val) {
261
+      console.log(`当前页: ${val}`)
262
+      this.listQuery.pageNum = val
263
+      this.list = this.getList()
131 264
     }
132 265
   }
133 266
 }

+ 1
- 1
VUECODE/smart-property-manage/src/views/building/batch/batchImport.vue Прегледај датотеку

@@ -52,7 +52,7 @@ export default {
52 52
       list: [],
53 53
       files: null,
54 54
       currentPage4: 4
55
-    };
55
+    }
56 56
   },
57 57
   computed: {
58 58
     ...mapState("batchImport", {