From b61eb1ed62218974596fc1e3fd717f0b1bb515a0 Mon Sep 17 00:00:00 2001 From: monkeyhouyi Date: Wed, 24 Jul 2024 10:53:53 +0800 Subject: [PATCH] 上报线索研判 --- src/api/systemData/dataInterface.js | 43 +++++++++++++++++++++++++++++++++++++++++-- src/components/Generator/components/InputTable/index.vue | 10 +++++----- src/main.js | 2 +- src/utils/index.js | 546 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- src/utils/request.js | 17 ++++++++++------- src/views/DisposalSuggestions/Form.vue | 260 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/views/DisposalSuggestions/index.vue | 209 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/views/baseInspectionReport/Form.vue | 60 ++++++++++++++++-------------------------------------------- src/views/baseInspectionReport/index.vue | 18 ++++++++++-------- src/views/extend/zyOaProfit/Form.vue | 2 +- src/views/extend/zyOaWfFinrmbt/ExportBox.vue | 2 +- src/views/homePage/components/news/NewsDialog.vue | 9 +++++++++ src/views/homePage/components/news/index.vue | 2 +- 13 files changed, 896 insertions(+), 284 deletions(-) create mode 100644 src/views/DisposalSuggestions/Form.vue create mode 100644 src/views/DisposalSuggestions/index.vue diff --git a/src/api/systemData/dataInterface.js b/src/api/systemData/dataInterface.js index 3568e5d..68cef67 100644 --- a/src/api/systemData/dataInterface.js +++ b/src/api/systemData/dataInterface.js @@ -1,13 +1,52 @@ import request from '@/utils/request' -// 获取字段列表 +// 查询需要判研的列表 +export function getListForJudge(data) { + return request({ + url: `/Extend/BaseInspectionReport/GetListForJudge`, + method: 'GET', + data + }) +} +// 查询当前登陆人发起的列表 export function getList(data) { return request({ - url: `/Extend/BaseInspectionReport`, + url: `/Extend/BaseInspectionReport/GetListForCurrentUser`, method: 'GET', data }) } +// 获取单个巡查上报 +export function getDetail(id) { + return request({ + url: `/Extend/BaseInspectionReport/${id}`, + method: 'GET', + }) +} +// 提交 +export function addForm(data) { + return request({ + url: `/Extend/BaseInspectionReport`, + method: 'POST', + data + }) +} +// 更新 +export function updataForm(data) { + return request({ + url: `/Extend/BaseInspectionReport/${data.id}`, + method: 'PUT', + data + }) +} +// 判研 +export function disposalSuggestions(data) { + return request({ + url: `/Extend/BaseInspectionReport/${data.id}/disposalSuggestions`, + method: 'PUT', + data + }) +} // 获取接口列表(分页) diff --git a/src/components/Generator/components/InputTable/index.vue b/src/components/Generator/components/InputTable/index.vue index 19fc5ed..d6f3d7b 100644 --- a/src/components/Generator/components/InputTable/index.vue +++ b/src/components/Generator/components/InputTable/index.vue @@ -327,7 +327,7 @@ export default { top: 74%; z-index: 1; } - >>> .el-input__inner { + .el-input__inner { border-color: #f56c6c; } } @@ -361,7 +361,7 @@ export default { .ncc-table-box.table { // 索引和删除按钮切换 - >>> .el-table__row:hover { + .el-table__row:hover { .index { display: none; &.btn-disabled { @@ -377,15 +377,15 @@ export default { opacity: 1; } } - >>> .el-input-number { + .el-input-number { width: 100%; min-width: 120px; } - >>> .el-table__header th { + .el-table__header th { line-height: 1; } - >>> .el-table .el-table__body { + .el-table .el-table__body { td { padding: 2px 0; background: #fff !important; diff --git a/src/main.js b/src/main.js index 73b796c..155cbad 100644 --- a/src/main.js +++ b/src/main.js @@ -58,7 +58,7 @@ Vue.directive('loadMore', { }) } }) -new Vue({ +export default new Vue({ router, store, i18n, diff --git a/src/utils/index.js b/src/utils/index.js index ef25042..b865bc3 100644 --- a/src/utils/index.js +++ b/src/utils/index.js @@ -1,234 +1,352 @@ +/** + * Parse the time to string + * @param {(Object|string|number)} time + * @param {string} cFormat + * @returns {string | null} + */ +export function parseTime(time, cFormat) { + if (arguments.length === 0 || !time) { + return null + } + const format = cFormat || '{y}-{m}-{d} {h}:{i}:{s}' + let date + if ((typeof time === 'string')) { + if ((/^[0-9]+$/.test(time))) { + // support "1548221490638" + time = parseInt(time) + } else { + // support safari + // https://stackoverflow.com/questions/4310953/invalid-date-in-safari + time = time.replace(new RegExp(/-/gm), '/') + } + } else { + if ((typeof time === 'string') && (/^[0-9]+$/.test(time))) { + time = parseInt(time) + } + if ((typeof time === 'number') && (time.toString().length === 10)) { + time = time * 1000 + } + 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(/{([ymdhisa])+}/g, (result, key) => { + const value = formatObj[key] + // Note: getDay() returns 0 on Sunday + if (key === 'a') { return ['日', '一', '二', '三', '四', '五', '六'][value] } + return value.toString().padStart(2, '0') + }) + return time_str +} + +/** + * @param {number} time + * @param {string} option + * @returns {string} + */ +export function formatTime(time, option) { + if (('' + time).length === 10) { + time = parseInt(time) * 1000 + } else { + time = +time + } + const d = new Date(time) + const now = Date.now() + const diff = (now - d) / 1000 + + if (diff < 30) { + return '刚刚' + } else if (diff < 3600) { + // less 1 hour + return Math.ceil(diff / 60) + '分钟前' + } else if (diff < 3600 * 24) { + return Math.ceil(diff / 3600) + '小时前' + } else if (diff < 3600 * 24 * 2) { + return '1天前' + } + if (option) { + return parseTime(time, option) + } else { + return ( + d.getMonth() + + 1 + + '月' + + d.getDate() + + '日' + + d.getHours() + + '时' + + d.getMinutes() + + '分' + ) + } +} /** - * 通用js方法封装处理 - * Copyright (c) 2019 ruoyi + * @param {string} url + * @returns {Object} */ +export function getQueryObject(url) { + url = url == null ? window.location.href : url + const search = url.substring(url.lastIndexOf('?') + 1) + const obj = {} + const reg = /([^?&=]+)=([^?&=]*)/g + search.replace(reg, (rs, $1, $2) => { + const name = decodeURIComponent($1) + let val = decodeURIComponent($2) + val = String(val) + obj[name] = val + return rs + }) + return obj +} -// 日期格式化 -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 ((typeof time === 'number') && (time.toString().length === 10)) { - time = time * 1000 - } - 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() +/** + * @param {string} input value + * @returns {number} output value + */ +export function byteLength(str) { + // returns the byte length of an utf8 string + let s = str.length + for (var i = str.length - 1; i >= 0; i--) { + const code = str.charCodeAt(i) + if (code > 0x7f && code <= 0x7ff) s++ + else if (code > 0x7ff && code <= 0xffff) s += 2 + if (code >= 0xDC00 && code <= 0xDFFF) i-- + } + return s +} + +/** + * @param {Array} actual + * @returns {Array} + */ +export function cleanArray(actual) { + const newArray = [] + for (let i = 0; i < actual.length; i++) { + if (actual[i]) { + newArray.push(actual[i]) } - 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 newArray +} + +/** + * @param {Object} json + * @returns {Array} + */ +export function param(json) { + if (!json) return '' + return cleanArray( + Object.keys(json).map(key => { + if (json[key] === undefined) return '' + return encodeURIComponent(key) + '=' + encodeURIComponent(json[key]) }) - return time_str + ).join('&') +} + +/** + * @param {string} url + * @returns {Object} + */ +export function param2Obj(url) { + const search = decodeURIComponent(url.split('?')[1]).replace(/\+/g, ' ') + if (!search) { + return {} } - - // 表单重置 - export function resetForm(refName) { - if (this.$refs[refName]) { - this.$refs[refName].resetFields(); + const obj = {} + const searchArr = search.split('&') + searchArr.forEach(v => { + const index = v.indexOf('=') + if (index !== -1) { + const name = v.substring(0, index) + const val = v.substring(index + 1, v.length) + obj[name] = val } + }) + return obj +} + +/** + * @param {string} val + * @returns {string} + */ +export function html2Text(val) { + const div = document.createElement('div') + div.innerHTML = val + return div.textContent || div.innerText +} + +/** + * Merges two objects, giving the last one precedence + * @param {Object} target + * @param {(Object|Array)} source + * @returns {Object} + */ +export function objectMerge(target, source) { + if (typeof target !== 'object') { + target = {} + } + if (Array.isArray(source)) { + return source.slice() } - - // 添加日期范围 - 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]; + Object.keys(source).forEach(property => { + const sourceProperty = source[property] + if (typeof sourceProperty === 'object') { + target[property] = objectMerge(target[property], sourceProperty) } else { - search.params['begin' + propName] = dateRange[0]; - search.params['end' + propName] = dateRange[1]; + target[property] = sourceProperty } - return search; + }) + return target +} + +/** + * @param {HTMLElement} element + * @param {string} className + */ +export function toggleClass(element, className) { + if (!element || !className) { + return } - - // 回显数据字典 - 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 (actions.length === 0) { - actions.push(value); - } - return actions.join(''); + let classString = element.className + const nameIndex = classString.indexOf(className) + if (nameIndex === -1) { + classString += '' + className + } else { + classString = + classString.substr(0, nameIndex) + + classString.substr(nameIndex + className.length) } - - // 回显数据字典(字符串、数组) - 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); - } - }) - 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 : ''; - } - - // 转换字符串,undefined,null等转化为"" - export function parseStrEmpty(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]; - } - } - return source; - }; - - /** - * 构造树型结构数据 - * @param {*} data 数据源 - * @param {*} id id字段 默认 'id' - * @param {*} parentId 父节点字段 默认 'parentId' - * @param {*} children 孩子节点字段 默认 'children' - */ - export function handleTree(data, id, parentId, children) { - let config = { - id: id || 'id', - parentId: parentId || 'parentId', - childrenList: children || 'children' - }; - - var childrenListMap = {}; - var nodeIds = {}; - var tree = []; - - for (let d of data) { - let parentId = d[config.parentId]; - if (childrenListMap[parentId] == null) { - childrenListMap[parentId] = []; - } - nodeIds[d[config.id]] = d; - childrenListMap[parentId].push(d); - } - - for (let d of data) { - let parentId = d[config.parentId]; - if (nodeIds[parentId] == null) { - tree.push(d); - } - } - - for (let t of tree) { - adaptToChildrenList(t); - } - - function adaptToChildrenList(o) { - if (childrenListMap[o[config.id]] !== null) { - o[config.childrenList] = childrenListMap[o[config.id]]; - } - if (o[config.childrenList]) { - for (let c of o[config.childrenList]) { - adaptToChildrenList(c); - } + element.className = classString +} + +/** + * @param {string} type + * @returns {Date} + */ +export function getTime(type) { + if (type === 'start') { + return new Date().getTime() - 3600 * 1000 * 24 * 90 + } else { + return new Date(new Date().toDateString()) + } +} + +/** + * @param {Function} func + * @param {number} wait + * @param {boolean} immediate + * @return {*} + */ +export function debounce(func, wait, immediate) { + let timeout, args, context, timestamp, result + + const later = function() { + // 据上一次触发时间间隔 + const last = +new Date() - timestamp + + // 上次被包装函数被调用时间间隔 last 小于设定时间间隔 wait + if (last < wait && last > 0) { + timeout = setTimeout(later, wait - last) + } else { + timeout = null + // 如果设定为immediate===true,因为开始边界已经调用过了此处无需调用 + if (!immediate) { + result = func.apply(context, args) + if (!timeout) context = args = null } } - return tree; - } - - /** - * 参数处理 - * @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]) + "&"; - } - } - } else { - result += part + encodeURIComponent(value) + "&"; - } - } + } + + return function(...args) { + context = this + timestamp = +new Date() + const callNow = immediate && !timeout + // 如果延时不存在,重新设定延时 + if (!timeout) timeout = setTimeout(later, wait) + if (callNow) { + result = func.apply(context, args) + context = args = null } + return result } - - // 验证是否为blob格式 - export function blobValidate(data) { - return data.type !== 'application/json' +} + +/** + * This is just a simple version of deep copy + * Has a lot of edge cases bug + * If you want to use a perfect deep copy, use lodash's _.cloneDeep + * @param {Object} source + * @returns {Object} + */ +export function deepClone(source) { + if (!source && typeof source !== 'object') { + throw new Error('error arguments', 'deepClone') + } + const targetObj = source.constructor === Array ? [] : {} + Object.keys(source).forEach(keys => { + if (source[keys] && typeof source[keys] === 'object') { + targetObj[keys] = deepClone(source[keys]) + } else { + targetObj[keys] = source[keys] + } + }) + return targetObj +} + +/** + * @param {Array} arr + * @returns {Array} + */ +export function uniqueArr(arr) { + return Array.from(new Set(arr)) +} + +/** + * @returns {string} + */ +export function createUniqueString() { + const timestamp = +new Date() + '' + const randomNum = parseInt((1 + Math.random()) * 65536) + '' + return (+(randomNum + timestamp)).toString(32) +} + +/** + * Check if an element has a class + * @param {HTMLElement} elm + * @param {string} cls + * @returns {boolean} + */ +export function hasClass(ele, cls) { + return !!ele.className.match(new RegExp('(\\s|^)' + cls + '(\\s|$)')) +} + +/** + * Add class to element + * @param {HTMLElement} elm + * @param {string} cls + */ +export function addClass(ele, cls) { + if (!hasClass(ele, cls)) ele.className += ' ' + cls +} + +/** + * Remove class from element + * @param {HTMLElement} elm + * @param {string} cls + */ +export function removeClass(ele, cls) { + if (hasClass(ele, cls)) { + const reg = new RegExp('(\\s|^)' + cls + '(\\s|$)') + ele.className = ele.className.replace(reg, ' ') } - \ No newline at end of file +} \ No newline at end of file diff --git a/src/utils/request.js b/src/utils/request.js index f597507..f058db7 100644 --- a/src/utils/request.js +++ b/src/utils/request.js @@ -20,6 +20,7 @@ const service = axios.create({ //拦截器(请求,响应) //请求 service.interceptors.request.use(config => { + if (config.url.indexOf('http') > -1) config.baseURL = '' // 是否需要设置 token const isToken = (config.headers || {}).isToken === false // 是否需要防止数据重复提交 @@ -28,14 +29,16 @@ service.interceptors.request.use(config => { if (getToken() && !isToken) { config.headers['Authorization'] = getToken() // 让每个请求携带自定义token 请根据实际情况自行修改 } - // get请求映射params参数 - if (config.method === 'get' && config.params) { - let url = config.url + '?' + tansParams(config.params); - url = url.slice(0, -1); - config.params = {}; - config.url = url; + if (config.method == 'get') { + config.params = config.data } - return config; + // let timestamp = Date.parse(new Date()) / 1000 + // if (config.url.indexOf('?') > -1) { + // config.url += `&n=${timestamp}` + // } else { + // config.url += `?n=${timestamp}` + // } + return config }) //响应 service.interceptors.response.use(res => { diff --git a/src/views/DisposalSuggestions/Form.vue b/src/views/DisposalSuggestions/Form.vue new file mode 100644 index 0000000..c537361 --- /dev/null +++ b/src/views/DisposalSuggestions/Form.vue @@ -0,0 +1,260 @@ + + + diff --git a/src/views/DisposalSuggestions/index.vue b/src/views/DisposalSuggestions/index.vue new file mode 100644 index 0000000..a8549ae --- /dev/null +++ b/src/views/DisposalSuggestions/index.vue @@ -0,0 +1,209 @@ + + + \ No newline at end of file diff --git a/src/views/baseInspectionReport/Form.vue b/src/views/baseInspectionReport/Form.vue index b7a0045..a71961a 100644 --- a/src/views/baseInspectionReport/Form.vue +++ b/src/views/baseInspectionReport/Form.vue @@ -120,7 +120,7 @@ \ No newline at end of file diff --git a/src/views/homePage/components/news/NewsDialog.vue b/src/views/homePage/components/news/NewsDialog.vue index 2aefd56..ef2cbad 100644 --- a/src/views/homePage/components/news/NewsDialog.vue +++ b/src/views/homePage/components/news/NewsDialog.vue @@ -11,6 +11,7 @@ class="list" v-infinite-scroll="load" infinite-scroll-disabled="disabled" + infinite-scroll-immediate >
  • @@ -30,12 +31,14 @@