licailing 4 лет назад
Родитель
Сommit
a44637f3b6

+ 5 - 1
src/main/java/com/izouma/wenlvju/service/PerformanceApplyService.java

@@ -1,6 +1,7 @@
 package com.izouma.wenlvju.service;
 
 import cn.hutool.core.util.ObjectUtil;
+import cn.hutool.core.util.StrUtil;
 import com.alibaba.fastjson.JSONObject;
 import com.izouma.wenlvju.domain.ArtType;
 import com.izouma.wenlvju.domain.Organization;
@@ -160,6 +161,9 @@ public class PerformanceApplyService {
 
 
     public void saveArrangement(String applies) {
+        if (StrUtil.isEmpty(applies)) {
+            return;
+        }
         List<PerformanceApply> applyList = JSONObject.parseArray(applies, PerformanceApply.class);
         List<Long> ids = applyList.stream().map(PerformanceApply::getId).collect(Collectors.toList());
         Map<Long, PerformanceApply> applyMap = performanceApplyRepo.findAllById(ids)
@@ -168,7 +172,7 @@ public class PerformanceApplyService {
 
         applyList.forEach(list -> {
             PerformanceApply apply = applyMap.get(list.getId());
-            if (ObjectUtil.isNull(apply)){
+            if (ObjectUtil.isNotNull(apply)) {
                 ObjUtils.merge(apply, list);
                 performanceApplyRepo.save(apply);
             }

+ 26 - 5
src/main/vue/src/views/PerformanceApplyList2.vue

@@ -3,7 +3,12 @@
         <div class="filters-container">
             <!-- <el-input placeholder="输入关键字" v-model="search" clearable class="filter-item"></el-input>
             <el-button @click="getData" type="primary" icon="el-icon-search" class="filter-item">搜索 </el-button> -->
-            <el-button @click="openArrangement" type="primary" class="filter-item" :loading="loading"
+            <el-button
+                @click="openArrangement"
+                type="primary"
+                class="filter-item"
+                :loading="loading"
+                v-if="totalElements > 0"
                 >自动编排
             </el-button>
             <el-button @click="distribute('已成功通知')" type="primary" class="filter-item">一键通知 </el-button>
@@ -37,7 +42,9 @@
             <el-table-column prop="contact" label="联系人"> </el-table-column>
             <el-table-column prop="phone" label="联系电话"> </el-table-column>
             <el-table-column prop="status" label="状态" :formatter="statusFormatter"> </el-table-column>
-            <el-table-column prop="showTime" label="表演时间" min-width="120"> </el-table-column>
+            <el-table-column label="表演时间" min-width="120">
+                <template slot-scope="{ row }"> {{ row.showStartTime }} 至 {{ row.showEndTime }} </template>
+            </el-table-column>
             <el-table-column prop="awards" label="奖项">
                 <template slot-scope="{ row }">
                     <span v-if="row.awards != null"> {{ row.awards }} </span>
@@ -199,6 +206,13 @@ export default {
     computed: {
         selection() {
             return this.$refs.table.selection.map(i => i.id);
+        },
+        saveOtherJson() {
+            const timeList = [...this.timeList].filter(item => {
+                return !!item.composition || !!item.showStartTime || !!item.showEndTime || !!item.organizationId;
+            });
+
+            return JSON.stringify(timeList);
         }
     },
     methods: {
@@ -330,11 +344,11 @@ export default {
             this.loading = true;
             this.$http
                 .post('/performanceApply/saveArrangement', {
-                    applies: ''
+                    applies: this.saveOtherJson
                 })
                 .then(res => {
                     this.loading = false;
-                    this.$message.success('OK');
+                    this.$message.success('自动编排成功');
                     this.getData();
                     this.dialogArrangement = false;
                 })
@@ -416,7 +430,14 @@ export default {
                 ...endInfo
             };
 
-            this.timeList = timeList;
+            this.timeList = this.sortByKey(timeList);
+        },
+        sortByKey(array) {
+            return array.sort(function(a, b) {
+                var x = a['showStartTime'];
+                var y = b['showStartTime'];
+                return x < y ? -1 : x > y ? 1 : 0;
+            });
         }
     }
 };