zhengnaiwen_citu 4 månader sedan
förälder
incheckning
120ae83cb5

+ 12 - 2
src/api/system.js

@@ -255,10 +255,20 @@ export function getDictList (params) {
 
 // 获取字典列表
 export function getDictionariesList (params) {
-  return http.get('/getDictionariesList', params)
+  return http.post('/dict/page', params)
 }
 
 // 删除字典
 export function deleteDictionaries (params) {
-  return http.get('/getDictionariesList', params)
+  return http.post('/dict/delete', params)
+}
+
+// 保存字典
+export function saveDictionaries (params) {
+  return http.post('/dict/save', params)
+}
+
+// 字典明细
+export function getDictionariesDetails (params) {
+  return http.get('/dict/item/list', params)
 }

+ 1 - 1
src/views/accumulatePoints/accumulatePointsMotivate/index.vue

@@ -6,7 +6,7 @@
         <span>兑换列表</span>
         <div class="tools">
           <span class="mr-5">
-            已使用积分:<span class="text-link" @click="onHistory">{{ itemData.canUsedScore ?? 0 }}</span>
+            <span class="text-link" @click="onHistory">已兑换积分:{{ itemData.canUsedScore ?? 0 }}</span>
           </span>
           <span>
             可用积分:<span>{{ itemData.canUsed ?? 0 }}</span>

+ 97 - 25
src/views/system/dictionaries/dictionariesEdit.vue

@@ -1,46 +1,118 @@
 <template>
-  <m-dialog :title="`${itemData ? '编辑' : '新增'}字典`" ref="dialog">
-    <m-form :items="formItems" v-model="formValues"></m-form>
+  <m-dialog :title="`${itemData ? '编辑' : '新增'}字典`" ref="dialog" @sure="onSure">
+    <m-form ref="form" :items="formItems" v-model="formValues" v-loading="loading">
+      <template #dictTitle>
+        <el-tag>{{ formValues.dictTitle }}</el-tag>
+      </template>
+      <template #dictCode>
+        <el-tag>{{ formValues.dictCode }}</el-tag>
+      </template>
+      <el-form-item label="字典配置">
+        <m-table
+          shadow="never"
+          clearHeader
+          :headers="headers"
+          :items="formValues.items"
+        >
+          <template #dictTitle="{ $index }">
+            <el-form-item :prop="`items.${$index}.dictTitle`" :rules="{ required: true, trigger: 'blur' }">
+              <el-input placeholder="字典项名称" v-model="formValues.items[$index].dictTitle"></el-input>
+            </el-form-item>
+          </template>
+          <template #dictValue="{ $index }">
+            <el-form-item :prop="`items.${$index}.dictValue`" :rules="{ required: true, trigger: 'blur' }">
+              <el-input placeholder="字典项值" v-model="formValues.items[$index].dictValue"></el-input>
+            </el-form-item>
+          </template>
+          <template #dictColor="{ $index }">
+            <el-form-item :prop="`items.${$index}.dictColor`" :rules="{ required: true, trigger: 'blur' }">
+              <el-input placeholder="色值" v-model="formValues.items[$index].dictColor"></el-input>
+            </el-form-item>
+          </template>
+          <template #actions="{ $index }">
+            <m-button v-if="formValues.items.length > 1" text type="danger" size="small" @click="onRemove($index)">移除</m-button>
+          </template>
+          <div class="text-center pt-3">
+            <m-button icon="el-icon-plus" size="small" type="orange" @click="onAdd">添加一项</m-button>
+          </div>
+        </m-table>
+      </el-form-item>
+    </m-form>
   </m-dialog>
 </template>
 
 <script>
+import {
+  getDictionariesDetails
+} from '@/api/system'
 export default {
   name: 'dictionariesEdit',
   data () {
     return {
+      loading: false,
       itemData: null,
-      formItems: [
+      headers: [
+        { label: '字典项名称', prop: 'dictTitle' },
+        { label: '字典项值', prop: 'dictValue' },
+        { label: '色值', prop: 'dictColor' },
+        { label: '操作', prop: 'actions' }
+      ],
+      formValues: {}
+    }
+  },
+  computed: {
+    formItems () {
+      return [
         {
           label: '字典名称',
-          prop: 'name',
-          type: 'input',
-          options: {
-            placeholder: '请输入字典名称'
-          },
-          rules: [
-            { required: true, message: '请输入字典名称', trigger: 'blur' }
-          ]
-        },
-        {
-          label: '字典类型',
-          prop: 'type',
-          type: 'input',
-          options: {
-            placeholder: '请输入字典类型'
-          },
-          rules: [
-            { required: true, message: '请输入字典类型', trigger: 'blur' }
-          ]
+          prop: 'dictTitle'
         }
-      ],
-      formValues: {}
+      ]
     }
   },
   methods: {
-    open (item) {
+    async open (item) {
       this.itemData = item ?? null
+      this.formValues = {
+        dictTitle: item?.dictTitle ?? null,
+        items: [
+          { dictTitle: null, dictValue: null, dictColor: null }
+        ]
+      }
       this.$refs.dialog.open()
+      if (!item) {
+        return
+      }
+      this.loading = true
+      try {
+        const { data } = await getDictionariesDetails({
+          dictCode: item.dictValue
+        })
+        this.formValues.items = data.map(e => ({
+          dictTitle: e.dictTitle,
+          dictValue: e.dictValue,
+          dictColor: null
+        }))
+      } catch (error) {
+        this.$message.error(error)
+      } finally {
+        this.loading = false
+      }
+    },
+    onAdd () {
+      this.formValues.items.push({
+        dictTitle: null,
+        dictValue: null,
+        dictColor: null
+      })
+    },
+    onRemove (index) {
+      this.formValues.items.splice(index, 1)
+    },
+    onSure () {
+      this.$refs.form.validate(valid => {
+        console.log(valid)
+      })
     }
   }
 }

+ 45 - 18
src/views/system/dictionaries/index.vue

@@ -10,12 +10,13 @@
       :total="total"
       @page-change="onPageChange"
     >
-      <template #card-tools>
+      <!-- <template #card-tools>
         <m-button type="orange" icon="el-icon-plus" @click="onAdd">新增</m-button>
-      </template>
+      </template> -->
       <template #actions="{ row }">
-        <m-button type="primary" text @click="onEdit(row)">编辑</m-button>
-        <m-button type="danger" text @click="onDelete(row)">删除</m-button>
+        <!-- <m-button type="primary" text @click="onEdit(row)">编辑</m-button> -->
+        <m-button type="primary" text @click="onEdit(row)">字典配置</m-button>
+        <!-- <m-button type="danger" text @click="onDelete(row)">删除</m-button> -->
       </template>
     </m-table>
     <DictionariesEdit ref="dictionariesEditRefs"></DictionariesEdit>
@@ -35,22 +36,14 @@ export default {
   },
   data () {
     return {
-      searchItems: [
-        {
-          label: '名称',
-          prop: 'name',
-          type: 'input',
-          options: {
-            placeholder: '请输入名称'
-          }
-        }
-      ],
       searchValues: {
-        name: null
+        dictTitle: null,
+        dictCode: 'systemCode'
       },
       headers: [
-        { label: '名称', prop: 'name' },
-        { label: '状态', prop: 'status' },
+        { label: '名称', prop: 'dictTitle' },
+        { label: '类型', prop: 'dictCode' },
+        { label: '创建时间', prop: 'createDate' },
         { label: '操作', prop: 'actions', fixed: 'right', width: 300 }
       ],
       items: [],
@@ -59,9 +52,37 @@ export default {
         current: 1,
         size: 10
       },
+      orders: [],
       loading: false
     }
   },
+  computed: {
+    searchItems () {
+      return [
+        {
+          label: '名称',
+          prop: 'dictTitle',
+          type: 'input',
+          options: {
+            placeholder: '请输入名称'
+          }
+        },
+        {
+          label: '类型',
+          prop: 'dictCode',
+          type: 'select',
+          options: {
+            placeholder: '请输入名称',
+            clearable: false,
+            items: [
+              { label: '系统类', value: 'systemCode' },
+              { label: '用户级', value: 'userCode' }
+            ]
+          }
+        }
+      ]
+    }
+  },
   created () {
     this.onInit()
   },
@@ -69,7 +90,13 @@ export default {
     async onInit () {
       this.loading = true
       try {
-        const { data } = await getDictionariesList()
+        const { data } = await getDictionariesList({
+          page: {
+            ...this.pageInfo,
+            orders: this.orders
+          },
+          ...this.searchValues
+        })
         this.items = data.records
         this.total = data.total
       } catch (error) {