1.1.0-rc1 • Published 3 years ago

antd-vue-tool v1.1.0-rc1

Weekly downloads
3
License
MIT
Repository
github
Last release
3 years ago
yarn add antd-vue-tool
import httpConfig from "antd-vue-tool/src/http"
httpConfig.engine = yoursHttpEngineLikeAxiosInstance
httpConfig.errorMsgAdapter = r => {
    return "format 「r」"
}

state

this.$state.newFailState(Promise, {
    response: Function,
    message: Function,
    title: String,
    onlyFail: Boolean
})

this.$state.newFailState(new Promise((ok, nok) => {
    setTimeout(() => ok(""), 1000)
}), {message: m => m, title: "hi"})

this.$state.newFailState(new Promise((ok, nok) => {
    setTimeout(() => nok("fail"), 1000)
}), {message: m => m, title: "hi"})

this.$state.newState(new Promise((ok, nok) => {
    setTimeout(() => ok(""), 1000)
}), {message: m => m, response: ({ok, result} => {
    if(ok) {
        //http status code 20x
    }else {
        
    }
})})

tool-curd

// jsx
<tool-curd 
    models={this.models} 
    fetchUrl="/project" 
    vOn:config={this.onConfig}
    columns={this.columns}>
</tool-curd>

<script>
    export default {
        methods: {
        onConfig(item){}
    },
    data(){
        return {
            columns: [
                {title: "项目", validate: "required", field: "Project", type: "string"},
                {title: "服务器", validate: "required", field: "Server.Key", form_key: "Server", form_value_key: "Server.Key", type: "select", filter: true, filterKey: "server", option: {
                    selectOptions: () => this.server,
                    minSelectWidth: "150px"
                }},
                {title: "简称", validate: "required", field: "Title", type: "string", help_msg: "人类可读信息"},
                {title: "简述", validate: "required", field: "Desc", type: "string", option: {textarea: true}},
                {title: "配置", validate: "required|configOk", field: "config", hidden: true, type: "code", option: {language: "yaml"}},
                {title: "危险锁", field: "Lock", type: "switch", option: {checkText: "已加锁", unCheckText: "未加锁"}, default: true, help_msg: "加锁后不可销毁和部署"},
                {title: "ID", validate: "required", field: "Id", hidden: true, type: "string", key: true},
            ], 
            models: [
                {dispatchArea: "topBar", hide: ["Id"], title: "新增项目", type: "action", key: "new", xhr: {url: "/project", method: "post"}, layout_group: 1, dispatchReset: true},
                {title: "修改", show: ["Title", "Desc", "Lock"], type: "action", key: "update", xhr: {url: "/project", method: "patch"}},
                {title: "配置", type: "api", api: "event", key: "config",},
                {title: "删除", type: "action", key: "delete", hide: "*", xhr: {url: "/project", method: "delete"}}
            ]}
        },
    }
</script>
字段类型默认值说明
titlestring|slot-标题
fetchUrl数据接口-返回{data: [], total: 0}
actionNewRowboolfalse启用新增行操作
actionEditRowboolFalse启用修改行操作
actionEditFilterfunctionr => r数据修改过滤
pageSizeint10每页条数
fetchTransformfunctionr => r数据接口过滤
dataSourcearray[]自定义数据 只有fetchUrl无效时
modelsarray[]模型
columnsarray[]

Columns

字段类型默认值说明
titlestring-列标题 表单标题
fieldstring-数据字段当type为select时field为value字段而不是title 会根据value字段选择对应的title字段 对应关系通过option的selectOptions提供
form_keystringfield表单字段
form_valuestringform_key表单数据字段
typestringstring数据类型
customRenderfunction(text, item, index) => {return {children: "", attrs: {}}}渲染函数
hiddenboolfalse隐藏
filterboolfalse开启筛选
filterKeystringfield筛选key
optionobj{}根据type设定选项
keyboolfalse主键
validatestring-验证规则
defaultmix根据type浮动默认值
help_msgstring-表单帮助消息

Models

字段类型默认值说明
dispatchAreaStringrowBar操作按钮出现的区域rowBar | topBar
typeStringaction操作类型action | api | relation
titlestring-操作标题 作用在button或modal
keystring-唯一操作标识 用于切换model或api event触发事件名
apistring-type为api时api得类型event | new-row | edit-row
xhrobj-表单提交
xhr.urlstring-表单提交地址 为空时等价fetchUrl
xhr.methodstringget表单提交方法
xhr.autoCloseboolfalse提交后自动关闭
xhr.okMsgstringok~提交成功提示信息
xhr.notifyEnginestringmessage提交成功显示控件
xhr.confirmbooltrue提交是否确认
xhr.confirmMsgstring确认操作?提交确认信息
layout_groupint2表单分栏数
showarray[]显示字段集合
hidearray[]隐藏字段集合
disabledarray[]禁用集合
pickarray[]表单提交字段集合
omitarray[]表单提交排除集合
dispatchResetboolfalse自动清空
1.1.0-rc1

3 years ago

1.0.12-beta7

3 years ago

1.0.12-beta6

3 years ago

1.0.12-beta5

3 years ago

1.0.12-beta3

3 years ago

1.0.12-beta4

3 years ago

1.0.12-beta2

3 years ago

1.0.12-beta1

3 years ago

1.0.11-beta14

3 years ago

1.0.11-beta13

3 years ago

1.0.11-beta12

3 years ago

1.0.11-beta10

3 years ago

1.0.11-beta11

3 years ago

1.0.11-beta9

3 years ago

1.0.11-beta8

3 years ago

1.0.11-beta7

3 years ago

1.0.11-beta6

3 years ago

1.0.11-beta5

4 years ago

1.0.11-beta2

4 years ago

1.0.11-beta3

4 years ago

1.0.11-beta4

4 years ago

1.0.11-beta1

4 years ago

1.0.10

4 years ago

1.0.9-beta2

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.2

4 years ago

1.0.3

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago