You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
69 lines
1.3 KiB
69 lines
1.3 KiB
export default {
|
|
/**
|
|
* 数组赋值有更新没有添加
|
|
* @param vue vue 对象
|
|
* @param array 要更新的数组
|
|
* @param data 数组更新或者添加的数据
|
|
*/
|
|
arraySetValue(vue, array, data) {
|
|
if (!Array.isArray(array) || !vue) {
|
|
console.warn('参数错误')
|
|
return
|
|
}
|
|
let index = array.findIndex(item => item.id === data.id)
|
|
if (index === -1) {
|
|
array.push(data)
|
|
} else {
|
|
vue.$set(array, index, data)
|
|
}
|
|
},
|
|
/**
|
|
* 数组赋值有更新没有添加
|
|
* @param array 要更新的数组
|
|
* @param data 数组更新或者添加的数据
|
|
*/
|
|
arrayPutValue(array, data) {
|
|
if (!Array.isArray(array)) {
|
|
console.warn('参数错误')
|
|
return
|
|
}
|
|
let index = array.findIndex(item => item.id === data.id)
|
|
if (index === -1) {
|
|
array.push(data)
|
|
} else {
|
|
array[index] = data
|
|
}
|
|
|
|
return array
|
|
},
|
|
|
|
/**
|
|
* 获取表格的筛选数据
|
|
* @param dictData
|
|
* @returns {*[]}
|
|
*/
|
|
getTableFiltersData(dictData) {
|
|
|
|
if (!Array.isArray(dictData)) {
|
|
console.warn('参数错误')
|
|
}
|
|
|
|
let data = []
|
|
|
|
dictData.forEach(item => {
|
|
data.push({
|
|
text: item.label,
|
|
value: item.value
|
|
})
|
|
})
|
|
|
|
return data
|
|
|
|
},
|
|
|
|
/** 数据类型筛选 */
|
|
filterValueType(value, row) {
|
|
return row.valueType.type === value
|
|
},
|
|
|
|
}
|
|
|