Ver código fonte

1213xx资源版本管理

XiaXxxxxx 1 ano atrás
pai
commit
7e1dcc0c02

+ 33 - 0
src/api/sys/version.ts

@@ -74,4 +74,37 @@ export const getResByVersion = (params: any) => {
             resolve(res)
         })
     })
+};
+
+/**
+ * @description: 获取所有版本
+ * @param page string 页码
+ * @param rows string 每页大小
+ * @param isgl number 是否已经管理
+ * @param keyStr string 关键字
+ * @param serviceType string 资源类型
+ */
+export const getResVersionList = (params: any) => {
+    let param = {
+        page:1,
+        rows:1000000,
+        ...params
+    }
+    return new Promise<void>((resolve) => {
+        defHttp.post({url: Api.GetResVersion, params: param }).then((res) => {
+            resolve(res)
+        })
+    })
+};
+
+/**
+ * @description: 保存版本
+ * @param: 2:实体json {}
+ */
+export const saveResVersion = (params: any) => {
+    return new Promise<void>((resolve) => {
+        defHttp.post({ url: Api.SaveResVersion, params: params }).then((res) => {
+            resolve(res)
+        })
+    })
 };

+ 178 - 0
src/views/dataAdmin/dataAdmin/resVersion/ResVersionManageModal.vue

@@ -0,0 +1,178 @@
+<template>
+    <BasicModal :maskClosable="false" :width="750" @register="registerModal" v-bind="$attrs" title="资源版本管理" centered
+        @ok="handleSubmit">
+        <div class="content">
+            <div class="base">
+                <div class="base-title">基本信息</div>
+                <div class="base-info">
+                    <div class="item">资源类型:<span>{{ type }}</span></div>
+                    <div class="item">资源名称:<span>{{ SERVICENAME }}</span></div>
+                </div>
+            </div>
+            <div class="version">
+                <div class="base-title">版本管理</div>
+                <div class="is-history">
+                    <div class="label">是否已存在:</div>
+                    <div class="radio-box">
+                        <a-radio-group v-model:value="isHistory">
+                            <a-radio :value="0">否</a-radio>
+                            <a-radio :value="1">是</a-radio>
+                        </a-radio-group>
+                    </div>
+                </div>
+                <div class="version-info" v-if="isHistory === 0">
+                    <div class="label">版本名称:</div>
+                    <div class="select">
+                        <a-select v-model:value="version" style="width: 100%" :options="versionSelect"></a-select>
+                    </div>
+                </div>
+            </div>
+        </div>
+    </BasicModal>
+</template>
+<script>
+import { defineComponent, reactive, ref, onMounted, watch, computed, toRefs } from 'vue';
+import { BasicModal, useModalInner } from '/@/components/Modal';
+// import { message } from 'ant-design-vue';
+import { getVersionList } from '/@/api/sys/version';
+
+export default defineComponent({
+    name: 'ResVersionModal',
+    components: { BasicModal },
+    setup(_, { emit }) {
+        const baseInfo = reactive({
+            RESOURCE_TYPE: "",
+            type: "",
+            SERVICENAME: "",
+            SERVICEID: ""
+        })
+        const isHistory = ref(0);
+        const version = ref("");
+        //获取大版本选项列表
+        const getVersionSelect = () => {
+            return new Promise((resolve) => {
+                let params = {
+                    keyStr: ""
+                }
+                getVersionList(params).then(res => {
+                    if (res.resp_code === 0 && res.datas) {
+                        let resData = []
+                        res.datas.pageData.forEach(element => {
+                            resData.push(
+                                {
+                                    label: element.VERSION_NAME,
+                                    value: element.VERSION_NAME
+                                }
+                            )
+                        });
+                        resolve(resData)
+                    }
+                    else {
+                        resolve([])
+                    }
+                })
+
+            })
+        }
+        const versionSelect = ref([]);
+        onMounted(async () => {
+            versionSelect.value = await getVersionSelect();
+        })
+
+        const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
+            resetForm()
+            console.log(data)
+            const { RESOURCE_TYPE, type, SERVICENAME, SERVICEID } = data.base;
+            baseInfo.RESOURCE_TYPE = RESOURCE_TYPE;
+            baseInfo.type = type;
+            baseInfo.SERVICENAME = SERVICENAME;
+            baseInfo.SERVICEID = SERVICEID;
+        });
+        const resetForm = () => {
+            isHistory.value = 0
+            version.value = ''
+        }
+        // 提交信息
+        const handleSubmit = () => {
+
+        };
+        return {
+            ...toRefs(baseInfo),
+            isHistory,
+            version,
+            versionSelect,
+            registerModal,
+            handleSubmit,
+        };
+    },
+});
+</script>
+<style lang="scss" scoped>
+.content {
+    padding: 10px;
+
+    .base {
+
+        .base-title {
+            width: 100px;
+            height: 20px;
+            line-height: 20px;
+            text-align: center;
+            border-left: 2px solid #0671DD;
+            font-size: 16px;
+            color: #333333;
+            margin-bottom: 20px;
+        }
+
+        .base-info {
+            display: flex;
+            align-items: center;
+
+            .item {
+                margin-right: 180px;
+                font-size: 14px;
+                color: #3D3D3D;
+
+                &:last-child {
+                    margin-right: 0;
+                }
+            }
+        }
+    }
+    .version{
+        .base-title {
+            margin: 20px 0;
+            width: 100px;
+            height: 20px;
+            line-height: 20px;
+            text-align: center;
+            border-left: 2px solid #0671DD;
+            font-size: 16px;
+            color: #333333;
+        }
+        .is-history{
+            display: flex;
+            align-items: center;
+
+            .label{
+                width: 90px;
+                margin-right: 10px;
+            }
+        }
+        .version-info{
+            margin-top: 10px;
+            display: flex;
+            align-items: center;
+
+            .label{
+                width: 90px;
+                margin-right: 10px;
+                flex-shrink: 0;
+            }
+            .select{
+                width: 250px;
+            }
+        }
+    }
+}
+</style>

+ 385 - 0
src/views/dataAdmin/dataAdmin/resVersion/index.vue

@@ -0,0 +1,385 @@
+<template>
+    <div class="p-4">
+        <div class="content">
+            <div class="left-box">
+                <div class="res-list-btn" v-for="(item, index) in resBtns" :key="index"
+                    :class="{ 'clicked': currentResType === item.value }" @click="handleChangeRes(item)">
+                    {{ item.label }}
+                </div>
+            </div>
+            <div class="right-box">
+                <div class="right-header">
+                    <div class="search">
+                        <span class="label">资源名称:</span>
+                        <a-input v-model:value="searchValue" placeholder="输入关键字查询" allow-clear />
+                        <span class="label" style="margin-left: 30px;">版本管理:</span>
+                        <a-radio-group v-model:value="searchType" style="display: flex;">
+                            <a-radio :value="0">未管理</a-radio>
+                            <a-radio :value="1">已管理</a-radio>
+                        </a-radio-group>
+                    </div>
+                    <div class="handle-btns">
+                        <a-button class="btn" @click="resetTable">重置</a-button>
+                        <a-button class="btn" type="primary" @click="searchTable">查询</a-button>
+                    </div>
+                </div>
+                <div class="right-body">
+                    <BasicTable @register="registerTable">
+                        <template #toolbar>
+                            <Button type="primary" :disabled="hasSelected" @click="handleManageAll" v-if="searchType === 0">
+                                批量版本管理
+                            </Button>
+                            <Button type="primary" danger :disabled="hasSelected" @click="handleDelAll" v-else>
+                                批量取消版本
+                            </Button>
+                        </template>
+                        <template #action="{ record }">
+                            <TableAction :actions="[
+                                {
+                                    label: '浏览',
+                                    tooltip: '浏览',
+                                    onClick: handleFetchRes.bind(null, record),
+                                },
+                                {
+                                    label: '查看',
+                                    tooltip: '查看',
+                                    onClick: handleLookRes.bind(null, record),
+                                },
+                                {
+                                    label: '版本管理',
+                                    tooltip: '版本管理',
+                                    onClick: handleManage.bind(null, record),
+                                },
+                            ]" />
+                        </template>
+                    </BasicTable>
+                </div>
+            </div>
+        </div>
+        <ResVersionManageModal @register="registerModal"></ResVersionManageModal>
+    </div>
+</template>
+
+<script>
+import { defineComponent, reactive, ref, toRefs, computed, onMounted, watch } from 'vue';
+// 导入表格组件,表格事件
+import { BasicTable, useTable, TableAction } from '/@/components/Table';
+import { Button, notification } from 'ant-design-vue';
+import { useModal } from '/@/components/Modal';
+import ResVersionManageModal from './ResVersionManageModal.vue';
+// import VersionModal from './VersionModal.vue';
+// import VersionResModal from './VersionResModal.vue';
+import { getResVersionList } from '/@/api/sys/version';
+import { message } from 'ant-design-vue';
+import moment from 'moment'
+import { session } from '/@/utils/Memory';
+import uiTool from '/@/utils/uiTool';
+
+export default defineComponent({
+    name: 'resVersion',
+    components: { ResVersionManageModal, BasicTable, TableAction, Button },
+    setup() {
+        const [registerModal, { openModal }] = useModal();
+        // const [registerResModal, { openModal: openResModal }] = useModal();
+        const data = reactive({
+            searchValue: "",//关键字
+            searchType: 0,//是否已关联
+        });
+        const resBtns = ref([
+            {
+                label: '地图资源',
+                value: 'MR'
+            },
+            {
+                label: '场景资源',
+                value: 'DR'
+            },
+            {
+                label: '文件资源',
+                value: 'ER'
+            },
+            {
+                label: '组件服务',
+                value: 'SR'
+            },
+            {
+                label: '接口服务',
+                value: 'interface'
+            }
+        ]);
+        const typeObj = {
+            MR: "地图资源",
+            DR: "场景资源",
+            ER: "文件资源",
+            SR: "组件服务",
+            interface: "接口服务"
+        }
+        const currentResType = ref("MR");
+        //获取所有标签
+        const getResData = () => {
+            return new Promise((resolve, reject) => {
+                let params = {
+                    isgl: data.searchType,
+                    keyStr: data.searchValue,
+                    serviceType: currentResType.value
+                }
+                getResVersionList(params).then(res => {
+                    if (res.resp_code === 0 && res.datas) {
+                        let resData = res.datas.pageData;
+                        resData.forEach(item => {
+                            item.type = typeObj[item.RESOURCE_TYPE]
+                        })
+                        resolve(resData)
+                    }
+                    else {
+                        resolve([])
+                        message.error(res.resp_msg)
+                    }
+                })
+            })
+        }
+        //表格列
+        const columns = [
+            {
+                title: '资源类型',
+                align: 'center',
+                dataIndex: 'type',
+                key: 'type'
+            },
+            {
+                title: '资源名称',
+                align: 'center',
+                dataIndex: 'SERVICENAME',
+                key: 'SERVICENAME'
+            },
+            {
+                title: '版本',
+                align: 'center',
+                dataIndex: 'VERSION_NAME',
+                key: 'VERSION_NAME'
+            },
+            {
+                title: '版本号',
+                align: 'center',
+                dataIndex: 'VERSION_NO',
+                key: 'VERSION_NO'
+            },
+            {
+                title: '操作时间',
+                align: 'center',
+                dataIndex: 'CREATE_DATE',
+                key: 'CREATE_DATE'
+            },
+            {
+                title: '操作人',
+                align: 'center',
+                dataIndex: 'CREATENAME',
+                key: 'CREATENAME'
+            }
+        ];
+        //表格查询功能
+        const searchTable = () => {
+            reload()
+        }
+        //重置
+        const resetTable = () => {
+            data.searchValue = ''
+            reload()
+        }
+        //判断是否选中数据
+        const hasSelected = computed(() => {
+            const rowSelection = getRowSelection();
+            return !rowSelection.selectedRowKeys?.length;
+        });
+        const handleChangeRes = (item) => {
+            currentResType.value = item.value;
+            reload()
+        }
+
+        //批量管理资源的版本
+        const handleManageAll = () => {
+            // openModal(true, {
+            //     status: 'add',
+            //     form: {}
+            // });
+        }
+        //批量取消选中资源的版本
+        const handleDelAll = () => {
+            uiTool.delModal('确定取消所有资源的版本?', (() => {
+                // const rowKeys = getSelectRowKeys();
+                // let ids = rowKeys.toString()
+                // let param = {
+                //     fid: ids
+                // }
+                // delVersion(param).then(res => {
+                //     if (res.resp_code === 0) {
+                //         message.success('操作成功');
+                //         reload();
+                //         setSelectedRowKeys([])
+                //     }
+                // })
+            }))
+        };
+        // 浏览资源
+        const handleFetchRes = (record) => {
+
+        }
+        // 查看资源
+        const handleLookRes = (record) => {
+            // const { FID, VERSION_NAME, VERSION_NO, VERSION_DISP } = record;
+            // openResModal(true, {
+            //     status: 'look',
+            //     form: { FID, VERSION_NAME, VERSION_NO, VERSION_DISP }
+            // });
+        }
+        //管理资源的版本
+        const handleManage = (record) => {
+            const { RESOURCE_TYPE, type, SERVICENAME, SERVICEID } = record;
+            openModal(true, {
+                status: 'manage',
+                base: { RESOURCE_TYPE, type, SERVICENAME, SERVICEID },
+                version: {}
+            });
+        }
+
+
+        //弹窗确认
+        // const onSubmit = () => {
+        //     reload();
+        // }
+        const [
+            registerTable,
+            { reload, getRowSelection, getSelectRowKeys, setSelectedRowKeys },
+        ] = useTable({
+            title: '版本列表', //'菜单列表'
+            api: getResData, //加载数据
+            columns: columns,
+            useSearchForm: false,     //开启搜索区域
+            bordered: false,
+            showTableSetting: true,  // 显示表格设置
+
+            tableSetting: {
+                redo: true,
+                size: true,
+                setting: false,
+                fullScreen: false
+            },
+            showIndexColumn: true,
+            pagination: {
+                hideOnSinglePage: false
+            },
+            rowKey: (record) => record.SERVICEID,
+            actionColumn: {
+                width: 200,
+                title: '操作',
+                dataIndex: 'action',
+                slots: { customRender: 'action' },
+            },
+            rowSelection: {
+                type: 'checkbox',
+            },
+        });
+        return {
+            resBtns,
+            currentResType,
+            columns,
+            hasSelected,
+            ...toRefs(data),
+            // func
+            // registerResModal,
+            registerModal,
+            registerTable,
+            getResData,
+            searchTable,
+            resetTable,
+            handleChangeRes,
+
+            handleManageAll,
+            handleDelAll,
+            handleFetchRes,
+            handleLookRes,
+            handleManage,
+            // onSubmit
+        };
+    },
+});
+</script>
+
+<style lang="less" scoped>
+.p-4 {
+    height: 100%;
+
+    .content {
+        width: 100%;
+        height: 100%;
+        display: flex;
+
+        .left-box {
+            padding: 20px;
+            margin-right: 10px;
+            width: 240px;
+            height: 100%;
+            background-color: #fff;
+            border-radius: 6px;
+
+            .res-list-btn {
+                height: 35px;
+                margin-bottom: 16px;
+                background-color: #eff0f5;
+                line-height: 35px;
+                text-align: center;
+                color: #333333;
+                cursor: pointer;
+                user-select: none;
+            }
+
+            .clicked {
+                background-color: #0671dd;
+                color: #FFFFFF;
+            }
+        }
+
+        .right-box {
+            width: calc(100% - 250px);
+            height: 100%;
+
+            .right-header {
+                margin-bottom: 10px;
+                height: 74px;
+                padding: 0 20px;
+                display: flex;
+                align-items: center;
+                background-color: #ffffff;
+                border-radius: 6px;
+                justify-content: space-between;
+
+                .search {
+                    display: flex;
+                    align-items: center;
+
+                    .label {
+                        width: 70px;
+                        flex-shrink: 0;
+                    }
+                }
+
+                .handle-btns {
+                    display: flex;
+                    align-items: center;
+
+                    .btn {
+                        margin-left: 10px;
+                    }
+                }
+            }
+
+            .right-body {
+                padding: 0 20px;
+                height: calc(100% - 84px);
+                background-color: #ffffff;
+                border-radius: 6px;
+            }
+        }
+    }
+}
+</style>

+ 116 - 0
src/views/dataAdmin/dataAdmin/resVersion/resVersion.data.ts

@@ -0,0 +1,116 @@
+import { FormSchema } from '/@/components/Table';
+
+const getVersionSelect = () => {
+    return new Promise((resolve) => {
+        resolve([
+            {
+                label: '版本1',
+                value: '版本1'
+            },
+            {
+                label: '版本2',
+                value: '版本2'
+            }
+        ])
+    })
+}
+export const formSchema: FormSchema[] = [
+    {
+        field: 'fid',
+        label: '版本id',
+        component: 'Input',
+        ifShow: false
+    },
+    {
+        field: 'addType',
+        label: '版本添加',
+        component: 'RadioGroup',
+        ifShow: true,
+        required: true,
+        defaultValue: '0',
+        componentProps({ formActionType }) {
+            const { updateSchema } = formActionType;
+            return {
+                options: [
+                    {
+                        label: '新增版本',
+                        value: '0'
+                    },
+                    {
+                        label: '已有版本',
+                        value: '1'
+                    }
+                ],
+                onChange(event: ChangeEvent) {
+                    if ((event.target as HTMLInputElement).value === "0") {
+                        updateSchema({ field: 'version_NAME', ifShow: true })
+                        updateSchema({ field: 'version_NAME_1', ifShow: false })
+                    } else {
+                        updateSchema({ field: 'version_NAME', ifShow: false })
+                        updateSchema({ field: 'version_NAME_1', ifShow: true })
+                    }
+                },
+                disabled: false
+            };
+        },
+    },
+    {
+        field: 'version_NAME',
+        label: '版本名称',
+        component: 'Input',
+        ifShow: true,
+        required: true,
+        componentProps: {
+            maxLength: 36,
+            placeholder: '请输入版本名称',
+            disabled: false
+        },
+    },
+    {
+        field: 'version_NAME_1',
+        label: '版本名称',
+        component: 'ApiSelect',
+        ifShow: false,
+        required: true,
+        componentProps: {
+            api: getVersionSelect,
+            placeholder: '请选择版本名称',
+            disabled: false
+        },
+    },
+    {
+        field: 'version_NO',
+        label: '版本号',
+        component: 'Input',
+        ifShow: true,
+        required: false,
+        componentProps: {
+            maxLength: 36,
+            placeholder: '自动生成版本号',
+            disabled: true
+        },
+    },
+    {
+        field: 'version_DISP',
+        label: '备注',
+        component: 'Input',
+        ifShow: true,
+        componentProps: {
+            maxLength: 255,
+            disabled: false
+        },
+        dynamicRules: () => {
+            return [
+                {
+                    required: false,
+                    validator: (_, value) => {
+                        if (String(value).length > 255) {
+                            return Promise.reject('字数不超过255个字');
+                        }
+                        return Promise.resolve();
+                    },
+                },
+            ];
+        },
+    }
+];

+ 15 - 8
src/views/dataAdmin/dataAdmin/version/VersionManageModal.vue

@@ -28,7 +28,13 @@ export default defineComponent({
                 updateSchema([
                     { field: 'addType', ifShow: false }
                 ])
-                setFieldsValue({ ...data.form })
+                const { FID, VERSION_NAME, VERSION_NO, VERSION_DISP } = data.form;
+                setFieldsValue({ 
+                    fid: FID,
+                    version_NAME: VERSION_NAME,
+                    version_NO: VERSION_NO,
+                    version_DISP: VERSION_DISP
+                 })
             }
             modalStatus.value = data.status;
         });
@@ -51,9 +57,9 @@ export default defineComponent({
             resetFields();
             updateSchema([
                 { field: 'addType', ifShow: true },
-                { field: 'VERSION_NAME', ifShow: true, componentProps: { disabled: false } },
-                { field: 'VERSION_NAME_1', ifShow: false, componentProps: { disabled: false } },
-                { field: 'VERSION_DISP', componentProps: { disabled: false } }
+                { field: 'version_NAME', ifShow: true, componentProps: { disabled: false } },
+                { field: 'version_NAME_1', ifShow: false, componentProps: { disabled: false } },
+                { field: 'version_DISP', componentProps: { disabled: false } }
             ])
         }
         // 提交信息
@@ -61,8 +67,9 @@ export default defineComponent({
             if (modalStatus.value === 'add') {
                 validate().then(async (res) => {
                     if (res) {
-                        const { VERSION_NAME, VERSION_DISP } = JSON.parse(JSON.stringify(res));
-                        await saveVersion({ version: { VERSION_NAME, VERSION_DISP } }).then((saveRes) => {
+                        const { addType, version_NAME, version_NAME_1, version_DISP } = JSON.parse(JSON.stringify(res));
+                        const realName = addType === '1' ? version_NAME_1 : version_NAME;
+                        await saveVersion({ version: { version_NAME: realName, version_DISP } }).then((saveRes) => {
                             console.log(saveRes)
                         })
                         console.log('res', res);
@@ -75,8 +82,8 @@ export default defineComponent({
             } else if (modalStatus.value === 'edit') {
                 validate().then(async (res) => {
                     if (res) {
-                        const { FID, VERSION_NAME, VERSION_DISP } = JSON.parse(JSON.stringify(res));
-                        await saveVersion({ version: { FID, VERSION_NAME, VERSION_DISP } }).then((saveRes) => {
+                        const { fid, version_NAME, version_DISP } = JSON.parse(JSON.stringify(res));
+                        await saveVersion({ version: { fid, version_NAME, version_DISP } }).then((saveRes) => {
                             console.log(saveRes)
                         })
                         console.log('res', res);

+ 30 - 18
src/views/dataAdmin/dataAdmin/version/version.data.ts

@@ -1,22 +1,34 @@
 import { FormSchema } from '/@/components/Table';
+import { getVersionList } from '/@/api/sys/version';
 
 const getVersionSelect = () => {
     return new Promise((resolve) => {
-        resolve([
-            {
-                label: '版本1',
-                value: '版本1'
-            },
-            {
-                label: '版本2',
-                value: '版本2'
+        let params = {
+            keyStr: ""
+        }
+        getVersionList(params).then(res => {
+            if (res.resp_code === 0 && res.datas) {
+                let resData:Array<{ label: string, value: string }> = []
+                res.datas.pageData.forEach(element => {
+                    resData.push(
+                        {
+                            label: element.VERSION_NAME,
+                            value: element.VERSION_NAME
+                        }
+                    )
+                });
+                resolve(resData)
+            }
+            else {
+                resolve([])
             }
-        ])
+        })
+
     })
 }
 export const formSchema: FormSchema[] = [
     {
-        field: 'FID',
+        field: 'fid',
         label: '版本id',
         component: 'Input',
         ifShow: false
@@ -43,11 +55,11 @@ export const formSchema: FormSchema[] = [
                 ],
                 onChange(event: ChangeEvent) {
                     if ((event.target as HTMLInputElement).value === "0") {
-                        updateSchema({ field: 'VERSION_NAME', ifShow: true })
-                        updateSchema({ field: 'VERSION_NAME_1', ifShow: false })
+                        updateSchema({ field: 'version_NAME', ifShow: true })
+                        updateSchema({ field: 'version_NAME_1', ifShow: false })
                     } else {
-                        updateSchema({ field: 'VERSION_NAME', ifShow: false })
-                        updateSchema({ field: 'VERSION_NAME_1', ifShow: true })
+                        updateSchema({ field: 'version_NAME', ifShow: false })
+                        updateSchema({ field: 'version_NAME_1', ifShow: true })
                     }
                 },
                 disabled: false
@@ -55,7 +67,7 @@ export const formSchema: FormSchema[] = [
         },
     },
     {
-        field: 'VERSION_NAME',
+        field: 'version_NAME',
         label: '版本名称',
         component: 'Input',
         ifShow: true,
@@ -67,7 +79,7 @@ export const formSchema: FormSchema[] = [
         },
     },
     {
-        field: 'VERSION_NAME_1',
+        field: 'version_NAME_1',
         label: '版本名称',
         component: 'ApiSelect',
         ifShow: false,
@@ -79,7 +91,7 @@ export const formSchema: FormSchema[] = [
         },
     },
     {
-        field: 'VERSION_NO',
+        field: 'version_NO',
         label: '版本号',
         component: 'Input',
         ifShow: true,
@@ -91,7 +103,7 @@ export const formSchema: FormSchema[] = [
         },
     },
     {
-        field: 'VERSION_DISP',
+        field: 'version_DISP',
         label: '备注',
         component: 'Input',
         ifShow: true,