TaskImportTruck.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375
  1. <template>
  2. <a-spin :spinning="spinningAdd">
  3. <div>
  4. <a-page-header
  5. style="background-color: #FFFFFF;"
  6. title="中继线稽核 客户资料导入"
  7. sub-title="1、先选择客户资料,进行导入前预览。2、信息无误后再确认导入"
  8. @back="goBack"
  9. >
  10. <a-descriptions :title="task.taskName" size="small" :column="3">
  11. <a-descriptions-item label="状态">
  12. <a-tag :color="task.taskStateColor">{{ task.taskStateText }}</a-tag>
  13. </a-descriptions-item>
  14. <a-descriptions-item label="开始时间">{{ task.taskStartTime }}</a-descriptions-item>
  15. <a-descriptions-item label="结束时间">{{ task.taskEndTime }}</a-descriptions-item>
  16. <a-descriptions-item label="描述"><span v-html="task.description"></span></a-descriptions-item>
  17. <!--{{task.description}}-->
  18. </a-descriptions>
  19. <a-divider style="margin: 6px;"/>
  20. </a-page-header>
  21. <a-card :bordered="false" style="margin-top: -22px;">
  22. <!-- 操作按钮区域 start -->
  23. <div class="table-operator">
  24. <a-upload name="file"
  25. :showUploadList="false"
  26. :multiple="false"
  27. :headers="tokenHeader"
  28. :action="url.importExcel"
  29. @change="uploadChange">
  30. <a-button type="primary" icon="upload">客户资料选择</a-button>
  31. </a-upload>
  32. <a-button type="primary" icon="import"
  33. @click="importInfo">确定导入
  34. </a-button>
  35. <a-button type="primary" icon="import"
  36. @click="downloadTemplat">下载导入模版
  37. </a-button>
  38. <a-button type="primary" icon="import" v-has="'taskImportTruck:excelError'"
  39. @click="handleExportXls('失败数据')">下载失败数据
  40. </a-button>
  41. </div>
  42. <!-- 操作按钮区域 end -->
  43. <!-- table区域 begin -->
  44. <div>
  45. <a-table
  46. ref="table"
  47. size="middle"
  48. bordered
  49. :scroll="{x:true}"
  50. :columns="columns"
  51. :dataSource="dataSource"
  52. :pagination="false"
  53. :loading="loading"
  54. class="j-table-force-nowrap"
  55. :rowClassName='getRowBackGround'
  56. @change="handleTableChange">
  57. </a-table>
  58. </div>
  59. <!-- table区域 end -->
  60. </a-card>
  61. </div>
  62. </a-spin>
  63. </template>
  64. <script>
  65. import {JeecgListMixin} from '@/mixins/JeecgListMixin'
  66. import { downFile, getAction, httpAction } from '@api/manage'
  67. export default {
  68. name: 'TaskImport',
  69. mixins: [JeecgListMixin],
  70. data() {
  71. return {
  72. //加载属性
  73. spinningAdd: false,
  74. description: '导入页面',
  75. autoSearch: false,
  76. dataSource: [],
  77. errorCount: 0,
  78. task: {},
  79. // 表头
  80. columns: [
  81. {
  82. title: '#',
  83. dataIndex: '',
  84. key: 'rowIndex',
  85. width: 60,
  86. align: "center",
  87. customRender: function (t, r, index) {
  88. return parseInt(index) + 1;
  89. }
  90. },
  91. {
  92. title: '客户名称',
  93. align: "center",
  94. dataIndex: 'customerName'
  95. },
  96. {
  97. title: '客户编号',
  98. align: "center",
  99. dataIndex: 'customerNo'
  100. },
  101. // {
  102. // title: '服务号码',
  103. // align: "center",
  104. // dataIndex: 'smsNumber'
  105. // },
  106. {
  107. title: '用户编号',
  108. align: "center",
  109. dataIndex: 'userNo'
  110. },
  111. {
  112. title: '入网时间',
  113. align: "center",
  114. dataIndex: 'networkAccessTime'
  115. },
  116. {
  117. title: '用户状态',
  118. align: "center",
  119. dataIndex: 'userState'
  120. },
  121. {
  122. title: '用户发展员工',
  123. align: "center",
  124. dataIndex: 'staffName'
  125. },
  126. {
  127. title: '员工编号',
  128. align: "center",
  129. dataIndex: 'staffNo'
  130. },
  131. {
  132. title: '员工二级部门',
  133. align: "center",
  134. dataIndex: 'staffDeptLevel2Name'
  135. },
  136. {
  137. title: '员工二级部门编号',
  138. align: "center",
  139. dataIndex: 'staffDeptLevel2No'
  140. },
  141. {
  142. title: '员工三级部门',
  143. align: "center",
  144. dataIndex: 'staffDeptLevel3Name'
  145. },
  146. {
  147. title: '员工三级部门编号',
  148. align: "center",
  149. dataIndex: 'staffDeptLevel3No'
  150. },
  151. {
  152. title: '首次激活时间(固网起租时间)',
  153. align: "center",
  154. dataIndex: 'firstActivationDate'
  155. }, {
  156. title: '账户编码',
  157. align: "center",
  158. dataIndex: 'accountCode'
  159. }, {
  160. title: '楼宇名称',
  161. align: "center",
  162. dataIndex: 'floorName'
  163. }, {
  164. title: '楼宇编号',
  165. align: "center",
  166. dataIndex: 'floorCode'
  167. },
  168. {
  169. title: '导入结果',
  170. align: "center",
  171. dataIndex: 'result',
  172. customRender: function (text, record, index) {
  173. if (text == "1") {
  174. return '成功'
  175. } else if (text == "0") {
  176. return '失败'
  177. }
  178. return '';
  179. }
  180. },
  181. {
  182. title: '错误结果',
  183. align: "center",
  184. dataIndex: 'errorMsg'
  185. },
  186. ],
  187. batchNo:"",
  188. url: {
  189. importExcel: window._CONFIG['domainURL'] + "/smsCheck/task/importCustomerExcel",
  190. importData: "/smsCheck/task/taskId/importCustomerData",
  191. queryTask: "/smsCheck/task/queryById",
  192. exportXlsUrl: "/smsCheckError/task/exportXls",
  193. },
  194. }
  195. },
  196. created() {
  197. this.task.id = this.$route.query.id;
  198. this.queryInfoById(this.task.id);
  199. },
  200. methods: {
  201. handleExportXls(fileName){
  202. if(!fileName || typeof fileName != "string"){
  203. fileName = "导出文件"
  204. }
  205. this.getQueryParams.taskId=this.task.id;
  206. let param = this.getQueryParams;
  207. if(this.selectedRowKeys && this.selectedRowKeys.length>0){
  208. param['selections'] = this.selectedRowKeys.join(",")
  209. }
  210. param['batchNo']=this.batchNo
  211. console.log("导出参数",param)
  212. downFile(this.url.exportXlsUrl,param).then((data)=>{
  213. if (!data) {
  214. this.$message.warning("文件下载失败")
  215. return
  216. }
  217. if (typeof window.navigator.msSaveBlob !== 'undefined') {
  218. window.navigator.msSaveBlob(new Blob([data],{type: 'application/vnd.ms-excel'}), fileName+'.xls')
  219. }else{
  220. let url = window.URL.createObjectURL(new Blob([data],{type: 'application/vnd.ms-excel'}))
  221. let link = document.createElement('a')
  222. link.style.display = 'none'
  223. link.href = url
  224. link.setAttribute('download', fileName+'.xls')
  225. document.body.appendChild(link)
  226. link.click()
  227. document.body.removeChild(link); //下载完成移除元素
  228. window.URL.revokeObjectURL(url); //释放掉blob对象
  229. }
  230. })
  231. },
  232. /**下载模版*/
  233. downloadTemplat(){
  234. const a = document.createElement('a')
  235. a.href = '/web/tnc/static/taskTruckModel.xlsx'
  236. //a.href = '/static/taskTruckModel.xlsx'
  237. //ttp://172.16.142.20:7766/web/tnc/smscheck/modules/web/tnc/static/taskTruckModel.xlsx
  238. a.setAttribute('download', '中继线稽核模版.xlsx')
  239. a.click();
  240. a.remove();
  241. },
  242. // 返回上一级
  243. goBack() {
  244. this.$router.go(-1);
  245. this.closeCurrent();
  246. },
  247. /**
  248. * 上传事件回调
  249. *
  250. * @param result 回调值
  251. */
  252. uploadChange(result) {
  253. let file = result.file;
  254. let event = result.event;
  255. if (event === undefined && file.status === 'uploading') {
  256. this.$message.info('开始上传');
  257. }
  258. if (event && file.status === 'uploading') {
  259. this.$message.info('上传中,请稍等……');
  260. }
  261. if (file.response) {
  262. let success = file.response.success;
  263. let message = file.response.message;
  264. if (!success) {
  265. this.$message.error(message);
  266. }
  267. if (file.status === 'done') {
  268. this.dataSource = file.response.result.data;
  269. this.errorCount = file.response.result.errorCount;
  270. if (this.errorCount > 0) {
  271. this.$message.error('导入含有错误项,请检查内容')
  272. } else {
  273. this.$message.info('上传完成');
  274. }
  275. }
  276. }
  277. },
  278. /**
  279. * 导入信息
  280. */
  281. importInfo() {
  282. if (this.dataSource.length === 0) {
  283. this.$message.error('暂无导入数据,请上传导入文件!');
  284. return;
  285. }
  286. if (this.errorCount !== 0) {
  287. this.$message.error('包含非法数据,无法导入!');
  288. return;
  289. }
  290. this.$message.info('开始导入,请稍等……');
  291. this.spinningAdd = true;
  292. let httpUrl = this.url.importData.replaceAll("taskId", this.task.id);
  293. let params = this.dataSource;
  294. let method = 'POST';
  295. let that = this;
  296. // 发送请求
  297. httpAction(httpUrl, params, method)
  298. .then((res) => {
  299. if (res.success) {
  300. that.dataSource = res.result
  301. if (res.result!==null){
  302. that.batchNo=res.result[0].batchNo
  303. }
  304. that.$message.success(res.message);
  305. that.$emit('ok');
  306. that.visible = false;
  307. } else {
  308. that.$message.warning(res.message);
  309. }
  310. this.spinningAdd = false;
  311. }).finally(() => {
  312. that.confirmLoading = false;
  313. this.spinningAdd = false;
  314. })
  315. },
  316. /**整行换色*/
  317. getRowBackGround(recordAlarm) {
  318. switch (recordAlarm.result) {//这里根据条件改变表格背景色
  319. case "0":
  320. return "table-color-error"
  321. }
  322. },
  323. getTaskState(taskState) {
  324. if (taskState === 0) {
  325. this.task.taskStateColor = '#fadb14';
  326. this.task.taskStateText = '未开始';
  327. } else if (taskState === 1) {
  328. this.task.taskStateColor = '#1890ff';
  329. this.task.taskStateText = '稽核中';
  330. } else if (taskState === 2) {
  331. this.task.taskStateColor = '#52c41a';
  332. this.task.taskStateText = '稽核完成';
  333. }
  334. },
  335. queryInfoById(id) {
  336. let url = this.url.queryTask;
  337. let params = {
  338. id: id
  339. }
  340. let that = this;
  341. getAction(url, params).then(res => {
  342. if (res.success) {
  343. that.task = res.result;
  344. that.getTaskState(that.task.taskState);
  345. }
  346. }).finally(() => {
  347. })
  348. },
  349. }
  350. }
  351. </script>
  352. <style>
  353. .table-color-error {
  354. color: rgba(255, 0, 0, 0.82);
  355. /*background-color: rgba(255, 0, 0, 0.82);*/
  356. }
  357. </style>