CheckPic.vue 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362
  1. <template>
  2. <div class="check-article">
  3. <div class="main">
  4. <div v-for="(item, index) in data.detail" :key="index + 'paragraph'" class="paragraph">
  5. <label>段 {{ index + 1 }}</label>
  6. <template v-if="data.type === 'article'">
  7. <el-upload
  8. action="no"
  9. accept="image/*,video/*"
  10. :file-list="item.sourceList"
  11. :http-request="handleImage"
  12. :before-upload="handleBeforeImage"
  13. :on-exceed="handleExceed"
  14. :limit="1"
  15. :key="index"
  16. @click.native="handleItem(index)"
  17. class="upload-resource"
  18. >
  19. <div class="remark-box"><i class="el-icon-upload"></i>上传图片/视频</div>
  20. </el-upload>
  21. <div class="set-para">
  22. <span>图片/视频位置:</span>
  23. <el-radio-group v-model="item.sourcePosition">
  24. <el-radio label="before">段落前</el-radio>
  25. <el-radio label="after">段落后</el-radio>
  26. </el-radio-group>
  27. </div>
  28. <div class="set-para">
  29. <span class="adult-book-lable">图片宽度:</span>
  30. <el-input
  31. v-model="item.widthNumber"
  32. class="adult-book-input"
  33. placeholder="请输入宽度值"
  34. maxlength="200"
  35. style="width: 150px"
  36. @blur="onBlur(item, 'widthNumber')"
  37. />
  38. <span class="adult-book-lable">图片高度:</span>
  39. <el-input
  40. v-model="item.heightNumber"
  41. class="adult-book-input"
  42. placeholder="请输入高度值"
  43. maxlength="200"
  44. style="width: 150px"
  45. @blur="onBlur(item, 'heightNumber')"
  46. />
  47. </div>
  48. </template>
  49. <div v-for="(items, indexs) in item.wordsList" :key="indexs + 'words'" class="sentence-box">
  50. <div class="sentence">
  51. <b>{{ indexs + 1 }}.</b>
  52. <div class="sentence">
  53. <span v-for="(itemss, indexss) in items" :key="indexss" class="sentence-item" @click="showPic(itemss)">
  54. {{ itemss.chs }}
  55. <img
  56. v-if="itemss.img && itemss.img.length > 0"
  57. style="height: 16px"
  58. :src="itemss.img[0].file_url_open"
  59. />
  60. <div :contenteditable="true" class="sentence-pic"></div>
  61. </span>
  62. </div>
  63. </div>
  64. </div>
  65. </div>
  66. </div>
  67. <el-dialog title="上传图片" :visible.sync="remarkVisible" width="50%" :close-on-click-modal="false" append-to-body>
  68. <template v-if="itemActive">
  69. <el-upload
  70. action="no"
  71. accept="image/*,video/*"
  72. :file-list="itemActive.img"
  73. :http-request="handleImages"
  74. :before-upload="handleBeforeImages"
  75. :on-exceed="handleExceeds"
  76. :limit="1"
  77. class="upload-resource"
  78. >
  79. <div class="remark-box"><i class="el-icon-upload"></i>上传图片</div>
  80. </el-upload>
  81. </template>
  82. <span slot="footer" class="dialog-footer">
  83. <el-button @click="remarkVisible = false">取 消</el-button>
  84. <el-button type="primary" @click="remarkVisible = false">保 存</el-button>
  85. </span>
  86. </el-dialog>
  87. </div>
  88. </template>
  89. <script>
  90. import { fileUpload } from '@/api/app';
  91. export default {
  92. components: {},
  93. props: ['data'],
  94. data() {
  95. return {
  96. // ArticelData: JSON.parse(JSON.stringify(this.data)),
  97. showWordFlag: false,
  98. showPinyinFlag: false,
  99. showStyleFlag: false,
  100. remarkVisible: false,
  101. remark: null,
  102. activeItem: null,
  103. itemActive: null,
  104. };
  105. },
  106. // 生命周期 - 创建完成(可以访问当前this实例)
  107. created() {
  108. this.getArticleData();
  109. },
  110. methods: {
  111. // 获取分析结果
  112. getArticleData() {
  113. this.data.detail.forEach((item) => {
  114. if (item.segList && item.segList.length > 0) {
  115. item.sentenceStr = [];
  116. item.segList.forEach((items, indexs) => {
  117. let str = '';
  118. items.forEach((itemss, indexss) => {
  119. str += itemss;
  120. if (indexss !== items.length - 1) str += '&nbsp;&nbsp;';
  121. });
  122. item.sentenceStr.push(str);
  123. });
  124. }
  125. });
  126. },
  127. changeImage(file) {
  128. fileUpload('Mid', file, { isGlobalprogress: true }).then(({ file_info_list }) => {
  129. if (file_info_list.length > 0) {
  130. const { file_id, file_url_open, file_name } = file_info_list[0];
  131. this.remark.img_list.push({
  132. name: file_name,
  133. url: file_url_open,
  134. id: file_id,
  135. imgNumber: 0,
  136. });
  137. }
  138. });
  139. },
  140. delImage(index) {
  141. this.remark.img_list.splice(index, 1);
  142. },
  143. onBlur(item, field) {
  144. item[field] = item[field] ? item[field].trim() : '';
  145. },
  146. // 处理超出图片个数操作
  147. handleExceed(files, fileList) {
  148. this.$message.warning(
  149. `当前限制选择 1 个文件,本次选择了 ${files.length} 个文件,共选择了 ${files.length + fileList.length} 个文件`,
  150. );
  151. },
  152. // 记录段落
  153. handleItem(index) {
  154. this.activeItem = this.data.detail[index];
  155. },
  156. // 图片上传前处理
  157. handleBeforeImage(file) {
  158. // 判断文件是否为图片
  159. if (!file.type.includes('image') && !file.type.includes('video')) {
  160. this.$message.error('请选择图片或视频文件');
  161. return false;
  162. }
  163. },
  164. // 图片上传
  165. handleImage(file) {
  166. fileUpload('Mid', file, { isGlobalprogress: true }).then(({ file_info_list }) => {
  167. if (file_info_list.length > 0) {
  168. this.activeItem.sourceList = file_info_list;
  169. this.activeItem.sourceList[0].name = file_info_list[0].file_name;
  170. this.activeItem.sourceList[0].type = file.file.type.includes('image') > -1 ? 'image' : 'video';
  171. }
  172. });
  173. },
  174. // 处理超出图片个数操作
  175. handleExceeds(files, fileList) {
  176. this.$message.warning(
  177. `当前限制选择 1 个文件,本次选择了 ${files.length} 个文件,共选择了 ${files.length + fileList.length} 个文件`,
  178. );
  179. },
  180. // 图片上传前处理
  181. handleBeforeImages(file) {
  182. // 判断文件是否为图片
  183. if (!file.type.includes('image')) {
  184. this.$message.error('请选择图片文件');
  185. return false;
  186. }
  187. },
  188. // 图片上传
  189. handleImages(file) {
  190. fileUpload('Mid', file, { isGlobalprogress: true }).then(({ file_info_list }) => {
  191. if (file_info_list.length > 0) {
  192. this.itemActive.img = file_info_list;
  193. this.itemActive.img[0].name = file_info_list[0].file_name;
  194. }
  195. });
  196. },
  197. showPic(item) {
  198. this.itemActive = item;
  199. this.remarkVisible = true;
  200. },
  201. },
  202. };
  203. </script>
  204. <style lang="scss" scoped>
  205. .check-article {
  206. min-height: 100%;
  207. background: #f6f6f6;
  208. .wheader {
  209. background: #fff;
  210. }
  211. .main {
  212. background: #fff;
  213. &-top {
  214. position: relative;
  215. display: flex;
  216. align-items: center;
  217. justify-content: flex-end;
  218. margin-bottom: 24px;
  219. b {
  220. position: absolute;
  221. top: 0;
  222. left: 50%;
  223. width: 50px;
  224. margin-left: -25px;
  225. font-size: 24px;
  226. font-weight: 500;
  227. line-height: 34px;
  228. color: #000;
  229. text-align: center;
  230. }
  231. .el-button {
  232. padding: 5px 16px;
  233. font-size: 14px;
  234. font-weight: 400;
  235. line-height: 22px;
  236. color: #165dff;
  237. border: 1px solid #165dff;
  238. border-radius: 2px;
  239. &.el-button--primary {
  240. color: #fff;
  241. background: #165dff;
  242. }
  243. }
  244. }
  245. .go-back {
  246. display: flex;
  247. align-items: center;
  248. width: 60px;
  249. padding: 5px 8px;
  250. font-size: 14px;
  251. font-weight: 400;
  252. line-height: 22px;
  253. color: #333;
  254. cursor: pointer;
  255. background: #fff;
  256. border: 1px solid #d9d9d9;
  257. border-radius: 4px;
  258. box-shadow: 0 2px 0 0 rgba(0, 0, 0, 2%);
  259. .el-icon-arrow-left {
  260. margin-right: 8px;
  261. font-size: 16px;
  262. }
  263. }
  264. .paragraph {
  265. margin-bottom: 8px;
  266. text-align: center;
  267. > label {
  268. padding: 1px 8px;
  269. font-size: 14px;
  270. font-weight: 400;
  271. line-height: 22px;
  272. color: var(--blue-05, #175dff);
  273. background: #e7eeff;
  274. border: 1px solid #175dff;
  275. border-radius: 2px;
  276. }
  277. .sentence-box {
  278. .sentence {
  279. display: flex;
  280. margin-top: 8px;
  281. b {
  282. flex-shrink: 0;
  283. width: 32px;
  284. margin-top: 16px;
  285. font-size: 16px;
  286. font-weight: 400;
  287. line-height: 24px;
  288. color: #000;
  289. }
  290. .sentence {
  291. flex: 1;
  292. padding: 8px;
  293. font-size: 16px;
  294. font-weight: 400;
  295. line-height: 24px;
  296. color: #000;
  297. text-align: left;
  298. background: #f7f7f7;
  299. }
  300. }
  301. }
  302. }
  303. }
  304. .set-para {
  305. margin-top: 8px;
  306. text-align: left;
  307. }
  308. }
  309. .remark-box {
  310. display: flex;
  311. gap: 8px;
  312. align-items: center;
  313. justify-content: center;
  314. width: fit-content;
  315. height: 24px;
  316. padding: 2px 12px;
  317. margin: 16px 0 0;
  318. font-size: 12px;
  319. font-weight: 400;
  320. line-height: 20px; /* 166.667% */
  321. color: #165dff;
  322. cursor: pointer;
  323. border: 1px solid #165dff;
  324. border-radius: 2px;
  325. }
  326. .upload-resource {
  327. text-align: left;
  328. }
  329. .sentence-item {
  330. display: flex;
  331. flex-flow: wrap;
  332. align-items: center;
  333. }
  334. .sentence-pic {
  335. width: 10px;
  336. text-align: center;
  337. }
  338. </style>