feat: 引入eslint

This commit is contained in:
chenjinsong
2021-03-19 18:52:19 +08:00
parent ca31480b84
commit 337ee9a938
159 changed files with 47146 additions and 47387 deletions

View File

@@ -44,101 +44,101 @@
</template>
<script>
export default {
name: "cabinetBox",
props:{
cabinet: {type:Object},
currentDc: {type:Object}
},
data(){
return {
editCabinet:{},
rules:{
name: [
{required: true, message: this.$t('validate.required'), trigger: 'blur'}
],
uSize: [
{required: true, message: this.$t('validate.required'), trigger: 'blur'},
{type: 'number', min: 1, max: 47,message: this.$t('validate.uSize'),trigger: 'blur'}
],
},
}
},
methods:{
clickOutside() {
this.esc(false);
},
esc(refresh) {
this.prevent_opt.save=false;
this.$emit("close", refresh);
},
save() {
if(this.prevent_opt.save){ return } ;
this.prevent_opt.save=true;
this.$refs.cabinetForm.validate((valid => {
if(valid){
this.editCabinet.idcId = this.currentDc.id;
if (this.editCabinet.id) {
this.$put('cabinet', this.editCabinet).then(res => {
this.prevent_opt.save=false;
if (res.code === 200) {
this.$message({duration: 2000, type: 'success', message: this.$t("tip.saveSuccess")});
this.esc(true);
} else {
this.$message.error(res.msg);
}
})
} else {
this.$post('cabinet', this.editCabinet).then(res => {
this.prevent_opt.save=false;
if (res.code === 200) {
this.$message({duration: 2000, type: 'success', message: this.$t("tip.saveSuccess")});
this.esc(true);
} else {
this.$message.error(res.msg);
}
})
}
}else{
this.prevent_opt.save=false;
return false;
}
}))
},
del() {
if(this.prevent_opt.save){ return } ;
this.prevent_opt.save=true;
this.$confirm(this.$t("tip.confirmDelete"), {
confirmButtonText: this.$t("tip.yes"),
cancelButtonText: this.$t("tip.no"),
type: 'warning'
}).then(() => {
this.$delete('/cabinet?ids=' + this.editCabinet.id).then(response=>{
this.prevent_opt.save=false;
if(response.code == 200){
this.$message({duration: 2000, type: 'success', message: this.$t("tip.saveSuccess")});
this.esc(true);
}else{
this.$message.error(response.msg);
}
})
}).catch(()=>{
this.prevent_opt.save=false;
})
}
},
watch:{
cabinet:{
deep:true,
immediate:true,
handler:function(n,o){
if (n) {
this.editCabinet = JSON.parse(JSON.stringify(n));
}
}
},
export default {
name: 'cabinetBox',
props: {
cabinet: { type: Object },
currentDc: { type: Object }
},
data () {
return {
editCabinet: {},
rules: {
name: [
{ required: true, message: this.$t('validate.required'), trigger: 'blur' }
],
uSize: [
{ required: true, message: this.$t('validate.required'), trigger: 'blur' },
{ type: 'number', min: 1, max: 47, message: this.$t('validate.uSize'), trigger: 'blur' }
]
}
}
},
methods: {
clickOutside () {
this.esc(false)
},
esc (refresh) {
this.prevent_opt.save = false
this.$emit('close', refresh)
},
save () {
if (this.prevent_opt.save) { return } ;
this.prevent_opt.save = true
this.$refs.cabinetForm.validate(valid => {
if (valid) {
this.editCabinet.idcId = this.currentDc.id
if (this.editCabinet.id) {
this.$put('cabinet', this.editCabinet).then(res => {
this.prevent_opt.save = false
if (res.code === 200) {
this.$message({ duration: 2000, type: 'success', message: this.$t('tip.saveSuccess') })
this.esc(true)
} else {
this.$message.error(res.msg)
}
})
} else {
this.$post('cabinet', this.editCabinet).then(res => {
this.prevent_opt.save = false
if (res.code === 200) {
this.$message({ duration: 2000, type: 'success', message: this.$t('tip.saveSuccess') })
this.esc(true)
} else {
this.$message.error(res.msg)
}
})
}
} else {
this.prevent_opt.save = false
return false
}
})
},
del () {
if (this.prevent_opt.save) { return } ;
this.prevent_opt.save = true
this.$confirm(this.$t('tip.confirmDelete'), {
confirmButtonText: this.$t('tip.yes'),
cancelButtonText: this.$t('tip.no'),
type: 'warning'
}).then(() => {
this.$delete('/cabinet?ids=' + this.editCabinet.id).then(response => {
this.prevent_opt.save = false
if (response.code == 200) {
this.$message({ duration: 2000, type: 'success', message: this.$t('tip.saveSuccess') })
this.esc(true)
} else {
this.$message.error(response.msg)
}
})
}).catch(() => {
this.prevent_opt.save = false
})
}
},
watch: {
cabinet: {
deep: true,
immediate: true,
handler: function (n, o) {
if (n) {
this.editCabinet = JSON.parse(JSON.stringify(n))
}
}
}
}
}
</script>
<style >
</style>