1.0.51 • Published 2 years ago

@south-rd/smarthub-form v1.0.51

Weekly downloads
152
License
MIT
Repository
-
Last release
2 years ago

smart-hub-form

smartHub 表单公共组件用于元素渲染与后台设置效果的预览

本地项目初始化

yarn install

查看例子

yarn dev

组件打包

yarn run lib

基于 elementui,使用响应式处理元素 PC、手机样式

本地开发调试

本地项目 执行组件打包命令

yarn run lib

开启文件链接

yarn link

本地项目环境安装本组件

项目链接引用

yarn link @south-rd/smarthub-form

引入组件

import smarthubWidgets from '@south-rd/smarthub-form'
import '@south-rd/smarthub-form/lib/smarthub-form.css'
Vue.use(smarthubWidgets)

使用组件

组件名称

 <smarthub-form
      :isPreview="false"
      :formData="mock"
      :getMessageCode="getMessageCode"
      :getStoreList="getStoreList"
      :getShopperList="getShopperList"
      :onChange="onChange"
      @submit="formSubmit"
    ></smarthub-form>

参数

formData:表单数据
isPreview:是否为预览状态
export default {
  name: "App",
  data() {
    return {
      mock: mock,
    };
  },
  methods: {
    onChange(formInfos,index) {//表单改变时触发
      console.log(formInfos,index);
    },
    getMessageCode(params, cb) {
      cb("res");
      if (params) {
        return;
      }
      commonApi
        .post("/api/apps/sms/obtailSmsCode", {
          ...params,
        })
        .then((res) => {
          cb(res);
        });
    },
    getStoreList(cb) {
      //门店
      commonApi.get("/api/apps/storeAndShopper/getStoreList").then((res) => {
        cb(res);
      });
    },
    getShopperList(storeId, cb) {
      //导购
      commonApi
        .post("/api/apps/storeAndShopper/getShopperList", {
          storeId,
        })
        .then((res) => {
          cb(res);
        });
    },
    formSubmit(submitDatas) {
      let content = {};
      submitDatas.list.forEach((i) => {
        let val = i.value;
        if (i.value instanceof Date) {
          val =
            i.type == "time"
              ? new Date(i.value).Format("hh:mm:ss")
              : new Date(i.value).Format("yyyy-MM-dd");
        } else if (i.value instanceof Array) {
          val = i.value.join(",");
        } else if (!i.value) {
          val = "";
        }
        content[`${i.text}`] = val.trim();
      });
      debugger;
      console.log(content);
    },
  },
};
</script>
1.0.51

2 years ago

1.0.50

2 years ago

1.0.48

2 years ago

1.0.47

2 years ago

1.0.46

2 years ago

1.0.49

2 years ago

1.0.39

2 years ago

1.0.38

2 years ago

1.0.40

2 years ago

1.0.44

2 years ago

1.0.43

2 years ago

1.0.42

2 years ago

1.0.41

2 years ago

1.0.45

2 years ago

1.0.37

2 years ago

1.0.36

2 years ago

1.0.35

3 years ago

1.0.34

3 years ago

1.0.33

3 years ago

1.0.32

3 years ago

1.0.31

3 years ago

1.0.30

3 years ago

1.0.29

3 years ago

1.0.28

3 years ago

1.0.27

3 years ago

1.0.26

3 years ago

1.0.25

3 years ago

1.0.24

3 years ago

1.0.23

3 years ago

1.0.22

3 years ago

1.0.21

3 years ago

1.0.20

3 years ago

1.0.19

3 years ago

1.0.18

3 years ago

1.0.17

3 years ago

1.0.16

3 years ago

1.0.11

3 years ago

1.0.10

3 years ago

1.0.15

3 years ago

1.0.14

3 years ago

1.0.13

3 years ago

1.0.12

3 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.2

3 years ago

1.0.3

3 years ago

1.0.1

3 years ago