ahdevicemgt-ui/src/views/material/mixins/common.js

109 lines
3.4 KiB
JavaScript
Raw Normal View History

2024-08-13 18:53:03 +08:00
export const commonMixin = {
data() {
return {
// 修改时的数据源
editParams: null,
}
},
methods: {
/** 新建 */
handleAddData() {
this.editParams = null
this.dialogConfig.outerTitle = this.addDialogTitle
this.dialogConfig.outerVisible = true
},
/** 新建-物资类型 */
handleAddMaData(level) {
if(level == null) {
this.$modal.msgError('请在左侧菜单选择设备类型!')
} else if(level > 3) {
this.$modal.msgError('该类型无法添加子类型!')
} else {
this.editParams = null
this.dialogConfig.outerTitle = this.addDialogTitle
this.dialogConfig.outerVisible = true
}
2024-08-13 18:53:03 +08:00
},
/** 删除 */
handleDeleteData(id, method) {
this.$modal.confirm('是否确定删除').then(() => {
console.log('确定删除--', id)
method(id).then(res => {
console.log(res)
if(res.code === 200) {
this.$modal.msgSuccess('操作成功!')
this.$refs.tableRef.getTableList()
}
}).catch(err => {})
})
},
/** 删除-物资类型 */
handleDeleteMaType(id, method) {
2024-08-13 18:53:03 +08:00
this.$modal.confirm('是否确定删除').then(() => {
console.log('确定删除--', id)
method(id).then(res => {
console.log(res)
if(res.code === 200) {
2024-08-14 10:38:18 +08:00
this.$modal.msgSuccess('操作成功!')
2024-08-13 18:53:03 +08:00
this.$refs.tableRef.getTableList()
2024-08-14 10:38:18 +08:00
this.getTreeData()
2024-08-13 18:53:03 +08:00
}
}).catch(err => {})
})
},
/** 编辑 */
handleEditData(data) {
this.disableForm = false
2024-08-13 18:53:03 +08:00
this.editParams = data
this.dialogConfig.outerTitle = this.editDialogTitle
this.dialogConfig.outerVisible = true
},
/** 查看 */
handleSee(data) {
this.disableForm = true
this.editParams = data
this.dialogConfig.outerTitle = this.seeDialogTitle
this.dialogConfig.outerVisible = true
},
2024-08-13 18:53:03 +08:00
/** 导入数据 */
handleImportData() {
console.log('导入--')
},
/** 导出数据 */
handleExportData(data, url, fileName) {
this.download(
url,
{
...data
},
`${fileName}_${new Date().getTime()}.xlsx`,
)
},
/** 关闭外侧弹框 */
closeDialogOuter() {
this.dialogConfig.outerVisible = false
},
/** 关闭内侧弹框 */
closeDialogInner() {
this.dialogConfig.innerVisible = false
},
/** 关闭弹框 由表单组件通知父组件关闭弹框的自定义事件 */
closeDialog(type) {
this.dialogConfig.outerVisible = false
if(type) {
this.$refs.tableRef.getTableList()
}
},
/** 手机号脱密处理 */
phoneCrypto(phoneNumber) {
let reg = /^(1[3-9][0-9])\d{4}(\d{4}$)/
let isMobile = reg.test(phoneNumber)
if (isMobile) {
return phoneNumber.replace(reg, "$1****$2")
}
return phoneNumber
}
2024-08-13 18:53:03 +08:00
}
}