管理系统PC端
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
 
 
 
 

423 líneas
17 KiB

  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
  4. <el-form-item label="区划代码" prop="xjqydm">
  5. <el-input v-model="queryParams.xjqydm" placeholder="请输入区划代码" clearable @keyup.enter.native="handleQuery"/>
  6. </el-form-item>
  7. <el-form-item label="区划名称" prop="xjqymc">
  8. <el-input v-model="queryParams.xjqymc" placeholder="请输入区划名称" clearable @keyup.enter.native="handleQuery"/>
  9. </el-form-item>
  10. <el-form-item label="级联代码" prop="importCode">
  11. <el-input v-model="queryParams.importCode" placeholder="请输入级联代码" clearable @keyup.enter.native="handleQuery"/>
  12. </el-form-item>
  13. <el-form-item>
  14. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  15. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  16. </el-form-item>
  17. </el-form>
  18. <el-row :gutter="10" class="mb8">
  19. <el-col :span="1.5">
  20. <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd" v-hasPermi="['business:xjqy:add']">新增</el-button>
  21. </el-col>
  22. <!--
  23. <el-col :span="1.5">
  24. <el-button type="success" plain icon="el-icon-edit" size="mini" :disabled="single" @click="handleUpdate" v-hasPermi="['business:xjqy:edit']">修改</el-button>
  25. </el-col>
  26. <el-col :span="1.5">
  27. <el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="multiple" @click="handleDelete" v-hasPermi="['business:xjqy:remove']">删除</el-button>
  28. </el-col>
  29. -->
  30. <el-col :span="1.5">
  31. <el-button type="success" plain icon="el-icon-upload2" size="mini" @click="handleImport" v-hasPermi="['business:xjqy:import']">导入</el-button>
  32. </el-col>
  33. <el-col :span="1.5">
  34. <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport" v-hasPermi="['business:xjqy:export']">导出</el-button>
  35. </el-col>
  36. <el-col :span="1.5">
  37. <el-button type="info" plain icon="el-icon-printer" size="mini" @click="handlePrint()" v-hasPermi="['business:xjqy:print']">打印</el-button>
  38. </el-col>
  39. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  40. </el-row>
  41. <!-- 数据列表 列属性 min-width="60" show-overflow-tooltip @selection-change="handleSelectionChange" -->
  42. <el-table v-loading="loading" :data="xjqyList" border>
  43. <!--<el-table-column type="selection" width="55" align="center" />-->
  44. <el-table-column label="区划代码" align="center" prop="xjqydm" />
  45. <el-table-column label="区划名称" align="center" prop="xjqymc" />
  46. <el-table-column label="标识码" align="center" prop="bsm" />
  47. <el-table-column label="要素代码" align="center" prop="ysdm" />
  48. <el-table-column label="级联代码" align="center" prop="importCode" />
  49. <el-table-column label="fid" align="center" prop="fid" min-width="60"/>
  50. <el-table-column label="操作" align="center" class-name="small-padding fixed-width" min-width="250">
  51. <template slot-scope="scope">
  52. <el-button size="mini" type="text" icon="el-icon-view" @click="handleLook(scope.row)" v-hasPermi="['business:xjqy:query']">查看</el-button>
  53. <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)" v-hasPermi="['business:xjqy:edit']">修改</el-button>
  54. <el-dropdown size="mini" v-hasPermi="['business:xjqy:remove']">
  55. <el-button size="mini" type="text" icon="el-icon-d-arrow-right">更多</el-button>
  56. <el-dropdown-menu slot="dropdown" style="padding: 5px">
  57. <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)" v-hasPermi="['business:xjqy:remove']">删除</el-button>
  58. </el-dropdown-menu>
  59. </el-dropdown>
  60. </template>
  61. </el-table-column>
  62. </el-table>
  63. <!-- 分页插件 -->
  64. <pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList"/>
  65. <!-- 导入EXCEL组件 -->
  66. <el-dialog :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body>
  67. <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>
  68. <i class="el-icon-upload"></i>
  69. <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
  70. <div class="el-upload__tip text-left" slot="tip">
  71. <div class="el-upload__tip" slot="tip">
  72. <el-checkbox v-model="upload.updateSupport" /> 是否更新已经存在的乡级区域
  73. </div>
  74. <p style="color: red">1、仅允许导入xls、xlsx格式文件;</p>
  75. <el-link type="primary" :underline="false" style="font-size: 12px; vertical-align: baseline" @click="importTemplate">下载模板</el-link>
  76. </div>
  77. </el-upload>
  78. <div slot="footer" class="dialog-footer">
  79. <el-button type="primary" @click="submitFileForm">确 定</el-button>
  80. <el-button @click="upload.open = false">取 消</el-button>
  81. </div>
  82. </el-dialog>
  83. <!-- 查看乡级区域对话框 -->
  84. <el-dialog :title="title" :visible.sync="viewOpen" width="800px" append-to-body>
  85. <el-descriptions id="printDetail" :column="descColumn" border :labelStyle="{width: `${descLabelWidth}%`}" :contentStyle="{width: `${(100 / descColumn) - descLabelWidth}%`}">
  86. <el-descriptions-item label="区划代码">{{ form.xjqydm }}</el-descriptions-item>
  87. <el-descriptions-item label="区划名称">{{ form.xjqymc }}</el-descriptions-item>
  88. <el-descriptions-item label="标识码">{{ form.bsm }}</el-descriptions-item>
  89. <el-descriptions-item label="要素代码">{{ form.ysdm }}</el-descriptions-item>
  90. <el-descriptions-item label="级联代码">{{ form.importCode }}</el-descriptions-item>
  91. </el-descriptions>
  92. <!-- 弹框操作按钮 -->
  93. <div slot="footer" class="dialog-footer">
  94. <el-button @click="doPrint">打 印</el-button>
  95. <el-button @click="cancelDetail">关 闭</el-button>
  96. </div>
  97. </el-dialog>
  98. <!-- 添加或修改乡级区域对话框 -->
  99. <el-dialog :title="title" :visible.sync="open" width="800px" append-to-body>
  100. <el-form ref="form" :model="form" :rules="rules" label-width="100px">
  101. <el-form-item label="区划代码" prop="xjqydm">
  102. <el-input v-model="form.xjqydm" placeholder="请输入区划代码" show-word-limit :maxlength="9"/>
  103. </el-form-item>
  104. <el-form-item label="区划名称" prop="xjqymc">
  105. <el-input v-model="form.xjqymc" placeholder="请输入区划名称" show-word-limit :maxlength="100"/>
  106. </el-form-item>
  107. <el-form-item label="标识码" prop="bsm">
  108. <el-input-number v-model="form.bsm" placeholder="请输入标识码" controls-position="right" />
  109. </el-form-item>
  110. <el-form-item label="要素代码" prop="ysdm">
  111. <el-input v-model="form.ysdm" placeholder="请输入要素代码" show-word-limit :maxlength="6"/>
  112. </el-form-item>
  113. <el-form-item label="级联代码" prop="importCode">
  114. <el-input v-model="form.importCode" placeholder="请输入级联代码" show-word-limit :maxlength="20"/>
  115. </el-form-item>
  116. </el-form>
  117. <div slot="footer" class="dialog-footer">
  118. <el-button type="primary" @click="submitForm">确 定</el-button>
  119. <el-button @click="cancel">取 消</el-button>
  120. </div>
  121. </el-dialog>
  122. </div>
  123. </template>
  124. <script>
  125. import { listXjqy, getXjqy, getXjqyDetail, delXjqy, addXjqy, updateXjqy, printXjqy } from "@/api/business/xjqy"
  126. import { getToken } from "@/utils/auth"
  127. export default {
  128. name: "Xjqy",
  129. data() {
  130. return {
  131. // 遮罩层
  132. loading: true,
  133. // 导出遮罩层
  134. exportLoading: false,
  135. // 选中数组
  136. ids: [],
  137. // 非单个禁用
  138. single: true,
  139. // 非多个禁用
  140. multiple: true,
  141. // 显示搜索条件
  142. showSearch: true,
  143. // 总条数
  144. total: 0,
  145. // 乡级区域表格数据
  146. xjqyList: [],
  147. // 弹出层标题
  148. title: "",
  149. // 是否显示弹出层
  150. open: false,
  151. // 详情组件列数
  152. descColumn: 2,
  153. // 详情组件Label所占百分比, 最大={100 / descColumn}. 内容所占百分比={100 / descColumn - descLabelWidth}
  154. descLabelWidth: 15,
  155. // 对话框显示只读的详情
  156. viewOpen: false,
  157. // 项目路径
  158. baseRoutingUrll: process.env.VUE_APP_BASE_API,
  159. // 查询参数
  160. queryParams: {
  161. pageNum: 1,
  162. pageSize: 10,
  163. // 查询排序
  164. //orderByColumn: "id",
  165. //isAsc: "desc",
  166. // 翻译字典
  167. //toTranslateDict: "1",
  168. xjqydm: null,
  169. xjqymc: null,
  170. importCode: null,
  171. },
  172. // 表单参数
  173. form: {},
  174. // 表单校验
  175. rules: {
  176. xjqydm: [
  177. { required: true, message: "区划代码不能为空", trigger: "blur" }
  178. ],
  179. xjqymc: [
  180. { required: true, message: "区划名称不能为空", trigger: "blur" }
  181. ],
  182. importCode: [
  183. { required: true, message: "级联代码不能为空", trigger: "blur" }
  184. ],
  185. },
  186. // EXCEL导入
  187. upload: {
  188. // 是否显示弹出层(用户导入)
  189. open: false,
  190. // 弹出层标题(用户导入)
  191. title: "",
  192. // 是否禁用上传
  193. isUploading: false,
  194. // 是否更新已经存在的用户数据
  195. updateSupport: 0,
  196. // 设置上传的请求头部
  197. headers: { Authorization: "Bearer " + getToken() },
  198. // 上传的地址
  199. url: process.env.VUE_APP_BASE_API + "/business/xjqy/importData"
  200. },
  201. }
  202. },
  203. created() {
  204. this.getList()
  205. },
  206. methods: {
  207. /** 查询乡级区域列表 */
  208. getList() {
  209. this.loading = true
  210. listXjqy(this.queryParams).then(response => {
  211. this.xjqyList = response.rows
  212. this.total = response.total
  213. this.loading = false
  214. })
  215. },
  216. // 取消按钮
  217. cancel() {
  218. this.open = false
  219. this.reset()
  220. },
  221. cancelDetail() {
  222. this.viewOpen = false
  223. },
  224. // 表单重置
  225. reset() {
  226. this.form = {
  227. xjqydm: null,
  228. xjqymc: null,
  229. bsm: null,
  230. ysdm: null,
  231. theGeom: null,
  232. importCode: null,
  233. fid: null
  234. }
  235. this.resetForm("form")
  236. },
  237. /** 搜索按钮操作 */
  238. handleQuery() {
  239. this.queryParams.pageNum = 1
  240. this.getList()
  241. },
  242. /** 重置按钮操作 */
  243. resetQuery() {
  244. this.resetForm("queryForm")
  245. this.handleQuery()
  246. },
  247. // 多选框选中数据
  248. handleSelectionChange(selection) {
  249. this.ids = selection.map(item => item.fid)
  250. this.single = selection.length!==1
  251. this.multiple = !selection.length
  252. },
  253. /** 新增按钮操作 */
  254. handleAdd() {
  255. this.reset()
  256. this.open = true
  257. this.title = "添加乡级区域"
  258. },
  259. /** 修改按钮操作 */
  260. handleUpdate(row) {
  261. this.reset()
  262. const fid = row.fid || this.ids
  263. getXjqy(fid).then(response => {
  264. this.form = response.data
  265. this.open = true
  266. this.title = "修改乡级区域"
  267. })
  268. },
  269. /** 查看按钮操作 */
  270. handleLook(row) {
  271. const fid = row.fid || this.ids
  272. getXjqyDetail(fid).then(response => {
  273. this.form = response.data;
  274. this.viewOpen = true;
  275. this.title = "查看乡级区域";
  276. });
  277. },
  278. /** 提交按钮 */
  279. submitForm() {
  280. this.$refs["form"].validate(valid => {
  281. if (valid) {
  282. if (this.form.fid != null) {
  283. updateXjqy(this.form).then(response => {
  284. this.$modal.msgSuccess("修改成功")
  285. this.open = false
  286. this.getList()
  287. })
  288. } else {
  289. addXjqy(this.form).then(response => {
  290. this.$modal.msgSuccess("新增成功")
  291. this.open = false
  292. this.getList()
  293. })
  294. }
  295. }
  296. })
  297. },
  298. /** 删除按钮操作 */
  299. handleDelete(row) {
  300. const fids = row.fid || this.ids
  301. this.$modal.confirm('是否确认删除乡级区域编号为"' + fids + '"的数据项?').then(function() {
  302. return delXjqy(fids)
  303. }).then(() => {
  304. this.getList()
  305. this.$modal.msgSuccess("删除成功")
  306. }).catch(() => {})
  307. },
  308. /** 导出按钮操作 */
  309. handleExport() {
  310. this.download('business/xjqy/export', {
  311. ...this.queryParams
  312. }, `乡级区域_${new Date().getTime()}.xlsx`)
  313. },
  314. /** 打印表单 */
  315. doPrint() {
  316. const originalTitle = document.title;
  317. try {
  318. document.title = this.title || '打印详情';
  319. const printElement = document.getElementById('printDetail');
  320. const printFrame = document.createElement('iframe');
  321. printFrame.style.position = 'absolute';
  322. printFrame.style.width = '0';
  323. printFrame.style.height = '0';
  324. printFrame.style.border = 'none';
  325. printFrame.style.left = '-9999px';
  326. printFrame.onload = function() {
  327. try {
  328. const frameDoc = printFrame.contentDocument || printFrame.contentWindow.document;
  329. const contentClone = printElement.cloneNode(true);
  330. const style = document.createElement('style');
  331. style.innerHTML = `
  332. @page {
  333. size: auto;
  334. margin: 10mm;
  335. }
  336. body {
  337. font-family: Arial, sans-serif;
  338. line-height: 1.5;
  339. margin: 0;
  340. padding: 0;
  341. }
  342. .el-descriptions {
  343. width: 100% !important;
  344. }
  345. .el-descriptions-item__label {
  346. width: ${this.descLabelWidth}% !important;
  347. }
  348. .el-descriptions-item__content {
  349. width: ${(100 / this.descColumn) - this.descLabelWidth}% !important;
  350. }
  351. /* 确保图片在打印时显示完整 */
  352. img, .el-image {
  353. max-width: 100% !important;
  354. height: auto !important;
  355. }
  356. `;
  357. frameDoc.head.appendChild(style);
  358. frameDoc.body.appendChild(contentClone);
  359. setTimeout(() => {
  360. printFrame.contentWindow.focus();
  361. printFrame.contentWindow.print();
  362. setTimeout(() => {
  363. document.body.removeChild(printFrame);
  364. document.title = originalTitle;
  365. }, 1000);
  366. }, 500);
  367. } catch (e) {
  368. document.body.removeChild(printFrame);
  369. document.title = originalTitle;
  370. this.$message.error('打印过程中发生错误');
  371. }
  372. };
  373. document.body.appendChild(printFrame);
  374. } catch (e) {
  375. document.title = originalTitle;
  376. this.$message.error('打印过程中发生错误');
  377. }
  378. },
  379. /** 打印按钮操作 */
  380. handlePrint() {
  381. printXjqy(this.queryParams).then(response => {})
  382. },
  383. /* 导入EXCEL组件 */
  384. handleImport() {
  385. this.upload.title = "乡级区域导入"
  386. this.upload.open = true
  387. },
  388. /** 下载模板操作 */
  389. importTemplate() {
  390. this.download('business/xjqy/importTemplate', {
  391. }, `乡级区域_template.xlsx`)
  392. },
  393. // 文件上传中处理
  394. handleFileUploadProgress(event, file, fileList) {
  395. this.upload.isUploading = true
  396. },
  397. // 文件上传成功处理
  398. handleFileSuccess(response, file, fileList) {
  399. this.upload.open = false
  400. this.upload.isUploading = false
  401. this.$refs.upload.clearFiles()
  402. this.$alert("<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" + response.msg + "</div>", "导入结果", { dangerouslyUseHTMLString: true })
  403. this.getList()
  404. },
  405. // 提交上传文件
  406. submitFileForm() {
  407. this.$refs.upload.submit()
  408. },
  409. }
  410. }
  411. </script>