|
@@ -2,13 +2,19 @@
|
|
|
<div class="classify">
|
|
|
<el-row :gutter="10" class="mb10">
|
|
|
<el-col :span="1.5">
|
|
|
- <el-button type="primary" size="small" plain @click="addClassify">新增</el-button>
|
|
|
+ <el-button type="primary" size="small" plain @click="addClassify"
|
|
|
+ >新增</el-button
|
|
|
+ >
|
|
|
</el-col>
|
|
|
<el-col :span="1.5">
|
|
|
- <el-button type="primary" size="small" plain @click="editClassify">修改</el-button>
|
|
|
+ <el-button type="primary" size="small" plain @click="editClassify"
|
|
|
+ >修改</el-button
|
|
|
+ >
|
|
|
</el-col>
|
|
|
<el-col :span="1.5">
|
|
|
- <el-button type="primary" size="small" plain @click="deleteClassify">删除</el-button>
|
|
|
+ <el-button type="primary" size="small" plain @click="deleteClassify"
|
|
|
+ >删除</el-button
|
|
|
+ >
|
|
|
</el-col>
|
|
|
<!-- <el-col :span="1.5">
|
|
|
<el-button type="primary" size="small" plain>启用</el-button>
|
|
@@ -24,7 +30,8 @@
|
|
|
<el-input
|
|
|
placeholder="输入关键字进行过滤"
|
|
|
size="small"
|
|
|
- v-model="filterText">
|
|
|
+ v-model="filterText"
|
|
|
+ >
|
|
|
</el-input>
|
|
|
|
|
|
<el-tree
|
|
@@ -37,23 +44,39 @@
|
|
|
:default-expanded-keys="[1]"
|
|
|
:default-checked-keys="[2]"
|
|
|
:filter-node-method="filterNode"
|
|
|
- ref="tree">
|
|
|
+ ref="tree"
|
|
|
+ >
|
|
|
+ <span slot-scope="{ node, data }">
|
|
|
+ {{ data.code }} 👉 {{ node.label }}
|
|
|
+ </span>
|
|
|
</el-tree>
|
|
|
</el-col>
|
|
|
|
|
|
<el-col :span="18">
|
|
|
<span class="title">基本信息</span>
|
|
|
- <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="140px" class="demo-ruleForm">
|
|
|
+ <el-form
|
|
|
+ :model="ruleForm"
|
|
|
+ :rules="rules"
|
|
|
+ ref="ruleForm"
|
|
|
+ label-width="140px"
|
|
|
+ class="demo-ruleForm"
|
|
|
+ >
|
|
|
<el-row :gutter="20">
|
|
|
<el-col :span="12">
|
|
|
<el-form-item label="物料基本分类编码" prop="code">
|
|
|
- <el-input :disabled="disable" v-model="ruleForm.code"></el-input>
|
|
|
+ <el-input
|
|
|
+ :disabled="disable"
|
|
|
+ v-model="ruleForm.code"
|
|
|
+ ></el-input>
|
|
|
<span>编码规则x-xxx-xxx-xxx</span>
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
<el-col :span="12">
|
|
|
<el-form-item label="物料基本分类名称" prop="materialType">
|
|
|
- <el-input :disabled="disable" v-model="ruleForm.materialType"></el-input>
|
|
|
+ <el-input
|
|
|
+ :disabled="disable"
|
|
|
+ v-model="ruleForm.materialType"
|
|
|
+ ></el-input>
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
</el-row>
|
|
@@ -102,14 +125,14 @@
|
|
|
<el-col :span="24">
|
|
|
<el-form-item label="" prop="name">
|
|
|
<el-checkbox-group :disabled="disable" v-model="checkList">
|
|
|
- <el-checkbox label="库存状态"></el-checkbox>
|
|
|
- <!-- <el-checkbox label="项目"></el-checkbox>
|
|
|
+ <el-checkbox label="库存状态"></el-checkbox>
|
|
|
+ <!-- <el-checkbox label="项目"></el-checkbox>
|
|
|
<el-checkbox label="供应商"></el-checkbox>
|
|
|
<el-checkbox label="生产厂商"></el-checkbox>
|
|
|
<el-checkbox label="客户"></el-checkbox>
|
|
|
<el-checkbox label="特征码"></el-checkbox> -->
|
|
|
- <el-checkbox label="产品批号"></el-checkbox>
|
|
|
- </el-checkbox-group>
|
|
|
+ <el-checkbox label="产品批号"></el-checkbox>
|
|
|
+ </el-checkbox-group>
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
</el-row>
|
|
@@ -117,12 +140,14 @@
|
|
|
<el-row :gutter="20">
|
|
|
<el-col :span="24">
|
|
|
<el-form-item v-if="!disable">
|
|
|
- <el-button type="primary" @click="submitForm('ruleForm')">保存</el-button>
|
|
|
+ <el-button type="primary" @click="submitForm('ruleForm')"
|
|
|
+ >保存</el-button
|
|
|
+ >
|
|
|
<el-button @click="resetForm('ruleForm')">取消</el-button>
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
</el-row>
|
|
|
- </el-form>
|
|
|
+ </el-form>
|
|
|
</el-col>
|
|
|
</el-row>
|
|
|
</el-card>
|
|
@@ -130,178 +155,197 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import { getTree, getDetail, add, delClassify, edit} from '@/api/classify/basic';
|
|
|
+import {
|
|
|
+ getTree,
|
|
|
+ getDetail,
|
|
|
+ add,
|
|
|
+ delClassify,
|
|
|
+ edit,
|
|
|
+} from "@/api/classify/basic";
|
|
|
export default {
|
|
|
- name:'classify',
|
|
|
- dicts: ['material_enable', 'sys_assist_condtion'],
|
|
|
+ name: "classify",
|
|
|
+ dicts: ["material_enable", "sys_assist_condtion"],
|
|
|
data() {
|
|
|
return {
|
|
|
- filterText: '',
|
|
|
+ filterText: "",
|
|
|
data: [],
|
|
|
defaultProps: {
|
|
|
- children: 'childrens',
|
|
|
- label: 'materialType'
|
|
|
+ children: "childrens",
|
|
|
+ label: "materialType",
|
|
|
},
|
|
|
ruleForm: {
|
|
|
- code: '',
|
|
|
- materialType: '',
|
|
|
- isEnable: '0',
|
|
|
- delFlag: '',
|
|
|
- marasstframe: '',
|
|
|
+ code: "",
|
|
|
+ materialType: "",
|
|
|
+ isEnable: "0",
|
|
|
+ delFlag: "",
|
|
|
+ marasstframe: "",
|
|
|
},
|
|
|
rules: {
|
|
|
- code:[{ required: true, message: '请输入物料基本分类编码', trigger: 'blur' }],
|
|
|
- materialType:[{ required: true, message: '请输入物料基本分类名称', trigger: 'blur' }],
|
|
|
+ code: [
|
|
|
+ {
|
|
|
+ required: true,
|
|
|
+ message: "请输入物料基本分类编码",
|
|
|
+ trigger: "blur",
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ materialType: [
|
|
|
+ {
|
|
|
+ required: true,
|
|
|
+ message: "请输入物料基本分类名称",
|
|
|
+ trigger: "blur",
|
|
|
+ },
|
|
|
+ ],
|
|
|
},
|
|
|
checkList: [],
|
|
|
disable: true,
|
|
|
- biao: {parentId: 0},
|
|
|
+ biao: { parentId: 0 },
|
|
|
// 删除节点id
|
|
|
- delId: '',
|
|
|
+ delId: "",
|
|
|
// 判断是新增还是修改
|
|
|
- isAdd: true
|
|
|
- }
|
|
|
+ isAdd: true,
|
|
|
+ };
|
|
|
},
|
|
|
created() {
|
|
|
- this.getTreeData()
|
|
|
- //
|
|
|
- },
|
|
|
- mounted() {
|
|
|
+ this.getTreeData();
|
|
|
+ //
|
|
|
},
|
|
|
+ mounted() {},
|
|
|
methods: {
|
|
|
// 获取树形结构
|
|
|
getTreeData(data) {
|
|
|
- getTree(data).then(res => {
|
|
|
- let {code, rows} = res
|
|
|
- if(code === 200) {
|
|
|
- this.data = rows
|
|
|
+ getTree(data).then((res) => {
|
|
|
+ let { code, rows } = res;
|
|
|
+ if (code === 200) {
|
|
|
+ console.log("2", rows);
|
|
|
+ this.data = rows;
|
|
|
}
|
|
|
- })
|
|
|
+ });
|
|
|
},
|
|
|
// 获取物料基本分类详情
|
|
|
getDetailData(id) {
|
|
|
- getDetail(id).then(res => {
|
|
|
- let {code, data} = res
|
|
|
+ getDetail(id).then((res) => {
|
|
|
+ let { code, data } = res;
|
|
|
if (code === 200) {
|
|
|
- console.log('data', data)
|
|
|
- this.ruleForm = data
|
|
|
+ console.log("data", data);
|
|
|
+ this.ruleForm = data;
|
|
|
}
|
|
|
- })
|
|
|
+ });
|
|
|
},
|
|
|
filterNode(value, data) {
|
|
|
- if (!value) return true;
|
|
|
- return data.label.indexOf(value) !== -1;
|
|
|
+ if (!value) return true;
|
|
|
+ return data.label.indexOf(value) !== -1;
|
|
|
},
|
|
|
- clickTree(data){
|
|
|
- console.log('data', data)
|
|
|
+ clickTree(data) {
|
|
|
+ console.log("data", data);
|
|
|
// 如果点击新增时选择了树形节点,则不回显数据,且需要清空ruleForm内的数据
|
|
|
if (this.disable) {
|
|
|
- this.getDetailData(data.id)
|
|
|
+ this.getDetailData(data.id);
|
|
|
} else {
|
|
|
- this.$refs['ruleForm'].resetFields();
|
|
|
+ this.$refs["ruleForm"].resetFields();
|
|
|
}
|
|
|
// 标记是否为树形结构最外层
|
|
|
- this.biao.parentId = data.id
|
|
|
+ this.biao.parentId = data.id;
|
|
|
// 将节点id用作删除id
|
|
|
- this.delId = data.id
|
|
|
+ this.delId = data.id;
|
|
|
},
|
|
|
submitForm(formName) {
|
|
|
- this.$refs[formName].validate((valid) => {
|
|
|
- if (valid) {
|
|
|
- if(this.isAdd) { //判断是走新增还是修改
|
|
|
- console.log('add!');
|
|
|
- console.log(this.biao.parentId)
|
|
|
- console.log(this.ruleForm)
|
|
|
- let params = {...this.ruleForm, ...this.biao}
|
|
|
- console.log('params',params)
|
|
|
- add(params).then(res => {
|
|
|
- if(res.code === 200) {
|
|
|
- this.$message({
|
|
|
- message: res.msg,
|
|
|
- type: 'success'
|
|
|
- });
|
|
|
- this.getTreeData()
|
|
|
- // this.$refs['ruleForm'].resetFields();
|
|
|
- this.disable = true
|
|
|
- }
|
|
|
- })
|
|
|
- } else { //修改
|
|
|
- console.log('edit')
|
|
|
- let ids = {id: this.biao.parentId}
|
|
|
- console.log('ids', ids)
|
|
|
- let params = {...this.ruleForm, ...ids}
|
|
|
- console.log('params', params)
|
|
|
- edit(params).then(res => {
|
|
|
- if(res.code === 200) {
|
|
|
- this.$message({
|
|
|
- message: res.msg,
|
|
|
- type: 'success'
|
|
|
- });
|
|
|
- this.disable = true
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
+ this.$refs[formName].validate((valid) => {
|
|
|
+ if (valid) {
|
|
|
+ if (this.isAdd) {
|
|
|
+ //判断是走新增还是修改
|
|
|
+ console.log("add!");
|
|
|
+ console.log(this.biao.parentId);
|
|
|
+ console.log(this.ruleForm);
|
|
|
+ let params = { ...this.ruleForm, ...this.biao };
|
|
|
+ console.log("params", params);
|
|
|
+ add(params).then((res) => {
|
|
|
+ if (res.code === 200) {
|
|
|
+ this.$message({
|
|
|
+ message: res.msg,
|
|
|
+ type: "success",
|
|
|
+ });
|
|
|
+ this.getTreeData();
|
|
|
+ // this.$refs['ruleForm'].resetFields();
|
|
|
+ this.disable = true;
|
|
|
+ }
|
|
|
+ });
|
|
|
} else {
|
|
|
- console.log('error submit!!');
|
|
|
- return false;
|
|
|
+ //修改
|
|
|
+ console.log("edit");
|
|
|
+ let ids = { id: this.biao.parentId };
|
|
|
+ console.log("ids", ids);
|
|
|
+ let params = { ...this.ruleForm, ...ids };
|
|
|
+ console.log("params", params);
|
|
|
+ edit(params).then((res) => {
|
|
|
+ if (res.code === 200) {
|
|
|
+ this.$message({
|
|
|
+ message: res.msg,
|
|
|
+ type: "success",
|
|
|
+ });
|
|
|
+ this.disable = true;
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
- });
|
|
|
- },
|
|
|
+ } else {
|
|
|
+ console.log("error submit!!");
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
resetForm(formName) {
|
|
|
- console.log(formName)
|
|
|
- if(this.isAdd) {
|
|
|
+ console.log(formName);
|
|
|
+ if (this.isAdd) {
|
|
|
this.$refs[formName].resetFields();
|
|
|
- this.disable = true
|
|
|
+ this.disable = true;
|
|
|
} else {
|
|
|
- this.disable = true
|
|
|
+ this.disable = true;
|
|
|
}
|
|
|
},
|
|
|
// 点击新增按钮
|
|
|
addClassify() {
|
|
|
// console.log('值呢:', this.ruleForm)
|
|
|
// 如果点击了树形节点后再点击新增,则清空数据再填写
|
|
|
- if(this.biao.parentId !== 0) {
|
|
|
- this.$refs['ruleForm'].resetFields();
|
|
|
+ if (this.biao.parentId !== 0) {
|
|
|
+ this.$refs["ruleForm"].resetFields();
|
|
|
}
|
|
|
- this.disable = false
|
|
|
- this.isAdd = true
|
|
|
+ this.disable = false;
|
|
|
+ this.isAdd = true;
|
|
|
},
|
|
|
// 删除按钮
|
|
|
deleteClassify() {
|
|
|
-
|
|
|
- if(this.biao.parentId == 0) {
|
|
|
+ if (this.biao.parentId == 0) {
|
|
|
this.$message({
|
|
|
- message: '请选择删除节点',
|
|
|
- type: 'warning'
|
|
|
+ message: "请选择删除节点",
|
|
|
+ type: "warning",
|
|
|
});
|
|
|
} else {
|
|
|
- console.log('删除', this.delId)
|
|
|
- delClassify({id: this.delId}).then(res => {
|
|
|
+ console.log("删除", this.delId);
|
|
|
+ delClassify({ id: this.delId }).then((res) => {
|
|
|
if (res.code === 200) {
|
|
|
this.$message({
|
|
|
- message: '删除成功',
|
|
|
- type: 'success'
|
|
|
+ message: "删除成功",
|
|
|
+ type: "success",
|
|
|
});
|
|
|
- this.getTreeData()
|
|
|
+ this.getTreeData();
|
|
|
}
|
|
|
- })
|
|
|
+ });
|
|
|
}
|
|
|
},
|
|
|
// 修改按钮
|
|
|
editClassify() {
|
|
|
- if(this.biao.parentId == 0) {
|
|
|
+ if (this.biao.parentId == 0) {
|
|
|
this.$message({
|
|
|
- message: '请选择修改节点',
|
|
|
- type: 'warning'
|
|
|
+ message: "请选择修改节点",
|
|
|
+ type: "warning",
|
|
|
});
|
|
|
} else {
|
|
|
- console.log('修改')
|
|
|
- this.disable = false
|
|
|
- this.isAdd = false
|
|
|
+ console.log("修改");
|
|
|
+ this.disable = false;
|
|
|
+ this.isAdd = false;
|
|
|
}
|
|
|
- }
|
|
|
+ },
|
|
|
},
|
|
|
-}
|
|
|
+};
|
|
|
</script>
|
|
|
|
|
|
<style scoped lang="scss">
|
|
@@ -313,4 +357,4 @@ export default {
|
|
|
.title {
|
|
|
font-weight: bold;
|
|
|
}
|
|
|
-</style>
|
|
|
+</style>
|