管理系统PC端
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

index.vue 22 KiB

2週間前
2週間前
2週間前
2週間前
2週間前
2週間前
2週間前
1週間前
2週間前
2週間前
2週間前
2週間前
1週間前
2週間前
1週間前
2週間前
2週間前
2週間前
2週間前
1週間前
2週間前
2週間前
1週間前
2週間前
2週間前
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538
  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="coordinateSystem">
  26. <el-select v-model="queryParams.coordinateSystem" placeholder="请选择坐标系" clearable>
  27. <el-option v-for="dict in dict.type.coordinate_system" :key="dict.value" :label="dict.label" :value="dict.value"/>
  28. </el-select>
  29. </el-form-item>
  30. <el-form-item label="任务状态" prop="taskStatus">
  31. <el-select v-model="queryParams.taskStatus" placeholder="请选择任务状态" clearable>
  32. <el-option v-for="dict in dict.type.task_status" :key="dict.value" :label="dict.label" :value="dict.value"/>
  33. </el-select>
  34. </el-form-item>
  35. <el-form-item>
  36. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  37. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  38. </el-form-item>
  39. </el-form>
  40. <el-row :gutter="10" class="mb8">
  41. <el-col :span="1.5">
  42. <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd" v-hasPermi="['business:export:add']">新增</el-button>
  43. </el-col>
  44. <!--
  45. <el-col :span="1.5">
  46. <el-button type="success" plain icon="el-icon-edit" size="mini" :disabled="single" @click="handleUpdate" v-hasPermi="['business:export:edit']">修改</el-button>
  47. </el-col>
  48. <el-col :span="1.5">
  49. <el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="multiple" @click="handleDelete" v-hasPermi="['business:export:remove']">删除</el-button>
  50. </el-col>
  51. -->
  52. <el-col :span="1.5">
  53. <el-button type="success" plain icon="el-icon-upload2" size="mini" @click="handleImport" v-hasPermi="['business:export:import']">导入</el-button>
  54. </el-col>
  55. <el-col :span="1.5">
  56. <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport" v-hasPermi="['business:export:export']">导出</el-button>
  57. </el-col>
  58. <el-col :span="1.5">
  59. <el-button type="info" plain icon="el-icon-printer" size="mini" @click="handlePrint()" v-hasPermi="['business:export:print']">打印</el-button>
  60. </el-col>
  61. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  62. </el-row>
  63. <!-- 数据列表 列属性 min-width="60" show-overflow-tooltip @selection-change="handleSelectionChange" -->
  64. <el-table v-loading="loading" :data="exportList" border>
  65. <!--<el-table-column type="selection" width="55" align="center" />-->
  66. <el-table-column label="id" align="center" prop="id" min-width="60"/>
  67. <el-table-column label="行政区划名称" align="center" prop="deptName" min-width="120"/>
  68. <el-table-column label="行政区划代码" align="center" prop="orgCode" min-width="150"/>
  69. <el-table-column label="文件格式" align="center" prop="fileType">
  70. <template slot-scope="scope">
  71. <dict-tag :options="dict.type.file_type" :value="scope.row.fileType"/>
  72. </template>
  73. </el-table-column>
  74. <el-table-column label="坐标系" align="center" prop="coordinateSystem">
  75. <template slot-scope="scope">
  76. <dict-tag :options="dict.type.coordinate_system" :value="scope.row.coordinateSystem"/>
  77. </template>
  78. </el-table-column>
  79. <el-table-column label="文件路径" align="center" prop="fileUrl" min-width="100" show-overflow-tooltip/>
  80. <el-table-column label="任务状态" align="center" prop="taskStatus">
  81. <template slot-scope="scope">
  82. <dict-tag :options="dict.type.task_status" :value="scope.row.taskStatus"/>
  83. </template>
  84. </el-table-column>
  85. <el-table-column label="操作" align="center" class-name="small-padding fixed-width" min-width="300">
  86. <template slot-scope="scope">
  87. <el-button size="mini" type="text" icon="el-icon-view" @click="handleLook(scope.row)" v-hasPermi="['business:export:query']">查看</el-button>
  88. <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)" v-hasPermi="['business:export:edit']">修改</el-button>
  89. <el-button size="mini" type="text" icon="el-icon-video-play" @click="handleDo(scope.row)" v-hasPermi="['business:export:do']" v-if="scope.row.taskStatus == '1'">执行</el-button>
  90. <el-button size="mini" type="text" icon="el-icon-download" @click="handleDown(scope.row)" v-hasPermi="['business:export:down']" v-if="scope.row.taskStatus == '3'">下载</el-button>
  91. <el-dropdown size="mini" v-hasPermi="['business:export:remove']">
  92. <el-button size="mini" type="text" icon="el-icon-d-arrow-right">更多</el-button>
  93. <el-dropdown-menu slot="dropdown" style="padding: 5px">
  94. <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)" v-hasPermi="['business:export:remove']">删除 </el-button>
  95. </el-dropdown-menu>
  96. </el-dropdown>
  97. </template>
  98. </el-table-column>
  99. </el-table>
  100. <!-- 分页插件 -->
  101. <pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList"/>
  102. </el-col>
  103. </pane>
  104. </splitpanes>
  105. </el-row>
  106. <!-- 导入EXCEL组件 -->
  107. <el-dialog :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body>
  108. <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>
  109. <i class="el-icon-upload"></i>
  110. <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
  111. <div class="el-upload__tip text-left" slot="tip">
  112. <div class="el-upload__tip" slot="tip">
  113. <el-checkbox v-model="upload.updateSupport" /> 是否更新已经存在的导出任务
  114. </div>
  115. <p style="color: red">1、仅允许导入xls、xlsx格式文件;</p>
  116. <el-link type="primary" :underline="false" style="font-size: 12px; vertical-align: baseline" @click="importTemplate">下载模板</el-link>
  117. </div>
  118. </el-upload>
  119. <div slot="footer" class="dialog-footer">
  120. <el-button type="primary" @click="submitFileForm">确 定</el-button>
  121. <el-button @click="upload.open = false">取 消</el-button>
  122. </div>
  123. </el-dialog>
  124. <!-- 查看导出任务对话框 -->
  125. <el-dialog :title="title" :visible.sync="viewOpen" width="800px" append-to-body>
  126. <el-descriptions id="printDetail" :column="descColumn" border :labelStyle="{width: `${descLabelWidth}%`}" :contentStyle="{width: `${(100 / descColumn) - descLabelWidth}%`}">
  127. <el-descriptions-item label="行政区划名称">{{ form.deptName }}</el-descriptions-item>
  128. <el-descriptions-item label="行政区划代码">{{ form.orgCode }}</el-descriptions-item>
  129. <el-descriptions-item label="文件格式">{{ form.fileType }}</el-descriptions-item>
  130. <el-descriptions-item label="坐标系">{{ form.coordinateSystem }}</el-descriptions-item>
  131. <el-descriptions-item label="文件路径">{{ form.fileUrl }}</el-descriptions-item>
  132. <el-descriptions-item label="任务状态">{{ form.taskStatus }}</el-descriptions-item>
  133. </el-descriptions>
  134. <!-- 弹框操作按钮 -->
  135. <div slot="footer" class="dialog-footer">
  136. <el-button @click="doPrint">打 印</el-button>
  137. <el-button @click="cancelDetail">关 闭</el-button>
  138. </div>
  139. </el-dialog>
  140. <!-- 添加或修改导出任务对话框 -->
  141. <el-dialog :title="title" :visible.sync="open" width="800px" append-to-body>
  142. <el-form ref="form" :model="form" :rules="rules" label-width="100px">
  143. <el-form-item label="区划名称" prop="deptName">
  144. <el-input v-model="form.deptName" placeholder="请输入行政区划名称" show-word-limit :maxlength="30" readonly/>
  145. </el-form-item>
  146. <el-form-item label="文件格式" prop="fileType">
  147. <el-select v-model="form.fileType" placeholder="请选择文件格式">
  148. <el-option v-for="dict in dict.type.file_type" :key="dict.value" :label="dict.label" :value="dict.value"></el-option>
  149. </el-select>
  150. </el-form-item>
  151. <el-form-item label="坐标系" prop="coordinateSystem">
  152. <el-select v-model="form.coordinateSystem" placeholder="请选择坐标系">
  153. <el-option v-for="dict in dict.type.coordinate_system" :key="dict.value" :label="dict.label" :value="dict.value"></el-option>
  154. </el-select>
  155. </el-form-item>
  156. </el-form>
  157. <div slot="footer" class="dialog-footer">
  158. <el-button type="primary" @click="submitForm">确 定</el-button>
  159. <el-button @click="cancel">取 消</el-button>
  160. </div>
  161. </el-dialog>
  162. </div>
  163. </template>
  164. <script>
  165. import { listExport, getExport, getExportDetail, delExport, addExport, updateExport, printExport } from "@/api/business/export"
  166. import { getToken } from "@/utils/auth"
  167. import Treeselect from "@riophae/vue-treeselect";
  168. import { Splitpanes, Pane } from "splitpanes"
  169. import "@riophae/vue-treeselect/dist/vue-treeselect.css"
  170. import "splitpanes/dist/splitpanes.css"
  171. import { deptTreeSelect } from "@/api/system/user"
  172. export default {
  173. name: "Export",
  174. dicts: ['task_status', 'file_type', 'coordinate_system'],
  175. components: { Treeselect, Splitpanes, Pane },
  176. data() {
  177. return {
  178. // 遮罩层
  179. loading: true,
  180. // 导出遮罩层
  181. exportLoading: false,
  182. // 选中数组
  183. ids: [],
  184. // 非单个禁用
  185. single: true,
  186. // 非多个禁用
  187. multiple: true,
  188. // 显示搜索条件
  189. showSearch: true,
  190. // 总条数
  191. total: 0,
  192. // 导出任务表格数据
  193. exportList: [],
  194. // 弹出层标题
  195. title: "",
  196. // 是否显示弹出层
  197. open: false,
  198. // 详情组件列数
  199. descColumn: 2,
  200. // 详情组件Label所占百分比, 最大={100 / descColumn}. 内容所占百分比={100 / descColumn - descLabelWidth}
  201. descLabelWidth: 15,
  202. // 对话框显示只读的详情
  203. viewOpen: false,
  204. // 项目路径
  205. baseRoutingUrl: process.env.VUE_APP_BASE_API,
  206. // 所有部门树选项
  207. deptOptions: undefined,
  208. // 过滤掉已禁用部门树选项
  209. enabledDeptOptions: undefined,
  210. // 筛选部门名称
  211. deptName: undefined,
  212. // 选中的部门
  213. selectDeptName: null,
  214. defaultProps: {
  215. children: "children",
  216. label: "label"
  217. },
  218. // 查询参数
  219. queryParams: {
  220. pageNum: 1,
  221. pageSize: 10,
  222. // 查询排序
  223. //orderByColumn: "id",
  224. //isAsc: "desc",
  225. // 翻译字典
  226. //toTranslateDict: "1",
  227. deptId: null,
  228. deptName: null,
  229. orgCode: null,
  230. fileType: null,
  231. coordinateSystem: null,
  232. fileUrl: null,
  233. taskStatus: null,
  234. },
  235. // 表单参数
  236. form: {},
  237. // 表单校验
  238. rules: {
  239. deptName: [
  240. { required: true, message: "行政区划名称不能为空", trigger: "blur" }
  241. ],
  242. fileType: [
  243. { required: true, message: "文件格式不能为空", trigger: "change" }
  244. ],
  245. coordinateSystem: [
  246. { required: true, message: "坐标系不能为空", trigger: "change" }
  247. ],
  248. taskStatus: [
  249. { required: true, message: "任务状态不能为空", trigger: "change" }
  250. ],
  251. },
  252. // EXCEL导入
  253. upload: {
  254. // 是否显示弹出层(用户导入)
  255. open: false,
  256. // 弹出层标题(用户导入)
  257. title: "",
  258. // 是否禁用上传
  259. isUploading: false,
  260. // 是否更新已经存在的用户数据
  261. updateSupport: 0,
  262. // 设置上传的请求头部
  263. headers: { Authorization: "Bearer " + getToken() },
  264. // 上传的地址
  265. url: process.env.VUE_APP_BASE_API + "/business/export/importData"
  266. },
  267. }
  268. },
  269. watch: {
  270. // 根据名称筛选部门树
  271. deptName(val) {
  272. this.$refs.tree.filter(val)
  273. }
  274. },
  275. created() {
  276. this.getDeptTree()
  277. this.getList()
  278. },
  279. methods: {
  280. /** 查询导出任务列表 */
  281. getList() {
  282. this.loading = true
  283. listExport(this.queryParams).then(response => {
  284. this.exportList = response.rows
  285. this.total = response.total
  286. this.loading = false
  287. })
  288. },
  289. // 取消按钮
  290. cancel() {
  291. this.open = false
  292. this.reset()
  293. },
  294. cancelDetail() {
  295. this.viewOpen = false
  296. },
  297. // 表单重置
  298. reset() {
  299. this.form = {
  300. id: null,
  301. deptId: null,
  302. deptName: null,
  303. orgCode: null,
  304. fileType: null,
  305. coordinateSystem: null,
  306. fileUrl: null,
  307. taskStatus: '1',
  308. }
  309. this.resetForm("form")
  310. },
  311. /** 搜索按钮操作 */
  312. handleQuery() {
  313. this.queryParams.pageNum = 1
  314. this.getList()
  315. },
  316. /** 重置按钮操作 */
  317. resetQuery() {
  318. this.resetForm("queryForm")
  319. this.handleQuery()
  320. },
  321. // 多选框选中数据
  322. handleSelectionChange(selection) {
  323. this.ids = selection.map(item => item.id)
  324. this.single = selection.length!==1
  325. this.multiple = !selection.length
  326. },
  327. /** 新增按钮操作 */
  328. handleAdd() {
  329. this.reset()
  330. this.form.deptId = this.queryParams.deptId;
  331. this.form.deptName = this.selectDeptName;
  332. this.open = true
  333. this.title = "添加导出任务"
  334. },
  335. /** 修改按钮操作 */
  336. handleUpdate(row) {
  337. this.reset()
  338. const id = row.id || this.ids
  339. getExport(id).then(response => {
  340. this.form = response.data
  341. this.open = true
  342. this.title = "修改导出任务"
  343. })
  344. },
  345. /** 查看按钮操作 */
  346. handleLook(row) {
  347. const id = row.id || this.ids
  348. getExportDetail(id).then(response => {
  349. this.form = response.data;
  350. this.viewOpen = true;
  351. this.title = "查看导出任务";
  352. });
  353. },
  354. /** 提交按钮 */
  355. submitForm() {
  356. this.$refs["form"].validate(valid => {
  357. if (valid) {
  358. if (this.form.id != null) {
  359. updateExport(this.form).then(response => {
  360. this.$modal.msgSuccess("修改成功")
  361. this.open = false
  362. this.getList()
  363. })
  364. } else {
  365. addExport(this.form).then(response => {
  366. this.$modal.msgSuccess("新增成功")
  367. this.open = false
  368. this.getList()
  369. })
  370. }
  371. }
  372. })
  373. },
  374. /** 删除按钮操作 */
  375. handleDelete(row) {
  376. const ids = row.id || this.ids
  377. this.$modal.confirm('是否确认删除导出任务编号为"' + ids + '"的数据项?').then(function() {
  378. return delExport(ids)
  379. }).then(() => {
  380. this.getList()
  381. this.$modal.msgSuccess("删除成功")
  382. }).catch(() => {})
  383. },
  384. /** 导出按钮操作 */
  385. handleExport() {
  386. this.download('business/export/export', {
  387. ...this.queryParams
  388. }, `导出任务_${new Date().getTime()}.xlsx`)
  389. },
  390. /** 打印表单 */
  391. doPrint() {
  392. const originalTitle = document.title;
  393. try {
  394. document.title = this.title || '打印详情';
  395. const printElement = document.getElementById('printDetail');
  396. const printFrame = document.createElement('iframe');
  397. printFrame.style.position = 'absolute';
  398. printFrame.style.width = '0';
  399. printFrame.style.height = '0';
  400. printFrame.style.border = 'none';
  401. printFrame.style.left = '-9999px';
  402. printFrame.onload = function() {
  403. try {
  404. const frameDoc = printFrame.contentDocument || printFrame.contentWindow.document;
  405. const contentClone = printElement.cloneNode(true);
  406. const style = document.createElement('style');
  407. style.innerHTML = `
  408. @page {
  409. size: auto;
  410. margin: 10mm;
  411. }
  412. body {
  413. font-family: Arial, sans-serif;
  414. line-height: 1.5;
  415. margin: 0;
  416. padding: 0;
  417. }
  418. .el-descriptions {
  419. width: 100% !important;
  420. }
  421. .el-descriptions-item__label {
  422. width: ${this.descLabelWidth}% !important;
  423. }
  424. .el-descriptions-item__content {
  425. width: ${(100 / this.descColumn) - this.descLabelWidth}% !important;
  426. }
  427. /* 确保图片在打印时显示完整 */
  428. img, .el-image {
  429. max-width: 100% !important;
  430. height: auto !important;
  431. }
  432. `;
  433. frameDoc.head.appendChild(style);
  434. frameDoc.body.appendChild(contentClone);
  435. setTimeout(() => {
  436. printFrame.contentWindow.focus();
  437. printFrame.contentWindow.print();
  438. setTimeout(() => {
  439. document.body.removeChild(printFrame);
  440. document.title = originalTitle;
  441. }, 1000);
  442. }, 500);
  443. } catch (e) {
  444. document.body.removeChild(printFrame);
  445. document.title = originalTitle;
  446. this.$message.error('打印过程中发生错误');
  447. }
  448. };
  449. document.body.appendChild(printFrame);
  450. } catch (e) {
  451. document.title = originalTitle;
  452. this.$message.error('打印过程中发生错误');
  453. }
  454. },
  455. /** 打印按钮操作 */
  456. handlePrint() {
  457. printExport(this.queryParams).then(response => {})
  458. },
  459. /* 导入EXCEL组件 */
  460. handleImport() {
  461. this.upload.title = "导出任务导入"
  462. this.upload.open = true
  463. },
  464. /** 下载模板操作 */
  465. importTemplate() {
  466. this.download('business/export/importTemplate', {
  467. }, `export_template.xlsx`)
  468. },
  469. // 文件上传中处理
  470. handleFileUploadProgress(event, file, fileList) {
  471. this.upload.isUploading = true
  472. },
  473. // 文件上传成功处理
  474. handleFileSuccess(response, file, fileList) {
  475. this.upload.open = false
  476. this.upload.isUploading = false
  477. this.$refs.upload.clearFiles()
  478. this.$alert("<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" + response.msg + "</div>", "导入结果", { dangerouslyUseHTMLString: true })
  479. this.getList()
  480. },
  481. // 提交上传文件
  482. submitFileForm() {
  483. this.$refs.upload.submit()
  484. },
  485. /** 查询部门下拉树结构 */
  486. getDeptTree() {
  487. deptTreeSelect().then(response => {
  488. this.deptOptions = response.data
  489. this.enabledDeptOptions = this.filterDisabledDept(JSON.parse(JSON.stringify(response.data)))
  490. })
  491. },
  492. // 过滤禁用的部门
  493. filterDisabledDept(deptList) {
  494. return deptList.filter(dept => {
  495. if (dept.disabled) {
  496. return false
  497. }
  498. if (dept.children && dept.children.length) {
  499. dept.children = this.filterDisabledDept(dept.children)
  500. }
  501. return true
  502. })
  503. },
  504. // 筛选节点
  505. filterNode(value, data) {
  506. if (!value) return true
  507. return data.label.indexOf(value) !== -1
  508. },
  509. // 节点单击事件
  510. handleNodeClick(data) {
  511. this.queryParams.deptId = data.id
  512. this.selectDeptName = data.label
  513. this.handleQuery()
  514. },
  515. }
  516. }
  517. </script>
  518. <style scoped type="scss">
  519. .container_main{
  520. height: 75vh;
  521. overflow-y: scroll;
  522. }
  523. </style>