Commit d1c95c4d8aeeb94d13bc65290ef7816d1e3e6fce
1 parent
f45224f2
1. 清理旧版本的 form generator
2. 接入表单详情
Showing
4 changed files
with
65 additions
and
193 deletions
yudao-admin-ui/src/utils/formGenerator.js
0 → 100644
yudao-admin-ui/src/views/bpm/form/formEditor.vue
| @@ -169,6 +169,7 @@ import { | @@ -169,6 +169,7 @@ import { | ||
| 169 | import loadBeautifier from '@/utils/loadBeautifier' | 169 | import loadBeautifier from '@/utils/loadBeautifier' |
| 170 | import {SysCommonStatusEnum} from "@/utils/constants"; | 170 | import {SysCommonStatusEnum} from "@/utils/constants"; |
| 171 | import {createForm, getForm, updateForm} from "@/api/bpm/form"; | 171 | import {createForm, getForm, updateForm} from "@/api/bpm/form"; |
| 172 | +import {decodeFields} from "@/utils/formGenerator"; | ||
| 172 | 173 | ||
| 173 | let beautifier | 174 | let beautifier |
| 174 | const emptyActiveData = { style: {}, autosize: {} } | 175 | const emptyActiveData = { style: {}, autosize: {} } |
| @@ -316,7 +317,7 @@ export default { | @@ -316,7 +317,7 @@ export default { | ||
| 316 | remark: data.remark | 317 | remark: data.remark |
| 317 | } | 318 | } |
| 318 | this.formConf = JSON.parse(data.conf) | 319 | this.formConf = JSON.parse(data.conf) |
| 319 | - this.drawingList = this.decodeFields(data.fields) | 320 | + this.drawingList = decodeFields(data.fields) |
| 320 | // 设置激活的表单项 | 321 | // 设置激活的表单项 |
| 321 | this.activeData = this.drawingList[0] | 322 | this.activeData = this.drawingList[0] |
| 322 | this.activeId = this.activeData.__config__.formId | 323 | this.activeId = this.activeData.__config__.formId |
| @@ -428,7 +429,6 @@ export default { | @@ -428,7 +429,6 @@ export default { | ||
| 428 | } | 429 | } |
| 429 | const form = { | 430 | const form = { |
| 430 | conf: JSON.stringify(this.formConf), // 表单配置 | 431 | conf: JSON.stringify(this.formConf), // 表单配置 |
| 431 | - // fields: JSON.stringify(this.drawingList), // 表单项的数组 | ||
| 432 | fields: this.encodeFields(), // 表单项的数组 | 432 | fields: this.encodeFields(), // 表单项的数组 |
| 433 | ...this.form // 表单名等 | 433 | ...this.form // 表单名等 |
| 434 | } | 434 | } |
| @@ -459,13 +459,6 @@ export default { | @@ -459,13 +459,6 @@ export default { | ||
| 459 | }) | 459 | }) |
| 460 | return fields | 460 | return fields |
| 461 | }, | 461 | }, |
| 462 | - decodeFields(fields) { | ||
| 463 | - const drawingList = [] | ||
| 464 | - fields.forEach(item => { | ||
| 465 | - drawingList.push(JSON.parse(item)) | ||
| 466 | - }) | ||
| 467 | - return drawingList | ||
| 468 | - }, | ||
| 469 | generate(data) { | 462 | generate(data) { |
| 470 | const func = this[`exec${titleCase(this.operationType)}`] | 463 | const func = this[`exec${titleCase(this.operationType)}`] |
| 471 | this.generateConf = data | 464 | this.generateConf = data |
yudao-admin-ui/src/views/bpm/form/index.vue
| @@ -63,6 +63,7 @@ | @@ -63,6 +63,7 @@ | ||
| 63 | <script> | 63 | <script> |
| 64 | import {deleteForm, getForm, getFormPage} from "@/api/bpm/form"; | 64 | import {deleteForm, getForm, getFormPage} from "@/api/bpm/form"; |
| 65 | import Parser from '@/components/parser/Parser' | 65 | import Parser from '@/components/parser/Parser' |
| 66 | +import {decodeFields} from "@/utils/formGenerator"; | ||
| 66 | 67 | ||
| 67 | export default { | 68 | export default { |
| 68 | name: "Form", | 69 | name: "Form", |
| @@ -87,7 +88,9 @@ export default { | @@ -87,7 +88,9 @@ export default { | ||
| 87 | }, | 88 | }, |
| 88 | // 表单详情 | 89 | // 表单详情 |
| 89 | detailOpen: false, | 90 | detailOpen: false, |
| 90 | - detailForm: {} | 91 | + detailForm: { |
| 92 | + fields: [] | ||
| 93 | + } | ||
| 91 | }; | 94 | }; |
| 92 | }, | 95 | }, |
| 93 | created() { | 96 | created() { |
| @@ -118,192 +121,16 @@ export default { | @@ -118,192 +121,16 @@ export default { | ||
| 118 | }, | 121 | }, |
| 119 | /** 详情按钮操作 */ | 122 | /** 详情按钮操作 */ |
| 120 | handleDetail(row) { | 123 | handleDetail(row) { |
| 121 | - this.detailOpen = true | ||
| 122 | getForm(row.id).then(response => { | 124 | getForm(row.id).then(response => { |
| 125 | + // 设置值 | ||
| 123 | const data = response.data | 126 | const data = response.data |
| 124 | this.detailForm = { | 127 | this.detailForm = { |
| 125 | ...JSON.parse(data.conf), | 128 | ...JSON.parse(data.conf), |
| 126 | - fields: this.decodeFields(data.fields) | 129 | + fields: decodeFields(data.fields) |
| 127 | } | 130 | } |
| 128 | - // console.log({ | ||
| 129 | - // ...JSON.parse(data.conf), | ||
| 130 | - // fields: this.decodeFields(data.fields) | ||
| 131 | - // }) | ||
| 132 | - // this.detailForm = { | ||
| 133 | - // fields: [ | ||
| 134 | - // { | ||
| 135 | - // __config__: { | ||
| 136 | - // label: '单行文本', | ||
| 137 | - // labelWidth: null, | ||
| 138 | - // showLabel: true, | ||
| 139 | - // changeTag: true, | ||
| 140 | - // tag: 'el-input', | ||
| 141 | - // tagIcon: 'input', | ||
| 142 | - // required: true, | ||
| 143 | - // layout: 'colFormItem', | ||
| 144 | - // span: 24, | ||
| 145 | - // document: 'https://element.eleme.cn/#/zh-CN/component/input', | ||
| 146 | - // regList: [ | ||
| 147 | - // { | ||
| 148 | - // pattern: '/^1(3|4|5|7|8|9)\\d{9}$/', | ||
| 149 | - // message: '手机号格式错误' | ||
| 150 | - // } | ||
| 151 | - // ] | ||
| 152 | - // }, | ||
| 153 | - // __slot__: { | ||
| 154 | - // prepend: '', | ||
| 155 | - // append: '' | ||
| 156 | - // }, | ||
| 157 | - // __vModel__: 'mobile', | ||
| 158 | - // placeholder: '请输入手机号', | ||
| 159 | - // style: { | ||
| 160 | - // width: '100%' | ||
| 161 | - // }, | ||
| 162 | - // clearable: true, | ||
| 163 | - // 'prefix-icon': 'el-icon-mobile', | ||
| 164 | - // 'suffix-icon': '', | ||
| 165 | - // maxlength: 11, | ||
| 166 | - // 'show-word-limit': true, | ||
| 167 | - // readonly: false, | ||
| 168 | - // disabled: false | ||
| 169 | - // }, | ||
| 170 | - // { | ||
| 171 | - // __config__: { | ||
| 172 | - // label: '日期范围', | ||
| 173 | - // tag: 'el-date-picker', | ||
| 174 | - // tagIcon: 'date-range', | ||
| 175 | - // defaultValue: null, | ||
| 176 | - // span: 24, | ||
| 177 | - // showLabel: true, | ||
| 178 | - // labelWidth: null, | ||
| 179 | - // required: true, | ||
| 180 | - // layout: 'colFormItem', | ||
| 181 | - // regList: [], | ||
| 182 | - // changeTag: true, | ||
| 183 | - // document: | ||
| 184 | - // 'https://element.eleme.cn/#/zh-CN/component/date-picker', | ||
| 185 | - // formId: 101, | ||
| 186 | - // renderKey: 1585980082729 | ||
| 187 | - // }, | ||
| 188 | - // style: { | ||
| 189 | - // width: '100%' | ||
| 190 | - // }, | ||
| 191 | - // type: 'daterange', | ||
| 192 | - // 'range-separator': '至', | ||
| 193 | - // 'start-placeholder': '开始日期', | ||
| 194 | - // 'end-placeholder': '结束日期', | ||
| 195 | - // disabled: false, | ||
| 196 | - // clearable: true, | ||
| 197 | - // format: 'yyyy-MM-dd', | ||
| 198 | - // 'value-format': 'yyyy-MM-dd', | ||
| 199 | - // readonly: false, | ||
| 200 | - // __vModel__: 'field101' | ||
| 201 | - // }, | ||
| 202 | - // { | ||
| 203 | - // __config__: { | ||
| 204 | - // layout: 'rowFormItem', | ||
| 205 | - // tagIcon: 'row', | ||
| 206 | - // label: '行容器', | ||
| 207 | - // layoutTree: true, | ||
| 208 | - // children: [ | ||
| 209 | - // { | ||
| 210 | - // __config__: { | ||
| 211 | - // label: '评分', | ||
| 212 | - // tag: 'el-rate', | ||
| 213 | - // tagIcon: 'rate', | ||
| 214 | - // defaultValue: 0, | ||
| 215 | - // span: 24, | ||
| 216 | - // showLabel: true, | ||
| 217 | - // labelWidth: null, | ||
| 218 | - // layout: 'colFormItem', | ||
| 219 | - // required: true, | ||
| 220 | - // regList: [], | ||
| 221 | - // changeTag: true, | ||
| 222 | - // document: 'https://element.eleme.cn/#/zh-CN/component/rate', | ||
| 223 | - // formId: 102, | ||
| 224 | - // renderKey: 1586839671259 | ||
| 225 | - // }, | ||
| 226 | - // style: {}, | ||
| 227 | - // max: 5, | ||
| 228 | - // 'allow-half': false, | ||
| 229 | - // 'show-text': false, | ||
| 230 | - // 'show-score': false, | ||
| 231 | - // disabled: false, | ||
| 232 | - // __vModel__: 'field102' | ||
| 233 | - // } | ||
| 234 | - // ], | ||
| 235 | - // document: 'https://element.eleme.cn/#/zh-CN/component/layout', | ||
| 236 | - // formId: 101, | ||
| 237 | - // span: 24, | ||
| 238 | - // renderKey: 1586839668999, | ||
| 239 | - // componentName: 'row101', | ||
| 240 | - // gutter: 15 | ||
| 241 | - // }, | ||
| 242 | - // type: 'default', | ||
| 243 | - // justify: 'start', | ||
| 244 | - // align: 'top' | ||
| 245 | - // }, | ||
| 246 | - // { | ||
| 247 | - // __config__: { | ||
| 248 | - // label: '按钮', | ||
| 249 | - // showLabel: true, | ||
| 250 | - // changeTag: true, | ||
| 251 | - // labelWidth: null, | ||
| 252 | - // tag: 'el-button', | ||
| 253 | - // tagIcon: 'button', | ||
| 254 | - // span: 24, | ||
| 255 | - // layout: 'colFormItem', | ||
| 256 | - // document: 'https://element.eleme.cn/#/zh-CN/component/button', | ||
| 257 | - // renderKey: 1594288459289 | ||
| 258 | - // }, | ||
| 259 | - // __slot__: { | ||
| 260 | - // default: '测试按钮1' | ||
| 261 | - // }, | ||
| 262 | - // type: 'primary', | ||
| 263 | - // icon: 'el-icon-search', | ||
| 264 | - // round: false, | ||
| 265 | - // size: 'medium', | ||
| 266 | - // plain: false, | ||
| 267 | - // circle: false, | ||
| 268 | - // disabled: false, | ||
| 269 | - // on: { | ||
| 270 | - // click: 'clickTestButton1' | ||
| 271 | - // } | ||
| 272 | - // } | ||
| 273 | - // ], | ||
| 274 | - // __methods__: { | ||
| 275 | - // clickTestButton1() { | ||
| 276 | - // console.log( | ||
| 277 | - // `%c【测试按钮1】点击事件里可以访问当前表单: | ||
| 278 | - // 1) formModel='formData', 所以this.formData可以拿到当前表单的model | ||
| 279 | - // 2) formRef='elForm', 所以this.$refs.elForm可以拿到当前表单的ref(vue组件) | ||
| 280 | - // `, | ||
| 281 | - // 'color:#409EFF;font-size: 15px' | ||
| 282 | - // ) | ||
| 283 | - // console.log('表单的Model:', this.formData) | ||
| 284 | - // console.log('表单的ref:', this.$refs.elForm) | ||
| 285 | - // } | ||
| 286 | - // }, | ||
| 287 | - // formRef: 'elForm', | ||
| 288 | - // formModel: 'formData', | ||
| 289 | - // size: 'small', | ||
| 290 | - // labelPosition: 'right', | ||
| 291 | - // labelWidth: 100, | ||
| 292 | - // formRules: 'rules', | ||
| 293 | - // gutter: 15, | ||
| 294 | - // disabled: false, | ||
| 295 | - // span: 24, | ||
| 296 | - // formBtns: true, | ||
| 297 | - // unFocusedComponentBorder: false | ||
| 298 | - // } | ||
| 299 | - }); | ||
| 300 | - }, | ||
| 301 | - decodeFields(fields) { | ||
| 302 | - const drawingList = [] | ||
| 303 | - fields.forEach(item => { | ||
| 304 | - drawingList.push(JSON.parse(item)) | 131 | + // 弹窗打开 |
| 132 | + this.detailOpen = true | ||
| 305 | }) | 133 | }) |
| 306 | - return drawingList | ||
| 307 | }, | 134 | }, |
| 308 | /** 新增按钮操作 */ | 135 | /** 新增按钮操作 */ |
| 309 | handleAdd() { | 136 | handleAdd() { |
yudao-admin-ui/src/views/bpm/model/index.vue
| @@ -40,7 +40,14 @@ | @@ -40,7 +40,14 @@ | ||
| 40 | <span>{{ getDictDataLabel(DICT_TYPE.BPM_MODEL_CATEGORY, scope.row.category) }}</span> | 40 | <span>{{ getDictDataLabel(DICT_TYPE.BPM_MODEL_CATEGORY, scope.row.category) }}</span> |
| 41 | </template> | 41 | </template> |
| 42 | </el-table-column> | 42 | </el-table-column> |
| 43 | - <el-table-column label="表单信息" align="center" prop="formId" /> <!-- TODO 芋艿:需要支持表单的点击 --> | 43 | + <el-table-column label="表单信息" align="center" prop="formId"> |
| 44 | + <template slot-scope="scope"> | ||
| 45 | + <el-button v-if="scope.row.formId" type="text" @click="handleFormDetail(scope.row)"> | ||
| 46 | + <span>{{ scope.row.formName }}</span> | ||
| 47 | + </el-button> | ||
| 48 | + <label v-else>暂无表单</label> | ||
| 49 | + </template> | ||
| 50 | + </el-table-column> | ||
| 44 | <el-table-column label="流程版本" align="center" prop="processDefinition.version" /> | 51 | <el-table-column label="流程版本" align="center" prop="processDefinition.version" /> |
| 45 | <el-table-column label="创建时间" align="center" prop="createTime" width="180"> | 52 | <el-table-column label="创建时间" align="center" prop="createTime" width="180"> |
| 46 | <template slot-scope="scope"> | 53 | <template slot-scope="scope"> |
| @@ -65,6 +72,13 @@ | @@ -65,6 +72,13 @@ | ||
| 65 | <vue-bpmn v-if="showBpmnOpen" product="activiti" @processSave="processSave" | 72 | <vue-bpmn v-if="showBpmnOpen" product="activiti" @processSave="processSave" |
| 66 | :bpmnXml="bpmnXML" :bpmnData="bpmnData" @beforeClose="cancel" /> | 73 | :bpmnXml="bpmnXML" :bpmnData="bpmnData" @beforeClose="cancel" /> |
| 67 | </el-dialog> | 74 | </el-dialog> |
| 75 | + | ||
| 76 | + <!-- 流程表单配置详情 --> | ||
| 77 | + <el-dialog title="表单详情" :visible.sync="detailOpen" width="50%" append-to-body> | ||
| 78 | + <div class="test-form"> | ||
| 79 | + <parser :key="new Date().getTime()" :form-conf="detailForm" /> | ||
| 80 | + </div> | ||
| 81 | + </el-dialog> | ||
| 68 | </div> | 82 | </div> |
| 69 | </template> | 83 | </template> |
| 70 | 84 | ||
| @@ -72,9 +86,16 @@ | @@ -72,9 +86,16 @@ | ||
| 72 | import {deleteModel, deployModel, createModel, updateModel, getModelPage, getModel} from "@/api/bpm/model"; | 86 | import {deleteModel, deployModel, createModel, updateModel, getModelPage, getModel} from "@/api/bpm/model"; |
| 73 | import VueBpmn from "@/components/bpmn/VueBpmn"; | 87 | import VueBpmn from "@/components/bpmn/VueBpmn"; |
| 74 | import {DICT_TYPE, getDictDatas} from "@/utils/dict"; | 88 | import {DICT_TYPE, getDictDatas} from "@/utils/dict"; |
| 89 | +import {getForm} from "@/api/bpm/form"; | ||
| 90 | +import {decodeFields} from "@/utils/formGenerator"; | ||
| 91 | +import Parser from '@/components/parser/Parser' | ||
| 75 | 92 | ||
| 76 | export default { | 93 | export default { |
| 77 | name: "model", | 94 | name: "model", |
| 95 | + components: { | ||
| 96 | + Parser, | ||
| 97 | + VueBpmn | ||
| 98 | + }, | ||
| 78 | data() { | 99 | data() { |
| 79 | return { | 100 | return { |
| 80 | // 遮罩层 | 101 | // 遮罩层 |
| @@ -96,11 +117,16 @@ export default { | @@ -96,11 +117,16 @@ export default { | ||
| 96 | bpmnXML: null, | 117 | bpmnXML: null, |
| 97 | bpmnData: {}, | 118 | bpmnData: {}, |
| 98 | 119 | ||
| 120 | + // 流程表单详情 | ||
| 121 | + detailOpen: false, | ||
| 122 | + detailForm: { | ||
| 123 | + fields: [] | ||
| 124 | + }, | ||
| 125 | + | ||
| 99 | // 数据字典 | 126 | // 数据字典 |
| 100 | categoryDictDatas: getDictDatas(DICT_TYPE.BPM_MODEL_CATEGORY), | 127 | categoryDictDatas: getDictDatas(DICT_TYPE.BPM_MODEL_CATEGORY), |
| 101 | }; | 128 | }; |
| 102 | }, | 129 | }, |
| 103 | - components: {VueBpmn}, | ||
| 104 | created() { | 130 | created() { |
| 105 | this.getList(); | 131 | this.getList(); |
| 106 | }, | 132 | }, |
| @@ -205,7 +231,20 @@ export default { | @@ -205,7 +231,20 @@ export default { | ||
| 205 | that.msgSuccess("部署成功"); | 231 | that.msgSuccess("部署成功"); |
| 206 | }) | 232 | }) |
| 207 | }) | 233 | }) |
| 208 | - } | 234 | + }, |
| 235 | + /** 流程表单的详情按钮操作 */ | ||
| 236 | + handleFormDetail(row) { | ||
| 237 | + getForm(row.formId).then(response => { | ||
| 238 | + // 设置值 | ||
| 239 | + const data = response.data | ||
| 240 | + this.detailForm = { | ||
| 241 | + ...JSON.parse(data.conf), | ||
| 242 | + fields: decodeFields(data.fields) | ||
| 243 | + } | ||
| 244 | + // 弹窗打开 | ||
| 245 | + this.detailOpen = true | ||
| 246 | + }) | ||
| 247 | + }, | ||
| 209 | } | 248 | } |
| 210 | }; | 249 | }; |
| 211 | </script> | 250 | </script> |