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 } }, /** 删除 */ 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) { 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() this.getTreeData() } }).catch(err => {}) }) }, /** 编辑 */ handleEditData(data) { this.editParams = data this.dialogConfig.outerTitle = this.editDialogTitle this.dialogConfig.outerVisible = true }, /** 导入数据 */ 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 } } }