Ver código fonte

医院合同

xiaohaizhao 6 meses atrás
pai
commit
f6a63c9952
2 arquivos alterados com 118 adições e 58 exclusões
  1. 87 34
      prsx/contract/insert.js
  2. 31 24
      prsx/select/saler/index.js

+ 87 - 34
prsx/contract/insert.js

@@ -14,7 +14,6 @@ Page({
         console.log("options", options)
         let type = '';
         if (options.type) type = options.type;
-
         let form = [{
             label: "经销商",
             error: false,
@@ -36,7 +35,7 @@ Page({
             checking: "base",
             required: options.type == '经销商协议',
             interrupt: options.type == '经销商协议',
-            disabled: options.type == '医院合作协议'
+            disabled: options.type == '医院协议'
         }, {
             label: "签约日期",
             error: false,
@@ -127,7 +126,6 @@ Page({
             required: true,
             params: {
                 "content": {
-                    "sys_enterpriseid": 0,
                     "pageNumber": 1,
                     "pageSize": 20,
                     "where": {
@@ -151,7 +149,7 @@ Page({
             checking: "base",
             required: false
         }]
-        if (type == '医院合作协议') form.unshift({
+        if (type == '医院协议') form.unshift({
             label: "医院",
             error: false,
             errMsg: "",
@@ -187,9 +185,10 @@ Page({
             form = form.map(v => {
                 v.value = data[v.valueName];
                 if (v.label == '负责人') {
-                    v.params.sys_enterpriseid = data.sa_agentsid[1][0]
-                    v.disabled = false
+                    v.params.sys_enterpriseid = data.sys_enterpriseid
+                    if (type != '医院协议') v.disabled = false
                 }
+                if (type == '医院协议' && v.label == '经销商') v.disabled = false
                 return v
             })
             this.setData({
@@ -220,11 +219,24 @@ Page({
             obj2.params.content.sa_customersid = data.id[0];
             obj2.value = '';
             obj2.disabled = false;
+
+            form.find(v => v.label == '医院').value = data.value;
+            let leader = data.item.leader[0];
+            let obj1 = form.find(v => v.label == '负责人')
+            obj1.value = [leader.name, ['']]
             wx.navigateBack()
         } else if (temporary.item.label == '经销商') {
             form.find(v => v.label == '经销商').value = data.value;
             let obj = form.find(v => v.label == '负责人')
-            obj.params.content.sys_enterpriseid = data.id[0]
+            obj.params.content.sys_enterpriseid = data.item.sys_enterpriseid
+            _Http.basic(obj.params).then(res => {
+                if (res.code == 1 && res.data.length == 1) {
+                    form.find(v => v.label == '负责人').value = [res.data[0].name, [res.data[0].hrid]];
+                    this.setData({
+                        form
+                    })
+                }
+            })
             obj.disabled = false;
             wx.navigateBack()
         } else if (temporary.item.label == '负责人') {
@@ -258,7 +270,9 @@ Page({
             loading: true
         })
         let data = this.selectComponent("#Form").submit(),
-            content = this.data.content
+            content = this.data.content,
+            that = this;
+
         data.sa_agentsid = data.sa_agentsid.length ? data.sa_agentsid[1][0] : 0
         data.saler_hrid = data.saler_hrid.length ? data.saler_hrid[1][0] : 0
         try {
@@ -266,34 +280,73 @@ Page({
         } catch (error) {
 
         }
-        _Http.basic({
-            "id": 20221121185302,
-            "content": {
-                ...content,
-                ...data,
-            }
-        }).then(res => {
-            this.setData({
-                loading: false
-            })
-            wx.showToast({
-                title: res.code != '1' ? res.msg : '保存成功',
-                icon: "none",
-                mask: res.code == '1'
-            })
-            if (res.code != '1') return;
-            getCurrentPages().forEach(v => {
-                if (v.route == 'prsx/contract/detail') v.getDetail()
-            })
-            setTimeout(() => {
-                if (content.sa_contractid == 0) {
-                    wx.redirectTo({
-                        url: '/prsx/contract/detail?id=' + res.data.sa_contractid,
+
+        if (this.data.type == '医院协议') {
+            _Http.basic({
+                "id": 2025102416540802,
+                "content": {
+                    ...content,
+                    ...data,
+                }
+            }).then(res => {
+                console.log("查询有无重复", res)
+                this.setData({
+                    loading: false
+                })
+                if (res.msg == "该合同已存在") {
+                    wx.showModal({
+                        content: '该医院存在有效期相同的医院协议,是否确定继续创建?',
+                        confirmText: "确定创建",
+                        complete: (res) => {
+                            if (res.confirm) {
+                                that.setData({
+                                    loading: true
+                                })
+                                handle()
+                            }
+                        }
                     })
                 } else {
-                    wx.navigateBack()
+                    this.setData({
+                        loading: true
+                    })
+                    handle()
                 }
-            }, 300)
-        })
+            })
+        } else {
+            handle()
+        }
+
+        function handle() {
+            _Http.basic({
+                "id": 20221121185302,
+                "content": {
+                    ...content,
+                    ...data,
+                }
+            }).then(res => {
+                that.setData({
+                    loading: false
+                })
+                wx.showToast({
+                    title: res.code != '1' ? res.msg : '保存成功',
+                    icon: "none",
+                    mask: res.code == '1'
+                })
+                if (res.code != '1') return;
+                getCurrentPages().forEach(v => {
+                    if (v.route == 'prsx/contract/detail') v.getDetail()
+                })
+                setTimeout(() => {
+                    if (content.sa_contractid == 0) {
+                        wx.redirectTo({
+                            url: '/prsx/contract/detail?id=' + res.data.sa_contractid,
+                        })
+                    } else {
+                        wx.navigateBack()
+                    }
+                }, 300)
+            })
+        }
     },
 })

+ 31 - 24
prsx/select/saler/index.js

@@ -9,30 +9,37 @@ Page({
         showName: "name", //表单用 显示名称
     },
     onLoad(options) {
-        _Http.basic({
-            "classname": "webmanage.sale.salearea.salearea",
-            "method": "query_area",
-            "content": {},
-        }).then(res => {
-            if (res.code == 1) {
-                this.setData({
-                    params: {
-                        "id": 20221011144603,
-                        "content": {
-                            "sa_saleareaid": res.data[0].sa_saleareaid,
-                            "isExport": 0,
-                            "pageNumber": 1,
-                            "pageSize": 20,
-                            pageTotal: 1,
-                            "where": {
-                                "condition": ""
-                            }
-                        },
-                    }
-                });
-                this.getList()
-            }
-        })
+        if (options.params) {
+            this.setData({
+                params: JSON.parse(options.params)
+            })
+            this.getList()
+        } else {
+            _Http.basic({
+                "classname": "webmanage.sale.salearea.salearea",
+                "method": "query_area",
+                "content": {},
+            }).then(res => {
+                if (res.code == 1) {
+                    this.setData({
+                        params: {
+                            "id": 20221011144603,
+                            "content": {
+                                "sa_saleareaid": res.data[0].sa_saleareaid,
+                                "isExport": 0,
+                                "pageNumber": 1,
+                                "pageSize": 20,
+                                pageTotal: 1,
+                                "where": {
+                                    "condition": ""
+                                }
+                            },
+                        }
+                    });
+                    this.getList()
+                }
+            })
+        }
         this.setData({
             radio: options.radio ? true : false,
             idname: options.idname || this.data.idname,