feat: 流程设计器表单字段必填配置

3.x
ssc 3 years ago
parent 066828c91e
commit 0da53c668c
  1. 2
      src/views/plugin/workflow/components/custom-fields/wf-user-select/index.vue
  2. 107
      src/views/plugin/workflow/components/nf-dept-select/index.vue
  3. 20
      src/views/plugin/workflow/mixins/ex-form.js
  4. 30
      src/views/plugin/workflow/utils/index.js

@ -35,7 +35,7 @@ export default {
size: {
type: String,
default: () => {
return 'small'
return 'default'
}
},
readonly: {

@ -1,34 +1,34 @@
<template>
<el-dialog ref="nf-dialog"
class="nf-dialog"
v-model="visible"
title="部门选择"
width="60%"
:before-close="handleClose"
append-to-body>
<avue-crud v-if="isInit"
:option="option"
:table-loading="loading"
:data="data"
v-model="form"
ref="crud"
@search-change="searchChange"
@search-reset="searchReset"
@selection-change="selectionList=$event"
@row-click="rowClick"
@on-load="onLoad"
@tree-load="treeLoad">
<el-dialog
ref="nf-dialog"
class="nf-dialog"
v-model="visible"
title="部门选择"
width="60%"
:before-close="handleClose"
append-to-body
>
<avue-crud
v-if="isInit && visible"
:option="option"
:table-loading="loading"
:data="data"
v-model="form"
ref="crud"
@search-change="searchChange"
@search-reset="searchReset"
@selection-change="selectionList = $event"
@row-click="rowClick"
@on-load="onLoad"
@tree-load="treeLoad"
>
</avue-crud>
<template #footer>
<span class="dialog-footer">
<el-button @click="handleClose"
size="default">取消</el-button>
<el-button type="primary"
@click="handleConfirm"
size="default">确定</el-button>
<el-button @click="handleClose" size="default">取消</el-button>
<el-button type="primary" @click="handleConfirm" size="default">确定</el-button>
</span>
</template>
</el-dialog>
</template>
<script>
@ -40,20 +40,20 @@ export default {
},
watch: {
visible: {
handler (val) {
handler(val) {
if (val) this.changeDefaultChecked()
},
}
},
computed: {
ids () {
ids() {
let ids = [];
this.selectionList.forEach(ele => {
ids.push(ele[this.props.id]);
});
return ids.join(",");
},
names () {
names() {
let names = [];
this.selectionList.forEach(ele => {
names.push(ele[this.props.name]);
@ -61,7 +61,7 @@ export default {
return names.join(",");
}
},
data () {
data() {
return {
isInit: false,
visible: false,
@ -113,11 +113,11 @@ export default {
}
}
},
mounted () {
mounted() {
this.init()
},
methods: {
init () {
init() {
if (!this.isInit) {
if (this.customOption) {
const { deptColumn, deptProps } = this.customOption
@ -127,7 +127,7 @@ export default {
this.isInit = true
}
},
handleConfirm () {
handleConfirm() {
if (this.selectionList.length === 0) {
this.$message.warning("请至少选择一项")
return
@ -135,16 +135,16 @@ export default {
this.$emit('confirm', this.ids, this.names)
this.handleClose()
},
handleClose (done) {
handleClose(done) {
// this.selectionClear()
this.visible = false
if (done && typeof done == 'function') done()
},
searchReset () {
searchReset() {
this.query = {}
this.onLoad(this.page)
},
searchChange (params, done) {
searchChange(params, done) {
this.query = {
...params,
parentId: ''
@ -153,26 +153,31 @@ export default {
this.onLoad(this.page, params)
done()
},
selectionClear () {
selectionClear() {
this.selectionList = []
if (this.$refs.crud) this.$refs.crud.toggleSelection()
},
rowClick (row) {
rowClick(row) {
this.$refs.crud.toggleSelection([row])
},
changeDefaultChecked () {
this.selectionClear()
changeDefaultChecked() {
// this.selectionClear()
if (this.defaultChecked) {
const checks = this.defaultChecked.split(",")
if (checks.length > 0) {
checks.forEach(c => {
const row = this.findRow(this.data, c)
if (row) this.$refs.crud.toggleRowSelection(row, true)
})
setTimeout(() => {
checks.forEach(c => {
let row = this.findRow(this.data, c)
if (!row) {
row = this.selectionList.find(d => d.id == c) //
}
if (row && this.$refs.crud) this.$refs.crud.toggleRowSelection(row, true)
})
}, 500)
}
}
},
findRow (list, id) {
findRow(list, id) {
if (!list) return
for (let i = 0; i < list.length; i++) {
const data = list[i]
@ -180,7 +185,7 @@ export default {
else if (data.children) return this.findRow(data.children, id)
}
},
onLoad (page, params = {}) {
onLoad(page, params = {}) {
this.loading = true;
const param = {
parentId: 0,
@ -189,15 +194,21 @@ export default {
this.$axios.get(this.url, { params: param }).then(res => {
this.data = this.getAsVal(res, this.props.data) || []
this.loading = false
this.changeDefaultChecked()
})
},
treeLoad (tree, treeNode, resolve) {
treeLoad(tree, treeNode, resolve) {
const parentId = tree.id;
this.$axios.get(this.url, { params: { parentId } }).then(res => {
resolve(this.getAsVal(res, this.props.data) || []);
const list = this.getAsVal(res, this.props.data) || []
resolve(list)
const parent = this.findRow(this.data, parentId)
parent.children = list
this.changeDefaultChecked()
})
},
getAsVal (obj, bind = '') {
getAsVal(obj, bind = '') {
let result = this.deepClone(obj)
if (this.validatenull(bind)) return result
bind.split('.').forEach(ele => {

@ -18,9 +18,12 @@ import defaultValues from './default-values.js'
import Print from '../utils/print.js'
import Watermark from '../utils/watermark.js'
import { versionCompare } from '../utils/index.js'
import { mapGetters } from 'vuex'
import { version } from '@nutflow/nf-design-elp'
export default {
mixins: [defaultValues],
computed: {
@ -89,7 +92,7 @@ export default {
}
})
},
// 根据可读可写,过滤avue column
// 根据可读可写,过滤column
filterAvueColumn(column, taskForm, isExForm = false, props = {
label: 'label',
prop: 'prop'
@ -103,6 +106,9 @@ export default {
const values = []
const vars = []
const versionFlag106 = version && versionCompare(version, '1.0.6')
column.forEach(col => {
let c = taskForm.find(s => s.id == col[props.prop])
if (c && c.readable) {
@ -144,6 +150,18 @@ export default {
})
}
col.display = true
// 处理字段必填
let required = false
if (versionFlag106) { // 1.0.6及版本以下,required默认为true
required = true
} else { // 1.0.7流程设计器表单配置支持required属性
required = c.required
}
if (!required && col.rules) {
const index = col.rules.findIndex(c => c.required)
if (index != -1) col.rules.splice(index, 1)
}
} else {
col.display = false
}

@ -0,0 +1,30 @@
/**
* 判断版本号v2是否小于等于v1
*/
export const versionCompare = (v1, v2) => {
if (!v1 || !v2) return true
let v1Arr = v1.split('.')
let v2Arr = v2.split('.')
const len = Math.max(v1Arr.length, v2Arr.length)
// 调整两个版本号位数相同
while (v1Arr.length < len) {
v1Arr.push('0')
}
while (v2Arr.length < len) {
v2Arr.push('0')
}
// 循环判断每位数的大小
for (let i = 0; i < len; i++) {
const num1 = parseInt(v1Arr[i])
const num2 = parseInt(v2Arr[i])
if (num1 > num2) {
return false
} else if (num1 < num2) {
return true
}
}
return true
}
Loading…
Cancel
Save