|
@@ -23,6 +23,7 @@ use Illuminate\Support\Facades\DB;
|
|
|
|
|
|
|
|
class ItemService extends Service
|
|
class ItemService extends Service
|
|
|
{
|
|
{
|
|
|
|
|
+ // 项目 任务 节点 都可以用的 文件上传 文件删除 更改交付物状态
|
|
|
public function itemFileUpLoad($data,$user){
|
|
public function itemFileUpLoad($data,$user){
|
|
|
// 1. 基础校验
|
|
// 1. 基础校验
|
|
|
$from = $data['from'] ?? null;
|
|
$from = $data['from'] ?? null;
|
|
@@ -140,6 +141,59 @@ class ItemService extends Service
|
|
|
return [true, ''];
|
|
return [true, ''];
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ public function itemFileIsDelivery($data, $user)
|
|
|
|
|
+ {
|
|
|
|
|
+ $typeMap = [
|
|
|
|
|
+ 1 => '标记为交付物',
|
|
|
|
|
+ 2 => '解除交付物',
|
|
|
|
|
+ ];
|
|
|
|
|
+ $fromMap = [
|
|
|
|
|
+ 'custom_fields' => CustomFieldValue::class,
|
|
|
|
|
+ 'item_file' => ItemFile::class,
|
|
|
|
|
+ ];
|
|
|
|
|
+
|
|
|
|
|
+ if (empty($data['opt_type']) || !isset($typeMap[$data['opt_type']])) return [false, '操作标识错误'];
|
|
|
|
|
+ if (empty($data['data']) || !is_array($data['data'])) return [false, '文件数据不能为空'];
|
|
|
|
|
+
|
|
|
|
|
+ // 状态值映射
|
|
|
|
|
+ $statusValue = ($data['opt_type'] == 1) ? 1 : 0;
|
|
|
|
|
+
|
|
|
|
|
+ $idsByType = [
|
|
|
|
|
+ 'custom_fields' => [],
|
|
|
|
|
+ 'item_file' => [],
|
|
|
|
|
+ ];
|
|
|
|
|
+
|
|
|
|
|
+ foreach ($data['data'] as $value) {
|
|
|
|
|
+ if (empty($value['id'])) return [false, '文件ID不能为空'];
|
|
|
|
|
+ if (empty($value['type']) || !isset($fromMap[$value['type']])) return [false, '文件类型错误'];
|
|
|
|
|
+
|
|
|
|
|
+ $idsByType[$value['type']][] = $value['id'];
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ try {
|
|
|
|
|
+ DB::beginTransaction();
|
|
|
|
|
+
|
|
|
|
|
+ foreach ($idsByType as $type => $ids) {
|
|
|
|
|
+ if (!empty($ids)) {
|
|
|
|
|
+ $modelClass = $fromMap[$type];
|
|
|
|
|
+ $modelClass::whereIn('id', $ids)->update([
|
|
|
|
|
+ 'is_delivery' => $statusValue,
|
|
|
|
|
+ ]);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ DB::commit();
|
|
|
|
|
+ } catch (\Exception $exception) {
|
|
|
|
|
+ DB::rollBack();
|
|
|
|
|
+ return [false, $exception->getMessage()];
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return [true, ''];
|
|
|
|
|
+ }
|
|
|
|
|
+ // 项目 任务 节点 都可以用的 文件上传 文件删除 更改交付物状态
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
public function itemEdit($data,$user){
|
|
public function itemEdit($data,$user){
|
|
|
list($status,$msg) = $this->itemRule($data, $user, false);
|
|
list($status,$msg) = $this->itemRule($data, $user, false);
|
|
|
if(!$status) return [$status,$msg];
|
|
if(!$status) return [$status,$msg];
|