You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

index.vue 9.1 kB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  1. <template>
  2. <div class="ui container">
  3. <div class="tuomin-title">
  4. <h2>{{$t('dataDesensitizationModelExperience')}}</h2>
  5. <p>{{$t('dataDesensitizationModelDesc')}} &nbsp;<a href="">tengxiao / tuomin</a></p>
  6. </div>
  7. <el-row :gutter="12" style="margin-top: 33px;">
  8. <el-col :xs="24" :span="12">
  9. <div class="tuomin-content-image">
  10. <div class="tuomin-icon">
  11. <i class="ri-image-line" style="font-size: 16px;margin-right:2px;"></i>
  12. <span style="font-size: 12px;">img</span>
  13. </div>
  14. <div style="height:230px;width: 96%;margin: 0 auto;">
  15. <el-upload
  16. action="#"
  17. accept=".jpg,.jpeg,.png,.JPG,.JPEG,.PNG"
  18. :show-file-list="false"
  19. :on-change="handleChangePicture"
  20. list-type="picture-card"
  21. :file-list="fileList"
  22. :style="{display:(ImageUrl ? 'none':'block')}"
  23. :auto-upload="false"
  24. >
  25. <div class="el-upload__text">{{$t('dragThePictureHere')}}<span style="color: rgba(136, 136, 136, 0.87);">{{$t('or')}}</span>{{$t('clickUpload')}}</div>
  26. </el-upload>
  27. <img class="preview-image" v-if="ImageUrl" :src="ImageUrl" alt="">
  28. </div>
  29. <div>
  30. <div class="tuomin-radio-model">
  31. <label class="radio-label">{{$t('desensitizationObject')}}:</label>
  32. <div>
  33. <el-radio-group v-model="radio">
  34. <el-radio :label="2">{{$t('all')}}</el-radio>
  35. <el-radio :label="1">{{$t('onlyFace')}}</el-radio>
  36. <el-radio :label="0">{{$t('onlyLicensePlate')}}</el-radio>
  37. </el-radio-group>
  38. </div>
  39. </div>
  40. <div class="tuomin-button-model">
  41. <el-button @click="cancelUpload">{{$t('cancel')}}</el-button>
  42. <el-button :disabled="fileList.length<1" @click="startTranform" type="primary">{{$t('startDesensitization')}}</el-button>
  43. </div>
  44. </div>
  45. </div>
  46. </el-col>
  47. <el-col :xs="24" :span="12">
  48. <div class="tuomin-content-image" v-loading="tranformImageLoading">
  49. <div class="tuomin-icon">
  50. <i class="ri-image-line" style="font-size: 16px;margin-right:2px;"></i>
  51. <span style="font-size: 12px;">output</span>
  52. </div>
  53. <div style="height: 358px;">
  54. <el-image
  55. style="height: 100%;width: 100%;"
  56. :src="resultImgSrc"
  57. :preview-src-list="[resultImgSrc]">
  58. <div slot="error" class="image-slot">
  59. <i style="font-size: 0;" class="el-icon-picture-outline"></i>
  60. </div>
  61. </el-image>
  62. </div>
  63. </div>
  64. </el-col>
  65. </el-row>
  66. <div style="margin: 39px 0 21px 0;">
  67. <span>{{$t('example')}}:</span>
  68. </div>
  69. <div class="table-container">
  70. <div>
  71. <el-table border :data="tableData1" style="width:100%">
  72. <el-table-column :label="$t('originPicture')" align="center">
  73. <template slot-scope="scope">
  74. <div style="width: 100%;height:200px;">
  75. <el-image
  76. style="height: 100%;width: 100%;"
  77. :src="scope.row.imgSrc1"
  78. :preview-src-list="[scope.row.imgSrc1]">
  79. <div slot="error" class="image-slot">
  80. <i style="font-size: 0;" class="el-icon-picture-outline"></i>
  81. </div>
  82. </el-image>
  83. </div>
  84. </template>
  85. </el-table-column>
  86. <el-table-column :label="$t('desensitizationPicture')" align="center">
  87. <template slot-scope="scope">
  88. <div style="width: 100%;height:200px;">
  89. <el-image
  90. style="height: 100%;width: 100%;"
  91. :src="scope.row.imgSrc2"
  92. :preview-src-list="[scope.row.imgSrc2]">
  93. <div slot="error" class="image-slot">
  94. <i style="font-size: 0;" class="el-icon-picture-outline"></i>
  95. </div>
  96. </el-image>
  97. </div>
  98. </template>
  99. </el-table-column>
  100. <el-table-column prop="mode" :label="$t('desensitizationObject')" align="center" header-align="center">
  101. </el-table-column>
  102. </el-table>
  103. </div>
  104. </div>
  105. </div>
  106. </template>
  107. <script>
  108. import axios from 'axios';
  109. export default {
  110. data() {
  111. return {
  112. ImageUrl:'',
  113. radio:2,
  114. file:'',
  115. fileList:[],
  116. resultImgSrc:'',
  117. tranformImageLoading:false,
  118. tableData1:[{
  119. imgSrc1:'/img/origin.png',
  120. imgSrc2:'/img/tuomin.png',
  121. mode:this.$t('all')
  122. }]
  123. };
  124. },
  125. components: {},
  126. methods: {
  127. // 选择文件、移除文件、上传文件成功/失败后,都会触发
  128. handleChangePicture(file,fileList) {
  129. console.log("----change:",file,fileList)
  130. let acceptList = ["jpg", "jpeg",'png']
  131. // 根据文件名获取文件的后缀名
  132. let fileType = file.name.split('.').pop().toLowerCase()
  133. // 判断文件格式是否符合要求
  134. if (acceptList.indexOf(fileType) === -1) {
  135. this.$message.error(this.$t('limitFilesUpload'));
  136. return false
  137. }
  138. // 判断文件大小是否符合要求
  139. if (file.size / 1024 / 1024 > 20) {
  140. this.$message.error(this.$t('limitSizeUpload'));
  141. return false
  142. }
  143. this.ImageUrl = URL.createObjectURL(file.raw);
  144. this.file = file
  145. this.fileList = fileList
  146. },
  147. cancelUpload(){
  148. this.ImageUrl = ''
  149. this.file=''
  150. this.fileList = []
  151. },
  152. startTranform(){
  153. if(!this.file)return
  154. let fd = new FormData();
  155. fd.append('file', this.file.raw);
  156. console.log(fd.get("file"))
  157. this.tranformImageLoading = true
  158. axios({
  159. method:'POST',
  160. url: '/extension/tuomin/upload',
  161. headers: {'Accept': 'image/png'},
  162. responseType: 'blob',
  163. params: { mode: this.radio },
  164. data:fd
  165. }).then(res => {
  166. console.log(res)
  167. const objectURL = URL.createObjectURL(res.data);
  168. this.resultImgSrc = objectURL;
  169. this.tranformImageLoading = false
  170. }).catch(err => {
  171. console.log(err);
  172. this.tranformImageLoading = false
  173. this.$message({
  174. type: 'error',
  175. message: this.$t('tranformImageFailed')
  176. });
  177. })
  178. },
  179. },
  180. mounted() {
  181. },
  182. beforeDestroy() {
  183. },
  184. };
  185. </script>
  186. <style scoped lang="less">
  187. .tuomin-title{
  188. margin-top: 34px;
  189. h2 {
  190. display: flex;
  191. justify-content: center;
  192. }
  193. p{
  194. display: flex;
  195. justify-content: center;
  196. color: rgba(136, 136, 136, 0.87);
  197. }
  198. }
  199. .tuomin-content-image{
  200. border: 1px solid rgba(0, 0, 0, 0.1);
  201. border-radius: 5px;
  202. min-height: 358px;
  203. position: relative;
  204. .tuomin-icon {
  205. display: flex;
  206. align-items: center;
  207. position: absolute;
  208. left: 0;
  209. top: 0;
  210. width: 66px;
  211. height: 22px;
  212. justify-content: center;
  213. color: rgba(136, 136, 136, 0.87);
  214. border-radius: 5px 0px 10px 0px;
  215. border: 1px solid rgba(0, 0, 0, 0.1);
  216. }
  217. .el-upload__text{
  218. height: 100%;
  219. display: flex;
  220. align-items: center;
  221. justify-content: center;
  222. }
  223. .preview-image{
  224. height: 100%;
  225. width: 100%;
  226. }
  227. .tuomin-radio-model{
  228. display: flex;
  229. margin: 25px 12px 0 12px;
  230. .radio-label{
  231. font-weight: 600;
  232. margin-right: 4px;
  233. color: rgba(16, 16, 16, 1);
  234. }
  235. }
  236. .tuomin-button-model{
  237. text-align: right;
  238. margin: 22px 12px 0 12px;
  239. }
  240. }
  241. /deep/ .el-upload--picture-card{
  242. width: 100%;
  243. background: #ffff;
  244. border: none;
  245. border-bottom: 1px dashed #888;
  246. border-radius: 0;
  247. min-height: 230px;
  248. }
  249. .table-container {
  250. margin-bottom: 16px;
  251. /deep/ .el-table__header {
  252. th {
  253. background: rgb(245, 245, 246);
  254. font-size: 14px;
  255. color: rgb(36, 36, 36);
  256. font-weight: 400;
  257. }
  258. }
  259. /deep/ .el-table__body {
  260. td {
  261. font-size: 14px;
  262. }
  263. }
  264. }
  265. .center {
  266. display: flex;
  267. justify-content: center;
  268. }
  269. @media screen and (max-width:768px){
  270. body{
  271. background-color: black
  272. }
  273. }
  274. </style>