随笔分类 - 公共方法
公共方法
JS 数组相同key 求和
摘要:#1、演示数据 demo: [ { key: '1', amount: '1' }, { key: '1', amount: '2' }, { key: '2', amount: '3' }, { key: '2', amount: '4' }, ], #2、公共方法 // Array 要计算的数组
阅读全文
JS数组去重
摘要:#1、方法 <!-- * @Descripttion: 数组去重 * @version: 0.0.1 * @Author: PengShuai * @Date: 2022-09-26 13:16:04 * @LastEditors: PengShuai * @LastEditTime: 2022-0
阅读全文
JS 验证自定义计算公式是否成功
摘要:#1、需求 1.项目需求表单中填写公式传入后台。 2.公式中可以使用汉字英文。 3.验证公式是否成功。 #2、思路 1.表单中输入公式存入后台是以字符串的形式传入。 2.循环字符串找出字符串中的汉字和英文并替换成数字1 3.替换成功后并进行计算,如果计算验证成功,代表公式验证成功,反之则验证失败。
阅读全文
json转表单格式
摘要:###1、方法 // json转表单格式 baseFormdataify(params) { const formData = new FormData() Object.keys(params).forEach((i) => { if (typeof params[i] == 'string')
阅读全文
前端生成主建UUID
摘要:###1、公共方法 <!-- * @Descripttion: 生成UUID * @version: 0.0.1 * @Author: PengShuai * @Date: 2022-06-13 15:45:31 * @LastEditors: PengShuai * @LastEditTime:
阅读全文
Js 数组与树状结构相互转换
摘要:#1、示例数据 [ { "importProductNo":null, "periodTemplateId":null, "importButaoId":"4a60be081644438e89ebf8e3e426e3ba", "importButaoPid":"e723aed3e58d49e088e
阅读全文
JS 一键复制
摘要:#1、公共方法 onCopy(data) { var input = document.createElement('input') input.value = data input.id = 'copyInput' document.body.appendChild(input) input.se
阅读全文
数组排序
摘要:#1、数组 var demo = [ { value: 26 }, { value: 29 }, { value: 30 }, { value: 31 }, { value: 22 }, { value: 20 } ]; #2、方法 function compareFunc(field) { ret
阅读全文
格式化日期
摘要:#1、方法 const formatDate = (date, format = "YYYY-MM-DD HH:mm:ss") => { if (!date) { return ""; } const d = new Date(date); // 年 if (/YYYY/.test(format))
阅读全文
数字千位符
摘要:#1、方法 const formatThousand = data => { let type = Object.prototype.toString.call(data); if (type "[object Number]") { return data .toString() .replace
阅读全文
VUE 判断数据类型
摘要:#1、方法 <!-- * @Descripttion: 类型判断 * @version: 0.0.1 * @Author: PengShuai * @Date: 2022年04月29日11:21:14 * @LastEditors: PengShuai * @LastEditTime: 2022年0
阅读全文
JS 数组对比去重
摘要:#1、两个数组通过唯一编码进行比较 /** * 根据某一属性找出差异 * @param {arry} arr1 第一个参数需要对比的数组 * @param {arry} arr2 第二个参数需要对比的数组 * @param {string} fildId 需要对比的属性 * @returns 返回有
阅读全文
新老数据对比
摘要:判断新数据与原始数据中有何不同(增删改) const formatSaveList = (newList, oldList) => { const insertList = []; const deleteList = []; const updateList = []; // 找到新增和修改 ne
阅读全文