|
|
@@ -7,7 +7,8 @@ Page({
|
|
|
result: [], //返回结果
|
|
|
radio: false, //是否为单选
|
|
|
idname: "contactsid", //idkey
|
|
|
- showName: "name"
|
|
|
+ showName: "name",
|
|
|
+ selected: 0,
|
|
|
},
|
|
|
onLoad(options) {
|
|
|
if (options.item) {
|
|
|
@@ -17,15 +18,19 @@ Page({
|
|
|
params: item.params
|
|
|
});
|
|
|
}
|
|
|
- if (options.params) this.setData({
|
|
|
- params: JSON.parse(options.params)
|
|
|
- });
|
|
|
+ if (options.params) {
|
|
|
+ let params = JSON.parse(options.params);
|
|
|
+ this.setData({
|
|
|
+ params,
|
|
|
+ sys_enterpriseid: params.content.sys_enterpriseid
|
|
|
+ });
|
|
|
+ }
|
|
|
this.setData({
|
|
|
radio: options.radio ? true : false,
|
|
|
idname: options.idname || this.data.idname,
|
|
|
showName: options.showName || this.data.showName,
|
|
|
});
|
|
|
- getApp().globalData.Language.getLanguagePackage(this, 'E-订单');
|
|
|
+ getApp().globalData.Language.getLanguagePackage(this, 'E-订单');
|
|
|
this.getList()
|
|
|
},
|
|
|
getList(init = false) {
|
|
|
@@ -42,16 +47,41 @@ Page({
|
|
|
title: res.msg,
|
|
|
icon: "none"
|
|
|
})
|
|
|
+ let list = res.pageNumber == 1 ? res.data : this.data.list.concat(res.data),
|
|
|
+ selected = list.find(v => v.isdefault).contactsid || 0
|
|
|
|
|
|
this.setData({
|
|
|
'params.content.pageNumber': res.pageNumber + 1,
|
|
|
'params.content.pageTotal': res.pageTotal,
|
|
|
'params.content.total': res.total,
|
|
|
- list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data),
|
|
|
+ selected: selected,
|
|
|
+ list,
|
|
|
loading: false
|
|
|
})
|
|
|
})
|
|
|
},
|
|
|
+ // 修改默认
|
|
|
+ radioChange({
|
|
|
+ detail
|
|
|
+ }) {
|
|
|
+ let list = this.data.list,
|
|
|
+ data = list.find(v => v.contactsid == detail)
|
|
|
+ if (data.isdefault == 1) return;
|
|
|
+ data.isdefault = 1;
|
|
|
+ _Http.basic({
|
|
|
+ "id": "20221009155703",
|
|
|
+ "content": data
|
|
|
+ }, false).then(res => {
|
|
|
+ console.log(res)
|
|
|
+ if (res.code != '1') return wx.showToast({
|
|
|
+ title: res.data,
|
|
|
+ icon: "none"
|
|
|
+ });
|
|
|
+ this.setData({
|
|
|
+ list
|
|
|
+ })
|
|
|
+ })
|
|
|
+ }, //处理操作
|
|
|
/* 选中 */
|
|
|
changeResult(e) {
|
|
|
let {
|
|
|
@@ -84,6 +114,47 @@ Page({
|
|
|
}
|
|
|
getApp().globalData.handleSelect && getApp().globalData.handleSelect(obj)
|
|
|
},
|
|
|
+ handleItem(e) {
|
|
|
+ const {
|
|
|
+ name,
|
|
|
+ item
|
|
|
+ } = e.target.dataset;
|
|
|
+ if (name == 'edit') {
|
|
|
+ wx.navigateTo({
|
|
|
+ url: '/select/address/addAndEdit?sys_enterpriseid=' + this.data.sys_enterpriseid + "&data=" + JSON.stringify(item),
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ wx.showModal({
|
|
|
+ cancelText: getApp().globalData.Language.getMapText('取消'),
|
|
|
+ confirmText: getApp().globalData.Language.getMapText('确定'),
|
|
|
+ title: getApp().globalData.Language.getMapText('提示'),
|
|
|
+ content: getApp().globalData.Language.getMapText('是否确定删除') + `“${item.name}”`,
|
|
|
+ complete: (res) => {
|
|
|
+ if (res.confirm) _Http.basic({
|
|
|
+ "id": "20221009155903",
|
|
|
+ "content": {
|
|
|
+ "contactsids": [item.contactsid]
|
|
|
+ },
|
|
|
+ }).then(res => {
|
|
|
+ console.log("删除明细", res)
|
|
|
+ wx.showToast({
|
|
|
+ title: res.code == '1' ? getApp().globalData.Language.getMapText('删除成功') : res.msg,
|
|
|
+ icon: "none"
|
|
|
+ });
|
|
|
+ this.setData({
|
|
|
+ "params.content.total": this.data.params.content.total - 1,
|
|
|
+ list: this.data.list.filter(v => v.contactsid != item.contactsid)
|
|
|
+ })
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
+ add() {
|
|
|
+ wx.navigateTo({
|
|
|
+ url: '/select/address/addAndEdit?sys_enterpriseid=' + this.data.sys_enterpriseid,
|
|
|
+ })
|
|
|
+ },
|
|
|
/* 开始搜索 */
|
|
|
startSearch({
|
|
|
detail
|
|
|
@@ -96,6 +167,24 @@ Page({
|
|
|
});
|
|
|
this.getList(true);
|
|
|
},
|
|
|
+ onShow() {
|
|
|
+ let params = JSON.parse(JSON.stringify(this.data.params));
|
|
|
+ params.content.pageSize = params.content.pageSize * (params.content.pageNumber - 1);
|
|
|
+ params.content.pageNumber = 1;
|
|
|
+
|
|
|
+ _Http.basic(params).then(res => {
|
|
|
+ this.selectComponent('#ListBox').RefreshToComplete();
|
|
|
+ if (res.code != '1') return;
|
|
|
+ let list = res.data,
|
|
|
+ selected = list.find(v => v.isdefault).contactsid || 0
|
|
|
+ this.setData({
|
|
|
+ 'params.content.total': res.total,
|
|
|
+ selected: selected,
|
|
|
+ list
|
|
|
+ })
|
|
|
+ })
|
|
|
+
|
|
|
+ },
|
|
|
/* 取消搜索 */
|
|
|
onClear() {
|
|
|
this.setData({
|
|
|
@@ -110,6 +199,6 @@ Page({
|
|
|
onUnload() {
|
|
|
//回收数据
|
|
|
getApp().globalData.handleSelect = null;
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
})
|