管理系统PC端
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

1周前
1周前
1周前
1周前
1周前
1周前
1周前
1周前
1周前
1周前
1周前
1周前
1周前
1周前
1周前
1周前
1周前
1周前
1周前
1周前
1周前
1周前
1周前
1周前
1周前
1周前
1周前
1周前
1周前
1周前
1周前
1周前
1周前
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677
  1. <template>
  2. <div class="app-container">
  3. <el-row :gutter="20">
  4. <splitpanes :horizontal="this.$store.getters.device === 'mobile'" class="default-theme">
  5. <!--部门数据-->
  6. <pane size="16">
  7. <el-col>
  8. <div class="head-container">
  9. <el-input v-model="deptName" placeholder="请输入区划名称" clearable size="small" prefix-icon="el-icon-search" style="margin-bottom: 20px" />
  10. </div>
  11. <div class="head-container container_main">
  12. <el-tree :data="deptOptions" :props="defaultProps" :expand-on-click-node="false" :filter-node-method="filterNode" ref="tree" node-key="id" default-expand-all highlight-current @node-click="handleNodeClick" />
  13. </div>
  14. </el-col>
  15. </pane>
  16. <!--用户数据-->
  17. <pane size="84">
  18. <el-col>
  19. <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
  20. <el-form-item label="文件格式" prop="fileType">
  21. <el-select v-model="queryParams.fileType" placeholder="请选择文件格式" clearable>
  22. <el-option v-for="dict in dict.type.file_type" :key="dict.value" :label="dict.label" :value="dict.value"/>
  23. </el-select>
  24. </el-form-item>
  25. <el-form-item label="导入方式" prop="importType">
  26. <el-select v-model="queryParams.importType" placeholder="请选择导入方式" clearable>
  27. <el-option v-for="dict in dict.type.import_type" :key="dict.value" :label="dict.label" :value="dict.value"/>
  28. </el-select>
  29. </el-form-item>
  30. <el-form-item label="坐标系" prop="coordinateSystem">
  31. <el-select v-model="queryParams.coordinateSystem" placeholder="请选择坐标系" clearable>
  32. <el-option v-for="dict in dict.type.coordinate_system" :key="dict.value" :label="dict.label" :value="dict.value"/>
  33. </el-select>
  34. </el-form-item>
  35. <el-form-item label="任务状态" prop="taskStatus">
  36. <el-select v-model="queryParams.taskStatus" placeholder="请选择任务状态" clearable>
  37. <el-option v-for="dict in dict.type.task_status" :key="dict.value" :label="dict.label" :value="dict.value"/>
  38. </el-select>
  39. </el-form-item>
  40. <el-form-item>
  41. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  42. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  43. </el-form-item>
  44. </el-form>
  45. <el-row :gutter="10" class="mb8">
  46. <el-col :span="1.5">
  47. <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd" v-hasPermi="['business:import:add']">新增</el-button>
  48. </el-col>
  49. <!--
  50. <el-col :span="1.5">
  51. <el-button type="success" plain icon="el-icon-edit" size="mini" :disabled="single" @click="handleUpdate" v-hasPermi="['business:import:edit']">修改</el-button>
  52. </el-col>
  53. <el-col :span="1.5">
  54. <el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="multiple" @click="handleDelete" v-hasPermi="['business:import:remove']">删除</el-button>
  55. </el-col>
  56. <el-col :span="1.5">
  57. <el-button type="success" plain icon="el-icon-upload2" size="mini" @click="handleImport" v-hasPermi="['business:import:import']">导入</el-button>
  58. </el-col>
  59. <el-col :span="1.5">
  60. <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport" v-hasPermi="['business:import:export']">导出</el-button>
  61. </el-col>
  62. <el-col :span="1.5">
  63. <el-button type="info" plain icon="el-icon-printer" size="mini" @click="handlePrint()" v-hasPermi="['business:import:print']">打印</el-button>
  64. </el-col>
  65. -->
  66. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  67. </el-row>
  68. <!-- 数据列表 列属性 min-width="60" show-overflow-tooltip @selection-change="handleSelectionChange" -->
  69. <el-table v-loading="loading" :data="importList" border>
  70. <!--<el-table-column type="selection" width="55" align="center" />-->
  71. <el-table-column label="id" align="center" prop="id" min-width="60"/>
  72. <el-table-column label="行政区划名称" align="center" prop="deptName" min-width="120"/>
  73. <el-table-column label="行政区划代码" align="center" prop="orgCode" min-width="150"/>
  74. <el-table-column label="文件格式" align="center" prop="fileType">
  75. <template slot-scope="scope">
  76. <dict-tag :options="dict.type.file_type" :value="scope.row.fileType"/>
  77. </template>
  78. </el-table-column>
  79. <el-table-column label="导入方式" align="center" prop="importType">
  80. <template slot-scope="scope">
  81. <dict-tag :options="dict.type.import_type" :value="scope.row.importType"/>
  82. </template>
  83. </el-table-column>
  84. <el-table-column label="坐标系" align="center" prop="coordinateSystem">
  85. <template slot-scope="scope">
  86. <dict-tag :options="dict.type.coordinate_system" :value="scope.row.coordinateSystem"/>
  87. </template>
  88. </el-table-column>
  89. <!--<el-table-column label="文件路径" align="center" prop="fileUrl" min-width="300" show-overflow-tooltip/>-->
  90. <el-table-column label="文件路径" header-align="center" align="left" prop="fileUrl" >
  91. <template slot-scope="scope">
  92. <div v-if="!!scope.row.fileUrl"><el-tooltip effect="light" :content="item.substr(item.lastIndexOf('/') + 1)" placement="bottom" v-for="(item, index) in scope.row.fileUrl.split(',')" :key="index"><a :href="baseRoutingUrll + item" target="_blank" style="height: 32px; width: 32px; margin: 2px; display: inline-block; text-align: center;"><img :src="getFileIcon(item)" style="height: 100%;"/></a></el-tooltip></div>
  93. </template>
  94. </el-table-column>
  95. <el-table-column label="任务状态" align="center" prop="taskStatus">
  96. <template slot-scope="scope">
  97. <dict-tag :options="dict.type.task_status" :value="scope.row.taskStatus"/>
  98. </template>
  99. </el-table-column>
  100. <el-table-column label="操作" align="center" class-name="small-padding fixed-width" min-width="300">
  101. <template slot-scope="scope">
  102. <el-button size="mini" type="text" icon="el-icon-view" @click="handleLook(scope.row)" v-hasPermi="['business:import:query']">查看</el-button>
  103. <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)" v-hasPermi="['business:import:edit']">修改</el-button>
  104. <el-button size="mini" type="text" icon="el-icon-video-play" @click="handleDo(scope.row)" v-hasPermi="['business:import:do']" v-if="scope.row.taskStatus == '0'">执行</el-button>
  105. <el-button size="mini" type="text" icon="el-icon-tickets" @click="openLog(scope.row)" v-hasPermi="['business:import:do']">日志</el-button>
  106. <el-dropdown size="mini" v-hasPermi="['business:import:remove']">
  107. <el-button size="mini" type="text" icon="el-icon-d-arrow-right">更多</el-button>
  108. <el-dropdown-menu slot="dropdown" style="padding: 5px">
  109. <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)" v-hasPermi="['business:import:remove']">删除</el-button>
  110. </el-dropdown-menu>
  111. </el-dropdown>
  112. </template>
  113. </el-table-column>
  114. </el-table>
  115. <!-- 分页插件 -->
  116. <pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList"/>
  117. </el-col>
  118. </pane>
  119. </splitpanes>
  120. </el-row>
  121. <!-- 导入EXCEL组件 -->
  122. <el-dialog :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body>
  123. <el-upload ref="upload" :limit="1" accept=".xlsx, .xls" :headers="upload.headers" :action="upload.url + '?updateSupport=' + upload.updateSupport" :disabled="upload.isUploading" :on-progress="handleFileUploadProgress" :on-success="handleFileSuccess" :auto-upload="false" drag>
  124. <i class="el-icon-upload"></i>
  125. <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
  126. <div class="el-upload__tip text-left" slot="tip">
  127. <div class="el-upload__tip" slot="tip">
  128. <el-checkbox v-model="upload.updateSupport" /> 是否更新已经存在的导入任务
  129. </div>
  130. <p style="color: red">1、仅允许导入zip格式文件;</p>
  131. <p style="color: red">2、覆盖导入:指先将所选区划当前在库数据删除,然后按新数据包解析导入;</p>
  132. <p style="color: red">3、增量导入:指按新数据包解析并追加导入;</p>
  133. <el-link type="primary" :underline="false" style="font-size: 12px; vertical-align: baseline" @click="importTemplate">下载模板</el-link>
  134. </div>
  135. </el-upload>
  136. <div slot="footer" class="dialog-footer">
  137. <el-button type="primary" @click="submitFileForm">确 定</el-button>
  138. <el-button @click="upload.open = false">取 消</el-button>
  139. </div>
  140. </el-dialog>
  141. <!-- 查看导入任务对话框 -->
  142. <el-dialog :title="title" :visible.sync="viewOpen" width="800px" append-to-body>
  143. <el-descriptions id="printDetail" :column="descColumn" border :labelStyle="{width: `${descLabelWidth}%`}" :contentStyle="{width: `${(100 / descColumn) - descLabelWidth}%`}">
  144. <el-descriptions-item label="行政区划名称">{{ form.deptName }}</el-descriptions-item>
  145. <el-descriptions-item label="行政区划代码">{{ form.orgCode }}</el-descriptions-item>
  146. <el-descriptions-item label="文件格式">{{ form.fileType }}</el-descriptions-item>
  147. <el-descriptions-item label="导入方式">{{ form.importType }}</el-descriptions-item>
  148. <el-descriptions-item label="坐标系">{{ form.coordinateSystem }}</el-descriptions-item>
  149. <el-descriptions-item label="文件路径">{{ form.fileUrl }}</el-descriptions-item>
  150. <el-descriptions-item label="任务状态">{{ form.taskStatus }}</el-descriptions-item>
  151. </el-descriptions>
  152. <!-- 弹框操作按钮 -->
  153. <div slot="footer" class="dialog-footer">
  154. <el-button @click="doPrint">打 印</el-button>
  155. <el-button @click="cancelDetail">关 闭</el-button>
  156. </div>
  157. </el-dialog>
  158. <!-- 添加或修改导入任务对话框 -->
  159. <el-dialog :title="title" :visible.sync="open" width="800px" append-to-body>
  160. <el-form ref="form" :model="form" :rules="rules" label-width="100px">
  161. <el-form-item label="区划名称" prop="deptName">
  162. <el-input v-model="form.deptName" placeholder="请输入行政区划名称" show-word-limit :maxlength="30" readonly/>
  163. </el-form-item>
  164. <el-form-item label="文件格式" prop="fileType">
  165. <el-select v-model="form.fileType" placeholder="请选择文件格式">
  166. <el-option v-for="dict in dict.type.file_type" :key="dict.value" :label="dict.label" :value="dict.value"></el-option>
  167. </el-select>
  168. </el-form-item>
  169. <el-form-item prop="importType">
  170. <span slot="label">
  171. 导入方式
  172. <el-tooltip content="覆盖导入:指先将所选区划当前在库数据删除,然后按新数据包解析导入;增量导入:指按新数据包解析并追加导入。" placement="top">
  173. <i class="el-icon-question"></i>
  174. </el-tooltip>
  175. </span>
  176. <el-select v-model="form.importType" placeholder="请选择导入方式">
  177. <el-option v-for="dict in dict.type.import_type" :key="dict.value" :label="dict.label" :value="dict.value"></el-option>
  178. </el-select>
  179. </el-form-item>
  180. <el-form-item label="坐标系" prop="coordinateSystem">
  181. <el-select v-model="form.coordinateSystem" placeholder="请选择坐标系">
  182. <el-option v-for="dict in dict.type.coordinate_system" :key="dict.value" :label="dict.label" :value="dict.value"></el-option>
  183. </el-select>
  184. </el-form-item>
  185. <el-form-item label="文件路径" prop="fileUrl">
  186. <file-upload v-model="form.fileUrl"/>
  187. </el-form-item>
  188. </el-form>
  189. <div slot="footer" class="dialog-footer">
  190. <el-button type="primary" @click="submitForm">确 定</el-button>
  191. <el-button @click="cancel">取 消</el-button>
  192. </div>
  193. </el-dialog>
  194. <el-dialog title="任务日志" :visible.sync="log.logOpen" width="800px" append-to-body>
  195. <div v-html="log.logText">
  196. </div>
  197. <!-- 弹框操作按钮 -->
  198. <div slot="footer" class="dialog-footer">
  199. <el-button @click="downloadLog">下 载</el-button>
  200. <el-button @click="closeLog">关 闭</el-button>
  201. </div>
  202. </el-dialog>
  203. </div>
  204. </template>
  205. <script>
  206. import {
  207. listImport,
  208. getImport,
  209. getImportDetail,
  210. delImport,
  211. addImport,
  212. updateImport,
  213. printImport,
  214. startImport, importLog, downloadLog
  215. } from "@/api/business/import"
  216. import { getToken } from "@/utils/auth"
  217. import Treeselect from "@riophae/vue-treeselect";
  218. import {Pane, Splitpanes} from "splitpanes";
  219. import "@riophae/vue-treeselect/dist/vue-treeselect.css"
  220. import "splitpanes/dist/splitpanes.css"
  221. import { deptTreeSelect } from "@/api/system/user"
  222. import {save} from "@/utils";
  223. export default {
  224. name: "Import",
  225. dicts: ['task_status', 'file_type', 'coordinate_system', 'import_type'],
  226. components: { Treeselect, Splitpanes, Pane },
  227. data() {
  228. return {
  229. // 遮罩层
  230. loading: true,
  231. // 导出遮罩层
  232. exportLoading: false,
  233. // 选中数组
  234. ids: [],
  235. // 非单个禁用
  236. single: true,
  237. // 非多个禁用
  238. multiple: true,
  239. // 显示搜索条件
  240. showSearch: true,
  241. // 总条数
  242. total: 0,
  243. // 导入任务表格数据
  244. importList: [],
  245. // 弹出层标题
  246. title: "",
  247. // 是否显示弹出层
  248. open: false,
  249. // 详情组件列数
  250. descColumn: 2,
  251. // 详情组件Label所占百分比, 最大={100 / descColumn}. 内容所占百分比={100 / descColumn - descLabelWidth}
  252. descLabelWidth: 15,
  253. // 对话框显示只读的详情
  254. viewOpen: false,
  255. // 项目路径
  256. baseRoutingUrll: process.env.VUE_APP_BASE_API,
  257. // 所有部门树选项
  258. deptOptions: undefined,
  259. // 过滤掉已禁用部门树选项
  260. enabledDeptOptions: undefined,
  261. // 筛选部门名称
  262. deptName: undefined,
  263. // 选中的部门
  264. selectDeptName: null,
  265. defaultProps: {
  266. children: "children",
  267. label: "label"
  268. },
  269. // 查询参数
  270. queryParams: {
  271. pageNum: 1,
  272. pageSize: 10,
  273. // 查询排序
  274. //orderByColumn: "id",
  275. //isAsc: "desc",
  276. // 翻译字典
  277. //toTranslateDict: "1",
  278. deptId: null,
  279. deptName: null,
  280. orgCode: null,
  281. fileType: null,
  282. importType: null,
  283. coordinateSystem: null,
  284. fileUrl: null,
  285. taskStatus: null,
  286. },
  287. // 表单参数
  288. form: {},
  289. // 表单校验
  290. rules: {
  291. deptName: [
  292. { required: true, message: "行政区划名称不能为空", trigger: "blur" }
  293. ],
  294. fileType: [
  295. { required: true, message: "文件格式不能为空", trigger: "change" }
  296. ],
  297. importType: [
  298. { required: true, message: "导入方式不能为空", trigger: "change" }
  299. ],
  300. coordinateSystem: [
  301. { required: true, message: "坐标系不能为空", trigger: "change" }
  302. ],
  303. /*fileUrl: [
  304. { required: true, message: "文件路径不能为空", trigger: "blur" }
  305. ],*/
  306. taskStatus: [
  307. { required: true, message: "任务状态不能为空", trigger: "change" }
  308. ],
  309. },
  310. // EXCEL导入
  311. upload: {
  312. // 是否显示弹出层(用户导入)
  313. open: false,
  314. // 弹出层标题(用户导入)
  315. title: "",
  316. // 是否禁用上传
  317. isUploading: false,
  318. // 是否更新已经存在的用户数据
  319. updateSupport: 0,
  320. // 设置上传的请求头部
  321. headers: { Authorization: "Bearer " + getToken() },
  322. // 上传的地址
  323. url: process.env.VUE_APP_BASE_API + "/business/import/importData"
  324. },
  325. log: {
  326. taskId: null,
  327. logOpen: false,
  328. logText: '',
  329. },
  330. }
  331. },
  332. watch: {
  333. // 根据名称筛选部门树
  334. deptName(val) {
  335. this.$refs.tree.filter(val)
  336. }
  337. },
  338. created() {
  339. this.getDeptTree()
  340. this.getList()
  341. },
  342. methods: {
  343. /** 查询导入任务列表 */
  344. getList() {
  345. this.loading = true
  346. listImport(this.queryParams).then(response => {
  347. this.importList = response.rows
  348. this.total = response.total
  349. this.loading = false
  350. })
  351. },
  352. // 取消按钮
  353. cancel() {
  354. this.open = false
  355. this.reset()
  356. },
  357. cancelDetail() {
  358. this.viewOpen = false
  359. },
  360. // 表单重置
  361. reset() {
  362. this.form = {
  363. id: null,
  364. deptId: null,
  365. deptName: null,
  366. orgCode: null,
  367. fileType: '1',
  368. importType: '1',
  369. coordinateSystem: '1',
  370. fileUrl: null,
  371. taskStatus: '1',
  372. }
  373. this.resetForm("form")
  374. },
  375. /** 搜索按钮操作 */
  376. handleQuery() {
  377. this.queryParams.pageNum = 1
  378. this.getList()
  379. },
  380. /** 重置按钮操作 */
  381. resetQuery() {
  382. this.resetForm("queryForm")
  383. this.handleQuery()
  384. },
  385. // 多选框选中数据
  386. handleSelectionChange(selection) {
  387. this.ids = selection.map(item => item.id)
  388. this.single = selection.length!==1
  389. this.multiple = !selection.length
  390. },
  391. /** 新增按钮操作 */
  392. handleAdd() {
  393. if(this.selectDeptName == null || this.selectDeptName == ''){
  394. this.$modal.msgWarning("请先选择县级及以下行政区划!")
  395. return
  396. }
  397. this.reset()
  398. this.open = true
  399. this.form.deptId = this.queryParams.deptId;
  400. this.form.deptName = this.selectDeptName;
  401. this.title = "添加导入任务"
  402. },
  403. /** 修改按钮操作 */
  404. handleUpdate(row) {
  405. this.reset()
  406. const id = row.id || this.ids
  407. getImport(id).then(response => {
  408. this.form = response.data
  409. this.open = true
  410. this.title = "修改导入任务"
  411. })
  412. },
  413. /** 查看按钮操作 */
  414. handleLook(row) {
  415. const id = row.id || this.ids
  416. getImportDetail(id).then(response => {
  417. this.form = response.data;
  418. this.viewOpen = true;
  419. this.title = "查看导入任务";
  420. });
  421. },
  422. /** 提交按钮 */
  423. submitForm() {
  424. this.$refs["form"].validate(valid => {
  425. if (valid) {
  426. if (this.form.id != null) {
  427. updateImport(this.form).then(response => {
  428. this.$modal.msgSuccess("修改成功")
  429. this.open = false
  430. this.getList()
  431. })
  432. } else {
  433. addImport(this.form).then(response => {
  434. this.$modal.msgSuccess("新增成功")
  435. this.open = false
  436. this.getList()
  437. })
  438. }
  439. }
  440. })
  441. },
  442. /** 删除按钮操作 */
  443. handleDelete(row) {
  444. const ids = row.id || this.ids
  445. this.$modal.confirm('是否确认删除导入任务编号为"' + ids + '"的数据项?').then(function() {
  446. return delImport(ids)
  447. }).then(() => {
  448. this.getList()
  449. this.$modal.msgSuccess("删除成功")
  450. }).catch(() => {})
  451. },
  452. /** 导出按钮操作 */
  453. handleExport() {
  454. this.download('business/import/export', {
  455. ...this.queryParams
  456. }, `导入任务_${new Date().getTime()}.xlsx`)
  457. },
  458. /** 打印表单 */
  459. doPrint() {
  460. const originalTitle = document.title;
  461. try {
  462. document.title = this.title || '打印详情';
  463. const printElement = document.getElementById('printDetail');
  464. const printFrame = document.createElement('iframe');
  465. printFrame.style.position = 'absolute';
  466. printFrame.style.width = '0';
  467. printFrame.style.height = '0';
  468. printFrame.style.border = 'none';
  469. printFrame.style.left = '-9999px';
  470. printFrame.onload = function() {
  471. try {
  472. const frameDoc = printFrame.contentDocument || printFrame.contentWindow.document;
  473. const contentClone = printElement.cloneNode(true);
  474. const style = document.createElement('style');
  475. style.innerHTML = `
  476. @page {
  477. size: auto;
  478. margin: 10mm;
  479. }
  480. body {
  481. font-family: Arial, sans-serif;
  482. line-height: 1.5;
  483. margin: 0;
  484. padding: 0;
  485. }
  486. .el-descriptions {
  487. width: 100% !important;
  488. }
  489. .el-descriptions-item__label {
  490. width: ${this.descLabelWidth}% !important;
  491. }
  492. .el-descriptions-item__content {
  493. width: ${(100 / this.descColumn) - this.descLabelWidth}% !important;
  494. }
  495. /* 确保图片在打印时显示完整 */
  496. img, .el-image {
  497. max-width: 100% !important;
  498. height: auto !important;
  499. }
  500. `;
  501. frameDoc.head.appendChild(style);
  502. frameDoc.body.appendChild(contentClone);
  503. setTimeout(() => {
  504. printFrame.contentWindow.focus();
  505. printFrame.contentWindow.print();
  506. setTimeout(() => {
  507. document.body.removeChild(printFrame);
  508. document.title = originalTitle;
  509. }, 1000);
  510. }, 500);
  511. } catch (e) {
  512. document.body.removeChild(printFrame);
  513. document.title = originalTitle;
  514. this.$message.error('打印过程中发生错误');
  515. }
  516. };
  517. document.body.appendChild(printFrame);
  518. } catch (e) {
  519. document.title = originalTitle;
  520. this.$message.error('打印过程中发生错误');
  521. }
  522. },
  523. /** 打印按钮操作 */
  524. handlePrint() {
  525. printImport(this.queryParams).then(response => {})
  526. },
  527. /* 导入EXCEL组件 */
  528. handleImport() {
  529. this.upload.title = "导入任务导入"
  530. this.upload.open = true
  531. },
  532. /** 下载模板操作 */
  533. importTemplate() {
  534. this.download('business/import/importTemplate', {
  535. }, `import_template.xlsx`)
  536. },
  537. // 文件上传中处理
  538. handleFileUploadProgress(event, file, fileList) {
  539. this.upload.isUploading = true
  540. },
  541. // 文件上传成功处理
  542. handleFileSuccess(response, file, fileList) {
  543. this.upload.open = false
  544. this.upload.isUploading = false
  545. this.$refs.upload.clearFiles()
  546. this.$alert("<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" + response.msg + "</div>", "导入结果", { dangerouslyUseHTMLString: true })
  547. this.getList()
  548. },
  549. // 提交上传文件
  550. submitFileForm() {
  551. this.$refs.upload.submit()
  552. },
  553. getFileIcon(file) {
  554. if(!file) return '';
  555. switch(file.toLowerCase().substr(file.lastIndexOf('.') + 1)) {
  556. case 'jpg': case 'png': case 'jpeg': case 'bmp': case 'gif':
  557. return this.baseRoutingUrll + file;
  558. case 'doc': case 'docx':
  559. return require('@/assets/images/icon_word.jpg');
  560. case 'xls': case 'xlsx':
  561. return require('@/assets/images/icon_excel.jpg');
  562. case 'pdf':
  563. return require('@/assets/images/icon_pdf.jpg');
  564. case 'zip': case 'rar': case '7z': case 'bz2': case 'gz':
  565. return require('@/assets/images/icon_zip.jpg');
  566. default:
  567. return require('@/assets/images/icon_rest.jpg');
  568. }
  569. },
  570. /** 查询部门下拉树结构 */
  571. getDeptTree() {
  572. deptTreeSelect().then(response => {
  573. this.deptOptions = response.data
  574. this.enabledDeptOptions = this.filterDisabledDept(JSON.parse(JSON.stringify(response.data)))
  575. })
  576. },
  577. // 过滤禁用的部门
  578. filterDisabledDept(deptList) {
  579. return deptList.filter(dept => {
  580. if (dept.disabled) {
  581. return false
  582. }
  583. if (dept.children && dept.children.length) {
  584. dept.children = this.filterDisabledDept(dept.children)
  585. }
  586. return true
  587. })
  588. },
  589. // 筛选节点
  590. filterNode(value, data) {
  591. if (!value) return true
  592. return data.label.indexOf(value) !== -1
  593. },
  594. // 节点单击事件
  595. handleNodeClick(data) {
  596. this.queryParams.deptId = data.id
  597. this.selectDeptName = data.label
  598. this.handleQuery()
  599. },
  600. /** 开始 */
  601. handleDo(row) {
  602. const ids = row.id || this.ids
  603. this.$modal.confirm('是否确认开始编号为"' + ids + '"的导入任务?').then(function() {
  604. return startImport(ids)
  605. }).then((resp) => {
  606. this.getList()
  607. this.$modal.msgSuccess(resp.data == 2 ? '正在执行' : '已加入队列, 等待执行')
  608. }).catch(() => {})
  609. },
  610. /** 日志 */
  611. handleLog(row, offset = 0) {
  612. if(!this.log.logOpen)
  613. return;
  614. importLog(row.id, offset).then(({data}) => {
  615. if(null == data.text)
  616. {
  617. this.log.logText = '';
  618. return;
  619. }
  620. this.log.logText += data.text
  621. .replaceAll('<', '&lt;')
  622. .replaceAll('>', '&gt;')
  623. .replaceAll('\r\n', '<br/>')
  624. .replaceAll('\r', '<br/>')
  625. .replaceAll('\n', '<br/>')
  626. ;
  627. if(!data.eof && this.log.logOpen && (data.taskStatus === '1' || data.taskStatus === '2'))
  628. {
  629. setTimeout(() => {
  630. this.handleLog(row, data.length);
  631. }, data.nextPollDelay > 0 ? data.nextPollDelay : 2000);
  632. }
  633. });
  634. },
  635. /** 日志 */
  636. downloadLog() {
  637. if(!this.log.taskId)
  638. return;
  639. downloadLog(this.log.taskId).then((resp) => {
  640. this.$message.success('开始下载......');
  641. save(`导入任务_${this.log.taskId}.log`, resp);
  642. });
  643. },
  644. openLog(row) {
  645. this.log.logText = '';
  646. this.log.logOpen = true;
  647. this.log.taskId = row.id;
  648. this.handleLog(row);
  649. },
  650. closeLog() {
  651. this.log.logOpen = false;
  652. this.log.taskId = null;
  653. this.log.logText = '';
  654. },
  655. }
  656. }
  657. </script>
  658. <style scoped type="scss">
  659. .container_main{
  660. height: 75vh;
  661. overflow-y: scroll;
  662. }
  663. </style>