浏览代码

参数配置

CzRger 1 年之前
父节点
当前提交
9d585cbf9b

+ 71 - 0
src/api/modules/ship-test/params.ts

@@ -0,0 +1,71 @@
+import { handle } from '../../index'
+
+const suffix = 'ax-node-api'
+
+export const shipTestParamsList = (params: any) => handle({
+  url: `/${suffix}/ship-test/params/list`,
+  method: 'post',
+  params
+})
+export const shipTestParamsPage = (params: any) => handle({
+  url: `/${suffix}/ship-test/params/page`,
+  method: 'post',
+  params
+})
+export const shipTestParamsInfo = (id: any) => handle({
+  url: `/${suffix}/ship-test/params/info/${id}`,
+  method: 'get',
+})
+export const shipTestParamsAdd = (params: any) => handle({
+  url: `/${suffix}/ship-test/params/add`,
+  method: 'post',
+  params
+})
+export const shipTestParamsEdit = (params: any) => handle({
+  url: `/${suffix}/ship-test/params/edit`,
+  method: 'put',
+  params
+})
+export const shipTestParamsDel = (params: any) => handle({
+  url: `/${suffix}/ship-test/params/del/`,
+  method: 'delete',
+  params
+})
+// 参数配置-字典
+export const shipTestParamsDictList = (params: any) => handle({
+  url: `/${suffix}/ship-test/params/dict/list`,
+  method: 'post',
+  params
+})
+export const shipTestParamsDictPage = (params: any) => handle({
+  url: `/${suffix}/ship-test/params/dict/page`,
+  method: 'post',
+  params
+})
+export const shipTestParamsDictInfo = (id: any) => handle({
+  url: `/${suffix}/ship-test/params/dict/info/${id}`,
+  method: 'get',
+})
+export const shipTestParamsDictAdd = (params: any) => handle({
+  url: `/${suffix}/ship-test/params/dict/add`,
+  method: 'post',
+  params
+})
+export const shipTestParamsDictEdit = (params: any) => handle({
+  url: `/${suffix}/ship-test/params/dict/edit`,
+  method: 'put',
+  params
+})
+export const shipTestParamsDictDel = (params: any) => handle({
+  url: `/${suffix}/ship-test/params/dict/del/`,
+  method: 'delete',
+  params
+})
+export const shipTestParamsDictEnabled = (ids: any) => handle({
+  url: `/${suffix}/ship-test/params/dict/enabled/${ids}`,
+  method: 'get',
+})
+export const shipTestParamsDictDisabled = (ids: any) => handle({
+  url: `/${suffix}/ship-test/params/dict/disabled/${ids}`,
+  method: 'get',
+})

二进制
src/assets/images/cus/tree-search.png


+ 3 - 3
src/components/cus/CusDialog.vue

@@ -129,17 +129,17 @@ export default defineComponent({
           type: "warning",
         }).then(() => {
           emit('update:show', false)
-          emit('close')
+          emit('onClose')
           done()
         }).catch(() => {})
       } else {
         emit('update:show', false)
-        emit('close')
+        emit('onClose')
         done()
       }
     }
     const CDSubmit = () => {
-      emit('submit')
+      emit('onSubmit')
     }
     onMounted(() => {
       state.showDialog = props.show

+ 1 - 1
src/components/cus/CusForm.vue

@@ -1,6 +1,6 @@
 <template>
   <div class="cus-form">
-    <el-form ref="ref_cusForm" :label-width="labelWidth" v-bind="$attrs">
+    <el-form ref="ref_cusForm" :label-width="labelWidth" v-bind="$attrs" @submit.native.prevent>
       <el-row style="display:flex; flex-wrap: wrap">
         <slot/>
       </el-row>

+ 1 - 1
src/router/ship-test.ts

@@ -20,7 +20,7 @@ const aisTestRouter = [
       {
         name: '4e53c650-a86c-4fde-83b2-eb316dd5e66a',
         path: 'params',
-        component: () => import('@/views/ship-test/manage/params.vue'),
+        component: () => import('@/views/ship-test/manage/params/index.vue'),
         meta: {
           title: '参数配置'
         }

+ 0 - 43
src/views/ship-test/manage/params.vue

@@ -1,43 +0,0 @@
-<template>
-  <div class="ss">
-  </div>
-</template>
-
-<script lang="ts">
-import {
-  defineComponent,
-  computed,
-  onMounted,
-  ref,
-  reactive,
-  watch,
-  getCurrentInstance,
-  ComponentInternalInstance,
-  toRefs,
-  nextTick
-} from 'vue'
-import {useStore} from 'vuex'
-import {useRouter, useRoute} from 'vue-router'
-import {ElMessage, ElMessageBox} from "element-plus";
-
-export default defineComponent({
-  name: '',
-  components: {},
-  props: {},
-  setup(props, {emit}) {
-    const store = useStore();
-    const router = useRouter();
-    const route = useRoute();
-    const that = (getCurrentInstance() as ComponentInternalInstance).appContext.config.globalProperties
-    const state = reactive({})
-    onMounted(() => {
-    })
-    return {
-      ...toRefs(state),
-    }
-  },
-})
-</script>
-
-<style scoped lang="scss">
-</style>

+ 139 - 0
src/views/ship-test/manage/params/detail.vue

@@ -0,0 +1,139 @@
+<template>
+  <CusDialog
+      :title="transfer.method === 'add' ? '新增数据源' : '数据源详情'"
+      :show="show"
+      @onClose="$emit('update:show', false)"
+      @onSubmit="onSubmit"
+      height="auto"
+      :closeConfirm="!isViewCpt"
+      :loading="loading"
+      :showSubmit="!isViewCpt"
+  >
+    <div class="__normal-form">
+      <CusForm labelWidth="120px" ref="ref_form" :formView="isViewCpt">
+        <CusFormColumn
+            :span="24"
+            required
+            label="名称"
+            v-model:param="cusDetail.name"
+            :maxLength="20"/>
+        <CusFormColumn
+            :span="12"
+            label="排序"
+            link="input-number"
+            :min="0"
+            :max="999"
+            v-model:param="cusDetail.sort"/>
+        <CusFormColumn
+            :span="24"
+            label="备注"
+            type="textarea"
+            v-model:param="cusDetail.remark"
+            :rows="4"
+            maxlength="225"
+            show-word-limit/>
+      </CusForm>
+    </div>
+  </CusDialog>
+</template>
+
+<script lang="ts">
+import {
+  defineComponent,
+  computed,
+  onMounted,
+  ref,
+  reactive,
+  watch,
+  getCurrentInstance,
+  ComponentInternalInstance,
+  toRefs,
+  nextTick
+} from 'vue'
+import {useStore} from 'vuex'
+import {useRouter, useRoute} from 'vue-router'
+import {ElMessage, ElMessageBox } from 'element-plus';
+
+export default defineComponent({
+  name: '',
+  components: {},
+  props: {
+    show: {},
+    transfer: <any>{}
+  },
+  setup(props, {emit}) {
+    const store = useStore();
+    const router = useRouter();
+    const route = useRoute();
+    const that = (getCurrentInstance() as ComponentInternalInstance).appContext.config.globalProperties
+    const state = reactive({
+      cusDetail: {},
+      loading: false
+    })
+    watch(() => props.show, (n) => {
+      if (n) {
+        state.cusDetail = {
+          sourceId: props.transfer.sourceId
+        }
+        if (props.transfer.method !== 'add') {
+          state.loading = true
+          that.$api.shipTestParamsInfo(props.transfer.id).then(res => {
+            if (res.code === 200) {
+              state.cusDetail = res.data
+              state.loading = false
+            } else {
+              ElMessage.error(res.msg)
+            }
+          })
+        }
+        nextTick(() => {
+          ref_form.value.reset()
+        })
+      }
+    })
+    const ref_form = ref()
+    const isViewCpt = computed(() => {
+      return props.transfer.method === 'view'
+    })
+    const onSubmit = () => {
+      ref_form.value.submit().then(() => {
+        ElMessageBox.confirm("是否提交?", "提示", {
+          confirmButtonText: "确定",
+          cancelButtonText: "取消",
+          type: "warning",
+        }).then(() => {
+          state.loading = true
+          const apiHandle = props.transfer.method === 'edit' ? that.$api.shipTestParamsEdit(state.cusDetail) : that.$api.shipTestParamsAdd(state.cusDetail)
+          apiHandle.then(res => {
+            if (res.code === 200) {
+              ElMessage.success(props.transfer.method === 'edit' ? '编辑成功' : '新增成功')
+              emit('update:show', false)
+              emit('refresh')
+            } else {
+              ElMessage.error(res.msg)
+            }
+            state.loading = false
+          }).catch(() => {
+            state.loading = false
+          })
+        }).catch(() => {})
+      }).catch((e) => {
+        ElMessage({
+          message: e[0].message,
+          grouping: true,
+          type: 'warning',
+        })
+      })
+    }
+    return {
+      ...toRefs(state),
+      onSubmit,
+      isViewCpt,
+      ref_form
+    }
+  },
+})
+</script>
+
+<style scoped lang="scss">
+</style>

+ 156 - 0
src/views/ship-test/manage/params/dict-detail.vue

@@ -0,0 +1,156 @@
+<template>
+  <CusDialog
+      :title="transfer.method === 'add' ? '新增字典' : '字典详情'"
+      :show="show"
+      @onClose="$emit('update:show', false)"
+      @onSubmit="onSubmit"
+      height="auto"
+      :closeConfirm="!isViewCpt"
+      :loading="loading"
+      :showSubmit="!isViewCpt"
+  >
+    <div class="__normal-form">
+      <CusForm labelWidth="120px" ref="ref_form" :formView="isViewCpt">
+        <CusFormColumn
+            :span="24"
+            required
+            label="名称"
+            v-model:param="cusDetail.name"
+            :maxLength="20"/>
+        <CusFormColumn
+            :span="12"
+            label="排序"
+            link="input-number"
+            :min="0"
+            :max="999"
+            v-model:param="cusDetail.sort"/>
+        <CusFormColumn
+            :span="12"
+            required
+            label="默认激活"
+            link="switch"
+            v-model:param="cusDetail.active"
+            :active-value="0"
+            :inactive-value="1"
+        />
+        <CusFormColumn
+            :span="24"
+            required
+            label="cql"
+            type="textarea"
+            v-model:param="cusDetail.cql"
+            :rows="4"/>
+        <CusFormColumn
+            :span="24"
+            label="备注"
+            type="textarea"
+            v-model:param="cusDetail.remark"
+            :rows="4"
+            maxlength="225"
+            show-word-limit/>
+      </CusForm>
+    </div>
+  </CusDialog>
+</template>
+
+<script lang="ts">
+import {
+  defineComponent,
+  computed,
+  onMounted,
+  ref,
+  reactive,
+  watch,
+  getCurrentInstance,
+  ComponentInternalInstance,
+  toRefs,
+  nextTick
+} from 'vue'
+import {useStore} from 'vuex'
+import {useRouter, useRoute} from 'vue-router'
+import {ElMessage, ElMessageBox } from 'element-plus';
+
+export default defineComponent({
+  name: '',
+  components: {},
+  props: {
+    show: {},
+    transfer: <any>{}
+  },
+  setup(props, {emit}) {
+    const store = useStore();
+    const router = useRouter();
+    const route = useRoute();
+    const that = (getCurrentInstance() as ComponentInternalInstance).appContext.config.globalProperties
+    const state = reactive({
+      cusDetail: {},
+      loading: false
+    })
+    watch(() => props.show, (n) => {
+      if (n) {
+        state.cusDetail = {
+          paramsId: props.transfer.paramsId,
+          active: 0
+        }
+        if (props.transfer.method !== 'add') {
+          state.loading = true
+          that.$api.shipTestParamsDictInfo(props.transfer.id).then(res => {
+            if (res.code === 200) {
+              state.cusDetail = res.data
+              state.loading = false
+            } else {
+              ElMessage.error(res.msg)
+            }
+          })
+        }
+        nextTick(() => {
+          ref_form.value.reset()
+        })
+      }
+    })
+    const ref_form = ref()
+    const isViewCpt = computed(() => {
+      return props.transfer.method === 'view'
+    })
+    const onSubmit = () => {
+      ref_form.value.submit().then(() => {
+        ElMessageBox.confirm("是否提交?", "提示", {
+          confirmButtonText: "确定",
+          cancelButtonText: "取消",
+          type: "warning",
+        }).then(() => {
+          state.loading = true
+          const apiHandle = props.transfer.method === 'edit' ? that.$api.shipTestParamsDictEdit(state.cusDetail) : that.$api.shipTestParamsDictAdd(state.cusDetail)
+          apiHandle.then(res => {
+            if (res.code === 200) {
+              ElMessage.success(props.transfer.method === 'edit' ? '编辑成功' : '新增成功')
+              emit('update:show', false)
+              emit('refresh')
+            } else {
+              ElMessage.error(res.msg)
+            }
+            state.loading = false
+          }).catch(() => {
+            state.loading = false
+          })
+        }).catch(() => {})
+      }).catch((e) => {
+        ElMessage({
+          message: e[0].message,
+          grouping: true,
+          type: 'warning',
+        })
+      })
+    }
+    return {
+      ...toRefs(state),
+      onSubmit,
+      isViewCpt,
+      ref_form
+    }
+  },
+})
+</script>
+
+<style scoped lang="scss">
+</style>

+ 325 - 0
src/views/ship-test/manage/params/dict-list.vue

@@ -0,0 +1,325 @@
+<template>
+  <CusDialog
+      :title="transfer.paramsName + '_字典项'"
+      :show="show"
+      @onClose="$emit('update:show', false)"
+      height="80%"
+      width="70%"
+      :loading="loading"
+      :showSubmit="false"
+      :showClose="false"
+  >
+    <div style="width: 100%; height: 100%;">
+      <CusContent
+        v-model:tableHead="tableHead"
+        @handleReset="handleReset"
+        @handleSearch="onSearch"
+        v-model:full="isFull"
+      >
+        <template #fieldOut>
+          <CusForm labelWidth="60px" @handleEnter="onSearch">
+            <CusFormColumn
+              :span="6"
+              label="名称"
+              v-model:param="queryForm.name"/>
+            <CusSearchButtons
+              @handleReset="handleReset"
+              @handleSearch="onSearch"
+            />
+          </CusForm>
+        </template>
+        <template #buttons>
+          <btn-add @click="onAdd"/>
+          <btn-delete @click="onDel()"/>
+          <btn-enable @click="switchActiveMore(0)"/>
+          <btn-disable @click="switchActiveMore(1)"/>
+        </template>
+        <template #table>
+          <CusTable
+            v-loading="loading"
+            ref="ref_cusTable"
+            :tableData="queryResult.tableData"
+            :tableHead="tableHead"
+            :total="queryResult.tableData.length"
+            @handleSort="handleSort"
+            v-model:selected="selected"
+            v-model:full="isFull"
+            noPage
+          >
+            <template #active-column-value="{ scope }">
+              <el-switch
+                v-model="scope.row.active"
+                :active-value="0"
+                :inactive-value="1"
+                :loading="scope.row.loading"
+                @change="switchActive(scope.row)"
+              >
+              </el-switch>
+            </template>
+            <template #caozuo-column-value="{ scope }">
+              <el-link
+                href="javascript:;"
+                type="primary"
+                @click="onEdit(scope.row)"
+              >编辑</el-link>
+              <el-link
+                href="javascript:;"
+                type="danger"
+                @click="onDel(scope.row)"
+              >删除</el-link>
+            </template>
+          </CusTable>
+        </template>
+      </CusContent>
+      <DictDetailCom v-model:show="showDictDetail" :transfer="transferDictDetail" @refresh="refreshSearch"/>
+    </div>
+  </CusDialog>
+</template>
+
+<script lang="ts">
+import {
+  defineComponent,
+  computed,
+  onMounted,
+  ref,
+  reactive,
+  watch,
+  getCurrentInstance,
+  ComponentInternalInstance,
+  toRefs,
+  nextTick
+} from 'vue'
+import {useStore} from 'vuex'
+import {useRouter, useRoute} from 'vue-router'
+import {ElMessage, ElMessageBox } from 'element-plus';
+import DictDetailCom from './dict-detail.vue'
+import DetailCom from "@/views/ship-test/manage/params/detail.vue";
+import {shipTestParamsDictDisabled, shipTestParamsDictEnabled} from "@/api/modules/ship-test/params";
+import BtnDelete from "@/components/button/btn-delete.vue";
+import BtnEnable from "@/components/button/btn-enable.vue";
+import BtnDisable from "@/components/button/btn-disable.vue";
+
+export default defineComponent({
+  name: '',
+  components: {
+    BtnDisable,
+    BtnEnable,
+    BtnDelete,
+    DetailCom,
+    DictDetailCom
+  },
+  props: {
+    show: {},
+    transfer: <any>{}
+  },
+  setup(props, {emit}) {
+    const store = useStore();
+    const router = useRouter();
+    const route = useRoute();
+    const that = (getCurrentInstance() as ComponentInternalInstance).appContext.config.globalProperties
+    const state = reactive({
+      //  加载中
+      loading: false,
+      //  查询结果
+      queryResult: {
+        total: 0,
+        tableData: []
+      },
+      //  查询表单参数
+      queryForm: <any>{},
+      //  查询表单参数备份
+      back_queryForm: {},
+      //  查询表格排序
+      querySort: {},
+      //  表格可选的情况下,绑定的数组
+      selected: [],
+      //  表格表头
+      tableHead: [
+        {value: 'name', label: '名称', show:true,},
+        {value: 'cql', label: 'cql过滤', show:true,},
+        {value: 'sort', label: '排序', show:true, sort: true},
+        {value: 'active', label: '默认激活', show:true},
+        {value: 'updateTime', label: '更新时间', show:true, sort: true},
+        {value: 'caozuo', label: '操作', show:true}
+      ],
+      isFull: false,
+      showDictDetail: false,
+      transferDictDetail: {}
+    })
+    watch(() => props.show, (n) => {
+      if (n) {
+        handleReset()
+      }
+    })
+    const ref_cusTable = ref()
+    //  查询排序参数改变处理方法
+    const handleSort = ({key, value}: any) => {
+      state.querySort = key ? {[key]: value} : {}
+      refreshSearch()
+    }
+    //  列表刷新方法
+    const refreshSearch = () => {
+      handleSearch()
+    }
+    //  重置查询表单方法
+    const handleReset = () => {
+      ref_cusTable.value?.reset()
+      state.querySort = {}
+      state.queryForm = {}
+      state.back_queryForm = JSON.parse(JSON.stringify(state.queryForm))
+      refreshSearch()
+    }
+    //  查询方法
+    const handleSearch = () => {
+      //  添加分页参数
+      const queryParams: any = {
+        paramsId: props.transfer.paramsId
+      }
+      //  添加排序参数
+      for (const [k, v] of Object.entries(state.querySort)) {
+        if (that.$util.isValue(v)) {
+          queryParams['orderByColumn'] = k
+          queryParams['isAsc'] = v === "ascending"
+        }
+      }
+      //  添加表单参数
+      for (const [k, v] of Object.entries(state.back_queryForm)) {
+        if (that.$util.isValue(v)) {
+          queryParams[k] = v
+        }
+      }
+      state.loading = true
+      that.$api.shipTestParamsDictList(queryParams).then((res) => {
+        if (res.code === 200) {
+          state.queryResult.tableData = res.data
+        } else {
+          ElMessage.error(res.msg)
+        }
+        state.loading = false
+      }).catch(() => {
+        state.loading = false
+      })
+    }
+    //  点击查询按钮后
+    const onSearch = () => {
+      state.back_queryForm = JSON.parse(JSON.stringify(state.queryForm))
+      refreshSearch()
+    }
+    const onAdd = () => {
+      state.transferDictDetail = {
+        method: 'add',
+        paramsId: props.transfer.paramsId
+      }
+      state.showDictDetail = true
+    }
+    const onEdit = (row) => {
+      state.transferDictDetail = {
+        method: 'edit',
+        id: row.id
+      }
+      state.showDictDetail = true
+    }
+    const onView = (row) => {
+      state.transferDictDetail = {
+        method: 'view',
+        id: row.id
+      }
+      state.showDictDetail = true
+    }
+    const onDel = (row: any = null) => {
+      const arr = row ? [row] : state.selected
+      if (arr.length > 0) {
+        ElMessageBox.confirm(`是否删除${arr.length === 1 ? arr[0].name : `${arr.length}条记录`}?`, "提示", {
+          confirmButtonText: "确定",
+          cancelButtonText: "取消",
+          type: "warning",
+        }).then(() => {
+          state.loading = true
+          that.$api.shipTestParamsDictDel(arr.map(v => v.id).join(',')).then(res => {
+            if (res.code === 200) {
+              ElMessage.success('删除成功')
+              refreshSearch()
+            } else {
+              ElMessage.error(res.msg)
+              state.loading = false
+            }
+          }).catch(() => {
+            state.loading = false
+          })
+        }).catch(() => {
+        })
+      } else {
+        ElMessage.warning('请至少选择一条记录!')
+      }
+    }
+    const switchActive = (row) => {
+      if (row.id) {
+        ElMessageBox.confirm(`是否默认${row.active == 0 ? '激活' : '不激活'}${row.name}?`, "提示", {
+          confirmButtonText: "确定",
+          cancelButtonText: "取消",
+          type: "warning",
+        }).then(() => {
+          row.loading = true
+          const apiHandle = row.active == 0 ? that.$api.shipTestParamsDictEnabled(row.id) : that.$api.shipTestParamsDictDisabled(row.id)
+          apiHandle.then(res => {
+            if (res.code === 200) {
+              ElMessage.success('操作成功')
+            } else {
+              ElMessage.error(res.msg)
+              row.active = row.active == 1 ? 0 : 1
+            }
+            row.loading = false
+          }).catch(() => {
+            row.loading = false
+            row.active = row.active == 1 ? 0 : 1
+          })
+        }).catch(() => {
+          row.active = row.active == 1 ? 0 : 1
+        })
+      }
+    }
+    const switchActiveMore = (active) => {
+      if (state.selected.length > 0) {
+        ElMessageBox.confirm(`是否批量默认${active == 0 ? '激活' : '不激活'}${state.selected.length}条记录?`, "提示", {
+          confirmButtonText: "确定",
+          cancelButtonText: "取消",
+          type: "warning",
+        }).then(() => {
+          const ids = state.selected.map(v => v.id).join(',')
+          const apiHandle = active == 0 ? that.$api.shipTestParamsDictEnabled(ids) : that.$api.shipTestParamsDictDisabled(ids)
+          apiHandle.then(res => {
+            if (res.code === 200) {
+              ElMessage.success('操作成功')
+            } else {
+              ElMessage.error(res.msg)
+            }
+            handleSearch()
+          }).catch(() => {
+          })
+        }).catch(() => {
+        })
+      } else {
+        ElMessage.warning('请至少选择一条记录!')
+      }
+    }
+    return {
+      ...toRefs(state),
+      ref_cusTable,
+      handleSearch,
+      refreshSearch,
+      handleSort,
+      handleReset,
+      onSearch,
+      onAdd,
+      onEdit,
+      onView,
+      onDel,
+      switchActive,
+      switchActiveMore
+    }
+  },
+})
+</script>
+
+<style scoped lang="scss">
+</style>

+ 327 - 0
src/views/ship-test/manage/params/index.vue

@@ -0,0 +1,327 @@
+<template>
+  <div class="__normal-page">
+    <div class="__normal-tree">
+      <div class="__normal-tree_filter">
+        <el-input v-model="treeName" placeholder="请输入关键词进行搜索" clearable>
+          <template #suffix>
+            <img src="@/assets/images/cus/tree-search.png" alt=""/>
+          </template>
+        </el-input>
+      </div>
+      <div class="__normal-tree_content">
+        <el-tree
+          ref="ref_tree"
+          :data="treeData"
+          node-key="id"
+          :props="{
+              children: 'children',
+              label: 'name',
+            }"
+          @node-click="handleNodeClick"
+          :expand-on-click-node="false"
+          highlight-current
+          :filter-node-method="treeFilter"
+        />
+      </div>
+    </div>
+    <div class="__normal-content" v-if="currentSource">
+      <CusContent
+          v-model:tableHead="tableHead"
+          @handleReset="handleReset"
+          @handleSearch="onSearch"
+          v-model:full="isFull"
+      >
+        <template #fieldOut>
+          <CusForm labelWidth="100px" @handleEnter="onSearch">
+            <CusFormColumn
+                filterSpan="1"
+                label="名称"
+                v-model:param="queryForm.name"/>
+            <CusSearchButtons
+                @handleReset="handleReset"
+                @handleSearch="onSearch"
+            />
+          </CusForm>
+        </template>
+        <template #buttons>
+          <btn-add @click="onAdd"/>
+          <btn-delete @click="onDel()"/>
+        </template>
+        <template #table>
+          <CusTable
+              v-loading="loading"
+              ref="ref_cusTable"
+              :tableData="queryResult.tableData"
+              :tableHead="tableHead"
+              :total="queryResult.total"
+              :page="queryPage.pageNum"
+              :pageSize="queryPage.pageSize"
+              @handlePage="handlePage"
+              @handleSort="handleSort"
+              v-model:selected="selected"
+              v-model:full="isFull"
+          >
+            <template #name-column-value="{ scope }">
+              <el-link
+                  class="__text-ellipsis"
+                  href="javascript:;"
+                  type="primary"
+                  @click="onView(scope.row)"
+              >{{scope.row.name}}</el-link>
+            </template>
+            <template #caozuo-column-value="{ scope }">
+              <el-link
+                  href="javascript:;"
+                  type="primary"
+                  @click="onEdit(scope.row)"
+              >编辑</el-link>
+              <el-link
+                  href="javascript:;"
+                  type="primary"
+                  @click="onDict(scope.row)"
+              >字典</el-link>
+              <el-link
+                  href="javascript:;"
+                  type="danger"
+                  @click="onDel(scope.row)"
+              >删除</el-link>
+            </template>
+          </CusTable>
+        </template>
+      </CusContent>
+    </div>
+    <DetailCom v-model:show="showDetail" :transfer="transfer" @refresh="refreshSearch"/>
+    <DictListCom v-model:show="showDictList" :transfer="transferDictList"/>
+  </div>
+</template>
+
+<script lang="ts">
+import {
+  defineComponent,
+  onMounted,
+  ref,
+  toRefs,
+  reactive,
+  watch,
+  getCurrentInstance,
+  ComponentInternalInstance,
+  computed,
+} from "vue";
+import { useStore } from "vuex";
+import { useRouter, useRoute } from "vue-router";
+import { ElMessage, ElMessageBox } from "element-plus";
+import DetailCom from './detail.vue'
+import DictListCom from './dict-list.vue'
+
+export default defineComponent({
+  name: "",
+  components: {
+    DetailCom,
+    DictListCom
+  },
+  setup(props, {emit}) {
+    const store = useStore();
+    const that = (getCurrentInstance() as ComponentInternalInstance).appContext.config.globalProperties;
+    const state = reactive({
+      //  加载中
+      loading: false,
+      //  查询分页参数
+      queryPage: {
+        pageNum: 1,
+        pageSize: 10
+      },
+      //  查询结果
+      queryResult: {
+        total: 0,
+        tableData: []
+      },
+      //  查询表单参数
+      queryForm: <any>{},
+      //  查询表单参数备份
+      back_queryForm: {},
+      //  查询表格排序
+      querySort: {},
+      //  表格可选的情况下,绑定的数组
+      selected: [],
+      //  表格表头
+      tableHead: [
+        {value: 'name', label: '名称', show:true,},
+        {value: 'sort', label: '排序', show:true, sort: true},
+        {value: 'updateTime', label: '更新时间', show:true, sort: true},
+        {value: 'caozuo', label: '操作', show:true}
+      ],
+      isFull: false,
+      transfer: {},
+      showDetail: false,
+      transferDictList: {},
+      showDictList: false,
+      treeData: [],
+      treeName: '',
+      currentSource: <any>null
+    });
+    const ref_cusTable = ref()
+    //  获取字典
+    const initDictionary = () => {
+    }
+    //  查询分页参数改变处理方法
+    const handlePage = ({page, pageSize}: any) => {
+      state.queryPage.pageNum = page
+      state.queryPage.pageSize = pageSize
+      handleSearch(page, pageSize)
+    }
+    //  查询排序参数改变处理方法
+    const handleSort = ({key, value}: any) => {
+      state.querySort = key ? {[key]: value} : {}
+      refreshSearch()
+    }
+    //  列表刷新方法
+    const refreshSearch = () => {
+      state.queryPage.pageNum = 1
+      handleSearch(state.queryPage.pageNum, state.queryPage.pageSize)
+    }
+    //  重置查询表单方法
+    const handleReset = () => {
+      ref_cusTable.value?.reset()
+      state.querySort = {}
+      state.queryForm = {}
+      state.back_queryForm = JSON.parse(JSON.stringify(state.queryForm))
+      refreshSearch()
+    }
+    //  查询方法
+    const handleSearch = (page = 1, pageSize = 10) => {
+      //  添加分页参数
+      const queryParams: any = {
+        pageNum: page,
+        pageSize: pageSize,
+        sourceId: state.currentSource.id
+      }
+      //  添加排序参数
+      for (const [k, v] of Object.entries(state.querySort)) {
+        if (that.$util.isValue(v)) {
+          queryParams['orderByColumn'] = k
+          queryParams['isAsc'] = v === "ascending"
+        }
+      }
+      //  添加表单参数
+      for (const [k, v] of Object.entries(state.back_queryForm)) {
+        if (that.$util.isValue(v)) {
+          queryParams[k] = v
+        }
+      }
+      state.loading = true
+      that.$api.shipTestParamsPage(queryParams).then((res) => {
+        if (res.code === 200) {
+          state.queryResult.tableData = res.data.data
+          state.queryResult.total = res.data.total
+        } else {
+          ElMessage.error(res.msg)
+        }
+        state.loading = false
+      }).catch(() => {
+        state.loading = false
+      })
+    }
+    //  点击查询按钮后
+    const onSearch = () => {
+      state.back_queryForm = JSON.parse(JSON.stringify(state.queryForm))
+      refreshSearch()
+    }
+    const onAdd = () => {
+      state.transfer = {
+        method: 'add',
+        sourceId: state.currentSource.id
+      }
+      state.showDetail = true
+    }
+    const onEdit = (row) => {
+      state.transfer = {
+        method: 'edit',
+        id: row.id
+      }
+      state.showDetail = true
+    }
+    const onView = (row) => {
+      state.transfer = {
+        method: 'view',
+        id: row.id
+      }
+      state.showDetail = true
+    }
+    const onDel = (row: any = null) => {
+      const arr = row ? [row] : state.selected
+      if (arr.length > 0) {
+        ElMessageBox.confirm(`是否删除${arr.length === 1 ? arr[0].name : `${arr.length}条记录`}?`, "提示", {
+          confirmButtonText: "确定",
+          cancelButtonText: "取消",
+          type: "warning",
+        }).then(() => {
+          state.loading = true
+          that.$api.shipTestParamsDel(arr.map(v => v.id).join(',')).then(res => {
+            if (res.code === 200) {
+              ElMessage.success('删除成功')
+              refreshSearch()
+            } else {
+              ElMessage.error(res.msg)
+              state.loading = false
+            }
+          }).catch(() => {
+            state.loading = false
+          })
+        }).catch(() => {
+        })
+      } else {
+        ElMessage.warning('请至少选择一条记录!')
+      }
+    }
+    const ref_tree = ref()
+    const handleNodeClick = (data) => {
+      state.currentSource = data
+      handleReset()
+    }
+    const treeFilter = (value, data) => {
+      if (!value) return true
+      return data.name.includes(value)
+    }
+    watch(() => state.treeName, (n) => {
+      ref_tree.value.filter(n)
+    })
+    const initSource = () => {
+      that.$api.shipTestSourceList().then(res => {
+        state.treeData = res.data
+      })
+    }
+    const onDict = (row) => {
+      state.transferDictList = {
+        paramsId: row.id,
+        paramsName: row.name,
+      }
+      state.showDictList = true
+    }
+    onMounted(() => {
+      state.back_queryForm = JSON.parse(JSON.stringify(state.queryForm))
+      initDictionary()
+      initSource()
+    })
+    return {
+      ref_cusTable,
+      ...toRefs(state),
+      handleSearch,
+      refreshSearch,
+      handlePage,
+      handleSort,
+      handleReset,
+      onSearch,
+      onAdd,
+      onEdit,
+      onView,
+      onDel,
+      handleNodeClick,
+      treeFilter,
+      ref_tree,
+      onDict
+    }
+  },
+});
+</script>
+<style scoped lang="scss">
+</style>

+ 2 - 3
src/views/ship-test/manage/source/detail.vue

@@ -2,8 +2,8 @@
   <CusDialog
       :title="transfer.method === 'add' ? '新增数据源' : '数据源详情'"
       :show="show"
-      @close="$emit('update:show', false)"
-      @submit="onSubmit"
+      @onClose="$emit('update:show', false)"
+      @onSubmit="onSubmit"
       height="auto"
       :closeConfirm="!isViewCpt"
       :loading="loading"
@@ -53,7 +53,6 @@ import {
 import {useStore} from 'vuex'
 import {useRouter, useRoute} from 'vue-router'
 import {ElMessage, ElMessageBox } from 'element-plus';
-import {shipTestSourceAdd, shipTestSourceEdit, shipTestSourceInfo} from "@/api/modules/ship-test/source";
 
 export default defineComponent({
   name: '',

+ 0 - 9
src/views/ship-test/manage/source/index.vue

@@ -81,13 +81,10 @@ import { useStore } from "vuex";
 import { useRouter, useRoute } from "vue-router";
 import { ElMessage, ElMessageBox } from "element-plus";
 import DetailCom from './detail.vue'
-import {shipTestList, shipTestPage, shipTestSourceDel, shipTestSourcePage} from "@/api/modules/ship-test/source";
-import BtnDelete from "@/components/button/btn-delete.vue";
 
 export default defineComponent({
   name: "",
   components: {
-    BtnDelete,
     DetailCom,
   },
   setup(props, {emit}) {
@@ -117,19 +114,13 @@ export default defineComponent({
       //  表格表头
       tableHead: [
         {value: 'name', label: '名称', show:true,},
-        {value: 'remark', label: '备注', show:true},
         {value: 'sort', label: '排序', show:true, sort: true},
         {value: 'updateTime', label: '更新时间', show:true, sort: true},
-        {value: 'createTime', label: '创建时间', show:true, sort: true},
         {value: 'caozuo', label: '操作', show:true}
       ],
       isFull: false,
       transfer: {},
       showDetail: false,
-      transferRelationUser: {},
-      showRelationUser: false,
-      transferAuth: {},
-      showAuth: false,
     });
     const ref_cusTable = ref()
     //  获取字典