TraceName.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443
  1. <template>
  2. <div>
  3. <Navbar :title="'任务详细信息' + (trace == null ? '' : '-' + trace.projectName)" :is-go-back="true" />
  4. <div v-if="isflag">
  5. <a-row justify="center" style="margin-bottom: 16px">
  6. <a-col :span="24" style="text-align: center">
  7. <div v-if="finished" class="checked" @click="getTimeLineNumber()" />
  8. <div v-else class="clickFinished" @click="getTimeLineNumber()">
  9. <div class="clickFinishedText">
  10. <span>点击完成任务</span>
  11. </div>
  12. </div>
  13. </a-col>
  14. </a-row>
  15. <a-space direction="vertical" style="width: 100%">
  16. <a-row align="middle">
  17. <a-col :flex="1">
  18. <a-typography-title :level="3" style="margin-bottom: 0;margin-top: 0px">
  19. <span>{{ trace.summary }}</span>
  20. <a-tag class="label" :color="trace.overdue ? '#d9534f' : '#337ab7'">
  21. 责任人:{{ trace.receiveUserName }}, 时间节点:{{
  22. formatDate(trace.planFinishedDate)
  23. }}
  24. </a-tag>
  25. </a-typography-title>
  26. </a-col>
  27. <a-col>
  28. <a-space>
  29. <a-button style="padding: 4px" type="link" @click="edit">编辑</a-button>
  30. <a-button style="padding: 4px" type="link" @click="deleteTrace">删除</a-button>
  31. <a-button style="padding: 4px" type="link" @click="copyShaneUrl">复制链接</a-button>
  32. </a-space>
  33. </a-col>
  34. </a-row>
  35. <a-divider />
  36. <!-- eslint-disable-next-line -->
  37. <div id="content-editor-view" v-html="trace.detail" />
  38. <AudioField :class-name="className" :src-array="srcArray" :is-readonly="'true'" @delete-audio-src="undefined" />
  39. </a-space>
  40. <TraceTimeLine ref="traceTimeLine" :trace-id="traceId" :trace="trace" @refresh-trace-log="refreshTraceLog" />
  41. <div style="margin-top: 20px">
  42. <span>附件</span>
  43. <a-divider />
  44. </div>
  45. <TraceAttachment :trace-id="traceId" :class-name="attachmentClassName" />
  46. <div style="margin-top: 20px">
  47. <span>评论信息</span>
  48. <a-divider />
  49. </div>
  50. <TraceComment :trace-id="traceId" />
  51. <a-button block style="margin-top: 16px;background: #efefef" @click="openTraceComment">
  52. <template #icon><edit-outlined /></template>
  53. 评论
  54. </a-button>
  55. <div style="margin-top: 20px">
  56. <TraceLog ref="traceLog" :trace-id="traceId" :trace="trace" :class-name="className" />
  57. </div>
  58. </div>
  59. <Loading v-if="loading" />
  60. </div>
  61. </template>
  62. <script>
  63. import Common from '../common/Common.js';
  64. import UpladFile from '../widget/UpladFile.js';
  65. import TraceCommon from './TraceCommon.js';
  66. import TraceResource from './TraceResource.js';
  67. import TraceLog from './TraceLog.vue';
  68. import TraceComment from './TraceComment.vue';
  69. import TraceTimeLine from './TraceTimeLine.vue';
  70. import TraceAttachment from './TraceAttachment.vue';
  71. import AudioField from '../widget/AudioField.vue';
  72. import { Notify } from 'pc-component-v3';
  73. import { EditOutlined } from '@ant-design/icons-vue';
  74. export default {
  75. components: {
  76. TraceLog,
  77. TraceComment,
  78. TraceTimeLine,
  79. TraceAttachment,
  80. UpladFile,
  81. AudioField,
  82. EditOutlined,
  83. },
  84. data: function () {
  85. this.formatDate = TraceCommon.formatDate;
  86. return {
  87. traceId: undefined,
  88. trace: {},
  89. finished: undefined,
  90. count: 0,
  91. attachmentList: [],
  92. className: 'com.leanwo.prodog.Trace',
  93. attachmentClassName: 'com.leanwo.prodog.model.trace.TraceAttachment',
  94. srcArray: [],
  95. isflag: true,
  96. loading: false,
  97. };
  98. },
  99. computed: {
  100. finishedImageName: function () {
  101. if (this.finished != true) {
  102. return '../../static/image/finished.png';
  103. } else {
  104. return '../../static/image/finished2.png';
  105. }
  106. },
  107. },
  108. mounted: function () {
  109. this.traceId = this.$route.params.traceId;
  110. this.judgePermission();
  111. },
  112. methods: {
  113. /**
  114. * 复制链接
  115. * @author GuoZhiBo 20191024
  116. */
  117. copyShaneUrl: function () {
  118. var input = document.createElement('input'); // 直接构建input
  119. var url = window.location.href;
  120. input.value = url; // 设置内容
  121. document.body.appendChild(input); // 添加临时实例
  122. input.select(); // 选择实例内容
  123. document.execCommand('Copy'); // 执行复制
  124. document.body.removeChild(input); // 删除临时实例
  125. Notify.success('提示', '复制链接成功');
  126. },
  127. back: function () {
  128. history.back();
  129. },
  130. getCount: function () {
  131. return this.$refs.traceTimeLine.count;
  132. },
  133. /**
  134. * 初始化数据
  135. * @author GuoZhiBo 20171201
  136. */
  137. initData: function () {
  138. this.loadTraceById();
  139. },
  140. /**
  141. * 根据追踪单Id查询追踪单的数据
  142. */
  143. loadTraceById: function () {
  144. var _self = this;
  145. $.ajax({
  146. url: Common.getApiURL('TraceResource/uniqueByTraceId'),
  147. type: 'get',
  148. dataType: 'json',
  149. data: {
  150. traceId: _self.traceId,
  151. },
  152. beforeSend: function (request) {
  153. Common.addTokenToRequest(request);
  154. },
  155. success: function (data) {
  156. if (data != null) {
  157. _self.traceId = data.id;
  158. _self.finished = data.finished;
  159. _self.trace = data;
  160. if (data.audioSrcs != null) {
  161. _self.srcArray = JSON.parse(data.audioSrcs);
  162. }
  163. _self.$nextTick(() => {
  164. Common.downloadByA('#content-editor-view');
  165. });
  166. }
  167. },
  168. error: function (XMLHttpRequest, textStatus, errorThrown) {
  169. Common.processException(XMLHttpRequest, textStatus, errorThrown);
  170. },
  171. });
  172. },
  173. getUrl: function (item) {
  174. var _self = this;
  175. var url =
  176. Common.getApiURL('file/fileDownload') +
  177. '?className=' +
  178. _self.className +
  179. '&fileName=' +
  180. item;
  181. return url;
  182. },
  183. /**
  184. * 修改追踪单的状态
  185. * @author GuoZhiBo 20171201
  186. */
  187. updateTracefinished: function () {
  188. var _self = this;
  189. if (_self.count == 0) {
  190. _self.loading = true;
  191. TraceResource.updateTraceFinished(_self.trace.id).then(
  192. successData => {
  193. _self.loadTraceById();
  194. _self.loading = false;
  195. _self.$refs.traceLog.getTraceLog();
  196. },
  197. errorData => {
  198. _self.loading = false;
  199. Common.processException(errorData);
  200. },
  201. );
  202. } else {
  203. Notify.error('提示', '还有时间节点没有完成!');
  204. }
  205. },
  206. getTimeLineNumber: function () {
  207. var _self = this;
  208. $.ajax({
  209. url: Common.getApiURL(
  210. 'TraceTimeLineResource/queryTraceTimeLineNumberFalse',
  211. ),
  212. type: 'get',
  213. dataType: 'json',
  214. async: false,
  215. data: {
  216. traceId: _self.trace.id,
  217. },
  218. beforeSend: function (request) {
  219. Common.addTokenToRequest(request);
  220. },
  221. success: function (data) {
  222. _self.count = data;
  223. _self.updateTracefinished();
  224. },
  225. error: function (XMLHttpRequest, textStatus, errorThrown) {
  226. Common.processException(XMLHttpRequest, textStatus, errorThrown);
  227. },
  228. });
  229. },
  230. /**
  231. * 打开评论界面进行评论
  232. * @author GuoZhiBo 20171201
  233. */
  234. openTraceComment: function () {
  235. var _self = this;
  236. this.$router.push('/trace/traceCommentCreate/' + _self.trace.id);
  237. },
  238. /**
  239. * 获取图片地址
  240. * @param {String} item 图片名称
  241. * @return {String} 图片URL地址
  242. */
  243. getImageSrc: function (item) {
  244. var _self = this;
  245. if (item != undefined && item != null) {
  246. return Common.getResourceUrl(
  247. 'image',
  248. 'com.leanwo.prodog.trace.model.TraceComment',
  249. item,
  250. );
  251. } else {
  252. return '';
  253. }
  254. },
  255. /**
  256. * 编辑
  257. */
  258. edit: function () {
  259. var _self = this;
  260. _self.$router.push('/trace/traceUpdate/' + _self.traceId);
  261. },
  262. /**
  263. * 删除
  264. */
  265. deleteTrace: function () {
  266. var _self = this;
  267. Notify.show({
  268. title: '删除确认',
  269. message:
  270. '您确定要删除任务' +
  271. _self.trace.summary +
  272. '吗?如果"是"的话,请点击"确定"按钮,否则点击"取消"按钮',
  273. buttons: [
  274. {
  275. label: '确定',
  276. cssClass: 'btn-primary',
  277. action: function (dialogItself) {
  278. dialogItself.close();
  279. $.ajax({
  280. url: Common.getApiURL('TraceResource/deleteTraceById'),
  281. type: 'get',
  282. dataType: 'json',
  283. data: {
  284. traceId: _self.traceId,
  285. },
  286. beforeSend: function (request) {
  287. Common.addTokenToRequest(request);
  288. },
  289. success: function (data) {
  290. Notify.success('提示', '删除成功!');
  291. _self.back();
  292. },
  293. error: function (XMLHttpRequest, textStatus, errorThrown) {
  294. Common.processException(
  295. XMLHttpRequest,
  296. textStatus,
  297. errorThrown,
  298. );
  299. Notify.error('提示', '删除失败!');
  300. },
  301. });
  302. },
  303. },
  304. {
  305. label: '取消',
  306. action: function (dialogItself) {
  307. dialogItself.close();
  308. },
  309. },
  310. ],
  311. });
  312. },
  313. refreshTraceLog: function () {
  314. this.$refs.traceLog.getTraceLog();
  315. },
  316. /**
  317. * 根据追踪单Id查询追踪单的数据
  318. */
  319. judgePermission: function () {
  320. var _self = this;
  321. $.ajax({
  322. url: Common.getApiURL('TraceResource/judgePermission'),
  323. type: 'get',
  324. dataType: 'json',
  325. data: {
  326. traceId: _self.traceId,
  327. },
  328. beforeSend: function (request) {
  329. Common.addTokenToRequest(request);
  330. },
  331. success: function (data) {
  332. _self.isflag = data;
  333. if (_self.isflag) {
  334. _self.initData();
  335. } else {
  336. Notify.error('提示', '你没有访问权限!');
  337. }
  338. },
  339. error: function (XMLHttpRequest, textStatus, errorThrown) {
  340. Common.processException(XMLHttpRequest, textStatus, errorThrown);
  341. },
  342. });
  343. },
  344. },
  345. };
  346. </script>
  347. <style scoped>
  348. .label {
  349. display: inline;
  350. padding: 0.2em 0.6em 0.3em;
  351. font-size: 64%;
  352. font-weight: 700;
  353. line-height: 1;
  354. color: #fff;
  355. text-align: center;
  356. white-space: nowrap;
  357. vertical-align: baseline;
  358. border-radius: 0.25em;
  359. margin-left: 10px;
  360. }
  361. .checked {
  362. background: #69ba52;
  363. width: 80px;
  364. height: 80px;
  365. border-radius: 16px;
  366. position: relative;
  367. cursor: pointer;
  368. margin: 0 auto;
  369. }
  370. .checked::after {
  371. content: "";
  372. background-color: white;
  373. width: 26px;
  374. height: 8px;
  375. position: absolute;
  376. top: 44px;
  377. left: 14px;
  378. border-radius: 8px;
  379. transform: rotate(34deg);
  380. }
  381. .checked::before {
  382. content: "";
  383. background-color: white;
  384. width: 43px;
  385. height: 8px;
  386. position: absolute;
  387. top: 37px;
  388. left: 26px;
  389. transform: rotate(-50deg);
  390. border-radius: 8px;
  391. }
  392. .clickFinished {
  393. border: 2px solid #9b9b9b;
  394. width: 80px;
  395. height: 80px;
  396. border-radius: 16px;
  397. position: relative;
  398. cursor: pointer;
  399. user-select: none;
  400. margin: 0 auto;
  401. }
  402. .clickFinishedText {
  403. width: 50px;
  404. height: 50px;
  405. color: #9b9b9b;
  406. margin-top: 16px;
  407. margin-left: 15px;
  408. }
  409. :deep(.ant-divider-horizontal) {
  410. margin: 10px 0 !important;
  411. }
  412. </style>