管理系统PC端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

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