| | |
| | | <template> |
| | | <basic-container> |
| | | <avue-crud :option="option" |
| | | <avue-crud v-if="permit" :option="option" |
| | | :table-loading="loading" |
| | | :data="data" |
| | | :page.sync="page" |
| | |
| | | </el-button> |
| | | </template> |
| | | </avue-crud> |
| | | |
| | | <avue-form v-else |
| | | v-model="form" |
| | | :option="option" |
| | | @submit="handleSubmit" |
| | | ></avue-form> |
| | | </basic-container> |
| | | </template> |
| | | |
| | | <script> |
| | | import {getList, getDetail, add, update, remove} from "@/api/enterprise/enterprise"; |
| | | import {getList, getDetail,getDetailByUserId, add, update, remove} from "@/api/enterprise/enterprise"; |
| | | import option from "@/const/enterprise/enterprise"; |
| | | import {mapGetters} from "vuex"; |
| | | |
| | |
| | | ids.push(ele.id); |
| | | }); |
| | | return ids.join(","); |
| | | }, |
| | | permit(){ |
| | | return this.userInfo.role_name == 'admin' || this.userInfo.role_name == 'administrator' ? true:false |
| | | } |
| | | }, |
| | | created() { |
| | | if (this.permit){ |
| | | this.getEnterpriseDetailByUserId() |
| | | } |
| | | }, |
| | | methods: { |
| | | handleSubmit(){ |
| | | if (this.form.id){ |
| | | update(this.form).then(res=>{ |
| | | if (res.data.code == 200){ |
| | | this.$message.success(res.data.msg) |
| | | }else { |
| | | this.$message.error(res.data.msg) |
| | | } |
| | | }) |
| | | }else { |
| | | add(this.form).then(res=>{ |
| | | if (res.data.code == 200){ |
| | | this.$message.success(res.data.msg) |
| | | }else { |
| | | this.$message.error(res.data.msg) |
| | | } |
| | | }) |
| | | } |
| | | }, |
| | | rowSave(row, done, loading) { |
| | | row.userId = this.userInfo.user_id |
| | | add(row).then(() => { |
| | |
| | | this.loading = false; |
| | | this.selectionClear(); |
| | | }); |
| | | }, |
| | | getEnterpriseDetailByUserId(){ |
| | | getDetailByUserId(this.userInfo.user_id).then(res=>{ |
| | | if (res.data.code == 200){ |
| | | this.form = res.data.data |
| | | this.form.account = this.userInfo.account |
| | | const group = this.findObject(this.option.group,"account"); |
| | | group.disabled = true |
| | | } |
| | | }) |
| | | } |
| | | } |
| | | }; |