Task.vue 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804
  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. <div class="title h2" v-if="!isModifyMode">基本信息</div>
  6. <el-form :model="task" :rules="rules" ref="task" label-width="12%" class="demo-task">
  7. <el-form-item label="任务名称" prop="title">
  8. <el-input size="small" v-if="isModifyMode" v-model="task.title"></el-input>
  9. <span v-if="!isModifyMode">{{task.title}}</span>
  10. <el-tag v-if="!isModifyMode" :type="task.statusVO&&task.statusVO.style">{{task.statusVO ? task.statusVO.text:''}}</el-tag>
  11. </el-form-item>
  12. <el-form-item label="任务描述" prop="desc">
  13. <el-input autosize v-if="isModifyMode" type="textarea" v-model="task.description"></el-input>
  14. <span v-if="!isModifyMode">{{task.description}}</span>
  15. </el-form-item>
  16. <el-form-item label="任务报价" prop="quotePrice">
  17. <el-input size="small" type="number" v-if="isModifyMode" v-model="task.quotePrice">
  18. <template slot="append">¥</template>
  19. </el-input>
  20. <span v-if="!isModifyMode">{{task.quotePrice}}¥</span>
  21. </el-form-item>
  22. <!--<el-form-item type="number" label="任务定价" prop="fixedPrice">-->
  23. <!--<el-input v-if="isModifyMode" v-model="task.fixedPrice">-->
  24. <!--<template slot="append">¥</template>-->
  25. <!--</el-input>-->
  26. <!--<span v-if="!isModifyMode">{{task.fixedPrice}}</span>-->
  27. <!--</el-form-item>-->
  28. <el-form-item label="测试类型" prop="serviceType">
  29. <el-radio-group v-if="isModifyMode" v-model="task.serviceType">
  30. <span v-for="(item,index) in serviceType" :key="index">
  31. <el-radio :label="item.code" name="serviceType">{{item.name}}</el-radio>
  32. </span>
  33. </el-radio-group>
  34. <span class="badge" v-if="!isModifyMode">{{task.serviceType}}</span>
  35. </el-form-item>
  36. <el-form-item label="任务可见性" prop="resource">
  37. <div v-if="!isModifyMode">
  38. <!--<div v-if="task.resource=='1'">{{updateLocation(task.location)}}</div>-->
  39. <div v-if="task.resource==0">定向</div>
  40. <div v-if="task.resource==2">{{resourceType[task.resource]}}</div>
  41. </div>
  42. <el-tabs
  43. :tab-position="tabPosition"
  44. v-model="task.resource"
  45. style="max-height: 200px;"
  46. v-if="isModifyMode"
  47. >
  48. <el-tab-pane :label="resourceType[0]" name="0">
  49. <el-radio-group v-model="task.institution">
  50. <el-radio
  51. :label="item"
  52. name="type"
  53. v-for="item,index in institutionArray"
  54. :key="index"
  55. >{{item.evaluationAgencyName}}
  56. </el-radio>
  57. </el-radio-group>
  58. </el-tab-pane>
  59. <!--<el-tab-pane :label="resourceType[1]" name="1">-->
  60. <!--<provincecity-->
  61. <!--ref="addFormProvince"-->
  62. <!--@selectChange="locationChange"-->
  63. <!--:provinceCode="task.location == null ||task.location.provinceCode==null?'3200':task.location.provinceCode"-->
  64. <!--:cityCode="task.location == null ||task.location.cityCode==null?'3201':task.location.cityCode"-->
  65. <!--&gt;</provincecity>-->
  66. <!--</el-tab-pane>-->
  67. <el-tab-pane :label="resourceType[2]" name="2"></el-tab-pane>
  68. </el-tabs>
  69. </el-form-item>
  70. <el-form-item label="领取人数" prop="quotePrice" v-if="isModifyMode && task.resource!=='0'">
  71. <el-input-number v-model="task.participantCount" :min="1" :max="100" label="领取人数"></el-input-number>
  72. </el-form-item>
  73. <el-form-item label="领取人数" prop="quotePrice" v-if="!isModifyMode">
  74. {{task.acceptedCount }}/{{ task.participantCount}}
  75. </el-form-item>
  76. <el-form-item label="需求文档" prop="doc">
  77. <el-upload
  78. style="width: 400px"
  79. v-if="isModifyMode"
  80. drag
  81. class="upload-demo"
  82. action=""
  83. :on-remove="handleRemove"
  84. :before-remove="beforeRemove"
  85. :limit="1"
  86. :on-exceed="handleExceed"
  87. :http-request="uploadRequireDoc"
  88. :file-list="task.doc"
  89. >
  90. <i class="el-icon-upload"></i>
  91. <div class="el-upload__text">
  92. 将文件拖到此处,或
  93. <em>点击上传</em>
  94. </div>
  95. </el-upload>
  96. <span v-if="!isModifyMode">
  97. <span v-if="task.requireDocUrl == null || task.requireDocUrl == ''">
  98. <i class="el-icon-document"></i>暂无文件
  99. </span>
  100. <span v-if="task.requireDocUrl != null && task.requireDocUrl != ''">
  101. <a :href="task.requireDocUrl"><el-link :underline="false" type="primary"><i
  102. class="el-icon-document"></i>下载文档</el-link></a>
  103. </span>
  104. </span>
  105. </el-form-item>
  106. <el-form-item label="任务截止时间" prop="datetime">
  107. <div class="block" v-if="isModifyMode">
  108. <el-date-picker
  109. size="small"
  110. v-model="task.datetime"
  111. type="datetime"
  112. placeholder="选择截止时间"
  113. align="right"
  114. :picker-options="pickerOptions"
  115. ></el-date-picker>
  116. </div>
  117. <span v-if="!isModifyMode">{{dateFormat(new Date(task.datetime),'yyyy-MM-dd HH:mm:ss')}}</span>
  118. </el-form-item>
  119. <el-form-item v-if="isModifyMode">
  120. <div class="btn btn-small btn-info" @click="updateTask()">确认修改</div>
  121. <!--<div class="btn btn-small" @click="resetForm()">重置</div>-->
  122. <div class="btn btn-small" @click="cancelMode()">取消</div>
  123. </el-form-item>
  124. <el-form-item v-if="!isModifyMode">
  125. <el-button size="mini" @click="toProject()">项目详情</el-button>
  126. <el-popover
  127. placement="top-start"
  128. title="确认结束?"
  129. width="200"
  130. trigger="hover"
  131. content="测评机构已提交结束申请,请确认是否结束该任务">
  132. <el-button v-if="taskOperationControl.confirmFinish" type="success" size="mini" slot="reference"
  133. @click="endTask()">确认结束
  134. </el-button>
  135. </el-popover>
  136. <el-popover
  137. placement="top-start"
  138. title="确认提交?"
  139. width="200"
  140. trigger="hover"
  141. content="提交任务后不可更改,等待区域管理员验收">
  142. <el-button v-if="taskOperationControl.finish" type="primary" size="mini" slot="reference"
  143. @click="submitTaskRequest()">提交任务
  144. </el-button>
  145. </el-popover>
  146. <el-popover
  147. placement="top-start"
  148. title="确认拒绝?"
  149. width="200"
  150. trigger="hover"
  151. content="拒绝后不可再接收此任务,且该任务对您不可见">
  152. <el-button v-if="taskOperationControl.reject" type="danger" size="mini" slot="reference"
  153. @click="rejectTask()">拒绝任务
  154. </el-button>
  155. </el-popover>
  156. <el-popover
  157. placement="top-start"
  158. title="确认接收?"
  159. width="200"
  160. trigger="hover"
  161. content="接收任务后请认真完成!">
  162. <el-button v-if="taskOperationControl.receive" type="primary" size="mini" slot="reference"
  163. @click="receiveTask()">接收任务
  164. </el-button>
  165. </el-popover>
  166. <el-button v-if="taskOperationControl.update" type="primary" size="mini" @click="modifyForm()">修改任务
  167. </el-button>
  168. <el-button v-if="taskOperationControl.uploadReport" type="primary" size="mini" @click="toCreateReport()">
  169. 上传报告
  170. </el-button>
  171. <!--<div class="btn btn-small btn-info"-->
  172. <!--v-if="taskOperationControl.confirmFinish"-->
  173. <!--@click="endTask()">确认结束-->
  174. <!--</div>-->
  175. <!--<div class="btn btn-small btn-info" v-if="!taskOperationControl.finish" @click="submitTaskRequest()">提交任务-->
  176. <!--</div>-->
  177. <!--<div class="btn btn-small btn-info" v-if="!taskOperationControl.receive" @click="receiveTask()">接收任务</div>-->
  178. <!--<div class="btn btn-small btn-danger" v-if="!taskOperationControl.reject" @click="rejectTask()">拒绝任务</div>-->
  179. <!--<div class="btn btn-small btn-info" v-if="taskOperationControl.update" @click="modifyForm()">修改任务</div>-->
  180. <!--<div class="btn btn-small btn-info" v-if="!taskOperationControl.uploadReport" @click="toCreateReport()">上传报告-->
  181. <!--</div>-->
  182. </el-form-item>
  183. </el-form>
  184. </div>
  185. <div class="create-body" v-if="!isModifyMode">
  186. <div class="title h2">用户报告列表</div>
  187. <el-collapse accordion style="margin: 0 30px">
  188. <el-collapse-item v-for="(item,index) in acceptedUserList" :key="item.id">
  189. <template slot="title">
  190. <el-row style="width: 100%;font-size: 16px">
  191. <el-col :span="6">{{item.userVO.userName}}</el-col>
  192. <el-col :span="6">{{item.userVO.email}}</el-col>
  193. <el-col :span="6">
  194. <el-tag type="success" v-if="item.crowdReportVOS">已提交报告</el-tag>
  195. <el-tag type="info" v-if="!item.crowdReportVOS">未提交报告</el-tag>
  196. </el-col>
  197. <el-col :span="6">
  198. <el-tag type="success" v-if="item.isCommitted">已提交任务</el-tag>
  199. <el-tag type="info" v-if="!item.isCommitted">未提交任务</el-tag>
  200. </el-col>
  201. </el-row>
  202. </template>
  203. <report-list v-bind:reports="item.crowdReportVOS" v-bind:taskId="taskId" v-bind:projectId="projectId"/>
  204. </el-collapse-item>
  205. </el-collapse>
  206. <!-- <report-list v-if="isAgency" v-bind:reports="reportList" v-bind:taskId="taskId" v-bind:projectId="projectId"/>-->
  207. <!-- <report-list v-bind:reports="reportList" v-bind:taskId="taskId" v-bind:projectId="projectId"/>-->
  208. </div>
  209. </div>
  210. </template>
  211. <script>
  212. import ResourceType from '@/constants/enum/resource-type.js'
  213. import provincecity from '@/components/commons/ProvinceCity'
  214. import ReportList from '@/components/report/ReportList'
  215. import Http from '@/js/http.js'
  216. import Apis from '@/js/api.js'
  217. import {notify} from '@/constants/index'
  218. import {
  219. ensureEndTask,
  220. getAllAgencies,
  221. getAllServiceTypes,
  222. getFormalTimeFromDate,
  223. getProvinceCodeByProvinceName,
  224. getProvinceNameByProvinceCode,
  225. getTask,
  226. receiveTaskRequest,
  227. rejectTask,
  228. storageGet,
  229. submitTaskRequest,
  230. updateTask
  231. } from '@/js/index'
  232. export default {
  233. name: 'Task',
  234. components: {
  235. provincecity,
  236. ReportList
  237. },
  238. data() {
  239. return {
  240. user: {},
  241. rolesPermissions: {},
  242. loading: false,
  243. isModifyMode: false,
  244. institutionArray: [],
  245. tabPosition: 'top',
  246. resourceType: ResourceType,
  247. serviceType: [],
  248. taskId: '',
  249. projectId: '',
  250. taskOperationControl: {
  251. confirmFinish: false,
  252. finish: false,
  253. receive: false,
  254. update: false,
  255. uploadReport: false
  256. },
  257. task: {
  258. agencyId: '',
  259. status: '',
  260. name: '',
  261. desc: '',
  262. serviceType: '',
  263. resource: '',
  264. location: {},
  265. institution: {},
  266. datetime: '',
  267. quotePrice: '',
  268. fixedPrice: '',
  269. doc: [],
  270. requireDocUrl: '',
  271. participantCount:1,
  272. title:'',
  273. description:''
  274. },
  275. reportList: [],
  276. pickerOptions: {
  277. shortcuts: [
  278. {
  279. text: '今天',
  280. onClick(picker) {
  281. picker.$emit('pick', new Date())
  282. }
  283. },
  284. {
  285. text: '昨天',
  286. onClick(picker) {
  287. const date = new Date()
  288. date.setTime(date.getTime() - 3600 * 1000 * 24)
  289. picker.$emit('pick', date)
  290. }
  291. },
  292. {
  293. text: '一周前',
  294. onClick(picker) {
  295. const date = new Date()
  296. date.setTime(date.getTime() - 3600 * 1000 * 24 * 7)
  297. picker.$emit('pick', date)
  298. }
  299. }
  300. ]
  301. },
  302. rules: {
  303. title: [
  304. {required: true, message: '请输入任务名称', trigger: 'blur'},
  305. {min: 5, max: 50, message: '任务名称长度在 5 到 50 个字符', trigger: 'blur'}
  306. ],
  307. serviceType: [
  308. {required: true, message: '测试类型不可为空', trigger: 'change'},
  309. ],
  310. desc: [{required: false, message: '请填写描述', trigger: 'blur'}],
  311. //price: [{required: true, message: '请填写价格', trigger: 'blur'}],
  312. quotePrice: [
  313. {required: true, message: '预算不可为空', trigger: 'blur'},
  314. {
  315. validator: (rule, value, callback) => {
  316. if (value <= 0) {
  317. callback(new Error('请输入大于0的数'))
  318. } else {
  319. callback()
  320. }
  321. }, trigger: 'blur'
  322. },
  323. ],
  324. resource: [
  325. {required: true},
  326. {
  327. validator: (rule, value, callback) => {
  328. if (value == 0 && this.task.institution.id == null) {
  329. callback(new Error('定向发布至少要选择一个测评机构'))
  330. } else {
  331. callback()
  332. }
  333. }, trigger: 'change'
  334. },
  335. ],
  336. datetime: [{required: true, message: '截止时间不可为空', trigger: 'blur'}],
  337. },
  338. acceptedUserList:[],
  339. }
  340. },
  341. watch: {
  342. institutionArray(val) {
  343. this.institutionArray = val
  344. },
  345. serviceType(val) {
  346. this.serviceType = val
  347. },
  348. // 'task.institution' () {
  349. // if (this.task.institution) {
  350. // //this.$refs.addFormProvince.resetProviceCity()
  351. // this.task.location = {provinceCode: '', cityCode: ''}
  352. // }
  353. // },
  354. // 'task.location' () {
  355. // if (this.task.location.provinceCode || this.task.location.cityCode) {
  356. // this.task.institution = ''
  357. // }
  358. // },
  359. // 'task.resource' () {
  360. // if (this.task.resource == '广场') {
  361. // this.$refs.addFormProvince.resetProviceCity()
  362. // this.task.institution = ''
  363. // this.task.location = {provinceCode: '', cityCode: ''}
  364. // }
  365. // },
  366. deep: true
  367. },
  368. mounted() {
  369. this.$nextTick(() => {
  370. this.init()
  371. })
  372. },
  373. methods: {
  374. init() {
  375. this.taskId = this.$route.params.taskId
  376. this.projectId = this.$route.params.projectId
  377. this.setUserInfo()
  378. this.setServiceType()
  379. //this.loadData(this.projectId, this.taskId)
  380. this.getTaskDetail()
  381. this.setInstitutions()
  382. },
  383. //跳转至项目详情页面
  384. toProject() {
  385. this.$router.push({
  386. name: 'Project',
  387. params: {projectId: this.projectId}
  388. })
  389. },
  390. //切换至可编辑页面
  391. modifyForm() {
  392. // this.task.serviceType = ''
  393. this.isModifyMode = true
  394. },
  395. //切换至不可编辑页面
  396. cancelMode() {
  397. this.isModifyMode = false
  398. },
  399. //重置表单
  400. resetForm() {
  401. this.task.name = ''
  402. this.task.desc = ''
  403. this.task.quotePrice = ''
  404. this.task.fixedPrice = ''
  405. this.task.type = ''
  406. this.task.resource = '2' //如果是广场不用管Location和institution ,定向看institution,区域看location
  407. this.task.location = {provinceCode: '', cityCode: ''}
  408. this.task.institution = ''
  409. this.task.datetime = ''
  410. this.task.participantCount = 1
  411. },
  412. //显示页面加载画面
  413. showLoading() {
  414. this.loading = true
  415. },
  416. //隐藏页面加载画面
  417. hideLoading() {
  418. this.loading = false
  419. },
  420. //加载用户信息
  421. setUserInfo() {
  422. this.user = storageGet('user')
  423. this.rolesPermissions = storageGet('rolesPermissions')
  424. },
  425. //加载任务的测试类型
  426. setServiceType() {
  427. getAllServiceTypes().then((res) => {
  428. this.serviceType = res
  429. }).catch((error) => {
  430. notify('error', '加载测试类型失败')
  431. })
  432. },
  433. //加载所有的测评机构
  434. setInstitutions() {
  435. getAllAgencies().then((res) => {
  436. this.institutionArray = res
  437. }).catch((error) => {
  438. notify('error', '获取机构列表失败')
  439. })
  440. },
  441. //获取任务详情
  442. getTaskDetail() {
  443. this.showLoading()
  444. getTask(this.projectId, this.taskId, this.getTaskDetailSuccess, this.getTaskDetailFail)
  445. },
  446. //获取任务详情成功时回调函数
  447. getTaskDetailSuccess(res) {
  448. console.log(res);
  449. this.hideLoading()
  450. console.log(res.crowdTaskVO)
  451. this.taskId = res.crowdTaskVO.id
  452. this.projectId = res.crowdTaskVO.projectId
  453. this.task.title = res.crowdTaskVO.title
  454. this.task.description = res.crowdTaskVO.description
  455. this.task.serviceType = res.crowdTaskVO.serviceType
  456. this.task.resource = res.crowdTaskVO.resource.toString()
  457. this.task.location = getProvinceCodeByProvinceName(res.crowdTaskVO.location.provinceCode, res.crowdTaskVO.location.cityCode)
  458. this.task.institution = res.crowdTaskVO.institution
  459. this.task.datetime = new Date(res.crowdTaskVO.datetime)
  460. this.task.quotePrice = res.crowdTaskVO.quotePrice
  461. this.task.acceptedCount = res.crowdTaskVO.acceptedCount
  462. this.task.participantCount = res.crowdTaskVO.participantCount
  463. this.task.fixedPrice = res.crowdTaskVO.fixedPrice
  464. this.task.doc = []
  465. this.task.requireDocUrl = res.crowdTaskVO.requirementFile
  466. this.task.agencyId = res.crowdTaskVO.agencyId
  467. this.task.status = res.crowdTaskVO.status
  468. this.task.statusVO = res.crowdTaskVO.statusVO
  469. this.taskOperationControl = res.taskOperationControl
  470. this.acceptedUserList = res.acceptedUserList;
  471. this.handleFormatReport(this.acceptedUserList);
  472. },
  473. //获取任务详情失败时回调函数
  474. getTaskDetailFail(error) {
  475. this.hideLoading()
  476. // notify('error', '获取任务详情失败:' + error.data)
  477. },
  478. //处理显示报告
  479. handleFormatReport(acceptedUserList) {
  480. acceptedUserList.map((user) => {
  481. user.crowdReportVOS && user.crowdReportVOS.map((report) => {
  482. report.userName = user.userVO.userName;
  483. this.reportList.push(report);
  484. })
  485. })
  486. },
  487. dateFormat (date, format) {
  488. date = new Date(date)
  489. let o = {
  490. 'M+' : date.getMonth() + 1, //month
  491. 'd+' : date.getDate(), //day
  492. 'H+' : date.getHours(), //hour+8小时
  493. 'm+' : date.getMinutes(), //minute
  494. 's+' : date.getSeconds(), //second
  495. 'q+' : Math.floor((date.getMonth() + 3) / 3), //quarter
  496. 'S' : date.getMilliseconds() //millisecond
  497. }
  498. if (/(y+)/.test(format)){
  499. format = format.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length));
  500. }
  501. for (let k in o)
  502. if (new RegExp('(' + k + ')').test(format))
  503. format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ('00' + o[k]).substr(('' + o[k]).length));
  504. return format;
  505. },
  506. //更新任务信息
  507. updateTask() {
  508. this.$refs['task'].validate(valid => {
  509. if (valid) {
  510. this.showLoading()
  511. const newTask = {
  512. name: this.task.title,
  513. desc: this.task.description,
  514. type: this.task.serviceType,
  515. resource: this.task.resource,
  516. location: this.task.location == null ? {} : getProvinceNameByProvinceCode(this.task.location.provinceCode, this.task.location.cityCode),
  517. institution: this.task.institution ? this.task.institution.id : null,
  518. datetime: this.task.datetime,
  519. quotePrice: this.task.quotePrice,
  520. fixedPrice: this.task.fixedPrice,
  521. requirementFile: this.task.requireDocUrl,
  522. participantCount: this.task.participantCount
  523. }
  524. //console.log(newTask)
  525. updateTask(this.projectId, this.taskId, newTask, this.updateTaskSuccess, this.updateTaskFail)
  526. } else {
  527. notify('error', '表单填写有误!')
  528. return false
  529. }
  530. })
  531. },
  532. //更新任务信息成功时回调函数
  533. updateTaskSuccess(res) {
  534. this.cancelMode()
  535. this.taskId = res.crowdTaskVO.id
  536. this.projectId = res.crowdTaskVO.projectId
  537. this.task.title = res.crowdTaskVO.title
  538. this.task.description = res.crowdTaskVO.description
  539. this.task.serviceType = res.crowdTaskVO.serviceType
  540. this.task.resource = res.crowdTaskVO.resource
  541. this.task.location = res.crowdTaskVO.location == null ? {
  542. provinceCode: 3200,
  543. cityCode: 3201
  544. } : getProvinceCodeByProvinceName(res.crowdTaskVO.location.provinceCode, res.crowdTaskVO.location.cityCode)
  545. this.task.institution = res.crowdTaskVO.institution
  546. this.task.datetime = new Date(res.crowdTaskVO.datetime)
  547. this.task.quotePrice = res.crowdTaskVO.quotePrice
  548. this.task.fixedPrice = res.crowdTaskVO.fixedPrice
  549. this.task.doc = []
  550. this.task.requireDocUrl = res.crowdTaskVO.requirementFile,
  551. this.task.participantCount = res.crowdTaskVO.participantCount
  552. this.reportList = res.crowdReportVOList
  553. this.acceptedUserList = res.acceptedUserList
  554. this.hideLoading()
  555. notify('success', '修改成功')
  556. },
  557. //更新任务信息失败时回调函数
  558. updateTaskFail(error) {
  559. notify('error', '修改失败:' + error.data)
  560. this.hideLoading()
  561. },
  562. //上传任务需求文档
  563. uploadRequireDoc(param) {
  564. const formData = new FormData()
  565. let config = {
  566. //添加请求头
  567. headers: {'Content-Type': 'multipart/form-data'},
  568. }
  569. formData.append('file', param.file)
  570. Http.upload(Apis.FILE.REQUIREMENT_FILE.replace('{userId}', this.user.userVO.id), formData, config).then((res) => {
  571. notify('success', '上传成功')
  572. this.uploadRequireDocSuccess(res)
  573. }).catch((error) => {
  574. notify('error', '上传失败:' + error.data)
  575. this.uploadRequireDocFail(error)
  576. })
  577. },
  578. //上传任务需求文档成功时回调函数
  579. uploadRequireDocSuccess(res) {
  580. this.hideLoading()
  581. console.log('上传成功')
  582. this.task.requireDocUrl = res.data
  583. console.log(res.data)
  584. },
  585. //上传任务需求文档失败时回调函数
  586. uploadRequireDocFail(error) {
  587. this.hideLoading()
  588. notify('error', '任务需求文档上传失败:' + error.data)
  589. },
  590. //文档上传前响应函数
  591. //移除文档前的响应函数
  592. beforeRemove(file, fileList) {
  593. //return this.$confirm(`确定移除 ${file.name}?`)
  594. },
  595. //移除文档时的响应函数
  596. handleRemove(file, fileList) {
  597. console.log(file, fileList)
  598. },
  599. //需求文档添加进来时的响应函数
  600. handleExceed(files, fileList) {
  601. this.$message.warning(
  602. `当前限制选择 1 个文件,本次选择了 ${
  603. files.length
  604. } 个文件,共选择了 ${files.length + fileList.length} 个文件`
  605. )
  606. },
  607. //接收任务
  608. receiveTask() {
  609. this.$confirm('确认接收任务?', '提示', {
  610. confirmButtonText: '确认接收',
  611. cancelButtonText: '取消',
  612. type: 'success'
  613. }).then(() => {
  614. this.showLoading()
  615. receiveTaskRequest(this.projectId, this.taskId, this.user.userVO.id, this.receiveTaskSuccess, this.receiveTaskFail)
  616. }).catch(() => {
  617. })
  618. },
  619. //接收任务成功时的回调函数
  620. receiveTaskSuccess(res) {
  621. this.hideLoading()
  622. this.getTaskDetail();
  623. notify('success', '接收任务成功')
  624. // console.log(res)
  625. this.taskOperationControl = res.taskOperationControl
  626. this.task.status = res.crowdTaskVO.status
  627. this.task.institution = res.crowdTaskVO.institution
  628. },
  629. //接收任务失败时的回调函数
  630. receiveTaskFail(error) {
  631. this.hideLoading()
  632. notify('error', '接收任务失败:' + error.data)
  633. },
  634. //拒绝任务
  635. rejectTask() {
  636. this.$confirm('确认拒绝任务?拒绝后将不能再接收该任务', '提示', {
  637. confirmButtonText: '确认拒绝',
  638. cancelButtonText: '取消',
  639. type: 'success'
  640. }).then(() => {
  641. this.showLoading()
  642. rejectTask(this.projectId, this.taskId, this.rejectTaskSuccess, this.rejectTaskFail)
  643. }).catch(() => {
  644. })
  645. },
  646. //拒绝任务成功时的回调函数
  647. rejectTaskSuccess(res) {
  648. this.hideLoading()
  649. this.$router.push({
  650. name: 'Mine'
  651. })
  652. notify('success', '拒绝任务成功,已为您自动跳转到个人中心')
  653. },
  654. //拒绝任务失败时的回调函数
  655. rejectTaskFail(error) {
  656. this.hideLoading()
  657. notify('error', '拒绝任务失败:' + error.data)
  658. },
  659. //提交结束任务申请
  660. submitTaskRequest() {
  661. this.$confirm('确认提交任务?提交后将不能再修改', '提示', {
  662. confirmButtonText: '确认提交',
  663. cancelButtonText: '取消',
  664. type: 'success'
  665. }).then(() => {
  666. this.showLoading()
  667. submitTaskRequest(this.projectId, this.taskId, this.submitTaskRequestSuccess, this.submitTaskRequestFail)
  668. }).catch(() => {
  669. })
  670. },
  671. //提交结束任务申请成功时的回调函数
  672. submitTaskRequestSuccess(res) {
  673. this.hideLoading()
  674. console.log(res)
  675. this.taskOperationControl = res.taskOperationControl
  676. this.task.status = res.crowdTaskVO.status
  677. this.task.institution = res.crowdTaskVO.institution
  678. notify('success', '提交任务成功,等待区域管理员审核')
  679. this.getTaskDetail();
  680. },
  681. //提交结束任务申请失败时的回调函数
  682. submitTaskRequestFail(error) {
  683. this.hideLoading()
  684. notify('error', '提交任务失败:' + error.data)
  685. },
  686. //结束任务
  687. endTask() {
  688. this.$confirm('确认结束任务?', '提示', {
  689. confirmButtonText: '确认结束',
  690. cancelButtonText: '取消',
  691. type: 'success'
  692. }).then(() => {
  693. this.getTaskDetail()
  694. this.showLoading()
  695. ensureEndTask(this.projectId, this.taskId, this.endTaskSuccess, this.endTaskFail)
  696. }).catch(() => {
  697. })
  698. },
  699. //结束任务成功时的回调函数
  700. endTaskSuccess(res) {
  701. this.hideLoading()
  702. this.taskOperationControl = res.taskOperationControl
  703. this.task.status = res.crowdTaskVO.status
  704. this.task.institution = res.crowdTaskVO.institution
  705. notify('success', '结束任务成功!')
  706. this.getTaskDetail();
  707. },
  708. //结束任务失败时的回调函数
  709. endTaskFail(error) {
  710. this.hideLoading()
  711. notify('error', '结束任务失败:' + error.data)
  712. },
  713. //跳转到创建项目报告页面
  714. toCreateReport() {
  715. this.$router.push({
  716. name: 'TaskReportCreate',
  717. params: {
  718. scope: 1,
  719. dependencyCode: this.taskId,
  720. projectId: this.projectId,
  721. taskId: this.taskId,
  722. }
  723. })
  724. },
  725. reformDate(date) {
  726. return getFormalTimeFromDate(date)
  727. }
  728. },
  729. }
  730. //回收站
  731. //
  732. // updateLocation (location) {
  733. // console.log(location)
  734. // const loactionName = getProvinceNameByProvinceCode(location.provinceCode, location.cityCode)
  735. // // var provinceName = ''
  736. // // var cityName = ''
  737. // // for (var item of provinceCityJSON.provinces) {
  738. // // if (item.code === location.provinceCode) {
  739. // // provinceName = item.name
  740. // // for (var city of item.cities) {
  741. // // if (city.code === location.cityCode) {
  742. // // cityName = city.name
  743. // // break
  744. // // }
  745. // // }
  746. // // }
  747. // // }
  748. // return loactionName.provinceCode + ' / ' + loactionName.cityCode
  749. // },
  750. //
  751. // locationChange (provinceId, cityId) {
  752. // if (provinceId || cityId) {
  753. // this.task.location = {provinceCode: provinceId, cityCode: cityId}
  754. // }
  755. // },
  756. // submitForm (formName) {
  757. // this.$refs[formName].validate(valid => {
  758. // if (valid) {
  759. // this.isModifyMode = false
  760. //
  761. // } else {
  762. // console.log('error submit!!')
  763. // return false
  764. // }
  765. // })
  766. // },
  767. </script>
  768. <style lang="less" scoped>
  769. .el-radio {
  770. margin: 10px 20px 10px 0;
  771. }
  772. .el-form-item /deep/ .el-tabs__content {
  773. max-height: 120px !important;
  774. overflow: auto;
  775. }
  776. .el-collapse-item__content{
  777. padding-bottom: 0 !important;
  778. }
  779. </style>