CzRger пре 7 месеци
родитељ
комит
c8b3354fba

+ 17 - 0
src/api/modules/manage/index.ts

@@ -35,3 +35,20 @@ export const sysIndexDeleteByLinkId = (id: any) => handle({
   url: `/${suffix}/sys-index/deleteByLinkId/${id}`,
   method: 'get',
 })
+// 索引id查询字段列表信息
+export const sysIndexFieldList = (params: any) => handle({
+  url: `/${suffix}/sys-index-field/list`,
+  method: 'get',
+  params
+})
+// 新增或修改索引字段信息
+export const sysIndexFieldSaveOrUpdate = (params: any) => handle({
+  url: `/${suffix}/sys-index-field/saveOrUpdate`,
+  method: 'post',
+  params
+})
+// 根据ID删除索引字段信息
+export const sysIndexFieldDeleteById = (id: any) => handle({
+  url: `/${suffix}/sys-index-field/deleteById/${id}`,
+  method: 'get',
+})

+ 2 - 0
src/stores/dictionary-define.ts

@@ -6,6 +6,8 @@ export const dictionaryDefine = {
 	gx_cycle: ['gxCycleList', 'gxCycleMap'], //  共享周期
 	theme_mode: ['themeModeList', 'themeModeMap'], //  主题模式
 	default_model: ['defaultModelList', 'defaultModelMap'], //  默认模式
+	true_false: ['trueFalseList', 'trueFalseMap'], //  是否
+	fie_type: ['fieTypeList', 'fieTypeMap'], //  字段类型
 }
 
 const stateMap = {}

+ 6 - 0
src/views/manage/index/index.vue

@@ -42,6 +42,7 @@
     </div>
     <DetailCom v-model:show="state.detail.show" :transfer="state.detail.transfer" @refresh="onSearch"/>
     <RelationCom v-model:show="state.relation.show" :transfer="state.relation.transfer" @refresh="onSearch"/>
+    <TextCom v-model:show="state.text.show" :transfer="state.text.transfer"/>
   </div>
 </template>
 
@@ -51,6 +52,7 @@ import {ElMessage} from "element-plus";
 import {sysIndexFindIndexByPage} from "@/api/modules/manage";
 import DetailCom from "./detail.vue";
 import RelationCom from "./relation.vue";
+import TextCom from "./text.vue";
 import {useDictionaryStore} from "@/stores";
 
 const {proxy} = getCurrentInstance()
@@ -143,6 +145,10 @@ const onRelation = (row) => {
   state.relation.show = true
 }
 const onText = (row) => {
+  state.text.transfer = {
+    id: row.id,
+  }
+  state.text.show = true
 }
 const onAdd = () => {
   state.detail.transfer = {

+ 174 - 0
src/views/manage/index/text-detail.vue

@@ -0,0 +1,174 @@
+<template>
+  <CusDialog
+    :show="show"
+    :title="titleCpt"
+    @onClose="$emit('update:show', false)"
+    width="1000px"
+    height="auto"
+    @onSubmit="onSubmit"
+    :loading="state.loading"
+  >
+    <div class="__cus-dialog-form">
+      <CusForm ref="ref_form" label-width="120">
+        <CusFormColumn
+          :span="12"
+          required
+          label="中文名称"
+          v-model:param="state.form.fieldNameCn"
+        />
+        <CusFormColumn
+          :span="12"
+          required
+          label="英文定义"
+          v-model:param="state.form.fieldNameEn"
+        />
+        <CusFormColumn
+          :span="12"
+          required
+          label="列占用数"
+          v-model:param="state.form.labelLength"
+          link="input-number"
+          :min="1"
+          :max="8"
+        />
+        <CusFormColumn
+          :span="12"
+          required
+          label="图片"
+          v-model:param="state.form.pictureField"
+          link="radio"
+          :options="DictionaryStore.trueFalseList"
+        />
+        <CusFormColumn
+          :span="12"
+          required
+          label="搜索展示"
+          v-model:param="state.form.searchShow"
+          link="radio"
+          :options="DictionaryStore.trueFalseList"
+        />
+        <CusFormColumn
+          :span="12"
+          required
+          label="搜索权重"
+          v-model:param="state.form.searchWeight"
+          link="input-number"
+          :min="1"
+        />
+        <CusFormColumn
+          :span="12"
+          required
+          label="字段类型"
+          v-model:param="state.form.fieldType"
+          link="select"
+          :options="DictionaryStore.fieTypeList"
+          :disabled="state.form.searchShow == 1"
+        />
+        <CusFormColumn
+          :span="12"
+          required
+          label="排序"
+          v-model:param="state.form.dataOrder"
+          link="input-number"
+          :min="1"
+          :max="999"
+        />
+        <CusFormColumn
+          :span="24"
+          label="备注"
+          v-model:param="state.form.remark"
+          type="textarea"
+          :rows="5"
+        />
+      </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 {sysIndexFieldSaveOrUpdate, sysIndexGetDetail, sysIndexSaveOrUpdate} 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
+})
+const ref_form = ref()
+const titleCpt = computed(() => {
+  let t = ''
+  switch (props.transfer.mode) {
+    case 'add': t = '新增索引'
+      break
+    case 'edit': t = '编辑索引'
+      break
+  }
+  return t
+})
+const onSubmit = () => {
+  ref_form.value.submit().then(() => {
+    ElMessageBox.confirm("是否提交?", "提示", {
+      confirmButtonText: "确定",
+      cancelButtonText: "取消",
+      type: "warning",
+    } as any).then(() => {
+      state.loading = true
+      sysIndexFieldSaveOrUpdate(state.form).then(res => {
+        if (res.code === 200) {
+          ElMessage.success(props.transfer.mode === 'add' ? '新增成功!' : '编辑成功!')
+          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',
+    })
+  })
+}
+watch(() => props.show, (n) => {
+  if (n) {
+    initDictionary()
+    if (props.transfer.mode === 'add') {
+      state.form = {
+        indexId: props.transfer.indexId,
+        pictureField: '0',
+        labelLength: 1,
+        dataOrder: 999
+      }
+    } else {
+      state.form = JSON.parse(JSON.stringify(props.transfer.row))
+    }
+    nextTick(() => {
+      ref_form.value.reset()
+    })
+  }
+})
+watch(() => state.form.searchShow, (n) => {
+  if (n == 1) {
+    state.form.fieldType = 'text'
+  }
+})
+
+const initDictionary = () => {
+  DictionaryStore.initDict('true_false')
+  DictionaryStore.initDict('fie_type')
+}
+</script>
+
+<style lang="scss" scoped>
+</style>

+ 145 - 0
src/views/manage/index/text.vue

@@ -0,0 +1,145 @@
+<template>
+  <CusDialog
+    :show="show"
+    title="字典信息"
+    @onClose="$emit('update:show', false)"
+    width="90%"
+    height="90%"
+    :show-submit="false"
+  >
+    <div class="__cus-manage_content">
+      <div class="__cus-manage_content-filters">
+        <CusButton type="main" title="新增" style="display: block;margin-left: auto" @click="onAdd"/>
+      </div>
+      <div class="__cus-manage_content-main" v-loading="state.query.loading">
+        <CusTable
+          :data="state.query.result.data"
+          :table-head="state.query.tableHead"
+          :no-page="true"
+        >
+          <template #fieldType-column-value="{scope}">
+            {{DictionaryStore.fieTypeMap.get(scope.row.fieldType)}}
+          </template>
+          <template #searchShow-column-value="{scope}">
+            {{DictionaryStore.trueFalseMap.get(String(scope.row.searchShow))}}
+          </template>
+          <template #pictureField-column-value="{scope}">
+            {{DictionaryStore.trueFalseMap.get(String(scope.row.pictureField))}}
+          </template>
+          <template #do-column-value="{scope}">
+            <CusButton type="table-edit" @click="onEdit(scope.row)"/>
+            <CusButton type="table-del" @click="onDel(scope.row)"/>
+          </template>
+        </CusTable>
+      </div>
+      <TextDetailCom v-model:show="state.detail.show" :transfer="state.detail.transfer" @refresh="initText"/>
+    </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 {
+  sysIndexFieldDeleteById,
+  sysIndexFieldList,
+} from "@/api/modules/manage";
+import TextDetailCom from './text-detail.vue'
+
+const emit = defineEmits(['update:show', 'refresh'])
+const {proxy} = getCurrentInstance()
+const DictionaryStore = useDictionaryStore()
+const props = defineProps({
+  show: {default: false},
+  transfer: {}
+ })
+const state: any = reactive({
+  query: {
+    loading: false,
+    tableHead: [
+      {value: "fieldNameCn", label: "中文名称", fixed: 'left', minWidth: 160},
+      {value: "fieldNameEn", label: "英文定义", fixed: 'left', minWidth: 160, popover: true},
+      {value: "fieldType", label: "字段类型", fixed: 'left', minWidth: 160},
+      {value: "dataOrder", label: "排序", minWidth: 100},
+      {value: "searchWeight", label: "搜索权重", minWidth: 100},
+      {value: "searchShow", label: "搜索展示", minWidth: 100},
+      {value: "labelLength", label: "列占用数", minWidth: 100},
+      {value: "pictureField", label: "图片", minWidth: 100},
+      {value: "createTime", label: "创建时间", width: 200},
+      {value: "updateTime", label: "最后更新时间", width: 200},
+      {value: "remark", label: "备注"},
+      {value: "do", label: "操作", width: 200, fixed: 'right'},
+    ],
+    result: {
+      data: []
+    }
+  },
+  detail: {
+    show: false,
+    transfer: {}
+  },
+})
+const initText = () => {
+  state.query.loading = true
+  sysIndexFieldList(proxy.$util.formatGetParam({
+    indexId: props.transfer.id
+  })).then(res => {
+    if (res.code === 200) {
+      state.query.result.data = res.data
+      state.query.loading = false
+    } else {
+      ElMessage.error(res.msg)
+    }
+  })
+}
+const onAdd = () => {
+  state.detail.transfer = {
+    mode: 'add',
+    indexId: props.transfer.id
+  }
+  state.detail.show = true
+}
+const onEdit = (row) => {
+  state.detail.transfer = {
+    mode: 'edit',
+    row: row
+  }
+  state.detail.show = true
+}
+const onDel = (row) => {
+  ElMessageBox.confirm(`请确认是否删除${row.fieldNameCn}?`, "提示", {
+    confirmButtonText: "确定",
+    cancelButtonText: "取消",
+    type: "warning",
+  } as any).then(() => {
+    state.query.loading = true
+    sysIndexFieldDeleteById(row.id).then(res => {
+      if (res.code === 200) {
+        ElMessage.success('删除成功!')
+        state.query.loading = false
+        initText()
+      } else {
+        ElMessage.error(res.msg)
+      }
+    })
+  }).catch(() => {})
+}
+watch(() => props.show, (n) => {
+  if (n) {
+    initDictionary()
+    initText()
+  }
+})
+const initDictionary = () => {
+  DictionaryStore.initDict('true_false')
+  DictionaryStore.initDict('fie_type')
+}
+</script>
+
+<style lang="scss" scoped>
+.__cus-manage_content {
+  margin-bottom: 0;
+  height: calc(100% - 24px);
+}
+</style>