# 本文档涵盖 axios、mixin、utils、全局属性、方法的注册

```
axios get 添加 constent-type

代码演示:
可以二次解析"[]"
function fn (config) {
  if(config.method === 'get'){
    // 更新默认方式
    config.data = true
    config.headers['Content-Type'] = 'application/x-www-form-urlencoded;charset=utf-8'
  }
  return config
}



```

# axios

axios使用说明和案例

<br/>  

## option

> 参数说明  
>  
> option: Object  
>  
> u: url(接口路径)默认从api中动态解析出来(urls)   
> m: method(接口对的HTTP方法 常用的有:'get'/'post'/'put'/'delete'等等，默认'get')  
> p: params/data(参数，是即将与请求一起发送的 URL 参数,data:是作为请求主体被发送的数据,只适用于这些请求方法 'PUT', 'POST', 和 'PATCH'), 默认:params    
> r: responseType(服务器响应的数据类型)  
> o: other(其他axios没有填的参数) [axios官网] http://www.axios-js.com/zh-cn/docs/  
> s：serializer(序列化)  

## isData

> 参数说明  
>   
> isData: Boolean  
>  
> isData：option中p参数是否起用data模式  
> params参数为数组时也会开启data模式

```
案例: 

this.$Axios.country.list({}, true).then(res => {})
```

<br />

## 基础用法
### 无参数

> 说明  
> 解析为｛url: urls, params: {}, method: 'get', responseType: 'json', serializer: {}｝

```
案例：

this.$Axios.country.list().then(res => {})
```

### params

> 说明  
>   
> 解析为｛url: urls, params: val, method: 'get', responseType: 'json', serializer: {}｝

```
案例：

this.$Axios.country.list(val).then(res => {})
```

### method

> 说明  
>   
> 解析为｛url: urls, arams: {}, method: 'post', responseType: 'json', serializer: {}｝

```
案例：

this.$Axios.country.list({m: 'post'}).then(res => {})
```

### url

> 说明  
>   
> 解析为｛url: url, params: {}, method: 'get', responseType: 'json', serializer: {}｝

```
案例：

this.$Axios.country.list({u: url}).then(res => {})
```

### responseType

> 说明  
>   
> 解析为｛url: urls, params: {}, method: 'get', responseType: 'arraybuffer', serializer: {}｝

```
案例：

this.$Axios.country.list({r: 'arraybuffer'}).then(res => {})
```

### serializer

> 说明  
>   
> 解析为｛url: urls, params: {}, method: 'get', responseType: 'json', serializer: true}  
> 使用qs.stringify(params, { indices: false }) 解析 params

```
案例：

this.$Axios.country.list({s: true}).then(res => {})
```

<br/>  
<br/>  
<br/>  

# index

全局变量、属性、方法、组件注册

##### 变量、属性、方法

> 说明  
>   
> 默认提供了$Axios、$Utils、$Api  
> $Axios: ajax方法  
> $Utils: 公用方法  
> $Api: url路径   
> 使用方法: this.xxx($Axios、$Utils、$Api)  

##### 组件

> 说明
>   
> 默认提供了Tree、TreeNode  
> 详细说明参考 [ant 树形控件] https://www.antdv.com/components/tree-cn/

<br/>  
<br/>  
<br/>  

# mixin

mixin涵盖语言包、新建编辑公用方法、按钮权限、剪切板数据、上传组件调用、页面内容是否具有编辑权限

> 说明  
>   
> language: 语言包  
> addAndEdit: 新建编辑   
> permission: 权限   
> clipboardData: 剪切板  
> upload: 上传组件  
> mixinEdit: 页面内容是否具有编辑权限   

### language

> 说明  
>   
> langZh：中文包  
> langEn: 英文包   
> selectModule: 接口模块名，默认'itConfigComSel'     
> languageLang: 语言包特殊配置  
> > Paths: 路由  
> > model: 模块项  
> > > model: 模块数组  
> > > name: 模块数组对应的名称 

```
案例:

const languageLang = {
  model: [{
    model: ['generalView', 'companyCodeView', 'salesView', 'allView'],
    name: 'generalView'
  }],
  Paths: ['so', 'soDraft']
}

data () {
  return {
    selctModule: 'itConfigComSel'
  }
}
```

### permission

> 说明  
>   
> permissionData：权限数据  

##### 基础用法

```
案例:

<a-button
  v-for="(but, index) in permissionData"
  :loading="butLoading(but)"
  :key="index"
  :type="but.type"
  :icon="but.icon"
  @click="clickBut(but)">
  {{ but.txt }}
</a-button>
```

##### prompt

```
案例:

<template v-for="(item, index) in permissionData" :key="index">
  <!-- 如果需要二次确认，则传needSure:true,同时传对应的title -->
  <template v-if="item.needSure">
    <a-popconfirm :key="index" okText="Sure" cancelText="Cancel" @confirm="clickCall(item.methods)">
      <template #title>
        <p>{{ item.title }}</p>
      </template>
      <a-button class="marleft8 smallbtn" :key="index" :type="item.type || 'primary'" :icon="item.icon">{{ filterTxt(item) }}</a-button>
    </a-popconfirm>
  </template>
  <template v-else>
    <a-button
      :loading="downloadLoading"
      class="marleft8 smallbtn"
      :key="index"
      :type="item.type || 'primary'"
      :icon="item.icon"
      @click="clickCall(item.methods)">{{ item.text }}</a-button>
  </template>
</template>

methods: {
    filterTxt (item) {
      if (notShowButTxt.length <= 0) return item.txt
      return notShowButTxt.includes(item.methods) ? '' : item.txt
    }
}
```

### upload

> 说明  
>   
> upload： 文件上传  
> refUpload: 上传组件的ref名称，默认是'upload',一个页面有多个时不能一样  
> uploadPath: 上传接口对像（this.$Axios.dbQueryTable.importDbQueryTablesUpload）
> 详细参数，请前往[ le_components/leUpload ]  

##### 基础用法

```
案例:

<le-upload ref="upload" :method="uploadPath"></le-upload>
```

##### 按钮用法

```
案例:

<le-upload ref="upload" :type="'button'" :method="uploadPath"></le-upload>
```

### clipboardData

> 说明  
>   
> clipboardData：  剪切版数据

```
案例: 

clipboardDataFn (key) {
  const clipboardData = this.getClipboardData
  
  this.getClipboardData = []
}
```

### mixinEdit

> 说明  
>   
> editPathM：页面标示  
> disabledObj：disabled对像（需要控制是否可编辑的内容）
> setDisabled：生成disabled属性    
> setDisabledFalse：设置可编辑项  
> setDisabledTrue: 设置不能编辑项


```
案例: 

html:
<a-input :disabled="setDisabled('soldToParty')" />

javascript:
methods: {
  editBut () {
    this.setDisabledTrue()
  }
}
```
