mirror of
				https://gitee.com/hhyykk/ipms-sjy.git
				synced 2025-11-04 04:08:43 +08:00 
			
		
		
		
	BPM Form 表单的完善
This commit is contained in:
		@@ -32,7 +32,7 @@
 | 
			
		||||
            </div>
 | 
			
		||||
          </draggable>
 | 
			
		||||
          <div class="components-title">
 | 
			
		||||
            <svg-icon icon-class="component" /> 布局型组件
 | 
			
		||||
            <svg-icon icon-class="component" />布局型组件
 | 
			
		||||
          </div>
 | 
			
		||||
          <draggable class="components-draggable" :list="layoutComponents" :group="{ name: 'componentsGroup', pull: 'clone', put: false }"
 | 
			
		||||
                     :clone="cloneComponent" draggable=".components-item" :sort="false" @end="onEnd">
 | 
			
		||||
@@ -66,11 +66,10 @@
 | 
			
		||||
    <div class="center-board">
 | 
			
		||||
      <!-- 上面:操作按钮 -->
 | 
			
		||||
      <div class="action-bar">
 | 
			
		||||
        <el-button class="delete-btn" icon="el-icon-delete" type="text" @click="empty">
 | 
			
		||||
          清空
 | 
			
		||||
        </el-button>
 | 
			
		||||
        <el-button icon="el-icon-check" type="text" @click="save">保存</el-button>
 | 
			
		||||
        <el-button class="delete-btn" icon="el-icon-delete" type="text" @click="empty">清空</el-button>
 | 
			
		||||
      </div>
 | 
			
		||||
      <!-- 中间,表单 -->
 | 
			
		||||
      <!-- 中间,表单项 -->
 | 
			
		||||
      <el-scrollbar class="center-scrollbar">
 | 
			
		||||
        <el-row class="center-board-row" :gutter="formConf.gutter">
 | 
			
		||||
          <el-form :size="formConf.size" :label-position="formConf.labelPosition" :disabled="formConf.disabled"
 | 
			
		||||
@@ -102,6 +101,8 @@ import drawingDefalut from '@/utils/generator/drawingDefalut'
 | 
			
		||||
// import logo from '@/assets/logo/logo.png'
 | 
			
		||||
import DraggableItem from './../../tool/build/DraggableItem'
 | 
			
		||||
import RightPanel from './../../tool/build/RightPanel'
 | 
			
		||||
import {createForm, getForm, updateForm} from "@/api/bpm/form";
 | 
			
		||||
import {SysCommonStatusEnum} from "@/utils/constants";
 | 
			
		||||
 | 
			
		||||
// const emptyActiveData = { style: {}, autosize: {} }
 | 
			
		||||
let oldActiveId
 | 
			
		||||
@@ -123,22 +124,25 @@ export default {
 | 
			
		||||
      selectComponents,
 | 
			
		||||
      layoutComponents,
 | 
			
		||||
      labelWidth: 100,
 | 
			
		||||
      drawingList: drawingDefalut, // 表单项的数组
 | 
			
		||||
      drawingData: {},
 | 
			
		||||
      activeId: drawingDefalut[0].formId,
 | 
			
		||||
 | 
			
		||||
      drawingData: {}, // 生成后的表单数据
 | 
			
		||||
 | 
			
		||||
      drawingList: [], // 表单项的数组
 | 
			
		||||
      activeId: 0,
 | 
			
		||||
      activeData: {},
 | 
			
		||||
      // drawerVisible: false,
 | 
			
		||||
      // formData: {},
 | 
			
		||||
      // dialogVisible: false,
 | 
			
		||||
      // showFileName: false,
 | 
			
		||||
      activeData: drawingDefalut[0],
 | 
			
		||||
 | 
			
		||||
      // 表单参数
 | 
			
		||||
      form: {},
 | 
			
		||||
      form: {
 | 
			
		||||
        status: SysCommonStatusEnum.ENABLE,
 | 
			
		||||
      },
 | 
			
		||||
      // 表单校验
 | 
			
		||||
      rules: {
 | 
			
		||||
        name: [{ required: true, message: "表单名不能为空", trigger: "blur" }],
 | 
			
		||||
        status: [{ required: true, message: "开启状态不能为空", trigger: "blur" }],
 | 
			
		||||
        fields: [{ required: true, message: "表单配置不能为空", trigger: "blur" }],
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
@@ -161,6 +165,23 @@ export default {
 | 
			
		||||
      immediate: true
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
  created() {
 | 
			
		||||
    // 读取表单配置
 | 
			
		||||
    const formId = this.$route.query && this.$route.query.formId
 | 
			
		||||
    if (formId) {
 | 
			
		||||
      getForm(formId).then(response => {
 | 
			
		||||
        const data = response.data
 | 
			
		||||
        this.form = {
 | 
			
		||||
          id: data.id,
 | 
			
		||||
          name: data.name,
 | 
			
		||||
          status: data.status,
 | 
			
		||||
          remark: data.remark
 | 
			
		||||
        }
 | 
			
		||||
        this.formConf = JSON.parse(data.conf)
 | 
			
		||||
        this.drawingList = this.decodeFields(data.fields)
 | 
			
		||||
      });
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
  methods: {
 | 
			
		||||
    activeFormItem(element) {
 | 
			
		||||
      this.activeData = element
 | 
			
		||||
@@ -202,6 +223,53 @@ export default {
 | 
			
		||||
        ...this.formConf
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
    save() {
 | 
			
		||||
      // this.AssembleFormData()
 | 
			
		||||
      // console.log(this.formData)
 | 
			
		||||
      this.$refs["form"].validate(valid => {
 | 
			
		||||
        if (!valid) {
 | 
			
		||||
          return;
 | 
			
		||||
        }
 | 
			
		||||
        const form = {
 | 
			
		||||
          conf: JSON.stringify(this.formConf), // 表单配置
 | 
			
		||||
          // fields: JSON.stringify(this.drawingList), // 表单项的数组
 | 
			
		||||
          fields: this.encodeFields(), // 表单项的数组
 | 
			
		||||
          ...this.form // 表单名等
 | 
			
		||||
        }
 | 
			
		||||
        // 修改的提交
 | 
			
		||||
        if (this.form.id != null) {
 | 
			
		||||
          updateForm(form).then(response => {
 | 
			
		||||
            this.msgSuccess("修改成功");
 | 
			
		||||
            this.close()
 | 
			
		||||
          });
 | 
			
		||||
          return;
 | 
			
		||||
        }
 | 
			
		||||
        // 添加的提交
 | 
			
		||||
        createForm(form).then(response => {
 | 
			
		||||
          this.msgSuccess("新增成功");
 | 
			
		||||
          this.close()
 | 
			
		||||
        });
 | 
			
		||||
      });
 | 
			
		||||
    },
 | 
			
		||||
    /** 关闭按钮 */
 | 
			
		||||
    close() {
 | 
			
		||||
      this.$store.dispatch("tagsView/delView", this.$route);
 | 
			
		||||
      this.$router.push({ path: "/bpm/manager/form", query: { t: Date.now()}})
 | 
			
		||||
    },
 | 
			
		||||
    encodeFields() {
 | 
			
		||||
      const fields = []
 | 
			
		||||
      this.drawingList.forEach(item => {
 | 
			
		||||
        fields.push(JSON.stringify(item))
 | 
			
		||||
      })
 | 
			
		||||
      return fields
 | 
			
		||||
    },
 | 
			
		||||
    decodeFields(fields) {
 | 
			
		||||
      const drawingList = []
 | 
			
		||||
      fields.forEach(item => {
 | 
			
		||||
        drawingList.push(JSON.parse(item))
 | 
			
		||||
      })
 | 
			
		||||
      return drawingList
 | 
			
		||||
    },
 | 
			
		||||
    empty() {
 | 
			
		||||
      this.$confirm('确定要清空所有组件吗?', '提示', { type: 'warning' }).then(
 | 
			
		||||
        () => {
 | 
			
		||||
 
 | 
			
		||||
@@ -30,7 +30,6 @@
 | 
			
		||||
          <span>{{ getDictDataLabel(DICT_TYPE.SYS_COMMON_STATUS, scope.row.status) }}</span>
 | 
			
		||||
        </template>
 | 
			
		||||
      </el-table-column>
 | 
			
		||||
      <el-table-column label="表单配置" align="center" prop="fields" />
 | 
			
		||||
      <el-table-column label="备注" align="center" prop="remark" />
 | 
			
		||||
      <el-table-column label="创建时间" align="center" prop="createTime" width="180">
 | 
			
		||||
        <template slot-scope="scope">
 | 
			
		||||
@@ -49,36 +48,11 @@
 | 
			
		||||
    <!-- 分页组件 -->
 | 
			
		||||
    <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
 | 
			
		||||
                @pagination="getList"/>
 | 
			
		||||
 | 
			
		||||
    <!-- 对话框(添加 / 修改) -->
 | 
			
		||||
    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
 | 
			
		||||
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
 | 
			
		||||
        <el-form-item label="表单名" prop="name">
 | 
			
		||||
          <el-input v-model="form.name" placeholder="请输入表单名" />
 | 
			
		||||
        </el-form-item>
 | 
			
		||||
        <el-form-item label="开启状态" prop="status">
 | 
			
		||||
          <el-radio-group v-model="form.status">
 | 
			
		||||
            <el-radio v-for="dict in this.getDictDatas(DICT_TYPE.SYS_COMMON_STATUS)"
 | 
			
		||||
                      :key="dict.value" :label="parseInt(dict.value)">{{dict.label}}</el-radio>
 | 
			
		||||
          </el-radio-group>
 | 
			
		||||
        </el-form-item>
 | 
			
		||||
        <el-form-item label="表单配置" prop="fields">
 | 
			
		||||
          <el-input v-model="form.fields" placeholder="请输入表单配置" />
 | 
			
		||||
        </el-form-item>
 | 
			
		||||
        <el-form-item label="备注" prop="remark">
 | 
			
		||||
          <el-input v-model="form.remark" placeholder="请输入备注" />
 | 
			
		||||
        </el-form-item>
 | 
			
		||||
      </el-form>
 | 
			
		||||
      <div slot="footer" class="dialog-footer">
 | 
			
		||||
        <el-button type="primary" @click="submitForm">确 定</el-button>
 | 
			
		||||
        <el-button @click="cancel">取 消</el-button>
 | 
			
		||||
      </div>
 | 
			
		||||
    </el-dialog>
 | 
			
		||||
  </div>
 | 
			
		||||
</template>
 | 
			
		||||
 | 
			
		||||
<script>
 | 
			
		||||
import { createForm, updateForm, deleteForm, getForm, getFormPage, exportFormExcel } from "@/api/bpm/form";
 | 
			
		||||
import { deleteForm, getFormPage} from "@/api/bpm/form";
 | 
			
		||||
 | 
			
		||||
export default {
 | 
			
		||||
  name: "Form",
 | 
			
		||||
@@ -94,24 +68,12 @@ export default {
 | 
			
		||||
      total: 0,
 | 
			
		||||
      // 工作流的列表
 | 
			
		||||
      list: [],
 | 
			
		||||
      // 弹出层标题
 | 
			
		||||
      title: "",
 | 
			
		||||
      // 是否显示弹出层
 | 
			
		||||
      open: false,
 | 
			
		||||
      // 查询参数
 | 
			
		||||
      queryParams: {
 | 
			
		||||
        pageNo: 1,
 | 
			
		||||
        pageSize: 10,
 | 
			
		||||
        name: null,
 | 
			
		||||
      },
 | 
			
		||||
      // 表单参数
 | 
			
		||||
      form: {},
 | 
			
		||||
      // 表单校验
 | 
			
		||||
      rules: {
 | 
			
		||||
        name: [{ required: true, message: "表单名不能为空", trigger: "blur" }],
 | 
			
		||||
        status: [{ required: true, message: "开启状态不能为空", trigger: "blur" }],
 | 
			
		||||
        fields: [{ required: true, message: "表单配置不能为空", trigger: "blur" }],
 | 
			
		||||
      }
 | 
			
		||||
    };
 | 
			
		||||
  },
 | 
			
		||||
  created() {
 | 
			
		||||
@@ -130,22 +92,6 @@ export default {
 | 
			
		||||
        this.loading = false;
 | 
			
		||||
      });
 | 
			
		||||
    },
 | 
			
		||||
    /** 取消按钮 */
 | 
			
		||||
    cancel() {
 | 
			
		||||
      this.open = false;
 | 
			
		||||
      this.reset();
 | 
			
		||||
    },
 | 
			
		||||
    /** 表单重置 */
 | 
			
		||||
    reset() {
 | 
			
		||||
      this.form = {
 | 
			
		||||
        id: undefined,
 | 
			
		||||
        name: undefined,
 | 
			
		||||
        status: undefined,
 | 
			
		||||
        fields: undefined,
 | 
			
		||||
        remark: undefined,
 | 
			
		||||
      };
 | 
			
		||||
      this.resetForm("form");
 | 
			
		||||
    },
 | 
			
		||||
    /** 搜索按钮操作 */
 | 
			
		||||
    handleQuery() {
 | 
			
		||||
      this.queryParams.pageNo = 1;
 | 
			
		||||
@@ -158,41 +104,17 @@ export default {
 | 
			
		||||
    },
 | 
			
		||||
    /** 新增按钮操作 */
 | 
			
		||||
    handleAdd() {
 | 
			
		||||
      this.reset();
 | 
			
		||||
      this.open = true;
 | 
			
		||||
      this.title = "添加工作流的";
 | 
			
		||||
      this.$router.push({
 | 
			
		||||
        path:"/bpm/manager/form/edit"
 | 
			
		||||
      });
 | 
			
		||||
    },
 | 
			
		||||
    /** 修改按钮操作 */
 | 
			
		||||
    handleUpdate(row) {
 | 
			
		||||
      this.reset();
 | 
			
		||||
      const id = row.id;
 | 
			
		||||
      getForm(id).then(response => {
 | 
			
		||||
        this.form = response.data;
 | 
			
		||||
        this.open = true;
 | 
			
		||||
        this.title = "修改工作流的";
 | 
			
		||||
      });
 | 
			
		||||
    },
 | 
			
		||||
    /** 提交按钮 */
 | 
			
		||||
    submitForm() {
 | 
			
		||||
      this.$refs["form"].validate(valid => {
 | 
			
		||||
        if (!valid) {
 | 
			
		||||
          return;
 | 
			
		||||
      this.$router.push({
 | 
			
		||||
        path:"/bpm/manager/form/edit",
 | 
			
		||||
        query:{
 | 
			
		||||
          formId: row.id
 | 
			
		||||
        }
 | 
			
		||||
        // 修改的提交
 | 
			
		||||
        if (this.form.id != null) {
 | 
			
		||||
          updateForm(this.form).then(response => {
 | 
			
		||||
            this.msgSuccess("修改成功");
 | 
			
		||||
            this.open = false;
 | 
			
		||||
            this.getList();
 | 
			
		||||
          });
 | 
			
		||||
          return;
 | 
			
		||||
        }
 | 
			
		||||
        // 添加的提交
 | 
			
		||||
        createForm(this.form).then(response => {
 | 
			
		||||
          this.msgSuccess("新增成功");
 | 
			
		||||
          this.open = false;
 | 
			
		||||
          this.getList();
 | 
			
		||||
        });
 | 
			
		||||
      });
 | 
			
		||||
    },
 | 
			
		||||
    /** 删除按钮操作 */
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user