TaskImport.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380
  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"
  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, postAction } 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: 'customerNo'
  95. },
  96. // {
  97. // title: '客户名称',
  98. // align: "center",
  99. // dataIndex: 'customerName'
  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: 'result',
  155. customRender: function (text, record, index) {
  156. if (text == "1") {
  157. return '成功'
  158. } else if (text == "0") {
  159. return '失败'
  160. }
  161. return '';
  162. }
  163. },
  164. {
  165. title: '错误结果',
  166. align: "center",
  167. dataIndex: 'errorMsg'
  168. },
  169. ],
  170. type:'',
  171. batchNo:"",
  172. url: {
  173. importExcel: window._CONFIG['domainURL'] + "/smsCheck/task/importCustomerExcel",
  174. importData: "/smsCheck/task/taskId/importCustomerData",
  175. queryTask: "/smsCheck/task/queryById",
  176. exportXlsUrl: "/smsCheckError/task/exportXls",
  177. },
  178. }
  179. },
  180. created() {
  181. this.task.id = this.$route.query.id;
  182. this.queryInfoById(this.task.id);
  183. this.getTask(this.task.id);
  184. },
  185. methods: {
  186. getTask(id){
  187. var that = this;
  188. var data = {
  189. "id": id,
  190. }
  191. postAction('/smsTurck/customerData/query/getTaskType', data).then((res) => {
  192. if (res.success) {
  193. // Line("1", "行短稽核"),
  194. // Business("2", "物联网业务稽核"),
  195. // Reopening("3", "复开审批"),
  196. // TrunkLineAudit("4", "中继线稽核");
  197. // that.taskId=res.result.taskId;
  198. that.type=res.result.type;
  199. }
  200. })
  201. },
  202. handleExportXls(fileName){
  203. if(!fileName || typeof fileName != "string"){
  204. fileName = "导出文件"
  205. }
  206. this.getQueryParams.taskId=this.task.id;
  207. let param = this.getQueryParams;
  208. if(this.selectedRowKeys && this.selectedRowKeys.length>0){
  209. param['selections'] = this.selectedRowKeys.join(",")
  210. }
  211. param['batchNo']=this.batchNo
  212. console.log("导出参数",param)
  213. downFile(this.url.exportXlsUrl,param).then((data)=>{
  214. if (!data) {
  215. this.$message.warning("文件下载失败")
  216. return
  217. }
  218. if (typeof window.navigator.msSaveBlob !== 'undefined') {
  219. window.navigator.msSaveBlob(new Blob([data],{type: 'application/vnd.ms-excel'}), fileName+'.xls')
  220. }else{
  221. let url = window.URL.createObjectURL(new Blob([data],{type: 'application/vnd.ms-excel'}))
  222. let link = document.createElement('a')
  223. link.style.display = 'none'
  224. link.href = url
  225. link.setAttribute('download', fileName+'.xls')
  226. document.body.appendChild(link)
  227. link.click()
  228. document.body.removeChild(link); //下载完成移除元素
  229. window.URL.revokeObjectURL(url); //释放掉blob对象
  230. }
  231. })
  232. },
  233. /**下载模版*/
  234. downloadTemplat(){
  235. const a = document.createElement('a')
  236. if (this.type==='2'){
  237. a.href = '/web/tnc/static/lotExcel.xlsx'
  238. a.setAttribute('download', '物联网稽核模版.xlsx')
  239. }
  240. if (this.type==='1'){
  241. a.href = '/web/tnc/static/taskModel.xlsx'
  242. a.setAttribute('download', '行短稽核模版.xlsx')
  243. }
  244. //a.href = '/static/taskModel.xlsx'
  245. a.click();
  246. a.remove();
  247. },
  248. // 返回上一级
  249. goBack() {
  250. this.$router.go(-1);
  251. this.closeCurrent();
  252. },
  253. /**
  254. * 上传事件回调
  255. *
  256. * @param result 回调值
  257. */
  258. uploadChange(result) {
  259. let file = result.file;
  260. let event = result.event;
  261. if (event === undefined && file.status === 'uploading') {
  262. this.$message.info('开始上传');
  263. }
  264. if (event && file.status === 'uploading') {
  265. this.$message.info('上传中,请稍等……');
  266. }
  267. if (file.response) {
  268. let success = file.response.success;
  269. let message = file.response.message;
  270. if (!success) {
  271. this.$message.error(message);
  272. }
  273. if (file.status === 'done') {
  274. this.dataSource = file.response.result.data;
  275. this.errorCount = file.response.result.errorCount;
  276. if (this.errorCount > 0) {
  277. this.$message.error('导入含有错误项,请检查内容')
  278. } else {
  279. this.$message.info('上传完成');
  280. }
  281. }
  282. }
  283. },
  284. /**
  285. * 导入信息
  286. */
  287. importInfo() {
  288. if (this.dataSource.length === 0) {
  289. this.$message.error('暂无导入数据,请上传导入文件!');
  290. return;
  291. }
  292. if (this.errorCount !== 0) {
  293. this.$message.error('包含非法数据,无法导入!');
  294. return;
  295. }
  296. this.$message.info('开始导入,请稍等……');
  297. this.spinningAdd = true;
  298. let httpUrl = this.url.importData.replaceAll("taskId", this.task.id);
  299. let params = this.dataSource;
  300. let method = 'POST';
  301. let that = this;
  302. // 发送请求
  303. httpAction(httpUrl, params, method)
  304. .then((res) => {
  305. if (res.success) {
  306. that.dataSource = res.result
  307. if (res.result!==null){
  308. that.batchNo=res.result[0].batchNo
  309. }
  310. that.$message.success(res.message);
  311. that.$emit('ok');
  312. that.visible = false;
  313. } else {
  314. that.$message.warning(res.message);
  315. }
  316. this.spinningAdd = false;
  317. }).finally(() => {
  318. that.confirmLoading = false;
  319. this.spinningAdd = false;
  320. })
  321. },
  322. /**整行换色*/
  323. getRowBackGround(recordAlarm) {
  324. switch (recordAlarm.result) {//这里根据条件改变表格背景色
  325. case "0":
  326. return "table-color-error"
  327. }
  328. },
  329. getTaskState(taskState) {
  330. if (taskState === 0) {
  331. this.task.taskStateColor = '#fadb14';
  332. this.task.taskStateText = '未开始';
  333. } else if (taskState === 1) {
  334. this.task.taskStateColor = '#1890ff';
  335. this.task.taskStateText = '稽核中';
  336. } else if (taskState === 2) {
  337. this.task.taskStateColor = '#52c41a';
  338. this.task.taskStateText = '稽核完成';
  339. }
  340. },
  341. queryInfoById(id) {
  342. let url = this.url.queryTask;
  343. let params = {
  344. id: id
  345. }
  346. let that = this;
  347. getAction(url, params).then(res => {
  348. if (res.success) {
  349. that.task = res.result;
  350. that.getTaskState(that.task.taskState);
  351. }
  352. }).finally(() => {
  353. })
  354. },
  355. }
  356. }
  357. </script>
  358. <style>
  359. .table-color-error {
  360. color: rgba(255, 0, 0, 0.82);
  361. /*background-color: rgba(255, 0, 0, 0.82);*/
  362. }
  363. </style>