diff --git a/src/api/flow/index.js b/src/api/flow/index.js new file mode 100644 index 0000000..b7ceace --- /dev/null +++ b/src/api/flow/index.js @@ -0,0 +1,17 @@ +import request from '@/utils/request' + +export function flow(isLoading=false) { + return request({ + method: 'get', + url: '/api/oa/flow', + isLoading + }) +} + +export function preConfig(custom_model_id,isLoading=false) { + return request({ + method: 'get', + url: `/api/oa/flow/create-pre/${custom_model_id}`, + isLoading + }) +} diff --git a/src/main.js b/src/main.js index 803b1a7..72bc58c 100644 --- a/src/main.js +++ b/src/main.js @@ -47,6 +47,7 @@ Vue.config.productionTip = false //vant import Vant from 'vant' +import 'vant/lib/index.css'; Vue.use(Vant) //moment diff --git a/src/router/index.js b/src/router/index.js index 12d6498..7a0e6e0 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -61,10 +61,15 @@ export const constantRoutes = [ redirect: '/flow/create', meta: { title: '流程', icon: 'tree' }, children: [{ + path: 'index', + name: 'flowIndex', + component: () => import('@/views/flow/index.vue'), + meta: { title: '流程创建', icon: 'tree' } + },{ path: 'create', name: 'create', component: () => import('@/views/flow/create'), - meta: { title: '流程创建', icon: 'tree' } + hidden: true }] } @@ -78,7 +83,7 @@ export const asyncRoutes = [ const createRouter = () => new Router({ // mode: 'history', // require service support scrollBehavior: () => ({ y: 0 }), - routes: constantRoutes + routes: constantRoutes, }) const router = createRouter() diff --git a/src/utils/formBuilder.js b/src/utils/formBuilder.js index 77f3722..4c1fcee 100644 --- a/src/utils/formBuilder.js +++ b/src/utils/formBuilder.js @@ -2,19 +2,21 @@ import formBuilderMap from './formBuilderMap' import { CreateElement } from 'vue' import moment from 'moment' import { getToken } from "@/utils/auth"; +import {deepCopy} from "@/utils/index"; /** * @param {String} device 'desktop' or 'mobile' * @param {Object} info field参数 * @param {CreateElement} h + * @param {Object} pForm 父级表单对象 **/ -export default function (device, info,h ) { +export default function formBuilder (device, info,h,pForm) { let formItem; if (device === 'desktop') { switch (info.type) { case 'text': formItem = h(formBuilderMap(device).get(info.type),{ props: { - value: this.form[info.name], + value: pForm ? pForm[info.name] : this.form[info.name], clearable: true, placeholder: info.help_text }, @@ -23,7 +25,7 @@ export default function (device, info,h ) { }, on: { input: e => { - this.form[info.name] = e + pForm ? this.$set(pForm,info.name,e) : this.$set(this.form,info.name,e) } } }) @@ -35,7 +37,7 @@ export default function (device, info,h ) { autosize: { minRows: 2 }, - value: this.form[info.name], + value: pForm ? pForm[info.name] : this.form[info.name], clearable: true, placeholder: info.help_text }, @@ -44,7 +46,7 @@ export default function (device, info,h ) { }, on: { input: e => { - this.form[info.name] = e + pForm ? this.$set(pForm,info.name,e) : this.$set(this.form,info.name,e) } } }) @@ -55,7 +57,7 @@ export default function (device, info,h ) { type: 'date', 'value-format': 'yyyy-MM-dd', format: 'yyyy年MM月dd日', - value: this.form[info.name], + value: pForm ? pForm[info.name] : this.form[info.name], clearable: true, placeholder: info.help_text, 'picker-options': { @@ -114,7 +116,7 @@ export default function (device, info,h ) { }, on: { input: e => { - this.$set(this.form,info.name,e) + pForm ? this.$set(pForm,info.name,e) : this.$set(this.form,info.name,e) } } }) @@ -125,7 +127,7 @@ export default function (device, info,h ) { type: 'datetime', 'value-format': 'yyyy-MM-dd', format: 'yyyy年MM月dd日', - value: this.form[info.name], + value: pForm ? pForm[info.name] : this.form[info.name], clearable: true, placeholder: info.help_text, 'picker-options': { @@ -184,7 +186,7 @@ export default function (device, info,h ) { }, on: { input: e => { - this.$set(this.form,info.name,e) + pForm ? this.$set(pForm,info.name,e) : this.$set(this.form,info.name,e) } } }) @@ -192,7 +194,7 @@ export default function (device, info,h ) { case 'select': formItem = h(formBuilderMap(device).get(info.type),{ props: { - value: this.form[info.name], + value: pForm ? pForm[info.name] : this.form[info.name], clearable: true, placeholder: info.help_text }, @@ -201,7 +203,7 @@ export default function (device, info,h ) { }, on: { input: e => { - this.$set(this.form,info.name,e) + pForm ? this.$set(pForm,info.name,e) : this.$set(this.form,info.name,e) } } },[1,2,3].map(option => ( @@ -216,14 +218,14 @@ export default function (device, info,h ) { case 'radio': formItem = h(formBuilderMap(device).get(info.type),{ props: { - value: this.form[info.name], + value: pForm ? pForm[info.name] : this.form[info.name], }, attrs: { placeholder: info.help_text }, on: { input: e => { - this.$set(this.form,info.name,e) + pForm ? this.$set(pForm,info.name,e) : this.$set(this.form,info.name,e) } } },[1,2,3].map(option => ( @@ -354,7 +356,7 @@ export default function (device, info,h ) { type: 'primary' }, attrs: { - href: this.form[info.name], + href: pForm ? pForm[info.name] : this.form[info.name], target: "_blank" } },info.label) @@ -366,7 +368,7 @@ export default function (device, info,h ) { case 'choice': formItem = h(formBuilderMap(device).get(info.type),{ props: { - value: this.form[info.name], + value: pForm ? pForm[info.name] : this.form[info.name], clearable: true, placeholder: info.help_text }, @@ -375,7 +377,7 @@ export default function (device, info,h ) { }, on: { input: e => { - this.$set(this.form,info.name,e) + pForm ? this.$set(pForm,info.name,e) : this.$set(this.form,info.name,e) } } },[1,2,3].map(option => ( @@ -390,7 +392,7 @@ export default function (device, info,h ) { case 'choices': formItem = h(formBuilderMap(device).get(info.type),{ props: { - value: this.form[info.name], + value: pForm ? pForm[info.name] : this.form[info.name], clearable: true, placeholder: info.help_text, multiple: true @@ -400,7 +402,7 @@ export default function (device, info,h ) { }, on: { input: e => { - this.$set(this.form,info.name,e) + pForm ? this.$set(pForm,info.name,e) : this.$set(this.form,info.name,e) } } },[1,2,3].map(option => ( @@ -412,6 +414,78 @@ export default function (device, info,h ) { }) ))) break; + case 'relation': + formItem = h('div',{ + + },[ + h('vxe-toolbar',[ + h('el-button',{ + slot: 'buttons', + props: { + type: 'primary', + size: 'small', + icon: "el-icon-plus" + }, + on: { + click: _ => { + this.form[info.name].push(deepCopy(pForm)) + } + } + },'增加') + ]), + h('vxe-table',{ + style: { + 'margin-top': '10px' + }, + props: { + stripe: true, + data: this.form[info.name] + } + },this.subForm.get(info.sub_custom_model_id)?.customModel?.fields?.map((subField,subIndex) => h('vxe-column',{ + props: { + field: subField.name, + title: subField.label, + align: 'center' + } + },formBuilder.bind(this)(device, subField, h, this.form[info.name][subIndex])))) + ]) + // formItem = h('div', [ + // h('div',[ + // h('el-button',{ + // props: { + // size: "small", + // type: "primary", + // icon: "el-icon-plus" + // }, + // on: { + // click: _ => { + // this.form[info.name].push(deepCopy(pForm)) + // } + // } + // },'增加') + // ]), + // ...this.form[info.name]?.map((i,subIndex) => h('el-card',[ + // h('el-button',{ + // props: { + // size: 'small', + // type: 'primary' + // }, + // on: { + // click: _ => { + // this.form[info.name].splice(subIndex,1) + // } + // } + // },'删除'), + // h('el-form', { + // class: 'form', + // props: { + // model: this.form[info.name][subIndex], + // 'label-position': 'top' + // } + // },this.subForm.get(info.sub_custom_model_id)?.customModel?.fields.map(subField => formBuilder.bind(this)(device, subField, h, this.form[info.name][subIndex]))) + // ])) + // ]) + break; } return h('el-form-item',{ props: { @@ -419,11 +493,116 @@ export default function (device, info,h ) { label: info.label }, style: { - 'grid-column-start': info.gs_x, - 'grid-column-end': info.gs_x + info.gs_width, - 'grid-row-start': info.gs_y, - 'grid-row-end': info.gs_y + info.gs_height + 'grid-column-start': info.gs_x+1, + 'grid-column-end': info.gs_x+1 + info.gs_width, + 'grid-row-start': info.gs_y+1, + 'grid-row-end': info.gs_y+1 + info.gs_height } },[formItem]) } + if(device === 'mobile') { + switch (info.type) { + case 'text': + formItem = h(formBuilderMap(device).get(info.type),{ + props: { + name: info.name, + label: info.label, + value: this.form[info.name], + clearable: true, + placeholder: info.help_text + }, + attrs: { + placeholder: info.help_text + }, + on: { + input: e => { + this.$set(this.form,info.name,e) + } + } + }) + break; + case 'textarea': + formItem = h(formBuilderMap(device).get(info.type),{ + props: { + name: info.name, + label: info.label, + type: 'textarea', + value: this.form[info.name], + clearable: true, + placeholder: info.help_text + }, + attrs: { + placeholder: info.help_text + }, + on: { + input: e => { + this.$set(this.form,info.name,e) + } + } + }) + break; + case 'date': + formItem = h('van-field',{ + props: { + readonly: true, + clickable: true, + name: info.name, + label: info.label, + value: this.form[info.name], + clearable: true, + placeholder: info.help_text, + }, + attrs: { + placeholder: info.help_text + }, + on: { + click: _ => { + this.vanCalendarOption.forFormName = info.name; + this.$set(this.vanCalendarOption,'isShow',true); + } + } + }) + break; + case 'datetime': + formItem = h('van-field',{ + props: { + readonly: true, + clickable: true, + name: info.name, + label: info.label, + value: this.form[info.name], + clearable: true, + placeholder: info.help_text, + }, + on: { + click:_ => { + this.vanTimePickerOption.forFormName = info.name; + this.$set(this.vanTimePickerOption,'isShow',true); + } + } + }) + break; + case 'select': + formItem = h('van-field',{ + props: { + readonly: true, + clickable: true, + name: info.name, + label: info.label, + value: this.form[info.name], + clearable: true, + placeholder: info.help_text, + }, + on: { + click:_ => { + this.vanPopupOption.forFormName = info.name; + this.$set(this.vanPopupOption,'columns',['杭州', '宁波', '温州', '嘉兴', '湖州']); + this.$set(this.vanPopupOption,'isShow',true); + } + } + }) + break; + } + return formItem + } } diff --git a/src/views/flow/DesktopForm.vue b/src/views/flow/DesktopForm.vue index c19f774..d510d11 100644 --- a/src/views/flow/DesktopForm.vue +++ b/src/views/flow/DesktopForm.vue @@ -1,148 +1,31 @@ diff --git a/src/views/flow/create.vue b/src/views/flow/create.vue index e445fe0..e6c65d0 100644 --- a/src/views/flow/create.vue +++ b/src/views/flow/create.vue @@ -2,16 +2,16 @@
@@ -22,20 +22,81 @@ diff --git a/src/views/flow/index.vue b/src/views/flow/index.vue index 98b6b2f..14eed47 100644 --- a/src/views/flow/index.vue +++ b/src/views/flow/index.vue @@ -1,17 +1,311 @@