project.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  1. <template>
  2. <div class="project">
  3. <div class="project_head">
  4. <div class="back" @click="$router.go(-1)">
  5. <i class="el-icon-arrow-left"></i> 返回项目列表
  6. </div>
  7. <div class="title">{{info.title}}</div>
  8. <div class="share" @click="share">
  9. <i class="el-icon-share"></i>
  10. </div>
  11. </div>
  12. <div class="project_main" v-loading="loading">
  13. <!-- <div class="imgs" v-if="imgs[currentImg].url">
  14. <p @click="imgClick(index)" v-for="(item, index) in imgs" :key="item.id" :class="index == currentImg ? 'current' : ''">{{item.title}}</p>
  15. </div>
  16. <div class="imgs nodata" v-if="!imgs[currentImg].url">
  17. <span>暂无图片</span>
  18. </div> -->
  19. <div class="canvas" v-if="imgs[currentImg].url">
  20. <myCanvas v-if="showImg" :url="imgs[currentImg].url" :imgId="imgs[currentImg].id" :datas="marks" @add="addMarks"></myCanvas>
  21. </div>
  22. <div class="canvas nodata" v-if="!imgs[currentImg].url">
  23. <div>
  24. <el-button type="primary" size="small" :icon="uploading ? 'el-icon-loading' : 'el-icon-upload'" plain>上传文件</el-button>
  25. <input @change="upload" type="file">
  26. </div>
  27. </div>
  28. <div class="marks" v-if="marks.length > 0">
  29. <div class="mark_item" v-for="item in marks" :key="item.id">
  30. <div class="mark_item_num">
  31. <span>{{item.mark_num}}</span>
  32. </div>
  33. <div class="mark_item_main">
  34. <p class="mark_item_title">{{item.mark_title}}</p>
  35. <p class="mark_item_text">{{item.mark_text}}</p>
  36. <p class="mark_item_time">
  37. <span>{{item.mark_time}}</span>
  38. <span>{{item.status}}</span>
  39. </p>
  40. </div>
  41. </div>
  42. </div>
  43. <div class="marks nodata" v-if="marks.length == 0">
  44. 暂无标注
  45. </div>
  46. </div>
  47. </div>
  48. </template>
  49. <script>
  50. import timer from '../tools/timer';
  51. import myCanvas from '../components/myCanvas.vue';
  52. export default {
  53. name: 'project',
  54. data (){
  55. return {
  56. loading: true,
  57. info: {},
  58. imgs: [
  59. { url: '' }
  60. ],
  61. marks: [],
  62. marksData: [],
  63. currentImg: 0,
  64. showImg: true,
  65. uploading: false
  66. }
  67. },
  68. components: {
  69. myCanvas
  70. },
  71. beforeMount (){
  72. this.$ajax.get(`/project/get/?id=${this.$route.query.id}`).then(r => {
  73. this.info = r.info;
  74. // 无数据
  75. if(r.imgs.length == 0){
  76. this.loading = false;
  77. return;
  78. }
  79. this.imgs = r.imgs.map(item => {
  80. item.url = `http://designer.xuxiangbo.com/${item.url}`;
  81. return item;
  82. })
  83. let status = {
  84. '0': '已标记',
  85. '1': '修改中',
  86. '2': '已修改',
  87. '3': '已结束'
  88. }
  89. this.marksData = r.marks.map(item => {
  90. item.mark_time = timer.time('y-m-d h:i:s', item.mark_time * 1000);
  91. item.status = status[item.status];
  92. return item;
  93. });
  94. this.getMarks();
  95. this.loading = false;
  96. })
  97. },
  98. methods: {
  99. // 根据当前图片的索引,生成标记列表
  100. getMarks (){
  101. let result = [];
  102. this.marksData.map(item => {
  103. if(item.img_id == this.imgs[this.currentImg].id){
  104. result.push(item);
  105. }
  106. })
  107. this.marks = result;
  108. },
  109. // 分享
  110. share (){
  111. this.$copy(this.info.id, this.info.title);
  112. },
  113. // 添加标记点监听
  114. addMarks (r){
  115. let data = this.marksData.map(item => item);
  116. data.push(r);
  117. this.marksData = data;
  118. },
  119. // 点击切换图片
  120. imgClick (index){
  121. this.currentImg = index;
  122. this.getMarks();
  123. },
  124. // 上传文件
  125. upload (){
  126. this.$nextTick(() => {
  127. let input = document.querySelector('input');
  128. let data = {
  129. file: input.files[0],
  130. project: this.$route.query.id,
  131. }
  132. this.$ajax.post('/project/upload/', data).then(result => {
  133. this.$router.go(0);
  134. })
  135. })
  136. }
  137. }
  138. }
  139. </script>
  140. <style lang="less" scoped>
  141. .project{
  142. width: 100%;
  143. height: 100%;
  144. overflow: hidden;
  145. position: relative;
  146. .project_head{
  147. width: calc(100% - 40px);
  148. height: 50px;
  149. background: #3B3755;
  150. position: absolute;
  151. top: 0;
  152. left: 0;
  153. display: flex;
  154. justify-content: space-between;
  155. align-items: center;
  156. color: #ffffff;
  157. padding: 0 20px;
  158. .back{
  159. cursor: pointer;
  160. }
  161. .share{
  162. i{
  163. font-size: 16px;
  164. cursor: pointer;
  165. }
  166. }
  167. }
  168. .project_main{
  169. width: 100%;
  170. height: calc(100% - 50px);
  171. position: absolute;
  172. top: 50px;
  173. left: 0;
  174. .imgs{
  175. width: 220px;
  176. height: 100%;
  177. overflow: hidden;
  178. overflow-y: auto;
  179. background: #ffffff;
  180. position: absolute;
  181. top: 0;
  182. left: 0;
  183. p{
  184. width: 100%;
  185. text-indent: 30px;
  186. padding: 10px 0;
  187. cursor: pointer;
  188. overflow: hidden;
  189. text-overflow: ellipsis;
  190. white-space: nowrap;
  191. }
  192. p.current{
  193. background: #EBEDEE;
  194. }
  195. }
  196. .imgs::-webkit-scrollbar{
  197. display: none;
  198. }
  199. .canvas{
  200. width: calc(100% - 260px);
  201. height: 100%;
  202. overflow: hidden;
  203. position: absolute;
  204. top: 0;
  205. left: 260px;
  206. }
  207. .marks{
  208. width: 260px;
  209. height: 100%;
  210. overflow: hidden;
  211. overflow-y: auto;
  212. background: #ffffff;
  213. position: absolute;
  214. top: 0;
  215. left: 0;
  216. .mark_item{
  217. display: flex;
  218. justify-content: flex-start;
  219. align-items: flex-start;
  220. padding: 15px 0;
  221. border-bottom: 1px solid rgb(238, 238, 238);
  222. .mark_item_num{
  223. width: 40px;
  224. text-align: center;
  225. span{
  226. display: inline-block;
  227. width: 22px;
  228. height: 22px;
  229. border-radius: 50%;
  230. background: #FD4F4F;
  231. color: #ffffff;
  232. line-height: 22px;
  233. font-size: 12px;
  234. position: relative;
  235. top: -2px;
  236. }
  237. }
  238. .mark_item_main{
  239. width: 200px;
  240. .mark_item_title{
  241. color: #555555;
  242. }
  243. .mark_item_text{
  244. font-size: 12px;
  245. margin-top: 5px;
  246. line-height: 24px;
  247. color: #999999;
  248. }
  249. .mark_item_time{
  250. font-size: 12px;
  251. color: #999999;
  252. margin-top: 10px;
  253. display: flex;
  254. justify-content: space-between;
  255. align-items: center;
  256. }
  257. }
  258. }
  259. }
  260. .marks::-webkit-scrollbar {
  261. width : 6px;
  262. height: 1px;
  263. }
  264. .marks::-webkit-scrollbar-thumb {
  265. border-radius: 10px;
  266. box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.05);
  267. background: rgb(216, 216, 216);
  268. }
  269. .marks::-webkit-scrollbar-track {
  270. box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.05);
  271. border-radius: 10px;
  272. background: rgb(241, 241, 241);
  273. }
  274. .nodata{
  275. text-align: center;
  276. padding-top: 50px;
  277. color: #a1a1a1;
  278. }
  279. .canvas.nodata{
  280. display: flex;
  281. justify-content: center;
  282. align-items: center;
  283. padding-top: 0;
  284. input{
  285. width: 100px;
  286. height: 34px;
  287. opacity: 0;
  288. cursor: pointer;
  289. position: absolute;
  290. z-index: 2;
  291. top: calc(50% - 17px);
  292. left: calc(50% - 50px);
  293. }
  294. }
  295. }
  296. }
  297. </style>