1.统一css样式调整

  1. .jm-query-form .ivu-btn-primary{
  2. background-color: #014df1;
  3. border-color: #014df1;
  4. }
  5. .ivu-collapse-header {
  6. display: none;
  7. }
  8. .ty-bar-container {
  9. float: right;
  10. background: transparent;
  11. }
  12. .ty-bar-container .jm-sheet-toolbar-divider {
  13. margin: 12px 0px 0;
  14. }

2.自定义下拉框,查询栏数据联动

前端代码

  1. //获取公司名称
  2. $http.metaGet('http://192.168.80.6:8088/jimu/linkage/get/company').then(res=>{
  3. let options = res.data;
  4. this.updateSelectOptions('wd', 'uid', options)
  5. })
  6. //获取公司下的仓库名称
  7. this.onSearchFormChange('wd', 'uid', (value)=>{
  8. let params = {params: {company_id: value}}
  9. $http.metaGet('http://192.168.80.6:8088/jimu/linkage/get/warehouse', params ).then(res=>{
  10. let options = res.data;
  11. this.updateSelectOptions('wd', 'warehouse_id', options)
  12. })
  13. })
  • 获取公司名称时需注意this.updateSelectOptions('wd', 'uid', options)
    • wd:代表数据源编码
    • uid:字段名
  • 获取公司下的仓库名称时需注意let params = {params: {company_id: value}}
    • company_id:代表公司id,为java固定参数

后端代码

controller层

  1. @RestController
  2. @RequestMapping("/jimu/linkage")
  3. public class LinkAgeController {
  4. @Autowired
  5. private ILinkAgeService iLinkAgeService;
  6. @GetMapping("/get/company")
  7. public List<LinkAge> getCompanyParameters() {
  8. return iLinkAgeService.getCompanyParameters();
  9. }
  10. @GetMapping("/get/warehouse")
  11. public List<LinkAge> getWarehouseParameters(@RequestParam(name = "company_id", required = false) String companyId) {
  12. return iLinkAgeService.getWarehouseParameters(companyId);
  13. }
  14. }

service层 只做了映射关系,没有业务代码,略过

mapper层

  1. <mapper namespace="com.ruoyi.report.mapper.LinkAgeMapper">
  2. <select id="getCompanyParameters" parameterType="String" resultType="com.ruoyi.report.domain.LinkAge">
  3. select id as value, company_name as text
  4. from hw_company_list
  5. </select>
  6. <select id="getWarehouseParameters" parameterType="String" resultType="com.ruoyi.report.domain.LinkAge">
  7. select t1.warehouse_id as value, t1.new_name as text
  8. from wh_warehouse t1
  9. left join hw_company_list t2
  10. on t1.company_id = t2.id
  11. where 1=1
  12. <if test="companyId != null">
  13. and t1.company_id = #{companyId}
  14. </if>
  15. </select>
  16. </mapper>

3.获取当月1号以及今天日期,格式为”YYYY-MM-DD”

  1. // 获取当天日期
  2. var today = new Date();
  3. var todaysDate = today.getFullYear()+'-'+(today.getMonth()+1)+'-'+today.getDate();
  4. // 获取本月1号
  5. var firstDay = new Date();
  6. firstDay.setDate(1);
  7. var firstDate = firstDay.getFullYear()+'-'+(firstDay.getMonth()+1)+'-'+firstDay.getDate();
  8. if ( (today.getMonth()+1) <10 ){
  9. todaysDate = today.getFullYear()+'-0'+(today.getMonth()+1)+'-'+today.getDate();
  10. firstDate = firstDay.getFullYear()+'-0'+(firstDay.getMonth()+1)+'-0'+firstDay.getDate();
  11. }
  12. if(today.getDate() <10 ){
  13. todaysDate = today.getFullYear()+'-'+(today.getMonth()+1)+'-0'+today.getDate();
  14. }
  • firstDate:当月1号日期
  • todaysDate:今天日期

4.默认打开显示查询栏

  1. function init(){
  2. this.queryPanel = '1';
  3. }

5.路径编码格式统一

  1. if (!!cs__create_time_begin) {
  2. cs__create_time_begin = decodeURI(cs__create_time_begin);
  3. }

6.获取路径传参(截取方式)

  1. //日期开始时间
  2. var cs__create_time_begin= firstDate;
  3. //日期结束时间
  4. var cs__create_time_end= todaysDate;
  5. let query = window.location.search.substring(1);
  6. let vars = query.split("&");
  7. for (let i=0;i<vars.length;i++) {
  8. let pair = vars[i].split("=");
  9. if(pair[0] == 'cs__create_time_begin'){
  10. if(pair[1] != '' && pair[1] != '%20' && pair[1] != ' ' && pair[1] != null && pair[1] != 'null'){
  11. cs__create_time_begin= pair[1];
  12. }
  13. }
  14. if(pair[0] == 'cs__create_time_end'){
  15. if(pair[1] != '' && pair[1] != '%20' && pair[1] != ' ' && pair[1] != null && pair[1] != 'null'){
  16. cs__create_time_end = pair[1];
  17. }
  18. }
  19. }

7.查询栏赋值方式

  1. this.updateSearchFormValue('cs', 'create_time', cs__create_time_begin + '|' +cs__create_time_end);

8.SQL查询语句中常用函数、方式

1.时间戳转换

  1. FROM_UNIXTIME(t1.deduction_time) as deduction_time

2.SQL条件判空

  1. <#if isNotEmpty(uid)>
  2. and t1.uid = ${uid}
  3. </#if>

3.SQL时间戳转换日期并格式化’YYYY-MM-DD’

  1. DATE_FORMAT(FROM_UNIXTIME(t1.create_time), '%Y-%m-%d')

4.SQL字段判空选择处理

  1. IFNULL(t5.sku,t7.sku),IFNULL(t4.sku,t7.sku))

5.数据库字段存储JSON格式数据,如何从中获取key:value形式数据值?

  1. CONVERT(JSON_EXTRACT(t1.deduction_detail, '$.volume'), DECIMAL(10, 2)) AS t_volume
  • t1.deduction_detail:字段
  • ‘$.volume’:字段中的key等于volume

6.拼接数据库字段,展示所需要的效果

  1. CONCAT( store_name, '(', country_zh, ')' ) AS store_name

7.判断展示

  1. (CASE r.paymethod
  2. WHEN '1' THEN "手动充值"
  3. WHEN '2' THEN "支付宝"
  4. WHEN '3' THEN "微信"
  5. WHEN '4' THEN "扣款"
  6. WHEN '5' THEN "退款"
  7. WHEN '6' THEN "银行卡"
  8. WHEN '7' THEN "其他"
  9. WHEN '8' THEN "信用充值"
  10. WHEN '9' THEN "现金"
  11. ELSE "其他" END) paymethod,
  12. IF(w.remark like '%<img%', NULL, w.remark) AS remark, '充值成功' `status`

8.如果遇到需要展示全部数据时,可使用UNION ALL进行拼接SQL

  1. SELECT d.company_name, d.uid, d.storage_fee, d.order_processing_fee, d.order_num, d.listing_fee,
  2. d.labeling_fee, d.total_recharge, d.evaluation_cost, d.deduction_application, d.packaging_fee,
  3. d.after_sale_fee, d.after_sales_freight, d.create_time
  4. FROM (SELECT a.company_name as company_name, a.id AS uid,
  5. sum(if(a.fee_type = '1', a.total, 0)) as storage_fee,
  6. sum(if(a.fee_type = '7', a.total, 0)) as order_processing_fee,
  7. -- count(a.fee_type = '7') as order_num,
  8. sum(order_number) as order_num,
  9. sum(if(a.fee_type = '4', a.total, 0)) as listing_fee,
  10. sum(if(a.fee_type = '28', a.total, 0)) as labeling_fee,
  11. sum(if(a.fee_type = '8', a.total, 0)) as total_recharge,
  12. sum(if(a.fee_type = '16', a.total, 0)) as evaluation_cost,
  13. IFNULL(b.total,0) as deduction_application,
  14. IFNULL(c.packaging_fee,0) as packaging_fee,
  15. IFNULL(c.after_sale_fee,0) as after_sale_fee,
  16. IFNULL((c.refund_ren_min_bi + c.repeat_ren_min_bi),0) AS after_sales_freight,
  17. FROM_UNIXTIME(a.create_time) AS create_time
  18. FROM (SELECT sum( amount ) AS `total`, l.id, `fee_type`, company_name, w.create_time,IF(fee_type = 7,count(orderno),0) as order_number
  19. FROM hw_company_list l
  20. left join `wallet_use_list` w ON l.id = w.uid
  21. WHERE fee_type IN ( 1, 7, 4, 28, 8, 16 ) AND w.uid IS NOT NULL AND w.uid > 0
  22. GROUP BY l.id, fee_type)a
  23. LEFT JOIN (SELECT l.id, sum( ren_min_bi ) AS `total`, company_name, w.create_time
  24. FROM hw_company_list l
  25. LEFT JOIN `wallet_deduction` w ON l.id = w.uid
  26. left JOIN wallet_use_list u on u.orderno = w.deductionno
  27. WHERE w.`status` = 2
  28. GROUP BY l.id)b ON a.id = b.id
  29. LEFT JOIN (SELECT l.id,
  30. SUM( packaging_fee ) AS `packaging_fee`,
  31. SUM( after_sale_fee ) AS `after_sale_fee`,
  32. SUM( refund_ren_min_bi ) AS `refund_ren_min_bi`,
  33. SUM( repeat_ren_min_bi ) AS `repeat_ren_min_bi`,
  34. company_name, wul.create_time
  35. FROM hw_company_list l
  36. LEFT JOIN `wallet_use_list` `wul` ON l.id = wul.uid
  37. LEFT JOIN `hw_after_sale_list` `asl` ON wul.orderno = asl.after_sale_order
  38. WHERE `fee_type` = 39
  39. GROUP BY l.id)c ON a.id = c.id
  40. WHERE 1=1
  41. GROUP BY a.id
  42. UNION ALL (SELECT company_name,id as uid,'0','0','0','0','0','0','0','0','0','0','0','0'
  43. FROM hw_company_list)) d
  44. GROUP BY uid