|
@@ -0,0 +1,313 @@
|
|
|
+<template>
|
|
|
+ <CusDialog
|
|
|
+ :show="show"
|
|
|
+ :title="titleCpt"
|
|
|
+ @onClose="$emit('update:show', false)"
|
|
|
+ width="90%"
|
|
|
+ max-height="90%"
|
|
|
+ @onSubmit="onSubmit"
|
|
|
+ :loading="state.loading"
|
|
|
+ >
|
|
|
+ <div class="__cus-dialog-form">
|
|
|
+ <CusForm ref="ref_form" label-width="100px">
|
|
|
+ <CusFormColumn
|
|
|
+ :span="12"
|
|
|
+ label="索引英文"
|
|
|
+ v-model:param="props.transfer.indexTableName"
|
|
|
+ :disabled="true"
|
|
|
+ />
|
|
|
+ <CusFormColumn
|
|
|
+ :span="12"
|
|
|
+ label="索引名称"
|
|
|
+ v-model:param="props.transfer.indexName"
|
|
|
+ :disabled="true"
|
|
|
+ />
|
|
|
+ <CusFormColumn
|
|
|
+ :span="12"
|
|
|
+ required
|
|
|
+ label="索引简称"
|
|
|
+ v-model:param="state.form.indexNameShort"
|
|
|
+ />
|
|
|
+ <CusFormColumn
|
|
|
+ :span="12"
|
|
|
+ required
|
|
|
+ label="主索引"
|
|
|
+ v-model:param="state.form.isMain"
|
|
|
+ link="select"
|
|
|
+ :options="DictionaryStore.isMainIndexList"
|
|
|
+ :disabled="transfer.hasMain"
|
|
|
+ />
|
|
|
+ <CusFormColumn
|
|
|
+ :span="12"
|
|
|
+ label="主显字段"
|
|
|
+ v-model:param="state.form.mainFieldId"
|
|
|
+ link="select"
|
|
|
+ :options="state.textOptions"
|
|
|
+ labelKey="fieldNameCn"
|
|
|
+ valueKey="id"
|
|
|
+ />
|
|
|
+ <CusFormColumn
|
|
|
+ :span="12"
|
|
|
+ label="关联索引"
|
|
|
+ v-model:param="state.form.relateIndexId"
|
|
|
+ link="select"
|
|
|
+ :options="transfer.relationOptions"
|
|
|
+ static
|
|
|
+ />
|
|
|
+ <CusFormColumn
|
|
|
+ :span="12"
|
|
|
+ :required="state.form.relateIndexId == 1"
|
|
|
+ label="权重"
|
|
|
+ v-model:param="state.form.weight"
|
|
|
+ link="select"
|
|
|
+ :options="DictionaryStore.nodeSizeList"
|
|
|
+ />
|
|
|
+ <CusFormColumn
|
|
|
+ :required="state.form.relateIndexId == 1"
|
|
|
+ :span="12"
|
|
|
+ required
|
|
|
+ label="关系描述"
|
|
|
+ v-model:param="state.form.relationDescription"
|
|
|
+ />
|
|
|
+ <el-col :span="12">
|
|
|
+ <div class="table-title">索引条件</div>
|
|
|
+ <CusTable
|
|
|
+ :data="state.conditionTable.data"
|
|
|
+ :table-head="state.conditionTable.tableHead"
|
|
|
+ :no-page="true"
|
|
|
+ >
|
|
|
+ <template #indexParam-column-value="{scope}">
|
|
|
+ <CusFormColumn
|
|
|
+ class="table-form-column"
|
|
|
+ required
|
|
|
+ :span="24"
|
|
|
+ v-model:param="scope.row.indexParam"
|
|
|
+ />
|
|
|
+ </template>
|
|
|
+ <template #condition-column-value="{scope}">
|
|
|
+ <CusFormColumn
|
|
|
+ class="table-form-column"
|
|
|
+ required
|
|
|
+ :span="24"
|
|
|
+ v-model:param="scope.row.condition"
|
|
|
+ link="select"
|
|
|
+ :options="DictionaryStore.conditionTypeList"
|
|
|
+ />
|
|
|
+ </template>
|
|
|
+ <template #do-header-value="{scope}">
|
|
|
+ <CusFormColumn
|
|
|
+ class="table-form-column"
|
|
|
+ :span="24"
|
|
|
+ v-model:param="state.conditionTable.selectValue"
|
|
|
+ link="select"
|
|
|
+ :options="transfer.conditionOptions.filter(v => state.conditionTable.data.every(s => s.themeParam !== v)).map(v => ({dictLabel: v, dictValue: v}))"
|
|
|
+ @change="handleChangeCondition"
|
|
|
+ />
|
|
|
+ </template>
|
|
|
+ <template #do-column-value="{scope}">
|
|
|
+ <CusButton type="table-del" @click="state.conditionTable.data.splice(scope.$index, 1)"/>
|
|
|
+ </template>
|
|
|
+ </CusTable>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="12" style="padding-left: 20px">
|
|
|
+ <div class="table-title">索引排序</div>
|
|
|
+ <CusTable
|
|
|
+ :data="state.sortTable.data"
|
|
|
+ :table-head="state.sortTable.tableHead"
|
|
|
+ :no-page="true"
|
|
|
+ >
|
|
|
+ <template #sortParam-column-value="{scope}">
|
|
|
+ <CusFormColumn
|
|
|
+ class="table-form-column"
|
|
|
+ required
|
|
|
+ :span="24"
|
|
|
+ v-model:param="scope.row.sortParam"
|
|
|
+ />
|
|
|
+ </template>
|
|
|
+ <template #sortType-column-value="{scope}">
|
|
|
+ <CusFormColumn
|
|
|
+ class="table-form-column"
|
|
|
+ required
|
|
|
+ :span="24"
|
|
|
+ v-model:param="scope.row.sortType"
|
|
|
+ link="select"
|
|
|
+ :options="DictionaryStore.sortTypeList"
|
|
|
+ />
|
|
|
+ </template>
|
|
|
+ <template #do-header-value="{scope}">
|
|
|
+ <CusButton title="新增" @click="state.sortTable.data.push({sortParam: '', sortType: ''})"/>
|
|
|
+ </template>
|
|
|
+ <template #do-column-value="{scope}">
|
|
|
+ <CusButton type="table-del" @click="state.sortTable.data.splice(scope.$index, 1)"/>
|
|
|
+ </template>
|
|
|
+ </CusTable>
|
|
|
+ </el-col>
|
|
|
+ </CusForm>
|
|
|
+ </div>
|
|
|
+ </CusDialog>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script setup lang="ts">
|
|
|
+import {computed, getCurrentInstance, nextTick, reactive, ref, watch} from "vue";
|
|
|
+import {useDictionaryStore} from "@/stores";
|
|
|
+import {ElMessage, ElMessageBox} from "element-plus";
|
|
|
+import {
|
|
|
+ sysThemeAdd,
|
|
|
+ sysThemeFind,
|
|
|
+ sysThemeIndexAdd, sysThemeIndexFindById,
|
|
|
+ sysThemeIndexUpdate,
|
|
|
+ sysThemeUpdate
|
|
|
+} from "@/api/modules/manage/theme";
|
|
|
+import {sysIndexFieldList} from "@/api/modules/manage";
|
|
|
+
|
|
|
+const emit = defineEmits(['update:show', 'refresh'])
|
|
|
+const {proxy} = getCurrentInstance()
|
|
|
+const DictionaryStore = useDictionaryStore()
|
|
|
+const props = defineProps({
|
|
|
+ show: {default: false},
|
|
|
+ transfer: {}
|
|
|
+ })
|
|
|
+const state: any = reactive({
|
|
|
+ form: {},
|
|
|
+ loading: false,
|
|
|
+ conditionTable: {
|
|
|
+ selectValue: '',
|
|
|
+ data: [],
|
|
|
+ tableHead: [
|
|
|
+ {value: "indexParam", label: "查询条件"},
|
|
|
+ {value: "condition", label: "条件类型"},
|
|
|
+ {value: "themeParam", label: "主题参数"},
|
|
|
+ {value: "do", label: "操作", width: 200, fixed: 'right'},
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ sortTable: {
|
|
|
+ selectValue: '',
|
|
|
+ data: [],
|
|
|
+ tableHead: [
|
|
|
+ {value: "sortParam", label: "排序字段"},
|
|
|
+ {value: "sortType", label: "排序类型"},
|
|
|
+ {value: "do", label: "操作", width: 100, fixed: 'right'},
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ textOptions: []
|
|
|
+})
|
|
|
+const ref_form = ref()
|
|
|
+const titleCpt = computed(() => {
|
|
|
+ let t = '索引构成-索引编辑'
|
|
|
+ return t
|
|
|
+})
|
|
|
+const onSubmit = () => {
|
|
|
+ ref_form.value.submit().then(() => {
|
|
|
+ ElMessageBox.confirm("是否提交?", "提示", {
|
|
|
+ confirmButtonText: "确定",
|
|
|
+ cancelButtonText: "取消",
|
|
|
+ type: "warning",
|
|
|
+ } as any).then(() => {
|
|
|
+ state.loading = true
|
|
|
+ const params = JSON.parse(JSON.stringify(state.form))
|
|
|
+ params.indexCondition = JSON.stringify(state.conditionTable.data)
|
|
|
+ params.indexOrder = JSON.stringify(state.sortTable.data)
|
|
|
+ if (props.transfer.mode === 'add') {
|
|
|
+ params.themeId = props.transfer.themeId
|
|
|
+ params.indexId = props.transfer.indexId
|
|
|
+ sysThemeIndexAdd(params).then(res => {
|
|
|
+ if (res.code === 200) {
|
|
|
+ ElMessage.success('新增成功!')
|
|
|
+ emit('update:show', false)
|
|
|
+ emit('refresh')
|
|
|
+ } else {
|
|
|
+ ElMessage.error(res.msg)
|
|
|
+ }
|
|
|
+ state.loading = false
|
|
|
+ })
|
|
|
+ } else if (props.transfer.mode === 'edit') {
|
|
|
+ sysThemeIndexUpdate(params).then(res => {
|
|
|
+ if (res.code === 200) {
|
|
|
+ ElMessage.success('编辑成功!')
|
|
|
+ emit('update:show', false)
|
|
|
+ emit('refresh')
|
|
|
+ } else {
|
|
|
+ ElMessage.error(res.msg)
|
|
|
+ }
|
|
|
+ state.loading = false
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }).catch(() => {})
|
|
|
+ }).catch((e) => {
|
|
|
+ ElMessage({
|
|
|
+ message: e[0].message,
|
|
|
+ grouping: true,
|
|
|
+ type: 'warning',
|
|
|
+ })
|
|
|
+ })
|
|
|
+}
|
|
|
+const initDetail = () => {
|
|
|
+ state.loading = true
|
|
|
+ sysThemeIndexFindById(props.transfer.id).then(res => {
|
|
|
+ if (res.code === 200) {
|
|
|
+ state.form = res.data
|
|
|
+ state.conditionTable.data = JSON.parse(state.form.indexCondition)
|
|
|
+ state.sortTable.data = JSON.parse(state.form.indexOrder)
|
|
|
+ initText(state.form.indexId)
|
|
|
+ } else {
|
|
|
+ ElMessage.error(res.msg)
|
|
|
+ }
|
|
|
+ state.loading = false
|
|
|
+ })
|
|
|
+}
|
|
|
+const initText = (id) => {
|
|
|
+ sysIndexFieldList(proxy.$util.formatGetParam({
|
|
|
+ indexId: id
|
|
|
+ })).then(res => {
|
|
|
+ if (res.code === 200) {
|
|
|
+ state.textOptions = res.data
|
|
|
+ } else {
|
|
|
+ ElMessage.error(res.msg)
|
|
|
+ }
|
|
|
+ state.loading = false
|
|
|
+ })
|
|
|
+}
|
|
|
+const handleChangeCondition = (val) => {
|
|
|
+ if (val) {
|
|
|
+ state.conditionTable.data.push({
|
|
|
+ indexParam: '',
|
|
|
+ condition: '',
|
|
|
+ themeParam: val
|
|
|
+ })
|
|
|
+ setTimeout(() => {
|
|
|
+ state.conditionTable.selectValue = ''
|
|
|
+ }, 100)
|
|
|
+ }
|
|
|
+}
|
|
|
+watch(() => props.show, (n) => {
|
|
|
+ if (n) {
|
|
|
+ initDictionary()
|
|
|
+ if (props.transfer.mode === 'add') {
|
|
|
+ state.form = {
|
|
|
+ isMain: '0'
|
|
|
+ }
|
|
|
+ initText(props.transfer.indexId)
|
|
|
+ } else if (props.transfer.mode === 'edit') {
|
|
|
+ initDetail()
|
|
|
+ }
|
|
|
+ nextTick(() => {
|
|
|
+ ref_form.value.reset()
|
|
|
+ })
|
|
|
+ }
|
|
|
+})
|
|
|
+const initDictionary = () => {
|
|
|
+ DictionaryStore.initDict('true_false')
|
|
|
+ DictionaryStore.initDict('node_size')
|
|
|
+ DictionaryStore.initDict('condition_type')
|
|
|
+ DictionaryStore.initDict('is_main_index')
|
|
|
+ DictionaryStore.initDict('sort_type')
|
|
|
+}
|
|
|
+</script>
|
|
|
+
|
|
|
+<style lang="scss" scoped>
|
|
|
+:deep(.table-form-column) {
|
|
|
+ .el-form-item {
|
|
|
+ margin-bottom: 0;
|
|
|
+ }
|
|
|
+}
|
|
|
+</style>
|