Project.vue 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992
  1. <template>
  2. <div class="create-container" v-loading="loading">
  3. <div class="title h1" v-if="!isModifyMode">项目</div>
  4. <div class="create-body">
  5. <el-row type="flex" align="middle" justify="start">
  6. <el-col :span="15">
  7. <div class="title h2" v-if="!isModifyMode">基本信息</div>
  8. <div v-if="!isModifyMode" class="el-form-item">
  9. <label class="el-form-item__label" style="width: 30%;">编号</label>
  10. <div class="el-form-item__content" style="margin-left: 30%;">
  11. <div>{{projectId}}</div>
  12. </div>
  13. </div>
  14. <el-form :model="project" :rules="rules" ref="project" label-width="30%" class="demo-project">
  15. <el-form-item label="项目名称" prop="name">
  16. <el-input size="small" v-if="isModifyMode" v-model="project.name"></el-input>
  17. <span v-if="!isModifyMode">{{project.name}}</span>
  18. </el-form-item>
  19. <el-form-item size="small" label="联系人" prop="contactName">
  20. <el-input v-if="isModifyMode" v-model="project.contactName" placeholder="请输入联系人姓名"></el-input>
  21. <span v-if="!isModifyMode">{{project.contactName}}</span>
  22. </el-form-item>
  23. <el-form-item size="small" label="联系人电话" prop="contactPhone">
  24. <el-input v-if="isModifyMode" v-model="project.contactPhone" placeholder="请输入联系人电话"></el-input>
  25. <span v-if="!isModifyMode">{{project.contactPhone}}</span>
  26. </el-form-item>
  27. <el-form-item size="small" label="预算" prop="budget">
  28. <el-input v-if="isModifyMode" type="number" v-model="project.budget">
  29. ¥
  30. <template slot="append"></template>
  31. </el-input>
  32. <span v-if="!isModifyMode">{{project.budget}}¥</span>
  33. </el-form-item>
  34. <el-form-item v-if="!isModifyMode" size="small" label="状态" prop="status">
  35. <span v-if="!isModifyMode">{{project.status==1?'等待接收':(project.status==2?'已被接收':(project.status==3?'项目已提交':'项目已结束'))}}</span>
  36. </el-form-item>
  37. <el-form-item label="需求描述">
  38. <el-input style="width: 400px" autosize v-if="isModifyMode" type="textarea"
  39. v-model="project.desc"></el-input>
  40. <span v-if="!isModifyMode">{{project.desc}}</span>
  41. </el-form-item>
  42. <!--<el-form-item label="价格" prop="price">-->
  43. <!--<el-input v-if="isModifyMode" type="number" v-model="project.price">-->
  44. <!--<template slot="append">¥</template>-->
  45. <!--</el-input>-->
  46. <!--<span v-if="!isModifyMode">{{project.price}}¥</span>-->
  47. <!--</el-form-item>-->
  48. <el-form-item label="平台" prop="platform">
  49. <el-checkbox-group v-if="isModifyMode" v-model="project.platform">
  50. <span v-for="(item,index) in platforms" :key="index">
  51. <el-checkbox :label="item">{{ item }}&nbsp;&nbsp;&nbsp;&nbsp;</el-checkbox>
  52. </span>
  53. </el-checkbox-group>
  54. <span
  55. v-if="!isModifyMode"
  56. class="badge"
  57. v-for="item in project.platform"
  58. >{{item}}</span>
  59. </el-form-item>
  60. <el-form-item label="服务类型" prop="type">
  61. <el-checkbox-group v-if="isModifyMode" v-model="project.type">
  62. <span v-for="(item,index) in serviceType" :key="index">
  63. <el-checkbox :label="item" name="type">{{ item }}&nbsp;&nbsp;</el-checkbox>
  64. </span>
  65. </el-checkbox-group>
  66. <span v-if="!isModifyMode" class="badge" v-for="item in project.type">{{item}}</span>
  67. </el-form-item>
  68. <!--<el-form-item label="用途" prop="usage">-->
  69. <!--<el-input v-if="isModifyMode" v-model="project.usage"></el-input>-->
  70. <!--<span v-if="!isModifyMode">{{project.usage}}</span>-->
  71. <!--</el-form-item>-->
  72. <el-form-item label="项目可见性" prop="resource">
  73. <div v-if="!isModifyMode">
  74. <div v-if="project.resource=='1'">{{updateLocation(project.location)}}</div>
  75. <div v-if="project.resource=='0'">{{project.institution==null?'暂未被接收':project.institution}}</div>
  76. <div v-if="project.resource=='2'">{{resourceType[project.resource]}}</div>
  77. </div>
  78. <el-tabs :tab-position="tabPosition" v-model="project.resource" style="max-height: 200px;"
  79. v-if="isModifyMode">
  80. <el-tab-pane :label="resourceType[0]" name="0">
  81. <el-radio-group v-model="project.institution">
  82. <el-radio :label="item" name="type" v-for="(item,index) in institutionArray" :key="index">
  83. {{item.name}}
  84. </el-radio>
  85. </el-radio-group>
  86. </el-tab-pane>
  87. <el-tab-pane :label="resourceType[1]" name="1">
  88. <provincecity
  89. ref="addFormProvince"
  90. @selectChange="locationChange"
  91. :provinceCode="project.location==null?'3200':project.location.provinceCode"
  92. :cityCode="project.location==null?'3201':project.location.cityCode"
  93. ></provincecity>
  94. </el-tab-pane>
  95. <el-tab-pane :label="resourceType[2]" name="2"></el-tab-pane>
  96. </el-tabs>
  97. </el-form-item>
  98. <el-form-item label="需求文档" prop="doc">
  99. <el-upload
  100. style="width: 400px"
  101. v-if="isModifyMode"
  102. drag
  103. class="upload-demo"
  104. action=""
  105. :on-remove="handleRemove"
  106. :before-remove="beforeRemove"
  107. :limit="1"
  108. :on-exceed="handleExceed"
  109. :before-upload="beforeFileUpload"
  110. :http-request="uploadRequireDoc"
  111. :file-list="project.doc"
  112. >
  113. <i class="el-icon-upload"></i>
  114. <div class="el-upload__text">
  115. 将文件拖到此处,或
  116. <em>点击上传</em>
  117. </div>
  118. </el-upload>
  119. <span v-if="!isModifyMode">
  120. <a :href="project.requireDocUrl" v-if="project.requireDocUrl!=null && project.requireDocUrl!=''"><el-link
  121. :underline="false" type="primary"><i
  122. class="el-icon-document"></i>下载文档</el-link></a>
  123. <i v-if="project.requireDocUrl==null || project.requireDocUrl==''" class="el-icon-document">暂无文档</i>
  124. </span>
  125. </el-form-item>
  126. <el-form-item label="安装包" prop="file">
  127. <el-upload
  128. style="width: 400px"
  129. v-if="isModifyMode"
  130. drag
  131. class="upload-demo"
  132. action=""
  133. :on-remove="handleRemove"
  134. :before-remove="beforeRemove"
  135. :limit="1"
  136. :on-exceed="handleExceed"
  137. :before-upload="beforeApkUpload"
  138. :http-request="uploadApkFile"
  139. :file-list="project.file"
  140. >
  141. <i class="el-icon-upload"></i>
  142. <div class="el-upload__text">
  143. 将文件拖到此处,或
  144. <em>点击上传</em>
  145. </div>
  146. </el-upload>
  147. <span v-if="!isModifyMode">
  148. <a v-if="project.fileUrl!=null && project.fileUrl!=''" :href="project.fileUrl"><el-link :underline="false"
  149. type="primary"><i
  150. class="el-icon-document"></i>下载文件</el-link></a>
  151. <i v-if="project.fileUrl==null || project.fileUrl==''" class="el-icon-document">暂无文件</i>
  152. </span>
  153. </el-form-item>
  154. <el-form-item label="项目截止时间" prop="datetime">
  155. <div class="block" v-if="isModifyMode">
  156. <el-date-picker
  157. size="small"
  158. v-model="project.datetime"
  159. type="datetime"
  160. placeholder="选择截止时间"
  161. align="right"
  162. :picker-options="pickerOptions"
  163. ></el-date-picker>
  164. </div>
  165. <span v-if="!isModifyMode">{{reformDate(new Date(project.datetime))}}</span>
  166. </el-form-item>
  167. <el-form-item v-if="isModifyMode">
  168. <div class="btn btn-small btn-info" @click="submitForm('project')">确认修改</div>
  169. <div class="btn btn-small" @click="resetForm('project')">重置</div>
  170. <div class="btn btn-small" @click="cancelMode('project')">取消</div>
  171. </el-form-item>
  172. <el-form-item v-if="!isModifyMode">
  173. <el-button v-if="projectOperationControl.confirmFinish" type="success" size="mini" @click="endProject()">
  174. 结束项目
  175. </el-button>
  176. <el-button v-if="projectOperationControl.finish" type="primary" size="mini"
  177. @click="submitProjectRequest()">
  178. 提交项目
  179. </el-button>
  180. <el-button v-if="projectOperationControl.receive" type="primary" size="mini" @click="receiveProject()">
  181. 接受项目
  182. </el-button>
  183. <el-button v-if="projectOperationControl.reject" type="danger" size="mini" @click="rejectProject()">
  184. 拒绝项目
  185. </el-button>
  186. <el-button v-if="projectOperationControl.update" type="primary" size="mini" @click="modifyForm()">
  187. 修改项目
  188. </el-button>
  189. <el-button v-if="projectOperationControl.createTask" type="primary" size="mini" @click="createNewTask()">
  190. 新建任务
  191. </el-button>
  192. <el-button v-if="projectOperationControl.uploadReport" type="primary" size="mini" @click="createReport()">
  193. 上传报告
  194. </el-button>
  195. </el-form-item>
  196. </el-form>
  197. </el-col>
  198. <el-col :span="5" id="pieImage" style="height: 500px;min-width: 500px">
  199. </el-col>
  200. </el-row>
  201. </div>
  202. <div class="create-body" v-if="!isModifyMode">
  203. <div class="title h2">任务列表</div>
  204. <div class="task-list">
  205. <el-table :showHeader="true" :stripe="true" :data="task" style="width: 100%">
  206. <el-table-column prop="title" label="任务名称" title="任务名称">
  207. <template slot-scope="scope">
  208. <span>{{ scope.row.title }}</span>
  209. </template>
  210. </el-table-column>
  211. <el-table-column prop="datetime" sortable label="任务截止时间">
  212. <template slot-scope="scope">
  213. <span>{{reformDate(new Date(scope.row.datetime))}}</span>
  214. </template>
  215. </el-table-column>
  216. <el-table-column prop="resource" label="任务可见性">
  217. <template slot-scope="scope">
  218. <div v-if="scope.row.resource=='1'">{{scope.row.location.provinceCode}}/{{scope.row.location.cityCode}}
  219. </div>
  220. <div v-if="scope.row.resource=='0'">{{scope.row.institution}}</div>
  221. <div v-if="scope.row.resource=='2'">{{resourceType[scope.row.resource]}}</div>
  222. </template>
  223. </el-table-column>
  224. <el-table-column prop="type" label="业务类型">
  225. <template slot-scope="scope">
  226. <div class="badge">{{scope.row.serviceType}}</div>
  227. </template>
  228. </el-table-column>
  229. <el-table-column align="center" label="状态">
  230. <template slot-scope="scope">
  231. <el-tag :type="scope.row.statusVO.style">{{scope.row.statusVO.text}}</el-tag>
  232. </template>
  233. </el-table-column>
  234. <el-table-column align="right" label="操作">
  235. <template slot-scope="scope">
  236. <div
  237. class="btn btn-small btn-info"
  238. @click="goToTaskDetail(projectId, scope.row.id)"
  239. >查看详情
  240. </div>
  241. <div
  242. class="btn btn-small btn-danger"
  243. @click="handleDelete(scope.$index, scope.row.id)"
  244. >删除
  245. </div>
  246. </template>
  247. </el-table-column>
  248. </el-table>
  249. </div>
  250. </div>
  251. <div class="create-body" v-if="!isModifyMode">
  252. <div class="title h2">报告列表</div>
  253. <report-list v-bind:reports="reportList" v-bind:taskId=null v-bind:projectId="projectId"/>
  254. </div>
  255. </div>
  256. </template>
  257. <script>
  258. import ReportList from '@/components/report/ReportList'
  259. import Http from '@/js/http.js'
  260. import Apis from '@/js/api.js'
  261. import ResourceType from '@/constants/enum/resource-type'
  262. import provincecity from '@/components/commons/ProvinceCity'
  263. import {notify} from '@/constants/index'
  264. import echarts from 'echarts'
  265. import {
  266. checkFileType,
  267. ensureEndProject,
  268. getAllInstitutions,
  269. getAllPlatformTypes,
  270. getAllServiceTypes,
  271. getFormalTimeFromDate,
  272. getProvinceCodeByProvinceName,
  273. getProvinceNameByProvinceCode,
  274. receiveProjectRequest,
  275. rejectProject,
  276. storageGet,
  277. submitProjectRequest
  278. } from '@/js/index'
  279. export default {
  280. name: 'Project',
  281. components: {
  282. provincecity,
  283. ReportList
  284. },
  285. data () {
  286. var validatePass = (rule, value, callback) => {
  287. var reg = /^(0|86|17951)?(13[0-9]|15[012356789]|17[678]|18[0-9]|14[57])[0-9]{8}$/
  288. if (this.project.contactPhone) {
  289. if (!reg.test(this.project.contactPhone)) {
  290. callback(new Error('请检查手机号码'))
  291. } else {
  292. callback()
  293. }
  294. }
  295. }
  296. return {
  297. projectId: 0,
  298. user: {},
  299. loading: false,
  300. tabPosition: 'top',
  301. institutionArray: [],
  302. isModifyMode: false,
  303. platforms: [],
  304. resourceType: ResourceType,
  305. serviceType: [],
  306. projectOperationControl: {
  307. confirmFinish: false,
  308. createTask: false,
  309. finish: false,
  310. receive: false,
  311. reject: false,
  312. update: false,
  313. uploadReport: false,
  314. },
  315. project: {
  316. userId: 0,
  317. name: '',
  318. type: '',
  319. platform: '',
  320. desc: '',
  321. resource: '',
  322. location: '',
  323. institution: {},
  324. contactName: '',
  325. contactPhone: '',
  326. doc: [],
  327. requireDocUrl: '',
  328. file: [],
  329. fileUrl: '',
  330. budget: '',
  331. price: '',
  332. datetime: '',
  333. usage: '',
  334. status: ''
  335. },
  336. task: [],
  337. progress: [],
  338. reportList: [],
  339. pickerOptions: {
  340. shortcuts: [
  341. {
  342. text: '今天',
  343. onClick (picker) {
  344. picker.$emit('pick', new Date())
  345. }
  346. },
  347. {
  348. text: '昨天',
  349. onClick (picker) {
  350. const date = new Date()
  351. date.setTime(date.getTime() - 3600 * 1000 * 24)
  352. picker.$emit('pick', date)
  353. }
  354. },
  355. {
  356. text: '一周前',
  357. onClick (picker) {
  358. const date = new Date()
  359. date.setTime(date.getTime() - 3600 * 1000 * 24 * 7)
  360. picker.$emit('pick', date)
  361. }
  362. }
  363. ]
  364. },
  365. rules: {
  366. name: [
  367. {required: true, message: '请输入项目名称', trigger: 'blur'},
  368. {min: 5, max: 50, message: '项目名称长度在 5 到 50 个字符', trigger: 'blur'}
  369. ],
  370. contactName: [
  371. {required: true, message: '请输入联系人姓名', trigger: 'blur'}
  372. // { min: 3, max: 5, message: "长度在 3 到 5 个字符", trigger: "blur" }
  373. ],
  374. contactPhone: [
  375. {required: true, message: '请输入手机号', trigger: 'blur'},
  376. //{min: 11, max: 11, message: '请输入正确的手机号', trigger: 'blur'}
  377. ],
  378. type: [
  379. {
  380. type: 'array',
  381. required: true,
  382. message: '请至少选择一种服务类型',
  383. trigger: 'change'
  384. }
  385. ],
  386. platform: [
  387. {
  388. type: 'array',
  389. required: true,
  390. message: '请至少选择一个平台',
  391. trigger: 'change'
  392. }
  393. ],
  394. desc: [{required: false, message: '请填写描述', trigger: 'blur'}],
  395. //price: [{required: true, message: '请填写价格', trigger: 'blur'}],
  396. budget: [
  397. {required: true, message: '预算不可为空', trigger: 'blur'},
  398. {
  399. validator: (rule, value, callback) => {
  400. if (value < 0) {
  401. callback(new Error('请输入不小于0的数'))
  402. } else {
  403. callback()
  404. }
  405. }, trigger: 'blur'
  406. },
  407. ],
  408. resource: [
  409. {required: true},
  410. {
  411. validator: (rule, value, callback) => {
  412. if (value == 0 && this.project.institution == null) {
  413. callback(new Error('定向发布至少要选择一个区域管理员'))
  414. } else {
  415. callback()
  416. }
  417. }, trigger: 'change'
  418. },
  419. ],
  420. datetime: [{required: true, message: '截止时间不可为空', trigger: 'blur'}],
  421. }
  422. }
  423. },
  424. mounted () {
  425. this.$nextTick(() => {
  426. this.init()
  427. })
  428. },
  429. watch: {
  430. serviceType (val) {
  431. this.serviceType = val
  432. },
  433. institutionArray (val) {
  434. this.institutionArray = val
  435. },
  436. // 'project.institution' () {
  437. // if (this.project.institution) {
  438. // //this.$refs.addFormProvince.resetProviceCity()
  439. // this.project.location = {provinceCode: '', cityCode: ''}
  440. // }
  441. // },
  442. // 'project.location' () {
  443. // if (this.project.location.provinceCode || this.project.location.cityCode) {
  444. // this.project.institution = ''
  445. // }
  446. // },
  447. // 'project.resource' () {
  448. // if (this.project.resource == '2') {
  449. // //this.$refs.addFormProvince.resetProviceCity()
  450. // this.project.institution = ''
  451. // this.project.location = {provinceCode: '', cityCode: ''}
  452. // }
  453. // },
  454. deep: true
  455. },
  456. methods: {
  457. updateLocation (location) {
  458. //console.log(location)
  459. const loactionName = getProvinceNameByProvinceCode(location.provinceCode, location.cityCode)
  460. // var provinceName = ''
  461. // var cityName = ''
  462. // for (var item of provinceCityJSON.provinces) {
  463. // if (item.code === location.provinceCode) {
  464. // provinceName = item.name
  465. // for (var city of item.cities) {
  466. // if (city.code === location.cityCode) {
  467. // cityName = city.name
  468. // break
  469. // }
  470. // }
  471. // }
  472. // }
  473. return loactionName.provinceCode + ' / ' + loactionName.cityCode
  474. },
  475. init () {
  476. this.projectId = this.$route.params.projectId
  477. this.setServiceType()
  478. this.setPlatformType()
  479. this.setInstitutions()
  480. this.setUserInfo()
  481. this.loadData()
  482. //this.reformDate(123)
  483. // this.project.platform.map(item => {
  484. // this.platformType.push(PlatformType[item])
  485. // })
  486. },
  487. //画个饼
  488. setEcharts () {
  489. // 基于准备好的dom,初始化echarts实例
  490. let myChart = echarts.init(document.getElementById('pieImage'))
  491. // 绘制图表
  492. var option = {
  493. tooltip: {
  494. trigger: 'item',
  495. formatter: '{a} <br/>{b}: {c} ({d}%)'
  496. },
  497. legend: {
  498. orient: 'vertical',
  499. x: 'left',
  500. data: ['已完成', '进行中']
  501. },
  502. series: [
  503. {
  504. name: '任务状态',
  505. type: 'pie',
  506. radius: ['50%', '70%'],
  507. avoidLabelOverlap: false,
  508. label: {
  509. normal: {
  510. show: false,
  511. position: 'center'
  512. },
  513. emphasis: {
  514. show: true,
  515. textStyle: {
  516. fontSize: '30',
  517. fontWeight: 'bold'
  518. }
  519. }
  520. },
  521. labelLine: {
  522. normal: {
  523. show: false
  524. }
  525. },
  526. data: this.progress,
  527. color:['#909399','#409EFF']
  528. }
  529. ]
  530. }
  531. myChart.setOption(option)
  532. },
  533. //提交修改
  534. submitForm (formName) {
  535. this.$refs['project'].validate(valid => {
  536. if (valid) {
  537. this.showLoading()
  538. const newProject = {
  539. userId: this.user.userVO.id,
  540. name: this.project.name,
  541. type: this.project.type,
  542. platform: this.project.platform,
  543. desc: this.project.desc,
  544. resource: this.project.resource,
  545. location: getProvinceNameByProvinceCode(this.project.location.provinceCode, this.project.location.cityCode),
  546. institution: this.project.institution == null ? null : this.project.institution.id,
  547. contactName: this.project.contactName,
  548. contactPhone: this.project.contactPhone,
  549. doc: this.project.requireDocUrl,
  550. file: this.project.fileUrl,
  551. budget: this.project.budget,
  552. price: this.project.price,
  553. datetime: this.project.datetime,
  554. usage: this.project.usage,
  555. }
  556. Http.put(Apis.PROJECT.UPDATE_PROJECT.replace('{projectId}', this.projectId), newProject).then((res) => {
  557. console.log('bb')
  558. console.log(res)
  559. this.projectId = res.projectDetails.id
  560. this.project.name = res.projectDetails.name
  561. this.project.contactName = res.projectDetails.contactName
  562. this.project.contactPhone = res.projectDetails.contactPhone
  563. this.project.type = res.projectDetails.type
  564. this.project.platform = res.projectDetails.platform
  565. this.project.desc = res.projectDetails.desc
  566. this.project.doc = []
  567. this.project.file = []
  568. this.project.resource = res.projectDetails.resource
  569. this.project.location = getProvinceCodeByProvinceName(res.projectDetails.location.provinceCode, res.projectDetails.location.cityCode)
  570. this.project.institution = res.projectDetails.institution
  571. this.project.datetime = new Date(res.projectDetails.datetime)
  572. this.project.price = res.projectDetails.price
  573. this.project.budget = res.projectDetails.budget
  574. this.project.usage = res.projectDetails.usage
  575. this.project.fileUrl = res.projectDetails.file
  576. this.project.requireDocUrl = res.projectDetails.doc
  577. this.task = res.taskList
  578. this.reportList = res.reportList
  579. this.isModifyMode = false
  580. this.hideLoading()
  581. notify('success', '项目修改成功')
  582. }).catch(error => {
  583. this.hideLoading()
  584. notify('error', error.data)
  585. console.log(error)
  586. })
  587. } else {
  588. notify('error', '表单填写错误!')
  589. return false
  590. }
  591. })
  592. },
  593. //重置表单
  594. resetForm (formName) {
  595. this.$refs[formName].resetFields()
  596. this.project.name = ''
  597. this.project.type = []
  598. this.project.platform = []
  599. this.project.desc = ''
  600. this.project.doc = ''
  601. this.project.file = ''
  602. this.project.contactName = ''
  603. this.project.contactPhone = ''
  604. this.project.resource = '2'
  605. this.project.institution = ''
  606. this.project.datetime = ''
  607. this.project.price = ''
  608. this.project.usage = ''
  609. this.project.budget = ''
  610. },
  611. //进入修改项目页面
  612. modifyForm () {
  613. this.isModifyMode = true
  614. console.log(this.project.doc)
  615. //this.setInstitutions()
  616. //获得update 信息
  617. //this.loadData()
  618. },
  619. //接收项目
  620. receiveProject () {
  621. this.$confirm('确认接收项目?', '提示', {
  622. confirmButtonText: '确认接收',
  623. cancelButtonText: '取消',
  624. type: 'success'
  625. }).then(() => {
  626. this.showLoading()
  627. console.log('接收项目')
  628. receiveProjectRequest(this.projectId, this.user.userVO.id, this.receiveProjectSuccess, this.receiveProjectFail)
  629. }).catch(() => {
  630. })
  631. },
  632. receiveProjectSuccess (res) {
  633. this.hideLoading()
  634. notify('success', '项目接收成功!')
  635. this.projectOperationControl = res.projectOperationControl
  636. this.project.status = res.projectDetails.status
  637. this.project.institution = res.projectDetails.institution
  638. },
  639. receiveProjectFail (error) {
  640. this.hideLoading()
  641. notify('error', '接收项目失败:' + error.data)
  642. },
  643. //拒绝项目
  644. rejectProject () {
  645. this.$confirm('确认拒绝项目?', '提示', {
  646. confirmButtonText: '确认拒绝',
  647. cancelButtonText: '取消',
  648. type: 'success'
  649. }).then(() => {
  650. this.showLoading()
  651. rejectProject(this.projectId, this.rejectProjectSuccess, this.rejectProjectFail)
  652. }).catch(() => {
  653. })
  654. },
  655. rejectProjectSuccess (res) {
  656. this.hideLoading()
  657. notify('success', '拒绝项目成功')
  658. },
  659. rejectProjectFail (error) {
  660. this.hideLoading()
  661. notify('error', '拒绝项目失败:' + error.data)
  662. },
  663. //提交项目
  664. submitProjectRequest () {
  665. this.$confirm('确认提交项目?', '提示', {
  666. confirmButtonText: '确认提交',
  667. cancelButtonText: '取消',
  668. type: 'success'
  669. }).then(() => {
  670. this.showLoading()
  671. submitProjectRequest(this.projectId, this.submitProjectRequestSuccess, this.submitProjectRequestFail)
  672. }).catch(() => {
  673. })
  674. },
  675. submitProjectRequestSuccess (res) {
  676. this.hideLoading()
  677. notify('success', '项目提交成功!')
  678. this.projectOperationControl = res.projectOperationControl
  679. this.project.status = res.projectDetails.status
  680. this.project.institution = res.projectDetails.institution
  681. },
  682. submitProjectRequestFail (error) {
  683. this.hideLoading()
  684. notify('error', '提交项目失败:' + error.data)
  685. },
  686. //结束项目
  687. endProject () {
  688. this.$confirm('确认结束项目?', '提示', {
  689. confirmButtonText: '确认结束',
  690. cancelButtonText: '取消',
  691. type: 'success'
  692. }).then(() => {
  693. this.showLoading()
  694. ensureEndProject(this.projectId, this.endProjectSuccess, this.endProjectFail)
  695. }).catch(() => {
  696. })
  697. },
  698. endProjectSuccess (res) {
  699. this.hideLoading()
  700. notify('success', '项目提交成功!')
  701. this.projectOperationControl = res.projectOperationControl
  702. this.project.status = res.projectDetails.status
  703. this.project.institution = res.projectDetails.institution
  704. },
  705. endProjectFail (error) {
  706. this.hideLoading()
  707. notify('error', '结束项目失败:' + error.data)
  708. },
  709. cancelMode (formName) {
  710. this.isModifyMode = false
  711. this.loadData()
  712. },
  713. goToTaskDetail (projectId, taskId) {
  714. this.$router.push({
  715. name: 'Task',
  716. params: {projectId: projectId, taskId: taskId}
  717. })
  718. },
  719. createNewTask () {
  720. const that = this
  721. this.$router.push({
  722. name: 'TaskCreate',
  723. params: {projectId: that.projectId}
  724. })
  725. },
  726. createReport () {
  727. this.$router.push({
  728. name: 'ProjectReportCreate',
  729. params: {
  730. scope: 0,
  731. dependencyCode: this.projectId,
  732. projectId: this.projectId,
  733. }
  734. })
  735. },
  736. handleDelete (index, id) {
  737. this.$confirm('确认删除该任务?')
  738. .then(_ => {
  739. //done()
  740. notify('success', '删除成功')
  741. })
  742. .catch(_ => {
  743. notify('error', '删除失败')
  744. })
  745. //this.task.splice(index, 1)
  746. },
  747. beforeApkUpload (file) {
  748. const isAPK = file.type === 'application/vnd.android.package-archive'
  749. const isDMG = file.type === 'application/octet-stream'
  750. if (!isAPK && !isDMG) {
  751. this.$message.error('上传安装包只能是 APK 或 DMG 格式!')
  752. }
  753. return isAPK || isDMG
  754. },
  755. beforeFileUpload (file) {
  756. console.log(file)
  757. const isPDF = file.type === 'application/pdf'
  758. const isDOC = file.type === 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'
  759. const isEXCEL = file.type === 'application/vnd.ms-excel'
  760. const isXLS = file.type === 'application/x-xls'
  761. const isTXT = file.type === 'text/plain'
  762. const isXLSX = file.type === 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
  763. //console.log(file)
  764. if (!(isDOC || isEXCEL || isPDF || isTXT || isXLS || isXLSX)) {
  765. this.$message.error('上传文件只能是 PDF 、 DOC 、DOCX 、XLS、TXT、XLSX 格式!')
  766. }
  767. return isDOC || isEXCEL || isPDF || isTXT || isXLS || isXLSX
  768. },
  769. analyseDemand () {
  770. this.$router.push({name: 'AnalyseDemand'})
  771. },
  772. handleAccept (index, id) {
  773. console.log('接受')
  774. },
  775. handleReject (index, id) {
  776. console.log('拒绝')
  777. },
  778. loadData () {//PROJ--2019073114009
  779. this.showLoading()
  780. Http.get(Apis.PROJECT.GET_PROJECT.replace('{projectId}', this.projectId)).then((res) => {
  781. console.log(res)
  782. this.projectId = res.projectDetails.id
  783. this.project.name = res.projectDetails.name
  784. this.project.contactName = res.projectDetails.contactName
  785. this.project.contactPhone = res.projectDetails.contactPhone
  786. this.project.type = res.projectDetails.type
  787. this.project.platform = res.projectDetails.platform
  788. this.project.desc = res.projectDetails.desc
  789. this.project.doc = []
  790. this.project.file = []
  791. this.project.resource = res.projectDetails.resource
  792. this.project.location = getProvinceCodeByProvinceName(res.projectDetails.location.provinceCode, res.projectDetails.location.cityCode)
  793. this.project.institution = res.projectDetails.institution
  794. this.project.datetime = new Date(res.projectDetails.datetime)
  795. this.project.price = res.projectDetails.price
  796. this.project.budget = res.projectDetails.budget
  797. this.project.usage = res.projectDetails.usage
  798. this.project.fileUrl = res.projectDetails.file
  799. this.project.requireDocUrl = res.projectDetails.doc
  800. this.project.userId = res.projectDetails.userId
  801. this.project.status = res.projectDetails.status
  802. this.task = res.taskList
  803. this.reportList = res.reportList
  804. this.projectOperationControl = res.projectOperationControl
  805. this.progress = res.progress
  806. this.hideLoading();
  807. for(var i = 0; i < this.progress.length; i++){
  808. if(this.progress[i].value != 0){
  809. this.setEcharts()
  810. break
  811. }
  812. }
  813. }).catch((error) => {
  814. this.hideLoading()
  815. notify('error', error.data)
  816. })
  817. },
  818. locationChange (provinceId, cityId) {
  819. if (provinceId || cityId) {
  820. this.project.location = {provinceCode: provinceId, cityCode: cityId}
  821. }
  822. },
  823. handleRemove (file, fileList) {
  824. console.log(file, fileList)
  825. },
  826. handleExceed (files, fileList) {
  827. this.$message.warning(
  828. `当前限制选择 1 个文件,本次选择了 ${
  829. files.length
  830. } 个文件,共选择了 ${files.length + fileList.length} 个文件`
  831. )
  832. },
  833. beforeRemove (file, fileList) {
  834. //return this.$confirm(`确定移除 ${file.name}?`)
  835. },
  836. beforeUploadRequireDoc () {
  837. },
  838. beforeUploadApkFile () {
  839. },
  840. uploadRequireDoc (param) {
  841. this.showLoading()
  842. const formData = new FormData()
  843. let config = {
  844. //添加请求头
  845. headers: {'Content-Type': 'multipart/form-data'},
  846. }
  847. formData.append('file', param.file)
  848. Http.upload(Apis.FILE.REQUIREMENT_FILE.replace('{userId}', this.user.userVO.id), formData, config).then((res) => {
  849. this.project.requireDocUrl = res.data
  850. this.hideLoading()
  851. notify('success', '需求文档上传成功')
  852. }).catch((error) => {
  853. this.hideLoading()
  854. notify('error', '需求文档上传失败:' + error.data)
  855. })
  856. },
  857. uploadApkFile (param) {
  858. this.showLoading()
  859. const formData = new FormData()
  860. let config = {
  861. //添加请求头
  862. headers: {'Content-Type': 'multipart/form-data'},
  863. }
  864. formData.append('file', param.file)
  865. Http.upload(Apis.FILE.APK.replace('{userId}', this.user.userVO.id), formData, config).then((res) => {
  866. this.project.fileUrl = res.data
  867. this.hideLoading()
  868. notify('success', '文件上传成功')
  869. }).catch((error) => {
  870. this.hideLoading()
  871. notify('error', '文件上传失败')
  872. })
  873. },
  874. setServiceType () {
  875. getAllServiceTypes().then((res) => {
  876. this.serviceType = res
  877. }).catch((error) => {
  878. notify('error', '获取项目类型列表失败')
  879. })
  880. },
  881. setPlatformType () {
  882. this.platforms = getAllPlatformTypes()
  883. },
  884. setInstitutions () {
  885. getAllInstitutions().then((res) => {
  886. this.institutionArray = res
  887. }).catch((error) => {
  888. notify('error', '获取institution失败' + error.data)
  889. })
  890. },
  891. setUserInfo () {
  892. this.user = storageGet('user')
  893. },
  894. showLoading () {
  895. this.loading = true
  896. },
  897. hideLoading () {
  898. this.loading = false
  899. },
  900. reformDate (date) {
  901. return getFormalTimeFromDate(date)
  902. }
  903. }
  904. }
  905. </script>
  906. <style lang="less" scoped>
  907. .task-list {
  908. margin: 0 30px;
  909. }
  910. .el-col {
  911. padding: 0 !important;
  912. }
  913. .el-row {
  914. margin-bottom: 10px;
  915. }
  916. .el-input {
  917. width: 400px;
  918. }
  919. </style>
  920. <!--<div class="create-body" v-if="!isModifyMode">-->
  921. <!--<div class="title h2">分析需求</div>-->
  922. <!--<div class="task-list">-->
  923. <!--<el-table :data="analyseDemandList" style="width: 100%" max-height="400">-->
  924. <!--<el-table-column prop="institution" label="承接单位" title="承接单位"></el-table-column>-->
  925. <!--<el-table-column prop="feasibilityReport" sortable label="可行性分析报告">-->
  926. <!--<template slot-scope="scope">-->
  927. <!--<span v-if="!scope.row.feasibilityReport.url">暂无文件</span>-->
  928. <!--<a-->
  929. <!--:href="scope.row.feasibilityReport.url"-->
  930. <!--v-if="scope.row.feasibilityReport.url"-->
  931. <!--target="_blank"-->
  932. <!--&gt;-->
  933. <!--<i class="fa fa-file-text-o"></i>-->
  934. <!--{{scope.row.feasibilityReport.name}}-->
  935. <!--</a>-->
  936. <!--</template>-->
  937. <!--</el-table-column>-->
  938. <!--<el-table-column prop="priceAuditReport" sortable label="可行性分析报告">-->
  939. <!--<template slot-scope="scope">-->
  940. <!--<span v-if="!scope.row.priceAuditReport.url">暂无文件</span>-->
  941. <!--<a-->
  942. <!--:href="scope.row.priceAuditReport.url"-->
  943. <!--v-if="scope.row.priceAuditReport.url"-->
  944. <!--target="_blank"-->
  945. <!--&gt;-->
  946. <!--<i class="fa fa-file-text-o"></i>-->
  947. <!--{{scope.row.priceAuditReport.name}}-->
  948. <!--</a>-->
  949. <!--</template>-->
  950. <!--</el-table-column>-->
  951. <!--<el-table-column align="right" label="操作">-->
  952. <!--<template slot-scope="scope">-->
  953. <!--<div-->
  954. <!--class="btn btn-small btn-info"-->
  955. <!--@click="handleAccept(scope.$index, scope.row.id)"-->
  956. <!--&gt;接受-->
  957. <!--</div>-->
  958. <!--<div-->
  959. <!--class="btn btn-small btn-danger"-->
  960. <!--@click="handleReject(scope.$index, scope.row.id)"-->
  961. <!--&gt;拒绝-->
  962. <!--</div>-->
  963. <!--</template>-->
  964. <!--</el-table-column>-->
  965. <!--</el-table>-->
  966. <!--</div>-->
  967. <!--</div>-->