|  |  | 
 |  |  |         @confirm="confirm" | 
 |  |  |     > | 
 |  |  |         <el-form :model="form" ref="form" :rules="rules"> | 
 |  |  |             <el-form-item label="名称" prop="name"> | 
 |  |  |                 <el-input v-model="form.name" placeholder="请输入名称" v-trim/> | 
 |  |  |             <el-form-item label="上级组织" prop="parentId"> | 
 |  |  |                 <companySelect v-if="visible" v-model="form.parentId" placeholder="请选择上级菜单" clearable :inline="false"/> | 
 |  |  |             </el-form-item> | 
 |  |  |             <el-form-item label="组织名称" prop="name"> | 
 |  |  |                 <el-input v-model="form.name" placeholder="请输入组织名称" v-trim/> | 
 |  |  |             </el-form-item> | 
 |  |  |         </el-form> | 
 |  |  |     </GlobalWindow> | 
 |  |  | 
 |  |  | <script> | 
 |  |  | import BaseOpera from '@/components/base/BaseOpera' | 
 |  |  | import GlobalWindow from '@/components/common/GlobalWindow' | 
 |  |  | import companySelect from '@/components/common/companySelect' | 
 |  |  | export default { | 
 |  |  |   name: 'OperaInternalCompanyWindow', | 
 |  |  |   extends: BaseOpera, | 
 |  |  |   components: { GlobalWindow }, | 
 |  |  |   components: { GlobalWindow, companySelect }, | 
 |  |  |   data () { | 
 |  |  |     return { | 
 |  |  |       options: [], | 
 |  |  |       // 表单数据 | 
 |  |  |       form: { | 
 |  |  |         id: null, | 
 |  |  |         name: '' | 
 |  |  |         name: '', | 
 |  |  |         parentId: [], | 
 |  |  |         disable: false | 
 |  |  |       }, | 
 |  |  |       // 验证规则 | 
 |  |  |       rules: { | 
 |  |  |         name: [ | 
 |  |  |           { required: true, message: '请输入组织名称' } | 
 |  |  |         ] | 
 |  |  |       } | 
 |  |  |     } | 
 |  |  |   }, | 
 |  |  |   props: { | 
 |  |  |     list: { | 
 |  |  |       type: Array | 
 |  |  |     } | 
 |  |  |   }, | 
 |  |  |   created () { | 
 |  |  | 
 |  |  |       api: '/business/company', | 
 |  |  |       'field.id': 'id' | 
 |  |  |     }) | 
 |  |  |   }, | 
 |  |  |   methods: { | 
 |  |  |     // 确认新建/修改 | 
 |  |  |     confirm () { | 
 |  |  |       this.$refs.form.validate((valid) => { | 
 |  |  |         if (!valid) { | 
 |  |  |           return | 
 |  |  |         } | 
 |  |  |         // 调用新建接口 | 
 |  |  |         this.isWorking = true | 
 |  |  |         if (this.form.id == null || this.form.id === '') { | 
 |  |  |           this.api.create({ | 
 |  |  |             parentId: this.form.parentId, | 
 |  |  |             name: this.form.name, | 
 |  |  |             type: 1 | 
 |  |  |           }) | 
 |  |  |             .then(() => { | 
 |  |  |               this.visible = false | 
 |  |  |               this.$tip.apiSuccess('新建成功') | 
 |  |  |               this.$emit('success') | 
 |  |  |             }) | 
 |  |  |             .catch(e => { | 
 |  |  |               this.$tip.apiFailed(e) | 
 |  |  |             }) | 
 |  |  |             .finally(() => { | 
 |  |  |               this.isWorking = false | 
 |  |  |             }) | 
 |  |  |         } else { | 
 |  |  |           this.api.updateById({ | 
 |  |  |             id: this.form.id, | 
 |  |  |             parentId: this.form.parentId, | 
 |  |  |             name: this.form.name, | 
 |  |  |             type: 1 | 
 |  |  |           }) | 
 |  |  |             .then(() => { | 
 |  |  |               this.visible = false | 
 |  |  |               this.$tip.apiSuccess('修改成功') | 
 |  |  |               this.$emit('success') | 
 |  |  |             }) | 
 |  |  |             .catch(e => { | 
 |  |  |               this.$tip.apiFailed(e) | 
 |  |  |             }) | 
 |  |  |             .finally(() => { | 
 |  |  |               this.isWorking = false | 
 |  |  |             }) | 
 |  |  |         } | 
 |  |  |       }) | 
 |  |  |     } | 
 |  |  |   } | 
 |  |  | } | 
 |  |  | </script> |