|
@@ -4,178 +4,214 @@
|
|
|
@Date: 2021-05-25 11:22
|
|
|
-->
|
|
|
<template>
|
|
|
- <div>
|
|
|
- <dg-card class="box-card" shadow="never" header="属性详情">
|
|
|
- <div style="height: calc(100vh - 19rem)">
|
|
|
- <dg-scrollbar>
|
|
|
- <el-form
|
|
|
- ref="ruleForm"
|
|
|
- :rules="rules"
|
|
|
- :model="form"
|
|
|
- label-width="80px"
|
|
|
- :style="{ width: type == 'SUB' ? '40%' : '90%' }"
|
|
|
- >
|
|
|
- <el-form-item label="属性类别">
|
|
|
- <el-input v-model="rootName" placeholder="请输入属性类别" disabled></el-input>
|
|
|
- </el-form-item>
|
|
|
- <el-form-item label="属性名称" prop="name">
|
|
|
- <el-input v-model="form.name" placeholder="请输入属性名称" :disabled="readOnly"></el-input>
|
|
|
- </el-form-item>
|
|
|
- <el-form-item
|
|
|
- v-for="(item, index) in form.child"
|
|
|
- :key="index"
|
|
|
- :label="index == 0 ? '属性值' : ''"
|
|
|
- :prop="'child.' + index + '.name'"
|
|
|
- class="prop-value-item"
|
|
|
- :rules="{
|
|
|
- required: true,
|
|
|
- message: '属性值不能为空',
|
|
|
- trigger: 'blur'
|
|
|
- }"
|
|
|
- >
|
|
|
- <div class="subject-property__form-item">
|
|
|
- <el-input
|
|
|
- v-model="item.name"
|
|
|
- placeholder="请输入属性值"
|
|
|
- :disabled="readOnly"
|
|
|
- ></el-input>
|
|
|
- <i
|
|
|
- class="el-icon-remove-outline icon"
|
|
|
- @click="handleDeletePropValue(index)"
|
|
|
- v-if="form.child.length > 1 && !readOnly"
|
|
|
- ></i>
|
|
|
- <!-- <dg-button class="delete-btn" size="mini" icon="el-icon-minus" plain></dg-button> -->
|
|
|
- </div>
|
|
|
- </el-form-item>
|
|
|
- <el-form-item label="">
|
|
|
- <dg-button
|
|
|
- v-if="!readOnly"
|
|
|
- :icon="'添加属性值' | optIcon"
|
|
|
- size="mini"
|
|
|
- type="primary"
|
|
|
- plain
|
|
|
- @click="handleAddPropValue"
|
|
|
- >添加属性值</dg-button
|
|
|
- >
|
|
|
- </el-form-item>
|
|
|
- <el-form-item label="说明" v-if="!readOnly">
|
|
|
- <el-input v-model="form.remark" type="textarea" row="3" placeholder="请输入说明"></el-input>
|
|
|
- </el-form-item>
|
|
|
- <el-form-item v-if="!readOnly" label="" style="text-align: center"
|
|
|
- ><dg-button type="primary" @click="handleSaveProp" :icon="'保存'| optIcon">保存</dg-button></el-form-item
|
|
|
- >
|
|
|
- </el-form>
|
|
|
- </dg-scrollbar>
|
|
|
- </div>
|
|
|
- </dg-card>
|
|
|
- </div>
|
|
|
+ <div>
|
|
|
+ <dg-card class="box-card" shadow="never" header="属性详情">
|
|
|
+ <div style="height: calc(100vh - 17rem)">
|
|
|
+ <dg-scrollbar>
|
|
|
+ <el-form
|
|
|
+ ref="ruleForm"
|
|
|
+ :rules="rules"
|
|
|
+ :model="form"
|
|
|
+ label-width="100px"
|
|
|
+ :style="{ width: type == 'SUB' ? '40%' : '90%' }"
|
|
|
+ >
|
|
|
+ <el-form-item label="属性类别">
|
|
|
+ <el-input v-model="rootName" placeholder="请输入属性类别" disabled></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="属性类别编码">
|
|
|
+ <el-input v-model="rootName" placeholder="请输入属性类别编码" disabled></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="属性名称" prop="name">
|
|
|
+ <el-input v-model="form.name" placeholder="请输入属性名称" :disabled="readOnly"></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="属性编码" prop="code" class="attr-code">
|
|
|
+ <el-input v-model="form.code" placeholder="请输入属性编码" :disabled="readOnly">
|
|
|
+ <template slot="prepend">APP-RA-</template>
|
|
|
+ </el-input>
|
|
|
+ <!-- <dg-row>
|
|
|
+ <dg-col :span="5"><el-input value="APP-RA" :disabled="true"></el-input></dg-col>
|
|
|
+ <dg-col :span="2" style="text-align: center"><i class="el-icon-minus"></i></dg-col>
|
|
|
+ <dg-col :span="17">
|
|
|
+ <el-input v-model="form.code" placeholder="请输入属性编码" :disabled="readOnly"></el-input>
|
|
|
+ </dg-col>
|
|
|
+ </dg-row> -->
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="是否内置">
|
|
|
+ <el-input :value="form.isDefault" disabled></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ <template v-for="(item, index) in form.child">
|
|
|
+ <dg-row :key="index">
|
|
|
+ <dg-col :span="12">
|
|
|
+ <el-form-item
|
|
|
+ :label="index == 0 ? '属性值名称' : ''"
|
|
|
+ :prop="'child.' + index + '.name'"
|
|
|
+ class="prop-value-item"
|
|
|
+ :rules="{
|
|
|
+ required: true,
|
|
|
+ message: '属性值名称不能为空',
|
|
|
+ trigger: 'blur'
|
|
|
+ }"
|
|
|
+ >
|
|
|
+ <el-input v-model="item.name" placeholder="请输入属性值名称" :disabled="readOnly"></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ </dg-col>
|
|
|
+ <dg-col :span="12">
|
|
|
+ <el-form-item
|
|
|
+ :label="index == 0 ? '属性值编码' : ''"
|
|
|
+ :prop="'child.' + index + '.code'"
|
|
|
+ class="prop-value-item"
|
|
|
+ :rules="{
|
|
|
+ required: true,
|
|
|
+ message: '属性值编码不能为空',
|
|
|
+ trigger: 'blur'
|
|
|
+ }"
|
|
|
+ >
|
|
|
+ <div class="subject-property__form-item">
|
|
|
+ <el-input v-model="item.code" placeholder="请输入属性值编码" :disabled="readOnly"></el-input>
|
|
|
+ <i
|
|
|
+ class="el-icon-remove-outline icon"
|
|
|
+ @click="handleDeletePropValue(index)"
|
|
|
+ v-if="form.child.length > 1 && !readOnly"
|
|
|
+ ></i>
|
|
|
+ </div>
|
|
|
+ </el-form-item>
|
|
|
+ </dg-col>
|
|
|
+ </dg-row>
|
|
|
+ </template>
|
|
|
+ <el-form-item label="">
|
|
|
+ <dg-button
|
|
|
+ v-if="!readOnly"
|
|
|
+ :icon="'添加属性值' | optIcon"
|
|
|
+ size="mini"
|
|
|
+ type="primary"
|
|
|
+ plain
|
|
|
+ @click="handleAddPropValue"
|
|
|
+ >添加属性值</dg-button
|
|
|
+ >
|
|
|
+ </el-form-item>
|
|
|
+ <!-- <el-form-item label="说明" v-if="!readOnly">
|
|
|
+ <el-input v-model="form.remark" type="textarea" row="3" placeholder="请输入说明"></el-input>
|
|
|
+ </el-form-item> -->
|
|
|
+ <el-form-item v-if="!readOnly" label="" style="text-align: center"
|
|
|
+ ><dg-button type="primary" @click="handleSaveProp" :icon="'保存' | optIcon">保存</dg-button></el-form-item
|
|
|
+ >
|
|
|
+ </el-form>
|
|
|
+ </dg-scrollbar>
|
|
|
+ </div>
|
|
|
+ </dg-card>
|
|
|
+ </div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import { saveProp } from "@/api/data-auth";
|
|
|
-import _ from "lodash";
|
|
|
+import { saveProp } from '@/api/data-auth';
|
|
|
+import _ from 'lodash';
|
|
|
export default {
|
|
|
- props: {
|
|
|
- parentNode: Object,
|
|
|
- type: String,
|
|
|
- operateType: String
|
|
|
+ props: {
|
|
|
+ parentNode: Object,
|
|
|
+ type: String,
|
|
|
+ operateType: String
|
|
|
+ },
|
|
|
+ components: {},
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ form: {
|
|
|
+ attrBelongType: this.parentNode.attrBelongType,
|
|
|
+ attrType: this.type,
|
|
|
+ child: [
|
|
|
+ {
|
|
|
+ name: '',
|
|
|
+ code: ''
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ remark: '',
|
|
|
+ name: '',
|
|
|
+ code: '',
|
|
|
+ pid: this.parentNode.id,
|
|
|
+ isDefault: 1
|
|
|
+ },
|
|
|
+ rules: {
|
|
|
+ name: [{ required: true, message: '属性名称不能为空', trigger: 'change' }],
|
|
|
+ code: [{ required: true, message: '属性编码不能为空', trigger: 'change' }]
|
|
|
+ },
|
|
|
+ rootName: '',
|
|
|
+ readOnly: this.parentNode.pid && !this.parentNode.child
|
|
|
+ };
|
|
|
+ },
|
|
|
+ computed: {},
|
|
|
+ methods: {
|
|
|
+ /**
|
|
|
+ * 添加属性值
|
|
|
+ */
|
|
|
+ handleAddPropValue() {
|
|
|
+ this.form.child.push({
|
|
|
+ name: '',
|
|
|
+ code: ''
|
|
|
+ });
|
|
|
},
|
|
|
- components: {},
|
|
|
- data() {
|
|
|
- return {
|
|
|
- form: {
|
|
|
- attrBelongType: this.parentNode.attrBelongType,
|
|
|
- attrType: this.type,
|
|
|
- child: [
|
|
|
- {
|
|
|
- name: ""
|
|
|
- }
|
|
|
- ],
|
|
|
- remark: "",
|
|
|
- name: "",
|
|
|
- pid: this.parentNode.id
|
|
|
- },
|
|
|
- rules: {
|
|
|
- name: [{ required: true, message: "属性名称不能为空", trigger: "change" }]
|
|
|
- },
|
|
|
- rootName: "",
|
|
|
- readOnly: this.parentNode.pid && !this.parentNode.child
|
|
|
- };
|
|
|
+ /**
|
|
|
+ * 删除属性值
|
|
|
+ */
|
|
|
+ handleDeletePropValue(index) {
|
|
|
+ this.form.child.splice(index, 1);
|
|
|
},
|
|
|
- computed: {},
|
|
|
- methods: {
|
|
|
- /**
|
|
|
- * 添加属性值
|
|
|
- */
|
|
|
- handleAddPropValue() {
|
|
|
- this.form.child.push({
|
|
|
- name: ""
|
|
|
- });
|
|
|
- },
|
|
|
- /**
|
|
|
- * 删除属性值
|
|
|
- */
|
|
|
- handleDeletePropValue(index) {
|
|
|
- this.form.child.splice(index, 1);
|
|
|
- },
|
|
|
- /**
|
|
|
- * 保存属性
|
|
|
- */
|
|
|
- handleSaveProp() {
|
|
|
- this.$refs.ruleForm.validate((valid) => {
|
|
|
- if (valid) {
|
|
|
- // 属性值不能重复
|
|
|
- let flag = false;
|
|
|
- this.form.child.sort((a, b) => {
|
|
|
- if (a.name == b.name) {
|
|
|
- flag = true;
|
|
|
- return;
|
|
|
- }
|
|
|
- });
|
|
|
- if (flag) {
|
|
|
- this.$message.warning("属性值不能重复");
|
|
|
- return;
|
|
|
- }
|
|
|
+ /**
|
|
|
+ * 保存属性
|
|
|
+ */
|
|
|
+ handleSaveProp() {
|
|
|
+ this.$refs.ruleForm.validate((valid) => {
|
|
|
+ if (valid) {
|
|
|
+ // 属性值不能重复
|
|
|
+ let flag = false;
|
|
|
+ this.form.child.sort((a, b) => {
|
|
|
+ if (a.name == b.name) {
|
|
|
+ flag = true;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ if (flag) {
|
|
|
+ this.$message.warning('属性值不能重复');
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
- saveProp(this.form).then((res) => {
|
|
|
- const { result, msg } = res.data;
|
|
|
- if (result == "200") {
|
|
|
- this.$message.success("保存成功");
|
|
|
- this.$emit("savePropSuccess");
|
|
|
- } else {
|
|
|
- this.$message.error(msg);
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
- },
|
|
|
- created() {
|
|
|
- if (this.parentNode.pname) {
|
|
|
- const pName = this.parentNode.pname.split("-");
|
|
|
- delete this.parentNode.operateType;
|
|
|
- this.form = _.cloneDeep(this.parentNode);
|
|
|
- if (pName.length > 1) {
|
|
|
- this.form.name = pName[1];
|
|
|
- this.form.child = [
|
|
|
- {
|
|
|
- ...this.parentNode
|
|
|
- }
|
|
|
- ];
|
|
|
- this.rootName = pName[0];
|
|
|
+ saveProp(this.form).then((res) => {
|
|
|
+ const { result, msg } = res.data;
|
|
|
+ if (result == '200') {
|
|
|
+ this.$message.success('保存成功');
|
|
|
+ this.$emit('savePropSuccess');
|
|
|
} else {
|
|
|
- this.rootName = pName[0];
|
|
|
+ this.$message.error(msg);
|
|
|
}
|
|
|
- } else {
|
|
|
- this.rootName = this.parentNode.name;
|
|
|
+ });
|
|
|
}
|
|
|
- },
|
|
|
- mounted() {}
|
|
|
+ });
|
|
|
+ }
|
|
|
+ },
|
|
|
+ created() {
|
|
|
+ if (this.parentNode.pname) {
|
|
|
+ const pName = this.parentNode.pname.split('-');
|
|
|
+ delete this.parentNode.operateType;
|
|
|
+ this.form = _.cloneDeep(this.parentNode);
|
|
|
+ if (pName.length > 1) {
|
|
|
+ this.form.name = pName[1];
|
|
|
+ this.form.child = [
|
|
|
+ {
|
|
|
+ ...this.parentNode
|
|
|
+ }
|
|
|
+ ];
|
|
|
+ this.rootName = pName[0];
|
|
|
+ } else {
|
|
|
+ this.rootName = pName[0];
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ this.rootName = this.parentNode.name;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ mounted() {}
|
|
|
};
|
|
|
</script>
|
|
|
|
|
|
<style lang='scss' scoped>
|
|
|
-.delete-btn {
|
|
|
- width: 50px !important;
|
|
|
+/deep/.el-input-group__prepend {
|
|
|
+ padding: 0 12px;
|
|
|
}
|
|
|
</style>
|