1.0.51 • Published 3 years ago
@south-rd/smarthub-form v1.0.51
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
3 years ago
1.0.50
4 years ago
1.0.48
4 years ago
1.0.47
4 years ago
1.0.46
4 years ago
1.0.49
4 years ago
1.0.39
4 years ago
1.0.38
4 years ago
1.0.40
4 years ago
1.0.44
4 years ago
1.0.43
4 years ago
1.0.42
4 years ago
1.0.41
4 years ago
1.0.45
4 years ago
1.0.37
4 years ago
1.0.36
4 years ago
1.0.35
4 years ago
1.0.34
4 years ago
1.0.33
4 years ago
1.0.32
4 years ago
1.0.31
4 years ago
1.0.30
4 years ago
1.0.29
5 years ago
1.0.28
5 years ago
1.0.27
5 years ago
1.0.26
5 years ago
1.0.25
5 years ago
1.0.24
5 years ago
1.0.23
5 years ago
1.0.22
5 years ago
1.0.21
5 years ago
1.0.20
5 years ago
1.0.19
5 years ago
1.0.18
5 years ago
1.0.17
5 years ago
1.0.16
5 years ago
1.0.11
5 years ago
1.0.10
5 years ago
1.0.15
5 years ago
1.0.14
5 years ago
1.0.13
5 years ago
1.0.12
5 years ago
1.0.9
5 years ago
1.0.8
5 years ago
1.0.7
5 years ago
1.0.6
5 years ago
1.0.5
5 years ago
1.0.4
5 years ago
1.0.2
5 years ago
1.0.3
5 years ago
1.0.1
5 years ago