|
@@ -0,0 +1,180 @@
|
|
|
+<template>
|
|
|
+ <div>
|
|
|
+ <div class="button-container" v-if="model != 'detail'">
|
|
|
+ <el-button type="primary" size="small" :loading="btnLoading" @click="submitForm">提 交</el-button>
|
|
|
+ <el-button size="small" @click="init">重 置</el-button>
|
|
|
+ </div>
|
|
|
+ <div class="form_center" >
|
|
|
+
|
|
|
+ <el-form ref="form" :model="form" :rules="rules" label-width="100px" label-position="left">
|
|
|
+
|
|
|
+ <el-form-item label="所属租户" prop="tenant">
|
|
|
+ <el-tooltip
|
|
|
+ class="item"
|
|
|
+ effect="dark"
|
|
|
+ :disabled="!userinfo.tenantName"
|
|
|
+ :content="userinfo.tenantName"
|
|
|
+ placement="top-start"
|
|
|
+ >
|
|
|
+ <el-input v-model="userinfo.tenantName" placeholder="请输入所属租户" :readonly="true"></el-input>
|
|
|
+ </el-tooltip>
|
|
|
+ </el-form-item>
|
|
|
+
|
|
|
+ <el-form-item label="职位名称" prop="position">
|
|
|
+ <el-input v-model="form.position" placeholder="请输入职位名称"></el-input>
|
|
|
+ </el-form-item>
|
|
|
+
|
|
|
+ <el-form-item label="是否唯一" prop="ismore">
|
|
|
+ <el-radio-group v-model="form.ismore">
|
|
|
+ <el-radio :label="1">是</el-radio>
|
|
|
+ <el-radio :label="0">否</el-radio>
|
|
|
+ </el-radio-group>
|
|
|
+ </el-form-item>
|
|
|
+
|
|
|
+ <el-form-item label="描述" prop="describe">
|
|
|
+ <el-input v-model="form.describe" placeholder="请输入描述" type="textarea" maxlength="100" show-word-limit></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+const currentForm = {
|
|
|
+ id:null,
|
|
|
+ position:null,
|
|
|
+ tenant:null,
|
|
|
+ tenantName:null,
|
|
|
+ ismore:null,
|
|
|
+ role:[],
|
|
|
+ describe:null
|
|
|
+}
|
|
|
+export default {
|
|
|
+ components: {},
|
|
|
+ mixins:[],
|
|
|
+ props: {
|
|
|
+ id:"",
|
|
|
+ model:{
|
|
|
+ type:String,
|
|
|
+ default:"add"
|
|
|
+ },
|
|
|
+ },
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ btnLoading: false,
|
|
|
+ disabled:false,
|
|
|
+ // 表单参数
|
|
|
+ form: {
|
|
|
+ ismore:0,
|
|
|
+ },
|
|
|
+ lastName:'',
|
|
|
+ rules: {
|
|
|
+ department: [{ required: true, message: '请选择所属部门', trigger: 'change' },],
|
|
|
+ position: [{ required: true, message: '请输入职位名称', trigger: 'blur' },],
|
|
|
+ ismore: [{ required: true, message: '请选择', trigger: 'change' },],
|
|
|
+ tenant:[{ required: true, message: "请选择", trigger: "change" }],
|
|
|
+ },
|
|
|
+ };
|
|
|
+ },
|
|
|
+ watch: {
|
|
|
+ id(){
|
|
|
+ if(this.$route.path != '/administrator/editPosition'){
|
|
|
+ return
|
|
|
+ }
|
|
|
+ this.init()
|
|
|
+ },
|
|
|
+ },
|
|
|
+ computed: {
|
|
|
+ userinfo() {
|
|
|
+ return this.$store.state.admin.userinfo
|
|
|
+ }
|
|
|
+ },
|
|
|
+ created() {},
|
|
|
+ mounted() {
|
|
|
+ this.init()
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ //初始化当前页面
|
|
|
+ async init(){
|
|
|
+ if(this.model == 'add'){
|
|
|
+ this.resetForm()
|
|
|
+ }else if(this.model == 'edit'){
|
|
|
+ await this.getById();
|
|
|
+ }
|
|
|
+ },
|
|
|
+ getById(){
|
|
|
+ if(!this.id){
|
|
|
+ this.$message.error('编辑缺少参数')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ var params = {
|
|
|
+ id: this.id,
|
|
|
+ };
|
|
|
+ this.$api.queryPositionInfo(params).then(response=>{
|
|
|
+ if(response.code == 200){
|
|
|
+ this.form = response.data;
|
|
|
+ }
|
|
|
+ }).catch(error=>{
|
|
|
+ this.resetForm()
|
|
|
+ })
|
|
|
+ },
|
|
|
+ //重置表单
|
|
|
+ resetForm(){
|
|
|
+ this.form = Object.assign({}, currentForm)
|
|
|
+ this.$refs['form'].resetFields();
|
|
|
+ },
|
|
|
+ /** 提交按钮 */
|
|
|
+ submitForm: function() {
|
|
|
+ this.$refs['form'].validate((valid) => {
|
|
|
+ if (valid) {
|
|
|
+ this.btnLoading = true
|
|
|
+ var a = '添加'
|
|
|
+ var api = 'addPosition'
|
|
|
+ if(this.model == "edit"){
|
|
|
+ a = '编辑'
|
|
|
+ api = 'updatePosition'
|
|
|
+ }
|
|
|
+ this.$api[api](this.form).then(response => {
|
|
|
+ if (response.code === 200) {
|
|
|
+ this.btnLoading = false
|
|
|
+ this.$message.success( a + '成功');
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .catch(error => {
|
|
|
+ this.$message.error(a + '失败')
|
|
|
+ this.btnLoading = false
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
+ getTenantList(){
|
|
|
+ this.$api.getAllTenantList().then(response => {
|
|
|
+ this.tenantList = response.data
|
|
|
+ })
|
|
|
+ },
|
|
|
+ },
|
|
|
+};
|
|
|
+</script>
|
|
|
+<style lang="scss">
|
|
|
+.form_center {
|
|
|
+ width: 800px;
|
|
|
+ margin: 30px auto;
|
|
|
+}
|
|
|
+
|
|
|
+.button-container {
|
|
|
+ max-width: 1200px;
|
|
|
+ display: flex;
|
|
|
+ justify-content:flex-end;
|
|
|
+ margin: 10px auto;
|
|
|
+ position:sticky;
|
|
|
+ top:10px,
|
|
|
+}
|
|
|
+.form_item_title{
|
|
|
+ color: black;
|
|
|
+ font-weight: bold;
|
|
|
+ font-size: 14px;
|
|
|
+ padding: 5px 0;
|
|
|
+ border-bottom: 1px solid white;
|
|
|
+}
|
|
|
+</style>
|