| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169 |
- <!-- 用户编辑弹窗 -->
- <template>
- <ele-modal
- width="50%"
- :visible.sync="showEditFlag"
- :close-on-click-modal="false"
- custom-class="ele-dialog-form"
- append-to-body
- @close="cancel"
- :title="title + '编码'"
- >
- <el-form ref="form" :model="form" :rules="rules" label-width="82px">
- <el-row :gutter="15">
- <el-col :span="12">
- <el-form-item label="名称" prop="name">
- <el-input v-model="form.name" placeholder="请输入"></el-input>
- </el-form-item>
- </el-col>
- <el-col :span="12">
- <el-form-item label="描述" prop="remark">
- <el-input
- v-model="form.remark"
- type="textarea"
- placeholder="请输入"
- ></el-input>
- </el-form-item>
- </el-col>
- <el-col :span="24">
- <el-form-item label="使用对象" prop="useObjList">
- <tree ref="treeRef"></tree>
- </el-form-item>
- </el-col>
- <!-- <el-col :span="24">
- <el-form-item label="创建人" prop="remark">
- <el-input
- v-model="form.remark"
- type="textarea"
- placeholder="请输入"
- ></el-input>
- </el-form-item>
- </el-col> -->
- </el-row>
- </el-form>
- <template v-slot:footer>
- <el-button @click="cancel">取消</el-button>
- <el-button type="primary" :loading="loading" @click="save">
- 确认
- </el-button>
- </template>
- </ele-modal>
- </template>
-
- <script>
- const defaultForm = {
- name: '', //名称
- parentId: '', //父id
- sort: '',
- status: '', //状态
- type: 2, //类型
- useObjList: [], //使用对象信息集合
- remark: '' //备注
- };
- import { save } from '@/api/businessCode';
- import tree from './tree.vue';
- export default {
- data() {
- return {
- // 表单数据
- form: { ...defaultForm },
- // 表单验证规则
- rules: {},
- // 提交状态
- loading: false,
- showEditFlag: false,
- title: '',
- type: '',
- rules: {
- name: [
- {
- required: true,
- message: '请输入',
- trigger: 'blur'
- }
- ]
- }
- };
- },
- props: {
- parentId: ''
- },
- components: {
- tree
- },
- created() {},
- methods: {
- async open(type, row) {
- this.title = type === 'edit' ? '编辑' : '新增';
- this.showEditFlag = true;
- this.type = type;
- if (type == 'add') {
- this.form.parentId = this.parentId;
- } else {
- this.form = JSON.parse(JSON.stringify(row));
- }
- console.log(this.form, 'row');
- this.$nextTick(() => {
- this.$refs.treeRef.init(this.form.useObjList || []);
- });
- },
- /* 保存编辑 */
- save() {
- this.$refs.form.validate(async (valid) => {
- if (!valid) {
- return false;
- }
- if (this.type != 'edit') {
- delete this.form.id;
- }
- this.form.useObjList = this.$refs.treeRef.getList();
- this.loading = true;
- save(this.form)
- .then((msg) => {
- this.loading = false;
- this.cancel();
- this.$emit('done');
- })
- .catch((e) => {
- this.loading = false;
- });
- });
- },
- cancel() {
- this.form = { ...defaultForm };
- this.$refs.form.clearValidate();
- this.showEditFlag = false;
- }
- }
- };
- </script>
- <style scoped lang="scss">
- .aaa {
- width: 100%;
- ::v-deep .upload-demo {
- width: 100%;
- .el-upload--text {
- width: 100%;
- button {
- width: 100%;
- background: #ffffff;
- border: 1px solid #dbdbdb;
- border-radius: 5px;
- }
- }
- .el-upload-list {
- transform: translate(10px, -39px);
- position: absolute;
- }
- }
- }
- </style>
-
|