cate-edit.php 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. <?php
  2. /**
  3. * @link:http://www.gdqijianshi.com/
  4. * @copyright: Copyright (c) 2020 广东七件事集团
  5. * Created by PhpStorm
  6. * Author: lun
  7. * Date: 2021-09-02
  8. * Time: 12:36
  9. */
  10. ?>
  11. <div id="app" v-cloak>
  12. <el-card v-loading="loading" style="border:0;min-width: 1200px;" shadow="never" body-style="background-color: #f3f3f3;padding: 0 0;">
  13. <el-form :model="ruleForm"
  14. ref="ruleForm"
  15. label-width="172px"
  16. style="position: relative"
  17. size="small">
  18. <el-card shadow="never" class="mt-24">
  19. <div slot="header">
  20. <span>链接分类编辑</span>
  21. </div>
  22. <el-form-item label="父级类别">
  23. <el-cascader
  24. expand-trigger="hover"
  25. v-model="ruleForm.pid"
  26. :options="options"
  27. :props="{ checkStrictly: true }"
  28. clearable
  29. :show-all-levels="false"
  30. @change="handleChange">
  31. </el-cascader>
  32. </el-form-item>
  33. <el-form-item label="name">
  34. <el-col :span="12">
  35. <el-input type="text" v-model="ruleForm.name"></el-input>
  36. </el-col>
  37. </el-form-item>
  38. <el-form-item label="标题">
  39. <el-col :span="12">
  40. <el-input type="text" v-model="ruleForm.title"></el-input>
  41. </el-col>
  42. </el-form-item>
  43. <el-form-item label="是否是列表数据">
  44. <el-col :span="12">
  45. <el-radio v-model="ruleForm.is_list" :label="0">否</el-radio>
  46. <el-radio v-model="ruleForm.is_list" :label="1">是</el-radio>
  47. </el-col>
  48. </el-form-item>
  49. <el-form-item label="备注">
  50. <el-col :span="12">
  51. <el-input type="text" v-model="ruleForm.remark"></el-input>
  52. </el-col>
  53. </el-form-item>
  54. <el-form-item>
  55. <el-col :span="12">
  56. <el-button :loading="submitLoading" size="small" type="primary"
  57. @click="submit('ruleForm')">保存
  58. </el-button>
  59. </el-col>
  60. </el-form-item>
  61. </el-card>
  62. </el-form>
  63. </el-card>
  64. </div>
  65. <script>
  66. const app = new Vue({
  67. el: '#app',
  68. data() {
  69. return {
  70. loading: false,
  71. submitLoading: false,
  72. ruleForm: {
  73. pid: 0,
  74. name: '',
  75. title: '',
  76. is_list: 0,
  77. },
  78. options:[],
  79. };
  80. },
  81. created() {
  82. this.loadData();
  83. },
  84. methods: {
  85. loadData() {
  86. this.loading = true;
  87. request({
  88. params: {
  89. r: 'admin/link/cate-edit',
  90. id: getQuery('id')
  91. },
  92. method: 'get',
  93. }).then(e => {
  94. this.loading = false;
  95. if (e.data.code === 0) {
  96. if (JSON.stringify(e.data.data.detail) != "[]") {
  97. this.ruleForm = e.data.data.detail;
  98. }
  99. this.options = e.data.data.menu;
  100. } else {
  101. this.$message.error(e.data.msg);
  102. }
  103. }).catch(e => {
  104. });
  105. },
  106. handleChange(val) {
  107. this.ruleForm.pid = val[val.length-1];
  108. },
  109. submit(formName) {
  110. this.submitLoading = true;
  111. request({
  112. params: {
  113. r: 'admin/link/cate-edit',
  114. },
  115. method: 'post',
  116. data: {
  117. detail: this.ruleForm
  118. },
  119. }).then(e => {
  120. this.submitLoading = false;
  121. if (e.data.code === 0) {
  122. this.$message.success(e.data.msg);
  123. navigateTo({
  124. r: 'admin/link/cate-index'
  125. })
  126. } else {
  127. this.$message.error(e.data.msg);
  128. }
  129. }).catch(e => {
  130. });
  131. }
  132. },
  133. computed: {
  134. }
  135. });
  136. </script>