|
@@ -0,0 +1,287 @@
|
|
|
+<script setup>
|
|
|
+import { computed, reactive, ref, watch } from 'vue'
|
|
|
+import { apiSystemCommon } from '@/api/system'
|
|
|
+import { apiETAChart } from '@/api/etaChart'
|
|
|
+import { SearchIcon } from 'tdesign-icons-vue-next';
|
|
|
+
|
|
|
+const show = defineModel('show', { type: Boolean, default: false })
|
|
|
+const emits=defineEmits(['success'])
|
|
|
+
|
|
|
+const filterState = reactive({
|
|
|
+ classify: '',
|
|
|
+ user: '',
|
|
|
+ searchVal: '',
|
|
|
+ checkAll: false,
|
|
|
+ targetClassify: ''
|
|
|
+})
|
|
|
+
|
|
|
+const userProps = {
|
|
|
+ label: 'RealName',
|
|
|
+ value: 'AdminId',
|
|
|
+ children: 'ChildrenList'
|
|
|
+}
|
|
|
+const userOpts = ref([])
|
|
|
+async function getCompanyUserData() {
|
|
|
+ const res = await apiSystemCommon.companyUserList()
|
|
|
+ if (res.Ret === 200) {
|
|
|
+ userOpts.value = res.Data.List || []
|
|
|
+ }
|
|
|
+}
|
|
|
+getCompanyUserData()
|
|
|
+
|
|
|
+
|
|
|
+const classifyTreeKeys = {
|
|
|
+ label: 'ChartClassifyName',
|
|
|
+ value: 'ChartClassifyId',
|
|
|
+ children: 'Children',
|
|
|
+}
|
|
|
+const classifyOpts = ref([])
|
|
|
+async function getClassifyOpts() {
|
|
|
+ const res = await apiETAChart.classifyNoChart()
|
|
|
+ if (res.Ret === 200) {
|
|
|
+ classifyOpts.value = res.Data.AllNodes || []
|
|
|
+ }
|
|
|
+}
|
|
|
+getClassifyOpts()
|
|
|
+
|
|
|
+
|
|
|
+const pagination = ref({
|
|
|
+ current: 1,
|
|
|
+ pageSize: 20,
|
|
|
+ defaultPageSize: 20,
|
|
|
+ total: 0,
|
|
|
+ pageSizeOptions: [],
|
|
|
+})
|
|
|
+const tableColumns = [
|
|
|
+ {
|
|
|
+ colKey: 'row-select',
|
|
|
+ type: 'multiple',
|
|
|
+ width: 50,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ colKey: 'ChartClassifyName',
|
|
|
+ title: '图表名称',
|
|
|
+ align: 'center'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ colKey: 'Company',
|
|
|
+ title: '机构',
|
|
|
+ width: '120',
|
|
|
+ align: 'center'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ colKey: 'SysUserRealName',
|
|
|
+ title: '创建人',
|
|
|
+ width: '120',
|
|
|
+ align: 'center'
|
|
|
+ }
|
|
|
+]
|
|
|
+const tableData = ref([])
|
|
|
+async function getChartList() {
|
|
|
+ const res = await apiETAChart.chartListFilter({
|
|
|
+ ChartClassifyIds: filterState.classify ? filterState.classify.join(',') : '',
|
|
|
+ PageSize: pagination.value.defaultPageSize,
|
|
|
+ CurrentIndex: pagination.value.current,
|
|
|
+ SysUserIds: filterState.user ? filterState.user.join(',') : '',
|
|
|
+ ChartName: filterState.searchVal
|
|
|
+ })
|
|
|
+ if (res.Ret === 200) {
|
|
|
+ tableData.value = res.Data.AllNodes || []
|
|
|
+ pagination.value.total = res.Data.Paging.Totals
|
|
|
+
|
|
|
+ if(filterState.checkAll){
|
|
|
+ handleClickCheckAll(filterState.checkAll)
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+getChartList()
|
|
|
+
|
|
|
+function handlePageChange(pageInfo) {
|
|
|
+ pagination.value.current = pageInfo.current
|
|
|
+ getChartList()
|
|
|
+}
|
|
|
+function handleRefreshList() {
|
|
|
+ pagination.value.current = 1
|
|
|
+ getChartList()
|
|
|
+}
|
|
|
+watch(
|
|
|
+ [() => filterState.classify, () => filterState.user],
|
|
|
+ () => {
|
|
|
+ handleRefreshList()
|
|
|
+ }
|
|
|
+)
|
|
|
+
|
|
|
+const indeterminate=computed(()=>{
|
|
|
+ if(filterState.checkAll) return false
|
|
|
+ if(selectedRowKeys.value.length>0) return true
|
|
|
+})
|
|
|
+const selectedRowKeys = ref([])
|
|
|
+function tableSelectChange(value, ctx) {
|
|
|
+ selectedRowKeys.value = value
|
|
|
+ if(ctx.type==="uncheck"&&filterState.checkAll){
|
|
|
+ filterState.checkAll=false
|
|
|
+ }
|
|
|
+ if(ctx.type==='check'&&selectedRowKeys.value.length>0){
|
|
|
+ filterState.indeterminate=true
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+function handleClickCheckAll(check) {
|
|
|
+ if(check){
|
|
|
+ // 全选
|
|
|
+ selectedRowKeys.value=[]
|
|
|
+ tableData.value.forEach(item=>{
|
|
|
+ selectedRowKeys.value.push(item.ChartInfoId)
|
|
|
+ })
|
|
|
+ }else{
|
|
|
+ selectedRowKeys.value=[]
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+function handleConfirmClassify() {
|
|
|
+ if(!filterState.checkAll&&selectedRowKeys.value.length===0){
|
|
|
+ MessagePlugin.warning('请选择要移动的图表')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if(!filterState.targetClassify){
|
|
|
+ MessagePlugin.warning('请选择要移动至的分类')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ const params={
|
|
|
+ SelectAll: filterState.checkAll,
|
|
|
+ ChartClassifyIds: filterState.classify ? filterState.classify.join(',') : '', //多个分类id用英文逗号拼接
|
|
|
+ SysUserIds: filterState.user ? filterState.user.join(',') : '',
|
|
|
+ ChartName: filterState.searchVal, //图表名称
|
|
|
+ ChartInfoIds: selectedRowKeys.value.join(','), //选中的图表ID
|
|
|
+ ChartClassifyId: filterState.targetClassify//新分类ID
|
|
|
+ }
|
|
|
+ console.log(params);
|
|
|
+ apiETAChart.moveChartBatch(params).then(res=>{
|
|
|
+ if(res.Ret===200){
|
|
|
+ MessagePlugin.success('操作成功')
|
|
|
+ filterState.classify=''
|
|
|
+ filterState.user=''
|
|
|
+ filterState.searchVal=''
|
|
|
+ filterState.checkAll=false
|
|
|
+ filterState.targetClassify=''
|
|
|
+ pagination.value.current=1
|
|
|
+ tableData.value=[]
|
|
|
+ selectedRowKeys.value=[]
|
|
|
+ show.value=false
|
|
|
+ emits('success')
|
|
|
+ }
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+</script>
|
|
|
+
|
|
|
+<template>
|
|
|
+ <t-dialog
|
|
|
+ v-model:visible="show"
|
|
|
+ header="编辑图表分类"
|
|
|
+ draggable
|
|
|
+ attach="body"
|
|
|
+ width="800px"
|
|
|
+ :confirm-on-enter="true"
|
|
|
+ :on-confirm="handleConfirmClassify"
|
|
|
+ class="batch-move-classify-wrap"
|
|
|
+ >
|
|
|
+ <div class="select-classify-wrap">
|
|
|
+ <div class="top-wrap">
|
|
|
+ <span class="label">待选图表</span>
|
|
|
+ <!-- tdesign 有bug 清空选择会触发多次 他们已经修复了但是还没发版 暂时用watch来代替下 -->
|
|
|
+ <!-- @change="handleRefreshList" -->
|
|
|
+ <t-cascader
|
|
|
+ v-model="filterState.classify"
|
|
|
+ :options="classifyOpts"
|
|
|
+ :keys="classifyTreeKeys"
|
|
|
+ multiple
|
|
|
+ :min-collapsed-num="1"
|
|
|
+ clearable
|
|
|
+ :showAllLevels="false"
|
|
|
+ placeholder="图表分类"
|
|
|
+ />
|
|
|
+ <!-- @change="handleRefreshList" -->
|
|
|
+ <t-cascader
|
|
|
+ v-model="filterState.user"
|
|
|
+ :options="userOpts"
|
|
|
+ :keys="userProps"
|
|
|
+ multiple
|
|
|
+ :minCollapsedNum="1"
|
|
|
+ clearable
|
|
|
+ filterable
|
|
|
+ :showAllLevels="false"
|
|
|
+ placeholder="创建人"
|
|
|
+ />
|
|
|
+ <t-input
|
|
|
+ v-model="filterState.searchVal"
|
|
|
+ placeholder="图表名称"
|
|
|
+ @change="handleRefreshList"
|
|
|
+ >
|
|
|
+ <template #prefix-icon>
|
|
|
+ <SearchIcon />
|
|
|
+ </template>
|
|
|
+ </t-input>
|
|
|
+ <t-checkbox
|
|
|
+ style="flex-shrink: 0"
|
|
|
+ :indeterminate="indeterminate"
|
|
|
+ v-model="filterState.checkAll"
|
|
|
+ @change="handleClickCheckAll"
|
|
|
+ >全选</t-checkbox
|
|
|
+ >
|
|
|
+ </div>
|
|
|
+ <div class="table-wrap">
|
|
|
+ <t-table
|
|
|
+ row-key="ChartInfoId"
|
|
|
+ :data="tableData"
|
|
|
+ :columns="tableColumns"
|
|
|
+ bordered
|
|
|
+ :pagination="pagination"
|
|
|
+ cell-empty-content="-"
|
|
|
+ resizable
|
|
|
+ max-height="500"
|
|
|
+ v-model:selectedRowKeys="selectedRowKeys"
|
|
|
+ @select-change="tableSelectChange"
|
|
|
+ @page-change="handlePageChange"
|
|
|
+ >
|
|
|
+ </t-table>
|
|
|
+ </div>
|
|
|
+ <div class="top-wrap">
|
|
|
+ <span class="label">移动至新分类</span>
|
|
|
+ <t-cascader
|
|
|
+ v-model="filterState.targetClassify"
|
|
|
+ :options="classifyOpts"
|
|
|
+ :keys="classifyTreeKeys"
|
|
|
+ placeholder="图表分类"
|
|
|
+ style="width: 300px"
|
|
|
+ check-strictly
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </t-dialog>
|
|
|
+</template>
|
|
|
+
|
|
|
+<style lang="scss">
|
|
|
+.batch-move-classify-wrap {
|
|
|
+ .t-dialog__footer {
|
|
|
+ text-align: center;
|
|
|
+ }
|
|
|
+}
|
|
|
+</style>
|
|
|
+<style lang="scss" scoped>
|
|
|
+.select-classify-wrap {
|
|
|
+ .top-wrap {
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ gap: 0 10px;
|
|
|
+ .label {
|
|
|
+ flex-shrink: 0;
|
|
|
+ color: #333;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .table-wrap {
|
|
|
+ margin: 20px 0;
|
|
|
+ }
|
|
|
+}
|
|
|
+</style>
|