diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/custom/SysOrderController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/custom/SysOrderController.java index 65f916843..f401d5b48 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/custom/SysOrderController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/custom/SysOrderController.java @@ -1,6 +1,14 @@ package com.ruoyi.web.controller.custom; +import java.util.ArrayList; import java.util.List; + +import com.ruoyi.common.core.domain.entity.SysUser; +import com.ruoyi.system.domain.SysPost; +import com.ruoyi.system.domain.SysUserPost; +import com.ruoyi.system.domain.custom.UserPostOption; +import com.ruoyi.system.service.ISysPostService; +import com.ruoyi.system.service.ISysUserService; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; @@ -28,31 +36,36 @@ import com.ruoyi.common.core.page.TableDataInfo; */ @RestController @RequestMapping("/custom/order") -public class SysOrderController extends BaseController -{ +public class SysOrderController extends BaseController { @Autowired private ISysOrderService sysOrderService; + @Autowired + private ISysPostService postService; + + @Autowired + private ISysUserService userService; + + /** * 查询销售订单列表 */ @PreAuthorize("@ss.hasPermi('custom:order:list')") @GetMapping("/list") - public TableDataInfo list(SysOrder sysOrder) - { + public TableDataInfo list(SysOrder sysOrder) { startPage(); List<SysOrder> list = sysOrderService.selectSysOrderList(sysOrder); return getDataTable(list); } + /** * 导出销售订单列表 */ @PreAuthorize("@ss.hasPermi('custom:order:export')") @Log(title = "销售订单", businessType = BusinessType.EXPORT) @GetMapping("/export") - public AjaxResult export(SysOrder sysOrder) - { + public AjaxResult export(SysOrder sysOrder) { List<SysOrder> list = sysOrderService.selectSysOrderList(sysOrder); ExcelUtil<SysOrder> util = new ExcelUtil<SysOrder>(SysOrder.class); return util.exportExcel(list, "order"); @@ -63,8 +76,7 @@ public class SysOrderController extends BaseController */ @PreAuthorize("@ss.hasPermi('custom:order:query')") @GetMapping(value = "/{orderId}") - public AjaxResult getInfo(@PathVariable("orderId") Long orderId) - { + public AjaxResult getInfo(@PathVariable("orderId") Long orderId) { return AjaxResult.success(sysOrderService.selectSysOrderById(orderId)); } @@ -74,8 +86,7 @@ public class SysOrderController extends BaseController @PreAuthorize("@ss.hasPermi('custom:order:add')") @Log(title = "销售订单", businessType = BusinessType.INSERT) @PostMapping - public AjaxResult add(@RequestBody SysOrder sysOrder) - { + public AjaxResult add(@RequestBody SysOrder sysOrder) { return toAjax(sysOrderService.insertSysOrder(sysOrder)); } @@ -85,8 +96,7 @@ public class SysOrderController extends BaseController @PreAuthorize("@ss.hasPermi('custom:order:edit')") @Log(title = "销售订单", businessType = BusinessType.UPDATE) @PutMapping - public AjaxResult edit(@RequestBody SysOrder sysOrder) - { + public AjaxResult edit(@RequestBody SysOrder sysOrder) { return toAjax(sysOrderService.updateSysOrder(sysOrder)); } @@ -96,8 +106,29 @@ public class SysOrderController extends BaseController @PreAuthorize("@ss.hasPermi('custom:order:remove')") @Log(title = "销售订单", businessType = BusinessType.DELETE) @DeleteMapping("/{orderIds}") - public AjaxResult remove(@PathVariable Long[] orderIds) - { + public AjaxResult remove(@PathVariable Long[] orderIds) { return toAjax(sysOrderService.deleteSysOrderByIds(orderIds)); } + + @GetMapping("/getOptions") + public AjaxResult getOptions() { + AjaxResult ajax = AjaxResult.success(); + List<SysUserPost> userPosts = postService.selectUserPostAll(); + + List<UserPostOption> userPostOptions = new ArrayList<>(); + + for (SysUserPost userPost : userPosts) { + SysPost post = postService.selectPostById(userPost.getPostId()); + SysUser user = userService.selectUserById(userPost.getUserId()); + UserPostOption userPostOption = new UserPostOption(); + userPostOption.setPostCode(post.getPostCode()); + userPostOption.setUserId(userPost.getUserId()); + userPostOption.setUserName(user.getNickName()); + userPostOptions.add(userPostOption); + } + + ajax.put(AjaxResult.DATA_TAG, userPostOptions); + return ajax; + } + } \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/application-druid.yml b/ruoyi-admin/src/main/resources/application-druid.yml index 8768b5f56..510657226 100644 --- a/ruoyi-admin/src/main/resources/application-druid.yml +++ b/ruoyi-admin/src/main/resources/application-druid.yml @@ -1,57 +1,60 @@ # 数据源配置 spring: - datasource: - type: com.alibaba.druid.pool.DruidDataSource - driverClassName: com.mysql.cj.jdbc.Driver - druid: - # 主库数据源 - master: - url: jdbc:mysql://localhost:3306/ry-vue?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 - username: root - password: wonderdb - # 从库数据源 - slave: - # 从数据源开关/默认关闭 - enabled: false - url: - username: - password: - # 初始连接数 - initialSize: 5 - # 最小连接池数量 - minIdle: 10 - # 最大连接池数量 - maxActive: 20 - # 配置获取连接等待超时的时间 - maxWait: 60000 - # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 - timeBetweenEvictionRunsMillis: 60000 - # 配置一个连接在池中最小生存的时间,单位是毫秒 - minEvictableIdleTimeMillis: 300000 - # 配置一个连接在池中最大生存的时间,单位是毫秒 - maxEvictableIdleTimeMillis: 900000 - # 配置检测连接是否有效 - validationQuery: SELECT 1 FROM DUAL - testWhileIdle: true - testOnBorrow: false - testOnReturn: false - webStatFilter: - enabled: true - statViewServlet: - enabled: true - # 设置白名单,不填则允许所有访问 - allow: - url-pattern: /druid/* - # 控制台管理用户名和密码 - login-username: - login-password: - filter: - stat: - enabled: true - # 慢SQL记录 - log-slow-sql: true - slow-sql-millis: 1000 - merge-sql: true - wall: - config: - multi-statement-allow: true \ No newline at end of file + datasource: + type: com.alibaba.druid.pool.DruidDataSource + driverClassName: com.mysql.cj.jdbc.Driver + druid: + # 主库数据源 + master: + # url: jdbc:mysql://localhost:3306/ry-vue?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 + # password: wonderdb + + url: jdbc:mysql://47.97.194.44:3306/long_shop?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 + password: 9gPUnV$#2s/j(7_( + username: root + # 从库数据源 + slave: + # 从数据源开关/默认关闭 + enabled: false + url: + username: + password: + # 初始连接数 + initialSize: 5 + # 最小连接池数量 + minIdle: 10 + # 最大连接池数量 + maxActive: 20 + # 配置获取连接等待超时的时间 + maxWait: 60000 + # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 + timeBetweenEvictionRunsMillis: 60000 + # 配置一个连接在池中最小生存的时间,单位是毫秒 + minEvictableIdleTimeMillis: 300000 + # 配置一个连接在池中最大生存的时间,单位是毫秒 + maxEvictableIdleTimeMillis: 900000 + # 配置检测连接是否有效 + validationQuery: SELECT 1 FROM DUAL + testWhileIdle: true + testOnBorrow: false + testOnReturn: false + webStatFilter: + enabled: true + statViewServlet: + enabled: true + # 设置白名单,不填则允许所有访问 + allow: + url-pattern: /druid/* + # 控制台管理用户名和密码 + login-username: + login-password: + filter: + stat: + enabled: true + # 慢SQL记录 + log-slow-sql: true + slow-sql-millis: 1000 + merge-sql: true + wall: + config: + multi-statement-allow: true \ No newline at end of file diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain/custom/UserPostOption.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain/custom/UserPostOption.java new file mode 100644 index 000000000..5ca5d0d56 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain/custom/UserPostOption.java @@ -0,0 +1,43 @@ +package com.ruoyi.system.domain.custom; + +public class UserPostOption { + + private Long userId; + + private String userName; + + private String postCode; + + public String getPostCode() { + return postCode; + } + + public Long getUserId() { + return userId; + } + + public String getUserName() { + return userName; + } + + public void setPostCode(String postCode) { + this.postCode = postCode; + } + + public void setUserId(Long userId) { + this.userId = userId; + } + + public void setUserName(String userName) { + this.userName = userName; + } + + @Override + public String toString() { + return "UserPostOption{" + + "userId=" + userId + + ", userName='" + userName + '\'' + + ", postCode='" + postCode + '\'' + + '}'; + } +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysPostMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysPostMapper.java index a98326f8b..48d0e9d44 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysPostMapper.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysPostMapper.java @@ -1,18 +1,19 @@ package com.ruoyi.system.mapper; import java.util.List; + import com.ruoyi.system.domain.SysPost; +import com.ruoyi.system.domain.SysUserPost; /** * 岗位信息 数据层 - * + * * @author ruoyi */ -public interface SysPostMapper -{ +public interface SysPostMapper { /** * 查询岗位数据集合 - * + * * @param post 岗位信息 * @return 岗位数据集合 */ @@ -20,14 +21,16 @@ public interface SysPostMapper /** * 查询所有岗位 - * + * * @return 岗位列表 */ public List<SysPost> selectPostAll(); + public List<SysUserPost> selectUserPostAll(); + /** * 通过岗位ID查询岗位信息 - * + * * @param postId 岗位ID * @return 角色对象信息 */ @@ -35,7 +38,7 @@ public interface SysPostMapper /** * 根据用户ID获取岗位选择框列表 - * + * * @param userId 用户ID * @return 选中岗位ID列表 */ @@ -43,7 +46,7 @@ public interface SysPostMapper /** * 查询用户所属岗位组 - * + * * @param userName 用户名 * @return 结果 */ @@ -51,7 +54,7 @@ public interface SysPostMapper /** * 删除岗位信息 - * + * * @param postId 岗位ID * @return 结果 */ @@ -59,7 +62,7 @@ public interface SysPostMapper /** * 批量删除岗位信息 - * + * * @param postIds 需要删除的岗位ID * @return 结果 */ @@ -67,7 +70,7 @@ public interface SysPostMapper /** * 修改岗位信息 - * + * * @param post 岗位信息 * @return 结果 */ @@ -75,7 +78,7 @@ public interface SysPostMapper /** * 新增岗位信息 - * + * * @param post 岗位信息 * @return 结果 */ @@ -83,7 +86,7 @@ public interface SysPostMapper /** * 校验岗位名称 - * + * * @param postName 岗位名称 * @return 结果 */ @@ -91,7 +94,7 @@ public interface SysPostMapper /** * 校验岗位编码 - * + * * @param postCode 岗位编码 * @return 结果 */ diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserPostMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserPostMapper.java index 9c33e546d..a7462ecd6 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserPostMapper.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserPostMapper.java @@ -1,18 +1,19 @@ package com.ruoyi.system.mapper; import java.util.List; + import com.ruoyi.system.domain.SysUserPost; /** * 用户与岗位关联表 数据层 - * + * * @author ruoyi */ -public interface SysUserPostMapper -{ +public interface SysUserPostMapper { + /** * 通过用户ID删除用户和岗位关联 - * + * * @param userId 用户ID * @return 结果 */ @@ -20,7 +21,7 @@ public interface SysUserPostMapper /** * 通过岗位ID查询岗位使用数量 - * + * * @param postId 岗位ID * @return 结果 */ @@ -28,7 +29,7 @@ public interface SysUserPostMapper /** * 批量删除用户和岗位关联 - * + * * @param ids 需要删除的数据ID * @return 结果 */ @@ -36,7 +37,7 @@ public interface SysUserPostMapper /** * 批量新增用户岗位信息 - * + * * @param userPostList 用户角色列表 * @return 结果 */ diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysPostService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysPostService.java index 2fb9a540d..ca3ab60ce 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysPostService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysPostService.java @@ -2,6 +2,7 @@ package com.ruoyi.system.service; import java.util.List; import com.ruoyi.system.domain.SysPost; +import com.ruoyi.system.domain.SysUserPost; /** * 岗位信息 服务层 @@ -18,6 +19,8 @@ public interface ISysPostService */ public List<SysPost> selectPostList(SysPost post); + public List<SysUserPost> selectUserPostAll(); + /** * 查询所有岗位 * diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysPostServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysPostServiceImpl.java index 127ed3fbd..c18c2d057 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysPostServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysPostServiceImpl.java @@ -1,6 +1,8 @@ package com.ruoyi.system.service.impl; import java.util.List; + +import com.ruoyi.system.domain.SysUserPost; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.ruoyi.common.constant.UserConstants; @@ -48,6 +50,11 @@ public class SysPostServiceImpl implements ISysPostService return postMapper.selectPostAll(); } + @Override + public List<SysUserPost> selectUserPostAll() { + return postMapper.selectUserPostAll(); + } + /** * 通过岗位ID查询岗位信息 * diff --git a/ruoyi-system/src/main/resources/mapper/system/SysPostMapper.xml b/ruoyi-system/src/main/resources/mapper/system/SysPostMapper.xml index 6ac8e7c36..a46334099 100644 --- a/ruoyi-system/src/main/resources/mapper/system/SysPostMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/SysPostMapper.xml @@ -1,122 +1,135 @@ <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE mapper -PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" -"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> + PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="com.ruoyi.system.mapper.SysPostMapper"> - <resultMap type="SysPost" id="SysPostResult"> - <id property="postId" column="post_id" /> - <result property="postCode" column="post_code" /> - <result property="postName" column="post_name" /> - <result property="postSort" column="post_sort" /> - <result property="status" column="status" /> - <result property="createBy" column="create_by" /> - <result property="createTime" column="create_time" /> - <result property="updateBy" column="update_by" /> - <result property="updateTime" column="update_time" /> - <result property="remark" column="remark" /> - </resultMap> - - <sql id="selectPostVo"> + <resultMap type="SysPost" id="SysPostResult"> + <id property="postId" column="post_id"/> + <result property="postCode" column="post_code"/> + <result property="postName" column="post_name"/> + <result property="postSort" column="post_sort"/> + <result property="status" column="status"/> + <result property="createBy" column="create_by"/> + <result property="createTime" column="create_time"/> + <result property="updateBy" column="update_by"/> + <result property="updateTime" column="update_time"/> + <result property="remark" column="remark"/> + </resultMap> + + <resultMap id="SysUserPostResult" type="SysUserPost"> + <id property="userId" column="user_id"/> + <result property="postId" column="post_id"/> + </resultMap> + + <sql id="selectPostVo"> select post_id, post_code, post_name, post_sort, status, create_by, create_time, remark from sys_post </sql> - - <select id="selectPostList" parameterType="SysPost" resultMap="SysPostResult"> - <include refid="selectPostVo"/> - <where> - <if test="postCode != null and postCode != ''"> - AND post_code like concat('%', #{postCode}, '%') - </if> - <if test="status != null and status != ''"> - AND status = #{status} - </if> - <if test="postName != null and postName != ''"> - AND post_name like concat('%', #{postName}, '%') - </if> - </where> - </select> - - <select id="selectPostAll" resultMap="SysPostResult"> - <include refid="selectPostVo"/> - </select> - - <select id="selectPostById" parameterType="Long" resultMap="SysPostResult"> - <include refid="selectPostVo"/> - where post_id = #{postId} - </select> - - <select id="selectPostListByUserId" parameterType="Long" resultType="Integer"> + + <sql id="selectUserPostVo"> + select * from sys_user_post + </sql> + + <select id="selectPostList" parameterType="SysPost" resultMap="SysPostResult"> + <include refid="selectPostVo"/> + <where> + <if test="postCode != null and postCode != ''"> + AND post_code like concat('%', #{postCode}, '%') + </if> + <if test="status != null and status != ''"> + AND status = #{status} + </if> + <if test="postName != null and postName != ''"> + AND post_name like concat('%', #{postName}, '%') + </if> + </where> + </select> + + <select id="selectPostAll" resultMap="SysPostResult"> + <include refid="selectPostVo"/> + </select> + + <select id="selectUserPostAll" resultMap="SysUserPostResult"> + <include refid="selectUserPostVo"/> + </select> + + <select id="selectPostById" parameterType="Long" resultMap="SysPostResult"> + <include refid="selectPostVo"/> + where post_id = #{postId} + </select> + + <select id="selectPostListByUserId" parameterType="Long" resultType="Integer"> select p.post_id from sys_post p left join sys_user_post up on up.post_id = p.post_id left join sys_user u on u.user_id = up.user_id where u.user_id = #{userId} </select> - - <select id="selectPostsByUserName" parameterType="String" resultMap="SysPostResult"> + + <select id="selectPostsByUserName" parameterType="String" resultMap="SysPostResult"> select p.post_id, p.post_name, p.post_code from sys_post p left join sys_user_post up on up.post_id = p.post_id left join sys_user u on u.user_id = up.user_id where u.user_name = #{userName} </select> - - <select id="checkPostNameUnique" parameterType="String" resultMap="SysPostResult"> - <include refid="selectPostVo"/> - where post_name=#{postName} limit 1 - </select> - - <select id="checkPostCodeUnique" parameterType="String" resultMap="SysPostResult"> - <include refid="selectPostVo"/> - where post_code=#{postCode} limit 1 - </select> - - <update id="updatePost" parameterType="SysPost"> - update sys_post - <set> - <if test="postCode != null and postCode != ''">post_code = #{postCode},</if> - <if test="postName != null and postName != ''">post_name = #{postName},</if> - <if test="postSort != null and postSort != ''">post_sort = #{postSort},</if> - <if test="status != null and status != ''">status = #{status},</if> - <if test="remark != null">remark = #{remark},</if> - <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if> - update_time = sysdate() - </set> - where post_id = #{postId} - </update> - - <insert id="insertPost" parameterType="SysPost" useGeneratedKeys="true" keyProperty="postId"> - insert into sys_post( - <if test="postId != null and postId != 0">post_id,</if> - <if test="postCode != null and postCode != ''">post_code,</if> - <if test="postName != null and postName != ''">post_name,</if> - <if test="postSort != null and postSort != ''">post_sort,</if> - <if test="status != null and status != ''">status,</if> - <if test="remark != null and remark != ''">remark,</if> - <if test="createBy != null and createBy != ''">create_by,</if> - create_time - )values( - <if test="postId != null and postId != 0">#{postId},</if> - <if test="postCode != null and postCode != ''">#{postCode},</if> - <if test="postName != null and postName != ''">#{postName},</if> - <if test="postSort != null and postSort != ''">#{postSort},</if> - <if test="status != null and status != ''">#{status},</if> - <if test="remark != null and remark != ''">#{remark},</if> - <if test="createBy != null and createBy != ''">#{createBy},</if> - sysdate() - ) - </insert> - - <delete id="deletePostById" parameterType="Long"> + + <select id="checkPostNameUnique" parameterType="String" resultMap="SysPostResult"> + <include refid="selectPostVo"/> + where post_name=#{postName} limit 1 + </select> + + <select id="checkPostCodeUnique" parameterType="String" resultMap="SysPostResult"> + <include refid="selectPostVo"/> + where post_code=#{postCode} limit 1 + </select> + + <update id="updatePost" parameterType="SysPost"> + update sys_post + <set> + <if test="postCode != null and postCode != ''">post_code = #{postCode},</if> + <if test="postName != null and postName != ''">post_name = #{postName},</if> + <if test="postSort != null and postSort != ''">post_sort = #{postSort},</if> + <if test="status != null and status != ''">status = #{status},</if> + <if test="remark != null">remark = #{remark},</if> + <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if> + update_time = sysdate() + </set> + where post_id = #{postId} + </update> + + <insert id="insertPost" parameterType="SysPost" useGeneratedKeys="true" keyProperty="postId"> + insert into sys_post( + <if test="postId != null and postId != 0">post_id,</if> + <if test="postCode != null and postCode != ''">post_code,</if> + <if test="postName != null and postName != ''">post_name,</if> + <if test="postSort != null and postSort != ''">post_sort,</if> + <if test="status != null and status != ''">status,</if> + <if test="remark != null and remark != ''">remark,</if> + <if test="createBy != null and createBy != ''">create_by,</if> + create_time + )values( + <if test="postId != null and postId != 0">#{postId},</if> + <if test="postCode != null and postCode != ''">#{postCode},</if> + <if test="postName != null and postName != ''">#{postName},</if> + <if test="postSort != null and postSort != ''">#{postSort},</if> + <if test="status != null and status != ''">#{status},</if> + <if test="remark != null and remark != ''">#{remark},</if> + <if test="createBy != null and createBy != ''">#{createBy},</if> + sysdate() + ) + </insert> + + <delete id="deletePostById" parameterType="Long"> delete from sys_post where post_id = #{postId} </delete> - - <delete id="deletePostByIds" parameterType="Long"> - delete from sys_post where post_id in - <foreach collection="array" item="postId" open="(" separator="," close=")"> - #{postId} - </foreach> - </delete> + + <delete id="deletePostByIds" parameterType="Long"> + delete from sys_post where post_id in + <foreach collection="array" item="postId" open="(" separator="," close=")"> + #{postId} + </foreach> + </delete> </mapper> \ No newline at end of file diff --git a/ruoyi-ui/src/api/custom/order.js b/ruoyi-ui/src/api/custom/order.js index fa76f76ae..f057d49f6 100644 --- a/ruoyi-ui/src/api/custom/order.js +++ b/ruoyi-ui/src/api/custom/order.js @@ -2,10 +2,18 @@ import request from '@/utils/request' // 查询销售订单列表 export function listOrder(query) { + const [fromOrderTime, toOrderTime] = query.orderTime || [null, null]; + const params = { + ...query, + fromOrderTime, + toOrderTime, + orderTime: null + } + return request({ url: '/custom/order/list', method: 'get', - params: query + params: params }) } @@ -51,3 +59,10 @@ export function exportOrder(query) { params: query }) } + +export function getOptions() { + return request({ + url: '/custom/order/getOptions', + method: 'get' + }) +} diff --git a/ruoyi-ui/src/components/RightToolbar/index.vue b/ruoyi-ui/src/components/RightToolbar/index.vue index 73d2dccea..299acb17c 100644 --- a/ruoyi-ui/src/components/RightToolbar/index.vue +++ b/ruoyi-ui/src/components/RightToolbar/index.vue @@ -1,38 +1,38 @@ -<!-- @author Shiyn/ huangmx 20200807优化--> -<template> - <div class="top-right-btn"> - <el-row> - <el-tooltip class="item" effect="dark" :content="showSearch ? '隐藏搜索' : '显示搜索'" placement="top"> - <el-button size="mini" circle icon="el-icon-search" @click="toggleSearch()" /> - </el-tooltip> - <el-tooltip class="item" effect="dark" content="刷新" placement="top"> - <el-button size="mini" circle icon="el-icon-refresh" @click="refresh()" /> - </el-tooltip> - </el-row> - </div> -</template> -<script> -export default { - name: "RightToolbar", - data() { - return {}; - }, - props: { - showSearch: { - type: Boolean, - default: true, - }, - }, - - methods: { - //搜索 - toggleSearch() { - this.$emit("update:showSearch", !this.showSearch); - }, - //刷新 - refresh() { - this.$emit("queryTable"); - }, - }, -}; -</script> +<!-- @author Shiyn/ huangmx 20200807优化--> +<template> + <div class="top-right-btn"> + <el-row> + <el-tooltip class="item" effect="dark" :content="showSearch ? '隐藏搜索' : '显示搜索'" placement="top"> + <el-button size="mini" circle icon="el-icon-search" @click="toggleSearch()" /> + </el-tooltip> + <el-tooltip class="item" effect="dark" content="刷新" placement="top"> + <el-button size="mini" circle icon="el-icon-refresh" @click="refresh()" /> + </el-tooltip> + </el-row> + </div> +</template> +<script> +export default { + name: "RightToolbar", + data() { + return {}; + }, + props: { + showSearch: { + type: Boolean, + default: false, + }, + }, + + methods: { + //搜索 + toggleSearch() { + this.$emit("update:showSearch", !this.showSearch); + }, + //刷新 + refresh() { + this.$emit("queryTable"); + }, + }, +}; +</script> diff --git a/ruoyi-ui/src/views/custom/order/index.vue b/ruoyi-ui/src/views/custom/order/index.vue index 1a93a2d41..ff60d4c6e 100644 --- a/ruoyi-ui/src/views/custom/order/index.vue +++ b/ruoyi-ui/src/views/custom/order/index.vue @@ -14,17 +14,17 @@ </el-form-item> </el-col> -<!-- <el-col :span="4">--> -<!-- <el-form-item label="电话" prop="phone">--> -<!-- <el-input--> -<!-- v-model="queryParams.phone"--> -<!-- placeholder="请输入电话"--> -<!-- clearable--> -<!-- size="small"--> -<!-- @keyup.enter.native="handleQuery"--> -<!-- />--> -<!-- </el-form-item>--> -<!-- </el-col>--> + <!-- <el-col :span="4">--> + <!-- <el-form-item label="电话" prop="phone">--> + <!-- <el-input--> + <!-- v-model="queryParams.phone"--> + <!-- placeholder="请输入电话"--> + <!-- clearable--> + <!-- size="small"--> + <!-- @keyup.enter.native="handleQuery"--> + <!-- />--> + <!-- </el-form-item>--> + <!-- </el-col>--> <el-col :span="4"> <el-form-item label="收款方式" prop="payTypeId"> @@ -141,14 +141,31 @@ <!-- @keyup.enter.native="handleQuery"--> <!-- />--> <!-- </el-form-item>--> - <el-col :span="4"> + <el-col :span="8"> <el-form-item label="成交日期" prop="orderTime"> - <el-date-picker clearable size="small" style="width: 200px" - v-model="queryParams.orderTime" - type="date" - value-format="yyyy-MM-dd" - placeholder="选择成交日期"> + + <el-date-picker + v-model="queryParams.orderTime" + type="daterange" + size="small" + align="right" + unlink-panels + range-separator="至" + start-placeholder="开始日期" + end-placeholder="结束日期" + value-format="yyyy-MM-dd" + :picker-options="pickerOptions"> </el-date-picker> + + <!-- <el-date-picker--> + <!-- clearable--> + <!-- size="small"--> + <!-- style="width: 200px"--> + <!-- v-model="queryParams.orderTime"--> + <!-- type="date"--> + <!-- value-format="yyyy-MM-dd"--> + <!-- placeholder="选择成交日期">>--> + <!-- </el-date-picker>--> </el-form-item> </el-col> @@ -432,7 +449,7 @@ </template> <script> - import {listOrder, getOrder, delOrder, addOrder, updateOrder, exportOrder} from "@/api/custom/order"; + import {listOrder, getOrder, delOrder, addOrder, updateOrder, exportOrder, getOptions} from "@/api/custom/order"; export default { name: "Order", @@ -447,7 +464,7 @@ // 非多个禁用 multiple: true, // 显示搜索条件 - showSearch: true, + showSearch: false, // 总条数 total: 0, // 销售订单表格数据 @@ -504,39 +521,68 @@ ], orderTime: [ {required: true, message: "成交日期不能为空", trigger: "blur"} + ], + payTypeId: [ + {required: true, message: "首款方式不能为空", trigger: "blur"} + ], + accountId: [ + {required: true, message: "账号不能为空", trigger: "blur"} ] - } + }, + pickerOptions: { + shortcuts: [{ + text: '最近一周', + onClick(picker) { + const end = new Date(); + const start = new Date(); + start.setTime(start.getTime() - 3600 * 1000 * 24 * 7); + picker.$emit('pick', [start, end]); + } + }, { + text: '最近一个月', + onClick(picker) { + const end = new Date(); + const start = new Date(); + start.setTime(start.getTime() - 3600 * 1000 * 24 * 30); + picker.$emit('pick', [start, end]); + } + }, { + text: '最近三个月', + onClick(picker) { + const end = new Date(); + const start = new Date(); + start.setTime(start.getTime() - 3600 * 1000 * 24 * 90); + picker.$emit('pick', [start, end]); + } + }] + }, }; }, created() { this.getList(); + getOptions().then(response => { + console.log(response) + const options = response.data.reduce((opts, cur) => { + if (!opts[cur.postCode]) { + opts[cur.postCode] = []; + } + opts[cur.postCode].push({dictValue: cur.userId, dictLabel: cur.userName}) + return opts; + }, {}) + this.preSaleIdOptions = options['pre_sale'] || []; + this.afterSaleIdOptions = options['after_sale'] || []; + this.nutritionistIdOptions = options['nutri'] || []; + this.nutriAssisIdOptions = options['nutri_assis'] || []; + this.plannerIdOptions = options['planner'] || []; + this.plannerAssisIdOptions = options['planner_assis'] || []; + this.operatorIdOptions = options['operator'] || []; + }) this.getDicts("cus_pay_type").then(response => { this.payTypeIdOptions = response.data; }); - this.getDicts("cus_pre_sale").then(response => { - this.preSaleIdOptions = response.data; - }); - this.getDicts("cus_after_sale").then(response => { - this.afterSaleIdOptions = response.data; - }); - this.getDicts("cus_nutri").then(response => { - this.nutritionistIdOptions = response.data; - }); - this.getDicts("cus_nutri_assis").then(response => { - this.nutriAssisIdOptions = response.data; - }); - this.getDicts("cus_planner").then(response => { - this.plannerIdOptions = response.data; - }); this.getDicts("cus_account").then(response => { this.accountIdOptions = response.data; }); - this.getDicts("cus_planner_assis").then(response => { - this.plannerAssisIdOptions = response.data; - }); - this.getDicts("cus_operator").then(response => { - this.operatorIdOptions = response.data; - }); }, methods: { /** 查询销售订单列表 */ @@ -627,33 +673,33 @@ handleQuery() { this.queryParams.pageNum = 1; this.getList(); - this.getDicts("cus_pay_type").then(response => { - this.payTypeIdOptions = response.data; - }); - this.getDicts("cus_pre_sale").then(response => { - this.preSaleIdOptions = response.data; - }); - this.getDicts("cus_after_sale").then(response => { - this.afterSaleIdOptions = response.data; - }); - this.getDicts("cus_nutri").then(response => { - this.nutritionistIdOptions = response.data; - }); - this.getDicts("cus_nutri_assis").then(response => { - this.nutriAssisIdOptions = response.data; - }); - this.getDicts("cus_planner").then(response => { - this.plannerIdOptions = response.data; - }); - this.getDicts("cus_custom").then(response => { - this.accountIdOptions = response.data; - }); - this.getDicts("cus_planner_assis").then(response => { - this.plannerAssisIdOptions = response.data; - }); - this.getDicts("cus_operator").then(response => { - this.operatorIdOptions = response.data; - }); + // this.getDicts("cus_pay_type").then(response => { + // this.payTypeIdOptions = response.data; + // }); + // this.getDicts("cus_pre_sale").then(response => { + // this.preSaleIdOptions = response.data; + // }); + // this.getDicts("cus_after_sale").then(response => { + // this.afterSaleIdOptions = response.data; + // }); + // this.getDicts("cus_nutri").then(response => { + // this.nutritionistIdOptions = response.data; + // }); + // this.getDicts("cus_nutri_assis").then(response => { + // this.nutriAssisIdOptions = response.data; + // }); + // this.getDicts("cus_planner").then(response => { + // this.plannerIdOptions = response.data; + // }); + // this.getDicts("cus_account").then(response => { + // this.accountIdOptions = response.data; + // }); + // this.getDicts("cus_planner_assis").then(response => { + // this.plannerAssisIdOptions = response.data; + // }); + // this.getDicts("cus_operator").then(response => { + // this.operatorIdOptions = response.data; + // }); }, /** 重置按钮操作 */ resetQuery() { @@ -687,7 +733,7 @@ this.$refs["form"].validate(valid => { if (valid) { - console.log(this.form) + // console.log(this.form) this.form.payType = this.selectDictLabel(this.payTypeIdOptions, this.form.payTypeId); this.form.preSale = this.selectDictLabel(this.preSaleIdOptions, this.form.preSaleId);