Forráskód Böngészése

projectCreatePageDTO增加数据传输(ProjectCreate.vue)

sunjh 6 éve
szülő
commit
21eb3801b3
2 módosított fájl, 113 hozzáadás és 98 törlés
  1. 110 97
      src/components/project/ProjectCreate.vue
  2. 3 1
      src/js/api.js

+ 110 - 97
src/components/project/ProjectCreate.vue

@@ -131,179 +131,192 @@
 </template>
 
 <script>
-import Enum from "@/constants/enum/index";
-import PlatformType from "@/constants/enum/platform-type";
-import provinceCity from "@/constants/provinceCity.json";
+import Enum from '@/constants/enum/index'
+import PlatformType from '@/constants/enum/platform-type'
+import Http from '@/js/http.js'
+import Apis from '@/js/api.js'
+
 export default {
-  name: "ProjectCreate",
-  data() {
+  name: 'ProjectCreate',
+  data () {
     var validatePass = (rule, value, callback) => {
-      var reg = /^(0|86|17951)?(13[0-9]|15[012356789]|17[678]|18[0-9]|14[57])[0-9]{8}$/;
+      var reg = /^(0|86|17951)?(13[0-9]|15[012356789]|17[678]|18[0-9]|14[57])[0-9]{8}$/
       if (value.phone) {
         if (!reg.test(value.phone)) {
-          callback(new Error("请检查手机号码"));
+          callback(new Error('请检查手机号码'))
         } else {
-          callback();
+          callback()
         }
       }
-    };
+    }
     return {
-      tabPosition: "top",
+      tabPosition: 'top',
       institutionArray: Enum.institution,
       platformType: [],
       project: {
-        name: "",
+        name: '',
         contact: {
-          name: "",
-          phone: ""
+          name: '',
+          phone: ''
         },
         type: [],
         platform: [],
-        desc: "",
-        doc: "",
-        file: "",
-        resource: "非定向",
-        institution: "",
-        datetime: "",
-        price: "",
-        usage: "",
-        budget: ""
+        desc: '',
+        doc: '',
+        file: '',
+        resource: '非定向',
+        institution: '',
+        datetime: '',
+        price: '',
+        usage: '',
+        budget: ''
       },
       pickerOptions: {
         shortcuts: [
           {
-            text: "今天",
-            onClick(picker) {
-              picker.$emit("pick", new Date());
+            text: '今天',
+            onClick (picker) {
+              picker.$emit('pick', new Date())
             }
           },
           {
-            text: "昨天",
-            onClick(picker) {
-              const date = new Date();
-              date.setTime(date.getTime() - 3600 * 1000 * 24);
-              picker.$emit("pick", date);
+            text: '昨天',
+            onClick (picker) {
+              const date = new Date()
+              date.setTime(date.getTime() - 3600 * 1000 * 24)
+              picker.$emit('pick', date)
             }
           },
           {
-            text: "一周前",
-            onClick(picker) {
-              const date = new Date();
-              date.setTime(date.getTime() - 3600 * 1000 * 24 * 7);
-              picker.$emit("pick", date);
+            text: '一周前',
+            onClick (picker) {
+              const date = new Date()
+              date.setTime(date.getTime() - 3600 * 1000 * 24 * 7)
+              picker.$emit('pick', date)
             }
           }
         ]
       },
       rules: {
         name: [
-          { required: true, message: "请输入项目名称", trigger: "blur" }
+          {required: true, message: '请输入项目名称', trigger: 'blur'}
           // { min: 3, max: 5, message: "长度在 3 到 5 个字符", trigger: "blur" }
         ],
         type: [
           {
-            type: "array",
+            type: 'array',
             required: true,
-            message: "请至少选择一种服务类型",
-            trigger: "change"
+            message: '请至少选择一种服务类型',
+            trigger: 'change'
           }
         ],
         platform: [
           {
-            type: "array",
+            type: 'array',
             required: true,
-            message: "请至少选择一个平台",
-            trigger: "change"
+            message: '请至少选择一个平台',
+            trigger: 'change'
           }
         ],
-        desc: [{ required: true, message: "请填写活动形式", trigger: "blur" }],
-        contact: [{ validator: validatePass, trigger: "blur" }],
+        desc: [{required: true, message: '请填写活动形式', trigger: 'blur'}],
+        contact: [{validator: validatePass, trigger: 'blur'}],
         resource: [
           {
             required: true,
-            message: "请选择项目可见性",
-            trigger: "change"
+            message: '请选择项目可见性',
+            trigger: 'change'
           }
         ]
       }
-    };
+    }
   },
-  mounted() {
+  mounted () {
     this.$nextTick(() => {
-      this.init();
-    });
+      this.init()
+    })
   },
   watch: {
-    "project.resource"() {
-      if (this.project.resource == "非定向") {
-        this.project.institution = "";
+    'project.resource' () {
+      if (this.project.resource == '非定向') {
+        this.project.institution = ''
       }
     },
     deep: true
   },
   methods: {
-    init() {
+    init () {
       this.project.platform.map(item => {
-        this.platformType.push(PlatformType[item]);
-      });
+        this.platformType.push(PlatformType[item])
+      })
     },
-    submitForm(formName) {
+    submitForm (formName) {
       this.$refs[formName].validate(valid => {
         if (valid) {
-          console.log(this.project);
+          console.log(this.project)
+          Http.post(Apis.PROJECT.CREATE_PROJECT_SUBMIT,this.project).then((res)=>{
+            console.log(res)
+          })
           //提交 project
         } else {
-          console.log("error submit!!");
-          return false;
+          console.log('error submit!!')
+          return false
         }
-      });
+      })
     },
-    resetForm(formName) {
-      this.$refs[formName].resetFields();
-      this.project.name = "";
-      this.project.type = [];
-      this.project.platform = [];
-      this.project.desc = "";
-      this.project.file = "";
-      this.project.doc = "";
+    resetForm (formName) {
+      this.$refs[formName].resetFields()
+      this.project.name = ''
+      this.project.type = []
+      this.project.platform = []
+      this.project.desc = ''
+      this.project.file = ''
+      this.project.doc = ''
       this.project.contact = {
-        name: "",
-        phone: ""
-      };
+        name: '',
+        phone: ''
+      }
 
-      this.project.resource = "非定向";
-      this.project.institution = "";
-      this.project.datetime = "";
-      this.project.price = "";
-      this.project.usage = "";
-      this.project.budget = "";
+      this.project.resource = '非定向'
+      this.project.institution = ''
+      this.project.datetime = ''
+      this.project.price = ''
+      this.project.usage = ''
+      this.project.budget = ''
     },
-    beforeFileUpload(file) {
-      const isAPK = file.type === "application/vnd.android.package-archive";
-      const isDMG = file.type === "application/octet-stream";
+    beforeFileUpload (file) {
+      const isAPK = file.type === 'application/vnd.android.package-archive'
+      const isDMG = file.type === 'application/octet-stream'
 
       if (!isAPK && !isDMG) {
-        this.$message.error("上传安装包只能是 APK 或 DMG 格式!");
+        this.$message.error('上传安装包只能是 APK 或 DMG 格式!')
       }
-      return isAPK && isDMG;
+      return isAPK && isDMG
+    },
+    loadData () {
+      Http.get(Apis.PAGE.CREATE_PROJECT_PAGE).then((res)=>{
+        this.project = res.project
+      })
     }
   }
-};
+}
 </script>
 
 <style lang="less" scoped>
-.el-col {
-  padding: 0 !important;
-}
-.el-row {
-  margin-bottom: 10px;
-}
-.el-radio {
-  margin: 10px 20px 10px 0;
-}
-.el-form-item /deep/.el-tabs__content {
-  max-height: 120px !important;
-  overflow: auto;
-}
+  .el-col {
+    padding: 0 !important;
+  }
+
+  .el-row {
+    margin-bottom: 10px;
+  }
+
+  .el-radio {
+    margin: 10px 20px 10px 0;
+  }
+
+  .el-form-item /deep/ .el-tabs__content {
+    max-height: 120px !important;
+    overflow: auto;
+  }
 </style>
 

+ 3 - 1
src/js/api.js

@@ -1,6 +1,8 @@
 export default {
   API: '/api/',
-  PROJECT: {},
+  PROJECT: {
+    CREATE_PROJECT_SUBMIT: this.API + 'project/createProject/'
+  },
   TASK: {
     GET_HOT_TASK_LIST: '/api/task/getHotTaskList/'
   },