standard-codetable_old.vue 11.1 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458
<route lang="yaml">
  name: metadataStandardCodetable
</route>

<script lang="ts" setup name="metadataStandardCodetable">
import { ref, reactive } from 'vue';
import { ElMessage } from "element-plus";
import Tree from '@/components/Tree/index.vue';
import TableTools from '@/components/Tools/table_tools.vue';
import { Search } from '@element-plus/icons-vue'
import { useRouter, useRoute } from "vue-router";
import { TableColumnWidth } from '@/utils/enum';
import { commonPageConfig } from '@/components/PageNav/index';
import { getParamsList } from '@/api/modules/dataAsset'
import { getStandardCodeList, saveStandardCode, updateStandardCode } from '@/api/modules/dataMetaService'

const { proxy } = getCurrentInstance() as any;
const router = useRouter();

const treeInfo:any = reactive({
    id: "data-pickup-tree",
    filter: true,
    queryValue: "",
    queryPlaceholder: "请输入关键字搜索",
    props: {
        label: "label",
        value: "value",
    },
    nodeKey: 'value',
    expandedKey: ['01'],
    currentNodeKey: '01',
    expandOnNodeClick: false,
    data: [],
    loading: false
});
function nodeClick (data) {

}

/** 分页及搜索传参信息配置。 */
const tableSearchInput = ref('')
function getFirstPageData () {
    page.value.curr = 1
    toSearch({})
}
function toSearch (val: any, clear: boolean = false) {
    let params: any = Object.keys(val).length ? { ...val } : {}
    params.pageIndex = page.value.curr;
    params.pageSize = page.value.limit;
    params.name = tableSearchInput.value
    getTableData(params);
}
const page = ref({
    ...commonPageConfig,
    collectTaskName: '',
    dataSourceGuid: '',
    taskState: null
});
const tableInfo = ref({
    id: 'data-source-table',
    fields: [
        { label: '序号', type: 'index', width: TableColumnWidth.INDEX, align: 'center' },
        { label: '代码名称', field: '1', width: 140 },
        { label: '标准号', field: '2', width: 140 },
        { label: '标准名称', field: '3', width: 140 },
        { label: '启用状态', field: '4', width: 140 },
        { label: '创建时间', field: '5', width: 140 }
    ],
    data: [],
    page: {
        type: 'normal',
        rows: 0,
        ...page.value
    },
    actionInfo: {
        label: '操作',
        type: 'btn',
        width: 160,
        btns: scope => {
            let row = scope.row
            return [
                { label: '编辑', value: 'edit' },
                { label: '删除', value: 'delete' },
            ]
        }
    },
    loading: false
})
function tableBtnClick (scope, btn) {

}
function tablePageChange (info) {
    page.value.curr = Number(info.curr);
    page.value.limit = Number(info.limit);
    // getTableData();
}
function getTableData (params) {

}
function handleCreate () {
    drawerInfo.value.visible = true;
    drawerInfo.value.type = 'add';
    drawerInfo.value.header.title = '新增标准代码';
    drawerInfo.value.footer.visible = true;
}

// drawer form
const standardOptions = ref([])
const publishingUnitCodeOptions = ref([])
const formRef = ref()
const formItems: any = ref([
    {
        label: '标准类型',
        type: 'select',
        placeholder: '请选择',
        field: 'standardTypeCode',
        default: '',
        options: standardOptions,
        clearable: true,
        required: true
    },
    {
        label: '代码名称',
        type: 'input',
        placeholder: '请输入',
        field: 'codeName',
        default: '',
        maxlength: 20,
        clearable: true,
        required: true
    },
    {
        label: '标准号',
        type: 'input',
        placeholder: '请输入',
        field: 'standard',
        default: '',
        maxlength: 50,
        clearable: true,
        required: true
    },
    {
        label: '标准名称',
        type: 'input',
        placeholder: '请输入',
        field: 'standardName',
        default: '',
        maxlength: 20,
        clearable: true,
        required: true
    },
    {
        label: '发布单位',
        type: 'select',
        placeholder: '请输入',
        field: 'publishingUnitCode',
        default: '',
        options: publishingUnitCodeOptions,
        clearable: true,
        required: true
    },
    {
        label: '排序',
        type: 'inputNumber',
        placeholder: '请输入',
        field: 'orderNum',
        default: '',
        maxlength: 6,
        clearable: true,
        required: true
    },
    {
        label: '启用状态',
        type: 'switch',
        field: 'bizState',
        default: false
    },
    {
        label: '代码类型',
        type: 'select',
        placeholder: '请选择',
        field: 'typeCode',
        default: '1',
        options: [
            { label: '列表结构', value: '1' },
            { label: '层级结构', value: '2' }
        ],
        clearable: true,
        required: true
    },
    {
        label: '编码字段',
        type: 'select',
        placeholder: '请选择',
        field: 'codeFields',
        default: [],
        options: [
            { label: 'code', value: 'code' },
            { label: 'name', value: 'name' }
        ],
        clearable: true,
        required: true,
        multiple: true
    },
    {
        label: '编码名称',
        type: 'select',
        placeholder: '请选择',
        field: 'codeFieldName',
        default: '',
        options: [
            { label: 'code', value: 'code' },
            { label: 'name', value: 'name' }
        ],
        clearable: true,
        required: true
    },
    {
        label: '层级结构',
        type: 'input',
        placeholder: '请输入',
        field: 'hierarchy',
        default: '',
        clearable: true,
        required: true
    }
])
const formRules = ref({

})
const formInfo = ref({
    type: 'form',
    title: '',
    col: 'span',
    formInfo: {
        id: 'add-dict-form',
        col: 'col2',
        items: formItems.value,
        formRules: formRules.value
    }
})
const formTable = reactive({
    type: "table",
    title: "定义表结构",
    col: 'no-margin',
    style: {
        height: 'calc(100% - 234px)'
    },
    tableInfo: {
        id: "role-authority-table",
        multiple: true,
        minHeight: 'unset',
        maxHeight: '100%',
        fields: [
            { label: '序号', type: 'index', width: 56, align: 'center' },
            { label: '字段名称', field: 'fieldName', width: 140, type: 'edit', customClass: 'edit-colum'}
        ],
        data: [{ fieldName: '1', index: 0}],
        showPage: false,
        actionInfo: {
            show: true,
            label: "操作",
            type: "btn",
            width: 60,
            fixed: 'right',
            btns: [{ label: "删除", value: "remove" }]
        },
        editInfo: {
            fieldName: {
                field: 'fieldName',
                label: '字段名称',
                type: 'input',
                clearable: true,
                maxlength: 20
            }
        },
        readonly: false,
        col: 'auto-height',
        style: { height: 'calc(100% - 40px)'},
        loading: false
    },
    tableTool: {
        col: 'float-right',
        visible: true,
        btns: [
            { label: "新增行", value: "tableAdd", type: 'primary' },
            { label: "批量删除", value: "tableDelete" },
        ]
    },
})
// 新增drawer
const drawerInfo = ref({
    visible: false,
    direction: 'rtl',
    size: 550,
    header: {
        title: '新增标准代码',
    },
    type: '',
    container: {
        contents: [formInfo.value, formTable],
    },
    footer: {
        visible: true,
        btns: [
            { type: 'default', label: '取消', value: 'cancel' },
            { type: 'primary', label: '保存', value: 'save' },
            { type: 'primary', label: '保存并添加数据', value: 'saveAndAdd', visible: true }
        ]
    }
})
async function drawerBtnClick (btn, info) {

}
function drawerTableToolBtnClick (btn, data) {
    console.log(btn, data)
    if (btn.value === 'tableAdd') {
        // 定义表结构新增行
        let rowInfo = { fieldName: '' }
        formTable.tableInfo.data.push(rowInfo)
    }
}

onMounted(() => {
    getParamsList({ dictType: '标准类型'}).then((res:any) => {
        if (res.code === proxy.$passCode) {
            const data = res.data || []
            treeInfo.data = data
            standardOptions.value = data
            // 默认展开第一个
            if (data.length === 0) return
            let params = {
                pageIndex: 1,
                pageSize: 100,
                standardTypeCode: data[0].value,
                codeName: '标准类型'
            }
            getStandardCodeList(params)
        }
    })
    getParamsList({ dictType: '发布单位' }).then((res:any) => {
        if (res.code === proxy.$passCode) {
            const data = res.data || []
            publishingUnitCodeOptions.value = data
        }
    })
})
</script>

<template>
<div class="container_wrap full flex">
    <div class="aside_wrap">
        <div class="aside_title">标准代码列表</div>
        <Tree :treeInfo="treeInfo" @nodeClick="nodeClick" />
    </div>
    <div class="main_wrap">
        <div class="table_tool_wrap">
            <div class="tools_btns">
                <el-button type="primary" @click="handleCreate">新建</el-button>
                <el-button>批量删除</el-button>
                <el-button>批量导入</el-button>
            </div>
            <el-input class="table_search_input" v-model.trim="tableSearchInput" placeholder="代码名称搜索"
            :suffix-icon="Search" clearable @change="val => getFirstPageData()" />
        </div>
        <div class="table_panel_wrap">
            <Table :tableInfo="tableInfo" @tableBtnClick="tableBtnClick" @tablePageChange="tablePageChange"
            />
        </div>
    </div>
    <Drawer
        :drawerInfo="drawerInfo"
        @drawerBtnClick="drawerBtnClick"
        ref="drawerRef"
        @drawerTableToolBtnClick="drawerTableToolBtnClick"
    >
        <!-- <Form ref="formRef"
            :itemList="formItems"
            formId="basic-info-form"
            :rules="formRules"
        /> -->
    </Drawer>
</div>
</template>

<style scoped lang="scss">
.container_wrap {

  .aside_wrap {
    width: 200px;
  }

  .main_wrap {
    padding: 10px 20px;


    :deep(.el-tabs) {
      height: 100%;

      .el-tabs__header {
        margin-bottom: 0;
      }

      .el-tabs__item {
        height: 32px;
        padding: 0px;
        width: 144px;

        &:last-child {
          width: 130px;
        }
      }

      .el-tabs__content {
        height: calc(100% - 32px);
      }

      .el-tab-pane {
        padding: 0px 16px;
        height: 100%;
      }
    }
  }

}

.tree_panel {
  height: calc(100% - 36px);
  padding-top: 0;

  :deep(.el-tree) {
    margin: 0;
    overflow: hidden auto;
  }
}

.table_tool_wrap {
  display: flex;
  flex-direction: column;

  .el-input {
    width: 230px;
    height: 32px;
  }

  :deep(.el-input) {
    .el-input__suffix-inner {
      flex-direction: row-reverse;
      -webkit-flex-direction: row-reverse;
      display: flex;
    }
  }
}

.table_panel_wrap {
  height: calc(100% - 44px);
}
</style>