Selaa lähdekoodia

新增/编辑 功能

XuZinan 3 vuotta sitten
vanhempi
commit
f8cb7c0bab
3 muutettua tiedostoa jossa 59 lisäystä ja 12 poistoa
  1. 2 2
      manifest.json
  2. 49 10
      pages/Project/add.vue
  3. 8 0
      services/project.js

+ 2 - 2
manifest.json

@@ -2,8 +2,8 @@
     "name" : "workload",
     "appid" : "__UNI__2F0D80E",
     "description" : "",
-    "versionName" : "2.0.2",
-    "versionCode" : 202,
+    "versionName" : "2.0.4",
+    "versionCode" : 204,
     "transformPx" : false,
     "app-plus" : {
         /* 5+App特有相关 */

+ 49 - 10
pages/Project/add.vue

@@ -138,7 +138,13 @@
 </template>
 
 <script>
-import { queryProjectType, queryIndustry, queryFlow } from "@/services/project";
+import {
+  queryProjectType,
+  queryIndustry,
+  queryFlow,
+  createApproval,
+  updateApproval,
+} from "@/services/project";
 import provinces from "./provinces";
 import { mapState } from "vuex";
 const versionList = ["一期", "二期", "三期", "四期", "五期"];
@@ -181,7 +187,7 @@ export default {
         industry: {
           rules: [
             {
-              required: true,
+              required: false,
               errorMessage: "请选择行业名称",
             },
           ],
@@ -189,7 +195,7 @@ export default {
         location: {
           rules: [
             {
-              required: true,
+              required: false,
               errorMessage: "请选择地区",
             },
           ],
@@ -197,7 +203,7 @@ export default {
         name: {
           rules: [
             {
-              required: true,
+              required: false,
               errorMessage: "请输入项目简称",
             },
             {
@@ -218,7 +224,7 @@ export default {
         version: {
           rules: [
             {
-              required: true,
+              required: false,
               errorMessage: "请选择期数",
             },
           ],
@@ -238,7 +244,9 @@ export default {
     ...mapState(["currentProject"]),
   },
   onLoad(options) {
-    this.project_id = options.project_id;
+    if (options.project_id) {
+      this.project_id = options.project_id;
+    }
     this.init(options);
   },
   onReady() {
@@ -247,9 +255,39 @@ export default {
   methods: {
     onHandleSubmit(value) {
       if (value) {
-        this.$refs.form.validate((err, formData) => {
+        this.$refs.form.validate(async (err, formData) => {
           if (!err) {
             console.log("success", formData);
+            let payload = {
+              project_name: this.formData.project_name,
+              type_id: Number(this.formData.type.id),
+              flow_id: Number(this.formData.flow.id),
+              node_id: this.flowList.find(
+                (item) => item.id == this.formData.flow.id
+              ).Nodes[0].id,
+            };
+            if (formData.type != 7) {
+              payload = {
+                ...payload,
+                industry_id: Number(this.formData.industry.id),
+                location: this.formData.location.name,
+                location_code: this.formData.location.code,
+                name: this.formData.name,
+                version: this.formData.version + "",
+                project_full_code:
+                  this.formData.code.type +
+                  this.formData.code.industry +
+                  this.formData.code.location +
+                  this.formData.code.name +
+                  this.formData.code.version,
+              };
+            }
+            if (this.project_id == 0) {
+              await createApproval(payload);
+            } else {
+              payload.id = Number(this.project_id);
+              await updateApproval(payload);
+            }
             uni.navigateTo({
               url: "./list",
             });
@@ -306,7 +344,8 @@ export default {
 
           this.locationIndex = searchLocation(this.provinces, current.location);
           if (this.provinces[this.locationIndex[0]].children)
-            this.locationList[1] = this.provinces[this.locationIndex[0]].children;
+            this.locationList[1] =
+              this.provinces[this.locationIndex[0]].children;
         }
       }
     },
@@ -320,7 +359,7 @@ export default {
       code.type = form.type.code;
       this.binddata("type", e.target.value);
       if (form.type.id == 7) {
-        form.flow = this.flowList.find((item) => item.id == 1);
+        form.flow = this.flowList.find((item) => item.id == 4);
         form.industry = null;
         form.location = null;
         form.name = null;
@@ -329,7 +368,7 @@ export default {
         code.location = "***";
         code.name = "***";
         code.version = "*";
-      } else form.flow = this.flowList.find((item) => item.id == 4);
+      } else form.flow = this.flowList.find((item) => item.id == 1);
     },
     selectChangeIndustry(e) {
       this.formData.industry = this.industryList[e.target.value];

+ 8 - 0
services/project.js

@@ -46,3 +46,11 @@ export async function queryUserDetail(user) {
 export async function authApproval(data) {
   return request(`v2/approval/auth`, "POST", data);
 }
+
+export async function createApproval(data) {
+  return request(`v2/approval/record`, "POST", data);
+}
+
+export async function updateApproval(data) {
+  return request(`v2/approval/record`, "PUT", data);
+}