<template>
|
<win-sm :title="setting.title" @close="close">
|
<el-form ref="ruleForm" :model="formData" :rules="rules" class="demo-ruleForm" label-width="120px" v-loading="loading">
|
<!-- <el-form-item label="父级分类名称" >-->
|
<!-- <el-input v-model="parentName" disabled clearable maxlength="20" show-word-limit />-->
|
<!-- </el-form-item>-->
|
<el-form-item label="分类名称" prop="title">
|
<el-input v-model="formData.title" clearable maxlength="20" show-word-limit />
|
</el-form-item>
|
<el-form-item label="顺序号" prop="orderNum">
|
<el-input v-model="formData.orderNum" clearable maxlength="20" type="Number" show-word-limit />
|
</el-form-item>
|
<el-form-item label="状态" prop="status">
|
<el-radio-group v-model="formData.status">
|
<el-radio :label="0" border>启用</el-radio>
|
<el-radio :label="1" border>禁用</el-radio>
|
</el-radio-group>
|
</el-form-item>
|
<el-form-item label="备注" prop="note">
|
<el-input
|
v-model="formData.note"
|
type="textarea"
|
:rows="3"
|
maxlength="500"
|
show-word-limit
|
/>
|
</el-form-item>
|
</el-form>
|
<div slot="footer" align="center" class="dialog-footer">
|
<my-button name="取消" site="form" @click="close" />
|
<my-button name="保存" site="form" @click="save" />
|
</div>
|
</win-sm>
|
</template>
|
|
<script>
|
import winSm from '@/components/win/win-sm'
|
import myButton from '@/components/myButton/myButton'
|
import * as classify from '@/api/projectManage/classify'
|
export default {
|
components: { winSm, myButton},
|
props: {
|
setting: {
|
type: Object,
|
default: () => {
|
}
|
}
|
},
|
data() {
|
return {
|
loading:false,
|
formData: {
|
projectId: this.setting.projectId,
|
title: '',
|
orderNum: null,
|
note: '',
|
status: 0,
|
parentId:this.setting.parentId,
|
},
|
parentName:this.setting.parentName,
|
rules: {
|
title: [
|
{ required: true, message: '请输入分类名称', trigger: 'blur' }
|
],
|
orderNum: [
|
{ required: true, message: '请输入分类顺序号', trigger: 'blur' }
|
],
|
}
|
}
|
},
|
created() {
|
if(this.setting){
|
this.getInfo();
|
}
|
},
|
methods: {
|
getInfo() {
|
this.title = this.setting.title
|
if (this.setting.id != null) {
|
this.loading = true
|
let params = {
|
id: this.setting.id
|
}
|
// 查询数据
|
classify.getdetail(params).then(res => {
|
const data = res
|
this.formData = Object.assign(this.formData, data)
|
this.loading = false
|
})
|
}
|
},
|
close() {
|
this.formData = {
|
name: '',
|
code: '',
|
description: '',
|
status: 0
|
}, this.$emit('close')
|
},
|
save() {
|
this.$refs.ruleForm.validate((valid) => {
|
if (valid) {
|
const params = Object.assign({}, this.formData)
|
if (params.id) {
|
classify.edit(params).then(res => {
|
if (res) {
|
this.$message.success('保存成功!')
|
this.close()
|
this.$emit('search')
|
this.$emit('initTreeData')
|
} else {
|
this.$message.error('保存失败')
|
}
|
})
|
} else {
|
classify.add(params).then(res => {
|
if (res) {
|
this.$message.success('保存成功!')
|
this.close()
|
this.$emit('search')
|
this.$emit('initTreeData')
|
} else {
|
this.$message.error('保存失败')
|
}
|
})
|
}
|
} else {
|
this.$message.error('校验未通过,请检查。')
|
}
|
})
|
}
|
}
|
}
|
</script>
|
|
<style scoped>
|
|
</style>
|