deason 6 éve
szülő
commit
a81f70aead
1 módosított fájl, 349 hozzáadás és 32 törlés
  1. 349 32
      src/modules/print/view/ProjectStatistic.vue

+ 349 - 32
src/modules/print/view/ProjectStatistic.vue

@@ -120,7 +120,7 @@
                 size="mini"
                 icon="el-icon-menu"
                 v-if="scope.row.btnType == 'BACKUP'"
-                @click="editBackupSetting(scope.row);"
+                @click="openBackupSettingDialog"
                 :disabled="!hasPermit"
                 >备份设置
               </el-button>
@@ -148,6 +148,96 @@
         </el-table>
       </div>
 
+      <!-- 备份设置弹窗 -->
+      <el-dialog
+        title="备份设置"
+        width="500px"
+        :visible.sync="backupSettingDialog"
+        @close="closeBackupSettingDialog"
+      >
+        <el-form
+          :model="backupSettingForm"
+          ref="backupSettingForm"
+          :rules="rules"
+          label-position="right"
+          label-width="80px"
+        >
+          <el-tabs v-model="eachPkgTab">
+            <el-tab-pane name="first">
+              <span slot="label"
+                >每袋冗余设置
+                <el-switch v-model="backupSettingForm.needEachPkg"></el-switch
+              ></span>
+              <el-form-item label="比例" prop="eachPkgPercent">
+                <el-input
+                  v-model="backupSettingForm.eachPkgPercent"
+                  :disabled="!backupSettingForm.needEachPkg"
+                ></el-input>
+              </el-form-item>
+              <el-form-item label="最大" prop="eachPkgMax">
+                <el-input
+                  v-model="backupSettingForm.eachPkgMax"
+                  :disabled="!backupSettingForm.needEachPkg"
+                ></el-input>
+              </el-form-item>
+              <el-form-item label="最小" prop="eachPkgMin">
+                <el-input
+                  v-model="backupSettingForm.eachPkgMin"
+                  :disabled="!backupSettingForm.needEachPkg"
+                ></el-input>
+              </el-form-item>
+            </el-tab-pane>
+          </el-tabs>
+
+          <el-tabs v-model="alonePkgTab">
+            <el-tab-pane name="first">
+              <span slot="label"
+                >单独备份袋设置
+                <el-switch v-model="backupSettingForm.needAlonePkg"></el-switch
+              ></span>
+              <el-form-item label="归集参数" prop="groupType">
+                <el-select
+                  v-model="backupSettingForm.groupType"
+                  :disabled="!backupSettingForm.needAlonePkg"
+                  placeholder="请选择"
+                >
+                  <el-option
+                    v-for="item in groupTypeList"
+                    :label="item.label"
+                    :value="item.value"
+                    :key="item.value"
+                  ></el-option>
+                </el-select>
+              </el-form-item>
+              <el-form-item label="比例" prop="alonePkgPercent">
+                <el-input
+                  v-model="backupSettingForm.alonePkgPercent"
+                  :disabled="!backupSettingForm.needAlonePkg"
+                ></el-input>
+              </el-form-item>
+              <el-form-item label="最大" prop="alonePkgMax">
+                <el-input
+                  v-model="backupSettingForm.alonePkgMax"
+                  :disabled="!backupSettingForm.needAlonePkg"
+                ></el-input>
+              </el-form-item>
+              <el-form-item label="最小" prop="alonePkgMin">
+                <el-input
+                  v-model="backupSettingForm.alonePkgMin"
+                  :disabled="!backupSettingForm.needAlonePkg"
+                ></el-input>
+              </el-form-item>
+            </el-tab-pane>
+          </el-tabs>
+        </el-form>
+        <div style="text-align: center;">
+          <el-button type="primary" @click="editBackupSetting"
+            >确 定
+          </el-button>
+          <el-button @click="closeBackupSettingDialog">取 消</el-button>
+        </div>
+      </el-dialog>
+
       <!-- 其它事项弹窗 -->
       <el-dialog
         title="其它事项"
@@ -181,25 +271,110 @@
 
 <script>
 import { PRINT_API } from "@/constants/constants";
-import { userRole } from "../constants/constants.js";
+import { userRole, groupTypeList } from "../constants/constants.js";
 import { mapState } from "vuex";
 
 export default {
   data() {
+    let validateEachPkgPercent = (rule, value, callback) => {
+      if (this.backupSettingForm.needEachPkg) {
+        if (this.isEmptyNumber(this.backupSettingForm.eachPkgPercent)) {
+          callback(new Error("请输入正确的数值!"));
+          return;
+        }
+      }
+      callback();
+    };
+
+    let validateEachPkgMax = (rule, value, callback) => {
+      if (this.backupSettingForm.needEachPkg) {
+        if (this.isEmptyNumber(this.backupSettingForm.eachPkgMax)) {
+          callback(new Error("请输入正确的数值!"));
+          return;
+        }
+      }
+      callback();
+    };
+
+    let validateEachPkgMin = (rule, value, callback) => {
+      if (this.backupSettingForm.needEachPkg) {
+        if (this.isEmptyNumber(this.backupSettingForm.eachPkgMin)) {
+          callback(new Error("请输入正确的数值!"));
+          return;
+        }
+      }
+      callback();
+    };
+
+    let validateAlonePkgPercent = (rule, value, callback) => {
+      if (this.backupSettingForm.needAlonePkg) {
+        if (this.isEmptyNumber(this.backupSettingForm.alonePkgPercent)) {
+          callback(new Error("请输入正确的数值!"));
+          return;
+        }
+      }
+      callback();
+    };
+
+    let validateAlonePkgMax = (rule, value, callback) => {
+      if (this.backupSettingForm.needAlonePkg) {
+        if (this.isEmptyNumber(this.backupSettingForm.alonePkgMax)) {
+          callback(new Error("请输入正确的数值!"));
+          return;
+        }
+      }
+      callback();
+    };
+
+    let validateAlonePkgMin = (rule, value, callback) => {
+      if (this.backupSettingForm.needAlonePkg) {
+        if (this.isEmptyNumber(this.backupSettingForm.alonePkgMin)) {
+          callback(new Error("请输入正确的数值!"));
+          return;
+        }
+      }
+      callback();
+    };
+
+    let validateGroupType = (rule, value, callback) => {
+      if (this.backupSettingForm.needAlonePkg) {
+        if (this.isEmptyStr(this.backupSettingForm.groupType)) {
+          callback(new Error("请选择归集参数!"));
+          return;
+        }
+      }
+      callback();
+    };
+
     return {
       formSearch: {
         orgId: "",
         examId: ""
       },
       curUserRole: userRole,
+      groupTypeList: groupTypeList,
       hasPermit: false,
       loading: false,
       showGoBack: false,
       tableData: [],
       projectId: "",
+      eachPkgTab: "first",
+      alonePkgTab: "first",
       orgList: [],
       examList: [],
       backupSettingDialog: false,
+      backupSettingForm: {
+        projectId: "",
+        needAlonePkg: true,
+        needEachPkg: true,
+        eachPkgPercent: "",
+        eachPkgMax: "",
+        eachPkgMin: "",
+        alonePkgPercent: "",
+        alonePkgMax: "",
+        alonePkgMin: "",
+        groupType: ""
+      },
       otherSettingDialog: false,
       otherSettingForm: {
         id: "",
@@ -207,7 +382,60 @@ export default {
         remark: ""
       },
       rules: {
-        remark: [{ required: true, message: "请输入事项内容", trigger: "blur" }]
+        eachPkgPercent: [
+          {
+            type: "number",
+            required: true,
+            validator: validateEachPkgPercent,
+            trigger: "blur"
+          }
+        ],
+        eachPkgMax: [
+          {
+            type: "number",
+            required: true,
+            validator: validateEachPkgMax,
+            trigger: "blur"
+          }
+        ],
+        eachPkgMin: [
+          {
+            type: "number",
+            required: true,
+            validator: validateEachPkgMin,
+            trigger: "blur"
+          }
+        ],
+        alonePkgPercent: [
+          {
+            type: "number",
+            required: true,
+            validator: validateAlonePkgPercent,
+            trigger: "blur"
+          }
+        ],
+        alonePkgMax: [
+          {
+            type: "number",
+            required: true,
+            validator: validateAlonePkgMax,
+            trigger: "blur"
+          }
+        ],
+        alonePkgMin: [
+          {
+            type: "number",
+            required: true,
+            validator: validateAlonePkgMin,
+            trigger: "blur"
+          }
+        ],
+        groupType: [
+          { required: true, validator: validateGroupType, trigger: "change" }
+        ],
+        remark: [
+          { required: true, message: "请输入事项内容!", trigger: "blur" }
+        ]
       }
     };
   },
@@ -296,20 +524,105 @@ export default {
     },
     refreshStatistic() {
       /* 刷新当前统计信息 */
-      console.log(this.projectId);
-      this.$notify({
-        message: "Todo...",
+      this.$confirm("刷新当前统计信息?", "提示", {
+        confirmButtonText: "确定",
+        cancelButtonText: "取消",
         type: "warning"
-      });
+      })
+        .then(() => {
+          let url =
+            PRINT_API +
+            "/printing/project/statistic/refresh/" +
+            +this.formSearch.orgId +
+            "/" +
+            this.formSearch.examId;
+          this.$http.post(url).then(
+            () => {
+              this.$notify({
+                type: "success",
+                message: "刷新成功!"
+              });
+              this.searchRecords();
+            },
+            () => {
+              this.$notify({
+                type: "error",
+                message: "刷新失败!"
+              });
+            }
+          );
+        })
+        .catch(() => {
+          //ignore
+        });
     },
-    editBackupSetting(row) {
-      /* 备份设置 */
-      console.log(row);
-      this.$notify({
-        message: "Todo...",
-        type: "warning"
+    editBackupSetting() {
+      /* 保存备份设置 */
+      this.$refs.backupSettingForm.validate(valid => {
+        if (!valid) {
+          return false;
+        }
+
+        if (
+          !this.backupSettingForm.needEachPkg &&
+          !this.backupSettingForm.needAlonePkg
+        ) {
+          this.$notify({
+            message: "请至少选择一种备份方式!",
+            type: "warning"
+          });
+          return;
+        }
+
+        let url = PRINT_API + "/project/backup/setting/save";
+        this.$http.post(url, this.backupSettingForm).then(
+          () => {
+            this.$notify({
+              type: "success",
+              message: "保存备份设置成功!"
+            });
+            this.backupSettingDialog = false;
+          },
+          error => {
+            console.log(error);
+            this.$notify({
+              message: "保存备份设置失败!",
+              type: "error"
+            });
+          }
+        );
       });
     },
+    openBackupSettingDialog() {
+      /* 打开备份设置弹窗 */
+      let url = PRINT_API + "/project/backup/setting/" + this.projectId;
+      this.$http.post(url).then(
+        response => {
+          this.backupSettingForm = response.data;
+          this.$refs.backupSettingForm.validate();
+        },
+        () => {
+          this.backupSettingForm = {
+            projectId: this.projectId,
+            needAlonePkg: true,
+            needEachPkg: true,
+            eachPkgPercent: "",
+            eachPkgMax: "",
+            eachPkgMin: "",
+            alonePkgPercent: "",
+            alonePkgMax: "",
+            alonePkgMin: "",
+            groupType: ""
+          };
+          this.$refs.backupSettingForm.validate();
+        }
+      );
+      this.backupSettingDialog = true;
+    },
+    closeBackupSettingDialog() {
+      /* 关闭备份设置弹窗 */
+      this.backupSettingDialog = false;
+    },
     loadOtherSetting(projectId) {
       /* 查询其它事项列表 */
       let url =
@@ -361,28 +674,32 @@ export default {
     },
     removeOtherSetting(row) {
       /* 删除某个其它事项 */
-      this.$confirm("确定删除当前事项?", "提示", {
+      this.$confirm("确定删除当前事项?", "提示", {
         confirmButtonText: "确定",
         cancelButtonText: "取消",
         type: "warning"
-      }).then(() => {
-        var url = PRINT_API + "/project/other/setting/delete/" + row.id;
-        this.$http.post(url).then(
-          () => {
-            this.$notify({
-              type: "success",
-              message: "删除当前事项成功!"
-            });
-            this.searchRecords();
-          },
-          () => {
-            this.$notify({
-              type: "error",
-              message: "删除当前事项失败!"
-            });
-          }
-        );
-      });
+      })
+        .then(() => {
+          var url = PRINT_API + "/project/other/setting/delete/" + row.id;
+          this.$http.post(url).then(
+            () => {
+              this.$notify({
+                type: "success",
+                message: "删除当前事项成功!"
+              });
+              this.searchRecords();
+            },
+            () => {
+              this.$notify({
+                type: "error",
+                message: "删除当前事项失败!"
+              });
+            }
+          );
+        })
+        .catch(() => {
+          //ignore
+        });
     },
     openOtherSettingDialog(row) {
       /* 打开其它事项弹窗 */