a261a278266204d732c8a9b745d4998ff73d709c.svn-base 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371
  1. <template>
  2. <el-dialog class="customs_dialog" :visible.sync="dialogVisible" :before-close="handleClose" title="督查计划批量创建">
  3. <div class="upload_div">
  4. <!-- <el-upload
  5. ref="upload"
  6. class="upload-demo"
  7. drag
  8. action="/pdcApi/bis/insp/fsc/pblm/uploadTemplate"
  9. :on-preview="handlePreview"
  10. :on-remove="handleRemove"
  11. :before-remove="beforeRemove"
  12. :before-upload="beforeAvatarUpload"
  13. :on-success="handleSuccess"
  14. multiple
  15. :limit="1"
  16. :on-exceed="handleExceed"
  17. :file-list="fileList">
  18. <i class="el-icon-upload"></i>
  19. <div class="el-upload__text">将模板文件拖到此处,或<em>点击选取模板文件</em></div>
  20. </el-upload> -->
  21. <el-upload
  22. ref="upload"
  23. class="upload-demo"
  24. drag
  25. :http-request="conPic"
  26. :on-remove="removePic"
  27. :before-upload="beforeAvatarUpload"
  28. :on-success="handleSuccess"
  29. :on-exceed="handleExceed"
  30. :file-list="fileList"
  31. :limit="1"
  32. action="111"
  33. multiple>
  34. <i class="el-icon-upload"></i>
  35. <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
  36. </el-upload>
  37. <!-- <el-form :model="addObj" :label-width="formLabelWidth">
  38. <el-form-item label="">
  39. <el-input v-model="addObj.file" id="file" type="file"></el-input>
  40. </el-form-item>
  41. </el-form> -->
  42. </div>
  43. <div ref="messageDiv" id="messageDiv" style="width: 100%;margin-top: 10px">
  44. </div>
  45. <!-- 验证数据的弹出框 -->
  46. <!--<shuiKuTianbaoPlVer v-if="showShuiKuTianBaoPlVer"-->
  47. <!--@closePlVerDialog="closePlVerDialog"-->
  48. <!--:tableData="tableData"-->
  49. <!--:uuid="uuid"-->
  50. <!--:id='id'-->
  51. <!--&gt;</shuiKuTianbaoPlVer>-->
  52. <!--<a type="primary" @click="openPlVerDialog" href="javascript:void(0)" v-show="showButton">点击弹框</a>-->
  53. <span slot="footer" class="dialog-footer">
  54. <el-button @click="handleClose">取 消</el-button>
  55. <el-button type="primary" @click="submitUpload" :loading="uploadLoading" >点击上传</el-button>
  56. </span>
  57. </el-dialog>
  58. </template>
  59. <script>
  60. import request from '../../utils/gw_ajax_request.js'
  61. import { hostUrl } from "@util/global_variable.js";
  62. // import shuiKuTianbaoPlVer from './shuiKuTianbao_piliang_verify'
  63. export default {
  64. props: [],
  65. components: {
  66. // shuiKuTianbaoPlVer:shuiKuTianbaoPlVer,
  67. },
  68. data(){
  69. return{
  70. addObj: {
  71. file:'',
  72. },
  73. dialogVisible:true,
  74. fileList:[],
  75. uuid:1,
  76. actionUrl:'',
  77. socket:null,
  78. showShuiKuTianBaoPlVer:false,
  79. filePath:'',
  80. tableData:[],
  81. showButton:false,
  82. uploadLoading: false,
  83. picLists:[],
  84. }
  85. },
  86. mounted:function(){
  87. },
  88. computed: {
  89. persId() {
  90. return localStorage.getItem("userid")
  91. ? localStorage.getItem("userid")
  92. : "1098101939614724096";
  93. },
  94. orgId() {
  95. return localStorage.getItem("guid") ? localStorage.getItem("guid") : "";
  96. },
  97. },
  98. methods:{
  99. removePic(file, fileList){
  100. this.picLists=[];
  101. console.log(file);
  102. console.log(fileList);
  103. fileList.forEach(ele =>{
  104. this.picLists.push(ele.raw);
  105. })
  106. // this.nextStepToFrom();
  107. console.log(this.picLists)
  108. },
  109. conPic(item){
  110. // this.form['upFiles'] = item.file;
  111. this.picLists.push(item.file)
  112. // this.form.app = item.file;
  113. console.log(item);
  114. console.log(this.picLists);
  115. },
  116. handleClose(done) {
  117. // this.closeSocket();
  118. // this.$parent.getSkDataList();
  119. this.$emit("closePlDialog");
  120. },
  121. handleRemove(file, fileList) {
  122. console.log(file, fileList);
  123. },
  124. handlePreview(file) {
  125. console.log(file);
  126. },
  127. handleExceed(files, fileList) {
  128. this.$message.warning(`当前限制选择 1 个文件,本次选择了 ${files.length} 个文件,共选择了 ${files.length + fileList.length} 个文件`);
  129. },
  130. beforeRemove(file, fileList) {
  131. //return this.$confirm(`确定移除 ${ file.name }?`);
  132. },
  133. beforeAvatarUpload(file) {
  134. let Xls = file.name.split('.');
  135. if(Xls[1] === 'xls' || Xls[1] === 'xlsx'){
  136. return file;
  137. }else {
  138. this.$message.error('请上传编辑后的模板文件!');
  139. return false;
  140. }
  141. },
  142. handleSuccess(res,file,fileList){
  143. let filePath = res.data.key;
  144. this.filePath = filePath;
  145. // 调用解析的接口
  146. // request.get(`/dc/impExcel/parseExcel/${this.persId}/${this.uuid}?filePath=${this.filePath}&tid=08&pid=${this.id}`).then(res => {
  147. //
  148. // this.tableData = res.data;
  149. // console.log("table:" + this.tableData)
  150. //
  151. // if(this.tableData.length > 0){
  152. // this.showButton = true;
  153. // this.showShuiKuTianBaoPlVer = true;
  154. // }else{
  155. // this.$alert('可填报数据条数为0或非本组数据,请确认!', '提示', {
  156. // confirmButtonText: '确定',
  157. // type: 'warning',
  158. // callback: action => {
  159. //
  160. // }
  161. // });
  162. // }
  163. // // 只展示错误数据的逻辑
  164. // // if(this.tableData[0].Message == undefined){
  165. // // this.showButton = true;
  166. // // this.showShuiKuTianBaoPlVer = true;
  167. // // }else{
  168. // // var message = this.tableData[0].Message;
  169. // // if(message == 'success'){
  170. // // this.showButton = true;
  171. // // this.showShuiKuTianBaoPlVer = true;
  172. // // }else {
  173. // // this.$alert('可填报数据条数为0或非本组数据,请确认!', '提示', {
  174. // // confirmButtonText: '确定',
  175. // // type: 'warning',
  176. // // callback: action => {
  177. //
  178. // // }
  179. // // });
  180. // // }
  181. // // }
  182. //
  183. // this.uploadLoading = false;
  184. // });
  185. },
  186. openSocket() {
  187. if (typeof(WebSocket) == "undefined") {
  188. console.log("您的浏览器不支持WebSocket");
  189. } else {
  190. this.closeSocket();
  191. console.log("您的浏览器支持WebSocket");
  192. console.log("sid:" + this.uuid);
  193. //实例化WebSocket对象,指定要连接的服务器地址与端口 建立连接
  194. // let baseUrl = "localhost:8101";
  195. // 测试服务器
  196. let baseUrl = "10.1.102.136:8100";
  197. // let baseUrl = "sv.goldenwater.com.cn";
  198. // let baseUrl = "localhost:8085/wsbackend";
  199. this.socket = new WebSocket(`ws://${baseUrl}/websocket/${this.uuid}`);
  200. // socket
  201. let socket = this.socket;
  202. //打开事件
  203. socket.onopen = function () {
  204. console.log("Socket 已打开");
  205. //socket.send("这是来自客户端的消息" + location.href + new Date());
  206. };
  207. //获得消息事件
  208. socket.onmessage = function (msg) {
  209. console.log(msg.data);
  210. document.getElementById('messageDiv').innerHTML = document.getElementById('messageDiv').innerHTML
  211. + msg.data + "<br/>"
  212. //发现消息进入 开始处理前端触发逻辑
  213. if(msg.data.indexOf('完成数据校验') > 0){
  214. }
  215. };
  216. //关闭事件
  217. socket.onclose = function () {
  218. console.log("Socket已关闭");
  219. };
  220. //发生了错误事件
  221. socket.onerror = function () {
  222. console.log("Socket发生了错误");
  223. //此时可以尝试刷新页面
  224. };
  225. // 路由跳转时结束websocket链接
  226. this.$router.afterEach(function () {
  227. socket.close()
  228. })
  229. }
  230. },
  231. // getUUID (){
  232. // request.get('/socket/uuid').then(res => {
  233. // if(res.success){
  234. // this.uuid = res.data.key;
  235. // this.actionUrl = `/pdcApi/dc/impExcel/imp/${this.persId}/${this.uuid}?tid=08`;
  236. // }else {
  237. // console.log("success不为true")
  238. // }
  239. // });
  240. // },
  241. closeSocket() {
  242. if (this.socket != null) {
  243. this.socket.close();
  244. }
  245. },
  246. submitUpload() {
  247. // let filePath = this.filePath;
  248. // if(filePath){
  249. // this.uploadLoading = true;
  250. // request.post(`/bis/insp/fsc/pblm/parseUpload?path=${filePath}&startRow=1`).then(res =>{
  251. // if(res.success){
  252. // this.uploadLoading = false;
  253. // request.post(`/bis/insp/fsc/pblm/insertIntoData?dataId=${res.data.dataId}`).then(res1 =>{
  254. // if(res1.success){
  255. // this.$message.success('上传成功');
  256. // this.$emit('uploadSuccess');
  257. // }else{
  258. // this.$message.warning(res1.message);
  259. // }
  260. // })
  261. // }
  262. // })
  263. // }else{
  264. // this.$message.warning('请选择要上传的文件模板');
  265. // }
  266. let _self = this
  267. var fd = new FormData();
  268. // fd.append('persId',_self.persId);
  269. // fd.append('orgId',_self.orgId);
  270. for (var i = 0; i < _self.picLists.length; i++) {
  271. fd.append('file',_self.picLists[i]);
  272. }
  273. // fd.append("file", $("#file")[0].files[0]);
  274. // fd.append("orgId", _self.orgId);
  275. request.post(`/supervision/plan/importExcel?orgId=${_self.orgId}`,fd,{headers:{'Content-Type': 'multipart/form-data'}}).then(res => {
  276. // request.post("http://127.0.0.1:8080/supeplat/api/order/save",fd,{headers:{'Content-Type': 'multipart/form-data'}}).then(res => {
  277. console.log(res);
  278. if(res.success){
  279. this.$message({
  280. message: '提交成功!',
  281. type: 'success'
  282. });
  283. this.$emit('uploadSuccess',res.success);
  284. }else{
  285. this.$message({
  286. message: '提交失败!',
  287. type: 'error'
  288. });
  289. }
  290. });
  291. },
  292. closePlVerDialog(){
  293. this.showShuiKuTianBaoPlVer = false;
  294. },
  295. openPlVerDialog(){
  296. this.showShuiKuTianBaoPlVer = true;
  297. }
  298. },
  299. watch:{
  300. showShuiKuTianBaoPl(n,o){
  301. // 想用监听得使用v-show,因为v-if会重新渲染DOM,子组件已关闭
  302. // alert("进入监听")
  303. // if(!n){
  304. // alert(this.showShuiKuTianBaoPl)
  305. // this.closeSocket();
  306. // }
  307. },
  308. },
  309. }
  310. </script>
  311. <style>
  312. .title{
  313. font-size: 16px;
  314. }
  315. .el-icon-edit{
  316. margin-right: 10px;
  317. }
  318. .customs_dialog .el-dialog{
  319. width: 40% !important;
  320. }
  321. .customs_dialog .el-dialog__body {
  322. padding: 30px 20px;
  323. color: #606266;
  324. font-size: 14px;
  325. height: 60vh;
  326. overflow: auto;
  327. }
  328. .upload_div {
  329. text-align: center;
  330. }
  331. .upload_div_left {
  332. border:1px solid red;
  333. width:50%;
  334. height:100px;
  335. float:left;
  336. }
  337. .upload_div_right {
  338. border:1px solid red;
  339. width:50%;
  340. height:100%;
  341. float:right;
  342. }
  343. </style>