Task.vue 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959
  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 0 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="description" 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, institutionArray: [],
  287. tabPosition: 'top',
  288. resourceType: ResourceType,
  289. serviceType: [],
  290. taskId: '',
  291. projectId: '',
  292. taskOperationControl: {
  293. confirmFinish: false,
  294. finish: false,
  295. receive: false,
  296. update: false,
  297. uploadReport: false,
  298. writeReport: false,
  299. taskDemonstrate: false,
  300. taskRecommend: false
  301. },
  302. crowdReportUrl: '',
  303. wordCloud:[],
  304. task: {
  305. agencyId: '',
  306. status: '',
  307. name: '',
  308. desc: '',
  309. serviceType: '',
  310. resource: '',
  311. location: {},
  312. institution: {},
  313. datetime: '',
  314. quotePrice: '',
  315. fixedPrice: '',
  316. doc: [],
  317. requireDocUrl: '',
  318. participantCount: 1,
  319. title: '',
  320. description: '',
  321. endPoint: {
  322. serverCode: '',
  323. token: ''
  324. }
  325. },
  326. reportList: [],
  327. pickerOptions: {
  328. shortcuts: [
  329. {
  330. text: '今天',
  331. onClick(picker) {
  332. picker.$emit('pick', new Date())
  333. }
  334. },
  335. {
  336. text: '昨天',
  337. onClick(picker) {
  338. const date = new Date()
  339. date.setTime(date.getTime() - 3600 * 1000 * 24)
  340. picker.$emit('pick', date)
  341. }
  342. },
  343. {
  344. text: '一周前',
  345. onClick(picker) {
  346. const date = new Date()
  347. date.setTime(date.getTime() - 3600 * 1000 * 24 * 7)
  348. picker.$emit('pick', date)
  349. }
  350. }
  351. ]
  352. },
  353. rules: {
  354. title: [
  355. {required: true, message: '请输入任务名称', trigger: 'blur'},
  356. {min: 5, max: 50, message: '任务名称长度在 5 到 50 个字符', trigger: 'blur'}
  357. ],
  358. serviceType: [
  359. {required: true, message: '测试类型不可为空', trigger: 'change'},
  360. ],
  361. description: [{required: true, message: '请填写描述', trigger: 'blur'}],
  362. //price: [{required: true, message: '请填写价格', trigger: 'blur'}],
  363. quotePrice: [
  364. {required: true, message: '预算不可为空', trigger: 'blur'},
  365. {
  366. validator: (rule, value, callback) => {
  367. if (value < 0) {
  368. callback(new Error('请输入不小于0的数'))
  369. } else {
  370. callback()
  371. }
  372. }, trigger: 'blur'
  373. },
  374. ],
  375. resource: [
  376. {required: true},
  377. {
  378. validator: (rule, value, callback) => {
  379. if (value == 0 && this.task.institution.id == null) {
  380. callback(new Error('定向发布至少要选择一个测评机构'))
  381. } else {
  382. callback()
  383. }
  384. }, trigger: 'change'
  385. },
  386. ],
  387. endPoint: [
  388. {
  389. validator: (rule, value, callback) => {
  390. if (this.currType.type === 1 && this.task.endPoint.serverCode === '') {
  391. callback(new Error('请填写对应得服务序列号'))
  392. } else {
  393. callback()
  394. }
  395. }, trigger: ['change','blur']
  396. },
  397. ],
  398. datetime: [{required: true, message: '截止时间不可为空', trigger: 'blur'}],
  399. },
  400. acceptedUserList: [],
  401. shortLink:'',
  402. editShortLink:false,
  403. }
  404. },
  405. watch: {
  406. institutionArray(val) {
  407. this.institutionArray = val
  408. },
  409. serviceType(val) {
  410. this.serviceType = val
  411. },
  412. deep: true
  413. },
  414. mounted() {
  415. this.$nextTick(() => {
  416. this.init()
  417. })
  418. },
  419. methods: {
  420. //跳转到任务对应的数据面板
  421. gotoDataboard(){
  422. window.open(this.task.endPoint.token)
  423. },
  424. //根据短链接获取生成databoard
  425. getTaskDataBoard(){
  426. this.showLoading()
  427. Http.put(`/api/project/${this.projectId}/task/${this.taskId}/addToken`,{"token":this.shortLink}).then((res)=>{
  428. this.taskOperationControl = res.taskOperationControl;
  429. this.task.endPoint = res.crowdTaskVO.endPointVO;
  430. this.shortLink = res.crowdTaskVO.endPointVO.token;
  431. if(this.shortLink != ''){
  432. this.editShortLink = false;
  433. }
  434. this.hideLoading()
  435. })
  436. },
  437. getServiceByCode(code){
  438. let serviceName = this.serviceType.filter((item) => {
  439. return item.code === code;
  440. });
  441. return serviceName&&serviceName[0]&&serviceName[0]['name']
  442. },
  443. handleTestTypeChange(val) {
  444. let type = this.serviceType.filter((item) => {
  445. return item.code === val;
  446. });
  447. this.currType = type[0] ? type[0] : {};
  448. if (this.currType.type === 0) {
  449. this.$refs.task.clearValidate('endPoint');
  450. }
  451. },
  452. init() {
  453. this.taskId = this.$route.params.taskId
  454. this.projectId = this.$route.params.projectId
  455. this.setUserInfo()
  456. this.setServiceType()
  457. //this.loadData(this.projectId, this.taskId)
  458. this.getTaskDetail()
  459. this.getWordCloud()
  460. this.setInstitutions()
  461. },
  462. //北斗测试报告填写跳转
  463. gotoWriteReport() {
  464. window.open(this.crowdReportUrl, '_blank');
  465. },
  466. //跳转至项目详情页面
  467. toProject() {
  468. this.$router.push({
  469. name: 'Project',
  470. params: {projectId: this.projectId}
  471. })
  472. },
  473. //切换至可编辑页面
  474. modifyForm() {
  475. // this.task.serviceType = ''
  476. this.isModifyMode = true
  477. },
  478. //切换至不可编辑页面
  479. cancelMode() {
  480. this.isModifyMode = false
  481. },
  482. //重置表单
  483. resetForm() {
  484. this.task.name = ''
  485. this.task.desc = ''
  486. this.task.quotePrice = ''
  487. this.task.fixedPrice = ''
  488. this.task.type = ''
  489. this.task.resource = '2' //如果是广场不用管Location和institution ,定向看institution,区域看location
  490. this.task.location = {provinceCode: '', cityCode: ''}
  491. this.task.institution = ''
  492. this.task.datetime = ''
  493. this.task.participantCount = 1
  494. // this.task.endPointVO.caseId = ''
  495. // this.task.endPointVO.examId = ''
  496. },
  497. //显示页面加载画面
  498. showLoading() {
  499. this.loading = true
  500. },
  501. //隐藏页面加载画面
  502. hideLoading() {
  503. this.loading = false
  504. },
  505. //加载用户信息
  506. setUserInfo() {
  507. this.user = storageGet('user')
  508. this.rolesPermissions = storageGet('rolesPermissions')
  509. if (storageGet('rolesPermissions').isRegionManager || storageGet('rolesPermissions').isSystemAdministrator) {
  510. this.showBD = true;
  511. } else {
  512. this.showBD = false;
  513. }
  514. },
  515. //加载任务的测试类型
  516. setServiceType() {
  517. getAllServiceTypes().then((res) => {
  518. this.serviceType = res
  519. }).catch((error) => {
  520. notify('error', '加载测试类型失败')
  521. })
  522. },
  523. //加载所有的测评机构
  524. setInstitutions() {
  525. getAllAgencies().then((res) => {
  526. this.institutionArray = res
  527. }).catch((error) => {
  528. notify('error', '获取机构列表失败')
  529. })
  530. },
  531. //获取任务详情
  532. getTaskDetail() {
  533. this.showLoading()
  534. getTask(this.projectId, this.taskId, this.getTaskDetailSuccess, this.getTaskDetailFail)
  535. },
  536. //获取词云
  537. getWordCloud(){
  538. getTaskWordCloud(this.projectId, this.taskId, this.getTaskCloudSuccess, this.getTaskCloudFail)
  539. },
  540. getTaskCloudSuccess(words){
  541. this.wordCloud = words.data;
  542. },
  543. getTaskCloudFail(err){
  544. notify('error',err)
  545. },
  546. //获取任务详情成功时回调函数
  547. getTaskDetailSuccess(res) {
  548. this.hideLoading()
  549. // console.log(res)
  550. this.taskId = res.crowdTaskVO.id
  551. this.projectId = res.crowdTaskVO.projectId
  552. this.task.title = res.crowdTaskVO.title
  553. this.task.description = res.crowdTaskVO.description
  554. this.task.serviceType = res.crowdTaskVO.serviceType
  555. this.task.resource = res.crowdTaskVO.resource.toString()
  556. this.task.location = getProvinceCodeByProvinceName(res.crowdTaskVO.location.provinceCode, res.crowdTaskVO.location.cityCode)
  557. this.task.institution = res.crowdTaskVO.institution
  558. this.task.datetime = new Date(res.crowdTaskVO.datetime)
  559. this.task.quotePrice = res.crowdTaskVO.quotePrice
  560. this.task.acceptedCount = res.crowdTaskVO.acceptedCount
  561. this.task.participantCount = res.crowdTaskVO.participantCount
  562. this.task.fixedPrice = res.crowdTaskVO.fixedPrice
  563. this.task.doc = []
  564. this.task.requireDocUrl = res.crowdTaskVO.requirementFile
  565. this.task.agencyId = res.crowdTaskVO.agencyId
  566. this.task.status = res.crowdTaskVO.status
  567. this.task.statusVO = res.crowdTaskVO.statusVO
  568. this.task.endPoint = res.crowdTaskVO.endPointVO ? res.crowdTaskVO.endPointVO : {
  569. serverCode: '',
  570. }
  571. this.taskOperationControl = res.taskOperationControl;
  572. this.acceptedUserList = res.acceptedUserList;
  573. this.crowdReportUrl = res.crowdTaskVO.writeReportUrl;
  574. this.handleFormatReport(this.acceptedUserList);
  575. this.handleTestTypeChange(res.crowdTaskVO.serviceType);
  576. this.serviceName = this.getServiceByCode(res.crowdTaskVO.serviceType);
  577. if(res.crowdTaskVO.endPointVO){
  578. if(res.crowdTaskVO.endPointVO.token){
  579. this.shortLink = res.crowdTaskVO.endPointVO.token;
  580. this.editShortLink = false
  581. }else{
  582. this.editShortLink = true
  583. }
  584. }
  585. // console.log(res.crowdTaskVO.endPointVO.token)
  586. // console.log(this.editShortLink)
  587. // console.log(this.isModifyMode)
  588. },
  589. //获取任务详情失败时回调函数
  590. getTaskDetailFail(error) {
  591. this.hideLoading()
  592. // notify('error', '获取任务详情失败:' + error.data)
  593. },
  594. //处理显示报告
  595. handleFormatReport(acceptedUserList) {
  596. acceptedUserList.map((user) => {
  597. user.crowdReportVOS && user.crowdReportVOS.map((report) => {
  598. report.userName = user.userVO.userName;
  599. this.reportList.push(report);
  600. })
  601. })
  602. },
  603. dateFormat(date, format) {
  604. date = new Date(date)
  605. let o = {
  606. 'M+': date.getMonth() + 1, //month
  607. 'd+': date.getDate(), //day
  608. 'H+': date.getHours(), //hour+8小时
  609. 'm+': date.getMinutes(), //minute
  610. 's+': date.getSeconds(), //second
  611. 'q+': Math.floor((date.getMonth() + 3) / 3), //quarter
  612. 'S': date.getMilliseconds() //millisecond
  613. }
  614. if (/(y+)/.test(format)) {
  615. format = format.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length));
  616. }
  617. for (let k in o)
  618. if (new RegExp('(' + k + ')').test(format))
  619. format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ('00' + o[k]).substr(('' + o[k]).length));
  620. return format;
  621. },
  622. //更新任务信息
  623. updateTask() {
  624. this.$refs['task'].validate(valid => {
  625. if (valid) {
  626. this.showLoading()
  627. const newTask = {
  628. name: this.task.title,
  629. desc: this.task.description,
  630. type: this.task.serviceType,
  631. resource: this.task.resource,
  632. location: this.task.location == null ? {} : getProvinceNameByProvinceCode(this.task.location.provinceCode, this.task.location.cityCode),
  633. institution: this.task.institution ? this.task.institution.id : null,
  634. datetime: this.task.datetime,
  635. quotePrice: this.task.quotePrice,
  636. fixedPrice: this.task.fixedPrice,
  637. requirementFile: this.task.requireDocUrl,
  638. participantCount: this.task.participantCount,
  639. endPoint: this.task.endPoint
  640. }
  641. //console.log(newTask)
  642. updateTask(this.projectId, this.taskId, newTask, this.updateTaskSuccess, this.updateTaskFail)
  643. } else {
  644. notify('error', '表单填写有误!')
  645. return false
  646. }
  647. })
  648. },
  649. //更新任务信息成功时回调函数
  650. updateTaskSuccess(res) {
  651. this.cancelMode()
  652. this.taskId = res.crowdTaskVO.id
  653. this.projectId = res.crowdTaskVO.projectId
  654. this.task.title = res.crowdTaskVO.title
  655. this.task.description = res.crowdTaskVO.description
  656. this.task.serviceType = res.crowdTaskVO.serviceType
  657. this.task.resource = res.crowdTaskVO.resource.toString()
  658. this.task.location = res.crowdTaskVO.location == null ? {
  659. provinceCode: 3200,
  660. cityCode: 3201
  661. } : getProvinceCodeByProvinceName(res.crowdTaskVO.location.provinceCode, res.crowdTaskVO.location.cityCode)
  662. this.task.institution = res.crowdTaskVO.institution
  663. this.task.datetime = new Date(res.crowdTaskVO.datetime)
  664. this.task.quotePrice = res.crowdTaskVO.quotePrice
  665. this.task.fixedPrice = res.crowdTaskVO.fixedPrice
  666. // this.task.endPointVO = res.crowdTaskVO.endPointVO
  667. this.task.doc = []
  668. this.task.requireDocUrl = res.crowdTaskVO.requirementFile,
  669. this.task.participantCount = res.crowdTaskVO.participantCount
  670. this.task.endPoint = res.crowdTaskVO.endPointVO ? res.crowdTaskVO.endPointVO : {
  671. serverCode: '',
  672. }
  673. this.task.createTime = res.crowdTaskVO.createTime,
  674. this.reportList = res.crowdReportVOList
  675. this.crowdReportUrl = res.crowdTaskVO.writeReportUrl;
  676. this.acceptedUserList = res.acceptedUserList
  677. this.handleTestTypeChange(res.crowdTaskVO.serviceType);
  678. this.serviceName = this.getServiceByCode(res.crowdTaskVO.serviceType)
  679. this.getWordCloud()
  680. this.hideLoading()
  681. notify('success', '修改成功')
  682. },
  683. //更新任务信息失败时回调函数
  684. updateTaskFail(error) {
  685. notify('error', '修改失败:' + error.data)
  686. this.hideLoading()
  687. },
  688. //上传任务需求文档
  689. uploadRequireDoc(param) {
  690. const formData = new FormData()
  691. let config = {
  692. //添加请求头
  693. headers: {'Content-Type': 'multipart/form-data'},
  694. }
  695. formData.append('file', param.file)
  696. Http.upload(Apis.FILE.REQUIREMENT_FILE.replace('{userId}', this.user.userVO.id), formData, config).then((res) => {
  697. notify('success', '上传成功')
  698. this.uploadRequireDocSuccess(res)
  699. }).catch((error) => {
  700. notify('error', '上传失败:' + error.data)
  701. this.uploadRequireDocFail(error)
  702. })
  703. },
  704. //上传任务需求文档成功时回调函数
  705. uploadRequireDocSuccess(res) {
  706. this.hideLoading()
  707. console.log('上传成功')
  708. this.task.requireDocUrl = res.data
  709. console.log(res.data)
  710. },
  711. //上传任务需求文档失败时回调函数
  712. uploadRequireDocFail(error) {
  713. this.hideLoading()
  714. notify('error', '任务需求文档上传失败:' + error.data)
  715. },
  716. //文档上传前响应函数
  717. //移除文档前的响应函数
  718. beforeRemove(file, fileList) {
  719. //return this.$confirm(`确定移除 ${file.name}?`)
  720. },
  721. //移除文档时的响应函数
  722. handleRemove(file, fileList) {
  723. console.log(file, fileList)
  724. },
  725. //需求文档添加进来时的响应函数
  726. handleExceed(files, fileList) {
  727. this.$message.warning(
  728. `当前限制选择 1 个文件,本次选择了 ${
  729. files.length
  730. } 个文件,共选择了 ${files.length + fileList.length} 个文件`
  731. )
  732. },
  733. //接收任务
  734. receiveTask() {
  735. this.$confirm('确认接收任务?', '提示', {
  736. confirmButtonText: '确认接收',
  737. cancelButtonText: '取消',
  738. type: 'success'
  739. }).then(() => {
  740. this.showLoading()
  741. receiveTaskRequest(this.projectId, this.taskId, this.user.userVO.id, this.receiveTaskSuccess, this.receiveTaskFail)
  742. }).catch(() => {
  743. })
  744. },
  745. //接收任务成功时的回调函数
  746. receiveTaskSuccess(res) {
  747. this.hideLoading()
  748. this.getTaskDetail();
  749. notify('success', '接收任务成功')
  750. // console.log(res)
  751. this.taskOperationControl = res.taskOperationControl
  752. this.task.status = res.crowdTaskVO.status
  753. this.task.institution = res.crowdTaskVO.institution
  754. },
  755. //接收任务失败时的回调函数
  756. receiveTaskFail(error) {
  757. this.hideLoading()
  758. notify('error', '接收任务失败:' + error.data)
  759. },
  760. // 任务推荐
  761. recommendTask(){
  762. let task = {
  763. "title": this.task.title,
  764. "description": this.task.description,
  765. "participantCount": this.task.participantCount,
  766. "quotePrice": this.task.quotePrice,
  767. "requirementFile": this.task.requireDocUrl,
  768. "serviceType": this.task.serviceType,
  769. "createTime": this.task.createTime,
  770. "datetime": this.task.datetime
  771. };
  772. Http.post('/recommendationtest/querywithparam',task).then((res)=>{
  773. window.open('http://59.42.10.54:7477/userinformation.html');
  774. })
  775. },
  776. //拒绝任务
  777. rejectTask() {
  778. this.$confirm('确认拒绝任务?拒绝后将不能再接收该任务', '提示', {
  779. confirmButtonText: '确认拒绝',
  780. cancelButtonText: '取消',
  781. type: 'success'
  782. }).then(() => {
  783. this.showLoading()
  784. rejectTask(this.projectId, this.taskId, this.rejectTaskSuccess, this.rejectTaskFail)
  785. }).catch(() => {
  786. })
  787. },
  788. //拒绝任务成功时的回调函数
  789. rejectTaskSuccess(res) {
  790. this.hideLoading()
  791. this.$router.push({
  792. name: 'Mine'
  793. })
  794. notify('success', '拒绝任务成功,已为您自动跳转到个人中心')
  795. },
  796. //拒绝任务失败时的回调函数
  797. rejectTaskFail(error) {
  798. this.hideLoading()
  799. notify('error', '拒绝任务失败:' + error.data)
  800. },
  801. //提交结束任务申请
  802. submitTaskRequest() {
  803. this.$confirm('确认提交任务?提交后将不能再修改', '提示', {
  804. confirmButtonText: '确认提交',
  805. cancelButtonText: '取消',
  806. type: 'success'
  807. }).then(() => {
  808. this.showLoading()
  809. submitTaskRequest(this.projectId, this.taskId, this.submitTaskRequestSuccess, this.submitTaskRequestFail)
  810. }).catch(() => {
  811. })
  812. },
  813. //提交结束任务申请成功时的回调函数
  814. submitTaskRequestSuccess(res) {
  815. this.hideLoading()
  816. console.log(res)
  817. this.taskOperationControl = res.taskOperationControl
  818. this.task.status = res.crowdTaskVO.status
  819. this.task.institution = res.crowdTaskVO.institution
  820. notify('success', '提交任务成功,等待区域管理员审核')
  821. this.getTaskDetail();
  822. },
  823. //提交结束任务申请失败时的回调函数
  824. submitTaskRequestFail(error) {
  825. this.hideLoading()
  826. notify('error', '提交任务失败:' + error.data)
  827. },
  828. //结束任务
  829. endTask() {
  830. this.$confirm('确认结束任务?', '提示', {
  831. confirmButtonText: '确认结束',
  832. cancelButtonText: '取消',
  833. type: 'success'
  834. }).then(() => {
  835. this.getTaskDetail()
  836. this.showLoading()
  837. ensureEndTask(this.projectId, this.taskId, this.endTaskSuccess, this.endTaskFail)
  838. }).catch(() => {
  839. })
  840. },
  841. //结束任务成功时的回调函数
  842. endTaskSuccess(res) {
  843. this.hideLoading()
  844. this.taskOperationControl = res.taskOperationControl
  845. this.task.status = res.crowdTaskVO.status
  846. this.task.institution = res.crowdTaskVO.institution
  847. notify('success', '结束任务成功!')
  848. this.getTaskDetail();
  849. },
  850. //结束任务失败时的回调函数
  851. endTaskFail(error) {
  852. this.hideLoading()
  853. notify('error', '结束任务失败:' + error.data)
  854. },
  855. //跳转到创建项目报告页面
  856. toCreateReport() {
  857. this.$router.push({
  858. name: 'TaskReportCreate',
  859. params: {
  860. scope: 1,
  861. dependencyCode: this.taskId,
  862. projectId: this.projectId,
  863. taskId: this.taskId,
  864. }
  865. })
  866. },
  867. reformDate(date) {
  868. return getFormalTimeFromDate(date)
  869. }
  870. },
  871. }
  872. //回收站
  873. //
  874. // updateLocation (location) {
  875. // console.log(location)
  876. // const loactionName = getProvinceNameByProvinceCode(location.provinceCode, location.cityCode)
  877. // // var provinceName = ''
  878. // // var cityName = ''
  879. // // for (var item of provinceCityJSON.provinces) {
  880. // // if (item.code === location.provinceCode) {
  881. // // provinceName = item.name
  882. // // for (var city of item.cities) {
  883. // // if (city.code === location.cityCode) {
  884. // // cityName = city.name
  885. // // break
  886. // // }
  887. // // }
  888. // // }
  889. // // }
  890. // return loactionName.provinceCode + ' / ' + loactionName.cityCode
  891. // },
  892. //
  893. // locationChange (provinceId, cityId) {
  894. // if (provinceId || cityId) {
  895. // this.task.location = {provinceCode: provinceId, cityCode: cityId}
  896. // }
  897. // },
  898. // submitForm (formName) {
  899. // this.$refs[formName].validate(valid => {
  900. // if (valid) {
  901. // this.isModifyMode = false
  902. //
  903. // } else {
  904. // console.log('error submit!!')
  905. // return false
  906. // }
  907. // })
  908. // },
  909. </script>
  910. <style lang="less" scoped>
  911. .el-radio {
  912. margin: 10px 20px 10px 0;
  913. }
  914. .el-form-item /deep/ .el-tabs__content {
  915. /*max-height: 120px !important;*/
  916. overflow: auto;
  917. }
  918. .el-collapse-item__content {
  919. padding-bottom: 0 !important;
  920. }
  921. </style>