|
|
@@ -0,0 +1,246 @@
|
|
|
+const _Http = getApp().globalData.http;
|
|
|
+Page({
|
|
|
+ data: {
|
|
|
+ sys_phonebookid: null, //是否为快捷选择创建的账号
|
|
|
+ fromShowAll: false,
|
|
|
+ form: [{
|
|
|
+ label: "姓名",
|
|
|
+ error: false,
|
|
|
+ errMsg: "",
|
|
|
+ type: "text",
|
|
|
+ value: "",
|
|
|
+ placeholder: "联系人名称",
|
|
|
+ valueName: "name",
|
|
|
+ required: true,
|
|
|
+ checking: "base"
|
|
|
+ }, {
|
|
|
+ label: "手机号",
|
|
|
+ error: false,
|
|
|
+ errMsg: "",
|
|
|
+ type: "number",
|
|
|
+ value: "",
|
|
|
+ placeholder: "联系人手机号码",
|
|
|
+ valueName: "phonenumber",
|
|
|
+ required: true,
|
|
|
+ checking: "phone"
|
|
|
+ }, {
|
|
|
+ label: "部门",
|
|
|
+ error: false,
|
|
|
+ errMsg: "",
|
|
|
+ type: "text",
|
|
|
+ value: "",
|
|
|
+ placeholder: "联系人所属部门",
|
|
|
+ valueName: "depname",
|
|
|
+ required: false,
|
|
|
+ checking: "base"
|
|
|
+ }, {
|
|
|
+ label: "单位",
|
|
|
+ error: false,
|
|
|
+ errMsg: "",
|
|
|
+ type: "route",
|
|
|
+ url: "/packageA/project/modules/contacts/select/index",
|
|
|
+ value: "",
|
|
|
+ placeholder: "选择单位",
|
|
|
+ valueName: "sys_enterpriseid",
|
|
|
+ required: true,
|
|
|
+ checking: "base",
|
|
|
+ }, {
|
|
|
+ label: "职位",
|
|
|
+ error: false,
|
|
|
+ errMsg: "",
|
|
|
+ type: "text",
|
|
|
+ value: "",
|
|
|
+ placeholder: "联系人职位",
|
|
|
+ valueName: "position",
|
|
|
+ required: false,
|
|
|
+ checking: "base"
|
|
|
+ }, {
|
|
|
+ label: "性别",
|
|
|
+ error: false,
|
|
|
+ errMsg: "",
|
|
|
+ type: "sex",
|
|
|
+ value: "",
|
|
|
+ placeholder: "联系人性别",
|
|
|
+ valueName: "sex",
|
|
|
+ required: false,
|
|
|
+ checking: "base"
|
|
|
+ }, {
|
|
|
+ label: "生日",
|
|
|
+ error: false,
|
|
|
+ errMsg: "",
|
|
|
+ type: "date",
|
|
|
+ value: "",
|
|
|
+ placeholder: "联系人生日",
|
|
|
+ valueName: "birthday",
|
|
|
+ required: false
|
|
|
+ }, {
|
|
|
+ label: "邮箱",
|
|
|
+ error: false,
|
|
|
+ errMsg: "",
|
|
|
+ type: "textarea",
|
|
|
+ value: "",
|
|
|
+ placeholder: "请填写",
|
|
|
+ valueName: "email",
|
|
|
+ required: false,
|
|
|
+ checking: "mail"
|
|
|
+ }, {
|
|
|
+ label: "地区",
|
|
|
+ error: false,
|
|
|
+ errMsg: "",
|
|
|
+ type: "region",
|
|
|
+ value: [],
|
|
|
+ placeholder: "省,市,区",
|
|
|
+ valueName: "region",
|
|
|
+ required: false
|
|
|
+ }, {
|
|
|
+ label: "详细地址",
|
|
|
+ error: false,
|
|
|
+ errMsg: "",
|
|
|
+ type: "textarea",
|
|
|
+ value: "",
|
|
|
+ placeholder: "例: 科创园11栋1103室",
|
|
|
+ valueName: "address",
|
|
|
+ required: false,
|
|
|
+ checking: "base"
|
|
|
+ }, {
|
|
|
+ label: "备注",
|
|
|
+ error: false,
|
|
|
+ errMsg: "",
|
|
|
+ type: "textarea",
|
|
|
+ value: "",
|
|
|
+ placeholder: "请填写",
|
|
|
+ valueName: "remarks",
|
|
|
+ required: false,
|
|
|
+ checking: "base"
|
|
|
+ }],
|
|
|
+ disabled: true,
|
|
|
+ "content": {
|
|
|
+ "contactsid": 0, //地址id
|
|
|
+ "sa_projectid": 0, //绑定数据
|
|
|
+ "isleader": 0, //默认0
|
|
|
+ "workaddress": 0,
|
|
|
+ "isdefault": 0, //是否默认地址
|
|
|
+ "isprimary": 0 //是否为主地址
|
|
|
+ }
|
|
|
+ },
|
|
|
+ onLoad(options) {
|
|
|
+ this.setData({
|
|
|
+ "content.sa_projectid": options.sa_projectid
|
|
|
+ });
|
|
|
+ if (options.data) {
|
|
|
+ let item = JSON.parse(options.data),
|
|
|
+ disabled = false,
|
|
|
+ form = this.data.form.map(v => {
|
|
|
+ if (v.valueName == 'region') {
|
|
|
+ v.value = item.province ? [item.province, item.city, item.county] : []
|
|
|
+ } else if (v.valueName == 'sys_enterpriseid') {
|
|
|
+ if (item.sys_enterpriseid) {
|
|
|
+ v.value = [item.enterprisename, [item.sys_enterpriseid]]
|
|
|
+ } else {
|
|
|
+ v.value = "";
|
|
|
+ disabled = true;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ v.value = Object.hasOwn(item, v.valueName) ? item[v.valueName] : v.value;
|
|
|
+ }
|
|
|
+ return v
|
|
|
+ });
|
|
|
+ this.setData({
|
|
|
+ form,
|
|
|
+ disabled,
|
|
|
+ "content.contactsid": item.contactsid
|
|
|
+ });
|
|
|
+ if (item.sys_phonebookid) this.setData({
|
|
|
+ sys_phonebookid: item.sys_phonebookid
|
|
|
+ })
|
|
|
+ };
|
|
|
+ },
|
|
|
+ /* 提交数据 */
|
|
|
+ submit() {
|
|
|
+ let data = this.selectComponent("#Form").submit();
|
|
|
+ if (!data || this.data.disabled) return;
|
|
|
+ data.sys_enterpriseid = data.sys_enterpriseid[1][0]
|
|
|
+ const content = {
|
|
|
+ ...this.data.content,
|
|
|
+ ...data,
|
|
|
+ "province": data.region[0] || "",
|
|
|
+ "city": data.region[1] || "",
|
|
|
+ "county": data.region[2] || "",
|
|
|
+ sys_phonebookid: ""
|
|
|
+ };
|
|
|
+ delete(content.region);
|
|
|
+ if (this.data.sys_phonebookid == null) {
|
|
|
+ this.handleSubmit(content);
|
|
|
+ } else {
|
|
|
+ let that = this;
|
|
|
+ wx.showModal({
|
|
|
+ title: '提示',
|
|
|
+ content: '是否删除原通讯录联系人信息',
|
|
|
+ complete({
|
|
|
+ confirm
|
|
|
+ }) {
|
|
|
+ content.sys_phonebookid = confirm ? that.data.sys_phonebookid : "";
|
|
|
+ that.handleSubmit(content);
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
+ handleSubmit(content) {
|
|
|
+ _Http.basic({
|
|
|
+ "id": "20221018141802",
|
|
|
+ content
|
|
|
+ }).then(res => {
|
|
|
+ console.log("编辑联系人", res)
|
|
|
+ if (res.msg != '成功') return wx.showToast({
|
|
|
+ title: res.data,
|
|
|
+ icon: "none"
|
|
|
+ });
|
|
|
+ let that = this;
|
|
|
+ let page = getCurrentPages()[getCurrentPages().length - 2];
|
|
|
+ _Http.basic({
|
|
|
+ "id": 20221111131104,
|
|
|
+ "content": {
|
|
|
+ "sa_project_contactsid": 0,
|
|
|
+ contactsids: [res.data.contactsid],
|
|
|
+ "sa_projectid": page.data.sa_projectid,
|
|
|
+ "remarks": ""
|
|
|
+ }
|
|
|
+ }).then(res => {
|
|
|
+ console.log("项目添加联系人", res)
|
|
|
+ if (res.msg != '成功') return wx.showToast({
|
|
|
+ title: res.data,
|
|
|
+ icon: "none"
|
|
|
+ });
|
|
|
+ wx.showToast({
|
|
|
+ title: '添加成功',
|
|
|
+ icon: "none"
|
|
|
+ });
|
|
|
+ setTimeout(() => {
|
|
|
+ wx.navigateBack();
|
|
|
+ let model = page.selectComponent("#Contacts")
|
|
|
+ model.getList(model.data.sa_projectid, true)
|
|
|
+ }, 300)
|
|
|
+ })
|
|
|
+ wx.showToast({
|
|
|
+ title: '保存成功',
|
|
|
+ icon: "none"
|
|
|
+ });
|
|
|
+ });
|
|
|
+ },
|
|
|
+ /* 表单是否填写完成 */
|
|
|
+ onConfirm({
|
|
|
+ detail
|
|
|
+ }) {
|
|
|
+ this.setData({
|
|
|
+ disabled: detail
|
|
|
+ })
|
|
|
+ },
|
|
|
+ /* 是否显示全部 */
|
|
|
+ changefromShowAll({
|
|
|
+ detail
|
|
|
+ }) {
|
|
|
+ this.setData({
|
|
|
+ fromShowAll: detail
|
|
|
+ })
|
|
|
+ },
|
|
|
+})
|