| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141 |
- <!-- 用户编辑弹窗 -->
- <template>
- <el-dialog
- class="ele-dialog-form"
- :title="title"
- :visible.sync="visible"
- :before-close="handleClose"
- :close-on-click-modal="false"
- :close-on-press-escape="false"
- width="450px"
- >
- <el-form ref="form" :model="form" :rules="rules" label-width="50px">
- <el-row>
- <el-col :span="24">
- <el-form-item
- label="名称"
- prop="name">
- <el-input
- clearable
- :maxlength="20"
- v-model="form.name"
- placeholder="请输入分类名"
- />
- </el-form-item>
- </el-col>
- <el-col :span="24">
- <el-form-item
- label="备注"
- prop="remark">
- <el-input
- type="textarea"
- clearable
- :maxlength="20"
- v-model="form.remark"
- />
- </el-form-item>
- </el-col>
- </el-row>
- </el-form>
- <template v-slot:footer>
- <el-button type="primary" :loading="loading" @click="save">保存</el-button>
- <el-button @click="handleClose">取消</el-button>
- </template>
- </el-dialog>
- </template>
- <script>
- import {getProcessTypeGetByIdAPI, processTypeSaveAPI, processTypeUpdateAPI} from "@/api/bpm/processClass";
- import {deepClone} from "@/utils";
- export default {
- data() {
- const defaultForm = function () {
- return {
- id: '',
- name: '',
- remark: '',
- };
- };
- return {
- defaultForm,
- // 表单数据
- form: {...defaultForm()},
- // 表单验证规则
- rules: {
- name: [{required: true, message: '请输入名称', trigger: 'blur'}],
- },
- visible: false,
- type: '', // add/edit
- loading: false,
- };
- },
- computed: {
- title() {
- switch (this.type) {
- case 'add':
- return '新增';
- break;
- case 'edit':
- return '编辑';
- break;
- default:
- break;
- }
- }
- },
- methods: {
- open(type, row) {
- this.type = type;
- this.visible = true;
- if (type == 'edit') {
- this.getInfo(row.id)
- }
- },
- async getInfo(id) {
- const res = await getProcessTypeGetByIdAPI(id)
- this.form = deepClone(res)
- },
- /* 保存编辑 */
- save() {
- this.$refs.form.validate((valid) => {
- if (!valid) {
- return false;
- }
- this.loading = true;
- if (this.type == 'add') {
- delete this.form.id;
- }
- let API = this.type == 'add' ? processTypeSaveAPI : processTypeUpdateAPI
- API(this.form)
- .then((msg) => {
- this.loading = false;
- this.$message.success('操作成功');
- this.handleClose();
- this.$emit('done');
- })
- .catch((e) => {
- this.loading = false;
- this.$message.error(e.message);
- });
- });
- },
- restForm() {
- this.form = {...this.defaultForm()};
- this.$nextTick(() => {
- this.$refs.form.clearValidate();
- });
- },
- handleClose() {
- this.restForm();
- this.visible = false;
- },
- }
- };
- </script>
- <style lang="scss" scoped>
- </style>
|