@@ -176,7 +176,7 @@ export default {
}
.jianbiase {
- width: 100px;
+ width: 120px;
height: 37px;
/* height: 25px; */
background: linear-gradient(128.13deg, rgba(82, 79, 255, 1) 0%, rgba(255, 74, 74, 1) 100%);
@@ -134,7 +134,27 @@ export const dynamicRoutes = [
]
},
-
+ {
+ path: '/system/fromModel/index',
+ component: Layout,
+ hidden: true,
+ permissions: ['system:fromModel:edit'],
+ children: [
+ path: 'fromModel/:index',
+ component: () => import('@/views/system/fromModel/index'),
+ name: 'fromModel',
+ meta: { title: '表单建模', activeMenu: '/system/fromModel/index' }
+ },
+ // {
+ // path: 'fromModel/:index',
+ // component: () => import('@/views/system/fromModel/formBuild'),
+ // name: 'fromModel',
+ // meta: { title: '表单建模', activeMenu: '/system/fromModel/formBuild' }
+ // }
+ ]
+
{
path: '/system/role-auth',
component: Layout,
@@ -233,9 +233,10 @@
<script>
import {listForm, getForm, delForm, addForm, updateForm} from "@/api/dragform/form";
+// import fromModel from '../system/fromModel/index.vue'
export default {
name: "Form",
data() {
return {
// 遮罩层
@@ -339,24 +340,19 @@ export default {
/** 新增按钮操作 */
handleAdd() {
- this.reset();
- this.open = true;
- this.title = "添加动态单";
+ this.$router.push("system/fromModel/index");
/** 修改按钮操作 */
handleUpdate(row) {
- const fId = row.fId || this.ids
- getForm(fId).then(response => {
- this.form = response.data;
- this.title = "修改动态单";
- });
+ const fId = row.fId || this.ids;
+ this.$router.push({name:"fromModel",params:{id:fId}});
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
+ console.log(this.form)
if (this.form.fId != null) {
updateForm(this.form).then(response => {
this.$modal.msgSuccess("修改成功");
@@ -181,7 +181,7 @@ export default {
// 这个是提交后端,新增接口,数据直接填写就可以了。
addSave(this.formLabelAlign).then((res) => {
console.log(res);
- // 新增成功后,操作的东西,写这里
+ // 新增成功后,操作的东西
});
} else {
console.log("error submit!!");
@@ -3,21 +3,127 @@
<k-form-design
:showHead="false"
@save="handleSave"
- @handleSave="asd"
+ @exportCode="handCode"
+ ref="kfd"
/>
</div>
</template>
+// 生成HTML的
+let codeHtmlFront = `<!DOCTYPE html>
+<html>
+<head>
+ <title>表单设计</title>
+ <meta charset="UTF-8">
+ <link rel="stylesheet" href="http://unpkg.com/k-form-design/lib/k-form-design.css">
+</head>
+<body>
+ <div class="app">
+ <k-form-build ref="KFB" @submit="handleSubmit" :value="jsonData"></k-form-build>
+ <button @click="getData">提交</button>
+ </div>
+ <script src="http://cdn.kcz66.com/vue.min.js"><\/script>
+ <script src="http://unpkg.com/k-form-design/lib/k-form-design.umd.min.js"><\/script>
+ <script>
+ let jsonData = `;
+ let codeHtmlLast = `
+ let vm = new Vue({
+ el: '.app',
+ data: {
+ jsonData
+ methods: {
+ handleSubmit(p) {
+ // 通过表单提交按钮触发,获取promise对象
+ p().then(res => {
+ // 获取数据成功
+ alert(JSON.stringify(res))
+ })
+ .catch(err => {
+ console.log(err, '校验失败')
+ getData() {
+ // 通过函数获取数据
+ this.$refs.KFB.getData().then(res => {
+ }
+ <\/script>
+</body>
+</html>`
+import { addForm ,getForm,updateForm} from "@/api/dragform/form";
+ name:'fromModel',
+ data() {
+ return {
+ fid: null,
+ };
methods: {
handleSave(values) {
- alert("111");
- console.log(values);
+ // console.log(values);
+ var jsonData = JSON.parse(values);
+ //
+ var editorHtmlJson =
+ codeHtmlFront + JSON.stringify(jsonData) + codeHtmlLast;
+ console.log(this.fid)
+ if(!this.fid){
+ addForm({
+ dfName:'1',
+ dfNickname:'1',
+ dfVueTemplate:values,
+ dfHtmlTemplate:editorHtmlJson.toString(),
+ dfFormSql:'',
+ dfNodeId:'',
+ dfDatabase:'',
+ dfTableName:'',
+ }).then((res)=>{
+ console.log(res);
+ }else{
+ updateForm({
+ fId:this.fid
+ console.log(res)
+ this.$message(res.msg)
- asd(row){
- console.log(row)
- }
+ mounted() {
+ const fid = this.$route.params.id;
+ if(!fid)return;
+ this.fid = fid;
+ getForm(fid).then(response => {
+ console.log(response)
+ const jsonData = JSON.parse(response.data.dfVueTemplate)
+ this.$refs.kfd.handleSetData(jsonData)
+ });
};
</script>
@@ -91,7 +91,7 @@ export default {
-<style lang="scss" >
+<style lang="scss">
.x6-widget-snapline-vertical {
border-right-color: #ff4e50 !important;