sys_prop_list.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496
  1. <template>
  2. <section class="content">
  3. <div
  4. v-loading.fullscreen="loading"
  5. class="box-body"
  6. element-loading-text="请稍后..."
  7. >
  8. <el-form ref="primaryForm" :inline="true" :model="formSearch">
  9. <el-row>
  10. <el-form-item label="名称">
  11. <el-input
  12. v-model="formSearch.propKey"
  13. class="input_width_lg"
  14. placeholder="请输入参数名称"
  15. />
  16. </el-form-item>
  17. <el-form-item label="描述">
  18. <el-input
  19. v-model="formSearch.description"
  20. class="input_width_lg"
  21. placeholder="请输入参数描述"
  22. />
  23. </el-form-item>
  24. <!-- <el-form-item label="类型">
  25. <el-select
  26. class="input"
  27. :remote-method="getBasicDataTypes"
  28. @focus="e => getBasicDataTypes(e.target.value)"
  29. :loading="basicDataTypeLoading"
  30. remote
  31. filterable
  32. clearable
  33. v-model="formSearch.basicDataTypeCode"
  34. placeholder="请选择参数类型"
  35. >
  36. <el-option
  37. v-for="item in basicDataTypeList4Search"
  38. :label="item.name"
  39. :value="item.code"
  40. :key="item.code"
  41. />
  42. </el-select>
  43. </el-form-item>-->
  44. <el-form-item label="参数值">
  45. <el-input
  46. v-model="formSearch.propValue"
  47. class="input_width_lg"
  48. placeholder="请输入参数值"
  49. />
  50. </el-form-item>
  51. <el-form-item>
  52. <el-button
  53. size="small"
  54. type="primary"
  55. icon="el-icon-search"
  56. @click="handleSearchBtn"
  57. >查询</el-button
  58. >
  59. <el-button
  60. size="small"
  61. icon="el-icon-refresh"
  62. @click="resetPrimaryForm"
  63. >重置</el-button
  64. >
  65. <el-button
  66. size="small"
  67. type="primary"
  68. icon="el-icon-plus"
  69. @click="insert"
  70. >新增</el-button
  71. >
  72. </el-form-item>
  73. </el-row>
  74. </el-form>
  75. <div class="block-seperator"></div>
  76. <span>操作:</span>
  77. <el-button
  78. size="small"
  79. type="danger"
  80. :disabled="noBatchSelected"
  81. icon="el-icon-delete"
  82. @click="deleteIds"
  83. >删除</el-button
  84. >
  85. <div style="width: 100%; margin-bottom: 10px"></div>
  86. <!-- 新增或修改弹出框 -->
  87. <el-dialog
  88. title="参数信息"
  89. width="700px"
  90. :visible.sync="sysPropDialog"
  91. :close-on-click-modal="false"
  92. @close="dialogBeforeClose"
  93. >
  94. <el-form
  95. ref="sysPropForm"
  96. :inline="true"
  97. inline-message
  98. :model="sysPropForm"
  99. :rules="rules"
  100. label-position="right"
  101. label-width="90px"
  102. >
  103. <el-form-item label="名称" prop="propKey">
  104. <el-input
  105. v-model="sysPropForm.propKey"
  106. :disabled="'modify' == operateType"
  107. class="pull_length"
  108. auto-complete="off"
  109. placeholder="请输入参数名称"
  110. maxlength="100"
  111. />
  112. </el-form-item>
  113. <el-form-item label="类型" prop="propValueType">
  114. <el-select
  115. v-model="sysPropForm.propValueType"
  116. :disabled="'modify' == operateType"
  117. class="pull_length"
  118. :remote-method="getBasicDataTypes"
  119. :loading="basicDataTypeLoading"
  120. remote
  121. filterable
  122. clearable
  123. placeholder="请选择参数类型"
  124. @focus="(e) => getBasicDataTypes(e.target.value)"
  125. >
  126. <el-option
  127. v-for="item in basicDataTypeList4Search"
  128. :key="item.code"
  129. :label="item.name"
  130. :value="item.code"
  131. />
  132. </el-select>
  133. </el-form-item>
  134. <el-form-item label="参数值" prop="propValue">
  135. <el-input
  136. v-model="sysPropForm.propValue"
  137. class="pull_length text_area"
  138. type="textarea"
  139. auto-complete="off"
  140. placeholder="请输入参数值"
  141. maxlength="1000"
  142. />
  143. </el-form-item>
  144. <el-form-item label="描述" prop="description">
  145. <el-input
  146. v-model="sysPropForm.description"
  147. type="textarea"
  148. class="pull_length text_area"
  149. auto-complete="off"
  150. placeholder="请输入参数描述"
  151. maxlength="1000"
  152. />
  153. </el-form-item>
  154. <el-row class="pull_center">
  155. <el-button type="primary" @click="submitForm('sysPropForm')"
  156. >保 存</el-button
  157. >
  158. <el-button @click="close">取 消</el-button>
  159. </el-row>
  160. </el-form>
  161. </el-dialog>
  162. <!-- 页面列表 -->
  163. <el-table
  164. :data="tableData"
  165. border
  166. @selection-change="handleSelectionChange"
  167. >
  168. <el-table-column type="selection" width="40"></el-table-column>
  169. <el-table-column prop="propKey" label="名称"></el-table-column>
  170. <el-table-column
  171. prop="propValueType"
  172. label="类型"
  173. width="100"
  174. ></el-table-column>
  175. <el-table-column prop="propValue" label="参数值"></el-table-column>
  176. <el-table-column prop="description" label="描述"></el-table-column>
  177. <el-table-column
  178. sortable
  179. prop="updateTime"
  180. label="更新时间"
  181. width="170"
  182. ></el-table-column>
  183. <el-table-column label="操作" width="200">
  184. <template slot-scope="scope">
  185. <div>
  186. <el-button
  187. size="mini"
  188. type="primary"
  189. icon="el-icon-edit"
  190. plain
  191. @click="edit(scope.row)"
  192. >编辑</el-button
  193. >
  194. <el-button
  195. size="mini"
  196. type="danger"
  197. icon="el-icon-delete"
  198. @click="deleteId(scope.row)"
  199. >删除</el-button
  200. >
  201. </div>
  202. </template>
  203. </el-table-column>
  204. </el-table>
  205. <div class="page pull-right">
  206. <el-pagination
  207. :current-page="currentPage"
  208. :page-size="pageSize"
  209. :page-sizes="[10, 20, 50, 100, 200, 300]"
  210. layout="total, sizes, prev, pager, next, jumper"
  211. :total="total"
  212. @current-change="handleCurrentChange"
  213. @size-change="handleSizeChange"
  214. />
  215. </div>
  216. </div>
  217. </section>
  218. </template>
  219. <script>
  220. import { CORE_API } from "@/constants/constants.js";
  221. import { mapState } from "vuex";
  222. import { BASIC_DATA_TYPE } from "@/constants/constants.js";
  223. export default {
  224. name: "SysPropList",
  225. data() {
  226. return {
  227. courseLoading: false,
  228. formSearch: {
  229. propKey: "",
  230. propValueType: "",
  231. propValue: "",
  232. description: "",
  233. },
  234. sysPropForm: {
  235. propKey: "",
  236. propValueType: "",
  237. propValue: "",
  238. description: "",
  239. },
  240. sysPropDialog: false,
  241. loading: false,
  242. basicDataTypeLoading: false,
  243. operateType: "add",
  244. tableData: [],
  245. currentPage: 1,
  246. pageSize: 10,
  247. total: 10,
  248. basicDataTypeList4Search: [],
  249. multipleSelection: [],
  250. rules: {
  251. propKey: [
  252. { required: true, message: "请输入参数名称", trigger: "blur" },
  253. ],
  254. propValueType: [
  255. { required: true, message: "请选择参数类型", trigger: "change" },
  256. ],
  257. propValue: [
  258. { required: true, message: "请输入参数值", trigger: "blur" },
  259. ],
  260. description: [
  261. { required: true, message: "请输入参数描述", trigger: "blur" },
  262. ],
  263. },
  264. };
  265. },
  266. computed: {
  267. ...mapState({
  268. user: (state) => state.user,
  269. }),
  270. noBatchSelected() {
  271. return this.multipleSelection.length === 0;
  272. },
  273. },
  274. //初始化查询
  275. created() {
  276. this.searchForm();
  277. },
  278. methods: {
  279. dialogBeforeClose() {
  280. this.$refs.sysPropForm.clearValidate();
  281. },
  282. handleSizeChange(val) {
  283. this.pageSize = val;
  284. this.searchForm();
  285. },
  286. resetPrimaryForm() {
  287. this.formSearch = {
  288. propKey: "",
  289. propValueType: "",
  290. propValue: "",
  291. description: "",
  292. };
  293. this.$refs.primaryForm.resetFields();
  294. },
  295. getBasicDataTypes() {
  296. this.basicDataTypeLoading = true;
  297. this.basicDataTypeList4Search = BASIC_DATA_TYPE;
  298. this.basicDataTypeLoading = false;
  299. // this.$httpWithMsg
  300. // .get(CORE_API + "/systemProperty/getBasicDataTypes?name=" + query)
  301. // .then(response => {
  302. // this.basicDataTypeList4Search = response.data;
  303. // this.basicDataTypeLoading = false;
  304. // });
  305. },
  306. handleSearchBtn() {
  307. this.currentPage = 1;
  308. this.searchForm();
  309. },
  310. //查询
  311. searchForm() {
  312. let searchLock = true;
  313. setTimeout(() => {
  314. if (searchLock) {
  315. this.loading = true;
  316. }
  317. }, 500);
  318. var param = new URLSearchParams(this.formSearch);
  319. var url =
  320. CORE_API +
  321. "/systemProperty/page/" +
  322. (this.currentPage - 1) +
  323. "/" +
  324. this.pageSize +
  325. "?" +
  326. param;
  327. this.$httpWithMsg
  328. .get(url)
  329. .then((response) => {
  330. // console.log("response :", response);
  331. this.tableData = response.data.content;
  332. this.total = response.data.totalElements;
  333. })
  334. .finally(() => {
  335. searchLock = false;
  336. this.loading = false;
  337. });
  338. },
  339. handleCurrentChange(val) {
  340. this.currentPage = val;
  341. this.searchForm();
  342. },
  343. handleCourseCurrentChange(val) {
  344. this.currentCoursePage = val;
  345. this.searchCoursePage();
  346. },
  347. //全选
  348. handleSelectionChange(val) {
  349. this.multipleSelection = val;
  350. },
  351. //保存
  352. submitForm(formData) {
  353. this.$refs[formData].validate((valid) => {
  354. if (valid) {
  355. var url = CORE_API + "/systemProperty";
  356. //修改
  357. if ("modify" == this.operateType) {
  358. this.$httpWithMsg.put(url, this.sysPropForm).then(
  359. () => {
  360. this.$notify({
  361. type: "success",
  362. message: "修改成功!",
  363. });
  364. this.searchForm();
  365. this.sysPropDialog = false;
  366. },
  367. () => {
  368. this.searchForm();
  369. this.sysPropDialog = false;
  370. }
  371. );
  372. }
  373. //新增
  374. else {
  375. this.$httpWithMsg.post(url, this.sysPropForm).then(
  376. () => {
  377. this.$notify({
  378. type: "success",
  379. message: "新增成功!",
  380. });
  381. this.sysPropDialog = false;
  382. this.searchForm();
  383. },
  384. () => {
  385. this.sysPropDialog = false;
  386. return this.searchForm();
  387. }
  388. );
  389. }
  390. } else {
  391. console.log("error submit!");
  392. return false;
  393. }
  394. });
  395. },
  396. //重置
  397. resetForm(formData) {
  398. this.$refs[formData].resetFields();
  399. },
  400. close() {
  401. this.sysPropDialog = false;
  402. },
  403. //新增
  404. insert() {
  405. this.operateType = "add";
  406. this.sysPropForm.propKey = "";
  407. this.sysPropForm.propValueType = "";
  408. this.sysPropForm.propValue = "";
  409. this.sysPropForm.description = "";
  410. this.sysPropDialog = true;
  411. },
  412. //修改
  413. edit(row) {
  414. this.operateType = "modify";
  415. this.sysPropForm = Object.assign({}, row);
  416. this.sysPropDialog = true;
  417. },
  418. //删除
  419. deleteId(row) {
  420. this.$confirm("是否删除该条配置信息?", "提示", {
  421. confirmButtonText: "确定",
  422. cancelButtonText: "取消",
  423. type: "error",
  424. }).then(() => {
  425. var url = CORE_API + "/systemProperty/" + row.propKey;
  426. this.$httpWithMsg.delete(url).then(() => {
  427. this.$notify({
  428. type: "success",
  429. message: "删除成功!",
  430. });
  431. this.searchForm();
  432. });
  433. });
  434. },
  435. //删除多条信息
  436. deleteIds() {
  437. if (this.multipleSelection.length === 0) {
  438. this.$notify({
  439. type: "warning",
  440. message: "请选择要删除的配置",
  441. });
  442. } else {
  443. this.$confirm("是否删除这些配置信息?", "提示", {
  444. confirmButtonText: "确定",
  445. cancelButtonText: "取消",
  446. type: "error",
  447. }).then(() => {
  448. var ids = [];
  449. for (var i = 0; i < this.multipleSelection.length; i++) {
  450. ids.push(this.multipleSelection[i].propKey);
  451. }
  452. var url = CORE_API + "/systemProperty/" + ids;
  453. this.$httpWithMsg.delete(url).then(() => {
  454. this.$notify({
  455. type: "success",
  456. message: "删除成功!",
  457. });
  458. this.searchForm();
  459. });
  460. });
  461. }
  462. },
  463. },
  464. };
  465. </script>
  466. <style scoped>
  467. .page {
  468. margin-top: 10px;
  469. }
  470. .input_width_lg {
  471. width: 180px;
  472. }
  473. .pull_center {
  474. text-align: center;
  475. }
  476. .pull_length {
  477. width: 400px;
  478. }
  479. .text_area {
  480. margin-bottom: 10px;
  481. }
  482. </style>