classManage.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. <template>
  2. <div>
  3. <el-button type="primary" size="small" @click="addBtn(drawer = true)">分类管理</el-button>
  4. <el-drawer
  5. title="分类管理"
  6. :visible.sync="drawer"
  7. direction="rtl"
  8. size="60%"
  9. append-to-body
  10. :show-close="false"
  11. @close="closeDrawer">
  12. <div class="drawer__panel" style="margin-bottom: 0!important;">
  13. <el-button style="margin-bottom: 10px" type="primary" size="small" @click="addClass">新增分类</el-button>
  14. <tableNewLayout ref="tableRef" :checkbox="false" :custom="true" :data="list" :layout="tablecols"
  15. :opwidth="200" :width="true" height="calc(100vh - 210px)" @rowSort="rowSort">
  16. <template v-slot:customcol="scope">
  17. <div v-if="scope.column.columnname === 'classname'">
  18. <el-input v-if="sat_notice === scope.column.data.sat_notice_classid" size="mini" v-model="scope.column.data.classname" placeholder="输入分类名称"></el-input>
  19. <p v-else>{{ scope.column.data.classname }}</p>
  20. </div>
  21. <div v-else-if="scope.column.columnname === 'isused'">
  22. <el-switch
  23. v-model="scope.column.data.isused"
  24. :active-value="1"
  25. :inactive-value="0"
  26. @change="useChange(scope.column.data)">
  27. </el-switch>
  28. </div>
  29. <p v-else>{{scope.column.data[scope.column.columnname]}}</p>
  30. </template>
  31. <template v-slot:opreation="scope">
  32. <el-button v-if="sat_notice === scope.data.sat_notice_classid" size="mini" type="text" class="table-button" @click="saveDate(scope.data)">保 存</el-button>
  33. <el-button v-if="sat_notice !== scope.data.sat_notice_classid" size="mini" type="text" class="table-button" @click="updateDate(scope.data)" :disabled="scope.data.isused == 1">编 辑</el-button>
  34. <el-button v-if="sat_notice !== scope.data.sat_notice_classid" size="mini" type="text" class="table-button" @click="delDate(scope.data)" :disabled="scope.data.isused == 1">删 除</el-button>
  35. </template>
  36. </tableNewLayout>
  37. <div class="container normal-panel" style="text-align:right">
  38. <el-pagination
  39. background
  40. @size-change="handleSizeChange"
  41. @current-change="handleCurrentChange"
  42. :current-page="currentPage"
  43. :page-sizes="[50, 100, 150, 200]"
  44. :page-size="50"
  45. layout="total,sizes, prev, pager, next, jumper"
  46. :total="total">
  47. </el-pagination>
  48. </div>
  49. </div>
  50. </el-drawer>
  51. </div>
  52. </template>
  53. <script>
  54. import tableNewLayout from '@/components/dynamic-newTable/index2'
  55. import {Message} from "element-ui";
  56. export default {
  57. name: "classManage",
  58. components:{tableNewLayout},
  59. data(){
  60. return {
  61. drawer:false,
  62. classData:[],
  63. tablecols:[],
  64. list:[],
  65. sat_notice:0,
  66. total:0,
  67. currentPage:0,
  68. param:{
  69. "id": "20240727133503",
  70. "content": {
  71. "pageNumber": 1,
  72. "pageSize": 50,
  73. "where":{
  74. "condition":""
  75. }
  76. }
  77. }
  78. }
  79. },
  80. methods:{
  81. addBtn(){
  82. this.listData(this.param.content.pageNumber = 1)
  83. },
  84. addClass(){
  85. this.sat_notice = 0
  86. this.list.unshift({
  87. "sat_notice_classid":0, //sat_notice_classid<=0时 为新增
  88. "classname": "",
  89. "sequence":this.list.length + 1,
  90. "isused":1
  91. })
  92. },
  93. async saveDate(row){
  94. const res = await this.$api.requested({
  95. "id": "20240727133403",
  96. "content": row
  97. })
  98. this.tool.showMessage(res,()=>{
  99. this.sat_notice = 0
  100. this.listData()
  101. })
  102. },
  103. async useChange(row){
  104. const res = await this.$api.requested({
  105. "id": "20240727133403",
  106. "content": row
  107. })
  108. if (res.code == 0){
  109. this.tool.showMessage(res,()=>{
  110. })
  111. }
  112. this.listData()
  113. },
  114. updateDate(row){
  115. this.sat_notice = row.sat_notice_classid
  116. },
  117. delDate(row){
  118. this.$confirm('确定删除当前分类吗?', '提示', {
  119. confirmButtonText: '确定',
  120. cancelButtonText: '取消',
  121. type: 'warning'
  122. }).then(async() => {
  123. const res = await this.$api.requested({
  124. "id": "20240727133603",
  125. "content": {
  126. "sat_notice_classids":[row.sat_notice_classid]
  127. }
  128. })
  129. /*this.tool.showMessage(res,()=>{
  130. this.listData()
  131. })*/
  132. if (res.code == 0){
  133. Message({
  134. message: res.data[0].errmsg,
  135. type: 'error',
  136. duration:3000,
  137. showClose:true
  138. });
  139. }else {
  140. Message({
  141. message: '操作成功',
  142. type: 'success',
  143. duration:3000,
  144. showClose:true
  145. });
  146. }
  147. this.listData()
  148. }).catch(() => {
  149. this.$message({
  150. type: 'info',
  151. message: '已取消删除'
  152. });
  153. });
  154. },
  155. async listData(){
  156. const res = await this.$api.requested(this.param)
  157. this.list = res.data
  158. this.total = res.total
  159. this.currentPage = res.pageNumber
  160. console.log(this.list,'list')
  161. },
  162. handleSizeChange(val) {
  163. // console.log(`每页 ${val} 条`);
  164. this.param.content.pageSize = val
  165. this.listData()
  166. },
  167. handleCurrentChange(val) {
  168. // console.log(`当前页: ${val}`);
  169. this.param.content.pageNumber = val
  170. this.listData()
  171. },
  172. closeDrawer(){
  173. this.drawer = false
  174. },
  175. rowSort(data){
  176. data.forEach((item,index)=>{
  177. console.log(item.classname,item.index,item.sequence,index)
  178. item.sequence = index
  179. })
  180. this.$nextTick(async()=>{
  181. let sequencesorts = data.map(item=>{
  182. console.log(item.sequence,item.classname)
  183. return {
  184. ownerid:item.sat_notice_classid,
  185. sequence:item.sequence
  186. }
  187. })
  188. const res = await this.$api.requested({
  189. id:20221201134901,
  190. content:{
  191. ownertable:'sat_notice_class',
  192. sequencesorts:sequencesorts
  193. }
  194. })
  195. })
  196. this.listData()
  197. }
  198. },
  199. created() {
  200. this.tablecols = this.tool.tabelCol(this.$route.name).classTable.tablecols
  201. }
  202. }
  203. </script>
  204. <style scoped>
  205. </style>