| | |
| | | const router = useRouter() |
| | | const userStore = useUserInfoStore() |
| | | const user = userStore.user.userName |
| | | //监听异步返回代码 |
| | | watch(()=>userStore.responseCode,(newVal) => { |
| | | switch (newVal){ |
| | | case 401:{ |
| | |
| | | ) |
| | | |
| | | store.createWebSocket(); |
| | | |
| | | // 退出登录 |
| | | function quit(){ |
| | | userStore.$patch({ |
| | | user:null |
| | |
| | | let menuList=$ref([]) |
| | | onMounted(()=>{ |
| | | request.get(`/menu/getMenu/${lang}`).then((res) => { |
| | | |
| | | if(res.code==200){ |
| | | menuList= deepClone(res.data) |
| | | } |
| | |
| | | component: () => import('../views/sd/basicData/SearchBasicData.vue') |
| | | }, |
| | | { |
| | | path: 'searchGlassType', |
| | | name: 'searchGlassType', |
| | | component: () => import('../views/sd/basicData/SearchGlassType.vue') |
| | | }, |
| | | { |
| | | name: 'OrderBasicData', |
| | | path: '', |
| | | redirect:'/main/orderBasicData/searchBasicData' |
| | |
| | | <div id="div-title"> |
| | | <el-breadcrumb :separator-icon="ArrowRight"> |
| | | <el-breadcrumb-item @click="changeRouter(1)" :class="indexFlag===1?'indexTag':''" :to="{ path: '/main/orderBasicData/searchBasicData' }">基础数据</el-breadcrumb-item> |
| | | <el-breadcrumb-item @click="changeRouter(2)" :class="indexFlag===2?'indexTag':''" :to="{ path: '/main/orderBasicData/searchGlassType' }">玻璃类别</el-breadcrumb-item> |
| | | <el-breadcrumb-item v-show="false" :to="{ path: '/main/order/orderReport' }">报表</el-breadcrumb-item> |
| | | </el-breadcrumb> |
| | | </div> |
| | |
| | | stripe:true,//斑马纹 |
| | | rowConfig: {isCurrent: true, isHover: true,height: 30},//鼠标移动或选择高亮 |
| | | id: 'OrderList', |
| | | showFooter: true,//显示脚 |
| | | printConfig: {}, |
| | | importConfig: {}, |
| | | exportConfig: {}, |
| | |
| | | zoom: true, |
| | | custom: true |
| | | }, |
| | | |
| | | footerMethod ({ columns, data }) {//页脚函数 |
| | | return[ |
| | | columns.map((column, columnIndex) => { |
| | | // if (columnIndex === 0) { |
| | | // return t('basicData.total') |
| | | // } |
| | | // if (props.tableProp.footList.includes(column.field)) { |
| | | // return sumNum(data, column.field) |
| | | // } |
| | | return '' |
| | | }) |
| | | ] |
| | | } |
| | | |
| | | }) |
| | | const gridEvents = { |
| | | toolbarButtonClick ({ code }) { |
| | |
| | | dialogTableVisible.value = true |
| | | break |
| | | } |
| | | |
| | | } |
| | | } |
| | | }, |
| | | menuClick ({ menu, row, column }) { |
| | | const $grid = xGrid.value |
| | | if ($grid) { |
| | | switch (menu.code) { |
| | | |
| | | |
| | | } |
| | | } |
New file |
| | |
| | | <script setup> |
| | | import {onMounted, reactive, ref} from "vue"; |
| | | import {VXETable} from "vxe-table"; |
| | | import {ElMessage} from "element-plus"; |
| | | import request from "@/utils/request" |
| | | import CreateBasicData from "@/views/sd/basicData/CreateBasicData.vue" |
| | | import {useRouter,useRoute} from "vue-router" |
| | | import {useI18n} from "vue-i18n" |
| | | const { t } = useI18n() |
| | | |
| | | let dialogTableVisible = ref(false) |
| | | const router = useRouter() |
| | | const xGrid = ref() |
| | | const gridOptions = reactive({ |
| | | border: "full",//表格加边框 |
| | | keepSource: true,//保持源数据 |
| | | align: 'center',//文字居中 |
| | | stripe:true,//斑马纹 |
| | | rowConfig: {isCurrent: true, isHover: true,height: 30},//鼠标移动或选择高亮 |
| | | id: 'OrderList', |
| | | printConfig: {}, |
| | | importConfig: {}, |
| | | exportConfig: {}, |
| | | scrollY:{ enabled: true },//开启虚拟滚动 |
| | | showOverflow:true, |
| | | columnConfig: { |
| | | resizable: true, |
| | | useKey: true |
| | | }, |
| | | filterConfig: { //筛选配置项 |
| | | remote: true |
| | | }, |
| | | customConfig: { |
| | | storage: true |
| | | }, |
| | | editConfig: { |
| | | trigger: 'click', |
| | | mode: 'row', |
| | | showStatus: true |
| | | }, |
| | | |
| | | //表头参数 |
| | | columns:[ |
| | | {title: t('basicData.operate'), width: 110, slots: { default: 'button_slot' },fixed:"left",}, |
| | | {type: 'seq', title: '序号', width: 80 ,fixed:"left",}, |
| | | {field:'level',title: '类别等级'}, |
| | | {field:'typeName',title: '名称'}, |
| | | {field:'createTime',title: '创建日期'} |
| | | ], |
| | | |
| | | //表头按钮 |
| | | toolbarConfig: { |
| | | buttons: [ |
| | | {'code': 'add', 'name': '新增',status: 'primary'}, |
| | | ], |
| | | |
| | | // import: false, |
| | | // export: true, |
| | | // print: true, |
| | | zoom: true, |
| | | custom: true |
| | | }, |
| | | }) |
| | | const rowIndex = ref(null) |
| | | const glassType = reactive([ |
| | | { |
| | | value:1, |
| | | label:'一级类别' |
| | | }, |
| | | { |
| | | value: 2, |
| | | label: '二级类别', |
| | | children: [] |
| | | } |
| | | ]) |
| | | const submit = ref({ |
| | | glassLevel:[null,null], |
| | | value:null, |
| | | type:null, |
| | | id:null |
| | | }) |
| | | |
| | | onMounted(()=>{ |
| | | request.get(`/basicGlassType/findAll`).then(res => { |
| | | xGrid.value.reloadData(res.data) |
| | | console.log(res.data) |
| | | }) |
| | | |
| | | request.get(`/basicGlassType/getOneLevelListMap`).then(res => { |
| | | glassType[1].children = res.data |
| | | }) |
| | | }) |
| | | |
| | | const gridEvents = { |
| | | toolbarButtonClick ({ code }) { |
| | | const $grid = xGrid.value |
| | | if ($grid) { |
| | | switch (code) { |
| | | case 'add': { |
| | | dialogTableVisible.value = true |
| | | break |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | const getTableRow = (row,type) => { |
| | | switch (type) { |
| | | case 'edit': { |
| | | rowIndex.value = row |
| | | submit.value.glassLevel = row.belong===''?[parseInt(row.level)]:[parseInt(row.level),row.belong] |
| | | submit.value.value = row.typeName |
| | | submit.value.id = row.id |
| | | dialogTableVisible.value = true |
| | | break |
| | | } |
| | | case 'delete': { |
| | | request.get(`/basicGlassType/deleteById/${row.id}`).then((res) => { |
| | | if(res.code==='200' && res.data===true){ |
| | | ElMessage.success(t('searchOrder.msgDeleteSuccess')) |
| | | router.push({ |
| | | path:'/main/orderBasicData/searchGlassType', |
| | | query:{random:Math.random() |
| | | } |
| | | }) |
| | | }else{ |
| | | ElMessage.warning(t('searchOrder.msgDeleteFail')) |
| | | } |
| | | }) |
| | | break |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | | |
| | | const saveBasicData = (type) =>{ |
| | | submit.value.type = type |
| | | request.post(`/basicGlassType/add`, submit.value).then(res => { |
| | | if (res.code==='200') { |
| | | ElMessage.success('保存成功') |
| | | router.push({ |
| | | path:'/main/orderBasicData/searchGlassType', |
| | | query:{random:Math.random() |
| | | } |
| | | }) |
| | | } |
| | | }) |
| | | } |
| | | |
| | | |
| | | </script> |
| | | |
| | | <template> |
| | | <div> |
| | | <vxe-grid |
| | | style="width: 40vw;" |
| | | class="mytable-scrollbar" |
| | | max-height="500px" |
| | | ref="xGrid" |
| | | v-bind="gridOptions" |
| | | v-on="gridEvents" |
| | | > |
| | | <template #button_slot="{ row }"> |
| | | <el-button @click="getTableRow(row,'edit')" link type="primary" size="small">{{ $t('basicData.edit') }}</el-button> |
| | | <el-popconfirm @confirm="getTableRow(row,'delete')" :title="$t('searchOrder.deleteConfirm')"> |
| | | <template #reference> |
| | | <el-button link type="primary" size="small">{{ $t('basicData.delete') }}</el-button> |
| | | </template> |
| | | </el-popconfirm> |
| | | </template> |
| | | </vxe-grid> |
| | | <el-dialog |
| | | v-model="dialogTableVisible" |
| | | destroy-on-close |
| | | style="width: 30%;height:30% "> |
| | | <el-row> |
| | | <el-cascader |
| | | v-model="submit.glassLevel" |
| | | :options="glassType" |
| | | clearable |
| | | placeholder="" |
| | | :disabled="rowIndex" |
| | | /> |
| | | </el-row> |
| | | <el-row> |
| | | <el-input v-model="submit.value"/> |
| | | </el-row> |
| | | <el-row> |
| | | <el-button v-if="!rowIndex" @click="saveBasicData('add')" type="primary">新增</el-button> |
| | | <el-button v-else @click="saveBasicData('update')" type="primary">修改</el-button> |
| | | </el-row> |
| | | </el-dialog> |
| | | |
| | | </div> |
| | | |
| | | </template> |
| | | |
| | | <style scoped> |
| | | .el-row{ |
| | | margin-top: 10px; |
| | | } |
| | | </style> |
| | |
| | | package com.example.erp.controller.sd; |
| | | |
| | | import com.example.erp.common.Result; |
| | | import com.example.erp.service.sd.BasicGlassTypeServise; |
| | | import com.example.erp.service.sd.BasicGlassTypeService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.Map; |
| | | |
| | | @RestController |
| | | @RequestMapping("/basicGlassType") |
| | | public class BasicGlassTypeController { |
| | | @Autowired |
| | | BasicGlassTypeServise basicGlassTypeServise; |
| | | BasicGlassTypeService basicGlassTypeServise; |
| | | |
| | | @GetMapping("/getOneLevel") |
| | | public Result getOneLevel(){ |
| | |
| | | public Result getAll(){ |
| | | return Result.seccess(basicGlassTypeServise.getAll()); |
| | | } |
| | | |
| | | @GetMapping("/findAll") |
| | | public Result findAll(){ |
| | | return Result.seccess(basicGlassTypeServise.findAll()); |
| | | } |
| | | |
| | | @GetMapping("/deleteById/{id}") |
| | | public Result deleteById(@PathVariable Integer id){ |
| | | return Result.seccess(basicGlassTypeServise.deleteById(id)); |
| | | } |
| | | |
| | | @GetMapping("/getOneLevelListMap") |
| | | public Result getOneLevelListMap(){ |
| | | return Result.seccess(basicGlassTypeServise.getOneLevelListMap()); |
| | | } |
| | | |
| | | @PostMapping("/add") |
| | | public Result add(@RequestBody Map<String,Object> map){ |
| | | return Result.seccess(basicGlassTypeServise.add(map)); |
| | | } |
| | | |
| | | } |
| | |
| | | private Integer id; |
| | | private Integer level; |
| | | private String belong; |
| | | private String typeID; |
| | | private String typeId; |
| | | private String typeName; |
| | | private String createTime; |
| | | |
| | |
| | | package com.example.erp.mapper.sd; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.example.erp.entity.sd.BasicGlassType; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import java.util.List; |
| | | |
| | | @Mapper |
| | | public interface BasicGlassTypeMapper { |
| | | public interface BasicGlassTypeMapper extends BaseMapper<BasicGlassType> { |
| | | List<BasicGlassType> getOneLevel(); |
| | | |
| | | List<BasicGlassType> getTwoLevel(); |
| | | |
| | | BasicGlassType selectMaxType(Integer type); |
| | | |
| | | BasicGlassType selectMaxTowLevelType(String type); |
| | | |
| | | |
| | | Boolean updateGlassTypeName(@Param("basicGlassType") BasicGlassType basicGlassType); |
| | | } |
New file |
| | |
| | | package com.example.erp.service.sd; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.baomidou.dynamic.datasource.annotation.DS; |
| | | import com.example.erp.entity.sd.BasicGlassType; |
| | | import com.example.erp.mapper.sd.BasicGlassTypeMapper; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.*; |
| | | |
| | | @Service |
| | | @DS("sd") |
| | | public class BasicGlassTypeService { |
| | | @Autowired |
| | | BasicGlassTypeMapper basicGlassTypeMapper; |
| | | public List<BasicGlassType> getOneLevel() { |
| | | return basicGlassTypeMapper.getOneLevel(); |
| | | } |
| | | |
| | | public List<BasicGlassType> getTwoLevel() { |
| | | return basicGlassTypeMapper.getTwoLevel(); |
| | | } |
| | | |
| | | public List<Map<String,String>> getAll() { |
| | | List<BasicGlassType> oneGlassType = basicGlassTypeMapper.getOneLevel(); |
| | | List<BasicGlassType> twoGlassType = basicGlassTypeMapper.getTwoLevel(); |
| | | List<Map<String,String>> list = new ArrayList<>(); |
| | | for (BasicGlassType glassType : oneGlassType) { |
| | | Map<String, String> map = new HashMap<>(); |
| | | map.put("value", glassType.getTypeId()); |
| | | map.put("label", glassType.getTypeName()); |
| | | map.put("children", ""); |
| | | List<String> equalList = new ArrayList<>(); |
| | | for (BasicGlassType basicGlassType : twoGlassType) { |
| | | if (Objects.equals(basicGlassType.getBelong(), glassType.getTypeId())) { |
| | | Map<String,String> getMap = JSON.parseObject(JSON.toJSONString(basicGlassType), Map.class); |
| | | getMap.put("value",getMap.get("typeID")); |
| | | getMap.put("label",getMap.get("typeName")); |
| | | equalList.add(JSON.toJSONString(getMap) ); |
| | | } |
| | | } |
| | | map.replace("children",equalList.toString()); |
| | | list.add(map); |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | public List<BasicGlassType> findAll() { |
| | | return basicGlassTypeMapper.selectList(null); |
| | | } |
| | | |
| | | public Boolean deleteById(Integer id) { |
| | | return basicGlassTypeMapper.deleteById(id) > 0; |
| | | } |
| | | |
| | | public List<Map<String,Object>> getOneLevelListMap() { |
| | | List<BasicGlassType> oneGlassType = basicGlassTypeMapper.getOneLevel(); |
| | | List<Map<String,Object>> list = new ArrayList<>(); |
| | | for (BasicGlassType glassType : oneGlassType) { |
| | | Map<String,Object> map = new HashMap<>(); |
| | | map.put("value", glassType.getTypeId()); |
| | | map.put("label", glassType.getTypeName()); |
| | | list.add(map); |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | public Boolean add(Map<String, Object> map) { |
| | | List<Object> list = (List<Object>) map.get("glassLevel"); |
| | | if(list.get(0)==null |
| | | || map.get("value") == null |
| | | || map.get("value").equals("")){ |
| | | return false; |
| | | } |
| | | BasicGlassType basicGlassTypeS = new BasicGlassType(); |
| | | if(map.get("type").equals("add")){ |
| | | if(list.size()==1){ |
| | | BasicGlassType basicGlassType = basicGlassTypeMapper.selectMaxType((Integer) list.get(0)); |
| | | int maxId = Integer.parseInt(basicGlassType.getTypeId()); |
| | | String newTypeId = String.format("%02d", maxId+1); |
| | | basicGlassTypeS.setLevel((Integer) list.get(0)); |
| | | basicGlassTypeS.setTypeId(newTypeId); |
| | | basicGlassTypeS.setTypeName((String) map.get("value")); |
| | | }else if(list.size()==2) { |
| | | BasicGlassType basicGlassType = basicGlassTypeMapper.selectMaxTowLevelType((String) list.get(1)); |
| | | int maxId = Integer.parseInt(basicGlassType.getTypeId().substring(2)); |
| | | String newTypeId =list.get(1) + String.format("%02d", maxId+1); |
| | | basicGlassTypeS.setLevel((Integer) list.get(0)); |
| | | basicGlassTypeS.setTypeId(newTypeId); |
| | | basicGlassTypeS.setTypeName((String) map.get("value")); |
| | | basicGlassTypeS.setBelong((String) list.get(1)); |
| | | } |
| | | return basicGlassTypeMapper.insert(basicGlassTypeS)>0; |
| | | }else{ |
| | | basicGlassTypeS.setId((Integer) map.get("id")); |
| | | basicGlassTypeS.setTypeName((String) map.get("value")); |
| | | return basicGlassTypeMapper.updateGlassTypeName(basicGlassTypeS); |
| | | } |
| | | |
| | | } |
| | | } |
| | |
| | | ORDER BY a.id ; |
| | | </select> |
| | | |
| | | <select id="selectMaxType"> |
| | | select |
| | | * |
| | | from |
| | | basic_glass_type as a |
| | | where a.level=1 |
| | | ORDER BY a.id desc limit 1; |
| | | |
| | | </select> |
| | | |
| | | <select id="selectMaxTowLevelType"> |
| | | select |
| | | * |
| | | from |
| | | basic_glass_type as a |
| | | where |
| | | a.level=2 |
| | | and a.belong = #{type} |
| | | |
| | | ORDER BY a.id desc limit 1; |
| | | </select> |
| | | |
| | | <update id="updateGlassTypeName" parameterType="com.example.erp.entity.sd.BasicGlassType" > |
| | | update |
| | | basic_glass_type as a |
| | | set a.type_name = #{basicGlassType.typeName} |
| | | where a.id = #{basicGlassType.id} |
| | | </update> |
| | | |
| | | </mapper> |
| | |
| | | ORDER BY a.id ; |
| | | </select> |
| | | |
| | | <select id="selectMaxType"> |
| | | select |
| | | * |
| | | from |
| | | basic_glass_type as a |
| | | where a.level=1 |
| | | ORDER BY a.id desc limit 1; |
| | | |
| | | </select> |
| | | |
| | | <select id="selectMaxTowLevelType"> |
| | | select |
| | | * |
| | | from |
| | | basic_glass_type as a |
| | | where |
| | | a.level=2 |
| | | and a.belong = #{type} |
| | | |
| | | ORDER BY a.id desc limit 1; |
| | | </select> |
| | | |
| | | <update id="updateGlassTypeName" parameterType="com.example.erp.entity.sd.BasicGlassType" > |
| | | update |
| | | basic_glass_type as a |
| | | set a.type_name = #{basicGlassType.typeName} |
| | | where a.id = #{basicGlassType.id} |
| | | </update> |
| | | |
| | | </mapper> |