|
|
@@ -10,6 +10,7 @@ use App\Model\Depart;
|
|
|
use App\Model\Device;
|
|
|
use App\Model\Employee;
|
|
|
use App\Model\EmployeeDepartPermission;
|
|
|
+use App\Model\ExpenseClaimsDetails;
|
|
|
use App\Model\Fee;
|
|
|
use App\Model\Item;
|
|
|
use App\Model\ItemDetails;
|
|
|
@@ -3722,12 +3723,12 @@ class ImportService extends Service
|
|
|
if ($fieldKey == 'fee_id') $fieldVal = $maps['fees'][$fieldVal] ?? 0;
|
|
|
|
|
|
// 转换枚举值(委托方式、是否定位到人)
|
|
|
- if ($fieldKey == 'entrust_type') {
|
|
|
- $fieldVal = array_search($fieldVal, \App\Model\ExpenseClaimsDetails::State_Type) ?: 0;
|
|
|
- }
|
|
|
- if ($fieldKey == 'expense_type') {
|
|
|
- $fieldVal = array_search($fieldVal, \App\Model\ExpenseClaimsDetails::State_Type_2) ?: 0;
|
|
|
- }
|
|
|
+// if ($fieldKey == 'entrust_type') {
|
|
|
+// $fieldVal = array_search($fieldVal, \App\Model\ExpenseClaimsDetails::State_Type) ?: 0;
|
|
|
+// }
|
|
|
+// if ($fieldKey == 'expense_type') {
|
|
|
+// $fieldVal = array_search($fieldVal, \App\Model\ExpenseClaimsDetails::State_Type_2) ?: 0;
|
|
|
+// }
|
|
|
|
|
|
// 注意:claim_date 已经在 check 方法里转成了时间戳,这里直接赋值即可
|
|
|
$detailTmp[$fieldKey] = $fieldVal;
|
|
|
@@ -3804,6 +3805,13 @@ class ImportService extends Service
|
|
|
$itemIdx = array_search('item_id', $keys);
|
|
|
$feeIdx = array_search('fee_id', $keys);
|
|
|
$claimDateIdx = array_search('claim_date', $keys);
|
|
|
+ $amountIdx = array_search('amount', $keys);
|
|
|
+ $eAmountIdx = array_search('entrust_amount', $keys);
|
|
|
+ $eTypeIdx = array_search('entrust_type', $keys);
|
|
|
+ $exTypeIdx = array_search('expense_type', $keys);
|
|
|
+
|
|
|
+ $state_map = array_flip(ExpenseClaimsDetails::State_Type);
|
|
|
+ $ex_map = array_flip(ExpenseClaimsDetails::State_Type_2);
|
|
|
|
|
|
$topDepartId = $user['top_depart_id'];
|
|
|
$errors = [];
|
|
|
@@ -3906,6 +3914,43 @@ class ImportService extends Service
|
|
|
$errors[] = "第{$line}行:月份[" . date('Y-m', $valMonthTs) . "]已存在单据[{$existingMonthsMap[$valMonthTs]}],请填写该单号进行编辑";
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ // 数字格式校验
|
|
|
+ $amount = $row[$amountIdx];
|
|
|
+ $res = $this->checkNumber($amount, 2, 'non-negative');
|
|
|
+ if (!$res['valid']) $errors[] = "第{$line}行费用金额:" . $res['error'];
|
|
|
+
|
|
|
+ // 委托方式
|
|
|
+ $e_text = $row[$eTypeIdx] ?? '';
|
|
|
+ if (!isset($state_map[$e_text])) {
|
|
|
+ $errors[] = "第{$line}行:委托方式[{$e_text}]无效";
|
|
|
+ } else {
|
|
|
+ $v_tmp = $state_map[$e_text];
|
|
|
+ $array[$rowIndex][$eTypeIdx] = $v_tmp;
|
|
|
+
|
|
|
+ if($v_tmp > 0){
|
|
|
+ $e2_text = $row[$eAmountIdx];
|
|
|
+ if($e2_text == '') {
|
|
|
+ $errors[] = "第{$line}行:{$e_text}金额必填";
|
|
|
+ }else{
|
|
|
+ $res = $this->checkNumber($e2_text, 2, 'non-negative');
|
|
|
+ if (!$res['valid']) {
|
|
|
+ $errors[] = "第{$line}行:{$e_text}金额" . $res['error'];
|
|
|
+ }else{
|
|
|
+ if($e2_text > $amount) $errors[] = "第{$line}行:{$e_text}金额不能超过费用金额";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //是否定位到人
|
|
|
+ $ex_text = $row[$exTypeIdx] ?? '';
|
|
|
+ if (!isset($ex_map[$ex_text])) {
|
|
|
+ $errors[] = "第{$line}行:是否定位到人[{$ex_text}]无效";
|
|
|
+ } else {
|
|
|
+ $v_tmp = $ex_map[$ex_text];
|
|
|
+ $array[$rowIndex][$exTypeIdx] = $v_tmp;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
$maps = ['emps' => $dbEmps, 'items' => $dbItems, 'fees' => $dbFees];
|