|
@@ -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>
|