|
|
@@ -10,23 +10,30 @@
|
|
|
<uni-forms-item v-if="'0' != elem.canEdit && '8' != elem.type" :name="elem.elementId"
|
|
|
:label="elem.elementName">
|
|
|
<!-- 关联变量输入框 -->
|
|
|
- <uni-easyinput v-if="undefined != elem.bindTimeRange" placeholder=""
|
|
|
- :value="calculateTimeDifference(elem, formElements)"></uni-easyinput>
|
|
|
+ <!-- 计算出差天数 -->
|
|
|
+ <uni-easyinput v-if="undefined != elem.bindTimeRange && elem.elementName == '出差天数'"
|
|
|
+ :type="fieldTypeDict[elem.fieldType] || 'text'"
|
|
|
+ :value="calculateBusinessDifference(elem, formElements)"
|
|
|
+ placeholder=""></uni-easyinput>
|
|
|
+
|
|
|
+ <uni-easyinput v-else-if="undefined != elem.bindTimeRange"
|
|
|
+ :type="fieldTypeDict[elem.fieldType] || 'text'"
|
|
|
+ :value="calculateTimeDifference(elem, formElements)" placeholder=""></uni-easyinput>
|
|
|
<!-- 金额转大写 -->
|
|
|
<uni-easyinput v-else-if="elem.elementName.endsWith('大写')" placeholder=""
|
|
|
:value="computedNumberToChineseCurrency(elem, formElements)"></uni-easyinput>
|
|
|
<!-- 主表关联重复表输入框 -->
|
|
|
- <uni-easyinput v-else-if="elem.BddzText.startsWith('re:')" placeholder=""
|
|
|
- :value="computedValueToRepeatingForm(elem)"></uni-easyinput>
|
|
|
+ <uni-easyinput v-else-if="elem.BddzText.startsWith('re:')"
|
|
|
+ :type="fieldTypeDict[elem.fieldType] || 'text'"
|
|
|
+ :value="computedValueToRepeatingForm(elem)" placeholder=""></uni-easyinput>
|
|
|
<!-- 输入框 -->
|
|
|
<uni-easyinput v-else-if="'0' == elem.type" :disabled="'0' == elem.canEdit"
|
|
|
:type="fieldTypeDict[elem.fieldType] || 'text'"
|
|
|
:placeholder="'0' == elem.canEdit ? '' : '请输入内容'"
|
|
|
- v-model="elem.defaultValue"></uni-easyinput>
|
|
|
+ v-model="elem.defaultValue" placeholderStyle="font-size: calc(14px + 1.2*(1rem - 16px))"></uni-easyinput>
|
|
|
<!-- 富文本输入框 -->
|
|
|
<uni-easyinput v-else-if="'1' == elem.type" :disabled="'0' == elem.canEdit"
|
|
|
- :placeholder="'0' == elem.canEdit ? '' : '请输入内容'" v-model="elem.defaultValue"
|
|
|
- type="textarea"></uni-easyinput>
|
|
|
+ :placeholder="'0' == elem.canEdit ? '' : '请输入内容'" v-model="elem.defaultValue" placeholderStyle="font-size: calc(14px + 1.2*(1rem - 16px))" type="textarea"></uni-easyinput>
|
|
|
<!-- 下拉框 -->
|
|
|
<picker class="picker_container" v-else-if="'2' == elem.type"
|
|
|
@change="bindPickerChange($event, elem)" :value="elem.defaultValue"
|
|
|
@@ -34,7 +41,7 @@
|
|
|
<view class="uni-input input_text">
|
|
|
<!-- 设置默认值为第一个选项 -->
|
|
|
{{ elem.defaultValue ? elem.defaultValue : elem.defaultValue =
|
|
|
- elem.typeDetail.enum[0].enumVname }}
|
|
|
+ elem.typeDetail.enum[0].enumVname }}
|
|
|
</view>
|
|
|
</picker>
|
|
|
<!-- 开始时间选择器 -->
|
|
|
@@ -66,11 +73,8 @@
|
|
|
<uni-forms-item :name="elem.tableField" v-for="(elem, itemIndex) in form"
|
|
|
:label="repeatingForm.elementItem[itemIndex].elementName.slice(3)" :key="itemIndex">
|
|
|
<!-- 自定义关联变量 -->
|
|
|
- <uni-easyinput v-if="repeatingForm.elementItem[itemIndex].bddzText" :placeholder="''"
|
|
|
- :value="calculateRepeatingFormExpression(elem, form)"></uni-easyinput>
|
|
|
- <uni-easyinput v-else placeholder="请输入内容" v-model="elem.defaultValue"
|
|
|
- :type="fieldTypeDict[repeatingForm.elementItem[itemIndex].fieldType.value] || 'text'"></uni-easyinput>
|
|
|
- </uni-forms-item>
|
|
|
+ <uni-easyinput v-if="repeatingForm.elementItem[itemIndex].bddzText" :placeholder="''" :type="fieldTypeDict[repeatingForm.elementItem[itemIndex].fieldType.value] || 'text'" placeholderStyle="font-size: calc(14px + 1.2*(1rem - 16px))" :value="calculateRepeatingFormExpression(elem, form)"></uni-easyinput>
|
|
|
+ <uni-easyinput v-else placeholder="请输入内容" v-model="elem.defaultValue" placeholderStyle="font-size: calc(14px + 1.2*(1rem - 16px))" :type="fieldTypeDict[repeatingForm.elementItem[itemIndex].fieldType.value] || 'text'"></uni-easyinput></uni-forms-item>
|
|
|
</uni-forms>
|
|
|
<view class="repeating_table_button_container">
|
|
|
<uni-row>
|
|
|
@@ -87,7 +91,7 @@
|
|
|
</view>
|
|
|
<!-- 上传附件 -->
|
|
|
<view class="file_picker_container">
|
|
|
- <uni-card title="上传附件" :extra="`${fileList.length}/15`" spacing="0">
|
|
|
+ <uni-card title="上传附件" :extra="`${fileList.length}/9`" spacing="0">
|
|
|
<uni-file-picker ref="filePicker" v-model="fileList" :auto-upload="true" mode="list" limit="10"
|
|
|
file-mediatype="all" @select="handleFileSelect" @progress="handleFileProgress"
|
|
|
@success="handleFileSuccess" @fail="handleFileFail" @delete="handleFileDelete" />
|
|
|
@@ -112,9 +116,10 @@ import $tab from '@/plugins/tab.js'
|
|
|
import { convertToChineseCurrency } from '@/utils/ygoa.js'
|
|
|
import { calCommonExp } from '@/utils/rpn.js'
|
|
|
import { getProcessInfo, getProcessForm, submitProcessForm, uploadFile, getAttendanceSegment } from '@/api/work.js'
|
|
|
+
|
|
|
const fieldTypeDict = {
|
|
|
'0': 'text',
|
|
|
- '1': 'number'
|
|
|
+ '1': 'digit'
|
|
|
}
|
|
|
let processInfo = reactive({
|
|
|
modelName: '流程申请',
|
|
|
@@ -173,6 +178,7 @@ function initProcessForm() {
|
|
|
formElements.value = returnParams.formElements
|
|
|
repeatingForm.value = returnParams.repeatingForm
|
|
|
getValidateRules()
|
|
|
+ computedMainFormValue()
|
|
|
// 生成第一个重复表数据
|
|
|
if (repeatingForm.value) {
|
|
|
addRepeatingFormItem(0)
|
|
|
@@ -184,7 +190,7 @@ function initProcessForm() {
|
|
|
const timeRangeItems = ref([
|
|
|
['开始时间', '结束时间', '多少小时'],
|
|
|
['出发时间', '预计返回时间'],
|
|
|
- ['出差时间', '返回时间'],
|
|
|
+ ['出差时间', '返回时间', '出差天数'],
|
|
|
['出门时间', '预计返回时间'],
|
|
|
['开始时间', '结束时间', '合计小时'],
|
|
|
])
|
|
|
@@ -197,18 +203,15 @@ function bindTimeRangeData() {
|
|
|
// 找到 startName 和 endName 的索引
|
|
|
const startIndex = formElements.value.findIndex((item) => item.elementName === startName);
|
|
|
const endIndex = formElements.value.findIndex((item) => item.elementName === endName);
|
|
|
-
|
|
|
+
|
|
|
+ const formatDate = (date) => {
|
|
|
+ const pad = (num) => num.toString().padStart(2, '0');
|
|
|
+ return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())} ${pad(date.getHours())}:${pad(date.getMinutes())}:${pad(date.getSeconds())}`;
|
|
|
+ }
|
|
|
+
|
|
|
// 只有找到 startName 和 endName 后,才检查 bindName
|
|
|
if (startIndex !== -1 && endIndex !== -1) {
|
|
|
- formElements.value[startIndex].defaultValue = new Date(Date.now()).toLocaleString('zh-CN', {
|
|
|
- year: 'numeric',
|
|
|
- month: '2-digit',
|
|
|
- day: '2-digit',
|
|
|
- hour: '2-digit',
|
|
|
- minute: '2-digit',
|
|
|
- second: '2-digit',
|
|
|
- hour12: false
|
|
|
- }).replace(/\//g, '-').replace(/, /g, ' ');
|
|
|
+ formElements.value[startIndex].defaultValue = formatDate(new Date())
|
|
|
if (bindName) {
|
|
|
const bindIndex = formElements.value.findIndex((item) => item.elementName === bindName);
|
|
|
if (bindIndex !== -1) {
|
|
|
@@ -233,18 +236,21 @@ function bindTimeRangeData() {
|
|
|
});
|
|
|
}
|
|
|
// 计算时间差
|
|
|
+function calculateBusinessDifference(item, form) {
|
|
|
+ return item.defaultValue = (calculateTimeDifference(item, form)/7).toFixed(2)
|
|
|
+}
|
|
|
function calculateTimeDifference(item, form) {
|
|
|
// 获取 开始时间 和 结束时间
|
|
|
const { startIndex, endIndex } = item.bindTimeRange;
|
|
|
const startTime = new Date(form[startIndex].defaultValue);
|
|
|
const endTime = new Date(form[endIndex].defaultValue);
|
|
|
-
|
|
|
+
|
|
|
// 检查时间是否合法
|
|
|
if (isNaN(startTime.getTime()) || isNaN(endTime.getTime())) {
|
|
|
return item.defaultValue = 0
|
|
|
}
|
|
|
- // 改为配置选择
|
|
|
- const type = item.elementName == '多少小时'?'请假':'加班'
|
|
|
+ // 请假申请的时间差 表单项为合计小时
|
|
|
+ const type = item.elementName == '合计小时' ? '非工作时间' : '工作时间'
|
|
|
// 计算时间差
|
|
|
const timeDifferenceInHours = calculateWorkingHours(startTime, endTime, type);
|
|
|
// const timeDifferenceInMs = endTime - startTime;
|
|
|
@@ -260,12 +266,12 @@ function calculateTimeDifference(item, form) {
|
|
|
// timeDifferenceInHours = Math.floor(timeDifferenceInHours);
|
|
|
// }
|
|
|
// 保存到 defaultValue
|
|
|
- return item.defaultValue = timeDifferenceInHours;
|
|
|
+ return item.defaultValue = Number(timeDifferenceInHours.toFixed(2));
|
|
|
}
|
|
|
let workingPeriods = []
|
|
|
let workDays = [] // 0为周日
|
|
|
function setAttendanceSegment() {
|
|
|
- getAttendanceSegment(userStore.user.unitId).then(({returnParams}) => {
|
|
|
+ getAttendanceSegment(userStore.user.unitId).then(({ returnParams }) => {
|
|
|
const workTime = returnParams[0].work_time.split(';')
|
|
|
for (const time of workTime) {
|
|
|
if (time == '') continue
|
|
|
@@ -283,7 +289,7 @@ function setAttendanceSegment() {
|
|
|
]
|
|
|
}
|
|
|
if (workDays.length == 0) {
|
|
|
- workDays = [1,2,3,4,5,6] // 0为周日
|
|
|
+ workDays = [1, 2, 3, 4, 5, 6, 0] // 0为周日
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
@@ -317,50 +323,50 @@ function calculateWorkingHours(startTime, endTime, type) {
|
|
|
let totalMinutes = 0
|
|
|
|
|
|
// 遍历时间范围的每一天
|
|
|
- for (
|
|
|
- let currentDate = new Date(startDate);
|
|
|
- currentDate <= endDate;
|
|
|
- currentDate.setDate(currentDate.getDate() + 1)
|
|
|
- ) {
|
|
|
- // 如果当前日期不是工作日,跳过
|
|
|
- if (isRestdays(currentDate)) continue;
|
|
|
-
|
|
|
- const isStartDay = currentDate.getTime() === startDate.getTime();
|
|
|
- const isEndDay = currentDate.getTime() === endDate.getTime();
|
|
|
-
|
|
|
- // 当天的起始和结束时间
|
|
|
- const dayStart = isStartDay ? dateToMinutes(startTime) : 0;
|
|
|
- const dayEnd = isEndDay ? dateToMinutes(endTime) : 1440; // 1440 = 24 * 60
|
|
|
- // TODO 改为配置选择
|
|
|
- if (type === "请假") {
|
|
|
- // 计算工作时间段内的时间
|
|
|
- workingPeriods.forEach((period) => {
|
|
|
- const periodStart = formatTime(period.start);
|
|
|
- const periodEnd = formatTime(period.end);
|
|
|
- totalMinutes += calculateOverlap(dayStart, dayEnd, periodStart, periodEnd);
|
|
|
- });
|
|
|
- } else if (type === "加班") {
|
|
|
- // 计算非工作时间段的时间
|
|
|
- let nonWorkingMinutes = 0;
|
|
|
- let current = dayStart;
|
|
|
- for (const period of workingPeriods) {
|
|
|
- const periodStart = formatTime(period.start);
|
|
|
- const periodEnd = formatTime(period.end);
|
|
|
-
|
|
|
- if (current < periodStart) {
|
|
|
- nonWorkingMinutes += calculateOverlap(current, dayEnd, current, periodStart);
|
|
|
- }
|
|
|
- current = Math.max(current, periodEnd);
|
|
|
- }
|
|
|
- if (current < dayEnd) {
|
|
|
- nonWorkingMinutes += dayEnd - current;
|
|
|
- }
|
|
|
- totalMinutes += nonWorkingMinutes;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // 转换为小时
|
|
|
- return totalMinutes / 60;
|
|
|
+ for (
|
|
|
+ let currentDate = new Date(startDate);
|
|
|
+ currentDate <= endDate;
|
|
|
+ currentDate.setDate(currentDate.getDate() + 1)
|
|
|
+ ) {
|
|
|
+ // 如果当前日期不是工作日,跳过
|
|
|
+ if (isRestdays(currentDate)) continue;
|
|
|
+
|
|
|
+ const isStartDay = currentDate.getTime() === startDate.getTime();
|
|
|
+ const isEndDay = currentDate.getTime() === endDate.getTime();
|
|
|
+
|
|
|
+ // 当天的起始和结束时间
|
|
|
+ const dayStart = isStartDay ? dateToMinutes(startTime) : 0;
|
|
|
+ const dayEnd = isEndDay ? dateToMinutes(endTime) : 1440; // 1440 = 24 * 60
|
|
|
+ // TODO 改为配置选择
|
|
|
+ if (type == "工作时间") {
|
|
|
+ // 计算工作时间段内的时间
|
|
|
+ workingPeriods.forEach((period) => {
|
|
|
+ const periodStart = formatTime(period.start);
|
|
|
+ const periodEnd = formatTime(period.end);
|
|
|
+ totalMinutes += calculateOverlap(dayStart, dayEnd, periodStart, periodEnd);
|
|
|
+ });
|
|
|
+ } else if (type == "非工作时间") {
|
|
|
+ // 计算非工作时间段的时间
|
|
|
+ let nonWorkingMinutes = 0;
|
|
|
+ let current = dayStart;
|
|
|
+ for (const period of workingPeriods) {
|
|
|
+ const periodStart = formatTime(period.start);
|
|
|
+ const periodEnd = formatTime(period.end);
|
|
|
+
|
|
|
+ if (current < periodStart) {
|
|
|
+ nonWorkingMinutes += calculateOverlap(current, dayEnd, current, periodStart);
|
|
|
+ }
|
|
|
+ current = Math.max(current, periodEnd);
|
|
|
+ }
|
|
|
+ if (current < dayEnd) {
|
|
|
+ nonWorkingMinutes += dayEnd - current;
|
|
|
+ }
|
|
|
+ totalMinutes += nonWorkingMinutes;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 转换为小时
|
|
|
+ return totalMinutes / 60;
|
|
|
}
|
|
|
|
|
|
function setTimeRange(e) {
|
|
|
@@ -372,12 +378,12 @@ function computedNumberToChineseCurrency(item, form) {
|
|
|
return item.defaultValue = convertToChineseCurrency(elem.defaultValue)
|
|
|
}
|
|
|
function computedValueToRepeatingForm(item) {
|
|
|
- const index = repeatingForm.value.elementItem.findIndex(({elementName}) => elementName.slice(3) == item.BddzText.slice(3))
|
|
|
+ const index = repeatingForm.value.elementItem.findIndex(({ elementName }) => elementName.slice(3) == item.BddzText.slice(3))
|
|
|
let result = 0
|
|
|
- for(const formItem of repeatingForm.value.elements) {
|
|
|
+ for (const formItem of repeatingForm.value.elements) {
|
|
|
result += Number(formItem[index].defaultValue) || 0
|
|
|
}
|
|
|
- return item.defaultValue = result
|
|
|
+ return item.defaultValue = Number(result.toFixed(2))
|
|
|
}
|
|
|
|
|
|
// 下拉框
|
|
|
@@ -432,9 +438,10 @@ function calculateRepeatingFormExpression(item, form) {
|
|
|
}
|
|
|
if (/[^0-9\+\-\*\/\(\)\.]/.test(expression)) {
|
|
|
console.error('错误的表达式:', expression);
|
|
|
- return expression;
|
|
|
+ $modal.msg('自动计算错误,请手动输入')
|
|
|
+ return item.defaultValue = 0;
|
|
|
}
|
|
|
- return item.defaultValue = calCommonExp(expression); // 返回填充后的表达式
|
|
|
+ return item.defaultValue = Number(calCommonExp(expression).toFixed(2)); // 返回填充后的表达式
|
|
|
}
|
|
|
|
|
|
const fileList = ref([]) // 文件列表
|
|
|
@@ -553,8 +560,8 @@ function getValidateRules() {
|
|
|
required: true,
|
|
|
},
|
|
|
// {
|
|
|
- // 类型判断 数值型使用string会出错
|
|
|
- // formatTypeDict: formatTypeDict[elem.fieldType.value] || 'string',
|
|
|
+ // 类型判断 数值型使用string会出错
|
|
|
+ // formatTypeDict: formatTypeDict[elem.fieldType.value] || 'string',
|
|
|
// }
|
|
|
],
|
|
|
label: elem.elementName.slice(3)
|
|
|
@@ -583,10 +590,7 @@ function getValidateRules() {
|
|
|
}
|
|
|
|
|
|
const button_state = ref(true)
|
|
|
-function submitProcess() { // 提交表单
|
|
|
- // 禁用提交按钮
|
|
|
- button_state.value = false
|
|
|
- // validateMainForm()
|
|
|
+function computedMainFormValue() {
|
|
|
// 设置主表校验数据
|
|
|
mainFormValue.value = computed(() => {
|
|
|
const obj = {};
|
|
|
@@ -596,6 +600,15 @@ function submitProcess() { // 提交表单
|
|
|
});
|
|
|
return obj;
|
|
|
}).value
|
|
|
+}
|
|
|
+function submitProcess() { // 提交表单
|
|
|
+ // 禁用提交按钮
|
|
|
+ button_state.value = false
|
|
|
+ // validateMainForm()
|
|
|
+ computedMainFormValue()
|
|
|
+ console.log('mainFormValue: ',mainFormValue.value);$mainForm
|
|
|
+ console.log('$mainFormRules: ',$mainFormRules.value);
|
|
|
+ console.log('$mainForm: ',$mainForm.value);
|
|
|
// 主表数据校验
|
|
|
$mainForm.value.validate().then(res => {
|
|
|
|
|
|
@@ -660,21 +673,26 @@ function submitProcess() { // 提交表单
|
|
|
|
|
|
.uni-forms-item__content {
|
|
|
.uni-easyinput__content-textarea {
|
|
|
- font-size: calc(14px + .5*(1rem - 16px)) !important;
|
|
|
+ font-size: calc(14px + 1.2*(1rem - 16px)) !important;
|
|
|
+ font-weight: 500;
|
|
|
}
|
|
|
|
|
|
.uni-easyinput__content-input {
|
|
|
- font-size: calc(14px + .5*(1rem - 16px)) !important;
|
|
|
+ font-size: calc(14px + 1.2*(1rem - 16px)) !important;
|
|
|
+ font-weight: 500;
|
|
|
color: #333;
|
|
|
}
|
|
|
|
|
|
.uni-date {
|
|
|
.uni-icons {
|
|
|
- font-size: calc(22px + .5*(1rem - 16px)) !important;
|
|
|
+ font-size: calc(22px + 1.2*(1rem - 16px)) !important;
|
|
|
+ font-weight: 500;
|
|
|
}
|
|
|
|
|
|
.uni-date__x-input {
|
|
|
- font-size: calc(14px + .5*(1rem - 16px)) !important;
|
|
|
+ height: auto;
|
|
|
+ font-size: calc(14px + 1.2*(1rem - 16px)) !important;
|
|
|
+ font-weight: 500;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -731,6 +749,7 @@ function submitProcess() { // 提交表单
|
|
|
::v-deep .uni-card {
|
|
|
.uni-card__header-content-title {
|
|
|
font-size: calc(15px + .5*(1rem - 16px));
|
|
|
+ font-weight: 700;
|
|
|
}
|
|
|
|
|
|
.uni-card__header-extra-text {
|
|
|
@@ -792,4 +811,50 @@ function submitProcess() { // 提交表单
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+::v-deep .uni-calendar__content {
|
|
|
+ margin: -20px;
|
|
|
+ margin-top: 20px;
|
|
|
+ .uni-calendar__header {
|
|
|
+ .uni-calendar__header-text {
|
|
|
+ font-size: calc(14px + .5*(1rem - 16px)) !important;
|
|
|
+ }
|
|
|
+ .uni-calendar__backtoday {
|
|
|
+ padding: 2px 8px 2px 10px !important;
|
|
|
+ font-size: calc(0.75rem + 0px) !important;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .uni-calendar__box {
|
|
|
+ .uni-calendar__weeks {
|
|
|
+ .uni-calendar__weeks-day {
|
|
|
+ .uni-calendar__weeks-day-text {
|
|
|
+ font-size: calc(14px + .5*(1rem - 16px)) !important;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .uni-calendar__weeks-item {
|
|
|
+ .uni-calendar-item__weeks-box-item {
|
|
|
+ .uni-calendar-item__weeks-box-circle {
|
|
|
+ width: calc(8px + .5*(1rem - 16px)) !important;
|
|
|
+ height: calc(8px + .5*(1rem - 16px)) !important;
|
|
|
+ top: calc(5px - .25*(1rem - 16px)) !important;
|
|
|
+ right: calc(5px - .25*(1rem - 16px)) !important;
|
|
|
+ }
|
|
|
+ .uni-calendar-item__weeks-box-text {
|
|
|
+ font-size: calc(14px + .5*(1rem - 16px)) !important;
|
|
|
+ }
|
|
|
+ .uni-calendar-item__weeks-lunar-text {
|
|
|
+ font-size: calc(12px + .5*(1rem - 16px)) !important;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .uni-date-changed {
|
|
|
+ .uni-date-changed--time-date {
|
|
|
+ font-size: calc(14px + 1*(1rem - 16px)) !important;
|
|
|
+ }
|
|
|
+ .uni-datetime-picker-text {
|
|
|
+ font-size: calc(14px + 1*(1rem - 16px)) !important;
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
</style>
|