Task.vue 37 KB

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