祖安之光
10 天以前 7df5ffa1db94e3225bd16ef2d0d8ef0e02084951
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
<template>
  <div class="notice">
    <el-dialog
        v-model="dialogVisible"
        :title="state.title"
        width="700px"
        :before-close="handleClose"
        :close-on-press-escape="false"
        :close-on-click-modal="false"
    >
      <el-form :model="state.form" size="default" ref="superRef" :rules="state.formRules" label-width="150px" >
        <el-form-item label="条款编码:" prop="clauseNum">
          <el-input v-model.trim="state.form.clauseNum" :disabled="state.title =='查看'" placeholder="条款编码"></el-input>
        </el-form-item>
        <el-form-item label="条款内容:" prop="name">
          <el-input v-model.trim="state.form.name" :disabled="state.title =='查看'" placeholder="条款内容"></el-input>
        </el-form-item>
      </el-form>
      <template #footer v-if="state.title !='查看'">
        <span class="dialog-footer">
            <el-button @click="handleClose" size="default">取 消</el-button>
            <el-button type="primary"  @click="onSubmit" size="default" v-preReClick>确认</el-button>
        </span>
      </template>
    </el-dialog>
  </div>
</template>
<script setup>
import {reactive, ref, toRefs, defineEmits, nextTick, onMounted} from 'vue'
import {ElMessage} from "element-plus";
import {addUser, editUser, getUserById, resetPwd} from "@/api/onlineEducation/user"
import {Base64} from "js-base64"
import {getCompany} from "@/api/onlineEducation/company";
import {updateInfoPlatforms, updateSysClause} from "@/api/staffManage/staff";
 
const emit = defineEmits(["getList"]);
const dialogVisible = ref(false)
const superRef = ref()
const state = reactive({
  title: '',
  form: {
    id: null,
    clauseNum: '',
    name: '',
    companyId: null
  },
  formRules:{
    clauseNum: [{ required: true, message: '请输入条款编码', trigger: 'blur' }],
    name: [{ required: true, message: '请输入条款内容', trigger: 'blur' }]
  }
})
onMounted(() => {
 
});
 
const openDialog = async (type, value,companyId) => {
  state.title = type === 'add' ? '新增' : type ==='edit' ? '编辑' : '查看'
  state.form.companyId = companyId
  if(state.title == '编辑'||state.title == '查看'){
    Object.keys(state.form).forEach(key => {
      if (key in value) {
        state.form[key] = value[key]
      }
    })
  }
  dialogVisible.value = true
}
 
 
const onSubmit = async () => {
  const valid = await superRef.value.validate();
  if(valid){
    let data = {}
    if(state.title == '新增'){
      data = {
        clauseNum: state.form.clauseNum,
        name: state.form.name,
        companyId: state.form.companyId
      }
    }else{
      data = state.form
    }
      const res = await updateSysClause(data)
      if(res.code == 200){
        ElMessage.success(res.message)
        emit('getList')
        handleClose()
        dialogVisible.value = false;
      }else{
        ElMessage.warning(res.message)
      }
 
  }
}
 
const handleClose = () => {
  state.form = {
    id: null,
    clauseNum: '',
    name: '',
    companyId: null
  }
  superRef.value.clearValidate();
  superRef.value.resetFields()
  dialogVisible.value = false;
}
 
defineExpose({
  openDialog
});
 
</script>
 
<style scoped lang="scss">
.notice{
  :deep(.el-form .el-form-item__label) {
    font-size: 15px;
  }
  .file {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
  }
}
</style>