index.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. <template>
  2. <div>
  3. <a-button @click="modeVisible=true" type="primary" size="samll">设置分类</a-button>
  4. <a-drawer
  5. ref="drawer"
  6. v-model:open="modeVisible"
  7. class="custom-class"
  8. :title="'设置分类'"
  9. placement="right"
  10. :width="'1200px'"
  11. :closable="false"
  12. v-if="modeVisible"
  13. >
  14. <div style="margin-bottom: 10px" class="inline-16">
  15. <Add @onSuccess="$refs.table.listData()" v-if="utils.hasPermission('setClass')"></Add>
  16. </div>
  17. <normalTable :sequence="true" @listData="listData" rowKey="sat_sharematerial_classid" :is-select="false" ref="table" size="small" :columns="utils.TBLayout('tableSCChildclass')" :param="param">
  18. <template #tb_cell="{data}">
  19. <template v-if="data.column.dataIndex === 'issecret'">
  20. <a-switch
  21. v-model:checked="data.record.isenable"
  22. :checkedValue="1"
  23. :unCheckedValue="0"
  24. unCheckedChildren="停用"
  25. checkedChildren="启用"
  26. @change="typeChange($event,data)"
  27. >
  28. </a-switch>
  29. </template>
  30. <template v-if="data.column.dataIndex === 'attinfos'">
  31. <a-image v-if="data.record.parentid == 0 && data.record.attinfos[0]" :src="data.record.attinfos[0].url" style="width: 100px;"></a-image>
  32. </template>
  33. <template v-else-if="data.column.dataIndex == 'operation'">
  34. <Edit :disabled="!data.record.isenable != 1" @onSuccess="$refs.table.listData()" :data="data.record" v-if="utils.hasPermission('setClass')"></Edit>
  35. <Add :disabled="!data.record.isenable != 1" @onSuccess="$refs.table.listData()" :data="data.record" v-if="data.record.level != 3 && utils.hasPermission('setClass')"></Add>
  36. <a-button :disabled="!data.record.isenable != 1" v-if="utils.hasPermission('setClass')" size="samll" type="link" @click="delClass(data.record)">删 除</a-button>
  37. </template>
  38. </template>
  39. </normalTable>
  40. </a-drawer>
  41. </div>
  42. </template>
  43. <script setup>
  44. import { EditOutlined } from '@ant-design/icons-vue';
  45. import normalTable from '@/template/normalTable/index.vue'
  46. import {ref, defineProps, defineEmits,watch, nextTick} from 'vue'
  47. import Api from '@/api/api'
  48. import utils from '@/utils/utils'
  49. import { message, Modal } from 'ant-design-vue';
  50. import Add from './add.vue'
  51. import Edit from './edit.vue'
  52. let modeVisible = ref(false)
  53. const emit = defineEmits(['onSuccess','back'])
  54. let param = ref({
  55. "id": "20221102143202",
  56. "content": {
  57. "parentid": 0,
  58. "pageSize":20,
  59. "pageNumber":1,
  60. "where": {
  61. "isenable": ''
  62. }
  63. }
  64. })
  65. let table = ref()
  66. watch(() => modeVisible.value,(val) => {
  67. if (!val) emit('back')
  68. })
  69. const typeChange = async (e,data) => {
  70. let arr = []
  71. function isChild(nodes) {
  72. for (let index = 0; index < nodes.length; index++) {
  73. arr.push(nodes[index].sat_sharematerial_classid)
  74. if (nodes[index].children && nodes[index].children.length) isChild(nodes[index].children)
  75. }
  76. }
  77. if(data.record.children) isChild(data.record.children)
  78. arr.push(data.record.sat_sharematerial_classid)
  79. let res = await Api.requested({
  80. "id": "20240403153602",
  81. "content": {
  82. "sat_sharematerial_classids": arr,
  83. "isenable":e
  84. }
  85. })
  86. utils.message(res,'操作成功',() => {
  87. data.record = Object.assign({},data.record,res.data)
  88. })
  89. }
  90. const listData = (res) => {
  91. res.forEach(item => {
  92. item.attinfos = utils.fileList(item.attinfos)
  93. item.children.forEach(item2 => {
  94. console.log(item2,'111');
  95. if (!item2.children.length) delete item2.children
  96. })
  97. if (!item.children.length) delete item.children
  98. })
  99. console.log(res);
  100. }
  101. //删除板块
  102. const delClass = (data) => {
  103. Modal.confirm({
  104. title:'确定删除当前分类吗?',
  105. okText:'确认',
  106. async onOk() {
  107. let res = await Api.requested({
  108. "id": "20221102143502",
  109. "content": {
  110. "sat_sharematerial_classids": [
  111. data.sat_sharematerial_classid
  112. ]
  113. }
  114. })
  115. utils.message(res,'操作成功',() => {
  116. table.value.listData()
  117. })
  118. },
  119. onCancel() {},
  120. })
  121. }
  122. </script>
  123. <style scoped>
  124. </style>