Task.vue 33 KB

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