rehearsalTaskSign.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675
  1. <template>
  2. <div>
  3. <NavBar :go="{ type: 'push', path: goBack }" />
  4. <div class="bigbox">
  5. <div class="mainItem">
  6. <van-row>
  7. <van-col :span="8" class="label">
  8. <div>标题</div>
  9. </van-col>
  10. <van-col :span="16">
  11. <div>{{ trainingData.title }}</div>
  12. </van-col>
  13. </van-row>
  14. </div>
  15. <div class="mainItem">
  16. <van-row>
  17. <van-col :span="8" class="label">
  18. <div>单位名称</div>
  19. </van-col>
  20. <van-col :span="16">
  21. <div>{{ trainingData.orgName }}</div>
  22. </van-col>
  23. </van-row>
  24. </div>
  25. <div class="mainItem">
  26. <van-row>
  27. <van-col :span="8" class="label">
  28. <div>演练开始时间</div>
  29. </van-col>
  30. <van-col :span="16">
  31. <div>{{ trainingData.drillStartTime }}</div>
  32. </van-col>
  33. </van-row>
  34. </div>
  35. <div class="mainItem">
  36. <van-row>
  37. <van-col :span="8" class="label">
  38. <div>演练结束时间</div>
  39. </van-col>
  40. <van-col :span="16">
  41. <div>{{ trainingData.drillEndTime }}</div>
  42. </van-col>
  43. </van-row>
  44. </div>
  45. <div class="mainItem">
  46. <van-row>
  47. <van-col :span="8" class="label">
  48. <div>演练地点</div>
  49. </van-col>
  50. <van-col :span="16">
  51. <div>{{ trainingData.drillSite }}</div>
  52. </van-col>
  53. </van-row>
  54. </div>
  55. <!-- <div class="mainItem">
  56. <div class="label">演练类型</div>
  57. <div>{{ trainingData.categoryText }}</div>
  58. </div> -->
  59. <div class="mainItem">
  60. <van-row>
  61. <van-col :span="8" class="label">
  62. <div>演练计划资料</div>
  63. </van-col>
  64. <van-col :span="16" class="zl">
  65. <div v-for="item in studyList" :key="item.name">
  66. <van-tag type="primary" class="tagCls" plain @click="tagHandler(item)">{{ item.name }}</van-tag>
  67. </div>
  68. </van-col>
  69. </van-row>
  70. </div>
  71. <div class="mainItem">
  72. <van-row>
  73. <van-col :span="8" class="label">
  74. <div>指挥人</div>
  75. </van-col>
  76. <van-col :span="16">
  77. <div>{{ trainingData.hostName }}</div>
  78. </van-col>
  79. </van-row>
  80. </div>
  81. <div class="mainItem">
  82. <van-row>
  83. <van-col :span="8" class="label">
  84. <div>演练项目</div>
  85. </van-col>
  86. <van-col :span="16">
  87. <div>{{ trainingData.typeText }}</div>
  88. </van-col>
  89. </van-row>
  90. </div>
  91. <div class="mainItem">
  92. <van-row>
  93. <van-col :span="8" class="label">
  94. <div>预设案由</div>
  95. </van-col>
  96. <van-col :span="16">
  97. <div>{{ trainingData.presetCase }}</div>
  98. </van-col>
  99. </van-row>
  100. </div>
  101. <div class="mainItem">
  102. <van-row>
  103. <van-col :span="8" class="label">
  104. <div>演练情况</div>
  105. </van-col>
  106. <van-col :span="16">
  107. <div>{{ trainingData.drillSituation }}</div>
  108. </van-col>
  109. </van-row>
  110. </div>
  111. <div class="mainItem">
  112. <van-row>
  113. <van-col :span="8" class="label">
  114. <div>点评总结</div>
  115. </van-col>
  116. <van-col :span="16">
  117. <div>{{ trainingData.comment }}</div>
  118. </van-col>
  119. </van-row>
  120. </div>
  121. <div class="mainItem">
  122. <van-row>
  123. <van-col :span="8" class="label">
  124. <div>参与人员</div>
  125. </van-col>
  126. <van-col :span="16">
  127. <div>{{ taskUserList }}</div>
  128. </van-col>
  129. </van-row>
  130. </div>
  131. <div class="mainItem">
  132. <van-row>
  133. <van-col :span="8" class="label">
  134. <div>缺席人员</div>
  135. </van-col>
  136. <van-col :span="16">
  137. <div>{{ qsUserList }}</div>
  138. </van-col>
  139. </van-row>
  140. </div>
  141. <div class="mainItem">
  142. <van-row>
  143. <van-col :span="8" class="label">
  144. <div>上传图片</div>
  145. </van-col>
  146. <van-col :span="16">
  147. <imgCom
  148. :width="'100'"
  149. v-for="item in imgList"
  150. :list="imgList"
  151. :key="item"
  152. :height="'100'"
  153. :src="item"
  154. ></imgCom>
  155. </van-col>
  156. </van-row>
  157. </div>
  158. <div class="mainItem" v-if="peopleShow">
  159. <van-row>
  160. <van-col :span="8" class="label">
  161. <div>参与人员签名图片</div>
  162. </van-col>
  163. <van-col :span="16">
  164. <!-- signUserList -->
  165. <template v-for="item in signUserList">
  166. <imgCom
  167. :width="'100'"
  168. v-if="item.signImage"
  169. :list="signUserListMap"
  170. :key="item.userId"
  171. :height="'100'"
  172. :src="item.signImage"
  173. ></imgCom>
  174. </template>
  175. </van-col>
  176. </van-row>
  177. </div>
  178. <div class="mainItem" v-if="evaluate">
  179. <van-row>
  180. <van-col :span="8" class="label">
  181. <div>评分</div>
  182. </van-col>
  183. <van-col :span="16">
  184. <van-rate :disabled="disabledShow" v-model="value" :count="10" />
  185. </van-col>
  186. </van-row>
  187. </div>
  188. <div class="mainItem" v-if="disabledShow">
  189. <van-row>
  190. <van-col :span="8" class="label">
  191. <div>评分</div>
  192. </van-col>
  193. <van-col :span="16">
  194. {{ value }}分
  195. </van-col>
  196. </van-row>
  197. </div>
  198. <div class="mainItem" v-if="islearning">
  199. <van-row>
  200. <van-col :span="8" class="label">
  201. <div>评优状态</div>
  202. </van-col>
  203. <van-col :span="16">
  204. {{ trainingData.recStatusText }}分
  205. </van-col>
  206. </van-row>
  207. </div>
  208. <div class="mainItem" v-if="$route.params.id.split('_')[1] === 'comment'">
  209. <van-row >
  210. <van-col :span="24" class="label bgc" >
  211. <van-checkbox-group v-model="result" direction="horizontal" @change="clickChekcBox($event)">
  212. <van-checkbox
  213. v-for="item in resultList"
  214. :key="item.value"
  215. :disabled="item.disabled"
  216. shape="square"
  217. :checked="item.checked"
  218. :name="item.value"
  219. >{{ item.name }}</van-checkbox
  220. >
  221. </van-checkbox-group>
  222. </van-col>
  223. </van-row>
  224. </div>
  225. </div>
  226. <van-row>
  227. <van-col span="24" class="btns">
  228. <!-- 签名 -->
  229. <van-button
  230. type="info"
  231. class="btn"
  232. v-if="this.$route.params.id.split('_')[1] === 'edit'"
  233. @click="signatureHandler"
  234. >签名</van-button
  235. >
  236. <!-- 评价 || 评优推优选 -->
  237. <van-button
  238. type="info"
  239. class="btn"
  240. v-if="this.$route.params.id.split('_')[1] === 'evaluate' || this.$route.params.id.split('_')[1] === 'comment'"
  241. @click="submitHandler"
  242. >提交</van-button
  243. >
  244. </van-col>
  245. </van-row>
  246. <van-action-sheet v-model="show" title="签署名字" class="sheet">
  247. <writingPad ref="esign" @resultImg="resultImg"></writingPad>
  248. </van-action-sheet>
  249. </div>
  250. </template>
  251. <script>
  252. import NavBar from '@/components/NavBar'
  253. import writingPad from '@/components/writingPad/index.vue'
  254. import { getrehearsalInfo, singrehearsalTask, drillSignInfo } from '@/api/drillTask.js'
  255. import { submitRecTask } from '@/api/optimalLearning.js'
  256. import { upload } from '@/api/public'
  257. import imgCom from '@/components/imgCom/index.vue'
  258. import { base64ToBlob } from '@/utils/base64TurnImg.js'
  259. import config from '@/config/index'
  260. import { Toast, Dialog } from 'vant'
  261. import VuePdf from '@/components/pdfCom/index.vue'
  262. export default {
  263. name: 'SocAppAddTraining',
  264. components: {
  265. NavBar,
  266. Dialog,
  267. Toast,
  268. VuePdf,
  269. imgCom,
  270. writingPad
  271. },
  272. data() {
  273. return {
  274. result: [],
  275. orgType: '', //机构类型
  276. content: '', //评语
  277. value: 0, //评分
  278. this_window: window,
  279. show: false,
  280. resultList: [],
  281. taskUserList: [], //参与人员
  282. qsUserList: [], //缺席人员
  283. imgList: [], //图片数组
  284. signUserList: [], //参与人员签名数组
  285. signUserListMap: [], //参与人员签名数组Map
  286. studyList: [], //学习资料数组
  287. trainingData: {} //详情数据
  288. }
  289. },
  290. computed: {
  291. goBack() {
  292. if (
  293. this.$route.params.id.split('_')[1] === 'evaluate' ||
  294. this.$route.params.id.split('_')[1] === 'edit' ||
  295. this.$route.params.id.split('_')[1] === 'info'
  296. ) {
  297. return '/rehearsalTask'
  298. } else if (this.$route.params.id.split('_')[1] === 'comment') {
  299. return '/rehearsaloptimal'
  300. } else if (this.$route.params.id.split('_')[1] === 'learning') {
  301. return '/rehearsallearning'
  302. } else if (this.$route.params.id.split('_')[1] === 'info1') {
  303. return '/rehearsaloptimal'
  304. }
  305. },
  306. evaluate() {
  307. if (this.$route.params.id.split('_')[1] === 'evaluate') {
  308. return true
  309. } else {
  310. return false
  311. }
  312. },
  313. disabledShow() {
  314. if (
  315. this.$route.params.id.split('_')[1] === 'info' ||
  316. this.$route.params.id.split('_')[1] === 'info1' ||
  317. this.$route.params.id.split('_')[1] === 'comment' ||
  318. this.$route.params.id.split('_')[1] === 'learning'
  319. ) {
  320. return true
  321. } else {
  322. return false
  323. }
  324. },
  325. islearning() {
  326. if (this.$route.params.id.split('_')[1] === 'learning') {
  327. return true
  328. } else {
  329. return false
  330. }
  331. },
  332. peopleShow() {
  333. if (
  334. this.$route.params.id.split('_')[1] === 'info' ||
  335. this.$route.params.id.split('_')[1] === 'info1' ||
  336. this.$route.params.id.split('_')[1] === 'comment' ||
  337. this.$route.params.id.split('_')[1] === 'learning'
  338. ) {
  339. return true
  340. } else {
  341. return false
  342. }
  343. }
  344. },
  345. created() {
  346. //获取详情信息
  347. getrehearsalInfo(this.$route.params.id.split('_')[0]).then(res => {
  348. let { code, data, msg } = res
  349. if (code == 200) {
  350. this.content = data.comment
  351. this.value = +data.commentScore
  352. this.trainingData = data
  353. if (this.trainingData.taskUserList && this.trainingData.taskUserList.length > 0) {
  354. this.trainingData.taskUserList.forEach(item => {
  355. if (item.type == 1) {
  356. this.taskUserList.push(item.userName)
  357. } else {
  358. this.qsUserList.push(item.userName)
  359. }
  360. })
  361. }
  362. this.taskUserList = this.taskUserList.join(',')
  363. this.qsUserList = this.qsUserList.join(',')
  364. this.signUserList = data.taskUserList || []
  365. if (data.taskUserList) {
  366. this.signUserListMap = data.taskUserList.map(item => item.signImage) || []
  367. }
  368. let list = data.fileList || []
  369. if (list.length > 0) {
  370. list.forEach(item => {
  371. let i = JSON.parse(item)
  372. if (i.url.split('.')[1] == 'pdf') {
  373. i.type = 1
  374. } else {
  375. i.type = 0
  376. }
  377. this.studyList.push(i)
  378. })
  379. }
  380. if (this.trainingData.imageList) {
  381. this.imgList = this.trainingData.imageList.split(',') || []
  382. }
  383. //获取当前登录人机构类型
  384. this.orgType = window.sessionStorage.getItem('SET_USER_ORGTYPE')
  385. console.log(this.orgType, 'this.orgType')
  386. if (this.orgType == 1) {
  387. //省联社
  388. this.resultList = [
  389. {
  390. name: '设置为省级优秀案例',
  391. value: 5,
  392. disabled: false
  393. }
  394. ]
  395. if (data.recStatus == 5) {
  396. this.result = [5]
  397. }
  398. } else if (this.orgType == 2) {
  399. //办事处
  400. this.resultList = [
  401. {
  402. name: '设置为地区优秀案例',
  403. value: 3,
  404. disabled: false
  405. },
  406. {
  407. name: '推荐为省级优秀案例',
  408. value: 4,
  409. disabled: true
  410. }
  411. ]
  412. if (data.recStatus == 4) {
  413. this.result = [3, 4]
  414. } else if (data.recStatus == 3) {
  415. this.result = [3]
  416. }
  417. } else if (this.orgType == 3) {
  418. //行社
  419. this.resultList = [
  420. {
  421. name: '设置为行社优秀案例',
  422. value: 1,
  423. disabled: false
  424. },
  425. {
  426. name: '推荐为地区优秀案例',
  427. value: 2,
  428. disabled: true
  429. }
  430. ]
  431. if (data.recStatus == 2) {
  432. this.result = [1, 2]
  433. } else if (data.recStatus == 1) {
  434. this.result = [1]
  435. }
  436. }
  437. }
  438. })
  439. },
  440. mounted() {},
  441. methods: {
  442. disabledCheck(item) {
  443. if (item == 'false') return false
  444. if (item == 'true') return true
  445. //当前是最后一个复选框禁用
  446. if (this.resultList.length > 1 && item.value == this.resultList[this.resultList.length - 1].value) {
  447. return true
  448. } else {
  449. return false
  450. }
  451. },
  452. clickChekcBox(v) {
  453. console.log(v)
  454. console.log(this.resultList[0])
  455. if (v[0] == this.resultList[0].value) {
  456. if (this.resultList[1]) {
  457. this.resultList[1].disabled = this.disabledCheck('false')
  458. }
  459. // if(v.length>1){
  460. // this.result=[]
  461. // }
  462. // this.resultList[1].checked = this.disabledCheck('false')
  463. } else if (v[0] > this.resultList[0].value) {
  464. this.result = []
  465. } else {
  466. this.resultList[1].disabled = this.disabledCheck('true')
  467. // this.result=[]
  468. }
  469. },
  470. signatureHandler() {
  471. this.show = true
  472. },
  473. //评价提交
  474. submitHandler() {
  475. //判断当前是评价 还是评价推优
  476. if (this.$route.params.id.split('_')[1] === 'evaluate') {
  477. //评价
  478. if (this.value == 0) {
  479. //评分不能为0分
  480. Toast('评分不能为0分')
  481. return
  482. }
  483. Dialog.confirm({
  484. title: '',
  485. message: `是否提交评价?`
  486. })
  487. .then(() => {
  488. drillSignInfo({
  489. taskId: this.trainingData.id,
  490. // type: this.trainingData.type,
  491. score: this.value,
  492. comment: this.content
  493. }).then(res => {
  494. let { code, msg } = res
  495. if (code == 200) {
  496. Toast('评价成功')
  497. setTimeout(() => {
  498. this.$router.push('/rehearsalTask')
  499. }, 1000)
  500. } else {
  501. Toast(msg)
  502. }
  503. })
  504. })
  505. .catch(() => {
  506. // on cancel
  507. })
  508. } else {
  509. //评价推优
  510. submitRecTask({
  511. drillTaskId: this.trainingData.id,
  512. recStatus: Math.max(...this.result)
  513. }).then(res => {
  514. if (this.result && this.result.length > 0) {
  515. Toast('评优成功')
  516. } else {
  517. Toast('取消成功')
  518. }
  519. setTimeout(() => {
  520. this.$router.push('/rehearsaloptimal')
  521. }, 1000)
  522. })
  523. }
  524. },
  525. clearHandler() {
  526. this.$refs.esign.handleReset()
  527. },
  528. //上传签名图到服务器
  529. resultImg(img) {
  530. let obj = base64ToBlob(img)
  531. let formData = new FormData()
  532. obj.name = '签名.jpg'
  533. formData.append('file', base64ToBlob(img))
  534. upload(formData, 'image')
  535. .then(res => {
  536. console.log(process.env.NODE_ENV)
  537. /*上传成功*/
  538. let imgUrl = process.env.NODE_ENV === 'development' ? res.data.url : res.data.url
  539. this.submitSign(imgUrl)
  540. // this.$emit("imgUrl", res.data.url);
  541. })
  542. .catch(err => {
  543. /*上传失败*/
  544. })
  545. },
  546. tagHandler(i) {
  547. let str = i.name.split('.')[1]
  548. if (str == 'png' || str == 'jpg' || str == 'jpeg' || str == 'pdf') {
  549. //当前是图片||PDF
  550. this.openFilePreview(i)
  551. } else {
  552. const filePath = `${process.env.NODE_ENV === 'development' ? '/dev' : window.origin}${i.url}`
  553. const tempLink = document.createElement('a')
  554. tempLink.style.display = 'none'
  555. tempLink.href = filePath
  556. tempLink.setAttribute('download', i.name)
  557. tempLink.setAttribute('target', '_blank')
  558. document.body.appendChild(tempLink)
  559. tempLink.click()
  560. document.body.removeChild(tempLink)
  561. }
  562. },
  563. //提交到后端数据
  564. submitSign(url) {
  565. singrehearsalTask({
  566. id: this.trainingData.id,
  567. signImage: url
  568. }).then(res => {
  569. this.$router.push('/rehearsalTask')
  570. })
  571. }
  572. }
  573. }
  574. </script>
  575. <style lang="scss" scoped>
  576. .mainItem {
  577. font-size: 28px;
  578. width: 100%;
  579. }
  580. .mainItemData {
  581. justify-content: end;
  582. }
  583. .bigbox {
  584. margin: 20px;
  585. box-shadow: 0 8px 12px #ebedf0;
  586. }
  587. .tagCls {
  588. margin-bottom: 20px;
  589. margin-left: 10px;
  590. }
  591. .btns {
  592. background-color: #fff;
  593. width: 100%;
  594. }
  595. .btn {
  596. width: 100%;
  597. }
  598. .sheet {
  599. height: 45%;
  600. }
  601. .van-row {
  602. background-color: #d7d7d7;
  603. display: flex;
  604. align-items: center;
  605. margin-top: -1px;
  606. border: 1px solid #ccc;
  607. .van-col--8 {
  608. min-height: 100px;
  609. display: flex;
  610. justify-content: center;
  611. align-items: center;
  612. padding: 10px;
  613. }
  614. .van-col{
  615. text-align: justify;
  616. white-space: pre-wrap;
  617. }
  618. .zl {
  619. display: block !important;
  620. flex: none !important;
  621. padding-left: 10px;
  622. }
  623. .van-col--16 {
  624. min-height: 100px;
  625. display: flex;
  626. align-items: center;
  627. padding-left: 10px;
  628. background-color: #fff;
  629. padding: 10px;
  630. }
  631. .tagCls {
  632. margin-top: 10px;
  633. }
  634. .bgc{
  635. background-color: #fff;
  636. padding: 10px;
  637. }
  638. }
  639. </style>