|
@@ -136,7 +136,8 @@
|
|
|
<!-- <uni-card v-if="flowInfo.seModel == '0' && repeatingFormNotEmpty" spacing="0" padding="0">
|
|
<!-- <uni-card v-if="flowInfo.seModel == '0' && repeatingFormNotEmpty" spacing="0" padding="0">
|
|
|
<button @click="handleRepeatingForm" type="primary">查看明细</button>
|
|
<button @click="handleRepeatingForm" type="primary">查看明细</button>
|
|
|
</uni-card> -->
|
|
</uni-card> -->
|
|
|
- <uni-card v-if="!(flowInfo.seModel == '0' && repeatingFormNotEmpty)"
|
|
|
|
|
|
|
+ <!-- <uni-card v-if="!(flowInfo.seModel == '0' && repeatingFormNotEmpty)" -->
|
|
|
|
|
+ <uni-card v-if="groupCanEdit && repeatingForm.elementItem.length > 0"
|
|
|
v-for="(table, tableIndex) in repeatingForm.elements" spacing="0" :key="tableIndex">
|
|
v-for="(table, tableIndex) in repeatingForm.elements" spacing="0" :key="tableIndex">
|
|
|
<uni-forms label-position="left" :label-width="125" :border="true">
|
|
<uni-forms label-position="left" :label-width="125" :border="true">
|
|
|
<uni-forms-item :name="elem.tableField" v-for="(elem, itemIndex) in table"
|
|
<uni-forms-item :name="elem.tableField" v-for="(elem, itemIndex) in table"
|
|
@@ -155,7 +156,7 @@
|
|
|
placeholderStyle="font-size: calc(14px + 1.2*(1rem - 16px))"></uni-easyinput>
|
|
placeholderStyle="font-size: calc(14px + 1.2*(1rem - 16px))"></uni-easyinput>
|
|
|
</uni-forms-item>
|
|
</uni-forms-item>
|
|
|
</uni-forms>
|
|
</uni-forms>
|
|
|
- <!-- <view class="repeating_table_button_container">
|
|
|
|
|
|
|
+ <view class="repeating_table_button_container">
|
|
|
<uni-row>
|
|
<uni-row>
|
|
|
<uni-col :span="10" :offset="1">
|
|
<uni-col :span="10" :offset="1">
|
|
|
<button @click="addrepeatingFormItem(tableIndex)" type="primary">新增</button>
|
|
<button @click="addrepeatingFormItem(tableIndex)" type="primary">新增</button>
|
|
@@ -165,7 +166,7 @@
|
|
|
:disabled="repeatingForm.elements.length <= 1" type="warn">删除</button>
|
|
:disabled="repeatingForm.elements.length <= 1" type="warn">删除</button>
|
|
|
</uni-col>
|
|
</uni-col>
|
|
|
</uni-row>
|
|
</uni-row>
|
|
|
- </view> -->
|
|
|
|
|
|
|
+ </view>
|
|
|
</uni-card>
|
|
</uni-card>
|
|
|
<!-- <uni-popup v-if="flowInfo.seModel == '0' && repeatingFormNotEmpty" ref="repeatingFormPopup">
|
|
<!-- <uni-popup v-if="flowInfo.seModel == '0' && repeatingFormNotEmpty" ref="repeatingFormPopup">
|
|
|
<uni-card margin="0px" spacing="0px" padding="0px">
|
|
<uni-card margin="0px" spacing="0px" padding="0px">
|
|
@@ -199,7 +200,8 @@
|
|
|
</uni-card>
|
|
</uni-card>
|
|
|
</view> -->
|
|
</view> -->
|
|
|
<view class="repeating_table_detail">
|
|
<view class="repeating_table_detail">
|
|
|
- <uni-card v-if="flowInfo.seModel == '0' && repeatingFormNotEmpty">
|
|
|
|
|
|
|
+ <!--<uni-card v-if="flowInfo.seModel == '0' && repeatingFormNotEmpty">-->
|
|
|
|
|
+ <uni-card v-if="!groupCanEdit && repeatingFormNotEmpty">
|
|
|
<uni-section titleFontSize="1.3rem" title="明细" type="line"></uni-section>
|
|
<uni-section titleFontSize="1.3rem" title="明细" type="line"></uni-section>
|
|
|
<view class="repeating_table_container">
|
|
<view class="repeating_table_container">
|
|
|
<uni-table :border="true" stripe>
|
|
<uni-table :border="true" stripe>
|
|
@@ -452,14 +454,19 @@
|
|
|
}
|
|
}
|
|
|
// 新增重复表表单
|
|
// 新增重复表表单
|
|
|
function addrepeatingFormItem(index) {
|
|
function addrepeatingFormItem(index) {
|
|
|
- // parseCalculation(repeatingForm.value.elementItem)
|
|
|
|
|
- const table = repeatingForm.value.elementItem.map(({ tableField, bddzText }) => {
|
|
|
|
|
- const item = {
|
|
|
|
|
- name: tableField,
|
|
|
|
|
- defaultValue: ""
|
|
|
|
|
|
|
+ // 直接克隆模板对象,并确保 groupid 正确
|
|
|
|
|
+ const table = repeatingForm.value.elementItem.map((templateItem) => {
|
|
|
|
|
+ const item = Object.assign({}, templateItem);
|
|
|
|
|
+ item.defaultValue = "";
|
|
|
|
|
+
|
|
|
|
|
+ // 关键修复:确保新行拥有和模板一样的 groupid
|
|
|
|
|
+ // 兼容大小写:优先使用 groupId,如果没有则使用 groupid
|
|
|
|
|
+ if (!item['groupid']) {
|
|
|
|
|
+ item['groupid'] = item['groupId'] || '';
|
|
|
}
|
|
}
|
|
|
- if (bddzText != '') {
|
|
|
|
|
- const mulItem = bddzText.split('*')
|
|
|
|
|
|
|
+
|
|
|
|
|
+ if (templateItem.bddzText != '') {
|
|
|
|
|
+ const mulItem = templateItem.bddzText.split('*')
|
|
|
// 保存关联数据索引
|
|
// 保存关联数据索引
|
|
|
item['bddzText'] = mulItem.map(item => {
|
|
item['bddzText'] = mulItem.map(item => {
|
|
|
// item['operation '].operands = mulItem.map(item => {
|
|
// item['operation '].operands = mulItem.map(item => {
|
|
@@ -486,6 +493,7 @@
|
|
|
})
|
|
})
|
|
|
const fileList = ref([])
|
|
const fileList = ref([])
|
|
|
const isCancel = ref(false)
|
|
const isCancel = ref(false)
|
|
|
|
|
+ const groupCanEdit = ref(false)
|
|
|
// 获取流程表单
|
|
// 获取流程表单
|
|
|
function initProcessForm() {
|
|
function initProcessForm() {
|
|
|
//debugger
|
|
//debugger
|
|
@@ -511,6 +519,13 @@
|
|
|
if (returnParams.isCancel == 1) {
|
|
if (returnParams.isCancel == 1) {
|
|
|
isCancel.value = true
|
|
isCancel.value = true
|
|
|
}
|
|
}
|
|
|
|
|
+ if (returnParams.groupCanEdit == 1) {
|
|
|
|
|
+ groupCanEdit.value = true
|
|
|
|
|
+ }
|
|
|
|
|
+ if (groupCanEdit.value && repeatingForm.value.elements.length <= 0){
|
|
|
|
|
+ addrepeatingFormItem(0)
|
|
|
|
|
+ //console.log('repeatingForm.value.elements', repeatingForm.value.elements);
|
|
|
|
|
+ }
|
|
|
repeatingFormHasValue()
|
|
repeatingFormHasValue()
|
|
|
bindTimeRangeData()
|
|
bindTimeRangeData()
|
|
|
remark.value = flowInfo.value.seModel == '0' ? '同意' : '重新提交'
|
|
remark.value = flowInfo.value.seModel == '0' ? '同意' : '重新提交'
|
|
@@ -1143,32 +1158,38 @@
|
|
|
}
|
|
}
|
|
|
function validateRepeatingForm2() {
|
|
function validateRepeatingForm2() {
|
|
|
// 设置重复表校验数据
|
|
// 设置重复表校验数据
|
|
|
- const filterElements = repeatingForm.value.elements.filter(item => item.canEdit == "1")
|
|
|
|
|
- if (filterElements.length == 0) return true
|
|
|
|
|
- repeatingFormsValue.value = filterElements.map((item, index) => {
|
|
|
|
|
|
|
+ // repeatingForm.value.elements 是二维数组,需要检查每一行是否有可编辑字段
|
|
|
|
|
+ /*const hasEditableRows = repeatingForm.value.elements.some(row =>
|
|
|
|
|
+ row.some(field => field.canEdit == "1")
|
|
|
|
|
+ )
|
|
|
|
|
+ if (!hasEditableRows) return true*/
|
|
|
|
|
+
|
|
|
|
|
+ repeatingFormsValue.value = repeatingForm.value.elements.map((item, index) => {
|
|
|
return computed(() => {
|
|
return computed(() => {
|
|
|
const obj = {};
|
|
const obj = {};
|
|
|
- item.forEach(({ name, defaultValue }) => {
|
|
|
|
|
- obj[name] = defaultValue;
|
|
|
|
|
|
|
+ item.forEach(({ tableField, defaultValue }) => {
|
|
|
|
|
+ obj[tableField] = defaultValue;
|
|
|
});
|
|
});
|
|
|
return obj;
|
|
return obj;
|
|
|
}).value
|
|
}).value
|
|
|
})
|
|
})
|
|
|
- let flag = false
|
|
|
|
|
- repeatingFormsValue.value.forEach((item, index) => {
|
|
|
|
|
- let ItemIndex = 0
|
|
|
|
|
- for (const elem in item) {
|
|
|
|
|
- if (item[elem] == '') {
|
|
|
|
|
- const name = repeatingForm.value.elementItem[ItemIndex].elementName.slice(3)
|
|
|
|
|
- $modal.msgError(`详情表 ${name} 数据填写错误`)
|
|
|
|
|
- flag = false
|
|
|
|
|
- return
|
|
|
|
|
- }
|
|
|
|
|
- ItemIndex++
|
|
|
|
|
- }
|
|
|
|
|
- flag = true
|
|
|
|
|
- })
|
|
|
|
|
- return flag
|
|
|
|
|
|
|
+ let flag = true
|
|
|
|
|
+ for (let i = 0; i < repeatingFormsValue.value.length; i++) {
|
|
|
|
|
+ const item = repeatingFormsValue.value[i]
|
|
|
|
|
+ // 遍历 elementItem 来获取字段名称,确保顺序一致
|
|
|
|
|
+ for (let j = 0; j < repeatingForm.value.elementItem.length; j++) {
|
|
|
|
|
+ const fieldElement = repeatingForm.value.elementItem[j]
|
|
|
|
|
+ const fieldName = fieldElement.tableField || fieldElement.name
|
|
|
|
|
+ const fieldValue = item[fieldName]
|
|
|
|
|
+
|
|
|
|
|
+ if (fieldValue == '' || fieldValue === undefined || fieldValue === null) {
|
|
|
|
|
+ const name = fieldElement.elementName.slice(3)
|
|
|
|
|
+ $modal.msgError(`详情表${name}不能为空`)
|
|
|
|
|
+ return false
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return flag
|
|
|
}
|
|
}
|
|
|
const button_state = ref(true)
|
|
const button_state = ref(true)
|
|
|
const remark = ref('')
|
|
const remark = ref('')
|
|
@@ -1201,14 +1222,25 @@
|
|
|
// 主表数据校验
|
|
// 主表数据校验
|
|
|
$mainForm.value.validate().then(res => {
|
|
$mainForm.value.validate().then(res => {
|
|
|
// 重复表数据校验
|
|
// 重复表数据校验
|
|
|
- if (repeatingFormNotEmpty.value && !validateRepeatingForm2()) {
|
|
|
|
|
|
|
+ /*const isGroupEditable = groupCanEdit.value;
|
|
|
|
|
+ const repeatingFormValid = isGroupEditable ? validateRepeatingForm2() : true;
|
|
|
|
|
+ console.log('groupCanEdit.value: ', groupCanEdit.value);
|
|
|
|
|
+ console.log('validateRepeatingForm2: ', repeatingFormValid);
|
|
|
|
|
+ if (isGroupEditable && !repeatingFormValid) {
|
|
|
button_state.value = true
|
|
button_state.value = true
|
|
|
return
|
|
return
|
|
|
- }
|
|
|
|
|
|
|
+ }*/
|
|
|
|
|
+ if (groupCanEdit.value){
|
|
|
|
|
+ if (!validateRepeatingForm2()) {
|
|
|
|
|
+ button_state.value = true
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
submitProcess(result)
|
|
submitProcess(result)
|
|
|
})
|
|
})
|
|
|
.catch(err => {
|
|
.catch(err => {
|
|
|
- button_state.value = true
|
|
|
|
|
|
|
+ console.log('验证发生错误', err);
|
|
|
|
|
+ button_state.value = true
|
|
|
$modal.msgError('表单填写错误')
|
|
$modal.msgError('表单填写错误')
|
|
|
})
|
|
})
|
|
|
} else {
|
|
} else {
|
|
@@ -1218,22 +1250,32 @@
|
|
|
}
|
|
}
|
|
|
function submitProcess(result) {
|
|
function submitProcess(result) {
|
|
|
let flow = Object.assign({}, flowInfo.value)
|
|
let flow = Object.assign({}, flowInfo.value)
|
|
|
|
|
+ // 1. 处理主表字段:保留 isGroup 标记
|
|
|
formInfo.value.formElements = formElements.value
|
|
formInfo.value.formElements = formElements.value
|
|
|
// 过滤不可编辑的表单项
|
|
// 过滤不可编辑的表单项
|
|
|
.filter(({ canEdit }) => canEdit == '1')
|
|
.filter(({ canEdit }) => canEdit == '1')
|
|
|
- .map(({ tableField, defaultValue, type }) => {
|
|
|
|
|
|
|
+ .map(({ tableField, defaultValue, type, elementId }) => {
|
|
|
let value = defaultValue
|
|
let value = defaultValue
|
|
|
if ('5' == type && Array.isArray(defaultValue)) {
|
|
if ('5' == type && Array.isArray(defaultValue)) {
|
|
|
value = defaultValue.join(",")
|
|
value = defaultValue.join(",")
|
|
|
}
|
|
}
|
|
|
return {
|
|
return {
|
|
|
name: tableField,
|
|
name: tableField,
|
|
|
- value
|
|
|
|
|
|
|
+ value,
|
|
|
|
|
+ /*isGroup: '0', // 明确标记为主表字段
|
|
|
|
|
+ elementId: elementId*/
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
|
|
|
+
|
|
|
|
|
+ // 2. 处理重复表字段:补充 value, isGroup 和 groupuid
|
|
|
repeatingForm.value.elements.forEach((table, index) => {
|
|
repeatingForm.value.elements.forEach((table, index) => {
|
|
|
const newItem = table.map((item) => {
|
|
const newItem = table.map((item) => {
|
|
|
item['value'] = item.defaultValue
|
|
item['value'] = item.defaultValue
|
|
|
|
|
+ //item['isGroup'] = '1'
|
|
|
|
|
+ // 确保 groupuid 存在(行的唯一身份证),新增的行 groupuid 为空,后端会自动生成
|
|
|
|
|
+ if (!item['groupuid']) {
|
|
|
|
|
+ item['groupuid'] = ''
|
|
|
|
|
+ }
|
|
|
return item
|
|
return item
|
|
|
})
|
|
})
|
|
|
formInfo.value.formElements.push(...newItem)
|
|
formInfo.value.formElements.push(...newItem)
|