1047269ee99212205e5bc8b486c3fd0f9ab7dda7.svn-base 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  1. <template>
  2. <el-dialog class="customs_dialog" :visible.sync="dialogVisible" :before-close="handleClose"
  3. :title="titleName + '问题批量导入'">
  4. <div class="upload_div">
  5. <el-upload
  6. ref="upload"
  7. class="upload-demo"
  8. drag
  9. :action="actionUrl"
  10. :on-preview="handlePreview"
  11. :on-remove="handleRemove"
  12. :before-remove="beforeRemove"
  13. :before-upload="beforeAvatarUpload"
  14. :on-success="handleSuccess"
  15. :on-error="handleError"
  16. multiple
  17. :limit="2"
  18. :on-exceed="handleExceed"
  19. :auto-upload="false"
  20. :file-list="fileList">
  21. <i class="el-icon-upload"></i>
  22. <div class="el-upload__text">将xls文件和zip文件拖到此处一块上传,或<em>点击上传</em></div>
  23. </el-upload>
  24. <el-button type="primary" @click="submitUpload" :loading="uploadLoading">点击上传</el-button>
  25. </div>
  26. <div ref="messageDiv" id="messageDiv" style="width: 100%;margin-top: 10px"></div>
  27. <!-- 验证数据的弹出框 -->
  28. <component :is="curComponent"
  29. v-if="showTianBaoPlVer"
  30. @closePlVerDialog="closePlVerDialog"
  31. :tableData="tableData"
  32. :cacheId="cacheId"
  33. :uploadButtonState="uploadButtonState">
  34. </component>
  35. <a type="primary" @click="openPlVerDialog" href="javascript:void(0)" v-show="showButton">点击查看本次填报数据
  36. (<b>再次填报需重新上传文件</b>)</a>
  37. </el-dialog>
  38. </template>
  39. <script>
  40. import request from '@util/gw_ajax_request.js'
  41. import shuiKuWentiPlVer from './shuiKuWenti_piliang_verify'
  42. import shuiZhaWentiPlVer from './shuiZhaWenti_piliang_verify'
  43. import JianSheWentiPlVer from './jianSheWenti_piliang_verify'
  44. import YunxingWentiPlVer from './yunXingWenti_piliang_verify'
  45. import YuDiBaWentiPlVer from './yudibaWenti_piliang_verify'
  46. import ShuiYuanDiWentiPlVer from './shuiYuanDiWenti_piliang_verify'
  47. import QuShuiKouWentiPlVer from './quShuikouWenti_piliang_verify'
  48. import JieShuiGLWentiPlVer from './jieShuiGLWenti_piliang_verify'
  49. import YongShuiDwWentiPlVer from './yongShuiDwWenti_piliang_verify'
  50. // import shuiKuFangHongWentiPlVer from './shuiKuFangHongWenti_piliang_verify'
  51. // import diFangWentiPlVer from './diFangWenti_piliang_verify.vue'
  52. // import shanHongWentiPlVer from './shanHongWenti_piliang_verify.vue'
  53. // import chaoBiaoWentiPlVer from './chaoBiaoWenti_piliang_verify.vue'
  54. import quYongShuiWentiPlVer from './quYongShuiWenti_piliang_verify'
  55. // import guanQuWentiPlVer from './guanQuWenti_piliang_verify.vue'
  56. export default {
  57. props: ['titleName'],
  58. components: {
  59. JianSheWentiPlVer: JianSheWentiPlVer,
  60. shuiKuWentiPlVer: shuiKuWentiPlVer,
  61. shuiZhaWentiPlVer: shuiZhaWentiPlVer,
  62. YunxingWentiPlVer: YunxingWentiPlVer,
  63. YuDiBaWentiPlVer: YuDiBaWentiPlVer,
  64. ShuiYuanDiWentiPlVer: ShuiYuanDiWentiPlVer,
  65. QuShuiKouWentiPlVer: QuShuiKouWentiPlVer,
  66. JieShuiGLWentiPlVer: JieShuiGLWentiPlVer,
  67. YongShuiDwWentiPlVer: YongShuiDwWentiPlVer,
  68. // shuiKuFangHongWentiPlVer: shuiKuFangHongWentiPlVer,
  69. // diFangWentiPlVer: diFangWentiPlVer,
  70. // shanHongWentiPlVer: shanHongWentiPlVer,
  71. // chaoBiaoWentiPlVer: chaoBiaoWentiPlVer,
  72. // guanQuWentiPlVer: guanQuWentiPlVer,
  73. quYongShuiWentiPlVer: quYongShuiWentiPlVer
  74. },
  75. data() {
  76. return {
  77. curComponent: 'JianSheWentiPlVer',
  78. dialogVisible: true,
  79. fileList: [],
  80. uuid: 1,
  81. actionUrl: '/pdcApi/dc/imp/pblm/upload',
  82. socket: null,
  83. showTianBaoPlVer: false,
  84. filePath: '',
  85. tableData: [],
  86. showButton: false,
  87. uploadLoading: false,
  88. uploadZipLoading: false,
  89. cacheId: '',
  90. uploadButtonState: false,
  91. uploadSum: 0,
  92. uploadSuccessSum: 0,
  93. orgType: "001",
  94. }
  95. },
  96. mounted: function () {
  97. if (this.titleName == "小水库") {
  98. this.curComponent = "shuiKuWentiPlVer";
  99. this.orgType = "001";
  100. } else if (this.titleName == "水闸") {
  101. this.curComponent = "shuiZhaWentiPlVer";
  102. this.orgType = "006";
  103. } else if (this.titleName == "水利工程建设") {
  104. this.curComponent = "JianSheWentiPlVer";
  105. this.orgType = "004";
  106. } else if (this.titleName == "水利工程运行") {
  107. this.curComponent = "YunxingWentiPlVer";
  108. this.orgType = "007";
  109. } else if (this.titleName == "淤地坝") {
  110. this.curComponent = "YuDiBaWentiPlVer";
  111. this.orgType = "011";
  112. } else if (this.titleName == "取水口") {
  113. this.curComponent = "QuShuiKouWentiPlVer";
  114. this.orgType = "012";
  115. } else if (this.titleName == "水源地") {
  116. this.curComponent = "ShuiYuanDiWentiPlVer";
  117. this.orgType = "013";
  118. } else if (this.titleName == "节水管理与评价") {
  119. this.curComponent = "JieShuiGLWentiPlVer";
  120. this.orgType = "015";
  121. } else if (this.titleName == "用水单位") {
  122. this.curComponent = "YongShuiDwWentiPlVer";
  123. this.orgType = "016";
  124. } else if (this.titleName == "取用水检查") {
  125. this.curComponent = "quYongShuiWentiPlVer";
  126. this.orgType = "031";
  127. }
  128. },
  129. computed: {
  130. persId() {
  131. return localStorage.getItem("userid")
  132. ? localStorage.getItem("userid")
  133. : "1098101939614724096";
  134. }
  135. },
  136. methods: {
  137. handleClose(done) {
  138. this.$emit("closePlDialog");
  139. },
  140. handleRemove(file, fileList) {
  141. console.log(file, fileList);
  142. },
  143. handlePreview(file) {
  144. console.log(file);
  145. },
  146. handleExceed(files, fileList) {
  147. this.$message.warning(`当前限制选择 2 个文件,本次选择了 ${files.length} 个文件,共选择了 ${files.length + fileList.length} 个文件`);
  148. },
  149. beforeRemove(file, fileList) {
  150. //return this.$confirm(`确定移除 ${ file.name }?`);
  151. },
  152. beforeAvatarUpload(file) {
  153. this.uploadLoading = true;
  154. let ext = file.name.split('.');
  155. if (ext[ext.length - 1] === 'xls' || ext[ext.length - 1] == 'zip') {
  156. this.uploadSum++;
  157. return file;
  158. } else {
  159. this.$message.error('请上传问题模板文件和zip压缩包!')
  160. return false;
  161. }
  162. },
  163. handleError(err, file, fileList) {
  164. this.$message({
  165. showClose: true,
  166. message: '上传失败,可能文件过大或者其他原因!',
  167. type: 'error'
  168. });
  169. this.restoration();
  170. },
  171. handleSuccess(res, file, fileList) {
  172. let ext = file.name.split('.');
  173. // 加1
  174. this.uploadSuccessSum++;
  175. if (ext[ext.length - 1] == 'xls') {
  176. this.filePath = res.data.key;
  177. }
  178. if (this.uploadSum == 1 && ext[ext.length - 1] == 'zip') {
  179. this.$message({
  180. message: 'zip上传成功!',
  181. type: 'success'
  182. });
  183. this.restoration();
  184. return;
  185. }
  186. if (this.uploadSuccessSum == this.uploadSum) {
  187. this.parse();
  188. }
  189. },
  190. restoration() {
  191. this.uploadLoading = false;
  192. this.uploadSuccessSum = 0;
  193. this.uploadSum = 0;
  194. },
  195. parse() {
  196. // this.filePath = res.data.key;
  197. // 调用解析的接口
  198. request.get(`/dc/imp/pblm/parse?filePath=${this.filePath}&userId=${this.persId}&orgType=${this.orgType}`).then(res => {
  199. this.tableData = res.data.listParse;
  200. this.cacheId = res.data.cacheId;
  201. console.log("table:" + this.tableData)
  202. if (this.tableData.length > 0) {
  203. this.showButton = true;
  204. this.showTianBaoPlVer = true;
  205. } else {
  206. this.$alert('可填报数据条数为0,请确认!', '提示', {
  207. confirmButtonText: '确定',
  208. type: 'warning',
  209. callback: action => {
  210. }
  211. });
  212. }
  213. this.restoration();
  214. });
  215. },
  216. async submitUpload() {
  217. await this.setUrl();
  218. await this.$refs.upload.submit();
  219. },
  220. setUrl() {
  221. this.actionUrl = `/pdcApi/dc/imp/pblm/upload`;
  222. this.$refs.messageDiv.innerHTML = '';
  223. },
  224. closePlVerDialog() {
  225. this.showTianBaoPlVer = false;
  226. },
  227. openPlVerDialog() {
  228. this.uploadButtonState = true;
  229. this.showTianBaoPlVer = true;
  230. }
  231. }
  232. }
  233. </script>
  234. <style>
  235. .title {
  236. font-size: 16px;
  237. }
  238. .el-icon-edit {
  239. margin-right: 10px;
  240. }
  241. .customs_dialog .el-dialog {
  242. width: 40% !important;
  243. }
  244. .customs_dialog .el-dialog__body {
  245. padding: 30px 20px;
  246. color: #606266;
  247. font-size: 14px;
  248. height: 60vh;
  249. overflow: auto;
  250. }
  251. .upload_div {
  252. text-align: center;
  253. }
  254. .upload_div_left {
  255. border: 1px solid red;
  256. width: 50%;
  257. height: 100px;
  258. float: left;
  259. }
  260. .upload_div_right {
  261. border: 1px solid red;
  262. width: 50%;
  263. height: 100%;
  264. float: right;
  265. }
  266. </style>