|
@@ -0,0 +1,156 @@
|
|
|
|
+<template>
|
|
|
|
+ <el-dialog
|
|
|
|
+ class="regist-flow-dialog"
|
|
|
|
+ :visible.sync="modalIsShow"
|
|
|
|
+ title="新增流程"
|
|
|
|
+ top="10vh"
|
|
|
|
+ width="600px"
|
|
|
|
+ :close-on-click-modal="false"
|
|
|
|
+ :close-on-press-escape="false"
|
|
|
|
+ append-to-body
|
|
|
|
+ @open="visibleChange"
|
|
|
|
+ >
|
|
|
|
+ <div class="part-box part-box-pad part-box-border">
|
|
|
|
+ <!-- apply-customer -->
|
|
|
|
+ <el-form
|
|
|
|
+ ref="modalFormComp"
|
|
|
|
+ :model="modalForm"
|
|
|
|
+ :rules="rules"
|
|
|
|
+ label-width="90px"
|
|
|
|
+ >
|
|
|
|
+ <el-form-item prop="name" label="名称:">
|
|
|
|
+ <el-input
|
|
|
|
+ style="width:300px"
|
|
|
|
+ v-model.trim="modalForm.name"
|
|
|
|
+ placeholder="请输入名称"
|
|
|
|
+ ></el-input>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <el-form-item label="是否发布:">
|
|
|
|
+ <el-switch
|
|
|
|
+ v-model="modalForm.publish"
|
|
|
|
+ active-color="#23c4b9"
|
|
|
|
+ inactive-color="#dcdfe6"
|
|
|
|
+ >
|
|
|
|
+ </el-switch>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <el-form-item prop="uploadData" label="上传文件:">
|
|
|
|
+ <upload-fetch-file
|
|
|
|
+ input-width="300px"
|
|
|
|
+ :format="format"
|
|
|
|
+ @valid-change="validChange"
|
|
|
|
+ @file-change="fileChange"
|
|
|
|
+ ref="UploadFetchFile"
|
|
|
|
+ ></upload-fetch-file>
|
|
|
|
+ <p class="tips-info">
|
|
|
|
+ 上传的文件只支持{{ format.join(",") }},大小不超过2M
|
|
|
|
+ </p>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ </el-form>
|
|
|
|
+ </div>
|
|
|
|
+ <div slot="footer">
|
|
|
|
+ <el-button type="primary" :disabled="isSubmit" @click="confirm"
|
|
|
|
+ >确定</el-button
|
|
|
|
+ >
|
|
|
|
+ <el-button type="danger" @click="cancel" plain>返回</el-button>
|
|
|
|
+ </div>
|
|
|
|
+ </el-dialog>
|
|
|
|
+</template>
|
|
|
|
+
|
|
|
|
+<script>
|
|
|
|
+import UploadFetchFile from "@/components/UploadFetchFile";
|
|
|
|
+import { flowRegister } from "../api";
|
|
|
|
+
|
|
|
|
+export default {
|
|
|
|
+ name: "regist-flow-dialog-view",
|
|
|
|
+ props: {
|
|
|
|
+ data: {
|
|
|
|
+ type: Object,
|
|
|
|
+ default() {
|
|
|
|
+ return {};
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ components: { UploadFetchFile },
|
|
|
|
+ data() {
|
|
|
|
+ return {
|
|
|
|
+ modalIsShow: false,
|
|
|
|
+ isSubmit: false,
|
|
|
|
+ modalForm: {
|
|
|
|
+ name: "",
|
|
|
|
+ publish: false
|
|
|
|
+ },
|
|
|
|
+ rules: {
|
|
|
|
+ name: [
|
|
|
|
+ {
|
|
|
|
+ required: true,
|
|
|
|
+ message: "请输入名称",
|
|
|
|
+ trigger: "change"
|
|
|
|
+ }
|
|
|
|
+ ],
|
|
|
|
+ uploadData: [
|
|
|
|
+ {
|
|
|
|
+ required: true,
|
|
|
|
+ validator: (rule, value, callback) => {
|
|
|
|
+ if (this.uploadData) {
|
|
|
|
+ callback();
|
|
|
|
+ } else {
|
|
|
|
+ return callback(new Error(`请选择合适的文件`));
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ trigger: "change"
|
|
|
|
+ }
|
|
|
|
+ ]
|
|
|
|
+ },
|
|
|
|
+ // upload
|
|
|
|
+ format: ["bpmn"],
|
|
|
|
+ maxSize: 2 * 1024 * 1024,
|
|
|
|
+ uploadData: null
|
|
|
|
+ };
|
|
|
|
+ },
|
|
|
|
+ methods: {
|
|
|
|
+ visibleChange() {
|
|
|
|
+ this.modalForm = { name: "", publish: false };
|
|
|
|
+ },
|
|
|
|
+ cancel() {
|
|
|
|
+ this.modalIsShow = false;
|
|
|
|
+ },
|
|
|
|
+ open() {
|
|
|
|
+ this.modalIsShow = true;
|
|
|
|
+ },
|
|
|
|
+ validChange(result) {
|
|
|
|
+ if (!result.success) {
|
|
|
|
+ this.uploadData = null;
|
|
|
|
+ this.$notify.error({ title: "错误提示", message: result.message });
|
|
|
|
+ this.$refs.modalFormComp.validateField("uploadData");
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ fileChange(data) {
|
|
|
|
+ this.uploadData = data;
|
|
|
|
+ this.$refs.modalFormComp.validateField("uploadData");
|
|
|
|
+ },
|
|
|
|
+ async confirm() {
|
|
|
|
+ const valid = await this.$refs.modalFormComp.validate().catch(() => {});
|
|
|
|
+ if (!valid) return;
|
|
|
|
+
|
|
|
|
+ if (this.isSubmit) return;
|
|
|
|
+ this.isSubmit = true;
|
|
|
|
+
|
|
|
|
+ let formData = new FormData();
|
|
|
|
+ Object.entries(this.modalForm).forEach(([k, v]) => {
|
|
|
|
+ formData.append(k, v);
|
|
|
|
+ });
|
|
|
|
+ formData.append("file", this.uploadData.file);
|
|
|
|
+
|
|
|
|
+ const data = await flowRegister(formData, {
|
|
|
|
+ md5: this.uploadData.md5
|
|
|
|
+ }).catch(() => {});
|
|
|
|
+ this.isSubmit = false;
|
|
|
|
+ if (!data) return;
|
|
|
|
+
|
|
|
|
+ this.$message.success("添加成功!");
|
|
|
|
+ this.cancel();
|
|
|
|
+ this.$emit("modified");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+};
|
|
|
|
+</script>
|