diff --git a/src/api/basicManage/businessType.js b/src/api/basicManage/businessType.js index 2c77b95..1f86b2b 100644 --- a/src/api/basicManage/businessType.js +++ b/src/api/basicManage/businessType.js @@ -3,25 +3,17 @@ import request from '@/utils/request' // 业务类型管理 - 查询列表 export function listBusinessTypeAPI(query) { return request({ - url: '/basic/businessType/list', - method: 'get', + url: '/planMajor/getPlanMajorList', + method: 'GET', params: query, }) } -// 业务类型管理 - 查询详情 -export function getBusinessTypeAPI(id) { - return request({ - url: `/basic/businessType/${id}`, - method: 'get', - }) -} - // 业务类型管理 - 新增 export function addBusinessTypeAPI(data) { return request({ - url: '/basic/businessType', - method: 'post', + url: '/planMajor/addPlanMajor', + method: 'POST', data, }) } @@ -29,16 +21,17 @@ export function addBusinessTypeAPI(data) { // 业务类型管理 - 修改 export function updateBusinessTypeAPI(data) { return request({ - url: '/basic/businessType', - method: 'put', + url: '/planMajor/updatePlanMajor', + method: 'POST', data, }) } // 业务类型管理 - 删除 -export function delBusinessTypeAPI(id) { +export function delBusinessTypeAPI(data) { return request({ - url: `/basic/businessType/${id}`, - method: 'delete', + url: `/planMajor/delPlanMajor`, + method: 'POST', + data, }) } diff --git a/src/api/basicManage/planCategory.js b/src/api/basicManage/planCategory.js index 520d64e..95887e0 100644 --- a/src/api/basicManage/planCategory.js +++ b/src/api/basicManage/planCategory.js @@ -3,25 +3,17 @@ import request from '@/utils/request' // 计划类别管理 - 查询列表 export function listPlanCategoryAPI(query) { return request({ - url: '/basic/planCategory/list', - method: 'get', + url: '/planMajor/getPlanMajorList', + method: 'GET', params: query, }) } -// 计划类别管理 - 查询详情 -export function getPlanCategoryAPI(id) { - return request({ - url: `/basic/planCategory/${id}`, - method: 'get', - }) -} - // 计划类别管理 - 新增 export function addPlanCategoryAPI(data) { return request({ - url: '/basic/planCategory', - method: 'post', + url: '/planMajor/addPlanMajor', + method: 'POST', data, }) } @@ -29,16 +21,17 @@ export function addPlanCategoryAPI(data) { // 计划类别管理 - 修改 export function updatePlanCategoryAPI(data) { return request({ - url: '/basic/planCategory', - method: 'put', + url: '/planMajor/updatePlanMajor', + method: 'POST', data, }) } // 计划类别管理 - 删除 -export function delPlanCategoryAPI(id) { +export function delPlanCategoryAPI(data) { return request({ - url: `/basic/planCategory/${id}`, - method: 'delete', + url: `/planMajor/delPlanMajor`, + method: 'POST', + data, }) } diff --git a/src/api/basicManage/planProfessional.js b/src/api/basicManage/planProfessional.js index 4d1c3f8..8fb2a6c 100644 --- a/src/api/basicManage/planProfessional.js +++ b/src/api/basicManage/planProfessional.js @@ -3,25 +3,17 @@ import request from '@/utils/request' // 计划专业管理 - 查询列表 export function listPlanProfessionalAPI(query) { return request({ - url: '/basic/planProfessional/list', - method: 'get', + url: '/planMajor/getPlanMajorList', + method: 'GET', params: query, }) } -// 计划专业管理 - 查询详情 -export function getPlanProfessionalAPI(id) { - return request({ - url: `/basic/planProfessional/${id}`, - method: 'get', - }) -} - // 计划专业管理 - 新增 export function addPlanProfessionalAPI(data) { return request({ - url: '/basic/planProfessional', - method: 'post', + url: '/planMajor/addPlanMajor', + method: 'POST', data, }) } @@ -29,16 +21,17 @@ export function addPlanProfessionalAPI(data) { // 计划专业管理 - 修改 export function updatePlanProfessionalAPI(data) { return request({ - url: '/basic/planProfessional', - method: 'put', + url: '/planMajor/updatePlanMajor', + method: 'POST', data, }) } // 计划专业管理 - 删除 -export function delPlanProfessionalAPI(id) { +export function delPlanProfessionalAPI(data) { return request({ - url: `/basic/planProfessional/${id}`, - method: 'delete', + url: `/planMajor/delPlanMajor`, + method: 'POST', + data, }) } diff --git a/src/api/basicManage/workloadCategory.js b/src/api/basicManage/workloadCategory.js index fb0de72..d13256f 100644 --- a/src/api/basicManage/workloadCategory.js +++ b/src/api/basicManage/workloadCategory.js @@ -3,25 +3,17 @@ import request from '@/utils/request' // 工作量类别管理 - 查询列表 export function listWorkloadCategoryAPI(query) { return request({ - url: '/basic/workloadCategory/list', - method: 'get', + url: '/workloadCategory/getWorkloadCategoryList', + method: 'GET', params: query, }) } -// 工作量类别管理 - 查询详情 -export function getWorkloadCategoryAPI(id) { - return request({ - url: `/basic/workloadCategory/${id}`, - method: 'get', - }) -} - // 工作量类别管理 - 新增 export function addWorkloadCategoryAPI(data) { return request({ - url: '/basic/workloadCategory', - method: 'post', + url: '/workloadCategory/addWorkloadCategory', + method: 'POST', data, }) } @@ -29,16 +21,17 @@ export function addWorkloadCategoryAPI(data) { // 工作量类别管理 - 修改 export function updateWorkloadCategoryAPI(data) { return request({ - url: '/basic/workloadCategory', - method: 'put', + url: '/workloadCategory/updateWorkloadCategory', + method: 'POST', data, }) } // 工作量类别管理 - 删除 -export function delWorkloadCategoryAPI(id) { +export function delWorkloadCategoryAPI(data) { return request({ - url: `/basic/workloadCategory/${id}`, - method: 'delete', + url: `/workloadCategory/delWorkloadCategory`, + method: 'POST', + data, }) } diff --git a/src/utils/ruoyi.js b/src/utils/ruoyi.js index 3de2d98..047aa5a 100644 --- a/src/utils/ruoyi.js +++ b/src/utils/ruoyi.js @@ -5,147 +5,157 @@ // 日期格式化 export function parseTime(time, pattern) { - if (arguments.length === 0 || !time) { - return null - } - const format = pattern || '{y}-{m}-{d} {h}:{i}:{s}' - let date - if (typeof time === 'object') { - date = time - } else { - if ((typeof time === 'string') && (/^[0-9]+$/.test(time))) { - time = parseInt(time) - } else if (typeof time === 'string') { - time = time.replace(new RegExp(/-/gm), '/').replace('T', ' ').replace(new RegExp(/\.[\d]{3}/gm), '') + if (arguments.length === 0 || !time) { + return null } - if ((typeof time === 'number') && (time.toString().length === 10)) { - time = time * 1000 + const format = pattern || '{y}-{m}-{d} {h}:{i}:{s}' + let date + if (typeof time === 'object') { + date = time + } else { + if (typeof time === 'string' && /^[0-9]+$/.test(time)) { + time = parseInt(time) + } else if (typeof time === 'string') { + time = time + .replace(new RegExp(/-/gm), '/') + .replace('T', ' ') + .replace(new RegExp(/\.[\d]{3}/gm), '') + } + if (typeof time === 'number' && time.toString().length === 10) { + time = time * 1000 + } + date = new Date(time) } - date = new Date(time) - } - const formatObj = { - y: date.getFullYear(), - m: date.getMonth() + 1, - d: date.getDate(), - h: date.getHours(), - i: date.getMinutes(), - s: date.getSeconds(), - a: date.getDay() - } - const time_str = format.replace(/{(y|m|d|h|i|s|a)+}/g, (result, key) => { - let value = formatObj[key] - // Note: getDay() returns 0 on Sunday - if (key === 'a') { return ['日', '一', '二', '三', '四', '五', '六'][value] } - if (result.length > 0 && value < 10) { - value = '0' + value + const formatObj = { + y: date.getFullYear(), + m: date.getMonth() + 1, + d: date.getDate(), + h: date.getHours(), + i: date.getMinutes(), + s: date.getSeconds(), + a: date.getDay(), } - return value || 0 - }) - return time_str + const time_str = format.replace(/{(y|m|d|h|i|s|a)+}/g, (result, key) => { + let value = formatObj[key] + // Note: getDay() returns 0 on Sunday + if (key === 'a') { + return ['日', '一', '二', '三', '四', '五', '六'][value] + } + if (result.length > 0 && value < 10) { + value = '0' + value + } + return value || 0 + }) + return time_str } // 表单重置 export function resetForm(refName) { - if (this.$refs[refName]) { - this.$refs[refName].resetFields() - } + if (this.$refs[refName]) { + this.$refs[refName].resetFields() + } } // 添加日期范围 export function addDateRange(params, dateRange, propName) { - let search = params - search.params = typeof (search.params) === 'object' && search.params !== null && !Array.isArray(search.params) ? search.params : {} - dateRange = Array.isArray(dateRange) ? dateRange : [] - if (typeof (propName) === 'undefined') { - search.params['beginTime'] = dateRange[0] - search.params['endTime'] = dateRange[1] - } else { - search.params['begin' + propName] = dateRange[0] - search.params['end' + propName] = dateRange[1] - } - return search + let search = params + search.params = + typeof search.params === 'object' && search.params !== null && !Array.isArray(search.params) + ? search.params + : {} + dateRange = Array.isArray(dateRange) ? dateRange : [] + if (typeof propName === 'undefined') { + search.params['beginTime'] = dateRange[0] + search.params['endTime'] = dateRange[1] + } else { + search.params['begin' + propName] = dateRange[0] + search.params['end' + propName] = dateRange[1] + } + return search } // 回显数据字典 export function selectDictLabel(datas, value) { - if (value === undefined) { - return "" - } - var actions = [] - Object.keys(datas).some((key) => { - if (datas[key].value == ('' + value)) { - actions.push(datas[key].label) - return true + if (value === undefined) { + return '' } - }) - if (actions.length === 0) { - actions.push(value) - } - return actions.join('') + var actions = [] + Object.keys(datas).some((key) => { + if (datas[key].value == '' + value) { + actions.push(datas[key].label) + return true + } + }) + if (actions.length === 0) { + actions.push(value) + } + return actions.join('') } // 回显数据字典(字符串、数组) export function selectDictLabels(datas, value, separator) { - if (value === undefined || value.length ===0) { - return "" - } - if (Array.isArray(value)) { - value = value.join(",") - } - var actions = [] - var currentSeparator = undefined === separator ? "," : separator - var temp = value.split(currentSeparator) - Object.keys(value.split(currentSeparator)).some((val) => { - var match = false - Object.keys(datas).some((key) => { - if (datas[key].value == ('' + temp[val])) { - actions.push(datas[key].label + currentSeparator) - match = true - } - }) - if (!match) { - actions.push(temp[val] + currentSeparator) + if (value === undefined || value.length === 0) { + return '' } - }) - return actions.join('').substring(0, actions.join('').length - 1) + if (Array.isArray(value)) { + value = value.join(',') + } + var actions = [] + var currentSeparator = undefined === separator ? ',' : separator + var temp = value.split(currentSeparator) + Object.keys(value.split(currentSeparator)).some((val) => { + var match = false + Object.keys(datas).some((key) => { + if (datas[key].value == '' + temp[val]) { + actions.push(datas[key].label + currentSeparator) + match = true + } + }) + if (!match) { + actions.push(temp[val] + currentSeparator) + } + }) + return actions.join('').substring(0, actions.join('').length - 1) } // 字符串格式化(%s ) export function sprintf(str) { - var args = arguments, flag = true, i = 1 - str = str.replace(/%s/g, function () { - var arg = args[i++] - if (typeof arg === 'undefined') { - flag = false - return '' - } - return arg - }) - return flag ? str : '' + var args = arguments, + flag = true, + i = 1 + str = str.replace(/%s/g, function () { + var arg = args[i++] + if (typeof arg === 'undefined') { + flag = false + return '' + } + return arg + }) + return flag ? str : '' } // 转换字符串,undefined,null等转化为"" export function parseStrEmpty(str) { - if (!str || str == "undefined" || str == "null") { - return "" - } - return str + if (!str || str == 'undefined' || str == 'null') { + return '' + } + return str } // 数据合并 export function mergeRecursive(source, target) { - for (var p in target) { - try { - if (target[p].constructor == Object) { - source[p] = mergeRecursive(source[p], target[p]) - } else { - source[p] = target[p] - } - } catch (e) { - source[p] = target[p] + for (var p in target) { + try { + if (target[p].constructor == Object) { + source[p] = mergeRecursive(source[p], target[p]) + } else { + source[p] = target[p] + } + } catch (e) { + source[p] = target[p] + } } - } - return source + return source } /** @@ -156,73 +166,129 @@ export function mergeRecursive(source, target) { * @param {*} children 孩子节点字段 默认 'children' */ export function handleTree(data, id, parentId, children) { - let config = { - id: id || 'id', - parentId: parentId || 'parentId', - childrenList: children || 'children' - } - - var childrenListMap = {} - var tree = [] - for (let d of data) { - let id = d[config.id] - childrenListMap[id] = d - if (!d[config.childrenList]) { - d[config.childrenList] = [] + let config = { + id: id || 'id', + parentId: parentId || 'parentId', + childrenList: children || 'children', } - } - for (let d of data) { - let parentId = d[config.parentId] - let parentObj = childrenListMap[parentId] - if (!parentObj) { - tree.push(d) - } else { - parentObj[config.childrenList].push(d) + var childrenListMap = {} + var tree = [] + for (let d of data) { + let id = d[config.id] + childrenListMap[id] = d + if (!d[config.childrenList]) { + d[config.childrenList] = [] + } } - } - return tree + + for (let d of data) { + let parentId = d[config.parentId] + let parentObj = childrenListMap[parentId] + if (!parentObj) { + tree.push(d) + } else { + parentObj[config.childrenList].push(d) + } + } + return tree } /** -* 参数处理 -* @param {*} params 参数 -*/ + * 参数处理 + * @param {*} params 参数 + */ export function tansParams(params) { - let result = '' - for (const propName of Object.keys(params)) { - const value = params[propName] - var part = encodeURIComponent(propName) + "=" - if (value !== null && value !== "" && typeof (value) !== "undefined") { - if (typeof value === 'object') { - for (const key of Object.keys(value)) { - if (value[key] !== null && value[key] !== "" && typeof (value[key]) !== 'undefined') { - let params = propName + '[' + key + ']' - var subPart = encodeURIComponent(params) + "=" - result += subPart + encodeURIComponent(value[key]) + "&" - } + let result = '' + for (const propName of Object.keys(params)) { + const value = params[propName] + var part = encodeURIComponent(propName) + '=' + if (value !== null && value !== '' && typeof value !== 'undefined') { + if (typeof value === 'object') { + for (const key of Object.keys(value)) { + if ( + value[key] !== null && + value[key] !== '' && + typeof value[key] !== 'undefined' + ) { + let params = propName + '[' + key + ']' + var subPart = encodeURIComponent(params) + '=' + result += subPart + encodeURIComponent(value[key]) + '&' + } + } + } else { + result += part + encodeURIComponent(value) + '&' + } } - } else { - result += part + encodeURIComponent(value) + "&" - } } - } - return result + return result } // 返回项目路径 export function getNormalPath(p) { - if (p.length === 0 || !p || p == 'undefined') { - return p - } - let res = p.replace('//', '/') - if (res[res.length - 1] === '/') { - return res.slice(0, res.length - 1) - } - return res + if (p.length === 0 || !p || p == 'undefined') { + return p + } + let res = p.replace('//', '/') + if (res[res.length - 1] === '/') { + return res.slice(0, res.length - 1) + } + return res } // 验证是否为blob格式 export function blobValidate(data) { - return data.type !== 'application/json' + return data.type !== 'application/json' +} + +/** + * 元转分(用于提交数据到后端) + * 使用字符串处理避免浮点数精度问题 + * @param {number|string} yuan 金额(元) + * @returns {number} 金额(分) + */ +export function yuanToFen(yuan) { + if (yuan === null || yuan === undefined || yuan === '') { + return 0 + } + // 转换为字符串处理,避免浮点数精度问题 + const yuanStr = String(yuan) + const parts = yuanStr.split('.') + const intPart = parts[0] || '0' + let decPart = parts[1] || '' + + // 补齐或截取小数部分到2位 + decPart = (decPart + '00').substring(0, 2) + + // 合并整数部分和小数部分,转为整数(分) + return parseInt(intPart + decPart, 10) +} + +/** + * 分转元(用于显示/回显数据) + * 使用字符串处理避免浮点数精度问题 + * @param {number|string} fen 金额(分) + * @returns {number} 金额(元) + */ +export function fenToYuan(fen) { + if (fen === null || fen === undefined || fen === '') { + return 0 + } + // 转换为整数 + const fenNum = parseInt(fen, 10) + if (isNaN(fenNum)) { + return 0 + } + + const isNegative = fenNum < 0 + const absFen = Math.abs(fenNum) + // 至少3位,确保能分出整数和小数部分 + const fenStr = String(absFen).padStart(3, '0') + + // 通过字符串截取分离整数和小数部分 + const intPart = fenStr.slice(0, -2) || '0' + const decPart = fenStr.slice(-2) + + const result = parseFloat(intPart + '.' + decPart) + return isNegative ? -result : result } diff --git a/src/views/basicManage/businessType/config.js b/src/views/basicManage/businessType/config.js new file mode 100644 index 0000000..cb00256 --- /dev/null +++ b/src/views/basicManage/businessType/config.js @@ -0,0 +1,28 @@ +import { reactive } from 'vue' +export default { + formColumns: [ + { + type: 'input', + prop: 'planMajorName', + placeholder: '请输入业务类型名称', + }, + ], + tableColumns: [ + { + prop: 'planMajorName', + label: '业务类型名称', + }, + { + prop: 'remark', + label: '备注', + }, + ], + + dialogConfig: reactive({ + outerVisible: false, + outerTitle: '新增业务类型', + outerWidth: '720px', + minHeight: '320px', + maxHeight: '80vh', + }), +} diff --git a/src/views/basicManage/businessType/index.vue b/src/views/basicManage/businessType/index.vue index db52bea..d380cfc 100644 --- a/src/views/basicManage/businessType/index.vue +++ b/src/views/basicManage/businessType/index.vue @@ -1,10 +1,156 @@ - + diff --git a/src/views/basicManage/inspectionStation/index.vue b/src/views/basicManage/inspectionStation/index.vue index 72fa240..a3dc0da 100644 --- a/src/views/basicManage/inspectionStation/index.vue +++ b/src/views/basicManage/inspectionStation/index.vue @@ -23,7 +23,7 @@