sunjh 6 years ago
parent
commit
433633599c

+ 312 - 268
src/components/project/Project.vue

@@ -88,8 +88,9 @@
         </el-form-item>
         </el-form-item>
         <el-form-item label="项目可见性" prop="resource">
         <el-form-item label="项目可见性" prop="resource">
           <div v-if="!isModifyMode">
           <div v-if="!isModifyMode">
-            <div v-if="project.resource=='定向'">{{project.institution}}</div>
-            <div v-if="project.resource=='非定向'">{{project.resource}}</div>
+            <div v-if="project.resource=='1'">{{updateLocation(project.location)}}</div>
+            <div v-if="project.resource=='0'">{{project.institution}}</div>
+            <div v-if="project.resource=='2'">{{resourceType[project.resource]}}</div>
           </div>
           </div>
           <el-tabs
           <el-tabs
             :tab-position="tabPosition"
             :tab-position="tabPosition"
@@ -97,7 +98,7 @@
             style="max-height: 200px;"
             style="max-height: 200px;"
             v-if="isModifyMode"
             v-if="isModifyMode"
           >
           >
-            <el-tab-pane label="定向" name="定向">
+            <el-tab-pane :label="resourceType[0]" name="0">
               <el-radio-group v-model="project.institution">
               <el-radio-group v-model="project.institution">
                 <el-radio
                 <el-radio
                   :label="item"
                   :label="item"
@@ -107,7 +108,15 @@
                 ></el-radio>
                 ></el-radio>
               </el-radio-group>
               </el-radio-group>
             </el-tab-pane>
             </el-tab-pane>
-            <el-tab-pane label="非定向" name="非定向"></el-tab-pane>
+            <el-tab-pane :label="resourceType[1]" name="1">
+              <provincecity
+                ref="addFormProvince"
+                @selectChange="locationChange"
+                :provinceCode="project.location.provinceCode"
+                :cityCode="project.location.cityCode"
+              ></provincecity>
+            </el-tab-pane>
+            <el-tab-pane :label="resourceType[2]" name="2"></el-tab-pane>
           </el-tabs>
           </el-tabs>
         </el-form-item>
         </el-form-item>
 
 
@@ -209,11 +218,13 @@
               <div
               <div
                 class="btn btn-small btn-info"
                 class="btn btn-small btn-info"
                 @click="handleAccept(scope.$index, scope.row.id)"
                 @click="handleAccept(scope.$index, scope.row.id)"
-              >接受</div>
+              >接受
+              </div>
               <div
               <div
                 class="btn btn-small btn-danger"
                 class="btn btn-small btn-danger"
                 @click="handleReject(scope.$index, scope.row.id)"
                 @click="handleReject(scope.$index, scope.row.id)"
-              >拒绝</div>
+              >拒绝
+              </div>
             </template>
             </template>
           </el-table-column>
           </el-table-column>
         </el-table>
         </el-table>
@@ -228,9 +239,9 @@
           <el-table-column prop="datetime" sortable label="任务截止时间"></el-table-column>
           <el-table-column prop="datetime" sortable label="任务截止时间"></el-table-column>
           <el-table-column prop="resource" label="任务可见性">
           <el-table-column prop="resource" label="任务可见性">
             <template slot-scope="scope">
             <template slot-scope="scope">
-              <div v-if="scope.row.resource=='区域'">{{updateLocation(scope.row.location)}}</div>
-              <div v-if="scope.row.resource=='定向'">{{scope.row.institution}}</div>
-              <div v-if="scope.row.resource=='广场'">{{scope.row.resource}}</div>
+              <div v-if="scope.row.resource=='1'">{{updateLocation(scope.row.location)}}</div>
+              <div v-if="scope.row.resource=='0'">{{scope.row.institution}}</div>
+              <div v-if="scope.row.resource=='2'">{{resourceType[scope.row.resource]}}</div>
             </template>
             </template>
           </el-table-column>
           </el-table-column>
           <el-table-column prop="type" label="业务类型">
           <el-table-column prop="type" label="业务类型">
@@ -244,11 +255,13 @@
               <div
               <div
                 class="btn btn-small btn-info"
                 class="btn btn-small btn-info"
                 @click="goToTaskDetail(projectId, scope.row.id)"
                 @click="goToTaskDetail(projectId, scope.row.id)"
-              >查看详情</div>
+              >查看详情
+              </div>
               <div
               <div
                 class="btn btn-small btn-danger"
                 class="btn btn-small btn-danger"
                 @click="handleDelete(scope.$index, scope.row.id)"
                 @click="handleDelete(scope.$index, scope.row.id)"
-              >删除</div>
+              >删除
+              </div>
             </template>
             </template>
           </el-table-column>
           </el-table-column>
         </el-table>
         </el-table>
@@ -263,83 +276,91 @@
 </template>
 </template>
 
 
 <script>
 <script>
-import Enum from "@/constants/enum/index";
-import PlatformType from "@/constants/enum/platform-type";
-import provinceCity from "@/constants/provinceCity.json";
-import ReportList from "@/components/report/ReportList";
+import Enum from '@/constants/enum/index'
+import PlatformType from '@/constants/enum/platform-type'
+import ReportList from '@/components/report/ReportList'
 import Http from '@/js/http.js'
 import Http from '@/js/http.js'
 import Apis from '@/js/api.js'
 import Apis from '@/js/api.js'
+import ResourceType from '@/constants/enum/resource-type'
+import provincecity from '@/components/commons/ProvinceCity'
+import provinceCityJSON from '@/constants/provinceCity.json'
+
 export default {
 export default {
-  name: "Project",
-  components: { ReportList },
-  data() {
+  name: 'Project',
+  components: {
+    provincecity,
+    ReportList
+  },
+  data () {
     var validatePass = (rule, value, callback) => {
     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 (value.phone) {
         if (!reg.test(value.phone)) {
         if (!reg.test(value.phone)) {
-          callback(new Error("请检查手机号码"));
+          callback(new Error('请检查手机号码'))
         } else {
         } else {
-          callback();
+          callback()
         }
         }
       }
       }
-    };
+    }
     return {
     return {
       projectId: 0,
       projectId: 0,
-      tabPosition: "top",
+      tabPosition: 'top',
       institutionArray: Enum.institution,
       institutionArray: Enum.institution,
       isModifyMode: false,
       isModifyMode: false,
       platformType: [],
       platformType: [],
+      resourceType: ResourceType,
       project: {
       project: {
-        name: "项目名",
-        code: "27382hdsjkfdskfK",
+        name: '项目名',
+        code: '27382hdsjkfdskfK',
         contact: {
         contact: {
-          name: "小王",
-          phone: "12426177281"
+          name: '小王',
+          phone: '12426177281'
         },
         },
-        type: ["安全漏洞扫描"],
-        platform: ["0", "1"],
-        desc: "需求描述文字",
-        doc: "",
-        file: "http://a.apk",
-        resource: "非定向",
-        institution: "",
-        datetime: new Date("2018-11-11 23:11:11"),
-        price: "400",
-        useage: "练习",
-        budget: "100",
+        type: ['安全漏洞扫描'],
+        platform: ['0', '1'],
+        desc: '需求描述文字',
+        doc: '',
+        file: 'http://a.apk',
+        resource: 1,
+        location: {provinceCode: '3200', cityCode: '3201'},
+        institution: '',
+        datetime: new Date('2018-11-11 23:11:11'),
+        price: '400',
+        useage: '练习',
+        budget: '100',
         task: [
         task: [
           {
           {
-            id: "1",
-            name: "任务1",
-            desc: "任务描述文字",
-            type: "安全漏洞扫描",
-            resource: "广场",
-            location: "",
-            institution: "",
-            datetime: "2018-11-12 11:11:01",
-            worker: ""
+            id: '1',
+            name: '任务1',
+            desc: '任务描述文字',
+            type: '安全漏洞扫描',
+            resource: 1,
+            location: {provinceCode: '3200', cityCode: '3201'},
+            institution: '',
+            datetime: '2018-11-12 11:11:01',
+            worker: ''
           },
           },
           {
           {
-            id: "2",
-            name: "任务2",
-            desc: "任务描述文字",
-            type: "接口测试",
-            resource: "定向",
-            location: "",
-            institution: "上软",
-            datetime: "2018-11-11 10:11:01",
-            worker: ""
+            id: '2',
+            name: '任务2',
+            desc: '任务描述文字',
+            type: '接口测试',
+            resource: 1,
+            location: {provinceCode: '3200', cityCode: '3201'},
+            institution: '',
+            datetime: '2018-11-11 10:11:01',
+            worker: ''
           },
           },
           {
           {
-            id: "3",
-            name: "任务3",
-            desc: "任务描述文字",
-            type: "功能测试服务",
-            resource: "区域",
-            location: { provinceCode: "3200", cityCode: "3201" },
-            institution: "",
-            datetime: "2018-11-11 11:11:01",
-            worker: ""
+            id: '3',
+            name: '任务3',
+            desc: '任务描述文字',
+            type: '功能测试服务',
+            resource: 1,
+            location: {provinceCode: '3200', cityCode: '3201'},
+            institution: '',
+            datetime: '2018-11-11 11:11:01',
+            worker: ''
           }
           }
         ],
         ],
         reportList: [
         reportList: [
@@ -372,321 +393,344 @@ export default {
       },
       },
       analyseDemandList: [
       analyseDemandList: [
         {
         {
-          id: "1",
-          institution: "上软",
+          id: '1',
+          institution: '上软',
           feasibilityReport: {
           feasibilityReport: {
-            name: "可行性分析报告",
-            url: "feasibilityReport.docx"
+            name: '可行性分析报告',
+            url: 'feasibilityReport.docx'
           },
           },
-          priceAuditReport: { name: "价格审核告", url: "priceAuditReport.docx" }
+          priceAuditReport: {name: '价格审核告', url: 'priceAuditReport.docx'}
         },
         },
         {
         {
-          id: "1",
-          institution: "上软",
+          id: '1',
+          institution: '上软',
           feasibilityReport: {
           feasibilityReport: {
-            name: "可行性分析报告",
-            url: "feasibilityReport.docx"
+            name: '可行性分析报告',
+            url: 'feasibilityReport.docx'
           },
           },
-          priceAuditReport: { name: "价格审核告", url: "priceAuditReport.docx" }
+          priceAuditReport: {name: '价格审核告', url: 'priceAuditReport.docx'}
         }
         }
       ],
       ],
       pickerOptions: {
       pickerOptions: {
         shortcuts: [
         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: {
       rules: {
         name: [
         name: [
-          { required: true, message: "请输入项目名称", trigger: "blur" }
+          {required: true, message: '请输入项目名称', trigger: 'blur'}
           // { min: 3, max: 5, message: "长度在 3 到 5 个字符", trigger: "blur" }
           // { min: 3, max: 5, message: "长度在 3 到 5 个字符", trigger: "blur" }
         ],
         ],
         type: [
         type: [
           {
           {
-            type: "array",
+            type: 'array',
             required: true,
             required: true,
-            message: "请至少选择一种服务类型",
-            trigger: "change"
+            message: '请至少选择一种服务类型',
+            trigger: 'change'
           }
           }
         ],
         ],
         platform: [
         platform: [
           {
           {
-            type: "array",
+            type: 'array',
             required: true,
             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: [
         resource: [
           {
           {
             required: true,
             required: true,
-            message: "请选择项目可见性",
-            trigger: "change"
+            message: '请选择项目可见性',
+            trigger: 'change'
           }
           }
         ]
         ]
       }
       }
-    };
+    }
   },
   },
-  mounted() {
+  mounted () {
     this.$nextTick(() => {
     this.$nextTick(() => {
-      this.init();
-    });
+      this.init()
+    })
   },
   },
   watch: {
   watch: {
-    "project.resource"() {
-      if (this.project.resource == "非定向") {
-        this.project.institution = "";
+    'project.institution' () {
+      if (this.project.institution) {
+        this.$refs.addFormProvince.resetProviceCity()
+        this.project.location = {provinceCode: '', cityCode: ''}
+      }
+    },
+    'project.location' () {
+      if (this.project.location.provinceCode || this.project.location.cityCode) {
+        this.project.institution = ''
+      }
+    },
+    'project.resource' () {
+      if (this.project.resource == '2') {
+        this.$refs.addFormProvince.resetProviceCity()
+        this.project.institution = ''
+        this.project.location = {provinceCode: '', cityCode: ''}
       }
       }
     },
     },
     deep: true
     deep: true
   },
   },
   methods: {
   methods: {
-    updateLocation(location) {
-      var provinceName = "";
-      var cityName = "";
-      for (var item of provinceCity.provinces) {
+    updateLocation (location) {
+      var provinceName = ''
+      var cityName = ''
+      for (var item of provinceCityJSON.provinces) {
         if (item.code === location.provinceCode) {
         if (item.code === location.provinceCode) {
-          provinceName = item.name;
+          provinceName = item.name
           for (var city of item.cities) {
           for (var city of item.cities) {
             if (city.code === location.cityCode) {
             if (city.code === location.cityCode) {
-              cityName = city.name;
-              break;
+              cityName = city.name
+              break
             }
             }
           }
           }
         }
         }
       }
       }
-      return provinceName + " / " + cityName;
+      return provinceName + ' / ' + cityName
     },
     },
-    init() {
-      this.projectId = +this.$route.params.projectId;
+    init () {
+      this.projectId = +this.$route.params.projectId
       this.project.platform.map(item => {
       this.project.platform.map(item => {
-        this.platformType.push(PlatformType[item]);
-      });
+        this.platformType.push(PlatformType[item])
+      })
     },
     },
-    submitForm(formName) {
+    submitForm (formName) {
       this.$refs[formName].validate(valid => {
       this.$refs[formName].validate(valid => {
         if (valid) {
         if (valid) {
-          this.isModifyMode = false;
-          Http.put(Apis.PROJECT.UPDATE_PROJECT_SUBMIT,this.project).then((res)=>{
-            console.log(res)
-            console.log(this.project)
-          })
+          this.isModifyMode = false
+          console.log(this.project)
+          // Http.put(Apis.PROJECT.UPDATE_PROJECT_SUBMIT, this.project).then((res) => {
+          //   console.log(res)
+          //   console.log(this.project)
+          // })
           //提交 project
           //提交 project
         } else {
         } 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.doc = "";
-      this.project.file = "";
+    resetForm (formName) {
+      this.$refs[formName].resetFields()
+      this.project.name = ''
+      this.project.type = []
+      this.project.platform = []
+      this.project.desc = ''
+      this.project.doc = ''
+      this.project.file = ''
       this.project.contact = {
       this.project.contact = {
-        name: "",
-        phone: ""
-      };
-      this.project.resource = "非定向";
-      this.project.institution = "";
-      this.project.datetime = "";
-      this.project.price = "";
-      this.project.useage = "";
-      this.project.budget = "";
+        name: '',
+        phone: ''
+      }
+      this.project.resource = '2'
+      this.project.institution = ''
+      this.project.datetime = ''
+      this.project.price = ''
+      this.project.useage = ''
+      this.project.budget = ''
     },
     },
-    modifyForm() {
-      this.isModifyMode = true;
+    modifyForm () {
+      this.isModifyMode = true
       //获得update 信息
       //获得update 信息
       this.project = {
       this.project = {
-        name: "项目名",
-        code: "27382hdsjkfdskfK",
+        name: '项目名',
+        code: '27382hdsjkfdskfK',
         contact: {
         contact: {
-          name: "小王",
-          phone: "13818022817"
+          name: '小王',
+          phone: '13818022817'
         },
         },
-        type: ["安全漏洞扫描"],
-        platform: ["0", "1"],
-        desc: "需求描述文字",
-        doc: "",
-        file: "http://a.apk",
-        resource: "非定向",
-        institution: "",
-        datetime: new Date("2018-11-11 23:11:11"),
-        price: "400",
-        useage: "练习",
-        budget: "100",
+        type: ['安全漏洞扫描'],
+        platform: ['0', '1'],
+        desc: '需求描述文字',
+        doc: '',
+        file: 'http://a.apk',
+        resource: '1',
+        location: {provinceCode: '3200', cityCode: '3201'},
+        institution: '',
+        datetime: new Date('2018-11-11 23:11:11'),
+        price: '400',
+        useage: '练习',
+        budget: '100',
         task: [
         task: [
           {
           {
-            id: "1",
-            name: "任务1",
-            desc: "任务描述文字",
-            type: "安全漏洞扫描",
-            resource: "广场",
-            location: { provinceCode: "", cityCode: "" },
-            institution: "",
-            datetime: "2018-11-12 11:11:01",
-            worker: ""
+            id: '1',
+            name: '任务1',
+            desc: '任务描述文字',
+            type: '安全漏洞扫描',
+            resource: '1',
+            location: {provinceCode: '', cityCode: ''},
+            institution: '',
+            datetime: '2018-11-12 11:11:01',
+            worker: ''
           },
           },
           {
           {
-            id: "2",
-            name: "任务2",
-            desc: "任务描述文字",
-            type: "接口测试",
-            resource: "定向",
-            location: { provinceCode: "", cityCode: "" },
-            institution: "上软",
-            datetime: "2018-11-11 10:11:01",
-            worker: ""
+            id: '2',
+            name: '任务2',
+            desc: '任务描述文字',
+            type: '接口测试',
+            resource: '1',
+            location: {provinceCode: '', cityCode: ''},
+            institution: '上软',
+            datetime: '2018-11-11 10:11:01',
+            worker: ''
           },
           },
           {
           {
-            id: "3",
-            name: "任务3",
-            desc: "任务描述文字",
-            type: "功能测试服务",
-            resource: "区域",
-            location: { provinceCode: "3200", cityCode: "3201" },
-            institution: "",
-            datetime: "2018-11-11 11:11:01",
-            worker: ""
+            id: '3',
+            name: '任务3',
+            desc: '任务描述文字',
+            type: '功能测试服务',
+            resource: '1',
+            location: {provinceCode: '3200', cityCode: '3201'},
+            institution: '',
+            datetime: '2018-11-11 11:11:01',
+            worker: ''
           }
           }
         ]
         ]
-      };
+      }
     },
     },
-    cancelMode(formName) {
-      this.isModifyMode = false;
+    cancelMode (formName) {
+      this.isModifyMode = false
       //获得update 信息
       //获得update 信息
       this.project = {
       this.project = {
-        name: "项目名",
-        code: "27382hdsjkfdskfK",
+        name: '项目名',
+        code: '27382hdsjkfdskfK',
         contact: {
         contact: {
-          name: "小王",
-          phone: "13818022817"
+          name: '小王',
+          phone: '13818022817'
         },
         },
-        type: ["安全漏洞扫描"],
-        platform: ["0", "1"],
-        desc: "需求描述文字",
-        doc: "",
-        file: "http://a.apk",
-        resource: "非定向",
-        institution: "",
-        datetime: new Date("2018-11-11 23:11:11"),
-        price: "400",
-        useage: "练习",
-        budget: "100",
+        type: ['安全漏洞扫描'],
+        platform: ['0', '1'],
+        desc: '需求描述文字',
+        doc: '',
+        file: 'http://a.apk',
+        resource: '1',
+        location: {provinceCode: '3200', cityCode: '3201'},
+        institution: '',
+        datetime: new Date('2018-11-11 23:11:11'),
+        price: '400',
+        useage: '练习',
+        budget: '100',
         task: [
         task: [
           {
           {
-            id: "1",
-            name: "任务1",
-            desc: "任务描述文字",
-            type: "安全漏洞扫描",
-            resource: "广场",
-            location: "",
-            institution: "",
-            datetime: "2018-11-12 11:11:01",
-            worker: ""
+            id: '1',
+            name: '任务1',
+            desc: '任务描述文字',
+            type: '安全漏洞扫描',
+            resource: '1',
+            location: {provinceCode: '3200', cityCode: '3201'},
+            institution: '',
+            datetime: '2018-11-12 11:11:01',
+            worker: ''
           },
           },
           {
           {
-            id: "2",
-            name: "任务2",
-            desc: "任务描述文字",
-            type: "接口测试",
-            resource: "定向",
-            location: "",
-            institution: "上软",
-            datetime: "2018-11-11 10:11:01",
-            worker: ""
+            id: '2',
+            name: '任务2',
+            desc: '任务描述文字',
+            type: '接口测试',
+            resource: '1',
+            location: {provinceCode: '3200', cityCode: '3201'},
+            institution: '',
+            datetime: '2018-11-11 10:11:01',
+            worker: ''
           },
           },
           {
           {
-            id: "3",
-            name: "任务3",
-            desc: "任务描述文字",
-            type: "功能测试服务",
-            resource: "区域",
-            location: { provinceCode: "3200", cityCode: "3201" },
-            institution: "",
-            datetime: "2018-11-11 11:11:01",
-            worker: ""
+            id: '3',
+            name: '任务3',
+            desc: '任务描述文字',
+            type: '功能测试服务',
+            resource: '1',
+            location: {provinceCode: '3200', cityCode: '3201'},
+            institution: '',
+            datetime: '2018-11-11 11:11:01',
+            worker: ''
           }
           }
         ]
         ]
-      };
+      }
     },
     },
-    goToTaskDetail(id) {
+    goToTaskDetail (id) {
       this.$router.push({
       this.$router.push({
-        name: "Task",
-        params: { projectId: this.projectId, taskId: id }
-      });
+        name: 'Task',
+        params: {projectId: this.projectId, taskId: id}
+      })
     },
     },
-    createTask() {
-      this.$router.push({ name: "TaskCreate" });
+    createTask () {
+      this.$router.push({name: 'TaskCreate'})
     },
     },
-    createReport() {
-      this.$router.push({ name: "ReportCreate" });
+    createReport () {
+      this.$router.push({name: 'ReportCreate'})
     },
     },
-    handleDelete(index, id) {
-      this.project.task.splice(index, 1);
+    handleDelete (index, id) {
+      this.project.task.splice(index, 1)
     },
     },
-    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) {
       if (!isAPK && !isDMG) {
-        this.$message.error("上传安装包只能是 APK 或 DMG 格式!");
+        this.$message.error('上传安装包只能是 APK 或 DMG 格式!')
       }
       }
-      return isAPK && isDMG;
+      return isAPK && isDMG
     },
     },
-    analyseDemand() {
-      this.$router.push({ name: "AnalyseDemand" });
+    analyseDemand () {
+      this.$router.push({name: 'AnalyseDemand'})
     },
     },
-    handleAccept(index, id) {
-      console.log("接受");
+    handleAccept (index, id) {
+      console.log('接受')
     },
     },
-    handleReject(index, id) {
-      console.log("拒绝");
+    handleReject (index, id) {
+      console.log('拒绝')
     },
     },
-    loadData() {
-      Http.get(Apis.PAGE.PROJECT_DETAIL_PAGE).then((res)=>{
+    loadData () {
+      Http.get(Apis.PAGE.PROJECT_DETAIL_PAGE).then((res) => {
         this.project = res.project
         this.project = res.project
         this.analyseDemandList = res.analyseDemandList
         this.analyseDemandList = res.analyseDemandList
       })
       })
-    }
+    },
+    locationChange (provinceId, cityId) {
+      if (provinceId || cityId) {
+        this.project.location = {provinceCode: provinceId, cityCode: cityId}
+      }
+    },
   }
   }
-};
+}
 </script>
 </script>
 
 
 <style lang="less" scoped>
 <style lang="less" scoped>
-.task-list {
-  margin: 0 30px;
-}
-.el-col {
-  padding: 0 !important;
-}
-.el-row {
-  margin-bottom: 10px;
-}
+  .task-list {
+    margin: 0 30px;
+  }
+
+  .el-col {
+    padding: 0 !important;
+  }
+
+  .el-row {
+    margin-bottom: 10px;
+  }
 </style>
 </style>
 
 

+ 51 - 4
src/components/project/ProjectCreate.vue

@@ -76,7 +76,15 @@
                 ></el-radio>
                 ></el-radio>
               </el-radio-group>
               </el-radio-group>
             </el-tab-pane>
             </el-tab-pane>
-            <el-tab-pane label="非定向" name="非定向"></el-tab-pane>
+            <el-tab-pane label="区域" name="区域">
+              <provincecity
+                ref="addFormProvince"
+                @selectChange="locationChange"
+                :provinceCode="project.location.provinceCode"
+                :cityCode="project.location.cityCode"
+              ></provincecity>
+            </el-tab-pane>
+            <el-tab-pane label="广场" name="广场"></el-tab-pane>
           </el-tabs>
           </el-tabs>
         </el-form-item>
         </el-form-item>
         <el-form-item label="需求文档" prop="doc">
         <el-form-item label="需求文档" prop="doc">
@@ -135,9 +143,13 @@ import Enum from '@/constants/enum/index'
 import PlatformType from '@/constants/enum/platform-type'
 import PlatformType from '@/constants/enum/platform-type'
 import Http from '@/js/http.js'
 import Http from '@/js/http.js'
 import Apis from '@/js/api.js'
 import Apis from '@/js/api.js'
-
+import provincecity from '@/components/commons/ProvinceCity'
+import provinceCityJSON from '@/constants/provinceCity.json'
 export default {
 export default {
   name: 'ProjectCreate',
   name: 'ProjectCreate',
+  components: {
+    provincecity
+  },
   data () {
   data () {
     var validatePass = (rule, value, callback) => {
     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}$/
@@ -164,7 +176,8 @@ export default {
         desc: '',
         desc: '',
         doc: '',
         doc: '',
         file: '',
         file: '',
-        resource: '非定向',
+        resource: '0',
+        location: {provinceCode: '3200', cityCode: '3201'},
         institution: '',
         institution: '',
         datetime: '',
         datetime: '',
         price: '',
         price: '',
@@ -236,14 +249,48 @@ export default {
     })
     })
   },
   },
   watch: {
   watch: {
+    'project.institution' () {
+      if (this.project.institution) {
+        this.$refs.addFormProvince.resetProviceCity()
+        this.project.location = {provinceCode: '', cityCode: ''}
+      }
+    },
+    'project.location' () {
+      if (this.project.location.provinceCode || this.project.location.cityCode) {
+        this.project.institution = ''
+      }
+    },
     'project.resource' () {
     'project.resource' () {
-      if (this.project.resource == '非定向') {
+      if (this.project.resource == '2') {
+        this.$refs.addFormProvince.resetProviceCity()
         this.project.institution = ''
         this.project.institution = ''
+        this.project.location = {provinceCode: '', cityCode: ''}
       }
       }
     },
     },
     deep: true
     deep: true
   },
   },
   methods: {
   methods: {
+    updateLocation (location) {
+      var provinceName = ''
+      var cityName = ''
+      for (var item of provinceCityJSON.provinces) {
+        if (item.code === location.provinceCode) {
+          provinceName = item.name
+          for (var city of item.cities) {
+            if (city.code === location.cityCode) {
+              cityName = city.name
+              break
+            }
+          }
+        }
+      }
+      return provinceName + ' / ' + cityName
+    },
+    locationChange (provinceId, cityId) {
+      if (provinceId || cityId) {
+        this.project.location = {provinceCode: provinceId, cityCode: cityId}
+      }
+    },
     init () {
     init () {
       this.project.platform.map(item => {
       this.project.platform.map(item => {
         this.platformType.push(PlatformType[item])
         this.platformType.push(PlatformType[item])

+ 7 - 5
src/components/task/TaskCreate.vue

@@ -22,7 +22,7 @@
         </el-form-item>
         </el-form-item>
         <el-form-item label="任务可见性" prop="resource">
         <el-form-item label="任务可见性" prop="resource">
           <el-tabs :tab-position="tabPosition" v-model="task.resource" style="max-height: 200px;">
           <el-tabs :tab-position="tabPosition" v-model="task.resource" style="max-height: 200px;">
-            <el-tab-pane label="定向" name="定向">
+            <el-tab-pane :label="resourceType[0]" name="0">
               <el-radio-group v-model="task.institution">
               <el-radio-group v-model="task.institution">
                 <el-radio
                 <el-radio
                   :label="item"
                   :label="item"
@@ -32,7 +32,7 @@
                 ></el-radio>
                 ></el-radio>
               </el-radio-group>
               </el-radio-group>
             </el-tab-pane>
             </el-tab-pane>
-            <el-tab-pane label="区域" name="区域">
+            <el-tab-pane :label="resourceType[1]" name="1">
               <provincecity
               <provincecity
                 ref="addFormProvince"
                 ref="addFormProvince"
                 @selectChange="locationChange"
                 @selectChange="locationChange"
@@ -40,7 +40,7 @@
                 :cityCode="task.location.cityCode"
                 :cityCode="task.location.cityCode"
               ></provincecity>
               ></provincecity>
             </el-tab-pane>
             </el-tab-pane>
-            <el-tab-pane label="广场" name="广场"></el-tab-pane>
+            <el-tab-pane :label="resourceType[0]" name="2"></el-tab-pane>
           </el-tabs>
           </el-tabs>
         </el-form-item>
         </el-form-item>
 
 
@@ -71,6 +71,7 @@ import provincecity from '@/components/commons/ProvinceCity'
 import provinceCityJSON from '@/constants/provinceCity.json'
 import provinceCityJSON from '@/constants/provinceCity.json'
 import Http from '@/js/http.js'
 import Http from '@/js/http.js'
 import Apis from '@/js/api.js'
 import Apis from '@/js/api.js'
+import ResourceType from '@/constants/enum/resource-type.js'
 
 
 export default {
 export default {
   name: 'Task',
   name: 'Task',
@@ -82,12 +83,13 @@ export default {
       projectId: 0,
       projectId: 0,
       institutionArray: Enum.institution,
       institutionArray: Enum.institution,
       tabPosition: 'top',
       tabPosition: 'top',
+      resourceType:ResourceType,
       task: {
       task: {
         name: '',
         name: '',
         desc: '',
         desc: '',
         type: '',
         type: '',
-        resource: '广场', //如果是广场不用管Location和institution ,定向看institution,区域看location
-        location: {provinceCode: '', cityCode: ''},
+        resource: '1', //如果是广场不用管Location和institution ,定向看institution,区域看location
+        location: {provinceCode: '3200', cityCode: '3201'},
         institution: '',
         institution: '',
         datetime: ''
         datetime: ''
       },
       },