Explorar el Código

新增项目页面 改

XuZinan hace 3 años
padre
commit
da1f1c20b3
Se han modificado 1 ficheros con 92 adiciones y 29 borrados
  1. 92 29
      pages/Project/add.vue

+ 92 - 29
pages/Project/add.vue

@@ -17,8 +17,7 @@
         >
           <view class="select">
             {{
-              formData.type_id &&
-              typeList.find((item) => item.id == formData.type_id).name
+              formData.type && `${formData.type.name}(${formData.type.code})`
             }}
           </view>
         </picker>
@@ -27,13 +26,15 @@
         <picker disabled>
           <view class="select">
             {{
-              formData.type_id &&
-              (formData.type_id == 7 ? "研发立项" : "销售立项")
+              formData.type && (formData.type.id == 7 ? "研发立项" : "销售立项")
             }}
           </view>
         </picker>
       </uni-forms-item>
-      <uni-forms-item label="行业名称" v-show="formData.type_id != 7">
+      <uni-forms-item
+        label="行业名称"
+        v-show="!formData.type || (formData.type && formData.type.id != 7)"
+      >
         <picker
           @change="selectChangeIndustry"
           :range="industryList"
@@ -41,26 +42,49 @@
         >
           <view class="select">
             {{
-              formData.industry_id &&
-              industryList.find((item) => item.id == formData.industry_id).name
+              formData.industry &&
+              `${formData.industry.name}(${formData.industry.code})`
             }}
           </view>
         </picker>
       </uni-forms-item>
-      <uni-forms-item label="项目地区" v-show="formData.type_id != 7">
+      <uni-forms-item
+        label="项目地区"
+        v-show="!formData.type || (formData.type && formData.type.id != 7)"
+      >
         <picker> <view class="select"></view></picker>
       </uni-forms-item>
-      <uni-forms-item label="项目简称" v-show="formData.type_id != 7">
-        <uni-easyinput type="text" v-model="formData.name" class="input" />
+      <uni-forms-item
+        label="项目简称"
+        v-show="!formData.type || (formData.type && formData.type.id != 7)"
+      >
+        <uni-easyinput
+          type="text"
+          v-model="formData.name"
+          class="input"
+          :clearable="false"
+          @blur="onChangeName"
+        />
       </uni-forms-item>
-      <uni-forms-item label="项目期数" v-show="formData.type_id != 7">
+      <uni-forms-item
+        label="项目期数"
+        v-show="!formData.type || (formData.type && formData.type.id != 7)"
+      >
         <picker @change="selectChangeVersion" :range="versionList">
           <view class="select">
             {{ versionList[this.formData.version - 1] }}
           </view>
         </picker>
       </uni-forms-item>
-      <uni-forms-item label="项目编号" v-show="formData.type_id != 7">
+      <uni-forms-item
+        label="项目编号"
+        v-show="!formData.type || (formData.type && formData.type.id != 7)"
+      >
+        <view>
+          {{
+            `${formData.code.type}-${formData.code.industry}-${formData.code.location}-${formData.code.name}-${formData.code.version}`
+          }}
+        </view>
       </uni-forms-item>
     </uni-forms>
     <view class="group">
@@ -81,13 +105,19 @@ export default {
     return {
       formData: {
         project_name: null,
-        type_id: null,
-        flow_id: null,
-        industry_id: null,
+        type: null,
+        flow: null,
+        industry: null,
         location: null,
         name: null,
         version: null,
-        code: null,
+        code: {
+          type: "***",
+          industry: "***",
+          location: "***",
+          name: "***",
+          version: "*",
+        },
       },
       project_id: 0,
 
@@ -111,15 +141,29 @@ export default {
       });
     },
     async init(options) {
+      let form = this.formData;
+      let code = this.formData.code;
+      let current = this.currentProject;
       if (options.project_id) {
-        this.formData.project_name = this.currentProject.project_name;
-        this.formData.type_id = this.currentProject.type_id;
-        this.formData.flow_id = this.currentProject.flow_id;
-        if (this.currentProject.type_id != 7) {
-          this.formData.industry_id = this.currentProject.industry_id;
-          this.formData.location = this.currentProject.location;
-          this.formData.name = this.currentProject.name;
-          this.formData.code = this.currentProject.project_full_code;
+        form.project_name = current.project_name;
+        form.type = this.typeList.find(
+          (item) => item.id == this.currentProject.type_id
+        );
+        form.flow = this.typeList.find(
+          (item) => item.id == this.currentProject.flow_id
+        );
+        if (current.type.id != 7) {
+          form.industry = this.industryList.find(
+            (item) => item.id == this.currentProject.industry_id
+          );
+          form.location = current.location;
+          form.name = current.name;
+          form.version = current.version;
+          code.type = form.type.code;
+          code.industry = form.industry.code;
+          code.location = form.location;
+          code.name = form.name;
+          code.version = form.version;
         }
       }
       let res;
@@ -129,16 +173,35 @@ export default {
       this.industryList = res.data;
     },
     selectChangeType(e) {
-      let item = this.typeList[e.target.value];
-      this.formData.type_id = item.id;
-      item.id == 7 ? (this.formData.flow_id = 1) : (this.formData.flow_id = 4);
+      let form = this.formData;
+      let code = this.formData.code;
+      form.type = this.typeList[e.target.value];
+      code.type = form.type.code;
+      if (form.type.id == 7) {
+        form.flow = this.typeList.find((item) => item.id == 1);
+        form.industry = null;
+        form.location = null;
+        form.name = null;
+        form.version = null;
+        code.industry = "***";
+        code.location = "***";
+        code.name = "***";
+        code.version = "*";
+      } else form.flow = this.typeList.find((item) => item.id == 4);
     },
     selectChangeIndustry(e) {
-      let item = this.industryList[e.target.value];
-      this.formData.industry_id = item.id;
+      this.formData.industry = this.industryList[e.target.value];
+      this.formData.code.industry = this.formData.industry.code;
+    },
+    onChangeName(e) {
+      let name = e.detail.value.toUpperCase();
+      while (name.length < 3) name += "V";
+      this.formData.name = name;
+      this.formData.code.name = name;
     },
     selectChangeVersion(e) {
       this.formData.version = e.target.value + 1;
+      this.formData.code.version = this.formData.version + "";
     },
   },
 };