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.8 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
3 years ago
3 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322
  1. <template>
  2. <div class="ui container">
  3. <div class="tuomin-title">
  4. <h2>{{$t('dataDesensitizationModelExperience')}}</h2>
  5. <p>{{$t('dataDesensitizationModelDesc')}} &nbsp;<a href="https://git.openi.org.cn/tengxiao/tuomin" target="_blank">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. if (err.response.status === 400) {
  174. const fr = new FileReader();
  175. fr.onload = (e) => {
  176. try {
  177. const jsonResult = JSON.parse(e.target.result);
  178. this.$message({
  179. type: 'error',
  180. message: jsonResult.Message
  181. });
  182. } catch (e) {
  183. this.$message({
  184. type: 'error',
  185. message: this.$t('tranformImageFailed')
  186. });
  187. }
  188. };
  189. fr.readAsText(err.response.data);
  190. }else{
  191. this.$message({
  192. type: 'error',
  193. message: this.$t('tranformImageFailed')
  194. });
  195. }
  196. })
  197. },
  198. },
  199. mounted() {
  200. },
  201. beforeDestroy() {
  202. },
  203. };
  204. </script>
  205. <style scoped lang="less">
  206. .tuomin-title{
  207. margin-top: 34px;
  208. h2 {
  209. display: flex;
  210. justify-content: center;
  211. }
  212. p{
  213. display: flex;
  214. justify-content: center;
  215. color: rgba(136, 136, 136, 0.87);
  216. }
  217. }
  218. .tuomin-content-image{
  219. border: 1px solid rgba(0, 0, 0, 0.1);
  220. border-radius: 5px;
  221. min-height: 358px;
  222. position: relative;
  223. .tuomin-icon {
  224. display: flex;
  225. align-items: center;
  226. position: absolute;
  227. left: 0;
  228. top: 0;
  229. width: 66px;
  230. height: 22px;
  231. justify-content: center;
  232. color: rgba(136, 136, 136, 0.87);
  233. border-radius: 5px 0px 10px 0px;
  234. border: 1px solid rgba(0, 0, 0, 0.1);
  235. }
  236. .el-upload__text{
  237. height: 100%;
  238. display: flex;
  239. align-items: center;
  240. justify-content: center;
  241. }
  242. .preview-image{
  243. height: 100%;
  244. width: 100%;
  245. }
  246. .tuomin-radio-model{
  247. display: flex;
  248. margin: 25px 12px 0 12px;
  249. .radio-label{
  250. font-weight: 600;
  251. margin-right: 4px;
  252. color: rgba(16, 16, 16, 1);
  253. }
  254. }
  255. .tuomin-button-model{
  256. text-align: right;
  257. margin: 22px 12px 0 12px;
  258. }
  259. }
  260. /deep/ .el-upload--picture-card{
  261. width: 100%;
  262. background: #ffff;
  263. border: none;
  264. border-bottom: 1px dashed #888;
  265. border-radius: 0;
  266. min-height: 230px;
  267. }
  268. .table-container {
  269. margin-bottom: 16px;
  270. /deep/ .el-table__header {
  271. th {
  272. background: rgb(245, 245, 246);
  273. font-size: 14px;
  274. color: rgb(36, 36, 36);
  275. font-weight: 400;
  276. }
  277. }
  278. /deep/ .el-table__body {
  279. td {
  280. font-size: 14px;
  281. }
  282. }
  283. }
  284. .center {
  285. display: flex;
  286. justify-content: center;
  287. }
  288. @media screen and (max-width:768px){
  289. body{
  290. background-color: black
  291. }
  292. }
  293. </style>