index.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. <template>
  2. <div class="tab">
  3. <div class="tab-search">
  4. <el-form :inline="true" :model="tabQuery">
  5. <el-form-item label="搜索">
  6. <el-input @input="ListBack" v-model="tabQuery.search" placeholder="请输入搜索内容"></el-input>
  7. </el-form-item>
  8. <el-form-item>
  9. <el-button type="primary" @click="search">搜索</el-button>
  10. <el-button type="primary" @click=" dialogVisibleTyep()">新增</el-button>
  11. </el-form-item>
  12. </el-form>
  13. </div>
  14. <div class="tab-header">
  15. <el-table :data="tableData" :preserve-expanded-content="preserveExpanded" border
  16. :tree-props="{ children: 'children', checkStrictly: false }" row-key="id">
  17. <!-- <el-table-column type="selection" width="55" :selectable="selectable" /> -->
  18. <el-table-column type="index" width="50" label="序号" />
  19. <el-table-column prop="name" width="600" label="名字" />
  20. <el-table-column width="100px" prop="id" label="标签id" />
  21. <el-table-column prop="updateTime" label="创建时间" />
  22. <!-- <el-table-column prop="sort" label="Address" /> -->
  23. <el-table-column prop="sort" label="排序值" />
  24. <el-table-column prop="status" label="操作">
  25. <template slot-scope="scope">
  26. <!-- <el-button type="text" @click="checkRow(scope.row)">查看</el-button> -->
  27. <el-button type="text" @click="updateRow(scope.row)">修改</el-button>
  28. <el-button type="text" @click="deleteRow(scope.row)">删除</el-button>
  29. </template>
  30. </el-table-column>
  31. </el-table>
  32. </div>
  33. <el-dialog :visible.sync="dialogVisible" title="修改分类" width=500>
  34. <el-form :model="classifyDetail" label-width="80px">
  35. <el-form-item label="标签类型">
  36. <el-radio-group v-model="radio">
  37. <el-radio @change="radioChange" :label=true size="large">一级标签</el-radio>
  38. <el-radio @change="radioChange" :label=false size="large">二级标签</el-radio>
  39. </el-radio-group>
  40. </el-form-item>
  41. <el-form-item label="一级标签">
  42. <el-select :disabled="radio" v-model="value" placeholder="请选择一级标签" size="large" style="width: 240px"
  43. @change="changeSelect(value)">
  44. <el-option v-for="item in fatherList" :key="item.id" :label="item.name" :value="item.id" />
  45. </el-select>
  46. </el-form-item>
  47. <el-form-item label="标签名称">
  48. <el-input v-model="classifyDetail.name" :placeholder="nameText" />
  49. </el-form-item>
  50. <el-form-item label="标签排序">
  51. <el-input v-model="classifyDetail.sort" type="Number" width="400" :placeholder="sortNumber" />
  52. </el-form-item>
  53. <el-form-item>
  54. <el-button type="primary" @click="add">确定</el-button>
  55. <el-button @click="dialogVisible = false">取消</el-button>
  56. </el-form-item>
  57. </el-form>
  58. </el-dialog>
  59. <!-- 修改 -->
  60. <el-dialog :visible.sync="updataType" title="修改分类" width=500>
  61. <el-form :model="classifyDetail" label-width="80px">
  62. <el-form-item label="标签名称">
  63. <el-input v-model="classifyDetail.name" />
  64. </el-form-item>
  65. <el-form-item label="标签排序">
  66. <el-input v-model="classifyDetail.sort" type="Number" width="400" />
  67. </el-form-item>
  68. <el-form-item>
  69. <el-button type="primary" @click="updateConfirm">确定</el-button>
  70. <el-button @click="updataType = false">取消</el-button>
  71. </el-form-item>
  72. </el-form>
  73. </el-dialog>
  74. </div>
  75. </template>
  76. <script>
  77. import { getTreeTypesApi, getTypesApi, deleteByIdApi, labelByIdApi, saveLabelApi,updateByIdApi } from '@/api/rm-bank'
  78. export default {
  79. data() {
  80. return {
  81. // searchText:''
  82. tabQuery: {
  83. search: '',
  84. type: 1,
  85. },
  86. getTypesList: {
  87. type: '1',
  88. search: ''
  89. },
  90. tableData: [],
  91. 'treeProps.checkStrictly': true,
  92. dialogVisible: false,
  93. updataType:false,
  94. //分类
  95. classifyDetail: {
  96. "parentId": 0,
  97. "name": '',
  98. "sort": '',
  99. "type": 1
  100. },
  101. fatherList: [],
  102. value: '',
  103. radio: true,
  104. nameText: '请输入标签名称',
  105. sortNumber: '请输入排序号(数字,越小越靠前)'
  106. }
  107. },
  108. created() {
  109. this.getTreeTypeList()
  110. this.getTypes()
  111. },
  112. methods: {
  113. async getTreeTypeList() {
  114. const res = await getTreeTypesApi()
  115. // console.log(res)
  116. this.fatherList = res.data
  117. },
  118. async getTypes() {
  119. const res = await getTypesApi(this.getTypesList)
  120. // console.log(res)
  121. this.tableData = res.data
  122. },
  123. //查看详情
  124. // async checkRow(row) {
  125. // // console.log(row);
  126. // const choseId = { id: row.id }
  127. // const res = await labelByIdApi(
  128. // choseId
  129. // )
  130. // console.log(res);
  131. // },
  132. // 修改信息
  133. async updateRow(e) {
  134. const res = await labelByIdApi({ id: e.id })
  135. // console.log(res.data);
  136. this.classifyDetail = res.data
  137. this.updataType = true
  138. // this.dialogVisibleTyep()
  139. },
  140. async updateConfirm() {
  141. // console.log(this.classifyDetail);
  142. const res = await updateByIdApi(this.classifyDetail)
  143. // console.log(res.data);
  144. this.getTypes()
  145. this.updataType = false
  146. },
  147. // 删除信息
  148. async deleteRow(row) {
  149. // this.deleteWindow()
  150. const deleteId = { id: row.id }
  151. // const res = await deleteByIdApi(deleteId)
  152. this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', {
  153. confirmButtonText: '确定',
  154. cancelButtonText: '取消',
  155. type: 'warning'
  156. }).then(async() => {
  157. const res = await deleteByIdApi(deleteId)
  158. if(res.code == 200){
  159. this.$message({
  160. type: 'success',
  161. message: '删除成功!',
  162. });
  163. this.getTypes()
  164. }
  165. }).catch(() => {
  166. this.$message({
  167. type: 'info',
  168. message: '已取消删除'
  169. });
  170. });
  171. },
  172. async search() {
  173. const res = await getTypesApi(this.tabQuery)
  174. // console.log(res);
  175. this.tableData = res.data
  176. },
  177. async add() {
  178. this.dialogVisibleTyep()
  179. const res = await saveLabelApi(this.classifyDetail)
  180. // console.log(res.data);
  181. this.getTypes()
  182. },
  183. dialogVisibleTyep() {
  184. this.dialogVisible = !this.dialogVisible
  185. // console.log(123);
  186. },
  187. radioChange() {
  188. // console.log(this.radio);
  189. if (this.radio) {
  190. this.classifyDetail.parentId = '0'
  191. } else {
  192. // this.classifyDetail.parentId = '2'
  193. }
  194. // console.log(this.classifyDetail.parentId);
  195. },
  196. changeSelect(e) {
  197. // console.log(e);
  198. this.classifyDetail.parentId = e
  199. },
  200. ListBack() {
  201. if (!this.tabQuery.search) {
  202. this.classifyDetail = {
  203. "parentId": 0,
  204. "name": '',
  205. "sort": '',
  206. "type": 1
  207. }
  208. setTimeout(() => {
  209. this.getTypes()
  210. }, 500);
  211. }
  212. }
  213. }
  214. }
  215. </script>
  216. <style lang="scss" scoped>
  217. @import url("../../../styles/elDialog.scss");
  218. .tab {
  219. margin-top: 20px;
  220. /* padding-left: 20px; */
  221. .tab-top {
  222. display: flex;
  223. }
  224. .tab-search {
  225. padding-left: 20px;
  226. }
  227. }</style>