功能变化: 系统配置优化,区分前台配置和后台配置
							parent
							
								
									886136b598
								
							
						
					
					
						commit
						8b099542e6
					
				| 
						 | 
				
			
			@ -40,7 +40,7 @@ def _get_all_system_config():
 | 
			
		|||
    from dvadmin.system.models import SystemConfig
 | 
			
		||||
 | 
			
		||||
    system_config_obj = (
 | 
			
		||||
        SystemConfig.objects.filter(status=True, parent_id__isnull=False)
 | 
			
		||||
        SystemConfig.objects.filter(parent_id__isnull=False)
 | 
			
		||||
        .values("parent__key", "key", "value", "form_item_type")
 | 
			
		||||
        .order_by("sort")
 | 
			
		||||
    )
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -250,9 +250,26 @@ class InitSettingsViewSet(APIView):
 | 
			
		|||
    authentication_classes = []
 | 
			
		||||
    permission_classes = []
 | 
			
		||||
 | 
			
		||||
    def filter_system_config_values(self, data: dict):
 | 
			
		||||
        """
 | 
			
		||||
        过滤系统初始化配置
 | 
			
		||||
        :param data:
 | 
			
		||||
        :return:
 | 
			
		||||
        """
 | 
			
		||||
        for key in self.request.query_params.get('key', '').split('|'):
 | 
			
		||||
            if key:
 | 
			
		||||
                data = dict(filter(lambda x: x[0].startswith(key), data.items()))
 | 
			
		||||
        return data
 | 
			
		||||
 | 
			
		||||
    def get(self, request):
 | 
			
		||||
        data = dispatch.get_system_config()
 | 
			
		||||
        if not data:
 | 
			
		||||
            dispatch.refresh_system_config()
 | 
			
		||||
            data = dispatch.get_system_config()
 | 
			
		||||
        # 不返回后端专用配置
 | 
			
		||||
        backend_config = [f"{ele.get('parent__key')}.{ele.get('key')}" for ele in
 | 
			
		||||
                          SystemConfig.objects.filter(status=False, parent_id__isnull=False).values('parent__key',
 | 
			
		||||
                                                                                                    'key')]
 | 
			
		||||
        data = dict(filter(lambda x: x[0] not in backend_config, data.items()))
 | 
			
		||||
        data = self.filter_system_config_values(data=data)
 | 
			
		||||
        return DetailResponse(data=data)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -2,10 +2,10 @@
 | 
			
		|||
  <div>
 | 
			
		||||
    <el-row :gutter="10">
 | 
			
		||||
      <el-col :span="4">变量标题</el-col>
 | 
			
		||||
      <el-col :span="8">变量值</el-col>
 | 
			
		||||
      <el-col :span="10">变量值</el-col>
 | 
			
		||||
      <el-col :span="4" >变量名</el-col>
 | 
			
		||||
      <el-col :span="4" >状态</el-col>
 | 
			
		||||
      <el-col :span="4" >操作</el-col>
 | 
			
		||||
      <el-col :span="2">是否前端配置</el-col>
 | 
			
		||||
      <el-col :span="3" :offset="1">操作</el-col>
 | 
			
		||||
    </el-row>
 | 
			
		||||
    <el-form ref="form" :model="form" label-width="240px" label-position="left" style="margin-top: 20px">
 | 
			
		||||
      <el-form-item :label="item.title" :prop="['array'].indexOf(item.form_item_type_label) >-1?'':item.key"
 | 
			
		||||
| 
						 | 
				
			
			@ -17,7 +17,7 @@
 | 
			
		|||
          <el-input v-if="item.edit" v-model="item.title" style="display: inline-block;width: 200px;" placeholder="请输入标题"></el-input>
 | 
			
		||||
          <span v-else>{{item.title}}</span>
 | 
			
		||||
        </template>
 | 
			
		||||
        <el-col :span="6" >
 | 
			
		||||
        <el-col :span="11" >
 | 
			
		||||
          <!--    文本      -->
 | 
			
		||||
          <el-input :key="index" v-if="['text','textarea'].indexOf(item.form_item_type_label) >-1"
 | 
			
		||||
                    :type="item.form_item_type_label"
 | 
			
		||||
| 
						 | 
				
			
			@ -201,7 +201,7 @@
 | 
			
		|||
            </div>
 | 
			
		||||
          </div>
 | 
			
		||||
        </el-col>
 | 
			
		||||
        <el-col :span="6" :offset="2">
 | 
			
		||||
        <el-col :span="4" :offset="1">
 | 
			
		||||
          <el-input v-if="item.edit" v-model="item.new_key" style="width: 200px;" placeholder="请输入变量key">
 | 
			
		||||
            <template slot="prepend">
 | 
			
		||||
              <span style="padding: 0px 5px">{{ editableTabsItem.key }}</span>
 | 
			
		||||
| 
						 | 
				
			
			@ -209,16 +209,14 @@
 | 
			
		|||
          </el-input>
 | 
			
		||||
          <span v-else>{{ editableTabsItem.key }}.{{ item.key }}</span>
 | 
			
		||||
          </el-col>
 | 
			
		||||
        <el-col :span="4" >
 | 
			
		||||
        <el-col :span="3" :offset="1">
 | 
			
		||||
          <el-switch
 | 
			
		||||
          v-model="item.status"
 | 
			
		||||
          active-color="#13ce66"
 | 
			
		||||
          inactive-color="#ff4949"
 | 
			
		||||
          active-text="启用"
 | 
			
		||||
          inactive-text="禁用">
 | 
			
		||||
          inactive-color="#ff4949">
 | 
			
		||||
        </el-switch>
 | 
			
		||||
        </el-col>
 | 
			
		||||
        <el-col :span="4" :offset="1">
 | 
			
		||||
        <el-col :span="2">
 | 
			
		||||
          <el-button v-if="item.edit" size="mini" type="primary"  icon="el-icon-success" @click="onEditSave(item)"></el-button>
 | 
			
		||||
          <el-button v-else size="mini" type="primary"  icon="el-icon-edit" @click="onEdit(index)"></el-button>
 | 
			
		||||
           <el-popconfirm
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue