|
|
@@ -68,7 +68,7 @@
|
|
|
<span class="seal-form-arrow">›</span>
|
|
|
</div>
|
|
|
<div class="seal-form-row" @click="openProcessTypePicker">
|
|
|
- <span class="seal-form-label">流程类型</span>
|
|
|
+ <span class="seal-form-label">发起流程</span>
|
|
|
<span class="seal-form-val">{{ form.FQLCName || '请选择' }}</span>
|
|
|
<span class="seal-form-arrow">›</span>
|
|
|
</div>
|
|
|
@@ -648,6 +648,7 @@
|
|
|
<!-- 流程分类级联选择弹窗 -->
|
|
|
<van-popup v-model:show="processCategoryPopVisible" position="bottom" :style="{ height: '50%' }">
|
|
|
<van-picker
|
|
|
+ :key="processCategoryPickerKey"
|
|
|
show-toolbar
|
|
|
title="选择流程分类"
|
|
|
:columns="processCategoryColumns"
|
|
|
@@ -660,7 +661,7 @@
|
|
|
<van-popup v-model:show="processTypePopVisible" position="bottom" :style="{ height: '40%' }">
|
|
|
<van-picker
|
|
|
show-toolbar
|
|
|
- title="选择流程类型"
|
|
|
+ title="选择发起流程"
|
|
|
:columns="processTypeColumns"
|
|
|
@confirm="onProcessTypeConfirm"
|
|
|
@cancel="processTypePopVisible = false"
|
|
|
@@ -979,8 +980,9 @@
|
|
|
{ value: '单程', text: '单程' },
|
|
|
{ value: '往返', text: '往返' }
|
|
|
],
|
|
|
- // 流程分类 / 流程类型
|
|
|
+ // 流程分类 / 发起流程
|
|
|
processCategoryPopVisible: false,
|
|
|
+ processCategoryPickerKey: 0,
|
|
|
processTypePopVisible: false,
|
|
|
processCategoryRawData: [],
|
|
|
processCategoryColumns: [],
|
|
|
@@ -1179,10 +1181,21 @@
|
|
|
url: this.APIUrl + `/main/categoryLevel/getProduceTreeByPid?code=PROCESS001`,
|
|
|
headers: this.headers,
|
|
|
}).then(res => {
|
|
|
- console.log('getProduceTreeByPid~~~', res.data.data[0].children)
|
|
|
- this.processCategoryRawData = res.data.data[0].children
|
|
|
+ var raw = res.data.data
|
|
|
+ console.log('getProduceTreeByPid raw type:', Array.isArray(raw) ? 'Array' : typeof raw, 'keys:', raw && Object.keys(raw).join(','))
|
|
|
+ // 兼容多种格式:数组 / 单对象 / 嵌套数组
|
|
|
+ if (Array.isArray(raw)) {
|
|
|
+ this.processCategoryRawData = raw
|
|
|
+ console.log(' → 直接存储数组,长度:', raw.length)
|
|
|
+ } else if (raw && raw.children) {
|
|
|
+ this.processCategoryRawData = [raw]
|
|
|
+ console.log(' → 包装为数组,根节点:', raw.name)
|
|
|
+ } else {
|
|
|
+ this.processCategoryRawData = []
|
|
|
+ console.log(' → 空数据')
|
|
|
+ }
|
|
|
// 树数据加载完成后,补充 LCFLName
|
|
|
- if (this.processCategoryRawData && this.form.LCFL) {
|
|
|
+ if (this.processCategoryRawData.length && this.form.LCFL) {
|
|
|
this.form.LCFLName = this.findCategoryNameByNameOrId(this.form.LCFL)
|
|
|
}
|
|
|
})
|
|
|
@@ -1506,44 +1519,53 @@
|
|
|
this.tripEditForm.isRoundTrip = sel
|
|
|
this.roundTripPopVisible = false
|
|
|
},
|
|
|
- // ===== 流程分类 / 流程类型(级联选择) =====
|
|
|
- buildProcessColumns(data) {
|
|
|
+ // ===== 流程分类 / 发起流程(级联选择) =====
|
|
|
+ buildProcessColumns(data, depth) {
|
|
|
if (!data || !data.length) return []
|
|
|
+ depth = depth || 0
|
|
|
+ var self = this
|
|
|
return data.map(function(item) {
|
|
|
var node = { text: item.name, value: item.id || item.name }
|
|
|
+ console.log('buildProcessColumns depth=' + depth, 'name=' + item.name, 'hasChildren=' + !!(item.children && item.children.length))
|
|
|
if (item.children && item.children.length) {
|
|
|
- node.children = item.children.map(function(child) {
|
|
|
- return { text: child.name, value: child.id || child.name }
|
|
|
- })
|
|
|
+ node.children = self.buildProcessColumns(item.children, depth + 1)
|
|
|
}
|
|
|
return node
|
|
|
})
|
|
|
},
|
|
|
findCategoryNameByNameOrId(val) {
|
|
|
var tree = this.processCategoryRawData || []
|
|
|
- for (var i = 0; i < tree.length; i++) {
|
|
|
- var cat = tree[i]
|
|
|
- if (cat.name === val || cat.id === val) return cat.name
|
|
|
- if (cat.children) {
|
|
|
- for (var j = 0; j < cat.children.length; j++) {
|
|
|
- if (cat.children[j].name === val || cat.children[j].id === val) return cat.children[j].name
|
|
|
+ function search(nodes) {
|
|
|
+ for (var i = 0; i < nodes.length; i++) {
|
|
|
+ var n = nodes[i]
|
|
|
+ if (n.name === val || n.id === val) return n.name
|
|
|
+ if (n.children && n.children.length) {
|
|
|
+ var result = search(n.children)
|
|
|
+ if (result) return result
|
|
|
}
|
|
|
}
|
|
|
+ return null
|
|
|
}
|
|
|
- return val || ''
|
|
|
+ return search(tree) || val || ''
|
|
|
},
|
|
|
openProcessCategoryPicker() {
|
|
|
- // 将树形数据转换为级联列格式
|
|
|
+ console.log('openProcessCategoryPicker rawData', JSON.stringify(this.processCategoryRawData).slice(0, 500))
|
|
|
if (this.processCategoryRawData && this.processCategoryRawData.length) {
|
|
|
this.processCategoryColumns = this.buildProcessColumns(this.processCategoryRawData)
|
|
|
+ } else {
|
|
|
+ console.log('processCategoryRawData 为空,未加载')
|
|
|
}
|
|
|
+ console.log('openProcessCategoryPicker columns count:', this.processCategoryColumns.length)
|
|
|
+ this.processCategoryPickerKey++
|
|
|
this.processCategoryPopVisible = true
|
|
|
},
|
|
|
onProcessCategoryConfirm(picker) {
|
|
|
var opts = picker && picker.selectedOptions
|
|
|
if (opts && opts.length > 0) {
|
|
|
- this.form.LCFL = opts[0].value || ''
|
|
|
- this.form.LCFLName = opts[0].text || ''
|
|
|
+ // 取最后一级(最深节点)作为选中值
|
|
|
+ var last = opts[opts.length - 1]
|
|
|
+ this.form.LCFL = last.value || ''
|
|
|
+ this.form.LCFLName = last.text || ''
|
|
|
}
|
|
|
this.processCategoryPopVisible = false
|
|
|
// 清空流程类型,重新加载
|
|
|
@@ -1806,8 +1828,8 @@
|
|
|
return Promise.reject(new Error('请选择流程分类'))
|
|
|
}
|
|
|
if (!this.form.FQLC) {
|
|
|
- vant.showNotify({ type: 'warning', message: '请选择流程类型' })
|
|
|
- return Promise.reject(new Error('请选择流程类型'))
|
|
|
+ vant.showNotify({ type: 'warning', message: '请选择流发起流程' })
|
|
|
+ return Promise.reject(new Error('请选择发起流程'))
|
|
|
}
|
|
|
return this.$refs.generateForm.getData(validate).then((data) => { //清空content
|
|
|
for (key in data) {
|