index.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329
  1. <template>
  2. <div class="m-container">
  3. <h2>
  4. <div class="squrt"></div>
  5. 操作手册管理
  6. </h2>
  7. <div class="m-core">
  8. <save-form
  9. :inline="true"
  10. :model="searchForm"
  11. @submit="search"
  12. @reset="onReSet"
  13. >
  14. <el-form-item prop="search">
  15. <el-input
  16. v-model.trim="searchForm.search"
  17. clearable
  18. @keyup.enter.native="search"
  19. placeholder="请输入手册名称"
  20. ></el-input>
  21. </el-form-item>
  22. <!-- search -->
  23. <el-form-item prop="menuId">
  24. <el-cascader
  25. ref="myCascader"
  26. class="myCascader"
  27. popper-class="myCascader"
  28. @change="changeCategor"
  29. :show-all-levels="false"
  30. clearable
  31. v-model="searchForm.menuId"
  32. style="width: 100%"
  33. :options="silderList"
  34. :props="optionProps"
  35. placeholder="请选择菜单"
  36. ></el-cascader>
  37. </el-form-item>
  38. <el-form-item>
  39. <el-button native-type="submit" type="primary">搜索</el-button>
  40. <el-button native-type="reset" type="danger">重置</el-button>
  41. </el-form-item>
  42. </save-form>
  43. <auth auths="sysManual/add">
  44. <el-button type="primary" style="margin-bottom: 20px" @click="addManual"
  45. >添加</el-button
  46. >
  47. </auth>
  48. <div class="tableWrap">
  49. <el-table
  50. style="width: 100%"
  51. :header-cell-style="{ background: '#EDEEF0', color: '#444' }"
  52. :data="tableList"
  53. >
  54. <el-table-column
  55. align="center"
  56. prop="menuName"
  57. label="菜单名"
  58. ></el-table-column>
  59. <el-table-column
  60. align="center"
  61. prop="name"
  62. label="手册名称"
  63. ></el-table-column>
  64. <el-table-column
  65. align="center"
  66. prop="updateTime"
  67. label="修改时间"
  68. ></el-table-column>
  69. <el-table-column
  70. align="center"
  71. prop="operatorName"
  72. label="修改人"
  73. ></el-table-column>
  74. <el-table-column align="center" prop="studentId" label="操作">
  75. <template slot-scope="scope">
  76. <div>
  77. <auth auths="sysManual/update">
  78. <el-button type="text" @click="resetManual(scope.row)"
  79. >修改</el-button
  80. >
  81. </auth>
  82. <auth auths="sysManual/remove">
  83. <el-button type="text" @click="deteleManual(scope.row)"
  84. >删除</el-button
  85. >
  86. </auth>
  87. </div>
  88. </template>
  89. </el-table-column>
  90. </el-table>
  91. <pagination
  92. sync
  93. :total.sync="rules.total"
  94. :page.sync="rules.page"
  95. :limit.sync="rules.limit"
  96. :page-sizes="rules.page_size"
  97. @pagination="getList"
  98. />
  99. </div>
  100. </div>
  101. <el-dialog
  102. :title="operationStatus == 'create' ? '新增操作手册' : '修改操作手册'"
  103. width="800px"
  104. :visible.sync="operationVisible"
  105. v-if="operationVisible"
  106. >
  107. <setForm
  108. :silderList="silderList"
  109. :form="form"
  110. ref="setForm"
  111. @getList="getList"
  112. @close="operationVisible = false"
  113. />
  114. <span slot="footer" class="dialog-footer">
  115. <el-button @click="operationVisible = false">取 消</el-button>
  116. <el-button type="primary" @click="submitOperation">确 定</el-button>
  117. </span>
  118. </el-dialog>
  119. </div>
  120. </template>
  121. <script>
  122. import axios from "axios";
  123. import { getToken } from "@/utils/auth";
  124. import pagination from "@/components/Pagination/index";
  125. import load from "@/utils/loading";
  126. import { getSilder } from "@/api/silder";
  127. import {
  128. getSysManualList,
  129. addSysManual,
  130. resetSysManual,
  131. deteltSysManual,
  132. } from "./api";
  133. import setForm from "./modals/manualSet";
  134. export default {
  135. components: { pagination, setForm },
  136. data() {
  137. return {
  138. searchForm: {
  139. menuId: [],
  140. search:''
  141. },
  142. operationStatus: "create",
  143. form: {
  144. funRule: "",
  145. menuId: "",
  146. name: "",
  147. opFlow: "",
  148. },
  149. tableList: [],
  150. organList: [],
  151. silderList: [],
  152. rules: {
  153. // 分页规则
  154. limit: 10, // 限制显示条数
  155. page: 1, // 当前页
  156. total: 0, // 总条数
  157. page_size: [10, 20, 40, 50], // 选择限制显示条数
  158. },
  159. optionProps: {
  160. value: "id",
  161. label: "name",
  162. children: "children",
  163. checkStrictly: true,
  164. expandTrigger: "hover",
  165. },
  166. operationVisible: false,
  167. };
  168. },
  169. //生命周期 - 创建完成(可以访问当前this实例)
  170. created() {},
  171. //生命周期 - 挂载完成(可以访问DOM元素)
  172. mounted() {
  173. // 获取分部
  174. this.init();
  175. },
  176. methods: {
  177. init() {
  178. getSilder({ hid: 0 }).then((res) => {
  179. if (res.code == 200) {
  180. this.silderList = this.setTableData(res.data);
  181. }
  182. });
  183. this.getList();
  184. },
  185. async getList() {
  186. try {
  187. const res = await getSysManualList({
  188. menuId: this.searchForm.menuId[this.searchForm.menuId.length - 1],
  189. search: this.searchForm.search,
  190. page: this.rules.page,
  191. rows: this.rules.limit,
  192. });
  193. this.tableList = res.data.rows;
  194. this.rules.total = res.data.total;
  195. } catch (e) {
  196. console.log(e);
  197. }
  198. },
  199. search() {
  200. this.rules.page = 1;
  201. this.getList();
  202. },
  203. onReSet() {
  204. this.$nextTick(() => {
  205. this.search();
  206. });
  207. },
  208. setTableData(result) {
  209. let list = [];
  210. for (let i in result) {
  211. if (result[i].type == 1) {
  212. continue;
  213. }
  214. let tempList = {};
  215. tempList = {
  216. id: result[i].id,
  217. name: result[i].name,
  218. type: result[i].type,
  219. path: result[i].path,
  220. permission: result[i].permission,
  221. icon: result[i].icon,
  222. parentId: result[i].parentId,
  223. component: result[i].component,
  224. sort: result[i].sort,
  225. hid: result[i].hid,
  226. icon: result[i].icon,
  227. type: result[i].type,
  228. keepAlive: result[i].keepAlive,
  229. parentPermission: result[i].parentPermission,
  230. memo: result[i].memo,
  231. };
  232. let flag = false;
  233. if (result[i].sysMenus && result[i].sysMenus.length > 0) {
  234. for (let j in result[i].sysMenus) {
  235. if (result[i].sysMenus[j].type == 0) {
  236. flag = true;
  237. break;
  238. }
  239. }
  240. if (flag) {
  241. tempList.children = this.setTableData(result[i].sysMenus);
  242. }
  243. }
  244. list.push(tempList);
  245. }
  246. return list;
  247. },
  248. changeCategor(e) {
  249. this.$refs.myCascader.dropDownVisible = false;
  250. },
  251. resetManual(row) {
  252. this.form = { ...row };
  253. this.operationStatus = "reset";
  254. this.operationVisible = true;
  255. },
  256. deteleManual(row) {
  257. this.$confirm(`您确定删除${row.name}`, "提示", {
  258. confirmButtonText: "确定",
  259. cancelButtonText: "取消",
  260. type: "warning",
  261. }).then(async () => {
  262. try {
  263. const res = await deteltSysManual({ id: row.id });
  264. this.$message.success("删除成功");
  265. this.getList();
  266. } catch (e) {
  267. console.log(e);
  268. }
  269. });
  270. },
  271. addManual() {
  272. this.operationStatus = "create";
  273. this.form = {
  274. funRule: "",
  275. menuId: "",
  276. name: "",
  277. opFlow: "",
  278. };
  279. this.operationVisible = true;
  280. },
  281. async submitOperation() {
  282. try {
  283. let { menuId, ...result } = this.form;
  284. if (this.operationStatus == "create") {
  285. const res = await addSysManual({
  286. ...result,
  287. menuId: menuId[menuId.length - 1],
  288. });
  289. this.$message.success("添加成功");
  290. this.operationVisible = false;
  291. this.getList();
  292. } else {
  293. const res = await resetSysManual({
  294. ...result,
  295. menuId: Array.isArray(menuId) ? menuId[menuId.length - 1] : menuId,
  296. });
  297. this.$message.success("修改成功");
  298. this.operationVisible = false;
  299. this.getList();
  300. }
  301. } catch (e) {
  302. console.log(e);
  303. }
  304. // console.log(this.form);
  305. },
  306. },
  307. };
  308. </script>
  309. <style lang='scss'>
  310. .myCascader {
  311. .el-radio {
  312. width: 100%;
  313. height: 100%;
  314. z-index: 10;
  315. position: absolute;
  316. top: 10px;
  317. right: 10px;
  318. }
  319. .el-radio__input {
  320. visibility: hidden;
  321. }
  322. .el-cascader-node__postfix {
  323. top: 10px;
  324. }
  325. }
  326. </style>