Selaa lähdekoodia

feature_20260228_周报半月报动态配置

zhujindu 6 päivää sitten
vanhempi
commit
fb0bd587ce
1 muutettua tiedostoa jossa 259 lisäystä ja 167 poistoa
  1. 259 167
      src/views/week/weekly.vue

+ 259 - 167
src/views/week/weekly.vue

@@ -90,102 +90,109 @@
             </van-row>
           </van-collapse-item>
         </template>
-        <van-collapse-item title="上周工作成果" name="8">
-          <div style="margin-top: -10px">
-            <div v-for="(item2, index2) in reportContentsList2" :key="index2">
-              <div v-if="index2 < 7">
-                <p class="texttitle">
+        <!-- isHistory 是否为历史汇报:0-新汇报 1-历史汇报 -->
+        <reportCustom
+          ref="reportCustom"
+          v-if="reportTarget.isHistory == '0'"
+          :reportCustomData="reportTarget.customTaskList"></reportCustom>
+        <template>
+          <van-collapse-item title="上周工作成果" name="8">
+            <div style="margin-top: -10px">
+              <div v-for="(item2, index2) in reportContentsList2" :key="index2">
+                <div v-if="index2 < 7">
+                  <p class="texttitle">
+                    <span class="opint"></span
+                    ><span v-if="!reportTarget.hideWeekDate">{{
+                      weeklyTimeDivision(item2.contentTime, 0)
+                    }}</span
+                    ><span>{{ weeklyTimeDivision(item2.contentTime, 1) }}</span
+                    ><span v-if="index2 < 5" class="colorRed">(必填)</span>
+                  </p>
+                  <p>
+                    <span class="blackcolor">上午:</span
+                    >{{ reportContentsList3[index2].weekContentAm }}
+                  </p>
+                  <p>
+                    <span class="blackcolor">下午:</span
+                    >{{ reportContentsList3[index2].weekContentPm }}
+                  </p>
+                  <p class="texttitle texttitle2">实际工作进度</p>
+                  <p>
+                    <van-field
+                      class="weeklyinput"
+                      v-model="item2.weekContentAm"
+                      label="上午:"
+                      placeholder="请输入" />
+                    <van-field
+                      class="weeklyinput"
+                      v-model="item2.weekContentPm"
+                      label="下午:"
+                      placeholder="请输入" />
+                  </p>
+                </div>
+                <p v-if="index2 == 7" class="texttitle"><span class="opint"></span>上周工作重点</p>
+                <div v-if="index2 == 7" style="padding: 10px 0" class="contentContainer1">
+                  <van-field
+                    v-model="reportContentsList3[index2].weekContentSummary"
+                    rows="4"
+                    autosize
+                    readonly
+                    type="textarea" />
+                </div>
+                <p v-if="index2 == 7" class="texttitle">
+                  <span class="opint"></span>上周工作成果<span class="colorRed">(必填)</span>
+                </p>
+                <div v-if="index2 == 7" style="padding: 10px 0" class="contentContainer">
+                  <van-field
+                    v-model="item2.weekContentSummary"
+                    rows="4"
+                    autosize
+                    maxlength="800"
+                    show-word-limit
+                    type="textarea" />
+                </div>
+              </div>
+            </div>
+          </van-collapse-item>
+          <van-collapse-item title="本周工作规划" name="9">
+            <div style="margin-top: -10px">
+              <div v-for="(item, index) in reportContentsList1" :key="index">
+                <p class="texttitle" v-if="index < 7">
                   <span class="opint"></span
                   ><span v-if="!reportTarget.hideWeekDate">{{
-                    weeklyTimeDivision(item2.contentTime, 0)
+                    weeklyTimeDivision(item.contentTime, 0)
                   }}</span
-                  ><span>{{ weeklyTimeDivision(item2.contentTime, 1) }}</span
-                  ><span v-if="index2 < 5" class="colorRed">(必填)</span>
+                  ><span>{{ weeklyTimeDivision(item.contentTime, 1) }}</span
+                  ><span v-if="index < 5" class="colorRed">(必填)</span>
                 </p>
-                <p>
-                  <span class="blackcolor">上午:</span
-                  >{{ reportContentsList3[index2].weekContentAm }}
-                </p>
-                <p>
-                  <span class="blackcolor">下午:</span
-                  >{{ reportContentsList3[index2].weekContentPm }}
-                </p>
-                <p class="texttitle texttitle2">实际工作进度</p>
-                <p>
+                <p v-if="index < 7">
                   <van-field
                     class="weeklyinput"
-                    v-model="item2.weekContentAm"
                     label="上午:"
-                    placeholder="请输入" />
+                    placeholder="请输入"
+                    v-model="item.weekContentAm" />
                   <van-field
                     class="weeklyinput"
-                    v-model="item2.weekContentPm"
                     label="下午:"
-                    placeholder="请输入" />
+                    placeholder="请输入"
+                    v-model="item.weekContentPm" />
                 </p>
-              </div>
-              <p v-if="index2 == 7" class="texttitle"><span class="opint"></span>上周工作重点</p>
-              <div v-if="index2 == 7" style="padding: 10px 0" class="contentContainer1">
-                <van-field
-                  v-model="reportContentsList3[index2].weekContentSummary"
-                  rows="4"
-                  autosize
-                  readonly
-                  type="textarea" />
-              </div>
-              <p v-if="index2 == 7" class="texttitle">
-                <span class="opint"></span>上周工作成果<span class="colorRed">(必填)</span>
-              </p>
-              <div v-if="index2 == 7" style="padding: 10px 0" class="contentContainer">
-                <van-field
-                  v-model="item2.weekContentSummary"
-                  rows="4"
-                  autosize
-                  maxlength="800"
-                  show-word-limit
-                  type="textarea" />
-              </div>
-            </div>
-          </div>
-        </van-collapse-item>
-        <van-collapse-item title="本周工作规划" name="9">
-          <div style="margin-top: -10px">
-            <div v-for="(item, index) in reportContentsList1" :key="index">
-              <p class="texttitle" v-if="index < 7">
-                <span class="opint"></span
-                ><span v-if="!reportTarget.hideWeekDate">{{
-                  weeklyTimeDivision(item.contentTime, 0)
-                }}</span
-                ><span>{{ weeklyTimeDivision(item.contentTime, 1) }}</span
-                ><span v-if="index < 5" class="colorRed">(必填)</span>
-              </p>
-              <p v-if="index < 7">
-                <van-field
-                  class="weeklyinput"
-                  label="上午:"
-                  placeholder="请输入"
-                  v-model="item.weekContentAm" />
-                <van-field
-                  class="weeklyinput"
-                  label="下午:"
-                  placeholder="请输入"
-                  v-model="item.weekContentPm" />
-              </p>
-              <p v-if="index == 7" class="texttitle">
-                <span class="opint"></span>本周工作重点<span class="colorRed">(必填)</span>
-              </p>
-              <div v-if="index == 7" style="padding: 10px 0" class="contentContainer">
-                <van-field
-                  v-model="item.weekContentSummary"
-                  rows="4"
-                  autosize
-                  maxlength="800"
-                  show-word-limit
-                  type="textarea" />
+                <p v-if="index == 7" class="texttitle">
+                  <span class="opint"></span>本周工作重点<span class="colorRed">(必填)</span>
+                </p>
+                <div v-if="index == 7" style="padding: 10px 0" class="contentContainer">
+                  <van-field
+                    v-model="item.weekContentSummary"
+                    rows="4"
+                    autosize
+                    maxlength="800"
+                    show-word-limit
+                    type="textarea" />
+                </div>
               </div>
             </div>
-          </div>
-        </van-collapse-item>
+          </van-collapse-item>
+        </template>
       </van-collapse>
       <br />
       <br />
@@ -209,6 +216,7 @@ import cizhuanjiaoSAP from '@/views/componentsTarget/cizhuanjiaoSAP';
 import neiqiangzhonggaoduanSAP from '@/views/componentsTarget/neiqiangzhonggaoduanSAP';
 import moshouqiSAP from '@/views/componentsTarget/moshouqiSAP';
 import fangshuiSAP from '@/views/componentsTarget/fangshuiSAP';
+import reportCustom from './reportCustom';
 export default {
   name: 'home',
   components: {
@@ -223,6 +231,7 @@ export default {
     neiqiangzhonggaoduanSAP,
     moshouqiSAP,
     fangshuiSAP,
+    reportCustom,
   },
   data() {
     return {
@@ -305,7 +314,7 @@ export default {
           var dayTime = res.data.date;
           this.type = res.data.userType;
           this.timeList = this.parseTimeParagraph(
-            dayTime.slice(0, 4) + '-' + dayTime.slice(4, 6) + '-' + dayTime.slice(6, 8)
+            dayTime.slice(0, 4) + '-' + dayTime.slice(4, 6) + '-' + dayTime.slice(6, 8),
           );
           if (res.data.status != '0' && res.data.status != '2') {
             this.$dialog
@@ -417,37 +426,102 @@ export default {
         forbidClick: true,
       });
       if (this.isclick) {
-        this.reportTarget.reportContents = [];
-        this.reportTarget.reportContents = this.reportContentsList2
-          .concat(this.reportContentsList1)
-          .concat(this.reportContentsList3);
-        this.reportTarget.status = '1';
-        console.log(this.reportContentsList1);
-        console.log(this.reportContentsList2);
-        console.log(this.reportContentsList3);
-        console.log(this.reportTarget.reportContents);
-        this.isclick = false;
-        tsContents(this.reportTarget).then((res) => {
-          loading1.clear();
-          this.isclick = true;
-          if (res.code == 200) {
-            this.$dialog
-              .alert({
-                title: '系统提示',
-                message: '暂存成功',
-              })
-              .then(() => {
-                // if(this.$route.query.reportId!=undefined){
-                //   window.location.replace(window.location.origin+"/mobile/myHistoricalDaily")
-                // }else{
-                //   window.location.replace(window.location.origin+"/mobile/home")
-                // }
-              });
+        if (this.reportTarget.isHistory == '1') {
+          this.reportTarget.reportContents = [];
+          this.reportTarget.reportContents = this.reportContentsList2
+            .concat(this.reportContentsList1)
+            .concat(this.reportContentsList3);
+          console.log(this.reportContentsList1);
+          console.log(this.reportContentsList2);
+          console.log(this.reportContentsList3);
+          console.log(this.reportTarget.reportContents);
+        } else {
+          // 新的
+          if (this.reportTarget.customTaskList && this.reportTarget.customTaskList.length) {
+            // 配置任务
+            this.filterReportCustomData((reportCustomAnswers) => {
+              this.tsContentsFun(reportCustomAnswers);
+            });
           } else {
-            this.$toast.fail(res.msg);
+            // 没有配置任务
+            this.tsContentsFun(null);
           }
+        }
+      }
+    },
+    tsContentsFun(reportCustomAnswers) {
+      if (reportCustomAnswers) this.reportTarget.reportCustomAnswers = reportCustomAnswers;
+      this.reportTarget.status = '1';
+      this.isclick = false;
+      tsContents(this.reportTarget).then((res) => {
+        loading1.clear();
+        this.isclick = true;
+        if (res.code == 200) {
+          this.$dialog
+            .alert({
+              title: '系统提示',
+              message: '暂存成功',
+            })
+            .then(() => {
+              // if(this.$route.query.reportId!=undefined){
+              //   window.location.replace(window.location.origin+"/mobile/myHistoricalDaily")
+              // }else{
+              //   window.location.replace(window.location.origin+"/mobile/home")
+              // }
+            });
+        } else {
+          this.$toast.fail(res.msg);
+        }
+      });
+    },
+    reportCustomTabstoreVal(callback) {
+      // 必填校验
+      this.$refs.reportCustom.$refs.tabstoreVal
+        .validate()
+        .then(() => {
+          // 验证通过
+          this.filterReportCustomData(callback);
+        })
+        .catch((errors) => {
+          this.toastLoading().clear();
+          return;
         });
+    },
+    filterReportCustomData(callback) {
+      let reportCustomData = this.$refs.reportCustom ? this.$refs.reportCustom.fromData : {} || {};
+      let reportCustomAnswers = [];
+      for (let i = 0; i < reportCustomData.length; i++) {
+        let customData = reportCustomData[i].sfaReportCustomCollections
+          ? reportCustomData[i].sfaReportCustomCollections
+          : [];
+        for (let x = 0; x < customData.length; x++) {
+          if (
+            customData[x].reportCustomCollectionType == 'dx' ||
+            customData[x].reportCustomCollectionType == 'duox'
+          ) {
+            let optionData = customData[x].sfaReportCustomOptions;
+            for (let y = 0; y < optionData.length; y++) {
+              if (optionData[y].answerValue == 'Y') {
+                reportCustomAnswers.push({
+                  reportCustomTaskId: customData[x].reportCustomTaskId,
+                  reportCustomCollectionId: optionData[y].reportCustomCollectionId,
+                  reportCustomOptionId: optionData[y].reportCustomOptionId,
+                  answerValue: 'Y',
+                });
+              }
+            }
+          } else {
+            if (customData[x].answerValue)
+              reportCustomAnswers.push({
+                reportCustomTaskId: customData[x].reportCustomTaskId,
+                reportCustomCollectionId: customData[x].reportCustomCollectionId,
+                answerValue: customData[x].answerValue,
+              });
+          }
+        }
       }
+      console.log(reportCustomAnswers);
+      callback && callback(reportCustomAnswers);
     },
     // 提交日报
     submint() {
@@ -457,69 +531,87 @@ export default {
         forbidClick: true,
       });
       if (this.isclick) {
-        this.reportTarget.reportContents = [];
-        for (var j = 0; j < 5; j++) {
-          if (
-            this.reportContentsList1[j].weekContentAm.trim() == '' ||
-            this.reportContentsList1[j].weekContentPm.trim() == ''
-          ) {
-            this.$toast('请完善本周规划内容!');
+        // 旧的
+        if (this.reportTarget.isHistory == '1') {
+          this.reportTarget.reportContents = [];
+          for (var j = 0; j < 5; j++) {
+            if (
+              this.reportContentsList1[j].weekContentAm.trim() == '' ||
+              this.reportContentsList1[j].weekContentPm.trim() == ''
+            ) {
+              this.$toast('请完善本周规划内容!');
+              return false;
+            }
+          }
+          for (var x = 0; x < 5; x++) {
+            if (
+              this.reportContentsList2[x].weekContentAm.trim() == '' ||
+              this.reportContentsList2[x].weekContentPm.trim() == ''
+            ) {
+              this.$toast('请完善上周周报内容!');
+              return false;
+            }
+          }
+          if (this.reportContentsList2[7].weekContentSummary.trim() == '') {
+            this.$toast('请完善上周工作成果!');
             return false;
           }
-        }
-        for (var x = 0; x < 5; x++) {
-          if (
-            this.reportContentsList2[x].weekContentAm.trim() == '' ||
-            this.reportContentsList2[x].weekContentPm.trim() == ''
-          ) {
-            this.$toast('请完善上周周报内容!');
+          if (this.reportContentsList1[7].weekContentSummary.trim() == '') {
+            this.$toast('请完善本周工作重点!');
             return false;
           }
-        }
-        if (this.reportContentsList2[7].weekContentSummary.trim() == '') {
-          this.$toast('请完善上周工作成果!');
-          return false;
-        }
-        if (this.reportContentsList1[7].weekContentSummary.trim() == '') {
-          this.$toast('请完善本周工作重点!');
-          return false;
-        }
-        if (this.reportContentsList1[7].weekContentSummary.length > 800) {
-          this.$toast('上周工作重点超过800字');
-          return false;
-        }
-        if (this.reportContentsList2[7].weekContentSummary.length > 800) {
-          this.$toast('上周工作成果超过800字!');
-          return false;
-        }
-        this.reportTarget.reportContents = this.reportContentsList2
-          .concat(this.reportContentsList1)
-          .concat(this.reportTarget.reportContents);
-        this.reportTarget.status = '1';
-        this.isclick = false;
-        updateReport(this.reportTarget).then((res) => {
-          loading1.clear();
-          this.isclick = true;
-          if (res.code == 200) {
-            this.$dialog
-              .alert({
-                title: '系统提示',
-                message: '提交成功',
-              })
-              .then(() => {
-                if (this.$route.query.reportId != undefined) {
-                  window.location.replace(window.location.origin + '/mobile/myHistoricalDaily');
-                } else {
-                  this.onClickLeft();
-                  // window.location.replace(window.location.origin + '/mobile/home');
-                }
-              });
+          if (this.reportContentsList1[7].weekContentSummary.length > 800) {
+            this.$toast('上周工作重点超过800字');
+            return false;
+          }
+          if (this.reportContentsList2[7].weekContentSummary.length > 800) {
+            this.$toast('上周工作成果超过800字!');
+            return false;
+          }
+          this.reportTarget.reportContents = this.reportContentsList2
+            .concat(this.reportContentsList1)
+            .concat(this.reportTarget.reportContents);
+          this.submintFun();
+        } else {
+          // 新的
+          if (this.reportTarget.customTaskList && this.reportTarget.customTaskList.length) {
+            // 配置任务
+            this.reportCustomTabstoreVal((reportCustomAnswers) => {
+              this.submintFun(reportCustomAnswers);
+            });
           } else {
-            this.$toast.fail(res.msg);
+            // 没有配置任务
+            this.submintFun(null);
           }
-        });
+        }
       }
     },
+    submintFun(reportCustomAnswers) {
+      if (reportCustomAnswers) this.reportTarget.reportCustomAnswers = reportCustomAnswers;
+      this.reportTarget.status = '1';
+      this.isclick = false;
+      updateReport(this.reportTarget).then((res) => {
+        loading1.clear();
+        this.isclick = true;
+        if (res.code == 200) {
+          this.$dialog
+            .alert({
+              title: '系统提示',
+              message: '提交成功',
+            })
+            .then(() => {
+              if (this.$route.query.reportId != undefined) {
+                window.location.replace(window.location.origin + '/mobile/myHistoricalDaily');
+              } else {
+                this.onClickLeft();
+                // window.location.replace(window.location.origin + '/mobile/home');
+              }
+            });
+        } else {
+          this.$toast.fail(res.msg);
+        }
+      });
+    },
     getReportInfo() {
       let loading1 = this.$toast.loading({
         duration: 0,
@@ -534,7 +626,7 @@ export default {
         var dayTime = res.data.date;
         this.YFQuota = res.data.postType == 'YF' ? true : false;
         this.timeList = this.parseTimeParagraph(
-          dayTime.slice(0, 4) + '-' + dayTime.slice(4, 6) + '-' + dayTime.slice(6, 8)
+          dayTime.slice(0, 4) + '-' + dayTime.slice(4, 6) + '-' + dayTime.slice(6, 8),
         );
         this.powerGrade = res.data.positionId;
         this.showButton = res.data.showButton;