Browse Source

项目商机新增或编辑

zhaoxiaohai 2 năm trước cách đây
mục cha
commit
8da10757af

+ 180 - 0
packageA/project/addAndEdit.js

@@ -0,0 +1,180 @@
+const _Http = getApp().globalData.http;
+
+Page({
+    data: {
+        "sa_projectid": 0,
+        showAll: false,
+        form: [{
+            label: "项目名称",
+            error: false,
+            errMsg: "",
+            type: "textarea",
+            value: "",
+            placeholder: "项目名称",
+            valueName: "projectname",
+            checking: "base",
+            required: true
+        }, {
+            label: "项目类型",
+            error: false,
+            errMsg: "",
+            type: "option",
+            optionNmae: "projecttype",
+            optionType: "radio", //复选   radio 单选
+            value: "",
+            placeholder: "选择类型",
+            valueName: "projecttype",
+            checking: "base",
+            required: true
+        }, {
+            label: "项目等级",
+            error: false,
+            errMsg: "",
+            type: "option",
+            optionNmae: "projectgrade",
+            optionType: "radio", //复选   radio 单选
+            value: "",
+            placeholder: "选择项目等级",
+            valueName: "grade",
+            checking: "base",
+            required: false
+        }, {
+            label: "地区",
+            error: false,
+            errMsg: "",
+            type: "region",
+            value: [],
+            placeholder: "所属地区 省/市/区",
+            valueName: "region",
+            required: false
+        }, {
+            label: "详细地址",
+            error: false,
+            errMsg: "",
+            type: "textarea",
+            value: "",
+            placeholder: "详细地址",
+            valueName: "address",
+            checking: "base",
+            required: false
+        }, {
+            label: "项目规模",
+            error: false,
+            errMsg: "",
+            type: "textarea",
+            value: "",
+            placeholder: "项目规模",
+            valueName: "scale",
+            checking: "base",
+            required: false
+        }, {
+            label: "项目预算",
+            error: false,
+            errMsg: "",
+            type: "number",
+            value: "",
+            placeholder: "项目预算",
+            valueName: "budgetary",
+            checking: "base",
+            required: false
+        }, {
+            label: "预计签约金额",
+            error: false,
+            errMsg: "",
+            type: "number",
+            value: "",
+            placeholder: "预计签约金额",
+            valueName: "signamount_due",
+            checking: "base",
+            required: false
+        }, {
+            label: "预计签约月份",
+            error: false,
+            errMsg: "",
+            type: "date",
+            fields: "month",
+            value: "",
+            placeholder: "预计签约月份",
+            valueName: "signdate_due",
+            checking: "base",
+            required: false
+        }],
+        disabled: true
+    },
+    onLoad(options) {
+        if (options.data) {
+            let data = JSON.parse(options.data);
+            this.setData({
+                disabled: false,
+                sa_projectid: data.sa_customersid,
+                form: this.data.form.map(v => {
+                    if (v.valueName != 'region') {
+                        v.value = data[v.valueName];
+                    } else {
+                        v.value = data.province ? [data.province, data.city, data.county] : []
+                    }
+                    return v
+                })
+            })
+        }
+    },
+    /* 表单必填项是否完成 */
+    onConfirm({
+        detail
+    }) {
+        this.setData({
+            disabled: detail
+        })
+    },
+    // 是否显示全部
+    onChange({
+        detail
+    }) {
+        this.setData({
+            showAll: detail
+        })
+    },
+    submit() {
+        let data = this.selectComponent("#Form").submit();
+        if (data.region.length != 0) {
+            data.province = data.region[0]
+            data.city = data.region[1]
+            data.county = data.region[2]
+        };
+        delete(data.region);
+        _Http.basic({
+            "id": 20221020144202,
+            "content": {
+                sa_projectid: this.data.sa_projectid,
+                ...data
+            }
+        }).then(res => {
+            console.log("新建客户", res)
+            if (res.msg != '成功') return wx.showToast({
+                title: res.data,
+                icon: "none"
+            })
+            wx.showToast({
+                title: '保存成功',
+                icon: "none"
+            })
+            setTimeout(() => {
+                wx.navigateBack()
+                getCurrentPages().forEach(v => {
+                    switch (v.__route__) {
+                        case 'packageA/project/index':
+                            v.getList(true);
+                            break;
+                        case 'packageA/project/search':
+                            v.getList(true);
+                            break;
+                    }
+                })
+                /*  let pages = getCurrentPages();
+                 if (pages[pages.length - 2].__route__ == 'packageA/project/index') wx.navigateTo({
+                     url: '/packageA/setclient/detail?id=' + res.data.sa_customersid,
+                 }) */
+            }, 300)
+        })
+    },
+})

+ 4 - 0
packageA/project/addAndEdit.json

@@ -0,0 +1,4 @@
+{
+    "usingComponents": {},
+    "navigationBarTitleText": "设置项目"
+}

+ 23 - 0
packageA/project/addAndEdit.scss

@@ -0,0 +1,23 @@
+.new-footer {
+    display: flex;
+    align-items: center;
+    justify-content: flex-end;
+    position: fixed;
+    width: 100vw;
+    height: 130rpx;
+    background: #FFFFFF;
+    box-shadow: 0px -4rpx 16rpx 2rpx rgba(150, 157, 165, 0.16);
+    bottom: 0;
+
+    .new-submit {
+        width: 156rpx;
+        height: 90rpx;
+        background: #3874F6;
+        border-radius: 8rpx;
+        font-size: 28rpx;
+        font-family: PingFang SC-Bold, PingFang SC;
+        font-weight: bold;
+        color: #FFFFFF;
+        margin-right: 30rpx;
+    }
+}

+ 6 - 0
packageA/project/addAndEdit.wxml

@@ -0,0 +1,6 @@
+<Yl_Headline title='基本信息' type='switch' switchLabel='仅显示必填信息' switch='{{showAll}}' bind:callBack='onChange' />
+<Yl_field id='Form' form='{{form}}' showAll='{{!showAll}}' bind:onConfirm='onConfirm' />
+<view style="height: 100rpx;" />
+<view class="new-footer">
+    <van-button custom-class='new-submit' disabled='{{disabled}}' bindclick='submit'>提交</van-button>
+</view>