|
@@ -0,0 +1,173 @@
|
|
|
+<script setup lang="ts">
|
|
|
+import { onMounted, ref } from 'vue';
|
|
|
+import { debounce } from 'lodash-es';
|
|
|
+
|
|
|
+import { useRequest } from '@/hooks/request';
|
|
|
+import { useViewVisible } from '@/hooks/view-visible';
|
|
|
+import { getProtocolStandardParamList } from '@/api';
|
|
|
+
|
|
|
+import type { Key } from 'ant-design-vue/es/table/interface';
|
|
|
+import type { PageParams, ProtocolStandardParam } from '@/types';
|
|
|
+
|
|
|
+interface Props {
|
|
|
+ protocolId?: number;
|
|
|
+}
|
|
|
+
|
|
|
+defineProps<Props>();
|
|
|
+
|
|
|
+const { visible, showView, hideView } = useViewVisible();
|
|
|
+const { handleRequest } = useRequest();
|
|
|
+const paramList = ref<ProtocolStandardParam[]>([]);
|
|
|
+const paramTotal = ref(0);
|
|
|
+const paramNameOrCode = ref('');
|
|
|
+const pageParams = ref<PageParams>({
|
|
|
+ pageIndex: 1,
|
|
|
+ pageSize: 10,
|
|
|
+ pageSorts: [
|
|
|
+ {
|
|
|
+ column: 'id',
|
|
|
+ asc: true,
|
|
|
+ },
|
|
|
+ ],
|
|
|
+});
|
|
|
+
|
|
|
+onMounted(() => {
|
|
|
+ getStandardParams();
|
|
|
+});
|
|
|
+
|
|
|
+const getStandardParams = () => {
|
|
|
+ handleRequest(async () => {
|
|
|
+ const { records, total } = await getProtocolStandardParamList({
|
|
|
+ ...pageParams.value,
|
|
|
+ paramName: paramNameOrCode.value,
|
|
|
+ paramCode: paramNameOrCode.value,
|
|
|
+ });
|
|
|
+
|
|
|
+ paramList.value = records;
|
|
|
+ paramTotal.value = total;
|
|
|
+ });
|
|
|
+};
|
|
|
+
|
|
|
+const handleParamNameOrCodeChange = debounce(() => {
|
|
|
+ pageParams.value.pageIndex = 1;
|
|
|
+ selectedParamIds.value = [];
|
|
|
+ getStandardParams();
|
|
|
+}, 300);
|
|
|
+
|
|
|
+const handlePageChange = (page: number, pageSize: number) => {
|
|
|
+ pageParams.value.pageIndex = page;
|
|
|
+ pageParams.value.pageSize = pageSize;
|
|
|
+ selectedParamIds.value = [];
|
|
|
+ getStandardParams();
|
|
|
+};
|
|
|
+
|
|
|
+const selectedParamIds = ref<number[]>([]);
|
|
|
+
|
|
|
+const handleParamSelectChange = (selectedRowKeys: Key[]) => {
|
|
|
+ selectedParamIds.value = selectedRowKeys as number[];
|
|
|
+};
|
|
|
+
|
|
|
+const handleOk = () => {};
|
|
|
+
|
|
|
+const handleClose = () => {
|
|
|
+ paramList.value = [];
|
|
|
+ paramTotal.value = 0;
|
|
|
+ paramNameOrCode.value = '';
|
|
|
+ pageParams.value.pageIndex = 1;
|
|
|
+ pageParams.value.pageSize = 10;
|
|
|
+ selectedParamIds.value = [];
|
|
|
+};
|
|
|
+
|
|
|
+defineExpose({
|
|
|
+ showView,
|
|
|
+ hideView,
|
|
|
+});
|
|
|
+</script>
|
|
|
+
|
|
|
+<template>
|
|
|
+ <AModal
|
|
|
+ v-model:open="visible"
|
|
|
+ :title="$t('setupProtocol.selectStandardParams')"
|
|
|
+ :width="1092"
|
|
|
+ centered
|
|
|
+ :after-close="handleClose"
|
|
|
+ @ok="handleOk"
|
|
|
+ >
|
|
|
+ <div class="params-container">
|
|
|
+ <div class="params-list">
|
|
|
+ <div class="params-list-header">
|
|
|
+ <span class="params-label">{{ $t('setupProtocol.paramList') }}</span>
|
|
|
+ <AInput
|
|
|
+ v-model:value="paramNameOrCode"
|
|
|
+ class="params-list-input"
|
|
|
+ :placeholder="$t('setupProtocol.plzEnterParamOrCode')"
|
|
|
+ allow-clear
|
|
|
+ @change="handleParamNameOrCodeChange"
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ <ATable
|
|
|
+ :data-source="paramList"
|
|
|
+ row-key="id"
|
|
|
+ :row-selection="{ selectedRowKeys: selectedParamIds, onChange: handleParamSelectChange }"
|
|
|
+ :pagination="{
|
|
|
+ current: pageParams.pageIndex,
|
|
|
+ pageSize: pageParams.pageSize,
|
|
|
+ total: paramTotal,
|
|
|
+ showSizeChanger: true,
|
|
|
+ hideOnSinglePage: false,
|
|
|
+ showTotal: (total) => $t('common.pageTotal', { total }),
|
|
|
+ onChange: handlePageChange,
|
|
|
+ }"
|
|
|
+ >
|
|
|
+ <ATableColumn :title="$t('setupProtocol.protocolParamFields.paramCode')" data-index="paramCode" />
|
|
|
+ <ATableColumn :title="$t('setupProtocol.protocolParamFields.paramName')" data-index="paramName" />
|
|
|
+ <ATableColumn :title="$t('setupProtocol.protocolParamFields.unit')" data-index="unit" />
|
|
|
+ <ATableColumn :title="$t('setupProtocol.protocolParamFields.module')" data-index="module" />
|
|
|
+ </ATable>
|
|
|
+ </div>
|
|
|
+ <div class="params-selected">
|
|
|
+ <div>
|
|
|
+ <span class="params-label">{{ $t('setupProtocol.selectedParams') }} ({{ selectedParamIds.length }})</span>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </AModal>
|
|
|
+</template>
|
|
|
+
|
|
|
+<style lang="scss" scoped>
|
|
|
+.params-container {
|
|
|
+ display: flex;
|
|
|
+ height: 470px;
|
|
|
+ border: 1px solid #e4e7ed;
|
|
|
+ border-radius: 8px;
|
|
|
+}
|
|
|
+
|
|
|
+.params-label {
|
|
|
+ font-size: 14px;
|
|
|
+ font-weight: 500;
|
|
|
+ line-height: 22px;
|
|
|
+ color: #333;
|
|
|
+}
|
|
|
+
|
|
|
+.params-list {
|
|
|
+ flex: 1;
|
|
|
+ padding: 16px 24px;
|
|
|
+}
|
|
|
+
|
|
|
+.params-list-header {
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ justify-content: space-between;
|
|
|
+ margin-bottom: 16px;
|
|
|
+}
|
|
|
+
|
|
|
+.params-list-input {
|
|
|
+ width: 272px;
|
|
|
+}
|
|
|
+
|
|
|
+.params-selected {
|
|
|
+ width: 299px;
|
|
|
+ padding: 16px 24px;
|
|
|
+ border-left: 1px solid #e4e7ed;
|
|
|
+}
|
|
|
+</style>
|