iconInfo-list.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421
  1. <template>
  2. <div>
  3. <el-breadcrumb separator=">">
  4. <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
  5. <el-breadcrumb-item>
  6. <a href="#">系统管理</a>
  7. </el-breadcrumb-item>
  8. <el-breadcrumb-item>
  9. <a href="/iconInfo">图标管理</a>
  10. </el-breadcrumb-item>
  11. </el-breadcrumb>
  12. <el-divider></el-divider>
  13. <!--
  14. 要resetFields起作用,必须配置:model和prop
  15. -->
  16. <el-form
  17. ref="queryForm"
  18. :model="queryModel"
  19. inline
  20. class="demo-form-inline"
  21. >
  22. <el-form-item label="图标名称" prop="iconName">
  23. <el-input
  24. type="text"
  25. size="mini"
  26. v-model="queryModel.iconName"
  27. ></el-input>
  28. </el-form-item>
  29. <el-form-item label="备注信息" prop="remark">
  30. <el-input
  31. type="text"
  32. size="mini"
  33. v-model="queryModel.remark"
  34. ></el-input>
  35. </el-form-item>
  36. <el-form-item>
  37. <el-button
  38. type="primary"
  39. size="mini"
  40. icon="ios-search"
  41. @click="changePage(1)"
  42. :loading="loading"
  43. >查询</el-button
  44. >&nbsp;
  45. <el-button
  46. type="info"
  47. size="mini"
  48. style="margin-left: 8px"
  49. @click="handleReset('queryForm')"
  50. >重置</el-button
  51. >&nbsp;
  52. </el-form-item>
  53. </el-form>
  54. <el-divider></el-divider>
  55. <el-row class="button-group">
  56. <el-button
  57. type="primary"
  58. size="small"
  59. plain
  60. icon="el-icon-circle-plus"
  61. @click="handleAdd"
  62. >新增</el-button
  63. >
  64. <el-button
  65. type="primary"
  66. size="small"
  67. plain
  68. icon="el-icon-circle-plus"
  69. :disabled="multipleSelection.length == 0"
  70. @click="handleBatchDelete"
  71. >删除选中项</el-button
  72. >
  73. </el-row>
  74. <el-table
  75. :data="tableData"
  76. style="min-height: 400px"
  77. v-loading="loading"
  78. stripe
  79. @sort-change="sortChange"
  80. @selection-change="handleSelectionChange"
  81. >
  82. <el-table-column type="selection" width="55"></el-table-column>
  83. <el-table-column
  84. prop="iconName"
  85. label="图标名称"
  86. width="130"
  87. ></el-table-column>
  88. <el-table-column
  89. prop="iconRoute"
  90. label="图标路由"
  91. show-overflow-tooltip
  92. width="220"
  93. ></el-table-column>
  94. <el-table-column
  95. prop="iconSubRoute"
  96. label="子页面路由"
  97. width="200"
  98. show-overflow-tooltip
  99. ></el-table-column>
  100. <el-table-column
  101. prop="iconUrl"
  102. label="图标url"
  103. show-overflow-tooltip
  104. width="150"
  105. ></el-table-column>
  106. <el-table-column
  107. prop="iconParam"
  108. label="参数"
  109. width="150"
  110. show-overflow-tooltip
  111. ></el-table-column>
  112. <el-table-column
  113. prop="useEnable"
  114. label="是否启用"
  115. width="120"
  116. >
  117. <template slot-scope="{ row }">
  118. <el-switch
  119. v-model="row.useEnable"
  120. active-color="#13ce66"
  121. inactive-color="#ff4949"
  122. @change="updateEnabled(row)"
  123. ></el-switch>
  124. </template>
  125. </el-table-column>
  126. <el-table-column
  127. prop="iconPic"
  128. label="图标图片"
  129. width="80"
  130. >
  131. <template slot-scope="{ row }">
  132. <a :href="row.iconPic" target="_blank">
  133. <el-avatar
  134. :size="48"
  135. shape="circle"
  136. :src="
  137. row.iconPic +
  138. '?x-oss-process=image/resize,m_fill,w_64,h_64'
  139. "
  140. :key="row.id"
  141. ></el-avatar>
  142. </a>
  143. </template>
  144. </el-table-column>
  145. <el-table-column
  146. prop="iconCommonPic"
  147. label="通用功能展示的图片"
  148. width="150"
  149. >
  150. <template slot-scope="{ row }">
  151. <a :href="row.iconCommonPic" target="_blank">
  152. <el-avatar
  153. :size="48"
  154. shape="circle"
  155. :src="
  156. row.iconCommonPic +
  157. '?x-oss-process=image/resize,m_fill,w_64,h_64'
  158. "
  159. :key="row.id"
  160. ></el-avatar>
  161. </a>
  162. </template>
  163. </el-table-column>
  164. <el-table-column
  165. prop="iconTypeName"
  166. label="图标类型"
  167. width="120"
  168. ></el-table-column>
  169. <el-table-column
  170. prop="remark"
  171. label="备注信息"
  172. width="180"
  173. show-overflow-tooltip
  174. ></el-table-column>
  175. <el-table-column label="操作" fixed="right" width="150">
  176. <template slot-scope="{ row }">
  177. <el-button size="mini" type="warning" @click="handleEdit(row)"
  178. >编辑</el-button
  179. >
  180. <el-button size="mini" type="danger" @click="handleDelete(row)"
  181. >删除</el-button
  182. >
  183. </template>
  184. </el-table-column>
  185. </el-table>
  186. <el-pagination
  187. :current-page.sync="pageIndex"
  188. :total="totalElements"
  189. :page-sizes="pageSizeList"
  190. @current-change="changePage"
  191. @size-change="pageSizeChange"
  192. layout="total, sizes, prev, pager, next, jumper"
  193. ></el-pagination>
  194. <iconInfo-detail
  195. v-if="showModal"
  196. :businessKey="businessKey"
  197. :title="modalTitle"
  198. @close="onDetailModalClose"
  199. ></iconInfo-detail>
  200. </div>
  201. </template>
  202. <script>
  203. import Constant from "@/constant";
  204. import IconInfoDetail from "./iconInfo-detail";
  205. import iconInfoApi from "@/api/base/iconInfo";
  206. import NProgress from "nprogress"; // progress bar
  207. import "nprogress/nprogress.css"; // progress bar style
  208. export default {
  209. name: "baseIconInfoList",
  210. data() {
  211. var self = this;
  212. return {
  213. queryModel: {
  214. id: "",
  215. iconName: "",
  216. iconRoute: "",
  217. iconSubRoute: "",
  218. iconUrl: "",
  219. iconParam: "",
  220. useEnable: "",
  221. iconPic: "",
  222. iconCommonPic: "",
  223. iconTypeId: "",
  224. delFlag: "",
  225. createBy: "",
  226. createTime: "",
  227. updateBy: "",
  228. updateTime: "",
  229. remark: "",
  230. },
  231. loading: false,
  232. tableData: [],
  233. pageIndex: 1,
  234. pageSize: 10,
  235. totalPages: 0,
  236. totalElements: 0,
  237. field: "",
  238. direction: "",
  239. pageSizeList: [10, 20, 30],
  240. multipleSelection: [],
  241. showModal: false,
  242. modalTitle: "",
  243. businessKey: "",
  244. };
  245. },
  246. methods: {
  247. changePage(pageIndex) {
  248. var self = this;
  249. self.loading = true;
  250. self.pageIndex = pageIndex;
  251. var formData = new FormData();
  252. formData.append("pageIndex", self.pageIndex);
  253. formData.append("pageSize", self.pageSize);
  254. formData.append("id", self.queryModel.id);
  255. formData.append("iconName", self.queryModel.iconName);
  256. formData.append("iconRoute", self.queryModel.iconRoute);
  257. formData.append("iconSubRoute", self.queryModel.iconSubRoute);
  258. formData.append("iconUrl", self.queryModel.iconUrl);
  259. formData.append("iconParam", self.queryModel.iconParam);
  260. formData.append("useEnable", self.queryModel.useEnable);
  261. formData.append("iconPic", self.queryModel.iconPic);
  262. formData.append("iconCommonPic", self.queryModel.iconCommonPic);
  263. formData.append("iconTypeId", self.queryModel.iconTypeId);
  264. formData.append("delFlag", self.queryModel.delFlag);
  265. formData.append("createBy", self.queryModel.createBy);
  266. formData.append("createTime", self.queryModel.createTime);
  267. formData.append("updateBy", self.queryModel.updateBy);
  268. formData.append("updateTime", self.queryModel.updateTime);
  269. formData.append("remark", self.queryModel.remark);
  270. if (this.field != null) {
  271. formData.append("field", this.field);
  272. }
  273. if (this.direction != null) {
  274. formData.append("direction", this.direction);
  275. }
  276. iconInfoApi
  277. .pageList(formData)
  278. .then(function (response) {
  279. self.loading = false;
  280. var jsonData = response.data.data;
  281. self.tableData = jsonData.data;
  282. self.totalPages = jsonData.totalPages;
  283. self.totalElements = jsonData.recordsTotal;
  284. })
  285. .catch((error) => {
  286. self.loading = false;
  287. // self.$message.error(error + "");
  288. });
  289. },
  290. pageSizeChange(pageSize) {
  291. this.pageSize = pageSize;
  292. this.$nextTick(() => {
  293. this.changePage(this.pageIndex);
  294. });
  295. },
  296. sortChange(data) {
  297. this.field = data.column.field;
  298. this.direction = data.order == "ascending" ? "asc" : "desc";
  299. this.changePage(this.pageIndex);
  300. },
  301. handleSelectionChange(val) {
  302. this.multipleSelection = val;
  303. },
  304. handleReset(name) {
  305. this.$refs[name].resetFields();
  306. },
  307. handleAdd() {
  308. this.modalTitle = "新增";
  309. this.businessKey = "";
  310. this.showModal = true;
  311. },
  312. handleEdit(record) {
  313. this.modalTitle = "编辑";
  314. this.businessKey = record.id;
  315. this.showModal = true;
  316. },
  317. handleDelete(record) {
  318. var self = this;
  319. self
  320. .$confirm("是否确认删除?", "提示", {
  321. confirmButtonText: "确定",
  322. cancelButtonText: "取消",
  323. type: "warning",
  324. })
  325. .then(() => {
  326. iconInfoApi.remove(record.id).then(function (response) {
  327. var jsonData = response.data;
  328. if (jsonData.result) {
  329. // var index = self.tableData.indexOf(record);
  330. // self.tableData.splice(index, 1);
  331. self.changePage(self.pageIndex);
  332. self.$message({
  333. type: "success",
  334. message: "删除成功!",
  335. });
  336. }
  337. });
  338. });
  339. },
  340. handleBatchDelete() {
  341. var self = this;
  342. var idList = this.multipleSelection.map((record) => {
  343. return record.id;
  344. });
  345. this.$confirm("是否确认删除选中项?", "提示", {
  346. confirmButtonText: "确定",
  347. cancelButtonText: "取消",
  348. type: "warning",
  349. }).then(() => {
  350. iconInfoApi.batchRemove(idList).then(function (response) {
  351. var jsonData = response.data;
  352. if (jsonData.result) {
  353. self.changePage(self.pageIndex);
  354. self.$message({
  355. type: "success",
  356. message: "删除成功!",
  357. });
  358. }
  359. });
  360. });
  361. },
  362. onDetailModalClose(refreshed) {
  363. //保存成功后回调
  364. this.showModal = false;
  365. if (refreshed) {
  366. this.changePage(this.pageIndex);
  367. }
  368. },
  369. updateEnabled(row) {
  370. iconInfoApi.update(row);
  371. },
  372. },
  373. mounted: function () {
  374. this.changePage(1);
  375. },
  376. components: {
  377. "iconInfo-detail": IconInfoDetail,
  378. },
  379. };
  380. </script>
  381. <style lang="scss" scoped>
  382. .el-breadcrumb {
  383. margin: 10px;
  384. line-height: 20px;
  385. }
  386. .el-divider {
  387. margin: 5px 0;
  388. }
  389. .demo-form-inline {
  390. margin-left: 10px;
  391. text-align: left;
  392. }
  393. .button-group {
  394. margin-left: 10px;
  395. text-align: left;
  396. }
  397. </style>