| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130 |
- <template>
- <div>
- <a-button @click="modeVisible=true" type="primary" size="samll">设置分类</a-button>
- <a-drawer
- ref="drawer"
- v-model:open="modeVisible"
- class="custom-class"
- :title="'设置分类'"
- placement="right"
- :width="'1200px'"
- :closable="false"
- v-if="modeVisible"
- >
- <div style="margin-bottom: 10px" class="inline-16">
- <Add @onSuccess="$refs.table.listData()" v-if="utils.hasPermission('setClass')"></Add>
- </div>
- <normalTable :sequence="true" @listData="listData" rowKey="sat_sharematerial_classid" :is-select="false" ref="table" size="small" :columns="utils.TBLayout('tableSCChildclass')" :param="param">
- <template #tb_cell="{data}">
- <template v-if="data.column.dataIndex === 'issecret'">
- <a-switch
- v-model:checked="data.record.isenable"
- :checkedValue="1"
- :unCheckedValue="0"
- unCheckedChildren="停用"
- checkedChildren="启用"
- @change="typeChange($event,data)"
- >
- </a-switch>
- </template>
- <template v-if="data.column.dataIndex === 'attinfos'">
- <a-image v-if="data.record.parentid == 0 && data.record.attinfos[0]" :src="data.record.attinfos[0].url" style="width: 100px;"></a-image>
- </template>
- <template v-else-if="data.column.dataIndex == 'operation'">
- <Edit :disabled="!data.record.isenable != 1" @onSuccess="$refs.table.listData()" :data="data.record" v-if="utils.hasPermission('setClass')"></Edit>
- <Add :disabled="!data.record.isenable != 1" @onSuccess="$refs.table.listData()" :data="data.record" v-if="data.record.level != 3 && utils.hasPermission('setClass')"></Add>
- <a-button :disabled="!data.record.isenable != 1" v-if="utils.hasPermission('setClass')" size="samll" type="link" @click="delClass(data.record)">删 除</a-button>
- </template>
- </template>
- </normalTable>
- </a-drawer>
- </div>
- </template>
- <script setup>
- import { EditOutlined } from '@ant-design/icons-vue';
- import normalTable from '@/template/normalTable/index.vue'
- import {ref, defineProps, defineEmits,watch, nextTick} from 'vue'
- import Api from '@/api/api'
- import utils from '@/utils/utils'
- import { message, Modal } from 'ant-design-vue';
- import Add from './add.vue'
- import Edit from './edit.vue'
- let modeVisible = ref(false)
- const emit = defineEmits(['onSuccess','back'])
- let param = ref({
- "id": "20221102143202",
- "content": {
- "parentid": 0,
- "pageSize":20,
- "pageNumber":1,
- "where": {
- "isenable": ''
- }
- }
- })
- let table = ref()
- watch(() => modeVisible.value,(val) => {
- if (!val) emit('back')
- })
- const typeChange = async (e,data) => {
- let arr = []
- function isChild(nodes) {
- for (let index = 0; index < nodes.length; index++) {
- arr.push(nodes[index].sat_sharematerial_classid)
- if (nodes[index].children && nodes[index].children.length) isChild(nodes[index].children)
- }
- }
- if(data.record.children) isChild(data.record.children)
- arr.push(data.record.sat_sharematerial_classid)
- let res = await Api.requested({
- "id": "20240403153602",
- "content": {
- "sat_sharematerial_classids": arr,
- "isenable":e
- }
- })
- utils.message(res,'操作成功',() => {
- data.record = Object.assign({},data.record,res.data)
- })
- }
- const listData = (res) => {
- res.forEach(item => {
- item.attinfos = utils.fileList(item.attinfos)
- item.children.forEach(item2 => {
- console.log(item2,'111');
- if (!item2.children.length) delete item2.children
- })
- if (!item.children.length) delete item.children
-
- })
- console.log(res);
- }
- //删除板块
- const delClass = (data) => {
- Modal.confirm({
- title:'确定删除当前分类吗?',
- okText:'确认',
- async onOk() {
- let res = await Api.requested({
- "id": "20221102143502",
- "content": {
- "sat_sharematerial_classids": [
- data.sat_sharematerial_classid
- ]
- }
- })
- utils.message(res,'操作成功',() => {
- table.value.listData()
- })
- },
- onCancel() {},
- })
- }
- </script>
- <style scoped>
- </style>
|